[dpdk-dev,v4,1/2] ethdev: add return code to rte_eth_stats_reset()
Checks
Commit Message
Some devices do not support reset of eth stats. An application may
need to know not to clear shadow stats if the device cannot.
rte_eth_stats_reset is updated to provide a return code to share
whether the device supports reset or not.
Signed-off-by: David Harton <dharton@cisco.com>
---
v4:
* commented return values
v3:
* overcame noob errors and figured out patch challenged
v2:
* fixed soft tab issue inserted while moving changes
lib/librte_ether/rte_ethdev.c | 8 +++++---
lib/librte_ether/rte_ethdev.h | 6 +++++-
2 files changed, 10 insertions(+), 4 deletions(-)
Comments
10/08/2017 15:29, David Harton:
> Some devices do not support reset of eth stats. An application may
> need to know not to clear shadow stats if the device cannot.
Yes, thanks for improving this old API.
> rte_eth_stats_reset is updated to provide a return code to share
> whether the device supports reset or not.
You need to change also this line:
typedef void (*eth_stats_reset_t)(struct rte_eth_dev *dev);
And while at it, you could apply the same change to stats_get.
A device can be in a state where it is impossible to read stats.
The same kind of update could be needed for promiscuous and allmulticast
functions but they are out of the scope of this patch.
@@ -1341,17 +1341,19 @@ rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
return 0;
}
-void
+int
rte_eth_stats_reset(uint8_t port_id)
{
struct rte_eth_dev *dev;
- RTE_ETH_VALID_PORTID_OR_RET(port_id);
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];
- RTE_FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_reset, -ENOTSUP);
(*dev->dev_ops->stats_reset)(dev);
dev->data->rx_mbuf_alloc_failed = 0;
+
+ return 0;
}
static int
@@ -2246,8 +2246,12 @@ int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats);
*
* @param port_id
* The port identifier of the Ethernet device.
+ * @return
+ * - (0) if device notified to reset stats.
+ * - (-ENOTSUP) if hardware doesn't support.
+ * - (-ENODEV) if *port_id* invalid.
*/
-void rte_eth_stats_reset(uint8_t port_id);
+int rte_eth_stats_reset(uint8_t port_id);
/**
* Retrieve names of extended statistics of an Ethernet device.