From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-3.cisco.com (rcdn-iport-3.cisco.com [173.37.86.74]) by dpdk.org (Postfix) with ESMTP id A9B06376C for ; Thu, 10 Aug 2017 15:30:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2034; q=dns/txt; s=iport; t=1502371837; x=1503581437; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=CGS01sg8RbvwAena1YENmLFxErm6y9wOP5nf1k4q/fs=; b=kF6BEEkimo3N8AM8GAkVX/5PndsuGSPYAsvOJttXqUmL922iECuWyYMw nB6AyqyQKdNIoecwH5V7OXeGQRBM4yC4MuBOqoeDDJzI+OKu6vsBjV6XV OvkRqoNtwyD+1O94tz8sU8gbhUL7PRf0tPI+dgH+GyMexEN00gXfgfEI+ c=; X-IronPort-AV: E=Sophos;i="5.41,353,1498521600"; d="scan'208";a="270608631" Received: from alln-core-8.cisco.com ([173.36.13.141]) by rcdn-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 10 Aug 2017 13:30:36 +0000 Received: from cpp-rtp-kvm-11.cisco.com (cpp-rtp-kvm-11.cisco.com [172.18.26.141]) by alln-core-8.cisco.com (8.14.5/8.14.5) with ESMTP id v7ADUaFk031587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Aug 2017 13:30:36 GMT Received: from cpp-rtp-kvm-11.cisco.com (localhost [127.0.0.1]) by cpp-rtp-kvm-11.cisco.com (8.14.7/8.14.7) with ESMTP id v7ADUaKb027630; Thu, 10 Aug 2017 09:30:36 -0400 Received: (from dharton@localhost) by cpp-rtp-kvm-11.cisco.com (8.14.7/8.14.7/Submit) id v7ADUZd9027627; Thu, 10 Aug 2017 09:30:35 -0400 From: David Harton To: thomas@monjalon.net Cc: dev@dpdk.org, harry.van.haaren@intel.com, christian.ehrhardt@canonical.com, David Harton Date: Thu, 10 Aug 2017 09:29:51 -0400 Message-Id: <20170810132952.26974-1-dharton@cisco.com> X-Mailer: git-send-email 2.10.3.dirty In-Reply-To: <20170807173914.36750-1-dharton@cisco.com> References: <20170807173914.36750-1-dharton@cisco.com> Subject: [dpdk-dev] [PATCH v4 1/2] 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: Thu, 10 Aug 2017 13:30:38 -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 --- 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(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0597641..b420391 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, -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 0adf327..b14a2b5 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -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. -- 2.10.3.dirty