Skip to content

Commit

Permalink
mlxsw: spectrum: Don't count on FID being present
Browse files Browse the repository at this point in the history
Not all vPorts will have FIDs assigned to them, so make sure functions
first test for FID presence.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ido Schimmel authored and David S. Miller committed Jun 21, 2016
1 parent 41b996c commit 56918b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion drivers/net/ethernet/mellanox/mlxsw/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -3323,7 +3323,9 @@ mlxsw_sp_port_master_bridge_check(const struct mlxsw_sp_port *mlxsw_sp_port,

list_for_each_entry(mlxsw_sp_vport, &mlxsw_sp_port->vports_list,
vport.list) {
if (mlxsw_sp_vport_br_get(mlxsw_sp_vport) == br_dev)
struct net_device *dev = mlxsw_sp_vport_br_get(mlxsw_sp_vport);

if (dev && dev == br_dev)
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ mlxsw_sp_vport_br_get(const struct mlxsw_sp_port *mlxsw_sp_vport)
{
struct mlxsw_sp_fid *f = mlxsw_sp_vport_fid_get(mlxsw_sp_vport);

return f->dev;
return f ? f->dev : NULL;
}

static inline struct mlxsw_sp_port *
Expand All @@ -317,7 +317,7 @@ mlxsw_sp_port_vport_find_by_fid(const struct mlxsw_sp_port *mlxsw_sp_port,
vport.list) {
struct mlxsw_sp_fid *f = mlxsw_sp_vport_fid_get(mlxsw_sp_vport);

if (f->fid == fid)
if (f && f->fid == fid)
return mlxsw_sp_vport;
}

Expand Down
11 changes: 6 additions & 5 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
static u16 mlxsw_sp_port_vid_to_fid_get(struct mlxsw_sp_port *mlxsw_sp_port,
u16 vid)
{
struct mlxsw_sp_fid *f = mlxsw_sp_vport_fid_get(mlxsw_sp_port);
u16 fid = vid;

if (mlxsw_sp_port_is_vport(mlxsw_sp_port))
fid = mlxsw_sp_vport_fid_get(mlxsw_sp_port)->fid;
fid = f ? f->fid : fid;

if (!fid)
fid = mlxsw_sp_port->pvid;
Expand Down Expand Up @@ -1196,7 +1196,8 @@ static int mlxsw_sp_port_fdb_dump(struct mlxsw_sp_port *mlxsw_sp_port,
{
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
struct mlxsw_sp_port *tmp;
u16 vport_fid = 0;
struct mlxsw_sp_fid *f;
u16 vport_fid;
char *sfd_pl;
char mac[ETH_ALEN];
u16 fid;
Expand All @@ -1211,8 +1212,8 @@ static int mlxsw_sp_port_fdb_dump(struct mlxsw_sp_port *mlxsw_sp_port,
if (!sfd_pl)
return -ENOMEM;

if (mlxsw_sp_port_is_vport(mlxsw_sp_port))
vport_fid = mlxsw_sp_vport_fid_get(mlxsw_sp_port)->fid;
f = mlxsw_sp_vport_fid_get(mlxsw_sp_port);
vport_fid = f ? f->fid : 0;

mlxsw_reg_sfd_pack(sfd_pl, MLXSW_REG_SFD_OP_QUERY_DUMP, 0);
do {
Expand Down

0 comments on commit 56918b6

Please sign in to comment.