Skip to content

Commit 77805dd

Browse files
nrescobarkuba-moo
authored andcommitted
enic: Report per queue statistics in netdev qstats
Report per queue wq/rq statistics in netdev qstats. Signed-off-by: Nelson Escobar <[email protected]> Signed-off-by: John Daley <[email protected]> Signed-off-by: Satish Kharat <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f3f9150 commit 77805dd

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

drivers/net/ethernet/cisco/enic/enic_main.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <linux/crash_dump.h>
4747
#include <net/busy_poll.h>
4848
#include <net/vxlan.h>
49+
#include <net/netdev_queues.h>
4950

5051
#include "cq_enet_desc.h"
5152
#include "vnic_dev.h"
@@ -2571,6 +2572,54 @@ static void enic_clear_intr_mode(struct enic *enic)
25712572
vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN);
25722573
}
25732574

2575+
static void enic_get_queue_stats_rx(struct net_device *dev, int idx,
2576+
struct netdev_queue_stats_rx *rxs)
2577+
{
2578+
struct enic *enic = netdev_priv(dev);
2579+
struct enic_rq_stats *rqstats = &enic->rq_stats[idx];
2580+
2581+
rxs->bytes = rqstats->bytes;
2582+
rxs->packets = rqstats->packets;
2583+
rxs->hw_drops = rqstats->bad_fcs + rqstats->pkt_truncated;
2584+
rxs->hw_drop_overruns = rqstats->pkt_truncated;
2585+
rxs->csum_unnecessary = rqstats->csum_unnecessary +
2586+
rqstats->csum_unnecessary_encap;
2587+
}
2588+
2589+
static void enic_get_queue_stats_tx(struct net_device *dev, int idx,
2590+
struct netdev_queue_stats_tx *txs)
2591+
{
2592+
struct enic *enic = netdev_priv(dev);
2593+
struct enic_wq_stats *wqstats = &enic->wq_stats[idx];
2594+
2595+
txs->bytes = wqstats->bytes;
2596+
txs->packets = wqstats->packets;
2597+
txs->csum_none = wqstats->csum_none;
2598+
txs->needs_csum = wqstats->csum_partial + wqstats->encap_csum +
2599+
wqstats->tso;
2600+
txs->hw_gso_packets = wqstats->tso;
2601+
txs->stop = wqstats->stopped;
2602+
txs->wake = wqstats->wake;
2603+
}
2604+
2605+
static void enic_get_base_stats(struct net_device *dev,
2606+
struct netdev_queue_stats_rx *rxs,
2607+
struct netdev_queue_stats_tx *txs)
2608+
{
2609+
rxs->bytes = 0;
2610+
rxs->packets = 0;
2611+
rxs->hw_drops = 0;
2612+
rxs->hw_drop_overruns = 0;
2613+
rxs->csum_unnecessary = 0;
2614+
txs->bytes = 0;
2615+
txs->packets = 0;
2616+
txs->csum_none = 0;
2617+
txs->needs_csum = 0;
2618+
txs->hw_gso_packets = 0;
2619+
txs->stop = 0;
2620+
txs->wake = 0;
2621+
}
2622+
25742623
static const struct net_device_ops enic_netdev_dynamic_ops = {
25752624
.ndo_open = enic_open,
25762625
.ndo_stop = enic_stop,
@@ -2619,6 +2668,12 @@ static const struct net_device_ops enic_netdev_ops = {
26192668
.ndo_features_check = enic_features_check,
26202669
};
26212670

2671+
static const struct netdev_stat_ops enic_netdev_stat_ops = {
2672+
.get_queue_stats_rx = enic_get_queue_stats_rx,
2673+
.get_queue_stats_tx = enic_get_queue_stats_tx,
2674+
.get_base_stats = enic_get_base_stats,
2675+
};
2676+
26222677
static void enic_dev_deinit(struct enic *enic)
26232678
{
26242679
unsigned int i;
@@ -2961,6 +3016,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
29613016
netdev->netdev_ops = &enic_netdev_dynamic_ops;
29623017
else
29633018
netdev->netdev_ops = &enic_netdev_ops;
3019+
netdev->stat_ops = &enic_netdev_stat_ops;
29643020

29653021
netdev->watchdog_timeo = 2 * HZ;
29663022
enic_set_ethtool_ops(netdev);

0 commit comments

Comments
 (0)