Skip to content

Commit a8ccf8a

Browse files
Alexander Duyckbjorn-helgaas
authored andcommitted
PCI/IOV: Add pci-pf-stub driver for PFs that only enable VFs
Some SR-IOV PF devices provide no functionality other than acting as a means of enabling VFs. For these devices, we want to enable the VFs and assign them to guest virtual machines, but there's no need to have a driver for the PF itself. Add a new pci-pf-stub driver to claim those PF devices and provide the generic VF enable functionality. An administrator can use the sysfs "sriov_numvfs" file to enable VFs, then assign them to guests. For now I only have one example ID provided by Amazon in terms of devices that require this functionality. The general idea is that in the future we will see other devices added as vendors come up with devices where the PF is more or less just a lightweight shim used to allocate VFs. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> [bhelgaas: changelog] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Greg Rose <gvrose8192@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 8effc39 commit a8ccf8a

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

drivers/pci/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ config PCI_STUB
7171

7272
When in doubt, say N.
7373

74+
config PCI_PF_STUB
75+
tristate "PCI PF Stub driver"
76+
depends on PCI
77+
depends on PCI_IOV
78+
help
79+
Say Y or M here if you want to enable support for devices that
80+
require SR-IOV support, while at the same time the PF itself is
81+
not providing any actual services on the host itself such as
82+
storage or networking.
83+
84+
When in doubt, say N.
85+
7486
config XEN_PCIDEV_FRONTEND
7587
tristate "Xen PCI Frontend"
7688
depends on PCI && X86 && XEN

drivers/pci/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ obj-$(CONFIG_PCI_LABEL) += pci-label.o
2424
obj-$(CONFIG_X86_INTEL_MID) += pci-mid.o
2525
obj-$(CONFIG_PCI_SYSCALL) += syscall.o
2626
obj-$(CONFIG_PCI_STUB) += pci-stub.o
27+
obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o
2728
obj-$(CONFIG_PCI_ECAM) += ecam.o
2829
obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o
2930

drivers/pci/pci-pf-stub.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* pci-pf-stub - simple stub driver for PCI SR-IOV PF device
3+
*
4+
* This driver is meant to act as a "whitelist" for devices that provde
5+
* SR-IOV functionality while at the same time not actually needing a
6+
* driver of their own.
7+
*/
8+
9+
#include <linux/module.h>
10+
#include <linux/pci.h>
11+
12+
/**
13+
* pci_pf_stub_whitelist - White list of devices to bind pci-pf-stub onto
14+
*
15+
* This table provides the list of IDs this driver is supposed to bind
16+
* onto. You could think of this as a list of "quirked" devices where we
17+
* are adding support for SR-IOV here since there are no other drivers
18+
* that they would be running under.
19+
*/
20+
static const struct pci_device_id pci_pf_stub_whitelist[] = {
21+
{ PCI_VDEVICE(AMAZON, 0x0053) },
22+
/* required last entry */
23+
{ 0 }
24+
};
25+
MODULE_DEVICE_TABLE(pci, pci_pf_stub_whitelist);
26+
27+
static int pci_pf_stub_probe(struct pci_dev *dev,
28+
const struct pci_device_id *id)
29+
{
30+
pci_info(dev, "claimed by pci-pf-stub\n");
31+
return 0;
32+
}
33+
34+
static struct pci_driver pf_stub_driver = {
35+
.name = "pci-pf-stub",
36+
.id_table = pci_pf_stub_whitelist,
37+
.probe = pci_pf_stub_probe,
38+
.sriov_configure = pci_sriov_configure_simple,
39+
};
40+
41+
static int __init pci_pf_stub_init(void)
42+
{
43+
return pci_register_driver(&pf_stub_driver);
44+
}
45+
46+
static void __exit pci_pf_stub_exit(void)
47+
{
48+
pci_unregister_driver(&pf_stub_driver);
49+
}
50+
51+
module_init(pci_pf_stub_init);
52+
module_exit(pci_pf_stub_exit);
53+
54+
MODULE_LICENSE("GPL");

include/linux/pci_ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,6 +2552,8 @@
25522552
#define PCI_VENDOR_ID_CIRCUITCO 0x1cc8
25532553
#define PCI_SUBSYSTEM_ID_CIRCUITCO_MINNOWBOARD 0x0001
25542554

2555+
#define PCI_VENDOR_ID_AMAZON 0x1d0f
2556+
25552557
#define PCI_VENDOR_ID_TEKRAM 0x1de1
25562558
#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
25572559

0 commit comments

Comments
 (0)