From patchwork Mon Aug 7 13:16:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Harton X-Patchwork-Id: 27476 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D5D74326B; Mon, 7 Aug 2017 15:16:56 +0200 (CEST) Received: from rcdn-iport-8.cisco.com (rcdn-iport-8.cisco.com [173.37.86.79]) by dpdk.org (Postfix) with ESMTP id 657292B9D for ; Mon, 7 Aug 2017 15:16:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1767; q=dns/txt; s=iport; t=1502111815; x=1503321415; h=from:to:cc:subject:date:message-id; bh=6Mnqi1tipEtBbey12cKlg6sgBsWTcS7S8Ub2rP4+LPU=; b=fuVsAMmAkAHJNKntSNFMFchd7pwu4zdeH2YVe5y1r3O5nz/YAEkERq1z zwaCU/iFCSBOWpTkj6d91dHCBnNNY453CM+RLUOigLaSGTVmnyka/FAKA lyAi1nPTE4Eg5ryQ2Ul6ugx/fuwNdqBsG6x1JH+5XnpYJ6wfqd7YSMaWt g=; X-IronPort-AV: E=Sophos;i="5.41,338,1498521600"; d="scan'208";a="277778829" Received: from alln-core-10.cisco.com ([173.36.13.132]) by rcdn-iport-8.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Aug 2017 13:16:54 +0000 Received: from cpp-rtpbld-31.cisco.com (cpp-rtpbld-31.cisco.com [172.18.5.114]) by alln-core-10.cisco.com (8.14.5/8.14.5) with ESMTP id v77DGrJi016249; Mon, 7 Aug 2017 13:16:54 GMT Received: by cpp-rtpbld-31.cisco.com (Postfix, from userid 140087) id C9E394F3; Mon, 7 Aug 2017 09:16:53 -0400 (EDT) From: David Harton To: thomas@monjalon.net Cc: dev@dpdk.org, David Harton Date: Mon, 7 Aug 2017 09:16:51 -0400 Message-Id: <20170807131651.27789-1-dharton@cisco.com> X-Mailer: git-send-email 2.10.3.dirty Subject: [dpdk-dev] [PATCH] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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..46ce42d 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); 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); (*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.