Skip to content

Commit 392188b

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
selftests: pci_endpoint: Migrate to Kselftest framework
Migrate the PCI endpoint test to Kselftest framework. All the tests that were part of the previous pcitest.sh file were migrated. Below is the list of tests converted: 1. BAR0 Test 2. BAR1 Test 3. BAR2 Test 4. BAR3 Test 5. BAR4 Test 6. BAR5 Test 7. Consecutive BAR Tests 8. Legacy IRQ Tests 9. MSI Interrupt Tests (MSI1 to MSI32) 10. MSI-X Interrupt Tests (MSI-X1 to MSI-X2048) 11. Read Tests - MEMCPY (For 1, 1024, 1025, 1024000, 1024001 Bytes) 12. Write Tests - MEMCPY (For 1, 1024, 1025, 1024000, 1024001 Bytes) 13. Copy Tests - MEMCPY (For 1, 1024, 1025, 1024000, 1024001 Bytes) 14. Read Tests - DMA (For 1, 1024, 1025, 1024000, 1024001 Bytes) 15. Write Tests - DMA (For 1, 1024, 1025, 1024000, 1024001 Bytes) 16. Copy Tests - DMA (For 1, 1024, 1025, 1024000, 1024001 Bytes) BAR, DMA and MEMCPY tests are added as fixture variants and can be executed separately as below: $ pci_endpoint_test -v BAR0 $ pci_endpoint_test -v dma $ pci_endpoint_test -v memcpy Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Aman Gupta <[email protected]> Co-developed-by: Padmanabhan Rajanbabu <[email protected]> [mani: reworked based on the IOCTL fix, cleanups, documentation, commit message] Signed-off-by: Aman Gupta <[email protected]> Signed-off-by: Padmanabhan Rajanbabu <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Tested-by: Niklas Cassel <[email protected]> Reviewed-by: Niklas Cassel <[email protected]>
1 parent e19bde2 commit 392188b

File tree

9 files changed

+302
-498
lines changed

9 files changed

+302
-498
lines changed

Documentation/PCI/endpoint/pci-test-howto.rst

Lines changed: 71 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ device, the following commands can be used::
8181

8282
# echo 0x104c > functions/pci_epf_test/func1/vendorid
8383
# echo 0xb500 > functions/pci_epf_test/func1/deviceid
84-
# echo 16 > functions/pci_epf_test/func1/msi_interrupts
85-
# echo 8 > functions/pci_epf_test/func1/msix_interrupts
84+
# echo 32 > functions/pci_epf_test/func1/msi_interrupts
85+
# echo 2048 > functions/pci_epf_test/func1/msix_interrupts
8686

8787

8888
Binding pci-epf-test Device to EP Controller
@@ -123,114 +123,83 @@ above::
123123
Using Endpoint Test function Device
124124
-----------------------------------
125125

126-
pcitest.sh added in tools/testing/selftests/pci_endpoint can be used to run all
127-
the default PCI endpoint tests. To compile this tool the following commands
128-
should be used::
126+
Kselftest added in tools/testing/selftests/pci_endpoint can be used to run all
127+
the default PCI endpoint tests. To build the Kselftest for PCI endpoint
128+
subsystem, the following commands should be used::
129129

130130
# cd <kernel-dir>
131131
# make -C tools/testing/selftests/pci_endpoint
132132

133133
or if you desire to compile and install in your system::
134134

135135
# cd <kernel-dir>
136-
# make -C tools/testing/selftests/pci_endpoint install
136+
# make -C tools/testing/selftests/pci_endpoint INSTALL_PATH=/usr/bin install
137137

138-
The tool and script will be located in <rootfs>/usr/bin/
138+
The test will be located in <rootfs>/usr/bin/
139139

140-
141-
pcitest.sh Output
142-
~~~~~~~~~~~~~~~~~
140+
Kselftest Output
141+
~~~~~~~~~~~~~~~~
143142
::
144143

145-
# pcitest.sh
146-
BAR tests
147-
148-
BAR0: OKAY
149-
BAR1: OKAY
150-
BAR2: OKAY
151-
BAR3: OKAY
152-
BAR4: NOT OKAY
153-
BAR5: NOT OKAY
154-
155-
Interrupt tests
156-
157-
SET IRQ TYPE TO LEGACY: OKAY
158-
LEGACY IRQ: NOT OKAY
159-
SET IRQ TYPE TO MSI: OKAY
160-
MSI1: OKAY
161-
MSI2: OKAY
162-
MSI3: OKAY
163-
MSI4: OKAY
164-
MSI5: OKAY
165-
MSI6: OKAY
166-
MSI7: OKAY
167-
MSI8: OKAY
168-
MSI9: OKAY
169-
MSI10: OKAY
170-
MSI11: OKAY
171-
MSI12: OKAY
172-
MSI13: OKAY
173-
MSI14: OKAY
174-
MSI15: OKAY
175-
MSI16: OKAY
176-
MSI17: NOT OKAY
177-
MSI18: NOT OKAY
178-
MSI19: NOT OKAY
179-
MSI20: NOT OKAY
180-
MSI21: NOT OKAY
181-
MSI22: NOT OKAY
182-
MSI23: NOT OKAY
183-
MSI24: NOT OKAY
184-
MSI25: NOT OKAY
185-
MSI26: NOT OKAY
186-
MSI27: NOT OKAY
187-
MSI28: NOT OKAY
188-
MSI29: NOT OKAY
189-
MSI30: NOT OKAY
190-
MSI31: NOT OKAY
191-
MSI32: NOT OKAY
192-
SET IRQ TYPE TO MSI-X: OKAY
193-
MSI-X1: OKAY
194-
MSI-X2: OKAY
195-
MSI-X3: OKAY
196-
MSI-X4: OKAY
197-
MSI-X5: OKAY
198-
MSI-X6: OKAY
199-
MSI-X7: OKAY
200-
MSI-X8: OKAY
201-
MSI-X9: NOT OKAY
202-
MSI-X10: NOT OKAY
203-
MSI-X11: NOT OKAY
204-
MSI-X12: NOT OKAY
205-
MSI-X13: NOT OKAY
206-
MSI-X14: NOT OKAY
207-
MSI-X15: NOT OKAY
208-
MSI-X16: NOT OKAY
209-
[...]
210-
MSI-X2047: NOT OKAY
211-
MSI-X2048: NOT OKAY
212-
213-
Read Tests
214-
215-
SET IRQ TYPE TO MSI: OKAY
216-
READ ( 1 bytes): OKAY
217-
READ ( 1024 bytes): OKAY
218-
READ ( 1025 bytes): OKAY
219-
READ (1024000 bytes): OKAY
220-
READ (1024001 bytes): OKAY
221-
222-
Write Tests
223-
224-
WRITE ( 1 bytes): OKAY
225-
WRITE ( 1024 bytes): OKAY
226-
WRITE ( 1025 bytes): OKAY
227-
WRITE (1024000 bytes): OKAY
228-
WRITE (1024001 bytes): OKAY
229-
230-
Copy Tests
231-
232-
COPY ( 1 bytes): OKAY
233-
COPY ( 1024 bytes): OKAY
234-
COPY ( 1025 bytes): OKAY
235-
COPY (1024000 bytes): OKAY
236-
COPY (1024001 bytes): OKAY
144+
# pci_endpoint_test
145+
TAP version 13
146+
1..16
147+
# Starting 16 tests from 9 test cases.
148+
# RUN pci_ep_bar.BAR0.BAR_TEST ...
149+
# OK pci_ep_bar.BAR0.BAR_TEST
150+
ok 1 pci_ep_bar.BAR0.BAR_TEST
151+
# RUN pci_ep_bar.BAR1.BAR_TEST ...
152+
# OK pci_ep_bar.BAR1.BAR_TEST
153+
ok 2 pci_ep_bar.BAR1.BAR_TEST
154+
# RUN pci_ep_bar.BAR2.BAR_TEST ...
155+
# OK pci_ep_bar.BAR2.BAR_TEST
156+
ok 3 pci_ep_bar.BAR2.BAR_TEST
157+
# RUN pci_ep_bar.BAR3.BAR_TEST ...
158+
# OK pci_ep_bar.BAR3.BAR_TEST
159+
ok 4 pci_ep_bar.BAR3.BAR_TEST
160+
# RUN pci_ep_bar.BAR4.BAR_TEST ...
161+
# OK pci_ep_bar.BAR4.BAR_TEST
162+
ok 5 pci_ep_bar.BAR4.BAR_TEST
163+
# RUN pci_ep_bar.BAR5.BAR_TEST ...
164+
# OK pci_ep_bar.BAR5.BAR_TEST
165+
ok 6 pci_ep_bar.BAR5.BAR_TEST
166+
# RUN pci_ep_basic.CONSECUTIVE_BAR_TEST ...
167+
# OK pci_ep_basic.CONSECUTIVE_BAR_TEST
168+
ok 7 pci_ep_basic.CONSECUTIVE_BAR_TEST
169+
# RUN pci_ep_basic.LEGACY_IRQ_TEST ...
170+
# OK pci_ep_basic.LEGACY_IRQ_TEST
171+
ok 8 pci_ep_basic.LEGACY_IRQ_TEST
172+
# RUN pci_ep_basic.MSI_TEST ...
173+
# OK pci_ep_basic.MSI_TEST
174+
ok 9 pci_ep_basic.MSI_TEST
175+
# RUN pci_ep_basic.MSIX_TEST ...
176+
# OK pci_ep_basic.MSIX_TEST
177+
ok 10 pci_ep_basic.MSIX_TEST
178+
# RUN pci_ep_data_transfer.memcpy.READ_TEST ...
179+
# OK pci_ep_data_transfer.memcpy.READ_TEST
180+
ok 11 pci_ep_data_transfer.memcpy.READ_TEST
181+
# RUN pci_ep_data_transfer.memcpy.WRITE_TEST ...
182+
# OK pci_ep_data_transfer.memcpy.WRITE_TEST
183+
ok 12 pci_ep_data_transfer.memcpy.WRITE_TEST
184+
# RUN pci_ep_data_transfer.memcpy.COPY_TEST ...
185+
# OK pci_ep_data_transfer.memcpy.COPY_TEST
186+
ok 13 pci_ep_data_transfer.memcpy.COPY_TEST
187+
# RUN pci_ep_data_transfer.dma.READ_TEST ...
188+
# OK pci_ep_data_transfer.dma.READ_TEST
189+
ok 14 pci_ep_data_transfer.dma.READ_TEST
190+
# RUN pci_ep_data_transfer.dma.WRITE_TEST ...
191+
# OK pci_ep_data_transfer.dma.WRITE_TEST
192+
ok 15 pci_ep_data_transfer.dma.WRITE_TEST
193+
# RUN pci_ep_data_transfer.dma.COPY_TEST ...
194+
# OK pci_ep_data_transfer.dma.COPY_TEST
195+
ok 16 pci_ep_data_transfer.dma.COPY_TEST
196+
# PASSED: 16 / 16 tests passed.
197+
# Totals: pass:16 fail:0 xfail:0 xpass:0 skip:0 error:0
198+
199+
200+
Testcase 16 (pci_ep_data_transfer.dma.COPY_TEST) will fail for most of the DMA
201+
capable endpoint controllers due to the absence of the MEMCPY over DMA. For such
202+
controllers, it is advisable to skip this testcase using this
203+
command::
204+
205+
# pci_endpoint_test -f pci_ep_bar -f pci_ep_basic -v memcpy -T COPY_TEST -v dma

tools/testing/selftests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ TARGETS += net/packetdrill
7272
TARGETS += net/rds
7373
TARGETS += net/tcp_ao
7474
TARGETS += nsfs
75+
TARGETS += pci_endpoint
7576
TARGETS += pcie_bwctrl
7677
TARGETS += perf_events
7778
TARGETS += pidfd
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
*.o
3-
pcitest
2+
pci_endpoint_test

tools/testing/selftests/pci_endpoint/Build

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
include ../../../scripts/Makefile.include
2+
CFLAGS += -O2 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
3+
LDFLAGS += -lrt -lpthread -lm
34

4-
bindir ?= /usr/bin
5+
TEST_GEN_PROGS = pci_endpoint_test
56

6-
ifeq ($(srctree),)
7-
srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR)))
8-
endif
9-
10-
# Do not use make's built-in rules
11-
# (this improves performance and avoids hard-to-debug behaviour);
12-
MAKEFLAGS += -r
13-
14-
CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
15-
16-
ALL_TARGETS := pcitest
17-
ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
18-
19-
SCRIPTS := pcitest.sh
20-
21-
all: $(ALL_PROGRAMS)
22-
23-
export srctree OUTPUT CC LD CFLAGS
24-
include $(srctree)/tools/build/Makefile.include
25-
26-
#
27-
# We need the following to be outside of kernel tree
28-
#
29-
$(OUTPUT)include/linux/: ../../../../include/uapi/linux/
30-
mkdir -p $(OUTPUT)include/linux/ 2>&1 || true
31-
ln -sf $(CURDIR)/../../../../include/uapi/linux/pcitest.h $@
32-
33-
$(info ${CURDIR})
34-
prepare: $(OUTPUT)include/linux/
35-
36-
PCITEST_IN := $(OUTPUT)pcitest-in.o
37-
$(PCITEST_IN): prepare FORCE
38-
$(Q)$(MAKE) $(build)=pcitest
39-
$(OUTPUT)pcitest: $(PCITEST_IN)
40-
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
41-
42-
clean:
43-
rm -f $(ALL_PROGRAMS)
44-
rm -rf $(OUTPUT)include/
45-
find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
46-
47-
install: $(ALL_PROGRAMS)
48-
install -d -m 755 $(DESTDIR)$(bindir); \
49-
for program in $(ALL_PROGRAMS); do \
50-
install $$program $(DESTDIR)$(bindir); \
51-
done; \
52-
for script in $(SCRIPTS); do \
53-
install $$script $(DESTDIR)$(bindir); \
54-
done
55-
56-
FORCE:
57-
58-
.PHONY: all install clean FORCE prepare
7+
include ../lib.mk
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_PCI_ENDPOINT=y
2+
CONFIG_PCI_ENDPOINT_CONFIGFS=y
3+
CONFIG_PCI_EPF_TEST=m
4+
CONFIG_PCI_ENDPOINT_TEST=m

0 commit comments

Comments
 (0)