1ccf80ddfSLuis Carlos Cobo /* 2ccf80ddfSLuis Carlos Cobo * Copyright (c) 2008 open80211s Ltd. 3ccf80ddfSLuis Carlos Cobo * Authors: Luis Carlos Cobo <luisca@cozybit.com> 4ccf80ddfSLuis Carlos Cobo * Javier Cardona <javier@cozybit.com> 5ccf80ddfSLuis Carlos Cobo * 6ccf80ddfSLuis Carlos Cobo * This program is free software; you can redistribute it and/or modify 7ccf80ddfSLuis Carlos Cobo * it under the terms of the GNU General Public License version 2 as 8ccf80ddfSLuis Carlos Cobo * published by the Free Software Foundation. 9ccf80ddfSLuis Carlos Cobo */ 10ccf80ddfSLuis Carlos Cobo 11ccf80ddfSLuis Carlos Cobo #ifndef IEEE80211S_H 12ccf80ddfSLuis Carlos Cobo #define IEEE80211S_H 13ccf80ddfSLuis Carlos Cobo 14902acc78SJohannes Berg #include <linux/types.h> 15ccf80ddfSLuis Carlos Cobo #include <linux/jhash.h> 16f375d558SAl Viro #include <asm/unaligned.h> 17902acc78SJohannes Berg #include "ieee80211_i.h" 18ccf80ddfSLuis Carlos Cobo 19ccf80ddfSLuis Carlos Cobo 20ccf80ddfSLuis Carlos Cobo /* Data structures */ 21ccf80ddfSLuis Carlos Cobo 22ccf80ddfSLuis Carlos Cobo /** 23ccf80ddfSLuis Carlos Cobo * enum mesh_path_flags - mac80211 mesh path flags 24ccf80ddfSLuis Carlos Cobo * 25ccf80ddfSLuis Carlos Cobo * 26ccf80ddfSLuis Carlos Cobo * 27eb80ed8dSRami Rosen * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding 28eb80ed8dSRami Rosen * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path 29ccf80ddfSLuis Carlos Cobo * @MESH_PATH_DSN_VALID: the mesh path contains a valid destination sequence 30ccf80ddfSLuis Carlos Cobo * number 31ccf80ddfSLuis Carlos Cobo * @MESH_PATH_FIXED: the mesh path has been manually set and should not be 32ccf80ddfSLuis Carlos Cobo * modified 33ccf80ddfSLuis Carlos Cobo * @MESH_PATH_RESOLVED: the mesh path can has been resolved 34ccf80ddfSLuis Carlos Cobo * 35eb80ed8dSRami Rosen * MESH_PATH_RESOLVED is used by the mesh path timer to 36ccf80ddfSLuis Carlos Cobo * decide when to stop or cancel the mesh path discovery. 37ccf80ddfSLuis Carlos Cobo */ 38ccf80ddfSLuis Carlos Cobo enum mesh_path_flags { 39ccf80ddfSLuis Carlos Cobo MESH_PATH_ACTIVE = BIT(0), 40ccf80ddfSLuis Carlos Cobo MESH_PATH_RESOLVING = BIT(1), 41ccf80ddfSLuis Carlos Cobo MESH_PATH_DSN_VALID = BIT(2), 42ccf80ddfSLuis Carlos Cobo MESH_PATH_FIXED = BIT(3), 43ccf80ddfSLuis Carlos Cobo MESH_PATH_RESOLVED = BIT(4), 44ccf80ddfSLuis Carlos Cobo }; 45ccf80ddfSLuis Carlos Cobo 46ccf80ddfSLuis Carlos Cobo /** 4718889231SJavier Cardona * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks 4818889231SJavier Cardona * 4918889231SJavier Cardona * 5018889231SJavier Cardona * 5118889231SJavier Cardona * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks 5218889231SJavier Cardona * @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs 5318889231SJavier Cardona * to grow. 5418889231SJavier Cardona * @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to 5518889231SJavier Cardona * grow 5618889231SJavier Cardona */ 5718889231SJavier Cardona enum mesh_deferred_task_flags { 5818889231SJavier Cardona MESH_WORK_HOUSEKEEPING, 5918889231SJavier Cardona MESH_WORK_GROW_MPATH_TABLE, 6018889231SJavier Cardona MESH_WORK_GROW_MPP_TABLE, 6118889231SJavier Cardona }; 6218889231SJavier Cardona 6318889231SJavier Cardona /** 64ccf80ddfSLuis Carlos Cobo * struct mesh_path - mac80211 mesh path structure 65ccf80ddfSLuis Carlos Cobo * 66ccf80ddfSLuis Carlos Cobo * @dst: mesh path destination mac address 67f698d856SJasper Bryant-Greene * @sdata: mesh subif 68ccf80ddfSLuis Carlos Cobo * @next_hop: mesh neighbor to which frames for this destination will be 69ccf80ddfSLuis Carlos Cobo * forwarded 70ccf80ddfSLuis Carlos Cobo * @timer: mesh path discovery timer 71ccf80ddfSLuis Carlos Cobo * @frame_queue: pending queue for frames sent to this destination while the 72ccf80ddfSLuis Carlos Cobo * path is unresolved 73ccf80ddfSLuis Carlos Cobo * @dsn: destination sequence number of the destination 74ccf80ddfSLuis Carlos Cobo * @metric: current metric to this destination 75ccf80ddfSLuis Carlos Cobo * @hop_count: hops to destination 76ccf80ddfSLuis Carlos Cobo * @exp_time: in jiffies, when the path will expire or when it expired 77ccf80ddfSLuis Carlos Cobo * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery 78ccf80ddfSLuis Carlos Cobo * retry 79ccf80ddfSLuis Carlos Cobo * @discovery_retries: number of discovery retries 80ccf80ddfSLuis Carlos Cobo * @flags: mesh path flags, as specified on &enum mesh_path_flags 81fe583434SJavier Cardona * @state_lock: mesh path state lock 82ccf80ddfSLuis Carlos Cobo * 83ccf80ddfSLuis Carlos Cobo * 84f698d856SJasper Bryant-Greene * The combination of dst and sdata is unique in the mesh path table. Since the 85d0709a65SJohannes Berg * next_hop STA is only protected by RCU as well, deleting the STA must also 86d0709a65SJohannes Berg * remove/substitute the mesh_path structure and wait until that is no longer 87d0709a65SJohannes Berg * reachable before destroying the STA completely. 88ccf80ddfSLuis Carlos Cobo */ 89ccf80ddfSLuis Carlos Cobo struct mesh_path { 90ccf80ddfSLuis Carlos Cobo u8 dst[ETH_ALEN]; 9179617deeSYanBo u8 mpp[ETH_ALEN]; /* used for MPP or MAP */ 92f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata; 93ccf80ddfSLuis Carlos Cobo struct sta_info *next_hop; 94ccf80ddfSLuis Carlos Cobo struct timer_list timer; 95ccf80ddfSLuis Carlos Cobo struct sk_buff_head frame_queue; 96ccf80ddfSLuis Carlos Cobo struct rcu_head rcu; 97ccf80ddfSLuis Carlos Cobo u32 dsn; 98ccf80ddfSLuis Carlos Cobo u32 metric; 99ccf80ddfSLuis Carlos Cobo u8 hop_count; 100ccf80ddfSLuis Carlos Cobo unsigned long exp_time; 101ccf80ddfSLuis Carlos Cobo u32 discovery_timeout; 102ccf80ddfSLuis Carlos Cobo u8 discovery_retries; 103ccf80ddfSLuis Carlos Cobo enum mesh_path_flags flags; 104ccf80ddfSLuis Carlos Cobo spinlock_t state_lock; 105ccf80ddfSLuis Carlos Cobo }; 106ccf80ddfSLuis Carlos Cobo 107ccf80ddfSLuis Carlos Cobo /** 108ccf80ddfSLuis Carlos Cobo * struct mesh_table 109ccf80ddfSLuis Carlos Cobo * 110ccf80ddfSLuis Carlos Cobo * @hash_buckets: array of hash buckets of the table 111ccf80ddfSLuis Carlos Cobo * @hashwlock: array of locks to protect write operations, one per bucket 112ccf80ddfSLuis Carlos Cobo * @hash_mask: 2^size_order - 1, used to compute hash idx 113ccf80ddfSLuis Carlos Cobo * @hash_rnd: random value used for hash computations 114ccf80ddfSLuis Carlos Cobo * @entries: number of entries in the table 115ccf80ddfSLuis Carlos Cobo * @free_node: function to free nodes of the table 116ccf80ddfSLuis Carlos Cobo * @copy_node: fuction to copy nodes of the table 117ccf80ddfSLuis Carlos Cobo * @size_order: determines size of the table, there will be 2^size_order hash 118ccf80ddfSLuis Carlos Cobo * buckets 119ccf80ddfSLuis Carlos Cobo * @mean_chain_len: maximum average length for the hash buckets' list, if it is 120ccf80ddfSLuis Carlos Cobo * reached, the table will grow 121ccf80ddfSLuis Carlos Cobo */ 122ccf80ddfSLuis Carlos Cobo struct mesh_table { 123ccf80ddfSLuis Carlos Cobo /* Number of buckets will be 2^N */ 124ccf80ddfSLuis Carlos Cobo struct hlist_head *hash_buckets; 125ccf80ddfSLuis Carlos Cobo spinlock_t *hashwlock; /* One per bucket, for add/del */ 126ccf80ddfSLuis Carlos Cobo unsigned int hash_mask; /* (2^size_order) - 1 */ 127ccf80ddfSLuis Carlos Cobo __u32 hash_rnd; /* Used for hash generation */ 128ccf80ddfSLuis Carlos Cobo atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */ 129ccf80ddfSLuis Carlos Cobo void (*free_node) (struct hlist_node *p, bool free_leafs); 1304caf86c6SPavel Emelyanov int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl); 131ccf80ddfSLuis Carlos Cobo int size_order; 132ccf80ddfSLuis Carlos Cobo int mean_chain_len; 133ccf80ddfSLuis Carlos Cobo }; 134ccf80ddfSLuis Carlos Cobo 135ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */ 136ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */ 137ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS 256 138ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN 4 139ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT (3 * HZ) 140ccf80ddfSLuis Carlos Cobo 141ccf80ddfSLuis Carlos Cobo /** 142ccf80ddfSLuis Carlos Cobo * struct rmc_entry - entry in the Recent Multicast Cache 143ccf80ddfSLuis Carlos Cobo * 144ccf80ddfSLuis Carlos Cobo * @seqnum: mesh sequence number of the frame 145ccf80ddfSLuis Carlos Cobo * @exp_time: expiration time of the entry, in jiffies 146ccf80ddfSLuis Carlos Cobo * @sa: source address of the frame 147ccf80ddfSLuis Carlos Cobo * 148ccf80ddfSLuis Carlos Cobo * The Recent Multicast Cache keeps track of the latest multicast frames that 149ccf80ddfSLuis Carlos Cobo * have been received by a mesh interface and discards received multicast frames 150ccf80ddfSLuis Carlos Cobo * that are found in the cache. 151ccf80ddfSLuis Carlos Cobo */ 152ccf80ddfSLuis Carlos Cobo struct rmc_entry { 153ccf80ddfSLuis Carlos Cobo struct list_head list; 154ccf80ddfSLuis Carlos Cobo u32 seqnum; 155ccf80ddfSLuis Carlos Cobo unsigned long exp_time; 156ccf80ddfSLuis Carlos Cobo u8 sa[ETH_ALEN]; 157ccf80ddfSLuis Carlos Cobo }; 158ccf80ddfSLuis Carlos Cobo 159ccf80ddfSLuis Carlos Cobo struct mesh_rmc { 160ccf80ddfSLuis Carlos Cobo struct rmc_entry bucket[RMC_BUCKETS]; 16151ceddadSLuis Carlos Cobo u32 idx_mask; 162ccf80ddfSLuis Carlos Cobo }; 163ccf80ddfSLuis Carlos Cobo 164ccf80ddfSLuis Carlos Cobo 165ccf80ddfSLuis Carlos Cobo /* 166ccf80ddfSLuis Carlos Cobo * MESH_CFG_COMP_LEN Includes: 167ccf80ddfSLuis Carlos Cobo * - Active path selection protocol ID. 168ccf80ddfSLuis Carlos Cobo * - Active path selection metric ID. 169ccf80ddfSLuis Carlos Cobo * - Congestion control mode identifier. 170ccf80ddfSLuis Carlos Cobo * - Channel precedence. 171ccf80ddfSLuis Carlos Cobo * Does not include mesh capabilities, which may vary across nodes in the same 172ccf80ddfSLuis Carlos Cobo * mesh 173ccf80ddfSLuis Carlos Cobo */ 1741239cd58SJohannes Berg #define MESH_CFG_CMP_LEN (IEEE80211_MESH_CONFIG_LEN - 2) 175ccf80ddfSLuis Carlos Cobo 176ccf80ddfSLuis Carlos Cobo /* Default values, timeouts in ms */ 177a1935218SRui Paulo #define MESH_TTL 31 178ccf80ddfSLuis Carlos Cobo #define MESH_MAX_RETR 3 179ccf80ddfSLuis Carlos Cobo #define MESH_RET_T 100 180ccf80ddfSLuis Carlos Cobo #define MESH_CONF_T 100 181ccf80ddfSLuis Carlos Cobo #define MESH_HOLD_T 100 182ccf80ddfSLuis Carlos Cobo 183ccf80ddfSLuis Carlos Cobo #define MESH_PATH_TIMEOUT 5000 184ccf80ddfSLuis Carlos Cobo /* Minimum interval between two consecutive PREQs originated by the same 185ccf80ddfSLuis Carlos Cobo * interface 186ccf80ddfSLuis Carlos Cobo */ 187ccf80ddfSLuis Carlos Cobo #define MESH_PREQ_MIN_INT 10 188ccf80ddfSLuis Carlos Cobo #define MESH_DIAM_TRAVERSAL_TIME 50 189ccf80ddfSLuis Carlos Cobo /* Paths will be refreshed if they are closer than PATH_REFRESH_TIME to their 190ccf80ddfSLuis Carlos Cobo * expiration 191ccf80ddfSLuis Carlos Cobo */ 192ccf80ddfSLuis Carlos Cobo #define MESH_PATH_REFRESH_TIME 1000 193ccf80ddfSLuis Carlos Cobo #define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME) 1945b365834SJavier Cardona #define MESH_DEFAULT_BEACON_INTERVAL 1000 /* in 1024 us units */ 195ccf80ddfSLuis Carlos Cobo 196ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PREQ_RETRIES 4 197ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ) 198ccf80ddfSLuis Carlos Cobo 199ccf80ddfSLuis Carlos Cobo /* Default maximum number of established plinks per interface */ 200ccf80ddfSLuis Carlos Cobo #define MESH_MAX_ESTAB_PLINKS 32 201ccf80ddfSLuis Carlos Cobo 202ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */ 203ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS 256 204ccf80ddfSLuis Carlos Cobo 205ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */ 206ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS 1024 207ccf80ddfSLuis Carlos Cobo 208ccf80ddfSLuis Carlos Cobo /* Pending ANA approval */ 2090938393fSRui Paulo #define MESH_PLINK_CATEGORY 30 210ccf80ddfSLuis Carlos Cobo #define MESH_PATH_SEL_CATEGORY 32 211*095de013SRui Paulo #define MESH_PATH_SEL_ACTION 0 212ccf80ddfSLuis Carlos Cobo 213ccf80ddfSLuis Carlos Cobo /* Public interfaces */ 214ccf80ddfSLuis Carlos Cobo /* Various */ 2153c5772a5SJavier Cardona int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, 2163c5772a5SJavier Cardona char *da, char *sa); 217ccf80ddfSLuis Carlos Cobo int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, 2183c5772a5SJavier Cardona struct ieee80211_sub_if_data *sdata, char *addr4, 2193c5772a5SJavier Cardona char *addr5, char *addr6); 220ccf80ddfSLuis Carlos Cobo int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr, 221f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 222f698d856SJasper Bryant-Greene bool mesh_matches_local(struct ieee802_11_elems *ie, 223f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 224472dbc45SJohannes Berg void mesh_ids_set_default(struct ieee80211_if_mesh *mesh); 225f698d856SJasper Bryant-Greene void mesh_mgmt_ies_add(struct sk_buff *skb, 226f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 227f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); 228f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); 229ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void); 230bfc32e6aSJavier Cardona void ieee80211s_update_metric(struct ieee80211_local *local, 231bfc32e6aSJavier Cardona struct sta_info *stainfo, struct sk_buff *skb); 232ccf80ddfSLuis Carlos Cobo void ieee80211s_stop(void); 233902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); 234472dbc45SJohannes Berg ieee80211_rx_result 235f1d58c25SJohannes Berg ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); 236472dbc45SJohannes Berg void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); 237472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); 238902acc78SJohannes Berg 239ccf80ddfSLuis Carlos Cobo /* Mesh paths */ 240f698d856SJasper Bryant-Greene int mesh_nexthop_lookup(struct sk_buff *skb, 241f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 242f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata); 243f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup(u8 *dst, 244f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 24579617deeSYanBo struct mesh_path *mpp_path_lookup(u8 *dst, 24679617deeSYanBo struct ieee80211_sub_if_data *sdata); 24779617deeSYanBo int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata); 248f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup_by_idx(int idx, 249f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 250ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop); 251f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata); 252f698d856SJasper Bryant-Greene void mesh_path_flush(struct ieee80211_sub_if_data *sdata); 253f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, 254f698d856SJasper Bryant-Greene struct ieee80211_mgmt *mgmt, size_t len); 255f698d856SJasper Bryant-Greene int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata); 256ccf80ddfSLuis Carlos Cobo /* Mesh plinks */ 257881d948cSJohannes Berg void mesh_neighbour_update(u8 *hw_addr, u32 rates, 258f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata, bool add); 259f698d856SJasper Bryant-Greene bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie); 260d0709a65SJohannes Berg void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata); 261ccf80ddfSLuis Carlos Cobo void mesh_plink_broken(struct sta_info *sta); 262ccf80ddfSLuis Carlos Cobo void mesh_plink_deactivate(struct sta_info *sta); 263ccf80ddfSLuis Carlos Cobo int mesh_plink_open(struct sta_info *sta); 264ccf80ddfSLuis Carlos Cobo void mesh_plink_block(struct sta_info *sta); 265f698d856SJasper Bryant-Greene void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, 266f698d856SJasper Bryant-Greene struct ieee80211_mgmt *mgmt, size_t len, 267f698d856SJasper Bryant-Greene struct ieee80211_rx_status *rx_status); 268ccf80ddfSLuis Carlos Cobo 269ccf80ddfSLuis Carlos Cobo /* Private interfaces */ 270ccf80ddfSLuis Carlos Cobo /* Mesh tables */ 271ccf80ddfSLuis Carlos Cobo struct mesh_table *mesh_table_alloc(int size_order); 272ccf80ddfSLuis Carlos Cobo void mesh_table_free(struct mesh_table *tbl, bool free_leafs); 27318889231SJavier Cardona void mesh_mpath_table_grow(void); 27418889231SJavier Cardona void mesh_mpp_table_grow(void); 275f698d856SJasper Bryant-Greene u32 mesh_table_hash(u8 *addr, struct ieee80211_sub_if_data *sdata, 276f698d856SJasper Bryant-Greene struct mesh_table *tbl); 277ccf80ddfSLuis Carlos Cobo /* Mesh paths */ 278ccf80ddfSLuis Carlos Cobo int mesh_path_error_tx(u8 *dest, __le32 dest_dsn, u8 *ra, 279f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 280ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta); 281ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath); 282ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath); 283ccf80ddfSLuis Carlos Cobo int mesh_pathtbl_init(void); 284ccf80ddfSLuis Carlos Cobo void mesh_pathtbl_unregister(void); 285f698d856SJasper Bryant-Greene int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata); 286ccf80ddfSLuis Carlos Cobo void mesh_path_timer(unsigned long data); 287ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta); 288f698d856SJasper Bryant-Greene void mesh_path_discard_frame(struct sk_buff *skb, 289f698d856SJasper Bryant-Greene struct ieee80211_sub_if_data *sdata); 2905bb644a0SJohannes Berg void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata); 2915bb644a0SJohannes Berg void mesh_path_restart(struct ieee80211_sub_if_data *sdata); 292ccf80ddfSLuis Carlos Cobo 293f5ea9120SJohannes Berg extern int mesh_paths_generation; 294f5ea9120SJohannes Berg 295902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH 296902acc78SJohannes Berg extern int mesh_allocated; 297902acc78SJohannes Berg 298ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata) 299ccf80ddfSLuis Carlos Cobo { 300472dbc45SJohannes Berg return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks - 301472dbc45SJohannes Berg atomic_read(&sdata->u.mesh.mshstats.estab_plinks); 302ccf80ddfSLuis Carlos Cobo } 303ccf80ddfSLuis Carlos Cobo 304ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata) 305ccf80ddfSLuis Carlos Cobo { 306d0709a65SJohannes Berg return (min_t(long, mesh_plink_free_count(sdata), 307ccf80ddfSLuis Carlos Cobo MESH_MAX_PLINKS - sdata->local->num_sta)) > 0; 308ccf80ddfSLuis Carlos Cobo } 309ccf80ddfSLuis Carlos Cobo 310ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath) 311ccf80ddfSLuis Carlos Cobo { 312ccf80ddfSLuis Carlos Cobo mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED; 313ccf80ddfSLuis Carlos Cobo } 314ccf80ddfSLuis Carlos Cobo 315ccf80ddfSLuis Carlos Cobo #define for_each_mesh_entry(x, p, node, i) \ 316ccf80ddfSLuis Carlos Cobo for (i = 0; i <= x->hash_mask; i++) \ 317ccf80ddfSLuis Carlos Cobo hlist_for_each_entry_rcu(node, p, &x->hash_buckets[i], list) 318ccf80ddfSLuis Carlos Cobo 319472dbc45SJohannes Berg void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local); 320472dbc45SJohannes Berg 3215bb644a0SJohannes Berg void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata); 3225bb644a0SJohannes Berg void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata); 3235bb644a0SJohannes Berg void mesh_plink_quiesce(struct sta_info *sta); 3245bb644a0SJohannes Berg void mesh_plink_restart(struct sta_info *sta); 325902acc78SJohannes Berg #else 326902acc78SJohannes Berg #define mesh_allocated 0 327472dbc45SJohannes Berg static inline void 328472dbc45SJohannes Berg ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {} 3295bb644a0SJohannes Berg static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata) 3305bb644a0SJohannes Berg {} 3315bb644a0SJohannes Berg static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata) 3325bb644a0SJohannes Berg {} 3335bb644a0SJohannes Berg static inline void mesh_plink_quiesce(struct sta_info *sta) {} 3345bb644a0SJohannes Berg static inline void mesh_plink_restart(struct sta_info *sta) {} 335902acc78SJohannes Berg #endif 336902acc78SJohannes Berg 337ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */ 338