netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: microchip: add MRP software ring support
@ 2023-11-22 11:20 Rasmus Villemoes
  2023-11-22 11:35 ` Vladimir Oltean
  0 siblings, 1 reply; 4+ messages in thread
From: Rasmus Villemoes @ 2023-11-22 11:20 UTC (permalink / raw)
  To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Florian Fainelli,
	Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: netdev, Per Noergaard Christensen, Rasmus Villemoes

From: Per Noergaard Christensen <per.christensen@prevas.dk>

Add dummy functions that tells the MRP bridge instance to use
implemented software routines instead of hardware-offloading.

Signed-off-by: Per Noergaard Christensen <per.christensen@prevas.dk>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/net/dsa/microchip/ksz_common.c | 55 ++++++++++++++++++++++++++
 drivers/net/dsa/microchip/ksz_common.h |  1 +
 2 files changed, 56 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 3fed406fb46a..b0935997dc05 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -3566,6 +3566,57 @@ static int ksz_set_wol(struct dsa_switch *ds, int port,
 	return -EOPNOTSUPP;
 }
 
+static int ksz_port_mrp_add(struct dsa_switch *ds, int port,
+			    const struct switchdev_obj_mrp *mrp)
+{
+	struct dsa_port *dp = dsa_to_port(ds, port);
+	struct ksz_device *dev = ds->priv;
+
+	/* port different from requested mrp ports */
+	if (mrp->p_port != dp->user && mrp->s_port != dp->user)
+		return -EOPNOTSUPP;
+
+	/* save ring id */
+	dev->ports[port].mrp_ring_id = mrp->ring_id;
+	return 0;
+}
+
+static int ksz_port_mrp_del(struct dsa_switch *ds, int port,
+			    const struct switchdev_obj_mrp *mrp)
+{
+	struct ksz_device *dev = ds->priv;
+
+	/* check if port not part of ring id */
+	if (mrp->ring_id != dev->ports[port].mrp_ring_id)
+		return -EOPNOTSUPP;
+
+	/* clear ring id */
+	dev->ports[port].mrp_ring_id = 0;
+	return 0;
+}
+
+static int ksz_port_mrp_add_ring_role(struct dsa_switch *ds, int port,
+				      const struct switchdev_obj_ring_role_mrp *mrp)
+{
+	struct ksz_device *dev = ds->priv;
+
+	if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
+		return 0;
+
+	return -EOPNOTSUPP;
+}
+
+static int ksz_port_mrp_del_ring_role(struct dsa_switch *ds, int port,
+				      const struct switchdev_obj_ring_role_mrp *mrp)
+{
+	struct ksz_device *dev = ds->priv;
+
+	if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
+		return 0;
+
+	return -EOPNOTSUPP;
+}
+
 static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
 				    const unsigned char *addr)
 {
@@ -3799,6 +3850,10 @@ static const struct dsa_switch_ops ksz_switch_ops = {
 	.port_fdb_del		= ksz_port_fdb_del,
 	.port_mdb_add           = ksz_port_mdb_add,
 	.port_mdb_del           = ksz_port_mdb_del,
+	.port_mrp_add		= ksz_port_mrp_add,
+	.port_mrp_del		= ksz_port_mrp_del,
+	.port_mrp_add_ring_role	= ksz_port_mrp_add_ring_role,
+	.port_mrp_del_ring_role	= ksz_port_mrp_del_ring_role,
 	.port_mirror_add	= ksz_port_mirror_add,
 	.port_mirror_del	= ksz_port_mirror_del,
 	.get_stats64		= ksz_get_stats64,
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index b7e8a403a132..24015f0a9c98 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -110,6 +110,7 @@ struct ksz_port {
 	bool remove_tag;		/* Remove Tag flag set, for ksz8795 only */
 	bool learning;
 	int stp_state;
+	u32 mrp_ring_id;
 	struct phy_device phydev;
 
 	u32 fiber:1;			/* port is fiber */
-- 
2.40.1.1.g1c60b9335d


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

end of thread, other threads:[~2023-11-24  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-22 11:20 [PATCH net-next] net: dsa: microchip: add MRP software ring support Rasmus Villemoes
2023-11-22 11:35 ` Vladimir Oltean
2023-11-22 13:28   ` Horatiu Vultur
2023-11-24  8:28   ` Rasmus Villemoes

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