mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v1 1/3] net: dsa: Add global forwarding mode support
Date: Wed, 12 Mar 2025 12:20:55 +0100	[thread overview]
Message-ID: <20250312112057.570001-1-o.rempel@pengutronix.de> (raw)

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




             reply	other threads:[~2025-03-12 11:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12 11:20 Oleksij Rempel [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250312112057.570001-1-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox