PCI/IOV: Add pci_iov_vf_id() to get VF index
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 24 Feb 2022 14:20:10 +0000 (16:20 +0200)
committerLeon Romanovsky <leonro@nvidia.com>
Sun, 27 Feb 2022 09:38:51 +0000 (11:38 +0200)
commit21ca9fb62d4688da41825e0f05d8e7e26afc69d6
tree955bbb2dbc34c27364cfb7e270cc5655325833ee
parentcfb92440ee71adcc2105b0890bb01ac3cddb8507
PCI/IOV: Add pci_iov_vf_id() to get VF index

The PCI core uses the VF index internally, often called the vf_id,
during the setup of the VF, eg pci_iov_add_virtfn().

This index is needed for device drivers that implement live migration
for their internal operations that configure/control their VFs.

Specifically, mlx5_vfio_pci driver that is introduced in coming patches
from this series needs it and not the bus/device/function which is
exposed today.

Add pci_iov_vf_id() which computes the vf_id by reversing the math that
was used to create the bus/device/function.

Link: https://lore.kernel.org/all/20220224142024.147653-2-yishaih@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
drivers/pci/iov.c
include/linux/pci.h