From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dharton@cisco.com>
Received: from alln-iport-4.cisco.com (alln-iport-4.cisco.com [173.37.142.91])
 by dpdk.org (Postfix) with ESMTP id 6350216E
 for <dev@dpdk.org>; Fri,  1 Sep 2017 04:26:44 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=cisco.com; i=@cisco.com; l=3282; q=dns/txt; s=iport;
 t=1504232804; x=1505442404;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=BaF5gj9YTobDhaPslvHU5stFd0w2vMRvlX+u/gT3bmY=;
 b=nA1syHpETAprp430oESOj5BhGodl967gKDkOIIsrieQn9jJq66KTeDoo
 b1nUjtDsZwB3kFyfoTmYH9hFFHBfBhui6GbuvqIzxzP2EJWBpRoWqVOAs
 YJtndNvwlIrv9mLcyYWlYzqWhBouUACPIWZo4wTXahf/hIkQSDyZJ2VWO M=;
X-IronPort-AV: E=Sophos;i="5.41,456,1498521600"; d="scan'208";a="477717816"
Received: from rcdn-core-11.cisco.com ([173.37.93.147])
 by alln-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 01 Sep 2017 02:26:43 +0000
Received: from cpp-rtpbld-31.cisco.com (cpp-rtpbld-31.cisco.com [172.18.5.114])
 by rcdn-core-11.cisco.com (8.14.5/8.14.5) with ESMTP id v812Qh67005784;
 Fri, 1 Sep 2017 02:26:43 GMT
Received: by cpp-rtpbld-31.cisco.com (Postfix, from userid 140087)
 id 0D6DC3D3; Thu, 31 Aug 2017 22:26:43 -0400 (EDT)
From: David Harton <dharton@cisco.com>
To: thomas@monjalon.net
Cc: dev@dpdk.org, David Harton <dharton@cisco.com>
Date: Thu, 31 Aug 2017 22:26:31 -0400
Message-Id: <20170901022631.19529-1-dharton@cisco.com>
X-Mailer: git-send-email 2.10.3.dirty
In-Reply-To: <20170810132952.26974-1-dharton@cisco.com>
References: <20170810132952.26974-1-dharton@cisco.com>
Subject: [dpdk-dev] [PATCH v5] 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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 01 Sep 2017 02:26:44 -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 <dharton@cisco.com>
---

v5:
* squashed doc patch
* moved rel_note change from ABI to API section

v4:
* commented return values

v3:
* overcame noob errors and figured out patch challenged

v2:
* fixed soft tab issue inserted while moving changes

 doc/guides/rel_notes/release_17_11.rst | 13 +++++++++++++
 lib/librte_ether/rte_ethdev.c          |  8 +++++---
 lib/librte_ether/rte_ethdev.h          |  6 +++++-
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_11.rst b/doc/guides/rel_notes/release_17_11.rst
index 22df4fd..6282667 100644
--- a/doc/guides/rel_notes/release_17_11.rst
+++ b/doc/guides/rel_notes/release_17_11.rst
@@ -110,6 +110,19 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+* **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.
+
+* **Modified the vlan_offload_set_t function prototype in the ethdev library.**
+
+  Changed the function prototype of ``vlan_offload_set_t``.  The return value
+  has been changed from ``void`` to ``int`` so the caller to knows whether
+  the backing device supports the operation or if the operation was
+  successfully performed.
+
 * **Modified the vlan_offload_set_t function prototype in the ethdev library.**
 
   Changed the function prototype of ``vlan_offload_set_t``.  The return value
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 05e52b8..f0f1775 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1341,17 +1341,19 @@ struct rte_eth_dev *
 	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 7254fd0..9110725 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2246,8 +2246,12 @@ int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
  *
  * @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.
-- 
1.8.3.1