From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alln-iport-3.cisco.com (alln-iport-3.cisco.com [173.37.142.90]) by dpdk.org (Postfix) with ESMTP id E688D2C16 for ; Mon, 7 Aug 2017 19:39:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1949; q=dns/txt; s=iport; t=1502127559; x=1503337159; h=from:to:cc:subject:date:message-id; bh=ndnqM3uKkGX5EPCd6HyeGm9ggtz6rWbdlMELgLtvpbc=; b=fKPX4Y8zOz1dA0RckQvzzUnc6jhPgB1pkl64V8FAtxQbLf6SoVvWxCmK wHqNhg2xNLzWWXRci9mDU92fMDSKenuzJc4Uoi2GVo6WLQ/V0EuWifjvl dxtCtBpZgO1ErGd4TVQyUcfhnNwD4JyFxD9vlj5CQ4eauV/r72MAAcXU0 s=; X-IronPort-AV: E=Sophos;i="5.41,339,1498521600"; d="scan'208";a="467351334" Received: from rcdn-core-7.cisco.com ([173.37.93.143]) by alln-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2017 17:39:17 +0000 Received: from cpp-rtpbld-31.cisco.com (cpp-rtpbld-31.cisco.com [172.18.5.114]) by rcdn-core-7.cisco.com (8.14.5/8.14.5) with ESMTP id v77HdHwq021531; Mon, 7 Aug 2017 17:39:17 GMT Received: by cpp-rtpbld-31.cisco.com (Postfix, from userid 140087) id F1A842C1; Mon, 7 Aug 2017 13:39:16 -0400 (EDT) From: David Harton To: thomas@monjalon.net Cc: dev@dpdk.org, David Harton Date: Mon, 7 Aug 2017 13:39:14 -0400 Message-Id: <20170807173914.36750-1-dharton@cisco.com> X-Mailer: git-send-email 2.10.3.dirty Subject: [dpdk-dev] [PATCH v3] ethdev: add return code to rte_eth_stats_reset() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 17:39:19 -0000 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 --- v3: * overcame noob errors and figured out patch challenges * this release should finally be clean :) v2: * fixed soft tab issue inserted while moving changes lib/librte_ether/rte_ethdev.c | 8 +++++--- lib/librte_ether/rte_ethdev.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0597641..f72cc5a 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -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, -EINVAL); 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 0adf327..d8ccd60 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -2246,8 +2246,10 @@ 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 + * Zero if successful. Non-zero otherwise. */ -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. -- 2.10.3.dirty