1 #!/bin/sh 2 3 CC="$1" 4 [ -n "$TARGET_CC_NOCACHE" ] && CC="$TARGET_CC_NOCACHE" 5 6 cat <<EOF 7 #include <linux/ethtool.h> 8 9 #define ETHTOOL_MODE_FULL(_speed, _mode) { \\ 10 .speed = (_speed), \\ 11 .bit_half = -1, \\ 12 .bit_full = ETHTOOL_LINK_MODE_ ## _speed ## base ## _mode ## _Full_BIT, \\ 13 .name = #_speed "base" #_mode, \\ 14 } 15 16 #define ETHTOOL_MODE_HALF(_speed, _mode) { \\ 17 .speed = (_speed), \\ 18 .bit_half = ETHTOOL_LINK_MODE_ ## _speed ## base ## _mode ## _Half_BIT, \\ 19 .bit_full = -1, \\ 20 .name = #_speed "base" #_mode, \\ 21 } 22 23 #define ETHTOOL_MODE_BOTH(_speed, _mode) { \\ 24 .speed = (_speed), \\ 25 .bit_half = ETHTOOL_LINK_MODE_ ## _speed ## base ## _mode ## _Half_BIT, \\ 26 .bit_full = ETHTOOL_LINK_MODE_ ## _speed ## base ## _mode ## _Full_BIT, \\ 27 .name = #_speed "base" #_mode, \\ 28 } 29 30 static const struct { 31 unsigned int speed; 32 int bit_half; 33 int bit_full; 34 const char *name; 35 } ethtool_modes[] = { 36 EOF 37 38 echo "#include <linux/ethtool.h>" | "$CC" -E - | \ 39 grep "ETHTOOL_LINK_MODE_[0-9]*base[A-Za-z0-9]*_...._BIT.*" | \ 40 sed -r 's/.*ETHTOOL_LINK_MODE_([0-9]*)base([A-Za-z0-9]*)_(....)_BIT.*/\1 \2 \3/' | \ 41 sort -u | LC_ALL=C sort -r -g | ( gothalf=0 ; while read -r speed mode duplex; do 42 if [ "$duplex" = "Half" ]; then 43 if [ "$gothalf" = "1" ]; then 44 printf "%s" "$speed \tETHTOOL_MODE_HALF($p_speed, $p_mode),\n" 45 fi 46 gothalf=1 47 elif [ "$duplex" = "Full" ]; then 48 if [ "$gothalf" = "1" ]; then 49 if [ "$p_speed" = "$speed" ] && [ "$p_mode" = "$mode" ]; then 50 printf "%d \t%s\n" "$speed" "ETHTOOL_MODE_BOTH($speed, $mode)," 51 else 52 printf "%d \t%s\n" "$p_speed" "ETHTOOL_MODE_HALF($p_speed, $p_mode)," 53 printf "%d \t%s\n" "$speed" "ETHTOOL_MODE_FULL($speed, $mode)," 54 fi 55 gothalf=0 56 else 57 printf "%d \t%s\n" "$speed" "ETHTOOL_MODE_FULL($speed, $mode)," 58 fi 59 else 60 continue 61 fi 62 p_speed="$speed" 63 p_mode="$mode" 64 done ; [ "$gothalf" = "1" ] && printf "%d \t%s\n" "$p_speed" "ETHTOOL_MODE_HALF($p_speed, $p_mode)," ) | \ 65 LC_ALL=C sort -g | sed -r 's/[0-9]* (.*)/\1/' 66 echo "};"
This page was automatically generated by LXR 0.3.1. • OpenWrt