From 86b5df0d2d38ec3459fbfb092f4352bf4afac2f7 Mon Sep 17 00:00:00 2001 From: Niklas Schnelle Date: Fri, 29 Nov 2024 14:30:53 +0100 Subject: [PATCH] libzpci: Add helper to check if a PCI function is a VF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add zpci_is_vf() helper based on the /sys/bus/pci/devices//vfn attribute which is non-zero for VFs unlike the common code VF number which starts at 0. Reviewed-by: Halil Pasic Signed-off-by: Niklas Schnelle Signed-off-by: Jan Höppner --- include/lib/pci_list.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/lib/pci_list.h b/include/lib/pci_list.h index 9d073fe2..829ec244 100644 --- a/include/lib/pci_list.h +++ b/include/lib/pci_list.h @@ -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);