Update the strings used for presenting stats to adhere to the scheme previously presented. Updated xstats_get() function to handle Q information only if xstats() is not implemented in the PMD, providing the PMD with the needed flexibility to expose its extended Q stats.
Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com> --- lib/librte_ether/rte_ethdev.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index b309309..4b0184f 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -143,7 +143,7 @@ static const struct rte_eth_xstats_name_off rte_stats_strings[] = { {"tx_bytes", offsetof(struct rte_eth_stats, obytes)}, {"tx_errors", offsetof(struct rte_eth_stats, oerrors)}, {"rx_errors", offsetof(struct rte_eth_stats, ierrors)}, - {"alloc_rx_buff_failed", offsetof(struct rte_eth_stats, rx_nombuf)}, + {"rx_no_mbuf_errors", offsetof(struct rte_eth_stats, rx_nombuf)}, }; #define RTE_NB_STATS (sizeof(rte_stats_strings) / sizeof(rte_stats_strings[0])) @@ -1666,8 +1666,6 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, /* 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; /* implemented by the driver */ if (dev->dev_ops->xstats_get != NULL) { @@ -1679,6 +1677,9 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, if (xcount < 0) return xcount; + } else { + count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS; + count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS; } if (n < count + xcount) @@ -1698,6 +1699,10 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, xstats[count++].value = val; } + /* if xstats_get() is implemented by the PMD, the Q stats are done */ + if (dev->dev_ops->xstats_get != NULL) + return count + xcount; + /* per-rxq stats */ for (q = 0; q < dev->data->nb_rx_queues; q++) { for (i = 0; i < RTE_NB_RXQ_STATS; i++) { @@ -1706,7 +1711,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, q * sizeof(uint64_t)); val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), - "rx_queue_%u_%s", q, + "rx_q%u_%s", q, rte_rxq_stats_strings[i].name); xstats[count++].value = val; } @@ -1720,7 +1725,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, q * sizeof(uint64_t)); val = *stats_ptr; snprintf(xstats[count].name, sizeof(xstats[count].name), - "tx_queue_%u_%s", q, + "tx_q%u_%s", q, rte_txq_stats_strings[i].name); xstats[count++].value = val; } -- 1.9.1