1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0-only 3 4 source ethtool-common.sh 5 6 NSIM_NETDEV=$(make_netdev) 7 [ a$ETHTOOL == a ] && ETHTOOL=ethtool 8 9 set -o pipefail 10 11 # Since commit 2b3ddcb35357 ("ethtool: fec: Change the prompt ...") 12 # in ethtool CLI the Configured lines start with Supported/Configured. 13 configured=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2 | head -1 | cut -d' ' -f1) 14 15 # netdevsim starts out with None/None 16 s=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2) 17 check $? "$s" "$configured FEC encodings: None 18 Active FEC encoding: None" 19 20 # Test Auto 21 $ETHTOOL --set-fec $NSIM_NETDEV encoding auto 22 check $? 23 s=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2) 24 check $? "$s" "$configured FEC encodings: Auto 25 Active FEC encoding: Off" 26 27 # Test case in-sensitivity 28 for o in off Off OFF; do 29 $ETHTOOL --set-fec $NSIM_NETDEV encoding $o 30 check $? 31 s=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2) 32 check $? "$s" "$configured FEC encodings: Off 33 Active FEC encoding: Off" 34 done 35 36 for o in BaseR baser BAser; do 37 $ETHTOOL --set-fec $NSIM_NETDEV encoding $o 38 check $? 39 s=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2) 40 check $? "$s" "$configured FEC encodings: BaseR 41 Active FEC encoding: BaseR" 42 done 43 44 for o in llrs rs; do 45 $ETHTOOL --set-fec $NSIM_NETDEV encoding $o 46 check $? 47 s=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2) 48 check $? "$s" "$configured FEC encodings: ${o^^} 49 Active FEC encoding: ${o^^}" 50 done 51 52 # Test multiple bits 53 $ETHTOOL --set-fec $NSIM_NETDEV encoding rs llrs 54 check $? 55 s=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2) 56 check $? "$s" "$configured FEC encodings: RS LLRS 57 Active FEC encoding: LLRS" 58 59 $ETHTOOL --set-fec $NSIM_NETDEV encoding rs off auto 60 check $? 61 s=$($ETHTOOL --show-fec $NSIM_NETDEV | tail -2) 62 check $? "$s" "$configured FEC encodings: Auto Off RS 63 Active FEC encoding: RS" 64 65 # Make sure other link modes are rejected 66 $ETHTOOL --set-fec $NSIM_NETDEV encoding FIBRE 2>/dev/null 67 check $? '' '' 1 68 69 $ETHTOOL --set-fec $NSIM_NETDEV encoding bla-bla-bla 2>/dev/null 70 check $? '' '' 1 71 72 # Try JSON 73 $ETHTOOL --json --show-fec $NSIM_NETDEV | jq empty >>/dev/null 2>&1 74 if [ $? -eq 0 ]; then 75 $ETHTOOL --set-fec $NSIM_NETDEV encoding auto 76 check $? 77 78 s=$($ETHTOOL --json --show-fec $NSIM_NETDEV | jq '.[].config[]') 79 check $? "$s" '"Auto"' 80 s=$($ETHTOOL --json --show-fec $NSIM_NETDEV | jq '.[].active[]') 81 check $? "$s" '"Off"' 82 83 $ETHTOOL --set-fec $NSIM_NETDEV encoding auto RS 84 check $? 85 86 s=$($ETHTOOL --json --show-fec $NSIM_NETDEV | jq '.[].config[]') 87 check $? "$s" '"Auto" 88 "RS"' 89 s=$($ETHTOOL --json --show-fec $NSIM_NETDEV | jq '.[].active[]') 90 check $? "$s" '"RS"' 91 fi 92 93 # Test error injection 94 echo 11 > $NSIM_DEV_DFS/ethtool/get_err 95 96 $ETHTOOL --show-fec $NSIM_NETDEV >>/dev/null 2>&1 97 check $? '' '' 1 98 99 echo 0 > $NSIM_DEV_DFS/ethtool/get_err 100 echo 11 > $NSIM_DEV_DFS/ethtool/set_err 101 102 $ETHTOOL --show-fec $NSIM_NETDEV >>/dev/null 2>&1 103 check $? 104 105 $ETHTOOL --set-fec $NSIM_NETDEV encoding RS 2>/dev/null 106 check $? '' '' 1 107 108 if [ $num_errors -eq 0 ]; then 109 echo "PASSED all $((num_passes)) checks" 110 exit 0 111 else 112 echo "FAILED $num_errors/$((num_errors+num_passes)) checks" 113 exit 1 114 fi
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.