lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 17 Dec 2009 17:34:10 -0800
From:	Jeff Kirsher <jeffrey.t.kirsher@...el.com>
To:	netdev@...r.kernel.org
Cc:	gospo@...hat.com, Mitch Williams <mitch.a.williams@...el.com>,
	Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Subject: [RFC PATCH v2 2/6] net: Add netif_num_vf function

From: Williams, Mitch A <mitch.a.williams@...el.com>

Add a convenience function to determine how many VF devices are associated
with a given PF network interface. If the device is not an SR-IOV physical
function device, the function returns 0.

Signed-off-by: Mitch Williams <mitch.a.williams@...el.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
---

 include/linux/netdevice.h |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a3fccc8..f6e521e 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -38,6 +38,7 @@
 #include <asm/byteorder.h>
 
 #include <linux/device.h>
+#include <linux/pci.h>
 #include <linux/percpu.h>
 #include <linux/rculist.h>
 #include <linux/dmaengine.h>
@@ -1509,6 +1510,32 @@ static inline int netif_is_multiqueue(const struct net_device *dev)
 {
 	return (dev->num_tx_queues > 1);
 }
+/**
+ *	netif_num_vf - return number of SR-IOV VFs
+ *	@dev: network device
+ *
+ *	Return the number of SR-IOV virtual function devices that are
+ *	associated with this physical function device. Returns 0 if
+ *	device is not a PF device, or if SR-IOV not enabled.
+ */
+static inline int netif_num_vf(const struct net_device *dev)
+{
+	struct pci_dev *pdev;
+	int retval = 0;
+
+	if (!dev)
+		goto out;
+
+	if (!dev->dev.parent)
+		goto out;
+
+	if (dev->dev.parent->bus == &pci_bus_type) {
+		pdev = to_pci_dev(dev->dev.parent);
+		retval = pci_num_vf(pdev);
+	}
+out:
+	return retval;
+}
 
 /* Use this variant when it is known for sure that it
  * is executing from hardware interrupt context or with hardware interrupts

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ