Skip to content

Commit e4b6f69

Browse files
Elad Razdavem330
authored andcommitted
mlxsw: Adding VID to FID translatation
Adding a generic function that translate VID to FID. Signed-off-by: Elad Raz <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 53ae628 commit e4b6f69

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@
5151
#include "core.h"
5252
#include "reg.h"
5353

54+
static u16 mlxsw_sp_port_vid_to_fid_get(struct mlxsw_sp_port *mlxsw_sp_port,
55+
u16 vid)
56+
{
57+
u16 fid = vid;
58+
59+
if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) {
60+
u16 vfid = mlxsw_sp_vport_vfid_get(mlxsw_sp_port);
61+
62+
fid = mlxsw_sp_vfid_to_fid(vfid);
63+
}
64+
65+
if (!fid)
66+
fid = mlxsw_sp_port->pvid;
67+
68+
return fid;
69+
}
70+
5471
static struct mlxsw_sp_port *
5572
mlxsw_sp_port_orig_get(struct net_device *dev,
5673
struct mlxsw_sp_port *mlxsw_sp_port)
@@ -641,22 +658,16 @@ mlxsw_sp_port_fdb_static_add(struct mlxsw_sp_port *mlxsw_sp_port,
641658
const struct switchdev_obj_port_fdb *fdb,
642659
struct switchdev_trans *trans)
643660
{
644-
u16 fid = fdb->vid;
661+
u16 fid = mlxsw_sp_port_vid_to_fid_get(mlxsw_sp_port, fdb->vid);
645662
u16 lag_vid = 0;
646663

647664
if (switchdev_trans_ph_prepare(trans))
648665
return 0;
649666

650667
if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) {
651-
u16 vfid = mlxsw_sp_vport_vfid_get(mlxsw_sp_port);
652-
653-
fid = mlxsw_sp_vfid_to_fid(vfid);
654668
lag_vid = mlxsw_sp_vport_vid_get(mlxsw_sp_port);
655669
}
656670

657-
if (!fid)
658-
fid = mlxsw_sp_port->pvid;
659-
660671
if (!mlxsw_sp_port->lagged)
661672
return mlxsw_sp_port_fdb_uc_op(mlxsw_sp_port->mlxsw_sp,
662673
mlxsw_sp_port->local_port,
@@ -787,13 +798,10 @@ static int
787798
mlxsw_sp_port_fdb_static_del(struct mlxsw_sp_port *mlxsw_sp_port,
788799
const struct switchdev_obj_port_fdb *fdb)
789800
{
790-
u16 fid = fdb->vid;
801+
u16 fid = mlxsw_sp_port_vid_to_fid_get(mlxsw_sp_port, fdb->vid);
791802
u16 lag_vid = 0;
792803

793804
if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) {
794-
u16 vfid = mlxsw_sp_vport_vfid_get(mlxsw_sp_port);
795-
796-
fid = mlxsw_sp_vfid_to_fid(vfid);
797805
lag_vid = mlxsw_sp_vport_vid_get(mlxsw_sp_port);
798806
}
799807

0 commit comments

Comments
 (0)