diff options
author | Donald Dutile <ddutile@redhat.com> | 2012-11-27 22:31:37 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-11-28 13:25:47 -0500 |
commit | 2597ba763fc44e247e462177abfe92d95bc5e6d5 (patch) | |
tree | 7d971907328ceb025fc079fba4ce2b73c442b70d /Documentation/PCI | |
parent | 1452cd76a97bf7b93a015586dcabc73fd935e692 (diff) |
PCI: SRIOV control and status via sysfs (documentation)
Add documentation of new sysfs files and new pci_driver SRIOV
configuration interface.
[bhelgaas: changelog]
Signed-off: Donald Dutile <ddutile@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'Documentation/PCI')
-rw-r--r-- | Documentation/PCI/pci-iov-howto.txt | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/Documentation/PCI/pci-iov-howto.txt b/Documentation/PCI/pci-iov-howto.txt index fc73ef5d65b8..cfaca7e69893 100644 --- a/Documentation/PCI/pci-iov-howto.txt +++ b/Documentation/PCI/pci-iov-howto.txt | |||
@@ -2,6 +2,9 @@ | |||
2 | Copyright (C) 2009 Intel Corporation | 2 | Copyright (C) 2009 Intel Corporation |
3 | Yu Zhao <yu.zhao@intel.com> | 3 | Yu Zhao <yu.zhao@intel.com> |
4 | 4 | ||
5 | Update: November 2012 | ||
6 | -- sysfs-based SRIOV enable-/disable-ment | ||
7 | Donald Dutile <ddutile@redhat.com> | ||
5 | 8 | ||
6 | 1. Overview | 9 | 1. Overview |
7 | 10 | ||
@@ -24,10 +27,21 @@ real existing PCI device. | |||
24 | 27 | ||
25 | 2.1 How can I enable SR-IOV capability | 28 | 2.1 How can I enable SR-IOV capability |
26 | 29 | ||
27 | The device driver (PF driver) will control the enabling and disabling | 30 | Multiple methods are available for SR-IOV enablement. |
28 | of the capability via API provided by SR-IOV core. If the hardware | 31 | In the first method, the device driver (PF driver) will control the |
29 | has SR-IOV capability, loading its PF driver would enable it and all | 32 | enabling and disabling of the capability via API provided by SR-IOV core. |
30 | VFs associated with the PF. | 33 | If the hardware has SR-IOV capability, loading its PF driver would |
34 | enable it and all VFs associated with the PF. Some PF drivers require | ||
35 | a module parameter to be set to determine the number of VFs to enable. | ||
36 | In the second method, a write to the sysfs file sriov_numvfs will | ||
37 | enable and disable the VFs associated with a PCIe PF. This method | ||
38 | enables per-PF, VF enable/disable values versus the first method, | ||
39 | which applies to all PFs of the same device. Additionally, the | ||
40 | PCI SRIOV core support ensures that enable/disable operations are | ||
41 | valid to reduce duplication in multiple drivers for the same | ||
42 | checks, e.g., check numvfs == 0 if enabling VFs, ensure | ||
43 | numvfs <= totalvfs. | ||
44 | The second method is the recommended method for new/future VF devices. | ||
31 | 45 | ||
32 | 2.2 How can I use the Virtual Functions | 46 | 2.2 How can I use the Virtual Functions |
33 | 47 | ||
@@ -40,13 +54,22 @@ requires device driver that is same as a normal PCI device's. | |||
40 | 3.1 SR-IOV API | 54 | 3.1 SR-IOV API |
41 | 55 | ||
42 | To enable SR-IOV capability: | 56 | To enable SR-IOV capability: |
57 | (a) For the first method, in the driver: | ||
43 | int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); | 58 | int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); |
44 | 'nr_virtfn' is number of VFs to be enabled. | 59 | 'nr_virtfn' is number of VFs to be enabled. |
60 | (b) For the second method, from sysfs: | ||
61 | echo 'nr_virtfn' > \ | ||
62 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs | ||
45 | 63 | ||
46 | To disable SR-IOV capability: | 64 | To disable SR-IOV capability: |
65 | (a) For the first method, in the driver: | ||
47 | void pci_disable_sriov(struct pci_dev *dev); | 66 | void pci_disable_sriov(struct pci_dev *dev); |
67 | (b) For the second method, from sysfs: | ||
68 | echo 0 > \ | ||
69 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs | ||
48 | 70 | ||
49 | To notify SR-IOV core of Virtual Function Migration: | 71 | To notify SR-IOV core of Virtual Function Migration: |
72 | (a) In the driver: | ||
50 | irqreturn_t pci_sriov_migration(struct pci_dev *dev); | 73 | irqreturn_t pci_sriov_migration(struct pci_dev *dev); |
51 | 74 | ||
52 | 3.2 Usage example | 75 | 3.2 Usage example |
@@ -88,6 +111,22 @@ static void dev_shutdown(struct pci_dev *dev) | |||
88 | ... | 111 | ... |
89 | } | 112 | } |
90 | 113 | ||
114 | static int dev_sriov_configure(struct pci_dev *dev, int numvfs) | ||
115 | { | ||
116 | if (numvfs > 0) { | ||
117 | ... | ||
118 | pci_enable_sriov(dev, numvfs); | ||
119 | ... | ||
120 | return numvfs; | ||
121 | } | ||
122 | if (numvfs == 0) { | ||
123 | .... | ||
124 | pci_disable_sriov(dev); | ||
125 | ... | ||
126 | return 0; | ||
127 | } | ||
128 | } | ||
129 | |||
91 | static struct pci_driver dev_driver = { | 130 | static struct pci_driver dev_driver = { |
92 | .name = "SR-IOV Physical Function driver", | 131 | .name = "SR-IOV Physical Function driver", |
93 | .id_table = dev_id_table, | 132 | .id_table = dev_id_table, |
@@ -96,4 +135,5 @@ static struct pci_driver dev_driver = { | |||
96 | .suspend = dev_suspend, | 135 | .suspend = dev_suspend, |
97 | .resume = dev_resume, | 136 | .resume = dev_resume, |
98 | .shutdown = dev_shutdown, | 137 | .shutdown = dev_shutdown, |
138 | .sriov_configure = dev_sriov_configure, | ||
99 | }; | 139 | }; |