From: David Harton Date: Wed, 20 Sep 2017 14:11:30 +0000 (-0400) Subject: ethdev: add return code to stats reset function X-Git-Tag: spdx-start~1479 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=80d0ff81e8bb1cf9772995fd7fe3d881c27e9fee;p=dpdk.git ethdev: add return code to stats reset function 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 Reviewed-by: Ferruh Yigit --- diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst index 5609c30f5d..4f5576df1a 100644 --- a/doc/guides/rel_notes/release_17_11.rst +++ b/doc/guides/rel_notes/release_17_11.rst @@ -47,6 +47,12 @@ New Features 256 ports in dpdk. All ethdev APIs which have port_id as parameter are changed in the meantime. +* **Modified the return type of rte_eth_stats_reset.** + + Changed return type of ``rte_eth_stats_reset`` from ``void`` to ``int`` + so the caller may know whether a device supports the operation or not + and if the operation was carried out. + * **Added a new driver for Marvell Armada 7k/8k devices.** Added the new mrvl net driver for Marvell Armada 7k/8k devices. See the diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index f20cb25b43..3c5441e4de 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1535,17 +1535,19 @@ rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats) return 0; } -void +int rte_eth_stats_reset(uint16_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 diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index b88005bb7a..8e928da807 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -2369,8 +2369,12 @@ int rte_eth_stats_get(uint16_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(uint16_t port_id); +int rte_eth_stats_reset(uint16_t port_id); /** * Retrieve names of extended statistics of an Ethernet device.