|
64 | 64 | #include "sysfs.h"
|
65 | 65 | #include "translation-table.h"
|
66 | 66 |
|
67 |
| -static void batadv_get_drvinfo(struct net_device *dev, |
68 |
| - struct ethtool_drvinfo *info); |
69 |
| -static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data); |
70 |
| -static void batadv_get_ethtool_stats(struct net_device *dev, |
71 |
| - struct ethtool_stats *stats, u64 *data); |
72 |
| -static int batadv_get_sset_count(struct net_device *dev, int stringset); |
73 |
| - |
74 |
| -static const struct ethtool_ops batadv_ethtool_ops = { |
75 |
| - .get_drvinfo = batadv_get_drvinfo, |
76 |
| - .get_link = ethtool_op_get_link, |
77 |
| - .get_strings = batadv_get_strings, |
78 |
| - .get_ethtool_stats = batadv_get_ethtool_stats, |
79 |
| - .get_sset_count = batadv_get_sset_count, |
80 |
| -}; |
81 |
| - |
82 | 67 | int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
|
83 | 68 | {
|
84 | 69 | int result;
|
@@ -944,6 +929,98 @@ static const struct net_device_ops batadv_netdev_ops = {
|
944 | 929 | .ndo_del_slave = batadv_softif_slave_del,
|
945 | 930 | };
|
946 | 931 |
|
| 932 | +static void batadv_get_drvinfo(struct net_device *dev, |
| 933 | + struct ethtool_drvinfo *info) |
| 934 | +{ |
| 935 | + strlcpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver)); |
| 936 | + strlcpy(info->version, BATADV_SOURCE_VERSION, sizeof(info->version)); |
| 937 | + strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
| 938 | + strlcpy(info->bus_info, "batman", sizeof(info->bus_info)); |
| 939 | +} |
| 940 | + |
| 941 | +/* Inspired by drivers/net/ethernet/dlink/sundance.c:1702 |
| 942 | + * Declare each description string in struct.name[] to get fixed sized buffer |
| 943 | + * and compile time checking for strings longer than ETH_GSTRING_LEN. |
| 944 | + */ |
| 945 | +static const struct { |
| 946 | + const char name[ETH_GSTRING_LEN]; |
| 947 | +} batadv_counters_strings[] = { |
| 948 | + { "tx" }, |
| 949 | + { "tx_bytes" }, |
| 950 | + { "tx_dropped" }, |
| 951 | + { "rx" }, |
| 952 | + { "rx_bytes" }, |
| 953 | + { "forward" }, |
| 954 | + { "forward_bytes" }, |
| 955 | + { "mgmt_tx" }, |
| 956 | + { "mgmt_tx_bytes" }, |
| 957 | + { "mgmt_rx" }, |
| 958 | + { "mgmt_rx_bytes" }, |
| 959 | + { "frag_tx" }, |
| 960 | + { "frag_tx_bytes" }, |
| 961 | + { "frag_rx" }, |
| 962 | + { "frag_rx_bytes" }, |
| 963 | + { "frag_fwd" }, |
| 964 | + { "frag_fwd_bytes" }, |
| 965 | + { "tt_request_tx" }, |
| 966 | + { "tt_request_rx" }, |
| 967 | + { "tt_response_tx" }, |
| 968 | + { "tt_response_rx" }, |
| 969 | + { "tt_roam_adv_tx" }, |
| 970 | + { "tt_roam_adv_rx" }, |
| 971 | +#ifdef CONFIG_BATMAN_ADV_DAT |
| 972 | + { "dat_get_tx" }, |
| 973 | + { "dat_get_rx" }, |
| 974 | + { "dat_put_tx" }, |
| 975 | + { "dat_put_rx" }, |
| 976 | + { "dat_cached_reply_tx" }, |
| 977 | +#endif |
| 978 | +#ifdef CONFIG_BATMAN_ADV_NC |
| 979 | + { "nc_code" }, |
| 980 | + { "nc_code_bytes" }, |
| 981 | + { "nc_recode" }, |
| 982 | + { "nc_recode_bytes" }, |
| 983 | + { "nc_buffer" }, |
| 984 | + { "nc_decode" }, |
| 985 | + { "nc_decode_bytes" }, |
| 986 | + { "nc_decode_failed" }, |
| 987 | + { "nc_sniffed" }, |
| 988 | +#endif |
| 989 | +}; |
| 990 | + |
| 991 | +static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data) |
| 992 | +{ |
| 993 | + if (stringset == ETH_SS_STATS) |
| 994 | + memcpy(data, batadv_counters_strings, |
| 995 | + sizeof(batadv_counters_strings)); |
| 996 | +} |
| 997 | + |
| 998 | +static void batadv_get_ethtool_stats(struct net_device *dev, |
| 999 | + struct ethtool_stats *stats, u64 *data) |
| 1000 | +{ |
| 1001 | + struct batadv_priv *bat_priv = netdev_priv(dev); |
| 1002 | + int i; |
| 1003 | + |
| 1004 | + for (i = 0; i < BATADV_CNT_NUM; i++) |
| 1005 | + data[i] = batadv_sum_counter(bat_priv, i); |
| 1006 | +} |
| 1007 | + |
| 1008 | +static int batadv_get_sset_count(struct net_device *dev, int stringset) |
| 1009 | +{ |
| 1010 | + if (stringset == ETH_SS_STATS) |
| 1011 | + return BATADV_CNT_NUM; |
| 1012 | + |
| 1013 | + return -EOPNOTSUPP; |
| 1014 | +} |
| 1015 | + |
| 1016 | +static const struct ethtool_ops batadv_ethtool_ops = { |
| 1017 | + .get_drvinfo = batadv_get_drvinfo, |
| 1018 | + .get_link = ethtool_op_get_link, |
| 1019 | + .get_strings = batadv_get_strings, |
| 1020 | + .get_ethtool_stats = batadv_get_ethtool_stats, |
| 1021 | + .get_sset_count = batadv_get_sset_count, |
| 1022 | +}; |
| 1023 | + |
947 | 1024 | /**
|
948 | 1025 | * batadv_softif_free - Deconstructor of batadv_soft_interface
|
949 | 1026 | * @dev: Device to cleanup and remove
|
@@ -1076,87 +1153,3 @@ struct rtnl_link_ops batadv_link_ops __read_mostly = {
|
1076 | 1153 | .setup = batadv_softif_init_early,
|
1077 | 1154 | .dellink = batadv_softif_destroy_netlink,
|
1078 | 1155 | };
|
1079 |
| - |
1080 |
| -static void batadv_get_drvinfo(struct net_device *dev, |
1081 |
| - struct ethtool_drvinfo *info) |
1082 |
| -{ |
1083 |
| - strlcpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver)); |
1084 |
| - strlcpy(info->version, BATADV_SOURCE_VERSION, sizeof(info->version)); |
1085 |
| - strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); |
1086 |
| - strlcpy(info->bus_info, "batman", sizeof(info->bus_info)); |
1087 |
| -} |
1088 |
| - |
1089 |
| -/* Inspired by drivers/net/ethernet/dlink/sundance.c:1702 |
1090 |
| - * Declare each description string in struct.name[] to get fixed sized buffer |
1091 |
| - * and compile time checking for strings longer than ETH_GSTRING_LEN. |
1092 |
| - */ |
1093 |
| -static const struct { |
1094 |
| - const char name[ETH_GSTRING_LEN]; |
1095 |
| -} batadv_counters_strings[] = { |
1096 |
| - { "tx" }, |
1097 |
| - { "tx_bytes" }, |
1098 |
| - { "tx_dropped" }, |
1099 |
| - { "rx" }, |
1100 |
| - { "rx_bytes" }, |
1101 |
| - { "forward" }, |
1102 |
| - { "forward_bytes" }, |
1103 |
| - { "mgmt_tx" }, |
1104 |
| - { "mgmt_tx_bytes" }, |
1105 |
| - { "mgmt_rx" }, |
1106 |
| - { "mgmt_rx_bytes" }, |
1107 |
| - { "frag_tx" }, |
1108 |
| - { "frag_tx_bytes" }, |
1109 |
| - { "frag_rx" }, |
1110 |
| - { "frag_rx_bytes" }, |
1111 |
| - { "frag_fwd" }, |
1112 |
| - { "frag_fwd_bytes" }, |
1113 |
| - { "tt_request_tx" }, |
1114 |
| - { "tt_request_rx" }, |
1115 |
| - { "tt_response_tx" }, |
1116 |
| - { "tt_response_rx" }, |
1117 |
| - { "tt_roam_adv_tx" }, |
1118 |
| - { "tt_roam_adv_rx" }, |
1119 |
| -#ifdef CONFIG_BATMAN_ADV_DAT |
1120 |
| - { "dat_get_tx" }, |
1121 |
| - { "dat_get_rx" }, |
1122 |
| - { "dat_put_tx" }, |
1123 |
| - { "dat_put_rx" }, |
1124 |
| - { "dat_cached_reply_tx" }, |
1125 |
| -#endif |
1126 |
| -#ifdef CONFIG_BATMAN_ADV_NC |
1127 |
| - { "nc_code" }, |
1128 |
| - { "nc_code_bytes" }, |
1129 |
| - { "nc_recode" }, |
1130 |
| - { "nc_recode_bytes" }, |
1131 |
| - { "nc_buffer" }, |
1132 |
| - { "nc_decode" }, |
1133 |
| - { "nc_decode_bytes" }, |
1134 |
| - { "nc_decode_failed" }, |
1135 |
| - { "nc_sniffed" }, |
1136 |
| -#endif |
1137 |
| -}; |
1138 |
| - |
1139 |
| -static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data) |
1140 |
| -{ |
1141 |
| - if (stringset == ETH_SS_STATS) |
1142 |
| - memcpy(data, batadv_counters_strings, |
1143 |
| - sizeof(batadv_counters_strings)); |
1144 |
| -} |
1145 |
| - |
1146 |
| -static void batadv_get_ethtool_stats(struct net_device *dev, |
1147 |
| - struct ethtool_stats *stats, u64 *data) |
1148 |
| -{ |
1149 |
| - struct batadv_priv *bat_priv = netdev_priv(dev); |
1150 |
| - int i; |
1151 |
| - |
1152 |
| - for (i = 0; i < BATADV_CNT_NUM; i++) |
1153 |
| - data[i] = batadv_sum_counter(bat_priv, i); |
1154 |
| -} |
1155 |
| - |
1156 |
| -static int batadv_get_sset_count(struct net_device *dev, int stringset) |
1157 |
| -{ |
1158 |
| - if (stringset == ETH_SS_STATS) |
1159 |
| - return BATADV_CNT_NUM; |
1160 |
| - |
1161 |
| - return -EOPNOTSUPP; |
1162 |
| -} |
0 commit comments