net/dpaa: fix xstats implementation
authorHemant Agrawal <hemant.agrawal@nxp.com>
Wed, 25 Apr 2018 12:57:01 +0000 (18:27 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 13 May 2018 22:36:38 +0000 (00:36 +0200)
Some of the applications are expecting that if n is 0, it shall
return the supported number of stats. e.g. VPP

Fixes: b21ed3e2a16d ("net/dpaa: support extended statistics")
Cc: stable@dpdk.org
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
drivers/net/dpaa/dpaa_ethdev.c

index 6bf8c15..f7e234d 100644 (file)
@@ -379,12 +379,12 @@ dpaa_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
        unsigned int i = 0, num = RTE_DIM(dpaa_xstats_strings);
        uint64_t values[sizeof(struct dpaa_if_stats) / 8];
 
-       if (xstats == NULL)
-               return 0;
-
        if (n < num)
                return num;
 
+       if (xstats == NULL)
+               return 0;
+
        fman_if_stats_get_all(dpaa_intf->fif, values,
                              sizeof(struct dpaa_if_stats) / 8);