pci-test-howto.rst 5.9 KB

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