summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaryam Tahhan <maryam.tahhan@intel.com>2015-07-15 14:11:28 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-07-17 02:26:14 +0200
commitd4fef8b0d5e5ca4595086c5f78d43f9cb54c4228 (patch)
treeeb677020d96b5ded654ff2bf8f265202784bc681
parentae4ac9a61636f2f2d9ecc8834a645aabcbe8a6d3 (diff)
downloaddpdk-d4fef8b0d5e5ca4595086c5f78d43f9cb54c4228.zip
dpdk-d4fef8b0d5e5ca4595086c5f78d43f9cb54c4228.tar.gz
dpdk-d4fef8b0d5e5ca4595086c5f78d43f9cb54c4228.tar.xz
ethdev: expose generic and driver specific stats in xstats
Extend rte_eth_xstats_get to retrieve additional stats from the device driver as well the ethdev generic stats. Signed-off-by: Maryam Tahhan <maryam.tahhan@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
-rw-r--r--lib/librte_ether/rte_ethdev.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index c47b91f..6e12a9a 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1661,26 +1661,35 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
{
struct rte_eth_stats eth_stats;
struct rte_eth_dev *dev;
- unsigned count, i, q;
+ unsigned count = 0, i, q;
+ signed xcount = 0;
uint64_t val, *stats_ptr;
VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
- /* implemented by the driver */
- if (dev->dev_ops->xstats_get != NULL)
- return (*dev->dev_ops->xstats_get)(dev, xstats, n);
-
- /* else, return generic statistics */
+ /* Return generic statistics */
count = RTE_NB_STATS;
count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
- if (n < count)
- return count;
- /* now fill the xstats structure */
+ /* implemented by the driver */
+ if (dev->dev_ops->xstats_get != NULL) {
+ /* Retrieve the xstats from the driver at the end of the
+ * xstats struct.
+ */
+ xcount = (*dev->dev_ops->xstats_get)(dev, &xstats[count],
+ (n > count) ? n - count : 0);
+ if (xcount < 0)
+ return xcount;
+ }
+
+ if (n < count + xcount)
+ return count + xcount;
+
+ /* now fill the xstats structure */
count = 0;
rte_eth_stats_get(port_id, &eth_stats);
@@ -1722,7 +1731,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
}
}
- return count;
+ return count + xcount;
}
/* reset ethdev extended statistics */