From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: [PATCH v2 2/4] ethdev: move error checking macros to header Date: Wed, 9 Sep 2015 16:09:32 +0100 Message-ID: <1441811374-28984-3-git-send-email-bruce.richardson@intel.com> References: <1434108496-1993-1-git-send-email-bruce.richardson@intel.com> <1441811374-28984-1-git-send-email-bruce.richardson@intel.com> To: dev@dpdk.org Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 68FBE5A35 for ; Wed, 9 Sep 2015 17:09:38 +0200 (CEST) In-Reply-To: <1441811374-28984-1-git-send-email-bruce.richardson@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Move the function ptr and port id checking macros to the header file, so that they can be used in the static inline functions there. In doxygen comments, mark them as for internal use only. Signed-off-by: Bruce Richardson --- lib/librte_ether/rte_ethdev.c | 38 ------------------------------ lib/librte_ether/rte_ethdev.h | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 38 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 09af303..01e44c6 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -69,14 +69,6 @@ #include "rte_ether.h" #include "rte_ethdev.h" -#ifdef RTE_LIBRTE_ETHDEV_DEBUG -#define RTE_PMD_DEBUG_TRACE(fmt, args...) 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 PROC_PRIMARY_OR_ERR_RET(retval) do { \ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \ @@ -92,36 +84,6 @@ } \ } while (0) -/* Macros to check for invalid function pointers in dev_ops structure */ -#define RTE_ETH_FPTR_OR_ERR_RET(func, retval) do { \ - if ((func) == NULL) { \ - RTE_PMD_DEBUG_TRACE("Function not supported\n"); \ - return (retval); \ - } \ -} while (0) - -#define RTE_ETH_FPTR_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 fa06554..5501b04 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -968,6 +968,61 @@ struct rte_eth_dev_callback; /** @internal Structure to keep track of registered callbacks */ TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback); +/** + * @internal + * Macro to print a message if in debugging mode + */ +#ifdef RTE_LIBRTE_ETHDEV_DEBUG +#define RTE_PMD_DEBUG_TRACE(fmt, args...) do { \ + RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \ + } while (0) +#else +#define RTE_PMD_DEBUG_TRACE(fmt, args...) +#endif + +/** + * @internal + * Macro to check for invalid function pointer in dev_ops structure + */ +#define RTE_ETH_FPTR_OR_ERR_RET(func, retval) do { \ + if ((func) == NULL) { \ + RTE_PMD_DEBUG_TRACE("Function not supported\n"); \ + return (retval); \ + } \ +} while(0) +/** + * @internal + * Macro to check for invalid function pointer in dev_ops structure + */ +#define RTE_ETH_FPTR_OR_RET(func) do { \ + if ((func) == NULL) { \ + RTE_PMD_DEBUG_TRACE("Function not supported\n"); \ + return; \ + } \ +} while(0) + +/** + * @internal + * Macro to check for valid port id + */ +#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) + +/** + * @internal + * Macro to check for valid port id + */ +#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