Module Name:    src
Committed By:   msaitoh
Date:           Mon Dec  3 04:39:44 UTC 2018

Modified Files:
        src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h

Log Message:
 Some counters are not per queue but per traffic class. Make new evcnt group
"ixgM tcN" (N = 0..7) and move those counters into it. We are using only
traffic class 0, so we will see only tc0's counter are updated.


To generate a diff of this commit:
cvs rdiff -u -r1.167 -r1.168 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/pci/ixgbe/ixgbe.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.167 src/sys/dev/pci/ixgbe/ixgbe.c:1.168
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.167	Thu Sep 27 05:40:27 2018
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Dec  3 04:39:44 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.167 2018/09/27 05:40:27 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.168 2018/12/03 04:39:44 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -1537,6 +1537,7 @@ ixgbe_update_stats_counters(struct adapt
 	u32                   missed_rx = 0, bprc, lxon, lxoff, total;
 	u64                   total_missed_rx = 0;
 	uint64_t              crcerrs, rlec;
+	int		      i, j;
 
 	crcerrs = IXGBE_READ_REG(hw, IXGBE_CRCERRS);
 	stats->crcerrs.ev_count += crcerrs;
@@ -1547,8 +1548,8 @@ ixgbe_update_stats_counters(struct adapt
 		stats->mbsdc.ev_count += IXGBE_READ_REG(hw, IXGBE_MBSDC);
 
 	/* 16 registers */
-	for (int i = 0; i < __arraycount(stats->qprc); i++) {
-		int j = i % adapter->num_queues;
+	for (i = 0; i < __arraycount(stats->qprc); i++) {
+		j = i % adapter->num_queues;
 
 		stats->qprc[j].ev_count += IXGBE_READ_REG(hw, IXGBE_QPRC(i));
 		stats->qptc[j].ev_count += IXGBE_READ_REG(hw, IXGBE_QPTC(i));
@@ -1559,36 +1560,35 @@ ixgbe_update_stats_counters(struct adapt
 	}
 
 	/* 8 registers */
-	for (int i = 0; i < __arraycount(stats->mpc); i++) {
+	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
 		uint32_t mp;
-		int j = i % adapter->num_queues;
 
 		/* MPC */
 		mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
 		/* global total per queue */
-		stats->mpc[j].ev_count += mp;
+		stats->mpc[i].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
+			stats->rnbc[i].ev_count
 			    += IXGBE_READ_REG(hw, IXGBE_RNBC(i));
 
-		stats->pxontxc[j].ev_count
+		stats->pxontxc[i].ev_count
 		    += IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
-		stats->pxofftxc[j].ev_count
+		stats->pxofftxc[i].ev_count
 		    += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
 		if (hw->mac.type >= ixgbe_mac_82599EB) {
-			stats->pxonrxc[j].ev_count
+			stats->pxonrxc[i].ev_count
 			    += IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
-			stats->pxoffrxc[j].ev_count
+			stats->pxoffrxc[i].ev_count
 			    += IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
-			stats->pxon2offc[j].ev_count
+			stats->pxon2offc[i].ev_count
 			    += IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
 		} else {
-			stats->pxonrxc[j].ev_count
+			stats->pxonrxc[i].ev_count
 			    += IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
-			stats->pxoffrxc[j].ev_count
+			stats->pxoffrxc[i].ev_count
 			    += IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
 		}
 	}
@@ -1738,6 +1738,43 @@ ixgbe_add_hw_stats(struct adapter *adapt
 	evcnt_attach_dynamic(&adapter->phy_sicount, EVCNT_TYPE_INTR,
 	    NULL, xname, "external PHY softint");
 
+	/* Max number of traffic class is 8 */
+	KASSERT(IXGBE_DCB_MAX_TRAFFIC_CLASS == 8);
+	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+		snprintf(adapter->tcs[i].evnamebuf,
+		    sizeof(adapter->tcs[i].evnamebuf), "%s tc%d",
+		    xname, i);
+		if (i < __arraycount(stats->mpc)) {
+			evcnt_attach_dynamic(&stats->mpc[i],
+			    EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
+			    "RX Missed Packet Count");
+			if (hw->mac.type == ixgbe_mac_82598EB)
+				evcnt_attach_dynamic(&stats->rnbc[i],
+				    EVCNT_TYPE_MISC, NULL,
+				    adapter->tcs[i].evnamebuf,
+				    "Receive No Buffers");
+		}
+		if (i < __arraycount(stats->pxontxc)) {
+			evcnt_attach_dynamic(&stats->pxontxc[i],
+			    EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
+			    "pxontxc");
+			evcnt_attach_dynamic(&stats->pxonrxc[i],
+			    EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
+			    "pxonrxc");
+			evcnt_attach_dynamic(&stats->pxofftxc[i],
+			    EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
+			    "pxofftxc");
+			evcnt_attach_dynamic(&stats->pxoffrxc[i],
+			    EVCNT_TYPE_MISC, NULL, adapter->tcs[i].evnamebuf,
+			    "pxoffrxc");
+			if (hw->mac.type >= ixgbe_mac_82599EB)
+				evcnt_attach_dynamic(&stats->pxon2offc[i],
+				    EVCNT_TYPE_MISC, NULL,
+				    adapter->tcs[i].evnamebuf,
+			    "pxon2offc");
+		}
+	}
+
 	for (i = 0; i < adapter->num_queues; i++, rxr++, txr++) {
 #ifdef LRO
 		struct lro_ctrl *lro = &rxr->lro;
@@ -1826,35 +1863,6 @@ ixgbe_add_hw_stats(struct adapter *adapt
 		    CTL_CREATE, CTL_EOL) != 0)
 			break;
 
-		if (i < __arraycount(stats->mpc)) {
-			evcnt_attach_dynamic(&stats->mpc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "RX 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],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "pxontxc");
-			evcnt_attach_dynamic(&stats->pxonrxc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "pxonrxc");
-			evcnt_attach_dynamic(&stats->pxofftxc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "pxofftxc");
-			evcnt_attach_dynamic(&stats->pxoffrxc[i],
-			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
-			    "pxoffrxc");
-			if (hw->mac.type >= ixgbe_mac_82599EB)
-				evcnt_attach_dynamic(&stats->pxon2offc[i],
-				    EVCNT_TYPE_MISC, NULL,
-				    adapter->queues[i].evnamebuf,
-			    "pxon2offc");
-		}
 		if (i < __arraycount(stats->qprc)) {
 			evcnt_attach_dynamic(&stats->qprc[i],
 			    EVCNT_TYPE_MISC, NULL, adapter->queues[i].evnamebuf,
@@ -2014,6 +2022,7 @@ ixgbe_clear_evcnt(struct adapter *adapte
 	struct rx_ring *rxr = adapter->rx_rings;
 	struct ixgbe_hw *hw = &adapter->hw;
 	struct ixgbe_hw_stats *stats = &adapter->stats.pf;
+	int i;
 
 	adapter->efbig_tx_dma_setup.ev_count = 0;
 	adapter->mbuf_defrag_failed.ev_count = 0;
@@ -2030,8 +2039,24 @@ ixgbe_clear_evcnt(struct adapter *adapte
 	adapter->msf_sicount.ev_count = 0;
 	adapter->phy_sicount.ev_count = 0;
 
+	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+		if (i < __arraycount(stats->mpc)) {
+			stats->mpc[i].ev_count = 0;
+			if (hw->mac.type == ixgbe_mac_82598EB)
+				stats->rnbc[i].ev_count = 0;
+		}
+		if (i < __arraycount(stats->pxontxc)) {
+			stats->pxontxc[i].ev_count = 0;
+			stats->pxonrxc[i].ev_count = 0;
+			stats->pxofftxc[i].ev_count = 0;
+			stats->pxoffrxc[i].ev_count = 0;
+			if (hw->mac.type >= ixgbe_mac_82599EB)
+				stats->pxon2offc[i].ev_count = 0;
+		}
+	}
+
 	txr = adapter->tx_rings;
-	for (int i = 0; i < adapter->num_queues; i++, rxr++, txr++) {
+	for (i = 0; i < adapter->num_queues; i++, rxr++, txr++) {
 		adapter->queues[i].irqs.ev_count = 0;
 		adapter->queues[i].handleq.ev_count = 0;
 		adapter->queues[i].req.ev_count = 0;
@@ -2050,19 +2075,6 @@ ixgbe_clear_evcnt(struct adapter *adapte
 		txr->q_enomem_tx_dma_setup = 0;
 		txr->q_tso_err = 0;
 
-		if (i < __arraycount(stats->mpc)) {
-			stats->mpc[i].ev_count = 0;
-			if (hw->mac.type == ixgbe_mac_82598EB)
-				stats->rnbc[i].ev_count = 0;
-		}
-		if (i < __arraycount(stats->pxontxc)) {
-			stats->pxontxc[i].ev_count = 0;
-			stats->pxonrxc[i].ev_count = 0;
-			stats->pxofftxc[i].ev_count = 0;
-			stats->pxoffrxc[i].ev_count = 0;
-			if (hw->mac.type >= ixgbe_mac_82599EB)
-				stats->pxon2offc[i].ev_count = 0;
-		}
 		if (i < __arraycount(stats->qprc)) {
 			stats->qprc[i].ev_count = 0;
 			stats->qptc[i].ev_count = 0;
@@ -3451,6 +3463,7 @@ ixgbe_detach(device_t dev, int flags)
 	struct ixgbe_hw *hw = &adapter->hw;
 	struct ixgbe_hw_stats *stats = &adapter->stats.pf;
 	u32	ctrl_ext;
+	int i;
 
 	INIT_DEBUGOUT("ixgbe_detach: begin");
 	if (adapter->osdep.attached == false)
@@ -3518,18 +3531,7 @@ ixgbe_detach(device_t dev, int flags)
 	evcnt_detach(&adapter->msf_sicount);
 	evcnt_detach(&adapter->phy_sicount);
 
-	txr = adapter->tx_rings;
-	for (int i = 0; i < adapter->num_queues; i++, rxr++, txr++) {
-		evcnt_detach(&adapter->queues[i].irqs);
-		evcnt_detach(&adapter->queues[i].handleq);
-		evcnt_detach(&adapter->queues[i].req);
-		evcnt_detach(&txr->no_desc_avail);
-		evcnt_detach(&txr->total_packets);
-		evcnt_detach(&txr->tso_tx);
-#ifndef IXGBE_LEGACY_TX
-		evcnt_detach(&txr->pcq_drops);
-#endif
-
+	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
 		if (i < __arraycount(stats->mpc)) {
 			evcnt_detach(&stats->mpc[i]);
 			if (hw->mac.type == ixgbe_mac_82598EB)
@@ -3543,6 +3545,20 @@ ixgbe_detach(device_t dev, int flags)
 			if (hw->mac.type >= ixgbe_mac_82599EB)
 				evcnt_detach(&stats->pxon2offc[i]);
 		}
+	}
+
+	txr = adapter->tx_rings;
+	for (i = 0; i < adapter->num_queues; i++, rxr++, txr++) {
+		evcnt_detach(&adapter->queues[i].irqs);
+		evcnt_detach(&adapter->queues[i].handleq);
+		evcnt_detach(&adapter->queues[i].req);
+		evcnt_detach(&txr->no_desc_avail);
+		evcnt_detach(&txr->total_packets);
+		evcnt_detach(&txr->tso_tx);
+#ifndef IXGBE_LEGACY_TX
+		evcnt_detach(&txr->pcq_drops);
+#endif
+
 		if (i < __arraycount(stats->qprc)) {
 			evcnt_detach(&stats->qprc[i]);
 			evcnt_detach(&stats->qptc[i]);
@@ -3616,7 +3632,7 @@ ixgbe_detach(device_t dev, int flags)
 
 	ixgbe_free_transmit_structures(adapter);
 	ixgbe_free_receive_structures(adapter);
-	for (int i = 0; i < adapter->num_queues; i++) {
+	for (i = 0; i < adapter->num_queues; i++) {
 		struct ix_queue * que = &adapter->queues[i];
 		mutex_destroy(&que->dc_mtx);
 	}

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.51 src/sys/dev/pci/ixgbe/ixgbe.h:1.52
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.51	Tue Jul 31 09:19:34 2018
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Mon Dec  3 04:39:44 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.51 2018/07/31 09:19:34 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.52 2018/12/03 04:39:44 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -451,6 +451,14 @@ struct ixgbe_vf {
 	uint16_t api_ver;
 };
 
+/*
+ * NetBSD: For trafic class
+ * Crrently, the following structure is only for statistics.
+ */
+struct ixgbe_tc {
+	char             evnamebuf[32];
+};
+
 /* Our adapter structure */
 struct adapter {
 	struct ixgbe_hw		hw;
@@ -603,6 +611,9 @@ struct adapter {
 	u32                     feat_cap;
 	u32                     feat_en;
 
+	/* Traffic classes */
+	struct ixgbe_tc tcs[IXGBE_DCB_MAX_TRAFFIC_CLASS];
+
 	struct sysctllog	*sysctllog;
 	const struct sysctlnode *sysctltop;
 };

Reply via email to