bootmem: Move node allocation macros back to !HAVE_ARCH_BOOTMEM_NODE
[pandora-kernel.git] / include / linux / netdevice.h
index f25d4f5..b4d056c 100644 (file)
@@ -118,14 +118,6 @@ struct wireless_dev;
 
 #endif  /*  __KERNEL__  */
 
-struct net_device_subqueue
-{
-       /* Give a control state for each queue.  This struct may contain
-        * per-queue locks in the future.
-        */
-       unsigned long   state;
-};
-
 /*
  *     Network device statistics. Akin to the 2.0 ether stats but
  *     with byte counters.
@@ -283,7 +275,6 @@ enum netdev_state_t
 {
        __LINK_STATE_START,
        __LINK_STATE_PRESENT,
-       __LINK_STATE_SCHED,
        __LINK_STATE_NOCARRIER,
        __LINK_STATE_LINKWATCH_PENDING,
        __LINK_STATE_DORMANT,
@@ -449,20 +440,15 @@ static inline void napi_synchronize(const struct napi_struct *n)
 enum netdev_queue_state_t
 {
        __QUEUE_STATE_XOFF,
-       __QUEUE_STATE_QDISC_RUNNING,
 };
 
 struct netdev_queue {
-       spinlock_t              lock;
        struct net_device       *dev;
        struct Qdisc            *qdisc;
        unsigned long           state;
-       struct sk_buff          *gso_skb;
        spinlock_t              _xmit_lock;
        int                     xmit_lock_owner;
        struct Qdisc            *qdisc_sleeping;
-       struct list_head        qdisc_list;
-       struct netdev_queue     *next_sched;
 } ____cacheline_aligned_in_smp;
 
 /*
@@ -533,7 +519,6 @@ struct net_device
 #define NETIF_F_LLTX           4096    /* LockLess TX - deprecated. Please */
                                        /* do not use LLTX in new drivers */
 #define NETIF_F_NETNS_LOCAL    8192    /* Does not change network namespaces */
-#define NETIF_F_MULTI_QUEUE    16384   /* Has multiple TX/RX queues */
 #define NETIF_F_LRO            32768   /* large receive offload */
 
        /* Segmentation offload features */
@@ -643,7 +628,13 @@ struct net_device
        struct netdev_queue     rx_queue;
 
        struct netdev_queue     *_tx ____cacheline_aligned_in_smp;
+
+       /* Number of TX queues allocated at alloc_netdev_mq() time  */
        unsigned int            num_tx_queues;
+
+       /* Number of TX queues currently active in device  */
+       unsigned int            real_num_tx_queues;
+
        unsigned long           tx_queue_len;   /* Max frames per queue allowed */
 
 /*
@@ -727,6 +718,9 @@ struct net_device
        void                    (*poll_controller)(struct net_device *dev);
 #endif
 
+       u16                     (*select_queue)(struct net_device *dev,
+                                               struct sk_buff *skb);
+
 #ifdef CONFIG_NET_NS
        /* Network namespace this network device is inside */
        struct net              *nd_net;
@@ -756,10 +750,6 @@ struct net_device
        /* for setting kernel sock attribute on TCP connection setup */
 #define GSO_MAX_SIZE           65536
        unsigned int            gso_max_size;
-
-       /* The TX queue control structures */
-       unsigned int                    egress_subqueue_count;
-       struct net_device_subqueue      egress_subqueue[1];
 };
 #define to_net_dev(d) container_of(d, struct net_device, dev)
 
@@ -815,7 +805,9 @@ void dev_net_set(struct net_device *dev, struct net *net)
  */
 static inline void *netdev_priv(const struct net_device *dev)
 {
-       return dev->priv;
+       return (char *)dev + ((sizeof(struct net_device)
+                              + NETDEV_ALIGN_CONST)
+                             & ~NETDEV_ALIGN_CONST);
 }
 
 /* Set the sysfs physical device reference for the network logical device
@@ -973,7 +965,7 @@ static inline int unregister_gifconf(unsigned int family)
  */
 struct softnet_data
 {
-       struct netdev_queue     *output_queue;
+       struct Qdisc            *output_queue;
        struct sk_buff_head     input_pkt_queue;
        struct list_head        poll_list;
        struct sk_buff          *completion_queue;
@@ -988,17 +980,25 @@ DECLARE_PER_CPU(struct softnet_data,softnet_data);
 
 #define HAVE_NETIF_QUEUE
 
-extern void __netif_schedule(struct netdev_queue *txq);
+extern void __netif_schedule(struct Qdisc *q);
 
 static inline void netif_schedule_queue(struct netdev_queue *txq)
 {
        if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
-               __netif_schedule(txq);
+               __netif_schedule(txq->qdisc);
+}
+
+static inline void netif_tx_schedule_all(struct net_device *dev)
+{
+       unsigned int i;
+
+       for (i = 0; i < dev->num_tx_queues; i++)
+               netif_schedule_queue(netdev_get_tx_queue(dev, i));
 }
 
-static inline void netif_schedule(struct net_device *dev)
+static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)
 {
-       netif_schedule_queue(netdev_get_tx_queue(dev, 0));
+       clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
 }
 
 /**
@@ -1007,23 +1007,21 @@ static inline void netif_schedule(struct net_device *dev)
  *
  *     Allow upper layers to call the device hard_start_xmit routine.
  */
-static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)
+static inline void netif_start_queue(struct net_device *dev)
 {
-       clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
+       netif_tx_start_queue(netdev_get_tx_queue(dev, 0));
 }
 
-static inline void netif_start_queue(struct net_device *dev)
+static inline void netif_tx_start_all_queues(struct net_device *dev)
 {
-       netif_tx_start_queue(netdev_get_tx_queue(dev, 0));
+       unsigned int i;
+
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+               netif_tx_start_queue(txq);
+       }
 }
 
-/**
- *     netif_wake_queue - restart transmit
- *     @dev: network device
- *
- *     Allow upper layers to call the device hard_start_xmit routine.
- *     Used for flow control when transmit resources are available.
- */
 static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
 {
 #ifdef CONFIG_NETPOLL_TRAP
@@ -1033,14 +1031,36 @@ static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
        }
 #endif
        if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state))
-               __netif_schedule(dev_queue);
+               __netif_schedule(dev_queue->qdisc);
 }
 
+/**
+ *     netif_wake_queue - restart transmit
+ *     @dev: network device
+ *
+ *     Allow upper layers to call the device hard_start_xmit routine.
+ *     Used for flow control when transmit resources are available.
+ */
 static inline void netif_wake_queue(struct net_device *dev)
 {
        netif_tx_wake_queue(netdev_get_tx_queue(dev, 0));
 }
 
+static inline void netif_tx_wake_all_queues(struct net_device *dev)
+{
+       unsigned int i;
+
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+               netif_tx_wake_queue(txq);
+       }
+}
+
+static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
+{
+       set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
+}
+
 /**
  *     netif_stop_queue - stop transmitted packets
  *     @dev: network device
@@ -1048,14 +1068,24 @@ static inline void netif_wake_queue(struct net_device *dev)
  *     Stop upper layers calling the device hard_start_xmit routine.
  *     Used for flow control when transmit resources are unavailable.
  */
-static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
+static inline void netif_stop_queue(struct net_device *dev)
 {
-       set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
+       netif_tx_stop_queue(netdev_get_tx_queue(dev, 0));
 }
 
-static inline void netif_stop_queue(struct net_device *dev)
+static inline void netif_tx_stop_all_queues(struct net_device *dev)
 {
-       netif_tx_stop_queue(netdev_get_tx_queue(dev, 0));
+       unsigned int i;
+
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+               netif_tx_stop_queue(txq);
+       }
+}
+
+static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
+{
+       return test_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
 }
 
 /**
@@ -1064,11 +1094,6 @@ static inline void netif_stop_queue(struct net_device *dev)
  *
  *     Test if transmit queue on device is currently unable to send.
  */
-static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
-{
-       return test_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
-}
-
 static inline int netif_queue_stopped(const struct net_device *dev)
 {
        return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
@@ -1101,7 +1126,8 @@ static inline int netif_running(const struct net_device *dev)
  */
 static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
 {
-       clear_bit(__QUEUE_STATE_XOFF, &dev->egress_subqueue[queue_index].state);
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
+       clear_bit(__QUEUE_STATE_XOFF, &txq->state);
 }
 
 /**
@@ -1113,11 +1139,12 @@ static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
  */
 static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
 {
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
 #ifdef CONFIG_NETPOLL_TRAP
        if (netpoll_trap())
                return;
 #endif
-       set_bit(__QUEUE_STATE_XOFF, &dev->egress_subqueue[queue_index].state);
+       set_bit(__QUEUE_STATE_XOFF, &txq->state);
 }
 
 /**
@@ -1130,8 +1157,8 @@ static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
 static inline int __netif_subqueue_stopped(const struct net_device *dev,
                                         u16 queue_index)
 {
-       return test_bit(__QUEUE_STATE_XOFF,
-                       &dev->egress_subqueue[queue_index].state);
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
+       return test_bit(__QUEUE_STATE_XOFF, &txq->state);
 }
 
 static inline int netif_subqueue_stopped(const struct net_device *dev,
@@ -1149,13 +1176,13 @@ static inline int netif_subqueue_stopped(const struct net_device *dev,
  */
 static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
 {
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
 #ifdef CONFIG_NETPOLL_TRAP
        if (netpoll_trap())
                return;
 #endif
-       if (test_and_clear_bit(__QUEUE_STATE_XOFF,
-                              &dev->egress_subqueue[queue_index].state))
-               __netif_schedule(netdev_get_tx_queue(dev, 0));
+       if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state))
+               __netif_schedule(txq->qdisc);
 }
 
 /**
@@ -1163,11 +1190,10 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
  *     @dev: network device
  *
  * Check if device has multiple transmit queues
- * Always falls if NETDEVICE_MULTIQUEUE is not configured
  */
 static inline int netif_is_multiqueue(const struct net_device *dev)
 {
-       return (!!(NETIF_F_MULTI_QUEUE & dev->features));
+       return (dev->num_tx_queues > 1);
 }
 
 /* Use this variant when it is known for sure that it
@@ -1200,7 +1226,8 @@ extern int                dev_set_mtu(struct net_device *, int);
 extern int             dev_set_mac_address(struct net_device *,
                                            struct sockaddr *);
 extern int             dev_hard_start_xmit(struct sk_buff *skb,
-                                           struct net_device *dev);
+                                           struct net_device *dev,
+                                           struct netdev_queue *txq);
 
 extern int             netdev_budget;
 
@@ -1436,6 +1463,18 @@ static inline void netif_rx_complete(struct net_device *dev,
        local_irq_restore(flags);
 }
 
+static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
+{
+       spin_lock(&txq->_xmit_lock);
+       txq->xmit_lock_owner = cpu;
+}
+
+static inline void __netif_tx_lock_bh(struct netdev_queue *txq)
+{
+       spin_lock_bh(&txq->_xmit_lock);
+       txq->xmit_lock_owner = smp_processor_id();
+}
+
 /**
  *     netif_tx_lock - grab network device transmit lock
  *     @dev: network device
@@ -1443,12 +1482,6 @@ static inline void netif_rx_complete(struct net_device *dev,
  *
  * Get network device transmit lock
  */
-static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
-{
-       spin_lock(&txq->_xmit_lock);
-       txq->xmit_lock_owner = cpu;
-}
-
 static inline void netif_tx_lock(struct net_device *dev)
 {
        int cpu = smp_processor_id();
@@ -1485,6 +1518,12 @@ static inline void __netif_tx_unlock(struct netdev_queue *txq)
        spin_unlock(&txq->_xmit_lock);
 }
 
+static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
+{
+       txq->xmit_lock_owner = -1;
+       spin_unlock_bh(&txq->_xmit_lock);
+}
+
 static inline void netif_tx_unlock(struct net_device *dev)
 {
        unsigned int i;
@@ -1516,8 +1555,13 @@ static inline void netif_tx_unlock_bh(struct net_device *dev)
 
 static inline void netif_tx_disable(struct net_device *dev)
 {
+       unsigned int i;
+
        netif_tx_lock_bh(dev);
-       netif_stop_queue(dev);
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+               netif_tx_stop_queue(txq);
+       }
        netif_tx_unlock_bh(dev);
 }
 
@@ -1601,6 +1645,8 @@ extern void dev_seq_stop(struct seq_file *seq, void *v);
 extern int netdev_class_create_file(struct class_attribute *class_attr);
 extern void netdev_class_remove_file(struct class_attribute *class_attr);
 
+extern char *netdev_drivername(struct net_device *dev, char *buffer, int len);
+
 extern void linkwatch_run_queue(void);
 
 extern int netdev_compute_features(unsigned long all, unsigned long one);