Skip to content

Commit e470355

Browse files
emuslndavem330
authored andcommitted
ionic: Add driver stats
Add in the detailed statistics for ethtool -S that the driver keeps as it processes packets. Display of the additional debug statistics can be enabled through the ethtool priv-flags feature. Signed-off-by: Shannon Nelson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a371ea commit e470355

File tree

5 files changed

+480
-2
lines changed

5 files changed

+480
-2
lines changed

drivers/net/ethernet/pensando/ionic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ obj-$(CONFIG_IONIC) := ionic.o
55

66
ionic-y := ionic_main.o ionic_bus_pci.o ionic_devlink.o ionic_dev.o \
77
ionic_debugfs.o ionic_lif.o ionic_rx_filter.o ionic_ethtool.o \
8-
ionic_txrx.o
8+
ionic_txrx.o ionic_stats.o

drivers/net/ethernet/pensando/ionic/ionic_ethtool.c

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,76 @@
88
#include "ionic_bus.h"
99
#include "ionic_lif.h"
1010
#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+
}
1181

1282
static void ionic_get_drvinfo(struct net_device *netdev,
1383
struct ethtool_drvinfo *drvinfo)
@@ -386,6 +456,32 @@ static int ionic_set_channels(struct net_device *netdev,
386456
return 0;
387457
}
388458

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+
389485
static int ionic_get_module_info(struct net_device *netdev,
390486
struct ethtool_modinfo *modinfo)
391487

@@ -483,6 +579,11 @@ static const struct ethtool_ops ionic_ethtool_ops = {
483579
.set_ringparam = ionic_set_ringparam,
484580
.get_channels = ionic_get_channels,
485581
.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,
486587
.get_module_info = ionic_get_module_info,
487588
.get_module_eeprom = ionic_get_module_eeprom,
488589
.get_pauseparam = ionic_get_pauseparam,

drivers/net/ethernet/pensando/ionic/ionic_lif.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define IONIC_MAX_NUM_NAPI_CNTR (NAPI_POLL_WEIGHT + 1)
1414
#define IONIC_MAX_NUM_SG_CNTR (IONIC_TX_MAX_SG_ELEMS + 1)
15-
#define IONIC_RX_COPYBREAK_DEFAULT 256
15+
#define IONIC_RX_COPYBREAK_DEFAULT 256
1616

1717
struct ionic_tx_stats {
1818
u64 dma_map_err;
@@ -106,8 +106,22 @@ struct ionic_deferred {
106106
struct work_struct work;
107107
};
108108

109+
struct ionic_lif_sw_stats {
110+
u64 tx_packets;
111+
u64 tx_bytes;
112+
u64 rx_packets;
113+
u64 rx_bytes;
114+
u64 tx_tso;
115+
u64 tx_no_csum;
116+
u64 tx_csum;
117+
u64 rx_csum_none;
118+
u64 rx_csum_complete;
119+
u64 rx_csum_error;
120+
};
121+
109122
enum ionic_lif_state_flags {
110123
IONIC_LIF_INITED,
124+
IONIC_LIF_SW_DEBUG_STATS,
111125
IONIC_LIF_UP,
112126
IONIC_LIF_LINK_CHECK_REQUESTED,
113127
IONIC_LIF_QUEUE_RESET,

0 commit comments

Comments
 (0)