tools/testing/selftests/drivers/net/hw/ethtool.sh

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/hw/ethtool.sh
Extension
.sh
Size
6702 bytes
Lines
298
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="
	same_speeds_autoneg_off
	different_speeds_autoneg_off
	combination_of_neg_on_and_off
	advertise_subset_of_speeds
	check_highest_speed_is_chosen
	different_speeds_autoneg_on
"
NUM_NETIFS=2
lib_dir=$(dirname "$0")
source "$lib_dir"/../../../net/forwarding/lib.sh
source ethtool_lib.sh

h1_create()
{
	simple_if_init $h1 192.0.2.1/24
}

h1_destroy()
{
	simple_if_fini $h1 192.0.2.1/24
}

h2_create()
{
	simple_if_init $h2 192.0.2.2/24
}

h2_destroy()
{
	simple_if_fini $h2 192.0.2.2/24
}

setup_prepare()
{
	h1=${NETIFS[p1]}
	h2=${NETIFS[p2]}

	h1_create
	h2_create
}

cleanup()
{
	pre_cleanup

	h2_destroy
	h1_destroy
}

same_speeds_autoneg_off()
{
	# Check that when each of the reported speeds is forced, the links come
	# up and are operational.
	local -a speeds_arr=($(common_speeds_get $h1 $h2 0 0))

	for speed in "${speeds_arr[@]}"; do
		RET=0
		ethtool_set $h1 speed $speed autoneg off
		ethtool_set $h2 speed $speed autoneg off

		setup_wait_dev_with_timeout $h1
		setup_wait_dev_with_timeout $h2
		ping_do $h1 192.0.2.2
		check_err $? "ping with speed $speed autoneg off"
		log_test "force speed $speed on both ends"
	done

Annotation

Implementation Notes