1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun=================== 4*4882a593SmuzhiyunPCI Test User Guide 5*4882a593Smuzhiyun=================== 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun:Author: Kishon Vijay Abraham I <kishon@ti.com> 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunThis document is a guide to help users use pci-epf-test function driver 10*4882a593Smuzhiyunand pci_endpoint_test host driver for testing PCI. The list of steps to 11*4882a593Smuzhiyunbe followed in the host side and EP side is given below. 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunEndpoint Device 14*4882a593Smuzhiyun=============== 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunEndpoint Controller Devices 17*4882a593Smuzhiyun--------------------------- 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunTo find the list of endpoint controller devices in the system:: 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun # ls /sys/class/pci_epc/ 22*4882a593Smuzhiyun 51000000.pcie_ep 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunIf PCI_ENDPOINT_CONFIGFS is enabled:: 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun # ls /sys/kernel/config/pci_ep/controllers 27*4882a593Smuzhiyun 51000000.pcie_ep 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunEndpoint Function Drivers 31*4882a593Smuzhiyun------------------------- 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunTo find the list of endpoint function drivers in the system:: 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun # ls /sys/bus/pci-epf/drivers 36*4882a593Smuzhiyun pci_epf_test 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunIf PCI_ENDPOINT_CONFIGFS is enabled:: 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun # ls /sys/kernel/config/pci_ep/functions 41*4882a593Smuzhiyun pci_epf_test 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunCreating pci-epf-test Device 45*4882a593Smuzhiyun---------------------------- 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunPCI endpoint function device can be created using the configfs. To create 48*4882a593Smuzhiyunpci-epf-test device, the following commands can be used:: 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun # mount -t configfs none /sys/kernel/config 51*4882a593Smuzhiyun # cd /sys/kernel/config/pci_ep/ 52*4882a593Smuzhiyun # mkdir functions/pci_epf_test/func1 53*4882a593Smuzhiyun 54*4882a593SmuzhiyunThe "mkdir func1" above creates the pci-epf-test function device that will 55*4882a593Smuzhiyunbe probed by pci_epf_test driver. 56*4882a593Smuzhiyun 57*4882a593SmuzhiyunThe PCI endpoint framework populates the directory with the following 58*4882a593Smuzhiyunconfigurable fields:: 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun # ls functions/pci_epf_test/func1 61*4882a593Smuzhiyun baseclass_code interrupt_pin progif_code subsys_id 62*4882a593Smuzhiyun cache_line_size msi_interrupts revid subsys_vendorid 63*4882a593Smuzhiyun deviceid msix_interrupts subclass_code vendorid 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunThe PCI endpoint function driver populates these entries with default values 66*4882a593Smuzhiyunwhen the device is bound to the driver. The pci-epf-test driver populates 67*4882a593Smuzhiyunvendorid with 0xffff and interrupt_pin with 0x0001:: 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun # cat functions/pci_epf_test/func1/vendorid 70*4882a593Smuzhiyun 0xffff 71*4882a593Smuzhiyun # cat functions/pci_epf_test/func1/interrupt_pin 72*4882a593Smuzhiyun 0x0001 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunConfiguring pci-epf-test Device 76*4882a593Smuzhiyun------------------------------- 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunThe user can configure the pci-epf-test device using configfs entry. In order 79*4882a593Smuzhiyunto change the vendorid and the number of MSI interrupts used by the function 80*4882a593Smuzhiyundevice, the following commands can be used:: 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun # echo 0x104c > functions/pci_epf_test/func1/vendorid 83*4882a593Smuzhiyun # echo 0xb500 > functions/pci_epf_test/func1/deviceid 84*4882a593Smuzhiyun # echo 16 > functions/pci_epf_test/func1/msi_interrupts 85*4882a593Smuzhiyun # echo 8 > functions/pci_epf_test/func1/msix_interrupts 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun 88*4882a593SmuzhiyunBinding pci-epf-test Device to EP Controller 89*4882a593Smuzhiyun-------------------------------------------- 90*4882a593Smuzhiyun 91*4882a593SmuzhiyunIn order for the endpoint function device to be useful, it has to be bound to 92*4882a593Smuzhiyuna PCI endpoint controller driver. Use the configfs to bind the function 93*4882a593Smuzhiyundevice to one of the controller driver present in the system:: 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun # ln -s functions/pci_epf_test/func1 controllers/51000000.pcie_ep/ 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunOnce the above step is completed, the PCI endpoint is ready to establish a link 98*4882a593Smuzhiyunwith the host. 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun 101*4882a593SmuzhiyunStart the Link 102*4882a593Smuzhiyun-------------- 103*4882a593Smuzhiyun 104*4882a593SmuzhiyunIn order for the endpoint device to establish a link with the host, the _start_ 105*4882a593Smuzhiyunfield should be populated with '1':: 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun # echo 1 > controllers/51000000.pcie_ep/start 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun 110*4882a593SmuzhiyunRootComplex Device 111*4882a593Smuzhiyun================== 112*4882a593Smuzhiyun 113*4882a593Smuzhiyunlspci Output 114*4882a593Smuzhiyun------------ 115*4882a593Smuzhiyun 116*4882a593SmuzhiyunNote that the devices listed here correspond to the value populated in 1.4 117*4882a593Smuzhiyunabove:: 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun 00:00.0 PCI bridge: Texas Instruments Device 8888 (rev 01) 120*4882a593Smuzhiyun 01:00.0 Unassigned class [ff00]: Texas Instruments Device b500 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun 123*4882a593SmuzhiyunUsing Endpoint Test function Device 124*4882a593Smuzhiyun----------------------------------- 125*4882a593Smuzhiyun 126*4882a593Smuzhiyunpcitest.sh added in tools/pci/ can be used to run all the default PCI endpoint 127*4882a593Smuzhiyuntests. To compile this tool the following commands should be used:: 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun # cd <kernel-dir> 130*4882a593Smuzhiyun # make -C tools/pci 131*4882a593Smuzhiyun 132*4882a593Smuzhiyunor if you desire to compile and install in your system:: 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun # cd <kernel-dir> 135*4882a593Smuzhiyun # make -C tools/pci install 136*4882a593Smuzhiyun 137*4882a593SmuzhiyunThe tool and script will be located in <rootfs>/usr/bin/ 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun 140*4882a593Smuzhiyunpcitest.sh Output 141*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~ 142*4882a593Smuzhiyun:: 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun # pcitest.sh 145*4882a593Smuzhiyun BAR tests 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun BAR0: OKAY 148*4882a593Smuzhiyun BAR1: OKAY 149*4882a593Smuzhiyun BAR2: OKAY 150*4882a593Smuzhiyun BAR3: OKAY 151*4882a593Smuzhiyun BAR4: NOT OKAY 152*4882a593Smuzhiyun BAR5: NOT OKAY 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun Interrupt tests 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun SET IRQ TYPE TO LEGACY: OKAY 157*4882a593Smuzhiyun LEGACY IRQ: NOT OKAY 158*4882a593Smuzhiyun SET IRQ TYPE TO MSI: OKAY 159*4882a593Smuzhiyun MSI1: OKAY 160*4882a593Smuzhiyun MSI2: OKAY 161*4882a593Smuzhiyun MSI3: OKAY 162*4882a593Smuzhiyun MSI4: OKAY 163*4882a593Smuzhiyun MSI5: OKAY 164*4882a593Smuzhiyun MSI6: OKAY 165*4882a593Smuzhiyun MSI7: OKAY 166*4882a593Smuzhiyun MSI8: OKAY 167*4882a593Smuzhiyun MSI9: OKAY 168*4882a593Smuzhiyun MSI10: OKAY 169*4882a593Smuzhiyun MSI11: OKAY 170*4882a593Smuzhiyun MSI12: OKAY 171*4882a593Smuzhiyun MSI13: OKAY 172*4882a593Smuzhiyun MSI14: OKAY 173*4882a593Smuzhiyun MSI15: OKAY 174*4882a593Smuzhiyun MSI16: OKAY 175*4882a593Smuzhiyun MSI17: NOT OKAY 176*4882a593Smuzhiyun MSI18: NOT OKAY 177*4882a593Smuzhiyun MSI19: NOT OKAY 178*4882a593Smuzhiyun MSI20: NOT OKAY 179*4882a593Smuzhiyun MSI21: NOT OKAY 180*4882a593Smuzhiyun MSI22: NOT OKAY 181*4882a593Smuzhiyun MSI23: NOT OKAY 182*4882a593Smuzhiyun MSI24: NOT OKAY 183*4882a593Smuzhiyun MSI25: NOT OKAY 184*4882a593Smuzhiyun MSI26: NOT OKAY 185*4882a593Smuzhiyun MSI27: NOT OKAY 186*4882a593Smuzhiyun MSI28: NOT OKAY 187*4882a593Smuzhiyun MSI29: NOT OKAY 188*4882a593Smuzhiyun MSI30: NOT OKAY 189*4882a593Smuzhiyun MSI31: NOT OKAY 190*4882a593Smuzhiyun MSI32: NOT OKAY 191*4882a593Smuzhiyun SET IRQ TYPE TO MSI-X: OKAY 192*4882a593Smuzhiyun MSI-X1: OKAY 193*4882a593Smuzhiyun MSI-X2: OKAY 194*4882a593Smuzhiyun MSI-X3: OKAY 195*4882a593Smuzhiyun MSI-X4: OKAY 196*4882a593Smuzhiyun MSI-X5: OKAY 197*4882a593Smuzhiyun MSI-X6: OKAY 198*4882a593Smuzhiyun MSI-X7: OKAY 199*4882a593Smuzhiyun MSI-X8: OKAY 200*4882a593Smuzhiyun MSI-X9: NOT OKAY 201*4882a593Smuzhiyun MSI-X10: NOT OKAY 202*4882a593Smuzhiyun MSI-X11: NOT OKAY 203*4882a593Smuzhiyun MSI-X12: NOT OKAY 204*4882a593Smuzhiyun MSI-X13: NOT OKAY 205*4882a593Smuzhiyun MSI-X14: NOT OKAY 206*4882a593Smuzhiyun MSI-X15: NOT OKAY 207*4882a593Smuzhiyun MSI-X16: NOT OKAY 208*4882a593Smuzhiyun [...] 209*4882a593Smuzhiyun MSI-X2047: NOT OKAY 210*4882a593Smuzhiyun MSI-X2048: NOT OKAY 211*4882a593Smuzhiyun 212*4882a593Smuzhiyun Read Tests 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun SET IRQ TYPE TO MSI: OKAY 215*4882a593Smuzhiyun READ ( 1 bytes): OKAY 216*4882a593Smuzhiyun READ ( 1024 bytes): OKAY 217*4882a593Smuzhiyun READ ( 1025 bytes): OKAY 218*4882a593Smuzhiyun READ (1024000 bytes): OKAY 219*4882a593Smuzhiyun READ (1024001 bytes): OKAY 220*4882a593Smuzhiyun 221*4882a593Smuzhiyun Write Tests 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun WRITE ( 1 bytes): OKAY 224*4882a593Smuzhiyun WRITE ( 1024 bytes): OKAY 225*4882a593Smuzhiyun WRITE ( 1025 bytes): OKAY 226*4882a593Smuzhiyun WRITE (1024000 bytes): OKAY 227*4882a593Smuzhiyun WRITE (1024001 bytes): OKAY 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun Copy Tests 230*4882a593Smuzhiyun 231*4882a593Smuzhiyun COPY ( 1 bytes): OKAY 232*4882a593Smuzhiyun COPY ( 1024 bytes): OKAY 233*4882a593Smuzhiyun COPY ( 1025 bytes): OKAY 234*4882a593Smuzhiyun COPY (1024000 bytes): OKAY 235*4882a593Smuzhiyun COPY (1024001 bytes): OKAY 236