netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling
@ 2025-10-15 22:31 Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 01/11] net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port Daniel Golle
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:31 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

Hi all,

This series was developed by Vladimir Oltean to improve and clean up the
VLAN handling logic in the Lantiq GSWIP DSA driver.

As Vladimir currently doesn't have the availability to take care of the
submission process, we agreed that I would send the patches on his
behalf.

The series focuses on consolidating the VLAN management paths for both
VLAN-unaware and VLAN-aware bridges, simplifying internal logic, and
removing legacy or redundant code. It also fixes a number of subtle
inconsistencies regarding VLAN ID 0 handling, bridge FDB entries, and
brings the driver into shape to permit dynamic changes to the VLAN
filtering state.

Notable changes include:

 - Support for bridge FDB entries on the CPU port

 - Consolidation of gswip_vlan_add_unaware() and gswip_vlan_add_aware()
   into a unified implementation

 - Removal of legacy VLAN configuration options and redundant
   assignments

 - Improved handling of VLAN ID 0 and PVID behavior

 - Better validation and error reporting in VLAN removal paths

 - Support for dynamic VLAN filtering configuration changes

Overall, this refactor improves readability and maintainability of the
Lantiq GSWIP DSA driver. It also results in all local-termination.sh
tests now passing, and slightly improves the results of
bridge-vlan-{un,}aware.sh.

All patches have been authored by Vladimir Oltean; a small unintended
functional change in patch "net: dsa: lantiq_gswip: merge
gswip_vlan_add_unaware() and gswip_vlan_add_aware()" has been ironed out
and some of the commit descriptions were improved by me, apart from that
I'm only handling the submission and will help with follow-up
discussions or review feedback as needed.

Despite the fact that some changes here do actually fix things (in the
sense that selftests which would previously FAIL now PASS) we decided
that it would be the best for this series of patches to go via net-next.
If requested some of it can still be ported to stable kernels later on.

Vladimir Oltean (11):
  net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port
  net: dsa: lantiq_gswip: define VLAN ID 0 constant
  net: dsa: lantiq_gswip: remove duplicate assignment to
    vlan_mapping.val[0]
  net: dsa: lantiq_gswip: merge gswip_vlan_add_unaware() and
    gswip_vlan_add_aware()
  net: dsa: lantiq_gswip: remove legacy
    configure_vlan_while_not_filtering option
  net: dsa: lantiq_gswip: permit dynamic changes to VLAN filtering state
  net: dsa: lantiq_gswip: disallow changes to privately set up VID 0
  net: dsa: lantiq_gswip: remove vlan_aware and pvid arguments from
    gswip_vlan_remove()
  net: dsa: lantiq_gswip: put a more descriptive error print in
    gswip_vlan_remove()
  net: dsa: lantiq_gswip: drop untagged on VLAN-aware bridge ports with
    no PVID
  net: dsa: lantiq_gswip: treat VID 0 like the PVID

 drivers/net/dsa/lantiq/lantiq_gswip.c | 224 ++++++++++++--------------
 drivers/net/dsa/lantiq/lantiq_gswip.h |   7 +-
 2 files changed, 107 insertions(+), 124 deletions(-)

-- 
2.51.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH net-next 01/11] net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
@ 2025-10-15 22:32 ` Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 02/11] net: dsa: lantiq_gswip: define VLAN ID 0 constant Daniel Golle
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:32 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

Currently, the driver takes the bridge from dsa_port_bridge_dev_get(),
which only works for user ports. This is why it has to ignore FDB
entries installed on the CPU port.

Commit c26933639b54 ("net: dsa: request drivers to perform FDB
isolation") introduced the possibility of getting the originating bridge
from the passed dsa_db argument, so let's do that instead. This way, we
can act on the local FDB entries coming from the bridge.

Note that we do not expect FDB events for the DSA_DB_PORT database,
because this driver doesn't fulfill the dsa_switch_supports_uc_filtering()
requirements. So we can just return -EOPNOTSUPP and expect it will never
be triggered.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 2169c0814a48..91755a5972fa 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -1140,9 +1140,9 @@ static void gswip_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
 }
 
 static int gswip_port_fdb(struct dsa_switch *ds, int port,
-			  const unsigned char *addr, u16 vid, bool add)
+			  struct net_device *bridge, const unsigned char *addr,
+			  u16 vid, bool add)
 {
-	struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
 	struct gswip_priv *priv = ds->priv;
 	struct gswip_pce_table_entry mac_bridge = {0,};
 	unsigned int max_ports = priv->hw_info->max_ports;
@@ -1150,10 +1150,6 @@ static int gswip_port_fdb(struct dsa_switch *ds, int port,
 	int i;
 	int err;
 
-	/* Operation not supported on the CPU port, don't throw errors */
-	if (!bridge)
-		return 0;
-
 	for (i = max_ports; i < ARRAY_SIZE(priv->vlans); i++) {
 		if (priv->vlans[i].bridge == bridge) {
 			fid = priv->vlans[i].fid;
@@ -1188,14 +1184,20 @@ static int gswip_port_fdb_add(struct dsa_switch *ds, int port,
 			      const unsigned char *addr, u16 vid,
 			      struct dsa_db db)
 {
-	return gswip_port_fdb(ds, port, addr, vid, true);
+	if (db.type != DSA_DB_BRIDGE)
+		return -EOPNOTSUPP;
+
+	return gswip_port_fdb(ds, port, db.bridge.dev, addr, vid, true);
 }
 
 static int gswip_port_fdb_del(struct dsa_switch *ds, int port,
 			      const unsigned char *addr, u16 vid,
 			      struct dsa_db db)
 {
-	return gswip_port_fdb(ds, port, addr, vid, false);
+	if (db.type != DSA_DB_BRIDGE)
+		return -EOPNOTSUPP;
+
+	return gswip_port_fdb(ds, port, db.bridge.dev, addr, vid, false);
 }
 
 static int gswip_port_fdb_dump(struct dsa_switch *ds, int port,
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 02/11] net: dsa: lantiq_gswip: define VLAN ID 0 constant
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 01/11] net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port Daniel Golle
@ 2025-10-15 22:32 ` Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 03/11] net: dsa: lantiq_gswip: remove duplicate assignment to vlan_mapping.val[0] Daniel Golle
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:32 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

This patch adds an explicit definition for VID 0 to the Lantiq GSWIP DSA
driver, clarifying its special meaning.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 12 +++++++-----
 drivers/net/dsa/lantiq/lantiq_gswip.h |  2 ++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 91755a5972fa..9526317443a1 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -432,7 +432,7 @@ static int gswip_add_single_port_br(struct gswip_priv *priv, int port, bool add)
 
 	vlan_active.index = port + 1;
 	vlan_active.table = GSWIP_TABLE_ACTIVE_VLAN;
-	vlan_active.key[0] = 0; /* vid */
+	vlan_active.key[0] = GSWIP_VLAN_UNAWARE_PVID;
 	vlan_active.val[0] = port + 1 /* fid */;
 	vlan_active.valid = add;
 	err = gswip_pce_table_entry_write(priv, &vlan_active);
@@ -446,7 +446,7 @@ static int gswip_add_single_port_br(struct gswip_priv *priv, int port, bool add)
 
 	vlan_mapping.index = port + 1;
 	vlan_mapping.table = GSWIP_TABLE_VLAN_MAPPING;
-	vlan_mapping.val[0] = 0 /* vid */;
+	vlan_mapping.val[0] = GSWIP_VLAN_UNAWARE_PVID;
 	vlan_mapping.val[1] = BIT(port) | dsa_cpu_ports(priv->ds);
 	vlan_mapping.val[2] = 0;
 	err = gswip_pce_table_entry_write(priv, &vlan_mapping);
@@ -772,7 +772,8 @@ static int gswip_vlan_add_unaware(struct gswip_priv *priv,
 	 * entry in a free slot and prepare the VLAN mapping table entry.
 	 */
 	if (idx == -1) {
-		idx = gswip_vlan_active_create(priv, bridge, -1, 0);
+		idx = gswip_vlan_active_create(priv, bridge, -1,
+					       GSWIP_VLAN_UNAWARE_PVID);
 		if (idx < 0)
 			return idx;
 		active_vlan_created = true;
@@ -780,7 +781,7 @@ static int gswip_vlan_add_unaware(struct gswip_priv *priv,
 		vlan_mapping.index = idx;
 		vlan_mapping.table = GSWIP_TABLE_VLAN_MAPPING;
 		/* VLAN ID byte, maps to the VLAN ID of vlan active table */
-		vlan_mapping.val[0] = 0;
+		vlan_mapping.val[0] = GSWIP_VLAN_UNAWARE_PVID;
 	} else {
 		/* Read the existing VLAN mapping entry from the switch */
 		vlan_mapping.index = idx;
@@ -977,7 +978,8 @@ static void gswip_port_bridge_leave(struct dsa_switch *ds, int port,
 	 * specific bridges. No bridge is configured here.
 	 */
 	if (!br_vlan_enabled(br))
-		gswip_vlan_remove(priv, br, port, 0, true, false);
+		gswip_vlan_remove(priv, br, port, GSWIP_VLAN_UNAWARE_PVID, true,
+				  false);
 }
 
 static int gswip_port_vlan_prepare(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.h b/drivers/net/dsa/lantiq/lantiq_gswip.h
index 2df9c8e8cfd0..6aae1ff2f130 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.h
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.h
@@ -222,6 +222,8 @@
  */
 #define GSWIP_MAX_PACKET_LENGTH	2400
 
+#define GSWIP_VLAN_UNAWARE_PVID	0
+
 struct gswip_pce_microcode {
 	u16 val_3;
 	u16 val_2;
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 03/11] net: dsa: lantiq_gswip: remove duplicate assignment to vlan_mapping.val[0]
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 01/11] net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 02/11] net: dsa: lantiq_gswip: define VLAN ID 0 constant Daniel Golle
@ 2025-10-15 22:32 ` Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 04/11] net: dsa: lantiq_gswip: merge gswip_vlan_add_unaware() and gswip_vlan_add_aware() Daniel Golle
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:32 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

When idx == -1 in gswip_vlan_add(), we set vlan_mapping.val[0] = vid,
even though we do the exact same thing again outside the if/else block.

Remove the duplicate assignment.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 9526317443a1..e41d67ea89c5 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -848,8 +848,6 @@ static int gswip_vlan_add_aware(struct gswip_priv *priv,
 
 		vlan_mapping.index = idx;
 		vlan_mapping.table = GSWIP_TABLE_VLAN_MAPPING;
-		/* VLAN ID byte, maps to the VLAN ID of vlan active table */
-		vlan_mapping.val[0] = vid;
 	} else {
 		/* Read the existing VLAN mapping entry from the switch */
 		vlan_mapping.index = idx;
@@ -862,6 +860,7 @@ static int gswip_vlan_add_aware(struct gswip_priv *priv,
 		}
 	}
 
+	/* VLAN ID byte, maps to the VLAN ID of vlan active table */
 	vlan_mapping.val[0] = vid;
 	/* Update the VLAN mapping entry and write it to the switch */
 	vlan_mapping.val[1] |= cpu_ports;
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 04/11] net: dsa: lantiq_gswip: merge gswip_vlan_add_unaware() and gswip_vlan_add_aware()
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (2 preceding siblings ...)
  2025-10-15 22:32 ` [PATCH net-next 03/11] net: dsa: lantiq_gswip: remove duplicate assignment to vlan_mapping.val[0] Daniel Golle
@ 2025-10-15 22:32 ` Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 05/11] net: dsa: lantiq_gswip: remove legacy configure_vlan_while_not_filtering option Daniel Golle
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:32 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

The two functions largely duplicate functionality. The differences
consist in:

- the "fid" passed to gswip_vlan_active_create(). The unaware variant
  always passes -1, the aware variant passes fid = priv->vlans[i].fid,
  where i is an index into priv->vlans[] for which priv->vlans[i].bridge
  is equal to the given bridge.

- the "vid" is not passed to gswip_vlan_add_unaware(). It is implicitly
  GSWIP_VLAN_UNAWARE_PVID (zero).

- The "untagged" is not passed to gswip_vlan_add_unaware(). It is
  implicitly true. Also, the CPU port must not be a tag member of the
  PVID used for VLAN-unaware bridging.

- The "pvid" is not passed to gswip_vlan_add_unaware(). It is implicitly
  true.

- The GSWIP_PCE_DEFPVID(port) register is written by the aware variant
  with an "idx", but with a hardcoded 0 by the unaware variant.

Merge the two functions into a single unified function without any
functional changes.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 94 +++++----------------------
 1 file changed, 17 insertions(+), 77 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index e41d67ea89c5..6cbcb54a5ed0 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -750,86 +750,25 @@ static int gswip_vlan_active_remove(struct gswip_priv *priv, int idx)
 	return err;
 }
 
-static int gswip_vlan_add_unaware(struct gswip_priv *priv,
-				  struct net_device *bridge, int port)
-{
-	struct gswip_pce_table_entry vlan_mapping = {0,};
-	unsigned int max_ports = priv->hw_info->max_ports;
-	bool active_vlan_created = false;
-	int idx = -1;
-	int i;
-	int err;
-
-	/* Check if there is already a page for this bridge */
-	for (i = max_ports; i < ARRAY_SIZE(priv->vlans); i++) {
-		if (priv->vlans[i].bridge == bridge) {
-			idx = i;
-			break;
-		}
-	}
-
-	/* If this bridge is not programmed yet, add a Active VLAN table
-	 * entry in a free slot and prepare the VLAN mapping table entry.
-	 */
-	if (idx == -1) {
-		idx = gswip_vlan_active_create(priv, bridge, -1,
-					       GSWIP_VLAN_UNAWARE_PVID);
-		if (idx < 0)
-			return idx;
-		active_vlan_created = true;
-
-		vlan_mapping.index = idx;
-		vlan_mapping.table = GSWIP_TABLE_VLAN_MAPPING;
-		/* VLAN ID byte, maps to the VLAN ID of vlan active table */
-		vlan_mapping.val[0] = GSWIP_VLAN_UNAWARE_PVID;
-	} else {
-		/* Read the existing VLAN mapping entry from the switch */
-		vlan_mapping.index = idx;
-		vlan_mapping.table = GSWIP_TABLE_VLAN_MAPPING;
-		err = gswip_pce_table_entry_read(priv, &vlan_mapping);
-		if (err) {
-			dev_err(priv->dev, "failed to read VLAN mapping: %d\n",
-				err);
-			return err;
-		}
-	}
-
-	/* Update the VLAN mapping entry and write it to the switch */
-	vlan_mapping.val[1] |= dsa_cpu_ports(priv->ds);
-	vlan_mapping.val[1] |= BIT(port);
-	err = gswip_pce_table_entry_write(priv, &vlan_mapping);
-	if (err) {
-		dev_err(priv->dev, "failed to write VLAN mapping: %d\n", err);
-		/* In case an Active VLAN was creaetd delete it again */
-		if (active_vlan_created)
-			gswip_vlan_active_remove(priv, idx);
-		return err;
-	}
-
-	gswip_switch_w(priv, 0, GSWIP_PCE_DEFPVID(port));
-	return 0;
-}
-
-static int gswip_vlan_add_aware(struct gswip_priv *priv,
-				struct net_device *bridge, int port,
-				u16 vid, bool untagged,
-				bool pvid)
+static int gswip_vlan_add(struct gswip_priv *priv, struct net_device *bridge,
+			  int port, u16 vid, bool untagged, bool pvid,
+			  bool vlan_aware)
 {
 	struct gswip_pce_table_entry vlan_mapping = {0,};
 	unsigned int max_ports = priv->hw_info->max_ports;
 	unsigned int cpu_ports = dsa_cpu_ports(priv->ds);
 	bool active_vlan_created = false;
-	int idx = -1;
-	int fid = -1;
-	int i;
-	int err;
+	int fid = -1, idx = -1;
+	int i, err;
 
 	/* Check if there is already a page for this bridge */
 	for (i = max_ports; i < ARRAY_SIZE(priv->vlans); i++) {
 		if (priv->vlans[i].bridge == bridge) {
-			if (fid != -1 && fid != priv->vlans[i].fid)
-				dev_err(priv->dev, "one bridge with multiple flow ids\n");
-			fid = priv->vlans[i].fid;
+			if (vlan_aware) {
+				if (fid != -1 && fid != priv->vlans[i].fid)
+					dev_err(priv->dev, "one bridge with multiple flow ids\n");
+				fid = priv->vlans[i].fid;
+			}
 			if (priv->vlans[i].vid == vid) {
 				idx = i;
 				break;
@@ -864,8 +803,9 @@ static int gswip_vlan_add_aware(struct gswip_priv *priv,
 	vlan_mapping.val[0] = vid;
 	/* Update the VLAN mapping entry and write it to the switch */
 	vlan_mapping.val[1] |= cpu_ports;
-	vlan_mapping.val[2] |= cpu_ports;
 	vlan_mapping.val[1] |= BIT(port);
+	if (vlan_aware)
+		vlan_mapping.val[2] |= cpu_ports;
 	if (untagged)
 		vlan_mapping.val[2] &= ~BIT(port);
 	else
@@ -879,8 +819,7 @@ static int gswip_vlan_add_aware(struct gswip_priv *priv,
 		return err;
 	}
 
-	if (pvid)
-		gswip_switch_w(priv, idx, GSWIP_PCE_DEFPVID(port));
+	gswip_switch_w(priv, vlan_aware ? idx : 0, GSWIP_PCE_DEFPVID(port));
 
 	return 0;
 }
@@ -955,7 +894,8 @@ static int gswip_port_bridge_join(struct dsa_switch *ds, int port,
 	 * specific bridges. No bridge is configured here.
 	 */
 	if (!br_vlan_enabled(br)) {
-		err = gswip_vlan_add_unaware(priv, br, port);
+		err = gswip_vlan_add(priv, br, port, GSWIP_VLAN_UNAWARE_PVID,
+				     true, true, false);
 		if (err)
 			return err;
 		priv->port_vlan_filter &= ~BIT(port);
@@ -1049,8 +989,8 @@ static int gswip_port_vlan_add(struct dsa_switch *ds, int port,
 	if (dsa_is_cpu_port(ds, port))
 		return 0;
 
-	return gswip_vlan_add_aware(priv, bridge, port, vlan->vid,
-				    untagged, pvid);
+	return gswip_vlan_add(priv, bridge, port, vlan->vid, untagged, pvid,
+			      true);
 }
 
 static int gswip_port_vlan_del(struct dsa_switch *ds, int port,
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 05/11] net: dsa: lantiq_gswip: remove legacy configure_vlan_while_not_filtering option
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (3 preceding siblings ...)
  2025-10-15 22:32 ` [PATCH net-next 04/11] net: dsa: lantiq_gswip: merge gswip_vlan_add_unaware() and gswip_vlan_add_aware() Daniel Golle
@ 2025-10-15 22:32 ` Daniel Golle
  2025-10-15 22:32 ` [PATCH net-next 06/11] net: dsa: lantiq_gswip: permit dynamic changes to VLAN filtering state Daniel Golle
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:32 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

This driver doesn't support dynamic VLAN filtering changes, for simplicity.
It expects that on a port, either gswip_vlan_add_unaware() or
gswip_vlan_add_aware() is called, but not both.

When !br_vlan_enabled(), the configure_vlan_while_not_filtering = false
option is exactly what will prevent calls to gswip_port_vlan_add() from
being issued by DSA.

In fact, at the time these features were submitted:
https://patchwork.ozlabs.org/project/netdev/patch/20190501204506.21579-3-hauke@hauke-m.de/
"configure_vlan_while_not_filtering = false" did not even have a name,
it was implicit behaviour. It only became legacy in commit 54a0ed0df496
("net: dsa: provide an option for drivers to always receive bridge
VLANs").

Section "Bridge VLAN filtering" of Documentation/networking/switchdev.rst
describes the exact set of rules. Notably, the PVID of the port must
follow the VLAN awareness state of the bridge port. A VLAN-unaware
bridge port should not respond to the addition of a bridge VLAN with the
PVID flag. In fact, the pvid_change() test in
tools/testing/selftests/net/forwarding/bridge_vlan_unaware.sh tests
exactly this.

The lantiq_gswip driver indeed does not respond to the addition of PVID
VLANs while VLAN-unaware in the way described above, but only because of
configure_vlan_while_not_filtering. Our purpose here is to get rid of
configure_vlan_while_not_filtering, so we must add more complex logic
which follows the VLAN awareness state and walks through the Active VLAN
table entries, to find the index of the PVID register that should be
committed to hardware on each port.

As a side-effect of now having a proper implementation to assign the
PVID all the "VLAN upper: ..." tests of the local_termination.sh self-
tests which would previously all FAIL now all PASS (or XFAIL, but
that's ok).

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Tested-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 49 +++++++++++++++++++++++----
 1 file changed, 43 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 6cbcb54a5ed0..30cff623bec0 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -547,6 +547,45 @@ static int gswip_pce_load_microcode(struct gswip_priv *priv)
 	return 0;
 }
 
+static void gswip_port_commit_pvid(struct gswip_priv *priv, int port)
+{
+	struct dsa_port *dp = dsa_to_port(priv->ds, port);
+	struct net_device *br = dsa_port_bridge_dev_get(dp);
+	int idx;
+
+	if (!dsa_port_is_user(dp))
+		return;
+
+	if (br) {
+		u16 pvid = GSWIP_VLAN_UNAWARE_PVID;
+
+		if (br_vlan_enabled(br))
+			br_vlan_get_pvid(br, &pvid);
+
+		/* VLAN-aware bridge ports with no PVID will use Active VLAN
+		 * index 0. The expectation is that this drops all untagged and
+		 * VID-0 tagged ingress traffic.
+		 */
+		idx = 0;
+		for (int i = priv->hw_info->max_ports;
+		     i < ARRAY_SIZE(priv->vlans); i++) {
+			if (priv->vlans[i].bridge == br &&
+			    priv->vlans[i].vid == pvid) {
+				idx = i;
+				break;
+			}
+		}
+	} else {
+		/* The Active VLAN table index as configured by
+		 * gswip_add_single_port_br()
+		 */
+		idx = port + 1;
+	}
+
+	/* GSWIP 2.2 (GRX300) and later program here the VID directly. */
+	gswip_switch_w(priv, idx, GSWIP_PCE_DEFPVID(port));
+}
+
 static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
 				     bool vlan_filtering,
 				     struct netlink_ext_ack *extack)
@@ -581,6 +620,8 @@ static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
 				  GSWIP_PCE_PCTRL_0p(port));
 	}
 
+	gswip_port_commit_pvid(priv, port);
+
 	return 0;
 }
 
@@ -677,8 +718,6 @@ static int gswip_setup(struct dsa_switch *ds)
 
 	ds->mtu_enforcement_ingress = true;
 
-	ds->configure_vlan_while_not_filtering = false;
-
 	return 0;
 }
 
@@ -819,7 +858,7 @@ static int gswip_vlan_add(struct gswip_priv *priv, struct net_device *bridge,
 		return err;
 	}
 
-	gswip_switch_w(priv, vlan_aware ? idx : 0, GSWIP_PCE_DEFPVID(port));
+	gswip_port_commit_pvid(priv, port);
 
 	return 0;
 }
@@ -874,9 +913,7 @@ static int gswip_vlan_remove(struct gswip_priv *priv,
 		}
 	}
 
-	/* GSWIP 2.2 (GRX300) and later program here the VID directly. */
-	if (pvid)
-		gswip_switch_w(priv, 0, GSWIP_PCE_DEFPVID(port));
+	gswip_port_commit_pvid(priv, port);
 
 	return 0;
 }
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 06/11] net: dsa: lantiq_gswip: permit dynamic changes to VLAN filtering state
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (4 preceding siblings ...)
  2025-10-15 22:32 ` [PATCH net-next 05/11] net: dsa: lantiq_gswip: remove legacy configure_vlan_while_not_filtering option Daniel Golle
@ 2025-10-15 22:32 ` Daniel Golle
  2025-10-15 22:33 ` [PATCH net-next 07/11] net: dsa: lantiq_gswip: disallow changes to privately set up VID 0 Daniel Golle
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:32 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

The driver should now tolerate these changes, now that the PVID is
automatically recalculated on a VLAN awareness state change.

The VLAN-unaware PVID must be installed to hardware even if the
joined bridge is currently VLAN-aware. Otherwise, when the bridge VLAN
filtering state dynamically changes to VLAN-unaware later, this PVID
will be missing.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 38 +++++++++------------------
 drivers/net/dsa/lantiq/lantiq_gswip.h |  1 -
 2 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 30cff623bec0..58fdd54094d6 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -590,16 +590,8 @@ static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
 				     bool vlan_filtering,
 				     struct netlink_ext_ack *extack)
 {
-	struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
 	struct gswip_priv *priv = ds->priv;
 
-	/* Do not allow changing the VLAN filtering options while in bridge */
-	if (bridge && !!(priv->port_vlan_filter & BIT(port)) != vlan_filtering) {
-		NL_SET_ERR_MSG_MOD(extack,
-				   "Dynamic toggling of vlan_filtering not supported");
-		return -EIO;
-	}
-
 	if (vlan_filtering) {
 		/* Use tag based VLAN */
 		gswip_switch_mask(priv,
@@ -927,18 +919,15 @@ static int gswip_port_bridge_join(struct dsa_switch *ds, int port,
 	struct gswip_priv *priv = ds->priv;
 	int err;
 
-	/* When the bridge uses VLAN filtering we have to configure VLAN
-	 * specific bridges. No bridge is configured here.
+	/* Set up the VLAN for VLAN-unaware bridging for this port, and remove
+	 * it from the "single-port bridge" through which it was operating as
+	 * standalone.
 	 */
-	if (!br_vlan_enabled(br)) {
-		err = gswip_vlan_add(priv, br, port, GSWIP_VLAN_UNAWARE_PVID,
-				     true, true, false);
-		if (err)
-			return err;
-		priv->port_vlan_filter &= ~BIT(port);
-	} else {
-		priv->port_vlan_filter |= BIT(port);
-	}
+	err = gswip_vlan_add(priv, br, port, GSWIP_VLAN_UNAWARE_PVID,
+			     true, true, false);
+	if (err)
+		return err;
+
 	return gswip_add_single_port_br(priv, port, false);
 }
 
@@ -948,14 +937,11 @@ static void gswip_port_bridge_leave(struct dsa_switch *ds, int port,
 	struct net_device *br = bridge.dev;
 	struct gswip_priv *priv = ds->priv;
 
-	gswip_add_single_port_br(priv, port, true);
-
-	/* When the bridge uses VLAN filtering we have to configure VLAN
-	 * specific bridges. No bridge is configured here.
+	/* Add the port back to the "single-port bridge", and remove it from
+	 * the VLAN-unaware PVID created for this bridge.
 	 */
-	if (!br_vlan_enabled(br))
-		gswip_vlan_remove(priv, br, port, GSWIP_VLAN_UNAWARE_PVID, true,
-				  false);
+	gswip_add_single_port_br(priv, port, true);
+	gswip_vlan_remove(priv, br, port, GSWIP_VLAN_UNAWARE_PVID, true, false);
 }
 
 static int gswip_port_vlan_prepare(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.h b/drivers/net/dsa/lantiq/lantiq_gswip.h
index 6aae1ff2f130..4590a1a7dbd9 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.h
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.h
@@ -270,7 +270,6 @@ struct gswip_priv {
 	struct gswip_vlan vlans[64];
 	int num_gphy_fw;
 	struct gswip_gphy_fw *gphy_fw;
-	u32 port_vlan_filter;
 	struct mutex pce_table_lock;
 	u16 version;
 };
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 07/11] net: dsa: lantiq_gswip: disallow changes to privately set up VID 0
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (5 preceding siblings ...)
  2025-10-15 22:32 ` [PATCH net-next 06/11] net: dsa: lantiq_gswip: permit dynamic changes to VLAN filtering state Daniel Golle
@ 2025-10-15 22:33 ` Daniel Golle
  2025-10-15 22:33 ` [PATCH net-next 08/11] net: dsa: lantiq_gswip: remove vlan_aware and pvid arguments from gswip_vlan_remove() Daniel Golle
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:33 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

User space can force the altering of VID 0 as it was privately set up by
this driver.

For example, when the port joins a VLAN-aware bridge,
dsa_user_manage_vlan_filtering() will set NETIF_F_HW_VLAN_CTAG_FILTER.
If the port is subsequently brought up and CONFIG_VLAN_8021Q is enabled,
the vlan_vid0_add() function will want to make sure we are capable of
accepting packets tagged with VID 0.

Generally, DSA/switchdev drivers want to suppress that bit of help from
the 8021q layer, and handle VID 0 filters themselves. The 8021q layer
might actually be even detrimential, because VLANs added through
vlan_vid_add() pass through dsa_user_vlan_rx_add_vid(), which is
documented as this:

	/* This API only allows programming tagged, non-PVID VIDs */
	.flags = 0,

so it will force VID 0 to be reconfigured as egress-tagged, non-PVID.
Whereas the driver configures it as PVID and egress-untagged, the exact
opposite.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 58fdd54094d6..26e963840f3b 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -1000,6 +1000,9 @@ static int gswip_port_vlan_add(struct dsa_switch *ds, int port,
 	bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
 	int err;
 
+	if (vlan->vid == GSWIP_VLAN_UNAWARE_PVID)
+		return 0;
+
 	err = gswip_port_vlan_prepare(ds, port, vlan, extack);
 	if (err)
 		return err;
@@ -1023,6 +1026,9 @@ static int gswip_port_vlan_del(struct dsa_switch *ds, int port,
 	struct gswip_priv *priv = ds->priv;
 	bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
 
+	if (vlan->vid == GSWIP_VLAN_UNAWARE_PVID)
+		return 0;
+
 	/* We have to receive all packets on the CPU port and should not
 	 * do any VLAN filtering here. This is also called with bridge
 	 * NULL and then we do not know for which bridge to configure
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 08/11] net: dsa: lantiq_gswip: remove vlan_aware and pvid arguments from gswip_vlan_remove()
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (6 preceding siblings ...)
  2025-10-15 22:33 ` [PATCH net-next 07/11] net: dsa: lantiq_gswip: disallow changes to privately set up VID 0 Daniel Golle
@ 2025-10-15 22:33 ` Daniel Golle
  2025-10-15 22:33 ` [PATCH net-next 09/11] net: dsa: lantiq_gswip: put a more descriptive error print in gswip_vlan_remove() Daniel Golle
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:33 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

"bool pvid" is unused since commit "net: dsa: lantiq_gswip: remove
legacy configure_vlan_while_not_filtering option".

"bool vlan_aware" shouldn't have a role in finding the bridge VLAN.
It should be identified by VID regardless of VLAN-aware or VLAN-unaware.
The driver sets up VID 0 for the VLAN-unaware PVID.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 26e963840f3b..d9a7a004f9eb 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -857,7 +857,7 @@ static int gswip_vlan_add(struct gswip_priv *priv, struct net_device *bridge,
 
 static int gswip_vlan_remove(struct gswip_priv *priv,
 			     struct net_device *bridge, int port,
-			     u16 vid, bool pvid, bool vlan_aware)
+			     u16 vid)
 {
 	struct gswip_pce_table_entry vlan_mapping = {0,};
 	unsigned int max_ports = priv->hw_info->max_ports;
@@ -868,7 +868,7 @@ static int gswip_vlan_remove(struct gswip_priv *priv,
 	/* Check if there is already a page for this bridge */
 	for (i = max_ports; i < ARRAY_SIZE(priv->vlans); i++) {
 		if (priv->vlans[i].bridge == bridge &&
-		    (!vlan_aware || priv->vlans[i].vid == vid)) {
+		    priv->vlans[i].vid == vid) {
 			idx = i;
 			break;
 		}
@@ -941,7 +941,7 @@ static void gswip_port_bridge_leave(struct dsa_switch *ds, int port,
 	 * the VLAN-unaware PVID created for this bridge.
 	 */
 	gswip_add_single_port_br(priv, port, true);
-	gswip_vlan_remove(priv, br, port, GSWIP_VLAN_UNAWARE_PVID, true, false);
+	gswip_vlan_remove(priv, br, port, GSWIP_VLAN_UNAWARE_PVID);
 }
 
 static int gswip_port_vlan_prepare(struct dsa_switch *ds, int port,
@@ -1024,7 +1024,6 @@ static int gswip_port_vlan_del(struct dsa_switch *ds, int port,
 {
 	struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
 	struct gswip_priv *priv = ds->priv;
-	bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
 
 	if (vlan->vid == GSWIP_VLAN_UNAWARE_PVID)
 		return 0;
@@ -1037,7 +1036,7 @@ static int gswip_port_vlan_del(struct dsa_switch *ds, int port,
 	if (dsa_is_cpu_port(ds, port))
 		return 0;
 
-	return gswip_vlan_remove(priv, bridge, port, vlan->vid, pvid, true);
+	return gswip_vlan_remove(priv, bridge, port, vlan->vid);
 }
 
 static void gswip_port_fast_age(struct dsa_switch *ds, int port)
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 09/11] net: dsa: lantiq_gswip: put a more descriptive error print in gswip_vlan_remove()
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (7 preceding siblings ...)
  2025-10-15 22:33 ` [PATCH net-next 08/11] net: dsa: lantiq_gswip: remove vlan_aware and pvid arguments from gswip_vlan_remove() Daniel Golle
@ 2025-10-15 22:33 ` Daniel Golle
  2025-10-15 22:33 ` [PATCH net-next 10/11] net: dsa: lantiq_gswip: drop untagged on VLAN-aware bridge ports with no PVID Daniel Golle
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:33 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

Improve the error message printed in case of a port VLAN entry not being
found upon removal.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index d9a7a004f9eb..cfdeb8148500 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -875,7 +875,8 @@ static int gswip_vlan_remove(struct gswip_priv *priv,
 	}
 
 	if (idx == -1) {
-		dev_err(priv->dev, "bridge to leave does not exists\n");
+		dev_err(priv->dev, "Port %d cannot find VID %u of bridge %s\n",
+			port, vid, bridge ? bridge->name : "(null)");
 		return -ENOENT;
 	}
 
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 10/11] net: dsa: lantiq_gswip: drop untagged on VLAN-aware bridge ports with no PVID
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (8 preceding siblings ...)
  2025-10-15 22:33 ` [PATCH net-next 09/11] net: dsa: lantiq_gswip: put a more descriptive error print in gswip_vlan_remove() Daniel Golle
@ 2025-10-15 22:33 ` Daniel Golle
  2025-10-15 22:34 ` [PATCH net-next 11/11] net: dsa: lantiq_gswip: treat VID 0 like the PVID Daniel Golle
  2025-10-18  1:30 ` [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling patchwork-bot+netdevbpf
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:33 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

Implement the required functionality, as written in
Documentation/networking/switchdev.rst section "Bridge VLAN filtering",
by using the "VLAN Ingress Tag Rule" feature of the switch.

The bit field definitions for this were found while browsing the Intel
dual BSD/GPLv2 licensed drivers for this switch IP.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 6 ++++++
 drivers/net/dsa/lantiq/lantiq_gswip.h | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index cfdeb8148500..1ff0932dae31 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -551,6 +551,7 @@ static void gswip_port_commit_pvid(struct gswip_priv *priv, int port)
 {
 	struct dsa_port *dp = dsa_to_port(priv->ds, port);
 	struct net_device *br = dsa_port_bridge_dev_get(dp);
+	u32 vinr;
 	int idx;
 
 	if (!dsa_port_is_user(dp))
@@ -582,6 +583,11 @@ static void gswip_port_commit_pvid(struct gswip_priv *priv, int port)
 		idx = port + 1;
 	}
 
+	vinr = idx ? GSWIP_PCE_VCTRL_VINR_ALL : GSWIP_PCE_VCTRL_VINR_TAGGED;
+	gswip_switch_mask(priv, GSWIP_PCE_VCTRL_VINR,
+			  FIELD_PREP(GSWIP_PCE_VCTRL_VINR, vinr),
+			  GSWIP_PCE_VCTRL(port));
+
 	/* GSWIP 2.2 (GRX300) and later program here the VID directly. */
 	gswip_switch_w(priv, idx, GSWIP_PCE_DEFPVID(port));
 }
diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.h b/drivers/net/dsa/lantiq/lantiq_gswip.h
index 4590a1a7dbd9..69c8d2deff2d 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.h
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.h
@@ -159,6 +159,10 @@
 #define  GSWIP_PCE_PCTRL_0_PSTATE_MASK	GENMASK(2, 0)
 #define GSWIP_PCE_VCTRL(p)		(0x485 + ((p) * 0xA))
 #define  GSWIP_PCE_VCTRL_UVR		BIT(0)	/* Unknown VLAN Rule */
+#define  GSWIP_PCE_VCTRL_VINR		GENMASK(2, 1) /* VLAN Ingress Tag Rule */
+#define  GSWIP_PCE_VCTRL_VINR_ALL	0 /* Admit tagged and untagged packets */
+#define  GSWIP_PCE_VCTRL_VINR_TAGGED	1 /* Admit only tagged packets */
+#define  GSWIP_PCE_VCTRL_VINR_UNTAGGED	2 /* Admit only untagged packets */
 #define  GSWIP_PCE_VCTRL_VIMR		BIT(3)	/* VLAN Ingress Member violation rule */
 #define  GSWIP_PCE_VCTRL_VEMR		BIT(4)	/* VLAN Egress Member violation rule */
 #define  GSWIP_PCE_VCTRL_VSR		BIT(5)	/* VLAN Security */
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 11/11] net: dsa: lantiq_gswip: treat VID 0 like the PVID
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (9 preceding siblings ...)
  2025-10-15 22:33 ` [PATCH net-next 10/11] net: dsa: lantiq_gswip: drop untagged on VLAN-aware bridge ports with no PVID Daniel Golle
@ 2025-10-15 22:34 ` Daniel Golle
  2025-10-18  1:30 ` [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling patchwork-bot+netdevbpf
  11 siblings, 0 replies; 13+ messages in thread
From: Daniel Golle @ 2025-10-15 22:34 UTC (permalink / raw)
  To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
  Cc: Andreas Schirm, Lukas Stockmann, Alexander Sverdlin,
	Peter Christen, Avinash Jayaraman, Bing tao Xu, Liang Xu,
	Juraj Povazanec, Fanni (Fang-Yi) Chan, Benny (Ying-Tsan) Weng,
	Livia M. Rosu, John Crispin

From: Vladimir Oltean <vladimir.oltean@nxp.com>

Documentation/networking/switchdev.rst says that VLAN-aware bridges must
treat packets tagged with VID 0 the same as untagged. It appears from
the documentation that setting the GSWIP_PCE_VCTRL_VID0 flag (which this
driver already had defined) might achieve this.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 drivers/net/dsa/lantiq/lantiq_gswip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/lantiq/lantiq_gswip.c b/drivers/net/dsa/lantiq/lantiq_gswip.c
index 1ff0932dae31..25f6b46957a0 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip.c
@@ -603,7 +603,7 @@ static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
 		gswip_switch_mask(priv,
 				  GSWIP_PCE_VCTRL_VSR,
 				  GSWIP_PCE_VCTRL_UVR | GSWIP_PCE_VCTRL_VIMR |
-				  GSWIP_PCE_VCTRL_VEMR,
+				  GSWIP_PCE_VCTRL_VEMR | GSWIP_PCE_VCTRL_VID0,
 				  GSWIP_PCE_VCTRL(port));
 		gswip_switch_mask(priv, GSWIP_PCE_PCTRL_0_TVM, 0,
 				  GSWIP_PCE_PCTRL_0p(port));
@@ -611,7 +611,7 @@ static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
 		/* Use port based VLAN */
 		gswip_switch_mask(priv,
 				  GSWIP_PCE_VCTRL_UVR | GSWIP_PCE_VCTRL_VIMR |
-				  GSWIP_PCE_VCTRL_VEMR,
+				  GSWIP_PCE_VCTRL_VEMR | GSWIP_PCE_VCTRL_VID0,
 				  GSWIP_PCE_VCTRL_VSR,
 				  GSWIP_PCE_VCTRL(port));
 		gswip_switch_mask(priv, 0, GSWIP_PCE_PCTRL_0_TVM,
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling
  2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
                   ` (10 preceding siblings ...)
  2025-10-15 22:34 ` [PATCH net-next 11/11] net: dsa: lantiq_gswip: treat VID 0 like the PVID Daniel Golle
@ 2025-10-18  1:30 ` patchwork-bot+netdevbpf
  11 siblings, 0 replies; 13+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-18  1:30 UTC (permalink / raw)
  To: Daniel Golle
  Cc: hauke, andrew, olteanv, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, andreas.schirm, lukas.stockmann, alexander.sverdlin,
	peter.christen, ajayaraman, bxu, lxu, jpovazanec, fchan, yweng,
	lrosu, john

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 15 Oct 2025 23:31:51 +0100 you wrote:
> Hi all,
> 
> This series was developed by Vladimir Oltean to improve and clean up the
> VLAN handling logic in the Lantiq GSWIP DSA driver.
> 
> As Vladimir currently doesn't have the availability to take care of the
> submission process, we agreed that I would send the patches on his
> behalf.
> 
> [...]

Here is the summary with links:
  - [net-next,01/11] net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port
    https://git.kernel.org/netdev/net-next/c/e29bbd73ad71
  - [net-next,02/11] net: dsa: lantiq_gswip: define VLAN ID 0 constant
    https://git.kernel.org/netdev/net-next/c/92790e6c11a8
  - [net-next,03/11] net: dsa: lantiq_gswip: remove duplicate assignment to vlan_mapping.val[0]
    https://git.kernel.org/netdev/net-next/c/8f5c71e44413
  - [net-next,04/11] net: dsa: lantiq_gswip: merge gswip_vlan_add_unaware() and gswip_vlan_add_aware()
    https://git.kernel.org/netdev/net-next/c/b92068755ee0
  - [net-next,05/11] net: dsa: lantiq_gswip: remove legacy configure_vlan_while_not_filtering option
    https://git.kernel.org/netdev/net-next/c/21c3237c60c3
  - [net-next,06/11] net: dsa: lantiq_gswip: permit dynamic changes to VLAN filtering state
    https://git.kernel.org/netdev/net-next/c/ab3ce58559d6
  - [net-next,07/11] net: dsa: lantiq_gswip: disallow changes to privately set up VID 0
    https://git.kernel.org/netdev/net-next/c/96a91e6eeb4d
  - [net-next,08/11] net: dsa: lantiq_gswip: remove vlan_aware and pvid arguments from gswip_vlan_remove()
    https://git.kernel.org/netdev/net-next/c/7ed1965f1010
  - [net-next,09/11] net: dsa: lantiq_gswip: put a more descriptive error print in gswip_vlan_remove()
    https://git.kernel.org/netdev/net-next/c/a57627626636
  - [net-next,10/11] net: dsa: lantiq_gswip: drop untagged on VLAN-aware bridge ports with no PVID
    https://git.kernel.org/netdev/net-next/c/3bb500caf656
  - [net-next,11/11] net: dsa: lantiq_gswip: treat VID 0 like the PVID
    https://git.kernel.org/netdev/net-next/c/1f89ed0ebf26

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-10-18  1:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 22:31 [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling Daniel Golle
2025-10-15 22:32 ` [PATCH net-next 01/11] net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port Daniel Golle
2025-10-15 22:32 ` [PATCH net-next 02/11] net: dsa: lantiq_gswip: define VLAN ID 0 constant Daniel Golle
2025-10-15 22:32 ` [PATCH net-next 03/11] net: dsa: lantiq_gswip: remove duplicate assignment to vlan_mapping.val[0] Daniel Golle
2025-10-15 22:32 ` [PATCH net-next 04/11] net: dsa: lantiq_gswip: merge gswip_vlan_add_unaware() and gswip_vlan_add_aware() Daniel Golle
2025-10-15 22:32 ` [PATCH net-next 05/11] net: dsa: lantiq_gswip: remove legacy configure_vlan_while_not_filtering option Daniel Golle
2025-10-15 22:32 ` [PATCH net-next 06/11] net: dsa: lantiq_gswip: permit dynamic changes to VLAN filtering state Daniel Golle
2025-10-15 22:33 ` [PATCH net-next 07/11] net: dsa: lantiq_gswip: disallow changes to privately set up VID 0 Daniel Golle
2025-10-15 22:33 ` [PATCH net-next 08/11] net: dsa: lantiq_gswip: remove vlan_aware and pvid arguments from gswip_vlan_remove() Daniel Golle
2025-10-15 22:33 ` [PATCH net-next 09/11] net: dsa: lantiq_gswip: put a more descriptive error print in gswip_vlan_remove() Daniel Golle
2025-10-15 22:33 ` [PATCH net-next 10/11] net: dsa: lantiq_gswip: drop untagged on VLAN-aware bridge ports with no PVID Daniel Golle
2025-10-15 22:34 ` [PATCH net-next 11/11] net: dsa: lantiq_gswip: treat VID 0 like the PVID Daniel Golle
2025-10-18  1:30 ` [PATCH net-next 00/11] net: dsa: lantiq_gswip: clean up and improve VLAN handling patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).