tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/hw/ethtool_extended_state.sh- Extension
.sh- Size
- 2185 bytes
- Lines
- 117
- 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
ALL_TESTS="
autoneg
autoneg_force_mode
no_cable
"
NUM_NETIFS=2
lib_dir=$(dirname "$0")
source "$lib_dir"/../../../net/forwarding/lib.sh
source ethtool_lib.sh
TIMEOUT=$((WAIT_TIMEOUT * 1000)) # ms
setup_prepare()
{
swp1=${NETIFS[p1]}
swp2=${NETIFS[p2]}
swp3=$NETIF_NO_CABLE
}
ethtool_ext_state()
{
local dev=$1; shift
local expected_ext_state=$1; shift
local expected_ext_substate=${1:-""}; shift
local ext_state=$(ethtool $dev | grep "Link detected" \
| cut -d "(" -f2 | cut -d ")" -f1)
local ext_substate=$(echo $ext_state | cut -sd "," -f2 \
| sed -e 's/^[[:space:]]*//')
ext_state=$(echo $ext_state | cut -d "," -f1)
if [[ $ext_state != $expected_ext_state ]]; then
echo "Expected \"$expected_ext_state\", got \"$ext_state\""
return 1
fi
if [[ $ext_substate != $expected_ext_substate ]]; then
echo "Expected \"$expected_ext_substate\", got \"$ext_substate\""
return 1
fi
}
autoneg()
{
local msg
RET=0
ip link set dev $swp1 up
msg=$(busywait $TIMEOUT ethtool_ext_state $swp1 \
"Autoneg" "No partner detected")
check_err $? "$msg"
log_test "Autoneg, No partner detected"
ip link set dev $swp1 down
}
autoneg_force_mode()
{
local msg
RET=0
ip link set dev $swp1 up
ip link set dev $swp2 up
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.