Skip to contentSkip to conversation

net: bridge: switchdev: allow port isolation to be offloaded

PATCH In review DENG Qingfang 3 participants 7 messages Aug 11, 2021 – Aug 12, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: bridge: switchdev: allow port isolation to be offloaded

Add BR_ISOLATED flag to BR_PORT_FLAGS_HW_OFFLOAD, to allow switchdev drivers to offload port isolation.

---
 net/bridge/br_switchdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/br_switchdev.c +2 -1
index 6bf518d78f02..898257153883 100644
@@ -71,7 +71,8 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
 
 /* Flags that can be offloaded to hardware */
 #define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \
-				  BR_MCAST_FLOOD | BR_BCAST_FLOOD)
+				  BR_MCAST_FLOOD | BR_BCAST_FLOOD | \
+				  BR_ISOLATED)
 
 int br_switchdev_set_port_flag(struct net_bridge_port *p,
 			       unsigned long flags,
Signature · 1 line
2.25.1
#1 lore raw
Quoted 14 lines · DENG Qingfang

Add BR_ISOLATED flag to BR_PORT_FLAGS_HW_OFFLOAD, to allow switchdev drivers to offload port isolation.

---
 net/bridge/br_switchdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/br_switchdev.c +0 -0
index 6bf518d78f02..898257153883 100644

net/bridge/br_switchdev.c bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, · line 75

Quoted 6 lines
net/bridge/br_switchdev.c +2 -1
@@ -71,7 +71,8 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
 
 /* Flags that can be offloaded to hardware */
 #define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \
-				  BR_MCAST_FLOOD | BR_BCAST_FLOOD)
+				  BR_MCAST_FLOOD | BR_BCAST_FLOOD | \
+				  BR_ISOLATED)

Why add it now and not as part of a patchset that actually makes use of the flag in a driver that offloads port isolation?

Quoted 6 lines
net/bridge/br_switchdev.c +0 -0
 int br_switchdev_set_port_flag(struct net_bridge_port *p,
 			       unsigned long flags,
Signature · 1 line
2.25.1
#2 lore raw
Quoted 16 lines · Ido Schimmel
Quoted 15 lines · DENG Qingfang

Add BR_ISOLATED flag to BR_PORT_FLAGS_HW_OFFLOAD, to allow switchdev drivers to offload port isolation.

---
 net/bridge/br_switchdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/br_switchdev.c +0 -0
index 6bf518d78f02..898257153883 100644
@@ -71,7 +71,8 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
 
Quoted 8 lines

net/bridge/br_switchdev.c bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, · line 75

Quoted 5 lines
net/bridge/br_switchdev.c +2 -1
 /* Flags that can be offloaded to hardware */
 #define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \
-				  BR_MCAST_FLOOD | BR_BCAST_FLOOD)
+				  BR_MCAST_FLOOD | BR_BCAST_FLOOD | \
+				  BR_ISOLATED)

Why add it now and not as part of a patchset that actually makes use of the flag in a driver that offloads port isolation?

The way the information got transmitted is a bit unfortunate.

Making BR_ISOLATED part of BR_PORT_FLAGS_HW_OFFLOAD is a matter of correctness when switchdev offloads the data path. Since this feature will not work correctly without driver intervention, it makes sense that drivers should reject it currently, which is exactly what this patch accomplishes - it makes the code path go through the SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS driver handlers, which return -EINVAL for everything they don't recognize.

(yes, we do still have a problem for drivers that don't catch SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS at all, switchdev will return -EOPNOTSUPP for those which is then ignored, but those are in the minority)

#3 lore raw
Quoted 28 lines · Vladimir Oltean
Quoted 16 lines · Ido Schimmel
Quoted 15 lines · DENG Qingfang

Add BR_ISOLATED flag to BR_PORT_FLAGS_HW_OFFLOAD, to allow switchdev drivers to offload port isolation.

---
 net/bridge/br_switchdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/br_switchdev.c +0 -0
index 6bf518d78f02..898257153883 100644
@@ -71,7 +71,8 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
 
Quoted 8 lines

net/bridge/br_switchdev.c bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, · line 75

Quoted 5 lines
net/bridge/br_switchdev.c +2 -1
 /* Flags that can be offloaded to hardware */
 #define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \
-				  BR_MCAST_FLOOD | BR_BCAST_FLOOD)
+				  BR_MCAST_FLOOD | BR_BCAST_FLOOD | \
+				  BR_ISOLATED)

Why add it now and not as part of a patchset that actually makes use of the flag in a driver that offloads port isolation?

The way the information got transmitted is a bit unfortunate.

Quoted 7 lines

Making BR_ISOLATED part of BR_PORT_FLAGS_HW_OFFLOAD is a matter of correctness when switchdev offloads the data path. Since this feature will not work correctly without driver intervention, it makes sense that drivers should reject it currently, which is exactly what this patch accomplishes - it makes the code path go through the SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS driver handlers, which return -EINVAL for everything they don't recognize.

If the purpose is correctness, then this is not the only flag that was missed. BR_HAIRPIN_MODE is also relevant for the data path, for example.

Anyway, the commit message needs to be reworded to reflect the true purpose of the patch.

Quoted 5 lines

(yes, we do still have a problem for drivers that don't catch SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS at all, switchdev will return -EOPNOTSUPP for those which is then ignored, but those are in the minority)

#4 lore raw
Quoted 37 lines · Ido Schimmel
Quoted 28 lines · Vladimir Oltean
Quoted 16 lines · Ido Schimmel
Quoted 15 lines · DENG Qingfang

Add BR_ISOLATED flag to BR_PORT_FLAGS_HW_OFFLOAD, to allow switchdev drivers to offload port isolation.

---
 net/bridge/br_switchdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/br_switchdev.c +0 -0
index 6bf518d78f02..898257153883 100644
@@ -71,7 +71,8 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
 
Quoted 8 lines

net/bridge/br_switchdev.c bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, · line 75

Quoted 5 lines
net/bridge/br_switchdev.c +2 -1
 /* Flags that can be offloaded to hardware */
 #define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \
-				  BR_MCAST_FLOOD | BR_BCAST_FLOOD)
+				  BR_MCAST_FLOOD | BR_BCAST_FLOOD | \
+				  BR_ISOLATED)

Why add it now and not as part of a patchset that actually makes use of the flag in a driver that offloads port isolation?

The way the information got transmitted is a bit unfortunate.

Quoted 7 lines

Making BR_ISOLATED part of BR_PORT_FLAGS_HW_OFFLOAD is a matter of correctness when switchdev offloads the data path. Since this feature will not work correctly without driver intervention, it makes sense that drivers should reject it currently, which is exactly what this patch accomplishes - it makes the code path go through the SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS driver handlers, which return -EINVAL for everything they don't recognize.

Quoted 2 lines

If the purpose is correctness, then this is not the only flag that was missed. BR_HAIRPIN_MODE is also relevant for the data path, for example.

I never wanted to suggest that I'm giving a comprehensive answer, I just answered Qingfang's punctual question here:
https://lore.kernel.org/netdev/CALW65jbotyW0MSOd-bd1TH_mkiBWhhRCQ29jgn+d12rXdj2pZA@mail.gmail.com/

Tobias also pointed out the same issue about BR_MULTICAST_TO_UNICAST in conjunction with tx_fwd_offload (although the same is probably true even without it):
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

Quoted 2 lines

Anyway, the commit message needs to be reworded to reflect the true purpose of the patch.

Agree, and potentially extended with all the bridge port flags which are broken without switchdev driver intervention.

#5 lore raw
Quoted 14 lines · Vladimir Oltean
Quoted 3 lines · Ido Schimmel

If the purpose is correctness, then this is not the only flag that was missed. BR_HAIRPIN_MODE is also relevant for the data path, for example.

I never wanted to suggest that I'm giving a comprehensive answer, I just answered Qingfang's punctual question here:
https://lore.kernel.org/netdev/CALW65jbotyW0MSOd-bd1TH_mkiBWhhRCQ29jgn+d12rXdj2pZA@mail.gmail.com/

Tobias also pointed out the same issue about BR_MULTICAST_TO_UNICAST in conjunction with tx_fwd_offload (although the same is probably true even without it):
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

Quoted 5 lines
Quoted 2 lines

Anyway, the commit message needs to be reworded to reflect the true purpose of the patch.

Agree, and potentially extended with all the bridge port flags which are broken without switchdev driver intervention.

So, what else flags should be added to BR_PORT_FLAGS_HW_OFFLOAD?

#6 lore raw
Quoted 15 lines · DENG Qingfang
Quoted 14 lines · Vladimir Oltean
Quoted 3 lines · Ido Schimmel

If the purpose is correctness, then this is not the only flag that was missed. BR_HAIRPIN_MODE is also relevant for the data path, for example.

I never wanted to suggest that I'm giving a comprehensive answer, I just answered Qingfang's punctual question here:
https://lore.kernel.org/netdev/CALW65jbotyW0MSOd-bd1TH_mkiBWhhRCQ29jgn+d12rXdj2pZA@mail.gmail.com/

Tobias also pointed out the same issue about BR_MULTICAST_TO_UNICAST in conjunction with tx_fwd_offload (although the same is probably true even without it):
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Anyway, the commit message needs to be reworded to reflect the true purpose of the patch.

Agree, and potentially extended with all the bridge port flags which are broken without switchdev driver intervention.

So, what else flags should be added to BR_PORT_FLAGS_HW_OFFLOAD?

I can't think of others beside these 3, BR_ISOLATED, BR_HAIRPIN_MODE and BR_MULTICAST_TO_UNICAST.