All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ethdev: Add checks for function support in driver
@ 2015-06-12 11:28 Bruce Richardson
  2015-06-12 11:28 ` [PATCH 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
                   ` (4 more replies)
  0 siblings, 5 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-06-12 11:28 UTC (permalink / raw)
  To: dev

The functions to check the current occupancy of the RX descriptor ring, and
to specifically query if a particular descriptor is ready to be received, are
used for load monitoring on the data path, and so are inline functions inside
rte_ethdev.h. However, these functions are not implemented for the majority of
drivers, so their use can cause crashes in applications as there are no checks
for a function call with a NULL pointer.

This patchset attempts to fix this by putting in place the minimal check
for a NULL pointer needed before calling the function and thereby avoid any
crashes. The functions now also have a new possible return code of -ENOTSUP
but no return type changes, so ABI is preserved.

As part of the patchset, some additional cleanup is performed. The two functions
in question, as well as the rx and tx burst functions actually have two copies in
the ethdev library - one in the header and a debug version in the C file. This
patchset removes this duplication by merging the debug version into the header
file version. Build-time and runtime behaviour was preserved as part of this
merge.

NOTE: This patchset depends on Stephen Hemminger's patch to make
rte_eth_dev_is_valid_port() public: http://dpdk.org/dev/patchwork/patch/5373/ 

Bruce Richardson (4):
  ethdev: rename macros to have RTE_ETH prefix
  ethdev: move RTE_ETH_FPTR_OR_ERR macros to header
  ethdev: remove duplicated debug functions
  ethdev: check support for rx_queue_count and descriptor_done fns

 lib/librte_ether/rte_ethdev.c | 626 ++++++++++++++++++------------------------
 lib/librte_ether/rte_ethdev.h | 112 +++++---
 2 files changed, 345 insertions(+), 393 deletions(-)

-- 
2.4.2

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH 1/4] ethdev: rename macros to have RTE_ETH prefix
  2015-06-12 11:28 [PATCH 0/4] ethdev: Add checks for function support in driver Bruce Richardson
@ 2015-06-12 11:28 ` Bruce Richardson
  2015-06-12 11:28 ` [PATCH 2/4] ethdev: move RTE_ETH_FPTR_OR_ERR macros to header Bruce Richardson
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-06-12 11:28 UTC (permalink / raw)
  To: dev

The macros to check that the function pointers are valid for an ethdev
are potentially useful to have in the ethdev.h file. However, since they
would then become externally visible, we apply the RTE_ETH prefix to
them.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 560 +++++++++++++++++++++---------------------
 1 file changed, 280 insertions(+), 280 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index ae4d86d..89471f1 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -70,37 +70,37 @@
 #include "rte_ethdev.h"
 
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
-#define PMD_DEBUG_TRACE(fmt, args...) do {                        \
+#define RTE_PMD_DEBUG_TRACE(fmt, args...) do {                        \
 		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \
 	} while (0)
 #else
-#define PMD_DEBUG_TRACE(fmt, args...)
+#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) { \
-		PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
+		RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
 		return (retval); \
 	} \
 } while(0)
 #define PROC_PRIMARY_OR_RET() do { \
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
-		PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
+		RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
 		return; \
 	} \
 } while(0)
 
 /* Macros to check for invlaid function pointers in dev_ops structure */
-#define FUNC_PTR_OR_ERR_RET(func, retval) do { \
+#define RTE_ETH_FPTR_OR_ERR_RET(func, retval) do { \
 	if ((func) == NULL) { \
-		PMD_DEBUG_TRACE("Function not supported\n"); \
+		RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
 		return (retval); \
 	} \
 } while(0)
-#define FUNC_PTR_OR_RET(func) do { \
+#define RTE_ETH_FPTR_OR_RET(func) do { \
 	if ((func) == NULL) { \
-		PMD_DEBUG_TRACE("Function not supported\n"); \
+		RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
 		return; \
 	} \
 } while(0)
@@ -233,7 +233,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 
 	port_id = rte_eth_dev_find_free_port();
 	if (port_id == RTE_MAX_ETHPORTS) {
-		PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
+		RTE_PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
 		return NULL;
 	}
 
@@ -241,7 +241,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 		rte_eth_dev_data_alloc();
 
 	if (rte_eth_dev_allocated(name) != NULL) {
-		PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n", name);
+		RTE_PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n", name);
 		return NULL;
 	}
 
@@ -327,7 +327,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	if (diag == 0)
 		return 0;
 
-	PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x)"
+	RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x)"
 			" failed\n", pci_drv->name,
 			(unsigned) pci_dev->id.vendor_id,
 			(unsigned) pci_dev->id.device_id);
@@ -466,12 +466,12 @@ static int
 rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
 {
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	if (addr == NULL) {
-		PMD_DEBUG_TRACE("Null pointer is specified\n");
+		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
 		return -EINVAL;
 	}
 
@@ -485,12 +485,12 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 	char *tmp;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	if (name == NULL) {
-		PMD_DEBUG_TRACE("Null pointer is specified\n");
+		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
 		return -EINVAL;
 	}
 
@@ -507,7 +507,7 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 	uint32_t drv_flags;
 
 	if (port_id >= RTE_MAX_ETHPORTS) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
@@ -742,7 +742,7 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 			return -(ENOMEM);
 		}
 	} else { /* re-configure */
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
 
 		rxq = dev->data->rx_queues;
 
@@ -775,17 +775,17 @@ rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id)
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
 
 	return dev->dev_ops->rx_queue_start(dev, rx_queue_id);
 
@@ -801,17 +801,17 @@ rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id)
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
 
 	return dev->dev_ops->rx_queue_stop(dev, rx_queue_id);
 
@@ -827,17 +827,17 @@ rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id)
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
 
 	return dev->dev_ops->tx_queue_start(dev, tx_queue_id);
 
@@ -853,17 +853,17 @@ rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id)
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
 
 	return dev->dev_ops->tx_queue_stop(dev, tx_queue_id);
 
@@ -885,7 +885,7 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 			return -(ENOMEM);
 		}
 	} else { /* re-configure */
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
 
 		txq = dev->data->tx_queues;
 
@@ -945,7 +945,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		    (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB_RSS) ||
 		    (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB)) {
 			/* SRIOV only works in VMDq enable mode */
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"wrong VMDQ mq_mode rx %u tx %u\n",
 					port_id,
@@ -958,13 +958,13 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		case ETH_MQ_RX_VMDQ_DCB:
 		case ETH_MQ_RX_VMDQ_DCB_RSS:
 			/* DCB/RSS VMDQ in SRIOV mode, not implement yet */
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"unsupported VMDQ mq_mode rx %u\n",
 					port_id, dev_conf->rxmode.mq_mode);
 			return -EINVAL;
 		case ETH_MQ_RX_RSS:
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"Rx mq mode is changed from:"
 					"mq_mode %u into VMDQ mq_mode %u\n",
@@ -975,7 +975,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
 			if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
 				if (rte_eth_dev_check_vf_rss_rxq_num(port_id, nb_rx_q) != 0) {
-					PMD_DEBUG_TRACE("ethdev port_id=%d"
+					RTE_PMD_DEBUG_TRACE("ethdev port_id=%d"
 						" SRIOV active, invalid queue"
 						" number for VMDQ RSS, allowed"
 						" value are 1, 2 or 4\n",
@@ -994,7 +994,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		switch (dev_conf->txmode.mq_mode) {
 		case ETH_MQ_TX_VMDQ_DCB:
 			/* DCB VMDQ in SRIOV mode, not implement yet */
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"unsupported VMDQ mq_mode tx %u\n",
 					port_id, dev_conf->txmode.mq_mode);
@@ -1008,7 +1008,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		/* check valid queue number */
 		if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
 		    (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d SRIOV active, "
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d SRIOV active, "
 				    "queue number must less equal to %d\n",
 					port_id, RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
 			return -EINVAL;
@@ -1019,7 +1019,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_vmdq_dcb_conf *conf;
 
 			if (nb_rx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_rx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_rx_q "
 						"!= %d\n",
 						port_id, ETH_VMDQ_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1027,7 +1027,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->rx_adv_conf.vmdq_dcb_conf);
 			if (! (conf->nb_queue_pools == ETH_16_POOLS ||
 			       conf->nb_queue_pools == ETH_32_POOLS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
 						"nb_queue_pools must be %d or %d\n",
 						port_id, ETH_16_POOLS, ETH_32_POOLS);
 				return -EINVAL;
@@ -1037,7 +1037,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_vmdq_dcb_tx_conf *conf;
 
 			if (nb_tx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
 						"!= %d\n",
 						port_id, ETH_VMDQ_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1045,7 +1045,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->tx_adv_conf.vmdq_dcb_tx_conf);
 			if (! (conf->nb_queue_pools == ETH_16_POOLS ||
 			       conf->nb_queue_pools == ETH_32_POOLS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
 						"nb_queue_pools != %d or nb_queue_pools "
 						"!= %d\n",
 						port_id, ETH_16_POOLS, ETH_32_POOLS);
@@ -1058,7 +1058,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_dcb_rx_conf *conf;
 
 			if (nb_rx_q != ETH_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
 						"!= %d\n",
 						port_id, ETH_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1066,7 +1066,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->rx_adv_conf.dcb_rx_conf);
 			if (! (conf->nb_tcs == ETH_4_TCS ||
 			       conf->nb_tcs == ETH_8_TCS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
 						"nb_tcs != %d or nb_tcs "
 						"!= %d\n",
 						port_id, ETH_4_TCS, ETH_8_TCS);
@@ -1078,7 +1078,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_dcb_tx_conf *conf;
 
 			if (nb_tx_q != ETH_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
 						"!= %d\n",
 						port_id, ETH_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1086,7 +1086,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->tx_adv_conf.dcb_tx_conf);
 			if (! (conf->nb_tcs == ETH_4_TCS ||
 			       conf->nb_tcs == ETH_8_TCS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
 						"nb_tcs != %d or nb_tcs "
 						"!= %d\n",
 						port_id, ETH_4_TCS, ETH_8_TCS);
@@ -1110,19 +1110,19 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 			"Number of RX queues requested (%u) is greater than max supported(%d)\n",
 			nb_rx_q, RTE_MAX_QUEUES_PER_PORT);
 		return -EINVAL;
 	}
 
 	if (nb_tx_q > RTE_MAX_QUEUES_PER_PORT) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 			"Number of TX queues requested (%u) is greater than max supported(%d)\n",
 			nb_tx_q, RTE_MAX_QUEUES_PER_PORT);
 		return -EINVAL;
@@ -1130,11 +1130,11 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
@@ -1146,22 +1146,22 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 */
 	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
 	if (nb_rx_q > dev_info.max_rx_queues) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
 				port_id, nb_rx_q, dev_info.max_rx_queues);
 		return -EINVAL;
 	}
 	if (nb_rx_q == 0) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
 		return -EINVAL;
 	}
 
 	if (nb_tx_q > dev_info.max_tx_queues) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
 				port_id, nb_tx_q, dev_info.max_tx_queues);
 		return -EINVAL;
 	}
 	if (nb_tx_q == 0) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
 		return -EINVAL;
 	}
 
@@ -1176,7 +1176,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
 
 		if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
-			PMD_DEBUG_TRACE("driver %s does not support lsc\n",
+			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
 					pci_drv->name);
 			return -EINVAL;
 		}
@@ -1189,7 +1189,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if (dev_conf->rxmode.jumbo_frame == 1) {
 		if (dev_conf->rxmode.max_rx_pkt_len >
 		    dev_info.max_rx_pktlen) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
 				" > max valid value %u\n",
 				port_id,
 				(unsigned)dev_conf->rxmode.max_rx_pkt_len,
@@ -1197,7 +1197,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			return -EINVAL;
 		}
 		else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
 				" < min valid value %u\n",
 				port_id,
 				(unsigned)dev_conf->rxmode.max_rx_pkt_len,
@@ -1215,7 +1215,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	/* multipe queue mode checking */
 	diag = rte_eth_dev_check_mq_mode(port_id, nb_rx_q, nb_tx_q, dev_conf);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
 				port_id, diag);
 		return diag;
 	}
@@ -1225,14 +1225,14 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 */
 	diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
 				port_id, diag);
 		return diag;
 	}
 
 	diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
 				port_id, diag);
 		rte_eth_dev_rx_queue_config(dev, 0);
 		return diag;
@@ -1240,7 +1240,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
 	diag = (*dev->dev_ops->dev_configure)(dev);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
 				port_id, diag);
 		rte_eth_dev_rx_queue_config(dev, 0);
 		rte_eth_dev_tx_queue_config(dev, 0);
@@ -1279,7 +1279,7 @@ rte_eth_dev_config_restore(uint8_t port_id)
 			(dev->data->mac_pool_sel[i] & (1ULL << pool)))
 			(*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
 		else {
-			PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
 					port_id);
 			/* exit the loop but not return an error */
 			break;
@@ -1310,16 +1310,16 @@ rte_eth_dev_start(uint8_t port_id)
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
 	if (dev->data->dev_started != 0) {
-		PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+		RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
 			" already started\n",
 			port_id);
 		return 0;
@@ -1334,7 +1334,7 @@ rte_eth_dev_start(uint8_t port_id)
 	rte_eth_dev_config_restore(port_id);
 
 	if (dev->data->dev_conf.intr_conf.lsc != 0) {
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
 		(*dev->dev_ops->link_update)(dev, 0);
 	}
 	return 0;
@@ -1350,16 +1350,16 @@ rte_eth_dev_stop(uint8_t port_id)
 	PROC_PRIMARY_OR_RET();
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_stop);
 
 	if (dev->data->dev_started == 0) {
-		PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+		RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
 			" already stopped\n",
 			port_id);
 		return;
@@ -1379,13 +1379,13 @@ rte_eth_dev_set_link_up(uint8_t port_id)
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
 	return (*dev->dev_ops->dev_set_link_up)(dev);
 }
 
@@ -1399,13 +1399,13 @@ rte_eth_dev_set_link_down(uint8_t port_id)
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
 	return (*dev->dev_ops->dev_set_link_down)(dev);
 }
 
@@ -1419,13 +1419,13 @@ rte_eth_dev_close(uint8_t port_id)
 	PROC_PRIMARY_OR_RET();
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_close);
 	dev->data->dev_started = 0;
 	(*dev->dev_ops->dev_close)(dev);
 }
@@ -1446,24 +1446,24 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
 
 	/*
 	 * Check the size of the mbuf data buffer.
@@ -1472,7 +1472,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	 */
 	rte_eth_dev_info_get(port_id, &dev_info);
 	if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
-		PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
+		RTE_PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
 				mp->name, (int) mp->private_data_size,
 				(int) sizeof(struct rte_pktmbuf_pool_private));
 		return -ENOSPC;
@@ -1480,7 +1480,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	mbp_buf_size = rte_pktmbuf_data_room_size(mp);
 
 	if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
-		PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
+		RTE_PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
 				"(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
 				"=%d)\n",
 				mp->name,
@@ -1519,24 +1519,24 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
 
 	rte_eth_dev_info_get(port_id, &dev_info);
 
@@ -1553,13 +1553,13 @@ rte_eth_promiscuous_enable(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_enable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->promiscuous_enable);
 	(*dev->dev_ops->promiscuous_enable)(dev);
 	dev->data->promiscuous = 1;
 }
@@ -1570,13 +1570,13 @@ rte_eth_promiscuous_disable(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_disable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->promiscuous_disable);
 	dev->data->promiscuous = 0;
 	(*dev->dev_ops->promiscuous_disable)(dev);
 }
@@ -1587,7 +1587,7 @@ rte_eth_promiscuous_get(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -1;
 	}
 
@@ -1601,13 +1601,13 @@ rte_eth_allmulticast_enable(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->allmulticast_enable);
 	(*dev->dev_ops->allmulticast_enable)(dev);
 	dev->data->all_multicast = 1;
 }
@@ -1618,13 +1618,13 @@ rte_eth_allmulticast_disable(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->allmulticast_disable);
 	dev->data->all_multicast = 0;
 	(*dev->dev_ops->allmulticast_disable)(dev);
 }
@@ -1635,7 +1635,7 @@ rte_eth_allmulticast_get(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -1;
 	}
 
@@ -1663,7 +1663,7 @@ rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
@@ -1672,7 +1672,7 @@ rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		rte_eth_dev_atomic_read_link_status(dev, eth_link);
 	else {
-		FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_ETH_FPTR_OR_RET(*dev->dev_ops->link_update);
 		(*dev->dev_ops->link_update)(dev, 1);
 		*eth_link = dev->data->dev_link;
 	}
@@ -1684,7 +1684,7 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
@@ -1693,7 +1693,7 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		rte_eth_dev_atomic_read_link_status(dev, eth_link);
 	else {
-		FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_ETH_FPTR_OR_RET(*dev->dev_ops->link_update);
 		(*dev->dev_ops->link_update)(dev, 0);
 		*eth_link = dev->data->dev_link;
 	}
@@ -1705,14 +1705,14 @@ rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	memset(stats, 0, sizeof(*stats));
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP);
+	RTE_ETH_FPTR_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;
@@ -1724,13 +1724,13 @@ rte_eth_stats_reset(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->stats_reset);
 	(*dev->dev_ops->stats_reset)(dev);
 }
 
@@ -1746,7 +1746,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 	char *stats_ptr;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -1;
 	}
 
@@ -1815,7 +1815,7 @@ rte_eth_xstats_reset(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
@@ -1838,13 +1838,13 @@ set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
 	return (*dev->dev_ops->queue_stats_mapping_set)
 			(dev, queue_id, stat_idx, is_rx);
 }
@@ -1874,7 +1874,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
@@ -1882,7 +1882,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 
 	memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
 	dev_info->pci_dev = dev->pci_dev;
 	if (dev->driver)
@@ -1895,7 +1895,7 @@ rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return;
 	}
 
@@ -1910,7 +1910,7 @@ rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -1926,12 +1926,12 @@ rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
 
 	ret = (*dev->dev_ops->mtu_set)(dev, mtu);
 	if (!ret)
@@ -1946,22 +1946,22 @@ rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (! (dev->data->dev_conf.rxmode.hw_vlan_filter)) {
-		PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
 		return -ENOSYS;
 	}
 
 	if (vlan_id > 4095) {
-		PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
+		RTE_PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
 				port_id, (unsigned) vlan_id);
 		return -EINVAL;
 	}
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
 
 	return (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on);
 }
@@ -1972,17 +1972,17 @@ rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int o
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_strip_queue_set)(dev, rx_queue_id, on);
 
 	return 0;
@@ -1994,12 +1994,12 @@ rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_tpid_set)(dev, tpid);
 
 	return 0;
@@ -2014,7 +2014,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
 	int cur, org = 0;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -2046,7 +2046,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
 	if(mask == 0)
 		return ret;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_offload_set)(dev, mask);
 
 	return ret;
@@ -2059,7 +2059,7 @@ rte_eth_dev_get_vlan_offload(uint8_t port_id)
 	int ret = 0;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -2083,12 +2083,12 @@ rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_pvid_set)(dev, pvid, on);
 
 	return 0;
@@ -2102,14 +2102,14 @@ rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2117,13 +2117,13 @@ rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
 				"None l4type, source & destinations ports " \
 				"should be null!\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_add_signature_filter)(dev, fdir_filter,
 								queue);
 }
@@ -2136,14 +2136,14 @@ rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2151,13 +2151,13 @@ rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
 				"None l4type, source & destinations ports " \
 				"should be null!\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_update_signature_filter)(dev, fdir_filter,
 								queue);
 
@@ -2170,14 +2170,14 @@ rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2185,13 +2185,13 @@ rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
 				"None l4type source & destinations ports " \
 				"should be null!\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_remove_signature_filter)(dev, fdir_filter);
 }
 
@@ -2201,17 +2201,17 @@ rte_eth_dev_fdir_get_infos(uint8_t port_id, struct rte_eth_fdir *fdir)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (! (dev->data->dev_conf.fdir_conf.mode)) {
-		PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
 		return -ENOSYS;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
 
 	(*dev->dev_ops->fdir_infos_get)(dev, fdir);
 	return 0;
@@ -2226,14 +2226,14 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2241,7 +2241,7 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
 				"None l4type, source & destinations ports " \
 				"should be null!\n");
 		return -EINVAL;
@@ -2251,7 +2251,7 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
 	if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
 		return -ENOTSUP;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_add_perfect_filter)(dev, fdir_filter,
 								soft_id, queue,
 								drop);
@@ -2266,14 +2266,14 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2281,7 +2281,7 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
 				"None l4type, source & destinations ports " \
 				"should be null!\n");
 		return -EINVAL;
@@ -2291,7 +2291,7 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
 	if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
 		return -ENOTSUP;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_update_perfect_filter)(dev, fdir_filter,
 							soft_id, queue, drop);
 }
@@ -2304,14 +2304,14 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2319,7 +2319,7 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and " \
 				"None l4type, source & destinations ports " \
 				"should be null!\n");
 		return -EINVAL;
@@ -2329,7 +2329,7 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
 	if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
 		return -ENOTSUP;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_remove_perfect_filter)(dev, fdir_filter,
 								soft_id);
 }
@@ -2340,17 +2340,17 @@ rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (! (dev->data->dev_conf.fdir_conf.mode)) {
-		PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
 		return -ENOSYS;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
 	return (*dev->dev_ops->fdir_set_masks)(dev, fdir_mask);
 }
 
@@ -2360,12 +2360,12 @@ rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
 	memset(fc_conf, 0, sizeof(*fc_conf));
 	return (*dev->dev_ops->flow_ctrl_get)(dev, fc_conf);
 }
@@ -2376,17 +2376,17 @@ rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
-		PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
+		RTE_PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
 	return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
 }
 
@@ -2396,12 +2396,12 @@ rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
-		PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
+		RTE_PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
 		return -EINVAL;
 	}
 
@@ -2422,7 +2422,7 @@ rte_eth_check_reta_mask(struct rte_eth_rss_reta_entry64 *reta_conf,
 		return -EINVAL;
 
 	if (reta_size != RTE_ALIGN(reta_size, RTE_RETA_GROUP_SIZE)) {
-		PMD_DEBUG_TRACE("Invalid reta size, should be %u aligned\n",
+		RTE_PMD_DEBUG_TRACE("Invalid reta size, should be %u aligned\n",
 							RTE_RETA_GROUP_SIZE);
 		return -EINVAL;
 	}
@@ -2447,7 +2447,7 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
 		return -EINVAL;
 
 	if (max_rxq == 0) {
-		PMD_DEBUG_TRACE("No receive queue is available\n");
+		RTE_PMD_DEBUG_TRACE("No receive queue is available\n");
 		return -EINVAL;
 	}
 
@@ -2456,7 +2456,7 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
 		shift = i % RTE_RETA_GROUP_SIZE;
 		if ((reta_conf[idx].mask & (1ULL << shift)) &&
 			(reta_conf[idx].reta[shift] >= max_rxq)) {
-			PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
+			RTE_PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
 				"the maximum rxq index: %u\n", idx, shift,
 				reta_conf[idx].reta[shift], max_rxq);
 			return -EINVAL;
@@ -2475,7 +2475,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,
 	int ret;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -2492,7 +2492,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,
 	if (ret < 0)
 		return ret;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
 	return (*dev->dev_ops->reta_update)(dev, reta_conf, reta_size);
 }
 
@@ -2505,7 +2505,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id,
 	int ret;
 
 	if (port_id >= nb_ports) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -2515,7 +2515,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id,
 		return ret;
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
 	return (*dev->dev_ops->reta_query)(dev, reta_conf, reta_size);
 }
 
@@ -2526,19 +2526,19 @@ rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)
 	uint16_t rss_hash_protos;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	rss_hash_protos = rss_conf->rss_hf;
 	if ((rss_hash_protos != 0) &&
 	    ((rss_hash_protos & ETH_RSS_PROTO_MASK) == 0)) {
-		PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
+		RTE_PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
 				rss_hash_protos);
 		return -EINVAL;
 	}
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
 	return (*dev->dev_ops->rss_hash_update)(dev, rss_conf);
 }
 
@@ -2549,12 +2549,12 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
 	return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
 }
 
@@ -2565,22 +2565,22 @@ rte_eth_dev_udp_tunnel_add(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if (udp_tunnel == NULL) {
-		PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+		RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
 		return -EINVAL;
 	}
 
 	if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-		PMD_DEBUG_TRACE("Invalid tunnel type\n");
+		RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
 	return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel);
 }
 
@@ -2591,23 +2591,23 @@ rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
 	if (udp_tunnel == NULL) {
-		PMD_DEBUG_TRACE("Invalid udp_tunnel parametr\n");
+		RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parametr\n");
 		return -EINVAL;
 	}
 
 	if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-		PMD_DEBUG_TRACE("Invalid tunnel type\n");
+		RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
 	return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel);
 }
 
@@ -2617,12 +2617,12 @@ rte_eth_led_on(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
 	return (*dev->dev_ops->dev_led_on)(dev);
 }
 
@@ -2632,12 +2632,12 @@ rte_eth_led_off(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
 	return (*dev->dev_ops->dev_led_off)(dev);
 }
 
@@ -2672,20 +2672,20 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
 	uint64_t pool_mask;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
 
 	if (is_zero_ether_addr(addr)) {
-		PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
 			port_id);
 		return -EINVAL;
 	}
 	if (pool >= ETH_64_POOLS) {
-		PMD_DEBUG_TRACE("pool id must be 0-%d\n",ETH_64_POOLS - 1);
+		RTE_PMD_DEBUG_TRACE("pool id must be 0-%d\n",ETH_64_POOLS - 1);
 		return -EINVAL;
 	}
 
@@ -2693,7 +2693,7 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
 	if (index < 0) {
 		index = get_mac_addr_index(port_id, &null_mac_addr);
 		if (index < 0) {
-			PMD_DEBUG_TRACE("port %d: MAC address array full\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
 				port_id);
 			return -ENOSPC;
 		}
@@ -2724,16 +2724,16 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
 	int index;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
 
 	index = get_mac_addr_index(port_id, addr);
 	if (index == 0) {
-		PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
 		return -EADDRINUSE;
 	} else if (index < 0)
 		return 0;  /* Do nothing if address wasn't found */
@@ -2759,7 +2759,7 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
 	struct rte_eth_dev_info dev_info;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=%d\n",
+		RTE_PMD_DEBUG_TRACE("set VF RX mode:Invalid port_id=%d\n",
 				port_id);
 		return -ENODEV;
 	}
@@ -2770,15 +2770,15 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs)
 	{
-		PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
+		RTE_PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
 		return -EINVAL;
 	}
 	if (rx_mode == 0)
 	{
-		PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
+		RTE_PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
 		return -EINVAL;
 	}
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rx_mode)(dev, vf, rx_mode, on);
 }
 
@@ -2814,14 +2814,14 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
+		RTE_PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
 			port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (is_zero_ether_addr(addr)) {
-		PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
 			port_id);
 		return -EINVAL;
 	}
@@ -2833,20 +2833,20 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
 
 	if (index < 0) {
 		if (!on) {
-			PMD_DEBUG_TRACE("port %d: the MAC address was not"
+			RTE_PMD_DEBUG_TRACE("port %d: the MAC address was not"
 				"set in UTA\n", port_id);
 			return -EINVAL;
 		}
 
 		index = get_hash_mac_addr_index(port_id, &null_mac_addr);
 		if (index < 0) {
-			PMD_DEBUG_TRACE("port %d: MAC address array full\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
 					port_id);
 			return -ENOSPC;
 		}
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
 	ret = (*dev->dev_ops->uc_hash_table_set)(dev, addr, on);
 	if (ret == 0) {
 		/* Update address in NIC data structure */
@@ -2867,14 +2867,14 @@ rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
+		RTE_PMD_DEBUG_TRACE("unicast hash setting:Invalid port_id=%d\n",
 			port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
 	return (*dev->dev_ops->uc_all_hash_table_set)(dev, on);
 }
 
@@ -2886,7 +2886,7 @@ rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, uint8_t on)
 	struct rte_eth_dev_info dev_info;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -2896,11 +2896,11 @@ rte_eth_dev_set_vf_rx(uint8_t port_id,uint16_t vf, uint8_t on)
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs)
 	{
-		PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rx)(dev, vf,on);
 }
 
@@ -2912,7 +2912,7 @@ rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, uint8_t on)
 	struct rte_eth_dev_info dev_info;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("set pool tx:Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("set pool tx:Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -2922,11 +2922,11 @@ rte_eth_dev_set_vf_tx(uint8_t port_id,uint16_t vf, uint8_t on)
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs)
 	{
-		PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
+		RTE_PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_tx)(dev, vf,on);
 }
 
@@ -2937,7 +2937,7 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=%d\n",
+		RTE_PMD_DEBUG_TRACE("VF VLAN filter:invalid port id=%d\n",
 				port_id);
 		return -ENODEV;
 	}
@@ -2945,17 +2945,17 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
 
 	if(vlan_id > ETHER_MAX_VLAN_ID)
 	{
-		PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
+		RTE_PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
 			vlan_id);
 		return -EINVAL;
 	}
 	if (vf_mask == 0)
 	{
-		PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
+		RTE_PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_vlan_filter)(dev, vlan_id,
 						vf_mask,vlan_on);
 }
@@ -2968,7 +2968,7 @@ int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
 	struct rte_eth_link link;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("set queue rate limit:invalid port id=%d\n",
+		RTE_PMD_DEBUG_TRACE("set queue rate limit:invalid port id=%d\n",
 				port_id);
 		return -ENODEV;
 	}
@@ -2978,19 +2978,19 @@ int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
 	link = dev->data->dev_link;
 
 	if (queue_idx > dev_info.max_tx_queues) {
-		PMD_DEBUG_TRACE("set queue rate limit:port %d: "
+		RTE_PMD_DEBUG_TRACE("set queue rate limit:port %d: "
 				"invalid queue id=%d\n", port_id, queue_idx);
 		return -EINVAL;
 	}
 
 	if (tx_rate > link.link_speed) {
-		PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
+		RTE_PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
 				"bigger than link speed= %d\n",
 			tx_rate, link.link_speed);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
 	return (*dev->dev_ops->set_queue_rate_limit)(dev, queue_idx, tx_rate);
 }
 
@@ -3005,7 +3005,7 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
 		return 0;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("set VF rate limit:invalid port id=%d\n",
+		RTE_PMD_DEBUG_TRACE("set VF rate limit:invalid port id=%d\n",
 				port_id);
 		return -ENODEV;
 	}
@@ -3015,19 +3015,19 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
 	link = dev->data->dev_link;
 
 	if (vf > dev_info.max_vfs) {
-		PMD_DEBUG_TRACE("set VF rate limit:port %d: "
+		RTE_PMD_DEBUG_TRACE("set VF rate limit:port %d: "
 				"invalid vf id=%d\n", port_id, vf);
 		return -EINVAL;
 	}
 
 	if (tx_rate > link.link_speed) {
-		PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
+		RTE_PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
 				"bigger than link speed= %d\n",
 				tx_rate, link.link_speed);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rate_limit)(dev, vf, tx_rate, q_msk);
 }
 
@@ -3039,37 +3039,37 @@ rte_eth_mirror_rule_set(uint8_t port_id,
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if (mirror_conf->rule_type_mask == 0) {
-		PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
+		RTE_PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
 		return -EINVAL;
 	}
 
 	if (mirror_conf->dst_pool >= ETH_64_POOLS) {
-		PMD_DEBUG_TRACE("Invalid dst pool, pool id must"
+		RTE_PMD_DEBUG_TRACE("Invalid dst pool, pool id must"
 			"be 0-%d\n",ETH_64_POOLS - 1);
 		return -EINVAL;
 	}
 
 	if ((mirror_conf->rule_type_mask & ETH_VMDQ_POOL_MIRROR) &&
 		(mirror_conf->pool_mask == 0)) {
-		PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not"
+		RTE_PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not"
 				"be 0.\n");
 		return -EINVAL;
 	}
 
 	if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
 	{
-		PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
+		RTE_PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
 			ETH_VMDQ_NUM_MIRROR_RULE - 1);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
 
 	return (*dev->dev_ops->mirror_rule_set)(dev, mirror_conf, rule_id, on);
 }
@@ -3080,19 +3080,19 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if(rule_id >= ETH_VMDQ_NUM_MIRROR_RULE)
 	{
-		PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
+		RTE_PMD_DEBUG_TRACE("Invalid rule_id, rule_id must be 0-%d\n",
 			ETH_VMDQ_NUM_MIRROR_RULE-1);
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
 
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
@@ -3105,14 +3105,14 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return 0;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 	if (queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
 		return 0;
 	}
 	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
@@ -3126,15 +3126,15 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return 0;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 	if (queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
 		return 0;
 	}
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
@@ -3147,12 +3147,12 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return 0;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
 	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -3162,12 +3162,12 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
@@ -3185,7 +3185,7 @@ rte_eth_dev_callback_register(uint8_t port_id,
 		return -EINVAL;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
@@ -3226,7 +3226,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,
 		return -EINVAL;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
@@ -3286,16 +3286,16 @@ int rte_eth_dev_bypass_init(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
 	(*dev->dev_ops->bypass_init)(dev);
 	return 0;
 }
@@ -3306,15 +3306,15 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_show)(dev, state);
 	return 0;
 }
@@ -3325,16 +3325,16 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_set)(dev, new_state);
 	return 0;
 }
@@ -3345,16 +3345,16 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_show)(dev, event, state);
 	return 0;
 }
@@ -3365,16 +3365,16 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_set)(dev, event, state);
 	return 0;
 }
@@ -3385,16 +3385,16 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
 	return 0;
 }
@@ -3405,16 +3405,16 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_ver_show)(dev, ver);
 	return 0;
 }
@@ -3425,16 +3425,16 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
 	return 0;
 }
@@ -3445,16 +3445,16 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	if ((dev= &rte_eth_devices[port_id]) == NULL) {
-		PMD_DEBUG_TRACE("Invalid port device\n");
+		RTE_PMD_DEBUG_TRACE("Invalid port device\n");
 		return -ENODEV;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_reset)(dev);
 	return 0;
 }
@@ -3466,12 +3466,12 @@ rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type)
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
 	return (*dev->dev_ops->filter_ctrl)(dev, filter_type,
 				RTE_ETH_FILTER_NOP, NULL);
 }
@@ -3483,12 +3483,12 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
 	return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
 }
 
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 2/4] ethdev: move RTE_ETH_FPTR_OR_ERR macros to header
  2015-06-12 11:28 [PATCH 0/4] ethdev: Add checks for function support in driver Bruce Richardson
  2015-06-12 11:28 ` [PATCH 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
@ 2015-06-12 11:28 ` Bruce Richardson
  2015-06-12 11:28 ` [PATCH 3/4] ethdev: remove duplicated debug functions Bruce Richardson
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-06-12 11:28 UTC (permalink / raw)
  To: dev

Move the RTE_ETH_FPTR_OR_ERR, and RTE_PMD_DEBUG_TRACE 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 <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 22 ----------------------
 lib/librte_ether/rte_ethdev.h | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 89471f1..7720a8e 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) { \
@@ -91,20 +83,6 @@
 	} \
 } while(0)
 
-/* Macros to check for invlaid 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)
-
 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 = NULL;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b640e5b..b1c1a31 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -948,6 +948,39 @@ 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)
+
 /*
  * 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.2

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 3/4] ethdev: remove duplicated debug functions
  2015-06-12 11:28 [PATCH 0/4] ethdev: Add checks for function support in driver Bruce Richardson
  2015-06-12 11:28 ` [PATCH 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
  2015-06-12 11:28 ` [PATCH 2/4] ethdev: move RTE_ETH_FPTR_OR_ERR macros to header Bruce Richardson
@ 2015-06-12 11:28 ` Bruce Richardson
  2015-06-12 11:28 ` [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns Bruce Richardson
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
  4 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-06-12 11:28 UTC (permalink / raw)
  To: dev

The functions for rx/tx burst, for rx_queue_count and descriptor_done in
the ethdev library all had two copies of the code. One copy in
rte_ethdev.h was inlined for performance, while a second was in
rte_ethdev.c for debugging purposes only. We can eliminate the second
copy of the functions by moving the additional debug checks into the
copies of the functions in the header file. [Any compilation for
debugging at optimization level 0 will not inline the function so the
result should be same as when the function was in the .c file.]

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 76 -------------------------------------------
 lib/librte_ether/rte_ethdev.h | 73 ++++++++++++++++++++++++-----------------
 2 files changed, 43 insertions(+), 106 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7720a8e..9029869 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3075,82 +3075,6 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-uint16_t
-rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-		return 0;
-	}
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_rx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
-						rx_pkts, nb_pkts);
-}
-
-uint16_t
-rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-		return 0;
-	}
-
-	dev = &rte_eth_devices[port_id];
-
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_tx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
-						tx_pkts, nb_pkts);
-}
-
-uint32_t
-rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
-{
-	struct rte_eth_dev *dev;
-
-	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-		return 0;
-	}
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
-	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
-}
-
-int
-rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
-{
-	struct rte_eth_dev *dev;
-
-	if (!rte_eth_dev_is_valid_port(port_id)) {
-		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-		return -ENODEV;
-	}
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
-	return (*dev->dev_ops->rx_descriptor_done)( \
-		dev->data->rx_queues[queue_id], offset);
-}
-#endif
-
 int
 rte_eth_dev_callback_register(uint8_t port_id,
 			enum rte_eth_event_type event,
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b1c1a31..827ca3e 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2452,18 +2452,23 @@ extern int rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on);
  *   of pointers to *rte_mbuf* structures effectively supplied to the
  *   *rx_pkts* array.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
-
-	dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return 0;
+	}
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 	int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
 			rx_pkts, nb_pkts);
 
@@ -2481,7 +2486,6 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return nb_rx;
 }
-#endif
 
 /**
  * Get the number of used descriptors in a specific queue
@@ -2493,18 +2497,20 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @return
  *  The number of used descriptors in the specific queue.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint32_t rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id);
-#else
 static inline uint32_t
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
-        struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-        dev = &rte_eth_devices[port_id];
-        return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
-}
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return 0;
+	}
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
 #endif
+	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
+}
 
 /**
  * Check if the DD bit of the specific RX descriptor in the queue has been set
@@ -2520,21 +2526,22 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern int rte_eth_rx_descriptor_done(uint8_t port_id,
-				      uint16_t queue_id,
-				      uint16_t offset);
-#else
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return -ENODEV;
+	}
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+#endif
 
-	dev = &rte_eth_devices[port_id];
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-#endif
 
 /**
  * Send a burst of output packets on a transmit queue of an Ethernet device.
@@ -2595,17 +2602,24 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
  *   the transmit ring. The return value can be less than the value of the
  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		return 0;
+	}
+
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
+	if (queue_id >= dev->data->nb_tx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 
 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
 	struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
@@ -2621,7 +2635,6 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
 }
-#endif
 
 /**
  * Setup a new signature filter rule on an Ethernet device
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns
  2015-06-12 11:28 [PATCH 0/4] ethdev: Add checks for function support in driver Bruce Richardson
                   ` (2 preceding siblings ...)
  2015-06-12 11:28 ` [PATCH 3/4] ethdev: remove duplicated debug functions Bruce Richardson
@ 2015-06-12 11:28 ` Bruce Richardson
  2015-06-12 17:32   ` Roger B. Melton
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
  4 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-06-12 11:28 UTC (permalink / raw)
  To: dev

The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
supported by very few PMDs. Therefore, it is best to check for support
for the functions in the ethdev library, so as to avoid crashes
at run-time if the application goes to use those APIs. The performance
impact of this change should be very small as this is a predictable
branch in the function.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 827ca3e..9ad1b6a 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2496,6 +2496,8 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  *  The queue id on the specific port.
  * @return
  *  The number of used descriptors in the specific queue.
+ *  NOTE: if function is not supported by device this call
+ *        returns (uint32_t)-ENOTSUP
  */
 static inline uint32_t
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
@@ -2507,8 +2509,9 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return 0;
 	}
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
 #endif
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, (uint32_t)-ENOTSUP);
+
 	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -2525,6 +2528,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (1) if the specific DD bit is set.
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
+ *  - (-ENOTSUP) if the device does not support this function
  */
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
@@ -2536,8 +2540,8 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 #endif
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
-- 
2.4.2

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns
  2015-06-12 11:28 ` [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns Bruce Richardson
@ 2015-06-12 17:32   ` Roger B. Melton
  2015-06-15 10:14     ` Bruce Richardson
  0 siblings, 1 reply; 55+ messages in thread
From: Roger B. Melton @ 2015-06-12 17:32 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

Hi Bruce,  Comment in-line.  Regards, Roger

On 6/12/15 7:28 AM, Bruce Richardson wrote:
> The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
> supported by very few PMDs. Therefore, it is best to check for support
> for the functions in the ethdev library, so as to avoid crashes
> at run-time if the application goes to use those APIs. The performance
> impact of this change should be very small as this is a predictable
> branch in the function.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>   lib/librte_ether/rte_ethdev.h | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 827ca3e..9ad1b6a 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -2496,6 +2496,8 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
>    *  The queue id on the specific port.
>    * @return
>    *  The number of used descriptors in the specific queue.
> + *  NOTE: if function is not supported by device this call
> + *        returns (uint32_t)-ENOTSUP
>    */
>   static inline uint32_t

Why not change the return type to int32_t?
In this way, the caller isn't required to make the assumption that a 
large queue count indicates an error.  < 0 means error, other wise it's 
a valid queue count.

This approach would be consistent with other APIs.

>   rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
> @@ -2507,8 +2509,9 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
>   		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>   		return 0;
>   	}
> -	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
>   #endif
> +	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, (uint32_t)-ENOTSUP);
> +
>   	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
>   }
>   
> @@ -2525,6 +2528,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
>    *  - (1) if the specific DD bit is set.
>    *  - (0) if the specific DD bit is not set.
>    *  - (-ENODEV) if *port_id* invalid.
> + *  - (-ENOTSUP) if the device does not support this function
>    */
>   static inline int
>   rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
> @@ -2536,8 +2540,8 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
>   		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
>   		return -ENODEV;
>   	}
> -	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
>   #endif
> +	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
>   
>   	return (*dev->dev_ops->rx_descriptor_done)( \
>   		dev->data->rx_queues[queue_id], offset);

-- 
  ____________________________________________________________________
|Roger B. Melton                |          |      Cisco Systems      |
|CPP Software                  :|:        :|:     7100 Kit Creek Rd  |
|+1.919.476.2332 phone        :|||:      :|||:    RTP, NC 27709-4987 |
|+1.919.392.1094 fax       .:|||||||:..:|||||||:. rmelton@cisco.com  |
|                                                                    |
| This email may contain confidential and privileged material for the|
| sole use of the intended recipient. Any review, use, distribution  |
| or disclosure by others is strictly prohibited. If you are not the |
| intended recipient (or authorized to receive for the recipient),   |
| please contact the sender by reply email and delete all copies of  |
| this message.                                                      |
|                                                                    |
| For corporate legal information go to:                             |
| http://www.cisco.com/web/about/doing_business/legal/cri/index.html |
|__________________________ http://www.cisco.com ____________________|

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns
  2015-06-12 17:32   ` Roger B. Melton
@ 2015-06-15 10:14     ` Bruce Richardson
  2015-07-06 15:11       ` Thomas Monjalon
  0 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-06-15 10:14 UTC (permalink / raw)
  To: Roger B. Melton; +Cc: dev

On Fri, Jun 12, 2015 at 01:32:56PM -0400, Roger B. Melton wrote:
> Hi Bruce,  Comment in-line.  Regards, Roger
> 
> On 6/12/15 7:28 AM, Bruce Richardson wrote:
> >The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
> >supported by very few PMDs. Therefore, it is best to check for support
> >for the functions in the ethdev library, so as to avoid crashes
> >at run-time if the application goes to use those APIs. The performance
> >impact of this change should be very small as this is a predictable
> >branch in the function.
> >
> >Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> >---
> >  lib/librte_ether/rte_ethdev.h | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> >diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> >index 827ca3e..9ad1b6a 100644
> >--- a/lib/librte_ether/rte_ethdev.h
> >+++ b/lib/librte_ether/rte_ethdev.h
> >@@ -2496,6 +2496,8 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
> >   *  The queue id on the specific port.
> >   * @return
> >   *  The number of used descriptors in the specific queue.
> >+ *  NOTE: if function is not supported by device this call
> >+ *        returns (uint32_t)-ENOTSUP
> >   */
> >  static inline uint32_t
> 
> Why not change the return type to int32_t?
> In this way, the caller isn't required to make the assumption that a large
> queue count indicates an error.  < 0 means error, other wise it's a valid
> queue count.
> 
> This approach would be consistent with other APIs.
> 

Yes, good point, I should see about that. One thing I'm unsure of, though, is
does this count as ABI breakage? I don't see how it should break any older
apps, since the return type is the same size, but I'm not sure as we are 
changing the return type of the function.

Neil, can you perhaps comment here? Is changing uint32_t to int32_t ok, from
an ABI point of view?

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns
  2015-06-15 10:14     ` Bruce Richardson
@ 2015-07-06 15:11       ` Thomas Monjalon
  2015-07-26 20:44         ` Thomas Monjalon
  0 siblings, 1 reply; 55+ messages in thread
From: Thomas Monjalon @ 2015-07-06 15:11 UTC (permalink / raw)
  To: nhorman; +Cc: dev

Neil, your ABI expertise is required for this patch.

2015-06-15 11:14, Bruce Richardson:
> On Fri, Jun 12, 2015 at 01:32:56PM -0400, Roger B. Melton wrote:
> > Hi Bruce,  Comment in-line.  Regards, Roger
> > 
> > On 6/12/15 7:28 AM, Bruce Richardson wrote:
> > >The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
> > >supported by very few PMDs. Therefore, it is best to check for support
> > >for the functions in the ethdev library, so as to avoid crashes
> > >at run-time if the application goes to use those APIs. The performance
> > >impact of this change should be very small as this is a predictable
> > >branch in the function.
> > >
> > >Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > >---
> > >  lib/librte_ether/rte_ethdev.h | 8 ++++++--
> > >  1 file changed, 6 insertions(+), 2 deletions(-)
> > >
> > >diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > >index 827ca3e..9ad1b6a 100644
> > >--- a/lib/librte_ether/rte_ethdev.h
> > >+++ b/lib/librte_ether/rte_ethdev.h
> > >@@ -2496,6 +2496,8 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
> > >   *  The queue id on the specific port.
> > >   * @return
> > >   *  The number of used descriptors in the specific queue.
> > >+ *  NOTE: if function is not supported by device this call
> > >+ *        returns (uint32_t)-ENOTSUP
> > >   */
> > >  static inline uint32_t
> > 
> > Why not change the return type to int32_t?
> > In this way, the caller isn't required to make the assumption that a large
> > queue count indicates an error.  < 0 means error, other wise it's a valid
> > queue count.
> > 
> > This approach would be consistent with other APIs.
> > 
> 
> Yes, good point, I should see about that. One thing I'm unsure of, though, is
> does this count as ABI breakage? I don't see how it should break any older
> apps, since the return type is the same size, but I'm not sure as we are 
> changing the return type of the function.
> 
> Neil, can you perhaps comment here? Is changing uint32_t to int32_t ok, from
> an ABI point of view?
> 
> Regards,
> /Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns
  2015-07-06 15:11       ` Thomas Monjalon
@ 2015-07-26 20:44         ` Thomas Monjalon
  0 siblings, 0 replies; 55+ messages in thread
From: Thomas Monjalon @ 2015-07-26 20:44 UTC (permalink / raw)
  To: nhorman, Bruce Richardson; +Cc: dev

Neil, Bruce,
Can we move forward?

2015-07-06 17:11, Thomas Monjalon:
> Neil, your ABI expertise is required for this patch.
> 
> 2015-06-15 11:14, Bruce Richardson:
> > On Fri, Jun 12, 2015 at 01:32:56PM -0400, Roger B. Melton wrote:
> > > Hi Bruce,  Comment in-line.  Regards, Roger
> > > 
> > > On 6/12/15 7:28 AM, Bruce Richardson wrote:
> > > >The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
> > > >supported by very few PMDs. Therefore, it is best to check for support
> > > >for the functions in the ethdev library, so as to avoid crashes
> > > >at run-time if the application goes to use those APIs. The performance
> > > >impact of this change should be very small as this is a predictable
> > > >branch in the function.
> > > >
> > > >Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > >---
> > > >  lib/librte_ether/rte_ethdev.h | 8 ++++++--
> > > >  1 file changed, 6 insertions(+), 2 deletions(-)
> > > >
> > > >diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > > >index 827ca3e..9ad1b6a 100644
> > > >--- a/lib/librte_ether/rte_ethdev.h
> > > >+++ b/lib/librte_ether/rte_ethdev.h
> > > >@@ -2496,6 +2496,8 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
> > > >   *  The queue id on the specific port.
> > > >   * @return
> > > >   *  The number of used descriptors in the specific queue.
> > > >+ *  NOTE: if function is not supported by device this call
> > > >+ *        returns (uint32_t)-ENOTSUP
> > > >   */
> > > >  static inline uint32_t
> > > 
> > > Why not change the return type to int32_t?
> > > In this way, the caller isn't required to make the assumption that a large
> > > queue count indicates an error.  < 0 means error, other wise it's a valid
> > > queue count.
> > > 
> > > This approach would be consistent with other APIs.
> > > 
> > 
> > Yes, good point, I should see about that. One thing I'm unsure of, though, is
> > does this count as ABI breakage? I don't see how it should break any older
> > apps, since the return type is the same size, but I'm not sure as we are 
> > changing the return type of the function.
> > 
> > Neil, can you perhaps comment here? Is changing uint32_t to int32_t ok, from
> > an ABI point of view?
> > 
> > Regards,
> > /Bruce
> 
> 

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v2 0/4] ethdev: minor cleanup
  2015-06-12 11:28 [PATCH 0/4] ethdev: Add checks for function support in driver Bruce Richardson
                   ` (3 preceding siblings ...)
  2015-06-12 11:28 ` [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns Bruce Richardson
@ 2015-09-09 15:09 ` Bruce Richardson
  2015-09-09 15:09   ` [PATCH v2 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
                     ` (5 more replies)
  4 siblings, 6 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-09-09 15:09 UTC (permalink / raw)
  To: dev

This patchset performs two cleanups:
1. Four functions in ethdev.c which were enabled for debug only have been
  merged into their inlined header-file counterparts. This change required that
  a number of macros be renamed and moved to the header file too. The macro changes
  are in patches 1 & 2, and the elimination of the separate debug fns are in patch 3.
2. Checks for valid function pointers are added to the API calls for reading
  the descriptor ring count, and checking for a valid descriptor. This is because
  these functions are not implemented by most drivers, and so it's far safer to
  have the check.

---

V2 Changes:
* Rebased to latest DPDK codebase
* Changed type from uint32_t to int for the count function, on the basis of
feedback received.

Bruce Richardson (4):
  ethdev: rename macros to have RTE_ETH prefix
  ethdev: move error checking macros to header
  ethdev: remove duplicated debug functions
  ethdev: check driver support for functions

 lib/librte_ether/rte_ethdev.c | 674 ++++++++++++++++++------------------------
 lib/librte_ether/rte_ethdev.h | 121 ++++++--
 2 files changed, 375 insertions(+), 420 deletions(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v2 1/4] ethdev: rename macros to have RTE_ETH prefix
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
@ 2015-09-09 15:09   ` Bruce Richardson
  2015-09-09 15:09   ` [PATCH v2 2/4] ethdev: move error checking macros to header Bruce Richardson
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-09-09 15:09 UTC (permalink / raw)
  To: dev

The macros to check that the function pointers and port ids are valid
for an ethdev are potentially useful to have in the ethdev.h file.
However, since they would then become externally visible, we apply
the RTE_ETH prefix to them.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 612 +++++++++++++++++++++---------------------
 1 file changed, 306 insertions(+), 306 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b309309..09af303 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -70,54 +70,54 @@
 #include "rte_ethdev.h"
 
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
-#define PMD_DEBUG_TRACE(fmt, args...) do {                        \
+#define RTE_PMD_DEBUG_TRACE(fmt, args...) do {                        \
 		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \
 	} while (0)
 #else
-#define PMD_DEBUG_TRACE(fmt, args...)
+#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) { \
-		PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
+		RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
 		return (retval); \
 	} \
 } while (0)
 
 #define PROC_PRIMARY_OR_RET() do { \
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
-		PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
+		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 FUNC_PTR_OR_ERR_RET(func, retval) do { \
+#define RTE_ETH_FPTR_OR_ERR_RET(func, retval) do { \
 	if ((func) == NULL) { \
-		PMD_DEBUG_TRACE("Function not supported\n"); \
+		RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
 		return (retval); \
 	} \
 } while (0)
 
-#define FUNC_PTR_OR_RET(func) do { \
+#define RTE_ETH_FPTR_OR_RET(func) do { \
 	if ((func) == NULL) { \
-		PMD_DEBUG_TRACE("Function not supported\n"); \
+		RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
 		return; \
 	} \
 } while (0)
 
 /* Macros to check for valid port */
-#define VALID_PORTID_OR_ERR_RET(port_id, retval) do {		\
+#define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do {		\
 	if (!rte_eth_dev_is_valid_port(port_id)) {		\
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
 		return retval;					\
 	}							\
 } while (0)
 
-#define VALID_PORTID_OR_RET(port_id) do {			\
+#define RTE_ETH_VALID_PORTID_OR_RET(port_id) do {			\
 	if (!rte_eth_dev_is_valid_port(port_id)) {		\
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
 		return;						\
 	}							\
 } while (0)
@@ -241,7 +241,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 
 	port_id = rte_eth_dev_find_free_port();
 	if (port_id == RTE_MAX_ETHPORTS) {
-		PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
+		RTE_PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
 		return NULL;
 	}
 
@@ -249,7 +249,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 		rte_eth_dev_data_alloc();
 
 	if (rte_eth_dev_allocated(name) != NULL) {
-		PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n",
+		RTE_PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n",
 				name);
 		return NULL;
 	}
@@ -336,7 +336,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	if (diag == 0)
 		return 0;
 
-	PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
+	RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
 			pci_drv->name,
 			(unsigned) pci_dev->id.vendor_id,
 			(unsigned) pci_dev->id.device_id);
@@ -470,10 +470,10 @@ rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *port_id)
 static int
 rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
 {
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	if (addr == NULL) {
-		PMD_DEBUG_TRACE("Null pointer is specified\n");
+		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
 		return -EINVAL;
 	}
 
@@ -486,10 +486,10 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 {
 	char *tmp;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	if (name == NULL) {
-		PMD_DEBUG_TRACE("Null pointer is specified\n");
+		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
 		return -EINVAL;
 	}
 
@@ -506,7 +506,7 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 	uint32_t drv_flags;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
@@ -724,7 +724,7 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 			return -(ENOMEM);
 		}
 	} else { /* re-configure */
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
 
 		rxq = dev->data->rx_queues;
 
@@ -757,15 +757,15 @@ rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
 
 	return dev->dev_ops->rx_queue_start(dev, rx_queue_id);
 
@@ -780,15 +780,15 @@ rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
 
 	return dev->dev_ops->rx_queue_stop(dev, rx_queue_id);
 
@@ -803,15 +803,15 @@ rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
 
 	return dev->dev_ops->tx_queue_start(dev, tx_queue_id);
 
@@ -826,15 +826,15 @@ rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
 
 	return dev->dev_ops->tx_queue_stop(dev, tx_queue_id);
 
@@ -856,7 +856,7 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 			return -(ENOMEM);
 		}
 	} else { /* re-configure */
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
 
 		txq = dev->data->tx_queues;
 
@@ -918,7 +918,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		    (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB_RSS) ||
 		    (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB)) {
 			/* SRIOV only works in VMDq enable mode */
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"wrong VMDQ mq_mode rx %u tx %u\n",
 					port_id,
@@ -931,13 +931,13 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		case ETH_MQ_RX_VMDQ_DCB:
 		case ETH_MQ_RX_VMDQ_DCB_RSS:
 			/* DCB/RSS VMDQ in SRIOV mode, not implement yet */
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"unsupported VMDQ mq_mode rx %u\n",
 					port_id, dev_conf->rxmode.mq_mode);
 			return -EINVAL;
 		case ETH_MQ_RX_RSS:
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"Rx mq mode is changed from:"
 					"mq_mode %u into VMDQ mq_mode %u\n",
@@ -948,7 +948,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
 			if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
 				if (rte_eth_dev_check_vf_rss_rxq_num(port_id, nb_rx_q) != 0) {
-					PMD_DEBUG_TRACE("ethdev port_id=%d"
+					RTE_PMD_DEBUG_TRACE("ethdev port_id=%d"
 							" SRIOV active, invalid queue"
 							" number for VMDQ RSS, allowed"
 							" value are 1, 2 or 4\n",
@@ -967,7 +967,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		switch (dev_conf->txmode.mq_mode) {
 		case ETH_MQ_TX_VMDQ_DCB:
 			/* DCB VMDQ in SRIOV mode, not implement yet */
-			PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%" PRIu8
 					" SRIOV active, "
 					"unsupported VMDQ mq_mode tx %u\n",
 					port_id, dev_conf->txmode.mq_mode);
@@ -981,7 +981,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		/* check valid queue number */
 		if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
 		    (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d SRIOV active, "
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d SRIOV active, "
 					"queue number must less equal to %d\n",
 					port_id,
 					RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
@@ -993,7 +993,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_vmdq_dcb_conf *conf;
 
 			if (nb_rx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_rx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_rx_q "
 						"!= %d\n",
 						port_id, ETH_VMDQ_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1001,7 +1001,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->rx_adv_conf.vmdq_dcb_conf);
 			if (!(conf->nb_queue_pools == ETH_16_POOLS ||
 			      conf->nb_queue_pools == ETH_32_POOLS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
 						"nb_queue_pools must be %d or %d\n",
 						port_id, ETH_16_POOLS, ETH_32_POOLS);
 				return -EINVAL;
@@ -1011,7 +1011,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_vmdq_dcb_tx_conf *conf;
 
 			if (nb_tx_q != ETH_VMDQ_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB, nb_tx_q "
 						"!= %d\n",
 						port_id, ETH_VMDQ_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1019,7 +1019,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->tx_adv_conf.vmdq_dcb_tx_conf);
 			if (!(conf->nb_queue_pools == ETH_16_POOLS ||
 			      conf->nb_queue_pools == ETH_32_POOLS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d VMDQ+DCB selected, "
 						"nb_queue_pools != %d or nb_queue_pools "
 						"!= %d\n",
 						port_id, ETH_16_POOLS, ETH_32_POOLS);
@@ -1032,7 +1032,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_dcb_rx_conf *conf;
 
 			if (nb_rx_q != ETH_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_rx_q "
 						"!= %d\n",
 						port_id, ETH_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1040,7 +1040,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->rx_adv_conf.dcb_rx_conf);
 			if (!(conf->nb_tcs == ETH_4_TCS ||
 			      conf->nb_tcs == ETH_8_TCS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
 						"nb_tcs != %d or nb_tcs "
 						"!= %d\n",
 						port_id, ETH_4_TCS, ETH_8_TCS);
@@ -1052,7 +1052,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			const struct rte_eth_dcb_tx_conf *conf;
 
 			if (nb_tx_q != ETH_DCB_NUM_QUEUES) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB, nb_tx_q "
 						"!= %d\n",
 						port_id, ETH_DCB_NUM_QUEUES);
 				return -EINVAL;
@@ -1060,7 +1060,7 @@ rte_eth_dev_check_mq_mode(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 			conf = &(dev_conf->tx_adv_conf.dcb_tx_conf);
 			if (!(conf->nb_tcs == ETH_4_TCS ||
 			      conf->nb_tcs == ETH_8_TCS)) {
-				PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
+				RTE_PMD_DEBUG_TRACE("ethdev port_id=%d DCB selected, "
 						"nb_tcs != %d or nb_tcs "
 						"!= %d\n",
 						port_id, ETH_4_TCS, ETH_8_TCS);
@@ -1083,17 +1083,17 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 			"Number of RX queues requested (%u) is greater than max supported(%d)\n",
 			nb_rx_q, RTE_MAX_QUEUES_PER_PORT);
 		return -EINVAL;
 	}
 
 	if (nb_tx_q > RTE_MAX_QUEUES_PER_PORT) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 			"Number of TX queues requested (%u) is greater than max supported(%d)\n",
 			nb_tx_q, RTE_MAX_QUEUES_PER_PORT);
 		return -EINVAL;
@@ -1101,11 +1101,11 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
@@ -1117,22 +1117,22 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 */
 	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
 	if (nb_rx_q > dev_info.max_rx_queues) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
 				port_id, nb_rx_q, dev_info.max_rx_queues);
 		return -EINVAL;
 	}
 	if (nb_rx_q == 0) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
 		return -EINVAL;
 	}
 
 	if (nb_tx_q > dev_info.max_tx_queues) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
 				port_id, nb_tx_q, dev_info.max_tx_queues);
 		return -EINVAL;
 	}
 	if (nb_tx_q == 0) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
 		return -EINVAL;
 	}
 
@@ -1147,7 +1147,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
 
 		if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
-			PMD_DEBUG_TRACE("driver %s does not support lsc\n",
+			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
 					pci_drv->name);
 			return -EINVAL;
 		}
@@ -1160,14 +1160,14 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if (dev_conf->rxmode.jumbo_frame == 1) {
 		if (dev_conf->rxmode.max_rx_pkt_len >
 		    dev_info.max_rx_pktlen) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
 				" > max valid value %u\n",
 				port_id,
 				(unsigned)dev_conf->rxmode.max_rx_pkt_len,
 				(unsigned)dev_info.max_rx_pktlen);
 			return -EINVAL;
 		} else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
 				" < min valid value %u\n",
 				port_id,
 				(unsigned)dev_conf->rxmode.max_rx_pkt_len,
@@ -1185,7 +1185,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	/* multiple queue mode checking */
 	diag = rte_eth_dev_check_mq_mode(port_id, nb_rx_q, nb_tx_q, dev_conf);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_check_mq_mode = %d\n",
 				port_id, diag);
 		return diag;
 	}
@@ -1195,14 +1195,14 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 */
 	diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
 				port_id, diag);
 		return diag;
 	}
 
 	diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
 				port_id, diag);
 		rte_eth_dev_rx_queue_config(dev, 0);
 		return diag;
@@ -1210,7 +1210,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
 	diag = (*dev->dev_ops->dev_configure)(dev);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
 				port_id, diag);
 		rte_eth_dev_rx_queue_config(dev, 0);
 		rte_eth_dev_tx_queue_config(dev, 0);
@@ -1249,7 +1249,7 @@ rte_eth_dev_config_restore(uint8_t port_id)
 			(dev->data->mac_pool_sel[i] & (1ULL << pool)))
 			(*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
 		else {
-			PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
 					port_id);
 			/* exit the loop but not return an error */
 			break;
@@ -1279,14 +1279,14 @@ rte_eth_dev_start(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
 	if (dev->data->dev_started != 0) {
-		PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+		RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
 			" already started\n",
 			port_id);
 		return 0;
@@ -1301,7 +1301,7 @@ rte_eth_dev_start(uint8_t port_id)
 	rte_eth_dev_config_restore(port_id);
 
 	if (dev->data->dev_conf.intr_conf.lsc != 0) {
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
 		(*dev->dev_ops->link_update)(dev, 0);
 	}
 	return 0;
@@ -1316,13 +1316,13 @@ rte_eth_dev_stop(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_RET();
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_stop);
 
 	if (dev->data->dev_started == 0) {
-		PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+		RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
 			" already stopped\n",
 			port_id);
 		return;
@@ -1341,11 +1341,11 @@ rte_eth_dev_set_link_up(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
 	return (*dev->dev_ops->dev_set_link_up)(dev);
 }
 
@@ -1358,11 +1358,11 @@ rte_eth_dev_set_link_down(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
 	return (*dev->dev_ops->dev_set_link_down)(dev);
 }
 
@@ -1375,10 +1375,10 @@ rte_eth_dev_close(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_RET();
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_close);
 	dev->data->dev_started = 0;
 	(*dev->dev_ops->dev_close)(dev);
 
@@ -1403,22 +1403,22 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
 
 	/*
 	 * Check the size of the mbuf data buffer.
@@ -1427,7 +1427,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	 */
 	rte_eth_dev_info_get(port_id, &dev_info);
 	if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
-		PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
+		RTE_PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
 				mp->name, (int) mp->private_data_size,
 				(int) sizeof(struct rte_pktmbuf_pool_private));
 		return -ENOSPC;
@@ -1435,7 +1435,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	mbp_buf_size = rte_pktmbuf_data_room_size(mp);
 
 	if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
-		PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
+		RTE_PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
 				"(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
 				"=%d)\n",
 				mp->name,
@@ -1473,22 +1473,22 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
 
 	rte_eth_dev_info_get(port_id, &dev_info);
 
@@ -1504,10 +1504,10 @@ rte_eth_promiscuous_enable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_enable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->promiscuous_enable);
 	(*dev->dev_ops->promiscuous_enable)(dev);
 	dev->data->promiscuous = 1;
 }
@@ -1517,10 +1517,10 @@ rte_eth_promiscuous_disable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_disable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->promiscuous_disable);
 	dev->data->promiscuous = 0;
 	(*dev->dev_ops->promiscuous_disable)(dev);
 }
@@ -1530,7 +1530,7 @@ rte_eth_promiscuous_get(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	return dev->data->promiscuous;
@@ -1541,10 +1541,10 @@ rte_eth_allmulticast_enable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->allmulticast_enable);
 	(*dev->dev_ops->allmulticast_enable)(dev);
 	dev->data->all_multicast = 1;
 }
@@ -1554,10 +1554,10 @@ rte_eth_allmulticast_disable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->allmulticast_disable);
 	dev->data->all_multicast = 0;
 	(*dev->dev_ops->allmulticast_disable)(dev);
 }
@@ -1567,7 +1567,7 @@ rte_eth_allmulticast_get(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	return dev->data->all_multicast;
@@ -1592,13 +1592,13 @@ rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		rte_eth_dev_atomic_read_link_status(dev, eth_link);
 	else {
-		FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_ETH_FPTR_OR_RET(*dev->dev_ops->link_update);
 		(*dev->dev_ops->link_update)(dev, 1);
 		*eth_link = dev->data->dev_link;
 	}
@@ -1609,13 +1609,13 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		rte_eth_dev_atomic_read_link_status(dev, eth_link);
 	else {
-		FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_ETH_FPTR_OR_RET(*dev->dev_ops->link_update);
 		(*dev->dev_ops->link_update)(dev, 0);
 		*eth_link = dev->data->dev_link;
 	}
@@ -1626,12 +1626,12 @@ rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	memset(stats, 0, sizeof(*stats));
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP);
+	RTE_ETH_FPTR_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;
@@ -1642,10 +1642,10 @@ rte_eth_stats_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->stats_reset);
 	(*dev->dev_ops->stats_reset)(dev);
 }
 
@@ -1660,7 +1660,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 	signed xcount = 0;
 	uint64_t val, *stats_ptr;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
@@ -1735,7 +1735,7 @@ rte_eth_xstats_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	/* implemented by the driver */
@@ -1754,11 +1754,11 @@ set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
 	return (*dev->dev_ops->queue_stats_mapping_set)
 			(dev, queue_id, stat_idx, is_rx);
 }
@@ -1787,12 +1787,12 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
 	dev_info->pci_dev = dev->pci_dev;
 	if (dev->driver)
@@ -1804,7 +1804,7 @@ rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 	ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
 }
@@ -1815,7 +1815,7 @@ rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	*mtu = dev->data->mtu;
@@ -1828,9 +1828,9 @@ rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)
 	int ret;
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
 
 	ret = (*dev->dev_ops->mtu_set)(dev, mtu);
 	if (!ret)
@@ -1844,19 +1844,19 @@ rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	if (!(dev->data->dev_conf.rxmode.hw_vlan_filter)) {
-		PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
 		return -ENOSYS;
 	}
 
 	if (vlan_id > 4095) {
-		PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
+		RTE_PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
 				port_id, (unsigned) vlan_id);
 		return -EINVAL;
 	}
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
 
 	return (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on);
 }
@@ -1866,14 +1866,14 @@ rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int o
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_strip_queue_set)(dev, rx_queue_id, on);
 
 	return 0;
@@ -1884,9 +1884,9 @@ rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_tpid_set)(dev, tpid);
 
 	return 0;
@@ -1900,7 +1900,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
 	int mask = 0;
 	int cur, org = 0;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	/*check which option changed by application*/
@@ -1929,7 +1929,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
 	if (mask == 0)
 		return ret;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_offload_set)(dev, mask);
 
 	return ret;
@@ -1941,7 +1941,7 @@ rte_eth_dev_get_vlan_offload(uint8_t port_id)
 	struct rte_eth_dev *dev;
 	int ret = 0;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.rxmode.hw_vlan_strip)
@@ -1961,9 +1961,9 @@ rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_pvid_set)(dev, pvid, on);
 
 	return 0;
@@ -1976,11 +1976,11 @@ rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -1988,13 +1988,13 @@ rte_eth_dev_fdir_add_signature_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
 				"None l4type, source & destinations ports "
 				"should be null!\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_add_signature_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_add_signature_filter)(dev, fdir_filter,
 								queue);
 }
@@ -2006,11 +2006,11 @@ rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2018,13 +2018,13 @@ rte_eth_dev_fdir_update_signature_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
 				"None l4type, source & destinations ports "
 				"should be null!\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_update_signature_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_update_signature_filter)(dev, fdir_filter,
 								queue);
 
@@ -2036,11 +2036,11 @@ rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_SIGNATURE) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2048,13 +2048,13 @@ rte_eth_dev_fdir_remove_signature_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
 				"None l4type source & destinations ports "
 				"should be null!\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_signature_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_remove_signature_filter)(dev, fdir_filter);
 }
 
@@ -2063,14 +2063,14 @@ rte_eth_dev_fdir_get_infos(uint8_t port_id, struct rte_eth_fdir *fdir)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	if (!(dev->data->dev_conf.fdir_conf.mode)) {
-		PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
 		return -ENOSYS;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_infos_get, -ENOTSUP);
 
 	(*dev->dev_ops->fdir_infos_get)(dev, fdir);
 	return 0;
@@ -2084,11 +2084,11 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2096,7 +2096,7 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
 				"None l4type, source & destinations ports "
 				"should be null!\n");
 		return -EINVAL;
@@ -2106,7 +2106,7 @@ rte_eth_dev_fdir_add_perfect_filter(uint8_t port_id,
 	if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
 		return -ENOTSUP;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_add_perfect_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_add_perfect_filter)(dev, fdir_filter,
 								soft_id, queue,
 								drop);
@@ -2120,11 +2120,11 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2132,7 +2132,7 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
 				"None l4type, source & destinations ports "
 				"should be null!\n");
 		return -EINVAL;
@@ -2142,7 +2142,7 @@ rte_eth_dev_fdir_update_perfect_filter(uint8_t port_id,
 	if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
 		return -ENOTSUP;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_update_perfect_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_update_perfect_filter)(dev, fdir_filter,
 							soft_id, queue, drop);
 }
@@ -2154,11 +2154,11 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
-		PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
+		RTE_PMD_DEBUG_TRACE("port %d: invalid FDIR mode=%u\n",
 				port_id, dev->data->dev_conf.fdir_conf.mode);
 		return -ENOSYS;
 	}
@@ -2166,7 +2166,7 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
 	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP
 	     || fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE)
 	    && (fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
+		RTE_PMD_DEBUG_TRACE(" Port are meaningless for SCTP and "
 				"None l4type, source & destinations ports "
 				"should be null!\n");
 		return -EINVAL;
@@ -2176,7 +2176,7 @@ rte_eth_dev_fdir_remove_perfect_filter(uint8_t port_id,
 	if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6)
 		return -ENOTSUP;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_remove_perfect_filter, -ENOTSUP);
 	return (*dev->dev_ops->fdir_remove_perfect_filter)(dev, fdir_filter,
 								soft_id);
 }
@@ -2186,14 +2186,14 @@ rte_eth_dev_fdir_set_masks(uint8_t port_id, struct rte_fdir_masks *fdir_mask)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	if (!(dev->data->dev_conf.fdir_conf.mode)) {
-		PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: pkt-filter disabled\n", port_id);
 		return -ENOSYS;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->fdir_set_masks, -ENOTSUP);
 	return (*dev->dev_ops->fdir_set_masks)(dev, fdir_mask);
 }
 
@@ -2202,9 +2202,9 @@ rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
 	memset(fc_conf, 0, sizeof(*fc_conf));
 	return (*dev->dev_ops->flow_ctrl_get)(dev, fc_conf);
 }
@@ -2214,14 +2214,14 @@ rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
-		PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
+		RTE_PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
 	return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
 }
 
@@ -2230,9 +2230,9 @@ rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
-		PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
+		RTE_PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
 		return -EINVAL;
 	}
 
@@ -2253,7 +2253,7 @@ rte_eth_check_reta_mask(struct rte_eth_rss_reta_entry64 *reta_conf,
 		return -EINVAL;
 
 	if (reta_size != RTE_ALIGN(reta_size, RTE_RETA_GROUP_SIZE)) {
-		PMD_DEBUG_TRACE("Invalid reta size, should be %u aligned\n",
+		RTE_PMD_DEBUG_TRACE("Invalid reta size, should be %u aligned\n",
 							RTE_RETA_GROUP_SIZE);
 		return -EINVAL;
 	}
@@ -2278,7 +2278,7 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
 		return -EINVAL;
 
 	if (max_rxq == 0) {
-		PMD_DEBUG_TRACE("No receive queue is available\n");
+		RTE_PMD_DEBUG_TRACE("No receive queue is available\n");
 		return -EINVAL;
 	}
 
@@ -2287,7 +2287,7 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
 		shift = i % RTE_RETA_GROUP_SIZE;
 		if ((reta_conf[idx].mask & (1ULL << shift)) &&
 			(reta_conf[idx].reta[shift] >= max_rxq)) {
-			PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
+			RTE_PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
 				"the maximum rxq index: %u\n", idx, shift,
 				reta_conf[idx].reta[shift], max_rxq);
 			return -EINVAL;
@@ -2305,7 +2305,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,
 	struct rte_eth_dev *dev;
 	int ret;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	/* Check mask bits */
 	ret = rte_eth_check_reta_mask(reta_conf, reta_size);
 	if (ret < 0)
@@ -2319,7 +2319,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,
 	if (ret < 0)
 		return ret;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
 	return (*dev->dev_ops->reta_update)(dev, reta_conf, reta_size);
 }
 
@@ -2332,7 +2332,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id,
 	int ret;
 
 	if (port_id >= nb_ports) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -2342,7 +2342,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id,
 		return ret;
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
 	return (*dev->dev_ops->reta_query)(dev, reta_conf, reta_size);
 }
 
@@ -2352,16 +2352,16 @@ rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)
 	struct rte_eth_dev *dev;
 	uint16_t rss_hash_protos;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	rss_hash_protos = rss_conf->rss_hf;
 	if ((rss_hash_protos != 0) &&
 	    ((rss_hash_protos & ETH_RSS_PROTO_MASK) == 0)) {
-		PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
+		RTE_PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
 				rss_hash_protos);
 		return -EINVAL;
 	}
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
 	return (*dev->dev_ops->rss_hash_update)(dev, rss_conf);
 }
 
@@ -2371,9 +2371,9 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
 	return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
 }
 
@@ -2383,19 +2383,19 @@ rte_eth_dev_udp_tunnel_add(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if (udp_tunnel == NULL) {
-		PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+		RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
 		return -EINVAL;
 	}
 
 	if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-		PMD_DEBUG_TRACE("Invalid tunnel type\n");
+		RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
 	return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel);
 }
 
@@ -2405,20 +2405,20 @@ rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (udp_tunnel == NULL) {
-		PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+		RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
 		return -EINVAL;
 	}
 
 	if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-		PMD_DEBUG_TRACE("Invalid tunnel type\n");
+		RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
 	return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel);
 }
 
@@ -2427,9 +2427,9 @@ rte_eth_led_on(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
 	return (*dev->dev_ops->dev_led_on)(dev);
 }
 
@@ -2438,9 +2438,9 @@ rte_eth_led_off(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
 	return (*dev->dev_ops->dev_led_off)(dev);
 }
 
@@ -2474,17 +2474,17 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
 	int index;
 	uint64_t pool_mask;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
 
 	if (is_zero_ether_addr(addr)) {
-		PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
 			port_id);
 		return -EINVAL;
 	}
 	if (pool >= ETH_64_POOLS) {
-		PMD_DEBUG_TRACE("pool id must be 0-%d\n", ETH_64_POOLS - 1);
+		RTE_PMD_DEBUG_TRACE("pool id must be 0-%d\n", ETH_64_POOLS - 1);
 		return -EINVAL;
 	}
 
@@ -2492,7 +2492,7 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
 	if (index < 0) {
 		index = get_mac_addr_index(port_id, &null_mac_addr);
 		if (index < 0) {
-			PMD_DEBUG_TRACE("port %d: MAC address array full\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
 				port_id);
 			return -ENOSPC;
 		}
@@ -2522,13 +2522,13 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
 	struct rte_eth_dev *dev;
 	int index;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
 
 	index = get_mac_addr_index(port_id, addr);
 	if (index == 0) {
-		PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
 		return -EADDRINUSE;
 	} else if (index < 0)
 		return 0;  /* Do nothing if address wasn't found */
@@ -2550,13 +2550,13 @@ rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	if (!is_valid_assigned_ether_addr(addr))
 		return -EINVAL;
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
 
 	/* Update default address in NIC data structure */
 	ether_addr_copy(addr, &dev->data->mac_addrs[0]);
@@ -2574,22 +2574,22 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_info dev_info;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs) {
-		PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
+		RTE_PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
 		return -EINVAL;
 	}
 
 	if (rx_mode == 0) {
-		PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
+		RTE_PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
 		return -EINVAL;
 	}
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rx_mode)(dev, vf, rx_mode, on);
 }
 
@@ -2624,11 +2624,11 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
 	int ret;
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	if (is_zero_ether_addr(addr)) {
-		PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
 			port_id);
 		return -EINVAL;
 	}
@@ -2640,20 +2640,20 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
 
 	if (index < 0) {
 		if (!on) {
-			PMD_DEBUG_TRACE("port %d: the MAC address was not "
+			RTE_PMD_DEBUG_TRACE("port %d: the MAC address was not "
 				"set in UTA\n", port_id);
 			return -EINVAL;
 		}
 
 		index = get_hash_mac_addr_index(port_id, &null_mac_addr);
 		if (index < 0) {
-			PMD_DEBUG_TRACE("port %d: MAC address array full\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
 					port_id);
 			return -ENOSPC;
 		}
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
 	ret = (*dev->dev_ops->uc_hash_table_set)(dev, addr, on);
 	if (ret == 0) {
 		/* Update address in NIC data structure */
@@ -2673,11 +2673,11 @@ rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
 	return (*dev->dev_ops->uc_all_hash_table_set)(dev, on);
 }
 
@@ -2688,18 +2688,18 @@ rte_eth_dev_set_vf_rx(uint8_t port_id, uint16_t vf, uint8_t on)
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_info dev_info;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs) {
-		PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rx)(dev, vf, on);
 }
 
@@ -2710,18 +2710,18 @@ rte_eth_dev_set_vf_tx(uint8_t port_id, uint16_t vf, uint8_t on)
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_info dev_info;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs) {
-		PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
+		RTE_PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_tx)(dev, vf, on);
 }
 
@@ -2731,22 +2731,22 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
 	if (vlan_id > ETHER_MAX_VLAN_ID) {
-		PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
+		RTE_PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
 			vlan_id);
 		return -EINVAL;
 	}
 
 	if (vf_mask == 0) {
-		PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
+		RTE_PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_vlan_filter)(dev, vlan_id,
 						   vf_mask, vlan_on);
 }
@@ -2758,26 +2758,26 @@ int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_link link;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 	link = dev->data->dev_link;
 
 	if (queue_idx > dev_info.max_tx_queues) {
-		PMD_DEBUG_TRACE("set queue rate limit:port %d: "
+		RTE_PMD_DEBUG_TRACE("set queue rate limit:port %d: "
 				"invalid queue id=%d\n", port_id, queue_idx);
 		return -EINVAL;
 	}
 
 	if (tx_rate > link.link_speed) {
-		PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
+		RTE_PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
 				"bigger than link speed= %d\n",
 			tx_rate, link.link_speed);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
 	return (*dev->dev_ops->set_queue_rate_limit)(dev, queue_idx, tx_rate);
 }
 
@@ -2791,26 +2791,26 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
 	if (q_msk == 0)
 		return 0;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 	link = dev->data->dev_link;
 
 	if (vf > dev_info.max_vfs) {
-		PMD_DEBUG_TRACE("set VF rate limit:port %d: "
+		RTE_PMD_DEBUG_TRACE("set VF rate limit:port %d: "
 				"invalid vf id=%d\n", port_id, vf);
 		return -EINVAL;
 	}
 
 	if (tx_rate > link.link_speed) {
-		PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
+		RTE_PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
 				"bigger than link speed= %d\n",
 				tx_rate, link.link_speed);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rate_limit)(dev, vf, tx_rate, q_msk);
 }
 
@@ -2821,14 +2821,14 @@ rte_eth_mirror_rule_set(uint8_t port_id,
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if (mirror_conf->rule_type == 0) {
-		PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
+		RTE_PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
 		return -EINVAL;
 	}
 
 	if (mirror_conf->dst_pool >= ETH_64_POOLS) {
-		PMD_DEBUG_TRACE("Invalid dst pool, pool id must be 0-%d\n",
+		RTE_PMD_DEBUG_TRACE("Invalid dst pool, pool id must be 0-%d\n",
 				ETH_64_POOLS - 1);
 		return -EINVAL;
 	}
@@ -2836,18 +2836,18 @@ rte_eth_mirror_rule_set(uint8_t port_id,
 	if ((mirror_conf->rule_type & (ETH_MIRROR_VIRTUAL_POOL_UP |
 	     ETH_MIRROR_VIRTUAL_POOL_DOWN)) &&
 	    (mirror_conf->pool_mask == 0)) {
-		PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not be 0.\n");
+		RTE_PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not be 0.\n");
 		return -EINVAL;
 	}
 
 	if ((mirror_conf->rule_type & ETH_MIRROR_VLAN) &&
 	    mirror_conf->vlan.vlan_mask == 0) {
-		PMD_DEBUG_TRACE("Invalid vlan mask, vlan mask can not be 0.\n");
+		RTE_PMD_DEBUG_TRACE("Invalid vlan mask, vlan mask can not be 0.\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
 
 	return (*dev->dev_ops->mirror_rule_set)(dev, mirror_conf, rule_id, on);
 }
@@ -2857,10 +2857,10 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
 
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
@@ -2872,12 +2872,12 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 	if (queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
 		return 0;
 	}
 	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
@@ -2890,13 +2890,13 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 	if (queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
 		return 0;
 	}
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
@@ -2908,10 +2908,10 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
 	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -2920,10 +2920,10 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 	return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id],
 						   offset);
 }
@@ -2940,7 +2940,7 @@ rte_eth_dev_callback_register(uint8_t port_id,
 	if (!cb_fn)
 		return -EINVAL;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
@@ -2980,7 +2980,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,
 	if (!cb_fn)
 		return -EINVAL;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
@@ -3043,14 +3043,14 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 	int rc;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	intr_handle = &dev->pci_dev->intr_handle;
 	if (!intr_handle->intr_vec) {
-		PMD_DEBUG_TRACE("RX Intr vector unset\n");
+		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
 	}
 
@@ -3058,7 +3058,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 		vec = intr_handle->intr_vec[qid];
 		rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
 		if (rc && rc != -EEXIST) {
-			PMD_DEBUG_TRACE("p %u q %u rx ctl error"
+			RTE_PMD_DEBUG_TRACE("p %u q %u rx ctl error"
 					" op %d epfd %d vec %u\n",
 					port_id, qid, op, epfd, vec);
 		}
@@ -3077,26 +3077,26 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
 	int rc;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%u\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%u\n", queue_id);
 		return -EINVAL;
 	}
 
 	intr_handle = &dev->pci_dev->intr_handle;
 	if (!intr_handle->intr_vec) {
-		PMD_DEBUG_TRACE("RX Intr vector unset\n");
+		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
 	}
 
 	vec = intr_handle->intr_vec[queue_id];
 	rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
 	if (rc && rc != -EEXIST) {
-		PMD_DEBUG_TRACE("p %u q %u rx ctl error"
+		RTE_PMD_DEBUG_TRACE("p %u q %u rx ctl error"
 				" op %d epfd %d vec %u\n",
 				port_id, queue_id, op, epfd, vec);
 		return rc;
@@ -3112,13 +3112,13 @@ rte_eth_dev_rx_intr_enable(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_enable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_enable, -ENOTSUP);
 	return (*dev->dev_ops->rx_queue_intr_enable)(dev, queue_id);
 }
 
@@ -3129,13 +3129,13 @@ rte_eth_dev_rx_intr_disable(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_disable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_disable, -ENOTSUP);
 	return (*dev->dev_ops->rx_queue_intr_disable)(dev, queue_id);
 }
 
@@ -3144,10 +3144,10 @@ int rte_eth_dev_bypass_init(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
 	(*dev->dev_ops->bypass_init)(dev);
 	return 0;
 }
@@ -3157,10 +3157,10 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_show)(dev, state);
 	return 0;
 }
@@ -3170,10 +3170,10 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_set)(dev, new_state);
 	return 0;
 }
@@ -3183,10 +3183,10 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_show)(dev, event, state);
 	return 0;
 }
@@ -3196,11 +3196,11 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_set)(dev, event, state);
 	return 0;
 }
@@ -3210,11 +3210,11 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
 	return 0;
 }
@@ -3224,11 +3224,11 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_ver_show)(dev, ver);
 	return 0;
 }
@@ -3238,11 +3238,11 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
 	return 0;
 }
@@ -3252,11 +3252,11 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_reset)(dev);
 	return 0;
 }
@@ -3267,10 +3267,10 @@ rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
 	return (*dev->dev_ops->filter_ctrl)(dev, filter_type,
 				RTE_ETH_FILTER_NOP, NULL);
 }
@@ -3281,10 +3281,10 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
 	return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
 }
 
@@ -3455,10 +3455,10 @@ rte_eth_dev_set_mc_addr_list(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP);
 	return dev->dev_ops->set_mc_addr_list(dev, mc_addr_set, nb_mc_addr);
 }
 
@@ -3467,10 +3467,10 @@ rte_eth_timesync_enable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_enable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_enable, -ENOTSUP);
 	return (*dev->dev_ops->timesync_enable)(dev);
 }
 
@@ -3479,10 +3479,10 @@ rte_eth_timesync_disable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_disable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_disable, -ENOTSUP);
 	return (*dev->dev_ops->timesync_disable)(dev);
 }
 
@@ -3492,10 +3492,10 @@ rte_eth_timesync_read_rx_timestamp(uint8_t port_id, struct timespec *timestamp,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_read_rx_timestamp, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_read_rx_timestamp, -ENOTSUP);
 	return (*dev->dev_ops->timesync_read_rx_timestamp)(dev, timestamp, flags);
 }
 
@@ -3504,10 +3504,10 @@ rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_read_tx_timestamp, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_read_tx_timestamp, -ENOTSUP);
 	return (*dev->dev_ops->timesync_read_tx_timestamp)(dev, timestamp);
 }
 
@@ -3516,10 +3516,10 @@ rte_eth_dev_get_reg_length(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg_length, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_reg_length, -ENOTSUP);
 	return (*dev->dev_ops->get_reg_length)(dev);
 }
 
@@ -3528,10 +3528,10 @@ rte_eth_dev_get_reg_info(uint8_t port_id, struct rte_dev_reg_info *info)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_reg, -ENOTSUP);
 	return (*dev->dev_ops->get_reg)(dev, info);
 }
 
@@ -3540,10 +3540,10 @@ rte_eth_dev_get_eeprom_length(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom_length, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_eeprom_length, -ENOTSUP);
 	return (*dev->dev_ops->get_eeprom_length)(dev);
 }
 
@@ -3552,10 +3552,10 @@ rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_eeprom, -ENOTSUP);
 	return (*dev->dev_ops->get_eeprom)(dev, info);
 }
 
@@ -3564,9 +3564,9 @@ rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
 	return (*dev->dev_ops->set_eeprom)(dev, info);
 }
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v2 2/4] ethdev: move error checking macros to header
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
  2015-09-09 15:09   ` [PATCH v2 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
@ 2015-09-09 15:09   ` Bruce Richardson
  2015-09-09 15:09   ` [PATCH v2 3/4] ethdev: remove duplicated debug functions Bruce Richardson
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-09-09 15:09 UTC (permalink / raw)
  To: 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 <bruce.richardson@intel.com>
---
 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

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v2 3/4] ethdev: remove duplicated debug functions
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
  2015-09-09 15:09   ` [PATCH v2 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
  2015-09-09 15:09   ` [PATCH v2 2/4] ethdev: move error checking macros to header Bruce Richardson
@ 2015-09-09 15:09   ` Bruce Richardson
  2015-09-09 15:09   ` [PATCH v2 4/4] ethdev: check driver support for functions Bruce Richardson
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-09-09 15:09 UTC (permalink / raw)
  To: dev

The functions for rx/tx burst, for rx_queue_count and descriptor_done in
the ethdev library all had two copies of the code. One copy in
rte_ethdev.h was inlined for performance, while a second was in
rte_ethdev.c for debugging purposes only. We can eliminate the second
copy of the functions by moving the additional debug checks into the
copies of the functions in the header file. [Any compilation for
debugging at optimization level 0 will not inline the function so the
result should be same as when the function was in the .c file.]

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 64 -------------------------------------------
 lib/librte_ether/rte_ethdev.h | 59 ++++++++++++++++++++-------------------
 2 files changed, 29 insertions(+), 94 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 01e44c6..4ce59dd 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2827,70 +2827,6 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-uint16_t
-rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_rx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
-						rx_pkts, nb_pkts);
-}
-
-uint16_t
-rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_tx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
-						tx_pkts, nb_pkts);
-}
-
-uint32_t
-rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
-	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
-}
-
-int
-rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
-	return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id],
-						   offset);
-}
-#endif
-
 int
 rte_eth_dev_callback_register(uint8_t port_id,
 			enum rte_eth_event_type event,
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 5501b04..1113ed2 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2567,18 +2567,21 @@ extern int rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on);
  *   of pointers to *rte_mbuf* structures effectively supplied to the
  *   *rx_pkts* array.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 	int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
 			rx_pkts, nb_pkts);
 
@@ -2596,7 +2599,6 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return nb_rx;
 }
-#endif
 
 /**
  * Get the number of used descriptors in a specific queue
@@ -2608,18 +2610,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @return
  *  The number of used descriptors in the specific queue.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint32_t rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id);
-#else
 static inline uint32_t
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
-        struct rte_eth_dev *dev;
-
-        dev = &rte_eth_devices[port_id];
+        struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+#endif
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
-#endif
 
 /**
  * Check if the DD bit of the specific RX descriptor in the queue has been set
@@ -2635,21 +2635,17 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern int rte_eth_rx_descriptor_done(uint8_t port_id,
-				      uint16_t queue_id,
-				      uint16_t offset);
-#else
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
-	struct rte_eth_dev *dev;
-
-	dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+#endif
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-#endif
 
 /**
  * Send a burst of output packets on a transmit queue of an Ethernet device.
@@ -2709,17 +2705,21 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
  *   the transmit ring. The return value can be less than the value of the
  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 
-	dev = &rte_eth_devices[port_id];
+	if (queue_id >= dev->data->nb_tx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 
 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
 	struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
@@ -2735,7 +2735,6 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
 }
-#endif
 
 /**
  * Setup a new signature filter rule on an Ethernet device
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v2 4/4] ethdev: check driver support for functions
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
                     ` (2 preceding siblings ...)
  2015-09-09 15:09   ` [PATCH v2 3/4] ethdev: remove duplicated debug functions Bruce Richardson
@ 2015-09-09 15:09   ` Bruce Richardson
  2015-09-28 10:23   ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
  2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
  5 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-09-09 15:09 UTC (permalink / raw)
  To: dev

The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
supported by very few PMDs. Therefore, it is best to check for support
for the functions in the ethdev library, so as to avoid run-time crashes
at run-time if the application goes to use those APIs. The performance
impact of this change should be very small as this is a predictable
branch in the function.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1113ed2..0759de4 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2608,16 +2608,18 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @param queue_id
  *  The queue id on the specific port.
  * @return
- *  The number of used descriptors in the specific queue.
+ *  The number of used descriptors in the specific queue, or:
+ *     (-EINVAL) if *port_id* is invalid
+ *     (-ENOTSUP) if the device does not support this function
  */
-static inline uint32_t
+static inline int
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 #endif
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -2634,6 +2636,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (1) if the specific DD bit is set.
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
+ *  - (-ENOTSUP) if the device does not support this function
  */
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
@@ -2641,8 +2644,8 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 #endif
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: [PATCH v2 0/4] ethdev: minor cleanup
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
                     ` (3 preceding siblings ...)
  2015-09-09 15:09   ` [PATCH v2 4/4] ethdev: check driver support for functions Bruce Richardson
@ 2015-09-28 10:23   ` Bruce Richardson
  2015-11-03  1:11     ` Thomas Monjalon
  2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
  5 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-09-28 10:23 UTC (permalink / raw)
  To: dev

On Wed, Sep 09, 2015 at 04:09:30PM +0100, Bruce Richardson wrote:
> This patchset performs two cleanups:
> 1. Four functions in ethdev.c which were enabled for debug only have been
>   merged into their inlined header-file counterparts. This change required that
>   a number of macros be renamed and moved to the header file too. The macro changes
>   are in patches 1 & 2, and the elimination of the separate debug fns are in patch 3.
> 2. Checks for valid function pointers are added to the API calls for reading
>   the descriptor ring count, and checking for a valid descriptor. This is because
>   these functions are not implemented by most drivers, and so it's far safer to
>   have the check.
> 
> ---
> 
> V2 Changes:
> * Rebased to latest DPDK codebase
> * Changed type from uint32_t to int for the count function, on the basis of
> feedback received.
> 
> Bruce Richardson (4):
>   ethdev: rename macros to have RTE_ETH prefix
>   ethdev: move error checking macros to header
>   ethdev: remove duplicated debug functions
>   ethdev: check driver support for functions
> 
>  lib/librte_ether/rte_ethdev.c | 674 ++++++++++++++++++------------------------
>  lib/librte_ether/rte_ethdev.h | 121 ++++++--
>  2 files changed, 375 insertions(+), 420 deletions(-)
> 
> -- 

Thomas, all,

Any comments on this set?

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v2 0/4] ethdev: minor cleanup
  2015-09-28 10:23   ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
@ 2015-11-03  1:11     ` Thomas Monjalon
  2015-11-03 10:06       ` Bruce Richardson
  0 siblings, 1 reply; 55+ messages in thread
From: Thomas Monjalon @ 2015-11-03  1:11 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

> > Bruce Richardson (4):
> >   ethdev: rename macros to have RTE_ETH prefix
> >   ethdev: move error checking macros to header
> >   ethdev: remove duplicated debug functions
> >   ethdev: check driver support for functions
> > 
> >  lib/librte_ether/rte_ethdev.c | 674 ++++++++++++++++++------------------------
> >  lib/librte_ether/rte_ethdev.h | 121 ++++++--
> >  2 files changed, 375 insertions(+), 420 deletions(-)
> > 
> 
> Thomas, all,
> 
> Any comments on this set?

Sorry I missed it.
Could you please rebase it on current code?
Thanks

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v2 0/4] ethdev: minor cleanup
  2015-11-03  1:11     ` Thomas Monjalon
@ 2015-11-03 10:06       ` Bruce Richardson
  0 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-03 10:06 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Tue, Nov 03, 2015 at 02:11:24AM +0100, Thomas Monjalon wrote:
> > > Bruce Richardson (4):
> > >   ethdev: rename macros to have RTE_ETH prefix
> > >   ethdev: move error checking macros to header
> > >   ethdev: remove duplicated debug functions
> > >   ethdev: check driver support for functions
> > > 
> > >  lib/librte_ether/rte_ethdev.c | 674 ++++++++++++++++++------------------------
> > >  lib/librte_ether/rte_ethdev.h | 121 ++++++--
> > >  2 files changed, 375 insertions(+), 420 deletions(-)
> > > 
> > 
> > Thomas, all,
> > 
> > Any comments on this set?
> 
> Sorry I missed it.
> Could you please rebase it on current code?
> Thanks

Sure. Will do.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v3 0/4] ethdev: minor cleanup
  2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
                     ` (4 preceding siblings ...)
  2015-09-28 10:23   ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
@ 2015-11-03 12:00   ` Bruce Richardson
  2015-11-03 12:00     ` [PATCH v3 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
                       ` (4 more replies)
  5 siblings, 5 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-03 12:00 UTC (permalink / raw)
  To: dev

This patchset performs two cleanups:
1. Four functions in ethdev.c which were enabled for debug only have been
  merged into their inlined header-file counterparts. This change required that
  a number of macros be renamed and moved to the header file too. The macro changes
  are in patches 1 & 2, and the elimination of the separate debug fns are in patch 3.
2. Checks for valid function pointers are added to the API calls for reading
  the descriptor ring count, and checking for a valid descriptor. This is because
  these functions are not implemented by most drivers, and so it's far safer to
  have the check.

---

V3 Changes:
* Rebased to latest DPDK codebase
* Fixed checkpatch issues in patches 2 and 3.

V2 Changes:
* Rebased to latest DPDK codebase
* Changed type from uint32_t to int for the count function, on the basis of
feedback received.

Bruce Richardson (4):
  ethdev: rename macros to have RTE_ETH prefix
  ethdev: move error checking macros to header
  ethdev: remove duplicated debug functions
  ethdev: check driver support for functions

 lib/librte_ether/rte_ethdev.c | 602 ++++++++++++++++++------------------------
 lib/librte_ether/rte_ethdev.h | 120 ++++++---
 2 files changed, 338 insertions(+), 384 deletions(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v3 1/4] ethdev: rename macros to have RTE_ETH prefix
  2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
@ 2015-11-03 12:00     ` Bruce Richardson
  2015-11-03 12:00     ` [PATCH v3 2/4] ethdev: move error checking macros to header Bruce Richardson
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-03 12:00 UTC (permalink / raw)
  To: dev

The macros to check that the function pointers and port ids are valid
for an ethdev are potentially useful to have in the ethdev.h file.
However, since they would then become externally visible, we apply
the RTE_ETH prefix to them.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 540 +++++++++++++++++++++---------------------
 1 file changed, 270 insertions(+), 270 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 073ffe9..21f213f 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -70,54 +70,54 @@
 #include "rte_ethdev.h"
 
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
-#define PMD_DEBUG_TRACE(fmt, args...) do {                        \
+#define RTE_PMD_DEBUG_TRACE(fmt, args...) do {                        \
 		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args); \
 	} while (0)
 #else
-#define PMD_DEBUG_TRACE(fmt, args...)
+#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) { \
-		PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
+		RTE_PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
 		return (retval); \
 	} \
 } while (0)
 
 #define PROC_PRIMARY_OR_RET() do { \
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) { \
-		PMD_DEBUG_TRACE("Cannot run in secondary processes\n"); \
+		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 FUNC_PTR_OR_ERR_RET(func, retval) do { \
+#define RTE_ETH_FPTR_OR_ERR_RET(func, retval) do { \
 	if ((func) == NULL) { \
-		PMD_DEBUG_TRACE("Function not supported\n"); \
+		RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
 		return (retval); \
 	} \
 } while (0)
 
-#define FUNC_PTR_OR_RET(func) do { \
+#define RTE_ETH_FPTR_OR_RET(func) do { \
 	if ((func) == NULL) { \
-		PMD_DEBUG_TRACE("Function not supported\n"); \
+		RTE_PMD_DEBUG_TRACE("Function not supported\n"); \
 		return; \
 	} \
 } while (0)
 
 /* Macros to check for valid port */
-#define VALID_PORTID_OR_ERR_RET(port_id, retval) do {		\
+#define RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, retval) do {		\
 	if (!rte_eth_dev_is_valid_port(port_id)) {		\
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
 		return retval;					\
 	}							\
 } while (0)
 
-#define VALID_PORTID_OR_RET(port_id) do {			\
+#define RTE_ETH_VALID_PORTID_OR_RET(port_id) do {			\
 	if (!rte_eth_dev_is_valid_port(port_id)) {		\
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); \
 		return;						\
 	}							\
 } while (0)
@@ -244,7 +244,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 
 	port_id = rte_eth_dev_find_free_port();
 	if (port_id == RTE_MAX_ETHPORTS) {
-		PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
+		RTE_PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n");
 		return NULL;
 	}
 
@@ -252,7 +252,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)
 		rte_eth_dev_data_alloc();
 
 	if (rte_eth_dev_allocated(name) != NULL) {
-		PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n",
+		RTE_PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n",
 				name);
 		return NULL;
 	}
@@ -339,7 +339,7 @@ rte_eth_dev_init(struct rte_pci_driver *pci_drv,
 	if (diag == 0)
 		return 0;
 
-	PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
+	RTE_PMD_DEBUG_TRACE("driver %s: eth_dev_init(vendor_id=0x%u device_id=0x%x) failed\n",
 			pci_drv->name,
 			(unsigned) pci_dev->id.vendor_id,
 			(unsigned) pci_dev->id.device_id);
@@ -473,10 +473,10 @@ rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *port_id)
 static int
 rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)
 {
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	if (addr == NULL) {
-		PMD_DEBUG_TRACE("Null pointer is specified\n");
+		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
 		return -EINVAL;
 	}
 
@@ -489,10 +489,10 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 {
 	char *tmp;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	if (name == NULL) {
-		PMD_DEBUG_TRACE("Null pointer is specified\n");
+		RTE_PMD_DEBUG_TRACE("Null pointer is specified\n");
 		return -EINVAL;
 	}
 
@@ -509,7 +509,7 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 	uint32_t drv_flags;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
@@ -727,7 +727,7 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 			return -(ENOMEM);
 		}
 	} else { /* re-configure */
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);
 
 		rxq = dev->data->rx_queues;
 
@@ -760,15 +760,15 @@ rte_eth_dev_rx_queue_start(uint8_t port_id, uint16_t rx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
 
 	return dev->dev_ops->rx_queue_start(dev, rx_queue_id);
 
@@ -783,15 +783,15 @@ rte_eth_dev_rx_queue_stop(uint8_t port_id, uint16_t rx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
 
 	return dev->dev_ops->rx_queue_stop(dev, rx_queue_id);
 
@@ -806,15 +806,15 @@ rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
 
 	return dev->dev_ops->tx_queue_start(dev, tx_queue_id);
 
@@ -829,15 +829,15 @@ rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
 
 	return dev->dev_ops->tx_queue_stop(dev, tx_queue_id);
 
@@ -859,7 +859,7 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 			return -(ENOMEM);
 		}
 	} else { /* re-configure */
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);
 
 		txq = dev->data->tx_queues;
 
@@ -895,17 +895,17 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 			"Number of RX queues requested (%u) is greater than max supported(%d)\n",
 			nb_rx_q, RTE_MAX_QUEUES_PER_PORT);
 		return -EINVAL;
 	}
 
 	if (nb_tx_q > RTE_MAX_QUEUES_PER_PORT) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 			"Number of TX queues requested (%u) is greater than max supported(%d)\n",
 			nb_tx_q, RTE_MAX_QUEUES_PER_PORT);
 		return -EINVAL;
@@ -913,11 +913,11 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
@@ -929,22 +929,22 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 */
 	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
 	if (nb_rx_q > dev_info.max_rx_queues) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
 				port_id, nb_rx_q, dev_info.max_rx_queues);
 		return -EINVAL;
 	}
 	if (nb_rx_q == 0) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_q == 0\n", port_id);
 		return -EINVAL;
 	}
 
 	if (nb_tx_q > dev_info.max_tx_queues) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_queues=%d > %d\n",
 				port_id, nb_tx_q, dev_info.max_tx_queues);
 		return -EINVAL;
 	}
 	if (nb_tx_q == 0) {
-		PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
+		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_tx_q == 0\n", port_id);
 		return -EINVAL;
 	}
 
@@ -959,7 +959,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
 
 		if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
-			PMD_DEBUG_TRACE("driver %s does not support lsc\n",
+			RTE_PMD_DEBUG_TRACE("driver %s does not support lsc\n",
 					pci_drv->name);
 			return -EINVAL;
 		}
@@ -972,14 +972,14 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	if (dev_conf->rxmode.jumbo_frame == 1) {
 		if (dev_conf->rxmode.max_rx_pkt_len >
 		    dev_info.max_rx_pktlen) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
 				" > max valid value %u\n",
 				port_id,
 				(unsigned)dev_conf->rxmode.max_rx_pkt_len,
 				(unsigned)dev_info.max_rx_pktlen);
 			return -EINVAL;
 		} else if (dev_conf->rxmode.max_rx_pkt_len < ETHER_MIN_LEN) {
-			PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
+			RTE_PMD_DEBUG_TRACE("ethdev port_id=%d max_rx_pkt_len %u"
 				" < min valid value %u\n",
 				port_id,
 				(unsigned)dev_conf->rxmode.max_rx_pkt_len,
@@ -999,14 +999,14 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 */
 	diag = rte_eth_dev_rx_queue_config(dev, nb_rx_q);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_rx_queue_config = %d\n",
 				port_id, diag);
 		return diag;
 	}
 
 	diag = rte_eth_dev_tx_queue_config(dev, nb_tx_q);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d rte_eth_dev_tx_queue_config = %d\n",
 				port_id, diag);
 		rte_eth_dev_rx_queue_config(dev, 0);
 		return diag;
@@ -1014,7 +1014,7 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
 	diag = (*dev->dev_ops->dev_configure)(dev);
 	if (diag != 0) {
-		PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
+		RTE_PMD_DEBUG_TRACE("port%d dev_configure = %d\n",
 				port_id, diag);
 		rte_eth_dev_rx_queue_config(dev, 0);
 		rte_eth_dev_tx_queue_config(dev, 0);
@@ -1053,7 +1053,7 @@ rte_eth_dev_config_restore(uint8_t port_id)
 			(dev->data->mac_pool_sel[i] & (1ULL << pool)))
 			(*dev->dev_ops->mac_addr_add)(dev, &addr, i, pool);
 		else {
-			PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array not supported\n",
 					port_id);
 			/* exit the loop but not return an error */
 			break;
@@ -1083,14 +1083,14 @@ rte_eth_dev_start(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
 
 	if (dev->data->dev_started != 0) {
-		PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+		RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
 			" already started\n",
 			port_id);
 		return 0;
@@ -1105,7 +1105,7 @@ rte_eth_dev_start(uint8_t port_id)
 	rte_eth_dev_config_restore(port_id);
 
 	if (dev->data->dev_conf.intr_conf.lsc != 0) {
-		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
+		RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
 		(*dev->dev_ops->link_update)(dev, 0);
 	}
 	return 0;
@@ -1120,13 +1120,13 @@ rte_eth_dev_stop(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_RET();
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_stop);
 
 	if (dev->data->dev_started == 0) {
-		PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
+		RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu8
 			" already stopped\n",
 			port_id);
 		return;
@@ -1145,11 +1145,11 @@ rte_eth_dev_set_link_up(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_up, -ENOTSUP);
 	return (*dev->dev_ops->dev_set_link_up)(dev);
 }
 
@@ -1162,11 +1162,11 @@ rte_eth_dev_set_link_down(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_set_link_down, -ENOTSUP);
 	return (*dev->dev_ops->dev_set_link_down)(dev);
 }
 
@@ -1179,10 +1179,10 @@ rte_eth_dev_close(uint8_t port_id)
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_RET();
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_close);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_close);
 	dev->data->dev_started = 0;
 	(*dev->dev_ops->dev_close)(dev);
 
@@ -1207,22 +1207,22 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", rx_queue_id);
 		return -EINVAL;
 	}
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP);
 
 	/*
 	 * Check the size of the mbuf data buffer.
@@ -1231,7 +1231,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	 */
 	rte_eth_dev_info_get(port_id, &dev_info);
 	if (mp->private_data_size < sizeof(struct rte_pktmbuf_pool_private)) {
-		PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
+		RTE_PMD_DEBUG_TRACE("%s private_data_size %d < %d\n",
 				mp->name, (int) mp->private_data_size,
 				(int) sizeof(struct rte_pktmbuf_pool_private));
 		return -ENOSPC;
@@ -1239,7 +1239,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 	mbp_buf_size = rte_pktmbuf_data_room_size(mp);
 
 	if ((mbp_buf_size - RTE_PKTMBUF_HEADROOM) < dev_info.min_rx_bufsize) {
-		PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
+		RTE_PMD_DEBUG_TRACE("%s mbuf_data_room_size %d < %d "
 				"(RTE_PKTMBUF_HEADROOM=%d + min_rx_bufsize(dev)"
 				"=%d)\n",
 				mp->name,
@@ -1255,7 +1255,7 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id,
 			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
 			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
 
-		PMD_DEBUG_TRACE("Invalid value for nb_rx_desc(=%hu), "
+		RTE_PMD_DEBUG_TRACE("Invalid value for nb_rx_desc(=%hu), "
 			"should be: <= %hu, = %hu, and a product of %hu\n",
 			nb_rx_desc,
 			dev_info.rx_desc_lim.nb_max,
@@ -1290,22 +1290,22 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id,
 	 * in a multi-process setup*/
 	PROC_PRIMARY_OR_ERR_RET(-E_RTE_SECONDARY);
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	if (tx_queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id);
 		return -EINVAL;
 	}
 
 	if (dev->data->dev_started) {
-		PMD_DEBUG_TRACE(
+		RTE_PMD_DEBUG_TRACE(
 		    "port %d must be stopped to allow configuration\n", port_id);
 		return -EBUSY;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->tx_queue_setup, -ENOTSUP);
 
 	rte_eth_dev_info_get(port_id, &dev_info);
 
@@ -1321,10 +1321,10 @@ rte_eth_promiscuous_enable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_enable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->promiscuous_enable);
 	(*dev->dev_ops->promiscuous_enable)(dev);
 	dev->data->promiscuous = 1;
 }
@@ -1334,10 +1334,10 @@ rte_eth_promiscuous_disable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->promiscuous_disable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->promiscuous_disable);
 	dev->data->promiscuous = 0;
 	(*dev->dev_ops->promiscuous_disable)(dev);
 }
@@ -1347,7 +1347,7 @@ rte_eth_promiscuous_get(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	return dev->data->promiscuous;
@@ -1358,10 +1358,10 @@ rte_eth_allmulticast_enable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_enable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->allmulticast_enable);
 	(*dev->dev_ops->allmulticast_enable)(dev);
 	dev->data->all_multicast = 1;
 }
@@ -1371,10 +1371,10 @@ rte_eth_allmulticast_disable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->allmulticast_disable);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->allmulticast_disable);
 	dev->data->all_multicast = 0;
 	(*dev->dev_ops->allmulticast_disable)(dev);
 }
@@ -1384,7 +1384,7 @@ rte_eth_allmulticast_get(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	return dev->data->all_multicast;
@@ -1409,13 +1409,13 @@ rte_eth_link_get(uint8_t port_id, struct rte_eth_link *eth_link)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		rte_eth_dev_atomic_read_link_status(dev, eth_link);
 	else {
-		FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_ETH_FPTR_OR_RET(*dev->dev_ops->link_update);
 		(*dev->dev_ops->link_update)(dev, 1);
 		*eth_link = dev->data->dev_link;
 	}
@@ -1426,13 +1426,13 @@ rte_eth_link_get_nowait(uint8_t port_id, struct rte_eth_link *eth_link)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.intr_conf.lsc != 0)
 		rte_eth_dev_atomic_read_link_status(dev, eth_link);
 	else {
-		FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
+		RTE_ETH_FPTR_OR_RET(*dev->dev_ops->link_update);
 		(*dev->dev_ops->link_update)(dev, 0);
 		*eth_link = dev->data->dev_link;
 	}
@@ -1443,12 +1443,12 @@ rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	memset(stats, 0, sizeof(*stats));
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP);
+	RTE_ETH_FPTR_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;
@@ -1459,10 +1459,10 @@ rte_eth_stats_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->stats_reset);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->stats_reset);
 	(*dev->dev_ops->stats_reset)(dev);
 }
 
@@ -1477,7 +1477,7 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats,
 	signed xcount = 0;
 	uint64_t val, *stats_ptr;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 
@@ -1557,7 +1557,7 @@ rte_eth_xstats_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	/* implemented by the driver */
@@ -1576,11 +1576,11 @@ set_queue_stats_mapping(uint8_t port_id, uint16_t queue_id, uint8_t stat_idx,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->queue_stats_mapping_set, -ENOTSUP);
 	return (*dev->dev_ops->queue_stats_mapping_set)
 			(dev, queue_id, stat_idx, is_rx);
 }
@@ -1614,14 +1614,14 @@ rte_eth_dev_info_get(uint8_t port_id, struct rte_eth_dev_info *dev_info)
 		.nb_align = 1,
 	};
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
 	memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
 	dev_info->rx_desc_lim = lim;
 	dev_info->tx_desc_lim = lim;
 
-	FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
+	RTE_ETH_FPTR_OR_RET(*dev->dev_ops->dev_infos_get);
 	(*dev->dev_ops->dev_infos_get)(dev, dev_info);
 	dev_info->pci_dev = dev->pci_dev;
 	if (dev->driver)
@@ -1633,7 +1633,7 @@ rte_eth_macaddr_get(uint8_t port_id, struct ether_addr *mac_addr)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_RET(port_id);
+	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 	ether_addr_copy(&dev->data->mac_addrs[0], mac_addr);
 }
@@ -1644,7 +1644,7 @@ rte_eth_dev_get_mtu(uint8_t port_id, uint16_t *mtu)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	*mtu = dev->data->mtu;
@@ -1657,9 +1657,9 @@ rte_eth_dev_set_mtu(uint8_t port_id, uint16_t mtu)
 	int ret;
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mtu_set, -ENOTSUP);
 
 	ret = (*dev->dev_ops->mtu_set)(dev, mtu);
 	if (!ret)
@@ -1673,19 +1673,19 @@ rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	if (!(dev->data->dev_conf.rxmode.hw_vlan_filter)) {
-		PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: vlan-filtering disabled\n", port_id);
 		return -ENOSYS;
 	}
 
 	if (vlan_id > 4095) {
-		PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
+		RTE_PMD_DEBUG_TRACE("(port_id=%d) invalid vlan_id=%u > 4095\n",
 				port_id, (unsigned) vlan_id);
 		return -EINVAL;
 	}
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_filter_set, -ENOTSUP);
 
 	return (*dev->dev_ops->vlan_filter_set)(dev, vlan_id, on);
 }
@@ -1695,14 +1695,14 @@ rte_eth_dev_set_vlan_strip_on_queue(uint8_t port_id, uint16_t rx_queue_id, int o
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	if (rx_queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid rx_queue_id=%d\n", port_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_strip_queue_set)(dev, rx_queue_id, on);
 
 	return 0;
@@ -1713,9 +1713,9 @@ rte_eth_dev_set_vlan_ether_type(uint8_t port_id, uint16_t tpid)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_tpid_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_tpid_set)(dev, tpid);
 
 	return 0;
@@ -1729,7 +1729,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
 	int mask = 0;
 	int cur, org = 0;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	/*check which option changed by application*/
@@ -1758,7 +1758,7 @@ rte_eth_dev_set_vlan_offload(uint8_t port_id, int offload_mask)
 	if (mask == 0)
 		return ret;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_offload_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_offload_set)(dev, mask);
 
 	return ret;
@@ -1770,7 +1770,7 @@ rte_eth_dev_get_vlan_offload(uint8_t port_id)
 	struct rte_eth_dev *dev;
 	int ret = 0;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (dev->data->dev_conf.rxmode.hw_vlan_strip)
@@ -1790,9 +1790,9 @@ rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->vlan_pvid_set, -ENOTSUP);
 	(*dev->dev_ops->vlan_pvid_set)(dev, pvid, on);
 
 	return 0;
@@ -1803,9 +1803,9 @@ rte_eth_dev_flow_ctrl_get(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_get, -ENOTSUP);
 	memset(fc_conf, 0, sizeof(*fc_conf));
 	return (*dev->dev_ops->flow_ctrl_get)(dev, fc_conf);
 }
@@ -1815,14 +1815,14 @@ rte_eth_dev_flow_ctrl_set(uint8_t port_id, struct rte_eth_fc_conf *fc_conf)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if ((fc_conf->send_xon != 0) && (fc_conf->send_xon != 1)) {
-		PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
+		RTE_PMD_DEBUG_TRACE("Invalid send_xon, only 0/1 allowed\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->flow_ctrl_set, -ENOTSUP);
 	return (*dev->dev_ops->flow_ctrl_set)(dev, fc_conf);
 }
 
@@ -1831,9 +1831,9 @@ rte_eth_dev_priority_flow_ctrl_set(uint8_t port_id, struct rte_eth_pfc_conf *pfc
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if (pfc_conf->priority > (ETH_DCB_NUM_USER_PRIORITIES - 1)) {
-		PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
+		RTE_PMD_DEBUG_TRACE("Invalid priority, only 0-7 allowed\n");
 		return -EINVAL;
 	}
 
@@ -1854,7 +1854,7 @@ rte_eth_check_reta_mask(struct rte_eth_rss_reta_entry64 *reta_conf,
 		return -EINVAL;
 
 	if (reta_size != RTE_ALIGN(reta_size, RTE_RETA_GROUP_SIZE)) {
-		PMD_DEBUG_TRACE("Invalid reta size, should be %u aligned\n",
+		RTE_PMD_DEBUG_TRACE("Invalid reta size, should be %u aligned\n",
 							RTE_RETA_GROUP_SIZE);
 		return -EINVAL;
 	}
@@ -1879,7 +1879,7 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
 		return -EINVAL;
 
 	if (max_rxq == 0) {
-		PMD_DEBUG_TRACE("No receive queue is available\n");
+		RTE_PMD_DEBUG_TRACE("No receive queue is available\n");
 		return -EINVAL;
 	}
 
@@ -1888,7 +1888,7 @@ rte_eth_check_reta_entry(struct rte_eth_rss_reta_entry64 *reta_conf,
 		shift = i % RTE_RETA_GROUP_SIZE;
 		if ((reta_conf[idx].mask & (1ULL << shift)) &&
 			(reta_conf[idx].reta[shift] >= max_rxq)) {
-			PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
+			RTE_PMD_DEBUG_TRACE("reta_conf[%u]->reta[%u]: %u exceeds "
 				"the maximum rxq index: %u\n", idx, shift,
 				reta_conf[idx].reta[shift], max_rxq);
 			return -EINVAL;
@@ -1906,7 +1906,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,
 	struct rte_eth_dev *dev;
 	int ret;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	/* Check mask bits */
 	ret = rte_eth_check_reta_mask(reta_conf, reta_size);
 	if (ret < 0)
@@ -1920,7 +1920,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id,
 	if (ret < 0)
 		return ret;
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->reta_update, -ENOTSUP);
 	return (*dev->dev_ops->reta_update)(dev, reta_conf, reta_size);
 }
 
@@ -1933,7 +1933,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id,
 	int ret;
 
 	if (port_id >= nb_ports) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
@@ -1943,7 +1943,7 @@ rte_eth_dev_rss_reta_query(uint8_t port_id,
 		return ret;
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->reta_query, -ENOTSUP);
 	return (*dev->dev_ops->reta_query)(dev, reta_conf, reta_size);
 }
 
@@ -1953,16 +1953,16 @@ rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf)
 	struct rte_eth_dev *dev;
 	uint16_t rss_hash_protos;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	rss_hash_protos = rss_conf->rss_hf;
 	if ((rss_hash_protos != 0) &&
 	    ((rss_hash_protos & ETH_RSS_PROTO_MASK) == 0)) {
-		PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
+		RTE_PMD_DEBUG_TRACE("Invalid rss_hash_protos=0x%x\n",
 				rss_hash_protos);
 		return -EINVAL;
 	}
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rss_hash_update, -ENOTSUP);
 	return (*dev->dev_ops->rss_hash_update)(dev, rss_conf);
 }
 
@@ -1972,9 +1972,9 @@ rte_eth_dev_rss_hash_conf_get(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
 	return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf);
 }
 
@@ -1984,19 +1984,19 @@ rte_eth_dev_udp_tunnel_add(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if (udp_tunnel == NULL) {
-		PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+		RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
 		return -EINVAL;
 	}
 
 	if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-		PMD_DEBUG_TRACE("Invalid tunnel type\n");
+		RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_add, -ENOTSUP);
 	return (*dev->dev_ops->udp_tunnel_add)(dev, udp_tunnel);
 }
 
@@ -2006,20 +2006,20 @@ rte_eth_dev_udp_tunnel_delete(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
 	if (udp_tunnel == NULL) {
-		PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
+		RTE_PMD_DEBUG_TRACE("Invalid udp_tunnel parameter\n");
 		return -EINVAL;
 	}
 
 	if (udp_tunnel->prot_type >= RTE_TUNNEL_TYPE_MAX) {
-		PMD_DEBUG_TRACE("Invalid tunnel type\n");
+		RTE_PMD_DEBUG_TRACE("Invalid tunnel type\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->udp_tunnel_del, -ENOTSUP);
 	return (*dev->dev_ops->udp_tunnel_del)(dev, udp_tunnel);
 }
 
@@ -2028,9 +2028,9 @@ rte_eth_led_on(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_led_on, -ENOTSUP);
 	return (*dev->dev_ops->dev_led_on)(dev);
 }
 
@@ -2039,9 +2039,9 @@ rte_eth_led_off(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->dev_led_off, -ENOTSUP);
 	return (*dev->dev_ops->dev_led_off)(dev);
 }
 
@@ -2075,17 +2075,17 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
 	int index;
 	uint64_t pool_mask;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP);
 
 	if (is_zero_ether_addr(addr)) {
-		PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
 			port_id);
 		return -EINVAL;
 	}
 	if (pool >= ETH_64_POOLS) {
-		PMD_DEBUG_TRACE("pool id must be 0-%d\n", ETH_64_POOLS - 1);
+		RTE_PMD_DEBUG_TRACE("pool id must be 0-%d\n", ETH_64_POOLS - 1);
 		return -EINVAL;
 	}
 
@@ -2093,7 +2093,7 @@ rte_eth_dev_mac_addr_add(uint8_t port_id, struct ether_addr *addr,
 	if (index < 0) {
 		index = get_mac_addr_index(port_id, &null_mac_addr);
 		if (index < 0) {
-			PMD_DEBUG_TRACE("port %d: MAC address array full\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
 				port_id);
 			return -ENOSPC;
 		}
@@ -2123,13 +2123,13 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
 	struct rte_eth_dev *dev;
 	int index;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_remove, -ENOTSUP);
 
 	index = get_mac_addr_index(port_id, addr);
 	if (index == 0) {
-		PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot remove default MAC address\n", port_id);
 		return -EADDRINUSE;
 	} else if (index < 0)
 		return 0;  /* Do nothing if address wasn't found */
@@ -2151,13 +2151,13 @@ rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	if (!is_valid_assigned_ether_addr(addr))
 		return -EINVAL;
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
 
 	/* Update default address in NIC data structure */
 	ether_addr_copy(addr, &dev->data->mac_addrs[0]);
@@ -2175,22 +2175,22 @@ rte_eth_dev_set_vf_rxmode(uint8_t port_id,  uint16_t vf,
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_info dev_info;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs) {
-		PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
+		RTE_PMD_DEBUG_TRACE("set VF RX mode:invalid VF id %d\n", vf);
 		return -EINVAL;
 	}
 
 	if (rx_mode == 0) {
-		PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
+		RTE_PMD_DEBUG_TRACE("set VF RX mode:mode mask ca not be zero\n");
 		return -EINVAL;
 	}
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx_mode, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rx_mode)(dev, vf, rx_mode, on);
 }
 
@@ -2225,11 +2225,11 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
 	int ret;
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	if (is_zero_ether_addr(addr)) {
-		PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
+		RTE_PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n",
 			port_id);
 		return -EINVAL;
 	}
@@ -2241,20 +2241,20 @@ rte_eth_dev_uc_hash_table_set(uint8_t port_id, struct ether_addr *addr,
 
 	if (index < 0) {
 		if (!on) {
-			PMD_DEBUG_TRACE("port %d: the MAC address was not "
+			RTE_PMD_DEBUG_TRACE("port %d: the MAC address was not "
 				"set in UTA\n", port_id);
 			return -EINVAL;
 		}
 
 		index = get_hash_mac_addr_index(port_id, &null_mac_addr);
 		if (index < 0) {
-			PMD_DEBUG_TRACE("port %d: MAC address array full\n",
+			RTE_PMD_DEBUG_TRACE("port %d: MAC address array full\n",
 					port_id);
 			return -ENOSPC;
 		}
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->uc_hash_table_set, -ENOTSUP);
 	ret = (*dev->dev_ops->uc_hash_table_set)(dev, addr, on);
 	if (ret == 0) {
 		/* Update address in NIC data structure */
@@ -2274,11 +2274,11 @@ rte_eth_dev_uc_all_hash_table_set(uint8_t port_id, uint8_t on)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->uc_all_hash_table_set, -ENOTSUP);
 	return (*dev->dev_ops->uc_all_hash_table_set)(dev, on);
 }
 
@@ -2289,18 +2289,18 @@ rte_eth_dev_set_vf_rx(uint8_t port_id, uint16_t vf, uint8_t on)
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_info dev_info;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs) {
-		PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
+		RTE_PMD_DEBUG_TRACE("port %d: invalid vf id\n", port_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rx, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rx)(dev, vf, on);
 }
 
@@ -2311,18 +2311,18 @@ rte_eth_dev_set_vf_tx(uint8_t port_id, uint16_t vf, uint8_t on)
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev_info dev_info;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	num_vfs = dev_info.max_vfs;
 	if (vf > num_vfs) {
-		PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
+		RTE_PMD_DEBUG_TRACE("set pool tx:invalid pool id=%d\n", vf);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_tx, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_tx)(dev, vf, on);
 }
 
@@ -2332,22 +2332,22 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
 	if (vlan_id > ETHER_MAX_VLAN_ID) {
-		PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
+		RTE_PMD_DEBUG_TRACE("VF VLAN filter:invalid VLAN id=%d\n",
 			vlan_id);
 		return -EINVAL;
 	}
 
 	if (vf_mask == 0) {
-		PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
+		RTE_PMD_DEBUG_TRACE("VF VLAN filter:pool_mask can not be 0\n");
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_vlan_filter, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_vlan_filter)(dev, vlan_id,
 						   vf_mask, vlan_on);
 }
@@ -2359,26 +2359,26 @@ int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
 	struct rte_eth_dev_info dev_info;
 	struct rte_eth_link link;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 	link = dev->data->dev_link;
 
 	if (queue_idx > dev_info.max_tx_queues) {
-		PMD_DEBUG_TRACE("set queue rate limit:port %d: "
+		RTE_PMD_DEBUG_TRACE("set queue rate limit:port %d: "
 				"invalid queue id=%d\n", port_id, queue_idx);
 		return -EINVAL;
 	}
 
 	if (tx_rate > link.link_speed) {
-		PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
+		RTE_PMD_DEBUG_TRACE("set queue rate limit:invalid tx_rate=%d, "
 				"bigger than link speed= %d\n",
 			tx_rate, link.link_speed);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_queue_rate_limit, -ENOTSUP);
 	return (*dev->dev_ops->set_queue_rate_limit)(dev, queue_idx, tx_rate);
 }
 
@@ -2392,26 +2392,26 @@ int rte_eth_set_vf_rate_limit(uint8_t port_id, uint16_t vf, uint16_t tx_rate,
 	if (q_msk == 0)
 		return 0;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 	rte_eth_dev_info_get(port_id, &dev_info);
 	link = dev->data->dev_link;
 
 	if (vf > dev_info.max_vfs) {
-		PMD_DEBUG_TRACE("set VF rate limit:port %d: "
+		RTE_PMD_DEBUG_TRACE("set VF rate limit:port %d: "
 				"invalid vf id=%d\n", port_id, vf);
 		return -EINVAL;
 	}
 
 	if (tx_rate > link.link_speed) {
-		PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
+		RTE_PMD_DEBUG_TRACE("set VF rate limit:invalid tx_rate=%d, "
 				"bigger than link speed= %d\n",
 				tx_rate, link.link_speed);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_vf_rate_limit, -ENOTSUP);
 	return (*dev->dev_ops->set_vf_rate_limit)(dev, vf, tx_rate, q_msk);
 }
 
@@ -2422,14 +2422,14 @@ rte_eth_mirror_rule_set(uint8_t port_id,
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	if (mirror_conf->rule_type == 0) {
-		PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
+		RTE_PMD_DEBUG_TRACE("mirror rule type can not be 0.\n");
 		return -EINVAL;
 	}
 
 	if (mirror_conf->dst_pool >= ETH_64_POOLS) {
-		PMD_DEBUG_TRACE("Invalid dst pool, pool id must be 0-%d\n",
+		RTE_PMD_DEBUG_TRACE("Invalid dst pool, pool id must be 0-%d\n",
 				ETH_64_POOLS - 1);
 		return -EINVAL;
 	}
@@ -2437,18 +2437,18 @@ rte_eth_mirror_rule_set(uint8_t port_id,
 	if ((mirror_conf->rule_type & (ETH_MIRROR_VIRTUAL_POOL_UP |
 	     ETH_MIRROR_VIRTUAL_POOL_DOWN)) &&
 	    (mirror_conf->pool_mask == 0)) {
-		PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not be 0.\n");
+		RTE_PMD_DEBUG_TRACE("Invalid mirror pool, pool mask can not be 0.\n");
 		return -EINVAL;
 	}
 
 	if ((mirror_conf->rule_type & ETH_MIRROR_VLAN) &&
 	    mirror_conf->vlan.vlan_mask == 0) {
-		PMD_DEBUG_TRACE("Invalid vlan mask, vlan mask can not be 0.\n");
+		RTE_PMD_DEBUG_TRACE("Invalid vlan mask, vlan mask can not be 0.\n");
 		return -EINVAL;
 	}
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_set, -ENOTSUP);
 
 	return (*dev->dev_ops->mirror_rule_set)(dev, mirror_conf, rule_id, on);
 }
@@ -2458,10 +2458,10 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->mirror_rule_reset, -ENOTSUP);
 
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
@@ -2473,12 +2473,12 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 	if (queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
 		return 0;
 	}
 	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
@@ -2491,13 +2491,13 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 	if (queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
 		return 0;
 	}
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
@@ -2509,10 +2509,10 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
 	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -2521,10 +2521,10 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 	return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id],
 						   offset);
 }
@@ -2541,7 +2541,7 @@ rte_eth_dev_callback_register(uint8_t port_id,
 	if (!cb_fn)
 		return -EINVAL;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
@@ -2581,7 +2581,7 @@ rte_eth_dev_callback_unregister(uint8_t port_id,
 	if (!cb_fn)
 		return -EINVAL;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	dev = &rte_eth_devices[port_id];
 	rte_spinlock_lock(&rte_eth_dev_cb_lock);
@@ -2644,14 +2644,14 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 	int rc;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	intr_handle = &dev->pci_dev->intr_handle;
 	if (!intr_handle->intr_vec) {
-		PMD_DEBUG_TRACE("RX Intr vector unset\n");
+		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
 	}
 
@@ -2659,7 +2659,7 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data)
 		vec = intr_handle->intr_vec[qid];
 		rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
 		if (rc && rc != -EEXIST) {
-			PMD_DEBUG_TRACE("p %u q %u rx ctl error"
+			RTE_PMD_DEBUG_TRACE("p %u q %u rx ctl error"
 					" op %d epfd %d vec %u\n",
 					port_id, qid, op, epfd, vec);
 		}
@@ -2678,26 +2678,26 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id,
 	int rc;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%u\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	if (queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%u\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%u\n", queue_id);
 		return -EINVAL;
 	}
 
 	intr_handle = &dev->pci_dev->intr_handle;
 	if (!intr_handle->intr_vec) {
-		PMD_DEBUG_TRACE("RX Intr vector unset\n");
+		RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n");
 		return -EPERM;
 	}
 
 	vec = intr_handle->intr_vec[queue_id];
 	rc = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
 	if (rc && rc != -EEXIST) {
-		PMD_DEBUG_TRACE("p %u q %u rx ctl error"
+		RTE_PMD_DEBUG_TRACE("p %u q %u rx ctl error"
 				" op %d epfd %d vec %u\n",
 				port_id, queue_id, op, epfd, vec);
 		return rc;
@@ -2713,13 +2713,13 @@ rte_eth_dev_rx_intr_enable(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_enable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_enable, -ENOTSUP);
 	return (*dev->dev_ops->rx_queue_intr_enable)(dev, queue_id);
 }
 
@@ -2730,13 +2730,13 @@ rte_eth_dev_rx_intr_disable(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_disable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_intr_disable, -ENOTSUP);
 	return (*dev->dev_ops->rx_queue_intr_disable)(dev, queue_id);
 }
 
@@ -2745,10 +2745,10 @@ int rte_eth_dev_bypass_init(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP);
 	(*dev->dev_ops->bypass_init)(dev);
 	return 0;
 }
@@ -2758,10 +2758,10 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_show)(dev, state);
 	return 0;
 }
@@ -2771,10 +2771,10 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_state_set)(dev, new_state);
 	return 0;
 }
@@ -2784,10 +2784,10 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_show)(dev, event, state);
 	return 0;
 }
@@ -2797,11 +2797,11 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_event_set)(dev, event, state);
 	return 0;
 }
@@ -2811,11 +2811,11 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout);
 	return 0;
 }
@@ -2825,11 +2825,11 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_ver_show)(dev, ver);
 	return 0;
 }
@@ -2839,11 +2839,11 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout);
 	return 0;
 }
@@ -2853,11 +2853,11 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP);
 	(*dev->dev_ops->bypass_wd_reset)(dev);
 	return 0;
 }
@@ -2868,10 +2868,10 @@ rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_type)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
 	return (*dev->dev_ops->filter_ctrl)(dev, filter_type,
 				RTE_ETH_FILTER_NOP, NULL);
 }
@@ -2882,10 +2882,10 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);
 	return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
 }
 
@@ -3055,18 +3055,18 @@ rte_eth_rx_queue_info_get(uint8_t port_id, uint16_t queue_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	if (qinfo == NULL)
 		return -EINVAL;
 
 	dev = &rte_eth_devices[port_id];
 	if (queue_id >= dev->data->nb_rx_queues) {
-		PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rxq_info_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rxq_info_get, -ENOTSUP);
 
 	memset(qinfo, 0, sizeof(*qinfo));
 	dev->dev_ops->rxq_info_get(dev, queue_id, qinfo);
@@ -3079,18 +3079,18 @@ rte_eth_tx_queue_info_get(uint8_t port_id, uint16_t queue_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	if (qinfo == NULL)
 		return -EINVAL;
 
 	dev = &rte_eth_devices[port_id];
 	if (queue_id >= dev->data->nb_tx_queues) {
-		PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
 		return -EINVAL;
 	}
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->txq_info_get, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->txq_info_get, -ENOTSUP);
 
 	memset(qinfo, 0, sizeof(*qinfo));
 	dev->dev_ops->txq_info_get(dev, queue_id, qinfo);
@@ -3104,10 +3104,10 @@ rte_eth_dev_set_mc_addr_list(uint8_t port_id,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_mc_addr_list, -ENOTSUP);
 	return dev->dev_ops->set_mc_addr_list(dev, mc_addr_set, nb_mc_addr);
 }
 
@@ -3116,10 +3116,10 @@ rte_eth_timesync_enable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_enable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_enable, -ENOTSUP);
 	return (*dev->dev_ops->timesync_enable)(dev);
 }
 
@@ -3128,10 +3128,10 @@ rte_eth_timesync_disable(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_disable, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_disable, -ENOTSUP);
 	return (*dev->dev_ops->timesync_disable)(dev);
 }
 
@@ -3141,10 +3141,10 @@ rte_eth_timesync_read_rx_timestamp(uint8_t port_id, struct timespec *timestamp,
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_read_rx_timestamp, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_read_rx_timestamp, -ENOTSUP);
 	return (*dev->dev_ops->timesync_read_rx_timestamp)(dev, timestamp, flags);
 }
 
@@ -3153,10 +3153,10 @@ rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->timesync_read_tx_timestamp, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->timesync_read_tx_timestamp, -ENOTSUP);
 	return (*dev->dev_ops->timesync_read_tx_timestamp)(dev, timestamp);
 }
 
@@ -3165,10 +3165,10 @@ rte_eth_dev_get_reg_length(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg_length, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_reg_length, -ENOTSUP);
 	return (*dev->dev_ops->get_reg_length)(dev);
 }
 
@@ -3177,10 +3177,10 @@ rte_eth_dev_get_reg_info(uint8_t port_id, struct rte_dev_reg_info *info)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_reg, -ENOTSUP);
 	return (*dev->dev_ops->get_reg)(dev, info);
 }
 
@@ -3189,10 +3189,10 @@ rte_eth_dev_get_eeprom_length(uint8_t port_id)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom_length, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_eeprom_length, -ENOTSUP);
 	return (*dev->dev_ops->get_eeprom_length)(dev);
 }
 
@@ -3201,10 +3201,10 @@ rte_eth_dev_get_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_eeprom, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_eeprom, -ENOTSUP);
 	return (*dev->dev_ops->get_eeprom)(dev, info);
 }
 
@@ -3213,10 +3213,10 @@ rte_eth_dev_set_eeprom(uint8_t port_id, struct rte_dev_eeprom_info *info)
 {
 	struct rte_eth_dev *dev;
 
-	VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 
 	dev = &rte_eth_devices[port_id];
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
 	return (*dev->dev_ops->set_eeprom)(dev, info);
 }
 
@@ -3227,13 +3227,13 @@ rte_eth_dev_get_dcb_info(uint8_t port_id,
 	struct rte_eth_dev *dev;
 
 	if (!rte_eth_dev_is_valid_port(port_id)) {
-		PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+		RTE_PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
 		return -ENODEV;
 	}
 
 	dev = &rte_eth_devices[port_id];
 	memset(dcb_info, 0, sizeof(struct rte_eth_dcb_info));
 
-	FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_dcb_info, -ENOTSUP);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->get_dcb_info, -ENOTSUP);
 	return (*dev->dev_ops->get_dcb_info)(dev, dcb_info);
 }
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
  2015-11-03 12:00     ` [PATCH v3 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
@ 2015-11-03 12:00     ` Bruce Richardson
  2015-11-04  1:19       ` Thomas Monjalon
  2015-11-03 12:00     ` [PATCH v3 3/4] ethdev: remove duplicated debug functions Bruce Richardson
                       ` (2 subsequent siblings)
  4 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-03 12:00 UTC (permalink / raw)
  To: 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 <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 38 ------------------------------
 lib/librte_ether/rte_ethdev.h | 54 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 38 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 21f213f..f95c4d2 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 7cf4af8..334fc7b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -925,6 +925,60 @@ 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...) \
+		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
+#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

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v3 3/4] ethdev: remove duplicated debug functions
  2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
  2015-11-03 12:00     ` [PATCH v3 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
  2015-11-03 12:00     ` [PATCH v3 2/4] ethdev: move error checking macros to header Bruce Richardson
@ 2015-11-03 12:00     ` Bruce Richardson
  2015-11-03 12:00     ` [PATCH v3 4/4] ethdev: check driver support for functions Bruce Richardson
  2015-11-17 12:21     ` [PATCH v4 0/2] ethdev: debug code cleanup Bruce Richardson
  4 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-03 12:00 UTC (permalink / raw)
  To: dev

The functions for rx/tx burst, for rx_queue_count and descriptor_done in
the ethdev library all had two copies of the code. One copy in
rte_ethdev.h was inlined for performance, while a second was in
rte_ethdev.c for debugging purposes only. We can eliminate the second
copy of the functions by moving the additional debug checks into the
copies of the functions in the header file. [Any compilation for
debugging at optimization level 0 will not inline the function so the
result should be same as when the function was in the .c file.]

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 64 -------------------------------------------
 lib/librte_ether/rte_ethdev.h | 59 ++++++++++++++++++++-------------------
 2 files changed, 29 insertions(+), 94 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f95c4d2..f884813 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2428,70 +2428,6 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-uint16_t
-rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_rx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
-						rx_pkts, nb_pkts);
-}
-
-uint16_t
-rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_tx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
-						tx_pkts, nb_pkts);
-}
-
-uint32_t
-rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
-	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
-}
-
-int
-rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
-	return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id],
-						   offset);
-}
-#endif
-
 int
 rte_eth_dev_callback_register(uint8_t port_id,
 			enum rte_eth_event_type event,
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 334fc7b..2b702c6 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2484,18 +2484,21 @@ extern int rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on);
  *   of pointers to *rte_mbuf* structures effectively supplied to the
  *   *rx_pkts* array.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 	int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
 			rx_pkts, nb_pkts);
 
@@ -2513,7 +2516,6 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return nb_rx;
 }
-#endif
 
 /**
  * Get the number of used descriptors in a specific queue
@@ -2525,18 +2527,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @return
  *  The number of used descriptors in the specific queue.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint32_t rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id);
-#else
 static inline uint32_t
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
-        struct rte_eth_dev *dev;
-
-        dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+#endif
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
-#endif
 
 /**
  * Check if the DD bit of the specific RX descriptor in the queue has been set
@@ -2552,21 +2552,17 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern int rte_eth_rx_descriptor_done(uint8_t port_id,
-				      uint16_t queue_id,
-				      uint16_t offset);
-#else
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
-	struct rte_eth_dev *dev;
-
-	dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+#endif
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-#endif
 
 /**
  * Send a burst of output packets on a transmit queue of an Ethernet device.
@@ -2626,17 +2622,21 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
  *   the transmit ring. The return value can be less than the value of the
  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 
-	dev = &rte_eth_devices[port_id];
+	if (queue_id >= dev->data->nb_tx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 
 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
 	struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
@@ -2652,7 +2652,6 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
 }
-#endif
 
 /**
  * The eth device event type for interrupt, and maybe others in the future.
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v3 4/4] ethdev: check driver support for functions
  2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
                       ` (2 preceding siblings ...)
  2015-11-03 12:00     ` [PATCH v3 3/4] ethdev: remove duplicated debug functions Bruce Richardson
@ 2015-11-03 12:00     ` Bruce Richardson
  2015-11-03 22:00       ` Stephen Hemminger
  2015-11-17 12:21     ` [PATCH v4 0/2] ethdev: debug code cleanup Bruce Richardson
  4 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-03 12:00 UTC (permalink / raw)
  To: dev

The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
supported by very few PMDs. Therefore, it is best to check for support
for the functions in the ethdev library, so as to avoid run-time crashes
at run-time if the application goes to use those APIs. The performance
impact of this change should be very small as this is a predictable
branch in the function.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2b702c6..78267b0 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2525,16 +2525,18 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @param queue_id
  *  The queue id on the specific port.
  * @return
- *  The number of used descriptors in the specific queue.
+ *  The number of used descriptors in the specific queue, or:
+ *     (-EINVAL) if *port_id* is invalid
+ *     (-ENOTSUP) if the device does not support this function
  */
-static inline uint32_t
+static inline int
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 #endif
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -2551,6 +2553,7 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (1) if the specific DD bit is set.
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
+ *  - (-ENOTSUP) if the device does not support this function
  */
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
@@ -2558,8 +2561,8 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 #endif
+	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 4/4] ethdev: check driver support for functions
  2015-11-03 12:00     ` [PATCH v3 4/4] ethdev: check driver support for functions Bruce Richardson
@ 2015-11-03 22:00       ` Stephen Hemminger
  2015-11-04 14:15         ` Bruce Richardson
  0 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2015-11-03 22:00 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Tue,  3 Nov 2015 12:00:59 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:

>  * @return
> - *  The number of used descriptors in the specific queue.
> + *  The number of used descriptors in the specific queue, or:
> + *     (-EINVAL) if *port_id* is invalid
> + *     (-ENOTSUP) if the device does not support this function
>   */
> -static inline uint32_t
> +static inline int
>  rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
>  {
>  	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
>  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> -	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
> -	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
>  #endif

I think it should always check validity of portid/queueid
the check is very brief.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-03 12:00     ` [PATCH v3 2/4] ethdev: move error checking macros to header Bruce Richardson
@ 2015-11-04  1:19       ` Thomas Monjalon
  2015-11-04 10:24         ` Adrien Mazarguil
  0 siblings, 1 reply; 55+ messages in thread
From: Thomas Monjalon @ 2015-11-04  1:19 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

2015-11-03 12:00, Bruce Richardson:
> 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.
[...]
> +/**
> + * @internal
> + *  Macro to print a message if in debugging mode
> + */
> +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> +		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> +#else
> +#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> +#endif

It does not compile because Mellanox drivers are pedantic:

In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0:
/home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level:
/home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros]
 #define RTE_PMD_DEBUG_TRACE(fmt, args...) \

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-04  1:19       ` Thomas Monjalon
@ 2015-11-04 10:24         ` Adrien Mazarguil
  2015-11-04 14:10           ` Bruce Richardson
  2015-11-04 18:39           ` Stephen Hemminger
  0 siblings, 2 replies; 55+ messages in thread
From: Adrien Mazarguil @ 2015-11-04 10:24 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote:
> 2015-11-03 12:00, Bruce Richardson:
> > 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.
> [...]
> > +/**
> > + * @internal
> > + *  Macro to print a message if in debugging mode
> > + */
> > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > +		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > +#else
> > +#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > +#endif
> 
> It does not compile because Mellanox drivers are pedantic:
> 
> In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0:
> /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level:
> /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros]
>  #define RTE_PMD_DEBUG_TRACE(fmt, args...) \

I suggest something like the following definitions as a pedantic-proof and
standard compliant method (one drawback being that it cannot be done with a
single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also
automatically appends a line feed:

 #ifdef RTE_LIBRTE_ETHDEV_DEBUG

 #define STRIP(a, b) a
 #define OPAREN (
 #define CPAREN )
 #define COMMA ,

 #define RTE_PMD_DEBUG_TRACE(...) \
         RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN)

 #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \
         RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__)

 #define RTE_PMD_DEBUG_TRACE__(...) \
         RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__)

 #else /* RTE_LIBRTE_ETHDEV_DEBUG */

 #define RTE_PMD_DEBUG_TRACE(...)

 #endif /* RTE_LIBRTE_ETHDEV_DEBUG */

STRIP() and other helper macros are used to manage the dangling comma issue
when __VA_ARGS__ is empty as in the first call below:

 RTE_PMD_DEBUG_TRACE("foo\n");
 RTE_PMD_DEBUG_TRACE("foo %u\n", 42);

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-04 10:24         ` Adrien Mazarguil
@ 2015-11-04 14:10           ` Bruce Richardson
  2015-11-04 15:25             ` Adrien Mazarguil
  2015-11-04 18:39           ` Stephen Hemminger
  1 sibling, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-04 14:10 UTC (permalink / raw)
  To: Thomas Monjalon, dev

On Wed, Nov 04, 2015 at 11:24:18AM +0100, Adrien Mazarguil wrote:
> On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote:
> > 2015-11-03 12:00, Bruce Richardson:
> > > 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.
> > [...]
> > > +/**
> > > + * @internal
> > > + *  Macro to print a message if in debugging mode
> > > + */
> > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > > +		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > > +#else
> > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > > +#endif
> > 
> > It does not compile because Mellanox drivers are pedantic:
> > 
> > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0:
> > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level:
> > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros]
> >  #define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> 
> I suggest something like the following definitions as a pedantic-proof and
> standard compliant method (one drawback being that it cannot be done with a
> single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also
> automatically appends a line feed:
> 
>  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> 
>  #define STRIP(a, b) a
>  #define OPAREN (
>  #define CPAREN )
>  #define COMMA ,
> 
>  #define RTE_PMD_DEBUG_TRACE(...) \
>          RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN)
> 
>  #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \
>          RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__)
> 
>  #define RTE_PMD_DEBUG_TRACE__(...) \
>          RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__)
> 
>  #else /* RTE_LIBRTE_ETHDEV_DEBUG */
> 
>  #define RTE_PMD_DEBUG_TRACE(...)
> 
>  #endif /* RTE_LIBRTE_ETHDEV_DEBUG */
> 
> STRIP() and other helper macros are used to manage the dangling comma issue
> when __VA_ARGS__ is empty as in the first call below:
> 
>  RTE_PMD_DEBUG_TRACE("foo\n");
>  RTE_PMD_DEBUG_TRACE("foo %u\n", 42);
> 
> -- 
> Adrien Mazarguil
> 6WIND

Is this really the best way around this? It looks like a lot more complicated
than the original solution. Do we really need to support the -pedantic flag
in our header files?

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 4/4] ethdev: check driver support for functions
  2015-11-03 22:00       ` Stephen Hemminger
@ 2015-11-04 14:15         ` Bruce Richardson
  0 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-04 14:15 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Tue, Nov 03, 2015 at 02:00:29PM -0800, Stephen Hemminger wrote:
> On Tue,  3 Nov 2015 12:00:59 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
> 
> >  * @return
> > - *  The number of used descriptors in the specific queue.
> > + *  The number of used descriptors in the specific queue, or:
> > + *     (-EINVAL) if *port_id* is invalid
> > + *     (-ENOTSUP) if the device does not support this function
> >   */
> > -static inline uint32_t
> > +static inline int
> >  rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
> >  {
> >  	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
> >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > -	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
> > -	RTE_ETH_FPTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
> > +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
> >  #endif
> 
> I think it should always check validity of portid/queueid
> the check is very brief.

I would tend to agree. I'll add in the checks for the rx_queue_count and 
descriptor done calls, if there are no objections.

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-04 14:10           ` Bruce Richardson
@ 2015-11-04 15:25             ` Adrien Mazarguil
  0 siblings, 0 replies; 55+ messages in thread
From: Adrien Mazarguil @ 2015-11-04 15:25 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Wed, Nov 04, 2015 at 02:10:50PM +0000, Bruce Richardson wrote:
> On Wed, Nov 04, 2015 at 11:24:18AM +0100, Adrien Mazarguil wrote:
> > On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote:
> > > 2015-11-03 12:00, Bruce Richardson:
> > > > 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.
> > > [...]
> > > > +/**
> > > > + * @internal
> > > > + *  Macro to print a message if in debugging mode
> > > > + */
> > > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > > > +		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > > > +#else
> > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > > > +#endif
> > > 
> > > It does not compile because Mellanox drivers are pedantic:
> > > 
> > > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0:
> > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level:
> > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros]
> > >  #define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > 
> > I suggest something like the following definitions as a pedantic-proof and
> > standard compliant method (one drawback being that it cannot be done with a
> > single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also
> > automatically appends a line feed:
> > 
> >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > 
> >  #define STRIP(a, b) a
> >  #define OPAREN (
> >  #define CPAREN )
> >  #define COMMA ,
> > 
> >  #define RTE_PMD_DEBUG_TRACE(...) \
> >          RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN)
> > 
> >  #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \
> >          RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__)
> > 
> >  #define RTE_PMD_DEBUG_TRACE__(...) \
> >          RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__)
> > 
> >  #else /* RTE_LIBRTE_ETHDEV_DEBUG */
> > 
> >  #define RTE_PMD_DEBUG_TRACE(...)
> > 
> >  #endif /* RTE_LIBRTE_ETHDEV_DEBUG */
> > 
> > STRIP() and other helper macros are used to manage the dangling comma issue
> > when __VA_ARGS__ is empty as in the first call below:
> > 
> >  RTE_PMD_DEBUG_TRACE("foo\n");
> >  RTE_PMD_DEBUG_TRACE("foo %u\n", 42);
> > 
> > -- 
> > Adrien Mazarguil
> > 6WIND
> 
> Is this really the best way around this? It looks like a lot more complicated
> than the original solution. Do we really need to support the -pedantic flag
> in our header files?

I know you didn't ask me directly but I think we should, at least for
exposed/installed headers. What we do internally does not matter, but we
cannot prevent user applications from adding -pedantic if they want to.

The above solution is one I suggest, perhaps it can be done in a different
manner if you think it's too complicated, although it's difficult using
macros only.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-04 10:24         ` Adrien Mazarguil
  2015-11-04 14:10           ` Bruce Richardson
@ 2015-11-04 18:39           ` Stephen Hemminger
  2015-11-05 15:09             ` Adrien Mazarguil
  1 sibling, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2015-11-04 18:39 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev

On Wed, 4 Nov 2015 11:24:18 +0100
Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:

> On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote:
> > 2015-11-03 12:00, Bruce Richardson:
> > > 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.
> > [...]
> > > +/**
> > > + * @internal
> > > + *  Macro to print a message if in debugging mode
> > > + */
> > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > > +		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > > +#else
> > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > > +#endif
> > 
> > It does not compile because Mellanox drivers are pedantic:
> > 
> > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0:
> > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level:
> > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros]
> >  #define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> 
> I suggest something like the following definitions as a pedantic-proof and
> standard compliant method (one drawback being that it cannot be done with a
> single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also
> automatically appends a line feed:
> 
>  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> 
>  #define STRIP(a, b) a
>  #define OPAREN (
>  #define CPAREN )
>  #define COMMA ,
> 
>  #define RTE_PMD_DEBUG_TRACE(...) \
>          RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN)
> 
>  #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \
>          RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__)
> 
>  #define RTE_PMD_DEBUG_TRACE__(...) \
>          RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__)
> 
>  #else /* RTE_LIBRTE_ETHDEV_DEBUG */
> 
>  #define RTE_PMD_DEBUG_TRACE(...)
> 
>  #endif /* RTE_LIBRTE_ETHDEV_DEBUG */
> 
> STRIP() and other helper macros are used to manage the dangling comma issue
> when __VA_ARGS__ is empty as in the first call below:
> 
>  RTE_PMD_DEBUG_TRACE("foo\n");
>  RTE_PMD_DEBUG_TRACE("foo %u\n", 42);

That solution is really ugly.

Why not do something that keeps the expected checks.

diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
index ede0dca..f3a3d34 100644
--- a/lib/librte_eal/common/include/rte_log.h
+++ b/lib/librte_eal/common/include/rte_log.h
@@ -99,6 +99,8 @@ extern struct rte_logs rte_logs;
 #define RTE_LOG_INFO     7U  /**< Informational.                    */
 #define RTE_LOG_DEBUG    8U  /**< Debug-level messages.             */
 
+#define RTE_LOG_DISABLED 99U /**< Never printed			    */
+
 /** The default log stream. */
 extern FILE *eal_default_log_stream;
 
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index eee1194..e431f2e 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -931,6 +931,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...) \
+	RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
+#else
+#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
+	RTE_LOG(DISABLED, PMD, "%s: " fmt, __func__, ## args)
+#endif

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-04 18:39           ` Stephen Hemminger
@ 2015-11-05 15:09             ` Adrien Mazarguil
  2015-11-05 15:17               ` Bruce Richardson
                                 ` (2 more replies)
  0 siblings, 3 replies; 55+ messages in thread
From: Adrien Mazarguil @ 2015-11-05 15:09 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Wed, Nov 04, 2015 at 10:39:57AM -0800, Stephen Hemminger wrote:
> On Wed, 4 Nov 2015 11:24:18 +0100
> Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
> 
> > On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote:
> > > 2015-11-03 12:00, Bruce Richardson:
> > > > 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.
> > > [...]
> > > > +/**
> > > > + * @internal
> > > > + *  Macro to print a message if in debugging mode
> > > > + */
> > > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > > > +		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > > > +#else
> > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > > > +#endif
> > > 
> > > It does not compile because Mellanox drivers are pedantic:
> > > 
> > > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0:
> > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level:
> > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros]
> > >  #define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > 
> > I suggest something like the following definitions as a pedantic-proof and
> > standard compliant method (one drawback being that it cannot be done with a
> > single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also
> > automatically appends a line feed:
> > 
> >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > 
> >  #define STRIP(a, b) a
> >  #define OPAREN (
> >  #define CPAREN )
> >  #define COMMA ,
> > 
> >  #define RTE_PMD_DEBUG_TRACE(...) \
> >          RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN)
> > 
> >  #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \
> >          RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__)
> > 
> >  #define RTE_PMD_DEBUG_TRACE__(...) \
> >          RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__)
> > 
> >  #else /* RTE_LIBRTE_ETHDEV_DEBUG */
> > 
> >  #define RTE_PMD_DEBUG_TRACE(...)
> > 
> >  #endif /* RTE_LIBRTE_ETHDEV_DEBUG */
> > 
> > STRIP() and other helper macros are used to manage the dangling comma issue
> > when __VA_ARGS__ is empty as in the first call below:
> > 
> >  RTE_PMD_DEBUG_TRACE("foo\n");
> >  RTE_PMD_DEBUG_TRACE("foo %u\n", 42);
> 
> That solution is really ugly.

I won't argue against this as it's obviously more complex than the original
method, however note that users of the RTE_PMD_DEBUG_TRACE() macro do not
have to modify their code. They shouldn't care about the implementation.

Also note that we can do much cleaner code if we drop the all macros
implementation using a (much easier to debug) static inline function,
only perhaps with a wrapper macro that provides __LINE__, __func__ and
__FILE__ as arguments. Nontrival code shouldn't be done in macros anyway.

> Why not do something that keeps the expected checks.

Sure but it's not the issue, we're discussing errors related to
-pedantic. I've only made the above suggestion to pass its pedantic
checks. RTE_LOG_DISABLED can be managed with these macros as well.

> diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
> index ede0dca..f3a3d34 100644
> --- a/lib/librte_eal/common/include/rte_log.h
> +++ b/lib/librte_eal/common/include/rte_log.h
> @@ -99,6 +99,8 @@ extern struct rte_logs rte_logs;
>  #define RTE_LOG_INFO     7U  /**< Informational.                    */
>  #define RTE_LOG_DEBUG    8U  /**< Debug-level messages.             */
>  
> +#define RTE_LOG_DISABLED 99U /**< Never printed			    */
> +
>  /** The default log stream. */
>  extern FILE *eal_default_log_stream;
>  
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index eee1194..e431f2e 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -931,6 +931,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...) \
> +	RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> +#else
> +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> +	RTE_LOG(DISABLED, PMD, "%s: " fmt, __func__, ## args)
> +#endif

My previous message was probably not clear enough about the reason for this
error. With -pedantic, GCC complains about these bits:

- "args..." causing "error: ISO C does not permit named variadic
  macros", as in C function you cannot put an ellipsis directly behind a
  token without a comma.

- ", ## args" for which I can't recall the error, but pasting a comma and
  args is also nonstandard, especially when args happens to be empty.
  Without -pedantic, GCC silently drops the comma.

Bruce is asking for a consensus about -pedantic, whether we want to do the
extra effort to support it in DPDK. Since I like checking for -pedantic
errors, it's enabled for mlx4 and mlx5 when compiling these drivers in
debugging mode. There is currently no established rule in DPDK against this.

I'm arguing that most C headers (C compiler, libc, most libraries, even the
Linux kernel in uapi to an extent) provide standards compliant includes
because they cannot predict or force particular compilation flags on
user applications.

If we consider DPDK as a system wide library, I think we should do it as
well in all installed header files. If we choose not to, then we must
document that our code is not standard, -pedantic is unsupported and I'll
have to drop it from mlx4 and mlx5.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-05 15:09             ` Adrien Mazarguil
@ 2015-11-05 15:17               ` Bruce Richardson
  2015-11-06 11:49               ` Bruce Richardson
  2015-11-06 17:10               ` Bruce Richardson
  2 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-05 15:17 UTC (permalink / raw)
  To: Stephen Hemminger, Thomas Monjalon, dev

On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
> On Wed, Nov 04, 2015 at 10:39:57AM -0800, Stephen Hemminger wrote:
> > On Wed, 4 Nov 2015 11:24:18 +0100
> > Adrien Mazarguil <adrien.mazarguil@6wind.com> wrote:
> > 
> > > On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote:
> > > > 2015-11-03 12:00, Bruce Richardson:
> > > > > 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.
> > > > [...]
> > > > > +/**
> > > > > + * @internal
> > > > > + *  Macro to print a message if in debugging mode
> > > > > + */
> > > > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > > > > +		RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > > > > +#else
> > > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > > > > +#endif
> > > > 
> > > > It does not compile because Mellanox drivers are pedantic:
> > > > 
> > > > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0:
> > > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level:
> > > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros]
> > > >  #define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > > 
> > > I suggest something like the following definitions as a pedantic-proof and
> > > standard compliant method (one drawback being that it cannot be done with a
> > > single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also
> > > automatically appends a line feed:
> > > 
> > >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > > 
> > >  #define STRIP(a, b) a
> > >  #define OPAREN (
> > >  #define CPAREN )
> > >  #define COMMA ,
> > > 
> > >  #define RTE_PMD_DEBUG_TRACE(...) \
> > >          RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN)
> > > 
> > >  #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \
> > >          RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__)
> > > 
> > >  #define RTE_PMD_DEBUG_TRACE__(...) \
> > >          RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__)
> > > 
> > >  #else /* RTE_LIBRTE_ETHDEV_DEBUG */
> > > 
> > >  #define RTE_PMD_DEBUG_TRACE(...)
> > > 
> > >  #endif /* RTE_LIBRTE_ETHDEV_DEBUG */
> > > 
> > > STRIP() and other helper macros are used to manage the dangling comma issue
> > > when __VA_ARGS__ is empty as in the first call below:
> > > 
> > >  RTE_PMD_DEBUG_TRACE("foo\n");
> > >  RTE_PMD_DEBUG_TRACE("foo %u\n", 42);
> > 
> > That solution is really ugly.
> 
> I won't argue against this as it's obviously more complex than the original
> method, however note that users of the RTE_PMD_DEBUG_TRACE() macro do not
> have to modify their code. They shouldn't care about the implementation.
> 
> Also note that we can do much cleaner code if we drop the all macros
> implementation using a (much easier to debug) static inline function,
> only perhaps with a wrapper macro that provides __LINE__, __func__ and
> __FILE__ as arguments. Nontrival code shouldn't be done in macros anyway.
> 

+1 to this. I was planning to seeing if a static inline could help here, but
haven't had the chance to try it yet.

> > Why not do something that keeps the expected checks.
> 
> Sure but it's not the issue, we're discussing errors related to
> -pedantic. I've only made the above suggestion to pass its pedantic
> checks. RTE_LOG_DISABLED can be managed with these macros as well.
> 
> > diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
> > index ede0dca..f3a3d34 100644
> > --- a/lib/librte_eal/common/include/rte_log.h
> > +++ b/lib/librte_eal/common/include/rte_log.h
> > @@ -99,6 +99,8 @@ extern struct rte_logs rte_logs;
> >  #define RTE_LOG_INFO     7U  /**< Informational.                    */
> >  #define RTE_LOG_DEBUG    8U  /**< Debug-level messages.             */
> >  
> > +#define RTE_LOG_DISABLED 99U /**< Never printed			    */
> > +
> >  /** The default log stream. */
> >  extern FILE *eal_default_log_stream;
> >  
> > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > index eee1194..e431f2e 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -931,6 +931,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...) \
> > +	RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > +#else
> > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > +	RTE_LOG(DISABLED, PMD, "%s: " fmt, __func__, ## args)
> > +#endif
> 
> My previous message was probably not clear enough about the reason for this
> error. With -pedantic, GCC complains about these bits:
> 
> - "args..." causing "error: ISO C does not permit named variadic
>   macros", as in C function you cannot put an ellipsis directly behind a
>   token without a comma.
> 
> - ", ## args" for which I can't recall the error, but pasting a comma and
>   args is also nonstandard, especially when args happens to be empty.
>   Without -pedantic, GCC silently drops the comma.
> 
> Bruce is asking for a consensus about -pedantic, whether we want to do the
> extra effort to support it in DPDK. Since I like checking for -pedantic
> errors, it's enabled for mlx4 and mlx5 when compiling these drivers in
> debugging mode. There is currently no established rule in DPDK against this.
> 
> I'm arguing that most C headers (C compiler, libc, most libraries, even the
> Linux kernel in uapi to an extent) provide standards compliant includes
> because they cannot predict or force particular compilation flags on
> user applications.
> 
> If we consider DPDK as a system wide library, I think we should do it as
> well in all installed header files. If we choose not to, then we must
> document that our code is not standard, -pedantic is unsupported and I'll
> have to drop it from mlx4 and mlx5.
> 
> -- 

I'm in favour in principle of being standards compliant so long as the cost is
not extremely high. If we have to go through a lot of macro gymnastics to get
things working in order to support pedantic, I'd be of the opinion that the cost
of supporting that particular flag is too high. Each one will probably have his
own opinion of this.

Hopefully a static inline can provide a good compromise solution that everyone
can live with. I'll look at it as soon as I can.

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-05 15:09             ` Adrien Mazarguil
  2015-11-05 15:17               ` Bruce Richardson
@ 2015-11-06 11:49               ` Bruce Richardson
  2015-11-06 17:10               ` Bruce Richardson
  2 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-06 11:49 UTC (permalink / raw)
  To: Stephen Hemminger, Thomas Monjalon, dev

On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
> Bruce is asking for a consensus about -pedantic, whether we want to do the
> extra effort to support it in DPDK. Since I like checking for -pedantic
> errors, it's enabled for mlx4 and mlx5 when compiling these drivers in
> debugging mode. There is currently no established rule in DPDK against this.
> 
> I'm arguing that most C headers (C compiler, libc, most libraries, even the
> Linux kernel in uapi to an extent) provide standards compliant includes
> because they cannot predict or force particular compilation flags on
> user applications.
> 
> If we consider DPDK as a system wide library, I think we should do it as
> well in all installed header files. If we choose not to, then we must
> document that our code is not standard, -pedantic is unsupported and I'll
> have to drop it from mlx4 and mlx5.
> 
> -- 
> Adrien Mazarguil
> 6WIND

Hi Adrien,

I'm trying to dig into this a bit more now, and try out using a static inline
function, but I'm having trouble getting DPDK to compile with the mlx drivers
turned on in the config. I'm trying to follow the instructions here:
http://dpdk.org/doc/guides/nics/mlx4.html, but it's not clearly called out what
requirements are for compilation vs requirements for running the PMD.

I'm running Fedora 23, and installed the libibverbs-devel package, but when I
compile I get the following error:

== Build drivers/net/mlx4
  CC mlx4.o
  /home/bruce/ethdev-cleanup/drivers/net/mlx4/mlx4.c: In function ‘txq_cleanup’:
  /home/bruce/ethdev-cleanup/drivers/net/mlx4/mlx4.c:886:37: error: storage size of ‘params’ isn’t known
    struct ibv_exp_release_intf_params params;
                                       ^
compilation terminated due to -Wfatal-errors.

Any suggestions on the fix for this?

Thanks,
/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-05 15:09             ` Adrien Mazarguil
  2015-11-05 15:17               ` Bruce Richardson
  2015-11-06 11:49               ` Bruce Richardson
@ 2015-11-06 17:10               ` Bruce Richardson
  2015-11-06 17:22                 ` Bruce Richardson
  2 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-06 17:10 UTC (permalink / raw)
  To: Stephen Hemminger, Thomas Monjalon, dev

On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
> 
> I won't argue against this as it's obviously more complex than the original
> method, however note that users of the RTE_PMD_DEBUG_TRACE() macro do not
> have to modify their code. They shouldn't care about the implementation.
> 
> Also note that we can do much cleaner code if we drop the all macros
> implementation using a (much easier to debug) static inline function,
> only perhaps with a wrapper macro that provides __LINE__, __func__ and
> __FILE__ as arguments. Nontrival code shouldn't be done in macros anyway.
> 
Getting something working with __FILE__ and probably __LINE__ would be easy enough
with a helper macro, but __func__ is not so easy as it's not a preprocessor symbol
[since the pre-processor has no idea what function you are in].

However, using func, here is the best I've come up with so far. It's not that
pretty, but it's probably easier to work with than the macro version.

 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
 -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
 -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
 +#define RTE_PMD_DEBUG_TRACE(...) \
 +               rte_pmd_debug_trace(__func__, __VA_ARGS__)
 +
 +static inline void
 +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 +{
 +       static __thread char buffer[128];
 +       char *out_buf = buffer;
 +       unsigned count;
 +       va_list ap;
 +
 +       count = snprintf(buffer, sizeof(buffer), "%s: %s", func_name, fmt);
 +       if (count >= sizeof(buffer)) { // truncated output
 +               char *new_buf = malloc(count + 1);
 +               if (new_buf == NULL) // no memory, just print 128 chars
 +                       goto print_buffer;
 +               snprintf(new_buf, count + 1, "%s: %s", func_name, fmt);
 +               va_start(ap, fmt);
 +               rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, buffer, ap);
 +               va_end(ap);
 +               free(new_buf);
 +               return;
 +       }
 +
 +print_buffer:
 +       va_start(ap, fmt);
 +       rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, out_buf, ap);
 +       va_end(ap);
 +}
  #else
  #define RTE_PMD_DEBUG_TRACE(fmt, args...)
  #endif

Comments or improvements?

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-06 17:10               ` Bruce Richardson
@ 2015-11-06 17:22                 ` Bruce Richardson
  2015-11-09 13:39                   ` Adrien Mazarguil
  0 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-06 17:22 UTC (permalink / raw)
  To: Stephen Hemminger, Thomas Monjalon, dev, adrien.mazarguil

On Fri, Nov 06, 2015 at 05:10:07PM +0000, Bruce Richardson wrote:
> On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
> > 
> > I won't argue against this as it's obviously more complex than the original
> > method, however note that users of the RTE_PMD_DEBUG_TRACE() macro do not
> > have to modify their code. They shouldn't care about the implementation.
> > 
> > Also note that we can do much cleaner code if we drop the all macros
> > implementation using a (much easier to debug) static inline function,
> > only perhaps with a wrapper macro that provides __LINE__, __func__ and
> > __FILE__ as arguments. Nontrival code shouldn't be done in macros anyway.
> > 
> Getting something working with __FILE__ and probably __LINE__ would be easy enough
> with a helper macro, but __func__ is not so easy as it's not a preprocessor symbol
> [since the pre-processor has no idea what function you are in].
> 
> However, using func, here is the best I've come up with so far. It's not that
> pretty, but it's probably easier to work with than the macro version.
> 
>  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
>  -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
>  -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
>  +#define RTE_PMD_DEBUG_TRACE(...) \
>  +               rte_pmd_debug_trace(__func__, __VA_ARGS__)
>  +
>  +static inline void
>  +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
>  +{
>  +       static __thread char buffer[128];
>  +       char *out_buf = buffer;
>  +       unsigned count;
>  +       va_list ap;
>  +
>  +       count = snprintf(buffer, sizeof(buffer), "%s: %s", func_name, fmt);
>  +       if (count >= sizeof(buffer)) { // truncated output
>  +               char *new_buf = malloc(count + 1);
>  +               if (new_buf == NULL) // no memory, just print 128 chars
>  +                       goto print_buffer;
>  +               snprintf(new_buf, count + 1, "%s: %s", func_name, fmt);
>  +               va_start(ap, fmt);
>  +               rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, buffer, ap);
>  +               va_end(ap);
>  +               free(new_buf);
>  +               return;
>  +       }
>  +
>  +print_buffer:
>  +       va_start(ap, fmt);
>  +       rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, out_buf, ap);
>  +       va_end(ap);
>  +}
>   #else
>   #define RTE_PMD_DEBUG_TRACE(fmt, args...)
>   #endif
> 
> Comments or improvements?
> 
> /Bruce

And here's the version if we are happy to have file and line number instead of
function name. I think this might be the best option.

/Bruce

 #ifdef RTE_LIBRTE_ETHDEV_DEBUG
 -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
 -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
 +#define RTE_PMD_DEBUG_TRACE(...) \
 +       RTE_LOG(ERR, PMD, __FILE__", " RTE_STR(__LINE__) ": " __VA_ARGS__)
  #else
 -#define RTE_PMD_DEBUG_TRACE(fmt, args...)
 +#define RTE_PMD_DEBUG_TRACE(...)
  #endif

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-06 17:22                 ` Bruce Richardson
@ 2015-11-09 13:39                   ` Adrien Mazarguil
  2015-11-09 13:50                     ` Adrien Mazarguil
  2015-11-09 14:02                     ` Richardson, Bruce
  0 siblings, 2 replies; 55+ messages in thread
From: Adrien Mazarguil @ 2015-11-09 13:39 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Fri, Nov 06, 2015 at 05:22:27PM +0000, Bruce Richardson wrote:
> On Fri, Nov 06, 2015 at 05:10:07PM +0000, Bruce Richardson wrote:
> > On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
> > > 
> > > I won't argue against this as it's obviously more complex than the original
> > > method, however note that users of the RTE_PMD_DEBUG_TRACE() macro do not
> > > have to modify their code. They shouldn't care about the implementation.
> > > 
> > > Also note that we can do much cleaner code if we drop the all macros
> > > implementation using a (much easier to debug) static inline function,
> > > only perhaps with a wrapper macro that provides __LINE__, __func__ and
> > > __FILE__ as arguments. Nontrival code shouldn't be done in macros anyway.
> > > 
> > Getting something working with __FILE__ and probably __LINE__ would be easy enough
> > with a helper macro, but __func__ is not so easy as it's not a preprocessor symbol
> > [since the pre-processor has no idea what function you are in].
> > 
> > However, using func, here is the best I've come up with so far. It's not that
> > pretty, but it's probably easier to work with than the macro version.
> > 
> >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> >  -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> >  -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> >  +#define RTE_PMD_DEBUG_TRACE(...) \
> >  +               rte_pmd_debug_trace(__func__, __VA_ARGS__)
> >  +
> >  +static inline void
> >  +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
> >  +{
> >  +       static __thread char buffer[128];
> >  +       char *out_buf = buffer;
> >  +       unsigned count;
> >  +       va_list ap;
> >  +
> >  +       count = snprintf(buffer, sizeof(buffer), "%s: %s", func_name, fmt);
> >  +       if (count >= sizeof(buffer)) { // truncated output
> >  +               char *new_buf = malloc(count + 1);
> >  +               if (new_buf == NULL) // no memory, just print 128 chars
> >  +                       goto print_buffer;
> >  +               snprintf(new_buf, count + 1, "%s: %s", func_name, fmt);
> >  +               va_start(ap, fmt);
> >  +               rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, buffer, ap);
> >  +               va_end(ap);
> >  +               free(new_buf);
> >  +               return;
> >  +       }
> >  +
> >  +print_buffer:
> >  +       va_start(ap, fmt);
> >  +       rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, out_buf, ap);
> >  +       va_end(ap);
> >  +}
> >   #else
> >   #define RTE_PMD_DEBUG_TRACE(fmt, args...)
> >   #endif
> > 
> > Comments or improvements?

Such a function shouldn't malloc() anything. The entire line should fit on
the stack (crashing is fine if it does not, then it's probably a bug). We
did something in two passes along these lines in mlx5_defs.h (not pretty but
quite useful):

 /* Allocate a buffer on the stack and fill it with a printf format string. */
 #define MKSTR(name, ...) \
         char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \
         \
         snprintf(name, sizeof(name), __VA_ARGS__)

Untested but I guess modifying that function accordingly would look like:

 static inline void
 rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 {
         va_list ap;
         va_start(ap, fmt);

         static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];

         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);
 }

> And here's the version if we are happy to have file and line number instead of
> function name. I think this might be the best option.
> 
> /Bruce
> 
>  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
>  -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
>  -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
>  +#define RTE_PMD_DEBUG_TRACE(...) \
>  +       RTE_LOG(ERR, PMD, __FILE__", " RTE_STR(__LINE__) ": " __VA_ARGS__)
>   #else
>  -#define RTE_PMD_DEBUG_TRACE(fmt, args...)
>  +#define RTE_PMD_DEBUG_TRACE(...)
>   #endif

Much cleaner indeed, however __func__ might be useful when comparing log
outputs from different source code versions. I think we should keep it.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-09 13:39                   ` Adrien Mazarguil
@ 2015-11-09 13:50                     ` Adrien Mazarguil
  2015-11-09 14:02                     ` Richardson, Bruce
  1 sibling, 0 replies; 55+ messages in thread
From: Adrien Mazarguil @ 2015-11-09 13:50 UTC (permalink / raw)
  To: Bruce Richardson, Stephen Hemminger, Thomas Monjalon, dev

On Mon, Nov 09, 2015 at 02:39:05PM +0100, Adrien Mazarguil wrote:
> On Fri, Nov 06, 2015 at 05:22:27PM +0000, Bruce Richardson wrote:
> > On Fri, Nov 06, 2015 at 05:10:07PM +0000, Bruce Richardson wrote:
> > > On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
> > > > 
> > > > I won't argue against this as it's obviously more complex than the original
> > > > method, however note that users of the RTE_PMD_DEBUG_TRACE() macro do not
> > > > have to modify their code. They shouldn't care about the implementation.
> > > > 
> > > > Also note that we can do much cleaner code if we drop the all macros
> > > > implementation using a (much easier to debug) static inline function,
> > > > only perhaps with a wrapper macro that provides __LINE__, __func__ and
> > > > __FILE__ as arguments. Nontrival code shouldn't be done in macros anyway.
> > > > 
> > > Getting something working with __FILE__ and probably __LINE__ would be easy enough
> > > with a helper macro, but __func__ is not so easy as it's not a preprocessor symbol
> > > [since the pre-processor has no idea what function you are in].
> > > 
> > > However, using func, here is the best I've come up with so far. It's not that
> > > pretty, but it's probably easier to work with than the macro version.
> > > 
> > >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > >  -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > >  -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > >  +#define RTE_PMD_DEBUG_TRACE(...) \
> > >  +               rte_pmd_debug_trace(__func__, __VA_ARGS__)
> > >  +
> > >  +static inline void
> > >  +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
> > >  +{
> > >  +       static __thread char buffer[128];
> > >  +       char *out_buf = buffer;
> > >  +       unsigned count;
> > >  +       va_list ap;
> > >  +
> > >  +       count = snprintf(buffer, sizeof(buffer), "%s: %s", func_name, fmt);
> > >  +       if (count >= sizeof(buffer)) { // truncated output
> > >  +               char *new_buf = malloc(count + 1);
> > >  +               if (new_buf == NULL) // no memory, just print 128 chars
> > >  +                       goto print_buffer;
> > >  +               snprintf(new_buf, count + 1, "%s: %s", func_name, fmt);
> > >  +               va_start(ap, fmt);
> > >  +               rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, buffer, ap);
> > >  +               va_end(ap);
> > >  +               free(new_buf);
> > >  +               return;
> > >  +       }
> > >  +
> > >  +print_buffer:
> > >  +       va_start(ap, fmt);
> > >  +       rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, out_buf, ap);
> > >  +       va_end(ap);
> > >  +}
> > >   #else
> > >   #define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > >   #endif
> > > 
> > > Comments or improvements?
> 
> Such a function shouldn't malloc() anything. The entire line should fit on
> the stack (crashing is fine if it does not, then it's probably a bug). We
> did something in two passes along these lines in mlx5_defs.h (not pretty but
> quite useful):
> 
>  /* Allocate a buffer on the stack and fill it with a printf format string. */
>  #define MKSTR(name, ...) \
>          char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \
>          \
>          snprintf(name, sizeof(name), __VA_ARGS__)
> 
> Untested but I guess modifying that function accordingly would look like:
> 
>  static inline void
>  rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
>  {
>          va_list ap;
>          va_start(ap, fmt);
> 
>          static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];

Of course this line should read:

         static __thread char buffer[vsnprintf(NULL, 0, fmt, ap) + 1];

>          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);
>  }
> 
> > And here's the version if we are happy to have file and line number instead of
> > function name. I think this might be the best option.
> > 
> > /Bruce
> > 
> >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> >  -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> >  -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> >  +#define RTE_PMD_DEBUG_TRACE(...) \
> >  +       RTE_LOG(ERR, PMD, __FILE__", " RTE_STR(__LINE__) ": " __VA_ARGS__)
> >   #else
> >  -#define RTE_PMD_DEBUG_TRACE(fmt, args...)
> >  +#define RTE_PMD_DEBUG_TRACE(...)
> >   #endif
> 
> Much cleaner indeed, however __func__ might be useful when comparing log
> outputs from different source code versions. I think we should keep it.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-09 13:39                   ` Adrien Mazarguil
  2015-11-09 13:50                     ` Adrien Mazarguil
@ 2015-11-09 14:02                     ` Richardson, Bruce
  2015-11-10 10:31                       ` Declan Doherty
  2015-11-10 16:08                       ` Adrien Mazarguil
  1 sibling, 2 replies; 55+ messages in thread
From: Richardson, Bruce @ 2015-11-09 14:02 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev



> -----Original Message-----
> From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> Sent: Monday, November 9, 2015 1:39 PM
> To: Richardson, Bruce <bruce.richardson@intel.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Thomas Monjalon
> <thomas.monjalon@6wind.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros
> to header
> 
> On Fri, Nov 06, 2015 at 05:22:27PM +0000, Bruce Richardson wrote:
> > On Fri, Nov 06, 2015 at 05:10:07PM +0000, Bruce Richardson wrote:
> > > On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
> > > >
> > > > I won't argue against this as it's obviously more complex than the
> original
> > > > method, however note that users of the RTE_PMD_DEBUG_TRACE() macro
> do not
> > > > have to modify their code. They shouldn't care about the
> implementation.
> > > >
> > > > Also note that we can do much cleaner code if we drop the all macros
> > > > implementation using a (much easier to debug) static inline
> function,
> > > > only perhaps with a wrapper macro that provides __LINE__, __func__
> and
> > > > __FILE__ as arguments. Nontrival code shouldn't be done in macros
> anyway.
> > > >
> > > Getting something working with __FILE__ and probably __LINE__ would be
> easy enough
> > > with a helper macro, but __func__ is not so easy as it's not a
> preprocessor symbol
> > > [since the pre-processor has no idea what function you are in].
> > >
> > > However, using func, here is the best I've come up with so far. It's
> not that
> > > pretty, but it's probably easier to work with than the macro version.
> > >
> > >  #ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > >  -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
> > >  -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
> > >  +#define RTE_PMD_DEBUG_TRACE(...) \
> > >  +               rte_pmd_debug_trace(__func__, __VA_ARGS__)
> > >  +
> > >  +static inline void
> > >  +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
> > >  +{
> > >  +       static __thread char buffer[128];
> > >  +       char *out_buf = buffer;
> > >  +       unsigned count;
> > >  +       va_list ap;
> > >  +
> > >  +       count = snprintf(buffer, sizeof(buffer), "%s: %s", func_name,
> fmt);
> > >  +       if (count >= sizeof(buffer)) { // truncated output
> > >  +               char *new_buf = malloc(count + 1);
> > >  +               if (new_buf == NULL) // no memory, just print 128
> chars
> > >  +                       goto print_buffer;
> > >  +               snprintf(new_buf, count + 1, "%s: %s", func_name,
> fmt);
> > >  +               va_start(ap, fmt);
> > >  +               rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, buffer, ap);
> > >  +               va_end(ap);
> > >  +               free(new_buf);
> > >  +               return;
> > >  +       }
> > >  +
> > >  +print_buffer:
> > >  +       va_start(ap, fmt);
> > >  +       rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, out_buf, ap);
> > >  +       va_end(ap);
> > >  +}
> > >   #else
> > >   #define RTE_PMD_DEBUG_TRACE(fmt, args...)
> > >   #endif
> > >
> > > Comments or improvements?
> 
> Such a function shouldn't malloc() anything. The entire line should fit on
> the stack (crashing is fine if it does not, then it's probably a bug). We
> did something in two passes along these lines in mlx5_defs.h (not pretty
> but
> quite useful):
> 
>  /* Allocate a buffer on the stack and fill it with a printf format
> string. */
>  #define MKSTR(name, ...) \
>          char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \
>          \
>          snprintf(name, sizeof(name), __VA_ARGS__)
> 
> Untested but I guess modifying that function accordingly would look like:
> 
>  static inline void
>  rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
>  {
>          va_list ap;
>          va_start(ap, fmt);
> 
>          static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];
> 
>          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);
>  }
> 

Looks a much better option.

>From this, though, I assume then that we are only looking to support the -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic with the pre-gcc-5 versions won't allow that to work though, as variably sized arrays only came in with c99, and were gnu extensions before that.

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-09 14:02                     ` Richardson, Bruce
@ 2015-11-10 10:31                       ` Declan Doherty
  2015-11-10 16:08                       ` Adrien Mazarguil
  1 sibling, 0 replies; 55+ messages in thread
From: Declan Doherty @ 2015-11-10 10:31 UTC (permalink / raw)
  To: Richardson, Bruce, Adrien Mazarguil; +Cc: dev

On 09/11/15 14:02, Richardson, Bruce wrote:
>
>
>> -----Original Message-----
>> From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
>> Sent: Monday, November 9, 2015 1:39 PM
>> To: Richardson, Bruce <bruce.richardson@intel.com>
>> Cc: Stephen Hemminger <stephen@networkplumber.org>; Thomas Monjalon
>> <thomas.monjalon@6wind.com>; dev@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros
>> to header
>>
>> On Fri, Nov 06, 2015 at 05:22:27PM +0000, Bruce Richardson wrote:
>>> On Fri, Nov 06, 2015 at 05:10:07PM +0000, Bruce Richardson wrote:
>>>> On Thu, Nov 05, 2015 at 04:09:18PM +0100, Adrien Mazarguil wrote:
>>>>>
>>>>> I won't argue against this as it's obviously more complex than the
>> original
>>>>> method, however note that users of the RTE_PMD_DEBUG_TRACE() macro
>> do not
>>>>> have to modify their code. They shouldn't care about the
>> implementation.
>>>>>
>>>>> Also note that we can do much cleaner code if we drop the all macros
>>>>> implementation using a (much easier to debug) static inline
>> function,
>>>>> only perhaps with a wrapper macro that provides __LINE__, __func__
>> and
>>>>> __FILE__ as arguments. Nontrival code shouldn't be done in macros
>> anyway.
>>>>>
>>>> Getting something working with __FILE__ and probably __LINE__ would be
>> easy enough
>>>> with a helper macro, but __func__ is not so easy as it's not a
>> preprocessor symbol
>>>> [since the pre-processor has no idea what function you are in].
>>>>
>>>> However, using func, here is the best I've come up with so far. It's
>> not that
>>>> pretty, but it's probably easier to work with than the macro version.
>>>>
>>>>   #ifdef RTE_LIBRTE_ETHDEV_DEBUG
>>>>   -#define RTE_PMD_DEBUG_TRACE(fmt, args...) \
>>>>   -               RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args)
>>>>   +#define RTE_PMD_DEBUG_TRACE(...) \
>>>>   +               rte_pmd_debug_trace(__func__, __VA_ARGS__)
>>>>   +
>>>>   +static inline void
>>>>   +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
>>>>   +{
>>>>   +       static __thread char buffer[128];
>>>>   +       char *out_buf = buffer;
>>>>   +       unsigned count;
>>>>   +       va_list ap;
>>>>   +
>>>>   +       count = snprintf(buffer, sizeof(buffer), "%s: %s", func_name,
>> fmt);
>>>>   +       if (count >= sizeof(buffer)) { // truncated output
>>>>   +               char *new_buf = malloc(count + 1);
>>>>   +               if (new_buf == NULL) // no memory, just print 128
>> chars
>>>>   +                       goto print_buffer;
>>>>   +               snprintf(new_buf, count + 1, "%s: %s", func_name,
>> fmt);
>>>>   +               va_start(ap, fmt);
>>>>   +               rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, buffer, ap);
>>>>   +               va_end(ap);
>>>>   +               free(new_buf);
>>>>   +               return;
>>>>   +       }
>>>>   +
>>>>   +print_buffer:
>>>>   +       va_start(ap, fmt);
>>>>   +       rte_vlog(RTE_LOG_ERR, RTE_LOGTYPE_PMD, out_buf, ap);
>>>>   +       va_end(ap);
>>>>   +}
>>>>    #else
>>>>    #define RTE_PMD_DEBUG_TRACE(fmt, args...)
>>>>    #endif
>>>>
>>>> Comments or improvements?
>>
>> Such a function shouldn't malloc() anything. The entire line should fit on
>> the stack (crashing is fine if it does not, then it's probably a bug). We
>> did something in two passes along these lines in mlx5_defs.h (not pretty
>> but
>> quite useful):
>>
>>   /* Allocate a buffer on the stack and fill it with a printf format
>> string. */
>>   #define MKSTR(name, ...) \
>>           char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \
>>           \
>>           snprintf(name, sizeof(name), __VA_ARGS__)
>>
>> Untested but I guess modifying that function accordingly would look like:
>>
>>   static inline void
>>   rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
>>   {
>>           va_list ap;
>>           va_start(ap, fmt);
>>
>>           static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];
>>
>>           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);
>>   }
>>
>
> Looks a much better option.
>
>  From this, though, I assume then that we are only looking to support the -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic with the pre-gcc-5 versions won't allow that to work though, as variably sized arrays only came in with c99, and were gnu extensions before that.
>
> Regards,
> /Bruce
>

I had made some similar changes in the cryptodev patch set to allow 
these macros to be shared between the ethdev and cryptodev, but I wasn't 
aware of the -pedantic build issues. I've incorporate the changes from 
patch 1 & 2 discussed here into the cryptodev patch set. See patch 2/10 
(http://dpdk.org/ml/archives/dev/2015-November/027888.html) for the 
implementation of the rte_pmf_debug_trace function. Any comments or 
ack's are welcome :)

Declan

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-09 14:02                     ` Richardson, Bruce
  2015-11-10 10:31                       ` Declan Doherty
@ 2015-11-10 16:08                       ` Adrien Mazarguil
  2015-11-10 16:21                         ` Richardson, Bruce
  1 sibling, 1 reply; 55+ messages in thread
From: Adrien Mazarguil @ 2015-11-10 16:08 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev

On Mon, Nov 09, 2015 at 02:02:28PM +0000, Richardson, Bruce wrote:
[...]
> > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
[...]
> > Untested but I guess modifying that function accordingly would look like:
> > 
> >  static inline void
> >  rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
> >  {
> >          va_list ap;
> >          va_start(ap, fmt);
> > 
> >          static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];
> > 
> >          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);
> >  }
> > 
> 
> Looks a much better option.
> 
> From this, though, I assume then that we are only looking to support the -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic with the pre-gcc-5 versions won't allow that to work though, as variably sized arrays only came in with c99, and were gnu extensions before that.

Right, -pedantic must follow a given standard such as -std=gnu99 otherwise
it's meaningless.

However pre-GCC 5 is fine for most if not all features we use, see:

 https://gcc.gnu.org/c99status.html

Mixed code and declarations are supported since GCC 3.0, __VA_ARGS__ in
macros since GCC 2.95 and variable length arrays since GCC 0.9, so as long
as we use a version that implements -std=gnu99 (or -std=c99 to be really
pedantic), it's fine.

Besides DPDK already uses C99 extensively, even a few C11 features (such as
embedded anonymous struct definitions) currently supported in C99 mode as
compiler extensions. I think we can safely ignore compilers that don't
support common C99 features.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-10 16:08                       ` Adrien Mazarguil
@ 2015-11-10 16:21                         ` Richardson, Bruce
  2015-11-10 17:12                           ` Adrien Mazarguil
  0 siblings, 1 reply; 55+ messages in thread
From: Richardson, Bruce @ 2015-11-10 16:21 UTC (permalink / raw)
  To: Adrien Mazarguil; +Cc: dev



> -----Original Message-----
> From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> Sent: Tuesday, November 10, 2015 4:08 PM
> To: Richardson, Bruce <bruce.richardson@intel.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Thomas Monjalon
> <thomas.monjalon@6wind.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros
> to header
> 
> On Mon, Nov 09, 2015 at 02:02:28PM +0000, Richardson, Bruce wrote:
> [...]
> > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> [...]
> > > Untested but I guess modifying that function accordingly would look
> like:
> > >
> > >  static inline void
> > >  rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)  {
> > >          va_list ap;
> > >          va_start(ap, fmt);
> > >
> > >          static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];
> > >
> > >          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);  }
> > >
> >
> > Looks a much better option.
> >
> > From this, though, I assume then that we are only looking to support the
> -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic
> with the pre-gcc-5 versions won't allow that to work though, as variably
> sized arrays only came in with c99, and were gnu extensions before that.
> 
> Right, -pedantic must follow a given standard such as -std=gnu99 otherwise
> it's meaningless.
> 
> However pre-GCC 5 is fine for most if not all features we use, see:
> 
>  https://gcc.gnu.org/c99status.html
> 
> Mixed code and declarations are supported since GCC 3.0, __VA_ARGS__ in
> macros since GCC 2.95 and variable length arrays since GCC 0.9, so as long
> as we use a version that implements -std=gnu99 (or -std=c99 to be really
> pedantic), it's fine.
> 
> Besides DPDK already uses C99 extensively, even a few C11 features (such
> as
> embedded anonymous struct definitions) currently supported in C99 mode as
> compiler extensions. I think we can safely ignore compilers that don't
> support common C99 features.
> 
> --
> Adrien Mazarguil
> 6WIND

Actually my point was slightly different. 
If we are supporting "-pedantic" in header files because "we don't know what compiler flags users are going to pass when", then we need to support it in C90 mode to do the job properly. If you take gcc 4.8 and compile some code with "-pedantic" as the only C-flag you are going to get lots of errors because it will default to C90 mode with pedantic, which means no varargs macros at all. 
This limits the usefulness of supporting pedantic flag at all in our header files, since we only support it in certain situations with non-latest compilers.

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-10 16:21                         ` Richardson, Bruce
@ 2015-11-10 17:12                           ` Adrien Mazarguil
  2015-11-11 10:51                             ` Bruce Richardson
  0 siblings, 1 reply; 55+ messages in thread
From: Adrien Mazarguil @ 2015-11-10 17:12 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev

On Tue, Nov 10, 2015 at 04:21:10PM +0000, Richardson, Bruce wrote:
> 
> 
> > -----Original Message-----
> > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> > Sent: Tuesday, November 10, 2015 4:08 PM
> > To: Richardson, Bruce <bruce.richardson@intel.com>
> > Cc: Stephen Hemminger <stephen@networkplumber.org>; Thomas Monjalon
> > <thomas.monjalon@6wind.com>; dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros
> > to header
> > 
> > On Mon, Nov 09, 2015 at 02:02:28PM +0000, Richardson, Bruce wrote:
> > [...]
> > > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> > [...]
> > > > Untested but I guess modifying that function accordingly would look
> > like:
> > > >
> > > >  static inline void
> > > >  rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)  {
> > > >          va_list ap;
> > > >          va_start(ap, fmt);
> > > >
> > > >          static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];
> > > >
> > > >          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);  }
> > > >
> > >
> > > Looks a much better option.
> > >
> > > From this, though, I assume then that we are only looking to support the
> > -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic
> > with the pre-gcc-5 versions won't allow that to work though, as variably
> > sized arrays only came in with c99, and were gnu extensions before that.
> > 
> > Right, -pedantic must follow a given standard such as -std=gnu99 otherwise
> > it's meaningless.
> > 
> > However pre-GCC 5 is fine for most if not all features we use, see:
> > 
> >  https://gcc.gnu.org/c99status.html
> > 
> > Mixed code and declarations are supported since GCC 3.0, __VA_ARGS__ in
> > macros since GCC 2.95 and variable length arrays since GCC 0.9, so as long
> > as we use a version that implements -std=gnu99 (or -std=c99 to be really
> > pedantic), it's fine.
> > 
> > Besides DPDK already uses C99 extensively, even a few C11 features (such
> > as
> > embedded anonymous struct definitions) currently supported in C99 mode as
> > compiler extensions. I think we can safely ignore compilers that don't
> > support common C99 features.
> > 
> > --
> > Adrien Mazarguil
> > 6WIND
> 
> Actually my point was slightly different. 
> If we are supporting "-pedantic" in header files because "we don't know what compiler flags users are going to pass when", then we need to support it in C90 mode to do the job properly. If you take gcc 4.8 and compile some code with "-pedantic" as the only C-flag you are going to get lots of errors because it will default to C90 mode with pedantic, which means no varargs macros at all. 

Agreed, exported headers should actually be C90 compliant for these reasons
but C99 would be a start. I didn't know GCC 5 switched to C99 by default
(don't worry, I do not intend to go back to C90).

> This limits the usefulness of supporting pedantic flag at all in our header files, since we only support it in certain situations with non-latest compilers.

I won't deny this, as the goal is partly to appease pedantic people like
myself. Using standard methods for doing things should be preferred over
extensions for compatibility with the unknown, unless there is no other way.

-- 
Adrien Mazarguil
6WIND

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3 2/4] ethdev: move error checking macros to header
  2015-11-10 17:12                           ` Adrien Mazarguil
@ 2015-11-11 10:51                             ` Bruce Richardson
  0 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-11 10:51 UTC (permalink / raw)
  To: Stephen Hemminger, Thomas Monjalon, dev

On Tue, Nov 10, 2015 at 06:12:28PM +0100, Adrien Mazarguil wrote:
> On Tue, Nov 10, 2015 at 04:21:10PM +0000, Richardson, Bruce wrote:
> > 
> > 
> > > -----Original Message-----
> > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> > > Sent: Tuesday, November 10, 2015 4:08 PM
> > > To: Richardson, Bruce <bruce.richardson@intel.com>
> > > Cc: Stephen Hemminger <stephen@networkplumber.org>; Thomas Monjalon
> > > <thomas.monjalon@6wind.com>; dev@dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros
> > > to header
> > > 
> > > On Mon, Nov 09, 2015 at 02:02:28PM +0000, Richardson, Bruce wrote:
> > > [...]
> > > > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> > > [...]
> > > > > Untested but I guess modifying that function accordingly would look
> > > like:
> > > > >
> > > > >  static inline void
> > > > >  rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)  {
> > > > >          va_list ap;
> > > > >          va_start(ap, fmt);
> > > > >
> > > > >          static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)];
> > > > >
> > > > >          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);  }
> > > > >
> > > >
> > > > Looks a much better option.
> > > >
> > > > From this, though, I assume then that we are only looking to support the
> > > -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic
> > > with the pre-gcc-5 versions won't allow that to work though, as variably
> > > sized arrays only came in with c99, and were gnu extensions before that.
> > > 
> > > Right, -pedantic must follow a given standard such as -std=gnu99 otherwise
> > > it's meaningless.
> > > 
> > > However pre-GCC 5 is fine for most if not all features we use, see:
> > > 
> > >  https://gcc.gnu.org/c99status.html
> > > 
> > > Mixed code and declarations are supported since GCC 3.0, __VA_ARGS__ in
> > > macros since GCC 2.95 and variable length arrays since GCC 0.9, so as long
> > > as we use a version that implements -std=gnu99 (or -std=c99 to be really
> > > pedantic), it's fine.
> > > 
> > > Besides DPDK already uses C99 extensively, even a few C11 features (such
> > > as
> > > embedded anonymous struct definitions) currently supported in C99 mode as
> > > compiler extensions. I think we can safely ignore compilers that don't
> > > support common C99 features.
> > > 
> > > --
> > > Adrien Mazarguil
> > > 6WIND
> > 
> > Actually my point was slightly different. 
> > If we are supporting "-pedantic" in header files because "we don't know what compiler flags users are going to pass when", then we need to support it in C90 mode to do the job properly. If you take gcc 4.8 and compile some code with "-pedantic" as the only C-flag you are going to get lots of errors because it will default to C90 mode with pedantic, which means no varargs macros at all. 
> 
> Agreed, exported headers should actually be C90 compliant for these reasons
> but C99 would be a start. I didn't know GCC 5 switched to C99 by default
> (don't worry, I do not intend to go back to C90).
> 
Actually, it's even better than C99, the default is now C11 (or gnu11 to be pedantic about it :-) )

https://gcc.gnu.org/gcc-5/changes.html

Top line item is: 
	"The default mode for C is now -std=gnu11 instead of -std=gnu89"

I believe clang is making a similar change to a c11-based default. \o/

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v4 0/2] ethdev: debug code cleanup
  2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
                       ` (3 preceding siblings ...)
  2015-11-03 12:00     ` [PATCH v3 4/4] ethdev: check driver support for functions Bruce Richardson
@ 2015-11-17 12:21     ` Bruce Richardson
  2015-11-17 12:21       ` [PATCH v4 1/2] ethdev: remove duplicated debug functions Bruce Richardson
                         ` (2 more replies)
  4 siblings, 3 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-17 12:21 UTC (permalink / raw)
  To: dev

This patchset performs two cleanups:
1. Four functions in ethdev.c which were enabled for debug only have been
  merged into their inlined header-file counterparts. This change required that
  a number of macros be renamed and moved to the header file too. The macro changes
  are in patches 1 & 2, and the elimination of the separate debug fns are in patch 3.
2. Checks for valid function pointers are added to the API calls for reading
  the descriptor ring count, and checking for a valid descriptor. This is because
  these functions are not implemented by most drivers, and so it's far safer to
  have the check.

NOTE: This patchset now depends upon the cryptodev patchset

---

V4 Changes:
* Originally this was a 4-patch set, but patches 1 and 2 duplicated changes being
  made in the patchset to add crypto device support. Therefore this set has
  been reduced to two patches to sit on top of that set.
* As suggested on-list, when adding checks for the function pointers being
  valid we can also add in the similarly lightweight checks for the port id
  being valid.

V3 Changes:
* Rebased to latest DPDK codebase
* Fixed checkpatch issues in patches 2 and 3.

V2 Changes:
* Rebased to latest DPDK codebase
* Changed type from uint32_t to int for the count function, on the basis of
feedback received.

Bruce Richardson (2):
  ethdev: remove duplicated debug functions
  ethdev: add sanity checks to functions

 lib/librte_ether/rte_ethdev.c | 64 -------------------------------------------
 lib/librte_ether/rte_ethdev.h | 62 ++++++++++++++++++++---------------------
 2 files changed, 30 insertions(+), 96 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v4 1/2] ethdev: remove duplicated debug functions
  2015-11-17 12:21     ` [PATCH v4 0/2] ethdev: debug code cleanup Bruce Richardson
@ 2015-11-17 12:21       ` Bruce Richardson
  2015-11-17 12:21       ` [PATCH v4 2/2] ethdev: add sanity checks to functions Bruce Richardson
  2015-11-24 17:37       ` [PATCH v5 0/2] ethdev: debug code cleanup Bruce Richardson
  2 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-17 12:21 UTC (permalink / raw)
  To: dev

The functions for rx/tx burst, for rx_queue_count and descriptor_done in
the ethdev library all had two copies of the code. One copy in
rte_ethdev.h was inlined for performance, while a second was in
rte_ethdev.c for debugging purposes only. We can eliminate the second
copy of the functions by moving the additional debug checks into the
copies of the functions in the header file. [Any compilation for
debugging at optimization level 0 will not inline the function so the
result should be same as when the function was in the .c file.]

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 64 -------------------------------------------
 lib/librte_ether/rte_ethdev.h | 59 ++++++++++++++++++++-------------------
 2 files changed, 29 insertions(+), 94 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f4648ac..739db81 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2439,70 +2439,6 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-uint16_t
-rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_rx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
-						rx_pkts, nb_pkts);
-}
-
-uint16_t
-rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_tx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
-						tx_pkts, nb_pkts);
-}
-
-uint32_t
-rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
-	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
-}
-
-int
-rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
-	return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id],
-						   offset);
-}
-#endif
-
 int
 rte_eth_dev_callback_register(uint8_t port_id,
 			enum rte_eth_event_type event,
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b51b8aa..a00cd46 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2492,18 +2492,21 @@ extern int rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on);
  *   of pointers to *rte_mbuf* structures effectively supplied to the
  *   *rx_pkts* array.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 	int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
 			rx_pkts, nb_pkts);
 
@@ -2521,7 +2524,6 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return nb_rx;
 }
-#endif
 
 /**
  * Get the number of used descriptors in a specific queue
@@ -2533,18 +2535,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @return
  *  The number of used descriptors in the specific queue.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint32_t rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id);
-#else
 static inline uint32_t
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
-        struct rte_eth_dev *dev;
-
-        dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+#endif
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
-#endif
 
 /**
  * Check if the DD bit of the specific RX descriptor in the queue has been set
@@ -2560,21 +2560,17 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern int rte_eth_rx_descriptor_done(uint8_t port_id,
-				      uint16_t queue_id,
-				      uint16_t offset);
-#else
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
-	struct rte_eth_dev *dev;
-
-	dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+#endif
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-#endif
 
 /**
  * Send a burst of output packets on a transmit queue of an Ethernet device.
@@ -2634,17 +2630,21 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
  *   the transmit ring. The return value can be less than the value of the
  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 
-	dev = &rte_eth_devices[port_id];
+	if (queue_id >= dev->data->nb_tx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 
 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
 	struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
@@ -2660,7 +2660,6 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
 }
-#endif
 
 /**
  * The eth device event type for interrupt, and maybe others in the future.
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v4 2/2] ethdev: add sanity checks to functions
  2015-11-17 12:21     ` [PATCH v4 0/2] ethdev: debug code cleanup Bruce Richardson
  2015-11-17 12:21       ` [PATCH v4 1/2] ethdev: remove duplicated debug functions Bruce Richardson
@ 2015-11-17 12:21       ` Bruce Richardson
  2015-11-17 15:53         ` Stephen Hemminger
  2015-11-24 17:37       ` [PATCH v5 0/2] ethdev: debug code cleanup Bruce Richardson
  2 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-17 12:21 UTC (permalink / raw)
  To: dev

The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
supported by very few PMDs. Therefore, it is best to check for support
for the functions in the ethdev library, so as to avoid run-time crashes
at run-time if the application goes to use those APIs. Similarly, the
port parameter should also be checked for validity.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

---
 lib/librte_ether/rte_ethdev.h | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index a00cd46..028be59 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2533,16 +2533,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @param queue_id
  *  The queue id on the specific port.
  * @return
- *  The number of used descriptors in the specific queue.
+ *  The number of used descriptors in the specific queue, or:
+ *     (-EINVAL) if *port_id* is invalid
+ *     (-ENOTSUP) if the device does not support this function
  */
-static inline uint32_t
+static inline int
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
-#endif
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -2559,15 +2559,14 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (1) if the specific DD bit is set.
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
+ *  - (-ENOTSUP) if the device does not support this function
  */
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
-#endif
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: [PATCH v4 2/2] ethdev: add sanity checks to functions
  2015-11-17 12:21       ` [PATCH v4 2/2] ethdev: add sanity checks to functions Bruce Richardson
@ 2015-11-17 15:53         ` Stephen Hemminger
  2015-11-24 14:56           ` Bruce Richardson
  0 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2015-11-17 15:53 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Tue, 17 Nov 2015 12:21:07 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:

> The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
> supported by very few PMDs. Therefore, it is best to check for support
> for the functions in the ethdev library, so as to avoid run-time crashes
> at run-time if the application goes to use those APIs. Similarly, the
> port parameter should also be checked for validity.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> ---
>  lib/librte_ether/rte_ethdev.h | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index a00cd46..028be59 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -2533,16 +2533,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
>   * @param queue_id
>   *  The queue id on the specific port.
>   * @return
> - *  The number of used descriptors in the specific queue.
> + *  The number of used descriptors in the specific queue, or:
> + *     (-EINVAL) if *port_id* is invalid
> + *     (-ENOTSUP) if the device does not support this function
>   */
> -static inline uint32_t
> +static inline int
>  rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
>  {
>  	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
> -#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> -	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
> -	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
> -#endif
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
> +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
>          return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
>  }
>  
> @@ -2559,15 +2559,14 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
>   *  - (1) if the specific DD bit is set.
>   *  - (0) if the specific DD bit is not set.
>   *  - (-ENODEV) if *port_id* invalid.
> + *  - (-ENOTSUP) if the device does not support this function
>   */
>  static inline int
>  rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
>  {
>  	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
> -#ifdef RTE_LIBRTE_ETHDEV_DEBUG
>  	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
> -#endif
>  	return (*dev->dev_ops->rx_descriptor_done)( \
>  		dev->data->rx_queues[queue_id], offset);
>  }

This breaks ABI since older application built with debug will try
and find the shared library entry for the routine.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v4 2/2] ethdev: add sanity checks to functions
  2015-11-17 15:53         ` Stephen Hemminger
@ 2015-11-24 14:56           ` Bruce Richardson
  2015-11-24 15:29             ` Thomas Monjalon
  0 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-24 14:56 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Tue, Nov 17, 2015 at 07:53:09AM -0800, Stephen Hemminger wrote:
> On Tue, 17 Nov 2015 12:21:07 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
> 
> > The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
> > supported by very few PMDs. Therefore, it is best to check for support
> > for the functions in the ethdev library, so as to avoid run-time crashes
> > at run-time if the application goes to use those APIs. Similarly, the
> > port parameter should also be checked for validity.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > 
> > ---
> >  lib/librte_ether/rte_ethdev.h | 15 +++++++--------
> >  1 file changed, 7 insertions(+), 8 deletions(-)
> > 
> > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > index a00cd46..028be59 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -2533,16 +2533,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
> >   * @param queue_id
> >   *  The queue id on the specific port.
> >   * @return
> > - *  The number of used descriptors in the specific queue.
> > + *  The number of used descriptors in the specific queue, or:
> > + *     (-EINVAL) if *port_id* is invalid
> > + *     (-ENOTSUP) if the device does not support this function
> >   */
> > -static inline uint32_t
> > +static inline int
> >  rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
> >  {
> >  	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
> > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > -	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
> > -	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
> > -#endif
> > +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
> > +	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
> >          return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
> >  }
> >  
> > @@ -2559,15 +2559,14 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
> >   *  - (1) if the specific DD bit is set.
> >   *  - (0) if the specific DD bit is not set.
> >   *  - (-ENODEV) if *port_id* invalid.
> > + *  - (-ENOTSUP) if the device does not support this function
> >   */
> >  static inline int
> >  rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
> >  {
> >  	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
> > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> >  	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
> >  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
> > -#endif
> >  	return (*dev->dev_ops->rx_descriptor_done)( \
> >  		dev->data->rx_queues[queue_id], offset);
> >  }
> 
> This breaks ABI since older application built with debug will try
> and find the shared library entry for the routine.

Ok, so assuming we care about the ABI for debug builds, is it enough to just
push a patch with a deprecation notice for this for 2.2, or do I need to see about
doing a new patchset with the NEXT_ABI macros included in it? My preference is
obviously for the former.

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v4 2/2] ethdev: add sanity checks to functions
  2015-11-24 14:56           ` Bruce Richardson
@ 2015-11-24 15:29             ` Thomas Monjalon
  2015-11-24 15:45               ` Bruce Richardson
  0 siblings, 1 reply; 55+ messages in thread
From: Thomas Monjalon @ 2015-11-24 15:29 UTC (permalink / raw)
  To: Bruce Richardson, Stephen Hemminger; +Cc: dev

2015-11-24 14:56, Bruce Richardson:
> On Tue, Nov 17, 2015 at 07:53:09AM -0800, Stephen Hemminger wrote:
> > On Tue, 17 Nov 2015 12:21:07 +0000
> > Bruce Richardson <bruce.richardson@intel.com> wrote:
> > > -static inline uint32_t
> > > +static inline int

Are we talking about this change only?
Or the move in the first patch from .c to .h?

[...]
> > This breaks ABI since older application built with debug will try
> > and find the shared library entry for the routine.
> 
> Ok, so assuming we care about the ABI for debug builds,

The return type is not only for debug build?

> is it enough to just push a patch with a deprecation notice for this for 2.2,

The ABI is already broken for ethdev in 2.2.
So the symbol move should not hurt more.
And the API change (return type) should not be a big deal,
but at least an API change notification is required in the release notes.
Other opinion?

> or do I need to see about doing a new patchset with the NEXT_ABI macros
> included in it? My preference is obviously for the former.

No NEXT_ABI is required when ABI is already broken IMHO.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v4 2/2] ethdev: add sanity checks to functions
  2015-11-24 15:29             ` Thomas Monjalon
@ 2015-11-24 15:45               ` Bruce Richardson
  2015-11-24 15:48                 ` Thomas Monjalon
  0 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-24 15:45 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Tue, Nov 24, 2015 at 04:29:12PM +0100, Thomas Monjalon wrote:
> 2015-11-24 14:56, Bruce Richardson:
> > On Tue, Nov 17, 2015 at 07:53:09AM -0800, Stephen Hemminger wrote:
> > > On Tue, 17 Nov 2015 12:21:07 +0000
> > > Bruce Richardson <bruce.richardson@intel.com> wrote:
> > > > -static inline uint32_t
> > > > +static inline int
> 
> Are we talking about this change only?
> Or the move in the first patch from .c to .h?
> 

The move is the ABI breaker.

> [...]
> > > This breaks ABI since older application built with debug will try
> > > and find the shared library entry for the routine.
> > 
> > Ok, so assuming we care about the ABI for debug builds,
> 
> The return type is not only for debug build?
> 
> > is it enough to just push a patch with a deprecation notice for this for 2.2,
> 
> The ABI is already broken for ethdev in 2.2.
> So the symbol move should not hurt more.
> And the API change (return type) should not be a big deal,
> but at least an API change notification is required in the release notes.
> Other opinion?

Ok, it makes sense.

> 
> > or do I need to see about doing a new patchset with the NEXT_ABI macros
> > included in it? My preference is obviously for the former.
> 
> No NEXT_ABI is required when ABI is already broken IMHO.

If ethdev ABI is already broken, then sure, this additional break for debug
build is no big deal, I think.

I can do a respin of these two patches to include an API note for release notes.
However, I see now that I also need to remove the functions from the map file.
I could do with some help to make sure I do this correctly though. Reading through
the doc on ABI versionning, it looks like I should completely move all existing
functions from the existing release versions and move them to a new 2.2 section,
dropping the four now-inline functions along the way. Is this the correct thing
to do?

/Bruce

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v4 2/2] ethdev: add sanity checks to functions
  2015-11-24 15:45               ` Bruce Richardson
@ 2015-11-24 15:48                 ` Thomas Monjalon
  0 siblings, 0 replies; 55+ messages in thread
From: Thomas Monjalon @ 2015-11-24 15:48 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

2015-11-24 15:45, Bruce Richardson:
> On Tue, Nov 24, 2015 at 04:29:12PM +0100, Thomas Monjalon wrote:
> > 2015-11-24 14:56, Bruce Richardson:
> > > On Tue, Nov 17, 2015 at 07:53:09AM -0800, Stephen Hemminger wrote:
> > > > On Tue, 17 Nov 2015 12:21:07 +0000
> > > > Bruce Richardson <bruce.richardson@intel.com> wrote:
> > > > > -static inline uint32_t
> > > > > +static inline int
> > 
> > Are we talking about this change only?
> > Or the move in the first patch from .c to .h?
> > 
> 
> The move is the ABI breaker.
> 
> > [...]
> > > > This breaks ABI since older application built with debug will try
> > > > and find the shared library entry for the routine.
> > > 
> > > Ok, so assuming we care about the ABI for debug builds,
> > 
> > The return type is not only for debug build?
> > 
> > > is it enough to just push a patch with a deprecation notice for this for 2.2,
> > 
> > The ABI is already broken for ethdev in 2.2.
> > So the symbol move should not hurt more.
> > And the API change (return type) should not be a big deal,
> > but at least an API change notification is required in the release notes.
> > Other opinion?
> 
> Ok, it makes sense.
> 
> > 
> > > or do I need to see about doing a new patchset with the NEXT_ABI macros
> > > included in it? My preference is obviously for the former.
> > 
> > No NEXT_ABI is required when ABI is already broken IMHO.
> 
> If ethdev ABI is already broken, then sure, this additional break for debug
> build is no big deal, I think.
> 
> I can do a respin of these two patches to include an API note for release notes.
> However, I see now that I also need to remove the functions from the map file.
> I could do with some help to make sure I do this correctly though. Reading through
> the doc on ABI versionning, it looks like I should completely move all existing
> functions from the existing release versions and move them to a new 2.2 section,
> dropping the four now-inline functions along the way. Is this the correct thing
> to do?

I think yes.
Removing some symbols means rewriting the symbol map from scratch.
But we never did it yet.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v5 0/2] ethdev: debug code cleanup
  2015-11-17 12:21     ` [PATCH v4 0/2] ethdev: debug code cleanup Bruce Richardson
  2015-11-17 12:21       ` [PATCH v4 1/2] ethdev: remove duplicated debug functions Bruce Richardson
  2015-11-17 12:21       ` [PATCH v4 2/2] ethdev: add sanity checks to functions Bruce Richardson
@ 2015-11-24 17:37       ` Bruce Richardson
  2015-11-24 17:37         ` [PATCH v5 1/2] ethdev: remove duplicated debug functions Bruce Richardson
                           ` (2 more replies)
  2 siblings, 3 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-24 17:37 UTC (permalink / raw)
  To: dev

This patchset performs two cleanups:
1. Four functions in ethdev.c which were enabled for debug only have been
  merged into their inlined header-file counterparts. This change required that
  a number of macros be renamed and moved to the header file too. The macro changes
  are in patches 1 & 2, and the elimination of the separate debug fns are in patch 3.
2. Checks for valid function pointers are added to the API calls for reading
  the descriptor ring count, and checking for a valid descriptor. This is because
  these functions are not implemented by most drivers, and so it's far safer to
  have the check.

NOTE: This patchset now depends upon the cryptodev patchset

---

V5 Changes:
* Remove the 4 debug functions from the map file and, as a result of this, move all
  previous functions to the new 2_2 version, sorting them alphabetically.
* Update release notes to cover ABI change
* Update release notes to cover API change for the rx_count() function 

V4 Changes:
* Originally this was a 4-patch set, but patches 1 and 2 duplicated changes being
  made in the patchset to add crypto device support. Therefore this set has
  been reduced to two patches to sit on top of that set.
* As suggested on-list, when adding checks for the function pointers being
  valid we can also add in the similarly lightweight checks for the port id
  being valid.

V3 Changes:
* Rebased to latest DPDK codebase
* Fixed checkpatch issues in patches 2 and 3.

V2 Changes:
* Rebased to latest DPDK codebase
* Changed type from uint32_t to int for the count function, on the basis of
  feedback received.

Bruce Richardson (2):
  ethdev: remove duplicated debug functions
  ethdev: add sanity checks to functions

 doc/guides/rel_notes/release_2_2.rst   |  7 ++++
 lib/librte_ether/rte_ethdev.c          | 64 ---------------------------------
 lib/librte_ether/rte_ethdev.h          | 62 ++++++++++++++++----------------
 lib/librte_ether/rte_ether_version.map | 66 +++++++++++++---------------------
 4 files changed, 61 insertions(+), 138 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v5 1/2] ethdev: remove duplicated debug functions
  2015-11-24 17:37       ` [PATCH v5 0/2] ethdev: debug code cleanup Bruce Richardson
@ 2015-11-24 17:37         ` Bruce Richardson
  2015-11-25 18:14           ` Thomas Monjalon
  2015-11-24 17:37         ` [PATCH v5 2/2] ethdev: add sanity checks to functions Bruce Richardson
  2015-11-25 18:21         ` [PATCH v5 0/2] ethdev: debug code cleanup Thomas Monjalon
  2 siblings, 1 reply; 55+ messages in thread
From: Bruce Richardson @ 2015-11-24 17:37 UTC (permalink / raw)
  To: dev

The functions for rx/tx burst, for rx_queue_count and descriptor_done in
the ethdev library all had two copies of the code. One copy in
rte_ethdev.h was inlined for performance, while a second was in
rte_ethdev.c for debugging purposes only. We can eliminate the second
copy of the functions by moving the additional debug checks into the
copies of the functions in the header file. [Any compilation for
debugging at optimization level 0 will not inline the function so the
result should be same as when the function was in the .c file.]

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 doc/guides/rel_notes/release_2_2.rst   |  5 +++
 lib/librte_ether/Makefile              |  2 +-
 lib/librte_ether/rte_ethdev.c          | 64 ---------------------------------
 lib/librte_ether/rte_ethdev.h          | 59 +++++++++++++++---------------
 lib/librte_ether/rte_ether_version.map | 66 +++++++++++++---------------------
 5 files changed, 59 insertions(+), 137 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst
index 8c77768..d39bf75 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -297,6 +297,11 @@ ABI Changes
 * librte_cfgfile: Allow longer names and values by increasing the constants
   CFG_NAME_LEN and CFG_VALUE_LEN to 64 and 256 respectively.
 
+* For debug builds, the functions rte_eth_rx_burst(), rte_eth_tx_burst()
+  rte_eth_rx_descriptor_done() and rte_eth_rx_queue_count() will
+  no longer be separate functions in the DPDK libraries. Instead, they will
+  only be present in the rte_ethdev.h header file.
+
 
 Shared Library Versions
 -----------------------
diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile
index 3e81a0e..e810284 100644
--- a/lib/librte_ether/Makefile
+++ b/lib/librte_ether/Makefile
@@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
 
 EXPORT_MAP := rte_ether_version.map
 
-LIBABIVER := 2
+LIBABIVER := 3
 
 SRCS-y += rte_ethdev.c
 
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f82b3a9..3840775 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2451,70 +2451,6 @@ rte_eth_mirror_rule_reset(uint8_t port_id, uint8_t rule_id)
 	return (*dev->dev_ops->mirror_rule_reset)(dev, rule_id);
 }
 
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-uint16_t
-rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_rx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
-						rx_pkts, nb_pkts);
-}
-
-uint16_t
-rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
-	if (queue_id >= dev->data->nb_tx_queues) {
-		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
-		return 0;
-	}
-	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id],
-						tx_pkts, nb_pkts);
-}
-
-uint32_t
-rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
-	return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
-}
-
-int
-rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
-{
-	struct rte_eth_dev *dev;
-
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
-
-	dev = &rte_eth_devices[port_id];
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
-	return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id],
-						   offset);
-}
-#endif
-
 int
 rte_eth_dev_callback_register(uint8_t port_id,
 			enum rte_eth_event_type event,
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b51b8aa..9fca6ba 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2492,18 +2492,21 @@ extern int rte_eth_dev_set_vlan_pvid(uint8_t port_id, uint16_t pvid, int on);
  *   of pointers to *rte_mbuf* structures effectively supplied to the
  *   *rx_pkts* array.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 
-	dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0);
 
+	if (queue_id >= dev->data->nb_rx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 	int16_t nb_rx = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id],
 			rx_pkts, nb_pkts);
 
@@ -2521,7 +2524,6 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return nb_rx;
 }
-#endif
 
 /**
  * Get the number of used descriptors in a specific queue
@@ -2533,18 +2535,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @return
  *  The number of used descriptors in the specific queue.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint32_t rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id);
-#else
 static inline uint32_t
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
-        struct rte_eth_dev *dev;
-
-        dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
+#endif
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
-#endif
 
 /**
  * Check if the DD bit of the specific RX descriptor in the queue has been set
@@ -2560,21 +2560,17 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern int rte_eth_rx_descriptor_done(uint8_t port_id,
-				      uint16_t queue_id,
-				      uint16_t offset);
-#else
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
-	struct rte_eth_dev *dev;
-
-	dev = &rte_eth_devices[port_id];
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
+#endif
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-#endif
 
 /**
  * Send a burst of output packets on a transmit queue of an Ethernet device.
@@ -2634,17 +2630,21 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
  *   the transmit ring. The return value can be less than the value of the
  *   *tx_pkts* parameter when the transmit ring is full or has been filled up.
  */
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-extern uint16_t rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
-				 struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-#else
 static inline uint16_t
 rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 		 struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
-	struct rte_eth_dev *dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+
+#ifdef RTE_LIBRTE_ETHDEV_DEBUG
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0);
 
-	dev = &rte_eth_devices[port_id];
+	if (queue_id >= dev->data->nb_tx_queues) {
+		RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id);
+		return 0;
+	}
+#endif
 
 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
 	struct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];
@@ -2660,7 +2660,6 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
 
 	return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);
 }
-#endif
 
 /**
  * The eth device event type for interrupt, and maybe others in the future.
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 0c35d53..431fe9c 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -1,4 +1,4 @@
-DPDK_2.0 {
+DPDK_2.2 {
 	global:
 
 	_rte_eth_dev_callback_process;
@@ -7,6 +7,7 @@ DPDK_2.0 {
 	rte_eth_allmulticast_disable;
 	rte_eth_allmulticast_enable;
 	rte_eth_allmulticast_get;
+	rte_eth_copy_pci_info;
 	rte_eth_dev_allocate;
 	rte_eth_dev_allocated;
 	rte_eth_dev_attach;
@@ -24,6 +25,7 @@ DPDK_2.0 {
 	rte_eth_dev_close;
 	rte_eth_dev_configure;
 	rte_eth_dev_count;
+	rte_eth_dev_default_mac_addr_set;
 	rte_eth_dev_detach;
 	rte_eth_dev_fdir_add_perfect_filter;
 	rte_eth_dev_fdir_add_signature_filter;
@@ -37,9 +39,16 @@ DPDK_2.0 {
 	rte_eth_dev_filter_supported;
 	rte_eth_dev_flow_ctrl_get;
 	rte_eth_dev_flow_ctrl_set;
+	rte_eth_dev_get_dcb_info;
+	rte_eth_dev_get_eeprom;
+	rte_eth_dev_get_eeprom_length;
 	rte_eth_dev_get_mtu;
+	rte_eth_dev_get_reg_info;
+	rte_eth_dev_get_reg_length;
 	rte_eth_dev_get_vlan_offload;
+	rte_eth_devices;
 	rte_eth_dev_info_get;
+	rte_eth_dev_is_valid_port;
 	rte_eth_dev_mac_addr_add;
 	rte_eth_dev_mac_addr_remove;
 	rte_eth_dev_priority_flow_ctrl_set;
@@ -48,10 +57,16 @@ DPDK_2.0 {
 	rte_eth_dev_rss_hash_update;
 	rte_eth_dev_rss_reta_query;
 	rte_eth_dev_rss_reta_update;
+	rte_eth_dev_rx_intr_ctl;
+	rte_eth_dev_rx_intr_ctl_q;
+	rte_eth_dev_rx_intr_disable;
+	rte_eth_dev_rx_intr_enable;
 	rte_eth_dev_rx_queue_start;
 	rte_eth_dev_rx_queue_stop;
+	rte_eth_dev_set_eeprom;
 	rte_eth_dev_set_link_down;
 	rte_eth_dev_set_link_up;
+	rte_eth_dev_set_mc_addr_list;
 	rte_eth_dev_set_mtu;
 	rte_eth_dev_set_rx_queue_stats_mapping;
 	rte_eth_dev_set_tx_queue_stats_mapping;
@@ -74,7 +89,7 @@ DPDK_2.0 {
 	rte_eth_dev_udp_tunnel_delete;
 	rte_eth_dev_vlan_filter;
 	rte_eth_dev_wd_timeout_store;
-	rte_eth_devices;
+	rte_eth_dma_zone_reserve;
 	rte_eth_driver_register;
 	rte_eth_led_off;
 	rte_eth_led_on;
@@ -89,55 +104,22 @@ DPDK_2.0 {
 	rte_eth_promiscuous_get;
 	rte_eth_remove_rx_callback;
 	rte_eth_remove_tx_callback;
-	rte_eth_rx_burst;
-	rte_eth_rx_descriptor_done;
-	rte_eth_rx_queue_count;
+	rte_eth_rx_queue_info_get;
 	rte_eth_rx_queue_setup;
 	rte_eth_set_queue_rate_limit;
 	rte_eth_set_vf_rate_limit;
 	rte_eth_stats;
 	rte_eth_stats_get;
 	rte_eth_stats_reset;
-	rte_eth_tx_burst;
-	rte_eth_tx_queue_setup;
-	rte_eth_xstats_get;
-	rte_eth_xstats_reset;
-
-	local: *;
-};
-
-DPDK_2.1 {
-	global:
-
-	rte_eth_dev_default_mac_addr_set;
-	rte_eth_dev_get_eeprom;
-	rte_eth_dev_get_eeprom_length;
-	rte_eth_dev_get_reg_info;
-	rte_eth_dev_get_reg_length;
-	rte_eth_dev_is_valid_port;
-	rte_eth_dev_rx_intr_ctl;
-	rte_eth_dev_rx_intr_ctl_q;
-	rte_eth_dev_rx_intr_disable;
-	rte_eth_dev_rx_intr_enable;
-	rte_eth_dev_set_eeprom;
-	rte_eth_dev_set_mc_addr_list;
+	rte_eth_timesync_adjust_time;
 	rte_eth_timesync_disable;
 	rte_eth_timesync_enable;
 	rte_eth_timesync_read_rx_timestamp;
-	rte_eth_timesync_read_tx_timestamp;
-
-} DPDK_2.0;
-
-DPDK_2.2 {
-	global:
-
-	rte_eth_copy_pci_info;
-	rte_eth_dev_get_dcb_info;
-	rte_eth_dma_zone_reserve;
-	rte_eth_rx_queue_info_get;
-	rte_eth_timesync_adjust_time;
 	rte_eth_timesync_read_time;
+	rte_eth_timesync_read_tx_timestamp;
 	rte_eth_timesync_write_time;
 	rte_eth_tx_queue_info_get;
-
-} DPDK_2.1;
+	rte_eth_tx_queue_setup;
+	rte_eth_xstats_get;
+	rte_eth_xstats_reset;
+};
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH v5 2/2] ethdev: add sanity checks to functions
  2015-11-24 17:37       ` [PATCH v5 0/2] ethdev: debug code cleanup Bruce Richardson
  2015-11-24 17:37         ` [PATCH v5 1/2] ethdev: remove duplicated debug functions Bruce Richardson
@ 2015-11-24 17:37         ` Bruce Richardson
  2015-11-25 18:21         ` [PATCH v5 0/2] ethdev: debug code cleanup Thomas Monjalon
  2 siblings, 0 replies; 55+ messages in thread
From: Bruce Richardson @ 2015-11-24 17:37 UTC (permalink / raw)
  To: dev

The functions rte_eth_rx_queue_count and rte_eth_descriptor_done are
supported by very few PMDs. Therefore, it is best to check for support
for the functions in the ethdev library, so as to avoid run-time crashes
at run-time if the application goes to use those APIs. Similarly, the
port parameter should also be checked for validity.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 doc/guides/rel_notes/release_2_2.rst |  2 ++
 lib/librte_ether/rte_ethdev.h        | 15 +++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst
index d39bf75..5b2ac63 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -259,6 +259,8 @@ API Changes
 
 * The devargs union field virtual is renamed to virt for C++ compatibility.
 
+* The rte_eth_rx_queue_count() ethdev API now returns "int" instead of "uint32_t"
+  to allow the use of negative values as error codes on return
 
 ABI Changes
 -----------
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9fca6ba..1ff29e2 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -2533,16 +2533,16 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
  * @param queue_id
  *  The queue id on the specific port.
  * @return
- *  The number of used descriptors in the specific queue.
+ *  The number of used descriptors in the specific queue, or:
+ *     (-EINVAL) if *port_id* is invalid
+ *     (-ENOTSUP) if the device does not support this function
  */
-static inline uint32_t
+static inline int
 rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
-	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0);
-	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0);
-#endif
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
         return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
 }
 
@@ -2559,15 +2559,14 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
  *  - (1) if the specific DD bit is set.
  *  - (0) if the specific DD bit is not set.
  *  - (-ENODEV) if *port_id* invalid.
+ *  - (-ENOTSUP) if the device does not support this function
  */
 static inline int
 rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-#ifdef RTE_LIBRTE_ETHDEV_DEBUG
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP);
-#endif
 	return (*dev->dev_ops->rx_descriptor_done)( \
 		dev->data->rx_queues[queue_id], offset);
 }
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: [PATCH v5 1/2] ethdev: remove duplicated debug functions
  2015-11-24 17:37         ` [PATCH v5 1/2] ethdev: remove duplicated debug functions Bruce Richardson
@ 2015-11-25 18:14           ` Thomas Monjalon
  0 siblings, 0 replies; 55+ messages in thread
From: Thomas Monjalon @ 2015-11-25 18:14 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

2015-11-24 17:37, Bruce Richardson:
> --- a/lib/librte_ether/Makefile
> +++ b/lib/librte_ether/Makefile
> @@ -41,7 +41,7 @@ CFLAGS += $(WERROR_FLAGS)
>  
>  EXPORT_MAP := rte_ether_version.map
>  
> -LIBABIVER := 2
> +LIBABIVER := 3

This number has already been increased at the beginning of this release cycle.
I will drop this change.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v5 0/2] ethdev: debug code cleanup
  2015-11-24 17:37       ` [PATCH v5 0/2] ethdev: debug code cleanup Bruce Richardson
  2015-11-24 17:37         ` [PATCH v5 1/2] ethdev: remove duplicated debug functions Bruce Richardson
  2015-11-24 17:37         ` [PATCH v5 2/2] ethdev: add sanity checks to functions Bruce Richardson
@ 2015-11-25 18:21         ` Thomas Monjalon
  2 siblings, 0 replies; 55+ messages in thread
From: Thomas Monjalon @ 2015-11-25 18:21 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

2015-11-24 17:37, Bruce Richardson:
> This patchset performs two cleanups:
> 1. Four functions in ethdev.c which were enabled for debug only have been
>   merged into their inlined header-file counterparts. This change required that
>   a number of macros be renamed and moved to the header file too. The macro changes
>   are in patches 1 & 2, and the elimination of the separate debug fns are in patch 3.
> 2. Checks for valid function pointers are added to the API calls for reading
>   the descriptor ring count, and checking for a valid descriptor. This is because
>   these functions are not implemented by most drivers, and so it's far safer to
>   have the check.
> 
> NOTE: This patchset now depends upon the cryptodev patchset

Applied with small changes, thanks

^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2015-11-25 18:22 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 11:28 [PATCH 0/4] ethdev: Add checks for function support in driver Bruce Richardson
2015-06-12 11:28 ` [PATCH 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
2015-06-12 11:28 ` [PATCH 2/4] ethdev: move RTE_ETH_FPTR_OR_ERR macros to header Bruce Richardson
2015-06-12 11:28 ` [PATCH 3/4] ethdev: remove duplicated debug functions Bruce Richardson
2015-06-12 11:28 ` [PATCH 4/4] ethdev: check support for rx_queue_count and descriptor_done fns Bruce Richardson
2015-06-12 17:32   ` Roger B. Melton
2015-06-15 10:14     ` Bruce Richardson
2015-07-06 15:11       ` Thomas Monjalon
2015-07-26 20:44         ` Thomas Monjalon
2015-09-09 15:09 ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
2015-09-09 15:09   ` [PATCH v2 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
2015-09-09 15:09   ` [PATCH v2 2/4] ethdev: move error checking macros to header Bruce Richardson
2015-09-09 15:09   ` [PATCH v2 3/4] ethdev: remove duplicated debug functions Bruce Richardson
2015-09-09 15:09   ` [PATCH v2 4/4] ethdev: check driver support for functions Bruce Richardson
2015-09-28 10:23   ` [PATCH v2 0/4] ethdev: minor cleanup Bruce Richardson
2015-11-03  1:11     ` Thomas Monjalon
2015-11-03 10:06       ` Bruce Richardson
2015-11-03 12:00   ` [PATCH v3 " Bruce Richardson
2015-11-03 12:00     ` [PATCH v3 1/4] ethdev: rename macros to have RTE_ETH prefix Bruce Richardson
2015-11-03 12:00     ` [PATCH v3 2/4] ethdev: move error checking macros to header Bruce Richardson
2015-11-04  1:19       ` Thomas Monjalon
2015-11-04 10:24         ` Adrien Mazarguil
2015-11-04 14:10           ` Bruce Richardson
2015-11-04 15:25             ` Adrien Mazarguil
2015-11-04 18:39           ` Stephen Hemminger
2015-11-05 15:09             ` Adrien Mazarguil
2015-11-05 15:17               ` Bruce Richardson
2015-11-06 11:49               ` Bruce Richardson
2015-11-06 17:10               ` Bruce Richardson
2015-11-06 17:22                 ` Bruce Richardson
2015-11-09 13:39                   ` Adrien Mazarguil
2015-11-09 13:50                     ` Adrien Mazarguil
2015-11-09 14:02                     ` Richardson, Bruce
2015-11-10 10:31                       ` Declan Doherty
2015-11-10 16:08                       ` Adrien Mazarguil
2015-11-10 16:21                         ` Richardson, Bruce
2015-11-10 17:12                           ` Adrien Mazarguil
2015-11-11 10:51                             ` Bruce Richardson
2015-11-03 12:00     ` [PATCH v3 3/4] ethdev: remove duplicated debug functions Bruce Richardson
2015-11-03 12:00     ` [PATCH v3 4/4] ethdev: check driver support for functions Bruce Richardson
2015-11-03 22:00       ` Stephen Hemminger
2015-11-04 14:15         ` Bruce Richardson
2015-11-17 12:21     ` [PATCH v4 0/2] ethdev: debug code cleanup Bruce Richardson
2015-11-17 12:21       ` [PATCH v4 1/2] ethdev: remove duplicated debug functions Bruce Richardson
2015-11-17 12:21       ` [PATCH v4 2/2] ethdev: add sanity checks to functions Bruce Richardson
2015-11-17 15:53         ` Stephen Hemminger
2015-11-24 14:56           ` Bruce Richardson
2015-11-24 15:29             ` Thomas Monjalon
2015-11-24 15:45               ` Bruce Richardson
2015-11-24 15:48                 ` Thomas Monjalon
2015-11-24 17:37       ` [PATCH v5 0/2] ethdev: debug code cleanup Bruce Richardson
2015-11-24 17:37         ` [PATCH v5 1/2] ethdev: remove duplicated debug functions Bruce Richardson
2015-11-25 18:14           ` Thomas Monjalon
2015-11-24 17:37         ` [PATCH v5 2/2] ethdev: add sanity checks to functions Bruce Richardson
2015-11-25 18:21         ` [PATCH v5 0/2] ethdev: debug code cleanup Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.