devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements
@ 2024-06-10 14:02 Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 01/12] dt-bindings: net: dsa: lantiq_gswip: Add missing CPU port phy-mode and fixed-link to example Martin Schiller
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

This patchset for the lantiq_gswip driver is a collection of minor fixes
and coding improvements by Martin Blumenstingl without any real changes
in the actual functionality.

=== Changelog ===
From v2:
- removed unused variable max_ports in gswip_add_single_port_br()

From v1:
- signal that we only update example code in dt-bindings
- don't use the word 'fix' if not appropriate
- new patch: add terminating '\n' where missing
- renamed MAC_BRIDGE macros to make it obvious which register field is
  used
- new patch: remove dead code from gswip_add_single_port_br()
- updated error message if FID not found in gswip_port_fdb()

Martin Blumenstingl (9):
  dt-bindings: net: dsa: lantiq_gswip: Add missing CPU port phy-mode and
    fixed-link to example
  net: dsa: lantiq_gswip: Only allow phy-mode = "internal" on the CPU
    port
  net: dsa: lantiq_gswip: Use dev_err_probe where appropriate
  net: dsa: lantiq_gswip: Don't manually call gswip_port_enable()
  net: dsa: lantiq_gswip: Use dsa_is_cpu_port() in
    gswip_port_change_mtu()
  net: dsa: lantiq_gswip: Change literal 6 to ETH_ALEN
  net: dsa: lantiq_gswip: Consistently use macros for the mac bridge
    table
  net: dsa: lantiq_gswip: Update comments in gswip_port_vlan_filtering()
  net: dsa: lantiq_gswip: Improve error message in gswip_port_fdb()

Martin Schiller (3):
  net: dsa: lantiq_gswip: add terminating \n where missing
  net: dsa: lantiq_gswip: do also enable or disable cpu port
  net: dsa: lantiq_gswip: Remove dead code from
    gswip_add_single_port_br()

 .../bindings/net/dsa/lantiq-gswip.txt         |   6 +
 drivers/net/dsa/lantiq_gswip.c                | 123 ++++++++----------
 2 files changed, 61 insertions(+), 68 deletions(-)

-- 
2.39.2


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

* [PATCH net-next v3 01/12] dt-bindings: net: dsa: lantiq_gswip: Add missing CPU port phy-mode and fixed-link to example
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 02/12] net: dsa: lantiq_gswip: Only allow phy-mode = "internal" on the CPU port Martin Schiller
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

The CPU port has to specify a phy-mode and either a phy or a fixed-link.
Since GSWIP is connected using a SoC internal protocol there's no PHY
involved. Add phy-mode = "internal" and a fixed-link to the example code
to describe the communication between the PMAC (Ethernet controller) and
GSWIP switch.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
---
 Documentation/devicetree/bindings/net/dsa/lantiq-gswip.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/dsa/lantiq-gswip.txt b/Documentation/devicetree/bindings/net/dsa/lantiq-gswip.txt
index 8bb1eff21cb1..e81ba0e0da0f 100644
--- a/Documentation/devicetree/bindings/net/dsa/lantiq-gswip.txt
+++ b/Documentation/devicetree/bindings/net/dsa/lantiq-gswip.txt
@@ -96,7 +96,13 @@ switch@e108000 {
 
 		port@6 {
 			reg = <0x6>;
+			phy-mode = "internal";
 			ethernet = <&eth0>;
+
+			fixed-link {
+				speed = <1000>;
+				full-duplex;
+			};
 		};
 	};
 
-- 
2.39.2


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

* [PATCH net-next v3 02/12] net: dsa: lantiq_gswip: Only allow phy-mode = "internal" on the CPU port
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 01/12] dt-bindings: net: dsa: lantiq_gswip: Add missing CPU port phy-mode and fixed-link to example Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 03/12] net: dsa: lantiq_gswip: add terminating \n where missing Martin Schiller
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Add the CPU port to gswip_xrx200_phylink_get_caps() and
gswip_xrx300_phylink_get_caps(). It connects through a SoC-internal bus,
so the only allowed phy-mode is PHY_INTERFACE_MODE_INTERNAL.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index a557049e34f5..b9c7076ce32f 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1516,6 +1516,7 @@ static void gswip_xrx200_phylink_get_caps(struct dsa_switch *ds, int port,
 	case 2:
 	case 3:
 	case 4:
+	case 6:
 		__set_bit(PHY_INTERFACE_MODE_INTERNAL,
 			  config->supported_interfaces);
 		break;
@@ -1547,6 +1548,7 @@ static void gswip_xrx300_phylink_get_caps(struct dsa_switch *ds, int port,
 	case 2:
 	case 3:
 	case 4:
+	case 6:
 		__set_bit(PHY_INTERFACE_MODE_INTERNAL,
 			  config->supported_interfaces);
 		break;
-- 
2.39.2


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

* [PATCH net-next v3 03/12] net: dsa: lantiq_gswip: add terminating \n where missing
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 01/12] dt-bindings: net: dsa: lantiq_gswip: Add missing CPU port phy-mode and fixed-link to example Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 02/12] net: dsa: lantiq_gswip: Only allow phy-mode = "internal" on the CPU port Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 21:46   ` Andrew Lunn
  2024-06-10 14:02 ` [PATCH net-next v3 04/12] net: dsa: lantiq_gswip: Use dev_err_probe where appropriate Martin Schiller
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

Some dev_err are missing the terminating \n. Let's add that.

Suggested-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 drivers/net/dsa/lantiq_gswip.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index b9c7076ce32f..fe64baf0d7f1 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -836,7 +836,7 @@ static int gswip_setup(struct dsa_switch *ds)
 
 	err = gswip_pce_load_microcode(priv);
 	if (err) {
-		dev_err(priv->dev, "writing PCE microcode failed, %i", err);
+		dev_err(priv->dev, "writing PCE microcode failed, %i\n", err);
 		return err;
 	}
 
@@ -1792,7 +1792,7 @@ static u32 gswip_bcm_ram_entry_read(struct gswip_priv *priv, u32 table,
 	err = gswip_switch_r_timeout(priv, GSWIP_BM_RAM_CTRL,
 				     GSWIP_BM_RAM_CTRL_BAS);
 	if (err) {
-		dev_err(priv->dev, "timeout while reading table: %u, index: %u",
+		dev_err(priv->dev, "timeout while reading table: %u, index: %u\n",
 			table, index);
 		return 0;
 	}
@@ -2021,7 +2021,7 @@ static void gswip_gphy_fw_remove(struct gswip_priv *priv,
 
 	ret = regmap_write(priv->rcu_regmap, gphy_fw->fw_addr_offset, 0);
 	if (ret)
-		dev_err(priv->dev, "can not reset GPHY FW pointer");
+		dev_err(priv->dev, "can not reset GPHY FW pointer\n");
 
 	clk_disable_unprepare(gphy_fw->clk_gate);
 
@@ -2050,7 +2050,7 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
 			priv->gphy_fw_name_cfg = &xrx200a2x_gphy_data;
 			break;
 		default:
-			dev_err(dev, "unknown GSWIP version: 0x%x", version);
+			dev_err(dev, "unknown GSWIP version: 0x%x\n", version);
 			return -ENOENT;
 		}
 	}
@@ -2060,7 +2060,7 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
 		priv->gphy_fw_name_cfg = match->data;
 
 	if (!priv->gphy_fw_name_cfg) {
-		dev_err(dev, "GPHY compatible type not supported");
+		dev_err(dev, "GPHY compatible type not supported\n");
 		return -ENOENT;
 	}
 
@@ -2163,7 +2163,7 @@ static int gswip_probe(struct platform_device *pdev)
 			return -EINVAL;
 		break;
 	default:
-		dev_err(dev, "unknown GSWIP version: 0x%x", version);
+		dev_err(dev, "unknown GSWIP version: 0x%x\n", version);
 		return -ENOENT;
 	}
 
@@ -2191,7 +2191,7 @@ static int gswip_probe(struct platform_device *pdev)
 		goto gphy_fw_remove;
 	}
 	if (!dsa_is_cpu_port(priv->ds, priv->hw_info->cpu_port)) {
-		dev_err(dev, "wrong CPU port defined, HW only supports port: %i",
+		dev_err(dev, "wrong CPU port defined, HW only supports port: %i\n",
 			priv->hw_info->cpu_port);
 		err = -EINVAL;
 		goto disable_switch;
-- 
2.39.2


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

* [PATCH net-next v3 04/12] net: dsa: lantiq_gswip: Use dev_err_probe where appropriate
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (2 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 03/12] net: dsa: lantiq_gswip: add terminating \n where missing Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 05/12] net: dsa: lantiq_gswip: Don't manually call gswip_port_enable() Martin Schiller
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

dev_err_probe() can be used to simplify the existing code. Also it means
we get rid of the following warning which is seen whenever the PMAC
(Ethernet controller which connects to GSWIP's CPU port) has not been
probed yet:
  gswip 1e108000.switch: dsa switch register failed: -517

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 53 ++++++++++++++++------------------
 1 file changed, 25 insertions(+), 28 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index fe64baf0d7f1..37cc0247dc78 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1931,11 +1931,9 @@ static int gswip_gphy_fw_load(struct gswip_priv *priv, struct gswip_gphy_fw *gph
 	msleep(200);
 
 	ret = request_firmware(&fw, gphy_fw->fw_name, dev);
-	if (ret) {
-		dev_err(dev, "failed to load firmware: %s, error: %i\n",
-			gphy_fw->fw_name, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to load firmware: %s\n",
+				     gphy_fw->fw_name);
 
 	/* GPHY cores need the firmware code in a persistent and contiguous
 	 * memory area with a 16 kB boundary aligned start address.
@@ -1948,9 +1946,9 @@ static int gswip_gphy_fw_load(struct gswip_priv *priv, struct gswip_gphy_fw *gph
 		dev_addr = ALIGN(dma_addr, XRX200_GPHY_FW_ALIGN);
 		memcpy(fw_addr, fw->data, fw->size);
 	} else {
-		dev_err(dev, "failed to alloc firmware memory\n");
 		release_firmware(fw);
-		return -ENOMEM;
+		return dev_err_probe(dev, -ENOMEM,
+				     "failed to alloc firmware memory\n");
 	}
 
 	release_firmware(fw);
@@ -1977,8 +1975,8 @@ static int gswip_gphy_fw_probe(struct gswip_priv *priv,
 
 	gphy_fw->clk_gate = devm_clk_get(dev, gphyname);
 	if (IS_ERR(gphy_fw->clk_gate)) {
-		dev_err(dev, "Failed to lookup gate clock\n");
-		return PTR_ERR(gphy_fw->clk_gate);
+		return dev_err_probe(dev, PTR_ERR(gphy_fw->clk_gate),
+				     "Failed to lookup gate clock\n");
 	}
 
 	ret = of_property_read_u32(gphy_fw_np, "reg", &gphy_fw->fw_addr_offset);
@@ -1998,8 +1996,8 @@ static int gswip_gphy_fw_probe(struct gswip_priv *priv,
 		gphy_fw->fw_name = priv->gphy_fw_name_cfg->ge_firmware_name;
 		break;
 	default:
-		dev_err(dev, "Unknown GPHY mode %d\n", gphy_mode);
-		return -EINVAL;
+		return dev_err_probe(dev, -EINVAL, "Unknown GPHY mode %d\n",
+				     gphy_mode);
 	}
 
 	gphy_fw->reset = of_reset_control_array_get_exclusive(gphy_fw_np);
@@ -2050,8 +2048,9 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
 			priv->gphy_fw_name_cfg = &xrx200a2x_gphy_data;
 			break;
 		default:
-			dev_err(dev, "unknown GSWIP version: 0x%x\n", version);
-			return -ENOENT;
+			return dev_err_probe(dev, -ENOENT,
+					     "unknown GSWIP version: 0x%x\n",
+					     version);
 		}
 	}
 
@@ -2059,10 +2058,9 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
 	if (match && match->data)
 		priv->gphy_fw_name_cfg = match->data;
 
-	if (!priv->gphy_fw_name_cfg) {
-		dev_err(dev, "GPHY compatible type not supported\n");
-		return -ENOENT;
-	}
+	if (!priv->gphy_fw_name_cfg)
+		return dev_err_probe(dev, -ENOENT,
+				     "GPHY compatible type not supported\n");
 
 	priv->num_gphy_fw = of_get_available_child_count(gphy_fw_list_np);
 	if (!priv->num_gphy_fw)
@@ -2163,8 +2161,8 @@ static int gswip_probe(struct platform_device *pdev)
 			return -EINVAL;
 		break;
 	default:
-		dev_err(dev, "unknown GSWIP version: 0x%x\n", version);
-		return -ENOENT;
+		return dev_err_probe(dev, -ENOENT,
+				     "unknown GSWIP version: 0x%x\n", version);
 	}
 
 	/* bring up the mdio bus */
@@ -2172,28 +2170,27 @@ static int gswip_probe(struct platform_device *pdev)
 	if (gphy_fw_np) {
 		err = gswip_gphy_fw_list(priv, gphy_fw_np, version);
 		of_node_put(gphy_fw_np);
-		if (err) {
-			dev_err(dev, "gphy fw probe failed\n");
-			return err;
-		}
+		if (err)
+			return dev_err_probe(dev, err,
+					     "gphy fw probe failed\n");
 	}
 
 	/* bring up the mdio bus */
 	err = gswip_mdio(priv);
 	if (err) {
-		dev_err(dev, "mdio probe failed\n");
+		dev_err_probe(dev, err, "mdio probe failed\n");
 		goto gphy_fw_remove;
 	}
 
 	err = dsa_register_switch(priv->ds);
 	if (err) {
-		dev_err(dev, "dsa switch register failed: %i\n", err);
+		dev_err_probe(dev, err, "dsa switch registration failed\n");
 		goto gphy_fw_remove;
 	}
 	if (!dsa_is_cpu_port(priv->ds, priv->hw_info->cpu_port)) {
-		dev_err(dev, "wrong CPU port defined, HW only supports port: %i\n",
-			priv->hw_info->cpu_port);
-		err = -EINVAL;
+		err = dev_err_probe(dev, -EINVAL,
+				    "wrong CPU port defined, HW only supports port: %i\n",
+				    priv->hw_info->cpu_port);
 		goto disable_switch;
 	}
 
-- 
2.39.2


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

* [PATCH net-next v3 05/12] net: dsa: lantiq_gswip: Don't manually call gswip_port_enable()
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (3 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 04/12] net: dsa: lantiq_gswip: Use dev_err_probe where appropriate Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 06/12] net: dsa: lantiq_gswip: do also enable or disable cpu port Martin Schiller
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

We don't need to manually call gswip_port_enable() from within
gswip_setup() for the CPU port. DSA does this automatically for us.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 37cc0247dc78..c1f9419af35f 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -898,8 +898,6 @@ static int gswip_setup(struct dsa_switch *ds)
 
 	ds->mtu_enforcement_ingress = true;
 
-	gswip_port_enable(ds, cpu_port, NULL);
-
 	ds->configure_vlan_while_not_filtering = false;
 
 	return 0;
-- 
2.39.2


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

* [PATCH net-next v3 06/12] net: dsa: lantiq_gswip: do also enable or disable cpu port
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (4 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 05/12] net: dsa: lantiq_gswip: Don't manually call gswip_port_enable() Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 07/12] net: dsa: lantiq_gswip: Use dsa_is_cpu_port() in gswip_port_change_mtu() Martin Schiller
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

Before commit 74be4babe72f ("net: dsa: do not enable or disable non user
ports"), gswip_port_enable/disable() were also executed for the cpu port
in gswip_setup() which disabled the cpu port during initialization.

Let's restore this by removing the dsa_is_user_port checks. Also, let's
clean up the gswip_port_enable() function so that we only have to check
for the cpu port once. The operation reordering done here is safe.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 drivers/net/dsa/lantiq_gswip.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index c1f9419af35f..8ec329d0c136 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -695,13 +695,18 @@ static int gswip_port_enable(struct dsa_switch *ds, int port,
 	struct gswip_priv *priv = ds->priv;
 	int err;
 
-	if (!dsa_is_user_port(ds, port))
-		return 0;
-
 	if (!dsa_is_cpu_port(ds, port)) {
+		u32 mdio_phy = 0;
+
 		err = gswip_add_single_port_br(priv, port, true);
 		if (err)
 			return err;
+
+		if (phydev)
+			mdio_phy = phydev->mdio.addr & GSWIP_MDIO_PHY_ADDR_MASK;
+
+		gswip_mdio_mask(priv, GSWIP_MDIO_PHY_ADDR_MASK, mdio_phy,
+				GSWIP_MDIO_PHYp(port));
 	}
 
 	/* RMON Counter Enable for port */
@@ -714,16 +719,6 @@ static int gswip_port_enable(struct dsa_switch *ds, int port,
 	gswip_switch_mask(priv, 0, GSWIP_SDMA_PCTRL_EN,
 			  GSWIP_SDMA_PCTRLp(port));
 
-	if (!dsa_is_cpu_port(ds, port)) {
-		u32 mdio_phy = 0;
-
-		if (phydev)
-			mdio_phy = phydev->mdio.addr & GSWIP_MDIO_PHY_ADDR_MASK;
-
-		gswip_mdio_mask(priv, GSWIP_MDIO_PHY_ADDR_MASK, mdio_phy,
-				GSWIP_MDIO_PHYp(port));
-	}
-
 	return 0;
 }
 
@@ -731,9 +726,6 @@ static void gswip_port_disable(struct dsa_switch *ds, int port)
 {
 	struct gswip_priv *priv = ds->priv;
 
-	if (!dsa_is_user_port(ds, port))
-		return;
-
 	gswip_switch_mask(priv, GSWIP_FDMA_PCTRL_EN, 0,
 			  GSWIP_FDMA_PCTRLp(port));
 	gswip_switch_mask(priv, GSWIP_SDMA_PCTRL_EN, 0,
-- 
2.39.2


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

* [PATCH net-next v3 07/12] net: dsa: lantiq_gswip: Use dsa_is_cpu_port() in gswip_port_change_mtu()
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (5 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 06/12] net: dsa: lantiq_gswip: do also enable or disable cpu port Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 08/12] net: dsa: lantiq_gswip: Change literal 6 to ETH_ALEN Martin Schiller
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Make the check for the CPU port in gswip_port_change_mtu() consistent
with other areas of the driver by using dsa_is_cpu_port().

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 8ec329d0c136..58c069f964dd 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1464,12 +1464,11 @@ static int gswip_port_max_mtu(struct dsa_switch *ds, int port)
 static int gswip_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
 {
 	struct gswip_priv *priv = ds->priv;
-	int cpu_port = priv->hw_info->cpu_port;
 
 	/* CPU port always has maximum mtu of user ports, so use it to set
 	 * switch frame size, including 8 byte special header.
 	 */
-	if (port == cpu_port) {
+	if (dsa_is_cpu_port(ds, port)) {
 		new_mtu += 8;
 		gswip_switch_w(priv, VLAN_ETH_HLEN + new_mtu + ETH_FCS_LEN,
 			       GSWIP_MAC_FLEN);
-- 
2.39.2


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

* [PATCH net-next v3 08/12] net: dsa: lantiq_gswip: Change literal 6 to ETH_ALEN
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (6 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 07/12] net: dsa: lantiq_gswip: Use dsa_is_cpu_port() in gswip_port_change_mtu() Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 09/12] net: dsa: lantiq_gswip: Consistently use macros for the mac bridge table Martin Schiller
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

The addr variable in gswip_port_fdb_dump() stores a mac address. Use
ETH_ALEN to make this consistent across other drivers.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 58c069f964dd..525a62a21601 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1413,7 +1413,7 @@ static int gswip_port_fdb_dump(struct dsa_switch *ds, int port,
 {
 	struct gswip_priv *priv = ds->priv;
 	struct gswip_pce_table_entry mac_bridge = {0,};
-	unsigned char addr[6];
+	unsigned char addr[ETH_ALEN];
 	int i;
 	int err;
 
-- 
2.39.2


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

* [PATCH net-next v3 09/12] net: dsa: lantiq_gswip: Consistently use macros for the mac bridge table
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (7 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 08/12] net: dsa: lantiq_gswip: Change literal 6 to ETH_ALEN Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 10/12] net: dsa: lantiq_gswip: Remove dead code from gswip_add_single_port_br() Martin Schiller
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Only bits [5:0] in mac_bridge.key[3] are reserved for the FID.
Also, for dynamic (learned) entries, bits [7:4] in mac_bridge.val[0]
represents the port.

Introduce new macros GSWIP_TABLE_MAC_BRIDGE_KEY3_FID and
GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT macro and use it throughout the driver.
Also rename and update GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC to use the
BIT() macro. This makes the driver code easier to understand.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 drivers/net/dsa/lantiq_gswip.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 525a62a21601..cd88b00cfdc1 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -236,7 +236,9 @@
 #define GSWIP_TABLE_ACTIVE_VLAN		0x01
 #define GSWIP_TABLE_VLAN_MAPPING	0x02
 #define GSWIP_TABLE_MAC_BRIDGE		0x0b
-#define  GSWIP_TABLE_MAC_BRIDGE_STATIC	0x01	/* Static not, aging entry */
+#define  GSWIP_TABLE_MAC_BRIDGE_KEY3_FID	GENMASK(5, 0)	/* Filtering identifier */
+#define  GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT	GENMASK(7, 4)	/* Port on learned entries */
+#define  GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC	BIT(0)		/* Static, non-aging entry */
 
 #define XRX200_GPHY_FW_ALIGN	(16 * 1024)
 
@@ -1304,10 +1306,11 @@ static void gswip_port_fast_age(struct dsa_switch *ds, int port)
 		if (!mac_bridge.valid)
 			continue;
 
-		if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_STATIC)
+		if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC)
 			continue;
 
-		if (((mac_bridge.val[0] & GENMASK(7, 4)) >> 4) != port)
+		if (port != FIELD_GET(GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT,
+				      mac_bridge.val[0]))
 			continue;
 
 		mac_bridge.valid = false;
@@ -1382,9 +1385,9 @@ static int gswip_port_fdb(struct dsa_switch *ds, int port,
 	mac_bridge.key[0] = addr[5] | (addr[4] << 8);
 	mac_bridge.key[1] = addr[3] | (addr[2] << 8);
 	mac_bridge.key[2] = addr[1] | (addr[0] << 8);
-	mac_bridge.key[3] = fid;
+	mac_bridge.key[3] = FIELD_PREP(GSWIP_TABLE_MAC_BRIDGE_KEY3_FID, fid);
 	mac_bridge.val[0] = add ? BIT(port) : 0; /* port map */
-	mac_bridge.val[1] = GSWIP_TABLE_MAC_BRIDGE_STATIC;
+	mac_bridge.val[1] = GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC;
 	mac_bridge.valid = add;
 
 	err = gswip_pce_table_entry_write(priv, &mac_bridge);
@@ -1438,14 +1441,15 @@ static int gswip_port_fdb_dump(struct dsa_switch *ds, int port,
 		addr[2] = (mac_bridge.key[1] >> 8) & 0xff;
 		addr[1] = mac_bridge.key[2] & 0xff;
 		addr[0] = (mac_bridge.key[2] >> 8) & 0xff;
-		if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_STATIC) {
+		if (mac_bridge.val[1] & GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC) {
 			if (mac_bridge.val[0] & BIT(port)) {
 				err = cb(addr, 0, true, data);
 				if (err)
 					return err;
 			}
 		} else {
-			if (((mac_bridge.val[0] & GENMASK(7, 4)) >> 4) == port) {
+			if (port == FIELD_GET(GSWIP_TABLE_MAC_BRIDGE_VAL0_PORT,
+					      mac_bridge.val[0])) {
 				err = cb(addr, 0, false, data);
 				if (err)
 					return err;
-- 
2.39.2


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

* [PATCH net-next v3 10/12] net: dsa: lantiq_gswip: Remove dead code from gswip_add_single_port_br()
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (8 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 09/12] net: dsa: lantiq_gswip: Consistently use macros for the mac bridge table Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 11/12] net: dsa: lantiq_gswip: Update comments in gswip_port_vlan_filtering() Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 12/12] net: dsa: lantiq_gswip: Improve error message in gswip_port_fdb() Martin Schiller
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

The port validation in gswip_add_single_port_br() is superfluous and
can be omitted.

Suggested-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 drivers/net/dsa/lantiq_gswip.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index cd88b00cfdc1..2bbc7dd45418 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -655,14 +655,8 @@ static int gswip_add_single_port_br(struct gswip_priv *priv, int port, bool add)
 	struct gswip_pce_table_entry vlan_active = {0,};
 	struct gswip_pce_table_entry vlan_mapping = {0,};
 	unsigned int cpu_port = priv->hw_info->cpu_port;
-	unsigned int max_ports = priv->hw_info->max_ports;
 	int err;
 
-	if (port >= max_ports) {
-		dev_err(priv->dev, "single port for %i supported\n", port);
-		return -EIO;
-	}
-
 	vlan_active.index = port + 1;
 	vlan_active.table = GSWIP_TABLE_ACTIVE_VLAN;
 	vlan_active.key[0] = 0; /* vid */
-- 
2.39.2


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

* [PATCH net-next v3 11/12] net: dsa: lantiq_gswip: Update comments in gswip_port_vlan_filtering()
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (9 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 10/12] net: dsa: lantiq_gswip: Remove dead code from gswip_add_single_port_br() Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  2024-06-10 14:02 ` [PATCH net-next v3 12/12] net: dsa: lantiq_gswip: Improve error message in gswip_port_fdb() Martin Schiller
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Update the comments in gswip_port_vlan_filtering() so it's clear that
there are two separate cases, one for "tag based VLAN" and another one
for "port based VLAN".

Suggested-by: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 2bbc7dd45418..ec52c62eadce 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -780,7 +780,7 @@ static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
 	}
 
 	if (vlan_filtering) {
-		/* Use port based VLAN tag */
+		/* Use tag based VLAN */
 		gswip_switch_mask(priv,
 				  GSWIP_PCE_VCTRL_VSR,
 				  GSWIP_PCE_VCTRL_UVR | GSWIP_PCE_VCTRL_VIMR |
@@ -789,7 +789,7 @@ static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
 		gswip_switch_mask(priv, GSWIP_PCE_PCTRL_0_TVM, 0,
 				  GSWIP_PCE_PCTRL_0p(port));
 	} else {
-		/* Use port based VLAN tag */
+		/* Use port based VLAN */
 		gswip_switch_mask(priv,
 				  GSWIP_PCE_VCTRL_UVR | GSWIP_PCE_VCTRL_VIMR |
 				  GSWIP_PCE_VCTRL_VEMR,
-- 
2.39.2


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

* [PATCH net-next v3 12/12] net: dsa: lantiq_gswip: Improve error message in gswip_port_fdb()
  2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
                   ` (10 preceding siblings ...)
  2024-06-10 14:02 ` [PATCH net-next v3 11/12] net: dsa: lantiq_gswip: Update comments in gswip_port_vlan_filtering() Martin Schiller
@ 2024-06-10 14:02 ` Martin Schiller
  11 siblings, 0 replies; 14+ messages in thread
From: Martin Schiller @ 2024-06-10 14:02 UTC (permalink / raw)
  To: martin.blumenstingl, hauke, andrew, f.fainelli, olteanv, davem,
	edumazet, kuba, pabeni, robh, krzk+dt, conor+dt
  Cc: netdev, devicetree, linux-kernel, ms

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Print that no FID is found for bridge %s instead of the incorrect
message that the port is not part of a bridge.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index ec52c62eadce..fcd4505f4925 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1370,7 +1370,8 @@ static int gswip_port_fdb(struct dsa_switch *ds, int port,
 	}
 
 	if (fid == -1) {
-		dev_err(priv->dev, "Port not part of a bridge\n");
+		dev_err(priv->dev, "no FID found for bridge %s\n",
+			bridge->name);
 		return -EINVAL;
 	}
 
-- 
2.39.2


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

* Re: [PATCH net-next v3 03/12] net: dsa: lantiq_gswip: add terminating \n where missing
  2024-06-10 14:02 ` [PATCH net-next v3 03/12] net: dsa: lantiq_gswip: add terminating \n where missing Martin Schiller
@ 2024-06-10 21:46   ` Andrew Lunn
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Lunn @ 2024-06-10 21:46 UTC (permalink / raw)
  To: Martin Schiller
  Cc: martin.blumenstingl, hauke, f.fainelli, olteanv, davem, edumazet,
	kuba, pabeni, robh, krzk+dt, conor+dt, netdev, devicetree,
	linux-kernel

On Mon, Jun 10, 2024 at 04:02:10PM +0200, Martin Schiller wrote:
> Some dev_err are missing the terminating \n. Let's add that.
> 
> Suggested-by: Vladimir Oltean <olteanv@gmail.com>
> Signed-off-by: Martin Schiller <ms@dev.tdt.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

end of thread, other threads:[~2024-06-10 21:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10 14:02 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: code improvements Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 01/12] dt-bindings: net: dsa: lantiq_gswip: Add missing CPU port phy-mode and fixed-link to example Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 02/12] net: dsa: lantiq_gswip: Only allow phy-mode = "internal" on the CPU port Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 03/12] net: dsa: lantiq_gswip: add terminating \n where missing Martin Schiller
2024-06-10 21:46   ` Andrew Lunn
2024-06-10 14:02 ` [PATCH net-next v3 04/12] net: dsa: lantiq_gswip: Use dev_err_probe where appropriate Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 05/12] net: dsa: lantiq_gswip: Don't manually call gswip_port_enable() Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 06/12] net: dsa: lantiq_gswip: do also enable or disable cpu port Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 07/12] net: dsa: lantiq_gswip: Use dsa_is_cpu_port() in gswip_port_change_mtu() Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 08/12] net: dsa: lantiq_gswip: Change literal 6 to ETH_ALEN Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 09/12] net: dsa: lantiq_gswip: Consistently use macros for the mac bridge table Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 10/12] net: dsa: lantiq_gswip: Remove dead code from gswip_add_single_port_br() Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 11/12] net: dsa: lantiq_gswip: Update comments in gswip_port_vlan_filtering() Martin Schiller
2024-06-10 14:02 ` [PATCH net-next v3 12/12] net: dsa: lantiq_gswip: Improve error message in gswip_port_fdb() Martin Schiller

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).