Skip to content

Commit 61f7785

Browse files
samikhawajaNipaLocal
authored and
NipaLocal
committed
selftests: Add napi threaded busy poll test in busy_poller
Add testcase to run busy poll test with threaded napi busy poll enabled. Signed-off-by: Samiullah Khawaja <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent ccd2948 commit 61f7785

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

tools/testing/selftests/net/busy_poll_test.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ NAPI_DEFER_HARD_IRQS=100
2727
GRO_FLUSH_TIMEOUT=50000
2828
SUSPEND_TIMEOUT=20000000
2929

30+
# NAPI threaded busy poll config
31+
NAPI_THREADED_POLL=2
32+
3033
setup_ns()
3134
{
3235
set -e
@@ -62,6 +65,9 @@ cleanup_ns()
6265
test_busypoll()
6366
{
6467
suspend_value=${1:-0}
68+
napi_threaded_value=${2:-0}
69+
prefer_busy_poll_value=${3:-$PREFER_BUSY_POLL}
70+
6571
tmp_file=$(mktemp)
6672
out_file=$(mktemp)
6773

@@ -73,10 +79,11 @@ test_busypoll()
7379
-b${SERVER_IP} \
7480
-m${MAX_EVENTS} \
7581
-u${BUSY_POLL_USECS} \
76-
-P${PREFER_BUSY_POLL} \
82+
-P${prefer_busy_poll_value} \
7783
-g${BUSY_POLL_BUDGET} \
7884
-i${NSIM_SV_IFIDX} \
7985
-s${suspend_value} \
86+
-t${napi_threaded_value} \
8087
-o${out_file}&
8188

8289
wait_local_port_listen nssv ${SERVER_PORT} tcp
@@ -109,6 +116,15 @@ test_busypoll_with_suspend()
109116
return $?
110117
}
111118

119+
test_busypoll_with_napi_threaded()
120+
{
121+
# Only enable napi threaded poll. Set suspend timeout and prefer busy
122+
# poll to 0.
123+
test_busypoll 0 ${NAPI_THREADED_POLL} 0
124+
125+
return $?
126+
}
127+
112128
###
113129
### Code start
114130
###
@@ -154,6 +170,13 @@ if [ $? -ne 0 ]; then
154170
exit 1
155171
fi
156172

173+
test_busypoll_with_napi_threaded
174+
if [ $? -ne 0 ]; then
175+
echo "test_busypoll_with_napi_threaded failed"
176+
cleanup_ns
177+
exit 1
178+
fi
179+
157180
echo "$NSIM_SV_FD:$NSIM_SV_IFIDX" > $NSIM_DEV_SYS_UNLINK
158181

159182
echo $NSIM_CL_ID > $NSIM_DEV_SYS_DEL

tools/testing/selftests/net/busy_poller.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ static uint32_t cfg_busy_poll_usecs;
6565
static uint16_t cfg_busy_poll_budget;
6666
static uint8_t cfg_prefer_busy_poll;
6767

68-
/* IRQ params */
68+
/* NAPI params */
6969
static uint32_t cfg_defer_hard_irqs;
7070
static uint64_t cfg_gro_flush_timeout;
7171
static uint64_t cfg_irq_suspend_timeout;
72+
static enum netdev_napi_threaded cfg_napi_threaded_poll = NETDEV_NAPI_THREADED_DISABLE;
7273

7374
static void usage(const char *filepath)
7475
{
7576
error(1, 0,
76-
"Usage: %s -p<port> -b<addr> -m<max_events> -u<busy_poll_usecs> -P<prefer_busy_poll> -g<busy_poll_budget> -o<outfile> -d<defer_hard_irqs> -r<gro_flush_timeout> -s<irq_suspend_timeout> -i<ifindex>",
77+
"Usage: %s -p<port> -b<addr> -m<max_events> -u<busy_poll_usecs> -P<prefer_busy_poll> -g<busy_poll_budget> -o<outfile> -d<defer_hard_irqs> -r<gro_flush_timeout> -s<irq_suspend_timeout> -t<napi_threaded_poll> -i<ifindex>",
7778
filepath);
7879
}
7980

@@ -86,7 +87,7 @@ static void parse_opts(int argc, char **argv)
8687
if (argc <= 1)
8788
usage(argv[0]);
8889

89-
while ((c = getopt(argc, argv, "p:m:b:u:P:g:o:d:r:s:i:")) != -1) {
90+
while ((c = getopt(argc, argv, "p:m:b:u:P:g:o:d:r:s:i:t:")) != -1) {
9091
/* most options take integer values, except o and b, so reduce
9192
* code duplication a bit for the common case by calling
9293
* strtoull here and leave bounds checking and casting per
@@ -168,6 +169,12 @@ static void parse_opts(int argc, char **argv)
168169

169170
cfg_ifindex = (int)tmp;
170171
break;
172+
case 't':
173+
if (tmp == ULLONG_MAX || tmp > 2)
174+
error(1, ERANGE, "napi threaded poll value must be 0-2");
175+
176+
cfg_napi_threaded_poll = (enum netdev_napi_threaded)tmp;
177+
break;
171178
}
172179
}
173180

@@ -246,6 +253,7 @@ static void setup_queue(void)
246253
cfg_gro_flush_timeout);
247254
netdev_napi_set_req_set_irq_suspend_timeout(set_req,
248255
cfg_irq_suspend_timeout);
256+
netdev_napi_set_req_set_threaded(set_req, cfg_napi_threaded_poll);
249257

250258
if (netdev_napi_set(ys, set_req))
251259
error(1, 0, "can't set NAPI params: %s\n", yerr.msg);

0 commit comments

Comments
 (0)