]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - include/linux/netdevice.h
ACPICA: Remove obsolete debug levels (WARN and ERROR)
[mv-sheeva.git] / include / linux / netdevice.h
index c8d5f128858dde466e5da96cefcd3c8e7ee0b8d5..488c56e649b585592856883043edf4b9dacc8163 100644 (file)
@@ -61,9 +61,7 @@ struct wireless_dev;
 #define NET_XMIT_DROP          1       /* skb dropped                  */
 #define NET_XMIT_CN            2       /* congestion notification      */
 #define NET_XMIT_POLICED       3       /* skb is shot by police        */
-#define NET_XMIT_BYPASS                4       /* packet does not leave via dequeue;
-                                          (TC use only - dev_queue_xmit
-                                          returns this as NET_XMIT_SUCCESS) */
+#define NET_XMIT_MASK          0xFFFF  /* qdisc flags in net/sch_generic.h */
 
 /* Backlog congestion levels */
 #define NET_RX_SUCCESS         0   /* keep 'em coming, baby */
@@ -118,14 +116,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.
@@ -281,14 +271,11 @@ struct header_ops {
 
 enum netdev_state_t
 {
-       __LINK_STATE_XOFF=0,
        __LINK_STATE_START,
        __LINK_STATE_PRESENT,
-       __LINK_STATE_SCHED,
        __LINK_STATE_NOCARRIER,
        __LINK_STATE_LINKWATCH_PENDING,
        __LINK_STATE_DORMANT,
-       __LINK_STATE_QDISC_RUNNING,
 };
 
 
@@ -448,17 +435,20 @@ static inline void napi_synchronize(const struct napi_struct *n)
 # define napi_synchronize(n)   barrier()
 #endif
 
+enum netdev_queue_state_t
+{
+       __QUEUE_STATE_XOFF,
+       __QUEUE_STATE_FROZEN,
+};
+
 struct netdev_queue {
-       spinlock_t              lock;
        struct net_device       *dev;
        struct Qdisc            *qdisc;
-       struct sk_buff          *gso_skb;
+       unsigned long           state;
        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;
 
 /*
  *     The DEVICE structure.
@@ -528,7 +518,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 */
@@ -604,6 +593,7 @@ struct net_device
        unsigned char           addr_len;       /* hardware address length      */
        unsigned short          dev_id;         /* for shared network cards */
 
+       spinlock_t              addr_list_lock;
        struct dev_addr_list    *uc_list;       /* Secondary unicast mac addresses */
        int                     uc_count;       /* Number of installed ucasts   */
        int                     uc_promisc;
@@ -635,9 +625,17 @@ struct net_device
        unsigned char           broadcast[MAX_ADDR_LEN];        /* hw bcast add */
 
        struct netdev_queue     rx_queue;
-       struct netdev_queue     tx_queue ____cacheline_aligned_in_smp;
-       unsigned long           tx_queue_len;   /* Max frames per queue allowed */
 
+       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 */
+       spinlock_t              tx_global_lock;
 /*
  * One part is mostly used on xmit path (device)
  */
@@ -719,6 +717,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;
@@ -748,16 +749,31 @@ 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)
 
 #define        NETDEV_ALIGN            32
 #define        NETDEV_ALIGN_CONST      (NETDEV_ALIGN - 1)
 
+static inline
+struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
+                                        unsigned int index)
+{
+       return &dev->_tx[index];
+}
+
+static inline void netdev_for_each_tx_queue(struct net_device *dev,
+                                           void (*f)(struct net_device *,
+                                                     struct netdev_queue *,
+                                                     void *),
+                                           void *arg)
+{
+       unsigned int i;
+
+       for (i = 0; i < dev->num_tx_queues; i++)
+               f(dev, &dev->_tx[i], arg);
+}
+
 /*
  * Net namespace inlines
  */
@@ -788,7 +804,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
@@ -823,6 +841,19 @@ static inline void netif_napi_add(struct net_device *dev,
        set_bit(NAPI_STATE_SCHED, &napi->state);
 }
 
+/**
+ *  netif_napi_del - remove a napi context
+ *  @napi: napi context
+ *
+ *  netif_napi_del() removes a napi context from the network device napi list
+ */
+static inline void netif_napi_del(struct napi_struct *napi)
+{
+#ifdef CONFIG_NETPOLL
+       list_del(&napi->dev_list);
+#endif
+}
+
 struct packet_type {
        __be16                  type;   /* This is really htons(ether_type). */
        struct net_device       *dev;   /* NULL is wildcarded here           */
@@ -933,7 +964,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;
@@ -948,19 +979,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)
 {
-       struct net_device *dev = txq->dev;
+       if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
+               __netif_schedule(txq->qdisc);
+}
+
+static inline void netif_tx_schedule_all(struct net_device *dev)
+{
+       unsigned int i;
 
-       if (!test_bit(__LINK_STATE_XOFF, &dev->state))
-               __netif_schedule(txq);
+       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(&dev->tx_queue);
+       clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
 }
 
 /**
@@ -971,7 +1008,29 @@ static inline void netif_schedule(struct net_device *dev)
  */
 static inline void netif_start_queue(struct net_device *dev)
 {
-       clear_bit(__LINK_STATE_XOFF, &dev->state);
+       netif_tx_start_queue(netdev_get_tx_queue(dev, 0));
+}
+
+static inline void netif_tx_start_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_start_queue(txq);
+       }
+}
+
+static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
+{
+#ifdef CONFIG_NETPOLL_TRAP
+       if (netpoll_trap()) {
+               clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
+               return;
+       }
+#endif
+       if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state))
+               __netif_schedule(dev_queue->qdisc);
 }
 
 /**
@@ -983,14 +1042,22 @@ static inline void netif_start_queue(struct net_device *dev)
  */
 static inline void netif_wake_queue(struct net_device *dev)
 {
-#ifdef CONFIG_NETPOLL_TRAP
-       if (netpoll_trap()) {
-               clear_bit(__LINK_STATE_XOFF, &dev->state);
-               return;
+       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);
        }
-#endif
-       if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state))
-               __netif_schedule(&dev->tx_queue);
+}
+
+static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
+{
+       set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
 }
 
 /**
@@ -1002,7 +1069,22 @@ static inline void netif_wake_queue(struct net_device *dev)
  */
 static inline void netif_stop_queue(struct net_device *dev)
 {
-       set_bit(__LINK_STATE_XOFF, &dev->state);
+       netif_tx_stop_queue(netdev_get_tx_queue(dev, 0));
+}
+
+static inline void netif_tx_stop_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_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);
 }
 
 /**
@@ -1013,7 +1095,12 @@ static inline void netif_stop_queue(struct net_device *dev)
  */
 static inline int netif_queue_stopped(const struct net_device *dev)
 {
-       return test_bit(__LINK_STATE_XOFF, &dev->state);
+       return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
+}
+
+static inline int netif_tx_queue_frozen(const struct netdev_queue *dev_queue)
+{
+       return test_bit(__QUEUE_STATE_FROZEN, &dev_queue->state);
 }
 
 /**
@@ -1043,9 +1130,8 @@ static inline int netif_running(const struct net_device *dev)
  */
 static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
 {
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
-       clear_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state);
-#endif
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
+       clear_bit(__QUEUE_STATE_XOFF, &txq->state);
 }
 
 /**
@@ -1057,13 +1143,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)
 {
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
+       struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
 #ifdef CONFIG_NETPOLL_TRAP
        if (netpoll_trap())
                return;
 #endif
-       set_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state);
-#endif
+       set_bit(__QUEUE_STATE_XOFF, &txq->state);
 }
 
 /**
@@ -1076,12 +1161,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)
 {
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
-       return test_bit(__LINK_STATE_XOFF,
-                       &dev->egress_subqueue[queue_index].state);
-#else
-       return 0;
-#endif
+       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,
@@ -1099,15 +1180,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)
 {
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
+       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(__LINK_STATE_XOFF,
-                              &dev->egress_subqueue[queue_index].state))
-               __netif_schedule(&dev->tx_queue);
-#endif
+       if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state))
+               __netif_schedule(txq->qdisc);
 }
 
 /**
@@ -1115,15 +1194,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)
 {
-#ifdef CONFIG_NETDEVICES_MULTIQUEUE
-       return (!!(NETIF_F_MULTI_QUEUE & dev->features));
-#else
-       return 0;
-#endif
+       return (dev->num_tx_queues > 1);
 }
 
 /* Use this variant when it is known for sure that it
@@ -1143,6 +1217,7 @@ extern int                netif_rx(struct sk_buff *skb);
 extern int             netif_rx_ni(struct sk_buff *skb);
 #define HAVE_NETIF_RECEIVE_SKB 1
 extern int             netif_receive_skb(struct sk_buff *skb);
+extern void            netif_nit_deliver(struct sk_buff *skb);
 extern int             dev_valid_name(const char *name);
 extern int             dev_ioctl(struct net *net, unsigned int cmd, void __user *);
 extern int             dev_ethtool(struct net *net, struct ifreq *);
@@ -1155,7 +1230,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;
 
@@ -1391,35 +1467,18 @@ static inline void netif_rx_complete(struct net_device *dev,
        local_irq_restore(flags);
 }
 
-/**
- *     netif_tx_lock - grab network device transmit lock
- *     @dev: network device
- *     @cpu: cpu number of lock owner
- *
- * 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)
-{
-       __netif_tx_lock(&dev->tx_queue, smp_processor_id());
-}
-
 static inline void __netif_tx_lock_bh(struct netdev_queue *txq)
 {
        spin_lock_bh(&txq->_xmit_lock);
        txq->xmit_lock_owner = smp_processor_id();
 }
 
-static inline void netif_tx_lock_bh(struct net_device *dev)
-{
-       __netif_tx_lock_bh(&dev->tx_queue);
-}
-
 static inline int __netif_tx_trylock(struct netdev_queue *txq)
 {
        int ok = spin_trylock(&txq->_xmit_lock);
@@ -1428,31 +1487,75 @@ static inline int __netif_tx_trylock(struct netdev_queue *txq)
        return ok;
 }
 
-static inline int netif_tx_trylock(struct net_device *dev)
+static inline void __netif_tx_unlock(struct netdev_queue *txq)
 {
-       return __netif_tx_trylock(&dev->tx_queue);
+       txq->xmit_lock_owner = -1;
+       spin_unlock(&txq->_xmit_lock);
 }
 
-static inline void __netif_tx_unlock(struct netdev_queue *txq)
+static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
 {
        txq->xmit_lock_owner = -1;
-       spin_unlock(&txq->_xmit_lock);
+       spin_unlock_bh(&txq->_xmit_lock);
 }
 
-static inline void netif_tx_unlock(struct net_device *dev)
+/**
+ *     netif_tx_lock - grab network device transmit lock
+ *     @dev: network device
+ *     @cpu: cpu number of lock owner
+ *
+ * Get network device transmit lock
+ */
+static inline void netif_tx_lock(struct net_device *dev)
 {
-       __netif_tx_unlock(&dev->tx_queue);
+       unsigned int i;
+       int cpu;
+
+       spin_lock(&dev->tx_global_lock);
+       cpu = smp_processor_id();
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+
+               /* We are the only thread of execution doing a
+                * freeze, but we have to grab the _xmit_lock in
+                * order to synchronize with threads which are in
+                * the ->hard_start_xmit() handler and already
+                * checked the frozen bit.
+                */
+               __netif_tx_lock(txq, cpu);
+               set_bit(__QUEUE_STATE_FROZEN, &txq->state);
+               __netif_tx_unlock(txq);
+       }
 }
 
-static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
+static inline void netif_tx_lock_bh(struct net_device *dev)
 {
-       txq->xmit_lock_owner = -1;
-       spin_unlock_bh(&txq->_xmit_lock);
+       local_bh_disable();
+       netif_tx_lock(dev);
+}
+
+static inline void netif_tx_unlock(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);
+
+               /* No need to grab the _xmit_lock here.  If the
+                * queue is not stopped for another reason, we
+                * force a schedule.
+                */
+               clear_bit(__QUEUE_STATE_FROZEN, &txq->state);
+               if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
+                       __netif_schedule(txq->qdisc);
+       }
+       spin_unlock(&dev->tx_global_lock);
 }
 
 static inline void netif_tx_unlock_bh(struct net_device *dev)
 {
-       __netif_tx_unlock_bh(&dev->tx_queue);
+       netif_tx_unlock(dev);
+       local_bh_enable();
 }
 
 #define HARD_TX_LOCK(dev, txq, cpu) {                  \
@@ -1469,9 +1572,39 @@ static inline void netif_tx_unlock_bh(struct net_device *dev)
 
 static inline void netif_tx_disable(struct net_device *dev)
 {
-       netif_tx_lock_bh(dev);
-       netif_stop_queue(dev);
-       netif_tx_unlock_bh(dev);
+       unsigned int i;
+       int cpu;
+
+       local_bh_disable();
+       cpu = smp_processor_id();
+       for (i = 0; i < dev->num_tx_queues; i++) {
+               struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
+
+               __netif_tx_lock(txq, cpu);
+               netif_tx_stop_queue(txq);
+               __netif_tx_unlock(txq);
+       }
+       local_bh_enable();
+}
+
+static inline void netif_addr_lock(struct net_device *dev)
+{
+       spin_lock(&dev->addr_list_lock);
+}
+
+static inline void netif_addr_lock_bh(struct net_device *dev)
+{
+       spin_lock_bh(&dev->addr_list_lock);
+}
+
+static inline void netif_addr_unlock(struct net_device *dev)
+{
+       spin_unlock(&dev->addr_list_lock);
+}
+
+static inline void netif_addr_unlock_bh(struct net_device *dev)
+{
+       spin_unlock_bh(&dev->addr_list_lock);
 }
 
 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
@@ -1534,6 +1667,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);