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>
This commit is contained in:
Maryam Tahhan 2015-07-15 14:11:28 +01:00 committed by Thomas Monjalon
parent ae4ac9a616
commit d4fef8b0d5

View File

@ -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;
/* 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 */