Skip to content

Commit 017b355

Browse files
mansrkuba-moo
authored andcommitted
net: dsa: lan9303: handle hwaccel VLAN tags
Check for a hwaccel VLAN tag on rx and use it if present. Otherwise, use __skb_vlan_pop() like the other tag parsers do. This fixes the case where the VLAN tag has already been consumed by the master. Fixes: a129259 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303") Signed-off-by: Mans Rullgard <mans@mansr.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Link: https://lore.kernel.org/r/20220216124634.23123-1-mans@mansr.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b920849 commit 017b355

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

net/dsa/tag_lan9303.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device *dev)
7777

7878
static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev)
7979
{
80-
__be16 *lan9303_tag;
8180
u16 lan9303_tag1;
8281
unsigned int source_port;
8382

@@ -87,14 +86,15 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev)
8786
return NULL;
8887
}
8988

90-
lan9303_tag = dsa_etype_header_pos_rx(skb);
91-
92-
if (lan9303_tag[0] != htons(ETH_P_8021Q)) {
93-
dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid VLAN marker\n");
94-
return NULL;
89+
if (skb_vlan_tag_present(skb)) {
90+
lan9303_tag1 = skb_vlan_tag_get(skb);
91+
__vlan_hwaccel_clear_tag(skb);
92+
} else {
93+
skb_push_rcsum(skb, ETH_HLEN);
94+
__skb_vlan_pop(skb, &lan9303_tag1);
95+
skb_pull_rcsum(skb, ETH_HLEN);
9596
}
9697

97-
lan9303_tag1 = ntohs(lan9303_tag[1]);
9898
source_port = lan9303_tag1 & 0x3;
9999

100100
skb->dev = dsa_master_find_slave(dev, 0, source_port);
@@ -103,13 +103,6 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev)
103103
return NULL;
104104
}
105105

106-
/* remove the special VLAN tag between the MAC addresses
107-
* and the current ethertype field.
108-
*/
109-
skb_pull_rcsum(skb, 2 + 2);
110-
111-
dsa_strip_etype_header(skb, LAN9303_TAG_LEN);
112-
113106
if (!(lan9303_tag1 & LAN9303_TAG_RX_TRAPPED_TO_CPU))
114107
dsa_default_offload_fwd_mark(skb);
115108

0 commit comments

Comments
 (0)