[dpdk-dev,4/5] net/qede: fix per queue stats/xstats
diff mbox

Message ID 1483172217-30186-4-git-send-email-rasesh.mody@cavium.com
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel compilation fail Compilation issues

Commit Message

Mody, Rasesh Dec. 31, 2016, 8:16 a.m. UTC
From: Rasesh Mody <Rasesh.Mody@cavium.com>

If value of number of rxq/txq is diffrent than
RTE_ETHDEV_QUEUE_STAT_CNTRS, limit per queue
stats/xstats to minimum of the two.

Fixes: 7634c5f91569 ("net/qede: add queue statistics")

Signed-off-by: Rasesh Mody <Rasesh.Mody@cavium.com>
---
 drivers/net/qede/qede_ethdev.c |   32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

Patch
diff mbox

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index b7606c8..de8286c 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -1160,6 +1160,7 @@  qede_get_stats(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats)
 	struct ecore_dev *edev = &qdev->edev;
 	struct ecore_eth_stats stats;
 	unsigned int i = 0, j = 0, qid;
+	unsigned int rxq_stat_cntrs, txq_stat_cntrs;
 	struct qede_tx_queue *txq;
 
 	qdev->ops->get_vport_stats(edev, &stats);
@@ -1193,6 +1194,17 @@  qede_get_stats(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats)
 	eth_stats->oerrors = stats.tx_err_drop_pkts;
 
 	/* Queue stats */
+	rxq_stat_cntrs = RTE_MIN(QEDE_RSS_COUNT(qdev),
+			       RTE_ETHDEV_QUEUE_STAT_CNTRS);
+	txq_stat_cntrs = RTE_MIN(QEDE_TSS_COUNT(qdev),
+			       RTE_ETHDEV_QUEUE_STAT_CNTRS);
+	if ((rxq_stat_cntrs != QEDE_RSS_COUNT(qdev)) ||
+	    (txq_stat_cntrs != QEDE_TSS_COUNT(qdev)))
+		DP_VERBOSE(edev, ECORE_MSG_DEBUG,
+		       "Not all the queue stats will be displayed. Set"
+		       " RTE_ETHDEV_QUEUE_STAT_CNTRS config param"
+		       " appropriately and retry.\n");
+
 	for (qid = 0; qid < QEDE_QUEUE_CNT(qdev); qid++) {
 		if (qdev->fp_array[qid].type & QEDE_FASTPATH_RX) {
 			eth_stats->q_ipackets[i] =
@@ -1211,7 +1223,11 @@  qede_get_stats(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats)
 					rx_alloc_errors));
 			i++;
 		}
+		if (i == rxq_stat_cntrs)
+			break;
+	}
 
+	for (qid = 0; qid < QEDE_QUEUE_CNT(qdev); qid++) {
 		if (qdev->fp_array[qid].type & QEDE_FASTPATH_TX) {
 			txq = qdev->fp_array[(qid)].txqs[0];
 			eth_stats->q_opackets[j] =
@@ -1221,13 +1237,17 @@  qede_get_stats(struct rte_eth_dev *eth_dev, struct rte_eth_stats *eth_stats)
 						  xmit_pkts)));
 			j++;
 		}
+		if (j == txq_stat_cntrs)
+			break;
 	}
 }
 
 static unsigned
 qede_get_xstats_count(struct qede_dev *qdev) {
 	return RTE_DIM(qede_xstats_strings) +
-		(RTE_DIM(qede_rxq_xstats_strings) * QEDE_RSS_COUNT(qdev));
+		(RTE_DIM(qede_rxq_xstats_strings) *
+		 RTE_MIN(QEDE_RSS_COUNT(qdev),
+			 RTE_ETHDEV_QUEUE_STAT_CNTRS));
 }
 
 static int
@@ -1237,6 +1257,7 @@  qede_get_xstats_names(__rte_unused struct rte_eth_dev *dev,
 	struct qede_dev *qdev = dev->data->dev_private;
 	const unsigned int stat_cnt = qede_get_xstats_count(qdev);
 	unsigned int i, qid, stat_idx = 0;
+	unsigned int rxq_stat_cntrs;
 
 	if (xstats_names != NULL) {
 		for (i = 0; i < RTE_DIM(qede_xstats_strings); i++) {
@@ -1247,7 +1268,9 @@  qede_get_xstats_names(__rte_unused struct rte_eth_dev *dev,
 			stat_idx++;
 		}
 
-		for (qid = 0; qid < QEDE_RSS_COUNT(qdev); qid++) {
+		rxq_stat_cntrs = RTE_MIN(QEDE_RSS_COUNT(qdev),
+					 RTE_ETHDEV_QUEUE_STAT_CNTRS);
+		for (qid = 0; qid < rxq_stat_cntrs; qid++) {
 			for (i = 0; i < RTE_DIM(qede_rxq_xstats_strings); i++) {
 				snprintf(xstats_names[stat_idx].name,
 					sizeof(xstats_names[stat_idx].name),
@@ -1271,6 +1294,7 @@  qede_get_xstats(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 	struct ecore_eth_stats stats;
 	const unsigned int num = qede_get_xstats_count(qdev);
 	unsigned int i, qid, stat_idx = 0;
+	unsigned int rxq_stat_cntrs;
 
 	if (n < num)
 		return num;
@@ -1283,7 +1307,9 @@  qede_get_xstats(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 		stat_idx++;
 	}
 
-	for (qid = 0; qid < QEDE_QUEUE_CNT(qdev); qid++) {
+	rxq_stat_cntrs = RTE_MIN(QEDE_RSS_COUNT(qdev),
+				 RTE_ETHDEV_QUEUE_STAT_CNTRS);
+	for (qid = 0; qid < rxq_stat_cntrs; qid++) {
 		if (qdev->fp_array[qid].type & QEDE_FASTPATH_RX) {
 			for (i = 0; i < RTE_DIM(qede_rxq_xstats_strings); i++) {
 				xstats[stat_idx].value = *(uint64_t *)(