From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-outbound-1.vmware.com (smtp-outbound-1.vmware.com [208.91.2.12]) by dpdk.org (Postfix) with ESMTP id 133E57F48 for ; Sat, 8 Nov 2014 02:30:53 +0100 (CET) Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id CC332281E8 for ; Fri, 7 Nov 2014 17:40:26 -0800 (PST) Received: from prmh-edge-ivybridge-13.eng.vmware.com (prmh-edge-ivybridge-13.eng.vmware.com [10.24.235.96]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id C8388B15E8; Fri, 7 Nov 2014 17:40:26 -0800 (PST) From: Jia Yu To: dev@dpdk.org Date: Fri, 7 Nov 2014 09:31:51 -0800 Message-Id: <1415381511-43364-3-git-send-email-jyu@vmware.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415381511-43364-1-git-send-email-jyu@vmware.com> References: <1415381511-43364-1-git-send-email-jyu@vmware.com> Subject: [dpdk-dev] [PATCH 2/2] rte_ethdev: add return status for rte_eth_stats_get X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Nov 2014 01:30:53 -0000 rte_eth_stats_get is to get physical device statistics. Without return status, caller does not know whether function fails or not (i.e. invalid port_id, driver has no stats_get callback). Caller cannot differiente normal 0 stats or error case. This fix adds a return status to the function. Signed-off-by: Jia Yu --- lib/librte_ether/rte_ethdev.c | 7 ++++--- lib/librte_ether/rte_ethdev.h | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 6c01b02..4ec9ca6 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1226,21 +1226,22 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link) } } -void +int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats) { struct rte_eth_dev *dev; if (port_id >= nb_ports) { PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); - return; + return (-ENODEV); } dev = &rte_eth_devices[port_id]; memset(stats, 0, sizeof(*stats)); - FUNC_PTR_OR_RET(*dev->dev_ops->stats_get); + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP); (*dev->dev_ops->stats_get)(dev, stats); stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed; + return 0; } void diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 8bf274d..e29e9be 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -2054,8 +2054,10 @@ extern void rte_eth_link_get_nowait(uint8_t port_id, * - *obytes* with the total of successfully transmitted bytes. * - *ierrors* with the total of erroneous received packets. * - *oerrors* with the total of failed transmitted packets. + * @return + * Zero if successful. Non-zero otherwise. */ -extern void rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats); +extern int rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats); /** * Reset the general I/O statistics of an Ethernet device. -- 1.9.1