1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later
3f08c3bdfSopenharmony_ci# Copyright (c) 2016-2020 Oracle and/or its affiliates. All Rights Reserved.
4f08c3bdfSopenharmony_ci#
5f08c3bdfSopenharmony_ci# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
6f08c3bdfSopenharmony_ci
7f08c3bdfSopenharmony_ciTST_TEST_DATA="udp udp_lite"
8f08c3bdfSopenharmony_ci
9f08c3bdfSopenharmony_cicleanup()
10f08c3bdfSopenharmony_ci{
11f08c3bdfSopenharmony_ci	[ -n "$busy_poll_old" ] && \
12f08c3bdfSopenharmony_ci		sysctl -q -w net.core.busy_poll=$busy_poll_old
13f08c3bdfSopenharmony_ci	[ -n "$rbusy_poll_old" ] && \
14f08c3bdfSopenharmony_ci		tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
15f08c3bdfSopenharmony_ci}
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ciset_busy_poll()
18f08c3bdfSopenharmony_ci{
19f08c3bdfSopenharmony_ci	local value=${1:-"0"}
20f08c3bdfSopenharmony_ci	tst_set_sysctl net.core.busy_poll $value safe
21f08c3bdfSopenharmony_ci}
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_cisetup()
24f08c3bdfSopenharmony_ci{
25f08c3bdfSopenharmony_ci	busy_poll_check_config
26f08c3bdfSopenharmony_ci
27f08c3bdfSopenharmony_ci	busy_poll_old="$(sysctl -n net.core.busy_poll)"
28f08c3bdfSopenharmony_ci	rbusy_poll_old=$(tst_rhost_run -c 'sysctl -ne net.core.busy_poll')
29f08c3bdfSopenharmony_ci}
30f08c3bdfSopenharmony_ci
31f08c3bdfSopenharmony_citest()
32f08c3bdfSopenharmony_ci{
33f08c3bdfSopenharmony_ci	for x in 50 0; do
34f08c3bdfSopenharmony_ci		tst_res TINFO "set low latency busy poll to $x per $2 socket"
35f08c3bdfSopenharmony_ci		set_busy_poll $x
36f08c3bdfSopenharmony_ci		tst_netload -H $(tst_ipaddr rhost) -n 10 -N 10 -d res_$x \
37f08c3bdfSopenharmony_ci			    -b $x -T $2
38f08c3bdfSopenharmony_ci	done
39f08c3bdfSopenharmony_ci
40f08c3bdfSopenharmony_ci	tst_netload_compare $(cat res_0) $(cat res_50) 1
41f08c3bdfSopenharmony_ci}
42f08c3bdfSopenharmony_ci
43f08c3bdfSopenharmony_ci. busy_poll_lib.sh
44f08c3bdfSopenharmony_citst_run
45