net: allocate tx queues in register_netdevice
[pandora-kernel.git] / include / linux / netdevice.h
index af05186..880d565 100644 (file)
@@ -228,9 +228,9 @@ struct netdev_hw_addr {
 #define NETDEV_HW_ADDR_T_SLAVE         3
 #define NETDEV_HW_ADDR_T_UNICAST       4
 #define NETDEV_HW_ADDR_T_MULTICAST     5
-       int                     refcount;
        bool                    synced;
        bool                    global_use;
+       int                     refcount;
        struct rcu_head         rcu_head;
 };
 
@@ -281,6 +281,12 @@ struct hh_cache {
        unsigned long   hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)];
 };
 
+static inline void hh_cache_put(struct hh_cache *hh)
+{
+       if (atomic_dec_and_test(&hh->hh_refcnt))
+               kfree(hh);
+}
+
 /* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much.
  * Alternative is:
  *   dev->hard_header_len ? (dev->hard_header_len +
@@ -884,6 +890,9 @@ struct net_device {
        int                     iflink;
 
        struct net_device_stats stats;
+       atomic_long_t           rx_dropped; /* dropped packets by core network
+                                            * Do not use this in drivers.
+                                            */
 
 #ifdef CONFIG_WIRELESS_EXT
        /* List of functions to handle Wireless Extensions (instead of ioctl).
@@ -918,10 +927,6 @@ struct net_device {
        unsigned short          needed_headroom;
        unsigned short          needed_tailroom;
 
-       struct net_device       *master; /* Pointer to master device of a group,
-                                         * which this device is member of.
-                                         */
-
        /* Interface address info. */
        unsigned char           perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
        unsigned char           addr_assign_type; /* hw address assignment type */
@@ -942,7 +947,7 @@ struct net_device {
        void                    *dsa_ptr;       /* dsa specific data */
 #endif
        void                    *atalk_ptr;     /* AppleTalk link       */
-       void                    *ip_ptr;        /* IPv4 specific data   */
+       struct in_device __rcu  *ip_ptr;        /* IPv4 specific data   */
        void                    *dn_ptr;        /* DECnet specific data */
        void                    *ip6_ptr;       /* IPv6 specific data */
        void                    *ec_ptr;        /* Econet specific data */
@@ -951,7 +956,7 @@ struct net_device {
                                                   assign before registering */
 
 /*
- * Cache line mostly used on receive path (including eth_type_trans())
+ * Cache lines mostly used on receive path (including eth_type_trans())
  */
        unsigned long           last_rx;        /* Time of last Rx
                                                 * This should not be set in
@@ -961,6 +966,10 @@ struct net_device {
                                                 * avoid dirtying this cache line.
                                                 */
 
+       struct net_device       *master; /* Pointer to master device of a group,
+                                         * which this device is member of.
+                                         */
+
        /* Interface address info used in eth_type_trans() */
        unsigned char           *dev_addr;      /* hw address, (before bcast
                                                   because most packets are
@@ -976,14 +985,21 @@ struct net_device {
 
        struct netdev_rx_queue  *_rx;
 
-       /* Number of RX queues allocated at alloc_netdev_mq() time  */
+       /* Number of RX queues allocated at register_netdev() time */
        unsigned int            num_rx_queues;
+
+       /* Number of RX queues currently active in device */
+       unsigned int            real_num_rx_queues;
 #endif
 
-       struct netdev_queue     rx_queue;
        rx_handler_func_t       *rx_handler;
        void                    *rx_handler_data;
 
+       struct netdev_queue __rcu *ingress_queue;
+
+/*
+ * Cache lines mostly used on transmit path
+ */
        struct netdev_queue     *_tx ____cacheline_aligned_in_smp;
 
        /* Number of TX queues allocated at alloc_netdev_mq() time  */
@@ -997,9 +1013,7 @@ struct net_device {
 
        unsigned long           tx_queue_len;   /* Max frames per queue allowed */
        spinlock_t              tx_global_lock;
-/*
- * One part is mostly used on xmit path (device)
- */
+
        /* These may be needed for future network-power-down code. */
 
        /*
@@ -1012,7 +1026,7 @@ struct net_device {
        struct timer_list       watchdog_timer;
 
        /* Number of references to this device */
-       atomic_t                refcnt ____cacheline_aligned_in_smp;
+       int __percpu            *pcpu_refcnt;
 
        /* delayed register/unregister */
        struct list_head        todo_list;
@@ -1048,8 +1062,12 @@ struct net_device {
 #endif
 
        /* mid-layer private */
-       void                    *ml_priv;
-
+       union {
+               void                            *ml_priv;
+               struct pcpu_lstats __percpu     *lstats; /* loopback stats */
+               struct pcpu_tstats __percpu     *tstats; /* tunnel stats */
+               struct pcpu_dstats __percpu     *dstats; /* dummy stats */
+       };
        /* GARP */
        struct garp_port        *garp_port;
 
@@ -1312,6 +1330,7 @@ static inline void unregister_netdevice(struct net_device *dev)
        unregister_netdevice_queue(dev, NULL);
 }
 
+extern int             netdev_refcnt_read(const struct net_device *dev);
 extern void            free_netdev(struct net_device *dev);
 extern void            synchronize_net(void);
 extern int             register_netdevice_notifier(struct notifier_block *nb);
@@ -1674,11 +1693,34 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
  */
 static inline int netif_is_multiqueue(const struct net_device *dev)
 {
-       return (dev->num_tx_queues > 1);
+       return dev->num_tx_queues > 1;
 }
 
-extern void netif_set_real_num_tx_queues(struct net_device *dev,
-                                        unsigned int txq);
+extern int netif_set_real_num_tx_queues(struct net_device *dev,
+                                       unsigned int txq);
+
+#ifdef CONFIG_RPS
+extern int netif_set_real_num_rx_queues(struct net_device *dev,
+                                       unsigned int rxq);
+#else
+static inline int netif_set_real_num_rx_queues(struct net_device *dev,
+                                               unsigned int rxq)
+{
+       return 0;
+}
+#endif
+
+static inline int netif_copy_real_num_queues(struct net_device *to_dev,
+                                            const struct net_device *from_dev)
+{
+       netif_set_real_num_tx_queues(to_dev, from_dev->real_num_tx_queues);
+#ifdef CONFIG_RPS
+       return netif_set_real_num_rx_queues(to_dev,
+                                           from_dev->real_num_rx_queues);
+#else
+       return 0;
+#endif
+}
 
 /* Use this variant when it is known for sure that it
  * is executing from hardware interrupt context or with hardware interrupts
@@ -1757,7 +1799,7 @@ extern void netdev_run_todo(void);
  */
 static inline void dev_put(struct net_device *dev)
 {
-       atomic_dec(&dev->refcnt);
+       irqsafe_cpu_dec(*dev->pcpu_refcnt);
 }
 
 /**
@@ -1768,7 +1810,7 @@ static inline void dev_put(struct net_device *dev)
  */
 static inline void dev_hold(struct net_device *dev)
 {
-       atomic_inc(&dev->refcnt);
+       irqsafe_cpu_inc(*dev->pcpu_refcnt);
 }
 
 /* Carrier loss detection, dial on demand. The functions netif_carrier_on