Commit fc1273af authored by Elad Raz's avatar Elad Raz Committed by David S. Miller

mlxsw: Remember untagged VLANs

When a vlan is been configured, remeber the untagged mode of the vlan.
When displaying the list of configured VLANs, show the untagged attribute.
Signed-off-by: default avatarElad Raz <eladr@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 26a4ea0f
...@@ -1370,6 +1370,11 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -1370,6 +1370,11 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
err = -ENOMEM; err = -ENOMEM;
goto err_port_active_vlans_alloc; goto err_port_active_vlans_alloc;
} }
mlxsw_sp_port->untagged_vlans = kzalloc(bytes, GFP_KERNEL);
if (!mlxsw_sp_port->untagged_vlans) {
err = -ENOMEM;
goto err_port_untagged_vlans_alloc;
}
INIT_LIST_HEAD(&mlxsw_sp_port->vports_list); INIT_LIST_HEAD(&mlxsw_sp_port->vports_list);
mlxsw_sp_port->pcpu_stats = mlxsw_sp_port->pcpu_stats =
...@@ -1472,6 +1477,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -1472,6 +1477,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
err_dev_addr_init: err_dev_addr_init:
free_percpu(mlxsw_sp_port->pcpu_stats); free_percpu(mlxsw_sp_port->pcpu_stats);
err_alloc_stats: err_alloc_stats:
kfree(mlxsw_sp_port->untagged_vlans);
err_port_untagged_vlans_alloc:
kfree(mlxsw_sp_port->active_vlans); kfree(mlxsw_sp_port->active_vlans);
err_port_active_vlans_alloc: err_port_active_vlans_alloc:
free_netdev(dev); free_netdev(dev);
...@@ -1505,6 +1512,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -1505,6 +1512,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
mlxsw_sp_port_vports_fini(mlxsw_sp_port); mlxsw_sp_port_vports_fini(mlxsw_sp_port);
mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
free_percpu(mlxsw_sp_port->pcpu_stats); free_percpu(mlxsw_sp_port->pcpu_stats);
kfree(mlxsw_sp_port->untagged_vlans);
kfree(mlxsw_sp_port->active_vlans); kfree(mlxsw_sp_port->active_vlans);
free_netdev(mlxsw_sp_port->dev); free_netdev(mlxsw_sp_port->dev);
} }
......
...@@ -144,6 +144,7 @@ struct mlxsw_sp_port { ...@@ -144,6 +144,7 @@ struct mlxsw_sp_port {
} vport; } vport;
/* 802.1Q bridge VLANs */ /* 802.1Q bridge VLANs */
unsigned long *active_vlans; unsigned long *active_vlans;
unsigned long *untagged_vlans;
/* VLAN interfaces */ /* VLAN interfaces */
struct list_head vports_list; struct list_head vports_list;
}; };
......
...@@ -526,8 +526,13 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -526,8 +526,13 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
} }
/* Changing activity bits only if HW operation succeded */ /* Changing activity bits only if HW operation succeded */
for (vid = vid_begin; vid <= vid_end; vid++) for (vid = vid_begin; vid <= vid_end; vid++) {
set_bit(vid, mlxsw_sp_port->active_vlans); set_bit(vid, mlxsw_sp_port->active_vlans);
if (flag_untagged)
set_bit(vid, mlxsw_sp_port->untagged_vlans);
else
clear_bit(vid, mlxsw_sp_port->untagged_vlans);
}
/* STP state change must be done after we set active VLANs */ /* STP state change must be done after we set active VLANs */
err = mlxsw_sp_port_stp_state_set(mlxsw_sp_port, err = mlxsw_sp_port_stp_state_set(mlxsw_sp_port,
...@@ -954,6 +959,8 @@ static int mlxsw_sp_port_vlan_dump(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -954,6 +959,8 @@ static int mlxsw_sp_port_vlan_dump(struct mlxsw_sp_port *mlxsw_sp_port,
vlan->flags = 0; vlan->flags = 0;
if (vid == mlxsw_sp_port->pvid) if (vid == mlxsw_sp_port->pvid)
vlan->flags |= BRIDGE_VLAN_INFO_PVID; vlan->flags |= BRIDGE_VLAN_INFO_PVID;
if (test_bit(vid, mlxsw_sp_port->untagged_vlans))
vlan->flags |= BRIDGE_VLAN_INFO_UNTAGGED;
vlan->vid_begin = vid; vlan->vid_begin = vid;
vlan->vid_end = vid; vlan->vid_end = vid;
err = cb(&vlan->obj); err = cb(&vlan->obj);
......
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