lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231122112006.255811-1-rasmus.villemoes@prevas.dk>
Date: Wed, 22 Nov 2023 12:20:06 +0100
From: Rasmus Villemoes <rasmus.villemoes@...vas.dk>
To: Woojung Huh <woojung.huh@...rochip.com>,
	UNGLinuxDriver@...rochip.com,
	Andrew Lunn <andrew@...n.ch>,
	Florian Fainelli <f.fainelli@...il.com>,
	Vladimir Oltean <olteanv@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org,
	Per Noergaard Christensen <per.christensen@...vas.dk>,
	Rasmus Villemoes <rasmus.villemoes@...vas.dk>
Subject: [PATCH net-next] net: dsa: microchip: add MRP software ring support

From: Per Noergaard Christensen <per.christensen@...vas.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@...vas.dk>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@...vas.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ