tools/testing/selftests/drivers/net/mlxsw/ethtool_lanes.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/mlxsw/ethtool_lanes.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/mlxsw/ethtool_lanes.sh- Extension
.sh- Size
- 4121 bytes
- Lines
- 191
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
lib_dir=$(dirname $0)/../../../net/forwarding
ethtool_lib_dir=$(dirname $0)/../hw
ALL_TESTS="
autoneg
autoneg_force_mode
"
NUM_NETIFS=2
: ${TIMEOUT:=30000} # ms
source $lib_dir/lib.sh
source $ethtool_lib_dir/ethtool_lib.sh
setup_prepare()
{
swp1=${NETIFS[p1]}
swp2=${NETIFS[p2]}
ip link set dev $swp1 up
ip link set dev $swp2 up
busywait "$TIMEOUT" wait_for_port_up ethtool $swp2
check_err $? "ports did not come up"
busywait $TIMEOUT sh -c "ethtool $swp1 | grep -q Lanes:"
if [[ $? -ne 0 ]]; then
log_test "SKIP: driver does not support lanes setting"
exit 1
fi
ip link set dev $swp2 down
ip link set dev $swp1 down
}
check_lanes()
{
local dev=$1; shift
local lanes=$1; shift
local max_speed=$1; shift
local chosen_lanes
chosen_lanes=$(ethtool $dev | grep 'Lanes:')
chosen_lanes=${chosen_lanes#*"Lanes: "}
((chosen_lanes == lanes))
check_err $? "swp1 advertise $max_speed and $lanes, devs sync to $chosen_lanes"
}
check_unsupported_lanes()
{
local dev=$1; shift
local max_speed=$1; shift
local max_lanes=$1; shift
local autoneg=$1; shift
local autoneg_str=""
local unsupported_lanes=$((max_lanes *= 2))
if [[ $autoneg -eq 0 ]]; then
autoneg_str="autoneg off"
fi
ethtool -s $swp1 speed $max_speed lanes $unsupported_lanes $autoneg_str &> /dev/null
check_fail $? "Unsuccessful $unsupported_lanes lanes setting was expected"
}
max_speed_and_lanes_get()
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.