[dpdk-dev,v2] bbdev: fix exported dynamic log type

Message ID 1517923770-45640-1-git-send-email-amr.mokhtar@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Mokhtar, Amr Feb. 6, 2018, 1:29 p.m. UTC
  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(-)
  

Comments

Thomas Monjalon Feb. 6, 2018, 5:50 p.m. UTC | #1
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
  

Patch

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;