]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/netdevice.h
xen: fix incorrect vcpu_register_vcpu_info hypercall argument
[linux-2.6-omap-h63xx.git] / include / linux / netdevice.h
index dc3c15b726bcafe5d0fbe0a3a0944c2ba661df6e..5a11f889e56a7f0780eb44572e4b9e2b68239c70 100644 (file)
@@ -41,7 +41,8 @@
 #include <linux/dmaengine.h>
 #include <linux/workqueue.h>
 
-struct net;
+#include <net/net_namespace.h>
+
 struct vlan_group;
 struct ethtool_ops;
 struct netpoll_info;
@@ -249,6 +250,19 @@ struct hh_cache
 #define LL_RESERVED_SPACE_EXTRA(dev,extra) \
        ((((dev)->hard_header_len+extra)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
 
+struct header_ops {
+       int     (*create) (struct sk_buff *skb, struct net_device *dev,
+                          unsigned short type, const void *daddr,
+                          const void *saddr, unsigned len);
+       int     (*parse)(const struct sk_buff *skb, unsigned char *haddr);
+       int     (*rebuild)(struct sk_buff *skb);
+#define HAVE_HEADER_CACHE
+       int     (*cache)(const struct neighbour *neigh, struct hh_cache *hh);
+       void    (*cache_update)(struct hh_cache *hh,
+                               const struct net_device *dev,
+                               const unsigned char *haddr);
+};
+
 /* These flag bits are private to the generic network queueing
  * layer, they may not be explicitly referenced by any other
  * code.
@@ -335,6 +349,16 @@ static inline void napi_schedule(struct napi_struct *n)
                __napi_schedule(n);
 }
 
+/* Try to reschedule poll. Called by dev->poll() after napi_complete().  */
+static inline int napi_reschedule(struct napi_struct *napi)
+{
+       if (napi_schedule_prep(napi)) {
+               __napi_schedule(napi);
+               return 1;
+       }
+       return 0;
+}
+
 /**
  *     napi_complete - NAPI processing complete
  *     @n: napi context
@@ -448,7 +472,9 @@ struct net_device
 #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_GSO            2048    /* Enable software GSO. */
-#define NETIF_F_LLTX           4096    /* LockLess TX */
+#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 */
 
@@ -489,6 +515,9 @@ struct net_device
 #endif
        const struct ethtool_ops *ethtool_ops;
 
+       /* Hardware header description */
+       const struct header_ops *header_ops;
+
        /*
         * This marks the end of the "visible" part of the structure. All
         * fields hereafter are internal to the system, and may change at
@@ -612,13 +641,6 @@ struct net_device
        int                     (*open)(struct net_device *dev);
        int                     (*stop)(struct net_device *dev);
 #define HAVE_NETDEV_POLL
-       int                     (*hard_header) (struct sk_buff *skb,
-                                               struct net_device *dev,
-                                               unsigned short type,
-                                               void *daddr,
-                                               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);
@@ -635,12 +657,6 @@ struct net_device
 #define HAVE_SET_CONFIG
        int                     (*set_config)(struct net_device *dev,
                                              struct ifmap *map);
-#define HAVE_HEADER_CACHE
-       int                     (*hard_header_cache)(struct neighbour *neigh,
-                                                    struct hh_cache *hh);
-       void                    (*header_cache_update)(struct hh_cache *hh,
-                                                      struct net_device *dev,
-                                                      unsigned char *  haddr);
 #define HAVE_CHANGE_MTU
        int                     (*change_mtu)(struct net_device *dev, int new_mtu);
 
@@ -654,8 +670,6 @@ struct net_device
        void                    (*vlan_rx_kill_vid)(struct net_device *dev,
                                                    unsigned short vid);
 
-       int                     (*hard_header_parse)(struct sk_buff *skb,
-                                                    unsigned char *haddr);
        int                     (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
 #ifdef CONFIG_NETPOLL
        struct netpoll_info     *npinfo;
@@ -700,7 +714,6 @@ static inline void *netdev_priv(const struct net_device *dev)
        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.
  */
@@ -740,45 +753,46 @@ struct packet_type {
 #include <linux/interrupt.h>
 #include <linux/notifier.h>
 
-extern struct net_device               loopback_dev;           /* The loopback */
-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 for_each_netdev(net, d)                \
+               list_for_each_entry(d, &(net)->dev_base_head, dev_list)
+#define for_each_netdev_safe(net, d, n)        \
+               list_for_each_entry_safe(d, n, &(net)->dev_base_head, dev_list)
+#define for_each_netdev_continue(net, d)               \
+               list_for_each_entry_continue(d, &(net)->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;
+       struct net *net;
 
+       net = dev->nd_net;
        lh = dev->dev_list.next;
-       return lh == &dev_base_head ? NULL : net_device_entry(lh);
+       return lh == &net->dev_base_head ? NULL : net_device_entry(lh);
 }
 
-static inline struct net_device *first_net_device(void)
+static inline struct net_device *first_net_device(struct net *net)
 {
-       return list_empty(&dev_base_head) ? NULL :
-               net_device_entry(dev_base_head.next);
+       return list_empty(&net->dev_base_head) ? NULL :
+               net_device_entry(net->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 struct net_device    *dev_getbyhwaddr(struct net *net, unsigned short type, char *hwaddr);
+extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type);
+extern struct net_device *__dev_getfirstbyhwtype(struct net *net, 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);
 
-extern struct net_device       *dev_get_by_flags(unsigned short flags,
+extern struct net_device       *dev_get_by_flags(struct net *net, unsigned short flags,
                                                  unsigned short mask);
-extern struct net_device       *dev_get_by_name(const char *name);
-extern struct net_device       *__dev_get_by_name(const char *name);
+extern struct net_device       *dev_get_by_name(struct net *net, const char *name);
+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);
@@ -789,14 +803,35 @@ extern void               free_netdev(struct net_device *dev);
 extern void            synchronize_net(void);
 extern int             register_netdevice_notifier(struct notifier_block *nb);
 extern int             unregister_netdevice_notifier(struct notifier_block *nb);
-extern int             call_netdevice_notifiers(unsigned long val, void *v);
-extern struct net_device       *dev_get_by_index(int ifindex);
-extern struct net_device       *__dev_get_by_index(int ifindex);
+extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
+extern struct net_device       *dev_get_by_index(struct net *net, int ifindex);
+extern struct net_device       *__dev_get_by_index(struct net *net, int ifindex);
 extern int             dev_restart(struct net_device *dev);
 #ifdef CONFIG_NETPOLL_TRAP
 extern int             netpoll_trap(void);
 #endif
 
+static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
+                                 unsigned short type,
+                                 const void *daddr, const void *saddr,
+                                 unsigned len)
+{
+       if (!dev->header_ops)
+               return 0;
+
+       return dev->header_ops->create(skb, dev, type, daddr, saddr, len);
+}
+
+static inline int dev_parse_header(const struct sk_buff *skb,
+                                  unsigned char *haddr)
+{
+       const struct net_device *dev = skb->dev;
+
+       if (!dev->header_ops->parse)
+               return 0;
+       return dev->header_ops->parse(skb, haddr);
+}
+
 typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
 extern int             register_gifconf(unsigned int family, gifconf_func_t * gifconf);
 static inline int unregister_gifconf(unsigned int family)
@@ -1007,11 +1042,13 @@ 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 int             dev_valid_name(const char *name);
-extern int             dev_ioctl(unsigned int cmd, void __user *);
-extern int             dev_ethtool(struct ifreq *);
+extern int             dev_ioctl(struct net *net, unsigned int cmd, void __user *);
+extern int             dev_ethtool(struct net *net, struct ifreq *);
 extern unsigned                dev_get_flags(const struct net_device *);
 extern int             dev_change_flags(struct net_device *, unsigned);
 extern int             dev_change_name(struct net_device *, char *);
+extern int             dev_change_net_namespace(struct net_device *,
+                                                struct net *, const char *);
 extern int             dev_set_mtu(struct net_device *, int);
 extern int             dev_set_mac_address(struct net_device *,
                                            struct sockaddr *);
@@ -1027,7 +1064,7 @@ extern void netdev_run_todo(void);
  *     dev_put - release reference to device
  *     @dev: network device
  *
- * Hold reference to device to keep it from being freed.
+ * Release reference to device to allow it to be freed.
  */
 static inline void dev_put(struct net_device *dev)
 {
@@ -1038,7 +1075,7 @@ static inline void dev_put(struct net_device *dev)
  *     dev_hold - get reference to device
  *     @dev: network device
  *
- * Release reference to device to allow it to be freed.
+ * Hold reference to device to keep it from being freed.
  */
 static inline void dev_hold(struct net_device *dev)
 {
@@ -1260,10 +1297,15 @@ 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)
+static inline void __netif_tx_lock(struct net_device *dev, int cpu)
 {
        spin_lock(&dev->_xmit_lock);
-       dev->xmit_lock_owner = smp_processor_id();
+       dev->xmit_lock_owner = cpu;
+}
+
+static inline void netif_tx_lock(struct net_device *dev)
+{
+       __netif_tx_lock(dev, smp_processor_id());
 }
 
 static inline void netif_tx_lock_bh(struct net_device *dev)
@@ -1292,6 +1334,18 @@ static inline void netif_tx_unlock_bh(struct net_device *dev)
        spin_unlock_bh(&dev->_xmit_lock);
 }
 
+#define HARD_TX_LOCK(dev, cpu) {                       \
+       if ((dev->features & NETIF_F_LLTX) == 0) {      \
+               __netif_tx_lock(dev, cpu);                      \
+       }                                               \
+}
+
+#define HARD_TX_UNLOCK(dev) {                          \
+       if ((dev->features & NETIF_F_LLTX) == 0) {      \
+               netif_tx_unlock(dev);                   \
+       }                                               \
+}
+
 static inline void netif_tx_disable(struct net_device *dev)
 {
        netif_tx_lock_bh(dev);
@@ -1327,7 +1381,7 @@ extern void               dev_set_allmulti(struct net_device *dev, int inc);
 extern void            netdev_state_change(struct net_device *dev);
 extern void            netdev_features_change(struct net_device *dev);
 /* Load a device via the kmod */
-extern void            dev_load(const char *name);
+extern void            dev_load(struct net *net, const char *name);
 extern void            dev_mcast_init(void);
 extern int             netdev_max_backlog;
 extern int             weight_p;