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