Commit 158135dc authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'enic-report-per-queue-stats'

Nelson Escobar says:

====================
enic: Report per queue stats

Patch #1: Use a macro instead of static const variables for array sizes.  I
          didn't want to add more static const variables in the next patch
          so clean up the existing ones first.

Patch #2: Collect per queue statistics

Patch #3: Report per queue stats in netdev qstats

Patch #4: Report some per queue stats in ethtool

 # NETIF="eno6" tools/testing/selftests/drivers/net/stats.py
KTAP version 1
1..5
ok 1 stats.check_pause # XFAIL pause not supported by the device
ok 2 stats.check_fec # XFAIL FEC not supported by the device
ok 3 stats.pkt_byte_sum
ok 4 stats.qstat_by_ifindex
ok 5 stats.check_down

 # tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
     --dump qstats-get --json '{"ifindex": "34"}'
[{'ifindex': 34,
  'rx-bytes': 66762680,
  'rx-csum-unnecessary': 1009345,
  'rx-hw-drop-overruns': 0,
  'rx-hw-drops': 0,
  'rx-packets': 1009673,
  'tx-bytes': 137936674899,
  'tx-csum-none': 125,
  'tx-hw-gso-packets': 2408712,
  'tx-needs-csum': 2431531,
  'tx-packets': 15475466,
  'tx-stop': 0,
  'tx-wake': 0}]

v2: https://lore.kernel.org/20240905010900.24152-1-neescoba@cisco.com
v1: https://lore.kernel.org/20240823235401.29996-1-neescoba@cisco.com
====================

Link: https://patch.msgid.link/20240912005039.10797-1-neescoba@cisco.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7bb50f30 bde04d98
......@@ -128,6 +128,40 @@ struct vxlan_offload {
u8 flags;
};
struct enic_wq_stats {
u64 packets; /* pkts queued for Tx */
u64 stopped; /* Tx ring almost full, queue stopped */
u64 wake; /* Tx ring no longer full, queue woken up*/
u64 tso; /* non-encap tso pkt */
u64 encap_tso; /* encap tso pkt */
u64 encap_csum; /* encap HW csum */
u64 csum_partial; /* skb->ip_summed = CHECKSUM_PARTIAL */
u64 csum_none; /* HW csum not required */
u64 bytes; /* bytes queued for Tx */
u64 add_vlan; /* HW adds vlan tag */
u64 cq_work; /* Tx completions processed */
u64 cq_bytes; /* Tx bytes processed */
u64 null_pkt; /* skb length <= 0 */
u64 skb_linear_fail; /* linearize failures */
u64 desc_full_awake; /* TX ring full while queue awake */
};
struct enic_rq_stats {
u64 packets; /* pkts received */
u64 bytes; /* bytes received */
u64 l4_rss_hash; /* hashed on l4 */
u64 l3_rss_hash; /* hashed on l3 */
u64 csum_unnecessary; /* HW verified csum */
u64 csum_unnecessary_encap; /* HW verified csum on encap packet */
u64 vlan_stripped; /* HW stripped vlan */
u64 napi_complete; /* napi complete intr reenabled */
u64 napi_repoll; /* napi poll again */
u64 bad_fcs; /* bad pkts */
u64 pkt_truncated; /* truncated pkts */
u64 no_skb; /* out of skbs */
u64 desc_skip; /* Rx pkt went into later buffer */
};
/* Per-instance private data structure */
struct enic {
struct net_device *netdev;
......@@ -162,16 +196,16 @@ struct enic {
/* work queue cache line section */
____cacheline_aligned struct vnic_wq wq[ENIC_WQ_MAX];
spinlock_t wq_lock[ENIC_WQ_MAX];
struct enic_wq_stats wq_stats[ENIC_WQ_MAX];
unsigned int wq_count;
u16 loop_enable;
u16 loop_tag;
/* receive queue cache line section */
____cacheline_aligned struct vnic_rq rq[ENIC_RQ_MAX];
struct enic_rq_stats rq_stats[ENIC_RQ_MAX];
unsigned int rq_count;
struct vxlan_offload vxlan;
u64 rq_truncated_pkts;
u64 rq_bad_fcs;
struct napi_struct napi[ENIC_RQ_MAX + ENIC_WQ_MAX];
/* interrupt resource cache line section */
......
......@@ -32,6 +32,41 @@ struct enic_stat {
.index = offsetof(struct vnic_gen_stats, stat) / sizeof(u64)\
}
#define ENIC_PER_RQ_STAT(stat) { \
.name = "rq[%d]_"#stat, \
.index = offsetof(struct enic_rq_stats, stat) / sizeof(u64) \
}
#define ENIC_PER_WQ_STAT(stat) { \
.name = "wq[%d]_"#stat, \
.index = offsetof(struct enic_wq_stats, stat) / sizeof(u64) \
}
static const struct enic_stat enic_per_rq_stats[] = {
ENIC_PER_RQ_STAT(l4_rss_hash),
ENIC_PER_RQ_STAT(l3_rss_hash),
ENIC_PER_RQ_STAT(csum_unnecessary_encap),
ENIC_PER_RQ_STAT(vlan_stripped),
ENIC_PER_RQ_STAT(napi_complete),
ENIC_PER_RQ_STAT(napi_repoll),
ENIC_PER_RQ_STAT(no_skb),
ENIC_PER_RQ_STAT(desc_skip),
};
#define NUM_ENIC_PER_RQ_STATS ARRAY_SIZE(enic_per_rq_stats)
static const struct enic_stat enic_per_wq_stats[] = {
ENIC_PER_WQ_STAT(encap_tso),
ENIC_PER_WQ_STAT(encap_csum),
ENIC_PER_WQ_STAT(add_vlan),
ENIC_PER_WQ_STAT(cq_work),
ENIC_PER_WQ_STAT(cq_bytes),
ENIC_PER_WQ_STAT(null_pkt),
ENIC_PER_WQ_STAT(skb_linear_fail),
ENIC_PER_WQ_STAT(desc_full_awake),
};
#define NUM_ENIC_PER_WQ_STATS ARRAY_SIZE(enic_per_wq_stats)
static const struct enic_stat enic_tx_stats[] = {
ENIC_TX_STAT(tx_frames_ok),
ENIC_TX_STAT(tx_unicast_frames_ok),
......@@ -46,6 +81,8 @@ static const struct enic_stat enic_tx_stats[] = {
ENIC_TX_STAT(tx_tso),
};
#define NUM_ENIC_TX_STATS ARRAY_SIZE(enic_tx_stats)
static const struct enic_stat enic_rx_stats[] = {
ENIC_RX_STAT(rx_frames_ok),
ENIC_RX_STAT(rx_frames_total),
......@@ -70,13 +107,13 @@ static const struct enic_stat enic_rx_stats[] = {
ENIC_RX_STAT(rx_frames_to_max),
};
#define NUM_ENIC_RX_STATS ARRAY_SIZE(enic_rx_stats)
static const struct enic_stat enic_gen_stats[] = {
ENIC_GEN_STAT(dma_map_error),
};
static const unsigned int enic_n_tx_stats = ARRAY_SIZE(enic_tx_stats);
static const unsigned int enic_n_rx_stats = ARRAY_SIZE(enic_rx_stats);
static const unsigned int enic_n_gen_stats = ARRAY_SIZE(enic_gen_stats);
#define NUM_ENIC_GEN_STATS ARRAY_SIZE(enic_gen_stats)
static void enic_intr_coal_set_rx(struct enic *enic, u32 timer)
{
......@@ -141,22 +178,38 @@ static void enic_get_drvinfo(struct net_device *netdev,
static void enic_get_strings(struct net_device *netdev, u32 stringset,
u8 *data)
{
struct enic *enic = netdev_priv(netdev);
unsigned int i;
unsigned int j;
switch (stringset) {
case ETH_SS_STATS:
for (i = 0; i < enic_n_tx_stats; i++) {
for (i = 0; i < NUM_ENIC_TX_STATS; i++) {
memcpy(data, enic_tx_stats[i].name, ETH_GSTRING_LEN);
data += ETH_GSTRING_LEN;
}
for (i = 0; i < enic_n_rx_stats; i++) {
for (i = 0; i < NUM_ENIC_RX_STATS; i++) {
memcpy(data, enic_rx_stats[i].name, ETH_GSTRING_LEN);
data += ETH_GSTRING_LEN;
}
for (i = 0; i < enic_n_gen_stats; i++) {
for (i = 0; i < NUM_ENIC_GEN_STATS; i++) {
memcpy(data, enic_gen_stats[i].name, ETH_GSTRING_LEN);
data += ETH_GSTRING_LEN;
}
for (i = 0; i < enic->rq_count; i++) {
for (j = 0; j < NUM_ENIC_PER_RQ_STATS; j++) {
snprintf(data, ETH_GSTRING_LEN,
enic_per_rq_stats[j].name, i);
data += ETH_GSTRING_LEN;
}
}
for (i = 0; i < enic->wq_count; i++) {
for (j = 0; j < NUM_ENIC_PER_WQ_STATS; j++) {
snprintf(data, ETH_GSTRING_LEN,
enic_per_wq_stats[j].name, i);
data += ETH_GSTRING_LEN;
}
}
break;
}
}
......@@ -242,9 +295,19 @@ static int enic_set_ringparam(struct net_device *netdev,
static int enic_get_sset_count(struct net_device *netdev, int sset)
{
struct enic *enic = netdev_priv(netdev);
unsigned int n_per_rq_stats;
unsigned int n_per_wq_stats;
unsigned int n_stats;
switch (sset) {
case ETH_SS_STATS:
return enic_n_tx_stats + enic_n_rx_stats + enic_n_gen_stats;
n_per_rq_stats = NUM_ENIC_PER_RQ_STATS * enic->rq_count;
n_per_wq_stats = NUM_ENIC_PER_WQ_STATS * enic->wq_count;
n_stats = NUM_ENIC_TX_STATS + NUM_ENIC_RX_STATS +
NUM_ENIC_GEN_STATS +
n_per_rq_stats + n_per_wq_stats;
return n_stats;
default:
return -EOPNOTSUPP;
}
......@@ -256,6 +319,7 @@ static void enic_get_ethtool_stats(struct net_device *netdev,
struct enic *enic = netdev_priv(netdev);
struct vnic_stats *vstats;
unsigned int i;
unsigned int j;
int err;
err = enic_dev_stats_dump(enic, &vstats);
......@@ -266,12 +330,30 @@ static void enic_get_ethtool_stats(struct net_device *netdev,
if (err == -ENOMEM)
return;
for (i = 0; i < enic_n_tx_stats; i++)
for (i = 0; i < NUM_ENIC_TX_STATS; i++)
*(data++) = ((u64 *)&vstats->tx)[enic_tx_stats[i].index];
for (i = 0; i < enic_n_rx_stats; i++)
for (i = 0; i < NUM_ENIC_RX_STATS; i++)
*(data++) = ((u64 *)&vstats->rx)[enic_rx_stats[i].index];
for (i = 0; i < enic_n_gen_stats; i++)
for (i = 0; i < NUM_ENIC_GEN_STATS; i++)
*(data++) = ((u64 *)&enic->gen_stats)[enic_gen_stats[i].index];
for (i = 0; i < enic->rq_count; i++) {
struct enic_rq_stats *rqstats = &enic->rq_stats[i];
int index;
for (j = 0; j < NUM_ENIC_PER_RQ_STATS; j++) {
index = enic_per_rq_stats[j].index;
*(data++) = ((u64 *)rqstats)[index];
}
}
for (i = 0; i < enic->wq_count; i++) {
struct enic_wq_stats *wqstats = &enic->wq_stats[i];
int index;
for (j = 0; j < NUM_ENIC_PER_WQ_STATS; j++) {
index = enic_per_wq_stats[j].index;
*(data++) = ((u64 *)wqstats)[index];
}
}
}
static u32 enic_get_msglevel(struct net_device *netdev)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment