xref: /linux/net/mac80211/mesh.h (revision b7cfcd113ac2a1e6b02afc7d283295729fc178a9)
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>
16902acc78SJohannes Berg #include "ieee80211_i.h"
17ccf80ddfSLuis Carlos Cobo 
18ccf80ddfSLuis Carlos Cobo 
19ccf80ddfSLuis Carlos Cobo /* Data structures */
20ccf80ddfSLuis Carlos Cobo 
21ccf80ddfSLuis Carlos Cobo /**
22ccf80ddfSLuis Carlos Cobo  * enum mesh_path_flags - mac80211 mesh path flags
23ccf80ddfSLuis Carlos Cobo  *
24ccf80ddfSLuis Carlos Cobo  *
25ccf80ddfSLuis Carlos Cobo  *
26eb80ed8dSRami Rosen  * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding
27eb80ed8dSRami Rosen  * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path
28d19b3bf6SRui Paulo  * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence
29ccf80ddfSLuis Carlos Cobo  * 	number
30ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_FIXED: the mesh path has been manually set and should not be
31ccf80ddfSLuis Carlos Cobo  * 	modified
32ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_RESOLVED: the mesh path can has been resolved
33f3011cf9SJavier Cardona  * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
34f3011cf9SJavier Cardona  * already queued up, waiting for the discovery process to start.
35ccf80ddfSLuis Carlos Cobo  *
36eb80ed8dSRami Rosen  * MESH_PATH_RESOLVED is used by the mesh path timer to
37ccf80ddfSLuis Carlos Cobo  * decide when to stop or cancel the mesh path discovery.
38ccf80ddfSLuis Carlos Cobo  */
39ccf80ddfSLuis Carlos Cobo enum mesh_path_flags {
40ccf80ddfSLuis Carlos Cobo 	MESH_PATH_ACTIVE =	BIT(0),
41ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVING =	BIT(1),
42d19b3bf6SRui Paulo 	MESH_PATH_SN_VALID =	BIT(2),
43ccf80ddfSLuis Carlos Cobo 	MESH_PATH_FIXED	=	BIT(3),
44ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVED =	BIT(4),
45f3011cf9SJavier Cardona 	MESH_PATH_REQ_QUEUED =	BIT(5),
46ccf80ddfSLuis Carlos Cobo };
47ccf80ddfSLuis Carlos Cobo 
48ccf80ddfSLuis Carlos Cobo /**
4918889231SJavier Cardona  * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks
5018889231SJavier Cardona  *
5118889231SJavier Cardona  *
5218889231SJavier Cardona  *
5318889231SJavier Cardona  * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
5418889231SJavier Cardona  * @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs
5518889231SJavier Cardona  * to grow.
5618889231SJavier Cardona  * @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to
5718889231SJavier Cardona  * grow
58e304bfd3SRui Paulo  * @MESH_WORK_ROOT: the mesh root station needs to send a frame
59dbf498fbSJavier Cardona  * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
60dbf498fbSJavier Cardona  * mesh nodes
6118889231SJavier Cardona  */
6218889231SJavier Cardona enum mesh_deferred_task_flags {
6318889231SJavier Cardona 	MESH_WORK_HOUSEKEEPING,
6418889231SJavier Cardona 	MESH_WORK_GROW_MPATH_TABLE,
6518889231SJavier Cardona 	MESH_WORK_GROW_MPP_TABLE,
66e304bfd3SRui Paulo 	MESH_WORK_ROOT,
67dbf498fbSJavier Cardona 	MESH_WORK_DRIFT_ADJUST,
6818889231SJavier Cardona };
6918889231SJavier Cardona 
7018889231SJavier Cardona /**
71ccf80ddfSLuis Carlos Cobo  * struct mesh_path - mac80211 mesh path structure
72ccf80ddfSLuis Carlos Cobo  *
73ccf80ddfSLuis Carlos Cobo  * @dst: mesh path destination mac address
74f698d856SJasper Bryant-Greene  * @sdata: mesh subif
75ccf80ddfSLuis Carlos Cobo  * @next_hop: mesh neighbor to which frames for this destination will be
76ccf80ddfSLuis Carlos Cobo  * 	forwarded
77ccf80ddfSLuis Carlos Cobo  * @timer: mesh path discovery timer
78ccf80ddfSLuis Carlos Cobo  * @frame_queue: pending queue for frames sent to this destination while the
79ccf80ddfSLuis Carlos Cobo  * 	path is unresolved
80d19b3bf6SRui Paulo  * @sn: target sequence number
81ccf80ddfSLuis Carlos Cobo  * @metric: current metric to this destination
82ccf80ddfSLuis Carlos Cobo  * @hop_count: hops to destination
83ccf80ddfSLuis Carlos Cobo  * @exp_time: in jiffies, when the path will expire or when it expired
84ccf80ddfSLuis Carlos Cobo  * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
85ccf80ddfSLuis Carlos Cobo  * 	retry
86ccf80ddfSLuis Carlos Cobo  * @discovery_retries: number of discovery retries
87ccf80ddfSLuis Carlos Cobo  * @flags: mesh path flags, as specified on &enum mesh_path_flags
88f5e50cd0SJavier Cardona  * @state_lock: mesh path state lock used to protect changes to the
89f5e50cd0SJavier Cardona  * mpath itself.  No need to take this lock when adding or removing
90f5e50cd0SJavier Cardona  * an mpath to a hash bucket on a path table.
913d045a54SChun-Yeow Yeoh  * @rann_snd_addr: the RANN sender address
92d2a079fdSChun-Yeow Yeoh  * @rann_metric: the aggregated path metric towards the root node
93728b19e5SChun-Yeow Yeoh  * @last_preq_to_root: Timestamp of last PREQ sent to root
943d045a54SChun-Yeow Yeoh  * @is_root: the destination station of this path is a root node
955ee68e5bSJavier Cardona  * @is_gate: the destination station of this path is a mesh gate
96ccf80ddfSLuis Carlos Cobo  *
97ccf80ddfSLuis Carlos Cobo  *
98f698d856SJasper Bryant-Greene  * The combination of dst and sdata is unique in the mesh path table. Since the
99d0709a65SJohannes Berg  * next_hop STA is only protected by RCU as well, deleting the STA must also
100d0709a65SJohannes Berg  * remove/substitute the mesh_path structure and wait until that is no longer
101d0709a65SJohannes Berg  * reachable before destroying the STA completely.
102ccf80ddfSLuis Carlos Cobo  */
103ccf80ddfSLuis Carlos Cobo struct mesh_path {
104ccf80ddfSLuis Carlos Cobo 	u8 dst[ETH_ALEN];
10579617deeSYanBo 	u8 mpp[ETH_ALEN];	/* used for MPP or MAP */
106f698d856SJasper Bryant-Greene 	struct ieee80211_sub_if_data *sdata;
10740b275b6SJohannes Berg 	struct sta_info __rcu *next_hop;
108ccf80ddfSLuis Carlos Cobo 	struct timer_list timer;
109ccf80ddfSLuis Carlos Cobo 	struct sk_buff_head frame_queue;
110ccf80ddfSLuis Carlos Cobo 	struct rcu_head rcu;
111d19b3bf6SRui Paulo 	u32 sn;
112ccf80ddfSLuis Carlos Cobo 	u32 metric;
113ccf80ddfSLuis Carlos Cobo 	u8 hop_count;
114ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
115ccf80ddfSLuis Carlos Cobo 	u32 discovery_timeout;
116ccf80ddfSLuis Carlos Cobo 	u8 discovery_retries;
117ccf80ddfSLuis Carlos Cobo 	enum mesh_path_flags flags;
118ccf80ddfSLuis Carlos Cobo 	spinlock_t state_lock;
1193d045a54SChun-Yeow Yeoh 	u8 rann_snd_addr[ETH_ALEN];
120d2a079fdSChun-Yeow Yeoh 	u32 rann_metric;
121728b19e5SChun-Yeow Yeoh 	unsigned long last_preq_to_root;
1223d045a54SChun-Yeow Yeoh 	bool is_root;
1235ee68e5bSJavier Cardona 	bool is_gate;
124ccf80ddfSLuis Carlos Cobo };
125ccf80ddfSLuis Carlos Cobo 
126ccf80ddfSLuis Carlos Cobo /**
127ccf80ddfSLuis Carlos Cobo  * struct mesh_table
128ccf80ddfSLuis Carlos Cobo  *
129ccf80ddfSLuis Carlos Cobo  * @hash_buckets: array of hash buckets of the table
130ccf80ddfSLuis Carlos Cobo  * @hashwlock: array of locks to protect write operations, one per bucket
131ccf80ddfSLuis Carlos Cobo  * @hash_mask: 2^size_order - 1, used to compute hash idx
132ccf80ddfSLuis Carlos Cobo  * @hash_rnd: random value used for hash computations
133ccf80ddfSLuis Carlos Cobo  * @entries: number of entries in the table
134ccf80ddfSLuis Carlos Cobo  * @free_node: function to free nodes of the table
135eef35c2dSStefan Weil  * @copy_node: function to copy nodes of the table
136ccf80ddfSLuis Carlos Cobo  * @size_order: determines size of the table, there will be 2^size_order hash
137ccf80ddfSLuis Carlos Cobo  *	buckets
138ccf80ddfSLuis Carlos Cobo  * @mean_chain_len: maximum average length for the hash buckets' list, if it is
139ccf80ddfSLuis Carlos Cobo  *	reached, the table will grow
1405ee68e5bSJavier Cardona  * @known_gates: list of known mesh gates and their mpaths by the station. The
1415ee68e5bSJavier Cardona  * gate's mpath may or may not be resolved and active.
1425ee68e5bSJavier Cardona  *
1431928ecabSJohannes Berg  * rcu_head: RCU head to free the table
144ccf80ddfSLuis Carlos Cobo  */
145ccf80ddfSLuis Carlos Cobo struct mesh_table {
146ccf80ddfSLuis Carlos Cobo 	/* Number of buckets will be 2^N */
147ccf80ddfSLuis Carlos Cobo 	struct hlist_head *hash_buckets;
148ccf80ddfSLuis Carlos Cobo 	spinlock_t *hashwlock;		/* One per bucket, for add/del */
149ccf80ddfSLuis Carlos Cobo 	unsigned int hash_mask;		/* (2^size_order) - 1 */
150ccf80ddfSLuis Carlos Cobo 	__u32 hash_rnd;			/* Used for hash generation */
151ccf80ddfSLuis Carlos Cobo 	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
152ccf80ddfSLuis Carlos Cobo 	void (*free_node) (struct hlist_node *p, bool free_leafs);
1534caf86c6SPavel Emelyanov 	int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
154ccf80ddfSLuis Carlos Cobo 	int size_order;
155ccf80ddfSLuis Carlos Cobo 	int mean_chain_len;
1565ee68e5bSJavier Cardona 	struct hlist_head *known_gates;
1575ee68e5bSJavier Cardona 	spinlock_t gates_lock;
1581928ecabSJohannes Berg 
1591928ecabSJohannes Berg 	struct rcu_head rcu_head;
160ccf80ddfSLuis Carlos Cobo };
161ccf80ddfSLuis Carlos Cobo 
162ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */
163ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */
164ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS		256
165ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN	4
166ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT		(3 * HZ)
167ccf80ddfSLuis Carlos Cobo 
168ccf80ddfSLuis Carlos Cobo /**
169ccf80ddfSLuis Carlos Cobo  * struct rmc_entry - entry in the Recent Multicast Cache
170ccf80ddfSLuis Carlos Cobo  *
171ccf80ddfSLuis Carlos Cobo  * @seqnum: mesh sequence number of the frame
172ccf80ddfSLuis Carlos Cobo  * @exp_time: expiration time of the entry, in jiffies
173ccf80ddfSLuis Carlos Cobo  * @sa: source address of the frame
174ccf80ddfSLuis Carlos Cobo  *
175ccf80ddfSLuis Carlos Cobo  * The Recent Multicast Cache keeps track of the latest multicast frames that
176ccf80ddfSLuis Carlos Cobo  * have been received by a mesh interface and discards received multicast frames
177ccf80ddfSLuis Carlos Cobo  * that are found in the cache.
178ccf80ddfSLuis Carlos Cobo  */
179ccf80ddfSLuis Carlos Cobo struct rmc_entry {
180ccf80ddfSLuis Carlos Cobo 	struct list_head list;
181ccf80ddfSLuis Carlos Cobo 	u32 seqnum;
182ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
183ccf80ddfSLuis Carlos Cobo 	u8 sa[ETH_ALEN];
184ccf80ddfSLuis Carlos Cobo };
185ccf80ddfSLuis Carlos Cobo 
186ccf80ddfSLuis Carlos Cobo struct mesh_rmc {
187*b7cfcd11SThomas Pedersen 	struct list_head bucket[RMC_BUCKETS];
18851ceddadSLuis Carlos Cobo 	u32 idx_mask;
189ccf80ddfSLuis Carlos Cobo };
190ccf80ddfSLuis Carlos Cobo 
19125d49e4dSThomas Pedersen #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ)
19225d49e4dSThomas Pedersen #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
193ccf80ddfSLuis Carlos Cobo 
1945b365834SJavier Cardona #define MESH_DEFAULT_BEACON_INTERVAL		1000 	/* in 1024 us units */
195ccf80ddfSLuis Carlos Cobo 
196ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ)
197ccf80ddfSLuis Carlos Cobo 
198ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */
199ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS		256
200ccf80ddfSLuis Carlos Cobo 
201ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */
202ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS		1024
203ccf80ddfSLuis Carlos Cobo 
2044bd4c2ddSThomas Pedersen /* Number of frames buffered per destination for unresolved destinations */
2054bd4c2ddSThomas Pedersen #define MESH_FRAME_QUEUE_LEN	10
2064bd4c2ddSThomas Pedersen 
207ccf80ddfSLuis Carlos Cobo /* Public interfaces */
208ccf80ddfSLuis Carlos Cobo /* Various */
2093c5772a5SJavier Cardona int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
21015ff6365SJohannes Berg 				  const u8 *da, const u8 *sa);
211ccf80ddfSLuis Carlos Cobo int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
21261ad5394SJavier Cardona 		struct ieee80211_sub_if_data *sdata, char *addr4or5,
21361ad5394SJavier Cardona 		char *addr6);
214ccf80ddfSLuis Carlos Cobo int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
215f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
216f743ff49SThomas Pedersen bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
217f743ff49SThomas Pedersen 			struct ieee802_11_elems *ie);
218472dbc45SJohannes Berg void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
219f698d856SJasper Bryant-Greene void mesh_mgmt_ies_add(struct sk_buff *skb,
220f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
221082ebb0cSThomas Pedersen int mesh_add_meshconf_ie(struct sk_buff *skb,
222082ebb0cSThomas Pedersen 			 struct ieee80211_sub_if_data *sdata);
223082ebb0cSThomas Pedersen int mesh_add_meshid_ie(struct sk_buff *skb,
224082ebb0cSThomas Pedersen 		       struct ieee80211_sub_if_data *sdata);
225082ebb0cSThomas Pedersen int mesh_add_rsn_ie(struct sk_buff *skb,
226082ebb0cSThomas Pedersen 		    struct ieee80211_sub_if_data *sdata);
227082ebb0cSThomas Pedersen int mesh_add_vendor_ies(struct sk_buff *skb,
228082ebb0cSThomas Pedersen 			struct ieee80211_sub_if_data *sdata);
229082ebb0cSThomas Pedersen int mesh_add_ds_params_ie(struct sk_buff *skb,
230082ebb0cSThomas Pedersen 			  struct ieee80211_sub_if_data *sdata);
231176f3608SThomas Pedersen int mesh_add_ht_cap_ie(struct sk_buff *skb,
232176f3608SThomas Pedersen 		       struct ieee80211_sub_if_data *sdata);
233074d46d1SJohannes Berg int mesh_add_ht_oper_ie(struct sk_buff *skb,
234176f3608SThomas Pedersen 			struct ieee80211_sub_if_data *sdata);
235f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
236f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
237ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void);
238bfc32e6aSJavier Cardona void ieee80211s_update_metric(struct ieee80211_local *local,
23935b3fe1cSJavier Cardona 		struct sta_info *sta, struct sk_buff *skb);
240ccf80ddfSLuis Carlos Cobo void ieee80211s_stop(void);
241902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
242472dbc45SJohannes Berg void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
243472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
24463c5723bSRui Paulo void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
2458ba7acf3SJohannes Berg const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
246902acc78SJohannes Berg 
247ccf80ddfSLuis Carlos Cobo /* Mesh paths */
248f698d856SJasper Bryant-Greene int mesh_nexthop_lookup(struct sk_buff *skb,
249f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
2500cfda851SThomas Pedersen int mesh_nexthop_resolve(struct sk_buff *skb,
2510cfda851SThomas Pedersen 			 struct ieee80211_sub_if_data *sdata);
252f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
253f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup(u8 *dst,
254f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
25579617deeSYanBo struct mesh_path *mpp_path_lookup(u8 *dst,
25679617deeSYanBo 				  struct ieee80211_sub_if_data *sdata);
25779617deeSYanBo int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
258f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup_by_idx(int idx,
259f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
260ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
261f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
262f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
263f698d856SJasper Bryant-Greene 		struct ieee80211_mgmt *mgmt, size_t len);
264f698d856SJasper Bryant-Greene int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
2655ee68e5bSJavier Cardona 
2665ee68e5bSJavier Cardona int mesh_path_add_gate(struct mesh_path *mpath);
2675ee68e5bSJavier Cardona int mesh_path_send_to_gates(struct mesh_path *mpath);
2685ee68e5bSJavier Cardona int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
269ccf80ddfSLuis Carlos Cobo /* Mesh plinks */
270f743ff49SThomas Pedersen void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
271f743ff49SThomas Pedersen 			   u8 *hw_addr,
2721570ca59SJavier Cardona 			   struct ieee802_11_elems *ie);
273f698d856SJasper Bryant-Greene bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
274df323818SMarco Porsch u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
275ccf80ddfSLuis Carlos Cobo void mesh_plink_broken(struct sta_info *sta);
276ccf80ddfSLuis Carlos Cobo void mesh_plink_deactivate(struct sta_info *sta);
277ccf80ddfSLuis Carlos Cobo int mesh_plink_open(struct sta_info *sta);
278ccf80ddfSLuis Carlos Cobo void mesh_plink_block(struct sta_info *sta);
279f698d856SJasper Bryant-Greene void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
280f698d856SJasper Bryant-Greene 			 struct ieee80211_mgmt *mgmt, size_t len,
281f698d856SJasper Bryant-Greene 			 struct ieee80211_rx_status *rx_status);
282ccf80ddfSLuis Carlos Cobo 
283ccf80ddfSLuis Carlos Cobo /* Private interfaces */
284ccf80ddfSLuis Carlos Cobo /* Mesh tables */
28518889231SJavier Cardona void mesh_mpath_table_grow(void);
28618889231SJavier Cardona void mesh_mpp_table_grow(void);
287ccf80ddfSLuis Carlos Cobo /* Mesh paths */
288d19b3bf6SRui Paulo int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
28915ff6365SJohannes Berg 		       const u8 *ra, struct ieee80211_sub_if_data *sdata);
290ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
291ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath);
292ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath);
293ccf80ddfSLuis Carlos Cobo int mesh_pathtbl_init(void);
294ccf80ddfSLuis Carlos Cobo void mesh_pathtbl_unregister(void);
295f698d856SJasper Bryant-Greene int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
296ccf80ddfSLuis Carlos Cobo void mesh_path_timer(unsigned long data);
297ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta);
298f698d856SJasper Bryant-Greene void mesh_path_discard_frame(struct sk_buff *skb,
299f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
3005bb644a0SJohannes Berg void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
3015bb644a0SJohannes Berg void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
302e304bfd3SRui Paulo void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
303ccf80ddfSLuis Carlos Cobo 
30425d49e4dSThomas Pedersen bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
305f5ea9120SJohannes Berg extern int mesh_paths_generation;
306f5ea9120SJohannes Berg 
307902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
308902acc78SJohannes Berg extern int mesh_allocated;
309902acc78SJohannes Berg 
310ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
311ccf80ddfSLuis Carlos Cobo {
312472dbc45SJohannes Berg 	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
3131258d976SAshok Nagarajan 	       atomic_read(&sdata->u.mesh.estab_plinks);
314ccf80ddfSLuis Carlos Cobo }
315ccf80ddfSLuis Carlos Cobo 
316ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
317ccf80ddfSLuis Carlos Cobo {
318d0709a65SJohannes Berg 	return (min_t(long, mesh_plink_free_count(sdata),
319ccf80ddfSLuis Carlos Cobo 		   MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
320ccf80ddfSLuis Carlos Cobo }
321ccf80ddfSLuis Carlos Cobo 
322ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath)
323ccf80ddfSLuis Carlos Cobo {
324ccf80ddfSLuis Carlos Cobo 	mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
325ccf80ddfSLuis Carlos Cobo }
326ccf80ddfSLuis Carlos Cobo 
327c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
328c7108a71SJavier Cardona {
329c7108a71SJavier Cardona 	return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
330c7108a71SJavier Cardona }
331c7108a71SJavier Cardona 
332472dbc45SJohannes Berg void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
333472dbc45SJohannes Berg 
3345bb644a0SJohannes Berg void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata);
3355bb644a0SJohannes Berg void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata);
3365bb644a0SJohannes Berg void mesh_plink_quiesce(struct sta_info *sta);
3375bb644a0SJohannes Berg void mesh_plink_restart(struct sta_info *sta);
33894c514feSAndrei Emeltchenko void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
339dbf498fbSJavier Cardona void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata);
340902acc78SJohannes Berg #else
341902acc78SJohannes Berg #define mesh_allocated	0
342472dbc45SJohannes Berg static inline void
343472dbc45SJohannes Berg ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
3445bb644a0SJohannes Berg static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
3455bb644a0SJohannes Berg {}
3465bb644a0SJohannes Berg static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
3475bb644a0SJohannes Berg {}
3485bb644a0SJohannes Berg static inline void mesh_plink_quiesce(struct sta_info *sta) {}
3495bb644a0SJohannes Berg static inline void mesh_plink_restart(struct sta_info *sta) {}
350c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
351c7108a71SJavier Cardona { return false; }
35294c514feSAndrei Emeltchenko static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
35394c514feSAndrei Emeltchenko {}
354902acc78SJohannes Berg #endif
355902acc78SJohannes Berg 
356ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */
357