diff mbox series

[v2] net: dsa: lan9303: handle hwaccel VLAN tags

Message ID 20220216124634.23123-1-mans@mansr.com (mailing list archive)
State Accepted
Commit 017b355bbdc6620fd8fe05fe297f553ce9d855ee
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: dsa: lan9303: handle hwaccel VLAN tags | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 41 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Måns Rullgård Feb. 16, 2022, 12:46 p.m. UTC
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.

Signed-off-by: Mans Rullgard <mans@mansr.com>
---
Changes:
- call skb_push/pull only where actually needed
---
 net/dsa/tag_lan9303.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

Comments

Vladimir Oltean Feb. 16, 2022, 1:47 p.m. UTC | #1
On Wed, Feb 16, 2022 at 12:46:34PM +0000, Mans Rullgard wrote:
> 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.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
> Changes:
> - call skb_push/pull only where actually needed
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
patchwork-bot+netdevbpf@kernel.org Feb. 17, 2022, 6:10 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 16 Feb 2022 12:46:34 +0000 you wrote:
> 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.
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
> Changes:
> - call skb_push/pull only where actually needed
> 
> [...]

Here is the summary with links:
  - [v2] net: dsa: lan9303: handle hwaccel VLAN tags
    https://git.kernel.org/netdev/net/c/017b355bbdc6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c
index cb548188f813..98d7d7120bab 100644
--- a/net/dsa/tag_lan9303.c
+++ b/net/dsa/tag_lan9303.c
@@ -77,7 +77,6 @@  static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device *dev)
 
 static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev)
 {
-	__be16 *lan9303_tag;
 	u16 lan9303_tag1;
 	unsigned int source_port;
 
@@ -87,14 +86,15 @@  static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev)
 		return NULL;
 	}
 
-	lan9303_tag = dsa_etype_header_pos_rx(skb);
-
-	if (lan9303_tag[0] != htons(ETH_P_8021Q)) {
-		dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid VLAN marker\n");
-		return NULL;
+	if (skb_vlan_tag_present(skb)) {
+		lan9303_tag1 = skb_vlan_tag_get(skb);
+		__vlan_hwaccel_clear_tag(skb);
+	} else {
+		skb_push_rcsum(skb, ETH_HLEN);
+		__skb_vlan_pop(skb, &lan9303_tag1);
+		skb_pull_rcsum(skb, ETH_HLEN);
 	}
 
-	lan9303_tag1 = ntohs(lan9303_tag[1]);
 	source_port = lan9303_tag1 & 0x3;
 
 	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)
 		return NULL;
 	}
 
-	/* remove the special VLAN tag between the MAC addresses
-	 * and the current ethertype field.
-	 */
-	skb_pull_rcsum(skb, 2 + 2);
-
-	dsa_strip_etype_header(skb, LAN9303_TAG_LEN);
-
 	if (!(lan9303_tag1 & LAN9303_TAG_RX_TRAPPED_TO_CPU))
 		dsa_default_offload_fwd_mark(skb);