diff options
author | Hans Westgaard Ry <hans.westgaard.ry@oracle.com> | 2016-04-21 07:13:21 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2016-05-13 19:39:43 -0400 |
commit | e3614bc9dc448c3395adf311098dfc64abcc5a35 (patch) | |
tree | 06c2304980cb3e687c7dfc689cbba82309b42a56 | |
parent | 01690e9c70c0b42072d6c82470d78b747fcc5c70 (diff) |
IB/ipoib: Add readout of statistics using ethtool
IPoIB collects statistics of traffic including number of packets
sent/received, number of bytes transferred, and certain errors. This
patch makes these statistics available to be queried by ethtool.
Signed-off-by: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Tested-by: Yuval Shaia <yuval.shaia@oracle.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c index a53fa5fc0dec..1502199c8e56 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | |||
@@ -36,6 +36,27 @@ | |||
36 | 36 | ||
37 | #include "ipoib.h" | 37 | #include "ipoib.h" |
38 | 38 | ||
39 | struct ipoib_stats { | ||
40 | char stat_string[ETH_GSTRING_LEN]; | ||
41 | int stat_offset; | ||
42 | }; | ||
43 | |||
44 | #define IPOIB_NETDEV_STAT(m) { \ | ||
45 | .stat_string = #m, \ | ||
46 | .stat_offset = offsetof(struct rtnl_link_stats64, m) } | ||
47 | |||
48 | static const struct ipoib_stats ipoib_gstrings_stats[] = { | ||
49 | IPOIB_NETDEV_STAT(rx_packets), | ||
50 | IPOIB_NETDEV_STAT(tx_packets), | ||
51 | IPOIB_NETDEV_STAT(rx_bytes), | ||
52 | IPOIB_NETDEV_STAT(tx_bytes), | ||
53 | IPOIB_NETDEV_STAT(tx_errors), | ||
54 | IPOIB_NETDEV_STAT(rx_dropped), | ||
55 | IPOIB_NETDEV_STAT(tx_dropped) | ||
56 | }; | ||
57 | |||
58 | #define IPOIB_GLOBAL_STATS_LEN ARRAY_SIZE(ipoib_gstrings_stats) | ||
59 | |||
39 | static void ipoib_get_drvinfo(struct net_device *netdev, | 60 | static void ipoib_get_drvinfo(struct net_device *netdev, |
40 | struct ethtool_drvinfo *drvinfo) | 61 | struct ethtool_drvinfo *drvinfo) |
41 | { | 62 | { |
@@ -92,11 +113,57 @@ static int ipoib_set_coalesce(struct net_device *dev, | |||
92 | 113 | ||
93 | return 0; | 114 | return 0; |
94 | } | 115 | } |
116 | static void ipoib_get_ethtool_stats(struct net_device *dev, | ||
117 | struct ethtool_stats __always_unused *stats, | ||
118 | u64 *data) | ||
119 | { | ||
120 | int i; | ||
121 | struct net_device_stats *net_stats = &dev->stats; | ||
122 | u8 *p = (u8 *)net_stats; | ||
123 | |||
124 | for (i = 0; i < IPOIB_GLOBAL_STATS_LEN; i++) | ||
125 | data[i] = *(u64 *)(p + ipoib_gstrings_stats[i].stat_offset); | ||
126 | |||
127 | } | ||
128 | static void ipoib_get_strings(struct net_device __always_unused *dev, | ||
129 | u32 stringset, u8 *data) | ||
130 | { | ||
131 | u8 *p = data; | ||
132 | int i; | ||
133 | |||
134 | switch (stringset) { | ||
135 | case ETH_SS_STATS: | ||
136 | for (i = 0; i < IPOIB_GLOBAL_STATS_LEN; i++) { | ||
137 | memcpy(p, ipoib_gstrings_stats[i].stat_string, | ||
138 | ETH_GSTRING_LEN); | ||
139 | p += ETH_GSTRING_LEN; | ||
140 | } | ||
141 | break; | ||
142 | case ETH_SS_TEST: | ||
143 | default: | ||
144 | break; | ||
145 | } | ||
146 | } | ||
147 | static int ipoib_get_sset_count(struct net_device __always_unused *dev, | ||
148 | int sset) | ||
149 | { | ||
150 | switch (sset) { | ||
151 | case ETH_SS_STATS: | ||
152 | return IPOIB_GLOBAL_STATS_LEN; | ||
153 | case ETH_SS_TEST: | ||
154 | default: | ||
155 | break; | ||
156 | } | ||
157 | return -EOPNOTSUPP; | ||
158 | } | ||
95 | 159 | ||
96 | static const struct ethtool_ops ipoib_ethtool_ops = { | 160 | static const struct ethtool_ops ipoib_ethtool_ops = { |
97 | .get_drvinfo = ipoib_get_drvinfo, | 161 | .get_drvinfo = ipoib_get_drvinfo, |
98 | .get_coalesce = ipoib_get_coalesce, | 162 | .get_coalesce = ipoib_get_coalesce, |
99 | .set_coalesce = ipoib_set_coalesce, | 163 | .set_coalesce = ipoib_set_coalesce, |
164 | .get_strings = ipoib_get_strings, | ||
165 | .get_ethtool_stats = ipoib_get_ethtool_stats, | ||
166 | .get_sset_count = ipoib_get_sset_count, | ||
100 | }; | 167 | }; |
101 | 168 | ||
102 | void ipoib_set_ethtool_ops(struct net_device *dev) | 169 | void ipoib_set_ethtool_ops(struct net_device *dev) |