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