Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Userspace PCI Endpoint Test Module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2017 Texas Instruments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Author: Kishon Vijay Abraham I <kishon@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <sys/ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/pcitest.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define BILLION 1E9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static char *result[] = { "NOT OKAY", "OKAY" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static char *irq[] = { "LEGACY", "MSI", "MSI-X" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) struct pci_test {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	char		*device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	char		barnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	bool		legacyirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	unsigned int	msinum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	unsigned int	msixnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	int		irqtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	bool		set_irqtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	bool		get_irqtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	bool		clear_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	bool		read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	bool		write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	bool		copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	unsigned long	size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	bool		use_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) static int run_test(struct pci_test *test)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	struct pci_endpoint_test_xfer_param param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	int fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	fd = open(test->device, O_RDWR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	if (fd < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		perror("can't open PCI Endpoint Test device");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (test->barnum >= 0 && test->barnum <= 5) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		ret = ioctl(fd, PCITEST_BAR, test->barnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		fprintf(stdout, "BAR%d:\t\t", test->barnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			fprintf(stdout, "TEST FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if (test->set_irqtype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		ret = ioctl(fd, PCITEST_SET_IRQTYPE, test->irqtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		fprintf(stdout, "SET IRQ TYPE TO %s:\t\t", irq[test->irqtype]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			fprintf(stdout, "FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (test->get_irqtype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		ret = ioctl(fd, PCITEST_GET_IRQTYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		fprintf(stdout, "GET IRQ TYPE:\t\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			fprintf(stdout, "FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			fprintf(stdout, "%s\n", irq[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	if (test->clear_irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		ret = ioctl(fd, PCITEST_CLEAR_IRQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		fprintf(stdout, "CLEAR IRQ:\t\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			fprintf(stdout, "FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (test->legacyirq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		ret = ioctl(fd, PCITEST_LEGACY_IRQ, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		fprintf(stdout, "LEGACY IRQ:\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			fprintf(stdout, "TEST FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if (test->msinum > 0 && test->msinum <= 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		ret = ioctl(fd, PCITEST_MSI, test->msinum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		fprintf(stdout, "MSI%d:\t\t", test->msinum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			fprintf(stdout, "TEST FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (test->msixnum > 0 && test->msixnum <= 2048) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		ret = ioctl(fd, PCITEST_MSIX, test->msixnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		fprintf(stdout, "MSI-X%d:\t\t", test->msixnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			fprintf(stdout, "TEST FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (test->write) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		param.size = test->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		if (test->use_dma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			param.flags = PCITEST_FLAGS_USE_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		ret = ioctl(fd, PCITEST_WRITE, &param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			fprintf(stdout, "TEST FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (test->read) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		param.size = test->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		if (test->use_dma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			param.flags = PCITEST_FLAGS_USE_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		ret = ioctl(fd, PCITEST_READ, &param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			fprintf(stdout, "TEST FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	if (test->copy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		param.size = test->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		if (test->use_dma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			param.flags = PCITEST_FLAGS_USE_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		ret = ioctl(fd, PCITEST_COPY, &param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			fprintf(stdout, "TEST FAILED\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			fprintf(stdout, "%s\n", result[ret]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	fflush(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	close(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) int main(int argc, char **argv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	int c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	struct pci_test *test;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	test = calloc(1, sizeof(*test));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	if (!test) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		perror("Fail to allocate memory for pci_test\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	/* since '0' is a valid BAR number, initialize it to -1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	test->barnum = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	/* set default size as 100KB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	test->size = 0x19000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	/* set default endpoint device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	test->device = "/dev/pci-endpoint-test.0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) != EOF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	switch (c) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	case 'D':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		test->device = optarg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	case 'b':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		test->barnum = atoi(optarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		if (test->barnum < 0 || test->barnum > 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			goto usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	case 'l':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		test->legacyirq = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	case 'm':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		test->msinum = atoi(optarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		if (test->msinum < 1 || test->msinum > 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			goto usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	case 'x':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		test->msixnum = atoi(optarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		if (test->msixnum < 1 || test->msixnum > 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			goto usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	case 'i':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		test->irqtype = atoi(optarg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (test->irqtype < 0 || test->irqtype > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			goto usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		test->set_irqtype = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	case 'I':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		test->get_irqtype = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	case 'r':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		test->read = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	case 'w':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		test->write = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	case 'c':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		test->copy = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	case 'e':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		test->clear_irq = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	case 's':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		test->size = strtoul(optarg, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	case 'd':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		test->use_dma = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	case 'h':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		fprintf(stderr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 			"usage: %s [options]\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			"Options:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 			"\t-D <dev>		PCI endpoint test device {default: /dev/pci-endpoint-test.0}\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			"\t-b <bar num>		BAR test (bar number between 0..5)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			"\t-m <msi num>		MSI test (msi number between 1..32)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			"\t-x <msix num>	\tMSI-X test (msix number between 1..2048)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			"\t-i <irq type>	\tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			"\t-e			Clear IRQ\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			"\t-I			Get current IRQ type configured\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			"\t-d			Use DMA\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			"\t-l			Legacy IRQ test\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			"\t-r			Read buffer test\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			"\t-w			Write buffer test\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			"\t-c			Copy buffer test\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			"\t-s <size>		Size of buffer {default: 100KB}\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			"\t-h			Print this help message\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			argv[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	return run_test(test);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }