xref: /linux/net/mac80211/mesh.h (revision 3a07362fab1653d3aca31a9155c8cc776138fd02)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2ccf80ddfSLuis Carlos Cobo /*
3264d9b7dSRui Paulo  * Copyright (c) 2008, 2009 open80211s Ltd.
403145a1dSJohannes Berg  * Copyright (C) 2023-2024 Intel Corporation
5ccf80ddfSLuis Carlos Cobo  * Authors:    Luis Carlos Cobo <luisca@cozybit.com>
6ccf80ddfSLuis Carlos Cobo  *             Javier Cardona <javier@cozybit.com>
7ccf80ddfSLuis Carlos Cobo  */
8ccf80ddfSLuis Carlos Cobo 
9ccf80ddfSLuis Carlos Cobo #ifndef IEEE80211S_H
10ccf80ddfSLuis Carlos Cobo #define IEEE80211S_H
11ccf80ddfSLuis Carlos Cobo 
12902acc78SJohannes Berg #include <linux/types.h>
13ccf80ddfSLuis Carlos Cobo #include <linux/jhash.h>
14902acc78SJohannes Berg #include "ieee80211_i.h"
15ccf80ddfSLuis Carlos Cobo 
16ccf80ddfSLuis Carlos Cobo 
17ccf80ddfSLuis Carlos Cobo /* Data structures */
18ccf80ddfSLuis Carlos Cobo 
19ccf80ddfSLuis Carlos Cobo /**
20ccf80ddfSLuis Carlos Cobo  * enum mesh_path_flags - mac80211 mesh path flags
21ccf80ddfSLuis Carlos Cobo  *
22eb80ed8dSRami Rosen  * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding
23eb80ed8dSRami Rosen  * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path
24d19b3bf6SRui Paulo  * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence
25ccf80ddfSLuis Carlos Cobo  *	number
26ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_FIXED: the mesh path has been manually set and should not be
27ccf80ddfSLuis Carlos Cobo  *	modified
28ccf80ddfSLuis Carlos Cobo  * @MESH_PATH_RESOLVED: the mesh path can has been resolved
29f3011cf9SJavier Cardona  * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination
30f3011cf9SJavier Cardona  *	already queued up, waiting for the discovery process to start.
3174932959SBob Copeland  * @MESH_PATH_DELETED: the mesh path has been deleted and should no longer
3274932959SBob Copeland  *	be used
33ccf80ddfSLuis Carlos Cobo  *
34eb80ed8dSRami Rosen  * MESH_PATH_RESOLVED is used by the mesh path timer to
35ccf80ddfSLuis Carlos Cobo  * decide when to stop or cancel the mesh path discovery.
36ccf80ddfSLuis Carlos Cobo  */
37ccf80ddfSLuis Carlos Cobo enum mesh_path_flags {
38ccf80ddfSLuis Carlos Cobo 	MESH_PATH_ACTIVE =	BIT(0),
39ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVING =	BIT(1),
40d19b3bf6SRui Paulo 	MESH_PATH_SN_VALID =	BIT(2),
41ccf80ddfSLuis Carlos Cobo 	MESH_PATH_FIXED	=	BIT(3),
42ccf80ddfSLuis Carlos Cobo 	MESH_PATH_RESOLVED =	BIT(4),
43f3011cf9SJavier Cardona 	MESH_PATH_REQ_QUEUED =	BIT(5),
4474932959SBob Copeland 	MESH_PATH_DELETED =	BIT(6),
45ccf80ddfSLuis Carlos Cobo };
46ccf80ddfSLuis Carlos Cobo 
47ccf80ddfSLuis Carlos Cobo /**
4818889231SJavier Cardona  * enum mesh_deferred_task_flags - mac80211 mesh deferred tasks
4918889231SJavier Cardona  *
5018889231SJavier Cardona  *
5118889231SJavier Cardona  *
5218889231SJavier Cardona  * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks
53e304bfd3SRui Paulo  * @MESH_WORK_ROOT: the mesh root station needs to send a frame
54dbf498fbSJavier Cardona  * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other
55dbf498fbSJavier Cardona  * mesh nodes
56f81a9dedSThomas Pedersen  * @MESH_WORK_MBSS_CHANGED: rebuild beacon and notify driver of BSS changes
5718889231SJavier Cardona  */
5818889231SJavier Cardona enum mesh_deferred_task_flags {
5918889231SJavier Cardona 	MESH_WORK_HOUSEKEEPING,
60e304bfd3SRui Paulo 	MESH_WORK_ROOT,
61dbf498fbSJavier Cardona 	MESH_WORK_DRIFT_ADJUST,
62f81a9dedSThomas Pedersen 	MESH_WORK_MBSS_CHANGED,
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
6968bb54b4SBob Copeland  * @mpp: mesh proxy mac address
7068bb54b4SBob Copeland  * @rhash: rhashtable list pointer
71b4c3fbe6SHerbert Xu  * @walk_list: linked list containing all mesh_path objects.
7268bb54b4SBob Copeland  * @gate_list: list pointer for known gates list
73f698d856SJasper Bryant-Greene  * @sdata: mesh subif
74ccf80ddfSLuis Carlos Cobo  * @next_hop: mesh neighbor to which frames for this destination will be
75ccf80ddfSLuis Carlos Cobo  *	forwarded
76ccf80ddfSLuis Carlos Cobo  * @timer: mesh path discovery timer
77ccf80ddfSLuis Carlos Cobo  * @frame_queue: pending queue for frames sent to this destination while the
78ccf80ddfSLuis Carlos Cobo  *	path is unresolved
7968bb54b4SBob Copeland  * @rcu: rcu head for freeing mesh path
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
96540bbcb9SJulan Hsu  * @path_change_count: the number of path changes to destination
9703145a1dSJohannes Berg  * @fast_tx_check: timestamp of last fast-xmit enable attempt
98ccf80ddfSLuis Carlos Cobo  *
99ccf80ddfSLuis Carlos Cobo  *
10068bb54b4SBob Copeland  * The dst address is unique in the mesh path table. Since the mesh_path is
10168bb54b4SBob Copeland  * protected by RCU, deleting the next_hop STA must remove / substitute the
10268bb54b4SBob Copeland  * mesh_path structure and wait until that is no longer reachable before
10368bb54b4SBob Copeland  * destroying the STA completely.
104ccf80ddfSLuis Carlos Cobo  */
105ccf80ddfSLuis Carlos Cobo struct mesh_path {
106ccf80ddfSLuis Carlos Cobo 	u8 dst[ETH_ALEN];
10779617deeSYanBo 	u8 mpp[ETH_ALEN];	/* used for MPP or MAP */
10860854fd9SBob Copeland 	struct rhash_head rhash;
109b4c3fbe6SHerbert Xu 	struct hlist_node walk_list;
110947c2a0eSBob Copeland 	struct hlist_node gate_list;
111f698d856SJasper Bryant-Greene 	struct ieee80211_sub_if_data *sdata;
11240b275b6SJohannes Berg 	struct sta_info __rcu *next_hop;
113ccf80ddfSLuis Carlos Cobo 	struct timer_list timer;
114ccf80ddfSLuis Carlos Cobo 	struct sk_buff_head frame_queue;
115ccf80ddfSLuis Carlos Cobo 	struct rcu_head rcu;
116d19b3bf6SRui Paulo 	u32 sn;
117ccf80ddfSLuis Carlos Cobo 	u32 metric;
118ccf80ddfSLuis Carlos Cobo 	u8 hop_count;
119ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
120ccf80ddfSLuis Carlos Cobo 	u32 discovery_timeout;
121ccf80ddfSLuis Carlos Cobo 	u8 discovery_retries;
122ccf80ddfSLuis Carlos Cobo 	enum mesh_path_flags flags;
123ccf80ddfSLuis Carlos Cobo 	spinlock_t state_lock;
1243d045a54SChun-Yeow Yeoh 	u8 rann_snd_addr[ETH_ALEN];
125d2a079fdSChun-Yeow Yeoh 	u32 rann_metric;
126728b19e5SChun-Yeow Yeoh 	unsigned long last_preq_to_root;
127d5edb9aeSFelix Fietkau 	unsigned long fast_tx_check;
1283d045a54SChun-Yeow Yeoh 	bool is_root;
1295ee68e5bSJavier Cardona 	bool is_gate;
130540bbcb9SJulan Hsu 	u32 path_change_count;
131ccf80ddfSLuis Carlos Cobo };
132ccf80ddfSLuis Carlos Cobo 
133d5edb9aeSFelix Fietkau #define MESH_FAST_TX_CACHE_MAX_SIZE		512
134d5edb9aeSFelix Fietkau #define MESH_FAST_TX_CACHE_THRESHOLD_SIZE	384
135d5edb9aeSFelix Fietkau #define MESH_FAST_TX_CACHE_TIMEOUT		8000 /* msecs */
136d5edb9aeSFelix Fietkau 
137d5edb9aeSFelix Fietkau /**
138*8c75cdcdSFelix Fietkau  * enum ieee80211_mesh_fast_tx_type - cached mesh fast tx entry type
139*8c75cdcdSFelix Fietkau  *
140*8c75cdcdSFelix Fietkau  * @MESH_FAST_TX_TYPE_LOCAL: tx from the local vif address as SA
141*8c75cdcdSFelix Fietkau  * @MESH_FAST_TX_TYPE_PROXIED: local tx with a different SA (e.g. bridged)
142*8c75cdcdSFelix Fietkau  * @MESH_FAST_TX_TYPE_FORWARDED: forwarded from a different mesh point
143*8c75cdcdSFelix Fietkau  * @NUM_MESH_FAST_TX_TYPE: number of entry types
144*8c75cdcdSFelix Fietkau  */
145*8c75cdcdSFelix Fietkau enum ieee80211_mesh_fast_tx_type {
146*8c75cdcdSFelix Fietkau 	MESH_FAST_TX_TYPE_LOCAL,
147*8c75cdcdSFelix Fietkau 	MESH_FAST_TX_TYPE_PROXIED,
148*8c75cdcdSFelix Fietkau 	MESH_FAST_TX_TYPE_FORWARDED,
149*8c75cdcdSFelix Fietkau 
150*8c75cdcdSFelix Fietkau 	/* must be last */
151*8c75cdcdSFelix Fietkau 	NUM_MESH_FAST_TX_TYPE
152*8c75cdcdSFelix Fietkau };
153*8c75cdcdSFelix Fietkau 
154*8c75cdcdSFelix Fietkau 
155*8c75cdcdSFelix Fietkau /**
156*8c75cdcdSFelix Fietkau  * struct ieee80211_mesh_fast_tx_key - cached mesh fast tx entry key
157*8c75cdcdSFelix Fietkau  *
158*8c75cdcdSFelix Fietkau  * @addr: The Ethernet DA for this entry
159*8c75cdcdSFelix Fietkau  * @type: cache entry type
160*8c75cdcdSFelix Fietkau  */
161*8c75cdcdSFelix Fietkau struct ieee80211_mesh_fast_tx_key {
162*8c75cdcdSFelix Fietkau 	u8 addr[ETH_ALEN] __aligned(2);
163*8c75cdcdSFelix Fietkau 	u16 type;
164*8c75cdcdSFelix Fietkau };
165*8c75cdcdSFelix Fietkau 
166*8c75cdcdSFelix Fietkau /**
167d5edb9aeSFelix Fietkau  * struct ieee80211_mesh_fast_tx - cached mesh fast tx entry
168d5edb9aeSFelix Fietkau  * @rhash: rhashtable pointer
169*8c75cdcdSFelix Fietkau  * @key: the lookup key for this cache entry
170d5edb9aeSFelix Fietkau  * @fast_tx: base fast_tx data
171d5edb9aeSFelix Fietkau  * @hdr: cached mesh and rfc1042 headers
172d5edb9aeSFelix Fietkau  * @hdrlen: length of mesh + rfc1042
173d5edb9aeSFelix Fietkau  * @walk_list: list containing all the fast tx entries
174d5edb9aeSFelix Fietkau  * @mpath: mesh path corresponding to the Mesh DA
175d5edb9aeSFelix Fietkau  * @mppath: MPP entry corresponding to this DA
176d5edb9aeSFelix Fietkau  * @timestamp: Last used time of this entry
177d5edb9aeSFelix Fietkau  */
178d5edb9aeSFelix Fietkau struct ieee80211_mesh_fast_tx {
179d5edb9aeSFelix Fietkau 	struct rhash_head rhash;
180*8c75cdcdSFelix Fietkau 	struct ieee80211_mesh_fast_tx_key key;
181d5edb9aeSFelix Fietkau 
182d5edb9aeSFelix Fietkau 	struct ieee80211_fast_tx fast_tx;
183d5edb9aeSFelix Fietkau 	u8 hdr[sizeof(struct ieee80211s_hdr) + sizeof(rfc1042_header)];
184d5edb9aeSFelix Fietkau 	u16 hdrlen;
185d5edb9aeSFelix Fietkau 
186d5edb9aeSFelix Fietkau 	struct mesh_path *mpath, *mppath;
187d5edb9aeSFelix Fietkau 	struct hlist_node walk_list;
188d5edb9aeSFelix Fietkau 	unsigned long timestamp;
189d5edb9aeSFelix Fietkau };
190d5edb9aeSFelix Fietkau 
191ccf80ddfSLuis Carlos Cobo /* Recent multicast cache */
192ccf80ddfSLuis Carlos Cobo /* RMC_BUCKETS must be a power of 2, maximum 256 */
193ccf80ddfSLuis Carlos Cobo #define RMC_BUCKETS		256
194ccf80ddfSLuis Carlos Cobo #define RMC_QUEUE_MAX_LEN	4
195ccf80ddfSLuis Carlos Cobo #define RMC_TIMEOUT		(3 * HZ)
196ccf80ddfSLuis Carlos Cobo 
197ccf80ddfSLuis Carlos Cobo /**
198ccf80ddfSLuis Carlos Cobo  * struct rmc_entry - entry in the Recent Multicast Cache
199ccf80ddfSLuis Carlos Cobo  *
200ccf80ddfSLuis Carlos Cobo  * @seqnum: mesh sequence number of the frame
201ccf80ddfSLuis Carlos Cobo  * @exp_time: expiration time of the entry, in jiffies
202ccf80ddfSLuis Carlos Cobo  * @sa: source address of the frame
20368bb54b4SBob Copeland  * @list: hashtable list pointer
204ccf80ddfSLuis Carlos Cobo  *
205ccf80ddfSLuis Carlos Cobo  * The Recent Multicast Cache keeps track of the latest multicast frames that
206ccf80ddfSLuis Carlos Cobo  * have been received by a mesh interface and discards received multicast frames
207ccf80ddfSLuis Carlos Cobo  * that are found in the cache.
208ccf80ddfSLuis Carlos Cobo  */
209ccf80ddfSLuis Carlos Cobo struct rmc_entry {
21047a0489cSBob Copeland 	struct hlist_node list;
211ccf80ddfSLuis Carlos Cobo 	unsigned long exp_time;
2123257523bSBob Copeland 	u32 seqnum;
213ccf80ddfSLuis Carlos Cobo 	u8 sa[ETH_ALEN];
214ccf80ddfSLuis Carlos Cobo };
215ccf80ddfSLuis Carlos Cobo 
216ccf80ddfSLuis Carlos Cobo struct mesh_rmc {
21747a0489cSBob Copeland 	struct hlist_head bucket[RMC_BUCKETS];
21851ceddadSLuis Carlos Cobo 	u32 idx_mask;
219ccf80ddfSLuis Carlos Cobo };
220ccf80ddfSLuis Carlos Cobo 
22125d49e4dSThomas Pedersen #define IEEE80211_MESH_HOUSEKEEPING_INTERVAL (60 * HZ)
222ccf80ddfSLuis Carlos Cobo 
223ccf80ddfSLuis Carlos Cobo #define MESH_PATH_EXPIRE (600 * HZ)
224ccf80ddfSLuis Carlos Cobo 
225ccf80ddfSLuis Carlos Cobo /* Default maximum number of plinks per interface */
226ccf80ddfSLuis Carlos Cobo #define MESH_MAX_PLINKS		256
227ccf80ddfSLuis Carlos Cobo 
228ccf80ddfSLuis Carlos Cobo /* Maximum number of paths per interface */
229ccf80ddfSLuis Carlos Cobo #define MESH_MAX_MPATHS		1024
230ccf80ddfSLuis Carlos Cobo 
2314bd4c2ddSThomas Pedersen /* Number of frames buffered per destination for unresolved destinations */
2324bd4c2ddSThomas Pedersen #define MESH_FRAME_QUEUE_LEN	10
2334bd4c2ddSThomas Pedersen 
234ccf80ddfSLuis Carlos Cobo /* Public interfaces */
235ccf80ddfSLuis Carlos Cobo /* Various */
2363c5772a5SJavier Cardona int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
23715ff6365SJohannes Berg 				  const u8 *da, const u8 *sa);
2385edfcee5SAndrzej Hajda unsigned int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
239bf7cd94dSJohannes Berg 				       struct ieee80211s_hdr *meshhdr,
240bf7cd94dSJohannes Berg 				       const char *addr4or5, const char *addr6);
241bf7cd94dSJohannes Berg int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
242bf7cd94dSJohannes Berg 		   const u8 *addr, struct ieee80211s_hdr *mesh_hdr);
243f743ff49SThomas Pedersen bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
244f743ff49SThomas Pedersen 			struct ieee802_11_elems *ie);
245bf7cd94dSJohannes Berg int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
246bf7cd94dSJohannes Berg 			 struct sk_buff *skb);
247bf7cd94dSJohannes Berg int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata,
248bf7cd94dSJohannes Berg 		       struct sk_buff *skb);
249bf7cd94dSJohannes Berg int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata,
250bf7cd94dSJohannes Berg 		    struct sk_buff *skb);
251bf7cd94dSJohannes Berg int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata,
252bf7cd94dSJohannes Berg 			struct sk_buff *skb);
253bf7cd94dSJohannes Berg int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata,
254bf7cd94dSJohannes Berg 		       struct sk_buff *skb);
255bf7cd94dSJohannes Berg int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata,
256bf7cd94dSJohannes Berg 			struct sk_buff *skb);
257c85fb53cSBob Copeland int mesh_add_vht_cap_ie(struct ieee80211_sub_if_data *sdata,
258c85fb53cSBob Copeland 			struct sk_buff *skb);
259c85fb53cSBob Copeland int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,
260c85fb53cSBob Copeland 			 struct sk_buff *skb);
26160ad72daSSven Eckelmann int mesh_add_he_cap_ie(struct ieee80211_sub_if_data *sdata,
26260ad72daSSven Eckelmann 		       struct sk_buff *skb, u8 ie_len);
26360ad72daSSven Eckelmann int mesh_add_he_oper_ie(struct ieee80211_sub_if_data *sdata,
26460ad72daSSven Eckelmann 			struct sk_buff *skb);
26524a2042cSRajkumar Manoharan int mesh_add_he_6ghz_cap_ie(struct ieee80211_sub_if_data *sdata,
26624a2042cSRajkumar Manoharan 			    struct sk_buff *skb);
267df1875c4SRyder Lee int mesh_add_eht_cap_ie(struct ieee80211_sub_if_data *sdata,
268df1875c4SRyder Lee 			struct sk_buff *skb, u8 ie_len);
269df1875c4SRyder Lee int mesh_add_eht_oper_ie(struct ieee80211_sub_if_data *sdata,
270df1875c4SRyder Lee 			 struct sk_buff *skb);
271f698d856SJasper Bryant-Greene void mesh_rmc_free(struct ieee80211_sub_if_data *sdata);
272f698d856SJasper Bryant-Greene int mesh_rmc_init(struct ieee80211_sub_if_data *sdata);
273ccf80ddfSLuis Carlos Cobo void ieee80211s_init(void);
274bfc32e6aSJavier Cardona void ieee80211s_update_metric(struct ieee80211_local *local,
275c4205510SYuan-Chi Pang 			      struct sta_info *sta,
276c4205510SYuan-Chi Pang 			      struct ieee80211_tx_status *st);
277902acc78SJohannes Berg void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata);
2780371a08fSBob Copeland void ieee80211_mesh_teardown_sdata(struct ieee80211_sub_if_data *sdata);
2792b5e1967SThomas Pedersen int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata);
280472dbc45SJohannes Berg void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata);
28163c5723bSRui Paulo void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh);
2828ba7acf3SJohannes Berg const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method);
2832b5e1967SThomas Pedersen /* wrapper for ieee80211_bss_info_change_notify() */
2842b5e1967SThomas Pedersen void ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
28515ddba5fSAnjaneyulu 				       u64 changed);
286902acc78SJohannes Berg 
2873f52b7e3SMarco Porsch /* mesh power save */
28815ddba5fSAnjaneyulu u64 ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata);
28915ddba5fSAnjaneyulu u64 ieee80211_mps_set_sta_local_pm(struct sta_info *sta,
2903f52b7e3SMarco Porsch 				   enum nl80211_mesh_power_mode pm);
2913f52b7e3SMarco Porsch void ieee80211_mps_set_frame_flags(struct ieee80211_sub_if_data *sdata,
2923f52b7e3SMarco Porsch 				   struct sta_info *sta,
2933f52b7e3SMarco Porsch 				   struct ieee80211_hdr *hdr);
2943f52b7e3SMarco Porsch void ieee80211_mps_sta_status_update(struct sta_info *sta);
2953f52b7e3SMarco Porsch void ieee80211_mps_rx_h_sta_process(struct sta_info *sta,
2963f52b7e3SMarco Porsch 				    struct ieee80211_hdr *hdr);
2973f52b7e3SMarco Porsch void ieee80211_mpsp_trigger_process(u8 *qc, struct sta_info *sta,
2983f52b7e3SMarco Porsch 				    bool tx, bool acked);
2993f52b7e3SMarco Porsch void ieee80211_mps_frame_release(struct sta_info *sta,
3003f52b7e3SMarco Porsch 				 struct ieee802_11_elems *elems);
3013f52b7e3SMarco Porsch 
302ccf80ddfSLuis Carlos Cobo /* Mesh paths */
303bf7cd94dSJohannes Berg int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
304bf7cd94dSJohannes Berg 			struct sk_buff *skb);
305bf7cd94dSJohannes Berg int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
306bf7cd94dSJohannes Berg 			 struct sk_buff *skb);
307f698d856SJasper Bryant-Greene void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata);
308bf7cd94dSJohannes Berg struct mesh_path *mesh_path_lookup(struct ieee80211_sub_if_data *sdata,
309bf7cd94dSJohannes Berg 				   const u8 *dst);
310bf7cd94dSJohannes Berg struct mesh_path *mpp_path_lookup(struct ieee80211_sub_if_data *sdata,
311bf7cd94dSJohannes Berg 				  const u8 *dst);
312bf7cd94dSJohannes Berg int mpp_path_add(struct ieee80211_sub_if_data *sdata,
313bf7cd94dSJohannes Berg 		 const u8 *dst, const u8 *mpp);
314bf7cd94dSJohannes Berg struct mesh_path *
315bf7cd94dSJohannes Berg mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
316a2db2ed3SHenning Rogge struct mesh_path *
317a2db2ed3SHenning Rogge mpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx);
318ccf80ddfSLuis Carlos Cobo void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop);
319f698d856SJasper Bryant-Greene void mesh_path_expire(struct ieee80211_sub_if_data *sdata);
320f698d856SJasper Bryant-Greene void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
321f698d856SJasper Bryant-Greene 			    struct ieee80211_mgmt *mgmt, size_t len);
322ae76eef0SBob Copeland struct mesh_path *
323ae76eef0SBob Copeland mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst);
3245ee68e5bSJavier Cardona 
3255ee68e5bSJavier Cardona int mesh_path_add_gate(struct mesh_path *mpath);
3265ee68e5bSJavier Cardona int mesh_path_send_to_gates(struct mesh_path *mpath);
3275ee68e5bSJavier Cardona int mesh_gate_num(struct ieee80211_sub_if_data *sdata);
328ab60633cSNarayanraddi Masti u32 airtime_link_metric_get(struct ieee80211_local *local,
329ab60633cSNarayanraddi Masti 			    struct sta_info *sta);
330bf7cd94dSJohannes Berg 
331ccf80ddfSLuis Carlos Cobo /* Mesh plinks */
332f743ff49SThomas Pedersen void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
333ecbc12adSBob Copeland 			   u8 *hw_addr, struct ieee802_11_elems *ie,
334ecbc12adSBob Copeland 			   struct ieee80211_rx_status *rx_status);
335f698d856SJasper Bryant-Greene bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
33615ddba5fSAnjaneyulu u64 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
3374c02d62fSKees Cook void mesh_plink_timer(struct timer_list *t);
338ccf80ddfSLuis Carlos Cobo void mesh_plink_broken(struct sta_info *sta);
33915ddba5fSAnjaneyulu u64 mesh_plink_deactivate(struct sta_info *sta);
34015ddba5fSAnjaneyulu u64 mesh_plink_open(struct sta_info *sta);
34115ddba5fSAnjaneyulu u64 mesh_plink_block(struct sta_info *sta);
342f698d856SJasper Bryant-Greene void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
343f698d856SJasper Bryant-Greene 			 struct ieee80211_mgmt *mgmt, size_t len,
344f698d856SJasper Bryant-Greene 			 struct ieee80211_rx_status *rx_status);
34545b5028eSThomas Pedersen void mesh_sta_cleanup(struct sta_info *sta);
346ccf80ddfSLuis Carlos Cobo 
347ccf80ddfSLuis Carlos Cobo /* Private interfaces */
348ccf80ddfSLuis Carlos Cobo /* Mesh paths */
349bf7cd94dSJohannes Berg int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
350f63f8421SChun-Yeow Yeoh 		       u8 ttl, const u8 *target, u32 target_sn,
351f63f8421SChun-Yeow Yeoh 		       u16 target_rcode, const u8 *ra);
352ccf80ddfSLuis Carlos Cobo void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
353ccf80ddfSLuis Carlos Cobo void mesh_path_flush_pending(struct mesh_path *mpath);
354ccf80ddfSLuis Carlos Cobo void mesh_path_tx_pending(struct mesh_path *mpath);
3558b5cb7e4SPavel Skripkin void mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);
3562bdaf386SBob Copeland void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);
357bf7cd94dSJohannes Berg int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);
35834f11cd3SKees Cook void mesh_path_timer(struct timer_list *t);
359ccf80ddfSLuis Carlos Cobo void mesh_path_flush_by_nexthop(struct sta_info *sta);
360bf7cd94dSJohannes Berg void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata,
361bf7cd94dSJohannes Berg 			     struct sk_buff *skb);
362e304bfd3SRui Paulo void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata);
363ccf80ddfSLuis Carlos Cobo 
36425d49e4dSThomas Pedersen bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt);
365d5edb9aeSFelix Fietkau struct ieee80211_mesh_fast_tx *
366*8c75cdcdSFelix Fietkau mesh_fast_tx_get(struct ieee80211_sub_if_data *sdata,
367*8c75cdcdSFelix Fietkau 		 struct ieee80211_mesh_fast_tx_key *key);
368d5edb9aeSFelix Fietkau bool ieee80211_mesh_xmit_fast(struct ieee80211_sub_if_data *sdata,
369d5edb9aeSFelix Fietkau 			      struct sk_buff *skb, u32 ctrl_flags);
370d5edb9aeSFelix Fietkau void mesh_fast_tx_cache(struct ieee80211_sub_if_data *sdata,
371d5edb9aeSFelix Fietkau 			struct sk_buff *skb, struct mesh_path *mpath);
372d5edb9aeSFelix Fietkau void mesh_fast_tx_gc(struct ieee80211_sub_if_data *sdata);
373d5edb9aeSFelix Fietkau void mesh_fast_tx_flush_addr(struct ieee80211_sub_if_data *sdata,
374d5edb9aeSFelix Fietkau 			     const u8 *addr);
375d5edb9aeSFelix Fietkau void mesh_fast_tx_flush_mpath(struct mesh_path *mpath);
376d5edb9aeSFelix Fietkau void mesh_fast_tx_flush_sta(struct ieee80211_sub_if_data *sdata,
377d5edb9aeSFelix Fietkau 			    struct sta_info *sta);
378d5edb9aeSFelix Fietkau void mesh_path_refresh(struct ieee80211_sub_if_data *sdata,
379d5edb9aeSFelix Fietkau 		       struct mesh_path *mpath, const u8 *addr);
380f5ea9120SJohannes Berg 
381902acc78SJohannes Berg #ifdef CONFIG_MAC80211_MESH
3821617bab8SMarco Porsch static inline
mesh_plink_inc_estab_count(struct ieee80211_sub_if_data * sdata)38315ddba5fSAnjaneyulu u64 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
3841617bab8SMarco Porsch {
3851617bab8SMarco Porsch 	atomic_inc(&sdata->u.mesh.estab_plinks);
386e05ecccdSJacob Minshall 	return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
3871617bab8SMarco Porsch }
3881617bab8SMarco Porsch 
3891617bab8SMarco Porsch static inline
mesh_plink_dec_estab_count(struct ieee80211_sub_if_data * sdata)39015ddba5fSAnjaneyulu u64 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
3911617bab8SMarco Porsch {
3921617bab8SMarco Porsch 	atomic_dec(&sdata->u.mesh.estab_plinks);
393e05ecccdSJacob Minshall 	return mesh_accept_plinks_update(sdata) | BSS_CHANGED_BEACON;
3941617bab8SMarco Porsch }
3951617bab8SMarco Porsch 
mesh_plink_free_count(struct ieee80211_sub_if_data * sdata)396ccf80ddfSLuis Carlos Cobo static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata)
397ccf80ddfSLuis Carlos Cobo {
398472dbc45SJohannes Berg 	return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks -
3991258d976SAshok Nagarajan 	       atomic_read(&sdata->u.mesh.estab_plinks);
400ccf80ddfSLuis Carlos Cobo }
401ccf80ddfSLuis Carlos Cobo 
mesh_plink_availables(struct ieee80211_sub_if_data * sdata)402ccf80ddfSLuis Carlos Cobo static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata)
403ccf80ddfSLuis Carlos Cobo {
404d0709a65SJohannes Berg 	return (min_t(long, mesh_plink_free_count(sdata),
405ccf80ddfSLuis Carlos Cobo 		   MESH_MAX_PLINKS - sdata->local->num_sta)) > 0;
406ccf80ddfSLuis Carlos Cobo }
407ccf80ddfSLuis Carlos Cobo 
mesh_path_activate(struct mesh_path * mpath)408ccf80ddfSLuis Carlos Cobo static inline void mesh_path_activate(struct mesh_path *mpath)
409ccf80ddfSLuis Carlos Cobo {
410ccf80ddfSLuis Carlos Cobo 	mpath->flags |= MESH_PATH_ACTIVE | MESH_PATH_RESOLVED;
411ccf80ddfSLuis Carlos Cobo }
412ccf80ddfSLuis Carlos Cobo 
mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data * sdata)413c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
414c7108a71SJavier Cardona {
415c7108a71SJavier Cardona 	return sdata->u.mesh.mesh_pp_id == IEEE80211_PATH_PROTOCOL_HWMP;
416c7108a71SJavier Cardona }
417c7108a71SJavier Cardona 
41894c514feSAndrei Emeltchenko void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata);
419445cd452SMasashi Honma void mesh_sync_adjust_tsf(struct ieee80211_sub_if_data *sdata);
420bf7cd94dSJohannes Berg void ieee80211s_stop(void);
421902acc78SJohannes Berg #else
mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data * sdata)422c7108a71SJavier Cardona static inline bool mesh_path_sel_is_hwmp(struct ieee80211_sub_if_data *sdata)
423c7108a71SJavier Cardona { return false; }
mesh_path_flush_by_iface(struct ieee80211_sub_if_data * sdata)42494c514feSAndrei Emeltchenko static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
42594c514feSAndrei Emeltchenko {}
ieee80211s_stop(void)426bf7cd94dSJohannes Berg static inline void ieee80211s_stop(void) {}
427902acc78SJohannes Berg #endif
428902acc78SJohannes Berg 
429ccf80ddfSLuis Carlos Cobo #endif /* IEEE80211S_H */
430