|
8 | 8 | #include "ionic_bus.h" |
9 | 9 | #include "ionic_lif.h" |
10 | 10 | #include "ionic_ethtool.h" |
| 11 | +#include "ionic_stats.h" |
| 12 | + |
| 13 | +static const char ionic_priv_flags_strings[][ETH_GSTRING_LEN] = { |
| 14 | +#define PRIV_F_SW_DBG_STATS BIT(0) |
| 15 | + "sw-dbg-stats", |
| 16 | +}; |
| 17 | +#define PRIV_FLAGS_COUNT ARRAY_SIZE(ionic_priv_flags_strings) |
| 18 | + |
| 19 | +static void ionic_get_stats_strings(struct ionic_lif *lif, u8 *buf) |
| 20 | +{ |
| 21 | + u32 i; |
| 22 | + |
| 23 | + for (i = 0; i < ionic_num_stats_grps; i++) |
| 24 | + ionic_stats_groups[i].get_strings(lif, &buf); |
| 25 | +} |
| 26 | + |
| 27 | +static void ionic_get_stats(struct net_device *netdev, |
| 28 | + struct ethtool_stats *stats, u64 *buf) |
| 29 | +{ |
| 30 | + struct ionic_lif *lif; |
| 31 | + u32 i; |
| 32 | + |
| 33 | + lif = netdev_priv(netdev); |
| 34 | + |
| 35 | + memset(buf, 0, stats->n_stats * sizeof(*buf)); |
| 36 | + for (i = 0; i < ionic_num_stats_grps; i++) |
| 37 | + ionic_stats_groups[i].get_values(lif, &buf); |
| 38 | +} |
| 39 | + |
| 40 | +static int ionic_get_stats_count(struct ionic_lif *lif) |
| 41 | +{ |
| 42 | + int i, num_stats = 0; |
| 43 | + |
| 44 | + for (i = 0; i < ionic_num_stats_grps; i++) |
| 45 | + num_stats += ionic_stats_groups[i].get_count(lif); |
| 46 | + |
| 47 | + return num_stats; |
| 48 | +} |
| 49 | + |
| 50 | +static int ionic_get_sset_count(struct net_device *netdev, int sset) |
| 51 | +{ |
| 52 | + struct ionic_lif *lif = netdev_priv(netdev); |
| 53 | + int count = 0; |
| 54 | + |
| 55 | + switch (sset) { |
| 56 | + case ETH_SS_STATS: |
| 57 | + count = ionic_get_stats_count(lif); |
| 58 | + break; |
| 59 | + case ETH_SS_PRIV_FLAGS: |
| 60 | + count = PRIV_FLAGS_COUNT; |
| 61 | + break; |
| 62 | + } |
| 63 | + return count; |
| 64 | +} |
| 65 | + |
| 66 | +static void ionic_get_strings(struct net_device *netdev, |
| 67 | + u32 sset, u8 *buf) |
| 68 | +{ |
| 69 | + struct ionic_lif *lif = netdev_priv(netdev); |
| 70 | + |
| 71 | + switch (sset) { |
| 72 | + case ETH_SS_STATS: |
| 73 | + ionic_get_stats_strings(lif, buf); |
| 74 | + break; |
| 75 | + case ETH_SS_PRIV_FLAGS: |
| 76 | + memcpy(buf, ionic_priv_flags_strings, |
| 77 | + PRIV_FLAGS_COUNT * ETH_GSTRING_LEN); |
| 78 | + break; |
| 79 | + } |
| 80 | +} |
11 | 81 |
|
12 | 82 | static void ionic_get_drvinfo(struct net_device *netdev, |
13 | 83 | struct ethtool_drvinfo *drvinfo) |
@@ -386,6 +456,32 @@ static int ionic_set_channels(struct net_device *netdev, |
386 | 456 | return 0; |
387 | 457 | } |
388 | 458 |
|
| 459 | +static u32 ionic_get_priv_flags(struct net_device *netdev) |
| 460 | +{ |
| 461 | + struct ionic_lif *lif = netdev_priv(netdev); |
| 462 | + u32 priv_flags = 0; |
| 463 | + |
| 464 | + if (test_bit(IONIC_LIF_SW_DEBUG_STATS, lif->state)) |
| 465 | + priv_flags |= PRIV_F_SW_DBG_STATS; |
| 466 | + |
| 467 | + return priv_flags; |
| 468 | +} |
| 469 | + |
| 470 | +static int ionic_set_priv_flags(struct net_device *netdev, u32 priv_flags) |
| 471 | +{ |
| 472 | + struct ionic_lif *lif = netdev_priv(netdev); |
| 473 | + u32 flags = lif->flags; |
| 474 | + |
| 475 | + clear_bit(IONIC_LIF_SW_DEBUG_STATS, lif->state); |
| 476 | + if (priv_flags & PRIV_F_SW_DBG_STATS) |
| 477 | + set_bit(IONIC_LIF_SW_DEBUG_STATS, lif->state); |
| 478 | + |
| 479 | + if (flags != lif->flags) |
| 480 | + lif->flags = flags; |
| 481 | + |
| 482 | + return 0; |
| 483 | +} |
| 484 | + |
389 | 485 | static int ionic_get_module_info(struct net_device *netdev, |
390 | 486 | struct ethtool_modinfo *modinfo) |
391 | 487 |
|
@@ -483,6 +579,11 @@ static const struct ethtool_ops ionic_ethtool_ops = { |
483 | 579 | .set_ringparam = ionic_set_ringparam, |
484 | 580 | .get_channels = ionic_get_channels, |
485 | 581 | .set_channels = ionic_set_channels, |
| 582 | + .get_strings = ionic_get_strings, |
| 583 | + .get_ethtool_stats = ionic_get_stats, |
| 584 | + .get_sset_count = ionic_get_sset_count, |
| 585 | + .get_priv_flags = ionic_get_priv_flags, |
| 586 | + .set_priv_flags = ionic_set_priv_flags, |
486 | 587 | .get_module_info = ionic_get_module_info, |
487 | 588 | .get_module_eeprom = ionic_get_module_eeprom, |
488 | 589 | .get_pauseparam = ionic_get_pauseparam, |
|
0 commit comments