Skip to content

Commit fc1273a

Browse files
Elad Razdavem330
authored andcommitted
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: Elad Raz <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 26a4ea0 commit fc1273a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,11 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
13701370
err = -ENOMEM;
13711371
goto err_port_active_vlans_alloc;
13721372
}
1373+
mlxsw_sp_port->untagged_vlans = kzalloc(bytes, GFP_KERNEL);
1374+
if (!mlxsw_sp_port->untagged_vlans) {
1375+
err = -ENOMEM;
1376+
goto err_port_untagged_vlans_alloc;
1377+
}
13731378
INIT_LIST_HEAD(&mlxsw_sp_port->vports_list);
13741379

13751380
mlxsw_sp_port->pcpu_stats =
@@ -1472,6 +1477,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port)
14721477
err_dev_addr_init:
14731478
free_percpu(mlxsw_sp_port->pcpu_stats);
14741479
err_alloc_stats:
1480+
kfree(mlxsw_sp_port->untagged_vlans);
1481+
err_port_untagged_vlans_alloc:
14751482
kfree(mlxsw_sp_port->active_vlans);
14761483
err_port_active_vlans_alloc:
14771484
free_netdev(dev);
@@ -1505,6 +1512,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
15051512
mlxsw_sp_port_vports_fini(mlxsw_sp_port);
15061513
mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
15071514
free_percpu(mlxsw_sp_port->pcpu_stats);
1515+
kfree(mlxsw_sp_port->untagged_vlans);
15081516
kfree(mlxsw_sp_port->active_vlans);
15091517
free_netdev(mlxsw_sp_port->dev);
15101518
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ struct mlxsw_sp_port {
144144
} vport;
145145
/* 802.1Q bridge VLANs */
146146
unsigned long *active_vlans;
147+
unsigned long *untagged_vlans;
147148
/* VLAN interfaces */
148149
struct list_head vports_list;
149150
};

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,13 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
526526
}
527527

528528
/* Changing activity bits only if HW operation succeded */
529-
for (vid = vid_begin; vid <= vid_end; vid++)
529+
for (vid = vid_begin; vid <= vid_end; vid++) {
530530
set_bit(vid, mlxsw_sp_port->active_vlans);
531+
if (flag_untagged)
532+
set_bit(vid, mlxsw_sp_port->untagged_vlans);
533+
else
534+
clear_bit(vid, mlxsw_sp_port->untagged_vlans);
535+
}
531536

532537
/* STP state change must be done after we set active VLANs */
533538
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,
954959
vlan->flags = 0;
955960
if (vid == mlxsw_sp_port->pvid)
956961
vlan->flags |= BRIDGE_VLAN_INFO_PVID;
962+
if (test_bit(vid, mlxsw_sp_port->untagged_vlans))
963+
vlan->flags |= BRIDGE_VLAN_INFO_UNTAGGED;
957964
vlan->vid_begin = vid;
958965
vlan->vid_end = vid;
959966
err = cb(&vlan->obj);

0 commit comments

Comments
 (0)