@@ -74,6 +74,8 @@ static int receive_port = 4444;
74
74
static int buf_size = 32 ;
75
75
static int bidi ;
76
76
static int ipv6 ;
77
+ static int napi ;
78
+ static int napi_timeout ;
77
79
static int verbose ;
78
80
79
81
static int nr_bufs = 256 ;
@@ -1064,6 +1066,8 @@ static void usage(const char *name)
1064
1066
printf ("\t-r:\t\tPort to receive on (%d)\n" , receive_port );
1065
1067
printf ("\t-p:\t\tPort to connect to (%d)\n" , send_port );
1066
1068
printf ("\t-6:\t\tUse IPv6 (%d)\n" , ipv6 );
1069
+ printf ("\t-N:\t\tUse NAPI polling (%d)\n" , napi );
1070
+ printf ("\t-T:\t\tNAPI timeout (usec) (%d)\n" , napi_timeout );
1067
1071
printf ("\t-V:\t\tIncrease verbosity (%d)\n" , verbose );
1068
1072
}
1069
1073
@@ -1164,7 +1168,7 @@ int main(int argc, char *argv[])
1164
1168
return 1 ;
1165
1169
}
1166
1170
1167
- while ((opt = getopt (argc , argv , "m:d:S:s:b:f:H:r:p:n:B:6Vh?" )) != -1 ) {
1171
+ while ((opt = getopt (argc , argv , "m:d:S:s:b:f:H:r:p:n:B:N:T: 6Vh?" )) != -1 ) {
1168
1172
switch (opt ) {
1169
1173
case 'm' :
1170
1174
mshot = !!atoi (optarg );
@@ -1199,6 +1203,12 @@ int main(int argc, char *argv[])
1199
1203
case 'B' :
1200
1204
bidi = !!atoi (optarg );
1201
1205
break ;
1206
+ case 'N' :
1207
+ napi = !!atoi (optarg );
1208
+ break ;
1209
+ case 'T' :
1210
+ napi_timeout = atoi (optarg );
1211
+ break ;
1202
1212
case '6' :
1203
1213
ipv6 = true;
1204
1214
break ;
@@ -1333,11 +1343,27 @@ int main(int argc, char *argv[])
1333
1343
}
1334
1344
}
1335
1345
1346
+ if (napi ) {
1347
+ struct io_uring_napi n = {
1348
+ .prefer_busy_poll = napi > 1 ? 1 : 0 ,
1349
+ .busy_poll_to = napi_timeout ,
1350
+ };
1351
+
1352
+ ret = io_uring_register_napi (& ring , & n );
1353
+ if (ret ) {
1354
+ fprintf (stderr , "io_uring_register_napi: %d\n" , ret );
1355
+ if (ret != - EINVAL )
1356
+ return 1 ;
1357
+ fprintf (stderr , "NAPI not available, turned off\n" );
1358
+ }
1359
+ }
1360
+
1336
1361
printf ("Backend: multishot=%d, sqpoll=%d, defer_tw=%d, fixed_files=%d "
1337
1362
"is_sink=%d, buf_size=%d, nr_bufs=%d, host=%s, send_port=%d "
1338
- "receive_port=%d\n" ,
1363
+ "receive_port=%d, napi=%d, napi_timeout=%d \n" ,
1339
1364
mshot , sqpoll , defer_tw , fixed_files , is_sink ,
1340
- buf_size , nr_bufs , host , send_port , receive_port );
1365
+ buf_size , nr_bufs , host , send_port , receive_port ,
1366
+ napi , napi_timeout );
1341
1367
1342
1368
return event_loop (& ring , fd );
1343
1369
}
0 commit comments