xref: /linux/net/mac80211/mesh.h (revision 0cfda8519c85eb279166fb55a8553ee66eac9b35)
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
34f3011cf9SJavier Cardona  * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
35f3011cf9SJavier Cardona  * already queued up, waiting for the discovery process to start.
36ccf80ddfSLuis Carlos Cobo  *
37eb80ed8dSRami Rosen  * MESH_PATH_RESOLVED is used by the mesh path timer to
38ccf80ddfSLuis Carlos Cobo  * decide when to stop or cancel the mesh path discovery.
39ccf80ddfSLuis Carlos Cobo  */
40ccf80ddfSLuis Carlos Cobo enum mesh_path_flags {
41ccf80ddfSLuis Carlos Cobo 	MESH_PATH_ACTIVE =	BIT(0),
42ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVING =	BIT(1),
43d19b3bf6SRui Paulo 	MESH_PATH_SN_VALID =	BIT(2),
44ccf80ddfSLuis Carlos Cobo 	MESH_PATH_FIXED	=	BIT(3),
45ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVED =	BIT(4),
46f3011cf9SJavier Cardona 	MESH_PATH_REQ_QUEUED =	BIT(5),
47ccf80ddfSLuis Carlos Cobo };
48ccf80ddfSLuis Carlos Cobo 
49ccf80ddfSLuis Carlos Cobo /**
5018889231SJavier Cardona  * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks
5118889231SJavier Cardona  *
5218889231SJavier Cardona  *
5318889231SJavier Cardona  *
5418889231SJavier Cardona  * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
5518889231SJavier Cardona  * @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs
5618889231SJavier Cardona  * to grow.
5718889231SJavier Cardona  * @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to
5818889231SJavier Cardona  * grow
59e304bfd3SRui Paulo  * @MESH_WORK_ROOT: the mesh root station needs to send a frame
6018889231SJavier Cardona  */
6118889231SJavier Cardona enum mesh_deferred_task_flags {
6218889231SJavier Cardona 	MESH_WORK_HOUSEKEEPING,
6318889231SJavier Cardona 	MESH_WORK_GROW_MPATH_TABLE,
6418889231SJavier Cardona 	MESH_WORK_GROW_MPP_TABLE,
65e304bfd3SRui Paulo 	MESH_WORK_ROOT,
6618889231SJavier Cardona };
6718889231SJavier Cardona 
6818889231SJavier Cardona /**
69ccf80ddfSLuis Carlos Cobo  * struct mesh_path - mac80211 mesh path structure
70ccf80ddfSLuis Carlos Cobo  *
71ccf80ddfSLuis Carlos Cobo  * @dst: mesh path destination mac address
72f698d856SJasper Bryant-Greene  * @sdata: mesh subif
73ccf80ddfSLuis Carlos Cobo  * @next_hop: mesh neighbor to which frames for this destination will be
74ccf80ddfSLuis Carlos Cobo  * 	forwarded
75ccf80ddfSLuis Carlos Cobo  * @timer: mesh path discovery timer
76ccf80ddfSLuis Carlos Cobo  * @frame_queue: pending queue for frames sent to this destination while the
77ccf80ddfSLuis Carlos Cobo  * 	path is unresolved
78d19b3bf6SRui Paulo  * @sn: target sequence number
79ccf80ddfSLuis Carlos Cobo  * @metric: current metric to this destination
80ccf80ddfSLuis Carlos Cobo  * @hop_count: hops to destination
81ccf80ddfSLuis Carlos Cobo  * @exp_time: in jiffies, when the path will expire or when it expired
82ccf80ddfSLuis Carlos Cobo  * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
83ccf80ddfSLuis Carlos Cobo  * 	retry
84ccf80ddfSLuis Carlos Cobo  * @discovery_retries: number of discovery retries
85ccf80ddfSLuis Carlos Cobo  * @flags: mesh path flags, as specified on &enum mesh_path_flags
86f5e50cd0SJavier Cardona  * @state_lock: mesh path state lock used to protect changes to the
87f5e50cd0SJavier Cardona  * mpath itself.  No need to take this lock when adding or removing
88f5e50cd0SJavier Cardona  * an mpath to a hash bucket on a path table.
895ee68e5bSJavier Cardona  * @is_gate: the destination station of this path is a mesh gate
90ccf80ddfSLuis Carlos Cobo  *
91ccf80ddfSLuis Carlos Cobo  *
92f698d856SJasper Bryant-Greene  * The combination of dst and sdata is unique in the mesh path table. Since the
93d0709a65SJohannes Berg  * next_hop STA is only protected by RCU as well, deleting the STA must also
94d0709a65SJohannes Berg  * remove/substitute the mesh_path structure and wait until that is no longer
95d0709a65SJohannes Berg  * reachable before destroying the STA completely.
96ccf80ddfSLuis Carlos Cobo  */
97ccf80ddfSLuis Carlos Cobo struct mesh_path {
98ccf80ddfSLuis Carlos Cobo 	u8 dst[ETH_ALEN];
9979617deeSYanBo 	u8 mpp[ETH_ALEN];	/* used for MPP or MAP */
100f698d856SJasper Bryant-Greene 	struct ieee80211_sub_if_data *sdata;
10140b275b6SJohannes Berg 	struct sta_info __rcu *next_hop;
102ccf80ddfSLuis Carlos Cobo 	struct timer_list timer;
103ccf80ddfSLuis Carlos Cobo 	struct sk_buff_head frame_queue;
104ccf80ddfSLuis Carlos Cobo 	struct rcu_head rcu;
105d19b3bf6SRui Paulo 	u32 sn;
106ccf80ddfSLuis Carlos Cobo 	u32 metric;
107ccf80ddfSLuis Carlos Cobo 	u8 hop_count;
108ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
109ccf80ddfSLuis Carlos Cobo 	u32 discovery_timeout;
110ccf80ddfSLuis Carlos Cobo 	u8 discovery_retries;
111ccf80ddfSLuis Carlos Cobo 	enum mesh_path_flags flags;
112ccf80ddfSLuis Carlos Cobo 	spinlock_t state_lock;
1135ee68e5bSJavier Cardona 	bool is_gate;
114ccf80ddfSLuis Carlos Cobo };
115ccf80ddfSLuis Carlos Cobo 
116ccf80ddfSLuis Carlos Cobo /**
117ccf80ddfSLuis Carlos Cobo  * struct mesh_table
118ccf80ddfSLuis Carlos Cobo  *
119ccf80ddfSLuis Carlos Cobo  * @hash_buckets: array of hash buckets of the table
120ccf80ddfSLuis Carlos Cobo  * @hashwlock: array of locks to protect write operations, one per bucket
121ccf80ddfSLuis Carlos Cobo  * @hash_mask: 2^size_order - 1, used to compute hash idx
122ccf80ddfSLuis Carlos Cobo  * @hash_rnd: random value used for hash computations
123ccf80ddfSLuis Carlos Cobo  * @entries: number of entries in the table
124ccf80ddfSLuis Carlos Cobo  * @free_node: function to free nodes of the table
125eef35c2dSStefan Weil  * @copy_node: function to copy nodes of the table
126ccf80ddfSLuis Carlos Cobo  * @size_order: determines size of the table, there will be 2^size_order hash
127ccf80ddfSLuis Carlos Cobo  *	buckets
128ccf80ddfSLuis Carlos Cobo  * @mean_chain_len: maximum average length for the hash buckets' list, if it is
129ccf80ddfSLuis Carlos Cobo  *	reached, the table will grow
1305ee68e5bSJavier Cardona  * @known_gates: list of known mesh gates and their mpaths by the station. The
1315ee68e5bSJavier Cardona  * gate's mpath may or may not be resolved and active.
1325ee68e5bSJavier Cardona  *
1331928ecabSJohannes Berg  * rcu_head: RCU head to free the table
134ccf80ddfSLuis Carlos Cobo  */
135ccf80ddfSLuis Carlos Cobo struct mesh_table {
136ccf80ddfSLuis Carlos Cobo 	/* Number of buckets will be 2^N */
137ccf80ddfSLuis Carlos Cobo 	struct hlist_head *hash_buckets;
138ccf80ddfSLuis Carlos Cobo 	spinlock_t *hashwlock;		/* One per bucket, for add/del */
139ccf80ddfSLuis Carlos Cobo 	unsigned int hash_mask;		/* (2^size_order) - 1 */
140ccf80ddfSLuis Carlos Cobo 	__u32 hash_rnd;			/* Used for hash generation */
141ccf80ddfSLuis Carlos Cobo 	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
142ccf80ddfSLuis Carlos Cobo 	void (*free_node) (struct hlist_node *p, bool free_leafs);
1434caf86c6SPavel Emelyanov 	int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
144ccf80ddfSLuis Carlos Cobo 	int size_order;
145ccf80ddfSLuis Carlos Cobo 	int mean_chain_len;
1465ee68e5bSJavier Cardona 	struct hlist_head *known_gates;
1475ee68e5bSJavier Cardona 	spinlock_t gates_lock;
1481928ecabSJohannes Berg 
1491928ecabSJohannes Berg 	struct rcu_head rcu_head;
150ccf80ddfSLuis Carlos Cobo };
151ccf80ddfSLuis Carlos Cobo 
152ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */
153ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */
154ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS		256
155ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN	4
156ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT		(3 * HZ)
157ccf80ddfSLuis Carlos Cobo 
158ccf80ddfSLuis Carlos Cobo /**
159ccf80ddfSLuis Carlos Cobo  * struct rmc_entry - entry in the Recent Multicast Cache
160ccf80ddfSLuis Carlos Cobo  *
161ccf80ddfSLuis Carlos Cobo  * @seqnum: mesh sequence number of the frame
162ccf80ddfSLuis Carlos Cobo  * @exp_time: expiration time of the entry, in jiffies
163ccf80ddfSLuis Carlos Cobo  * @sa: source address of the frame
164ccf80ddfSLuis Carlos Cobo  *
165ccf80ddfSLuis Carlos Cobo  * The Recent Multicast Cache keeps track of the latest multicast frames that
166ccf80ddfSLuis Carlos Cobo  * have been received by a mesh interface and discards received multicast frames
167ccf80ddfSLuis Carlos Cobo  * that are found in the cache.
168ccf80ddfSLuis Carlos Cobo  */
169ccf80ddfSLuis Carlos Cobo struct rmc_entry {
170ccf80ddfSLuis Carlos Cobo 	struct list_head list;
171ccf80ddfSLuis Carlos Cobo 	u32 seqnum;
172ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
173ccf80ddfSLuis Carlos Cobo 	u8 sa[ETH_ALEN];
174ccf80ddfSLuis Carlos Cobo };
175ccf80ddfSLuis Carlos Cobo 
176ccf80ddfSLuis Carlos Cobo struct mesh_rmc {
177ccf80ddfSLuis Carlos Cobo 	struct rmc_entry bucket[RMC_BUCKETS];
17851ceddadSLuis Carlos Cobo 	u32 idx_mask;
179ccf80ddfSLuis Carlos Cobo };
180ccf80ddfSLuis Carlos Cobo 
18125d49e4dSThomas Pedersen #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ)
18225d49e4dSThomas Pedersen #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
183ccf80ddfSLuis Carlos Cobo 
1845b365834SJavier Cardona #define MESH_DEFAULT_BEACON_INTERVAL		1000 	/* in 1024 us units */
185ccf80ddfSLuis Carlos Cobo 
186ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ)
187ccf80ddfSLuis Carlos Cobo 
188ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */
189ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS		256
190ccf80ddfSLuis Carlos Cobo 
191ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */
192ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS		1024
193ccf80ddfSLuis Carlos Cobo 
194ccf80ddfSLuis Carlos Cobo /* Public interfaces */
195ccf80ddfSLuis Carlos Cobo /* Various */
1963c5772a5SJavier Cardona int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
19715ff6365SJohannes Berg 				  const u8 *da, const u8 *sa);
198ccf80ddfSLuis Carlos Cobo int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
19961ad5394SJavier Cardona 		struct ieee80211_sub_if_data *sdata, char *addr4or5,
20061ad5394SJavier Cardona 		char *addr6);
201ccf80ddfSLuis Carlos Cobo int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
202f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
203f698d856SJasper Bryant-Greene bool mesh_matches_local(struct ieee802_11_elems *ie,
204f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
205472dbc45SJohannes Berg void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
206f698d856SJasper Bryant-Greene void mesh_mgmt_ies_add(struct sk_buff *skb,
207f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
208082ebb0cSThomas Pedersen int mesh_add_meshconf_ie(struct sk_buff *skb,
209082ebb0cSThomas Pedersen 			 struct ieee80211_sub_if_data *sdata);
210082ebb0cSThomas Pedersen int mesh_add_meshid_ie(struct sk_buff *skb,
211082ebb0cSThomas Pedersen 		       struct ieee80211_sub_if_data *sdata);
212082ebb0cSThomas Pedersen int mesh_add_rsn_ie(struct sk_buff *skb,
213082ebb0cSThomas Pedersen 		    struct ieee80211_sub_if_data *sdata);
214082ebb0cSThomas Pedersen int mesh_add_vendor_ies(struct sk_buff *skb,
215082ebb0cSThomas Pedersen 			struct ieee80211_sub_if_data *sdata);
216082ebb0cSThomas Pedersen int mesh_add_ds_params_ie(struct sk_buff *skb,
217082ebb0cSThomas Pedersen 			  struct ieee80211_sub_if_data *sdata);
218176f3608SThomas Pedersen int mesh_add_ht_cap_ie(struct sk_buff *skb,
219176f3608SThomas Pedersen 		       struct ieee80211_sub_if_data *sdata);
220176f3608SThomas Pedersen int mesh_add_ht_info_ie(struct sk_buff *skb,
221176f3608SThomas Pedersen 			struct ieee80211_sub_if_data *sdata);
222f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
223f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
224ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void);
225bfc32e6aSJavier Cardona void ieee80211s_update_metric(struct ieee80211_local *local,
226bfc32e6aSJavier Cardona 		struct sta_info *stainfo, struct sk_buff *skb);
227ccf80ddfSLuis Carlos Cobo void ieee80211s_stop(void);
228902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
229472dbc45SJohannes Berg void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
230472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
23163c5723bSRui Paulo void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
232902acc78SJohannes Berg 
233ccf80ddfSLuis Carlos Cobo /* Mesh paths */
234f698d856SJasper Bryant-Greene int mesh_nexthop_lookup(struct sk_buff *skb,
235f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
236*0cfda851SThomas Pedersen int mesh_nexthop_resolve(struct sk_buff *skb,
237*0cfda851SThomas Pedersen 			 struct ieee80211_sub_if_data *sdata);
238f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
239f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup(u8 *dst,
240f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
24179617deeSYanBo struct mesh_path *mpp_path_lookup(u8 *dst,
24279617deeSYanBo 				  struct ieee80211_sub_if_data *sdata);
24379617deeSYanBo int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
244f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup_by_idx(int idx,
245f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
246ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
247f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
248f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
249f698d856SJasper Bryant-Greene 		struct ieee80211_mgmt *mgmt, size_t len);
250f698d856SJasper Bryant-Greene int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
2515ee68e5bSJavier Cardona 
2525ee68e5bSJavier Cardona int mesh_path_add_gate(struct mesh_path *mpath);
2535ee68e5bSJavier Cardona int mesh_path_send_to_gates(struct mesh_path *mpath);
2545ee68e5bSJavier Cardona int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
255ccf80ddfSLuis Carlos Cobo /* Mesh plinks */
256881d948cSJohannes Berg void mesh_neighbour_update(u8 *hw_addr, u32 rates,
2571570ca59SJavier Cardona 		struct ieee80211_sub_if_data *sdata,
2581570ca59SJavier Cardona 		struct ieee802_11_elems *ie);
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 */
27118889231SJavier Cardona void mesh_mpath_table_grow(void);
27218889231SJavier Cardona void mesh_mpp_table_grow(void);
273ccf80ddfSLuis Carlos Cobo /* Mesh paths */
274d19b3bf6SRui Paulo int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
27515ff6365SJohannes Berg 		       const u8 *ra, struct ieee80211_sub_if_data *sdata);
276ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
277ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath);
278ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath);
279ccf80ddfSLuis Carlos Cobo int mesh_pathtbl_init(void);
280ccf80ddfSLuis Carlos Cobo void mesh_pathtbl_unregister(void);
281f698d856SJasper Bryant-Greene int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
282ccf80ddfSLuis Carlos Cobo void mesh_path_timer(unsigned long data);
283ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta);
284ece1a2e7SJavier Cardona void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
285f698d856SJasper Bryant-Greene void mesh_path_discard_frame(struct sk_buff *skb,
286f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
2875bb644a0SJohannes Berg void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
2885bb644a0SJohannes Berg void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
289e304bfd3SRui Paulo void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
290ccf80ddfSLuis Carlos Cobo 
29125d49e4dSThomas Pedersen bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
292f5ea9120SJohannes Berg extern int mesh_paths_generation;
293f5ea9120SJohannes Berg 
294902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
295902acc78SJohannes Berg extern int mesh_allocated;
296902acc78SJohannes Berg 
297ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
298ccf80ddfSLuis Carlos Cobo {
299472dbc45SJohannes Berg 	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
300472dbc45SJohannes Berg 	       atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
301ccf80ddfSLuis Carlos Cobo }
302ccf80ddfSLuis Carlos Cobo 
303ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
304ccf80ddfSLuis Carlos Cobo {
305d0709a65SJohannes Berg 	return (min_t(long, mesh_plink_free_count(sdata),
306ccf80ddfSLuis Carlos Cobo 		   MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
307ccf80ddfSLuis Carlos Cobo }
308ccf80ddfSLuis Carlos Cobo 
309ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath)
310ccf80ddfSLuis Carlos Cobo {
311ccf80ddfSLuis Carlos Cobo 	mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
312ccf80ddfSLuis Carlos Cobo }
313ccf80ddfSLuis Carlos Cobo 
314c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
315c7108a71SJavier Cardona {
316c7108a71SJavier Cardona 	return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
317c7108a71SJavier Cardona }
318c7108a71SJavier Cardona 
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) {}
335c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
336c7108a71SJavier Cardona { return false; }
337902acc78SJohannes Berg #endif
338902acc78SJohannes Berg 
339ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */
340