Commit add3c132 authored by Samiullah Khawaja's avatar Samiullah Khawaja Committed by Jakub Kicinski
Browse files

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: default avatarSamiullah Khawaja <skhawaja@google.com>
Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
Acked-by: default avatarMartin Karsten <mkarsten@uwaterloo.ca>
Tested-by: default avatarMartin Karsten <mkarsten@uwaterloo.ca>
Link: https://patch.msgid.link/20251028203007.575686-3-skhawaja@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c18d4b19
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ NAPI_DEFER_HARD_IRQS=100
GRO_FLUSH_TIMEOUT=50000
SUSPEND_TIMEOUT=20000000

NAPI_THREADED_MODE_BUSY_POLL=2

setup_ns()
{
	set -e
@@ -62,6 +64,9 @@ cleanup_ns()
test_busypoll()
{
	suspend_value=${1:-0}
	napi_threaded_value=${2:-0}
	prefer_busy_poll_value=${3:-$PREFER_BUSY_POLL}

	tmp_file=$(mktemp)
	out_file=$(mktemp)

@@ -73,10 +78,11 @@ test_busypoll()
					     -b${SERVER_IP}        \
					     -m${MAX_EVENTS}       \
					     -u${BUSY_POLL_USECS}  \
					     -P${PREFER_BUSY_POLL} \
					     -P${prefer_busy_poll_value} \
					     -g${BUSY_POLL_BUDGET} \
					     -i${NSIM_SV_IFIDX}    \
					     -s${suspend_value}    \
					     -t${napi_threaded_value} \
					     -o${out_file}&

	wait_local_port_listen nssv ${SERVER_PORT} tcp
@@ -109,6 +115,15 @@ test_busypoll_with_suspend()
	return $?
}

test_busypoll_with_napi_threaded()
{
	# Only enable napi threaded poll. Set suspend timeout and prefer busy
	# poll to 0.
	test_busypoll 0 ${NAPI_THREADED_MODE_BUSY_POLL} 0

	return $?
}

###
### Code start
###
@@ -154,6 +169,13 @@ if [ $? -ne 0 ]; then
	exit 1
fi

test_busypoll_with_napi_threaded
if [ $? -ne 0 ]; then
	echo "test_busypoll_with_napi_threaded failed"
	cleanup_ns
	exit 1
fi

echo "$NSIM_SV_FD:$NSIM_SV_IFIDX" > $NSIM_DEV_SYS_UNLINK

echo $NSIM_CL_ID > $NSIM_DEV_SYS_DEL
+13 −3
Original line number Diff line number Diff line
@@ -65,15 +65,16 @@ static uint32_t cfg_busy_poll_usecs;
static uint16_t cfg_busy_poll_budget;
static uint8_t cfg_prefer_busy_poll;

/* IRQ params */
/* NAPI params */
static uint32_t cfg_defer_hard_irqs;
static uint64_t cfg_gro_flush_timeout;
static uint64_t cfg_irq_suspend_timeout;
static enum netdev_napi_threaded cfg_napi_threaded_poll = NETDEV_NAPI_THREADED_DISABLED;

static void usage(const char *filepath)
{
	error(1, 0,
	      "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>",
	      "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>",
	      filepath);
}

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

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

			cfg_ifindex = (int)tmp;
			break;
		case 't':
			if (tmp > 2)
				error(1, ERANGE, "napi threaded poll value must be 0-2");

			cfg_napi_threaded_poll = (enum netdev_napi_threaded)tmp;
			break;
		}
	}

@@ -247,6 +254,9 @@ static void setup_queue(void)
	netdev_napi_set_req_set_irq_suspend_timeout(set_req,
						    cfg_irq_suspend_timeout);

	if (cfg_napi_threaded_poll)
		netdev_napi_set_req_set_threaded(set_req, cfg_napi_threaded_poll);

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