summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChangbin Du <changbin.du@gmail.com>2019-05-14 10:47:26 -0400
committerBjorn Helgaas <bhelgaas@google.com>2019-05-30 18:54:32 -0400
commit4d2c729c62328d6841111d98396374476367ae83 (patch)
tree6cc827289a946c738aca826af370ce032a59a54c
parent2e6422444894685a8a3135f7b982aa026dc0f74c (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.rst1
-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 5PCI Express I/O Virtualization Howto
7 Donald Dutile <ddutile@redhat.com> 6====================================
8 7
91. Overview 8:Copyright: |copy| 2009 Intel Corporation
9:Authors: - Yu Zhao <yu.zhao@intel.com>
10 - Donald Dutile <ddutile@redhat.com>
10 11
111.1 What is SR-IOV 12Overview
13========
14
15What is SR-IOV
16--------------
12 17
13Single Root I/O Virtualization (SR-IOV) is a PCI Express Extended 18Single Root I/O Virtualization (SR-IOV) is a PCI Express Extended
14capability which makes one physical device appear as multiple virtual 19capability 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
23operates on the register set so it can be functional and appear as a 28operates on the register set so it can be functional and appear as a
24real existing PCI device. 29real existing PCI device.
25 30
262. User Guide 31User Guide
32==========
27 33
282.1 How can I enable SR-IOV capability 34How can I enable SR-IOV capability
35----------------------------------
29 36
30Multiple methods are available for SR-IOV enablement. 37Multiple methods are available for SR-IOV enablement.
31In the first method, the device driver (PF driver) will control the 38In 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
43numvfs <= totalvfs. 50numvfs <= totalvfs.
44The second method is the recommended method for new/future VF devices. 51The second method is the recommended method for new/future VF devices.
45 52
462.2 How can I use the Virtual Functions 53How can I use the Virtual Functions
54-----------------------------------
47 55
48The VF is treated as hot-plugged PCI devices in the kernel, so they 56The VF is treated as hot-plugged PCI devices in the kernel, so they
49should be able to work in the same way as real PCI devices. The VF 57should be able to work in the same way as real PCI devices. The VF
50requires device driver that is same as a normal PCI device's. 58requires device driver that is same as a normal PCI device's.
51 59
523. Developer Guide 60Developer Guide
61===============
53 62
543.1 SR-IOV API 63SR-IOV API
64----------
55 65
56To enable SR-IOV capability: 66To 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
64To disable SR-IOV capability: 79To 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
71To enable auto probing VFs by a compatible driver on the host, run 90To enable auto probing VFs by a compatible driver on the host, run
72command below before enabling SR-IOV capabilities. This is the 91command below before enabling SR-IOV capabilities. This is the
73default behavior. 92default 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
77To disable auto probing VFs by a compatible driver on the host, run 98To disable auto probing VFs by a compatible driver on the host, run
78command below before enabling SR-IOV capabilities. Updating this 99command below before enabling SR-IOV capabilities. Updating this
79entry will not affect VFs which are already probed. 100entry 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
833.2 Usage example 106Usage example
107-------------
84 108
85Following piece of code illustrates the usage of the SR-IOV API. 109Following piece of code illustrates the usage of the SR-IOV API.
110::
86 111
87static 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
96static 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
103static 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
110static 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
117static void dev_shutdown(struct pci_dev *dev) 139 return 0;
118{ 140 }
119 ...
120}
121 141
122static 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 = {
138static 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};