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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/hw/ethtool_mm.sh
Extension
.sh
Size
7539 bytes
Lines
342
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="
	manual_with_verification_h1_to_h2
	manual_with_verification_h2_to_h1
	manual_without_verification_h1_to_h2
	manual_without_verification_h2_to_h1
	manual_failed_verification_h1_to_h2
	manual_failed_verification_h2_to_h1
	lldp
"

NUM_NETIFS=2
REQUIRE_MZ=no
PREEMPTIBLE_PRIO=0
lib_dir=$(dirname "$0")
source "$lib_dir"/../../../net/forwarding/lib.sh

traffic_test()
{
	local if=$1; shift
	local src=$1; shift
	local num_pkts=10000
	local before=
	local after=
	local delta=

	if [ ${has_pmac_stats[$if]} = false ]; then
		src="aggregate"
	fi

	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)

	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO

	after=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)

	delta=$((after - before))

	# Allow an extra 1% tolerance for random packets sent by the stack
	[ $delta -ge $num_pkts ] && [ $delta -le $((num_pkts + 100)) ]
}

manual_with_verification()
{
	local tx=$1; shift
	local rx=$1; shift

	RET=0

	# It isn't completely clear from IEEE 802.3-2018 Figure 99-5: Transmit
	# Processing state diagram whether the "send_r" variable (send response
	# to verification frame) should be taken into consideration while the
	# MAC Merge TX direction is disabled. That being said, at least the
	# NXP ENETC does not, and requires tx-enabled on in order to respond to
	# the link partner's verification frames.
	ethtool --set-mm $rx tx-enabled on
	ethtool --set-mm $tx verify-enabled on tx-enabled on

	# Wait for verification to finish
	sleep 1

	ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
		grep -q 'SUCCEEDED'
	check_err "$?" "Verification did not succeed"

	ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
	check_err "$?" "pMAC TX is not active"

Annotation

Implementation Notes