Commit 45bfe6b4 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

mlxsw: spectrum_switchdev: Don't batch STP operations

Simplify the code by using the common function that sets an STP state
for a Port-VLAN and remove the existing one that tries to batch it for
several VLANs.

This will help us in a follow-up patchset to introduce a unified
infrastructure for bridge ports, regardless if the bridge is VLAN-aware
or not.
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fe9ccc78
...@@ -146,58 +146,33 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev, ...@@ -146,58 +146,33 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
return 0; return 0;
} }
static int mlxsw_sp_port_stp_state_set(struct mlxsw_sp_port *mlxsw_sp_port, static int mlxsw_sp_port_attr_stp_state_set(struct mlxsw_sp_port *mlxsw_sp_port,
struct switchdev_trans *trans,
u8 state) u8 state)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
enum mlxsw_reg_spms_state spms_state;
char *spms_pl;
u16 vid; u16 vid;
int err; int err;
switch (state) { if (switchdev_trans_ph_prepare(trans))
case BR_STATE_FORWARDING: return 0;
spms_state = MLXSW_REG_SPMS_STATE_FORWARDING;
break;
case BR_STATE_LEARNING:
spms_state = MLXSW_REG_SPMS_STATE_LEARNING;
break;
case BR_STATE_LISTENING: /* fall-through */
case BR_STATE_DISABLED: /* fall-through */
case BR_STATE_BLOCKING:
spms_state = MLXSW_REG_SPMS_STATE_DISCARDING;
break;
default:
BUG();
}
spms_pl = kmalloc(MLXSW_REG_SPMS_LEN, GFP_KERNEL);
if (!spms_pl)
return -ENOMEM;
mlxsw_reg_spms_pack(spms_pl, mlxsw_sp_port->local_port);
if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) { if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) {
vid = mlxsw_sp_vport_vid_get(mlxsw_sp_port); vid = mlxsw_sp_vport_vid_get(mlxsw_sp_port);
mlxsw_reg_spms_vid_pack(spms_pl, vid, spms_state); err = mlxsw_sp_port_vid_stp_set(mlxsw_sp_port, vid, state);
} else { if (err)
for_each_set_bit(vid, mlxsw_sp_port->active_vlans, VLAN_N_VID) return err;
mlxsw_reg_spms_vid_pack(spms_pl, vid, spms_state); mlxsw_sp_port->stp_state = state;
return 0;
} }
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spms), spms_pl); for_each_set_bit(vid, mlxsw_sp_port->active_vlans, VLAN_N_VID) {
kfree(spms_pl); err = mlxsw_sp_port_vid_stp_set(mlxsw_sp_port, vid, state);
if (err)
return err; return err;
} }
mlxsw_sp_port->stp_state = state;
static int mlxsw_sp_port_attr_stp_state_set(struct mlxsw_sp_port *mlxsw_sp_port,
struct switchdev_trans *trans,
u8 state)
{
if (switchdev_trans_ph_prepare(trans))
return 0; return 0;
mlxsw_sp_port->stp_state = state;
return mlxsw_sp_port_stp_state_set(mlxsw_sp_port, state);
} }
static int __mlxsw_sp_port_flood_table_set(struct mlxsw_sp_port *mlxsw_sp_port, static int __mlxsw_sp_port_flood_table_set(struct mlxsw_sp_port *mlxsw_sp_port,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment