tools: PCI: Add 'd' command line option to support DMA
Add a new command line option 'd' to use DMA for data transfers. It should be used with read, write or copy commands. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Tested-by: Alan Mikhak <alan.mikhak@sifive.com>
This commit is contained in:
parent
0a121f9bc3
commit
73c5762652
|
@ -20,4 +20,11 @@
|
||||||
#define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int)
|
#define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int)
|
||||||
#define PCITEST_GET_IRQTYPE _IO('P', 0x9)
|
#define PCITEST_GET_IRQTYPE _IO('P', 0x9)
|
||||||
|
|
||||||
|
#define PCITEST_FLAGS_USE_DMA 0x00000001
|
||||||
|
|
||||||
|
struct pci_endpoint_test_xfer_param {
|
||||||
|
unsigned long size;
|
||||||
|
unsigned char flags;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __UAPI_LINUX_PCITEST_H */
|
#endif /* __UAPI_LINUX_PCITEST_H */
|
||||||
|
|
|
@ -34,10 +34,12 @@ struct pci_test {
|
||||||
bool write;
|
bool write;
|
||||||
bool copy;
|
bool copy;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
bool use_dma;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int run_test(struct pci_test *test)
|
static int run_test(struct pci_test *test)
|
||||||
{
|
{
|
||||||
|
struct pci_endpoint_test_xfer_param param;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -102,7 +104,10 @@ static int run_test(struct pci_test *test)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test->write) {
|
if (test->write) {
|
||||||
ret = ioctl(fd, PCITEST_WRITE, test->size);
|
param.size = test->size;
|
||||||
|
if (test->use_dma)
|
||||||
|
param.flags = PCITEST_FLAGS_USE_DMA;
|
||||||
|
ret = ioctl(fd, PCITEST_WRITE, ¶m);
|
||||||
fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
|
fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
fprintf(stdout, "TEST FAILED\n");
|
fprintf(stdout, "TEST FAILED\n");
|
||||||
|
@ -111,7 +116,10 @@ static int run_test(struct pci_test *test)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test->read) {
|
if (test->read) {
|
||||||
ret = ioctl(fd, PCITEST_READ, test->size);
|
param.size = test->size;
|
||||||
|
if (test->use_dma)
|
||||||
|
param.flags = PCITEST_FLAGS_USE_DMA;
|
||||||
|
ret = ioctl(fd, PCITEST_READ, ¶m);
|
||||||
fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
|
fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
fprintf(stdout, "TEST FAILED\n");
|
fprintf(stdout, "TEST FAILED\n");
|
||||||
|
@ -120,7 +128,10 @@ static int run_test(struct pci_test *test)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test->copy) {
|
if (test->copy) {
|
||||||
ret = ioctl(fd, PCITEST_COPY, test->size);
|
param.size = test->size;
|
||||||
|
if (test->use_dma)
|
||||||
|
param.flags = PCITEST_FLAGS_USE_DMA;
|
||||||
|
ret = ioctl(fd, PCITEST_COPY, ¶m);
|
||||||
fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
|
fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
fprintf(stdout, "TEST FAILED\n");
|
fprintf(stdout, "TEST FAILED\n");
|
||||||
|
@ -153,7 +164,7 @@ int main(int argc, char **argv)
|
||||||
/* set default endpoint device */
|
/* set default endpoint device */
|
||||||
test->device = "/dev/pci-endpoint-test.0";
|
test->device = "/dev/pci-endpoint-test.0";
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "D:b:m:x:i:Ilhrwcs:")) != EOF)
|
while ((c = getopt(argc, argv, "D:b:m:x:i:dIlhrwcs:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'D':
|
case 'D':
|
||||||
test->device = optarg;
|
test->device = optarg;
|
||||||
|
@ -197,6 +208,9 @@ int main(int argc, char **argv)
|
||||||
case 's':
|
case 's':
|
||||||
test->size = strtoul(optarg, NULL, 0);
|
test->size = strtoul(optarg, NULL, 0);
|
||||||
continue;
|
continue;
|
||||||
|
case 'd':
|
||||||
|
test->use_dma = true;
|
||||||
|
continue;
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
usage:
|
usage:
|
||||||
|
@ -209,6 +223,7 @@ usage:
|
||||||
"\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n"
|
"\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n"
|
||||||
"\t-i <irq type> \tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n"
|
"\t-i <irq type> \tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n"
|
||||||
"\t-I Get current IRQ type configured\n"
|
"\t-I Get current IRQ type configured\n"
|
||||||
|
"\t-d Use DMA\n"
|
||||||
"\t-l Legacy IRQ test\n"
|
"\t-l Legacy IRQ test\n"
|
||||||
"\t-r Read buffer test\n"
|
"\t-r Read buffer test\n"
|
||||||
"\t-w Write buffer test\n"
|
"\t-w Write buffer test\n"
|
||||||
|
|
Loading…
Reference in New Issue