xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/include/mbo.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Fundamental types and constants relating to WFA MBO
3  * (Multiband Operation)
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 _MBO_H_
25 #define _MBO_H_
26 
27 /* This marks the start of a packed structure section. */
28 #include <packed_section_start.h>
29 
30 /* WiFi MBO OUI values */
31 #define MBO_OUI         WFA_OUI      /* WiFi OUI 50:6F:9A */
32 /* oui_type field identifying the type and version of the MBO IE. */
33 #define MBO_OUI_TYPE    WFA_OUI_TYPE_MBO /* OUI Type/Version */
34 /* IEEE 802.11 vendor specific information element. */
35 #define MBO_IE_ID          0xdd
36 
37 /* MBO ATTR related macros */
38 #define MBO_ATTR_ID_OFF         0
39 #define MBO_ATTR_LEN_OFF        1
40 #define MBO_ATTR_DATA_OFF       2
41 
42 #define MBO_ATTR_ID_LEN          1      /* Attr ID field length */
43 #define MBO_ATTR_LEN_LEN         1      /* Attr Length field length */
44 #define MBO_ATTR_HDR_LEN         2      /* ID + 1-byte length field */
45 
46 /* MBO subelemts related */
47 #define MBO_SUBELEM_ID          0xdd
48 #define MBO_SUBELEM_OUI         WFA_OUI
49 
50 #define MBO_SUBELEM_ID_LEN          1      /* SubElement ID field length */
51 #define MBO_SUBELEM_LEN_LEN         1      /* SubElement length field length */
52 #define MBO_SUBELEM_HDR_LEN         6      /* ID + length + OUI + OUY TYPE */
53 
54 #define MBO_NON_PREF_CHAN_SUBELEM_LEN_LEN(L)  (7 + (L))  /* value of length field */
55 #define MBO_NON_PREF_CHAN_SUBELEM_TOT_LEN(L) \
56 	(MBO_SUBELEM_ID_LEN + MBO_SUBELEM_LEN_LEN + MBO_NON_PREF_CHAN_SUBELEM_LEN_LEN(L))
57 /* MBO attributes as defined in the mbo spec */
58 enum {
59 	MBO_ATTR_MBO_AP_CAPABILITY = 1,
60 	MBO_ATTR_NON_PREF_CHAN_REPORT = 2,
61 	MBO_ATTR_CELL_DATA_CAP = 3,
62 	MBO_ATTR_ASSOC_DISALLOWED = 4,
63 	MBO_ATTR_CELL_DATA_CONN_PREF = 5,
64 	MBO_ATTR_TRANS_REASON_CODE = 6,
65 	MBO_ATTR_TRANS_REJ_REASON_CODE = 7,
66 	MBO_ATTR_ASSOC_RETRY_DELAY = 8
67 };
68 
69 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_ie_s {
70 	uint8 id;      /* IE ID: MBO_IE_ID 0xDD */
71 	uint8 len;     /* IE length */
72 	uint8 oui[WFA_OUI_LEN]; /* MBO_OUI 50:6F:9A */
73 	uint8 oui_type;   /* MBO_OUI_TYPE 0x16 */
74 	uint8 attr[1]; /* var len attributes */
75 } BWL_POST_PACKED_STRUCT wifi_mbo_ie_t;
76 
77 #define MBO_IE_HDR_SIZE (OFFSETOF(wifi_mbo_ie_t, attr))
78 /* oui:3 bytes + oui type:1 byte */
79 #define MBO_IE_NO_ATTR_LEN  4
80 
81 /* MBO AP Capability Attribute */
82 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_ap_cap_ind_attr_s {
83 	/* Attribute ID - 0x01. */
84 	uint8 id;
85 	/* Length of the following fields in the attribute */
86 	uint8 len;
87 	/* AP capability bitmap */
88 	uint8 cap_ind;
89 } BWL_POST_PACKED_STRUCT wifi_mbo_ap_cap_ind_attr_t;
90 
91 /* MBO AP Capability Indication Field Values */
92 #define MBO_AP_CAP_IND_CELLULAR_AWARE  0x40
93 
94 /* Non-preferred Channel Report Attribute */
95 #define MBO_NON_PREF_CHAN_ATTR_OPCALSS_OFF       2
96 #define MBO_NON_PREF_CHAN_ATTR_CHANLIST_OFF      3
97 #define MBO_NON_PREF_CHAN_ATTR_PREF_OFF(L)      \
98 	(MBO_NON_PREF_CHAN_ATTR_CHANLIST_OFF + (L))
99 
100 #define MBO_NON_PREF_CHAN_ATTR_OPCALSS_LEN       1
101 #define MBO_NON_PREF_CHAN_ATTR_PREF_LEN          1
102 #define MBO_NON_PREF_CHAN_ATTR_REASON_LEN        1
103 
104 #define MBO_NON_PREF_CHAN_ATTR_LEN(L)  ((L) + 3)
105 #define MBO_NON_PREF_CHAN_ATTR_TOT_LEN(L)  (MBO_ATTR_HDR_LEN + (L) + 3)
106 
107 /* attribute len - (opclass + Pref + Reason) */
108 #define MBO_NON_PREF_CHAN_ATTR_CHANLIST_LEN(L) ((L) - 3)
109 
110 /* MBO Non-preferred Channel Report: "Preference" field value */
111 enum {
112 	MBO_STA_NON_OPERABLE_BAND_CHAN = 0,
113 	MBO_STA_NON_PREFERRED_BAND_CHAN = 1,
114 	MBO_STA_PREFERRED_BAND_CHAN = 255
115 };
116 
117 /* MBO Non-preferred Channel Report: "Reason Code" field value */
118 enum {
119 	MBO_NON_PREF_CHAN_RC_UNSPECIFIED = 0,
120 	MBO_NON_PREF_CHAN_RC_BCN_STRENGTH = 1,
121 	MBO_NON_PREF_CHAN_RC_CO_LOC_INTERFERENCE = 2,
122 	MBO_NON_PREF_CHAN_RC_IN_DEV_INTERFERENCE = 3
123 };
124 
125 /* Cellular Data Capability Attribute */
126 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_cell_data_cap_attr_s {
127 	/* Attribute ID - 0x03. */
128 	uint8 id;
129 	/* Length of the following fields in the attribute */
130 	uint8 len;
131 	/* MBO STA's cellular capability */
132 	uint8 cell_conn;
133 } BWL_POST_PACKED_STRUCT wifi_mbo_cell_data_cap_attr_t;
134 
135 /* MBO Cellular Data Capability:  "Cellular Connectivity" field value */
136 enum {
137 	MBO_CELL_DATA_CONN_AVAILABLE = 1,
138 	MBO_CELL_DATA_CONN_NOT_AVAILABLE = 2,
139 	MBO_CELL_DATA_CONN_NOT_CAPABLE = 3
140 };
141 
142 /* Association Disallowed attribute */
143 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_assoc_disallowed_attr_s {
144 	/* Attribute ID - 0x04. */
145 	uint8 id;
146 	/* Length of the following fields in the attribute */
147 	uint8 len;
148 	/* Reason of not accepting new association */
149 	uint8 reason_code;
150 } BWL_POST_PACKED_STRUCT wifi_mbo_assoc_disallowed_attr_t;
151 
152 /* Association Disallowed attr Reason code field values */
153 enum {
154 	MBO_ASSOC_DISALLOWED_RC_UNSPECIFIED = 1,
155 	MBO_ASSOC_DISALLOWED_RC_MAX_STA_REACHED = 2,
156 	MBO_ASSOC_DISALLOWED_RC_AIR_IFACE_OVERLOADED = 3,
157 	MBO_ASSOC_DISALLOWED_RC_AUTH_SRVR_OVERLOADED = 4,
158 	MBO_ASSOC_DISALLOWED_RC_INSUFFIC_RSSI = 5
159 };
160 
161 /* Cellular Data Conn Pref attribute */
162 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_cell_data_conn_pref_attr_s {
163 	/* Attribute ID - 0x05. */
164 	uint8 id;
165 	/* Length of the following fields in the attribute */
166 	uint8 len;
167 	/* Preference value of cellular connection */
168 	uint8 cell_pref;
169 } BWL_POST_PACKED_STRUCT wifi_mbo_cell_data_conn_pref_attr_t;
170 
171 /* Cellular Data Conn Pref attr: Cellular Pref field values */
172 enum {
173 	MBO_CELLULAR_DATA_CONN_EXCLUDED = 1,
174 	MBO_CELLULAR_DATA_CONN_NOT_PREFERRED = 2,
175 	MBO_CELLULAR_DATA_CONN_PREFERRED = 255
176 };
177 
178 /* Transition Reason Code Attribute */
179 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_trans_reason_code_attr_s {
180 	/* Attribute ID - 0x06. */
181 	uint8 id;
182 	/* Length of the following fields in the attribute */
183 	uint8 len;
184 	/* Reason of transition recommendation */
185 	uint8 trans_reason_code;
186 } BWL_POST_PACKED_STRUCT wifi_mbo_trans_reason_code_attr_t;
187 
188 /* Transition Reason Code Attr: trans reason code field values */
189 enum {
190 	MBO_TRANS_REASON_UNSPECIFIED = 0,
191 	MBO_TRANS_REASON_EXCESSV_FRM_LOSS_RATE = 1,
192 	MBO_TRANS_REASON_EXCESSV_TRAFFIC_DELAY = 2,
193 	MBO_TRANS_REASON_INSUFF_BW = 3,
194 	MBO_TRANS_REASON_LOAD_BALANCING = 4,
195 	MBO_TRANS_REASON_LOW_RSSI = 5,
196 	MBO_TRANS_REASON_EXCESSV_RETRANS_RCVD = 6,
197 	MBO_TRANS_REASON_HIGH_INTERFERENCE = 7,
198 	MBO_TRANS_REASON_GRAY_ZONE = 8,
199 	MBO_TRANS_REASON_PREMIUM_AP_TRANS = 9
200 };
201 
202 /* Transition Rejection Reason Code Attribute */
203 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_trans_rej_reason_code_attr_s {
204 	/* Attribute ID - 0x07. */
205 	uint8 id;
206 	/* Length of the following fields in the attribute */
207 	uint8 len;
208 	/* Reason of transition rejection */
209 	uint8 trans_rej_reason_code;
210 } BWL_POST_PACKED_STRUCT wifi_mbo_trans_rej_reason_code_attr_t;
211 
212 /* Transition Rej Reason Code Attr: trans rej reason code field values */
213 enum {
214 	MBO_TRANS_REJ_REASON_UNSPECIFIED = 0,
215 	MBO_TRANS_REJ_REASON_EXSSIV_FRM_LOSS_RATE = 1,
216 	MBO_TRANS_REJ_REASON_EXSSIV_TRAFFIC_DELAY = 2,
217 	MBO_TRANS_REJ_REASON_INSUFF_QOS_CAPACITY = 3,
218 	MBO_TRANS_REJ_REASON_LOW_RSSI = 4,
219 	MBO_TRANS_REJ_REASON_HIGH_INTERFERENCE = 5,
220 	MBO_TRANS_REJ_REASON_SERVICE_UNAVAIL = 6
221 };
222 
223 /* Assoc Retry Delay Attribute */
224 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_assoc_retry_delay_attr_s {
225 	/* Attribute ID - 0x08. */
226 	uint8 id;
227 	/* Length of the following fields in the attribute */
228 	uint8 len;
229 	/* No of Seconds before next assoc attempt */
230 	uint16 reassoc_delay;
231 } BWL_POST_PACKED_STRUCT wifi_mbo_assoc_retry_delay_attr_t;
232 
233 #define MBO_ANQP_OUI_TYPE    0x12     /* OUTI Type/Version */
234 
235 /* MBO ANQP Element */
236 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_anqp_elem_s {
237 	/* ID - 56797 */
238 	uint16 info_id;
239 	/* Length of the OUI + Vendor Specific content */
240 	uint16 len;
241 	/* WFA_OUI 50:6F:9A */
242 	uint8 oui[WFA_OUI_LEN];
243 	/* MBO_ANQP_OUI_TYPE 0x12 */
244 	uint8 oui_type;
245 	/* MBO ANQP element type */
246 	uint8 sub_type;
247 	/* variable len payload */
248 	uint8 payload[1];
249 } BWL_POST_PACKED_STRUCT wifi_mbo_anqp_elem_t;
250 
251 #define MBO_ANQP_ELEM_HDR_SIZE (OFFSETOF(wifi_mbo_anqp_elem_t, payload))
252 
253 /* oui:3 bytes + oui type:1 byte + sub type:1 byte */
254 #define MBO_ANQP_ELEM_NO_PAYLOAD_LEN  5
255 
256 /* MBO ANQP Subtype Values */
257 enum {
258 	MBO_ANQP_ELEM_MBO_QUERY_LIST = 1,
259 	MBO_ANQP_ELEM_CELL_DATA_CONN_PREF = 2
260 };
261 
262 /* MBO sub-elements */
263 typedef BWL_PRE_PACKED_STRUCT struct wifi_mbo_cell_cap_subelem_s {
264 	/* 0xDD */
265 	uint8 sub_elem_id;
266 	/* Length of the following fields in sub-element */
267 	uint8 len;
268 	/* WFA_OUI 50:6F:9A */
269 	uint8 oui[WFA_OUI_LEN];
270 	/* OUI_TYPE 0x03 */
271 	uint8 oui_type;
272 	/* STA cellular capability */
273 	uint8 cell_conn;
274 } BWL_POST_PACKED_STRUCT wifi_mbo_cell_cap_subelem_t;
275 
276 /* This marks the end of a packed structure section. */
277 #include <packed_section_end.h>
278 
279 #endif /* __MBO_H__ */
280