netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: mrp: use stp state as substitute for unimplemented mrp state
@ 2021-01-18 18:13 Rasmus Villemoes
  2021-01-18 18:56 ` Horatiu Vultur
  0 siblings, 1 reply; 9+ messages in thread
From: Rasmus Villemoes @ 2021-01-18 18:13 UTC (permalink / raw)
  To: Roopa Prabhu, Nikolay Aleksandrov, David S. Miller, Jakub Kicinski
  Cc: Horatiu Vultur, Florian Fainelli, Vladimir Oltean, Andrew Lunn,
	Rasmus Villemoes, bridge, netdev, linux-kernel

When using MRP with hardware that does understand the concept of
blocked or forwarding ports, but not the full MRP offload, we
currently fail to tell the hardware what state it should put the port
in when the ring is closed - resulting in a ring of forwarding ports
and all the trouble that comes with that.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---

I don't really understand why SWITCHDEV_ATTR_ID_MRP_PORT_STATE even
has to exist seperately from SWITCHDEV_ATTR_ID_PORT_STP_STATE, and
it's hard to tell what the difference might be since no kernel code
implements the former.

 net/bridge/br_mrp_switchdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/net/bridge/br_mrp_switchdev.c b/net/bridge/br_mrp_switchdev.c
index ed547e03ace1..8a1c7953e57a 100644
--- a/net/bridge/br_mrp_switchdev.c
+++ b/net/bridge/br_mrp_switchdev.c
@@ -180,6 +180,24 @@ int br_mrp_port_switchdev_set_state(struct net_bridge_port *p,
 	int err;
 
 	err = switchdev_port_attr_set(p->dev, &attr);
+	if (err == -EOPNOTSUPP) {
+		attr.id = SWITCHDEV_ATTR_ID_PORT_STP_STATE;
+		switch (state) {
+		case BR_MRP_PORT_STATE_DISABLED:
+		case BR_MRP_PORT_STATE_NOT_CONNECTED:
+			attr.u.stp_state = BR_STATE_DISABLED;
+			break;
+		case BR_MRP_PORT_STATE_BLOCKED:
+			attr.u.stp_state = BR_STATE_BLOCKING;
+			break;
+		case BR_MRP_PORT_STATE_FORWARDING:
+			attr.u.stp_state = BR_STATE_FORWARDING;
+			break;
+		default:
+			return err;
+		};
+		err = switchdev_port_attr_set(p->dev, &attr);
+	}
 	if (err && err != -EOPNOTSUPP)
 		br_warn(p->br, "error setting offload MRP state on port %u(%s)\n",
 			(unsigned int)p->port_no, p->dev->name);
-- 
2.23.0


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

end of thread, other threads:[~2021-01-25 22:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 18:13 [PATCH net] net: mrp: use stp state as substitute for unimplemented mrp state Rasmus Villemoes
2021-01-18 18:56 ` Horatiu Vultur
2021-01-18 19:46   ` Vladimir Oltean
2021-01-18 20:20     ` Horatiu Vultur
2021-01-18 21:27       ` Vladimir Oltean
2021-01-19  8:32         ` Horatiu Vultur
2021-01-19 15:52           ` Andrew Lunn
2021-01-19 20:59             ` Horatiu Vultur
2021-01-25 21:36             ` 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).