Skip to content

Commit 2ec16dd

Browse files
lrw514Saeed Mahameed
authored andcommitted
net/mlx5: Introduce new device index wrapper
Downstream patches. Signed-off-by: Rongwei Liu <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 7b1b6d3 commit 2ec16dd

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int mlx5e_devlink_port_register(struct mlx5e_priv *priv)
2424

2525
if (mlx5_core_is_pf(priv->mdev)) {
2626
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
27-
attrs.phys.port_number = PCI_FUNC(priv->mdev->pdev->devfn);
27+
attrs.phys.port_number = mlx5_get_dev_index(priv->mdev);
2828
if (MLX5_ESWITCH_MANAGER(priv->mdev)) {
2929
mlx5e_devlink_get_port_parent_id(priv->mdev, &ppid);
3030
memcpy(attrs.switch_id.id, ppid.id, ppid.id_len);

drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static struct devlink_port *mlx5_esw_dl_port_alloc(struct mlx5_eswitch *esw, u16
3636
return NULL;
3737

3838
mlx5_esw_get_port_parent_id(dev, &ppid);
39-
pfnum = PCI_FUNC(dev->pdev->devfn);
39+
pfnum = mlx5_get_dev_index(dev);
4040
external = mlx5_core_is_ecpf_esw_manager(dev);
4141
if (external)
4242
controller_num = dev->priv.eswitch->offloads.host_number + 1;
@@ -149,7 +149,7 @@ int mlx5_esw_devlink_sf_port_register(struct mlx5_eswitch *esw, struct devlink_p
149149
if (IS_ERR(vport))
150150
return PTR_ERR(vport);
151151

152-
pfnum = PCI_FUNC(dev->pdev->devfn);
152+
pfnum = mlx5_get_dev_index(dev);
153153
mlx5_esw_get_port_parent_id(dev, &ppid);
154154
memcpy(dl_port->attrs.switch_id.id, &ppid.id[0], ppid.id_len);
155155
dl_port->attrs.switch_id.id_len = ppid.id_len;

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ u32 mlx5_esw_match_metadata_alloc(struct mlx5_eswitch *esw)
27982798
int id;
27992799

28002800
/* Only 4 bits of pf_num */
2801-
pf_num = PCI_FUNC(esw->dev->pdev->devfn);
2801+
pf_num = mlx5_get_dev_index(esw->dev);
28022802
if (pf_num > max_pf_num)
28032803
return 0;
28042804

drivers/net/ethernet/mellanox/mlx5/core/lag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static void mlx5_ldev_add_netdev(struct mlx5_lag *ldev,
688688
struct mlx5_core_dev *dev,
689689
struct net_device *netdev)
690690
{
691-
unsigned int fn = PCI_FUNC(dev->pdev->devfn);
691+
unsigned int fn = mlx5_get_dev_index(dev);
692692

693693
if (fn >= MLX5_MAX_PORTS)
694694
return;
@@ -718,7 +718,7 @@ static void mlx5_ldev_remove_netdev(struct mlx5_lag *ldev,
718718
static void mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
719719
struct mlx5_core_dev *dev)
720720
{
721-
unsigned int fn = PCI_FUNC(dev->pdev->devfn);
721+
unsigned int fn = mlx5_get_dev_index(dev);
722722

723723
if (fn >= MLX5_MAX_PORTS)
724724
return;

drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_
323323
NL_SET_ERR_MSG_MOD(extack, "External controller is unsupported");
324324
return -EOPNOTSUPP;
325325
}
326-
if (new_attr->pfnum != PCI_FUNC(dev->pdev->devfn)) {
326+
if (new_attr->pfnum != mlx5_get_dev_index(dev)) {
327327
NL_SET_ERR_MSG_MOD(extack, "Invalid pfnum supplied");
328328
return -EOPNOTSUPP;
329329
}

include/linux/mlx5/driver.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,11 @@ static inline int mlx5_core_native_port_num(struct mlx5_core_dev *dev)
12431243
return MLX5_CAP_GEN(dev, native_port_num);
12441244
}
12451245

1246+
static inline int mlx5_get_dev_index(struct mlx5_core_dev *dev)
1247+
{
1248+
return PCI_FUNC(dev->pdev->devfn);
1249+
}
1250+
12461251
enum {
12471252
MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32,
12481253
};

0 commit comments

Comments
 (0)