xref: /linux/net/mac80211/mesh.h (revision eef35c2d41ddcc653c20d26b977acaa45c811e1f)
1ccf80ddfSLuis Carlos Cobo /*
2264d9b7dSRui Paulo  * Copyright (c) 2008, 2009 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
29d19b3bf6SRui Paulo  * @MESH_PATH_SN_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),
41d19b3bf6SRui Paulo 	MESH_PATH_SN_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
56e304bfd3SRui Paulo  * @MESH_WORK_ROOT: the mesh root station needs to send a frame
5718889231SJavier Cardona  */
5818889231SJavier Cardona enum mesh_deferred_task_flags {
5918889231SJavier Cardona 	MESH_WORK_HOUSEKEEPING,
6018889231SJavier Cardona 	MESH_WORK_GROW_MPATH_TABLE,
6118889231SJavier Cardona 	MESH_WORK_GROW_MPP_TABLE,
62e304bfd3SRui Paulo 	MESH_WORK_ROOT,
6318889231SJavier Cardona };
6418889231SJavier Cardona 
6518889231SJavier Cardona /**
66ccf80ddfSLuis Carlos Cobo  * struct mesh_path - mac80211 mesh path structure
67ccf80ddfSLuis Carlos Cobo  *
68ccf80ddfSLuis Carlos Cobo  * @dst: mesh path destination mac address
69f698d856SJasper Bryant-Greene  * @sdata: mesh subif
70ccf80ddfSLuis Carlos Cobo  * @next_hop: mesh neighbor to which frames for this destination will be
71ccf80ddfSLuis Carlos Cobo  * 	forwarded
72ccf80ddfSLuis Carlos Cobo  * @timer: mesh path discovery timer
73ccf80ddfSLuis Carlos Cobo  * @frame_queue: pending queue for frames sent to this destination while the
74ccf80ddfSLuis Carlos Cobo  * 	path is unresolved
75d19b3bf6SRui Paulo  * @sn: target sequence number
76ccf80ddfSLuis Carlos Cobo  * @metric: current metric to this destination
77ccf80ddfSLuis Carlos Cobo  * @hop_count: hops to destination
78ccf80ddfSLuis Carlos Cobo  * @exp_time: in jiffies, when the path will expire or when it expired
79ccf80ddfSLuis Carlos Cobo  * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
80ccf80ddfSLuis Carlos Cobo  * 	retry
81ccf80ddfSLuis Carlos Cobo  * @discovery_retries: number of discovery retries
82ccf80ddfSLuis Carlos Cobo  * @flags: mesh path flags, as specified on &enum mesh_path_flags
83fe583434SJavier Cardona  * @state_lock: mesh path state lock
84ccf80ddfSLuis Carlos Cobo  *
85ccf80ddfSLuis Carlos Cobo  *
86f698d856SJasper Bryant-Greene  * The combination of dst and sdata is unique in the mesh path table. Since the
87d0709a65SJohannes Berg  * next_hop STA is only protected by RCU as well, deleting the STA must also
88d0709a65SJohannes Berg  * remove/substitute the mesh_path structure and wait until that is no longer
89d0709a65SJohannes Berg  * reachable before destroying the STA completely.
90ccf80ddfSLuis Carlos Cobo  */
91ccf80ddfSLuis Carlos Cobo struct mesh_path {
92ccf80ddfSLuis Carlos Cobo 	u8 dst[ETH_ALEN];
9379617deeSYanBo 	u8 mpp[ETH_ALEN];	/* used for MPP or MAP */
94f698d856SJasper Bryant-Greene 	struct ieee80211_sub_if_data *sdata;
95ccf80ddfSLuis Carlos Cobo 	struct sta_info *next_hop;
96ccf80ddfSLuis Carlos Cobo 	struct timer_list timer;
97ccf80ddfSLuis Carlos Cobo 	struct sk_buff_head frame_queue;
98ccf80ddfSLuis Carlos Cobo 	struct rcu_head rcu;
99d19b3bf6SRui Paulo 	u32 sn;
100ccf80ddfSLuis Carlos Cobo 	u32 metric;
101ccf80ddfSLuis Carlos Cobo 	u8 hop_count;
102ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
103ccf80ddfSLuis Carlos Cobo 	u32 discovery_timeout;
104ccf80ddfSLuis Carlos Cobo 	u8 discovery_retries;
105ccf80ddfSLuis Carlos Cobo 	enum mesh_path_flags flags;
106ccf80ddfSLuis Carlos Cobo 	spinlock_t state_lock;
107ccf80ddfSLuis Carlos Cobo };
108ccf80ddfSLuis Carlos Cobo 
109ccf80ddfSLuis Carlos Cobo /**
110ccf80ddfSLuis Carlos Cobo  * struct mesh_table
111ccf80ddfSLuis Carlos Cobo  *
112ccf80ddfSLuis Carlos Cobo  * @hash_buckets: array of hash buckets of the table
113ccf80ddfSLuis Carlos Cobo  * @hashwlock: array of locks to protect write operations, one per bucket
114ccf80ddfSLuis Carlos Cobo  * @hash_mask: 2^size_order - 1, used to compute hash idx
115ccf80ddfSLuis Carlos Cobo  * @hash_rnd: random value used for hash computations
116ccf80ddfSLuis Carlos Cobo  * @entries: number of entries in the table
117ccf80ddfSLuis Carlos Cobo  * @free_node: function to free nodes of the table
118*eef35c2dSStefan Weil  * @copy_node: function to copy nodes of the table
119ccf80ddfSLuis Carlos Cobo  * @size_order: determines size of the table, there will be 2^size_order hash
120ccf80ddfSLuis Carlos Cobo  *	buckets
121ccf80ddfSLuis Carlos Cobo  * @mean_chain_len: maximum average length for the hash buckets' list, if it is
122ccf80ddfSLuis Carlos Cobo  *	reached, the table will grow
123ccf80ddfSLuis Carlos Cobo  */
124ccf80ddfSLuis Carlos Cobo struct mesh_table {
125ccf80ddfSLuis Carlos Cobo 	/* Number of buckets will be 2^N */
126ccf80ddfSLuis Carlos Cobo 	struct hlist_head *hash_buckets;
127ccf80ddfSLuis Carlos Cobo 	spinlock_t *hashwlock;		/* One per bucket, for add/del */
128ccf80ddfSLuis Carlos Cobo 	unsigned int hash_mask;		/* (2^size_order) - 1 */
129ccf80ddfSLuis Carlos Cobo 	__u32 hash_rnd;			/* Used for hash generation */
130ccf80ddfSLuis Carlos Cobo 	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
131ccf80ddfSLuis Carlos Cobo 	void (*free_node) (struct hlist_node *p, bool free_leafs);
1324caf86c6SPavel Emelyanov 	int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
133ccf80ddfSLuis Carlos Cobo 	int size_order;
134ccf80ddfSLuis Carlos Cobo 	int mean_chain_len;
135ccf80ddfSLuis Carlos Cobo };
136ccf80ddfSLuis Carlos Cobo 
137ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */
138ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */
139ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS		256
140ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN	4
141ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT		(3 * HZ)
142ccf80ddfSLuis Carlos Cobo 
143ccf80ddfSLuis Carlos Cobo /**
144ccf80ddfSLuis Carlos Cobo  * struct rmc_entry - entry in the Recent Multicast Cache
145ccf80ddfSLuis Carlos Cobo  *
146ccf80ddfSLuis Carlos Cobo  * @seqnum: mesh sequence number of the frame
147ccf80ddfSLuis Carlos Cobo  * @exp_time: expiration time of the entry, in jiffies
148ccf80ddfSLuis Carlos Cobo  * @sa: source address of the frame
149ccf80ddfSLuis Carlos Cobo  *
150ccf80ddfSLuis Carlos Cobo  * The Recent Multicast Cache keeps track of the latest multicast frames that
151ccf80ddfSLuis Carlos Cobo  * have been received by a mesh interface and discards received multicast frames
152ccf80ddfSLuis Carlos Cobo  * that are found in the cache.
153ccf80ddfSLuis Carlos Cobo  */
154ccf80ddfSLuis Carlos Cobo struct rmc_entry {
155ccf80ddfSLuis Carlos Cobo 	struct list_head list;
156ccf80ddfSLuis Carlos Cobo 	u32 seqnum;
157ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
158ccf80ddfSLuis Carlos Cobo 	u8 sa[ETH_ALEN];
159ccf80ddfSLuis Carlos Cobo };
160ccf80ddfSLuis Carlos Cobo 
161ccf80ddfSLuis Carlos Cobo struct mesh_rmc {
162ccf80ddfSLuis Carlos Cobo 	struct rmc_entry bucket[RMC_BUCKETS];
16351ceddadSLuis Carlos Cobo 	u32 idx_mask;
164ccf80ddfSLuis Carlos Cobo };
165ccf80ddfSLuis Carlos Cobo 
166ccf80ddfSLuis Carlos Cobo 
167ccf80ddfSLuis Carlos Cobo /*
168ccf80ddfSLuis Carlos Cobo  * MESH_CFG_COMP_LEN Includes:
169ccf80ddfSLuis Carlos Cobo  * 	- Active path selection protocol ID.
170ccf80ddfSLuis Carlos Cobo  * 	- Active path selection metric ID.
171ccf80ddfSLuis Carlos Cobo  * 	- Congestion control mode identifier.
172ccf80ddfSLuis Carlos Cobo  * 	- Channel precedence.
173ccf80ddfSLuis Carlos Cobo  * Does not include mesh capabilities, which may vary across nodes in the same
174ccf80ddfSLuis Carlos Cobo  * mesh
175ccf80ddfSLuis Carlos Cobo  */
1761239cd58SJohannes Berg #define MESH_CFG_CMP_LEN 	(IEEE80211_MESH_CONFIG_LEN - 2)
177ccf80ddfSLuis Carlos Cobo 
178ccf80ddfSLuis Carlos Cobo /* Default values, timeouts in ms */
179a1935218SRui Paulo #define MESH_TTL 		31
180ccf80ddfSLuis Carlos Cobo #define MESH_MAX_RETR	 	3
181ccf80ddfSLuis Carlos Cobo #define MESH_RET_T 		100
182ccf80ddfSLuis Carlos Cobo #define MESH_CONF_T 		100
183ccf80ddfSLuis Carlos Cobo #define MESH_HOLD_T 		100
184ccf80ddfSLuis Carlos Cobo 
185ccf80ddfSLuis Carlos Cobo #define MESH_PATH_TIMEOUT	5000
186ccf80ddfSLuis Carlos Cobo /* Minimum interval between two consecutive PREQs originated by the same
187ccf80ddfSLuis Carlos Cobo  * interface
188ccf80ddfSLuis Carlos Cobo  */
189ccf80ddfSLuis Carlos Cobo #define MESH_PREQ_MIN_INT	10
190ccf80ddfSLuis Carlos Cobo #define MESH_DIAM_TRAVERSAL_TIME 50
1917b324d28SJavier Cardona /* A path will be refreshed if it is used PATH_REFRESH_TIME milliseconds before
1927b324d28SJavier Cardona  * timing out.  This way it will remain ACTIVE and no data frames will be
1937b324d28SJavier Cardona  * unnecesarily held in the pending queue.
194ccf80ddfSLuis Carlos Cobo  */
195ccf80ddfSLuis Carlos Cobo #define MESH_PATH_REFRESH_TIME			1000
196ccf80ddfSLuis Carlos Cobo #define MESH_MIN_DISCOVERY_TIMEOUT (2 * MESH_DIAM_TRAVERSAL_TIME)
1975b365834SJavier Cardona #define MESH_DEFAULT_BEACON_INTERVAL		1000 	/* in 1024 us units */
198ccf80ddfSLuis Carlos Cobo 
199ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PREQ_RETRIES 4
200ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ)
201ccf80ddfSLuis Carlos Cobo 
202ccf80ddfSLuis Carlos Cobo /* Default maximum number of established plinks per interface */
203ccf80ddfSLuis Carlos Cobo #define MESH_MAX_ESTAB_PLINKS	32
204ccf80ddfSLuis Carlos Cobo 
205ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */
206ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS		256
207ccf80ddfSLuis Carlos Cobo 
208ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */
209ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS		1024
210ccf80ddfSLuis Carlos Cobo 
211ccf80ddfSLuis Carlos Cobo /* Pending ANA approval */
212095de013SRui Paulo #define MESH_PATH_SEL_ACTION	0
213ccf80ddfSLuis Carlos Cobo 
214d611f062SRui Paulo /* PERR reason codes */
215d611f062SRui Paulo #define PEER_RCODE_UNSPECIFIED  11
216d611f062SRui Paulo #define PERR_RCODE_NO_ROUTE     12
217d611f062SRui Paulo #define PERR_RCODE_DEST_UNREACH 13
218d611f062SRui Paulo 
219ccf80ddfSLuis Carlos Cobo /* Public interfaces */
220ccf80ddfSLuis Carlos Cobo /* Various */
2213c5772a5SJavier Cardona int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
22215ff6365SJohannes Berg 				  const u8 *da, const u8 *sa);
223ccf80ddfSLuis Carlos Cobo int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
2243c5772a5SJavier Cardona 		struct ieee80211_sub_if_data *sdata, char *addr4,
2253c5772a5SJavier Cardona 		char *addr5, char *addr6);
226ccf80ddfSLuis Carlos Cobo int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
227f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
228f698d856SJasper Bryant-Greene bool mesh_matches_local(struct ieee802_11_elems *ie,
229f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
230472dbc45SJohannes Berg void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
231f698d856SJasper Bryant-Greene void mesh_mgmt_ies_add(struct sk_buff *skb,
232f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
233f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
234f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
235ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void);
236bfc32e6aSJavier Cardona void ieee80211s_update_metric(struct ieee80211_local *local,
237bfc32e6aSJavier Cardona 		struct sta_info *stainfo, struct sk_buff *skb);
238ccf80ddfSLuis Carlos Cobo void ieee80211s_stop(void);
239902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
240472dbc45SJohannes Berg void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
241472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
24263c5723bSRui Paulo void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
243902acc78SJohannes Berg 
244ccf80ddfSLuis Carlos Cobo /* Mesh paths */
245f698d856SJasper Bryant-Greene int mesh_nexthop_lookup(struct sk_buff *skb,
246f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
247f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
248f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup(u8 *dst,
249f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
25079617deeSYanBo struct mesh_path *mpp_path_lookup(u8 *dst,
25179617deeSYanBo 				  struct ieee80211_sub_if_data *sdata);
25279617deeSYanBo int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
253f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup_by_idx(int idx,
254f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
255ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
256f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
257f698d856SJasper Bryant-Greene void mesh_path_flush(struct ieee80211_sub_if_data *sdata);
258f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
259f698d856SJasper Bryant-Greene 		struct ieee80211_mgmt *mgmt, size_t len);
260f698d856SJasper Bryant-Greene int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
261ccf80ddfSLuis Carlos Cobo /* Mesh plinks */
262881d948cSJohannes Berg void mesh_neighbour_update(u8 *hw_addr, u32 rates,
263f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata, bool add);
264f698d856SJasper Bryant-Greene bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
265d0709a65SJohannes Berg void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
266ccf80ddfSLuis Carlos Cobo void mesh_plink_broken(struct sta_info *sta);
267ccf80ddfSLuis Carlos Cobo void mesh_plink_deactivate(struct sta_info *sta);
268ccf80ddfSLuis Carlos Cobo int mesh_plink_open(struct sta_info *sta);
269ccf80ddfSLuis Carlos Cobo void mesh_plink_block(struct sta_info *sta);
270f698d856SJasper Bryant-Greene void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
271f698d856SJasper Bryant-Greene 			 struct ieee80211_mgmt *mgmt, size_t len,
272f698d856SJasper Bryant-Greene 			 struct ieee80211_rx_status *rx_status);
273ccf80ddfSLuis Carlos Cobo 
274ccf80ddfSLuis Carlos Cobo /* Private interfaces */
275ccf80ddfSLuis Carlos Cobo /* Mesh tables */
276ccf80ddfSLuis Carlos Cobo struct mesh_table *mesh_table_alloc(int size_order);
277ccf80ddfSLuis Carlos Cobo void mesh_table_free(struct mesh_table *tbl, bool free_leafs);
27818889231SJavier Cardona void mesh_mpath_table_grow(void);
27918889231SJavier Cardona void mesh_mpp_table_grow(void);
280f698d856SJasper Bryant-Greene u32 mesh_table_hash(u8 *addr, struct ieee80211_sub_if_data *sdata,
281f698d856SJasper Bryant-Greene 		struct mesh_table *tbl);
282ccf80ddfSLuis Carlos Cobo /* Mesh paths */
283d19b3bf6SRui Paulo int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
28415ff6365SJohannes Berg 		       const u8 *ra, struct ieee80211_sub_if_data *sdata);
285ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
286ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath);
287ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath);
288ccf80ddfSLuis Carlos Cobo int mesh_pathtbl_init(void);
289ccf80ddfSLuis Carlos Cobo void mesh_pathtbl_unregister(void);
290f698d856SJasper Bryant-Greene int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
291ccf80ddfSLuis Carlos Cobo void mesh_path_timer(unsigned long data);
292ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta);
293f698d856SJasper Bryant-Greene void mesh_path_discard_frame(struct sk_buff *skb,
294f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
2955bb644a0SJohannes Berg void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
2965bb644a0SJohannes Berg void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
297e304bfd3SRui Paulo void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
298ccf80ddfSLuis Carlos Cobo 
299f5ea9120SJohannes Berg extern int mesh_paths_generation;
300f5ea9120SJohannes Berg 
301902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
302902acc78SJohannes Berg extern int mesh_allocated;
303902acc78SJohannes Berg 
304ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
305ccf80ddfSLuis Carlos Cobo {
306472dbc45SJohannes Berg 	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
307472dbc45SJohannes Berg 	       atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
308ccf80ddfSLuis Carlos Cobo }
309ccf80ddfSLuis Carlos Cobo 
310ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
311ccf80ddfSLuis Carlos Cobo {
312d0709a65SJohannes Berg 	return (min_t(long, mesh_plink_free_count(sdata),
313ccf80ddfSLuis Carlos Cobo 		   MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
314ccf80ddfSLuis Carlos Cobo }
315ccf80ddfSLuis Carlos Cobo 
316ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath)
317ccf80ddfSLuis Carlos Cobo {
318ccf80ddfSLuis Carlos Cobo 	mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
319ccf80ddfSLuis Carlos Cobo }
320ccf80ddfSLuis Carlos Cobo 
321ccf80ddfSLuis Carlos Cobo #define for_each_mesh_entry(x, p, node, i) \
322ccf80ddfSLuis Carlos Cobo 	for (i = 0; i <= x->hash_mask; i++) \
323ccf80ddfSLuis Carlos Cobo 		hlist_for_each_entry_rcu(node, p, &x->hash_buckets[i], list)
324ccf80ddfSLuis Carlos Cobo 
325472dbc45SJohannes Berg void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
326472dbc45SJohannes Berg 
3275bb644a0SJohannes Berg void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata);
3285bb644a0SJohannes Berg void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata);
3295bb644a0SJohannes Berg void mesh_plink_quiesce(struct sta_info *sta);
3305bb644a0SJohannes Berg void mesh_plink_restart(struct sta_info *sta);
331902acc78SJohannes Berg #else
332902acc78SJohannes Berg #define mesh_allocated	0
333472dbc45SJohannes Berg static inline void
334472dbc45SJohannes Berg ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
3355bb644a0SJohannes Berg static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
3365bb644a0SJohannes Berg {}
3375bb644a0SJohannes Berg static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
3385bb644a0SJohannes Berg {}
3395bb644a0SJohannes Berg static inline void mesh_plink_quiesce(struct sta_info *sta) {}
3405bb644a0SJohannes Berg static inline void mesh_plink_restart(struct sta_info *sta) {}
341902acc78SJohannes Berg #endif
342902acc78SJohannes Berg 
343ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */
344