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