Commit 2ec16ddd authored by Rongwei Liu's avatar Rongwei Liu Committed by Saeed Mahameed

net/mlx5: Introduce new device index wrapper

Downstream patches.
Signed-off-by: default avatarRongwei Liu <rongweil@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 7b1b6d35
...@@ -24,7 +24,7 @@ int mlx5e_devlink_port_register(struct mlx5e_priv *priv) ...@@ -24,7 +24,7 @@ int mlx5e_devlink_port_register(struct mlx5e_priv *priv)
if (mlx5_core_is_pf(priv->mdev)) { if (mlx5_core_is_pf(priv->mdev)) {
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL; attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
attrs.phys.port_number = PCI_FUNC(priv->mdev->pdev->devfn); attrs.phys.port_number = mlx5_get_dev_index(priv->mdev);
if (MLX5_ESWITCH_MANAGER(priv->mdev)) { if (MLX5_ESWITCH_MANAGER(priv->mdev)) {
mlx5e_devlink_get_port_parent_id(priv->mdev, &ppid); mlx5e_devlink_get_port_parent_id(priv->mdev, &ppid);
memcpy(attrs.switch_id.id, ppid.id, ppid.id_len); memcpy(attrs.switch_id.id, ppid.id, ppid.id_len);
......
...@@ -36,7 +36,7 @@ static struct devlink_port *mlx5_esw_dl_port_alloc(struct mlx5_eswitch *esw, u16 ...@@ -36,7 +36,7 @@ static struct devlink_port *mlx5_esw_dl_port_alloc(struct mlx5_eswitch *esw, u16
return NULL; return NULL;
mlx5_esw_get_port_parent_id(dev, &ppid); mlx5_esw_get_port_parent_id(dev, &ppid);
pfnum = PCI_FUNC(dev->pdev->devfn); pfnum = mlx5_get_dev_index(dev);
external = mlx5_core_is_ecpf_esw_manager(dev); external = mlx5_core_is_ecpf_esw_manager(dev);
if (external) if (external)
controller_num = dev->priv.eswitch->offloads.host_number + 1; 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 ...@@ -149,7 +149,7 @@ int mlx5_esw_devlink_sf_port_register(struct mlx5_eswitch *esw, struct devlink_p
if (IS_ERR(vport)) if (IS_ERR(vport))
return PTR_ERR(vport); return PTR_ERR(vport);
pfnum = PCI_FUNC(dev->pdev->devfn); pfnum = mlx5_get_dev_index(dev);
mlx5_esw_get_port_parent_id(dev, &ppid); mlx5_esw_get_port_parent_id(dev, &ppid);
memcpy(dl_port->attrs.switch_id.id, &ppid.id[0], ppid.id_len); memcpy(dl_port->attrs.switch_id.id, &ppid.id[0], ppid.id_len);
dl_port->attrs.switch_id.id_len = ppid.id_len; dl_port->attrs.switch_id.id_len = ppid.id_len;
......
...@@ -2798,7 +2798,7 @@ u32 mlx5_esw_match_metadata_alloc(struct mlx5_eswitch *esw) ...@@ -2798,7 +2798,7 @@ u32 mlx5_esw_match_metadata_alloc(struct mlx5_eswitch *esw)
int id; int id;
/* Only 4 bits of pf_num */ /* Only 4 bits of pf_num */
pf_num = PCI_FUNC(esw->dev->pdev->devfn); pf_num = mlx5_get_dev_index(esw->dev);
if (pf_num > max_pf_num) if (pf_num > max_pf_num)
return 0; return 0;
......
...@@ -688,7 +688,7 @@ static void mlx5_ldev_add_netdev(struct mlx5_lag *ldev, ...@@ -688,7 +688,7 @@ static void mlx5_ldev_add_netdev(struct mlx5_lag *ldev,
struct mlx5_core_dev *dev, struct mlx5_core_dev *dev,
struct net_device *netdev) struct net_device *netdev)
{ {
unsigned int fn = PCI_FUNC(dev->pdev->devfn); unsigned int fn = mlx5_get_dev_index(dev);
if (fn >= MLX5_MAX_PORTS) if (fn >= MLX5_MAX_PORTS)
return; return;
...@@ -718,7 +718,7 @@ static void mlx5_ldev_remove_netdev(struct mlx5_lag *ldev, ...@@ -718,7 +718,7 @@ static void mlx5_ldev_remove_netdev(struct mlx5_lag *ldev,
static void mlx5_ldev_add_mdev(struct mlx5_lag *ldev, static void mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
struct mlx5_core_dev *dev) struct mlx5_core_dev *dev)
{ {
unsigned int fn = PCI_FUNC(dev->pdev->devfn); unsigned int fn = mlx5_get_dev_index(dev);
if (fn >= MLX5_MAX_PORTS) if (fn >= MLX5_MAX_PORTS)
return; return;
......
...@@ -323,7 +323,7 @@ mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_ ...@@ -323,7 +323,7 @@ mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_
NL_SET_ERR_MSG_MOD(extack, "External controller is unsupported"); NL_SET_ERR_MSG_MOD(extack, "External controller is unsupported");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (new_attr->pfnum != PCI_FUNC(dev->pdev->devfn)) { if (new_attr->pfnum != mlx5_get_dev_index(dev)) {
NL_SET_ERR_MSG_MOD(extack, "Invalid pfnum supplied"); NL_SET_ERR_MSG_MOD(extack, "Invalid pfnum supplied");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -1243,6 +1243,11 @@ static inline int mlx5_core_native_port_num(struct mlx5_core_dev *dev) ...@@ -1243,6 +1243,11 @@ static inline int mlx5_core_native_port_num(struct mlx5_core_dev *dev)
return MLX5_CAP_GEN(dev, native_port_num); return MLX5_CAP_GEN(dev, native_port_num);
} }
static inline int mlx5_get_dev_index(struct mlx5_core_dev *dev)
{
return PCI_FUNC(dev->pdev->devfn);
}
enum { enum {
MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32, MLX5_TRIGGERED_CMD_COMP = (u64)1 << 32,
}; };
......
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