DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] bb/null: fix exported dynamic log type
@ 2018-02-05 22:27 Amr Mokhtar
  2018-02-06  0:41 ` Thomas Monjalon
  2018-02-06 13:29 ` [dpdk-dev] [PATCH v2] bbdev: " Amr Mokhtar
  0 siblings, 2 replies; 4+ messages in thread
From: Amr Mokhtar @ 2018-02-05 22:27 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, Amr Mokhtar

This patch fixes shared library compilation due to undefined
reference to an exported variable 'bbdev_logtype'.
In this fix, the logtype is converted to static in the bbdev lib
and in the bbdev null pmd.

Fixes: 7dc2b1589440 ("bb/null: add null base band device driver")
Cc: thomas@monjalon.net

Signed-off-by: Amr Mokhtar <amr.mokhtar@intel.com>
---
 drivers/bbdev/null/bbdev_null.c        |  30 ++++---
 lib/librte_bbdev/rte_bbdev.c           | 154 +++++++++++++++++----------------
 lib/librte_bbdev/rte_bbdev.h           |  28 +-----
 lib/librte_bbdev/rte_bbdev_op.h        |  68 +--------------
 lib/librte_bbdev/rte_bbdev_version.map |   1 -
 5 files changed, 104 insertions(+), 177 deletions(-)

diff --git a/drivers/bbdev/null/bbdev_null.c b/drivers/bbdev/null/bbdev_null.c
index b23d766..3b5482a 100644
--- a/drivers/bbdev/null/bbdev_null.c
+++ b/drivers/bbdev/null/bbdev_null.c
@@ -15,6 +15,13 @@
 
 #define DRIVER_NAME bbdev_null
 
+/* NULL BBDev logging ID */
+static int bbdev_null_logtype;
+
+/* Helper macro for logging */
+#define BBDEV_NULL_LOG(level, fmt, ...) \
+	rte_log(RTE_LOG_ ## level, bbdev_null_logtype, fmt "\n", ##__VA_ARGS__)
+
 /*  Initialisation params structure that can be used by null BBDEV driver */
 struct bbdev_null_params {
 	int socket_id;  /*< Null BBDEV socket */
@@ -66,7 +73,7 @@ info_get(struct rte_bbdev *dev, struct rte_bbdev_driver_info *dev_info)
 	dev_info->cpu_flag_reqs = NULL;
 	dev_info->min_alignment = 0;
 
-	rte_bbdev_log_debug("got device info from %u", dev->data->dev_id);
+	BBDEV_NULL_LOG(DEBUG, "got device info from %u", dev->data->dev_id);
 }
 
 /* Release queue */
@@ -81,7 +88,7 @@ q_release(struct rte_bbdev *dev, uint16_t q_id)
 		dev->data->queues[q_id].queue_private = NULL;
 	}
 
-	rte_bbdev_log_debug("released device queue %u:%u",
+	BBDEV_NULL_LOG(DEBUG, "released device queue %u:%u",
 			dev->data->dev_id, q_id);
 	return 0;
 }
@@ -100,19 +107,19 @@ q_setup(struct rte_bbdev *dev, uint16_t q_id,
 	q = rte_zmalloc_socket(RTE_STR(DRIVER_NAME), sizeof(*q),
 			RTE_CACHE_LINE_SIZE, queue_conf->socket);
 	if (q == NULL) {
-		rte_bbdev_log(ERR, "Failed to allocate queue memory");
+		BBDEV_NULL_LOG(ERR, "Failed to allocate queue memory");
 		return -ENOMEM;
 	}
 
 	q->processed_pkts = rte_ring_create(ring_name, queue_conf->queue_size,
 			queue_conf->socket, RING_F_SP_ENQ | RING_F_SC_DEQ);
 	if (q->processed_pkts == NULL) {
-		rte_bbdev_log(ERR, "Failed to create ring");
+		BBDEV_NULL_LOG(ERR, "Failed to create ring");
 		goto free_q;
 	}
 
 	dev->data->queues[q_id].queue_private = q;
-	rte_bbdev_log_debug("setup device queue %s", ring_name);
+	BBDEV_NULL_LOG(DEBUG, "setup device queue %s", ring_name);
 	return 0;
 
 free_q:
@@ -194,7 +201,7 @@ parse_u16_arg(const char *key, const char *value, void *extra_args)
 	errno = 0;
 	result = strtoul(value, NULL, 0);
 	if ((result >= (1 << 16)) || (errno != 0)) {
-		rte_bbdev_log(ERR, "Invalid value %lu for %s", result, key);
+		BBDEV_NULL_LOG(ERR, "Invalid value %lu for %s", result, key);
 		return -ERANGE;
 	}
 	*u16 = (uint16_t)result;
@@ -227,7 +234,7 @@ parse_bbdev_null_params(struct bbdev_null_params *params,
 			goto exit;
 
 		if (params->socket_id >= RTE_MAX_NUMA_NODES) {
-			rte_bbdev_log(ERR, "Invalid socket, must be < %u",
+			BBDEV_NULL_LOG(ERR, "Invalid socket, must be < %u",
 					RTE_MAX_NUMA_NODES);
 			goto exit;
 		}
@@ -296,7 +303,7 @@ null_bbdev_probe(struct rte_vdev_device *vdev)
 	input_args = rte_vdev_device_args(vdev);
 	parse_bbdev_null_params(&init_params, input_args);
 
-	rte_bbdev_log_debug("Init %s on NUMA node %d with max queues: %d",
+	BBDEV_NULL_LOG(DEBUG, "Init %s on NUMA node %d with max queues: %d",
 			name, init_params.socket_id, init_params.queues_num);
 
 	return null_bbdev_create(vdev, &init_params);
@@ -335,12 +342,11 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	BBDEV_NULL_MAX_NB_QUEUES_ARG"=<int> "
 	BBDEV_NULL_SOCKET_ID_ARG"=<int>");
 
-int bbdev_logtype;
 RTE_INIT(null_bbdev_init_log);
 static void
 null_bbdev_init_log(void)
 {
-	bbdev_logtype = rte_log_register("pmd.bbdev.null");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
+	bbdev_null_logtype = rte_log_register("pmd.bbdev.null");
+	if (bbdev_null_logtype >= 0)
+		rte_log_set_level(bbdev_null_logtype, RTE_LOG_NOTICE);
 }
diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index 8a053e3..17a00d0 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -27,10 +27,17 @@
 #define DEV_NAME "BBDEV"
 
 
+/* BBDev library logging ID */
+static int bbdev_logtype;
+
+/* Helper macro for logging */
+#define BBDEV_LOG(level, fmt, ...) \
+	rte_log(RTE_LOG_ ## level, bbdev_logtype, fmt "\n", ##__VA_ARGS__)
+
 /* Helper macro to check dev_id is valid */
 #define VALID_DEV_OR_RET_ERR(dev, dev_id) do { \
 	if (dev == NULL) { \
-		rte_bbdev_log(ERR, "device %u is invalid", dev_id); \
+		BBDEV_LOG(ERR, "device %u is invalid", dev_id); \
 		return -ENODEV; \
 	} \
 } while (0)
@@ -38,7 +45,7 @@
 /* Helper macro to check dev_ops is valid */
 #define VALID_DEV_OPS_OR_RET_ERR(dev, dev_id) do { \
 	if (dev->dev_ops == NULL) { \
-		rte_bbdev_log(ERR, "NULL dev_ops structure in device %u", \
+		BBDEV_LOG(ERR, "NULL dev_ops structure in device %u", \
 				dev_id); \
 		return -ENODEV; \
 	} \
@@ -47,7 +54,7 @@
 /* Helper macro to check that driver implements required function pointer */
 #define VALID_FUNC_OR_RET_ERR(func, dev_id) do { \
 	if (func == NULL) { \
-		rte_bbdev_log(ERR, "device %u does not support %s", \
+		BBDEV_LOG(ERR, "device %u does not support %s", \
 				dev_id, #func); \
 		return -ENOTSUP; \
 	} \
@@ -56,7 +63,7 @@
 /* Helper macro to check that queue is valid */
 #define VALID_QUEUE_OR_RET_ERR(queue_id, dev) do { \
 	if (queue_id >= dev->data->num_queues) { \
-		rte_bbdev_log(ERR, "Invalid queue_id %u for device %u", \
+		BBDEV_LOG(ERR, "Invalid queue_id %u for device %u", \
 				queue_id, dev->data->dev_id); \
 		return -ERANGE; \
 	} \
@@ -113,7 +120,7 @@ rte_bbdev_data_alloc(void)
 	} else
 		mz = rte_memzone_lookup(MZ_RTE_BBDEV_DATA);
 	if (mz == NULL) {
-		rte_bbdev_log(CRIT,
+		BBDEV_LOG(CRIT,
 				"Cannot allocate memzone for bbdev port data");
 		return -ENOMEM;
 	}
@@ -168,18 +175,18 @@ rte_bbdev_allocate(const char *name)
 	uint16_t dev_id;
 
 	if (name == NULL) {
-		rte_bbdev_log(ERR, "Invalid null device name");
+		BBDEV_LOG(ERR, "Invalid null device name");
 		return NULL;
 	}
 
 	if (rte_bbdev_get_named_dev(name) != NULL) {
-		rte_bbdev_log(ERR, "Device \"%s\" is already allocated", name);
+		BBDEV_LOG(ERR, "Device \"%s\" is already allocated", name);
 		return NULL;
 	}
 
 	dev_id = find_free_dev_id();
 	if (dev_id == RTE_BBDEV_MAX_DEVS) {
-		rte_bbdev_log(ERR, "Reached maximum number of devices");
+		BBDEV_LOG(ERR, "Reached maximum number of devices");
 		return NULL;
 	}
 
@@ -193,7 +200,7 @@ rte_bbdev_allocate(const char *name)
 
 	bbdev->data = find_bbdev_data(name);
 	if (bbdev->data == NULL) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Max BBDevs already allocated in multi-process environment!");
 		return NULL;
 	}
@@ -204,7 +211,7 @@ rte_bbdev_allocate(const char *name)
 
 	ret = snprintf(bbdev->data->name, RTE_BBDEV_NAME_MAX_LEN, "%s", name);
 	if ((ret < 0) || (ret >= RTE_BBDEV_NAME_MAX_LEN)) {
-		rte_bbdev_log(ERR, "Copying device name \"%s\" failed", name);
+		BBDEV_LOG(ERR, "Copying device name \"%s\" failed", name);
 		return NULL;
 	}
 
@@ -213,7 +220,8 @@ rte_bbdev_allocate(const char *name)
 
 	num_devs++;
 
-	rte_bbdev_log_debug("Initialised device %s (id = %u). Num devices = %u",
+	BBDEV_LOG(DEBUG,
+			"Initialised device %s (id = %u). Num devices = %u",
 			name, dev_id, num_devs);
 
 	return bbdev;
@@ -226,7 +234,7 @@ rte_bbdev_release(struct rte_bbdev *bbdev)
 	struct rte_bbdev_callback *cb, *next;
 
 	if (bbdev == NULL) {
-		rte_bbdev_log(ERR, "NULL bbdev");
+		BBDEV_LOG(ERR, "NULL bbdev");
 		return -ENODEV;
 	}
 	dev_id = bbdev->data->dev_id;
@@ -247,7 +255,7 @@ rte_bbdev_release(struct rte_bbdev *bbdev)
 	num_devs--;
 	bbdev->state = RTE_BBDEV_UNUSED;
 
-	rte_bbdev_log_debug(
+	BBDEV_LOG(DEBUG,
 			"Un-initialised device id = %u. Num devices = %u",
 			dev_id, num_devs);
 	return 0;
@@ -259,7 +267,7 @@ rte_bbdev_get_named_dev(const char *name)
 	unsigned int i;
 
 	if (name == NULL) {
-		rte_bbdev_log(ERR, "NULL driver name");
+		BBDEV_LOG(ERR, "NULL driver name");
 		return NULL;
 	}
 
@@ -310,7 +318,7 @@ rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
 	VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
 
 	if (dev->data->started) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Device %u cannot be configured when started",
 				dev_id);
 		return -EBUSY;
@@ -322,7 +330,7 @@ rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
 	dev->dev_ops->info_get(dev, &dev_info);
 
 	if ((num_queues == 0) || (num_queues > dev_info.max_num_queues)) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Device %u supports 0 < N <= %u queues, not %u",
 				dev_id, dev_info.max_num_queues, num_queues);
 		return -EINVAL;
@@ -334,7 +342,7 @@ rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
 		for (i = 0; i < dev->data->num_queues; i++) {
 			int ret = dev->dev_ops->queue_release(dev, i);
 			if (ret < 0) {
-				rte_bbdev_log(ERR,
+				BBDEV_LOG(ERR,
 						"Device %u queue %u release failed",
 						dev_id, i);
 				return ret;
@@ -344,7 +352,7 @@ rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
 		if (dev->dev_ops->close) {
 			ret = dev->dev_ops->close(dev);
 			if (ret < 0) {
-				rte_bbdev_log(ERR,
+				BBDEV_LOG(ERR,
 						"Device %u couldn't be closed",
 						dev_id);
 				return ret;
@@ -358,7 +366,7 @@ rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
 			sizeof(dev->data->queues[0]), RTE_CACHE_LINE_SIZE,
 				dev->data->socket_id);
 	if (dev->data->queues == NULL) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"calloc of %u queues for device %u on socket %i failed",
 				num_queues, dev_id, dev->data->socket_id);
 		return -ENOMEM;
@@ -370,14 +378,14 @@ rte_bbdev_setup_queues(uint16_t dev_id, uint16_t num_queues, int socket_id)
 	if (dev->dev_ops->setup_queues) {
 		ret = dev->dev_ops->setup_queues(dev, num_queues, socket_id);
 		if (ret < 0) {
-			rte_bbdev_log(ERR,
+			BBDEV_LOG(ERR,
 					"Device %u memory configuration failed",
 					dev_id);
 			goto error;
 		}
 	}
 
-	rte_bbdev_log_debug("Device %u set up with %u queues", dev_id,
+	BBDEV_LOG(DEBUG, "Device %u set up with %u queues", dev_id,
 			num_queues);
 	return 0;
 
@@ -398,7 +406,7 @@ rte_bbdev_intr_enable(uint16_t dev_id)
 	VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
 
 	if (dev->data->started) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Device %u cannot be configured when started",
 				dev_id);
 		return -EBUSY;
@@ -407,16 +415,16 @@ rte_bbdev_intr_enable(uint16_t dev_id)
 	if (dev->dev_ops->intr_enable) {
 		ret = dev->dev_ops->intr_enable(dev);
 		if (ret < 0) {
-			rte_bbdev_log(ERR,
+			BBDEV_LOG(ERR,
 					"Device %u interrupts configuration failed",
 					dev_id);
 			return ret;
 		}
-		rte_bbdev_log_debug("Enabled interrupts for dev %u", dev_id);
+		BBDEV_LOG(DEBUG, "Enabled interrupts for dev %u", dev_id);
 		return 0;
 	}
 
-	rte_bbdev_log(ERR, "Device %u doesn't support interrupts", dev_id);
+	BBDEV_LOG(ERR, "Device %u doesn't support interrupts", dev_id);
 	return -ENOTSUP;
 }
 
@@ -437,7 +445,7 @@ rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
 	VALID_QUEUE_OR_RET_ERR(queue_id, dev);
 
 	if (dev->data->queues[queue_id].started || dev->data->started) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Queue %u of device %u cannot be configured when started",
 				queue_id, dev_id);
 		return -EBUSY;
@@ -467,24 +475,24 @@ rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
 			}
 		}
 		if (ret == 0) {
-			rte_bbdev_log(ERR, "Invalid operation type");
+			BBDEV_LOG(ERR, "Invalid operation type");
 			return -EINVAL;
 		}
 		if (conf->queue_size > dev_info.queue_size_lim) {
-			rte_bbdev_log(ERR,
+			BBDEV_LOG(ERR,
 					"Size (%u) of queue %u of device %u must be: <= %u",
 					conf->queue_size, queue_id, dev_id,
 					dev_info.queue_size_lim);
 			return -EINVAL;
 		}
 		if (!rte_is_power_of_2(conf->queue_size)) {
-			rte_bbdev_log(ERR,
+			BBDEV_LOG(ERR,
 					"Size (%u) of queue %u of device %u must be a power of 2",
 					conf->queue_size, queue_id, dev_id);
 			return -EINVAL;
 		}
 		if (conf->priority > dev_info.max_queue_priority) {
-			rte_bbdev_log(ERR,
+			BBDEV_LOG(ERR,
 					"Priority (%u) of queue %u of bdev %u must be <= %u",
 					conf->priority, queue_id, dev_id,
 					dev_info.max_queue_priority);
@@ -496,7 +504,7 @@ rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
 	if (dev->data->queues[queue_id].queue_private != NULL) {
 		ret = dev->dev_ops->queue_release(dev, queue_id);
 		if (ret < 0) {
-			rte_bbdev_log(ERR, "Device %u queue %u release failed",
+			BBDEV_LOG(ERR, "Device %u queue %u release failed",
 					dev_id, queue_id);
 			return ret;
 		}
@@ -506,7 +514,7 @@ rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
 	ret = dev->dev_ops->queue_setup(dev, queue_id, (conf != NULL) ?
 			conf : &dev_info.default_queue_conf);
 	if (ret < 0) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Device %u queue %u setup failed", dev_id,
 				queue_id);
 		return ret;
@@ -522,7 +530,7 @@ rte_bbdev_queue_configure(uint16_t dev_id, uint16_t queue_id,
 	if (op_type_str == NULL)
 		return -EINVAL;
 
-	rte_bbdev_log_debug("Configured dev%uq%u (size=%u, type=%s, prio=%u)",
+	BBDEV_LOG(DEBUG, "Configured dev%uq%u (size=%u, type=%s, prio=%u)",
 			dev_id, queue_id, stored_conf->queue_size, op_type_str,
 			stored_conf->priority);
 
@@ -539,14 +547,14 @@ rte_bbdev_start(uint16_t dev_id)
 	VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
 
 	if (dev->data->started) {
-		rte_bbdev_log_debug("Device %u is already started", dev_id);
+		BBDEV_LOG(DEBUG, "Device %u is already started", dev_id);
 		return 0;
 	}
 
 	if (dev->dev_ops->start) {
 		int ret = dev->dev_ops->start(dev);
 		if (ret < 0) {
-			rte_bbdev_log(ERR, "Device %u start failed", dev_id);
+			BBDEV_LOG(ERR, "Device %u start failed", dev_id);
 			return ret;
 		}
 	}
@@ -557,7 +565,7 @@ rte_bbdev_start(uint16_t dev_id)
 			dev->data->queues[i].started = true;
 	dev->data->started = true;
 
-	rte_bbdev_log_debug("Started device %u", dev_id);
+	BBDEV_LOG(DEBUG, "Started device %u", dev_id);
 	return 0;
 }
 
@@ -570,7 +578,7 @@ rte_bbdev_stop(uint16_t dev_id)
 	VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
 
 	if (!dev->data->started) {
-		rte_bbdev_log_debug("Device %u is already stopped", dev_id);
+		BBDEV_LOG(DEBUG, "Device %u is already stopped", dev_id);
 		return 0;
 	}
 
@@ -578,7 +586,7 @@ rte_bbdev_stop(uint16_t dev_id)
 		dev->dev_ops->stop(dev);
 	dev->data->started = false;
 
-	rte_bbdev_log_debug("Stopped device %u", dev_id);
+	BBDEV_LOG(DEBUG, "Stopped device %u", dev_id);
 	return 0;
 }
 
@@ -595,7 +603,7 @@ rte_bbdev_close(uint16_t dev_id)
 	if (dev->data->started) {
 		ret = rte_bbdev_stop(dev_id);
 		if (ret < 0) {
-			rte_bbdev_log(ERR, "Device %u stop failed", dev_id);
+			BBDEV_LOG(ERR, "Device %u stop failed", dev_id);
 			return ret;
 		}
 	}
@@ -604,7 +612,7 @@ rte_bbdev_close(uint16_t dev_id)
 	for (i = 0; i < dev->data->num_queues; i++) {
 		ret = dev->dev_ops->queue_release(dev, i);
 		if (ret < 0) {
-			rte_bbdev_log(ERR, "Device %u queue %u release failed",
+			BBDEV_LOG(ERR, "Device %u queue %u release failed",
 					dev_id, i);
 			return ret;
 		}
@@ -614,7 +622,7 @@ rte_bbdev_close(uint16_t dev_id)
 	if (dev->dev_ops->close) {
 		ret = dev->dev_ops->close(dev);
 		if (ret < 0) {
-			rte_bbdev_log(ERR, "Device %u close failed", dev_id);
+			BBDEV_LOG(ERR, "Device %u close failed", dev_id);
 			return ret;
 		}
 	}
@@ -623,7 +631,7 @@ rte_bbdev_close(uint16_t dev_id)
 	dev->data->queues = NULL;
 	dev->data->num_queues = 0;
 
-	rte_bbdev_log_debug("Closed device %u", dev_id);
+	BBDEV_LOG(DEBUG, "Closed device %u", dev_id);
 	return 0;
 }
 
@@ -638,7 +646,7 @@ rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
 	VALID_QUEUE_OR_RET_ERR(queue_id, dev);
 
 	if (dev->data->queues[queue_id].started) {
-		rte_bbdev_log_debug("Queue %u of device %u already started",
+		BBDEV_LOG(DEBUG, "Queue %u of device %u already started",
 				queue_id, dev_id);
 		return 0;
 	}
@@ -646,14 +654,14 @@ rte_bbdev_queue_start(uint16_t dev_id, uint16_t queue_id)
 	if (dev->dev_ops->queue_start) {
 		int ret = dev->dev_ops->queue_start(dev, queue_id);
 		if (ret < 0) {
-			rte_bbdev_log(ERR, "Device %u queue %u start failed",
+			BBDEV_LOG(ERR, "Device %u queue %u start failed",
 					dev_id, queue_id);
 			return ret;
 		}
 	}
 	dev->data->queues[queue_id].started = true;
 
-	rte_bbdev_log_debug("Started queue %u of device %u", queue_id, dev_id);
+	BBDEV_LOG(DEBUG, "Started queue %u of device %u", queue_id, dev_id);
 	return 0;
 }
 
@@ -668,7 +676,7 @@ rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
 	VALID_QUEUE_OR_RET_ERR(queue_id, dev);
 
 	if (!dev->data->queues[queue_id].started) {
-		rte_bbdev_log_debug("Queue %u of device %u already stopped",
+		BBDEV_LOG(DEBUG, "Queue %u of device %u already stopped",
 				queue_id, dev_id);
 		return 0;
 	}
@@ -676,14 +684,14 @@ rte_bbdev_queue_stop(uint16_t dev_id, uint16_t queue_id)
 	if (dev->dev_ops->queue_stop) {
 		int ret = dev->dev_ops->queue_stop(dev, queue_id);
 		if (ret < 0) {
-			rte_bbdev_log(ERR, "Device %u queue %u stop failed",
+			BBDEV_LOG(ERR, "Device %u queue %u stop failed",
 					dev_id, queue_id);
 			return ret;
 		}
 	}
 	dev->data->queues[queue_id].started = false;
 
-	rte_bbdev_log_debug("Stopped queue %u of device %u", queue_id, dev_id);
+	BBDEV_LOG(DEBUG, "Stopped queue %u of device %u", queue_id, dev_id);
 	return 0;
 }
 
@@ -701,7 +709,7 @@ get_stats_from_queues(struct rte_bbdev *dev, struct rte_bbdev_stats *stats)
 		stats->enqueue_err_count += q_stats->enqueue_err_count;
 		stats->dequeue_err_count += q_stats->dequeue_err_count;
 	}
-	rte_bbdev_log_debug("Got stats on %u", dev->data->dev_id);
+	BBDEV_LOG(DEBUG, "Got stats on %u", dev->data->dev_id);
 }
 
 static void
@@ -714,7 +722,7 @@ reset_stats_in_queues(struct rte_bbdev *dev)
 
 		memset(q_stats, 0, sizeof(*q_stats));
 	}
-	rte_bbdev_log_debug("Reset stats on %u", dev->data->dev_id);
+	BBDEV_LOG(DEBUG, "Reset stats on %u", dev->data->dev_id);
 }
 
 int
@@ -726,7 +734,7 @@ rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
 	VALID_DEV_OPS_OR_RET_ERR(dev, dev_id);
 
 	if (stats == NULL) {
-		rte_bbdev_log(ERR, "NULL stats structure");
+		BBDEV_LOG(ERR, "NULL stats structure");
 		return -EINVAL;
 	}
 
@@ -736,7 +744,7 @@ rte_bbdev_stats_get(uint16_t dev_id, struct rte_bbdev_stats *stats)
 	else
 		get_stats_from_queues(dev, stats);
 
-	rte_bbdev_log_debug("Retrieved stats of device %u", dev_id);
+	BBDEV_LOG(DEBUG, "Retrieved stats of device %u", dev_id);
 	return 0;
 }
 
@@ -753,7 +761,7 @@ rte_bbdev_stats_reset(uint16_t dev_id)
 	else
 		reset_stats_in_queues(dev);
 
-	rte_bbdev_log_debug("Reset stats of device %u", dev_id);
+	BBDEV_LOG(DEBUG, "Reset stats of device %u", dev_id);
 	return 0;
 }
 
@@ -766,7 +774,7 @@ rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
 	VALID_FUNC_OR_RET_ERR(dev->dev_ops->info_get, dev_id);
 
 	if (dev_info == NULL) {
-		rte_bbdev_log(ERR, "NULL dev info structure");
+		BBDEV_LOG(ERR, "NULL dev info structure");
 		return -EINVAL;
 	}
 
@@ -781,7 +789,7 @@ rte_bbdev_info_get(uint16_t dev_id, struct rte_bbdev_info *dev_info)
 	/* Copy data maintained by device driver layer */
 	dev->dev_ops->info_get(dev, &dev_info->drv);
 
-	rte_bbdev_log_debug("Retrieved info of device %u", dev_id);
+	BBDEV_LOG(DEBUG, "Retrieved info of device %u", dev_id);
 	return 0;
 }
 
@@ -795,7 +803,7 @@ rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
 	VALID_QUEUE_OR_RET_ERR(queue_id, dev);
 
 	if (queue_info == NULL) {
-		rte_bbdev_log(ERR, "NULL queue info structure");
+		BBDEV_LOG(ERR, "NULL queue info structure");
 		return -EINVAL;
 	}
 
@@ -804,7 +812,7 @@ rte_bbdev_queue_info_get(uint16_t dev_id, uint16_t queue_id,
 	queue_info->conf = dev->data->queues[queue_id].conf;
 	queue_info->started = dev->data->queues[queue_id].started;
 
-	rte_bbdev_log_debug("Retrieved info of queue %u of device %u",
+	BBDEV_LOG(DEBUG, "Retrieved info of queue %u of device %u",
 			queue_id, dev_id);
 	return 0;
 }
@@ -860,12 +868,12 @@ rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
 	const char *op_type_str;
 
 	if (name == NULL) {
-		rte_bbdev_log(ERR, "NULL name for op pool");
+		BBDEV_LOG(ERR, "NULL name for op pool");
 		return NULL;
 	}
 
 	if (type >= RTE_BBDEV_OP_TYPE_COUNT) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Invalid op type (%u), should be less than %u",
 				type, RTE_BBDEV_OP_TYPE_COUNT);
 		return NULL;
@@ -875,7 +883,7 @@ rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
 			cache_size, sizeof(struct rte_bbdev_op_pool_private),
 			NULL, NULL, bbdev_op_init, &type, socket_id, 0);
 	if (mp == NULL) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Failed to create op pool %s (num ops=%u, op size=%u) with error: %s",
 				name, num_elements, get_bbdev_op_size(type),
 				rte_strerror(rte_errno));
@@ -886,7 +894,7 @@ rte_bbdev_op_pool_create(const char *name, enum rte_bbdev_op_type type,
 	if (op_type_str == NULL)
 		return NULL;
 
-	rte_bbdev_log_debug(
+	BBDEV_LOG(DEBUG,
 			"Op pool %s created for %u ops (type=%s, cache=%u, socket=%u, size=%u)",
 			name, num_elements, op_type_str, cache_size, socket_id,
 			get_bbdev_op_size(type));
@@ -906,14 +914,14 @@ rte_bbdev_callback_register(uint16_t dev_id, enum rte_bbdev_event_type event,
 	VALID_DEV_OR_RET_ERR(dev, dev_id);
 
 	if (event >= RTE_BBDEV_EVENT_MAX) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Invalid event type (%u), should be less than %u",
 				event, RTE_BBDEV_EVENT_MAX);
 		return -EINVAL;
 	}
 
 	if (cb_fn == NULL) {
-		rte_bbdev_log(ERR, "NULL callback function");
+		BBDEV_LOG(ERR, "NULL callback function");
 		return -EINVAL;
 	}
 
@@ -952,14 +960,14 @@ rte_bbdev_callback_unregister(uint16_t dev_id, enum rte_bbdev_event_type event,
 	VALID_DEV_OR_RET_ERR(dev, dev_id);
 
 	if (event >= RTE_BBDEV_EVENT_MAX) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Invalid event type (%u), should be less than %u",
 				event, RTE_BBDEV_EVENT_MAX);
 		return -EINVAL;
 	}
 
 	if (cb_fn == NULL) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"NULL callback function cannot be unregistered");
 		return -EINVAL;
 	}
@@ -995,17 +1003,17 @@ rte_bbdev_pmd_callback_process(struct rte_bbdev *dev,
 	struct rte_bbdev_callback dev_cb;
 
 	if (dev == NULL) {
-		rte_bbdev_log(ERR, "NULL device");
+		BBDEV_LOG(ERR, "NULL device");
 		return;
 	}
 
 	if (dev->data == NULL) {
-		rte_bbdev_log(ERR, "NULL data structure");
+		BBDEV_LOG(ERR, "NULL data structure");
 		return;
 	}
 
 	if (event >= RTE_BBDEV_EVENT_MAX) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"Invalid event type (%u), should be less than %u",
 				event, RTE_BBDEV_EVENT_MAX);
 		return;
@@ -1065,12 +1073,12 @@ rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
 
 	intr_handle = dev->intr_handle;
 	if (!intr_handle || !intr_handle->intr_vec) {
-		rte_bbdev_log(ERR, "Device %u intr handle unset\n", dev_id);
+		BBDEV_LOG(ERR, "Device %u intr handle unset\n", dev_id);
 		return -ENOTSUP;
 	}
 
 	if (queue_id >= RTE_MAX_RXTX_INTR_VEC_ID) {
-		rte_bbdev_log(ERR, "Device %u queue_id %u is too big\n",
+		BBDEV_LOG(ERR, "Device %u queue_id %u is too big\n",
 				dev_id, queue_id);
 		return -ENOTSUP;
 	}
@@ -1078,7 +1086,7 @@ rte_bbdev_queue_intr_ctl(uint16_t dev_id, uint16_t queue_id, int epfd, int op,
 	vec = intr_handle->intr_vec[queue_id];
 	ret = rte_intr_rx_ctl(intr_handle, epfd, op, vec, data);
 	if (ret && (ret != -EEXIST)) {
-		rte_bbdev_log(ERR,
+		BBDEV_LOG(ERR,
 				"dev %u q %u int ctl error op %d epfd %d vec %u\n",
 				dev_id, queue_id, op, epfd, vec);
 		return ret;
@@ -1100,13 +1108,11 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
 	if (op_type < RTE_BBDEV_OP_TYPE_COUNT)
 		return op_types[op_type];
 
-	rte_bbdev_log(ERR, "Invalid operation type");
+	BBDEV_LOG(ERR, "Invalid operation type");
 	return NULL;
 }
 
 
-int bbdev_logtype;
-
 RTE_INIT(rte_bbdev_init_log);
 static void
 rte_bbdev_init_log(void)
diff --git a/lib/librte_bbdev/rte_bbdev.h b/lib/librte_bbdev/rte_bbdev.h
index 37a0d05..3a8f97f 100644
--- a/lib/librte_bbdev/rte_bbdev.h
+++ b/lib/librte_bbdev/rte_bbdev.h
@@ -462,12 +462,7 @@ rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->enqueue_enc_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u encode ops enqueued to dev%u,q%u.\n",
-			num_ops, dev_id, queue_id);
-
-	return n;
+	return dev->enqueue_enc_ops(q_data, ops, num_ops);
 }
 
 /**
@@ -497,12 +492,7 @@ rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->enqueue_dec_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u decode ops enqueued to dev%u,q%u.\n",
-			num_ops, dev_id, queue_id);
-
-	return n;
+	return dev->enqueue_dec_ops(q_data, ops, num_ops);
 }
 
 /**
@@ -532,12 +522,7 @@ rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->dequeue_enc_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u encode ops dequeued to dev%u,q%u\n",
-			n, dev_id, queue_id);
-
-	return n;
+	return dev->dequeue_enc_ops(q_data, ops, num_ops);
 }
 
 /**
@@ -568,12 +553,7 @@ rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->dequeue_dec_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u decode ops dequeued to dev%u,q%u\n",
-			n, dev_id, queue_id);
-
-	return n;
+	return dev->dequeue_dec_ops(q_data, ops, num_ops);
 }
 
 /** Definitions of device event types */
diff --git a/lib/librte_bbdev/rte_bbdev_op.h b/lib/librte_bbdev/rte_bbdev_op.h
index c0c7d73..9a80c64 100644
--- a/lib/librte_bbdev/rte_bbdev_op.h
+++ b/lib/librte_bbdev/rte_bbdev_op.h
@@ -27,58 +27,6 @@ extern "C" {
 
 #define RTE_BBDEV_MAX_CODE_BLOCKS 64
 
-extern int bbdev_logtype;
-
-/**
- * Helper macro for logging
- *
- * @param level
- *   Log level: EMERG, ALERT, CRIT, ERR, WARNING, NOTICE, INFO, or DEBUG
- * @param fmt
- *   The format string, as in printf(3).
- * @param ...
- *   The variable arguments required by the format string.
- *
- * @return
- *   - 0 on success
- *   - Negative on error
- */
-#define rte_bbdev_log(level, fmt, ...) \
-	rte_log(RTE_LOG_ ## level, bbdev_logtype, fmt "\n", ##__VA_ARGS__)
-
-/**
- * Helper macro for debug logging with extra source info
- *
- * @param fmt
- *   The format string, as in printf(3).
- * @param ...
- *   The variable arguments required by the format string.
- *
- * @return
- *   - 0 on success
- *   - Negative on error
- */
-#define rte_bbdev_log_debug(fmt, ...) \
-	rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
-		##__VA_ARGS__)
-
-/**
- * Helper macro for extra conditional logging from datapath
- *
- * @param fmt
- *   The format string, as in printf(3).
- * @param ...
- *   The variable arguments required by the format string.
- *
- * @return
- *   - 0 on success
- *   - Negative on error
- */
-#define rte_bbdev_log_verbose(fmt, ...) \
-	(void)((RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL) ? \
-	rte_log(RTE_LOG_DEBUG, \
-		bbdev_logtype, ": " fmt "\n", ##__VA_ARGS__) : 0)
-
 /** Flags for turbo decoder operation and capability structure */
 enum rte_bbdev_op_td_flag_bitmasks {
 	/**< If sub block de-interleaving is to be performed. */
@@ -547,9 +495,6 @@ rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
 	if (unlikely(ret < 0))
 		return ret;
 
-	rte_bbdev_log_verbose("%u encode ops allocated from %s\n",
-			num_ops, mempool->name);
-
 	return 0;
 }
 
@@ -585,9 +530,6 @@ rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
 	if (unlikely(ret < 0))
 		return ret;
 
-	rte_bbdev_log_verbose("%u encode ops allocated from %s\n",
-			num_ops, mempool->name);
-
 	return 0;
 }
 
@@ -604,11 +546,8 @@ rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
 static inline void
 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
 {
-	if (num_ops > 0) {
+	if (num_ops > 0)
 		rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
-		rte_bbdev_log_verbose("%u decode ops freed to %s\n", num_ops,
-				ops[0]->mempool->name);
-	}
 }
 
 /**
@@ -624,11 +563,8 @@ rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
 static inline void
 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
 {
-	if (num_ops > 0) {
+	if (num_ops > 0)
 		rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
-		rte_bbdev_log_verbose("%u encode ops freed to %s\n", num_ops,
-				ops[0]->mempool->name);
-	}
 }
 
 #ifdef __cplusplus
diff --git a/lib/librte_bbdev/rte_bbdev_version.map b/lib/librte_bbdev/rte_bbdev_version.map
index 737c339..d3b81ea 100644
--- a/lib/librte_bbdev/rte_bbdev_version.map
+++ b/lib/librte_bbdev/rte_bbdev_version.map
@@ -1,7 +1,6 @@
 EXPERIMENTAL {
 	global:
 
-	bbdev_logtype;
 	rte_bbdev_allocate;
 	rte_bbdev_callback_register;
 	rte_bbdev_callback_unregister;
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH] bb/null: fix exported dynamic log type
  2018-02-05 22:27 [dpdk-dev] [PATCH] bb/null: fix exported dynamic log type Amr Mokhtar
@ 2018-02-06  0:41 ` Thomas Monjalon
  2018-02-06 13:29 ` [dpdk-dev] [PATCH v2] bbdev: " Amr Mokhtar
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2018-02-06  0:41 UTC (permalink / raw)
  To: Amr Mokhtar; +Cc: dev, ferruh.yigit

05/02/2018 23:27, Amr Mokhtar:
> This patch fixes shared library compilation due to undefined
> reference to an exported variable 'bbdev_logtype'.
> In this fix, the logtype is converted to static in the bbdev lib
> and in the bbdev null pmd.
> 
> Fixes: 7dc2b1589440 ("bb/null: add null base band device driver")
> Cc: thomas@monjalon.net
> 
> Signed-off-by: Amr Mokhtar <amr.mokhtar@intel.com>

It probably requires a rebase because it does not apply cleanly
on the master branch.

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

* [dpdk-dev] [PATCH v2] bbdev: fix exported dynamic log type
  2018-02-05 22:27 [dpdk-dev] [PATCH] bb/null: fix exported dynamic log type Amr Mokhtar
  2018-02-06  0:41 ` Thomas Monjalon
@ 2018-02-06 13:29 ` Amr Mokhtar
  2018-02-06 17:50   ` Thomas Monjalon
  1 sibling, 1 reply; 4+ messages in thread
From: Amr Mokhtar @ 2018-02-06 13:29 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, Amr Mokhtar

This patch fixes shared library compilation due to undefined
reference to an exported variable 'bbdev_logtype'.

v2:
* In this fix,
* - The logtype has become static and owned individually by each
*    component.
* - Helper logging macros are removed from bbdev lib header files
*    and replaced with macros defined by each driver at its ease.
* - 'bbdev_logtype' removed from .map

v1:
* This patch fixes shared library compilation due to undefined
* reference to an exported variable 'bbdev_logtype'.
* In this fix, the logtype is converted to static in the bbdev lib,
* in bbdev null pmd and turbo sw pmd.


Fixes: 4935e1e9f76e ("bbdev: introduce wireless base band device lib")
Fixes: b8cfe2c9aed2 ("bb/turbo_sw: add software turbo driver")
Fixes: 7dc2b1589440 ("bb/null: add null base band device driver")
Cc: thomas@monjalon.net

Signed-off-by: Amr Mokhtar <amr.mokhtar@intel.com>
---
 drivers/bbdev/null/bbdev_null.c               | 18 +++++--
 drivers/bbdev/turbo_sw/bbdev_turbo_software.c | 19 ++++++--
 lib/librte_bbdev/rte_bbdev.c                  | 14 ++++--
 lib/librte_bbdev/rte_bbdev.h                  | 28 ++---------
 lib/librte_bbdev/rte_bbdev_op.h               | 68 +--------------------------
 lib/librte_bbdev/rte_bbdev_version.map        |  1 -
 6 files changed, 46 insertions(+), 102 deletions(-)

diff --git a/drivers/bbdev/null/bbdev_null.c b/drivers/bbdev/null/bbdev_null.c
index 1a66de1..6bc8491 100644
--- a/drivers/bbdev/null/bbdev_null.c
+++ b/drivers/bbdev/null/bbdev_null.c
@@ -15,6 +15,17 @@
 
 #define DRIVER_NAME bbdev_null
 
+/* NULL BBDev logging ID */
+static int bbdev_null_logtype;
+
+/* Helper macro for logging */
+#define rte_bbdev_log(level, fmt, ...) \
+	rte_log(RTE_LOG_ ## level, bbdev_null_logtype, fmt "\n", ##__VA_ARGS__)
+
+#define rte_bbdev_log_debug(fmt, ...) \
+	rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
+		##__VA_ARGS__)
+
 /*  Initialisation params structure that can be used by null BBDEV driver */
 struct bbdev_null_params {
 	int socket_id;  /*< Null BBDEV socket */
@@ -335,12 +346,11 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	BBDEV_NULL_MAX_NB_QUEUES_ARG"=<int> "
 	BBDEV_NULL_SOCKET_ID_ARG"=<int>");
 
-int bbdev_logtype;
 RTE_INIT(null_bbdev_init_log);
 static void
 null_bbdev_init_log(void)
 {
-	bbdev_logtype = rte_log_register("pmd.bb.null");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
+	bbdev_null_logtype = rte_log_register("pmd.bb.null");
+	if (bbdev_null_logtype >= 0)
+		rte_log_set_level(bbdev_null_logtype, RTE_LOG_NOTICE);
 }
diff --git a/drivers/bbdev/turbo_sw/bbdev_turbo_software.c b/drivers/bbdev/turbo_sw/bbdev_turbo_software.c
index 33f7135..302abf5 100644
--- a/drivers/bbdev/turbo_sw/bbdev_turbo_software.c
+++ b/drivers/bbdev/turbo_sw/bbdev_turbo_software.c
@@ -20,6 +20,18 @@
 
 #define DRIVER_NAME turbo_sw
 
+/* Turbo SW PMD logging ID */
+static int bbdev_turbo_sw_logtype;
+
+/* Helper macro for logging */
+#define rte_bbdev_log(level, fmt, ...) \
+	rte_log(RTE_LOG_ ## level, bbdev_turbo_sw_logtype, fmt "\n", \
+		##__VA_ARGS__)
+
+#define rte_bbdev_log_debug(fmt, ...) \
+	rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
+		##__VA_ARGS__)
+
 /* Number of columns in sub-block interleaver (36.212, section 5.1.4.1.1) */
 #define C_SUBBLOCK (32)
 #define MAX_TB_SIZE (391656)
@@ -1195,12 +1207,11 @@ RTE_PMD_REGISTER_PARAM_STRING(DRIVER_NAME,
 	TURBO_SW_MAX_NB_QUEUES_ARG"=<int> "
 	TURBO_SW_SOCKET_ID_ARG"=<int>");
 
-int bbdev_logtype;
 RTE_INIT(null_bbdev_init_log);
 static void
 null_bbdev_init_log(void)
 {
-	bbdev_logtype = rte_log_register("pmd.bb.turbo_sw");
-	if (bbdev_logtype >= 0)
-		rte_log_set_level(bbdev_logtype, RTE_LOG_NOTICE);
+	bbdev_turbo_sw_logtype = rte_log_register("pmd.bb.turbo_sw");
+	if (bbdev_turbo_sw_logtype >= 0)
+		rte_log_set_level(bbdev_turbo_sw_logtype, RTE_LOG_NOTICE);
 }
diff --git a/lib/librte_bbdev/rte_bbdev.c b/lib/librte_bbdev/rte_bbdev.c
index db1c00a..74ecc49 100644
--- a/lib/librte_bbdev/rte_bbdev.c
+++ b/lib/librte_bbdev/rte_bbdev.c
@@ -28,6 +28,17 @@
 #define DEV_NAME "BBDEV"
 
 
+/* BBDev library logging ID */
+static int bbdev_logtype;
+
+/* Helper macro for logging */
+#define rte_bbdev_log(level, fmt, ...) \
+	rte_log(RTE_LOG_ ## level, bbdev_logtype, fmt "\n", ##__VA_ARGS__)
+
+#define rte_bbdev_log_debug(fmt, ...) \
+	rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
+		##__VA_ARGS__)
+
 /* Helper macro to check dev_id is valid */
 #define VALID_DEV_OR_RET_ERR(dev, dev_id) do { \
 	if (dev == NULL) { \
@@ -1105,9 +1116,6 @@ rte_bbdev_op_type_str(enum rte_bbdev_op_type op_type)
 	return NULL;
 }
 
-
-int bbdev_logtype;
-
 RTE_INIT(rte_bbdev_init_log);
 static void
 rte_bbdev_init_log(void)
diff --git a/lib/librte_bbdev/rte_bbdev.h b/lib/librte_bbdev/rte_bbdev.h
index 767a1e1..5e7e495 100644
--- a/lib/librte_bbdev/rte_bbdev.h
+++ b/lib/librte_bbdev/rte_bbdev.h
@@ -463,12 +463,7 @@ rte_bbdev_enqueue_enc_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->enqueue_enc_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u encode ops enqueued to dev%u,q%u.\n",
-			num_ops, dev_id, queue_id);
-
-	return n;
+	return dev->enqueue_enc_ops(q_data, ops, num_ops);
 }
 
 /**
@@ -498,12 +493,7 @@ rte_bbdev_enqueue_dec_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->enqueue_dec_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u decode ops enqueued to dev%u,q%u.\n",
-			num_ops, dev_id, queue_id);
-
-	return n;
+	return dev->enqueue_dec_ops(q_data, ops, num_ops);
 }
 
 /**
@@ -533,12 +523,7 @@ rte_bbdev_dequeue_enc_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->dequeue_enc_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u encode ops dequeued to dev%u,q%u\n",
-			n, dev_id, queue_id);
-
-	return n;
+	return dev->dequeue_enc_ops(q_data, ops, num_ops);
 }
 
 /**
@@ -569,12 +554,7 @@ rte_bbdev_dequeue_dec_ops(uint16_t dev_id, uint16_t queue_id,
 {
 	struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
 	struct rte_bbdev_queue_data *q_data = &dev->data->queues[queue_id];
-	uint16_t n = dev->dequeue_dec_ops(q_data, ops, num_ops);
-
-	rte_bbdev_log_verbose("%u decode ops dequeued to dev%u,q%u\n",
-			n, dev_id, queue_id);
-
-	return n;
+	return dev->dequeue_dec_ops(q_data, ops, num_ops);
 }
 
 /** Definitions of device event types */
diff --git a/lib/librte_bbdev/rte_bbdev_op.h b/lib/librte_bbdev/rte_bbdev_op.h
index c0c7d73..9a80c64 100644
--- a/lib/librte_bbdev/rte_bbdev_op.h
+++ b/lib/librte_bbdev/rte_bbdev_op.h
@@ -27,58 +27,6 @@ extern "C" {
 
 #define RTE_BBDEV_MAX_CODE_BLOCKS 64
 
-extern int bbdev_logtype;
-
-/**
- * Helper macro for logging
- *
- * @param level
- *   Log level: EMERG, ALERT, CRIT, ERR, WARNING, NOTICE, INFO, or DEBUG
- * @param fmt
- *   The format string, as in printf(3).
- * @param ...
- *   The variable arguments required by the format string.
- *
- * @return
- *   - 0 on success
- *   - Negative on error
- */
-#define rte_bbdev_log(level, fmt, ...) \
-	rte_log(RTE_LOG_ ## level, bbdev_logtype, fmt "\n", ##__VA_ARGS__)
-
-/**
- * Helper macro for debug logging with extra source info
- *
- * @param fmt
- *   The format string, as in printf(3).
- * @param ...
- *   The variable arguments required by the format string.
- *
- * @return
- *   - 0 on success
- *   - Negative on error
- */
-#define rte_bbdev_log_debug(fmt, ...) \
-	rte_bbdev_log(DEBUG, RTE_STR(__LINE__) ":%s() " fmt, __func__, \
-		##__VA_ARGS__)
-
-/**
- * Helper macro for extra conditional logging from datapath
- *
- * @param fmt
- *   The format string, as in printf(3).
- * @param ...
- *   The variable arguments required by the format string.
- *
- * @return
- *   - 0 on success
- *   - Negative on error
- */
-#define rte_bbdev_log_verbose(fmt, ...) \
-	(void)((RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL) ? \
-	rte_log(RTE_LOG_DEBUG, \
-		bbdev_logtype, ": " fmt "\n", ##__VA_ARGS__) : 0)
-
 /** Flags for turbo decoder operation and capability structure */
 enum rte_bbdev_op_td_flag_bitmasks {
 	/**< If sub block de-interleaving is to be performed. */
@@ -547,9 +495,6 @@ rte_bbdev_enc_op_alloc_bulk(struct rte_mempool *mempool,
 	if (unlikely(ret < 0))
 		return ret;
 
-	rte_bbdev_log_verbose("%u encode ops allocated from %s\n",
-			num_ops, mempool->name);
-
 	return 0;
 }
 
@@ -585,9 +530,6 @@ rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
 	if (unlikely(ret < 0))
 		return ret;
 
-	rte_bbdev_log_verbose("%u encode ops allocated from %s\n",
-			num_ops, mempool->name);
-
 	return 0;
 }
 
@@ -604,11 +546,8 @@ rte_bbdev_dec_op_alloc_bulk(struct rte_mempool *mempool,
 static inline void
 rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
 {
-	if (num_ops > 0) {
+	if (num_ops > 0)
 		rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
-		rte_bbdev_log_verbose("%u decode ops freed to %s\n", num_ops,
-				ops[0]->mempool->name);
-	}
 }
 
 /**
@@ -624,11 +563,8 @@ rte_bbdev_dec_op_free_bulk(struct rte_bbdev_dec_op **ops, unsigned int num_ops)
 static inline void
 rte_bbdev_enc_op_free_bulk(struct rte_bbdev_enc_op **ops, unsigned int num_ops)
 {
-	if (num_ops > 0) {
+	if (num_ops > 0)
 		rte_mempool_put_bulk(ops[0]->mempool, (void **)ops, num_ops);
-		rte_bbdev_log_verbose("%u encode ops freed to %s\n", num_ops,
-				ops[0]->mempool->name);
-	}
 }
 
 #ifdef __cplusplus
diff --git a/lib/librte_bbdev/rte_bbdev_version.map b/lib/librte_bbdev/rte_bbdev_version.map
index 737c339..d3b81ea 100644
--- a/lib/librte_bbdev/rte_bbdev_version.map
+++ b/lib/librte_bbdev/rte_bbdev_version.map
@@ -1,7 +1,6 @@
 EXPERIMENTAL {
 	global:
 
-	bbdev_logtype;
 	rte_bbdev_allocate;
 	rte_bbdev_callback_register;
 	rte_bbdev_callback_unregister;
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v2] bbdev: fix exported dynamic log type
  2018-02-06 13:29 ` [dpdk-dev] [PATCH v2] bbdev: " Amr Mokhtar
@ 2018-02-06 17:50   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2018-02-06 17:50 UTC (permalink / raw)
  To: Amr Mokhtar; +Cc: dev, ferruh.yigit

06/02/2018 14:29, Amr Mokhtar:
> This patch fixes shared library compilation due to undefined
> reference to an exported variable 'bbdev_logtype'.
> 
> v2:
> * In this fix,
> * - The logtype has become static and owned individually by each
> *    component.
> * - Helper logging macros are removed from bbdev lib header files
> *    and replaced with macros defined by each driver at its ease.
> * - 'bbdev_logtype' removed from .map
> 
> v1:
> * This patch fixes shared library compilation due to undefined
> * reference to an exported variable 'bbdev_logtype'.
> * In this fix, the logtype is converted to static in the bbdev lib,
> * in bbdev null pmd and turbo sw pmd.
> 
> 
> Fixes: 4935e1e9f76e ("bbdev: introduce wireless base band device lib")
> Fixes: b8cfe2c9aed2 ("bb/turbo_sw: add software turbo driver")
> Fixes: 7dc2b1589440 ("bb/null: add null base band device driver")
> Cc: thomas@monjalon.net
> 
> Signed-off-by: Amr Mokhtar <amr.mokhtar@intel.com>

Applied, thanks

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

end of thread, other threads:[~2018-02-06 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-05 22:27 [dpdk-dev] [PATCH] bb/null: fix exported dynamic log type Amr Mokhtar
2018-02-06  0:41 ` Thomas Monjalon
2018-02-06 13:29 ` [dpdk-dev] [PATCH v2] bbdev: " Amr Mokhtar
2018-02-06 17:50   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).