Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci/ixgbe - Count "Total Packets Missed" by evcnt(9)



details:   https://anonhg.NetBSD.org/src/rev/6129cf92225c
branches:  trunk
changeset: 353696:6129cf92225c
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu May 18 08:27:19 2017 +0000

description:
- Count "Total Packets Missed" by evcnt(9)
- Call evcnt_attach_dynamic()/detach() for stats->mngpdc
  (Management Packets Dropped).
- Make stats->rnbc (Receive No Buffers) evcnt(9). Only 82598 has this register.
- Set RQSMR, TQSM (or TQSMR on 82598) to count qprc, qptc, qbrc, qbtc and qprdc
  in each queue counter. Without this change, all queue's counts are counted in
  queue 0's. Even if with this change, only MPC[0] is counted and other MPCs
  are not counted.

diffstat:

 sys/dev/pci/ixgbe/ixgbe.c      |  58 ++++++++++++++++++++++++++++++++++++++++-
 sys/dev/pci/ixgbe/ixgbe_type.h |   4 +-
 2 files changed, 58 insertions(+), 4 deletions(-)

diffs (173 lines):

diff -r b01574c1cb13 -r 6129cf92225c sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Thu May 18 08:25:37 2017 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Thu May 18 08:27:19 2017 +0000
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*$FreeBSD: head/sys/dev/ixgbe/if_ix.c 302384 2016-07-07 03:39:18Z sbruno $*/
-/*$NetBSD: ixgbe.c,v 1.81 2017/04/28 10:24:45 msaitoh Exp $*/
+/*$NetBSD: ixgbe.c,v 1.82 2017/05/18 08:27:19 msaitoh Exp $*/
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -765,6 +765,7 @@
        struct ix_queue *que = adapter->queues;
        struct rx_ring *rxr = adapter->rx_rings;
        struct tx_ring *txr = adapter->tx_rings;
+       struct ixgbe_hw *hw = &adapter->hw;
        struct ixgbe_hw_stats *stats = &adapter->stats.pf;
        u32     ctrl_ext;
 
@@ -860,6 +861,8 @@
 
                if (i < __arraycount(stats->mpc)) {
                        evcnt_detach(&stats->mpc[i]);
+                       if (hw->mac.type == ixgbe_mac_82598EB)
+                               evcnt_detach(&stats->rnbc[i]);
                }
                if (i < __arraycount(stats->pxontxc)) {
                        evcnt_detach(&stats->pxontxc[i]);
@@ -892,6 +895,7 @@
        evcnt_detach(&stats->illerrc);
        evcnt_detach(&stats->errbc);
        evcnt_detach(&stats->mspdc);
+       evcnt_detach(&stats->mpctotal);
        evcnt_detach(&stats->mlfc);
        evcnt_detach(&stats->mrfc);
        evcnt_detach(&stats->rlec);
@@ -918,6 +922,7 @@
        evcnt_detach(&stats->roc);
        evcnt_detach(&stats->rjc);
        evcnt_detach(&stats->mngprc);
+       evcnt_detach(&stats->mngpdc);
        evcnt_detach(&stats->xec);
 
        /* Packet Transmission Stats */
@@ -1587,7 +1592,7 @@
        }
 }
 
-__unused static inline void
+static inline void
 ixgbe_disable_queue(struct adapter *adapter, u32 vector)
 {
        struct ixgbe_hw *hw = &adapter->hw;
@@ -3498,6 +3503,9 @@
        for (i = 0; i < adapter->num_queues; i++, rxr++) {
                u64 rdba = rxr->rxdma.dma_paddr;
                int j = rxr->me;
+               u32 tqsmreg, reg;
+               int regnum = i / 4;     /* 1 register per 4 queues */
+               int regshift = i % 4;   /* 4 bits per 1 queue */
 
                /* Setup the Base and Length of the Rx Descriptor Ring */
                IXGBE_WRITE_REG(hw, IXGBE_RDBAL(j),
@@ -3513,6 +3521,26 @@
                srrctl |= bufsz;
                srrctl |= IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF;
 
+               /* Set RQSMR (Receive Queue Statistic Mapping) register */
+               reg = IXGBE_READ_REG(hw, IXGBE_RQSMR(regnum));
+               reg &= ~(0x000000ff << (regshift * 8));
+               reg |= i << (regshift * 8);
+               IXGBE_WRITE_REG(hw, IXGBE_RQSMR(regnum), reg);
+
+               /*
+                * Set RQSMR (Receive Queue Statistic Mapping) register.
+                * Register location for queue 0...7 are different between
+                * 82598 and newer.
+                */
+               if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+                       tqsmreg = IXGBE_TQSMR(regnum);
+               else
+                       tqsmreg = IXGBE_TQSM(regnum);
+               reg = IXGBE_READ_REG(hw, tqsmreg);
+               reg &= ~(0x000000ff << (regshift * 8));
+               reg |= i << (regshift * 8);
+               IXGBE_WRITE_REG(hw, tqsmreg, reg);
+
                /*
                 * Set DROP_EN iff we have no flow control and >1 queue.
                 * Note that srrctl was cleared shortly before during reset,
@@ -4308,6 +4336,22 @@
                stats->qptc[j].ev_count += IXGBE_READ_REG(hw, IXGBE_QPTC(i));
                stats->qprdc[j].ev_count += IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
        }
+       for (int i = 0; i < __arraycount(stats->mpc); i++) {
+               uint32_t mp;
+               int j = i % adapter->num_queues;
+
+               mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
+               /* global total per queue */
+               stats->mpc[j].ev_count += mp;
+               /* running comprehensive total for stats display */
+               total_missed_rx += mp;
+
+               if (hw->mac.type == ixgbe_mac_82598EB)
+                       stats->rnbc[j].ev_count
+                           += IXGBE_READ_REG(hw, IXGBE_RNBC(i));
+               
+       }
+       stats->mpctotal.ev_count += total_missed_rx;
        stats->mlfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MLFC);
        stats->mrfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MRFC);
        rlec = IXGBE_READ_REG(hw, IXGBE_RLEC);
@@ -4699,6 +4743,7 @@
        struct sysctllog **log = &adapter->sysctllog;
        struct tx_ring *txr = adapter->tx_rings;
        struct rx_ring *rxr = adapter->rx_rings;
+       struct ixgbe_hw *hw = &adapter->hw;
        struct ixgbe_hw_stats *stats = &adapter->stats.pf;
        const char *xname = device_xname(dev);
 
@@ -4828,6 +4873,11 @@
                        evcnt_attach_dynamic(&stats->mpc[i],
                            EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
                            "Missed Packet Count");
+                       if (hw->mac.type == ixgbe_mac_82598EB)
+                               evcnt_attach_dynamic(&stats->rnbc[i],
+                                   EVCNT_TYPE_MISC, NULL,
+                                   adapter->queues[i].evnamebuf,
+                                   "Receive No Buffers");
                }
                if (i < __arraycount(stats->pxontxc)) {
                        evcnt_attach_dynamic(&stats->pxontxc[i],
@@ -4909,6 +4959,8 @@
            stats->namebuf, "Byte Errors");
        evcnt_attach_dynamic(&stats->mspdc, EVCNT_TYPE_MISC, NULL,
            stats->namebuf, "MAC Short Packets Discarded");
+       evcnt_attach_dynamic(&stats->mpctotal, EVCNT_TYPE_MISC, NULL,
+           stats->namebuf, "Total Packets Missed");
        evcnt_attach_dynamic(&stats->mlfc, EVCNT_TYPE_MISC, NULL,
            stats->namebuf, "MAC Local Faults");
        evcnt_attach_dynamic(&stats->mrfc, EVCNT_TYPE_MISC, NULL,
@@ -4959,6 +5011,8 @@
            stats->namebuf, "Received Jabber");
        evcnt_attach_dynamic(&stats->mngprc, EVCNT_TYPE_MISC, NULL,
            stats->namebuf, "Management Packets Received");
+       evcnt_attach_dynamic(&stats->mngpdc, EVCNT_TYPE_MISC, NULL,
+           stats->namebuf, "Management Packets Dropped");
        evcnt_attach_dynamic(&stats->xec, EVCNT_TYPE_MISC, NULL,
            stats->namebuf, "Checksum Errors");
 
diff -r b01574c1cb13 -r 6129cf92225c sys/dev/pci/ixgbe/ixgbe_type.h
--- a/sys/dev/pci/ixgbe/ixgbe_type.h    Thu May 18 08:25:37 2017 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_type.h    Thu May 18 08:27:19 2017 +0000
@@ -31,7 +31,7 @@
 
 ******************************************************************************/
 /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_type.h 299200 2016-05-06 22:54:56Z pfg $*/
-/*$NetBSD: ixgbe_type.h,v 1.19 2017/02/24 05:38:30 msaitoh Exp $*/
+/*$NetBSD: ixgbe_type.h,v 1.20 2017/05/18 08:27:19 msaitoh Exp $*/
 
 #ifndef _IXGBE_TYPE_H_
 #define _IXGBE_TYPE_H_
@@ -3593,7 +3593,7 @@
        struct evcnt gptc;
        struct evcnt gorc;
        struct evcnt gotc;
-       u64 rnbc[8];
+       struct evcnt rnbc[8];
        struct evcnt ruc;
        struct evcnt rfc;
        struct evcnt roc;



Home | Main Index | Thread Index | Old Index