]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/netdevice.h
vlan: deliver packets received with VLAN acceleration to network taps
[linux-2.6-omap-h63xx.git] / include / linux / netdevice.h
index 25f87102ab663e149e10043c9c399a8d8ca3bd96..ba5c4639ea91a58a25094c9ccde58ef7eb762f78 100644 (file)
@@ -281,14 +281,12 @@ 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,6 +446,25 @@ 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_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;
+};
+
 /*
  *     The DEVICE structure.
  *     Actually, this whole structure is a big mistake.  It mixes I/O
@@ -537,8 +554,6 @@ struct net_device
 #define NETIF_F_V6_CSUM                (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
 #define NETIF_F_ALL_CSUM       (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
 
-       struct net_device       *next_sched;
-
        /* Interface index. Unique device identifier    */
        int                     ifindex;
        int                     iflink;
@@ -599,8 +614,8 @@ struct net_device
        int                     uc_promisc;
        struct dev_addr_list    *mc_list;       /* Multicast mac addresses      */
        int                     mc_count;       /* Number of installed mcasts   */
-       int                     promiscuity;
-       int                     allmulti;
+       unsigned int            promiscuity;
+       unsigned int            allmulti;
 
 
        /* Protocol specific pointers */
@@ -624,32 +639,13 @@ struct net_device
 
        unsigned char           broadcast[MAX_ADDR_LEN];        /* hw bcast add */
 
-       /* ingress path synchronizer */
-       spinlock_t              ingress_lock;
-       struct Qdisc            *qdisc_ingress;
-
-/*
- * Cache line mostly used on queue transmit path (qdisc)
- */
-       /* device queue lock */
-       spinlock_t              queue_lock ____cacheline_aligned_in_smp;
-       struct Qdisc            *qdisc;
-       struct Qdisc            *qdisc_sleeping;
-       struct list_head        qdisc_list;
+       struct netdev_queue     rx_queue;
+       struct netdev_queue     tx_queue ____cacheline_aligned_in_smp;
        unsigned long           tx_queue_len;   /* Max frames per queue allowed */
 
-       /* Partially transmitted GSO packet. */
-       struct sk_buff          *gso_skb;
-
 /*
  * One part is mostly used on xmit path (device)
  */
-       /* hard_start_xmit synchronizer */
-       spinlock_t              _xmit_lock ____cacheline_aligned_in_smp;
-       /* cpu id of processor entered to hard_start_xmit or -1,
-          if nobody entered there.
-        */
-       int                     xmit_lock_owner;
        void                    *priv;  /* pointer to private data      */
        int                     (*hard_start_xmit) (struct sk_buff *skb,
                                                    struct net_device *dev);
@@ -740,6 +736,8 @@ struct net_device
        struct net_bridge_port  *br_port;
        /* macvlan */
        struct macvlan_port     *macvlan_port;
+       /* GARP */
+       struct garp_port        *garp_port;
 
        /* class/net/name entry */
        struct device           dev;
@@ -830,6 +828,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           */
@@ -890,6 +901,7 @@ extern struct net_device    *__dev_get_by_name(struct net *net, const char *name);
 extern int             dev_alloc_name(struct net_device *dev, const char *name);
 extern int             dev_open(struct net_device *dev);
 extern int             dev_close(struct net_device *dev);
+extern void            dev_disable_lro(struct net_device *dev);
 extern int             dev_queue_xmit(struct sk_buff *skb);
 extern int             register_netdevice(struct net_device *dev);
 extern void            unregister_netdevice(struct net_device *dev);
@@ -939,7 +951,7 @@ static inline int unregister_gifconf(unsigned int family)
  */
 struct softnet_data
 {
-       struct net_device       *output_queue;
+       struct netdev_queue     *output_queue;
        struct sk_buff_head     input_pkt_queue;
        struct list_head        poll_list;
        struct sk_buff          *completion_queue;
@@ -954,12 +966,17 @@ DECLARE_PER_CPU(struct softnet_data,softnet_data);
 
 #define HAVE_NETIF_QUEUE
 
-extern void __netif_schedule(struct net_device *dev);
+extern void __netif_schedule(struct netdev_queue *txq);
+
+static inline void netif_schedule_queue(struct netdev_queue *txq)
+{
+       if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
+               __netif_schedule(txq);
+}
 
 static inline void netif_schedule(struct net_device *dev)
 {
-       if (!test_bit(__LINK_STATE_XOFF, &dev->state))
-               __netif_schedule(dev);
+       netif_schedule_queue(&dev->tx_queue);
 }
 
 /**
@@ -968,9 +985,14 @@ 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)
+{
+       clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
+}
+
 static inline void netif_start_queue(struct net_device *dev)
 {
-       clear_bit(__LINK_STATE_XOFF, &dev->state);
+       netif_tx_start_queue(&dev->tx_queue);
 }
 
 /**
@@ -980,16 +1002,21 @@ static inline void netif_start_queue(struct net_device *dev)
  *     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)
+static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
 {
 #ifdef CONFIG_NETPOLL_TRAP
        if (netpoll_trap()) {
-               clear_bit(__LINK_STATE_XOFF, &dev->state);
+               clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
                return;
        }
 #endif
-       if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state))
-               __netif_schedule(dev);
+       if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state))
+               __netif_schedule(dev_queue);
+}
+
+static inline void netif_wake_queue(struct net_device *dev)
+{
+       netif_tx_wake_queue(&dev->tx_queue);
 }
 
 /**
@@ -999,9 +1026,14 @@ 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)
+{
+       set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
+}
+
 static inline void netif_stop_queue(struct net_device *dev)
 {
-       set_bit(__LINK_STATE_XOFF, &dev->state);
+       netif_tx_stop_queue(&dev->tx_queue);
 }
 
 /**
@@ -1010,9 +1042,14 @@ 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 test_bit(__LINK_STATE_XOFF, &dev->state);
+       return netif_tx_queue_stopped(&dev->tx_queue);
 }
 
 /**
@@ -1042,9 +1079,7 @@ 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
+       clear_bit(__QUEUE_STATE_XOFF, &dev->egress_subqueue[queue_index].state);
 }
 
 /**
@@ -1056,13 +1091,11 @@ 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
 #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, &dev->egress_subqueue[queue_index].state);
 }
 
 /**
@@ -1075,12 +1108,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,
+       return test_bit(__QUEUE_STATE_XOFF,
                        &dev->egress_subqueue[queue_index].state);
-#else
-       return 0;
-#endif
 }
 
 static inline int netif_subqueue_stopped(const struct net_device *dev,
@@ -1098,15 +1127,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
 #ifdef CONFIG_NETPOLL_TRAP
        if (netpoll_trap())
                return;
 #endif
-       if (test_and_clear_bit(__LINK_STATE_XOFF,
+       if (test_and_clear_bit(__QUEUE_STATE_XOFF,
                               &dev->egress_subqueue[queue_index].state))
-               __netif_schedule(dev);
-#endif
+               __netif_schedule(&dev->tx_queue);
 }
 
 /**
@@ -1118,11 +1145,7 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
  */
 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
 }
 
 /* Use this variant when it is known for sure that it
@@ -1142,6 +1165,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 *);
@@ -1397,52 +1421,72 @@ static inline void netif_rx_complete(struct net_device *dev,
  *
  * Get network device transmit lock
  */
-static inline void __netif_tx_lock(struct net_device *dev, int cpu)
+static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
 {
-       spin_lock(&dev->_xmit_lock);
-       dev->xmit_lock_owner = 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, smp_processor_id());
+       __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)
 {
-       spin_lock_bh(&dev->_xmit_lock);
-       dev->xmit_lock_owner = smp_processor_id();
+       __netif_tx_lock_bh(&dev->tx_queue);
 }
 
-static inline int netif_tx_trylock(struct net_device *dev)
+static inline int __netif_tx_trylock(struct netdev_queue *txq)
 {
-       int ok = spin_trylock(&dev->_xmit_lock);
+       int ok = spin_trylock(&txq->_xmit_lock);
        if (likely(ok))
-               dev->xmit_lock_owner = smp_processor_id();
+               txq->xmit_lock_owner = smp_processor_id();
        return ok;
 }
 
+static inline int netif_tx_trylock(struct net_device *dev)
+{
+       return __netif_tx_trylock(&dev->tx_queue);
+}
+
+static inline void __netif_tx_unlock(struct netdev_queue *txq)
+{
+       txq->xmit_lock_owner = -1;
+       spin_unlock(&txq->_xmit_lock);
+}
+
 static inline void netif_tx_unlock(struct net_device *dev)
 {
-       dev->xmit_lock_owner = -1;
-       spin_unlock(&dev->_xmit_lock);
+       __netif_tx_unlock(&dev->tx_queue);
+}
+
+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_bh(struct net_device *dev)
 {
-       dev->xmit_lock_owner = -1;
-       spin_unlock_bh(&dev->_xmit_lock);
+       __netif_tx_unlock_bh(&dev->tx_queue);
 }
 
-#define HARD_TX_LOCK(dev, cpu) {                       \
+#define HARD_TX_LOCK(dev, txq, cpu) {                  \
        if ((dev->features & NETIF_F_LLTX) == 0) {      \
-               __netif_tx_lock(dev, cpu);                      \
+               __netif_tx_lock(txq, cpu);              \
        }                                               \
 }
 
-#define HARD_TX_UNLOCK(dev) {                          \
+#define HARD_TX_UNLOCK(dev, txq) {                     \
        if ((dev->features & NETIF_F_LLTX) == 0) {      \
-               netif_tx_unlock(dev);                   \
+               __netif_tx_unlock(txq);                 \
        }                                               \
 }
 
@@ -1480,9 +1524,10 @@ extern int               __dev_addr_delete(struct dev_addr_list **list, int *count, void *ad
 extern int             __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly);
 extern int             __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
 extern void            __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
-extern void            dev_set_promiscuity(struct net_device *dev, int inc);
-extern void            dev_set_allmulti(struct net_device *dev, int inc);
+extern int             dev_set_promiscuity(struct net_device *dev, int inc);
+extern int             dev_set_allmulti(struct net_device *dev, int inc);
 extern void            netdev_state_change(struct net_device *dev);
+extern void            netdev_bonding_change(struct net_device *dev);
 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);
@@ -1509,6 +1554,9 @@ extern void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos);
 extern void dev_seq_stop(struct seq_file *seq, void *v);
 #endif
 
+extern int netdev_class_create_file(struct class_attribute *class_attr);
+extern void netdev_class_remove_file(struct class_attribute *class_attr);
+
 extern void linkwatch_run_queue(void);
 
 extern int netdev_compute_features(unsigned long all, unsigned long one);