net: Get rid of rtnl_link_stats64 / net_device_stats union
[pandora-kernel.git] / include / linux / netdevice.h
index 8fa5e5a..17e95e3 100644 (file)
@@ -162,42 +162,32 @@ static inline bool dev_xmit_complete(int rc)
 /*
  *     Old network device statistics. Fields are native words
  *     (unsigned long) so they can be read and written atomically.
- *     Each field is padded to 64 bits for compatibility with
- *     rtnl_link_stats64.
  */
 
-#if BITS_PER_LONG == 64
-#define NET_DEVICE_STATS_DEFINE(name)  unsigned long name
-#elif defined(__LITTLE_ENDIAN)
-#define NET_DEVICE_STATS_DEFINE(name)  unsigned long name, pad_ ## name
-#else
-#define NET_DEVICE_STATS_DEFINE(name)  unsigned long pad_ ## name, name
-#endif
-
 struct net_device_stats {
-       NET_DEVICE_STATS_DEFINE(rx_packets);
-       NET_DEVICE_STATS_DEFINE(tx_packets);
-       NET_DEVICE_STATS_DEFINE(rx_bytes);
-       NET_DEVICE_STATS_DEFINE(tx_bytes);
-       NET_DEVICE_STATS_DEFINE(rx_errors);
-       NET_DEVICE_STATS_DEFINE(tx_errors);
-       NET_DEVICE_STATS_DEFINE(rx_dropped);
-       NET_DEVICE_STATS_DEFINE(tx_dropped);
-       NET_DEVICE_STATS_DEFINE(multicast);
-       NET_DEVICE_STATS_DEFINE(collisions);
-       NET_DEVICE_STATS_DEFINE(rx_length_errors);
-       NET_DEVICE_STATS_DEFINE(rx_over_errors);
-       NET_DEVICE_STATS_DEFINE(rx_crc_errors);
-       NET_DEVICE_STATS_DEFINE(rx_frame_errors);
-       NET_DEVICE_STATS_DEFINE(rx_fifo_errors);
-       NET_DEVICE_STATS_DEFINE(rx_missed_errors);
-       NET_DEVICE_STATS_DEFINE(tx_aborted_errors);
-       NET_DEVICE_STATS_DEFINE(tx_carrier_errors);
-       NET_DEVICE_STATS_DEFINE(tx_fifo_errors);
-       NET_DEVICE_STATS_DEFINE(tx_heartbeat_errors);
-       NET_DEVICE_STATS_DEFINE(tx_window_errors);
-       NET_DEVICE_STATS_DEFINE(rx_compressed);
-       NET_DEVICE_STATS_DEFINE(tx_compressed);
+       unsigned long   rx_packets;
+       unsigned long   tx_packets;
+       unsigned long   rx_bytes;
+       unsigned long   tx_bytes;
+       unsigned long   rx_errors;
+       unsigned long   tx_errors;
+       unsigned long   rx_dropped;
+       unsigned long   tx_dropped;
+       unsigned long   multicast;
+       unsigned long   collisions;
+       unsigned long   rx_length_errors;
+       unsigned long   rx_over_errors;
+       unsigned long   rx_crc_errors;
+       unsigned long   rx_frame_errors;
+       unsigned long   rx_fifo_errors;
+       unsigned long   rx_missed_errors;
+       unsigned long   tx_aborted_errors;
+       unsigned long   tx_carrier_errors;
+       unsigned long   tx_fifo_errors;
+       unsigned long   tx_heartbeat_errors;
+       unsigned long   tx_window_errors;
+       unsigned long   rx_compressed;
+       unsigned long   tx_compressed;
 };
 
 #endif  /*  __KERNEL__  */
@@ -666,13 +656,13 @@ struct netdev_rx_queue {
  *     Callback uses when the transmitter has not made any progress
  *     for dev->watchdog ticks.
  *
- * struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev);
+ * struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
+ *                      struct rtnl_link_stats64 *storage);
  * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
  *     Called when a user wants to get the network device usage
  *     statistics. Drivers must do one of the following:
- *     1. Define @ndo_get_stats64 to update a rtnl_link_stats64 structure
- *        (which should normally be dev->stats64) and return a ponter to
- *        it. The structure must not be changed asynchronously.
+ *     1. Define @ndo_get_stats64 to fill in a zero-initialised
+ *        rtnl_link_stats64 structure passed by the caller.
  *     2. Define @ndo_get_stats to update a net_device_stats structure
  *        (which should normally be dev->stats) and return a pointer to
  *        it. The structure may be changed asynchronously only if each
@@ -733,7 +723,8 @@ struct net_device_ops {
                                                   struct neigh_parms *);
        void                    (*ndo_tx_timeout) (struct net_device *dev);
 
-       struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev);
+       struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
+                                                    struct rtnl_link_stats64 *storage);
        struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
 
        void                    (*ndo_vlan_rx_register)(struct net_device *dev,
@@ -886,10 +877,7 @@ struct net_device {
        int                     ifindex;
        int                     iflink;
 
-       union {
-               struct rtnl_link_stats64 stats64;
-               struct net_device_stats stats;
-       };
+       struct net_device_stats stats;
 
 #ifdef CONFIG_WIRELESS_EXT
        /* List of functions to handle Wireless Extensions (instead of ioctl).
@@ -1672,6 +1660,9 @@ static inline int netif_is_multiqueue(const struct net_device *dev)
        return (dev->num_tx_queues > 1);
 }
 
+extern void netif_set_real_num_tx_queues(struct net_device *dev,
+                                        unsigned int txq);
+
 /* Use this variant when it is known for sure that it
  * is executing from hardware interrupt context or with hardware interrupts
  * disabled.
@@ -2139,8 +2130,10 @@ extern void              netdev_features_change(struct net_device *dev);
 /* Load a device via the kmod */
 extern void            dev_load(struct net *net, const char *name);
 extern void            dev_mcast_init(void);
-extern const struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev);
-extern void            dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats);
+extern const struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
+                                                    struct rtnl_link_stats64 *storage);
+extern void            dev_txq_stats_fold(const struct net_device *dev,
+                                          struct rtnl_link_stats64 *stats);
 
 extern int             netdev_max_backlog;
 extern int             netdev_tstamp_prequeue;
@@ -2250,25 +2243,23 @@ static inline const char *netdev_name(const struct net_device *dev)
        return dev->name;
 }
 
-#define netdev_printk(level, netdev, format, args...)          \
-       dev_printk(level, (netdev)->dev.parent,                 \
-                  "%s: " format,                               \
-                  netdev_name(netdev), ##args)
-
-#define netdev_emerg(dev, format, args...)                     \
-       netdev_printk(KERN_EMERG, dev, format, ##args)
-#define netdev_alert(dev, format, args...)                     \
-       netdev_printk(KERN_ALERT, dev, format, ##args)
-#define netdev_crit(dev, format, args...)                      \
-       netdev_printk(KERN_CRIT, dev, format, ##args)
-#define netdev_err(dev, format, args...)                       \
-       netdev_printk(KERN_ERR, dev, format, ##args)
-#define netdev_warn(dev, format, args...)                      \
-       netdev_printk(KERN_WARNING, dev, format, ##args)
-#define netdev_notice(dev, format, args...)                    \
-       netdev_printk(KERN_NOTICE, dev, format, ##args)
-#define netdev_info(dev, format, args...)                      \
-       netdev_printk(KERN_INFO, dev, format, ##args)
+extern int netdev_printk(const char *level, const struct net_device *dev,
+                        const char *format, ...)
+       __attribute__ ((format (printf, 3, 4)));
+extern int netdev_emerg(const struct net_device *dev, const char *format, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int netdev_alert(const struct net_device *dev, const char *format, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int netdev_crit(const struct net_device *dev, const char *format, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int netdev_err(const struct net_device *dev, const char *format, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int netdev_warn(const struct net_device *dev, const char *format, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int netdev_notice(const struct net_device *dev, const char *format, ...)
+       __attribute__ ((format (printf, 2, 3)));
+extern int netdev_info(const struct net_device *dev, const char *format, ...)
+       __attribute__ ((format (printf, 2, 3)));
 
 #if defined(DEBUG)
 #define netdev_dbg(__dev, format, args...)                     \
@@ -2316,20 +2307,26 @@ do {                                                            \
                netdev_printk(level, (dev), fmt, ##args);       \
 } while (0)
 
+#define netif_level(level, priv, type, dev, fmt, args...)      \
+do {                                                           \
+       if (netif_msg_##type(priv))                             \
+               netdev_##level(dev, fmt, ##args);               \
+} while (0)
+
 #define netif_emerg(priv, type, dev, fmt, args...)             \
-       netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args)
+       netif_level(emerg, priv, type, dev, fmt, ##args)
 #define netif_alert(priv, type, dev, fmt, args...)             \
-       netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args)
+       netif_level(alert, priv, type, dev, fmt, ##args)
 #define netif_crit(priv, type, dev, fmt, args...)              \
-       netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args)
+       netif_level(crit, priv, type, dev, fmt, ##args)
 #define netif_err(priv, type, dev, fmt, args...)               \
-       netif_printk(priv, type, KERN_ERR, dev, fmt, ##args)
+       netif_level(err, priv, type, dev, fmt, ##args)
 #define netif_warn(priv, type, dev, fmt, args...)              \
-       netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args)
+       netif_level(warn, priv, type, dev, fmt, ##args)
 #define netif_notice(priv, type, dev, fmt, args...)            \
-       netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args)
+       netif_level(notice, priv, type, dev, fmt, ##args)
 #define netif_info(priv, type, dev, fmt, args...)              \
-       netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args)
+       netif_level(info, priv, type, dev, fmt, ##args)
 
 #if defined(DEBUG)
 #define netif_dbg(priv, type, dev, format, args...)            \
@@ -2352,7 +2349,7 @@ do {                                                              \
 #endif
 
 #if defined(VERBOSE_DEBUG)
-#define netif_vdbg     netdev_dbg
+#define netif_vdbg     netif_dbg
 #else
 #define netif_vdbg(priv, type, dev, format, args...)           \
 ({                                                             \