-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Alexander Duyck
authored and
Bjorn Helgaas
committed
Apr 24, 2018
1 parent
8effc39
commit a8ccf8a
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* pci-pf-stub - simple stub driver for PCI SR-IOV PF device | ||
* | ||
* This driver is meant to act as a "whitelist" for devices that provde | ||
* SR-IOV functionality while at the same time not actually needing a | ||
* driver of their own. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/pci.h> | ||
|
||
/** | ||
* pci_pf_stub_whitelist - White list of devices to bind pci-pf-stub onto | ||
* | ||
* This table provides the list of IDs this driver is supposed to bind | ||
* onto. You could think of this as a list of "quirked" devices where we | ||
* are adding support for SR-IOV here since there are no other drivers | ||
* that they would be running under. | ||
*/ | ||
static const struct pci_device_id pci_pf_stub_whitelist[] = { | ||
{ PCI_VDEVICE(AMAZON, 0x0053) }, | ||
/* required last entry */ | ||
{ 0 } | ||
}; | ||
MODULE_DEVICE_TABLE(pci, pci_pf_stub_whitelist); | ||
|
||
static int pci_pf_stub_probe(struct pci_dev *dev, | ||
const struct pci_device_id *id) | ||
{ | ||
pci_info(dev, "claimed by pci-pf-stub\n"); | ||
return 0; | ||
} | ||
|
||
static struct pci_driver pf_stub_driver = { | ||
.name = "pci-pf-stub", | ||
.id_table = pci_pf_stub_whitelist, | ||
.probe = pci_pf_stub_probe, | ||
.sriov_configure = pci_sriov_configure_simple, | ||
}; | ||
|
||
static int __init pci_pf_stub_init(void) | ||
{ | ||
return pci_register_driver(&pf_stub_driver); | ||
} | ||
|
||
static void __exit pci_pf_stub_exit(void) | ||
{ | ||
pci_unregister_driver(&pf_stub_driver); | ||
} | ||
|
||
module_init(pci_pf_stub_init); | ||
module_exit(pci_pf_stub_exit); | ||
|
||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters