xref: /OK3568_Linux_fs/external/rkwifibt/drivers/infineon/include/mbo.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Fundamental types and constants relating to WFA MBO
3  * (Multiband Operation)
4  * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation
5  *
6  * Copyright (C) 1999-2017, Broadcom Corporation
7  *
8  *      Unless you and Broadcom execute a separate written software license
9  * agreement governing use of this software, this software is licensed to you
10  * under the terms of the GNU General Public License version 2 (the "GPL"),
11  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
12  * following added to such license:
13  *
14  *      As a special exception, the copyright holders of this software give you
15  * permission to link this software with independent modules, and to copy and
16  * distribute the resulting executable under terms of your choice, provided that
17  * you also meet, for each linked independent module, the terms and conditions of
18  * the license of that module.  An independent module is a module which is not
19  * derived from this software.  The special exception does not apply to any
20  * modifications of the software.
21  *
22  *      Notwithstanding the above, under no circumstances may you combine this
23  * software in any way with any other Broadcom software provided under a license
24  * other than the GPL, without Broadcom's express prior written consent.
25  *
26  *
27  * <<Broadcom-WL-IPTag/Open:>>
28  *
29  * $Id$
30  */
31 
32 #ifndef _MBO_H_
33 #define _MBO_H_
34 
35 /* This marks the start of a packed structure section. */
36 #include <packed_section_start.h>
37 
38 /* WiFi MBO OUI values */
39 #define MBO_OUI         WFA_OUI      /* WiFi OUI 50:6F:9A */
40 /* oui_type field identifying the type and version of the MBO IE. */
41 #define MBO_OUI_TYPE    WFA_OUI_TYPE_MBO /* OUI Type/Version */
42 /* IEEE 802.11 vendor specific information element. */
43 #define MBO_IE_ID          0xdd
44 
45 /* MBO ATTR related macros */
46 #define MBO_ATTR_ID_OFF         0
47 #define MBO_ATTR_LEN_OFF        1
48 #define MBO_ATTR_DATA_OFF       2
49 
50 #define MBO_ATTR_ID_LEN          1      /* Attr ID field length */
51 #define MBO_ATTR_LEN_LEN         1      /* Attr Length field length */
52 #define MBO_ATTR_HDR_LEN         2      /* ID + 1-byte length field */
53 
54 /* MBO subelemts related */
55 #define MBO_SUBELEM_ID          0xdd
56 #define MBO_SUBELEM_OUI         WFA_OUI
57 
58 #define MBO_SUBELEM_ID_LEN          1      /* SubElement ID field length */
59 #define MBO_SUBELEM_LEN_LEN         1      /* SubElement length field length */
60 #define MBO_SUBELEM_HDR_LEN         6      /* ID + length + OUI + OUY TYPE */
61 
62 #define MBO_NON_PREF_CHAN_SUBELEM_LEN_LEN(L)  (7 + (L))  /* value of length field */
63 #define MBO_NON_PREF_CHAN_SUBELEM_TOT_LEN(L) \
64 	(MBO_SUBELEM_ID_LEN + MBO_SUBELEM_LEN_LEN + MBO_NON_PREF_CHAN_SUBELEM_LEN_LEN(L))
65 /* MBO attributes as defined in the mbo spec */
66 enum {
67 	MBO_ATTR_MBO_AP_CAPABILITY = 1,
68 	MBO_ATTR_NON_PREF_CHAN_REPORT = 2,
69 	MBO_ATTR_CELL_DATA_CAP = 3,
70 	MBO_ATTR_ASSOC_DISALLOWED = 4,
71 	MBO_ATTR_CELL_DATA_CONN_PREF = 5,
72 	MBO_ATTR_TRANS_REASON_CODE = 6,
73 	MBO_ATTR_TRANS_REJ_REASON_CODE = 7,
74 	MBO_ATTR_ASSOC_RETRY_DELAY = 8
75 };
76 
77 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_ie_s {
78 	uint8 id;      /* IE ID: MBO_IE_ID 0xDD */
79 	uint8 len;     /* IE length */
80 	uint8 oui[WFA_OUI_LEN]; /* MBO_OUI 50:6F:9A */
81 	uint8 oui_type;   /* MBO_OUI_TYPE 0x16 */
82 	uint8 attr[1]; /* var len attributes */
83 } BWL_POST_PACKED_STRUCT wifi_mbo_ie_t;
84 
85 #define MBO_IE_HDR_SIZE (OFFSETOF(wifi_mbo_ie_t, attr))
86 /* oui:3 bytes + oui type:1 byte */
87 #define MBO_IE_NO_ATTR_LEN  4
88 
89 /* MBO AP Capability Attribute */
90 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_ap_cap_ind_attr_s {
91 	/* Attribute ID - 0x01. */
92 	uint8 id;
93 	/* Length of the following fields in the attribute */
94 	uint8 len;
95 	/* AP capability bitmap */
96 	uint8 cap_ind;
97 } BWL_POST_PACKED_STRUCT wifi_mbo_ap_cap_ind_attr_t;
98 
99 /* MBO AP Capability Indication Field Values */
100 #define MBO_AP_CAP_IND_CELLULAR_AWARE  0x40
101 
102 /* Non-preferred Channel Report Attribute */
103 #define MBO_NON_PREF_CHAN_ATTR_OPCALSS_OFF       2
104 #define MBO_NON_PREF_CHAN_ATTR_CHANLIST_OFF      3
105 #define MBO_NON_PREF_CHAN_ATTR_PREF_OFF(L)      \
106 	(MBO_NON_PREF_CHAN_ATTR_CHANLIST_OFF + (L))
107 
108 #define MBO_NON_PREF_CHAN_ATTR_OPCALSS_LEN       1
109 #define MBO_NON_PREF_CHAN_ATTR_PREF_LEN          1
110 #define MBO_NON_PREF_CHAN_ATTR_REASON_LEN        1
111 
112 #define MBO_NON_PREF_CHAN_ATTR_LEN(L)  ((L) + 3)
113 #define MBO_NON_PREF_CHAN_ATTR_TOT_LEN(L)  (MBO_ATTR_HDR_LEN + (L) + 3)
114 
115 /* attribute len - (opclass + Pref + Reason) */
116 #define MBO_NON_PREF_CHAN_ATTR_CHANLIST_LEN(L) ((L) - 3)
117 
118 /* MBO Non-preferred Channel Report: "Preference" field value */
119 enum {
120 	MBO_STA_NON_OPERABLE_BAND_CHAN = 0,
121 	MBO_STA_NON_PREFERRED_BAND_CHAN = 1,
122 	MBO_STA_PREFERRED_BAND_CHAN = 255
123 };
124 
125 /* MBO Non-preferred Channel Report: "Reason Code" field value */
126 enum {
127 	MBO_NON_PREF_CHAN_RC_UNSPECIFIED = 0,
128 	MBO_NON_PREF_CHAN_RC_BCN_STRENGTH = 1,
129 	MBO_NON_PREF_CHAN_RC_CO_LOC_INTERFERENCE = 2,
130 	MBO_NON_PREF_CHAN_RC_IN_DEV_INTERFERENCE = 3
131 };
132 
133 /* Cellular Data Capability Attribute */
134 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_cell_data_cap_attr_s {
135 	/* Attribute ID - 0x03. */
136 	uint8 id;
137 	/* Length of the following fields in the attribute */
138 	uint8 len;
139 	/* MBO STA's cellular capability */
140 	uint8 cell_conn;
141 } BWL_POST_PACKED_STRUCT wifi_mbo_cell_data_cap_attr_t;
142 
143 /* MBO Cellular Data Capability:  "Cellular Connectivity" field value */
144 enum {
145 	MBO_CELL_DATA_CONN_AVAILABLE = 1,
146 	MBO_CELL_DATA_CONN_NOT_AVAILABLE = 2,
147 	MBO_CELL_DATA_CONN_NOT_CAPABLE = 3
148 };
149 
150 /* Association Disallowed attribute */
151 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_assoc_disallowed_attr_s {
152 	/* Attribute ID - 0x04. */
153 	uint8 id;
154 	/* Length of the following fields in the attribute */
155 	uint8 len;
156 	/* Reason of not accepting new association */
157 	uint8 reason_code;
158 } BWL_POST_PACKED_STRUCT wifi_mbo_assoc_disallowed_attr_t;
159 
160 /* Association Disallowed attr Reason code field values */
161 enum {
162 	MBO_ASSOC_DISALLOWED_RC_UNSPECIFIED = 1,
163 	MBO_ASSOC_DISALLOWED_RC_MAX_STA_REACHED = 2,
164 	MBO_ASSOC_DISALLOWED_RC_AIR_IFACE_OVERLOADED = 3,
165 	MBO_ASSOC_DISALLOWED_RC_AUTH_SRVR_OVERLOADED = 4,
166 	MBO_ASSOC_DISALLOWED_RC_INSUFFIC_RSSI = 5,
167 	MBO_ASSOC_DISALLOWED_RC_INVALID = 0xffff
168 };
169 
170 /* Cellular Data Conn Pref attribute */
171 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_cell_data_conn_pref_attr_s {
172 	/* Attribute ID - 0x05. */
173 	uint8 id;
174 	/* Length of the following fields in the attribute */
175 	uint8 len;
176 	/* Preference value of cellular connection */
177 	uint8 cell_pref;
178 } BWL_POST_PACKED_STRUCT wifi_mbo_cell_data_conn_pref_attr_t;
179 
180 /* Cellular Data Conn Pref attr: Cellular Pref field values */
181 enum {
182 	MBO_CELLULAR_DATA_CONN_EXCLUDED = 1,
183 	MBO_CELLULAR_DATA_CONN_NOT_PREFERRED = 2,
184 	MBO_CELLULAR_DATA_CONN_PREFERRED = 255
185 };
186 
187 /* Transition Reason Code Attribute */
188 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_trans_reason_code_attr_s {
189 	/* Attribute ID - 0x06. */
190 	uint8 id;
191 	/* Length of the following fields in the attribute */
192 	uint8 len;
193 	/* Reason of transition recommendation */
194 	uint8 trans_reason_code;
195 } BWL_POST_PACKED_STRUCT wifi_mbo_trans_reason_code_attr_t;
196 
197 /* Transition Reason Code Attr: trans reason code field values */
198 enum {
199 	MBO_TRANS_REASON_UNSPECIFIED = 0,
200 	MBO_TRANS_REASON_EXCESSV_FRM_LOSS_RATE = 1,
201 	MBO_TRANS_REASON_EXCESSV_TRAFFIC_DELAY = 2,
202 	MBO_TRANS_REASON_INSUFF_BW = 3,
203 	MBO_TRANS_REASON_LOAD_BALANCING = 4,
204 	MBO_TRANS_REASON_LOW_RSSI = 5,
205 	MBO_TRANS_REASON_EXCESSV_RETRANS_RCVD = 6,
206 	MBO_TRANS_REASON_HIGH_INTERFERENCE = 7,
207 	MBO_TRANS_REASON_GRAY_ZONE = 8,
208 	MBO_TRANS_REASON_PREMIUM_AP_TRANS = 9
209 };
210 
211 /* Transition Rejection Reason Code Attribute */
212 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_trans_rej_reason_code_attr_s {
213 	/* Attribute ID - 0x07. */
214 	uint8 id;
215 	/* Length of the following fields in the attribute */
216 	uint8 len;
217 	/* Reason of transition rejection */
218 	uint8 trans_rej_reason_code;
219 } BWL_POST_PACKED_STRUCT wifi_mbo_trans_rej_reason_code_attr_t;
220 
221 /* Transition Rej Reason Code Attr: trans rej reason code field values */
222 enum {
223 	MBO_TRANS_REJ_REASON_UNSPECIFIED = 0,
224 	MBO_TRANS_REJ_REASON_EXSSIV_FRM_LOSS_RATE = 1,
225 	MBO_TRANS_REJ_REASON_EXSSIV_TRAFFIC_DELAY = 2,
226 	MBO_TRANS_REJ_REASON_INSUFF_QOS_CAPACITY = 3,
227 	MBO_TRANS_REJ_REASON_LOW_RSSI = 4,
228 	MBO_TRANS_REJ_REASON_HIGH_INTERFERENCE = 5,
229 	MBO_TRANS_REJ_REASON_SERVICE_UNAVAIL = 6
230 };
231 
232 /* Assoc Retry Delay Attribute */
233 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_assoc_retry_delay_attr_s {
234 	/* Attribute ID - 0x08. */
235 	uint8 id;
236 	/* Length of the following fields in the attribute */
237 	uint8 len;
238 	/* No of Seconds before next assoc attempt */
239 	uint16 reassoc_delay;
240 } BWL_POST_PACKED_STRUCT wifi_mbo_assoc_retry_delay_attr_t;
241 
242 #define MBO_ANQP_OUI_TYPE    0x12     /* OUTI Type/Version */
243 
244 /* MBO ANQP Element */
245 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_anqp_elem_s {
246 	/* ID - 56797 */
247 	uint16 info_id;
248 	/* Length of the OUI + Vendor Specific content */
249 	uint16 len;
250 	/* WFA_OUI 50:6F:9A */
251 	uint8 oui[WFA_OUI_LEN];
252 	/* MBO_ANQP_OUI_TYPE 0x12 */
253 	uint8 oui_type;
254 	/* MBO ANQP element type */
255 	uint8 sub_type;
256 	/* variable len payload */
257 	uint8 payload[1];
258 } BWL_POST_PACKED_STRUCT wifi_mbo_anqp_elem_t;
259 
260 #define MBO_ANQP_ELEM_HDR_SIZE (OFFSETOF(wifi_mbo_anqp_elem_t, payload))
261 
262 /* oui:3 bytes + oui type:1 byte + sub type:1 byte */
263 #define MBO_ANQP_ELEM_NO_PAYLOAD_LEN  5
264 
265 /* MBO ANQP Subtype Values */
266 enum {
267 	MBO_ANQP_ELEM_MBO_QUERY_LIST = 1,
268 	MBO_ANQP_ELEM_CELL_DATA_CONN_PREF = 2
269 };
270 
271 /* MBO sub-elements */
272 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_cell_cap_subelem_s {
273 	/* 0xDD */
274 	uint8 sub_elem_id;
275 	/* Length of the following fields in sub-element */
276 	uint8 len;
277 	/* WFA_OUI 50:6F:9A */
278 	uint8 oui[WFA_OUI_LEN];
279 	/* OUI_TYPE 0x03 */
280 	uint8 oui_type;
281 	/* STA cellular capability */
282 	uint8 cell_conn;
283 } BWL_POST_PACKED_STRUCT wifi_mbo_cell_cap_subelem_t;
284 
285 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_perf_chan_subelem_s {
286 	/* 0xDD */
287 	uint8 sub_elem_id;
288 	/* Length of the following fields in sub-element */
289 	uint8 len;
290 	/* WFA_OUI 50:6F:9A */
291 	uint8 oui[WFA_OUI_LEN];
292 	/* OUI_TYPE 0x02 */
293 	uint8 oui_type;
294 	/* variable length of channel preference data */
295 	uint8 data[1];
296 } BWL_POST_PACKED_STRUCT wifi_mbo_pref_chan_subelem_t;
297 
298 /* This marks the end of a packed structure section. */
299 #include <packed_section_end.h>
300 
301 #endif /* __MBO_H__ */
302