[NET]: Add macvlan driver
[safe/jmp/linux-2.6] / include / linux / netdevice.h
index e432b74..322b5ea 100644 (file)
 #include <linux/if_packet.h>
 
 #ifdef __KERNEL__
+#include <linux/timer.h>
 #include <asm/atomic.h>
 #include <asm/cache.h>
 #include <asm/byteorder.h>
 
-#include <linux/config.h>
 #include <linux/device.h>
 #include <linux/percpu.h>
 #include <linux/dmaengine.h>
 
-struct divert_blk;
 struct vlan_group;
 struct ethtool_ops;
 struct netpoll_info;
+/* 802.11 specific */
+struct wireless_dev;
                                        /* source back-compat hooks */
 #define SET_ETHTOOL_OPS(netdev,ops) \
        ( (netdev)->ethtool_ops = (ops) )
@@ -68,6 +69,10 @@ struct netpoll_info;
 #define NET_RX_CN_HIGH         4   /* The storm is here */
 #define NET_RX_BAD             5  /* packet dropped due to kernel error */
 
+/* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It
+ * indicates that the device will soon be dropping packets, or already drops
+ * some packets of the same priority; prompting us to send less aggressively. */
+#define net_xmit_eval(e)       ((e) == NET_XMIT_CN? 0 : (e))
 #define net_xmit_errno(e)      ((e) != NET_XMIT_CN ? -ENOBUFS : 0)
 
 #endif
@@ -94,13 +99,23 @@ struct netpoll_info;
 #endif
 #endif
 
-#if !defined(CONFIG_NET_IPIP) && \
-    !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE)
+#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \
+    !defined(CONFIG_NET_IPGRE) &&  !defined(CONFIG_NET_IPGRE_MODULE) && \
+    !defined(CONFIG_IPV6_SIT) && !defined(CONFIG_IPV6_SIT_MODULE) && \
+    !defined(CONFIG_IPV6_TUNNEL) && !defined(CONFIG_IPV6_TUNNEL_MODULE)
 #define MAX_HEADER LL_MAX_HEADER
 #else
 #define MAX_HEADER (LL_MAX_HEADER + 48)
 #endif
 
+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.
@@ -170,31 +185,44 @@ struct netif_rx_stats
 
 DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat);
 
+struct dev_addr_list
+{
+       struct dev_addr_list    *next;
+       u8                      da_addr[MAX_ADDR_LEN];
+       u8                      da_addrlen;
+       u8                      da_synced;
+       int                     da_users;
+       int                     da_gusers;
+};
 
 /*
  *     We tag multicasts with these structures.
  */
-struct dev_mc_list
-{      
-       struct dev_mc_list      *next;
-       __u8                    dmi_addr[MAX_ADDR_LEN];
-       unsigned char           dmi_addrlen;
-       int                     dmi_users;
-       int                     dmi_gusers;
-};
+
+#define dev_mc_list    dev_addr_list
+#define dmi_addr       da_addr
+#define dmi_addrlen    da_addrlen
+#define dmi_users      da_users
+#define dmi_gusers     da_gusers
 
 struct hh_cache
 {
        struct hh_cache *hh_next;       /* Next entry                        */
        atomic_t        hh_refcnt;      /* number of users                   */
-       unsigned short  hh_type;        /* protocol identifier, f.e ETH_P_IP
+/*
+ * We want hh_output, hh_len, hh_lock and hh_data be a in a separate
+ * cache line on SMP.
+ * They are mostly read, but hh_refcnt may be changed quite frequently,
+ * incurring cache line ping pongs.
+ */
+       __be16          hh_type ____cacheline_aligned_in_smp;
+                                       /* protocol identifier, f.e ETH_P_IP
                                          *  NOTE:  For VLANs, this will be the
                                          *  encapuslated type. --BLG
                                          */
-       int             hh_len;         /* length of header */
+       u16             hh_len;         /* length of header */
        int             (*hh_output)(struct sk_buff *skb);
-       rwlock_t        hh_lock;
+       seqlock_t       hh_lock;
 
        /* cached hardware header; allow for machine alignment needs.        */
 #define HH_DATA_MOD    16
@@ -233,6 +261,9 @@ enum netdev_state_t
        __LINK_STATE_RX_SCHED,
        __LINK_STATE_LINKWATCH_PENDING,
        __LINK_STATE_DORMANT,
+       __LINK_STATE_QDISC_RUNNING,
+       /* Set by the netpoll NAPI code */
+       __LINK_STATE_POLL_LIST_FROZEN,
 };
 
 
@@ -289,7 +320,7 @@ struct net_device
 
        unsigned long           state;
 
-       struct net_device       *next;
+       struct list_head        dev_list;
        
        /* The device initialization function. Called only once. */
        int                     (*init)(struct net_device *dev);
@@ -299,21 +330,37 @@ struct net_device
        /* Net device features */
        unsigned long           features;
 #define NETIF_F_SG             1       /* Scatter/gather IO. */
-#define NETIF_F_IP_CSUM                2       /* Can checksum only TCP/UDP over IPv4. */
+#define NETIF_F_IP_CSUM                2       /* Can checksum TCP/UDP over IPv4. */
 #define NETIF_F_NO_CSUM                4       /* Does not require checksum. F.e. loopack. */
 #define NETIF_F_HW_CSUM                8       /* Can checksum all the packets. */
+#define NETIF_F_IPV6_CSUM      16      /* Can checksum TCP/UDP over IPV6 */
 #define NETIF_F_HIGHDMA                32      /* Can DMA to high memory. */
 #define NETIF_F_FRAGLIST       64      /* Scatter/gather IO. */
 #define NETIF_F_HW_VLAN_TX     128     /* Transmit VLAN hw acceleration */
 #define NETIF_F_HW_VLAN_RX     256     /* Receive VLAN hw acceleration */
 #define NETIF_F_HW_VLAN_FILTER 512     /* Receive filtering on VLAN */
 #define NETIF_F_VLAN_CHALLENGED        1024    /* Device cannot handle VLAN packets */
-#define NETIF_F_TSO            2048    /* Can offload TCP/IP segmentation */
+#define NETIF_F_GSO            2048    /* Enable software GSO. */
 #define NETIF_F_LLTX           4096    /* LockLess TX */
-#define NETIF_F_UFO             8192    /* Can offload UDP Large Send*/
+#define NETIF_F_MULTI_QUEUE    16384   /* Has multiple TX/RX queues */
+
+       /* Segmentation offload features */
+#define NETIF_F_GSO_SHIFT      16
+#define NETIF_F_GSO_MASK       0xffff0000
+#define NETIF_F_TSO            (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
+#define NETIF_F_UFO            (SKB_GSO_UDP << NETIF_F_GSO_SHIFT)
+#define NETIF_F_GSO_ROBUST     (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
+#define NETIF_F_TSO_ECN                (SKB_GSO_TCP_ECN << NETIF_F_GSO_SHIFT)
+#define NETIF_F_TSO6           (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT)
+
+       /* List of features with software fallbacks. */
+#define NETIF_F_GSO_SOFTWARE   (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6)
+
 
 #define NETIF_F_GEN_CSUM       (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
-#define NETIF_F_ALL_CSUM       (NETIF_F_IP_CSUM | NETIF_F_GEN_CSUM)
+#define NETIF_F_V4_CSUM                (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM)
+#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;
 
@@ -323,15 +370,16 @@ struct net_device
 
 
        struct net_device_stats* (*get_stats)(struct net_device *dev);
-       struct iw_statistics*   (*get_wireless_stats)(struct net_device *dev);
+       struct net_device_stats stats;
 
+#ifdef CONFIG_WIRELESS_EXT
        /* List of functions to handle Wireless Extensions (instead of ioctl).
         * See <net/iw_handler.h> for details. Jean II */
        const struct iw_handler_def *   wireless_handlers;
        /* Instance data managed by the core of Wireless Extensions. */
        struct iw_public_data * wireless_data;
-
-       struct ethtool_ops *ethtool_ops;
+#endif
+       const struct ethtool_ops *ethtool_ops;
 
        /*
         * This marks the end of the "visible" part of the structure. All
@@ -361,7 +409,10 @@ struct net_device
        unsigned char           addr_len;       /* hardware address length      */
        unsigned short          dev_id;         /* for shared network cards */
 
-       struct dev_mc_list      *mc_list;       /* Multicast mac addresses      */
+       struct dev_addr_list    *uc_list;       /* Secondary unicast mac addresses */
+       int                     uc_count;       /* Number of installed ucasts   */
+       int                     uc_promisc;
+       struct dev_addr_list    *mc_list;       /* Multicast mac addresses      */
        int                     mc_count;       /* Number of installed mcasts   */
        int                     promiscuity;
        int                     allmulti;
@@ -375,6 +426,8 @@ struct net_device
        void                    *ip6_ptr;       /* IPv6 specific data */
        void                    *ec_ptr;        /* Econet specific data */
        void                    *ax25_ptr;      /* AX.25 specific data */
+       struct wireless_dev     *ieee80211_ptr; /* IEEE 802.11 specific data,
+                                                  assign before registering */
 
 /*
  * Cache line mostly used on receive path (including eth_type_trans())
@@ -402,6 +455,9 @@ struct net_device
        struct list_head        qdisc_list;
        unsigned long           tx_queue_len;   /* Max frames per queue allowed */
 
+       /* Partially transmitted GSO packet. */
+       struct sk_buff          *gso_skb;
+
        /* ingress path synchronizer */
        spinlock_t              ingress_lock;
        struct Qdisc            *qdisc_ingress;
@@ -435,6 +491,8 @@ struct net_device
        /* device index hash chain */
        struct hlist_node       index_hlist;
 
+       struct net_device       *link_watch_next;
+
        /* register/unregister state machine */
        enum { NETREG_UNINITIALIZED=0,
               NETREG_REGISTERED,       /* completed register_netdevice */
@@ -459,6 +517,11 @@ struct net_device
                                                void *saddr,
                                                unsigned len);
        int                     (*rebuild_header)(struct sk_buff *skb);
+#define HAVE_CHANGE_RX_FLAGS
+       void                    (*change_rx_flags)(struct net_device *dev,
+                                                  int flags);
+#define HAVE_SET_RX_MODE
+       void                    (*set_rx_mode)(struct net_device *dev);
 #define HAVE_MULTICAST                  
        void                    (*set_multicast_list)(struct net_device *dev);
 #define HAVE_SET_MAC_ADDR               
@@ -501,33 +564,36 @@ struct net_device
 
        /* bridge stuff */
        struct net_bridge_port  *br_port;
-
-#ifdef CONFIG_NET_DIVERT
-       /* this will get initialized at each interface type init routine */
-       struct divert_blk       *divert;
-#endif /* CONFIG_NET_DIVERT */
+       /* macvlan */
+       struct macvlan_port     *macvlan_port;
 
        /* class/net/name entry */
-       struct class_device     class_dev;
+       struct device           dev;
        /* space for optional statistics and wireless sysfs groups */
        struct attribute_group  *sysfs_groups[3];
+
+       /* rtnetlink link ops */
+       const struct rtnl_link_ops *rtnl_link_ops;
+
+       /* The TX queue control structures */
+       unsigned int                    egress_subqueue_count;
+       struct net_device_subqueue      egress_subqueue[0];
 };
+#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 void *netdev_priv(struct net_device *dev)
+static inline void *netdev_priv(const struct net_device *dev)
 {
-       return (char *)dev + ((sizeof(struct net_device)
-                                       + NETDEV_ALIGN_CONST)
-                               & ~NETDEV_ALIGN_CONST);
+       return dev->priv;
 }
 
 #define SET_MODULE_OWNER(dev) do { } while (0)
 /* Set the sysfs physical device reference for the network logical device
  * if set prior to registration will cause a symlink during initialization.
  */
-#define SET_NETDEV_DEV(net, pdev)      ((net)->class_dev.dev = (pdev))
+#define SET_NETDEV_DEV(net, pdev)      ((net)->dev.parent = (pdev))
 
 struct packet_type {
        __be16                  type;   /* This is really htons(ether_type). */
@@ -536,6 +602,9 @@ struct packet_type {
                                         struct net_device *,
                                         struct packet_type *,
                                         struct net_device *);
+       struct sk_buff          *(*gso_segment)(struct sk_buff *skb,
+                                               int features);
+       int                     (*gso_send_check)(struct sk_buff *skb);
        void                    *af_packet_priv;
        struct list_head        list;
 };
@@ -544,13 +613,36 @@ struct packet_type {
 #include <linux/notifier.h>
 
 extern struct net_device               loopback_dev;           /* The loopback */
-extern struct net_device               *dev_base;              /* All devices */
+extern struct list_head                        dev_base_head;          /* All devices */
 extern rwlock_t                                dev_base_lock;          /* Device list lock */
 
+#define for_each_netdev(d)             \
+               list_for_each_entry(d, &dev_base_head, dev_list)
+#define for_each_netdev_safe(d, n)     \
+               list_for_each_entry_safe(d, n, &dev_base_head, dev_list)
+#define for_each_netdev_continue(d)            \
+               list_for_each_entry_continue(d, &dev_base_head, dev_list)
+#define net_device_entry(lh)   list_entry(lh, struct net_device, dev_list)
+
+static inline struct net_device *next_net_device(struct net_device *dev)
+{
+       struct list_head *lh;
+
+       lh = dev->dev_list.next;
+       return lh == &dev_base_head ? NULL : net_device_entry(lh);
+}
+
+static inline struct net_device *first_net_device(void)
+{
+       return list_empty(&dev_base_head) ? NULL :
+               net_device_entry(dev_base_head.next);
+}
+
 extern int                     netdev_boot_setup_check(struct net_device *dev);
 extern unsigned long           netdev_boot_base(const char *prefix, int unit);
 extern struct net_device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
 extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
+extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
 extern void            dev_add_pack(struct packet_type *pt);
 extern void            dev_remove_pack(struct packet_type *pt);
 extern void            __dev_remove_pack(struct packet_type *pt);
@@ -564,7 +656,7 @@ extern int          dev_open(struct net_device *dev);
 extern int             dev_close(struct net_device *dev);
 extern int             dev_queue_xmit(struct sk_buff *skb);
 extern int             register_netdevice(struct net_device *dev);
-extern int             unregister_netdevice(struct net_device *dev);
+extern void            unregister_netdevice(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);
@@ -622,8 +714,10 @@ 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())
+       if (netpoll_trap()) {
+               clear_bit(__LINK_STATE_XOFF, &dev->state);
                return;
+       }
 #endif
        if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state))
                __netif_schedule(dev);
@@ -631,10 +725,6 @@ static inline void netif_wake_queue(struct net_device *dev)
 
 static inline void netif_stop_queue(struct net_device *dev)
 {
-#ifdef CONFIG_NETPOLL_TRAP
-       if (netpoll_trap())
-               return;
-#endif
        set_bit(__LINK_STATE_XOFF, &dev->state);
 }
 
@@ -648,6 +738,62 @@ static inline int netif_running(const struct net_device *dev)
        return test_bit(__LINK_STATE_START, &dev->state);
 }
 
+/*
+ * Routines to manage the subqueues on a device.  We only need start
+ * stop, and a check if it's stopped.  All other device management is
+ * done at the overall netdevice level.
+ * Also test the device if we're multiqueue.
+ */
+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
+}
+
+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
+}
+
+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
+}
+
+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,
+                              &dev->egress_subqueue[queue_index].state))
+               __netif_schedule(dev);
+#endif
+}
+
+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
  * is executing from interrupt context.
@@ -686,11 +832,11 @@ extern int                dev_change_name(struct net_device *, char *);
 extern int             dev_set_mtu(struct net_device *, int);
 extern int             dev_set_mac_address(struct net_device *,
                                            struct sockaddr *);
-extern void            dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev);
+extern int             dev_hard_start_xmit(struct sk_buff *skb,
+                                           struct net_device *dev);
 
 extern void            dev_init(void);
 
-extern int             netdev_nit;
 extern int             netdev_budget;
 
 /* Called by rtnetlink.c:rtnl_unlock() */
@@ -856,6 +1002,17 @@ static inline int netif_rx_reschedule(struct net_device *dev, int undo)
        return 0;
 }
 
+/* same as netif_rx_complete, except that local_irq_save(flags)
+ * has already been issued
+ */
+static inline void __netif_rx_complete(struct net_device *dev)
+{
+       BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state));
+       list_del(&dev->poll_list);
+       smp_mb__before_clear_bit();
+       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
+}
+
 /* Remove interface from poll list: it must be in the poll list
  * on current cpu. This primitive is called by dev->poll(), when
  * it completes the work. The device cannot be out of poll list at this
@@ -865,11 +1022,16 @@ static inline void netif_rx_complete(struct net_device *dev)
 {
        unsigned long flags;
 
+#ifdef CONFIG_NETPOLL
+       /* Prevent race with netpoll - yes, this is a kludge.
+        * But at least it doesn't penalize the non-netpoll
+        * code path. */
+       if (test_bit(__LINK_STATE_POLL_LIST_FROZEN, &dev->state))
+               return;
+#endif
+
        local_irq_save(flags);
-       BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state));
-       list_del(&dev->poll_list);
-       smp_mb__before_clear_bit();
-       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
+       __netif_rx_complete(dev);
        local_irq_restore(flags);
 }
 
@@ -882,16 +1044,6 @@ static inline void netif_poll_disable(struct net_device *dev)
 
 static inline void netif_poll_enable(struct net_device *dev)
 {
-       clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
-}
-
-/* same as netif_rx_complete, except that local_irq_save(flags)
- * has already been issued
- */
-static inline void __netif_rx_complete(struct net_device *dev)
-{
-       BUG_ON(!test_bit(__LINK_STATE_RX_SCHED, &dev->state));
-       list_del(&dev->poll_list);
        smp_mb__before_clear_bit();
        clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
 }
@@ -910,10 +1062,10 @@ static inline void netif_tx_lock_bh(struct net_device *dev)
 
 static inline int netif_tx_trylock(struct net_device *dev)
 {
-       int err = spin_trylock(&dev->_xmit_lock);
-       if (!err)
+       int ok = spin_trylock(&dev->_xmit_lock);
+       if (likely(ok))
                dev->xmit_lock_owner = smp_processor_id();
-       return err;
+       return ok;
 }
 
 static inline void netif_tx_unlock(struct net_device *dev)
@@ -940,15 +1092,26 @@ static inline void netif_tx_disable(struct net_device *dev)
 extern void            ether_setup(struct net_device *dev);
 
 /* Support for loadable net-drivers */
-extern struct net_device *alloc_netdev(int sizeof_priv, const char *name,
-                                      void (*setup)(struct net_device *));
+extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
+                                      void (*setup)(struct net_device *),
+                                      unsigned int queue_count);
+#define alloc_netdev(sizeof_priv, name, setup) \
+       alloc_netdev_mq(sizeof_priv, name, setup, 1)
 extern int             register_netdev(struct net_device *dev);
 extern void            unregister_netdev(struct net_device *dev);
-/* Functions used for multicast support */
-extern void            dev_mc_upload(struct net_device *dev);
+/* Functions used for secondary unicast and multicast support */
+extern void            dev_set_rx_mode(struct net_device *dev);
+extern void            __dev_set_rx_mode(struct net_device *dev);
+extern int             dev_unicast_delete(struct net_device *dev, void *addr, int alen);
+extern int             dev_unicast_add(struct net_device *dev, void *addr, int alen);
 extern int             dev_mc_delete(struct net_device *dev, void *addr, int alen, int all);
 extern int             dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly);
+extern int             dev_mc_sync(struct net_device *to, struct net_device *from);
+extern void            dev_mc_unsync(struct net_device *to, struct net_device *from);
 extern void            dev_mc_discard(struct net_device *dev);
+extern int             __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all);
+extern int             __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly);
+extern void            __dev_addr_discard(struct dev_addr_list **list);
 extern void            dev_set_promiscuity(struct net_device *dev, int inc);
 extern void            dev_set_allmulti(struct net_device *dev, int inc);
 extern void            netdev_state_change(struct net_device *dev);
@@ -959,7 +1122,8 @@ extern void                dev_mcast_init(void);
 extern int             netdev_max_backlog;
 extern int             weight_p;
 extern int             netdev_set_master(struct net_device *dev, struct net_device *master);
-extern int skb_checksum_help(struct sk_buff *skb, int inward);
+extern int skb_checksum_help(struct sk_buff *skb);
+extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features);
 #ifdef CONFIG_BUG
 extern void netdev_rx_csum_fault(struct net_device *dev);
 #else
@@ -979,6 +1143,53 @@ extern void dev_seq_stop(struct seq_file *seq, void *v);
 
 extern void linkwatch_run_queue(void);
 
+static inline int net_gso_ok(int features, int gso_type)
+{
+       int feature = gso_type << NETIF_F_GSO_SHIFT;
+       return (features & feature) == feature;
+}
+
+static inline int skb_gso_ok(struct sk_buff *skb, int features)
+{
+       return net_gso_ok(features, skb_shinfo(skb)->gso_type);
+}
+
+static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
+{
+       return skb_is_gso(skb) &&
+              (!skb_gso_ok(skb, dev->features) ||
+               unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
+}
+
+/* On bonding slaves other than the currently active slave, suppress
+ * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and
+ * ARP on active-backup slaves with arp_validate enabled.
+ */
+static inline int skb_bond_should_drop(struct sk_buff *skb)
+{
+       struct net_device *dev = skb->dev;
+       struct net_device *master = dev->master;
+
+       if (master &&
+           (dev->priv_flags & IFF_SLAVE_INACTIVE)) {
+               if ((dev->priv_flags & IFF_SLAVE_NEEDARP) &&
+                   skb->protocol == __constant_htons(ETH_P_ARP))
+                       return 0;
+
+               if (master->priv_flags & IFF_MASTER_ALB) {
+                       if (skb->pkt_type != PACKET_BROADCAST &&
+                           skb->pkt_type != PACKET_MULTICAST)
+                               return 0;
+               }
+               if (master->priv_flags & IFF_MASTER_8023AD &&
+                   skb->protocol == __constant_htons(ETH_P_SLOW))
+                       return 0;
+
+               return 1;
+       }
+       return 0;
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_DEV_H */