diff mbox series

[v1,17/30] net/dpaa2: add cgr counters in xtra stats

Message ID 20190827070730.11206-18-sachin.saxena@nxp.com
State Superseded
Headers show
Series [v1,01/30] bus/dpaa: fix DPAA SEC blacklist case | expand

Commit Message

Sachin Saxena Aug. 27, 2019, 7:07 a.m. UTC
From: Hemant Agrawal <hemant.agrawal@nxp.com>


Add congestion frame drop and byte drop count in xtra stats.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index b30f37ecb..259180e4f 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -84,6 +84,8 @@  static const struct rte_dpaa2_xstats_name_off dpaa2_xstats_strings[] = {
 	{"ingress_nobuffer_discards", 2, 2},
 	{"egress_discarded_frames", 2, 3},
 	{"egress_confirmed_frames", 2, 4},
+	{"cgr_reject_frames", 4, 0},
+	{"cgr_reject_bytes", 4, 1},
 };
 
 static const enum rte_filter_op dpaa2_supported_filter_ops[] = {
@@ -1370,7 +1372,7 @@  dpaa2_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
 	struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
 	int32_t  retcode;
-	union dpni_statistics value[3] = {};
+	union dpni_statistics value[5] = {};
 	unsigned int i = 0, num = RTE_DIM(dpaa2_xstats_strings);
 
 	if (n < num)
@@ -1397,6 +1399,18 @@  dpaa2_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 	if (retcode)
 		goto err;
 
+	for (i = 0; i < priv->max_cgs; i++) {
+		if (!priv->cgid_in_use[i]) {
+			/* Get Counters from page_4*/
+			retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
+						      priv->token,
+						      4, 0, &value[4]);
+			if (retcode)
+				goto err;
+			break;
+		}
+	}
+
 	for (i = 0; i < num; i++) {
 		xstats[i].id = i;
 		xstats[i].value = value[dpaa2_xstats_strings[i].page_id].
@@ -1438,7 +1452,7 @@  dpaa2_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
 		struct dpaa2_dev_priv *priv = dev->data->dev_private;
 		struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
 		int32_t  retcode;
-		union dpni_statistics value[3] = {};
+		union dpni_statistics value[5] = {};
 
 		if (n < stat_cnt)
 			return stat_cnt;
@@ -1464,6 +1478,12 @@  dpaa2_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
 		if (retcode)
 			return 0;
 
+		/* Get Counters from page_4*/
+		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
+					      4, 0, &value[4]);
+		if (retcode)
+			return 0;
+
 		for (i = 0; i < stat_cnt; i++) {
 			values[i] = value[dpaa2_xstats_strings[i].page_id].
 				raw.counter[dpaa2_xstats_strings[i].stats_id];