summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@nvidia.com>2022-02-24 17:20:11 +0300
committerLeon Romanovsky <leonro@nvidia.com>2022-02-27 12:40:00 +0300
commit6ebd25b80c0d325a4a7f12614885aaf33dae76ab (patch)
tree90bcbd97daa12237754032bfb2471b47c483588f /drivers/net/ethernet/mellanox/mlx5/core/sriov.c
parent21ca9fb62d4688da41825e0f05d8e7e26afc69d6 (diff)
downloadlinux-6ebd25b80c0d325a4a7f12614885aaf33dae76ab.tar.xz
net/mlx5: Reuse exported virtfn index function call
Instead open-code iteration to compare virtfn internal index, use newly introduced pci_iov_vf_id() call. Link: https://lore.kernel.org/all/20220224142024.147653-3-yishaih@nvidia.com Signed-off-by: Yishai Hadas <yishaih@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx5/core/sriov.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/sriov.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
index e8185b69ac6c..24c4b4f05214 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
@@ -205,19 +205,8 @@ int mlx5_core_sriov_set_msix_vec_count(struct pci_dev *vf, int msix_vec_count)
mlx5_get_default_msix_vec_count(dev, pci_num_vf(pf));
sriov = &dev->priv.sriov;
-
- /* Reversed translation of PCI VF function number to the internal
- * function_id, which exists in the name of virtfn symlink.
- */
- for (id = 0; id < pci_num_vf(pf); id++) {
- if (!sriov->vfs_ctx[id].enabled)
- continue;
-
- if (vf->devfn == pci_iov_virtfn_devfn(pf, id))
- break;
- }
-
- if (id == pci_num_vf(pf) || !sriov->vfs_ctx[id].enabled)
+ id = pci_iov_vf_id(vf);
+ if (id < 0 || !sriov->vfs_ctx[id].enabled)
return -EINVAL;
return mlx5_set_msix_vec_count(dev, id + 1, msix_vec_count);