xref: /linux/net/mac80211/mesh.h (revision 79617deeebb9cf089e2bc2aad19743b1209043f6)
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  *
27ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_ACTIVE: the mesh path is can be used for forwarding
28ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_RESOLVED: 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  *
35ccf80ddfSLuis Carlos Cobo  * MESH_PATH_RESOLVED and MESH_PATH_DELETE are 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 /**
47ccf80ddfSLuis Carlos Cobo  * struct mesh_path - mac80211 mesh path structure
48ccf80ddfSLuis Carlos Cobo  *
49ccf80ddfSLuis Carlos Cobo  * @dst: mesh path destination mac address
50f698d856SJasper Bryant-Greene  * @sdata: mesh subif
51ccf80ddfSLuis Carlos Cobo  * @next_hop: mesh neighbor to which frames for this destination will be
52ccf80ddfSLuis Carlos Cobo  * 	forwarded
53ccf80ddfSLuis Carlos Cobo  * @timer: mesh path discovery timer
54ccf80ddfSLuis Carlos Cobo  * @frame_queue: pending queue for frames sent to this destination while the
55ccf80ddfSLuis Carlos Cobo  * 	path is unresolved
56ccf80ddfSLuis Carlos Cobo  * @dsn: destination sequence number of the destination
57ccf80ddfSLuis Carlos Cobo  * @metric: current metric to this destination
58ccf80ddfSLuis Carlos Cobo  * @hop_count: hops to destination
59ccf80ddfSLuis Carlos Cobo  * @exp_time: in jiffies, when the path will expire or when it expired
60ccf80ddfSLuis Carlos Cobo  * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
61ccf80ddfSLuis Carlos Cobo  * 	retry
62ccf80ddfSLuis Carlos Cobo  * @discovery_retries: number of discovery retries
63ccf80ddfSLuis Carlos Cobo  * @flags: mesh path flags, as specified on &enum mesh_path_flags
64ccf80ddfSLuis Carlos Cobo  * @state_lock: mesh pat state lock
65ccf80ddfSLuis Carlos Cobo  *
66ccf80ddfSLuis Carlos Cobo  *
67f698d856SJasper Bryant-Greene  * The combination of dst and sdata is unique in the mesh path table. Since the
68d0709a65SJohannes Berg  * next_hop STA is only protected by RCU as well, deleting the STA must also
69d0709a65SJohannes Berg  * remove/substitute the mesh_path structure and wait until that is no longer
70d0709a65SJohannes Berg  * reachable before destroying the STA completely.
71ccf80ddfSLuis Carlos Cobo  */
72ccf80ddfSLuis Carlos Cobo struct mesh_path {
73ccf80ddfSLuis Carlos Cobo 	u8 dst[ETH_ALEN];
74*79617deeSYanBo 	u8 mpp[ETH_ALEN];	/* used for MPP or MAP */
75f698d856SJasper Bryant-Greene 	struct ieee80211_sub_if_data *sdata;
76ccf80ddfSLuis Carlos Cobo 	struct sta_info *next_hop;
77ccf80ddfSLuis Carlos Cobo 	struct timer_list timer;
78ccf80ddfSLuis Carlos Cobo 	struct sk_buff_head frame_queue;
79ccf80ddfSLuis Carlos Cobo 	struct rcu_head rcu;
80ccf80ddfSLuis Carlos Cobo 	u32 dsn;
81ccf80ddfSLuis Carlos Cobo 	u32 metric;
82ccf80ddfSLuis Carlos Cobo 	u8 hop_count;
83ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
84ccf80ddfSLuis Carlos Cobo 	u32 discovery_timeout;
85ccf80ddfSLuis Carlos Cobo 	u8 discovery_retries;
86ccf80ddfSLuis Carlos Cobo 	enum mesh_path_flags flags;
87ccf80ddfSLuis Carlos Cobo 	spinlock_t state_lock;
88ccf80ddfSLuis Carlos Cobo };
89ccf80ddfSLuis Carlos Cobo 
90ccf80ddfSLuis Carlos Cobo /**
91ccf80ddfSLuis Carlos Cobo  * struct mesh_table
92ccf80ddfSLuis Carlos Cobo  *
93ccf80ddfSLuis Carlos Cobo  * @hash_buckets: array of hash buckets of the table
94ccf80ddfSLuis Carlos Cobo  * @hashwlock: array of locks to protect write operations, one per bucket
95ccf80ddfSLuis Carlos Cobo  * @hash_mask: 2^size_order - 1, used to compute hash idx
96ccf80ddfSLuis Carlos Cobo  * @hash_rnd: random value used for hash computations
97ccf80ddfSLuis Carlos Cobo  * @entries: number of entries in the table
98ccf80ddfSLuis Carlos Cobo  * @free_node: function to free nodes of the table
99ccf80ddfSLuis Carlos Cobo  * @copy_node: fuction to copy nodes of the table
100ccf80ddfSLuis Carlos Cobo  * @size_order: determines size of the table, there will be 2^size_order hash
101ccf80ddfSLuis Carlos Cobo  *	buckets
102ccf80ddfSLuis Carlos Cobo  * @mean_chain_len: maximum average length for the hash buckets' list, if it is
103ccf80ddfSLuis Carlos Cobo  *	reached, the table will grow
104ccf80ddfSLuis Carlos Cobo  */
105ccf80ddfSLuis Carlos Cobo struct mesh_table {
106ccf80ddfSLuis Carlos Cobo 	/* Number of buckets will be 2^N */
107ccf80ddfSLuis Carlos Cobo 	struct hlist_head *hash_buckets;
108ccf80ddfSLuis Carlos Cobo 	spinlock_t *hashwlock;		/* One per bucket, for add/del */
109ccf80ddfSLuis Carlos Cobo 	unsigned int hash_mask;		/* (2^size_order) - 1 */
110ccf80ddfSLuis Carlos Cobo 	__u32 hash_rnd;			/* Used for hash generation */
111ccf80ddfSLuis Carlos Cobo 	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
112ccf80ddfSLuis Carlos Cobo 	void (*free_node) (struct hlist_node *p, bool free_leafs);
1134caf86c6SPavel Emelyanov 	int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
114ccf80ddfSLuis Carlos Cobo 	int size_order;
115ccf80ddfSLuis Carlos Cobo 	int mean_chain_len;
116ccf80ddfSLuis Carlos Cobo };
117ccf80ddfSLuis Carlos Cobo 
118ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */
119ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */
120ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS		256
121ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN	4
122ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT		(3 * HZ)
123ccf80ddfSLuis Carlos Cobo 
124ccf80ddfSLuis Carlos Cobo /**
125ccf80ddfSLuis Carlos Cobo  * struct rmc_entry - entry in the Recent Multicast Cache
126ccf80ddfSLuis Carlos Cobo  *
127ccf80ddfSLuis Carlos Cobo  * @seqnum: mesh sequence number of the frame
128ccf80ddfSLuis Carlos Cobo  * @exp_time: expiration time of the entry, in jiffies
129ccf80ddfSLuis Carlos Cobo  * @sa: source address of the frame
130ccf80ddfSLuis Carlos Cobo  *
131ccf80ddfSLuis Carlos Cobo  * The Recent Multicast Cache keeps track of the latest multicast frames that
132ccf80ddfSLuis Carlos Cobo  * have been received by a mesh interface and discards received multicast frames
133ccf80ddfSLuis Carlos Cobo  * that are found in the cache.
134ccf80ddfSLuis Carlos Cobo  */
135ccf80ddfSLuis Carlos Cobo struct rmc_entry {
136ccf80ddfSLuis Carlos Cobo 	struct list_head list;
137ccf80ddfSLuis Carlos Cobo 	u32 seqnum;
138ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
139ccf80ddfSLuis Carlos Cobo 	u8 sa[ETH_ALEN];
140ccf80ddfSLuis Carlos Cobo };
141ccf80ddfSLuis Carlos Cobo 
142ccf80ddfSLuis Carlos Cobo struct mesh_rmc {
143ccf80ddfSLuis Carlos Cobo 	struct rmc_entry bucket[RMC_BUCKETS];
14451ceddadSLuis Carlos Cobo 	u32 idx_mask;
145ccf80ddfSLuis Carlos Cobo };
146ccf80ddfSLuis Carlos Cobo 
147ccf80ddfSLuis Carlos Cobo 
148ccf80ddfSLuis Carlos Cobo /* Mesh IEs constants */
149ccf80ddfSLuis Carlos Cobo #define MESH_CFG_LEN		19
150ccf80ddfSLuis Carlos Cobo 
151ccf80ddfSLuis Carlos Cobo /*
152ccf80ddfSLuis Carlos Cobo  * MESH_CFG_COMP_LEN Includes:
153ccf80ddfSLuis Carlos Cobo  * 	- Active path selection protocol ID.
154ccf80ddfSLuis Carlos Cobo  * 	- Active path selection metric ID.
155ccf80ddfSLuis Carlos Cobo  * 	- Congestion control mode identifier.
156ccf80ddfSLuis Carlos Cobo  * 	- Channel precedence.
157ccf80ddfSLuis Carlos Cobo  * Does not include mesh capabilities, which may vary across nodes in the same
158ccf80ddfSLuis Carlos Cobo  * mesh
159ccf80ddfSLuis Carlos Cobo  */
160ccf80ddfSLuis Carlos Cobo #define MESH_CFG_CMP_LEN 	17
161ccf80ddfSLuis Carlos Cobo 
162ccf80ddfSLuis Carlos Cobo /* Default values, timeouts in ms */
163ccf80ddfSLuis Carlos Cobo #define MESH_TTL 		5
164ccf80ddfSLuis Carlos Cobo #define MESH_MAX_RETR	 	3
165ccf80ddfSLuis Carlos Cobo #define MESH_RET_T 		100
166ccf80ddfSLuis Carlos Cobo #define MESH_CONF_T 		100
167ccf80ddfSLuis Carlos Cobo #define MESH_HOLD_T 		100
168ccf80ddfSLuis Carlos Cobo 
169ccf80ddfSLuis Carlos Cobo #define MESH_PATH_TIMEOUT	5000
170ccf80ddfSLuis Carlos Cobo /* Minimum interval between two consecutive PREQs originated by the same
171ccf80ddfSLuis Carlos Cobo  * interface
172ccf80ddfSLuis Carlos Cobo  */
173ccf80ddfSLuis Carlos Cobo #define MESH_PREQ_MIN_INT	10
174ccf80ddfSLuis Carlos Cobo #define MESH_DIAM_TRAVERSAL_TIME 50
175ccf80ddfSLuis Carlos Cobo /* Paths will be refreshed if they are closer than PATH_REFRESH_TIME to their
176ccf80ddfSLuis Carlos Cobo  * expiration
177ccf80ddfSLuis Carlos Cobo  */
178ccf80ddfSLuis Carlos Cobo #define MESH_PATH_REFRESH_TIME			1000
179ccf80ddfSLuis Carlos Cobo #define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME)
180ccf80ddfSLuis Carlos Cobo 
181ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PREQ_RETRIES 4
182ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ)
183ccf80ddfSLuis Carlos Cobo 
184ccf80ddfSLuis Carlos Cobo /* Default maximum number of established plinks per interface */
185ccf80ddfSLuis Carlos Cobo #define MESH_MAX_ESTAB_PLINKS	32
186ccf80ddfSLuis Carlos Cobo 
187ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */
188ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS		256
189ccf80ddfSLuis Carlos Cobo 
190ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */
191ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS		1024
192ccf80ddfSLuis Carlos Cobo 
193ccf80ddfSLuis Carlos Cobo /* Pending ANA approval */
194ccf80ddfSLuis Carlos Cobo #define PLINK_CATEGORY		30
195ccf80ddfSLuis Carlos Cobo #define MESH_PATH_SEL_CATEGORY	32
196ccf80ddfSLuis Carlos Cobo 
197ccf80ddfSLuis Carlos Cobo /* Mesh Header Flags */
198ccf80ddfSLuis Carlos Cobo #define IEEE80211S_FLAGS_AE	0x3
199ccf80ddfSLuis Carlos Cobo 
200ccf80ddfSLuis Carlos Cobo /* Public interfaces */
201ccf80ddfSLuis Carlos Cobo /* Various */
202ccf80ddfSLuis Carlos Cobo u8 mesh_id_hash(u8 *mesh_id, int mesh_id_len);
203ccf80ddfSLuis Carlos Cobo int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
204ccf80ddfSLuis Carlos Cobo int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
205ccf80ddfSLuis Carlos Cobo 		struct ieee80211_sub_if_data *sdata);
206ccf80ddfSLuis Carlos Cobo int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
207f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
208f698d856SJasper Bryant-Greene bool mesh_matches_local(struct ieee802_11_elems *ie,
209f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
210472dbc45SJohannes Berg void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
211f698d856SJasper Bryant-Greene void mesh_mgmt_ies_add(struct sk_buff *skb,
212f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
213f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
214f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
215ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void);
216ccf80ddfSLuis Carlos Cobo void ieee80211s_stop(void);
217902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
218472dbc45SJohannes Berg ieee80211_rx_result
219472dbc45SJohannes Berg ieee80211_mesh_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
220472dbc45SJohannes Berg 		       struct ieee80211_rx_status *rx_status);
221472dbc45SJohannes Berg void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
222472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
223902acc78SJohannes Berg 
224ccf80ddfSLuis Carlos Cobo /* Mesh paths */
225f698d856SJasper Bryant-Greene int mesh_nexthop_lookup(struct sk_buff *skb,
226f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
227f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
228f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup(u8 *dst,
229f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
230*79617deeSYanBo struct mesh_path *mpp_path_lookup(u8 *dst,
231*79617deeSYanBo 				  struct ieee80211_sub_if_data *sdata);
232*79617deeSYanBo int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
233f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup_by_idx(int idx,
234f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
235ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
236f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
237f698d856SJasper Bryant-Greene void mesh_path_flush(struct ieee80211_sub_if_data *sdata);
238f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
239f698d856SJasper Bryant-Greene 		struct ieee80211_mgmt *mgmt, size_t len);
240f698d856SJasper Bryant-Greene int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
241ccf80ddfSLuis Carlos Cobo /* Mesh plinks */
242f698d856SJasper Bryant-Greene void mesh_neighbour_update(u8 *hw_addr, u64 rates,
243f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata, bool add);
244f698d856SJasper Bryant-Greene bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
245d0709a65SJohannes Berg void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
246ccf80ddfSLuis Carlos Cobo void mesh_plink_broken(struct sta_info *sta);
247ccf80ddfSLuis Carlos Cobo void mesh_plink_deactivate(struct sta_info *sta);
248ccf80ddfSLuis Carlos Cobo int mesh_plink_open(struct sta_info *sta);
249ccf80ddfSLuis Carlos Cobo int mesh_plink_close(struct sta_info *sta);
250ccf80ddfSLuis Carlos Cobo void mesh_plink_block(struct sta_info *sta);
251f698d856SJasper Bryant-Greene void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
252f698d856SJasper Bryant-Greene 			 struct ieee80211_mgmt *mgmt, size_t len,
253f698d856SJasper Bryant-Greene 			 struct ieee80211_rx_status *rx_status);
254ccf80ddfSLuis Carlos Cobo 
255ccf80ddfSLuis Carlos Cobo /* Private interfaces */
256ccf80ddfSLuis Carlos Cobo /* Mesh tables */
257ccf80ddfSLuis Carlos Cobo struct mesh_table *mesh_table_alloc(int size_order);
258ccf80ddfSLuis Carlos Cobo void mesh_table_free(struct mesh_table *tbl, bool free_leafs);
259ccf80ddfSLuis Carlos Cobo struct mesh_table *mesh_table_grow(struct mesh_table *tbl);
260f698d856SJasper Bryant-Greene u32 mesh_table_hash(u8 *addr, struct ieee80211_sub_if_data *sdata,
261f698d856SJasper Bryant-Greene 		struct mesh_table *tbl);
262ccf80ddfSLuis Carlos Cobo /* Mesh paths */
263ccf80ddfSLuis Carlos Cobo int mesh_path_error_tx(u8 *dest, __le32 dest_dsn, u8 *ra,
264f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
265ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
266ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath);
267ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath);
268ccf80ddfSLuis Carlos Cobo int mesh_pathtbl_init(void);
269ccf80ddfSLuis Carlos Cobo void mesh_pathtbl_unregister(void);
270f698d856SJasper Bryant-Greene int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
271ccf80ddfSLuis Carlos Cobo void mesh_path_timer(unsigned long data);
272ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta);
273f698d856SJasper Bryant-Greene void mesh_path_discard_frame(struct sk_buff *skb,
274f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
275ccf80ddfSLuis Carlos Cobo 
276902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
277902acc78SJohannes Berg extern int mesh_allocated;
278902acc78SJohannes Berg 
279ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
280ccf80ddfSLuis Carlos Cobo {
281472dbc45SJohannes Berg 	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
282472dbc45SJohannes Berg 	       atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
283ccf80ddfSLuis Carlos Cobo }
284ccf80ddfSLuis Carlos Cobo 
285ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
286ccf80ddfSLuis Carlos Cobo {
287d0709a65SJohannes Berg 	return (min_t(long, mesh_plink_free_count(sdata),
288ccf80ddfSLuis Carlos Cobo 		   MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
289ccf80ddfSLuis Carlos Cobo }
290ccf80ddfSLuis Carlos Cobo 
291ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath)
292ccf80ddfSLuis Carlos Cobo {
293ccf80ddfSLuis Carlos Cobo 	mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
294ccf80ddfSLuis Carlos Cobo }
295ccf80ddfSLuis Carlos Cobo 
296ccf80ddfSLuis Carlos Cobo #define for_each_mesh_entry(x, p, node, i) \
297ccf80ddfSLuis Carlos Cobo 	for (i = 0; i <= x->hash_mask; i++) \
298ccf80ddfSLuis Carlos Cobo 		hlist_for_each_entry_rcu(node, p, &x->hash_buckets[i], list)
299ccf80ddfSLuis Carlos Cobo 
300472dbc45SJohannes Berg void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
301472dbc45SJohannes Berg 
302902acc78SJohannes Berg #else
303902acc78SJohannes Berg #define mesh_allocated	0
304472dbc45SJohannes Berg static inline void
305472dbc45SJohannes Berg ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
306902acc78SJohannes Berg #endif
307902acc78SJohannes Berg 
308ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */
309