xref: /linux/net/mac80211/mesh.h (revision 94c514fe240fc0dd02187b78facefde8b6744634)
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 /**
22dbf498fbSJavier Cardona  * enum mesh_config_capab_flags - mesh config IE capability flags
23dbf498fbSJavier Cardona  *
24dbf498fbSJavier Cardona  * @MESHCONF_CAPAB_ACCEPT_PLINKS: STA is willing to establish
25dbf498fbSJavier Cardona  * additional mesh peerings with other mesh STAs
26dbf498fbSJavier Cardona  * @MESHCONF_CAPAB_FORWARDING: the STA forwards MSDUs
27dbf498fbSJavier Cardona  * @MESHCONF_CAPAB_TBTT_ADJUSTING: TBTT adjustment procedure is ongoing
28dbf498fbSJavier Cardona  */
29dbf498fbSJavier Cardona enum mesh_config_capab_flags {
30dbf498fbSJavier Cardona 	MESHCONF_CAPAB_ACCEPT_PLINKS = BIT(0),
31dbf498fbSJavier Cardona 	MESHCONF_CAPAB_FORWARDING = BIT(3),
32dbf498fbSJavier Cardona 	MESHCONF_CAPAB_TBTT_ADJUSTING = BIT(5),
33dbf498fbSJavier Cardona };
34dbf498fbSJavier Cardona 
35dbf498fbSJavier Cardona /**
36ccf80ddfSLuis Carlos Cobo  * enum mesh_path_flags - mac80211 mesh path flags
37ccf80ddfSLuis Carlos Cobo  *
38ccf80ddfSLuis Carlos Cobo  *
39ccf80ddfSLuis Carlos Cobo  *
40eb80ed8dSRami Rosen  * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding
41eb80ed8dSRami Rosen  * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path
42d19b3bf6SRui Paulo  * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence
43ccf80ddfSLuis Carlos Cobo  * 	number
44ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_FIXED: the mesh path has been manually set and should not be
45ccf80ddfSLuis Carlos Cobo  * 	modified
46ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_RESOLVED: the mesh path can has been resolved
47f3011cf9SJavier Cardona  * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
48f3011cf9SJavier Cardona  * already queued up, waiting for the discovery process to start.
49ccf80ddfSLuis Carlos Cobo  *
50eb80ed8dSRami Rosen  * MESH_PATH_RESOLVED is used by the mesh path timer to
51ccf80ddfSLuis Carlos Cobo  * decide when to stop or cancel the mesh path discovery.
52ccf80ddfSLuis Carlos Cobo  */
53ccf80ddfSLuis Carlos Cobo enum mesh_path_flags {
54ccf80ddfSLuis Carlos Cobo 	MESH_PATH_ACTIVE =	BIT(0),
55ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVING =	BIT(1),
56d19b3bf6SRui Paulo 	MESH_PATH_SN_VALID =	BIT(2),
57ccf80ddfSLuis Carlos Cobo 	MESH_PATH_FIXED	=	BIT(3),
58ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVED =	BIT(4),
59f3011cf9SJavier Cardona 	MESH_PATH_REQ_QUEUED =	BIT(5),
60ccf80ddfSLuis Carlos Cobo };
61ccf80ddfSLuis Carlos Cobo 
62ccf80ddfSLuis Carlos Cobo /**
6318889231SJavier Cardona  * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks
6418889231SJavier Cardona  *
6518889231SJavier Cardona  *
6618889231SJavier Cardona  *
6718889231SJavier Cardona  * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
6818889231SJavier Cardona  * @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs
6918889231SJavier Cardona  * to grow.
7018889231SJavier Cardona  * @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to
7118889231SJavier Cardona  * grow
72e304bfd3SRui Paulo  * @MESH_WORK_ROOT: the mesh root station needs to send a frame
73dbf498fbSJavier Cardona  * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
74dbf498fbSJavier Cardona  * mesh nodes
7518889231SJavier Cardona  */
7618889231SJavier Cardona enum mesh_deferred_task_flags {
7718889231SJavier Cardona 	MESH_WORK_HOUSEKEEPING,
7818889231SJavier Cardona 	MESH_WORK_GROW_MPATH_TABLE,
7918889231SJavier Cardona 	MESH_WORK_GROW_MPP_TABLE,
80e304bfd3SRui Paulo 	MESH_WORK_ROOT,
81dbf498fbSJavier Cardona 	MESH_WORK_DRIFT_ADJUST,
8218889231SJavier Cardona };
8318889231SJavier Cardona 
8418889231SJavier Cardona /**
85ccf80ddfSLuis Carlos Cobo  * struct mesh_path - mac80211 mesh path structure
86ccf80ddfSLuis Carlos Cobo  *
87ccf80ddfSLuis Carlos Cobo  * @dst: mesh path destination mac address
88f698d856SJasper Bryant-Greene  * @sdata: mesh subif
89ccf80ddfSLuis Carlos Cobo  * @next_hop: mesh neighbor to which frames for this destination will be
90ccf80ddfSLuis Carlos Cobo  * 	forwarded
91ccf80ddfSLuis Carlos Cobo  * @timer: mesh path discovery timer
92ccf80ddfSLuis Carlos Cobo  * @frame_queue: pending queue for frames sent to this destination while the
93ccf80ddfSLuis Carlos Cobo  * 	path is unresolved
94d19b3bf6SRui Paulo  * @sn: target sequence number
95ccf80ddfSLuis Carlos Cobo  * @metric: current metric to this destination
96ccf80ddfSLuis Carlos Cobo  * @hop_count: hops to destination
97ccf80ddfSLuis Carlos Cobo  * @exp_time: in jiffies, when the path will expire or when it expired
98ccf80ddfSLuis Carlos Cobo  * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery
99ccf80ddfSLuis Carlos Cobo  * 	retry
100ccf80ddfSLuis Carlos Cobo  * @discovery_retries: number of discovery retries
101ccf80ddfSLuis Carlos Cobo  * @flags: mesh path flags, as specified on &enum mesh_path_flags
102f5e50cd0SJavier Cardona  * @state_lock: mesh path state lock used to protect changes to the
103f5e50cd0SJavier Cardona  * mpath itself.  No need to take this lock when adding or removing
104f5e50cd0SJavier Cardona  * an mpath to a hash bucket on a path table.
1053d045a54SChun-Yeow Yeoh  * @rann_snd_addr: the RANN sender address
106d2a079fdSChun-Yeow Yeoh  * @rann_metric: the aggregated path metric towards the root node
1073d045a54SChun-Yeow Yeoh  * @is_root: the destination station of this path is a root node
1085ee68e5bSJavier Cardona  * @is_gate: the destination station of this path is a mesh gate
109ccf80ddfSLuis Carlos Cobo  *
110ccf80ddfSLuis Carlos Cobo  *
111f698d856SJasper Bryant-Greene  * The combination of dst and sdata is unique in the mesh path table. Since the
112d0709a65SJohannes Berg  * next_hop STA is only protected by RCU as well, deleting the STA must also
113d0709a65SJohannes Berg  * remove/substitute the mesh_path structure and wait until that is no longer
114d0709a65SJohannes Berg  * reachable before destroying the STA completely.
115ccf80ddfSLuis Carlos Cobo  */
116ccf80ddfSLuis Carlos Cobo struct mesh_path {
117ccf80ddfSLuis Carlos Cobo 	u8 dst[ETH_ALEN];
11879617deeSYanBo 	u8 mpp[ETH_ALEN];	/* used for MPP or MAP */
119f698d856SJasper Bryant-Greene 	struct ieee80211_sub_if_data *sdata;
12040b275b6SJohannes Berg 	struct sta_info __rcu *next_hop;
121ccf80ddfSLuis Carlos Cobo 	struct timer_list timer;
122ccf80ddfSLuis Carlos Cobo 	struct sk_buff_head frame_queue;
123ccf80ddfSLuis Carlos Cobo 	struct rcu_head rcu;
124d19b3bf6SRui Paulo 	u32 sn;
125ccf80ddfSLuis Carlos Cobo 	u32 metric;
126ccf80ddfSLuis Carlos Cobo 	u8 hop_count;
127ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
128ccf80ddfSLuis Carlos Cobo 	u32 discovery_timeout;
129ccf80ddfSLuis Carlos Cobo 	u8 discovery_retries;
130ccf80ddfSLuis Carlos Cobo 	enum mesh_path_flags flags;
131ccf80ddfSLuis Carlos Cobo 	spinlock_t state_lock;
1323d045a54SChun-Yeow Yeoh 	u8 rann_snd_addr[ETH_ALEN];
133d2a079fdSChun-Yeow Yeoh 	u32 rann_metric;
1343d045a54SChun-Yeow Yeoh 	bool is_root;
1355ee68e5bSJavier Cardona 	bool is_gate;
136ccf80ddfSLuis Carlos Cobo };
137ccf80ddfSLuis Carlos Cobo 
138ccf80ddfSLuis Carlos Cobo /**
139ccf80ddfSLuis Carlos Cobo  * struct mesh_table
140ccf80ddfSLuis Carlos Cobo  *
141ccf80ddfSLuis Carlos Cobo  * @hash_buckets: array of hash buckets of the table
142ccf80ddfSLuis Carlos Cobo  * @hashwlock: array of locks to protect write operations, one per bucket
143ccf80ddfSLuis Carlos Cobo  * @hash_mask: 2^size_order - 1, used to compute hash idx
144ccf80ddfSLuis Carlos Cobo  * @hash_rnd: random value used for hash computations
145ccf80ddfSLuis Carlos Cobo  * @entries: number of entries in the table
146ccf80ddfSLuis Carlos Cobo  * @free_node: function to free nodes of the table
147eef35c2dSStefan Weil  * @copy_node: function to copy nodes of the table
148ccf80ddfSLuis Carlos Cobo  * @size_order: determines size of the table, there will be 2^size_order hash
149ccf80ddfSLuis Carlos Cobo  *	buckets
150ccf80ddfSLuis Carlos Cobo  * @mean_chain_len: maximum average length for the hash buckets' list, if it is
151ccf80ddfSLuis Carlos Cobo  *	reached, the table will grow
1525ee68e5bSJavier Cardona  * @known_gates: list of known mesh gates and their mpaths by the station. The
1535ee68e5bSJavier Cardona  * gate's mpath may or may not be resolved and active.
1545ee68e5bSJavier Cardona  *
1551928ecabSJohannes Berg  * rcu_head: RCU head to free the table
156ccf80ddfSLuis Carlos Cobo  */
157ccf80ddfSLuis Carlos Cobo struct mesh_table {
158ccf80ddfSLuis Carlos Cobo 	/* Number of buckets will be 2^N */
159ccf80ddfSLuis Carlos Cobo 	struct hlist_head *hash_buckets;
160ccf80ddfSLuis Carlos Cobo 	spinlock_t *hashwlock;		/* One per bucket, for add/del */
161ccf80ddfSLuis Carlos Cobo 	unsigned int hash_mask;		/* (2^size_order) - 1 */
162ccf80ddfSLuis Carlos Cobo 	__u32 hash_rnd;			/* Used for hash generation */
163ccf80ddfSLuis Carlos Cobo 	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
164ccf80ddfSLuis Carlos Cobo 	void (*free_node) (struct hlist_node *p, bool free_leafs);
1654caf86c6SPavel Emelyanov 	int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
166ccf80ddfSLuis Carlos Cobo 	int size_order;
167ccf80ddfSLuis Carlos Cobo 	int mean_chain_len;
1685ee68e5bSJavier Cardona 	struct hlist_head *known_gates;
1695ee68e5bSJavier Cardona 	spinlock_t gates_lock;
1701928ecabSJohannes Berg 
1711928ecabSJohannes Berg 	struct rcu_head rcu_head;
172ccf80ddfSLuis Carlos Cobo };
173ccf80ddfSLuis Carlos Cobo 
174ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */
175ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */
176ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS		256
177ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN	4
178ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT		(3 * HZ)
179ccf80ddfSLuis Carlos Cobo 
180ccf80ddfSLuis Carlos Cobo /**
181ccf80ddfSLuis Carlos Cobo  * struct rmc_entry - entry in the Recent Multicast Cache
182ccf80ddfSLuis Carlos Cobo  *
183ccf80ddfSLuis Carlos Cobo  * @seqnum: mesh sequence number of the frame
184ccf80ddfSLuis Carlos Cobo  * @exp_time: expiration time of the entry, in jiffies
185ccf80ddfSLuis Carlos Cobo  * @sa: source address of the frame
186ccf80ddfSLuis Carlos Cobo  *
187ccf80ddfSLuis Carlos Cobo  * The Recent Multicast Cache keeps track of the latest multicast frames that
188ccf80ddfSLuis Carlos Cobo  * have been received by a mesh interface and discards received multicast frames
189ccf80ddfSLuis Carlos Cobo  * that are found in the cache.
190ccf80ddfSLuis Carlos Cobo  */
191ccf80ddfSLuis Carlos Cobo struct rmc_entry {
192ccf80ddfSLuis Carlos Cobo 	struct list_head list;
193ccf80ddfSLuis Carlos Cobo 	u32 seqnum;
194ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
195ccf80ddfSLuis Carlos Cobo 	u8 sa[ETH_ALEN];
196ccf80ddfSLuis Carlos Cobo };
197ccf80ddfSLuis Carlos Cobo 
198ccf80ddfSLuis Carlos Cobo struct mesh_rmc {
199ccf80ddfSLuis Carlos Cobo 	struct rmc_entry bucket[RMC_BUCKETS];
20051ceddadSLuis Carlos Cobo 	u32 idx_mask;
201ccf80ddfSLuis Carlos Cobo };
202ccf80ddfSLuis Carlos Cobo 
20325d49e4dSThomas Pedersen #define IEEE80211_MESH_PEER_INACTIVITY_LIMIT (1800 * HZ)
20425d49e4dSThomas Pedersen #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
205ccf80ddfSLuis Carlos Cobo 
2065b365834SJavier Cardona #define MESH_DEFAULT_BEACON_INTERVAL		1000 	/* in 1024 us units */
207ccf80ddfSLuis Carlos Cobo 
208ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ)
209ccf80ddfSLuis Carlos Cobo 
210ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */
211ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS		256
212ccf80ddfSLuis Carlos Cobo 
213ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */
214ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS		1024
215ccf80ddfSLuis Carlos Cobo 
216ccf80ddfSLuis Carlos Cobo /* Public interfaces */
217ccf80ddfSLuis Carlos Cobo /* Various */
2183c5772a5SJavier Cardona int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
21915ff6365SJohannes Berg 				  const u8 *da, const u8 *sa);
220ccf80ddfSLuis Carlos Cobo int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
22161ad5394SJavier Cardona 		struct ieee80211_sub_if_data *sdata, char *addr4or5,
22261ad5394SJavier Cardona 		char *addr6);
223ccf80ddfSLuis Carlos Cobo int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
224f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
225f743ff49SThomas Pedersen bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
226f743ff49SThomas Pedersen 			struct ieee802_11_elems *ie);
227472dbc45SJohannes Berg void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
228f698d856SJasper Bryant-Greene void mesh_mgmt_ies_add(struct sk_buff *skb,
229f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
230082ebb0cSThomas Pedersen int mesh_add_meshconf_ie(struct sk_buff *skb,
231082ebb0cSThomas Pedersen 			 struct ieee80211_sub_if_data *sdata);
232082ebb0cSThomas Pedersen int mesh_add_meshid_ie(struct sk_buff *skb,
233082ebb0cSThomas Pedersen 		       struct ieee80211_sub_if_data *sdata);
234082ebb0cSThomas Pedersen int mesh_add_rsn_ie(struct sk_buff *skb,
235082ebb0cSThomas Pedersen 		    struct ieee80211_sub_if_data *sdata);
236082ebb0cSThomas Pedersen int mesh_add_vendor_ies(struct sk_buff *skb,
237082ebb0cSThomas Pedersen 			struct ieee80211_sub_if_data *sdata);
238082ebb0cSThomas Pedersen int mesh_add_ds_params_ie(struct sk_buff *skb,
239082ebb0cSThomas Pedersen 			  struct ieee80211_sub_if_data *sdata);
240176f3608SThomas Pedersen int mesh_add_ht_cap_ie(struct sk_buff *skb,
241176f3608SThomas Pedersen 		       struct ieee80211_sub_if_data *sdata);
242074d46d1SJohannes Berg int mesh_add_ht_oper_ie(struct sk_buff *skb,
243176f3608SThomas Pedersen 			struct ieee80211_sub_if_data *sdata);
244f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
245f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
246ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void);
247bfc32e6aSJavier Cardona void ieee80211s_update_metric(struct ieee80211_local *local,
248bfc32e6aSJavier Cardona 		struct sta_info *stainfo, struct sk_buff *skb);
249ccf80ddfSLuis Carlos Cobo void ieee80211s_stop(void);
250902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
251472dbc45SJohannes Berg void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
252472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
25363c5723bSRui Paulo void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
254dbf498fbSJavier Cardona struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
255902acc78SJohannes Berg 
256ccf80ddfSLuis Carlos Cobo /* Mesh paths */
257f698d856SJasper Bryant-Greene int mesh_nexthop_lookup(struct sk_buff *skb,
258f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
2590cfda851SThomas Pedersen int mesh_nexthop_resolve(struct sk_buff *skb,
2600cfda851SThomas Pedersen 			 struct ieee80211_sub_if_data *sdata);
261f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
262f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup(u8 *dst,
263f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
26479617deeSYanBo struct mesh_path *mpp_path_lookup(u8 *dst,
26579617deeSYanBo 				  struct ieee80211_sub_if_data *sdata);
26679617deeSYanBo int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata);
267f698d856SJasper Bryant-Greene struct mesh_path *mesh_path_lookup_by_idx(int idx,
268f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
269ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
270f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
271f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
272f698d856SJasper Bryant-Greene 		struct ieee80211_mgmt *mgmt, size_t len);
273f698d856SJasper Bryant-Greene int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
2745ee68e5bSJavier Cardona 
2755ee68e5bSJavier Cardona int mesh_path_add_gate(struct mesh_path *mpath);
2765ee68e5bSJavier Cardona int mesh_path_send_to_gates(struct mesh_path *mpath);
2775ee68e5bSJavier Cardona int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
278ccf80ddfSLuis Carlos Cobo /* Mesh plinks */
279f743ff49SThomas Pedersen void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
280f743ff49SThomas Pedersen 			   u8 *hw_addr,
2811570ca59SJavier Cardona 			   struct ieee802_11_elems *ie);
282f698d856SJasper Bryant-Greene bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
283d0709a65SJohannes Berg void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
284ccf80ddfSLuis Carlos Cobo void mesh_plink_broken(struct sta_info *sta);
285ccf80ddfSLuis Carlos Cobo void mesh_plink_deactivate(struct sta_info *sta);
286ccf80ddfSLuis Carlos Cobo int mesh_plink_open(struct sta_info *sta);
287ccf80ddfSLuis Carlos Cobo void mesh_plink_block(struct sta_info *sta);
288f698d856SJasper Bryant-Greene void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
289f698d856SJasper Bryant-Greene 			 struct ieee80211_mgmt *mgmt, size_t len,
290f698d856SJasper Bryant-Greene 			 struct ieee80211_rx_status *rx_status);
291ccf80ddfSLuis Carlos Cobo 
292ccf80ddfSLuis Carlos Cobo /* Private interfaces */
293ccf80ddfSLuis Carlos Cobo /* Mesh tables */
29418889231SJavier Cardona void mesh_mpath_table_grow(void);
29518889231SJavier Cardona void mesh_mpp_table_grow(void);
296ccf80ddfSLuis Carlos Cobo /* Mesh paths */
297d19b3bf6SRui Paulo int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
29815ff6365SJohannes Berg 		       const u8 *ra, struct ieee80211_sub_if_data *sdata);
299ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
300ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath);
301ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath);
302ccf80ddfSLuis Carlos Cobo int mesh_pathtbl_init(void);
303ccf80ddfSLuis Carlos Cobo void mesh_pathtbl_unregister(void);
304f698d856SJasper Bryant-Greene int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata);
305ccf80ddfSLuis Carlos Cobo void mesh_path_timer(unsigned long data);
306ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta);
307f698d856SJasper Bryant-Greene void mesh_path_discard_frame(struct sk_buff *skb,
308f698d856SJasper Bryant-Greene 		struct ieee80211_sub_if_data *sdata);
3095bb644a0SJohannes Berg void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata);
3105bb644a0SJohannes Berg void mesh_path_restart(struct ieee80211_sub_if_data *sdata);
311e304bfd3SRui Paulo void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
312ccf80ddfSLuis Carlos Cobo 
31325d49e4dSThomas Pedersen bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
314f5ea9120SJohannes Berg extern int mesh_paths_generation;
315f5ea9120SJohannes Berg 
316902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
317902acc78SJohannes Berg extern int mesh_allocated;
318902acc78SJohannes Berg 
319ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
320ccf80ddfSLuis Carlos Cobo {
321472dbc45SJohannes Berg 	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
322472dbc45SJohannes Berg 	       atomic_read(&sdata->u.mesh.mshstats.estab_plinks);
323ccf80ddfSLuis Carlos Cobo }
324ccf80ddfSLuis Carlos Cobo 
325ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
326ccf80ddfSLuis Carlos Cobo {
327d0709a65SJohannes Berg 	return (min_t(long, mesh_plink_free_count(sdata),
328ccf80ddfSLuis Carlos Cobo 		   MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
329ccf80ddfSLuis Carlos Cobo }
330ccf80ddfSLuis Carlos Cobo 
331ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath)
332ccf80ddfSLuis Carlos Cobo {
333ccf80ddfSLuis Carlos Cobo 	mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
334ccf80ddfSLuis Carlos Cobo }
335ccf80ddfSLuis Carlos Cobo 
336c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
337c7108a71SJavier Cardona {
338c7108a71SJavier Cardona 	return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
339c7108a71SJavier Cardona }
340c7108a71SJavier Cardona 
341472dbc45SJohannes Berg void ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local);
342472dbc45SJohannes Berg 
3435bb644a0SJohannes Berg void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata);
3445bb644a0SJohannes Berg void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata);
3455bb644a0SJohannes Berg void mesh_plink_quiesce(struct sta_info *sta);
3465bb644a0SJohannes Berg void mesh_plink_restart(struct sta_info *sta);
347*94c514feSAndrei Emeltchenko void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
348dbf498fbSJavier Cardona void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata);
349902acc78SJohannes Berg #else
350902acc78SJohannes Berg #define mesh_allocated	0
351472dbc45SJohannes Berg static inline void
352472dbc45SJohannes Berg ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {}
3535bb644a0SJohannes Berg static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata)
3545bb644a0SJohannes Berg {}
3555bb644a0SJohannes Berg static inline void ieee80211_mesh_restart(struct ieee80211_sub_if_data *sdata)
3565bb644a0SJohannes Berg {}
3575bb644a0SJohannes Berg static inline void mesh_plink_quiesce(struct sta_info *sta) {}
3585bb644a0SJohannes Berg static inline void mesh_plink_restart(struct sta_info *sta) {}
359c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
360c7108a71SJavier Cardona { return false; }
361*94c514feSAndrei Emeltchenko static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
362*94c514feSAndrei Emeltchenko {}
363902acc78SJohannes Berg #endif
364902acc78SJohannes Berg 
365ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */
366