bonding: Remove net_device_stats from bonding struct
[safe/jmp/linux-2.6] / drivers / net / bonding / bonding.h
index 3881969..257a7a4 100644 (file)
  *     This software may be used and distributed according to the terms
  *     of the GNU Public License, incorporated herein by reference.
  *
- *
- * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
- *             Tsippy Mendelson <tsippy.mendelson at intel dot com> and
- *             Shmulik Hen <shmulik.hen at intel dot com>
- *     - Added support for IEEE 802.3ad Dynamic link aggregation mode.
- *
- * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
- *             Amir Noam <amir.noam at intel dot com>
- *     - Code beautification and style changes (mainly in comments).
- *
- * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
- *     - Added support for Transmit load balancing mode.
- *
- * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
- *     - Code cleanup and style changes
- *
- * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov>
- *      - added "xmit_policy" kernel parameter for alternate hashing policy
- *       support for mode 2
  */
 
 #ifndef _LINUX_BONDING_H
 #include <linux/timer.h>
 #include <linux/proc_fs.h>
 #include <linux/if_bonding.h>
+#include <linux/kobject.h>
+#include <linux/in6.h>
 #include "bond_3ad.h"
 #include "bond_alb.h"
 
-#define DRV_VERSION    "2.6.3"
-#define DRV_RELDATE    "June 8, 2005"
+#define DRV_VERSION    "3.6.0"
+#define DRV_RELDATE    "September 26, 2009"
 #define DRV_NAME       "bonding"
 #define DRV_DESCRIPTION        "Ethernet Channel Bonding Driver"
 
 #define BOND_MAX_ARP_TARGETS   16
 
-#ifdef BONDING_DEBUG
-#define dprintk(fmt, args...) \
-       printk(KERN_DEBUG     \
-              DRV_NAME ": %s() %d: " fmt, __FUNCTION__, __LINE__ , ## args )
-#else
-#define dprintk(fmt, args...)
-#endif /* BONDING_DEBUG */
-
 #define IS_UP(dev)                                        \
              ((((dev)->flags & IFF_UP) == IFF_UP)      && \
               netif_running(dev)                       && \
@@ -143,39 +118,63 @@ struct bond_params {
        int mode;
        int xmit_policy;
        int miimon;
+       int num_grat_arp;
+       int num_unsol_na;
        int arp_interval;
+       int arp_validate;
        int use_carrier;
+       int fail_over_mac;
        int updelay;
        int downdelay;
        int lacp_fast;
+       int ad_select;
        char primary[IFNAMSIZ];
-       u32 arp_targets[BOND_MAX_ARP_TARGETS];
+       int primary_reselect;
+       __be32 arp_targets[BOND_MAX_ARP_TARGETS];
 };
 
+struct bond_parm_tbl {
+       char *modename;
+       int mode;
+};
+
+#define BOND_MAX_MODENAME_LEN 20
+
 struct vlan_entry {
        struct list_head vlan_list;
-       u32 vlan_ip;
+       __be32 vlan_ip;
        unsigned short vlan_id;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       struct in6_addr vlan_ipv6;
+#endif
 };
 
 struct slave {
-       struct net_device *dev; /* first - usefull for panic debug */
+       struct net_device *dev; /* first - useful for panic debug */
        struct slave *next;
        struct slave *prev;
-       s16    delay;
-       u32    jiffies;
+       int    delay;
+       unsigned long jiffies;
+       unsigned long last_arp_rx;
        s8     link;    /* one of BOND_LINK_XXXX */
+       s8     new_link;
        s8     state;   /* one of BOND_STATE_XXXX */
        u32    original_flags;
+       u32    original_mtu;
        u32    link_failure_count;
+       u8     perm_hwaddr[ETH_ALEN];
        u16    speed;
        u8     duplex;
-       u8     perm_hwaddr[ETH_ALEN];
        struct ad_slave_info ad_info; /* HUGE - better to dynamically alloc */
        struct tlb_slave_info tlb_info;
 };
 
 /*
+ * Link pseudo-state only used internally by monitors
+ */
+#define BOND_LINK_NOCHANGE -1
+
+/*
  * Here are the locking policies for the two bonding locks:
  *
  * 1) Get bond->lock when reading/writing slave list.
@@ -185,35 +184,43 @@ struct slave {
  *    beforehand.
  */
 struct bonding {
-       struct   net_device *dev; /* first - usefull for panic debug */
+       struct   net_device *dev; /* first - useful for panic debug */
        struct   slave *first_slave;
        struct   slave *curr_active_slave;
        struct   slave *current_arp_slave;
        struct   slave *primary_slave;
+       bool     force_primary;
        s32      slave_cnt; /* never change this value outside the attach/detach wrappers */
        rwlock_t lock;
        rwlock_t curr_slave_lock;
-       struct   timer_list mii_timer;
-       struct   timer_list arp_timer;
        s8       kill_timers;
-       struct   net_device_stats stats;
+       s8       send_grat_arp;
+       s8       send_unsol_na;
+       s8       setup_by_slave;
 #ifdef CONFIG_PROC_FS
        struct   proc_dir_entry *proc_entry;
        char     proc_file_name[IFNAMSIZ];
 #endif /* CONFIG_PROC_FS */
        struct   list_head bond_list;
        struct   dev_mc_list *mc_list;
-       int      (*xmit_hash_policy)(struct sk_buff *, struct net_device *, int);
-       u32      master_ip;
+       int      (*xmit_hash_policy)(struct sk_buff *, int);
+       __be32   master_ip;
        u16      flags;
+       u16      rr_tx_counter;
        struct   ad_bond_info ad_info;
        struct   alb_bond_info alb_info;
        struct   bond_params params;
        struct   list_head vlan_list;
        struct   vlan_group *vlgrp;
-       /* the features the bonding device supports, independently 
-        * of any slaves */
-       int      bond_features; 
+       struct   packet_type arp_mon_pt;
+       struct   workqueue_struct *wq;
+       struct   delayed_work mii_work;
+       struct   delayed_work arp_work;
+       struct   delayed_work alb_work;
+       struct   delayed_work ad_work;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+       struct   in6_addr master_ipv6;
+#endif
 };
 
 /**
@@ -221,7 +228,7 @@ struct bonding {
  *
  * Caller must hold bond lock for read
  */
-extern inline struct slave *bond_get_slave_by_dev(struct bonding *bond, struct net_device *slave_dev)
+static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, struct net_device *slave_dev)
 {
        struct slave *slave = NULL;
        int i;
@@ -235,29 +242,142 @@ extern inline struct slave *bond_get_slave_by_dev(struct bonding *bond, struct n
        return slave;
 }
 
-extern inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
+static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
 {
        if (!slave || !slave->dev->master) {
                return NULL;
        }
 
-       return (struct bonding *)slave->dev->master->priv;
+       return (struct bonding *)netdev_priv(slave->dev->master);
+}
+
+static inline bool bond_is_lb(const struct bonding *bond)
+{
+       return (bond->params.mode == BOND_MODE_TLB ||
+               bond->params.mode == BOND_MODE_ALB);
+}
+
+#define BOND_PRI_RESELECT_ALWAYS       0
+#define BOND_PRI_RESELECT_BETTER       1
+#define BOND_PRI_RESELECT_FAILURE      2
+
+#define BOND_FOM_NONE                  0
+#define BOND_FOM_ACTIVE                        1
+#define BOND_FOM_FOLLOW                        2
+
+#define BOND_ARP_VALIDATE_NONE         0
+#define BOND_ARP_VALIDATE_ACTIVE       (1 << BOND_STATE_ACTIVE)
+#define BOND_ARP_VALIDATE_BACKUP       (1 << BOND_STATE_BACKUP)
+#define BOND_ARP_VALIDATE_ALL          (BOND_ARP_VALIDATE_ACTIVE | \
+                                        BOND_ARP_VALIDATE_BACKUP)
+
+static inline int slave_do_arp_validate(struct bonding *bond,
+                                       struct slave *slave)
+{
+       return bond->params.arp_validate & (1 << slave->state);
+}
+
+static inline unsigned long slave_last_rx(struct bonding *bond,
+                                       struct slave *slave)
+{
+       if (slave_do_arp_validate(bond, slave))
+               return slave->last_arp_rx;
+
+       return slave->dev->last_rx;
 }
 
-extern inline void bond_set_slave_inactive_flags(struct slave *slave)
+static inline void bond_set_slave_inactive_flags(struct slave *slave)
 {
-       slave->state = BOND_STATE_BACKUP;
-       slave->dev->flags |= IFF_NOARP;
+       struct bonding *bond = netdev_priv(slave->dev->master);
+       if (!bond_is_lb(bond))
+               slave->state = BOND_STATE_BACKUP;
+       slave->dev->priv_flags |= IFF_SLAVE_INACTIVE;
+       if (slave_do_arp_validate(bond, slave))
+               slave->dev->priv_flags |= IFF_SLAVE_NEEDARP;
 }
 
-extern inline void bond_set_slave_active_flags(struct slave *slave)
+static inline void bond_set_slave_active_flags(struct slave *slave)
 {
        slave->state = BOND_STATE_ACTIVE;
-       slave->dev->flags &= ~IFF_NOARP;
+       slave->dev->priv_flags &= ~(IFF_SLAVE_INACTIVE | IFF_SLAVE_NEEDARP);
+}
+
+static inline void bond_set_master_3ad_flags(struct bonding *bond)
+{
+       bond->dev->priv_flags |= IFF_MASTER_8023AD;
+}
+
+static inline void bond_unset_master_3ad_flags(struct bonding *bond)
+{
+       bond->dev->priv_flags &= ~IFF_MASTER_8023AD;
+}
+
+static inline void bond_set_master_alb_flags(struct bonding *bond)
+{
+       bond->dev->priv_flags |= IFF_MASTER_ALB;
+}
+
+static inline void bond_unset_master_alb_flags(struct bonding *bond)
+{
+       bond->dev->priv_flags &= ~IFF_MASTER_ALB;
 }
 
 struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);
 int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
+int bond_create(struct net *net, const char *name);
+int  bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev);
+int bond_create_sysfs(void);
+void bond_destroy_sysfs(void);
+void bond_prepare_sysfs_group(struct bonding *bond);
+int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave);
+void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave);
+int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
+int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
+void bond_mii_monitor(struct work_struct *);
+void bond_loadbalance_arp_mon(struct work_struct *);
+void bond_activebackup_arp_mon(struct work_struct *);
+void bond_set_mode_ops(struct bonding *bond, int mode);
+int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl);
+void bond_select_active_slave(struct bonding *bond);
+void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
+void bond_register_arp(struct bonding *);
+void bond_unregister_arp(struct bonding *);
 
-#endif /* _LINUX_BONDING_H */
+struct bond_net {
+       struct net *            net;    /* Associated network namespace */
+       struct list_head        dev_list;
+#ifdef CONFIG_PROC_FS
+       struct proc_dir_entry * proc_dir;
+#endif
+};
+
+/* exported from bond_main.c */
+extern int bond_net_id;
+extern const struct bond_parm_tbl bond_lacp_tbl[];
+extern const struct bond_parm_tbl bond_mode_tbl[];
+extern const struct bond_parm_tbl xmit_hashtype_tbl[];
+extern const struct bond_parm_tbl arp_validate_tbl[];
+extern const struct bond_parm_tbl fail_over_mac_tbl[];
+extern const struct bond_parm_tbl pri_reselect_tbl[];
+extern struct bond_parm_tbl ad_select_tbl[];
 
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+void bond_send_unsolicited_na(struct bonding *bond);
+void bond_register_ipv6_notifier(void);
+void bond_unregister_ipv6_notifier(void);
+#else
+static inline void bond_send_unsolicited_na(struct bonding *bond)
+{
+       return;
+}
+static inline void bond_register_ipv6_notifier(void)
+{
+       return;
+}
+static inline void bond_unregister_ipv6_notifier(void)
+{
+       return;
+}
+#endif
+
+#endif /* _LINUX_BONDING_H */