batman-adv: Make bat_priv->primary_if an rcu protected pointer
[pandora-kernel.git] / net / batman-adv / types.h
index bf3f6f5..947bafc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
+ * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Simon Wunderlich
  *
@@ -33,7 +33,7 @@
         sizeof(struct bcast_packet))))
 
 
-struct batman_if {
+struct hard_iface {
        struct list_head list;
        int16_t if_num;
        char if_status;
@@ -43,7 +43,7 @@ struct batman_if {
        unsigned char *packet_buff;
        int packet_len;
        struct kobject *hardif_obj;
-       struct kref refcount;
+       atomic_t refcount;
        struct packet_type batman_adv_ptype;
        struct net_device *soft_iface;
        struct rcu_head rcu;
@@ -67,11 +67,9 @@ struct batman_if {
 struct orig_node {
        uint8_t orig[ETH_ALEN];
        uint8_t primary_addr[ETH_ALEN];
-       struct neigh_node *router;
+       struct neigh_node __rcu *router; /* rcu protected pointer */
        unsigned long *bcast_own;
        uint8_t *bcast_own_sum;
-       uint8_t tq_own;
-       int tq_asym_penalty;
        unsigned long last_valid;
        unsigned long bcast_seqno_reset;
        unsigned long batman_seqno_reset;
@@ -83,20 +81,28 @@ struct orig_node {
        uint8_t last_ttl;
        unsigned long bcast_bits[NUM_WORDS];
        uint32_t last_bcast_seqno;
-       struct list_head neigh_list;
+       struct hlist_head neigh_list;
        struct list_head frag_list;
+       spinlock_t neigh_list_lock; /* protects neigh_list and router */
+       atomic_t refcount;
+       struct rcu_head rcu;
+       struct hlist_node hash_entry;
+       struct bat_priv *bat_priv;
        unsigned long last_frag_packet;
-       struct {
-               uint8_t candidates;
-               struct neigh_node *selected;
-       } bond;
+       spinlock_t ogm_cnt_lock; /* protects: bcast_own, bcast_own_sum,
+                                 * neigh_node->real_bits,
+                                 * neigh_node->real_packet_count */
+       spinlock_t bcast_seqno_lock; /* protects bcast_bits,
+                                     *  last_bcast_seqno */
+       atomic_t bond_candidates;
+       struct list_head bond_list;
 };
 
 struct gw_node {
        struct hlist_node list;
        struct orig_node *orig_node;
        unsigned long deleted;
-       struct kref refcount;
+       atomic_t refcount;
        struct rcu_head rcu;
 };
 
@@ -105,18 +111,21 @@ struct gw_node {
  *     @last_valid: when last packet via this neighbor was received
  */
 struct neigh_node {
-       struct list_head list;
+       struct hlist_node list;
        uint8_t addr[ETH_ALEN];
        uint8_t real_packet_count;
        uint8_t tq_recv[TQ_GLOBAL_WINDOW_SIZE];
        uint8_t tq_index;
        uint8_t tq_avg;
        uint8_t last_ttl;
-       struct neigh_node *next_bond_candidate;
+       struct list_head bonding_list;
        unsigned long last_valid;
        unsigned long real_bits[NUM_WORDS];
+       atomic_t refcount;
+       struct rcu_head rcu;
        struct orig_node *orig_node;
-       struct batman_if *if_incoming;
+       struct hard_iface *if_incoming;
+       spinlock_t tq_lock;     /* protects: tq_recv, tq_index */
 };
 
 
@@ -138,9 +147,8 @@ struct bat_priv {
        atomic_t batman_queue_left;
        char num_ifaces;
        struct hlist_head softif_neigh_list;
-       struct softif_neigh *softif_neigh;
+       struct softif_neigh __rcu *softif_neigh;
        struct debug_log *debug_log;
-       struct batman_if *primary_if;
        struct kobject *mesh_obj;
        struct dentry *debug_dir;
        struct hlist_head forw_bat_list;
@@ -151,12 +159,11 @@ struct bat_priv {
        struct hashtable_t *hna_local_hash;
        struct hashtable_t *hna_global_hash;
        struct hashtable_t *vis_hash;
-       spinlock_t orig_hash_lock; /* protects orig_hash */
        spinlock_t forw_bat_list_lock; /* protects forw_bat_list */
        spinlock_t forw_bcast_list_lock; /* protects  */
        spinlock_t hna_lhash_lock; /* protects hna_local_hash */
        spinlock_t hna_ghash_lock; /* protects hna_global_hash */
-       spinlock_t gw_list_lock; /* protects gw_list */
+       spinlock_t gw_list_lock; /* protects gw_list and curr_gw */
        spinlock_t vis_hash_lock; /* protects vis_hash */
        spinlock_t vis_list_lock; /* protects vis_info::recv_list */
        spinlock_t softif_neigh_lock; /* protects soft-interface neigh list */
@@ -165,7 +172,8 @@ struct bat_priv {
        struct delayed_work hna_work;
        struct delayed_work orig_work;
        struct delayed_work vis_work;
-       struct gw_node *curr_gw;
+       struct gw_node __rcu *curr_gw;  /* rcu protected pointer */
+       struct hard_iface __rcu *primary_if;  /* rcu protected pointer */
        struct vis_info *my_vis_info;
 };
 
@@ -188,11 +196,13 @@ struct hna_local_entry {
        uint8_t addr[ETH_ALEN];
        unsigned long last_seen;
        char never_purge;
+       struct hlist_node hash_entry;
 };
 
 struct hna_global_entry {
        uint8_t addr[ETH_ALEN];
        struct orig_node *orig_node;
+       struct hlist_node hash_entry;
 };
 
 /**
@@ -208,7 +218,7 @@ struct forw_packet {
        uint32_t direct_link_flags;
        uint8_t num_packets;
        struct delayed_work delayed_work;
-       struct batman_if *if_incoming;
+       struct hard_iface *if_incoming;
 };
 
 /* While scanning for vis-entries of a particular vis-originator
@@ -242,6 +252,7 @@ struct vis_info {
                             * from.  we should not reply to them. */
        struct list_head send_list;
        struct kref refcount;
+       struct hlist_node hash_entry;
        struct bat_priv *bat_priv;
        /* this packet might be part of the vis send queue. */
        struct sk_buff *skb_packet;
@@ -264,7 +275,7 @@ struct softif_neigh {
        uint8_t addr[ETH_ALEN];
        unsigned long last_seen;
        short vid;
-       struct kref refcount;
+       atomic_t refcount;
        struct rcu_head rcu;
 };