0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 ===================
0004 PCI Test User Guide
0005 ===================
0006
0007 :Author: Kishon Vijay Abraham I <kishon@ti.com>
0008
0009 This document is a guide to help users use pci-epf-test function driver
0010 and pci_endpoint_test host driver for testing PCI. The list of steps to
0011 be followed in the host side and EP side is given below.
0012
0013 Endpoint Device
0014 ===============
0015
0016 Endpoint Controller Devices
0017 ---------------------------
0018
0019 To find the list of endpoint controller devices in the system::
0020
0021 # ls /sys/class/pci_epc/
0022 51000000.pcie_ep
0023
0024 If PCI_ENDPOINT_CONFIGFS is enabled::
0025
0026 # ls /sys/kernel/config/pci_ep/controllers
0027 51000000.pcie_ep
0028
0029
0030 Endpoint Function Drivers
0031 -------------------------
0032
0033 To find the list of endpoint function drivers in the system::
0034
0035 # ls /sys/bus/pci-epf/drivers
0036 pci_epf_test
0037
0038 If PCI_ENDPOINT_CONFIGFS is enabled::
0039
0040 # ls /sys/kernel/config/pci_ep/functions
0041 pci_epf_test
0042
0043
0044 Creating pci-epf-test Device
0045 ----------------------------
0046
0047 PCI endpoint function device can be created using the configfs. To create
0048 pci-epf-test device, the following commands can be used::
0049
0050 # mount -t configfs none /sys/kernel/config
0051 # cd /sys/kernel/config/pci_ep/
0052 # mkdir functions/pci_epf_test/func1
0053
0054 The "mkdir func1" above creates the pci-epf-test function device that will
0055 be probed by pci_epf_test driver.
0056
0057 The PCI endpoint framework populates the directory with the following
0058 configurable fields::
0059
0060 # ls functions/pci_epf_test/func1
0061 baseclass_code interrupt_pin progif_code subsys_id
0062 cache_line_size msi_interrupts revid subsys_vendorid
0063 deviceid msix_interrupts subclass_code vendorid
0064
0065 The PCI endpoint function driver populates these entries with default values
0066 when the device is bound to the driver. The pci-epf-test driver populates
0067 vendorid with 0xffff and interrupt_pin with 0x0001::
0068
0069 # cat functions/pci_epf_test/func1/vendorid
0070 0xffff
0071 # cat functions/pci_epf_test/func1/interrupt_pin
0072 0x0001
0073
0074
0075 Configuring pci-epf-test Device
0076 -------------------------------
0077
0078 The user can configure the pci-epf-test device using configfs entry. In order
0079 to change the vendorid and the number of MSI interrupts used by the function
0080 device, the following commands can be used::
0081
0082 # echo 0x104c > functions/pci_epf_test/func1/vendorid
0083 # echo 0xb500 > functions/pci_epf_test/func1/deviceid
0084 # echo 16 > functions/pci_epf_test/func1/msi_interrupts
0085 # echo 8 > functions/pci_epf_test/func1/msix_interrupts
0086
0087
0088 Binding pci-epf-test Device to EP Controller
0089 --------------------------------------------
0090
0091 In order for the endpoint function device to be useful, it has to be bound to
0092 a PCI endpoint controller driver. Use the configfs to bind the function
0093 device to one of the controller driver present in the system::
0094
0095 # ln -s functions/pci_epf_test/func1 controllers/51000000.pcie_ep/
0096
0097 Once the above step is completed, the PCI endpoint is ready to establish a link
0098 with the host.
0099
0100
0101 Start the Link
0102 --------------
0103
0104 In order for the endpoint device to establish a link with the host, the _start_
0105 field should be populated with '1'::
0106
0107 # echo 1 > controllers/51000000.pcie_ep/start
0108
0109
0110 RootComplex Device
0111 ==================
0112
0113 lspci Output
0114 ------------
0115
0116 Note that the devices listed here correspond to the value populated in 1.4
0117 above::
0118
0119 00:00.0 PCI bridge: Texas Instruments Device 8888 (rev 01)
0120 01:00.0 Unassigned class [ff00]: Texas Instruments Device b500
0121
0122
0123 Using Endpoint Test function Device
0124 -----------------------------------
0125
0126 pcitest.sh added in tools/pci/ can be used to run all the default PCI endpoint
0127 tests. To compile this tool the following commands should be used::
0128
0129 # cd <kernel-dir>
0130 # make -C tools/pci
0131
0132 or if you desire to compile and install in your system::
0133
0134 # cd <kernel-dir>
0135 # make -C tools/pci install
0136
0137 The tool and script will be located in <rootfs>/usr/bin/
0138
0139
0140 pcitest.sh Output
0141 ~~~~~~~~~~~~~~~~~
0142 ::
0143
0144 # pcitest.sh
0145 BAR tests
0146
0147 BAR0: OKAY
0148 BAR1: OKAY
0149 BAR2: OKAY
0150 BAR3: OKAY
0151 BAR4: NOT OKAY
0152 BAR5: NOT OKAY
0153
0154 Interrupt tests
0155
0156 SET IRQ TYPE TO LEGACY: OKAY
0157 LEGACY IRQ: NOT OKAY
0158 SET IRQ TYPE TO MSI: OKAY
0159 MSI1: OKAY
0160 MSI2: OKAY
0161 MSI3: OKAY
0162 MSI4: OKAY
0163 MSI5: OKAY
0164 MSI6: OKAY
0165 MSI7: OKAY
0166 MSI8: OKAY
0167 MSI9: OKAY
0168 MSI10: OKAY
0169 MSI11: OKAY
0170 MSI12: OKAY
0171 MSI13: OKAY
0172 MSI14: OKAY
0173 MSI15: OKAY
0174 MSI16: OKAY
0175 MSI17: NOT OKAY
0176 MSI18: NOT OKAY
0177 MSI19: NOT OKAY
0178 MSI20: NOT OKAY
0179 MSI21: NOT OKAY
0180 MSI22: NOT OKAY
0181 MSI23: NOT OKAY
0182 MSI24: NOT OKAY
0183 MSI25: NOT OKAY
0184 MSI26: NOT OKAY
0185 MSI27: NOT OKAY
0186 MSI28: NOT OKAY
0187 MSI29: NOT OKAY
0188 MSI30: NOT OKAY
0189 MSI31: NOT OKAY
0190 MSI32: NOT OKAY
0191 SET IRQ TYPE TO MSI-X: OKAY
0192 MSI-X1: OKAY
0193 MSI-X2: OKAY
0194 MSI-X3: OKAY
0195 MSI-X4: OKAY
0196 MSI-X5: OKAY
0197 MSI-X6: OKAY
0198 MSI-X7: OKAY
0199 MSI-X8: OKAY
0200 MSI-X9: NOT OKAY
0201 MSI-X10: NOT OKAY
0202 MSI-X11: NOT OKAY
0203 MSI-X12: NOT OKAY
0204 MSI-X13: NOT OKAY
0205 MSI-X14: NOT OKAY
0206 MSI-X15: NOT OKAY
0207 MSI-X16: NOT OKAY
0208 [...]
0209 MSI-X2047: NOT OKAY
0210 MSI-X2048: NOT OKAY
0211
0212 Read Tests
0213
0214 SET IRQ TYPE TO MSI: OKAY
0215 READ ( 1 bytes): OKAY
0216 READ ( 1024 bytes): OKAY
0217 READ ( 1025 bytes): OKAY
0218 READ (1024000 bytes): OKAY
0219 READ (1024001 bytes): OKAY
0220
0221 Write Tests
0222
0223 WRITE ( 1 bytes): OKAY
0224 WRITE ( 1024 bytes): OKAY
0225 WRITE ( 1025 bytes): OKAY
0226 WRITE (1024000 bytes): OKAY
0227 WRITE (1024001 bytes): OKAY
0228
0229 Copy Tests
0230
0231 COPY ( 1 bytes): OKAY
0232 COPY ( 1024 bytes): OKAY
0233 COPY ( 1025 bytes): OKAY
0234 COPY (1024000 bytes): OKAY
0235 COPY (1024001 bytes): OKAY