@@ -34,10 +34,12 @@ struct pci_test {
34
34
bool write ;
35
35
bool copy ;
36
36
unsigned long size ;
37
+ bool use_dma ;
37
38
};
38
39
39
40
static int run_test (struct pci_test * test )
40
41
{
42
+ struct pci_endpoint_test_xfer_param param ;
41
43
int ret = - EINVAL ;
42
44
int fd ;
43
45
@@ -102,7 +104,10 @@ static int run_test(struct pci_test *test)
102
104
}
103
105
104
106
if (test -> write ) {
105
- ret = ioctl (fd , PCITEST_WRITE , test -> size );
107
+ param .size = test -> size ;
108
+ if (test -> use_dma )
109
+ param .flags = PCITEST_FLAGS_USE_DMA ;
110
+ ret = ioctl (fd , PCITEST_WRITE , & param );
106
111
fprintf (stdout , "WRITE (%7ld bytes):\t\t" , test -> size );
107
112
if (ret < 0 )
108
113
fprintf (stdout , "TEST FAILED\n" );
@@ -111,7 +116,10 @@ static int run_test(struct pci_test *test)
111
116
}
112
117
113
118
if (test -> read ) {
114
- ret = ioctl (fd , PCITEST_READ , test -> size );
119
+ param .size = test -> size ;
120
+ if (test -> use_dma )
121
+ param .flags = PCITEST_FLAGS_USE_DMA ;
122
+ ret = ioctl (fd , PCITEST_READ , & param );
115
123
fprintf (stdout , "READ (%7ld bytes):\t\t" , test -> size );
116
124
if (ret < 0 )
117
125
fprintf (stdout , "TEST FAILED\n" );
@@ -120,7 +128,10 @@ static int run_test(struct pci_test *test)
120
128
}
121
129
122
130
if (test -> copy ) {
123
- ret = ioctl (fd , PCITEST_COPY , test -> size );
131
+ param .size = test -> size ;
132
+ if (test -> use_dma )
133
+ param .flags = PCITEST_FLAGS_USE_DMA ;
134
+ ret = ioctl (fd , PCITEST_COPY , & param );
124
135
fprintf (stdout , "COPY (%7ld bytes):\t\t" , test -> size );
125
136
if (ret < 0 )
126
137
fprintf (stdout , "TEST FAILED\n" );
@@ -153,7 +164,7 @@ int main(int argc, char **argv)
153
164
/* set default endpoint device */
154
165
test -> device = "/dev/pci-endpoint-test.0" ;
155
166
156
- while ((c = getopt (argc , argv , "D:b:m:x:i:Ilhrwcs :" )) != EOF )
167
+ while ((c = getopt (argc , argv , "D:b:m:x:i:dIlhrwcs :" )) != EOF )
157
168
switch (c ) {
158
169
case 'D' :
159
170
test -> device = optarg ;
@@ -197,6 +208,9 @@ int main(int argc, char **argv)
197
208
case 's' :
198
209
test -> size = strtoul (optarg , NULL , 0 );
199
210
continue ;
211
+ case 'd' :
212
+ test -> use_dma = true;
213
+ continue ;
200
214
case 'h' :
201
215
default :
202
216
usage :
@@ -209,6 +223,7 @@ int main(int argc, char **argv)
209
223
"\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n"
210
224
"\t-i <irq type> \tSet IRQ type (0 - Legacy, 1 - MSI, 2 - MSI-X)\n"
211
225
"\t-I Get current IRQ type configured\n"
226
+ "\t-d Use DMA\n"
212
227
"\t-l Legacy IRQ test\n"
213
228
"\t-r Read buffer test\n"
214
229
"\t-w Write buffer test\n"
0 commit comments