Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1.. SPDX-License-Identifier: GPL-2.0
2
3===================
4PCI Test User Guide
5===================
6
7:Author: Kishon Vijay Abraham I <kishon@ti.com>
8
9This document is a guide to help users use pci-epf-test function driver
10and pci_endpoint_test host driver for testing PCI. The list of steps to
11be followed in the host side and EP side is given below.
12
13Endpoint Device
14===============
15
16Endpoint Controller Devices
17---------------------------
18
19To find the list of endpoint controller devices in the system::
20
21 # ls /sys/class/pci_epc/
22 51000000.pcie_ep
23
24If PCI_ENDPOINT_CONFIGFS is enabled::
25
26 # ls /sys/kernel/config/pci_ep/controllers
27 51000000.pcie_ep
28
29
30Endpoint Function Drivers
31-------------------------
32
33To find the list of endpoint function drivers in the system::
34
35 # ls /sys/bus/pci-epf/drivers
36 pci_epf_test
37
38If PCI_ENDPOINT_CONFIGFS is enabled::
39
40 # ls /sys/kernel/config/pci_ep/functions
41 pci_epf_test
42
43
44Creating pci-epf-test Device
45----------------------------
46
47PCI endpoint function device can be created using the configfs. To create
48pci-epf-test device, the following commands can be used::
49
50 # mount -t configfs none /sys/kernel/config
51 # cd /sys/kernel/config/pci_ep/
52 # mkdir functions/pci_epf_test/func1
53
54The "mkdir func1" above creates the pci-epf-test function device that will
55be probed by pci_epf_test driver.
56
57The PCI endpoint framework populates the directory with the following
58configurable fields::
59
60 # ls functions/pci_epf_test/func1
61 baseclass_code interrupt_pin progif_code subsys_id
62 cache_line_size msi_interrupts revid subsys_vendorid
63 deviceid msix_interrupts subclass_code vendorid
64
65The PCI endpoint function driver populates these entries with default values
66when the device is bound to the driver. The pci-epf-test driver populates
67vendorid with 0xffff and interrupt_pin with 0x0001::
68
69 # cat functions/pci_epf_test/func1/vendorid
70 0xffff
71 # cat functions/pci_epf_test/func1/interrupt_pin
72 0x0001
73
74
75Configuring pci-epf-test Device
76-------------------------------
77
78The user can configure the pci-epf-test device using configfs entry. In order
79to change the vendorid and the number of MSI interrupts used by the function
80device, the following commands can be used::
81
82 # echo 0x104c > functions/pci_epf_test/func1/vendorid
83 # echo 0xb500 > functions/pci_epf_test/func1/deviceid
84 # echo 32 > functions/pci_epf_test/func1/msi_interrupts
85 # echo 2048 > functions/pci_epf_test/func1/msix_interrupts
86
87
88Binding pci-epf-test Device to EP Controller
89--------------------------------------------
90
91In order for the endpoint function device to be useful, it has to be bound to
92a PCI endpoint controller driver. Use the configfs to bind the function
93device to one of the controller driver present in the system::
94
95 # ln -s functions/pci_epf_test/func1 controllers/51000000.pcie_ep/
96
97Once the above step is completed, the PCI endpoint is ready to establish a link
98with the host.
99
100
101Start the Link
102--------------
103
104In order for the endpoint device to establish a link with the host, the _start_
105field should be populated with '1'::
106
107 # echo 1 > controllers/51000000.pcie_ep/start
108
109
110RootComplex Device
111==================
112
113lspci Output
114------------
115
116Note that the devices listed here correspond to the value populated in 1.4
117above::
118
119 00:00.0 PCI bridge: Texas Instruments Device 8888 (rev 01)
120 01:00.0 Unassigned class [ff00]: Texas Instruments Device b500
121
122
123Using Endpoint Test function Device
124-----------------------------------
125
126Kselftest added in tools/testing/selftests/pci_endpoint can be used to run all
127the default PCI endpoint tests. To build the Kselftest for PCI endpoint
128subsystem, the following commands should be used::
129
130 # cd <kernel-dir>
131 # make -C tools/testing/selftests/pci_endpoint
132
133or if you desire to compile and install in your system::
134
135 # cd <kernel-dir>
136 # make -C tools/testing/selftests/pci_endpoint INSTALL_PATH=/usr/bin install
137
138The test will be located in <rootfs>/usr/bin/
139
140Kselftest Output
141~~~~~~~~~~~~~~~~
142::
143
144 # pci_endpoint_test
145 TAP version 13
146 1..16
147 # Starting 16 tests from 9 test cases.
148 # RUN pci_ep_bar.BAR0.BAR_TEST ...
149 # OK pci_ep_bar.BAR0.BAR_TEST
150 ok 1 pci_ep_bar.BAR0.BAR_TEST
151 # RUN pci_ep_bar.BAR1.BAR_TEST ...
152 # OK pci_ep_bar.BAR1.BAR_TEST
153 ok 2 pci_ep_bar.BAR1.BAR_TEST
154 # RUN pci_ep_bar.BAR2.BAR_TEST ...
155 # OK pci_ep_bar.BAR2.BAR_TEST
156 ok 3 pci_ep_bar.BAR2.BAR_TEST
157 # RUN pci_ep_bar.BAR3.BAR_TEST ...
158 # OK pci_ep_bar.BAR3.BAR_TEST
159 ok 4 pci_ep_bar.BAR3.BAR_TEST
160 # RUN pci_ep_bar.BAR4.BAR_TEST ...
161 # OK pci_ep_bar.BAR4.BAR_TEST
162 ok 5 pci_ep_bar.BAR4.BAR_TEST
163 # RUN pci_ep_bar.BAR5.BAR_TEST ...
164 # OK pci_ep_bar.BAR5.BAR_TEST
165 ok 6 pci_ep_bar.BAR5.BAR_TEST
166 # RUN pci_ep_basic.CONSECUTIVE_BAR_TEST ...
167 # OK pci_ep_basic.CONSECUTIVE_BAR_TEST
168 ok 7 pci_ep_basic.CONSECUTIVE_BAR_TEST
169 # RUN pci_ep_basic.LEGACY_IRQ_TEST ...
170 # OK pci_ep_basic.LEGACY_IRQ_TEST
171 ok 8 pci_ep_basic.LEGACY_IRQ_TEST
172 # RUN pci_ep_basic.MSI_TEST ...
173 # OK pci_ep_basic.MSI_TEST
174 ok 9 pci_ep_basic.MSI_TEST
175 # RUN pci_ep_basic.MSIX_TEST ...
176 # OK pci_ep_basic.MSIX_TEST
177 ok 10 pci_ep_basic.MSIX_TEST
178 # RUN pci_ep_data_transfer.memcpy.READ_TEST ...
179 # OK pci_ep_data_transfer.memcpy.READ_TEST
180 ok 11 pci_ep_data_transfer.memcpy.READ_TEST
181 # RUN pci_ep_data_transfer.memcpy.WRITE_TEST ...
182 # OK pci_ep_data_transfer.memcpy.WRITE_TEST
183 ok 12 pci_ep_data_transfer.memcpy.WRITE_TEST
184 # RUN pci_ep_data_transfer.memcpy.COPY_TEST ...
185 # OK pci_ep_data_transfer.memcpy.COPY_TEST
186 ok 13 pci_ep_data_transfer.memcpy.COPY_TEST
187 # RUN pci_ep_data_transfer.dma.READ_TEST ...
188 # OK pci_ep_data_transfer.dma.READ_TEST
189 ok 14 pci_ep_data_transfer.dma.READ_TEST
190 # RUN pci_ep_data_transfer.dma.WRITE_TEST ...
191 # OK pci_ep_data_transfer.dma.WRITE_TEST
192 ok 15 pci_ep_data_transfer.dma.WRITE_TEST
193 # RUN pci_ep_data_transfer.dma.COPY_TEST ...
194 # OK pci_ep_data_transfer.dma.COPY_TEST
195 ok 16 pci_ep_data_transfer.dma.COPY_TEST
196 # PASSED: 16 / 16 tests passed.
197 # Totals: pass:16 fail:0 xfail:0 xpass:0 skip:0 error:0
198
199
200Testcase 16 (pci_ep_data_transfer.dma.COPY_TEST) will fail for most of the DMA
201capable endpoint controllers due to the absence of the MEMCPY over DMA. For such
202controllers, it is advisable to skip this testcase using this
203command::
204
205 # pci_endpoint_test -f pci_ep_bar -f pci_ep_basic -v memcpy -T COPY_TEST -v dma