]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ice: use pci_iov_vf_id() to get VF ID
authorJacob Keller <jacob.e.keller@intel.com>
Wed, 18 Jun 2025 22:24:41 +0000 (15:24 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 10 Jul 2025 21:36:58 +0000 (14:36 -0700)
The ice_sriov_set_msix_vec_count() obtains the VF device ID in a strange
way by iterating over the possible VF IDs and calling
pci_iov_virtfn_devfn to calculate the device and function combos and
compare them to the pdev->devfn.

This is unnecessary. The pci_iov_vf_id() helper already exists which does
the reverse calculation of pci_iov_virtfn_devfn(), which is much simpler
and avoids the loop construction. Use this instead.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_sriov.c

index 0e4dc1a5cff0f3f690d78b146a7ddb8de9aab31a..f88bfd2f3f003082e4263bb278adc10171b23cf2 100644 (file)
@@ -952,17 +952,11 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
        if (msix_vec_count < ICE_MIN_INTR_PER_VF)
                return -EINVAL;
 
-       /* Transition of PCI VF function number to function_id */
-       for (id = 0; id < pci_num_vf(pdev); id++) {
-               if (vf_dev->devfn == pci_iov_virtfn_devfn(pdev, id))
-                       break;
-       }
-
-       if (id == pci_num_vf(pdev))
-               return -ENOENT;
+       id = pci_iov_vf_id(vf_dev);
+       if (id < 0)
+               return id;
 
        vf = ice_get_vf_by_id(pf, id);
-
        if (!vf)
                return -ENOENT;