Skip to content

Commit ed9ddd3

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum: Don't create FIDs upon creation of VLAN uppers
Up until now we used to create FIDs upon the creation of VLAN uppers on top of the VLAN-aware bridge. This was done so that in case a router interface (RIF) was configured on top of the bridge, the FID would already be there. Instead, simplify the code and only create the FID upon RIF creation. This is an intermediary step towards the introduction of the common FID core, in which this code would be completely removed. Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f0cebd8 commit ed9ddd3

File tree

2 files changed

+13
-98
lines changed

2 files changed

+13
-98
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3982,17 +3982,6 @@ int mlxsw_sp_port_fdb_flush(struct mlxsw_sp_port *mlxsw_sp_port, u16 fid)
39823982
return mlxsw_sp_port_fdb_flush_by_port_fid(mlxsw_sp_port, fid);
39833983
}
39843984

3985-
static void mlxsw_sp_master_bridge_gone_sync(struct mlxsw_sp *mlxsw_sp)
3986-
{
3987-
struct mlxsw_sp_fid *f, *tmp;
3988-
3989-
list_for_each_entry_safe(f, tmp, &mlxsw_sp->fids, list)
3990-
if (--f->ref_count == 0)
3991-
mlxsw_sp_fid_destroy(mlxsw_sp, f);
3992-
else
3993-
WARN_ON_ONCE(1);
3994-
}
3995-
39963985
static bool mlxsw_sp_master_bridge_check(struct mlxsw_sp *mlxsw_sp,
39973986
struct net_device *br_dev)
39983987
{
@@ -4014,15 +4003,8 @@ static void mlxsw_sp_master_bridge_dec(struct mlxsw_sp *mlxsw_sp)
40144003
{
40154004
struct mlxsw_sp_upper *master_bridge = mlxsw_sp_master_bridge(mlxsw_sp);
40164005

4017-
if (--master_bridge->ref_count == 0) {
4006+
if (--master_bridge->ref_count == 0)
40184007
master_bridge->dev = NULL;
4019-
/* It's possible upper VLAN devices are still holding
4020-
* references to underlying FIDs. Drop the reference
4021-
* and release the resources if it was the last one.
4022-
* If it wasn't, then something bad happened.
4023-
*/
4024-
mlxsw_sp_master_bridge_gone_sync(mlxsw_sp);
4025-
}
40264008
}
40274009

40284010
static int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port,
@@ -4584,79 +4566,6 @@ static int mlxsw_sp_netdevice_lag_event(struct net_device *lag_dev,
45844566
return 0;
45854567
}
45864568

4587-
static int mlxsw_sp_master_bridge_vlan_link(struct mlxsw_sp *mlxsw_sp,
4588-
struct net_device *vlan_dev)
4589-
{
4590-
u16 fid = vlan_dev_vlan_id(vlan_dev);
4591-
struct mlxsw_sp_fid *f;
4592-
4593-
f = mlxsw_sp_fid_find(mlxsw_sp, fid);
4594-
if (!f) {
4595-
f = mlxsw_sp_fid_create(mlxsw_sp, fid);
4596-
if (IS_ERR(f))
4597-
return PTR_ERR(f);
4598-
}
4599-
4600-
f->ref_count++;
4601-
4602-
return 0;
4603-
}
4604-
4605-
static void mlxsw_sp_master_bridge_vlan_unlink(struct mlxsw_sp *mlxsw_sp,
4606-
struct net_device *vlan_dev)
4607-
{
4608-
u16 fid = vlan_dev_vlan_id(vlan_dev);
4609-
struct mlxsw_sp_fid *f;
4610-
4611-
f = mlxsw_sp_fid_find(mlxsw_sp, fid);
4612-
if (f && f->rif)
4613-
mlxsw_sp_rif_bridge_destroy(mlxsw_sp, f->rif);
4614-
if (f && --f->ref_count == 0)
4615-
mlxsw_sp_fid_destroy(mlxsw_sp, f);
4616-
}
4617-
4618-
static int mlxsw_sp_netdevice_bridge_event(struct net_device *br_dev,
4619-
unsigned long event, void *ptr)
4620-
{
4621-
struct netdev_notifier_changeupper_info *info;
4622-
struct net_device *upper_dev;
4623-
struct mlxsw_sp *mlxsw_sp;
4624-
int err = 0;
4625-
4626-
mlxsw_sp = mlxsw_sp_lower_get(br_dev);
4627-
if (!mlxsw_sp)
4628-
return 0;
4629-
4630-
info = ptr;
4631-
4632-
switch (event) {
4633-
case NETDEV_PRECHANGEUPPER:
4634-
upper_dev = info->upper_dev;
4635-
if (!is_vlan_dev(upper_dev))
4636-
return -EINVAL;
4637-
if (is_vlan_dev(upper_dev) &&
4638-
br_dev != mlxsw_sp_master_bridge(mlxsw_sp)->dev)
4639-
return -EINVAL;
4640-
break;
4641-
case NETDEV_CHANGEUPPER:
4642-
upper_dev = info->upper_dev;
4643-
if (is_vlan_dev(upper_dev)) {
4644-
if (info->linking)
4645-
err = mlxsw_sp_master_bridge_vlan_link(mlxsw_sp,
4646-
upper_dev);
4647-
else
4648-
mlxsw_sp_master_bridge_vlan_unlink(mlxsw_sp,
4649-
upper_dev);
4650-
} else {
4651-
err = -EINVAL;
4652-
WARN_ON(1);
4653-
}
4654-
break;
4655-
}
4656-
4657-
return err;
4658-
}
4659-
46604569
static u16 mlxsw_sp_avail_vfid_get(const struct mlxsw_sp *mlxsw_sp)
46614570
{
46624571
return find_first_zero_bit(mlxsw_sp->vfids.mapped,
@@ -5012,8 +4921,6 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *unused,
50124921
err = mlxsw_sp_netdevice_port_event(dev, dev, event, ptr);
50134922
else if (netif_is_lag_master(dev))
50144923
err = mlxsw_sp_netdevice_lag_event(dev, event, ptr);
5015-
else if (netif_is_bridge_master(dev))
5016-
err = mlxsw_sp_netdevice_bridge_event(dev, event, ptr);
50174924
else if (is_vlan_dev(dev))
50184925
err = mlxsw_sp_netdevice_vlan_event(dev, event, ptr);
50194926

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,16 +3239,24 @@ static int mlxsw_sp_inetaddr_lag_event(struct net_device *lag_dev,
32393239
static struct mlxsw_sp_fid *mlxsw_sp_bridge_fid_get(struct mlxsw_sp *mlxsw_sp,
32403240
struct net_device *l3_dev)
32413241
{
3242-
u16 fid;
3242+
struct mlxsw_sp_fid *fid;
3243+
u16 fid_index;
32433244

32443245
if (is_vlan_dev(l3_dev))
3245-
fid = vlan_dev_vlan_id(l3_dev);
3246+
fid_index = vlan_dev_vlan_id(l3_dev);
32463247
else if (mlxsw_sp_master_bridge(mlxsw_sp)->dev == l3_dev)
3247-
fid = 1;
3248+
fid_index = 1;
32483249
else
32493250
return mlxsw_sp_vfid_find(mlxsw_sp, l3_dev);
32503251

3251-
return mlxsw_sp_fid_find(mlxsw_sp, fid);
3252+
fid = mlxsw_sp_fid_find(mlxsw_sp, fid_index);
3253+
if (fid)
3254+
return fid;
3255+
3256+
fid = mlxsw_sp_fid_create(mlxsw_sp, fid_index);
3257+
if (IS_ERR(fid))
3258+
return NULL;
3259+
return fid;
32523260
}
32533261

32543262
static u8 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp)

0 commit comments

Comments
 (0)