batman-adv: OGMv2 - add basic infrastructure
[deliverable/linux.git] / net / batman-adv / types.h
index 868f6b592b7cffd9a40cac17a6b6fe689d8ba745..e213ccdd4c6c1506ba72e041d3e4a1fd8d995363 100644 (file)
@@ -22,6 +22,7 @@
 #error only "main.h" can be included directly
 #endif
 
+#include <linux/average.h>
 #include <linux/bitops.h>
 #include <linux/compiler.h>
 #include <linux/if_ether.h>
@@ -85,6 +86,20 @@ struct batadv_hard_iface_bat_iv {
        atomic_t ogm_seqno;
 };
 
+/**
+ * struct batadv_hard_iface_bat_v - per hard-interface B.A.T.M.A.N. V data
+ * @elp_interval: time interval between two ELP transmissions
+ * @elp_seqno: current ELP sequence number
+ * @elp_skb: base skb containing the ELP message to send
+ * @elp_wq: workqueue used to schedule ELP transmissions
+ */
+struct batadv_hard_iface_bat_v {
+       atomic_t elp_interval;
+       atomic_t elp_seqno;
+       struct sk_buff *elp_skb;
+       struct delayed_work elp_wq;
+};
+
 /**
  * struct batadv_hard_iface - network device known to batman-adv
  * @list: list node for batadv_hardif_list
@@ -99,6 +114,7 @@ struct batadv_hard_iface_bat_iv {
  * @soft_iface: the batman-adv interface which uses this network interface
  * @rcu: struct used for freeing in an RCU-safe manner
  * @bat_iv: per hard-interface B.A.T.M.A.N. IV data
+ * @bat_v: per hard-interface B.A.T.M.A.N. V data
  * @cleanup_work: work queue callback item for hard-interface deinit
  * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
  * @neigh_list: list of unique single hop neighbors via this interface
@@ -111,11 +127,14 @@ struct batadv_hard_iface {
        struct net_device *net_dev;
        u8 num_bcasts;
        struct kobject *hardif_obj;
-       atomic_t refcount;
+       struct kref refcount;
        struct packet_type batman_adv_ptype;
        struct net_device *soft_iface;
        struct rcu_head rcu;
        struct batadv_hard_iface_bat_iv bat_iv;
+#ifdef CONFIG_BATMAN_ADV_BATMAN_V
+       struct batadv_hard_iface_bat_v bat_v;
+#endif
        struct work_struct cleanup_work;
        struct dentry *debug_dir;
        struct hlist_head neigh_list;
@@ -141,7 +160,7 @@ struct batadv_orig_ifinfo {
        u32 last_real_seqno;
        u8 last_ttl;
        unsigned long batman_seqno_reset;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -197,7 +216,7 @@ struct batadv_orig_node_vlan {
        unsigned short vid;
        struct batadv_vlan_tt tt;
        struct hlist_node list;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -299,7 +318,7 @@ struct batadv_orig_node {
        struct batadv_priv *bat_priv;
        /* bcast_seqno_lock protects: bcast_bits & last_bcast_seqno */
        spinlock_t bcast_seqno_lock;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 #ifdef CONFIG_BATMAN_ADV_NC
        struct list_head in_coding_list;
@@ -346,12 +365,28 @@ struct batadv_gw_node {
        struct rcu_head rcu;
 };
 
+DECLARE_EWMA(throughput, 1024, 8)
+
+/**
+ * struct batadv_hardif_neigh_node_bat_v - B.A.T.M.A.N. V private neighbor
+ *  information
+ * @throughput: ewma link throughput towards this neighbor
+ * @elp_interval: time interval between two ELP transmissions
+ * @elp_latest_seqno: latest and best known ELP sequence number
+ */
+struct batadv_hardif_neigh_node_bat_v {
+       struct ewma_throughput throughput;
+       u32 elp_interval;
+       u32 elp_latest_seqno;
+};
+
 /**
  * struct batadv_hardif_neigh_node - unique neighbor per hard-interface
  * @list: list node for batadv_hard_iface::neigh_list
  * @addr: the MAC address of the neighboring interface
  * @if_incoming: pointer to incoming hard-interface
  * @last_seen: when last packet via this neighbor was received
+ * @bat_v: B.A.T.M.A.N. V private data
  * @refcount: number of contexts the object is used
  * @rcu: struct used for freeing in a RCU-safe manner
  */
@@ -360,6 +395,9 @@ struct batadv_hardif_neigh_node {
        u8 addr[ETH_ALEN];
        struct batadv_hard_iface *if_incoming;
        unsigned long last_seen;
+#ifdef CONFIG_BATMAN_ADV_BATMAN_V
+       struct batadv_hardif_neigh_node_bat_v bat_v;
+#endif
        struct kref refcount;
        struct rcu_head rcu;
 };
@@ -384,7 +422,7 @@ struct batadv_neigh_node {
        spinlock_t ifinfo_lock; /* protects ifinfo_list and its members */
        struct batadv_hard_iface *if_incoming;
        unsigned long last_seen;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -406,11 +444,21 @@ struct batadv_neigh_ifinfo_bat_iv {
        u8 real_packet_count;
 };
 
+/**
+ * struct batadv_neigh_ifinfo_bat_v - neighbor information per outgoing
+ *  interface for B.A.T.M.A.N. V
+ * @throughput: last throughput metric received from originator via this neigh
+ */
+struct batadv_neigh_ifinfo_bat_v {
+       u32 throughput;
+};
+
 /**
  * struct batadv_neigh_ifinfo - neighbor information per outgoing interface
  * @list: list node for batadv_neigh_node::ifinfo_list
  * @if_outgoing: pointer to outgoing hard-interface
  * @bat_iv: B.A.T.M.A.N. IV private structure
+ * @bat_v: B.A.T.M.A.N. V private data
  * @last_ttl: last received ttl from this neigh node
  * @refcount: number of contexts the object is used
  * @rcu: struct used for freeing in a RCU-safe manner
@@ -419,8 +467,11 @@ struct batadv_neigh_ifinfo {
        struct hlist_node list;
        struct batadv_hard_iface *if_outgoing;
        struct batadv_neigh_ifinfo_bat_iv bat_iv;
+#ifdef CONFIG_BATMAN_ADV_BATMAN_V
+       struct batadv_neigh_ifinfo_bat_v bat_v;
+#endif
        u8 last_ttl;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -750,6 +801,20 @@ struct batadv_softif_vlan {
        struct rcu_head rcu;
 };
 
+/**
+ * struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
+ * @ogm_buff: buffer holding the OGM packet
+ * @ogm_buff_len: length of the OGM packet buffer
+ * @ogm_seqno: OGM sequence number - used to identify each OGM
+ * @ogm_wq: workqueue used to schedule OGM transmissions
+ */
+struct batadv_priv_bat_v {
+       unsigned char *ogm_buff;
+       int ogm_buff_len;
+       atomic_t ogm_seqno;
+       struct delayed_work ogm_wq;
+};
+
 /**
  * struct batadv_priv - per mesh interface data
  * @mesh_state: current status of the mesh (inactive/active/deactivating)
@@ -804,6 +869,7 @@ struct batadv_softif_vlan {
  * @mcast: multicast data
  * @network_coding: bool indicating whether network coding is enabled
  * @nc: network coding data
+ * @bat_v: B.A.T.M.A.N. V per soft-interface private data
  */
 struct batadv_priv {
        atomic_t mesh_state;
@@ -869,6 +935,9 @@ struct batadv_priv {
        atomic_t network_coding;
        struct batadv_priv_nc nc;
 #endif /* CONFIG_BATMAN_ADV_NC */
+#ifdef CONFIG_BATMAN_ADV_BATMAN_V
+       struct batadv_priv_bat_v bat_v;
+#endif
 };
 
 /**
@@ -930,7 +999,7 @@ struct batadv_bla_backbone_gw {
        atomic_t request_sent;
        u16 crc;
        spinlock_t crc_lock; /* protects crc */
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -951,7 +1020,7 @@ struct batadv_bla_claim {
        unsigned long lasttime;
        struct hlist_node hash_entry;
        struct rcu_head rcu;
-       atomic_t refcount;
+       struct kref refcount;
 };
 #endif
 
@@ -972,7 +1041,7 @@ struct batadv_tt_common_entry {
        struct hlist_node hash_entry;
        u16 flags;
        unsigned long added_at;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -1014,7 +1083,7 @@ struct batadv_tt_orig_list_entry {
        struct batadv_orig_node *orig_node;
        u8 ttvn;
        struct hlist_node list;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -1067,7 +1136,7 @@ struct batadv_tt_roam_node {
 struct batadv_nc_node {
        struct list_head list;
        u8 addr[ETH_ALEN];
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
        struct batadv_orig_node *orig_node;
        unsigned long last_seen;
@@ -1087,7 +1156,7 @@ struct batadv_nc_node {
 struct batadv_nc_path {
        struct hlist_node hash_entry;
        struct rcu_head rcu;
-       atomic_t refcount;
+       struct kref refcount;
        struct list_head packet_list;
        spinlock_t packet_list_lock; /* Protects packet_list */
        u8 next_hop[ETH_ALEN];
@@ -1230,7 +1299,7 @@ struct batadv_dat_entry {
        unsigned short vid;
        unsigned long last_update;
        struct hlist_node hash_entry;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
@@ -1266,7 +1335,7 @@ struct batadv_dat_candidate {
 struct batadv_tvlv_container {
        struct hlist_node list;
        struct batadv_tvlv_hdr tvlv_hdr;
-       atomic_t refcount;
+       struct kref refcount;
 };
 
 /**
@@ -1293,7 +1362,7 @@ struct batadv_tvlv_handler {
        u8 type;
        u8 version;
        u8 flags;
-       atomic_t refcount;
+       struct kref refcount;
        struct rcu_head rcu;
 };
 
This page took 0.033584 seconds and 5 git commands to generate.