libzpci: Add helper to check if a PCI function is a VF

Add zpci_is_vf() helper based on the /sys/bus/pci/devices/<dev>/vfn
attribute which is non-zero for VFs unlike the common code VF number
which starts at 0.

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Niklas Schnelle
2024-11-29 14:30:53 +01:00
committed by Jan Höppner
parent e0caed5534
commit 86b5df0d2d

View File

@@ -71,6 +71,18 @@ struct zpci_dev {
struct zpci_netdev *netdevs;
};
/**
* Get if a PCI device is a PCI Virtual Function
*
* @param[in] zdev The device in question
*
* @return true if the device is a VF false otherwise
*/
static inline bool zpci_is_vf(struct zpci_dev *zdev)
{
return !!zdev->vfn;
}
struct util_list *zpci_dev_list(void);
void zpci_free_dev_list(struct util_list *zpci_list);
void zpci_free_dev(struct zpci_dev *zdev);