tools/testing/selftests/drivers/net/mlxsw/sharedbuffer.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/mlxsw/sharedbuffer.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/mlxsw/sharedbuffer.sh
Extension
.sh
Size
5370 bytes
Lines
244
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

ALL_TESTS="
	port_pool_test
	port_tc_ip_test
	port_tc_arp_test
"

NUM_NETIFS=2
source ../../../net/forwarding/lib.sh
source ../../../net/forwarding/devlink_lib.sh
source mlxsw_lib.sh

SB_POOL_ING=0
SB_POOL_EGR_CPU=10

SB_ITC_CPU_IP=2
SB_ITC_CPU_ARP=2
SB_ITC=0

h1_create()
{
	simple_if_init $h1 192.0.1.1/24
	tc qdisc add dev $h1 clsact

	# Add egress filter on $h1 that will guarantee that the packet sent,
	# will be the only packet being passed to the device.
	tc filter add dev $h1 egress pref 2 handle 102 matchall action drop
}

h1_destroy()
{
	tc filter del dev $h1 egress pref 2 handle 102 matchall action drop
	tc qdisc del dev $h1 clsact
	simple_if_fini $h1 192.0.1.1/24
}

h2_create()
{
	simple_if_init $h2 192.0.1.2/24
	tc qdisc add dev $h2 clsact

	# Add egress filter on $h2 that will guarantee that the packet sent,
	# will be the only packet being passed to the device.
	tc filter add dev $h2 egress pref 1 handle 101 matchall action drop
}

h2_destroy()
{
	tc filter del dev $h2 egress pref 1 handle 101 matchall action drop
	tc qdisc del dev $h2 clsact
	simple_if_fini $h2 192.0.1.2/24
}

sb_occ_pool_check()
{
	local dl_port=$1; shift
	local pool=$1; shift
	local exp_max_occ=$1
	local max_occ
	local err=0

	max_occ=$(devlink sb -j occupancy show $dl_port \
		  | jq -e ".[][][\"pool\"][\"$pool\"][\"max\"]")

	if [[ "$max_occ" -ne "$exp_max_occ" ]]; then
		err=1
	fi

Annotation

Implementation Notes