[dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
On 18/05/2016 09:31, Tahhan, Maryam wrote: [..] >> +eth_xstats_count_t xstats_count; >> +/**< Get number of extended statistics. */ > > Hi Remy > While reviewing the second patch in this patchset I noticed you aren't > actually using > eth_xstats_count_t xstats_count in the eth_dev_ops to retrieve the count in > the driver. > Do you still need xstats_count? Well spotted - bit of dead code that slipped through the net when I decided to use the existing convention for the driver-side interface. Currently working on a v3 that will convert all the drivers, so will fix in that patchset. ..Remy
[dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
>uint8_t stat_idx, > @@ -1427,6 +1447,10 @@ struct eth_dev_ops { > eth_stats_reset_t stats_reset; /**< Reset generic device > statistics. */ > eth_xstats_get_t xstats_get;/**< Get extended device > statistics. */ > eth_xstats_reset_t xstats_reset; /**< Reset extended > device statistics. */ > + eth_xstats_names_t xstats_names; > + /**< Get names of extended statistics. */ > + eth_xstats_count_t xstats_count; > + /**< Get number of extended statistics. */ Hi Remy While reviewing the second patch in this patchset I noticed you aren't actually using eth_xstats_count_t xstats_count in the eth_dev_ops to retrieve the count in the driver. Do you still need xstats_count? BR Maryam
[dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Remy Horton > Sent: Friday, May 6, 2016 12:11 PM > To: dev at dpdk.org > Subject: [dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer > keys > > Signed-off-by: Remy Horton > --- Acked-by: Maryam Tahhan
[dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
2016-05-09 13:59, David Harton: > > } > > > > - > > Not sure how the community feels about white-space only changes. > Just mentioning in case some folks get excited about it. One here and a few > below. It's a trivial cleanup. No problem I think.
[dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
On 09/05/2016 14:59, David Harton (dharton) wrote: [..] >> } >> >> - > > Not sure how the community feels about white-space only changes. > Just mentioning in case some folks get excited about it. One here and a few > below. I doubt it'll be showstopper. In any case hoping to get a v3 out that converts the 4 other drivers that have xstats. ..Remy
[dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
> -Original Message- > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Remy Horton > Sent: Friday, May 06, 2016 7:11 AM > To: dev at dpdk.org > Subject: [dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer > keys > > Signed-off-by: Remy Horton > --- > lib/librte_ether/rte_ethdev.c | 100 - > - > lib/librte_ether/rte_ethdev.h | 55 +++ > 2 files changed, 142 insertions(+), 13 deletions(-) > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c > index a31018e..29ba12c 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -112,7 +112,6 @@ static const struct rte_eth_xstats_name_off > rte_txq_stats_strings[] = { > #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) /\ > sizeof(rte_txq_stats_strings[0])) > > - > /** > * The user application callback description. > * > @@ -1507,6 +1506,87 @@ rte_eth_stats_reset(uint8_t port_id) > dev->data->rx_mbuf_alloc_failed = 0; > } > > +int > +rte_eth_xstats_count(uint8_t port_id) > +{ > + struct rte_eth_dev *dev; > + int count; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > + dev = _eth_devices[port_id]; > + if (dev->dev_ops->xstats_names != NULL) { > + count = (*dev->dev_ops->xstats_names)(dev, NULL, 0); > + if (count < 0) > + return count; > + } else > + count = 0; > + count += RTE_NB_STATS; > + count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS; > + count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS; > + return count; > +} > + > +int > +rte_eth_xstats_names(uint8_t port_id, struct rte_eth_xstats_name > *ptr_names, > + unsigned limit) > +{ > + struct rte_eth_dev *dev; > + int cnt_used_entries; > + int cnt_expected_entries; > + uint32_t idx, id_queue; > + > + if (ptr_names == NULL) > + return -EINVAL; > + cnt_expected_entries = rte_eth_xstats_count(port_id); > + if (cnt_expected_entries < 0) > + return cnt_expected_entries; > + if ((int)limit < cnt_expected_entries) > + return -ERANGE; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > + dev = _eth_devices[port_id]; > + if (dev->dev_ops->xstats_names != NULL) { > + cnt_used_entries = (*dev->dev_ops->xstats_names)( > + dev, ptr_names, limit); > + if (cnt_used_entries < 0) > + return cnt_used_entries; > + } else > + /* Driver itself does not support extended stats, but > + * still have basic stats. > + */ > + cnt_used_entries = 0; > + > + for (idx = 0; idx < RTE_NB_STATS; idx++) { > + ptr_names[cnt_used_entries].id = cnt_used_entries; > + snprintf(ptr_names[cnt_used_entries].name, > + sizeof(ptr_names[0].name), > + "%s", rte_stats_strings[idx].name); > + cnt_used_entries++; > + } > + for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) { > + for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) { > + ptr_names[cnt_used_entries].id = cnt_used_entries; > + snprintf(ptr_names[cnt_used_entries].name, > + sizeof(ptr_names[0].name), > + "rx_q%u%s", > + id_queue, rte_rxq_stats_strings[idx].name); > + cnt_used_entries++; > + } > + > + } > + for (id_queue = 0; id_queue < dev->data->nb_tx_queues; id_queue++) { > + for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) { > + ptr_names[cnt_used_entries].id = cnt_used_entries; > + snprintf(ptr_names[cnt_used_entries].name, > + sizeof(ptr_names[0].name), > + "tx_q%u%s", > + id_queue, rte_txq_stats_strings[idx].name); > + cnt_used_entries++; > + } > + } > + return cnt_used_entries; > +} > + > /* retrieve ethdev extended statistics */ int > rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, @@ - > 1551,8 +1631,8 @@ rte_eth_xstats_get(uint8_t port_id, struct > rte_eth_xstats *xstats, > stats_ptr = RTE_PTR_ADD(_stats, >
[dpdk-dev] [RFC PATCH v2 1/3] rte: change xstats to use integer keys
Signed-off-by: Remy Horton --- lib/librte_ether/rte_ethdev.c | 100 -- lib/librte_ether/rte_ethdev.h | 55 +++ 2 files changed, 142 insertions(+), 13 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index a31018e..29ba12c 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -112,7 +112,6 @@ static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = { #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) / \ sizeof(rte_txq_stats_strings[0])) - /** * The user application callback description. * @@ -1507,6 +1506,87 @@ rte_eth_stats_reset(uint8_t port_id) dev->data->rx_mbuf_alloc_failed = 0; } +int +rte_eth_xstats_count(uint8_t port_id) +{ + struct rte_eth_dev *dev; + int count; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); + dev = _eth_devices[port_id]; + if (dev->dev_ops->xstats_names != NULL) { + count = (*dev->dev_ops->xstats_names)(dev, NULL, 0); + if (count < 0) + return count; + } else + count = 0; + count += RTE_NB_STATS; + count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS; + count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS; + return count; +} + +int +rte_eth_xstats_names(uint8_t port_id, struct rte_eth_xstats_name *ptr_names, + unsigned limit) +{ + struct rte_eth_dev *dev; + int cnt_used_entries; + int cnt_expected_entries; + uint32_t idx, id_queue; + + if (ptr_names == NULL) + return -EINVAL; + cnt_expected_entries = rte_eth_xstats_count(port_id); + if (cnt_expected_entries < 0) + return cnt_expected_entries; + if ((int)limit < cnt_expected_entries) + return -ERANGE; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); + dev = _eth_devices[port_id]; + if (dev->dev_ops->xstats_names != NULL) { + cnt_used_entries = (*dev->dev_ops->xstats_names)( + dev, ptr_names, limit); + if (cnt_used_entries < 0) + return cnt_used_entries; + } else + /* Driver itself does not support extended stats, but +* still have basic stats. +*/ + cnt_used_entries = 0; + + for (idx = 0; idx < RTE_NB_STATS; idx++) { + ptr_names[cnt_used_entries].id = cnt_used_entries; + snprintf(ptr_names[cnt_used_entries].name, + sizeof(ptr_names[0].name), + "%s", rte_stats_strings[idx].name); + cnt_used_entries++; + } + for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) { + for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) { + ptr_names[cnt_used_entries].id = cnt_used_entries; + snprintf(ptr_names[cnt_used_entries].name, + sizeof(ptr_names[0].name), + "rx_q%u%s", + id_queue, rte_rxq_stats_strings[idx].name); + cnt_used_entries++; + } + + } + for (id_queue = 0; id_queue < dev->data->nb_tx_queues; id_queue++) { + for (idx = 0; idx < RTE_NB_TXQ_STATS; idx++) { + ptr_names[cnt_used_entries].id = cnt_used_entries; + snprintf(ptr_names[cnt_used_entries].name, + sizeof(ptr_names[0].name), + "tx_q%u%s", + id_queue, rte_txq_stats_strings[idx].name); + cnt_used_entries++; + } + } + return cnt_used_entries; +} + /* retrieve ethdev extended statistics */ int rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, @@ -1551,8 +1631,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, stats_ptr = RTE_PTR_ADD(_stats, rte_stats_strings[i].offset); val = *stats_ptr; - snprintf(xstats[count].name, sizeof(xstats[count].name), - "%s", rte_stats_strings[i].name); + xstats[count].name[0] = '\0'; + xstats[count].id = count + xcount; xstats[count++].value = val; } @@ -1563,9 +1643,8 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, rte_rxq_stats_strings[i].offset + q * sizeof(uint64_t)); val = *stats_ptr; - snprintf(xstats[count].name, sizeof(xstats[count].name), - "rx_q%u_%s", q, -