Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci ixl(4) supports in-chip statistic counters per port



details:   https://anonhg.NetBSD.org/src/rev/64e86a77fcf2
branches:  trunk
changeset: 847897:64e86a77fcf2
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Thu Jan 09 02:43:45 2020 +0000

description:
ixl(4) supports in-chip statistic counters per port

diffstat:

 sys/dev/pci/if_ixl.c |  465 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 463 insertions(+), 2 deletions(-)

diffs (truncated from 564 to 300 lines):

diff -r 6329456389ab -r 64e86a77fcf2 sys/dev/pci/if_ixl.c
--- a/sys/dev/pci/if_ixl.c      Thu Jan 09 01:38:34 2020 +0000
+++ b/sys/dev/pci/if_ixl.c      Thu Jan 09 02:43:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ixl.c,v 1.16 2020/01/08 09:12:11 yamaguchi Exp $    */
+/*     $NetBSD: if_ixl.c,v 1.17 2020/01/09 02:43:45 yamaguchi Exp $    */
 
 /*
  * Copyright (c) 2013-2015, Intel Corporation
@@ -485,6 +485,82 @@
        unsigned int     product_id;
 };
 
+struct ixl_stats_counters {
+       bool             isc_has_offset;
+       struct evcnt     isc_crc_errors;
+       uint64_t         isc_crc_errors_offset;
+       struct evcnt     isc_illegal_bytes;
+       uint64_t         isc_illegal_bytes_offset;
+       struct evcnt     isc_rx_bytes;
+       uint64_t         isc_rx_bytes_offset;
+       struct evcnt     isc_rx_discards;
+       uint64_t         isc_rx_discards_offset;
+       struct evcnt     isc_rx_unicast;
+       uint64_t         isc_rx_unicast_offset;
+       struct evcnt     isc_rx_multicast;
+       uint64_t         isc_rx_multicast_offset;
+       struct evcnt     isc_rx_broadcast;
+       uint64_t         isc_rx_broadcast_offset;
+       struct evcnt     isc_rx_size_64;
+       uint64_t         isc_rx_size_64_offset;
+       struct evcnt     isc_rx_size_127;
+       uint64_t         isc_rx_size_127_offset;
+       struct evcnt     isc_rx_size_255;
+       uint64_t         isc_rx_size_255_offset;
+       struct evcnt     isc_rx_size_511;
+       uint64_t         isc_rx_size_511_offset;
+       struct evcnt     isc_rx_size_1023;
+       uint64_t         isc_rx_size_1023_offset;
+       struct evcnt     isc_rx_size_1522;
+       uint64_t         isc_rx_size_1522_offset;
+       struct evcnt     isc_rx_size_big;
+       uint64_t         isc_rx_size_big_offset;
+       struct evcnt     isc_rx_undersize;
+       uint64_t         isc_rx_undersize_offset;
+       struct evcnt     isc_rx_oversize;
+       uint64_t         isc_rx_oversize_offset;
+       struct evcnt     isc_rx_fragments;
+       uint64_t         isc_rx_fragments_offset;
+       struct evcnt     isc_rx_jabber;
+       uint64_t         isc_rx_jabber_offset;
+       struct evcnt     isc_tx_bytes;
+       uint64_t         isc_tx_bytes_offset;
+       struct evcnt     isc_tx_dropped_link_down;
+       uint64_t         isc_tx_dropped_link_down_offset;
+       struct evcnt     isc_tx_unicast;
+       uint64_t         isc_tx_unicast_offset;
+       struct evcnt     isc_tx_multicast;
+       uint64_t         isc_tx_multicast_offset;
+       struct evcnt     isc_tx_broadcast;
+       uint64_t         isc_tx_broadcast_offset;
+       struct evcnt     isc_tx_size_64;
+       uint64_t         isc_tx_size_64_offset;
+       struct evcnt     isc_tx_size_127;
+       uint64_t         isc_tx_size_127_offset;
+       struct evcnt     isc_tx_size_255;
+       uint64_t         isc_tx_size_255_offset;
+       struct evcnt     isc_tx_size_511;
+       uint64_t         isc_tx_size_511_offset;
+       struct evcnt     isc_tx_size_1023;
+       uint64_t         isc_tx_size_1023_offset;
+       struct evcnt     isc_tx_size_1522;
+       uint64_t         isc_tx_size_1522_offset;
+       struct evcnt     isc_tx_size_big;
+       uint64_t         isc_tx_size_big_offset;
+       struct evcnt     isc_mac_local_faults;
+       uint64_t         isc_mac_local_faults_offset;
+       struct evcnt     isc_mac_remote_faults;
+       uint64_t         isc_mac_remote_faults_offset;
+       struct evcnt     isc_link_xon_rx;
+       uint64_t         isc_link_xon_rx_offset;
+       struct evcnt     isc_link_xon_tx;
+       uint64_t         isc_link_xon_tx_offset;
+       struct evcnt     isc_link_xoff_rx;
+       uint64_t         isc_link_xoff_rx_offset;
+       struct evcnt     isc_link_xoff_tx;
+       uint64_t         isc_link_xoff_tx_offset;
+};
+
 /*
  * Locking notes:
  * + a field in ixl_tx_ring is protected by txr_lock (a spin mutex), and
@@ -508,9 +584,15 @@
        bool                     sc_attached;
        bool                     sc_dead;
        bool                     sc_rxctl_atq;
+       uint32_t                 sc_port;
        struct sysctllog        *sc_sysctllog;
        struct workqueue        *sc_workq;
        struct workqueue        *sc_workq_txrx;
+       int                      sc_stats_intval;
+       callout_t                sc_stats_callout;
+       struct ixl_work          sc_stats_task;
+       struct ixl_stats_counters
+                                sc_stats_counters;
        uint8_t                  sc_enaddr[ETHER_ADDR_LEN];
        struct ifmedia           sc_media;
        uint64_t                 sc_media_status;
@@ -613,6 +695,9 @@
 #define DDPRINTF(sc, fmt, args...)     __nothing
 #endif
 #define IXL_NOMSIX     false
+#ifndef IXL_STATS_INTERVAL_MSEC
+#define IXL_STATS_INTERVAL_MSEC        10000
+#endif
 
 static enum i40e_mac_type
     ixl_mactype(pci_product_id_t);
@@ -742,6 +827,8 @@
 static void    ixl_teardown_interrupts(struct ixl_softc *);
 static int     ixl_setup_stats(struct ixl_softc *);
 static void    ixl_teardown_stats(struct ixl_softc *);
+static void    ixl_stats_callout(void *);
+static void    ixl_stats_update(void *);
 static int     ixl_setup_sysctls(struct ixl_softc *);
 static void    ixl_teardown_sysctls(struct ixl_softc *);
 static int     ixl_queue_pairs_alloc(struct ixl_softc *);
@@ -973,7 +1060,8 @@
        port = ixl_rd(sc, I40E_PFGEN_PORTNUM);
        port &= I40E_PFGEN_PORTNUM_PORT_NUM_MASK;
        port >>= I40E_PFGEN_PORTNUM_PORT_NUM_SHIFT;
-       aprint_normal(": port %u", port);
+       sc->sc_port = port;
+       aprint_normal(": port %u", sc->sc_port);
 
        ari = ixl_rd(sc, I40E_GLPCI_CAPSUP);
        ari &= I40E_GLPCI_CAPSUP_ARI_EN_MASK;
@@ -1261,6 +1349,10 @@
        sc->sc_tx_intr_process_limit = IXL_TX_INTR_PROCESS_LIMIT;
        sc->sc_rx_intr_process_limit = IXL_RX_INTR_PROCESS_LIMIT;
 
+       ixl_stats_update(sc);
+       sc->sc_stats_counters.isc_has_offset = true;
+       callout_schedule(&sc->sc_stats_callout, mstohz(sc->sc_stats_intval));
+
        if (pmf_device_register(self, NULL, NULL) != true)
                aprint_debug_dev(self, "couldn't establish power handler\n");
        sc->sc_attached = true;
@@ -1328,6 +1420,9 @@
 
        ixl_disable_other_intr(sc);
 
+       callout_stop(&sc->sc_stats_callout);
+       ixl_work_wait(sc->sc_workq, &sc->sc_stats_task);
+
        /* wait for ATQ handler */
        mutex_enter(&sc->sc_atq_lock);
        mutex_exit(&sc->sc_atq_lock);
@@ -5447,6 +5542,7 @@
        struct ixl_queue_pair *qp;
        struct ixl_tx_ring *txr;
        struct ixl_rx_ring *rxr;
+       struct ixl_stats_counters *isc;
        unsigned int i;
 
        for (i = 0; i < sc->sc_nqueue_pairs_max; i++) {
@@ -5491,6 +5587,90 @@
        evcnt_attach_dynamic(&sc->sc_event_crit_err, EVCNT_TYPE_MISC,
            NULL, device_xname(sc->sc_dev), "Critical error");
 
+       isc = &sc->sc_stats_counters;
+       evcnt_attach_dynamic(&isc->isc_crc_errors, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "CRC errors");
+       evcnt_attach_dynamic(&isc->isc_illegal_bytes, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Illegal bytes");
+       evcnt_attach_dynamic(&isc->isc_mac_local_faults, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Mac local faults");
+       evcnt_attach_dynamic(&isc->isc_mac_remote_faults, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Mac remote faults");
+       evcnt_attach_dynamic(&isc->isc_link_xon_rx, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx xon");
+       evcnt_attach_dynamic(&isc->isc_link_xon_tx, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx xon");
+       evcnt_attach_dynamic(&isc->isc_link_xoff_rx, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx xoff");
+       evcnt_attach_dynamic(&isc->isc_link_xoff_tx, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx xoff");
+       evcnt_attach_dynamic(&isc->isc_rx_fragments, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx fragments");
+       evcnt_attach_dynamic(&isc->isc_rx_jabber, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx jabber");
+
+       evcnt_attach_dynamic(&isc->isc_rx_size_64, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx size 64");
+       evcnt_attach_dynamic(&isc->isc_rx_size_127, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx size 127");
+       evcnt_attach_dynamic(&isc->isc_rx_size_255, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx size 255");
+       evcnt_attach_dynamic(&isc->isc_rx_size_511, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx size 511");
+       evcnt_attach_dynamic(&isc->isc_rx_size_1023, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx size 1023");
+       evcnt_attach_dynamic(&isc->isc_rx_size_1522, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx size 1522");
+       evcnt_attach_dynamic(&isc->isc_rx_size_big, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx jumbo packets");
+       evcnt_attach_dynamic(&isc->isc_rx_undersize, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx under size");
+       evcnt_attach_dynamic(&isc->isc_rx_oversize, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx over size");
+
+       evcnt_attach_dynamic(&isc->isc_rx_bytes, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx bytes / port");
+       evcnt_attach_dynamic(&isc->isc_rx_discards, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx discards / port");
+       evcnt_attach_dynamic(&isc->isc_rx_unicast, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx unicast / port");
+       evcnt_attach_dynamic(&isc->isc_rx_multicast, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx multicast / port");
+       evcnt_attach_dynamic(&isc->isc_rx_broadcast, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Rx broadcast / port");
+
+       evcnt_attach_dynamic(&isc->isc_tx_size_64, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx size 64");
+       evcnt_attach_dynamic(&isc->isc_tx_size_127, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx size 127");
+       evcnt_attach_dynamic(&isc->isc_tx_size_255, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx size 255");
+       evcnt_attach_dynamic(&isc->isc_tx_size_511, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx size 511");
+       evcnt_attach_dynamic(&isc->isc_tx_size_1023, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx size 1023");
+       evcnt_attach_dynamic(&isc->isc_tx_size_1522, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx size 1522");
+       evcnt_attach_dynamic(&isc->isc_tx_size_big, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx jumbo packets");
+
+       evcnt_attach_dynamic(&isc->isc_tx_bytes, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx bytes / port");
+       evcnt_attach_dynamic(&isc->isc_tx_dropped_link_down, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev),
+           "Tx dropped due to link down / port");
+       evcnt_attach_dynamic(&isc->isc_tx_unicast, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx unicast / port");
+       evcnt_attach_dynamic(&isc->isc_tx_multicast, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx multicast / port");
+       evcnt_attach_dynamic(&isc->isc_tx_broadcast, EVCNT_TYPE_MISC,
+           NULL, device_xname(sc->sc_dev), "Tx broadcast / port");
+
+       sc->sc_stats_intval = IXL_STATS_INTERVAL_MSEC;
+       callout_init(&sc->sc_stats_callout, CALLOUT_MPSAFE);
+       callout_setfunc(&sc->sc_stats_callout, ixl_stats_callout, sc);
+       ixl_work_set(&sc->sc_stats_task, ixl_stats_update, sc);
+
        return 0;
 }
 
@@ -5499,6 +5679,7 @@
 {
        struct ixl_tx_ring *txr;
        struct ixl_rx_ring *rxr;
+       struct ixl_stats_counters *isc;
        unsigned int i;
 
        for (i = 0; i < sc->sc_nqueue_pairs_max; i++) {
@@ -5519,11 +5700,286 @@
                evcnt_detach(&rxr->rxr_defer);
        }
 
+       isc = &sc->sc_stats_counters;
+       evcnt_detach(&isc->isc_crc_errors);
+       evcnt_detach(&isc->isc_illegal_bytes);
+       evcnt_detach(&isc->isc_mac_local_faults);
+       evcnt_detach(&isc->isc_mac_remote_faults);
+       evcnt_detach(&isc->isc_link_xon_rx);
+       evcnt_detach(&isc->isc_link_xon_tx);
+       evcnt_detach(&isc->isc_link_xoff_rx);
+       evcnt_detach(&isc->isc_link_xoff_tx);
+       evcnt_detach(&isc->isc_rx_fragments);
+       evcnt_detach(&isc->isc_rx_jabber);
+       evcnt_detach(&isc->isc_rx_bytes);
+       evcnt_detach(&isc->isc_rx_discards);
+       evcnt_detach(&isc->isc_rx_unicast);
+       evcnt_detach(&isc->isc_rx_multicast);
+       evcnt_detach(&isc->isc_rx_broadcast);
+       evcnt_detach(&isc->isc_rx_size_64);
+       evcnt_detach(&isc->isc_rx_size_127);
+       evcnt_detach(&isc->isc_rx_size_255);
+       evcnt_detach(&isc->isc_rx_size_511);
+       evcnt_detach(&isc->isc_rx_size_1023);
+       evcnt_detach(&isc->isc_rx_size_1522);
+       evcnt_detach(&isc->isc_rx_size_big);
+       evcnt_detach(&isc->isc_rx_undersize);
+       evcnt_detach(&isc->isc_rx_oversize);
+       evcnt_detach(&isc->isc_tx_bytes);
+       evcnt_detach(&isc->isc_tx_dropped_link_down);
+       evcnt_detach(&isc->isc_tx_unicast);
+       evcnt_detach(&isc->isc_tx_multicast);
+       evcnt_detach(&isc->isc_tx_broadcast);
+       evcnt_detach(&isc->isc_tx_size_64);



Home | Main Index | Thread Index | Old Index