From 7d6321de8d0fcc62edae73ab8ff81027f998f602 Mon Sep 17 00:00:00 2001 From: Pavan Nikhilesh Date: Tue, 19 Dec 2017 17:55:08 +0530 Subject: [PATCH] mempool/octeontx: implement dynamic logging Signed-off-by: Pavan Nikhilesh Acked-by: Santosh Shukla Acked-by: Stephen Hemminger --- config/common_base | 1 - drivers/mempool/octeontx/octeontx_fpavf.c | 16 +++++++ drivers/mempool/octeontx/octeontx_pool_logs.h | 43 ++++++++----------- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/config/common_base b/config/common_base index e58f041f9c..a50f9febdc 100644 --- a/config/common_base +++ b/config/common_base @@ -589,7 +589,6 @@ CONFIG_RTE_DRIVER_MEMPOOL_STACK=y # Compile PMD for octeontx fpa mempool device # CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL=y -CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL_DEBUG=n # # Compile librte_mbuf diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c index 51225a0708..23e2b9d6f7 100644 --- a/drivers/mempool/octeontx/octeontx_fpavf.c +++ b/drivers/mempool/octeontx/octeontx_fpavf.c @@ -105,6 +105,22 @@ struct octeontx_fpadev { static struct octeontx_fpadev fpadev; +int octeontx_logtype_fpavf; +int octeontx_logtype_fpavf_mbox; + +RTE_INIT(otx_pool_init_log); +static void +otx_pool_init_log(void) +{ + octeontx_logtype_fpavf = rte_log_register("pmd.otx.mempool"); + if (octeontx_logtype_fpavf >= 0) + rte_log_set_level(octeontx_logtype_fpavf, RTE_LOG_NOTICE); + + octeontx_logtype_fpavf_mbox = rte_log_register("pmd.otx.mempool.mbox"); + if (octeontx_logtype_fpavf_mbox >= 0) + rte_log_set_level(octeontx_logtype_fpavf_mbox, RTE_LOG_NOTICE); +} + /* lock is taken by caller */ static int octeontx_fpa_gpool_alloc(unsigned int object_size) diff --git a/drivers/mempool/octeontx/octeontx_pool_logs.h b/drivers/mempool/octeontx/octeontx_pool_logs.h index c91e6de3a2..9586519241 100644 --- a/drivers/mempool/octeontx/octeontx_pool_logs.h +++ b/drivers/mempool/octeontx/octeontx_pool_logs.h @@ -7,34 +7,25 @@ #include -#ifdef RTE_LIBRTE_OCTEONTX_MEMPOOL_DEBUG -#define fpavf_log_info(fmt, args...) \ - RTE_LOG(INFO, PMD, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) -#define fpavf_log_dbg(fmt, args...) \ - RTE_LOG(DEBUG, PMD, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) - -#define mbox_log_info(fmt, args...) \ - RTE_LOG(INFO, PMD, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) -#define mbox_log_dbg(fmt, args...) \ - RTE_LOG(DEBUG, PMD, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) -#else -#define fpavf_log_info(fmt, args...) -#define fpavf_log_dbg(fmt, args...) -#define mbox_log_info(fmt, args...) -#define mbox_log_dbg(fmt, args...) -#endif +#define FPAVF_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, octeontx_logtype_fpavf,\ + "%s() line %u: " fmt "\n", __func__, __LINE__, ## args) +#define MBOX_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, octeontx_logtype_fpavf_mbox,\ + "%s() line %u: " fmt "\n", __func__, __LINE__, ## args) + +#define fpavf_log_info(fmt, ...) FPAVF_LOG(INFO, fmt, ##__VA_ARGS__) +#define fpavf_log_dbg(fmt, ...) FPAVF_LOG(DEBUG, fmt, ##__VA_ARGS__) +#define fpavf_log_err(fmt, ...) FPAVF_LOG(ERR, fmt, ##__VA_ARGS__) #define fpavf_func_trace fpavf_log_dbg -#define fpavf_log_err(fmt, args...) \ - RTE_LOG(ERR, PMD, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) + +#define mbox_log_info(fmt, ...) MBOX_LOG(INFO, fmt, ##__VA_ARGS__) +#define mbox_log_dbg(fmt, ...) MBOX_LOG(DEBUG, fmt, ##__VA_ARGS__) +#define mbox_log_err(fmt, ...) MBOX_LOG(ERR, fmt, ##__VA_ARGS__) #define mbox_func_trace mbox_log_dbg -#define mbox_log_err(fmt, args...) \ - RTE_LOG(ERR, PMD, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) + +extern int octeontx_logtype_fpavf; +extern int octeontx_logtype_fpavf_mbox; #endif /* __OCTEONTX_POOL_LOGS_H__*/ -- 2.20.1