#define LAN9303_TAG_LEN 4
# define LAN9303_TAG_TX_USE_ALR BIT(3)
# define LAN9303_TAG_TX_STP_OVERRIDE BIT(4)
+# define LAN9303_TAG_RX_IGMP BIT(3)
+# define LAN9303_TAG_RX_STP BIT(4)
+# define LAN9303_TAG_RX_TRAPPED_TO_CPU (LAN9303_TAG_RX_IGMP | \
+ LAN9303_TAG_RX_STP)
/* Decide whether to transmit using ALR lookup, or transmit directly to
* port using tag. ALR learning is performed only when using ALR lookup.
struct packet_type *pt)
{
u16 *lan9303_tag;
+ u16 lan9303_tag1;
unsigned int source_port;
- u16 ether_type_nw;
- u8 ip_protocol;
if (unlikely(!pskb_may_pull(skb, LAN9303_TAG_LEN))) {
dev_warn_ratelimited(&dev->dev,
return NULL;
}
- source_port = ntohs(lan9303_tag[1]) & 0x3;
+ lan9303_tag1 = ntohs(lan9303_tag[1]);
+ source_port = lan9303_tag1 & 0x3;
skb->dev = dsa_master_find_slave(dev, 0, source_port);
if (!skb->dev) {
skb_pull_rcsum(skb, 2 + 2);
memmove(skb->data - ETH_HLEN, skb->data - (ETH_HLEN + LAN9303_TAG_LEN),
2 * ETH_ALEN);
- skb->offload_fwd_mark = !ether_addr_equal(skb->data - ETH_HLEN,
- eth_stp_addr);
-
- /* We also need IGMP packets to have skb->offload_fwd_mark = 0.
- * Solving this for all conceivable situations would add more cost to
- * every packet. Instead we handle just the common case:
- * No VLAN tag + Ethernet II framing.
- * Test least probable term first.
- */
- ether_type_nw = lan9303_tag[2];
- ip_protocol = *(skb->data + 9);
- if (ip_protocol == IPPROTO_IGMP && ether_type_nw == htons(ETH_P_IP))
- skb->offload_fwd_mark = 0;
+ skb->offload_fwd_mark = !(lan9303_tag1 & LAN9303_TAG_RX_TRAPPED_TO_CPU);
return skb;
}