Commit 923abb9d authored by Gal Pressman's avatar Gal Pressman Committed by Doug Ledford

RDMA/core: Introduce RDMA subsystem ibdev_* print functions

Similarly to dev/netdev/etc printk helpers, add standard printk helpers
for the RDMA subsystem.

Example output:
efa 0000:00:06.0 efa_0: Hello World!
efa_0: Hello World! (no parent device set)
(NULL ib_device): Hello World! (ibdev is NULL)

Cc: Jason Baron <jbaron@akamai.com>
Suggested-by: default avatarJason Gunthorpe <jgg@ziepe.ca>
Suggested-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarGal Pressman <galpress@amazon.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Reviewed-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent b9b0f345
...@@ -197,6 +197,66 @@ static int ib_security_change(struct notifier_block *nb, unsigned long event, ...@@ -197,6 +197,66 @@ static int ib_security_change(struct notifier_block *nb, unsigned long event,
static void ib_policy_change_task(struct work_struct *work); static void ib_policy_change_task(struct work_struct *work);
static DECLARE_WORK(ib_policy_change_work, ib_policy_change_task); static DECLARE_WORK(ib_policy_change_work, ib_policy_change_task);
static void __ibdev_printk(const char *level, const struct ib_device *ibdev,
struct va_format *vaf)
{
if (ibdev && ibdev->dev.parent)
dev_printk_emit(level[1] - '0',
ibdev->dev.parent,
"%s %s %s: %pV",
dev_driver_string(ibdev->dev.parent),
dev_name(ibdev->dev.parent),
dev_name(&ibdev->dev),
vaf);
else if (ibdev)
printk("%s%s: %pV",
level, dev_name(&ibdev->dev), vaf);
else
printk("%s(NULL ib_device): %pV", level, vaf);
}
void ibdev_printk(const char *level, const struct ib_device *ibdev,
const char *format, ...)
{
struct va_format vaf;
va_list args;
va_start(args, format);
vaf.fmt = format;
vaf.va = &args;
__ibdev_printk(level, ibdev, &vaf);
va_end(args);
}
EXPORT_SYMBOL(ibdev_printk);
#define define_ibdev_printk_level(func, level) \
void func(const struct ib_device *ibdev, const char *fmt, ...) \
{ \
struct va_format vaf; \
va_list args; \
\
va_start(args, fmt); \
\
vaf.fmt = fmt; \
vaf.va = &args; \
\
__ibdev_printk(level, ibdev, &vaf); \
\
va_end(args); \
} \
EXPORT_SYMBOL(func);
define_ibdev_printk_level(ibdev_emerg, KERN_EMERG);
define_ibdev_printk_level(ibdev_alert, KERN_ALERT);
define_ibdev_printk_level(ibdev_crit, KERN_CRIT);
define_ibdev_printk_level(ibdev_err, KERN_ERR);
define_ibdev_printk_level(ibdev_warn, KERN_WARNING);
define_ibdev_printk_level(ibdev_notice, KERN_NOTICE);
define_ibdev_printk_level(ibdev_info, KERN_INFO);
static struct notifier_block ibdev_lsm_nb = { static struct notifier_block ibdev_lsm_nb = {
.notifier_call = ib_security_change, .notifier_call = ib_security_change,
}; };
......
...@@ -71,6 +71,13 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, ...@@ -71,6 +71,13 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
const struct net_device *dev, const struct net_device *dev,
const char *fmt, ...); const char *fmt, ...);
struct ib_device;
extern __printf(3, 4)
void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
const struct ib_device *ibdev,
const char *fmt, ...);
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
static struct _ddebug __aligned(8) \ static struct _ddebug __aligned(8) \
__attribute__((section("__verbose"))) name = { \ __attribute__((section("__verbose"))) name = { \
...@@ -154,6 +161,10 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, ...@@ -154,6 +161,10 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
_dynamic_func_call(fmt, __dynamic_netdev_dbg, \ _dynamic_func_call(fmt, __dynamic_netdev_dbg, \
dev, fmt, ##__VA_ARGS__) dev, fmt, ##__VA_ARGS__)
#define dynamic_ibdev_dbg(dev, fmt, ...) \
_dynamic_func_call(fmt, __dynamic_ibdev_dbg, \
dev, fmt, ##__VA_ARGS__)
#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
groupsize, buf, len, ascii) \ groupsize, buf, len, ascii) \
_dynamic_func_call_no_desc(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \ _dynamic_func_call_no_desc(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \
......
...@@ -74,6 +74,36 @@ extern struct workqueue_struct *ib_wq; ...@@ -74,6 +74,36 @@ extern struct workqueue_struct *ib_wq;
extern struct workqueue_struct *ib_comp_wq; extern struct workqueue_struct *ib_comp_wq;
extern struct workqueue_struct *ib_comp_unbound_wq; extern struct workqueue_struct *ib_comp_unbound_wq;
__printf(3, 4) __cold
void ibdev_printk(const char *level, const struct ib_device *ibdev,
const char *format, ...);
__printf(2, 3) __cold
void ibdev_emerg(const struct ib_device *ibdev, const char *format, ...);
__printf(2, 3) __cold
void ibdev_alert(const struct ib_device *ibdev, const char *format, ...);
__printf(2, 3) __cold
void ibdev_crit(const struct ib_device *ibdev, const char *format, ...);
__printf(2, 3) __cold
void ibdev_err(const struct ib_device *ibdev, const char *format, ...);
__printf(2, 3) __cold
void ibdev_warn(const struct ib_device *ibdev, const char *format, ...);
__printf(2, 3) __cold
void ibdev_notice(const struct ib_device *ibdev, const char *format, ...);
__printf(2, 3) __cold
void ibdev_info(const struct ib_device *ibdev, const char *format, ...);
#if defined(CONFIG_DYNAMIC_DEBUG)
#define ibdev_dbg(__dev, format, args...) \
dynamic_ibdev_dbg(__dev, format, ##args)
#elif defined(DEBUG)
#define ibdev_dbg(__dev, format, args...) \
ibdev_printk(KERN_DEBUG, __dev, format, ##args)
#else
__printf(2, 3) __cold
static inline
void ibdev_dbg(const struct ib_device *ibdev, const char *format, ...) {}
#endif
union ib_gid { union ib_gid {
u8 raw[16]; u8 raw[16];
struct { struct {
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <rdma/ib_verbs.h>
extern struct _ddebug __start___verbose[]; extern struct _ddebug __start___verbose[];
extern struct _ddebug __stop___verbose[]; extern struct _ddebug __stop___verbose[];
...@@ -636,6 +638,41 @@ EXPORT_SYMBOL(__dynamic_netdev_dbg); ...@@ -636,6 +638,41 @@ EXPORT_SYMBOL(__dynamic_netdev_dbg);
#endif #endif
#if IS_ENABLED(CONFIG_INFINIBAND)
void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
const struct ib_device *ibdev, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
if (ibdev && ibdev->dev.parent) {
char buf[PREFIX_SIZE];
dev_printk_emit(LOGLEVEL_DEBUG, ibdev->dev.parent,
"%s%s %s %s: %pV",
dynamic_emit_prefix(descriptor, buf),
dev_driver_string(ibdev->dev.parent),
dev_name(ibdev->dev.parent),
dev_name(&ibdev->dev),
&vaf);
} else if (ibdev) {
printk(KERN_DEBUG "%s: %pV", dev_name(&ibdev->dev), &vaf);
} else {
printk(KERN_DEBUG "(NULL ib_device): %pV", &vaf);
}
va_end(args);
}
EXPORT_SYMBOL(__dynamic_ibdev_dbg);
#endif
#define DDEBUG_STRING_SIZE 1024 #define DDEBUG_STRING_SIZE 1024
static __initdata char ddebug_setup_string[DDEBUG_STRING_SIZE]; static __initdata char ddebug_setup_string[DDEBUG_STRING_SIZE];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment