From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id 9C129E72 for ; Tue, 10 Nov 2015 16:51:13 +0100 (CET) Received: by wmec201 with SMTP id c201so140378779wme.0 for ; Tue, 10 Nov 2015 07:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind_com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to; bh=/OqPRt3g8+jwxsaa7ZKWN/fN7lX9Y7iOO3dnwM+P0Xw=; b=InOL1yu9pKnoab8G0dCKEF+vgIPXKdIGqN/PhVofMFgjPnmpxchzG+M/AaYDb0pn17 nhfCldWlQ2CL9yGrtmjUX9RdGISiAOepQPC3SshOOLihh48Tlh0PJcwTwXyO5YyToQi6 bDFPoaQkMa0DmTKXzhw6dRraBXMaq2i51vyyCjedzKAmP42P9ST6ngyx2GT3SuUM7S/o USpHQIdWbM7G6E7qd+6seFMhgDkxuE28OCQSt2NGQBBVwUR8G76CS/qUDuxwbQJPPO06 Yju7omPIUyLLn0i+HEK16n2n+OLK69rQ/HFkadaPdgBAOhoeDbRC/vieGsIV/z7KfGzW U25w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-type :content-disposition:in-reply-to; bh=/OqPRt3g8+jwxsaa7ZKWN/fN7lX9Y7iOO3dnwM+P0Xw=; b=KjAfS0pxCigTiwU5PfUAbdSECoRWbxPvSKeXLm+T2jwVvpK0KjrXW8kZK72C5wGXWG 5bp7oHZiiTO1mftD904RJaZRaZzDddhit6UUGVZddvIfcoRub0lR/XXWwCXjbtUudBxp eB2TkML/XzDUq+SS/8uwM5yecQ5u+iGgrTravhHZN8HOjpFmp3yw/qdK3a4dA2c2iBbE wy0vS2teQahG/PViYwjqrB0qODhzPIR7ukR6Tv5aoSPV5sKsPDVzXm3yCb7y+8O7VZb+ Ex8dErGr9DmQlvE8spKq9pkOVKRdSWRH0P4RcoJJ8uO1XR2uvBOXulM7UIYC+LfQL+01 W3UQ== X-Gm-Message-State: ALoCoQl6nP8LhmT+WA2zFs+f7A+0PeWsegaaGXQstKdw9ajmPaLr+HbDPFzd7nVKvmDRUaCTkeNB X-Received: by 10.194.239.104 with SMTP id vr8mr4687847wjc.64.1447170673497; Tue, 10 Nov 2015 07:51:13 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id lv4sm4141613wjb.43.2015.11.10.07.51.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 10 Nov 2015 07:51:12 -0800 (PST) Date: Tue, 10 Nov 2015 16:50:53 +0100 From: Adrien Mazarguil To: Declan Doherty Message-ID: <20151110155053.GU4013@6wind.com> Mail-Followup-To: Declan Doherty , dev@dpdk.org, Bruce Richardson References: <1446572746-26207-1-git-send-email-declan.doherty@intel.com> <1447101259-18972-1-git-send-email-declan.doherty@intel.com> <1447101259-18972-3-git-send-email-declan.doherty@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447101259-18972-3-git-send-email-declan.doherty@intel.com> Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v5 02/10] ethdev: make error checking macros public 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: Tue, 10 Nov 2015 15:51:13 -0000 On Mon, Nov 09, 2015 at 08:34:11PM +0000, Declan Doherty wrote: > Move the function pointer and port id checking macros to rte_ethdev and > rte_dev header files, so that they can be used in the static inline > functions there. Also replace the RTE_LOG call within > RTE_PMD_DEBUG_TRACE so this macro can be built with the -pedantic flag > > Signed-off-by: Declan Doherty > --- > lib/librte_eal/common/include/rte_dev.h | 52 +++++++++++++++++++++++++++++++ > lib/librte_ether/rte_ethdev.c | 54 --------------------------------- > lib/librte_ether/rte_ethdev.h | 26 ++++++++++++++++ > 3 files changed, 78 insertions(+), 54 deletions(-) > > diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h > index f601d21..fd09b3d 100644 > --- a/lib/librte_eal/common/include/rte_dev.h > +++ b/lib/librte_eal/common/include/rte_dev.h > @@ -46,8 +46,60 @@ > extern "C" { > #endif > > +#include > #include > > +#include > + > +__attribute__((format(printf, 2, 0))) > +static inline void > +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) > +{ > + va_list ap; > + > + va_start(ap, fmt); I suggest adding an empty line here since we're mixing code and declarations. > + char buffer[vsnprintf(NULL, 0, fmt, ap)]; I forgot an extra byte for trailing '\0' in my original comment, the above line should read: char buffer[vsnprintf(NULL, 0, fmt, ap) + 1]; Otherwise the last character will be missing. Did you test that function? > + > + va_end(ap); > + > + va_start(ap, fmt); > + vsnprintf(buffer, sizeof(buffer), fmt, ap); > + va_end(ap); > + > + rte_log(RTE_LOG_ERR, RTE_LOGTYPE_PMD, "%s: %s", func_name, buffer); > +} > + > +/* Macros for checking for restricting functions to primary instance only */ > +#define RTE_PROC_PRIMARY_OR_ERR_RET(retval) do { \ > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \ > + RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \ > + return retval; \ > + } \ > +} while (0) > + > +#define RTE_PROC_PRIMARY_OR_RET() do { \ > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \ > + RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \ > + return; \ > + } \ > +} while (0) > + > +/* Macros to check for invalid function pointers */ > +#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \ > + if ((func) == NULL) { \ > + RTE_PMD_DEBUG_TRACE("Function not supported\n"); \ > + return retval; \ > + } \ > +} while (0) > + > +#define RTE_FUNC_PTR_OR_RET(func) do { \ > + if ((func) == NULL) { \ > + RTE_PMD_DEBUG_TRACE("Function not supported\n"); \ > + return; \ > + } \ > +} while (0) > + > + > /** Double linked list of device drivers. */ > TAILQ_HEAD(rte_driver_list, rte_driver); > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c > index 7387f65..d3c8aba 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -69,60 +69,6 @@ > #include "rte_ether.h" > #include "rte_ethdev.h" > > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > -#define RTE_PMD_DEBUG_TRACE(fmt, args...) do {do { \ > - RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \ > - } while (0) > -#else > -#define RTE_PMD_DEBUG_TRACE(fmt, args...) > -#endif > - > -/* Macros for checking for restricting functions to primary instance only */ > -#define RTE_PROC_PRIMARY_OR_ERR_RET(retval) do { \ > - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \ > - RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \ > - return (retval); \ > - } \ > -} while (0) > - > -#define RTE_PROC_PRIMARY_OR_RET() do { \ > - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \ > - RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \ > - return; \ > - } \ > -} while (0) > - > -/* Macros to check for invalid function pointers in dev_ops structure */ > -#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \ > - if ((func) == NULL) { \ > - RTE_PMD_DEBUG_TRACE("Function not supported\n"); \ > - return (retval); \ > - } \ > -} while (0) > - > -#define RTE_FUNC_PTR_OR_RET(func) do { \ > - if ((func) == NULL) { \ > - RTE_PMD_DEBUG_TRACE("Function not supported\n"); \ > - return; \ > - } \ > -} while (0) > - > -/* Macros to check for valid port */ > -#define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \ > - if (!rte_eth_dev_is_valid_port(port_id)) { \ > - RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \ > - return retval; \ > - } \ > -} while (0) > - > -#define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \ > - if (!rte_eth_dev_is_valid_port(port_id)) { \ > - RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \ > - return; \ > - } \ > -} while (0) > - > - > static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data"; > struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS]; > static struct rte_eth_dev_data *rte_eth_dev_data; > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h > index 48a540d..9b07a0b 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -172,6 +172,8 @@ extern "C" { > > #include > > +#include > + > /* Use this macro to check if LRO API is supported */ > #define RTE_ETHDEV_HAS_LRO_SUPPORT > > @@ -931,6 +933,30 @@ struct rte_eth_dev_callback; > /** @internal Structure to keep track of registered callbacks */ > TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback); > > + > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > +#define RTE_PMD_DEBUG_TRACE(...) \ > + rte_pmd_debug_trace(__func__, __VA_ARGS__) > +#else > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) > +#endif > + > + > +/* Macros to check for valid port */ > +#define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do { \ > + if (!rte_eth_dev_is_valid_port(port_id)) { \ > + RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \ > + return retval; \ > + } \ > +} while (0) > + > +#define RTE_ETH_VALID_PORTID_OR_RET(port_id) do { \ > + if (!rte_eth_dev_is_valid_port(port_id)) { \ > + RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \ > + return; \ > + } \ > +} while (0) > + > /* > * Definitions of all functions exported by an Ethernet driver through the > * the generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev* > -- > 2.4.3 > -- Adrien Mazarguil 6WIND