aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
diff options
context:
space:
mode:
authorEugenia Emantayev <eugenia@mellanox.co.il>2012-01-19 04:45:05 -0500
committerDavid S. Miller <davem@davemloft.net>2012-01-22 15:08:43 -0500
commit93ece0c1a7ace88f10411dbb5643d2aa2fe00ebf (patch)
treec6a00edd4504b9c026bc555e3d74fe155cacadbf /drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
parent35fb9afbdeef9d5859d9a878d0372907baf119e1 (diff)
mlx4_en: eth statistics modification
In native mode display all available staticstics. In SRIOV mode on VF display only SW counters statistics, in SRIOV mode on hypervisor display SW counters and errors (got from FW) statistics. Signed-off-by: Eugenia Emantayev <eugenia@mellanox.co.il> Reviewed-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/en_ethtool.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_ethtool.c66
1 files changed, 50 insertions, 16 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 53c66869aecd..70346fd7f9c4 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -183,10 +183,11 @@ static int mlx4_en_set_wol(struct net_device *netdev,
183static int mlx4_en_get_sset_count(struct net_device *dev, int sset) 183static int mlx4_en_get_sset_count(struct net_device *dev, int sset)
184{ 184{
185 struct mlx4_en_priv *priv = netdev_priv(dev); 185 struct mlx4_en_priv *priv = netdev_priv(dev);
186 int bit_count = hweight64(priv->stats_bitmap);
186 187
187 switch (sset) { 188 switch (sset) {
188 case ETH_SS_STATS: 189 case ETH_SS_STATS:
189 return NUM_ALL_STATS + 190 return (priv->stats_bitmap ? bit_count : NUM_ALL_STATS) +
190 (priv->tx_ring_num + priv->rx_ring_num) * 2; 191 (priv->tx_ring_num + priv->rx_ring_num) * 2;
191 case ETH_SS_TEST: 192 case ETH_SS_TEST:
192 return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags 193 return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags
@@ -201,14 +202,34 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
201{ 202{
202 struct mlx4_en_priv *priv = netdev_priv(dev); 203 struct mlx4_en_priv *priv = netdev_priv(dev);
203 int index = 0; 204 int index = 0;
204 int i; 205 int i, j = 0;
205 206
206 spin_lock_bh(&priv->stats_lock); 207 spin_lock_bh(&priv->stats_lock);
207 208
208 for (i = 0; i < NUM_MAIN_STATS; i++) 209 if (!(priv->stats_bitmap)) {
209 data[index++] = ((unsigned long *) &priv->stats)[i]; 210 for (i = 0; i < NUM_MAIN_STATS; i++)
210 for (i = 0; i < NUM_PORT_STATS; i++) 211 data[index++] =
211 data[index++] = ((unsigned long *) &priv->port_stats)[i]; 212 ((unsigned long *) &priv->stats)[i];
213 for (i = 0; i < NUM_PORT_STATS; i++)
214 data[index++] =
215 ((unsigned long *) &priv->port_stats)[i];
216 for (i = 0; i < NUM_PKT_STATS; i++)
217 data[index++] =
218 ((unsigned long *) &priv->pkstats)[i];
219 } else {
220 for (i = 0; i < NUM_MAIN_STATS; i++) {
221 if ((priv->stats_bitmap >> j) & 1)
222 data[index++] =
223 ((unsigned long *) &priv->stats)[i];
224 j++;
225 }
226 for (i = 0; i < NUM_PORT_STATS; i++) {
227 if ((priv->stats_bitmap >> j) & 1)
228 data[index++] =
229 ((unsigned long *) &priv->port_stats)[i];
230 j++;
231 }
232 }
212 for (i = 0; i < priv->tx_ring_num; i++) { 233 for (i = 0; i < priv->tx_ring_num; i++) {
213 data[index++] = priv->tx_ring[i].packets; 234 data[index++] = priv->tx_ring[i].packets;
214 data[index++] = priv->tx_ring[i].bytes; 235 data[index++] = priv->tx_ring[i].bytes;
@@ -217,8 +238,6 @@ static void mlx4_en_get_ethtool_stats(struct net_device *dev,
217 data[index++] = priv->rx_ring[i].packets; 238 data[index++] = priv->rx_ring[i].packets;
218 data[index++] = priv->rx_ring[i].bytes; 239 data[index++] = priv->rx_ring[i].bytes;
219 } 240 }
220 for (i = 0; i < NUM_PKT_STATS; i++)
221 data[index++] = ((unsigned long *) &priv->pkstats)[i];
222 spin_unlock_bh(&priv->stats_lock); 241 spin_unlock_bh(&priv->stats_lock);
223 242
224} 243}
@@ -247,11 +266,29 @@ static void mlx4_en_get_strings(struct net_device *dev,
247 266
248 case ETH_SS_STATS: 267 case ETH_SS_STATS:
249 /* Add main counters */ 268 /* Add main counters */
250 for (i = 0; i < NUM_MAIN_STATS; i++) 269 if (!priv->stats_bitmap) {
251 strcpy(data + (index++) * ETH_GSTRING_LEN, main_strings[i]); 270 for (i = 0; i < NUM_MAIN_STATS; i++)
252 for (i = 0; i< NUM_PORT_STATS; i++) 271 strcpy(data + (index++) * ETH_GSTRING_LEN,
253 strcpy(data + (index++) * ETH_GSTRING_LEN, 272 main_strings[i]);
254 main_strings[i + NUM_MAIN_STATS]); 273 for (i = 0; i < NUM_PORT_STATS; i++)
274 strcpy(data + (index++) * ETH_GSTRING_LEN,
275 main_strings[i +
276 NUM_MAIN_STATS]);
277 for (i = 0; i < NUM_PKT_STATS; i++)
278 strcpy(data + (index++) * ETH_GSTRING_LEN,
279 main_strings[i +
280 NUM_MAIN_STATS +
281 NUM_PORT_STATS]);
282 } else
283 for (i = 0; i < NUM_MAIN_STATS + NUM_PORT_STATS; i++) {
284 if ((priv->stats_bitmap >> i) & 1) {
285 strcpy(data +
286 (index++) * ETH_GSTRING_LEN,
287 main_strings[i]);
288 }
289 if (!(priv->stats_bitmap >> i))
290 break;
291 }
255 for (i = 0; i < priv->tx_ring_num; i++) { 292 for (i = 0; i < priv->tx_ring_num; i++) {
256 sprintf(data + (index++) * ETH_GSTRING_LEN, 293 sprintf(data + (index++) * ETH_GSTRING_LEN,
257 "tx%d_packets", i); 294 "tx%d_packets", i);
@@ -264,9 +301,6 @@ static void mlx4_en_get_strings(struct net_device *dev,
264 sprintf(data + (index++) * ETH_GSTRING_LEN, 301 sprintf(data + (index++) * ETH_GSTRING_LEN,
265 "rx%d_bytes", i); 302 "rx%d_bytes", i);
266 } 303 }
267 for (i = 0; i< NUM_PKT_STATS; i++)
268 strcpy(data + (index++) * ETH_GSTRING_LEN,
269 main_strings[i + NUM_MAIN_STATS + NUM_PORT_STATS]);
270 break; 304 break;
271 } 305 }
272} 306}