diff options
author | Changbin Du <changbin.du@gmail.com> | 2019-05-14 10:47:26 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2019-05-30 18:54:32 -0400 |
commit | 4d2c729c62328d6841111d98396374476367ae83 (patch) | |
tree | 6cc827289a946c738aca826af370ce032a59a54c | |
parent | 2e6422444894685a8a3135f7b982aa026dc0f74c (diff) |
Documentation: PCI: convert pci-iov-howto.txt to reST
Convert plain text documentation to reStructuredText format and add it to
Sphinx TOC tree. No essential content change.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r-- | Documentation/PCI/index.rst | 1 | ||||
-rw-r--r-- | Documentation/PCI/pci-iov-howto.rst (renamed from Documentation/PCI/pci-iov-howto.txt) | 161 |
2 files changed, 94 insertions, 68 deletions
diff --git a/Documentation/PCI/index.rst b/Documentation/PCI/index.rst index 79d6d75bbf28..0d9390298c4a 100644 --- a/Documentation/PCI/index.rst +++ b/Documentation/PCI/index.rst | |||
@@ -10,3 +10,4 @@ Linux PCI Bus Subsystem | |||
10 | 10 | ||
11 | pci | 11 | pci |
12 | picebus-howto | 12 | picebus-howto |
13 | pci-iov-howto | ||
diff --git a/Documentation/PCI/pci-iov-howto.txt b/Documentation/PCI/pci-iov-howto.rst index d2a84151e99c..b9fd003206f1 100644 --- a/Documentation/PCI/pci-iov-howto.txt +++ b/Documentation/PCI/pci-iov-howto.rst | |||
@@ -1,14 +1,19 @@ | |||
1 | PCI Express I/O Virtualization Howto | 1 | .. SPDX-License-Identifier: GPL-2.0 |
2 | Copyright (C) 2009 Intel Corporation | 2 | .. include:: <isonum.txt> |
3 | Yu Zhao <yu.zhao@intel.com> | ||
4 | 3 | ||
5 | Update: November 2012 | 4 | ==================================== |
6 | -- sysfs-based SRIOV enable-/disable-ment | 5 | PCI Express I/O Virtualization Howto |
7 | Donald Dutile <ddutile@redhat.com> | 6 | ==================================== |
8 | 7 | ||
9 | 1. Overview | 8 | :Copyright: |copy| 2009 Intel Corporation |
9 | :Authors: - Yu Zhao <yu.zhao@intel.com> | ||
10 | - Donald Dutile <ddutile@redhat.com> | ||
10 | 11 | ||
11 | 1.1 What is SR-IOV | 12 | Overview |
13 | ======== | ||
14 | |||
15 | What is SR-IOV | ||
16 | -------------- | ||
12 | 17 | ||
13 | Single Root I/O Virtualization (SR-IOV) is a PCI Express Extended | 18 | Single Root I/O Virtualization (SR-IOV) is a PCI Express Extended |
14 | capability which makes one physical device appear as multiple virtual | 19 | capability which makes one physical device appear as multiple virtual |
@@ -23,9 +28,11 @@ Memory Space, which is used to map its register set. VF device driver | |||
23 | operates on the register set so it can be functional and appear as a | 28 | operates on the register set so it can be functional and appear as a |
24 | real existing PCI device. | 29 | real existing PCI device. |
25 | 30 | ||
26 | 2. User Guide | 31 | User Guide |
32 | ========== | ||
27 | 33 | ||
28 | 2.1 How can I enable SR-IOV capability | 34 | How can I enable SR-IOV capability |
35 | ---------------------------------- | ||
29 | 36 | ||
30 | Multiple methods are available for SR-IOV enablement. | 37 | Multiple methods are available for SR-IOV enablement. |
31 | In the first method, the device driver (PF driver) will control the | 38 | In the first method, the device driver (PF driver) will control the |
@@ -43,105 +50,123 @@ checks, e.g., check numvfs == 0 if enabling VFs, ensure | |||
43 | numvfs <= totalvfs. | 50 | numvfs <= totalvfs. |
44 | The second method is the recommended method for new/future VF devices. | 51 | The second method is the recommended method for new/future VF devices. |
45 | 52 | ||
46 | 2.2 How can I use the Virtual Functions | 53 | How can I use the Virtual Functions |
54 | ----------------------------------- | ||
47 | 55 | ||
48 | The VF is treated as hot-plugged PCI devices in the kernel, so they | 56 | The VF is treated as hot-plugged PCI devices in the kernel, so they |
49 | should be able to work in the same way as real PCI devices. The VF | 57 | should be able to work in the same way as real PCI devices. The VF |
50 | requires device driver that is same as a normal PCI device's. | 58 | requires device driver that is same as a normal PCI device's. |
51 | 59 | ||
52 | 3. Developer Guide | 60 | Developer Guide |
61 | =============== | ||
53 | 62 | ||
54 | 3.1 SR-IOV API | 63 | SR-IOV API |
64 | ---------- | ||
55 | 65 | ||
56 | To enable SR-IOV capability: | 66 | To enable SR-IOV capability: |
57 | (a) For the first method, in the driver: | 67 | |
68 | (a) For the first method, in the driver:: | ||
69 | |||
58 | int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); | 70 | int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); |
59 | 'nr_virtfn' is number of VFs to be enabled. | 71 | |
60 | (b) For the second method, from sysfs: | 72 | 'nr_virtfn' is number of VFs to be enabled. |
73 | |||
74 | (b) For the second method, from sysfs:: | ||
75 | |||
61 | echo 'nr_virtfn' > \ | 76 | echo 'nr_virtfn' > \ |
62 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs | 77 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs |
63 | 78 | ||
64 | To disable SR-IOV capability: | 79 | To disable SR-IOV capability: |
65 | (a) For the first method, in the driver: | 80 | |
81 | (a) For the first method, in the driver:: | ||
82 | |||
66 | void pci_disable_sriov(struct pci_dev *dev); | 83 | void pci_disable_sriov(struct pci_dev *dev); |
67 | (b) For the second method, from sysfs: | 84 | |
85 | (b) For the second method, from sysfs:: | ||
86 | |||
68 | echo 0 > \ | 87 | echo 0 > \ |
69 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs | 88 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs |
70 | 89 | ||
71 | To enable auto probing VFs by a compatible driver on the host, run | 90 | To enable auto probing VFs by a compatible driver on the host, run |
72 | command below before enabling SR-IOV capabilities. This is the | 91 | command below before enabling SR-IOV capabilities. This is the |
73 | default behavior. | 92 | default behavior. |
93 | :: | ||
94 | |||
74 | echo 1 > \ | 95 | echo 1 > \ |
75 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_drivers_autoprobe | 96 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_drivers_autoprobe |
76 | 97 | ||
77 | To disable auto probing VFs by a compatible driver on the host, run | 98 | To disable auto probing VFs by a compatible driver on the host, run |
78 | command below before enabling SR-IOV capabilities. Updating this | 99 | command below before enabling SR-IOV capabilities. Updating this |
79 | entry will not affect VFs which are already probed. | 100 | entry will not affect VFs which are already probed. |
101 | :: | ||
102 | |||
80 | echo 0 > \ | 103 | echo 0 > \ |
81 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_drivers_autoprobe | 104 | /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_drivers_autoprobe |
82 | 105 | ||
83 | 3.2 Usage example | 106 | Usage example |
107 | ------------- | ||
84 | 108 | ||
85 | Following piece of code illustrates the usage of the SR-IOV API. | 109 | Following piece of code illustrates the usage of the SR-IOV API. |
110 | :: | ||
86 | 111 | ||
87 | static int dev_probe(struct pci_dev *dev, const struct pci_device_id *id) | 112 | static int dev_probe(struct pci_dev *dev, const struct pci_device_id *id) |
88 | { | 113 | { |
89 | pci_enable_sriov(dev, NR_VIRTFN); | 114 | pci_enable_sriov(dev, NR_VIRTFN); |
90 | 115 | ||
91 | ... | 116 | ... |
92 | |||
93 | return 0; | ||
94 | } | ||
95 | 117 | ||
96 | static void dev_remove(struct pci_dev *dev) | 118 | return 0; |
97 | { | 119 | } |
98 | pci_disable_sriov(dev); | ||
99 | 120 | ||
100 | ... | 121 | static void dev_remove(struct pci_dev *dev) |
101 | } | 122 | { |
123 | pci_disable_sriov(dev); | ||
102 | 124 | ||
103 | static int dev_suspend(struct pci_dev *dev, pm_message_t state) | 125 | ... |
104 | { | 126 | } |
105 | ... | ||
106 | 127 | ||
107 | return 0; | 128 | static int dev_suspend(struct pci_dev *dev, pm_message_t state) |
108 | } | 129 | { |
130 | ... | ||
109 | 131 | ||
110 | static int dev_resume(struct pci_dev *dev) | 132 | return 0; |
111 | { | 133 | } |
112 | ... | ||
113 | 134 | ||
114 | return 0; | 135 | static int dev_resume(struct pci_dev *dev) |
115 | } | 136 | { |
137 | ... | ||
116 | 138 | ||
117 | static void dev_shutdown(struct pci_dev *dev) | 139 | return 0; |
118 | { | 140 | } |
119 | ... | ||
120 | } | ||
121 | 141 | ||
122 | static int dev_sriov_configure(struct pci_dev *dev, int numvfs) | 142 | static void dev_shutdown(struct pci_dev *dev) |
123 | { | 143 | { |
124 | if (numvfs > 0) { | ||
125 | ... | ||
126 | pci_enable_sriov(dev, numvfs); | ||
127 | ... | 144 | ... |
128 | return numvfs; | ||
129 | } | 145 | } |
130 | if (numvfs == 0) { | 146 | |
131 | .... | 147 | static int dev_sriov_configure(struct pci_dev *dev, int numvfs) |
132 | pci_disable_sriov(dev); | 148 | { |
133 | ... | 149 | if (numvfs > 0) { |
134 | return 0; | 150 | ... |
151 | pci_enable_sriov(dev, numvfs); | ||
152 | ... | ||
153 | return numvfs; | ||
154 | } | ||
155 | if (numvfs == 0) { | ||
156 | .... | ||
157 | pci_disable_sriov(dev); | ||
158 | ... | ||
159 | return 0; | ||
160 | } | ||
135 | } | 161 | } |
136 | } | 162 | |
137 | 163 | static struct pci_driver dev_driver = { | |
138 | static struct pci_driver dev_driver = { | 164 | .name = "SR-IOV Physical Function driver", |
139 | .name = "SR-IOV Physical Function driver", | 165 | .id_table = dev_id_table, |
140 | .id_table = dev_id_table, | 166 | .probe = dev_probe, |
141 | .probe = dev_probe, | 167 | .remove = dev_remove, |
142 | .remove = dev_remove, | 168 | .suspend = dev_suspend, |
143 | .suspend = dev_suspend, | 169 | .resume = dev_resume, |
144 | .resume = dev_resume, | 170 | .shutdown = dev_shutdown, |
145 | .shutdown = dev_shutdown, | 171 | .sriov_configure = dev_sriov_configure, |
146 | .sriov_configure = dev_sriov_configure, | 172 | }; |
147 | }; | ||