Skip to content

Commit

Permalink
net/mlx5e: Move to use common phys port names for vport representors
Browse files Browse the repository at this point in the history
With VF LAG commit 491c37e "net/mlx5e: In case of LAG, one switch
parent id is used for all representors", both uplinks and all the VFs
(on both of them) get the same switchdev id.

This cause the provisioning system method to identify the rep of a given
VF from the parent PF PCI device using switchev id and physical port
name to break, since VFm of PF0 will have the (id, name) as VFm of PF1.

To fix that, we align to use the framework agreed upstream and set by
nfp commit 168c478 "nfp: wire get_phys_port_name on representors":

$ cat /sys/class/net/eth4_*/phys_port_name
p0
pf0vf0
pf0vf1

Now, the names will be different, e.g. pf0vf0 vs. pf1vf0.

Fixes: 491c37e ("net/mlx5e: In case of LAG, one switch parent id is used for all representors")
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Waleed Musa <waleedm@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
  • Loading branch information
ogerlitz authored and Saeed Mahameed committed Jan 25, 2019
1 parent 9d2cbdc commit c12ecc2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,9 +1126,17 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,
struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
int ret;
int ret, pf_num;

ret = mlx5_lag_get_pf_num(priv->mdev, &pf_num);
if (ret)
return ret;

if (rep->vport == FDB_UPLINK_VPORT)
ret = snprintf(buf, len, "p%d", pf_num);
else
ret = snprintf(buf, len, "pf%dvf%d", pf_num, rep->vport - 1);

ret = snprintf(buf, len, "%d", rep->vport - 1);
if (ret >= len)
return -EOPNOTSUPP;

Expand Down
21 changes: 21 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/lag.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,27 @@ void mlx5_lag_add(struct mlx5_core_dev *dev, struct net_device *netdev)
}
}

int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num)
{
struct mlx5_lag *ldev;
int n;

ldev = mlx5_lag_dev_get(dev);
if (!ldev) {
mlx5_core_warn(dev, "no lag device, can't get pf num\n");
return -EINVAL;
}

for (n = 0; n < MLX5_MAX_PORTS; n++)
if (ldev->pf[n].dev == dev) {
*pf_num = n;
return 0;
}

mlx5_core_warn(dev, "wasn't able to locate pf in the lag device\n");
return -EINVAL;
}

/* Must be called with intf_mutex held */
void mlx5_lag_remove(struct mlx5_core_dev *dev)
{
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ static inline int mlx5_lag_is_lacp_owner(struct mlx5_core_dev *dev)
MLX5_CAP_GEN(dev, lag_master);
}

int mlx5_lag_get_pf_num(struct mlx5_core_dev *dev, int *pf_num);

void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol);
void mlx5_lag_update(struct mlx5_core_dev *dev);

Expand Down

0 comments on commit c12ecc2

Please sign in to comment.