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

mlxsw: spectrum: Make vFID struct generic

Up until now we had a dedicated struct only for vFIDs, but before
introducing support for L3 interfaces we need to make it generic and
use it for all three types of FIDs:

1) FIDs - 0..4K-1, used for the VLAN-aware bridge
2) vFIDs - 4K..15K-1, used for VLAN-unaware bridges
3) rFIDs - 15K..16K-1, used to direct traffic to / from the router in
the device. Will be introduced later in the series.

The three types of L3 interfaces - Router InterFaces, RIFs - that will
be introduced correspond to the three types of FIDs and are configured
using them. Therefore, we'll need to store the links between them as
well as a reference count on the underlying FID, so that the
corresponding RIF will be destroyed when it reaches zero.

Note that the lower 0.5K vFIDs are currently used for for non-bridged
netdevs, so that traffic could be flooded to the CPU port. However, when
rFIDs will be introduced we'll no longer need these and they too will be
used for VLAN-unaware bridges.

Make the vFID struct generic by renaming it and some of its fields. FIDs
will be converted to use it later in the series.
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 e6060027
...@@ -87,11 +87,11 @@ struct mlxsw_sp_upper { ...@@ -87,11 +87,11 @@ struct mlxsw_sp_upper {
unsigned int ref_count; unsigned int ref_count;
}; };
struct mlxsw_sp_vfid { struct mlxsw_sp_fid {
struct list_head list; struct list_head list;
u16 nr_vports; unsigned int ref_count;
u16 vfid; /* Starting at 0 */ struct net_device *dev;
struct net_device *br_dev; u16 fid;
u16 vid; u16 vid;
}; };
...@@ -217,7 +217,7 @@ struct mlxsw_sp_port { ...@@ -217,7 +217,7 @@ struct mlxsw_sp_port {
u16 lag_id; u16 lag_id;
struct { struct {
struct list_head list; struct list_head list;
struct mlxsw_sp_vfid *vfid; struct mlxsw_sp_fid *f;
u16 vid; u16 vid;
} vport; } vport;
struct { struct {
...@@ -262,13 +262,13 @@ mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index) ...@@ -262,13 +262,13 @@ mlxsw_sp_port_lagged_get(struct mlxsw_sp *mlxsw_sp, u16 lag_id, u8 port_index)
static inline bool static inline bool
mlxsw_sp_port_is_vport(const struct mlxsw_sp_port *mlxsw_sp_port) mlxsw_sp_port_is_vport(const struct mlxsw_sp_port *mlxsw_sp_port)
{ {
return mlxsw_sp_port->vport.vfid; return mlxsw_sp_port->vport.f;
} }
static inline struct net_device * static inline struct net_device *
mlxsw_sp_vport_br_get(const struct mlxsw_sp_port *mlxsw_sp_vport) mlxsw_sp_vport_br_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
{ {
return mlxsw_sp_vport->vport.vfid->br_dev; return mlxsw_sp_vport->vport.f->dev;
} }
static inline u16 static inline u16
...@@ -278,9 +278,9 @@ mlxsw_sp_vport_vid_get(const struct mlxsw_sp_port *mlxsw_sp_vport) ...@@ -278,9 +278,9 @@ mlxsw_sp_vport_vid_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
} }
static inline u16 static inline u16
mlxsw_sp_vport_vfid_get(const struct mlxsw_sp_port *mlxsw_sp_vport) mlxsw_sp_vport_fid_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
{ {
return mlxsw_sp_vport->vport.vfid->vfid; return mlxsw_sp_vport->vport.f->fid;
} }
static inline struct mlxsw_sp_port * static inline struct mlxsw_sp_port *
...@@ -298,14 +298,14 @@ mlxsw_sp_port_vport_find(const struct mlxsw_sp_port *mlxsw_sp_port, u16 vid) ...@@ -298,14 +298,14 @@ mlxsw_sp_port_vport_find(const struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
} }
static inline struct mlxsw_sp_port * static inline struct mlxsw_sp_port *
mlxsw_sp_port_vport_find_by_vfid(const struct mlxsw_sp_port *mlxsw_sp_port, mlxsw_sp_port_vport_find_by_fid(const struct mlxsw_sp_port *mlxsw_sp_port,
u16 vfid) u16 fid)
{ {
struct mlxsw_sp_port *mlxsw_sp_vport; struct mlxsw_sp_port *mlxsw_sp_vport;
list_for_each_entry(mlxsw_sp_vport, &mlxsw_sp_port->vports_list, list_for_each_entry(mlxsw_sp_vport, &mlxsw_sp_port->vports_list,
vport.list) { vport.list) {
if (mlxsw_sp_vport_vfid_get(mlxsw_sp_vport) == vfid) if (mlxsw_sp_vport_fid_get(mlxsw_sp_vport) == fid)
return mlxsw_sp_vport; return mlxsw_sp_vport;
} }
......
...@@ -57,11 +57,8 @@ static u16 mlxsw_sp_port_vid_to_fid_get(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -57,11 +57,8 @@ static u16 mlxsw_sp_port_vid_to_fid_get(struct mlxsw_sp_port *mlxsw_sp_port,
{ {
u16 fid = vid; u16 fid = vid;
if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) { if (mlxsw_sp_port_is_vport(mlxsw_sp_port))
u16 vfid = mlxsw_sp_vport_vfid_get(mlxsw_sp_port); fid = mlxsw_sp_vport_fid_get(mlxsw_sp_port);
fid = mlxsw_sp_vfid_to_fid(vfid);
}
if (!fid) if (!fid)
fid = mlxsw_sp_port->pvid; fid = mlxsw_sp_port->pvid;
...@@ -236,8 +233,9 @@ static int mlxsw_sp_port_uc_flood_set(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -236,8 +233,9 @@ static int mlxsw_sp_port_uc_flood_set(struct mlxsw_sp_port *mlxsw_sp_port,
int err; int err;
if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) { if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) {
u16 vfid = mlxsw_sp_vport_vfid_get(mlxsw_sp_port); u16 vfid, fid = mlxsw_sp_vport_fid_get(mlxsw_sp_port);
vfid = mlxsw_sp_fid_to_vfid(fid);
return __mlxsw_sp_port_flood_set(mlxsw_sp_port, vfid, vfid, return __mlxsw_sp_port_flood_set(mlxsw_sp_port, vfid, vfid,
set, true); set, true);
} }
...@@ -1136,12 +1134,8 @@ static int mlxsw_sp_port_fdb_dump(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1136,12 +1134,8 @@ static int mlxsw_sp_port_fdb_dump(struct mlxsw_sp_port *mlxsw_sp_port,
if (!sfd_pl) if (!sfd_pl)
return -ENOMEM; return -ENOMEM;
if (mlxsw_sp_port_is_vport(mlxsw_sp_port)) { if (mlxsw_sp_port_is_vport(mlxsw_sp_port))
u16 tmp; vport_fid = mlxsw_sp_vport_fid_get(mlxsw_sp_port);
tmp = mlxsw_sp_vport_vfid_get(mlxsw_sp_port);
vport_fid = mlxsw_sp_vfid_to_fid(tmp);
}
mlxsw_reg_sfd_pack(sfd_pl, MLXSW_REG_SFD_OP_QUERY_DUMP, 0); mlxsw_reg_sfd_pack(sfd_pl, MLXSW_REG_SFD_OP_QUERY_DUMP, 0);
do { do {
...@@ -1313,11 +1307,10 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp, ...@@ -1313,11 +1307,10 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
} }
if (mlxsw_sp_fid_is_vfid(fid)) { if (mlxsw_sp_fid_is_vfid(fid)) {
u16 vfid = mlxsw_sp_fid_to_vfid(fid);
struct mlxsw_sp_port *mlxsw_sp_vport; struct mlxsw_sp_port *mlxsw_sp_vport;
mlxsw_sp_vport = mlxsw_sp_port_vport_find_by_vfid(mlxsw_sp_port, mlxsw_sp_vport = mlxsw_sp_port_vport_find_by_fid(mlxsw_sp_port,
vfid); fid);
if (!mlxsw_sp_vport) { if (!mlxsw_sp_vport) {
netdev_err(mlxsw_sp_port->dev, "Failed to find a matching vPort following FDB notification\n"); netdev_err(mlxsw_sp_port->dev, "Failed to find a matching vPort following FDB notification\n");
goto just_remove; goto just_remove;
...@@ -1373,11 +1366,10 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp, ...@@ -1373,11 +1366,10 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,
} }
if (mlxsw_sp_fid_is_vfid(fid)) { if (mlxsw_sp_fid_is_vfid(fid)) {
u16 vfid = mlxsw_sp_fid_to_vfid(fid);
struct mlxsw_sp_port *mlxsw_sp_vport; struct mlxsw_sp_port *mlxsw_sp_vport;
mlxsw_sp_vport = mlxsw_sp_port_vport_find_by_vfid(mlxsw_sp_port, mlxsw_sp_vport = mlxsw_sp_port_vport_find_by_fid(mlxsw_sp_port,
vfid); fid);
if (!mlxsw_sp_vport) { if (!mlxsw_sp_vport) {
netdev_err(mlxsw_sp_port->dev, "Failed to find a matching vPort following FDB notification\n"); netdev_err(mlxsw_sp_port->dev, "Failed to find a matching vPort following FDB notification\n");
goto just_remove; goto just_remove;
......
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