mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v1 1/3] net: dsa: Add global forwarding mode support
@ 2025-03-12 11:20 Oleksij Rempel
  2025-03-12 11:20 ` [PATCH v1 2/3] Documentation: networking: Add DSA switch support documentation Oleksij Rempel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Oleksij Rempel @ 2025-03-12 11:20 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel

This patch introduces a global forwarding mode control for DSA switches
in Barebox.  It adds a new `forwarding` parameter that allows enabling
or disabling forwarding  between all ports on a DSA switch.

This enables users to configure global forwarding dynamically via:
dev.switch0.forwarding=1  # Enable forwarding
dev.switch0.forwarding=0  # Disable forwarding (isolated mode)

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa.c | 12 ++++++++++++
 include/dsa.h     |  4 ++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
index a451a1a35e8b..537e9dd72ac6 100644
--- a/drivers/net/dsa.c
+++ b/drivers/net/dsa.c
@@ -4,6 +4,7 @@
 #include <dma.h>
 #include <dsa.h>
 #include <of_net.h>
+#include <param.h>
 
 u32 dsa_user_ports(struct dsa_switch *ds)
 {
@@ -431,6 +432,13 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 	return ret;
 }
 
+static int dsa_set_forwarding(struct param_d *p, void *priv)
+{
+	struct dsa_switch *ds = priv;
+
+	return ds->ops->set_forwarding(ds, ds->forwarding_enable);
+}
+
 int dsa_register_switch(struct dsa_switch *ds)
 {
 	int ret;
@@ -448,6 +456,10 @@ int dsa_register_switch(struct dsa_switch *ds)
 		return -EINVAL;
 	}
 
+	if (ds->ops->set_forwarding)
+		dev_add_param_bool(ds->dev, "forwarding", dsa_set_forwarding,
+				   NULL, &ds->forwarding_enable, ds);
+
 	ret = dsa_switch_parse_ports_of(ds, ds->dev->of_node);
 	if (ret)
 		return ret;
diff --git a/include/dsa.h b/include/dsa.h
index 527941c26949..ecf7c4f429f3 100644
--- a/include/dsa.h
+++ b/include/dsa.h
@@ -56,6 +56,9 @@ struct dsa_switch_ops {
 	int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
 	int (*phy_write)(struct dsa_switch *ds, int port, int regnum, u16 val);
 	void (*adjust_link)(struct eth_device *dev);
+
+	/* enable/disable forwarding between all ports on the switch */
+	int (*set_forwarding)(struct dsa_switch *ds, bool enable);
 };
 
 struct dsa_port {
@@ -84,6 +87,7 @@ struct dsa_switch {
 	struct mii_bus *slave_mii_bus;
 	u32 phys_mii_mask;
 	void *priv;
+	u32 forwarding_enable;
 };
 
 static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
-- 
2.39.5




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

end of thread, other threads:[~2025-03-14 16:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-12 11:20 [PATCH v1 1/3] net: dsa: Add global forwarding mode support Oleksij Rempel
2025-03-12 11:20 ` [PATCH v1 2/3] Documentation: networking: Add DSA switch support documentation Oleksij Rempel
2025-03-12 11:20 ` [PATCH v1 3/3] net: dsa: sja1105: Add support for global forwarding mode Oleksij Rempel
2025-03-14 16:13 ` [PATCH v1 1/3] net: dsa: Add global forwarding mode support Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox