diff mbox series

[v4,net-next,06/15] net: switchdev: guard drivers against multiple obj replays on same bridge port

Message ID 20210718214434.3938850-7-vladimir.oltean@nxp.com
State New
Headers show
Series Allow forwarding for the software bridge data path to be offloaded to capable devices | expand

Commit Message

Vladimir Oltean July 18, 2021, 9:44 p.m. UTC
Prepare the drivers which support LAG offload but don't have support for
switchdev object replay yet, i.e. the mlxsw and prestera drivers, to
deal with bridge switchdev objects being replayed on the LAG bridge port
multiple times, once for each time a physical port beneath the LAG calls
switchdev_bridge_port_offload().

Cc: Vadym Kochan <vkochan@marvell.com>
Cc: Taras Chornyi <tchornyi@marvell.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
v3->v4: squash mlxsw and prestera into a single patch

 drivers/net/ethernet/marvell/prestera/prestera_switchdev.c | 6 ++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c   | 6 ++++++
 2 files changed, 12 insertions(+)

Comments

Florian Fainelli July 19, 2021, 2:17 a.m. UTC | #1
On 7/18/2021 2:44 PM, Vladimir Oltean wrote:
> Prepare the drivers which support LAG offload but don't have support for
> switchdev object replay yet, i.e. the mlxsw and prestera drivers, to
> deal with bridge switchdev objects being replayed on the LAG bridge port
> multiple times, once for each time a physical port beneath the LAG calls
> switchdev_bridge_port_offload().
> 
> Cc: Vadym Kochan <vkochan@marvell.com>
> Cc: Taras Chornyi <tchornyi@marvell.com>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
index 0b3e8f2db294..a1fc4ab53ccf 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
@@ -1047,6 +1047,9 @@  static int prestera_port_obj_add(struct net_device *dev, const void *ctx,
 	struct prestera_port *port = netdev_priv(dev);
 	const struct switchdev_obj_port_vlan *vlan;
 
+	if (ctx && ctx != port)
+		return 0;
+
 	switch (obj->id) {
 	case SWITCHDEV_OBJ_ID_PORT_VLAN:
 		vlan = SWITCHDEV_OBJ_PORT_VLAN(obj);
@@ -1083,6 +1086,9 @@  static int prestera_port_obj_del(struct net_device *dev, const void *ctx,
 {
 	struct prestera_port *port = netdev_priv(dev);
 
+	if (ctx && ctx != port)
+		return 0;
+
 	switch (obj->id) {
 	case SWITCHDEV_OBJ_ID_PORT_VLAN:
 		return prestera_port_vlans_del(port, SWITCHDEV_OBJ_PORT_VLAN(obj));
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 61911fed6aeb..5a0c7c94874e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1772,6 +1772,9 @@  static int mlxsw_sp_port_obj_add(struct net_device *dev, const void *ctx,
 	const struct switchdev_obj_port_vlan *vlan;
 	int err = 0;
 
+	if (ctx && ctx != mlxsw_sp_port)
+		return 0;
+
 	switch (obj->id) {
 	case SWITCHDEV_OBJ_ID_PORT_VLAN:
 		vlan = SWITCHDEV_OBJ_PORT_VLAN(obj);
@@ -1920,6 +1923,9 @@  static int mlxsw_sp_port_obj_del(struct net_device *dev, const void *ctx,
 	struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
 	int err = 0;
 
+	if (ctx && ctx != mlxsw_sp_port)
+		return 0;
+
 	switch (obj->id) {
 	case SWITCHDEV_OBJ_ID_PORT_VLAN:
 		err = mlxsw_sp_port_vlans_del(mlxsw_sp_port,