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