Merge "cnss2: Add more debug info in ipc_log"

This commit is contained in:
qctecmdr 2021-07-11 07:42:48 -07:00 • committed by Gerrit - the friendly Code Review server
commit 304bff3f76
2 changed files with 71 additions and 34 deletions

View file

@ -876,6 +876,24 @@ void cnss_debugfs_destroy(struct cnss_plat_data *plat_priv)
#endif
#if IS_ENABLED(CONFIG_IPC_LOGGING)
void cnss_debug_ipc_log_print(void *log_ctx, char *process, const char *fn,
const char *log_level, char *fmt, ...)
{
struct va_format vaf;
va_list va_args;
va_start(va_args, fmt);
vaf.fmt = fmt;
vaf.va = &va_args;
if (log_level)
printk("%scnss: %pV", log_level, &vaf);
ipc_log_string(log_ctx, "[%s] %s: %pV", process, fn, &vaf);
va_end(va_args);
}
static int cnss_ipc_logging_init(void)
{
cnss_ipc_log_context = ipc_log_context_create(CNSS_IPC_LOG_PAGES,
@ -911,6 +929,21 @@ static void cnss_ipc_logging_deinit(void)
#else
static int cnss_ipc_logging_init(void) { return 0; }
static void cnss_ipc_logging_deinit(void) {}
void cnss_debug_ipc_log_print(void *log_ctx, char *process, const char *fn,
const char *log_level, char *fmt, ...)
{
struct va_format vaf;
va_list va_args;
va_start(va_args, fmt);
vaf.fmt = fmt;
vaf.va = &va_args;
if (log_level)
printk("%scnss: %pV", log_level, &vaf);
va_end(va_args);
}
#endif
int cnss_debug_init(void)

View file

@ -4,55 +4,58 @@
#ifndef _CNSS_DEBUG_H
#define _CNSS_DEBUG_H
#if IS_ENABLED(CONFIG_IPC_LOGGING)
#include <linux/ipc_logging.h>
#endif
#include <linux/printk.h>
#if IS_ENABLED(CONFIG_IPC_LOGGING)
#define CNSS_IPC_LOG_PAGES 32
#include <linux/ipc_logging.h>
#include <asm/current.h>
extern void *cnss_ipc_log_context;
extern void *cnss_ipc_log_long_context;
#define cnss_ipc_log_string(_x...) \
ipc_log_string(cnss_ipc_log_context, _x)
#define cnss_ipc_log_long_string(_x...) \
ipc_log_string(cnss_ipc_log_long_context, _x)
#ifdef CONFIG_CNSS2_DEBUG
#define CNSS_IPC_LOG_PAGES 100
#else
#define cnss_ipc_log_string(_x...)
#define cnss_ipc_log_long_string(_x...)
#define CNSS_IPC_LOG_PAGES 50
#endif
#define cnss_debug_log_print(_x...) \
cnss_debug_ipc_log_print(cnss_ipc_log_context, _x)
#define cnss_debug_log_long_print(_x...) \
cnss_debug_ipc_log_print(cnss_ipc_log_long_context, _x)
#else
#define cnss_debug_log_print(_x...) \
cnss_debug_ipc_log_print((void *)NULL, _x)
#define cnss_debug_log_long_print(_x...) \
cnss_debug_ipc_log_print((void *)NULL, _x)
#endif
#define cnss_pr_err(_fmt, ...) do { \
printk("%scnss: " _fmt, KERN_ERR, ##__VA_ARGS__); \
cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
} while (0)
#define proc_name (in_irq() ? "irq" : \
(in_softirq() ? "soft_irq" : current->comm))
#define cnss_pr_warn(_fmt, ...) do { \
printk("%scnss: " _fmt, KERN_WARNING, ##__VA_ARGS__); \
cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
} while (0)
#define cnss_pr_err(_fmt, ...) \
cnss_debug_log_print(proc_name, __func__, \
KERN_ERR, _fmt, ##__VA_ARGS__)
#define cnss_pr_info(_fmt, ...) do { \
printk("%scnss: " _fmt, KERN_INFO, ##__VA_ARGS__); \
cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
} while (0)
#define cnss_pr_warn(_fmt, ...) \
cnss_debug_log_print(proc_name, __func__, \
KERN_WARNING, _fmt, ##__VA_ARGS__)
#define cnss_pr_dbg(_fmt, ...) do { \
printk("%scnss: " _fmt, KERN_DEBUG, ##__VA_ARGS__); \
cnss_ipc_log_string("%scnss: " _fmt, "", ##__VA_ARGS__);\
} while (0)
#define cnss_pr_info(_fmt, ...) \
cnss_debug_log_print(proc_name, __func__, \
KERN_INFO, _fmt, ##__VA_ARGS__)
#define cnss_pr_vdbg(_fmt, ...) do { \
printk("%scnss: " _fmt, KERN_DEBUG, ##__VA_ARGS__); \
cnss_ipc_log_long_string("%scnss: " _fmt, "", \
##__VA_ARGS__); \
} while (0)
#define cnss_pr_dbg(_fmt, ...) \
cnss_debug_log_print(proc_name, __func__, \
KERN_DEBUG, _fmt, ##__VA_ARGS__)
#define cnss_pr_buf(_fmt, ...) \
cnss_ipc_log_long_string("%scnss: " _fmt, "", ##__VA_ARGS__) \
#define cnss_pr_vdbg(_fmt, ...) \
cnss_debug_log_long_print(proc_name, __func__, \
KERN_DEBUG, _fmt, ##__VA_ARGS__)
#define cnss_pr_buf(_fmt, ...) \
cnss_debug_log_long_print(proc_name, __func__, \
NULL, _fmt, ##__VA_ARGS__)
#ifdef CONFIG_CNSS2_DEBUG
#define CNSS_ASSERT(_condition) do { \
@ -79,5 +82,6 @@ int cnss_debug_init(void);
void cnss_debug_deinit(void);
int cnss_debugfs_create(struct cnss_plat_data *plat_priv);
void cnss_debugfs_destroy(struct cnss_plat_data *plat_priv);
void cnss_debug_ipc_log_print(void *log_ctx, char *process, const char *fn,
const char *log_level, char *fmt, ...);
#endif /* _CNSS_DEBUG_H */