ethtool-pause.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0-only
  3. source ethtool-common.sh
  4. # Bail if ethtool is too old
  5. if ! ethtool -h | grep include-stat 2>&1 >/dev/null; then
  6. echo "SKIP: No --include-statistics support in ethtool"
  7. exit 4
  8. fi
  9. NSIM_NETDEV=$(make_netdev)
  10. set -o pipefail
  11. echo n > $NSIM_DEV_DFS/ethtool/pause/report_stats_tx
  12. echo n > $NSIM_DEV_DFS/ethtool/pause/report_stats_rx
  13. s=$(ethtool --json -a $NSIM_NETDEV | jq '.[].statistics')
  14. check $? "$s" "null"
  15. s=$(ethtool -I --json -a $NSIM_NETDEV | jq '.[].statistics')
  16. check $? "$s" "{}"
  17. echo y > $NSIM_DEV_DFS/ethtool/pause/report_stats_tx
  18. s=$(ethtool -I --json -a $NSIM_NETDEV | jq '.[].statistics | length')
  19. check $? "$s" "1"
  20. s=$(ethtool -I --json -a $NSIM_NETDEV | jq '.[].statistics.tx_pause_frames')
  21. check $? "$s" "2"
  22. echo y > $NSIM_DEV_DFS/ethtool/pause/report_stats_rx
  23. s=$(ethtool -I --json -a $NSIM_NETDEV | jq '.[].statistics | length')
  24. check $? "$s" "2"
  25. s=$(ethtool -I --json -a $NSIM_NETDEV | jq '.[].statistics.rx_pause_frames')
  26. check $? "$s" "1"
  27. s=$(ethtool -I --json -a $NSIM_NETDEV | jq '.[].statistics.tx_pause_frames')
  28. check $? "$s" "2"
  29. if [ $num_errors -eq 0 ]; then
  30. echo "PASSED all $((num_passes)) checks"
  31. exit 0
  32. else
  33. echo "FAILED $num_errors/$((num_errors+num_passes)) checks"
  34. exit 1
  35. fi