diff mbox series

[RFC,net,2/2] net: dsa: felix: fix reception from VLAN-unaware ports

Message ID 20241215163334.615427-3-robert.hodaszi@digi.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: felix: fix VLAN-unaware reception | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
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/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Robert Hodaszi Dec. 15, 2024, 4:33 p.m. UTC
In ocelot-8021q mode, the driver always enables
'untag_vlan_aware_bridge_pvid' to do software VLAN untagging, no matter
if tagging is enabled on the port (VLAN-aware) or not (VLAN-unaware).
That corrupts packets on VLAN-unaware ports.

Exclude the port from VLAN untagging by setting the 'not_tagged' port
flag on VLAN-unaware ports.

Fixes: f1288fd7293b ("net: dsa: felix: fix VLAN tag loss on CPU reception with ocelot-8021q")
Signed-off-by: Robert Hodaszi <robert.hodaszi@digi.com>
---
 drivers/net/dsa/ocelot/felix.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 3aa9c997018a..8a2650a428ec 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -273,6 +273,7 @@  static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid,
 	struct dsa_port *dp = dsa_to_port(ds, port);
 	struct dsa_port *cpu_dp;
 	int err;
+	bool tagging_enabled;
 
 	/* tag_8021q.c assumes we are implementing this via port VLAN
 	 * membership, which we aren't. So we don't need to add any VCAP filter
@@ -281,9 +282,11 @@  static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid,
 	if (!dsa_port_is_user(dp))
 		return 0;
 
+	tagging_enabled = dsa_port_is_vlan_filtering(dp);
+
 	dsa_switch_for_each_cpu_port(cpu_dp, ds) {
 		err = felix_tag_8021q_vlan_add_rx(ds, port, cpu_dp->index, vid,
-						  dsa_port_is_vlan_filtering(dp));
+						  tagging_enabled);
 		if (err)
 			return err;
 	}
@@ -292,6 +295,8 @@  static int felix_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid,
 	if (err)
 		goto add_tx_failed;
 
+	dp->not_tagged = !tagging_enabled;
+
 	return 0;
 
 add_tx_failed:
@@ -320,6 +325,8 @@  static int felix_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid)
 	if (err)
 		goto del_tx_failed;
 
+	dp->not_tagged = 0;
+
 	return 0;
 
 del_tx_failed: