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);