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
ethtool -s $h2 autoneg on
ethtool -s $h1 autoneg on
}
different_speeds_autoneg_off()
{ # Test that when we force different speeds, links are not up and ping # fails.
RET=0
local -a speeds_arr=($(different_speeds_get $h1 $h2 0 0))
local speed1=${speeds_arr[0]}
local speed2=${speeds_arr[1]}
ethtool_set $h1 speed $speed1 autoneg off
ethtool_set $h2 speed $speed2 autoneg off
setup_wait_dev_with_timeout $h1
setup_wait_dev_with_timeout $h2
ping_do $h1 192.0.2.2
check_fail $? "ping with different speeds"
log_test "force of different speeds autoneg off"
ethtool -s $h2 autoneg on
ethtool -s $h1 autoneg on
}
combination_of_neg_on_and_off()
{ # Test that when one device is forced to a speed supported by both # endpoints and the other device is configured to autoneg on, the links # are up and ping passes.
local -a speeds_arr=($(common_speeds_get $h1 $h2 0 1))
for speed in "${speeds_arr[@]}"; do
RET=0
ethtool_set $h1 speed $speed autoneg off
local shift_size=${speed_values[$speed]}
speed=$((0x1 << $"shift_size"))
printf "%#x" "$speed"
}
subset_of_common_speeds_get()
{
local dev1=$1; shift
local dev2=$1; shift
local adver=$1; shift
local -a speeds_arr=($(common_speeds_get $dev1 $dev2 0 $adver))
local speed_to_advertise=0
local speed_to_remove=${speeds_arr[0]}
speed_to_remove+='base'
local -a speeds_mode_arr=($(common_speeds_get $dev1 $dev2 1 $adver))
for speed in ${speeds_mode_arr[@]}; do if [[ $speed != $speed_to_remove* ]]; then
speed=$(hex_speed_value_get $speed)
speed_to_advertise=$(($speed_to_advertise | \
$speed)) fi
done
# Convert to hex.
printf "%#x" "$speed_to_advertise"
}
speed_to_advertise_get()
{ # The function returns the hex number that is composed by OR-ing all # the modes corresponding to the provided speed.
local speed_without_mode=$1; shift
local supported_speeds=("$@"); shift
local speed_to_advertise=0
speed_without_mode+='base'
for speed in ${supported_speeds[@]}; do if [[ $speed == $speed_without_mode* ]]; then
speed=$(hex_speed_value_get $speed)
speed_to_advertise=$(($speed_to_advertise | \
$speed)) fi
done
# Convert to hex.
printf "%#x" "$speed_to_advertise"
}
advertise_subset_of_speeds()
{ # Test that when one device advertises a subset of speeds and another # advertises a specific speed (but all modes of this speed), the links # are up and ping passes.
RET=0
local speed_1_to_advertise=$(subset_of_common_speeds_get $h1 $h2 1)
ethtool_set $h1 advertise $speed_1_to_advertise
if [ $RET != 0 ]; then
log_test "advertise subset of speeds"
return fi
local -a speeds_arr_without_mode=($(common_speeds_get $h1 $h2 0 1)) # Check only speeds that h1 advertised. Remove the first speed.
unset speeds_arr_without_mode[0]
local -a speeds_arr_with_mode=($(common_speeds_get $h1 $h2 1 1))
for speed_value in ${speeds_arr_without_mode[@]}; do
RET=0
local speed_2_to_advertise=$(speed_to_advertise_get $speed_value \ "${speeds_arr_with_mode[@]}")
ethtool_set $h2 advertise $speed_2_to_advertise
log_test "advertise $speed_1_to_advertise vs. $speed_2_to_advertise" done
ethtool -s $h2 autoneg on
ethtool -s $h1 autoneg on
}
check_highest_speed_is_chosen()
{ # Test that when one device advertises a subset of speeds, the other # chooses the highest speed. This test checks configuration without # traffic.
RET=0
local max_speed
local chosen_speed
local speed_to_advertise=$(subset_of_common_speeds_get $h1 $h2 1)
ethtool_set $h1 advertise $speed_to_advertise
if [ $RET != 0 ]; then
log_test "check highest speed"
return fi
local -a speeds_arr=($(common_speeds_get $h1 $h2 0 1))
max_speed=${speeds_arr[0]} for current in ${speeds_arr[@]}; do if [[ $current -gt $max_speed ]]; then
max_speed=$current fi done
if (($RET)); then
setup_wait_dev_with_timeout $h1
setup_wait_dev_with_timeout $h2
ping_do $h1 192.0.2.2
check_fail $? "ping with different speeds autoneg on" fi
log_test "advertise different speeds autoneg on"
ethtool -s $h2 autoneg on
ethtool -s $h1 autoneg on
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.