diff options
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index cdf53a8d9ff5..a51228ac9331 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -2095,6 +2095,77 @@ static inline u32 dev_ethtool_get_flags(struct net_device *dev) | |||
2095 | return 0; | 2095 | return 0; |
2096 | return dev->ethtool_ops->get_flags(dev); | 2096 | return dev->ethtool_ops->get_flags(dev); |
2097 | } | 2097 | } |
2098 | |||
2099 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ | ||
2100 | |||
2101 | /* netdev_printk helpers, similar to dev_printk */ | ||
2102 | |||
2103 | static inline const char *netdev_name(const struct net_device *dev) | ||
2104 | { | ||
2105 | if (dev->reg_state != NETREG_REGISTERED) | ||
2106 | return "(unregistered net_device)"; | ||
2107 | return dev->name; | ||
2108 | } | ||
2109 | |||
2110 | #define netdev_printk(level, netdev, format, args...) \ | ||
2111 | dev_printk(level, (netdev)->dev.parent, \ | ||
2112 | "%s: " format, \ | ||
2113 | netdev_name(netdev), ##args) | ||
2114 | |||
2115 | #define netdev_emerg(dev, format, args...) \ | ||
2116 | netdev_printk(KERN_EMERG, dev, format, ##args) | ||
2117 | #define netdev_alert(dev, format, args...) \ | ||
2118 | netdev_printk(KERN_ALERT, dev, format, ##args) | ||
2119 | #define netdev_crit(dev, format, args...) \ | ||
2120 | netdev_printk(KERN_CRIT, dev, format, ##args) | ||
2121 | #define netdev_err(dev, format, args...) \ | ||
2122 | netdev_printk(KERN_ERR, dev, format, ##args) | ||
2123 | #define netdev_warn(dev, format, args...) \ | ||
2124 | netdev_printk(KERN_WARNING, dev, format, ##args) | ||
2125 | #define netdev_notice(dev, format, args...) \ | ||
2126 | netdev_printk(KERN_NOTICE, dev, format, ##args) | ||
2127 | #define netdev_info(dev, format, args...) \ | ||
2128 | netdev_printk(KERN_INFO, dev, format, ##args) | ||
2129 | |||
2130 | #if defined(DEBUG) | ||
2131 | #define netdev_dbg(__dev, format, args...) \ | ||
2132 | netdev_printk(KERN_DEBUG, __dev, format, ##args) | ||
2133 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
2134 | #define netdev_dbg(__dev, format, args...) \ | ||
2135 | do { \ | ||
2136 | dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \ | ||
2137 | netdev_name(__dev), ##args); \ | ||
2138 | } while (0) | ||
2139 | #else | ||
2140 | #define netdev_dbg(__dev, format, args...) \ | ||
2141 | ({ \ | ||
2142 | if (0) \ | ||
2143 | netdev_printk(KERN_DEBUG, __dev, format, ##args); \ | ||
2144 | 0; \ | ||
2145 | }) | ||
2146 | #endif | ||
2147 | |||
2148 | #if defined(VERBOSE_DEBUG) | ||
2149 | #define netdev_vdbg netdev_dbg | ||
2150 | #else | ||
2151 | |||
2152 | #define netdev_vdbg(dev, format, args...) \ | ||
2153 | ({ \ | ||
2154 | if (0) \ | ||
2155 | netdev_printk(KERN_DEBUG, dev, format, ##args); \ | ||
2156 | 0; \ | ||
2157 | }) | ||
2158 | #endif | ||
2159 | |||
2160 | /* | ||
2161 | * netdev_WARN() acts like dev_printk(), but with the key difference | ||
2162 | * of using a WARN/WARN_ON to get the message out, including the | ||
2163 | * file/line information and a backtrace. | ||
2164 | */ | ||
2165 | #define netdev_WARN(dev, format, args...) \ | ||
2166 | WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args); | ||
2167 | |||
2168 | |||
2098 | #endif /* __KERNEL__ */ | 2169 | #endif /* __KERNEL__ */ |
2099 | 2170 | ||
2100 | #endif /* _LINUX_NETDEVICE_H */ | 2171 | #endif /* _LINUX_NETDEVICE_H */ |