Skip to content

Commit 1a48fbd

Browse files
hjelmelanddavem330
authored andcommitted
net: dsa: lan9303: calculate offload_fwd_mark from tag
The lan9303 set bits in the host CPU tag indicating if a ingress frame is a trapped IGMP or STP frame. Use these bits to calculate skb->offload_fwd_mark more efficiently. Signed-off-by: Egil Hjelmeland <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 887c382 commit 1a48fbd

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

net/dsa/tag_lan9303.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#define LAN9303_TAG_LEN 4
4343
# define LAN9303_TAG_TX_USE_ALR BIT(3)
4444
# define LAN9303_TAG_TX_STP_OVERRIDE BIT(4)
45+
# define LAN9303_TAG_RX_IGMP BIT(3)
46+
# define LAN9303_TAG_RX_STP BIT(4)
47+
# define LAN9303_TAG_RX_TRAPPED_TO_CPU (LAN9303_TAG_RX_IGMP | \
48+
LAN9303_TAG_RX_STP)
4549

4650
/* Decide whether to transmit using ALR lookup, or transmit directly to
4751
* port using tag. ALR learning is performed only when using ALR lookup.
@@ -91,9 +95,8 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
9195
struct packet_type *pt)
9296
{
9397
u16 *lan9303_tag;
98+
u16 lan9303_tag1;
9499
unsigned int source_port;
95-
u16 ether_type_nw;
96-
u8 ip_protocol;
97100

98101
if (unlikely(!pskb_may_pull(skb, LAN9303_TAG_LEN))) {
99102
dev_warn_ratelimited(&dev->dev,
@@ -114,7 +117,8 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
114117
return NULL;
115118
}
116119

117-
source_port = ntohs(lan9303_tag[1]) & 0x3;
120+
lan9303_tag1 = ntohs(lan9303_tag[1]);
121+
source_port = lan9303_tag1 & 0x3;
118122

119123
skb->dev = dsa_master_find_slave(dev, 0, source_port);
120124
if (!skb->dev) {
@@ -128,19 +132,7 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
128132
skb_pull_rcsum(skb, 2 + 2);
129133
memmove(skb->data - ETH_HLEN, skb->data - (ETH_HLEN + LAN9303_TAG_LEN),
130134
2 * ETH_ALEN);
131-
skb->offload_fwd_mark = !ether_addr_equal(skb->data - ETH_HLEN,
132-
eth_stp_addr);
133-
134-
/* We also need IGMP packets to have skb->offload_fwd_mark = 0.
135-
* Solving this for all conceivable situations would add more cost to
136-
* every packet. Instead we handle just the common case:
137-
* No VLAN tag + Ethernet II framing.
138-
* Test least probable term first.
139-
*/
140-
ether_type_nw = lan9303_tag[2];
141-
ip_protocol = *(skb->data + 9);
142-
if (ip_protocol == IPPROTO_IGMP && ether_type_nw == htons(ETH_P_IP))
143-
skb->offload_fwd_mark = 0;
135+
skb->offload_fwd_mark = !(lan9303_tag1 & LAN9303_TAG_RX_TRAPPED_TO_CPU);
144136

145137
return skb;
146138
}

0 commit comments

Comments
 (0)