xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/include/802.11s.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Fundamental types and constants relating to 802.11s Mesh
3  *
4  * Copyright (C) 2020, Broadcom.
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *
21  * <<Broadcom-WL-IPTag/Dual:>>
22  */
23 
24 #ifndef _802_11s_h_
25 #define _802_11s_h_
26 
27 /* This marks the start of a packed structure section. */
28 #include <packed_section_start.h>
29 
30 #define DOT11_MESH_FLAGS_AE_MASK	0x3u
31 #define DOT11_MESH_FLAGS_AE_SHIFT	0u
32 
33 /* Mesh Control Flags: Address Exetension mode values */
34 #define DOT11_MESH_AE_NONE              0u
35 #define DOT11_MESH_AE_A4                1u
36 #define DOT11_MESH_AE_A5_A6             2u
37 
38 #define DOT11_MESH_CONNECTED_AS_SET         7
39 #define DOT11_MESH_NUMBER_PEERING_SET       1
40 #define DOT11_MESH_MESH_GWSET               0
41 
42 #define DOT11_MESH_ACTION_LINK_MET_REP      0
43 #define DOT11_MESH_ACTION_PATH_SEL          1
44 #define DOT11_MESH_ACTION_GATE_ANN          2
45 #define DOT11_MESH_ACTION_CONG_CONT_NOTIF   3
46 #define DOT11_MESH_ACTION_MCCA_SETUP_REQ    4
47 #define DOT11_MESH_ACTION_MCCA_SETUP_REP    5
48 #define DOT11_MESH_ACTION_MCCA_ADVT_REQ     6
49 #define DOT11_MESH_ACTION_MCCA_ADVT         7
50 #define DOT11_MESH_ACTION_MCCA_TEARDOWN     8
51 #define DOT11_MESH_ACTION_TBTT_ADJ_REQ      9
52 #define DOT11_MESH_ACTION_TBTT_ADJ_RESP     10
53 
54 /* self-protected action field values: 7-57v24 */
55 #define DOT11_SELFPROT_ACTION_MESH_PEER_OPEN    1
56 #define DOT11_SELFPROT_ACTION_MESH_PEER_CONFM   2
57 #define DOT11_SELFPROT_ACTION_MESH_PEER_CLOSE   3
58 #define DOT11_SELFPROT_ACTION_MESH_PEER_GK_INF  4
59 #define DOT11_SELFPROT_ACTION_MESH_PEER_GK_ACK  5
60 
61 #define DOT11_MESH_AUTH_PROTO_NONE        0
62 #define DOT11_MESH_AUTH_PROTO_SAE         1
63 #define DOT11_MESH_AUTH_PROTO_8021X       2
64 #define DOT11_MESH_AUTH_PROTO_VS        255
65 
66 #define DOT11_MESH_PATHSEL_LEN   2
67 #define DOT11_MESH_PERR_LEN1     2   /* Least PERR length fixed */
68 #define DOT11_MESH_PERR_LEN2     13  /* Least PERR length variable */
69 #define DOT11_MESH_PREP_LEN      31  /* Least PREP length */
70 #define DOT11_MESH_PREQ_LEN      37  /* Least PREQ length */
71 
72 #define DOT11_MESH_PATHSEL_PROTID_HWMP    1
73 #define DOT11_MESH_PATHSEL_METRICID_ALM   1 /* Air link metric */
74 #define DOT11_MESH_CONGESTCTRL_NONE       0
75 #define DOT11_MESH_CONGESTCTRL_SP         1
76 #define DOT11_MESH_SYNCMETHOD_NOFFSET     1
77 
78 BWL_PRE_PACKED_STRUCT struct dot11_meshctrl_hdr {
79 	uint8               flags;      /* flag bits such as ae etc */
80 	uint8               ttl;        /* time to live */
81 	uint32              seq;        /* sequence control */
82 	struct ether_addr   a5;         /* optional address 5 */
83 	struct ether_addr   a6;         /* optional address 6 */
84 } BWL_POST_PACKED_STRUCT;
85 
86 #define DOT11_MESH_CONTROL_MIN_LEN      6u
87 #define DOT11_MESH_CONTROL_A4_LEN      12u
88 #define DOT11_MESH_CONTROL_A5A6_LEN    18u
89 
90 /* Mesh Path Selection Action Frame */
91 BWL_PRE_PACKED_STRUCT struct dot11_mesh_pathsel {
92 	uint8   category;
93 	uint8   meshaction;
94 	uint8   data[];
95 } BWL_POST_PACKED_STRUCT;
96 typedef struct dot11_mesh_pathsel dot11_mesh_pathsel_t;
97 
98 /*  Mesh PREQ IE */
99 BWL_PRE_PACKED_STRUCT struct mesh_preq_ie {
100 	uint8   id;
101 	uint8   len;
102 	uint8   flags;
103 	uint8   hop_count;
104 	uint8   ttl;
105 	uint32  pathdis_id;
106 	struct  ether_addr  originator_addr;
107 	uint32  originator_seq;
108 	union {
109 		BWL_PRE_PACKED_STRUCT struct {
110 			struct ether_addr target_ext_add;
111 			uint32  lifetime;
112 			uint32  metric;
113 			uint8   target_count;
114 			uint8   data[];
115 		} BWL_POST_PACKED_STRUCT oea;
116 
117 		BWL_PRE_PACKED_STRUCT struct {
118 			uint32  lifetime;
119 			uint32  metric;
120 			uint8   target_count;
121 			uint8   data[];
122 		} BWL_POST_PACKED_STRUCT noea;
123 	} u;
124 } BWL_POST_PACKED_STRUCT;
125 typedef struct mesh_preq_ie mesh_preq_ie_t;
126 
127 /* Target info (part of Mesh PREQ IE) */
128 BWL_PRE_PACKED_STRUCT struct mesh_targetinfo {
129 	uint8	target_flag;
130 	struct	ether_addr	target_addr;
131 	uint32	target_seq;
132 } BWL_POST_PACKED_STRUCT;
133 typedef struct mesh_targetinfo mesh_targetinfo_t;
134 
135 /* Mesh PREP IE */
136 BWL_PRE_PACKED_STRUCT struct mesh_prep_ie {
137 	uint8	id;
138 	uint8	len;
139 	uint8	flags;
140 	uint8	hop_count;
141 	uint8	ttl;
142 	struct	ether_addr	target_addr;
143 	uint32	target_seq;
144 	union {
145 		BWL_PRE_PACKED_STRUCT struct {
146 			struct ether_addr target_ext_add;
147 			uint32  lifetime;
148 			uint32  metric;
149 			uint8   target_count;
150 	                struct	ether_addr	originator_addr;
151 	                uint32	originator_seq;
152 		} BWL_POST_PACKED_STRUCT oea;
153 
154 		BWL_PRE_PACKED_STRUCT struct {
155 			uint32  lifetime;
156 			uint32  metric;
157 			uint8   target_count;
158 	                struct	ether_addr	originator_addr;
159 	                uint32	originator_seq;
160 		} BWL_POST_PACKED_STRUCT noea;
161 	} u;
162 } BWL_POST_PACKED_STRUCT;
163 typedef struct mesh_prep_ie mesh_prep_ie_t;
164 
165 /* Mesh PERR IE */
166 struct mesh_perr_ie {
167 	uint8	id;
168 	uint8	len;
169 	uint8	ttl;
170 	uint8	num_dest;
171 	uint8	data[];
172 };
173 typedef struct mesh_perr_ie mesh_perr_ie_t;
174 
175 /* Destination info is part of PERR IE */
176 BWL_PRE_PACKED_STRUCT struct mesh_perr_destinfo {
177 	uint8	flags;
178 	struct	ether_addr	destination_addr;
179 	uint32	dest_seq;
180 	union {
181 		BWL_PRE_PACKED_STRUCT struct {
182 			struct  ether_addr      dest_ext_addr;
183 		} BWL_POST_PACKED_STRUCT dea;
184 
185 		BWL_PRE_PACKED_STRUCT struct {
186 		/* 1 byte reason code to be populated manually in software */
187 			uint16	reason_code;
188 		} BWL_POST_PACKED_STRUCT nodea;
189 	} u;
190 } BWL_POST_PACKED_STRUCT;
191 typedef struct mesh_perr_destinfo mesh_perr_destinfo_t;
192 
193 /* Mesh peering action frame hdr */
194 BWL_PRE_PACKED_STRUCT struct mesh_peering_frmhdr {
195 	uint8	category;
196 	uint8	action;
197 	union	{
198 		struct {
199 			uint16	capability;
200 		} open;
201 		struct {
202 			uint16	capability;
203 			uint16	AID;
204 		} confirm;
205 		uint8 data[1];
206 	} u;
207 } BWL_POST_PACKED_STRUCT;
208 typedef struct mesh_peering_frmhdr mesh_peering_frmhdr_t;
209 
210 /* Mesh peering mgmt IE */
211 BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_common {
212 	uint16	mesh_peer_prot_id;
213 	uint16	local_link_id;
214 } BWL_POST_PACKED_STRUCT;
215 typedef struct mesh_peer_mgmt_ie_common mesh_peer_mgmt_ie_common_t;
216 #define MESH_PEER_MGMT_IE_OPEN_LEN	(4)
217 
218 BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_cfm {
219 	mesh_peer_mgmt_ie_common_t	common;
220 	uint16	peer_link_id;
221 } BWL_POST_PACKED_STRUCT;
222 typedef struct mesh_peer_mgmt_ie_cfm mesh_peer_mgmt_ie_cfm_t;
223 #define MESH_PEER_MGMT_IE_CONF_LEN	(6)
224 
225 BWL_PRE_PACKED_STRUCT struct mesh_peer_mgmt_ie_close {
226 	mesh_peer_mgmt_ie_common_t	common;
227 	/* uint16	peer_link_id;
228 	* simplicity: not supported, TODO for future
229 	*/
230 	uint16	reason_code;
231 } BWL_POST_PACKED_STRUCT;
232 typedef struct mesh_peer_mgmt_ie_close mesh_peer_mgmt_ie_close_t;
233 #define MESH_PEER_MGMT_IE_CLOSE_LEN	(6)
234 
235 struct mesh_config_ie {
236 	uint8	activ_path_sel_prot_id;
237 	uint8	activ_path_sel_metric_id;
238 	uint8	cong_ctl_mode_id;
239 	uint8	sync_method_id;
240 	uint8	auth_prot_id;
241 	uint8	mesh_formation_info;
242 	uint8	mesh_cap;
243 };
244 typedef struct mesh_config_ie mesh_config_ie_t;
245 #define MESH_CONFIG_IE_LEN	(7)
246 
247 /* Mesh peering states */
248 #define MESH_PEERING_IDLE               0
249 #define MESH_PEERING_OPEN_SNT           1
250 #define MESH_PEERING_CNF_RCVD           2
251 #define MESH_PEERING_OPEN_RCVD          3
252 #define MESH_PEERING_ESTAB              4
253 #define MESH_PEERING_HOLDING            5
254 #define MESH_PEERING_LAST_STATE         6
255 /* for debugging: mapping strings */
256 #define MESH_PEERING_STATE_STRINGS \
257 	{"IDLE  ", "OPNSNT", "CNFRCV", "OPNRCV", "ESTAB ", "HOLDNG"}
258 
259 #ifdef WLMESH
260 typedef BWL_PRE_PACKED_STRUCT struct mesh_peer_info {
261 	/* mesh_peer_instance as given in the spec. Note that, peer address
262 	 * is stored in scb
263 	 */
264 	uint16	mesh_peer_prot_id;
265 	uint16	local_link_id;
266 	uint16	peer_link_id;
267 	/* AID generated by *peer* to self & received in peer_confirm */
268 	uint16  peer_aid;
269 
270 	/* TODO: no mention in spec? possibly used in PS case. Note that aid generated
271 	* from self to peer is stored in scb.
272 	*/
273 	uint8   state;
274 	/* TODO: struct mesh_peer_info *next; this field is required
275 	 * if multiple peerings per same src is allowed, which is
276 	 * true as per spec.
277 	 */
278 } BWL_POST_PACKED_STRUCT mesh_peer_info_t;
279 
280 typedef BWL_PRE_PACKED_STRUCT struct mesh_peer_info_ext {
281 	mesh_peer_info_t	peer_info;
282 	uint16	local_aid;	/* AID generated by *local* to peer */
283 	struct ether_addr ea; /* peer ea */
284 	uint32	entry_state;	/* see MESH_PEER_ENTRY_STATE_ACTIVE etc; valid
285 		* ONLY for internal peering requests
286 		*/
287 	int rssi;
288 } BWL_POST_PACKED_STRUCT mesh_peer_info_ext_t;
289 
290 /* #ifdef WLMESH */
291 typedef BWL_PRE_PACKED_STRUCT struct mesh_peer_info_dump {
292 	uint32 buflen;
293 	uint32 version;
294 	uint32 count;	/* number of results */
295 	mesh_peer_info_ext_t	mpi_ext[1];
296 } BWL_POST_PACKED_STRUCT mesh_peer_info_dump_t;
297 #define WL_MESH_PEER_RES_FIXED_SIZE (sizeof(mesh_peer_info_dump_t) - sizeof(mesh_peer_info_ext_t))
298 
299 #endif /* WLMESH */
300 
301 /* once an entry is added into mesh_peer_list, if peering is lost, it will
302 * get retried for peering, MAX_MESH_PEER_ENTRY_RETRIES times. after wards, it
303 * wont get retried and will be moved to MESH_PEER_ENTRY_STATE_TIMEDOUT state,
304 * until user adds it again explicitely, when its entry_state is changed
305 * to MESH_PEER_ENTRY_STATE_ACTIVE and tried again.
306 */
307 #define MAX_MESH_SELF_PEER_ENTRY_RETRIES	3
308 #define MESH_SELF_PEER_ENTRY_STATE_ACTIVE	1
309 #define MESH_SELF_PEER_ENTRY_STATE_TIMEDOUT	2
310 
311 /** Mesh Channel Switch Parameter IE data structure */
312 BWL_PRE_PACKED_STRUCT struct dot11_mcsp_body {
313 	uint8 ttl;           /* remaining number of hops allowed for this element. */
314 	uint8 flags;         /* attributes of this channel switch attempt */
315 	uint8 reason;        /* reason for the mesh channel switch */
316 	uint16 precedence;    /* random value in the range 0 to 65535 */
317 } BWL_POST_PACKED_STRUCT;
318 
319 #define DOT11_MCSP_TTL_DEFAULT          1
320 #define DOT11_MCSP_FLAG_TRANS_RESTRICT	0x1	/* no transmit except frames with mcsp */
321 #define DOT11_MCSP_FLAG_INIT		0x2	/* initiates the channel switch attempt */
322 #define DOT11_MCSP_FLAG_REASON		0x4	/* validity of reason code field */
323 #define DOT11_MCSP_REASON_REGULATORY	0	/* meet regulatory requirements */
324 #define DOT11_MCSP_REASON_UNSPECIFIED	1	/* unspecified reason */
325 
326 BWL_PRE_PACKED_STRUCT struct dot11_mesh_csp {
327 	uint8 id; /* id DOT11_MNG_MESH_CSP_ID */
328 	uint8 len; /* length of IE */
329 	struct dot11_mcsp_body body; /* body of the ie */
330 } BWL_POST_PACKED_STRUCT;
331 typedef struct dot11_mesh_csp dot11_mesh_csp_ie_t;
332 #define DOT11_MESH_CSP_IE_LEN    5       /* length of mesh channel switch parameter IE body */
333 
334 /* This marks the end of a packed structure section. */
335 #include <packed_section_end.h>
336 
337 #endif  /* #ifndef _802_11s_H_ */
338