net/dpaa2: fix xstats
authorHemant Agrawal <hemant.agrawal@nxp.com>
Mon, 9 Apr 2018 10:22:50 +0000 (15:52 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 11 Apr 2018 22:20:52 +0000 (00:20 +0200)
Fixes: 1d6329b2fc1f ("net/dpaa2: support extra stats")
Cc: stable@dpdk.org
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/net/dpaa2/dpaa2_ethdev.c

index 5b8f30a..146566e 100644 (file)
@@ -1115,12 +1115,12 @@ dpaa2_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
        union dpni_statistics value[3] = {};
        unsigned int i = 0, num = RTE_DIM(dpaa2_xstats_strings);
 
-       if (xstats == NULL)
-               return 0;
-
        if (n < num)
                return num;
 
+       if (xstats == NULL)
+               return 0;
+
        /* Get Counters from page_0*/
        retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
                                      0, 0, &value[0]);
@@ -1153,10 +1153,13 @@ err:
 static int
 dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
                       struct rte_eth_xstat_name *xstats_names,
-                      __rte_unused unsigned int limit)
+                      unsigned int limit)
 {
        unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
 
+       if (limit < stat_cnt)
+               return stat_cnt;
+
        if (xstats_names != NULL)
                for (i = 0; i < stat_cnt; i++)
                        snprintf(xstats_names[i].name,