236 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3===================4PCI Test User Guide5===================6 7:Author: Kishon Vijay Abraham I <kishon@ti.com>8 9This document is a guide to help users use pci-epf-test function driver10and pci_endpoint_test host driver for testing PCI. The list of steps to11be followed in the host side and EP side is given below.12 13Endpoint Device14===============15 16Endpoint Controller Devices17---------------------------18 19To find the list of endpoint controller devices in the system::20 21 # ls /sys/class/pci_epc/22 51000000.pcie_ep23 24If PCI_ENDPOINT_CONFIGFS is enabled::25 26 # ls /sys/kernel/config/pci_ep/controllers27 51000000.pcie_ep28 29 30Endpoint Function Drivers31-------------------------32 33To find the list of endpoint function drivers in the system::34 35 # ls /sys/bus/pci-epf/drivers36 pci_epf_test37 38If PCI_ENDPOINT_CONFIGFS is enabled::39 40 # ls /sys/kernel/config/pci_ep/functions41 pci_epf_test42 43 44Creating pci-epf-test Device45----------------------------46 47PCI endpoint function device can be created using the configfs. To create48pci-epf-test device, the following commands can be used::49 50 # mount -t configfs none /sys/kernel/config51 # cd /sys/kernel/config/pci_ep/52 # mkdir functions/pci_epf_test/func153 54The "mkdir func1" above creates the pci-epf-test function device that will55be probed by pci_epf_test driver.56 57The PCI endpoint framework populates the directory with the following58configurable fields::59 60 # ls functions/pci_epf_test/func161 baseclass_code interrupt_pin progif_code subsys_id62 cache_line_size msi_interrupts revid subsys_vendorid63 deviceid msix_interrupts subclass_code vendorid64 65The PCI endpoint function driver populates these entries with default values66when the device is bound to the driver. The pci-epf-test driver populates67vendorid with 0xffff and interrupt_pin with 0x0001::68 69 # cat functions/pci_epf_test/func1/vendorid70 0xffff71 # cat functions/pci_epf_test/func1/interrupt_pin72 0x000173 74 75Configuring pci-epf-test Device76-------------------------------77 78The user can configure the pci-epf-test device using configfs entry. In order79to change the vendorid and the number of MSI interrupts used by the function80device, the following commands can be used::81 82 # echo 0x104c > functions/pci_epf_test/func1/vendorid83 # echo 0xb500 > functions/pci_epf_test/func1/deviceid84 # echo 16 > functions/pci_epf_test/func1/msi_interrupts85 # echo 8 > functions/pci_epf_test/func1/msix_interrupts86 87 88Binding pci-epf-test Device to EP Controller89--------------------------------------------90 91In order for the endpoint function device to be useful, it has to be bound to92a PCI endpoint controller driver. Use the configfs to bind the function93device 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 link98with the host.99 100 101Start the Link102--------------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/start108 109 110RootComplex Device111==================112 113lspci Output114------------115 116Note that the devices listed here correspond to the value populated in 1.4117above::118 119 00:00.0 PCI bridge: Texas Instruments Device 8888 (rev 01)120 01:00.0 Unassigned class [ff00]: Texas Instruments Device b500121 122 123Using Endpoint Test function Device124-----------------------------------125 126pcitest.sh added in tools/pci/ can be used to run all the default PCI endpoint127tests. To compile this tool the following commands should be used::128 129 # cd <kernel-dir>130 # make -C tools/pci131 132or if you desire to compile and install in your system::133 134 # cd <kernel-dir>135 # make -C tools/pci install136 137The tool and script will be located in <rootfs>/usr/bin/138 139 140pcitest.sh Output141~~~~~~~~~~~~~~~~~142::143 144 # pcitest.sh145 BAR tests146 147 BAR0: OKAY148 BAR1: OKAY149 BAR2: OKAY150 BAR3: OKAY151 BAR4: NOT OKAY152 BAR5: NOT OKAY153 154 Interrupt tests155 156 SET IRQ TYPE TO LEGACY: OKAY157 LEGACY IRQ: NOT OKAY158 SET IRQ TYPE TO MSI: OKAY159 MSI1: OKAY160 MSI2: OKAY161 MSI3: OKAY162 MSI4: OKAY163 MSI5: OKAY164 MSI6: OKAY165 MSI7: OKAY166 MSI8: OKAY167 MSI9: OKAY168 MSI10: OKAY169 MSI11: OKAY170 MSI12: OKAY171 MSI13: OKAY172 MSI14: OKAY173 MSI15: OKAY174 MSI16: OKAY175 MSI17: NOT OKAY176 MSI18: NOT OKAY177 MSI19: NOT OKAY178 MSI20: NOT OKAY179 MSI21: NOT OKAY180 MSI22: NOT OKAY181 MSI23: NOT OKAY182 MSI24: NOT OKAY183 MSI25: NOT OKAY184 MSI26: NOT OKAY185 MSI27: NOT OKAY186 MSI28: NOT OKAY187 MSI29: NOT OKAY188 MSI30: NOT OKAY189 MSI31: NOT OKAY190 MSI32: NOT OKAY191 SET IRQ TYPE TO MSI-X: OKAY192 MSI-X1: OKAY193 MSI-X2: OKAY194 MSI-X3: OKAY195 MSI-X4: OKAY196 MSI-X5: OKAY197 MSI-X6: OKAY198 MSI-X7: OKAY199 MSI-X8: OKAY200 MSI-X9: NOT OKAY201 MSI-X10: NOT OKAY202 MSI-X11: NOT OKAY203 MSI-X12: NOT OKAY204 MSI-X13: NOT OKAY205 MSI-X14: NOT OKAY206 MSI-X15: NOT OKAY207 MSI-X16: NOT OKAY208 [...]209 MSI-X2047: NOT OKAY210 MSI-X2048: NOT OKAY211 212 Read Tests213 214 SET IRQ TYPE TO MSI: OKAY215 READ ( 1 bytes): OKAY216 READ ( 1024 bytes): OKAY217 READ ( 1025 bytes): OKAY218 READ (1024000 bytes): OKAY219 READ (1024001 bytes): OKAY220 221 Write Tests222 223 WRITE ( 1 bytes): OKAY224 WRITE ( 1024 bytes): OKAY225 WRITE ( 1025 bytes): OKAY226 WRITE (1024000 bytes): OKAY227 WRITE (1024001 bytes): OKAY228 229 Copy Tests230 231 COPY ( 1 bytes): OKAY232 COPY ( 1024 bytes): OKAY233 COPY ( 1025 bytes): OKAY234 COPY (1024000 bytes): OKAY235 COPY (1024001 bytes): OKAY236