diff options
-rw-r--r-- | include/linux/dynamic_debug.h | 17 | ||||
-rw-r--r-- | include/linux/netdevice.h | 6 | ||||
-rw-r--r-- | lib/dynamic_debug.c | 25 | ||||
-rw-r--r-- | net/core/dev.c | 3 |
4 files changed, 48 insertions, 3 deletions
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 843cb9eb4226..feaac1ee3001 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h | |||
@@ -47,6 +47,13 @@ extern int __dynamic_dev_dbg(struct _ddebug *descriptor, | |||
47 | const char *fmt, ...) | 47 | const char *fmt, ...) |
48 | __attribute__ ((format (printf, 3, 4))); | 48 | __attribute__ ((format (printf, 3, 4))); |
49 | 49 | ||
50 | struct net_device; | ||
51 | |||
52 | extern int __dynamic_netdev_dbg(struct _ddebug *descriptor, | ||
53 | const struct net_device *dev, | ||
54 | const char *fmt, ...) | ||
55 | __attribute__ ((format (printf, 3, 4))); | ||
56 | |||
50 | #define dynamic_pr_debug(fmt, ...) do { \ | 57 | #define dynamic_pr_debug(fmt, ...) do { \ |
51 | static struct _ddebug descriptor \ | 58 | static struct _ddebug descriptor \ |
52 | __used \ | 59 | __used \ |
@@ -67,6 +74,16 @@ extern int __dynamic_dev_dbg(struct _ddebug *descriptor, | |||
67 | __dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__); \ | 74 | __dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__); \ |
68 | } while (0) | 75 | } while (0) |
69 | 76 | ||
77 | #define dynamic_netdev_dbg(dev, fmt, ...) do { \ | ||
78 | static struct _ddebug descriptor \ | ||
79 | __used \ | ||
80 | __attribute__((section("__verbose"), aligned(8))) = \ | ||
81 | { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ | ||
82 | _DPRINTK_FLAGS_DEFAULT }; \ | ||
83 | if (unlikely(descriptor.enabled)) \ | ||
84 | __dynamic_netdev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);\ | ||
85 | } while (0) | ||
86 | |||
70 | #else | 87 | #else |
71 | 88 | ||
72 | static inline int ddebug_remove_module(const char *mod) | 89 | static inline int ddebug_remove_module(const char *mod) |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ddee79bb8f15..9333a0300c5e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -2617,6 +2617,9 @@ static inline const char *netdev_name(const struct net_device *dev) | |||
2617 | return dev->name; | 2617 | return dev->name; |
2618 | } | 2618 | } |
2619 | 2619 | ||
2620 | extern int __netdev_printk(const char *level, const struct net_device *dev, | ||
2621 | struct va_format *vaf); | ||
2622 | |||
2620 | extern int netdev_printk(const char *level, const struct net_device *dev, | 2623 | extern int netdev_printk(const char *level, const struct net_device *dev, |
2621 | const char *format, ...) | 2624 | const char *format, ...) |
2622 | __attribute__ ((format (printf, 3, 4))); | 2625 | __attribute__ ((format (printf, 3, 4))); |
@@ -2644,8 +2647,7 @@ extern int netdev_info(const struct net_device *dev, const char *format, ...) | |||
2644 | #elif defined(CONFIG_DYNAMIC_DEBUG) | 2647 | #elif defined(CONFIG_DYNAMIC_DEBUG) |
2645 | #define netdev_dbg(__dev, format, args...) \ | 2648 | #define netdev_dbg(__dev, format, args...) \ |
2646 | do { \ | 2649 | do { \ |
2647 | dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \ | 2650 | dynamic_netdev_dbg(__dev, format, ##args); \ |
2648 | netdev_name(__dev), ##args); \ | ||
2649 | } while (0) | 2651 | } while (0) |
2650 | #else | 2652 | #else |
2651 | #define netdev_dbg(__dev, format, args...) \ | 2653 | #define netdev_dbg(__dev, format, args...) \ |
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 4fc03ddb05f2..ee3b9ba625c5 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/hardirq.h> | 33 | #include <linux/hardirq.h> |
34 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/netdevice.h> | ||
36 | 37 | ||
37 | extern struct _ddebug __start___verbose[]; | 38 | extern struct _ddebug __start___verbose[]; |
38 | extern struct _ddebug __stop___verbose[]; | 39 | extern struct _ddebug __stop___verbose[]; |
@@ -503,6 +504,30 @@ int __dynamic_dev_dbg(struct _ddebug *descriptor, | |||
503 | } | 504 | } |
504 | EXPORT_SYMBOL(__dynamic_dev_dbg); | 505 | EXPORT_SYMBOL(__dynamic_dev_dbg); |
505 | 506 | ||
507 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, | ||
508 | const struct net_device *dev, const char *fmt, ...) | ||
509 | { | ||
510 | struct va_format vaf; | ||
511 | va_list args; | ||
512 | int res; | ||
513 | |||
514 | BUG_ON(!descriptor); | ||
515 | BUG_ON(!fmt); | ||
516 | |||
517 | va_start(args, fmt); | ||
518 | |||
519 | vaf.fmt = fmt; | ||
520 | vaf.va = &args; | ||
521 | |||
522 | res = dynamic_emit_prefix(descriptor); | ||
523 | res += __netdev_printk(KERN_CONT, dev, &vaf); | ||
524 | |||
525 | va_end(args); | ||
526 | |||
527 | return res; | ||
528 | } | ||
529 | EXPORT_SYMBOL(__dynamic_netdev_dbg); | ||
530 | |||
506 | static __initdata char ddebug_setup_string[1024]; | 531 | static __initdata char ddebug_setup_string[1024]; |
507 | static __init int ddebug_setup_query(char *str) | 532 | static __init int ddebug_setup_query(char *str) |
508 | { | 533 | { |
diff --git a/net/core/dev.c b/net/core/dev.c index 17d67b579beb..c47a7bcf3c64 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -6290,7 +6290,7 @@ const char *netdev_drivername(const struct net_device *dev) | |||
6290 | return empty; | 6290 | return empty; |
6291 | } | 6291 | } |
6292 | 6292 | ||
6293 | static int __netdev_printk(const char *level, const struct net_device *dev, | 6293 | int __netdev_printk(const char *level, const struct net_device *dev, |
6294 | struct va_format *vaf) | 6294 | struct va_format *vaf) |
6295 | { | 6295 | { |
6296 | int r; | 6296 | int r; |
@@ -6305,6 +6305,7 @@ static int __netdev_printk(const char *level, const struct net_device *dev, | |||
6305 | 6305 | ||
6306 | return r; | 6306 | return r; |
6307 | } | 6307 | } |
6308 | EXPORT_SYMBOL(__netdev_printk); | ||
6308 | 6309 | ||
6309 | int netdev_printk(const char *level, const struct net_device *dev, | 6310 | int netdev_printk(const char *level, const struct net_device *dev, |
6310 | const char *format, ...) | 6311 | const char *format, ...) |