Re: [RFC PATCH v1] rte: add bit-rate metrics to xstats
From: Pattan, Reshma <hidden>
Date: 2016-08-26 13:28:49
Hi,
-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton
Sent: Wednesday, August 24, 2016 3:58 PM
To: thomas.monjalon@6wind.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [RFC PATCH v1] rte: add bit-rate metrics to xstats
This patch adds peak and average data-rate metrics to the extended statistics.
The intervals used to generate the statistics are controlled by any application
wishing to make use of these metrics.
Signed-off-by: Remy Horton <redacted>
---
+int
+rte_eth_dev_stats_init(uint8_t port_id, uint32_t cnt_buckets) {
+ struct rte_eth_dev *dev;
+ struct rte_eth_dev_stats *stats;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+ dev = &rte_eth_devices[port_id];
+ stats = &dev->data->stats;
+
+ memset(stats, 0, sizeof(struct rte_eth_dev_stats));
+ stats->list_ibuckets = rte_zmalloc(
+ NULL, sizeof(uint64_t) * cnt_buckets, 0);We can have the sizeof(uint64_t) * cnt_buckets, calculated on top and use that in both the rte_zmallocs, Instead of performing * operation twice.
+ stats->list_obuckets = rte_zmalloc( + NULL, sizeof(uint64_t) * cnt_buckets, 0); + if (stats->list_ibuckets == NULL || stats->list_obuckets == NULL) + return -ENOMEM;
If either of them has valid pointer we should free that before returning.
+ stats->cnt_buckets = cnt_buckets; + return 0; +} +
Thanks, Reshma