• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef _WIFI_MAC_FRAME_H
16 #define _WIFI_MAC_FRAME_H
17 
18 // for the CO_BIT macro
19 #include "wb_co_math.h"
20 #include "wifi_mac.h"
21 #include "rwnx_config.h"
22 
23 /// IV Length
24 #define MAC_IV_LEN          (4)
25 /// EIV Length
26 #define MAC_EIV_LEN         (4)
27 /// Length of the FCS field
28 #define MAC_FCS_LEN     4
29 
30 /// Long MAC Header length (with QoS control field and HT control field)
31 #define MAC_LONG_QOS_HTC_MAC_HDR_LEN   36
32 /// Long MAC Header length (with QoS control field)
33 #define MAC_LONG_QOS_MAC_HDR_LEN       32
34 /// Long MAC Header length (without QoS control field)
35 #define MAC_LONG_MAC_HDR_LEN           30
36 /// Short MAC Header length (with QoS control field and HT control field)
37 #define MAC_SHORT_QOS_HTC_MAC_HDR_LEN  30
38 /// Short MAC Header length (with QoS control field)
39 #define MAC_SHORT_QOS_MAC_HDR_LEN      26
40 /// Short MAC Header length (without QoS control field)
41 #define MAC_SHORT_MAC_HDR_LEN          24
42 
43 /// QoS Control Field Length
44 #define MAC_HDR_QOS_CTRL_LEN           2
45 
46 /// Longest possible MAC Header
47 #define MAC_HDR_LEN_MAX                MAC_LONG_QOS_HTC_MAC_HDR_LEN
48 
49 /// Long control frame header length
50 #define MAC_LONG_CTRLFRAME_LEN         16
51 /// Short control frame header length (ACK/CTS)
52 #define MAC_SHORT_CTRLFRAME_LEN        10
53 
54 /** @} */
55 
56 /**
57  * @name MAC Header offset definitions
58  * @{
59  ****************************************************************************************
60  */
61 /// 802.11 MAC header definition
62 #define MAC_HEAD_FCTRL_OFT              0
63 #define MAC_HEAD_DURATION_OFT           2
64 #define MAC_HEAD_DURATION_CFP      0x8000
65 #define MAC_HEAD_ADDR1_OFT              4
66 #define MAC_HEAD_ADDR2_OFT             10
67 #define MAC_HEAD_ADDR3_OFT             16
68 #define MAC_HEAD_CTRL_OFT              22
69 #define MAC_HEAD_ADDR4_OFT             24
70 #define MAC_HEAD_SHORT_QOS_OFT         24
71 #define MAC_HEAD_LONG_QOS_OFT          30
72 #define MAC_ORIGINAL_ETHTYPE_OFT       36
73 /** @} */
74 
75 
76 
77 /**
78  * @name Frame Control bit field definitions
79  * @{
80  ****************************************************************************************
81  */
82 /* The type information in the header of a frame consists of the Type and Subtype fields
83  * When using the term "frame type" in the code, we refer to the type field and not to
84  * the combined type+subtype information.
85  */
86 /// 802.11 frame control definition
87 #define MAC_FCTRL_LEN                   2
88 
89 #define MAC_FCTRL_PROTOCOLVERSION_MASK  0x0003
90 #define MAC_FCTRL_TYPE_MASK             0x000C
91 #define MAC_FCTRL_SUBT_MASK             0x00F0
92 #define MAC_FCTRL_TODS                  0x0100
93 #define MAC_FCTRL_FROMDS                0x0200
94 #define MAC_FCTRL_MOREFRAG              0x0400
95 #define MAC_FCTRL_RETRY                 0x0800
96 #define MAC_FCTRL_PWRMGT                0x1000
97 #define MAC_FCTRL_MOREDATA              0x2000
98 #define MAC_FCTRL_PROTECTEDFRAME        0x4000
99 #define MAC_FCTRL_ORDER                 0x8000
100 
101 #define MAC_FCTRL_TODS_FROMDS          (MAC_FCTRL_TODS | MAC_FCTRL_FROMDS)
102 /** @} */
103 
104 /**
105  * @name Frame Control Type definitions
106  * @{
107  ****************************************************************************************
108  */
109 /// 802.11 type definition
110 #define MAC_FCTRL_MGT_T                 0x0000
111 #define MAC_FCTRL_CTRL_T                0x0004
112 #define MAC_FCTRL_DATA_T                0x0008
113 /** @} */
114 
115 /**
116  * @name Frame Control Subtype definitions
117  * @{
118  ****************************************************************************************
119  */
120 /// 802.11 subtype definition
121 // Management SubType
122 #define MAC_FCTRL_ASSOCREQ_ST           0x0000
123 #define MAC_FCTRL_ASSOCRSP_ST           0x0010
124 #define MAC_FCTRL_REASSOCREQ_ST         0x0020
125 #define MAC_FCTRL_REASSOCRSP_ST         0x0030
126 #define MAC_FCTRL_PROBEREQ_ST           0x0040
127 #define MAC_FCTRL_PROBERSP_ST           0x0050
128 #define MAC_FCTRL_BEACON_ST             0x0080
129 #define MAC_FCTRL_ATIM_ST               0x0090
130 #define MAC_FCTRL_DISASSOC_ST           0x00A0
131 #define MAC_FCTRL_AUTHENT_ST            0x00B0
132 #define MAC_FCTRL_DEAUTHENT_ST          0x00C0
133 #define MAC_FCTRL_ACTION_ST             0x00D0
134 #define MAC_FCTRL_ACTION_NO_ACK_ST      0x00E0
135 // Control SubTypes
136 #define MAC_FCTRL_HE_TRIGGER_ST         0x0020
137 #define MAC_FCTRL_BFM_REPORT_POLL_ST    0x0040
138 #define MAC_FCTRL_VHT_NDPA_ST           0x0050
139 #define MAC_FCTRL_CTRL_WRAPPER_ST       0x0070
140 #define MAC_FCTRL_BAR_ST                0x0080
141 #define MAC_FCTRL_BA_ST                 0x0090
142 #define MAC_FCTRL_PSPOLL_ST             0x00A0
143 #define MAC_FCTRL_RTS_ST                0x00B0
144 #define MAC_FCTRL_CTS_ST                0x00C0
145 #define MAC_FCTRL_ACK_ST                0x00D0
146 #define MAC_FCTRL_CFEND_ST              0x00E0
147 #define MAC_FCTRL_CFEND_CFACK_ST        0x00F0
148 
149 #define MAC_FCTRL_IS(fc, type) (((fc) & MAC_FCTRL_TYPESUBTYPE_MASK) == MAC_FCTRL_##type)
150 #define MAC_FCTRL_SUBTYPE(fc) (((fc) & MAC_FCTRL_SUBT_MASK) >> 4)
151 
152 // Data SubTypes
153 /* Decoding the subtypes of data type frames can take advantage of the fact that
154  * each subtype field bit position is used to indicate a specific modification of
155  * the basic data frame (subtype 0). Frame control bit 4 is set to 1 in data
156  * subtypes which include +CF-Ack, bit 5 is set to 1 in data subtypes which include
157  * +CF-Poll, bit 6 is set to 1 in data subtypes that contain no Frame Body,
158  * and bit 7 is set to 1 in the QoS data subtypes, which have QoS Control fields in
159  * their MAC headers.
160  *
161  * Usage: check FrameT and FrameSubT individually. If the FrameT is MAC_FCTRL_DATA_T,
162  * check the following bits of the FrameSubT
163  */
164 #define MAC_CFACK_ST_BIT                CO_BIT(4)
165 #define MAC_CFPOLL_ST_BIT               CO_BIT(5)
166 #define MAC_NODATA_ST_BIT               CO_BIT(6)
167 #define MAC_QOS_ST_BIT                  CO_BIT(7)
168 #define MAC_FCTRL_DATACFACKPOLL_ST      (MAC_CFACK_ST_BIT | MAC_CFPOLL_ST_BIT)
169 /** @} */
170 
171 /**
172  * @name Frame Control various frame type/subtype definitions
173  * @{
174  ****************************************************************************************
175  */
176 /// 802.11 type/subtype definition
177 #define MAC_FCTRL_TYPESUBTYPE_MASK      (MAC_FCTRL_TYPE_MASK | MAC_FCTRL_SUBT_MASK)
178 #define MAC_FCTRL_ASSOCREQ              (MAC_FCTRL_MGT_T     | MAC_FCTRL_ASSOCREQ_ST)
179 #define MAC_FCTRL_ASSOCRSP              (MAC_FCTRL_MGT_T     | MAC_FCTRL_ASSOCRSP_ST)
180 #define MAC_FCTRL_REASSOCREQ            (MAC_FCTRL_MGT_T     | MAC_FCTRL_REASSOCREQ_ST)
181 #define MAC_FCTRL_REASSOCRSP            (MAC_FCTRL_MGT_T     | MAC_FCTRL_REASSOCRSP_ST)
182 #define MAC_FCTRL_PROBEREQ              (MAC_FCTRL_MGT_T     | MAC_FCTRL_PROBEREQ_ST)
183 #define MAC_FCTRL_PROBERSP              (MAC_FCTRL_MGT_T     | MAC_FCTRL_PROBERSP_ST)
184 #define MAC_FCTRL_BEACON                (MAC_FCTRL_MGT_T     | MAC_FCTRL_BEACON_ST)
185 #define MAC_FCTRL_ATIM                  (MAC_FCTRL_MGT_T     | MAC_FCTRL_ATIM_ST)
186 #define MAC_FCTRL_DISASSOC              (MAC_FCTRL_MGT_T     | MAC_FCTRL_DISASSOC_ST)
187 #define MAC_FCTRL_AUTHENT               (MAC_FCTRL_MGT_T     | MAC_FCTRL_AUTHENT_ST)
188 #define MAC_FCTRL_DEAUTHENT             (MAC_FCTRL_MGT_T     | MAC_FCTRL_DEAUTHENT_ST)
189 #define MAC_FCTRL_ACTION                (MAC_FCTRL_MGT_T     | MAC_FCTRL_ACTION_ST)
190 #define MAC_FCTRL_ACTION_NO_ACK         (MAC_FCTRL_MGT_T     | MAC_FCTRL_ACTION_NO_ACK_ST)
191 #define MAC_FCTRL_BFM_REPORT_POLL       (MAC_FCTRL_CTRL_T    | MAC_FCTRL_BFM_REPORT_POLL_ST)
192 #define MAC_FCTRL_HE_TRIGGER            (MAC_FCTRL_CTRL_T    | MAC_FCTRL_HE_TRIGGER_ST)
193 #define MAC_FCTRL_VHT_NDPA              (MAC_FCTRL_CTRL_T    | MAC_FCTRL_VHT_NDPA_ST)
194 #define MAC_FCTRL_BA                    (MAC_FCTRL_CTRL_T    | MAC_FCTRL_BA_ST)
195 #define MAC_FCTRL_BAR                   (MAC_FCTRL_CTRL_T    | MAC_FCTRL_BAR_ST)
196 #define MAC_FCTRL_PSPOLL                (MAC_FCTRL_CTRL_T    | MAC_FCTRL_PSPOLL_ST)
197 #define MAC_FCTRL_RTS                   (MAC_FCTRL_CTRL_T    | MAC_FCTRL_RTS_ST)
198 #define MAC_FCTRL_CTS                   (MAC_FCTRL_CTRL_T    | MAC_FCTRL_CTS_ST)
199 #define MAC_FCTRL_ACK                   (MAC_FCTRL_CTRL_T    | MAC_FCTRL_ACK_ST)
200 #define MAC_FCTRL_CFEND                 (MAC_FCTRL_CTRL_T    | MAC_FCTRL_CFEND_ST)
201 #define MAC_FCTRL_CFEND_CFACK           (MAC_FCTRL_CFEND     | MAC_CFACK_ST_BIT)
202 #define MAC_FCTRL_DATA_CFACK            (MAC_FCTRL_DATA_T    | MAC_CFACK_ST_BIT)
203 #define MAC_FCTRL_DATA_CFPOLL           (MAC_FCTRL_DATA_T    | MAC_CFPOLL_ST_BIT)
204 #define MAC_FCTRL_DATA_CFACKPOLL        (MAC_FCTRL_DATA_T    | MAC_FCTRL_DATACFACKPOLL_ST)
205 #define MAC_FCTRL_NULL_FUNCTION         (MAC_FCTRL_DATA_T    | MAC_NODATA_ST_BIT)
206 #define MAC_FCTRL_NULL_CFACK            (MAC_FCTRL_NULL_FUNCTION  | MAC_CFACK_ST_BIT)
207 #define MAC_FCTRL_NULL_CFPOLL           (MAC_FCTRL_NULL_FUNCTION  | MAC_CFPOLL_ST_BIT)
208 #define MAC_FCTRL_NULL_CFACKPOLL        (MAC_FCTRL_NULL_FUNCTION  | MAC_FCTRL_DATACFACKPOLL_ST)
209 #define MAC_FCTRL_QOS_DATA              (MAC_FCTRL_DATA_T    | MAC_QOS_ST_BIT)
210 #define MAC_FCTRL_QOS_DATA_CFACK        (MAC_FCTRL_QOS_DATA  | MAC_CFACK_ST_BIT)
211 #define MAC_FCTRL_QOS_DATA_CFPOLL       (MAC_FCTRL_QOS_DATA  | MAC_CFPOLL_ST_BIT)
212 #define MAC_FCTRL_QOS_DATA_CFACKPOLL    (MAC_FCTRL_QOS_DATA  | MAC_FCTRL_DATACFACKPOLL_ST)
213 #define MAC_FCTRL_QOS_NULL              (MAC_FCTRL_QOS_DATA  | MAC_NODATA_ST_BIT)
214 #define MAC_FCTRL_QOS_NULL_CFACK        (MAC_FCTRL_QOS_DATA  | MAC_FCTRL_NULL_CFACK)
215 #define MAC_FCTRL_QOS_NULL_CFPOLL       (MAC_FCTRL_QOS_DATA  | MAC_FCTRL_NULL_CFPOLL)
216 #define MAC_FCTRL_QOS_NULL_CFACKPOLL    (MAC_FCTRL_QOS_DATA  | MAC_FCTRL_NULL_CFACKPOLL)
217 
218 #define MAC_FCTRL_IS(fc, type) (((fc) & MAC_FCTRL_TYPESUBTYPE_MASK) == MAC_FCTRL_##type)
219 /** @} */
220 
221 /*
222  * FIELD DESCRIPTION
223  ****************************************************************************************
224  */
225 /**
226  * @name Duration/AID field definitions
227  * @{
228  ****************************************************************************************
229  */
230 /// DURATION FIELD Length
231 #define MAC_DURATION_LEN                2
232 
233 /// ASSOCIATION ID Field Mask
234 #define MAC_AID_MSK                     0x3FFF
235 /** @} */
236 
237 #define ADDR1_MUTLICAST_BIT CO_BIT(0)
238 
239 /**
240  * @name Sequence Control definitions
241  * @{
242  ****************************************************************************************
243  */
244 /// 802.11 Sequence Control definition
245 #define MAC_SEQCTRL_LEN                 2
246 #define MAC_SEQCTRL_NUM_OFT             4
247 #define MAC_SEQCTRL_NUM_MSK             0xFFF0
248 #define MAC_SEQCTRL_NUM_MAX             (MAC_SEQCTRL_NUM_MSK >> MAC_SEQCTRL_NUM_OFT)
249 #define MAC_SEQCTRL_FRAG_OFT            0
250 #define MAC_SEQCTRL_FRAG_MSK            0x000F
251 /** @} */
252 
253 /**
254  * @name Security header definitions
255  * @{
256  ****************************************************************************************
257  */
258 /// 802.11 Security header definition
259 #define MAC_HDR_TSC_LEN          6
260 #define MAC_TKIP_TSC1_OFT        0
261 #define MAC_TKIP_TSC0_OFT        2
262 #define MAC_TKIP_KEYID_OFT       3
263 #define MAC_CCMP_PN0_OFT         0
264 #define MAC_CCMP_PN1_OFT         1
265 #define MAC_CCMP_RSV_OFT         2
266 #define MAC_CCMP_PN2BIT_OFT      8
267 #define MAC_IV_EXTIV             0x20000000
268 /** @} */
269 
270 /**
271  * @name QoS Control definitions
272  * @{
273  ****************************************************************************************
274  */
275 /// 802.11 QoS control definition
276 #define MAC_QOSCTRL_LEN                 2
277 #define MAC_QOSCTRL_UP_OFT              0
278 #define MAC_QOSCTRL_UP_MSK              0x0007
279 #define MAC_QOSCTRL_EOSP_OFT            4
280 #define MAC_QOSCTRL_EOSP                0x10
281 #define MAC_QOSCTRL_QUEUE_SIZE_PRESENT  0x10
282 #define MAC_QOSCTRL_QUEUE_SIZE_OFT      8
283 #define MAC_QOSCTRL_QUEUE_SIZE_UNKNOWN  (0xFF << MAC_QOSCTRL_QUEUE_SIZE_OFT)
284 #define MAC_QOSCTRL_HE_QUEUE_SIZE       (MAC_QOSCTRL_QUEUE_SIZE_PRESENT |                \
285                                          MAC_QOSCTRL_QUEUE_SIZE_UNKNOWN)
286 #define MAC_QOSCTRL_ACK_OFT             5
287 #define MAC_QOSCTRL_ACK_NORMAL          0x0000
288 #define MAC_QOSCTRL_ACK_NOACK           0x0020
289 #define MAC_QOSCTRL_ACK_NOEXPL          0x0040
290 #define MAC_QOSCTRL_ACK_BLOCK           0x0060
291 #define MAC_QOSCTRL_AMSDU_OFT           7
292 #define MAC_QOSCTRL_AMSDU_PRESENT       CO_BIT(7)
293 #define MAC_QOSCTRL_MESH_CTRL_PRESENT   CO_BIT(8)
294 #define MAC_QOSCTRL_MESH_POWER_SAVE_LVL CO_BIT(9)
295 #define MAC_QOSCTRL_MESH_RSPI           CO_BIT(10)
296 /** @} */
297 
298 
299 /**
300  * @name HT Control definitions
301  * @{
302  ****************************************************************************************
303  */
304 /// HT CONTROL FIELD
305 #define MAC_HTCTRL_LEN                  4
306 /** @} */
307 
308 
309 /**
310  * @name Capability Information definitions
311  * @{
312  ****************************************************************************************
313  */
314 /// 802.11 Capability definition
315 // CAPABILITY INFORMATION FIELD
316 #define MAC_CAPA_ESS                    CO_BIT(0)
317 #define MAC_CAPA_IBSS                   CO_BIT(1)
318 #define MAC_CAPA_CFPOLL                 CO_BIT(2)
319 #define MAC_CAPA_CFREQ                  CO_BIT(3)
320 #define MAC_CAPA_PRIVA                  CO_BIT(4)
321 #define MAC_CAPA_SHORT_PREAMBLE         CO_BIT(5)
322 #define MAC_CAPA_PBCB                   CO_BIT(6)
323 #define MAC_CAPA_AGILITY                CO_BIT(7)
324 #define MAC_CAPA_SPECTRUM               CO_BIT(8)
325 #define MAC_CAPA_QOS                    CO_BIT(9)
326 #define MAC_CAPA_SHORT_SLOT             CO_BIT(10)
327 //#define MAC_CAPA_ROBUST_SECURITY       CO_BIT(11)
328 #define MAC_CAPA_APSD                   CO_BIT(11)
329 #define MAC_CAPA_DSSS_OFDM              CO_BIT(13)
330 #define MAC_CAPA_DELAYED_BA             CO_BIT(14)
331 #define MAC_CAPA_IMMEDIATE_BA           CO_BIT(15)
332 #define MAC_CAPA_BA_POLICY              (MAC_CAPA_DELAYED_BA | MAC_CAPA_IMMEDIATE_BA)
333 /** @} */
334 
335 /**
336  * @name HT Capability Information Element definitions
337  * @{
338  ****************************************************************************************
339  */
340 /// 802.11 HT capability definition
341 #define MAC_HTCAPA_LDPC                 CO_BIT(0)
342 #define MAC_HTCAPA_40_MHZ               CO_BIT(1)
343 #define MAC_HTCAPA_SMPS_OFT             2
344 #define MAC_HTCAPA_SMPS_MSK             (0x03 << MAC_HTCAPA_SMPS_OFT)
345 #define MAC_HTCAPA_SMPS_STATIC          (0x00 << MAC_HTCAPA_SMPS_OFT)
346 #define MAC_HTCAPA_SMPS_DYNAMIC         (0x01 << MAC_HTCAPA_SMPS_OFT)
347 #define MAC_HTCAPA_SMPS_DISABLE         (0x03 << MAC_HTCAPA_SMPS_OFT)
348 #define MAC_HTCAPA_GREEN_FIELD          CO_BIT(4)
349 #define MAC_HTCAPA_SHORTGI_20           CO_BIT(5)
350 #define MAC_HTCAPA_SHORTGI_40           CO_BIT(6)
351 #define MAC_HTCAPA_TX_STBC              CO_BIT(7)
352 #define MAC_HTCAPA_RX_STBC_OFT          8
353 #define MAC_HTCAPA_RX_STBC_MSK          (0x03 << MAC_HTCAPA_RX_STBC_OFT)
354 #define MAC_HTCAPA_AMSDU                CO_BIT(11)
355 #define MAC_HTCAPA_DSSS_CCK_40          CO_BIT(12)
356 #define MAC_HTCAPA_40_INTOLERANT        CO_BIT(14)
357 #define MAC_HTCAPA_LSIG                 CO_BIT(15)
358 
359 #define MAC_AMPDU_LEN_EXP_OFT           0
360 #define MAC_AMPDU_LEN_EXP_MSK           (0x03 << MAC_AMPDU_LEN_EXP_OFT)
361 #define MAC_AMPDU_MIN_SPACING_OFT       2
362 #define MAC_AMPDU_MIN_SPACING_MSK       (0x07 << MAC_AMPDU_MIN_SPACING_OFT)
363 
364 #define MAC_HT_MAX_AMPDU_FACTOR         13
365 
366 #define MAC_HTXCAPA_MFB_UNSOLICIT       CO_BIT(9)
367 /** @} */
368 
369 
370 /**
371  * @name VHT Capability Information Element definitions
372  * @{
373  ****************************************************************************************
374  */
375 /// 802.11 VHT capability definition
376 #define MAC_VHTCAPA_MAX_MPDU_LENGTH_OFT        0
377 #define MAC_VHTCAPA_MAX_MPDU_LENGTH_MSK        (0x03 << MAC_VHTCAPA_MAX_MPDU_LENGTH_OFT)
378 #define MAC_VHTCAPA_MAX_MPDU_LENGTH_3895       (0x00 << MAC_VHTCAPA_MAX_MPDU_LENGTH_OFT)
379 #define MAC_VHTCAPA_MAX_MPDU_LENGTH_7991       (0x01 << MAC_VHTCAPA_MAX_MPDU_LENGTH_OFT)
380 #define MAC_VHTCAPA_MAX_MPDU_LENGTH_11454      (0x02 << MAC_VHTCAPA_MAX_MPDU_LENGTH_OFT)
381 #define MAC_VHTCAPA_SUPP_CHAN_WIDTH_OFT        2
382 #define MAC_VHTCAPA_SUPP_CHAN_WIDTH_MSK        (0x03 << MAC_VHTCAPA_SUPP_CHAN_WIDTH_OFT)
383 #define MAC_VHTCAPA_SUPP_CHAN_WIDTH_80         (0x00 << MAC_VHTCAPA_SUPP_CHAN_WIDTH_OFT)
384 #define MAC_VHTCAPA_SUPP_CHAN_WIDTH_160        (0x01 << MAC_VHTCAPA_SUPP_CHAN_WIDTH_OFT)
385 #define MAC_VHTCAPA_SUPP_CHAN_WIDTH_160_80P80  (0x02 << MAC_VHTCAPA_SUPP_CHAN_WIDTH_OFT)
386 #define MAC_VHTCAPA_RXLDPC                     CO_BIT(4)
387 #define MAC_VHTCAPA_SHORT_GI_80                CO_BIT(5)
388 #define MAC_VHTCAPA_SHORT_GI_160               CO_BIT(6)
389 #define MAC_VHTCAPA_TXSTBC                     CO_BIT(7)
390 #define MAC_VHTCAPA_RXSTBC_OFT                 8
391 #define MAC_VHTCAPA_RXSTBC_MSK                 (0x07 << MAC_VHTCAPA_RXSTBC_OFT)
392 #define MAC_VHTCAPA_RXSTBC_1                   (0x01 << MAC_VHTCAPA_RXSTBC_OFT)
393 #define MAC_VHTCAPA_RXSTBC_2                   (0x02 << MAC_VHTCAPA_RXSTBC_OFT)
394 #define MAC_VHTCAPA_RXSTBC_3                   (0x03 << MAC_VHTCAPA_RXSTBC_OFT)
395 #define MAC_VHTCAPA_RXSTBC_4                   (0x04 << MAC_VHTCAPA_RXSTBC_OFT)
396 #define MAC_VHTCAPA_SU_BEAMFORMER_CAPABLE      CO_BIT(11)
397 #define MAC_VHTCAPA_SU_BEAMFORMEE_CAPABLE      CO_BIT(12)
398 #define MAC_VHTCAPA_BEAMFORMEE_STS_OFT         13
399 #define MAC_VHTCAPA_BEAMFORMEE_STS_MSK         (0x07 << MAC_VHTCAPA_BEAMFORMEE_STS_OFT)
400 #define MAC_VHTCAPA_SOUNDING_DIMENSIONS_OFT    16
401 #define MAC_VHTCAPA_SOUNDING_DIMENSIONS_MSK    (0x07 << MAC_VHTCAPA_SOUNDING_DIMENSIONS_OFT)
402 #define MAC_VHTCAPA_MU_BEAMFORMER_CAPABLE      CO_BIT(19)
403 #define MAC_VHTCAPA_MU_BEAMFORMEE_CAPABLE      CO_BIT(20)
404 #define MAC_VHTCAPA_VHT_TXOP_PS                CO_BIT(21)
405 #define MAC_VHTCAPA_HTC_VHT                    CO_BIT(22)
406 #define MAC_VHTCAPA_MAX_A_MPDU_LENGTH_EXP_OFT  23
407 #define MAC_VHTCAPA_MAX_A_MPDU_LENGTH_EXP_MSK  (0x07 << MAC_VHTCAPA_MAX_A_MPDU_LENGTH_EXP_OFT)
408 #define MAC_VHTCAPA_VHT_LA_VHT_UNSOL_MFB       0x08000000
409 #define MAC_VHTCAPA_VHT_LA_VHT_MRQ_MFB         0x0c000000
410 #define MAC_VHTCAPA_RX_ANTENNA_PATTERN         CO_BIT(28)
411 #define MAC_VHTCAPA_TX_ANTENNA_PATTERN         CO_BIT(29)
412 
413 #define MAC_VHT_MCS_MAP_MSK                    0x03
414 #define MAC_VHT_MCS_MAP_0_7                    0x00
415 #define MAC_VHT_MCS_MAP_0_8                    0x01
416 #define MAC_VHT_MCS_MAP_0_9                    0x02
417 #define MAC_VHT_MCS_MAP_NONE                   0x03
418 /** @} */
419 
420 /**
421  * @name HE MAC Capability Information Element definitions
422  * @{
423  ****************************************************************************************
424  */
425 /// 802.11 HE MAC capability definition
426 #define HE_MAC_CAPA_HTC_HE_POS                             0
427 #define HE_MAC_CAPA_TWT_REQ_POS                            1
428 #define HE_MAC_CAPA_TWT_RES_POS                            2
429 
430 #define HE_MAC_CAPA_DYNAMIC_FRAG_OFT                       3
431 #define HE_MAC_CAPA_DYNAMIC_FRAG_WIDTH                     2
432 #define HE_MAC_CAPA_DYNAMIC_FRAG_NOT_SUPP                         0x00
433 #define HE_MAC_CAPA_DYNAMIC_FRAG_LEVEL_1                          0x01
434 #define HE_MAC_CAPA_DYNAMIC_FRAG_LEVEL_2                          0x02
435 #define HE_MAC_CAPA_DYNAMIC_FRAG_LEVEL_3                          0x03
436 
437 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_OFT                  5
438 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_WIDTH                3
439 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_1                           0x00
440 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_2                           0x01
441 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_4                           0x02
442 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_8                           0x03
443 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_16                          0x04
444 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_32                          0x05
445 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_64                          0x06
446 #define HE_MAC_CAPA_MAX_NUM_FRAG_MSDU_UNLIMITED                   0x07
447 
448 #define HE_MAC_CAPA_MIN_FRAG_SIZE_OFT                      8
449 #define HE_MAC_CAPA_MIN_FRAG_SIZE_WIDTH                    2
450 #define HE_MAC_CAPA_MIN_FRAG_SIZE_UNLIMITED                       0x00
451 #define HE_MAC_CAPA_MIN_FRAG_SIZE_128                             0x01
452 #define HE_MAC_CAPA_MIN_FRAG_SIZE_256                             0x02
453 #define HE_MAC_CAPA_MIN_FRAG_SIZE_512                             0x03
454 
455 #define HE_MAC_CAPA_TF_MAC_PAD_DUR_OFT                     10
456 #define HE_MAC_CAPA_TF_MAC_PAD_DUR_WIDTH                   2
457 #define HE_MAC_CAPA_TF_MAC_PAD_DUR_0US                            0x00
458 #define HE_MAC_CAPA_TF_MAC_PAD_DUR_8US                            0x01
459 #define HE_MAC_CAPA_TF_MAC_PAD_DUR_16US                           0x02
460 
461 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_OFT                   12
462 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_WIDTH                 3
463 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_1                            0x00
464 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_2                            0x01
465 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_3                            0x02
466 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_4                            0x03
467 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_5                            0x04
468 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_6                            0x05
469 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_7                            0x06
470 #define HE_MAC_CAPA_MULTI_TID_AGG_RX_8                            0x07
471 
472 #define HE_MAC_CAPA_LINK_ADAPTATION_OFT                    15
473 #define HE_MAC_CAPA_LINK_ADAPTATION_WIDTH                  2
474 #define HE_MAC_CAPA_LINK_ADAPTATION_NONE                          0x00
475 #define HE_MAC_CAPA_LINK_ADAPTATION_RSVD                          0x01
476 #define HE_MAC_CAPA_LINK_ADAPTATION_UNSOL                         0x02
477 #define HE_MAC_CAPA_LINK_ADAPTATION_BOTH                          0x03
478 
479 #define HE_MAC_CAPA_ALL_ACK_POS                            17
480 #define HE_MAC_CAPA_TSR_POS                                18
481 #define HE_MAC_CAPA_BSR_POS                                19
482 #define HE_MAC_CAPA_BCAST_TWT_POS                          20
483 #define HE_MAC_CAPA_32BIT_BA_BITMAP_POS                    21
484 #define HE_MAC_CAPA_MU_CASCADING_POS                       22
485 #define HE_MAC_CAPA_ACK_EN_POS                             23
486 #define HE_MAC_CAPA_OM_CONTROL_POS                         25
487 #define HE_MAC_CAPA_OFDMA_RA_POS                           26
488 
489 #define HE_MAC_CAPA_MAX_A_AMPDU_LEN_EXP_OFT                27
490 #define HE_MAC_CAPA_MAX_A_AMPDU_LEN_EXP_WIDTH              2
491 #define HE_MAC_CAPA_MAX_A_AMPDU_LEN_EXP_USE_VHT                   0x00
492 #define HE_MAC_CAPA_MAX_A_AMPDU_LEN_EXP_VHT_1                     0x01
493 #define HE_MAC_CAPA_MAX_A_AMPDU_LEN_EXP_VHT_2                     0x02
494 #define HE_MAC_CAPA_MAX_A_AMPDU_LEN_EXP_RSVD                      0x03
495 
496 #define HE_MAC_CAPA_A_AMSDU_FRAG_POS                       29
497 #define HE_MAC_CAPA_FLEX_TWT_SCHED_POS                     30
498 #define HE_MAC_CAPA_RX_CTRL_FRAME_TO_MULTIBSS_POS          31
499 #define HE_MAC_CAPA_BSRP_BQRP_A_MPDU_AGG_POS               32
500 #define HE_MAC_CAPA_QTP_POS                                33
501 #define HE_MAC_CAPA_BQR_POS                                34
502 #define HE_MAC_CAPA_SRP_RESP_POS                           35
503 #define HE_MAC_CAPA_NDP_FB_REP_POS                         36
504 #define HE_MAC_CAPA_OPS_POS                                37
505 #define HE_MAC_CAPA_AMDSU_IN_AMPDU_POS                     38
506 
507 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_OFT                   39
508 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_WIDTH                 3
509 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_1                            0x00
510 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_2                            0x01
511 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_3                            0x02
512 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_4                            0x03
513 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_5                            0x04
514 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_6                            0x05
515 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_7                            0x06
516 #define HE_MAC_CAPA_MULTI_TID_AGG_TX_8                            0x07
517 
518 #define HE_MAC_CAPA_SUB_CHNL_SEL_TX_POS                    42
519 #define HE_MAC_CAPA_UL_2_996_TONE_RU_POS                   43
520 #define HE_MAC_CAPA_OM_CONTROL_UL_MU_DIS_RX_POS            44
521 #define HE_MAC_CAPA_DYN_SMPS_POS                           45
522 
523 /** @} */
524 
525 /**
526  * @name HE PHY Capability Information Element definitions
527  * @{
528  ****************************************************************************************
529  */
530 /// 802.11 HE PHY capability definition
531 #define HE_PHY_CAPA_CHAN_WIDTH_SET_OFT                     1
532 #define HE_PHY_CAPA_CHAN_WIDTH_SET_WIDTH                   7
533 #define HE_PHY_CAPA_CHAN_WIDTH_SET_40MHZ_IN_2G                    0x01
534 #define HE_PHY_CAPA_CHAN_WIDTH_SET_40MHZ_80MHZ_IN_5G              0x02
535 #define HE_PHY_CAPA_CHAN_WIDTH_SET_160MHZ_IN_5G                   0x04
536 #define HE_PHY_CAPA_CHAN_WIDTH_SET_80PLUS80_MHZ_IN_5G             0x08
537 #define HE_PHY_CAPA_CHAN_WIDTH_SET_RU_MAPPING_IN_2G               0x10
538 #define HE_PHY_CAPA_CHAN_WIDTH_SET_RU_MAPPING_IN_5G               0x20
539 
540 #define HE_PHY_CAPA_PREAMBLE_PUNC_RX_OFT                   8
541 #define HE_PHY_CAPA_PREAMBLE_PUNC_RX_WIDTH                 4
542 #define HE_PHY_CAPA_PREAMBLE_PUNC_RX_80M_ONLY_SCND_20M            0x01
543 #define HE_PHY_CAPA_PREAMBLE_PUNC_RX_80M_ONLY_SCND_40M            0x02
544 #define HE_PHY_CAPA_PREAMBLE_PUNC_RX_160M_ONLY_SCND_20M           0x04
545 #define HE_PHY_CAPA_PREAMBLE_PUNC_RX_160M_ONLY_SCND_40M           0x08
546 
547 #define HE_PHY_CAPA_DEVICE_CLASS_A_POS                     12
548 #define HE_PHY_CAPA_LDPC_CODING_IN_PAYLOAD_POS             13
549 #define HE_PHY_CAPA_HE_SU_PPDU_1x_LTF_AND_GI_0_8US_POS     14
550 
551 #define HE_PHY_CAPA_MIDAMBLE_RX_MAX_NSTS_OFT               15
552 #define HE_PHY_CAPA_MIDAMBLE_RX_MAX_NSTS_WIDTH             2
553 
554 #define HE_PHY_CAPA_NDP_4x_LTF_AND_3_2US_POS               17
555 #define HE_PHY_CAPA_STBC_TX_UNDER_80MHZ_POS                18
556 #define HE_PHY_CAPA_STBC_RX_UNDER_80MHZ_POS                19
557 #define HE_PHY_CAPA_DOPPLER_TX_POS                         20
558 #define HE_PHY_CAPA_DOPPLER_RX_POS                         21
559 #define HE_PHY_CAPA_FULL_BW_UL_MU_MIMO_POS                 22
560 #define HE_PHY_CAPA_PARTIAL_BW_UL_MU_MIMO_POS              23
561 
562 #define HE_PHY_CAPA_DCM_MAX_CONST_TX_OFT                   24
563 #define HE_PHY_CAPA_DCM_MAX_CONST_TX_WIDTH                 2
564 #define HE_PHY_CAPA_DCM_MAX_CONST_TX_NO_DCM                       0x00
565 #define HE_PHY_CAPA_DCM_MAX_CONST_TX_BPSK                         0x01
566 #define HE_PHY_CAPA_DCM_MAX_CONST_TX_QPSK                         0x02
567 #define HE_PHY_CAPA_DCM_MAX_CONST_TX_16_QAM                       0x03
568 
569 #define HE_PHY_CAPA_DCM_MAX_NSS_TX_POS                     26
570 
571 #define HE_PHY_CAPA_DCM_MAX_CONST_RX_OFT                   27
572 #define HE_PHY_CAPA_DCM_MAX_CONST_RX_WIDTH                 2
573 #define HE_PHY_CAPA_DCM_MAX_CONST_RX_NO_DCM                       0x00
574 #define HE_PHY_CAPA_DCM_MAX_CONST_RX_BPSK                         0x01
575 #define HE_PHY_CAPA_DCM_MAX_CONST_RX_QPSK                         0x02
576 #define HE_PHY_CAPA_DCM_MAX_CONST_RX_16_QAM                       0x03
577 
578 #define HE_PHY_CAPA_DCM_MAX_NSS_RX_POS                     29
579 #define HE_PHY_CAPA_RX_HE_MU_PPDU_FRM_NON_AP_POS           30
580 #define HE_PHY_CAPA_SU_BEAMFORMER_POS                      31
581 #define HE_PHY_CAPA_SU_BEAMFORMEE_POS                      32
582 #define HE_PHY_CAPA_MU_BEAMFORMER_POS                      33
583 
584 #define HE_PHY_CAPA_BFMEE_MAX_STS_UNDER_80MHZ_OFT          34
585 #define HE_PHY_CAPA_BFMEE_MAX_STS_UNDER_80MHZ_WIDTH         3
586 #define HE_PHY_CAPA_BFMEE_MAX_STS_UNDER_80MHZ_4                   0x03
587 #define HE_PHY_CAPA_BFMEE_MAX_STS_UNDER_80MHZ_5                   0x04
588 #define HE_PHY_CAPA_BFMEE_MAX_STS_UNDER_80MHZ_6                   0x05
589 #define HE_PHY_CAPA_BFMEE_MAX_STS_UNDER_80MHZ_7                   0x06
590 #define HE_PHY_CAPA_BFMEE_MAX_STS_UNDER_80MHZ_8                   0x07
591 
592 #define HE_PHY_CAPA_BFMEE_MAX_STS_ABOVE_80MHZ_OFT          37
593 #define HE_PHY_CAPA_BFMEE_MAX_STS_ABOVE_80MHZ_WIDTH         3
594 #define HE_PHY_CAPA_BFMEE_MAX_STS_ABOVE_80MHZ_4                   0x03
595 #define HE_PHY_CAPA_BFMEE_MAX_STS_ABOVE_80MHZ_5                   0x04
596 #define HE_PHY_CAPA_BFMEE_MAX_STS_ABOVE_80MHZ_6                   0x05
597 #define HE_PHY_CAPA_BFMEE_MAX_STS_ABOVE_80MHZ_7                   0x06
598 #define HE_PHY_CAPA_BFMEE_MAX_STS_ABOVE_80MHZ_8                   0x07
599 
600 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_OFT      40
601 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_WIDTH     3
602 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_1               0x00
603 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_2               0x01
604 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_3               0x02
605 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_4               0x03
606 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_5               0x04
607 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_6               0x05
608 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_7               0x06
609 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_UNDER_80MHZ_8               0x07
610 
611 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_OFT      43
612 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_WIDTH     3
613 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_1               0x00
614 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_2               0x01
615 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_3               0x02
616 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_4               0x03
617 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_5               0x04
618 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_6               0x05
619 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_7               0x06
620 #define HE_PHY_CAPA_BFMEE_NUM_SND_DIM_ABOVE_80MHZ_8               0x07
621 
622 #define HE_PHY_CAPA_NG16_SU_FEEDBACK_POS                   46
623 #define HE_PHY_CAPA_NG16_MU_FEEDBACK_POS                   47
624 #define HE_PHY_CAPA_CODEBOOK_SIZE_42_SU_POS                48
625 #define HE_PHY_CAPA_CODEBOOK_SIZE_75_MU_POS                49
626 #define HE_PHY_CAPA_TRIG_SU_BEAMFORMER_FB_POS              50
627 #define HE_PHY_CAPA_TRIG_MU_BEAMFORMER_FB_POS              51
628 #define HE_PHY_CAPA_TRIG_CQI_FB_POS                        52
629 #define HE_PHY_CAPA_PARTIAL_BW_EXT_RANGE_POS               53
630 #define HE_PHY_CAPA_PARTIAL_BW_DL_MUMIMO_POS               54
631 #define HE_PHY_CAPA_PPE_THRESHOLD_PRESENT_POS              55
632 #define HE_PHY_CAPA_SRP_BASED_SR_POS                       56
633 #define HE_PHY_CAPA_POWER_BOOST_FACTOR_AR_POS              57
634 #define HE_PHY_CAPA_HE_SU_MU_PPDU_4x_LTF_AND_08_US_GI_POS  58
635 
636 #define HE_PHY_CAPA_MAX_NC_OFT                             59
637 #define HE_PHY_CAPA_MAX_NC_WIDTH                           3
638 #define HE_PHY_CAPA_MAX_NC_1                                      0x01
639 #define HE_PHY_CAPA_MAX_NC_2                                      0x02
640 #define HE_PHY_CAPA_MAX_NC_3                                      0x03
641 #define HE_PHY_CAPA_MAX_NC_4                                      0x04
642 #define HE_PHY_CAPA_MAX_NC_5                                      0x05
643 #define HE_PHY_CAPA_MAX_NC_6                                      0x06
644 #define HE_PHY_CAPA_MAX_NC_7                                      0x07
645 
646 #define HE_PHY_CAPA_STBC_TX_ABOVE_80MHZ_POS                62
647 #define HE_PHY_CAPA_STBC_RX_ABOVE_80MHZ_POS                63
648 #define HE_PHY_CAPA_HE_ER_SU_PPDU_4x_LTF_AND_08_US_GI_POS  64
649 #define HE_PHY_CAPA_20MHZ_IN_40MHZ_HE_PPDU_IN_2G_POS       65
650 #define HE_PHY_CAPA_20MHZ_IN_160MHZ_HE_PPDU_POS            66
651 #define HE_PHY_CAPA_80MHZ_IN_160MHZ_HE_PPDU_POS            67
652 #define HE_PHY_CAPA_HE_ER_SU_1x_LTF_AND_08_US_GI_POS       68
653 #define HE_PHY_CAPA_MIDAMBLE_RX_2x_AND_1x_LTF_POS          69
654 
655 #define HE_PHY_CAPA_DCM_MAX_BW_OFT                         70
656 #define HE_PHY_CAPA_DCM_MAX_BW_WIDTH                        3
657 #define HE_PHY_CAPA_DCM_MAX_BW_20MHZ                              0x00
658 #define HE_PHY_CAPA_DCM_MAX_BW_40MHZ                              0x01
659 #define HE_PHY_CAPA_DCM_MAX_BW_80MHZ                              0x02
660 #define HE_PHY_CAPA_DCM_MAX_BW_160MHZ_80P80MHZ                    0x03
661 
662 #define HE_PHY_CAPA_16PLUS_HE_SIGB_OFDM_SYM_POS            72
663 #define HE_PHY_CAPA_NON_TRIG_CQI_FEEDBACK_POS              73
664 #define HE_PHY_CAPA_TX_1024QAM_LESS_242_RU_POS             74
665 #define HE_PHY_CAPA_RX_1024QAM_LESS_242_RU_POS             75
666 #define HE_PHY_CAPA_RX_FULL_BW_SU_COMP_SIGB_POS            76
667 #define HE_PHY_CAPA_RX_FULL_BW_SU_NON_COMP_SIGB_POS        77
668 
669 #define HE_PHY_CAPA_NOMINAL_PACKET_PADDING_OFT             78
670 #define HE_PHY_CAPA_NOMINAL_PACKET_PADDING_WIDTH           2
671 
672 /** @} */
673 
674 /**
675  * @name HE MCS MAP definitions
676  * @{
677  ****************************************************************************************
678  */
679 /// 802.11 HE MCS map definition
680 #define MAC_HE_MCS_MAP_MSK                                 0x03
681 #define MAC_HE_MCS_MAP_0_7                                 0x00
682 #define MAC_HE_MCS_MAP_0_9                                 0x01
683 #define MAC_HE_MCS_MAP_0_11                                0x02
684 #define MAC_HE_MCS_MAP_NONE                                0x03
685 /** @} */
686 
687 /**
688  * @name Information Element offsets, lengths and other definitions
689  * @{
690  ****************************************************************************************
691  */
692 /// 802.11 information element definition
693 // Offset for the length frame in any element ID
694 #define MAC_LEN_OFT                             1
695 
696 // SSID FIELD
697 #define MAC_SSID_ID_OFT                         0
698 #define MAC_SSID_LEN_OFT                        1
699 #define MAC_SSID_SSID_OFT                       2
700 #define MAC_SSID_MAX_LEN                       (MAC_SSID_LEN + 2)
701 
702 // SUPPORTED RATES FIELD
703 #define MAC_RATES_ID_OFT                        0
704 #define MAC_RATES_LEN_OFT                       1
705 #define MAC_RATES_RATES_OFT                     2
706 #define MAC_RATES_ELMT_MAX_LEN                  8
707 #define MAC_RATES_MAX_LEN                       10
708 #define MAC_RATES_MIN_LEN                       3
709 
710 // FH PARAM SET FIELD
711 #define MAC_FH_ID_OFT                           0
712 #define MAC_FH_LEN_OFT                          1
713 #define MAC_FH_DWELL_OFT                        2
714 #define MAC_FH_HOP_SET_OFT                      4
715 #define MAC_FH_HOP_PAT_OFT                      5
716 #define MAC_FH_HOP_IDX_OFT                      6
717 #define MAC_FH_PARAM_LEN                        7
718 
719 // DS PARAM SET
720 #define MAC_DS_ID_OFT                           0
721 #define MAC_DS_LEN_OFT                          1
722 #define MAC_DS_CHANNEL_OFT                      2
723 #define MAC_DS_PARAM_LEN                        3
724 
725 // CF PARAM SET
726 #define MAC_CF_ID_OFT                           0
727 #define MAC_CF_LEN_OFT                          1
728 #define MAC_CF_COUNT_OFT                        2
729 #define MAC_CF_PERIOD_OFT                       3
730 #define MAC_CF_MAX_DUR_OFT                      4
731 #define MAC_CF_REM_DUR_OFT                      6
732 #define MAC_CF_PARAM_LEN                        8
733 
734 // TIM
735 #define MAC_TIM_ID_OFT                          0
736 #define MAC_TIM_LEN_OFT                         1
737 #define MAC_TIM_CNT_OFT                         2
738 #define MAC_TIM_PERIOD_OFT                      3
739 #define MAC_TIM_BMPC_OFT                        4
740 #define MAC_TIM_BMP_OFT                         5
741 #define MAC_TIM_MIN_LEN                         6
742 #define MAC_TIM_MAX_LEN                        (5 + MAC_TIM_SIZE)
743 #define MAC_TIM_BCMC_PRESENT                    CO_BIT(0)
744 
745 // IBSS PARAM SET
746 #define MAC_IBSS_ID_OFT                         0
747 #define MAC_IBSS_LEN_OFT                        1
748 #define MAC_IBSSATIM_OFT                        2
749 #define MAC_IBSS_PARAM_LEN                      4
750 
751 // Country
752 #define MAC_COUNTRY_ID_OFT                      0
753 #define MAC_COUNTRY_LEN_OFT                     1
754 #define MAC_COUNTRY_MIN_LEN                     8
755 #define MAC_COUNTRY_STRING_OFT                  2
756 #define MAC_COUNTRY_STRING_LEN                  3
757 #define MAC_COUNTRY_FIRST_CHAN_OFT              0
758 #define MAC_COUNTRY_NB_CHAN_OFT                 1
759 #define MAC_COUNTRY_PWR_LEVEL_OFT               2
760 #define MAC_COUNTRY_TRIPLET_LEN                 3
761 
762 // CHALLENGE PARAM SET
763 #define MAC_CHALLENGE_ID_OFT                    0
764 #define MAC_CHALLENGE_LEN_OFT                   1
765 #define MAC_CHALLENGE_TEXT_OFT                  2
766 
767 // ERP
768 #define MAC_ERP_ID_OFT                          0
769 #define MAC_ERP_LEN_OFT                         1
770 #define MAC_ERP_PARAM_OFT                       2
771 #define MAC_ERP_LEN                             3
772 // ERP BIT FIELD
773 #define MAC_ERP_NON_ERP_PRESENT                 CO_BIT(0)
774 #define MAC_ERP_USE_PROTECTION                  CO_BIT(1)
775 #define MAC_ERP_BARKER_PREAMBLE_MODE            CO_BIT(2)
776 #define MAC_ERP_IE_PRESENT                      CO_BIT(7)   // not standard, used internally
777 
778 // RSN INFORMATION FIELD (WPA Extension)
779 #define MAC_RSNIE_ID_OFT                         0
780 #define MAC_RSNIE_LEN_OFT                        1
781 #define MAC_RSNIE_INFO_OFT                       2
782 #define MAC_RSNIE_VERSION_OFT                    2
783 #define MAC_RSNIE_GROUP_CIPHER_OFT               4
784 #define MAC_RSNIE_PAIRWISE_CIPHER_SUITE_CNT_OFT  8
785 #define MAC_RSNIE_PAIRWISE_CIPHER_SUITE_LIST_OFT 10
786 #define MAC_RSNIE_PAIRWISE_CIPHER_SIZE           4
787 #define MAC_RSNIE_KEY_MANAGEMENT_SUITE_CNT_OFT   14
788 #define MAC_RSNIE_KEY_MANAGEMENT_SUITE_LIST_OFT  16
789 #define MAC_RSNIE_KEY_MANAGEMENT_SIZE            4
790 #define MAC_RSNIE_RSN_CAPABILITIES_OFT           20
791 #define MAC_RSNIE_RSN_PMKID_COUNT_OFT            22
792 #define MAC_RSNIE_RSN_PMKID_COUNT_LIST_OFT       24
793 #define MAC_RSNIE_RSN_PMKID_SIZE                 16
794 #define MAC_RSNIE_MIN_LEN                        20
795 
796 // BSS Load IE
797 #define MAC_BSS_LOAD_ID_OFT                     0
798 #define MAC_BSS_LOAD_LEN_OFT                    1
799 #define MAC_BSS_LOAD_STA_CNT_OFT                2
800 #define MAC_BSS_LOAD_CH_UTILIZATION_OFT         4
801 #define MAC_BSS_LOAD_AVAIL_ADM_CAPA             5
802 #define MAC_BSS_LOAD_LEN                        7
803 
804 // EDCA Parameter Set IE
805 #define MAC_EDCA_PARAM_ID_OFT                   0
806 #define MAC_EDCA_PARAM_LEN_OFT                  1
807 #define MAC_EDCA_PARAM_QOS_INFO_OFT             2
808 #define MAC_EDCA_PARAM_RESERVED_OFT             3
809 #define MAC_EDCA_PARAM_BE_PARAM_OFT             4
810 #define MAC_EDCA_PARAM_BK_PARAM_OFT             8
811 #define MAC_EDCA_PARAM_VI_PARAM_OFT             12
812 #define MAC_EDCA_PARAM_VO_PARAM_OFT             16
813 #define MAC_EDCA_PARAM_LEN                      20
814 
815 // QoS Capability IE
816 #define MAC_QOS_CAPA_ID_OFT                     0
817 #define MAC_QOS_CAPA_LEN_OFT                    1
818 #define MAC_QOS_CAPA_INFO_OFT                   2
819 #define MAC_QOS_CAPA_LEN                        3
820 
821 // HT Capability IE
822 #define MAC_HT_CAPA_ID_OFT                      0
823 #define MAC_HT_CAPA_LEN_OFT                     1
824 #define MAC_HT_CAPA_INFO_OFT                    2
825 #define MAC_HT_CAPA_AMPDU_PARAM_OFT             4
826 #define MAC_HT_CAPA_SUPPORTED_MCS_SET_OFT       5
827 #define MAC_HT_CAPA_EXTENDED_CAPA_OFT           21
828 #define MAC_HT_CAPA_TX_BEAM_FORMING_CAPA_OFT    23
829 #define MAC_HT_CAPA_ASEL_CAPA_OFT               27
830 #define MAC_HT_CAPA_ELMT_LEN                    26
831 #define MAC_HT_CAPA_ELMT_LEN_WD                (CO_ALIGN4_HI(MAC_HT_CAPA_ELMT_LEN) / 4)
832 #define MAC_HT_CAPA_LEN                         28
833 
834 // HT Operation IE
835 #define MAC_HT_OPER_ID_OFT                      0
836 #define MAC_HT_OPER_LEN_OFT                     1
837 #define MAC_HT_OPER_PRIM_CH_OFT                 2
838 #define MAC_HT_OPER_INFO_OFT                    3
839 #define MAC_HT_OPER_INFO_SUBSET2_OFT            4
840 #define MAC_HT_OPER_OP_MODE_MASK                0x0003
841 #define MAC_HT_OPER_NONGF_MASK                  0x0004
842 #define MAC_HT_OPER_OBSS_MASK                   0x0010
843 #define MAC_HT_OPER_INFO_SUBSET3_OFT            6
844 #define MAC_HT_OPER_BASIC_MSC_SET_OFT           8
845 #define MAC_HT_OPER_ELMT_LEN                    22
846 #define MAC_HT_OPER_LEN                         24
847 
848 // HT Protection values
849 enum mac_ht_oper_prot_val
850 {
851     MAC_HT_OPER_PROT_NO_PROT   = 0,
852     MAC_HT_OPER_PROT_NONMEMBER,
853     MAC_HT_OPER_PROT_20MHZ,
854     MAC_HT_OPER_PROP_NON_HT_MIXED
855 };
856 
857 // VHT Capability IE
858 #define MAC_VHT_CAPA_ELMT_LEN                   12
859 #define MAC_VHT_CAPA_ELMT_LEN_WD               (CO_ALIGN4_HI(MAC_VHT_CAPA_ELMT_LEN) / 4)
860 #define MAC_VHT_CAPA_LEN                        14
861 #define MAC_VHT_CAPA_ID_OFT                     0
862 #define MAC_VHT_CAPA_LEN_OFT                    1
863 #define MAC_VHT_CAPA_INFO_OFT                   2
864 #define MAC_VHT_RX_MCS_MAP_OFT                  6
865 #define MAC_VHT_RX_HIGHEST_RATE_OFT             8
866 #define MAC_VHT_TX_MCS_MAP_OFT                  10
867 #define MAC_VHT_TX_HIGHEST_RATE_OFT             12
868 
869 // VHT Operation IE
870 #define MAC_VHT_OPER_ELMT_LEN                   5
871 #define MAC_VHT_OPER_LEN                        7
872 #define MAC_VHT_OPER_ID_OFT                     0
873 #define MAC_VHT_OPER_LEN_OFT                    1
874 #define MAC_VHT_CHAN_WIDTH_OFT                  2
875 #define MAC_VHT_CENTER_FREQ0_OFT                3
876 #define MAC_VHT_CENTER_FREQ1_OFT                4
877 #define MAC_VHT_BASIC_MCS_OFT                   5
878 
879 // 20/40 Coexistence IE
880 #define MAC_20_40_COEXISTENCE_ID_OFT                0
881 #define MAC_20_40_COEXISTENCE_LEN_OFT               1
882 #define MAC_20_40_COEXISTENCE_INFO_OFT              2
883 #define MAC_20_40_COEXISTENCE_ELMT_LEN              1
884 #define MAC_20_40_COEXISTENCE_LEN                   3
885 #define MAC_20_40_COEXISTENCE_INFO_REQ_MASK         0x01
886 #define MAC_20_40_COEXISTENCE_40_INTOLERANT_MASK    0x02
887 #define MAC_20_40_COEXISTENCE_20_BSS_WIDTH_REQ_MASK 0x04
888 #define MAC_20_40_COEXISTENCE_OBSS_SCAN_REQ_MASK    0x08
889 #define MAC_20_40_COEXISTENCE_OBSS_SCAN_GRANT_MASK  0x10
890 
891 // Mgmt MIC IE
892 #define MAC_MGMT_MIC_ID_OFT    0
893 #define MAC_MGMT_MIC_LEN_OFT   1
894 #define MAC_MGMT_MIC_KEYID_OFT 2
895 #define MAC_MGMT_MIC_IPN_OFT   4
896 #define MAC_MGMT_MIC_IPN_LEN   6
897 #define MAC_MGMT_MIC_MIC_OFT   10
898 #define MAC_MGMT_MIC_MIC_LEN   8
899 #define MAC_MGMT_MIC_LEN       18
900 
901 // WME IE
902 #define MAC_WMM_PARAM_ELMT_LEN           24
903 #define MAC_WMM_PARAM_LEN                26
904 #define MAC_WMM_PARAM_QOS_INFO_OFT        8
905 #define MAC_WMM_PARAM_SET_CNT_MSK         0x0F
906 #define MAC_WMM_PARAM_RESERVED_OFT        9
907 #define MAC_WMM_PARAM_BK_PARAM_OFT       14
908 #define MAC_WMM_PARAM_BE_PARAM_OFT       10
909 #define MAC_WMM_PARAM_VI_PARAM_OFT       18
910 #define MAC_WMM_PARAM_VO_PARAM_OFT       22
911 
912 // QOS INFORMATION FIELD
913 #define MAC_QINFO_OFT                           6
914 
915 // QOS INFORMATION FIELD received from the AP
916 #define MAC_QINFO_SET_COUNT_OFT                 8
917 #define MAC_QINFO_SET_UAPSD_OFT                 8
918 
919 // Bit position for QOS INFORMATION FEILD received from the AP
920 #define MAC_QINFO_SET_COUNT                     0x07   // Bits 0,1,2
921 #define MAC_QINFO_SET_UAPSD                     0x80   // Bit 7
922 
923 #define SUP_MCS_RX_HIGHEST_RATE_OFT             10 // 10,11th Byte from Start of MCS.
924 #define SUP_MCS_RX_HIGHEST_RATE_SIZE            10 // 10 Bits
925 #define SUP_TX_MCS_SET_OFT                      12 // 12th Byte from Start of MCS.
926 
927 // HE Capability IE
928 #define MAC_HE_CAPA_ID_OFT                      0
929 #define MAC_HE_CAPA_LEN_OFT                     1
930 #define MAC_HE_CAPA_EXT_ID_OFT                  2
931 #if NX_11AX_DRAFT_2_0
932 #define MAC_HE_CAPA_IE_MAC_CAPA_LEN            (MAC_HE_MAC_CAPA_LEN - 1)
933 #define MAC_HE_CAPA_IE_PHY_CAPA_LEN            (MAC_HE_PHY_CAPA_LEN - 2)
934 #else
935 #define MAC_HE_CAPA_IE_MAC_CAPA_LEN             MAC_HE_MAC_CAPA_LEN
936 #define MAC_HE_CAPA_IE_PHY_CAPA_LEN             MAC_HE_PHY_CAPA_LEN
937 #endif
938 #define MAC_HE_MAC_CAPA_INFO_OFT                3
939 #define MAC_HE_PHY_CAPA_INFO_OFT               (MAC_HE_MAC_CAPA_INFO_OFT + MAC_HE_CAPA_IE_MAC_CAPA_LEN)
940 #define MAC_HE_MCS_INFO_OFT                    (MAC_HE_PHY_CAPA_INFO_OFT + MAC_HE_CAPA_IE_PHY_CAPA_LEN)
941 #define MAC_HE_MCS_INFO_PER_BW_LEN              4
942 #define MAC_HE_CAPA_MIN_LEN                    (MAC_HE_MCS_INFO_OFT + MAC_HE_MCS_INFO_PER_BW_LEN)
943 #define MAC_HE_CAPA_MAX_LEN                    (MAC_HE_MCS_INFO_OFT + 3 * MAC_HE_MCS_INFO_PER_BW_LEN +\
944                                                 MAC_HE_PPE_THRES_MAX_LEN)
945 
946 // HE Operation IE
947 #define MAC_HE_OPER_ID_OFT                      0
948 #define MAC_HE_OPER_LEN_OFT                     1
949 #define MAC_HE_OPER_EXT_ID_OFT                  2
950 #define MAC_HE_OPER_PARAM_OFT                   3
951 #define MAC_HE_OPER_PARAM_LEN                   4
952 #if NX_11AX_DRAFT_2_0
953 #define MAC_HE_OPER_BSS_COLOR_OFT               0
954 #define MAC_HE_OPER_BSS_COLOR_PARTIAL_BIT       CO_BIT(20)
955 #define MAC_HE_OPER_BSS_COLOR_DISABLED_BIT      CO_BIT(30)
956 #else
957 #define MAC_HE_OPER_BSS_COLOR_OFT               24
958 #define MAC_HE_OPER_BSS_COLOR_PARTIAL_BIT       CO_BIT(30)
959 #define MAC_HE_OPER_BSS_COLOR_DISABLED_BIT      CO_BIT(31)
960 #endif
961 #define MAC_HE_OPER_BSS_COLOR_MASK             (0x3F << MAC_HE_OPER_BSS_COLOR_OFT)
962 #define MAC_HE_OPER_TXOP_DUR_RTS_THRES_OFT      4
963 #define MAC_HE_OPER_TXOP_DUR_RTS_THRES_MSK     (0x3FF << MAC_HE_OPER_TXOP_DUR_RTS_THRES_OFT)
964 #define MAC_HE_OPER_TXOP_DUR_RTS_THRES_DISABLED 1023
965 #define MAC_HE_OPER_BASIC_MCS_OFT               7
966 #define MAC_HE_OPER_MIN_LEN                     9
967 #define MAC_HE_OPER_MAX_LEN                     13
968 
969 // MU EDCA Operation IE
970 #define MAC_MU_EDCA_ELMT_LEN                    13
971 #define MAC_MU_EDCA_LEN                         16
972 #define MAC_MU_EDCA_ID_OFT                      0
973 #define MAC_MU_EDCA_LEN_OFT                     1
974 #define MAC_MU_EDCA_EXT_ID_OFT                  2
975 #define MAC_MU_EDCA_QOS_INFO_OFT                3
976 #define MAC_MU_EDCA_PARAM_SET_CNT_MSK           0x0F
977 #define MAC_MU_EDCA_AC_BE_OFT                   4
978 #define MAC_MU_EDCA_AC_BK_OFT                   7
979 #define MAC_MU_EDCA_AC_VI_OFT                   10
980 #define MAC_MU_EDCA_AC_VO_OFT                   13
981 
982 #define MAC_MESHID_ELMT_MAX_LEN                 32
983 #define MAC_MESHID_MAX_LEN                      34
984 
985 #define MAC_MPM_INFO_MIN_LEN                    4
986 #define MAC_MPM_PEERING_PROT_OFT               (MAC_INFOELT_INFO_OFT + 0)
987 #define MAC_MPM_LOCAL_LINK_ID_OFT              (MAC_INFOELT_INFO_OFT + 2)
988 #define MAC_MPM_OPT_FIELD_OFT                  (MAC_INFOELT_INFO_OFT + MAC_MPM_INFO_MIN_LEN)
989 #define MAC_MPM_MIN_LEN                         6
990 #define MAC_MPM_MAX_LEN                         26
991 
992 #define MAC_MAW_AWAKE_WIND_OFT                  MAC_INFOELT_INFO_OFT
993 #define MAC_MAW_LEN                             4
994 
995 #define MAC_MCFG_ELMT_LEN                       7
996 #define MAC_MCFG_PATH_SEL_PROT_OFT             (MAC_INFOELT_INFO_OFT + 0)
997 #define MAC_MCFG_PATH_METRIC_PROT_OFT          (MAC_INFOELT_INFO_OFT + 1)
998 #define MAC_MCFG_CONG_CTRL_MODE_OFT            (MAC_INFOELT_INFO_OFT + 2)
999 #define MAC_MCFG_SYNC_METHOD_OFT               (MAC_INFOELT_INFO_OFT + 3)
1000 #define MAC_MCFG_AUTH_PROT_OFT                 (MAC_INFOELT_INFO_OFT + 4)
1001 #define MAC_MCFG_MESH_FORM_INFO_OFT            (MAC_INFOELT_INFO_OFT + 5)
1002 #define MAC_MCFG_MESH_CAP_OFT                  (MAC_INFOELT_INFO_OFT + 6)
1003 #define MAC_MCFG_LEN                            9
1004 /** @} */
1005 
1006 /**
1007  * @name Management Frame Element definitions and offsets
1008  * @{
1009  ****************************************************************************************
1010  */
1011 /// 802.11 Management frame element and offset definition
1012 #define MAC_BEACON_MAX_LEN              333
1013 #define MAC_BEACONINFO_SIZE              78   // size without TIM
1014 #define MAC_TIM_SIZE                    251   // max TIM size
1015 // Attention, in a non-AP STA the IBSS
1016 // parameter set is stored in place of
1017 // the TIM -> min size 4
1018 
1019 #define MAC_BEACON_HDR_LEN               36
1020 
1021 /*
1022  * Beacon Frame offset (Table 5 p46)
1023  */
1024 #define MAC_BEACON_TIMESTAMP_OFT          MAC_SHORT_MAC_HDR_LEN   // Order 1
1025 #define MAC_BEACON_INTERVAL_OFT          (MAC_SHORT_MAC_HDR_LEN + 8)   // Order 2
1026 #define MAC_BEACON_CAPA_OFT              (MAC_SHORT_MAC_HDR_LEN + 10)   // Order 3
1027 #define MAC_BEACON_VARIABLE_PART_OFT     (MAC_SHORT_MAC_HDR_LEN + 12)   // Order 4
1028 /*
1029  * Probe Request Frame offset
1030  */
1031 #define MAC_PROBEREQ_SSID_OFT             0   // Order 1
1032 
1033 /*
1034  * Probe Response Frame offset (Table 12 p49)
1035  */
1036 #define MAC_PROBE_TIMESTAMP_OFT           0   // Order 1
1037 #define MAC_PROBE_INTERVAL_OFT            8   // Order 2
1038 #define MAC_PROBE_CAPA_OFT               10   // Order 3
1039 #define MAC_PROBE_SSID_OFT               12   // Order 4
1040 
1041 /*
1042  * Authentication Frame offset
1043  */
1044 #define MAC_AUTH_ALGONBR_OFT              0   // Order 1
1045 #define MAC_AUTH_SEQNBR_OFT               2   // Order 2
1046 #define MAC_AUTH_STATUS_OFT               4   // Order 3
1047 #define MAC_AUTH_CHALLENGE_OFT            6   // Order 4
1048 #define MAC_AUTH_CHALLENGE_LEN          128
1049 //challenge text IE size
1050 #define CHALLENGE_TEXT_SIZE             130
1051 
1052 /*
1053  * Association Req Frame offset
1054  */
1055 #define MAC_ASSO_REQ_CAPA_OFT             0   // Order 1
1056 #define MAC_ASSO_REQ_LISTEN_OFT           2   // Order 2
1057 #define MAC_ASSO_REQ_SSID_OFT             4   // Order 3
1058 
1059 /*
1060  * Association Rsp Frame offset
1061  */
1062 #define MAC_ASSO_RSP_CAPA_OFT             0   // Order 1
1063 #define MAC_ASSO_RSP_STATUS_OFT           2   // Order 2
1064 #define MAC_ASSO_RSP_AID_OFT              4   // Order 3
1065 #define MAC_ASSO_RSP_RATES_OFT            6   // Order 4
1066 
1067 /*
1068  * Re association Req Frame offset
1069  */
1070 #define MAC_REASSO_REQ_CAPA_OFT           0   // Order 1
1071 #define MAC_REASSO_REQ_LISTEN_OFT         2   // Order 2
1072 #define MAC_REASSO_REQ_AP_ADDR_OFT        4   // Order 3
1073 #define MAC_REASSO_REQ_SSID_OFT          10   // Order 4
1074 
1075 /*
1076  * Deauthentication Req Frame offset
1077  */
1078 
1079 #define MAC_DEAUTH_REASON_OFT             0
1080 
1081 /*
1082  * De association Req Frame offset
1083  */
1084 
1085 #define MAC_DISASSOC_REASON_OFT           0
1086 #define MAC_DISASSOC_REASON_LEN           2
1087 
1088 /*
1089  * Category and action for all action frames
1090  */
1091 #define MAC_ACTION_CATEGORY_OFT           0
1092 #define MAC_ACTION_ACTION_OFT             1
1093 #define MAC_ACTION_TOKEN_OFT              2
1094 #define MAC_ACTION_P2P_ACTION_OFT         5
1095 #define MAC_ACTION_P2P_TAGGED_OFT         7
1096 /** @} */
1097 
1098 /**
1099  * @name Action Frames categories and other definitions
1100  * @{
1101  ****************************************************************************************
1102  */
1103 /// 802.11 Action frame category
1104 #define MAC_SPECTRUM_ACTION_CATEGORY        0
1105 #define MAC_WMMAC_QOS_ACTION_CATEGORY       1
1106 #define MAC_DLS_ACTION_CATEGORY             2
1107 #define MAC_BA_ACTION_CATEGORY              3
1108 #define MAC_PUBLIC_ACTION_CATEGORY          4
1109 #define MAC_RADIO_MEASURE_ACTION_CATEGORY   5
1110 #define MAC_FAST_BSS_ACTION_CATEGORY        6
1111 #define MAC_HT_ACTION_CATEGORY              7
1112 #define MAC_SA_QUERY_ACTION_CATEGORY        8
1113 #define MAC_PROT_PUBLIC_ACTION_CATEGORY     9
1114 #define MAC_WNM_ACTION_CATEGORY            10
1115 #define MAC_UNPROT_WNM_ACTION_CATEGORY     11
1116 #define MAC_TDLS_ACTION_CATEGORY           12
1117 #define MAC_MESH_ACTION_CATEGORY           13
1118 #define MAC_MULTIHOP_ACTION_CATEGORY       14
1119 #define MAC_SELF_PROT_ACTION_CATEGORY      15
1120 #define MAC_VHT_ACTION_CATEGORY            21
1121 #define MAC_VENDOR_PROT_ACTION_CATEGORY   126
1122 #define MAC_VENDOR_ACTION_CATEGORY        127
1123 #define MAC_ACTION_CATEGORY_ERROR         128
1124 
1125 #define MAC_P2P_ACTION_NOA_SUBTYPE          0
1126 
1127 #define MAC_SELF_PROT_ACTION_CAPA_OFT     2
1128 #define MAC_SELF_PROT_ACTION_CAPA_LEN     2
1129 #define MAC_SELF_PROT_ACTION_AID_OFT      4
1130 #define MAC_SELF_PROT_ACTION_AID_LEN      2
1131 /** @} */
1132 
1133 /**
1134  * @name Capability Information definitions
1135  * See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation
1136  * Ethernet-II snap header (RFC1042 for most EtherTypes)
1137  * @{
1138  ****************************************************************************************
1139  */
1140 /// LLC definition
1141 #define FRAME_BODY_LLC_H 0x0003AAAA
1142 #define FRAME_BODY_LLC_L 0x0D890000
1143 #define PAYLOAD_TYPE_TDLS 0x02
1144 
1145 #define MAC_ENCAPSULATED_LLC_H_OFT  0
1146 #define MAC_ENCAPSULATED_LLC_L_OFT  4
1147 #define MAC_ENCAPSULATED_PAYLOAD_TYPE_OFT  8
1148 #define MAC_ENCAPSULATED_PAYLOAD_OFT  9
1149 /** @} */
1150 
1151 /**
1152  * @name WMM-AC Frames and Values definitions
1153  * @{
1154  ****************************************************************************************
1155  */
1156 /*
1157 *---------------------------------------------------------------------------------------
1158 *---------------------------------WMM-AC fields offsets---------------------------------
1159 *---------------------------------------------------------------------------------------
1160 */
1161 /// 802.11 WMM-AC frame definition
1162 #define MAC_WMMAC_OUI_BYTE                              0x00
1163 #define MAC_WMMAC_OUI_TYPE_BYTE                         0x50
1164 #define MAC_WMMAC_OUI_SUBTYPE_BYTE                      0xF2
1165 
1166 /* TSPEC field offsets
1167 *--------------------------------------------------------------------------------------*/
1168 #define MAC_WMMAC_TSPEC_HDR_OFT                         0
1169 #define MAC_WMMAC_TSPEC_TSINFO_OFT                      8
1170 #define MAC_WMMAC_TSPEC_NOM_MSDU_SIZE_OFT              11
1171 #define MAC_WMMAC_TSPEC_MAX_MSDU_SIZE_OFT              13
1172 #define MAC_WMMAC_TSPEC_MINSI_OFT                      15
1173 #define MAC_WMMAC_TSPEC_MAXSI_OFT                      19
1174 #define MAC_WMMAC_TSPEC_INACTIVITY_INTERVAL_OFT        23
1175 #define MAC_WMMAC_TSPEC_SUSPENSION_INTERVAL_OFT        27
1176 #define MAC_WMMAC_TSPEC_SERVICE_START_TIME_OFT         31
1177 #define MAC_WMMAC_TSPEC_MIN_DATA_RATE_OFT              35
1178 #define MAC_WMMAC_TSPEC_MEAN_DATA_RATE_OFT             39
1179 #define MAC_WMMAC_TSPEC_PEAK_DATA_RATE_OFT             43
1180 #define MAC_WMMAC_TSPEC_BURST_SIZE_OFT                 47
1181 #define MAC_WMMAC_TSPEC_DELAY_BOUND_OFT                51
1182 #define MAC_WMMAC_TSPEC_MIN_PHY_RATE_OFT               55
1183 #define MAC_WMMAC_TSPEC_SURPLUS_BW_OFT                 59
1184 #define MAC_WMMAC_TSPEC_MEDUIM_TIME_OFT                61
1185 
1186 /* TSINFO field offsets
1187 *--------------------------------------------------------------------------------------*/
1188 #define MAC_WMMAC_TSINFO_HDR_OFT                        0
1189 #define MAC_WMMAC_TSINFO_BODY_OFT                       8
1190 
1191 /* TSDELAY field offsets
1192 *--------------------------------------------------------------------------------------*/
1193 #define MAC_WMMSA_TSDELAY_HDR_OFT                       0
1194 #define MAC_WMMSA_TSDELAY_BODY_OFT                      8
1195 /*
1196 *---------------------------------------------------------------------------------------
1197 *---------------------------------WMM-AC fields subtypes--------------------------------
1198 *---------------------------------------------------------------------------------------
1199 */
1200 
1201 
1202 #define MAC_WMMAC_OUI_SUBTYPE_TSPEC_LEN                 61
1203 
1204 
1205 #define MAC_OUI_SUBTYPE_WMMAC_TSINFO_LEN                9
1206 
1207 // Used by the unit test of the WMM-AC
1208 #define MAC_OUI_SUBTYPE_WMMAC_TSDELAY_LEN              10
1209 
1210 // Bit position for TSPEC info field
1211 #define MAC_TSPEC_TRAFIC_TYPE_OFT                        0
1212 #define MAC_TSPEC_TRAFIC_TYPE_MASK                       (CO_BIT(0))
1213 
1214 #define MAC_TSPEC_TSID_OFT                               1
1215 #define MAC_TSPEC_TSID_MASK                              (CO_BIT(1)|CO_BIT(2)|CO_BIT(3)|CO_BIT(4))
1216 
1217 #define MAC_TSPEC_DIRECTION_OFT                          5
1218 #define MAC_TSPEC_DIRECTION_MASK                         (CO_BIT(5)|CO_BIT(6))
1219 
1220 #define MAC_TSPEC_ACCESS_POLICY_OFT                      7
1221 #define MAC_TSPEC_ACCESS_POLICY_MASK                     (CO_BIT(7)|CO_BIT(8))
1222 
1223 #define MAC_TSPEC_AGGREGATION_OFT                        9
1224 #define MAC_TSPEC_AGGREGATION_MASK                       (CO_BIT(9))
1225 
1226 #define MAC_TSPEC_APSD_OFT                               10
1227 #define MAC_TSPEC_APSD_MASK                              (CO_BIT(10))
1228 
1229 #define MAC_TSPEC_USER_PRIORITY_OFT                      11
1230 #define MAC_TSPEC_USER_PRIORITY_MASK                     (CO_BIT(11)|CO_BIT(12)|CO_BIT(13))
1231 
1232 #define MAC_TSPEC_ACK_POLICY_OFT                         14
1233 #define MAC_TSPEC_ACK_POLICY_MASK                        (CO_BIT(14)|CO_BIT(15))
1234 
1235 #define MAC_TSPEC_SCHEDULE_OFT                           16
1236 #define MAC_TSPEC_SCHEDULE_MASK                          (CO_BIT(16))
1237 
1238 /*
1239 *---------------------------------------------------------------------------------------
1240 *---------------------------------WMM-AC Status Codes-----------------------------------
1241 *---------------------------------------------------------------------------------------
1242 */
1243 #define MAC_WMMAC_ST_ADDTS_SUCESS                      0
1244 #define MAC_WMMAC_ST_DELTS_POOR_CHANNEL_COND          34
1245 #define MAC_WMMAC_ST_ADDTS_REQUEST_DECLINED           37
1246 #define MAC_WMMAC_ST_ADDTS_INVALID_PARAMETERS         38
1247 #define MAC_WMMAC_ST_ADDTS_REJ_W_SUG_CHANGES          39
1248 #define MAC_WMMAC_ST_ADDTS_REJ_W_DELAY_PRD            47
1249 
1250 /*
1251 *---------------------------------------------------------------------------------------
1252 *---------------------------------WMM-AC Reason Codes-----------------------------------
1253 *---------------------------------------------------------------------------------------
1254 */
1255 #define MAC_WMMAC_RS_DELTS_QSTA_LEAVING               36
1256 #define MAC_WMMAC_RS_DELTS_END_TS                     37
1257 #define MAC_WMMAC_RS_DELTS_UNKOWN_TS                  38
1258 #define MAC_WMMAC_RS_DELTS_TIMEOUT                    39
1259 #define MAC_WMMAC_RS_DELTS_UNSPECIFIED                32
1260 
1261 
1262 /*
1263 *---------------------------------------------------------------------------------------
1264 *---------------------------------WMM-AC Action Frames----------------------------------
1265 *---------------------------------------------------------------------------------------
1266 */
1267 
1268 
1269 /* CATEGORY \ ACTION values
1270 *--------------------------------------------------------------------------------------*/
1271 #define MAC_WMMAC_ACTION_ADDTS_REQ        0
1272 #define MAC_WMMAC_ACTION_ADDTS_RSP        1
1273 #define MAC_WMMAC_ACTION_DELTS            2
1274 #define MAC_WMMAC_ACTION_SCHEDULE         3
1275 
1276 
1277 /* ADDTS_REQ offsets
1278 *--------------------------------------------------------------------------------------*/
1279 
1280 #define MAC_ADDTS_REQ_TSPEC_OFT           3
1281 #define MAC_ADDTS_REQ_TCLASS_OFT         66
1282 
1283 
1284 /* ADDTS_RSP offsets
1285 *--------------------------------------------------------------------------------------*/
1286 
1287 #define MAC_ADDTS_RSP_STATUS_OFT          3
1288 #define MAC_ADDTS_RSP_TSDELAY_OFT         5
1289 #define MAC_ADDTS_RSP_TSPEC_OFT          17
1290 #define MAC_ADDTS_RSP_TCLASS_OFT         80
1291 
1292 /* DELTS offsets
1293 *--------------------------------------------------------------------------------------*/
1294 
1295 #define MAC_DELTS_TSINFO_OFT              2
1296 #define MAC_DELTS_REASON_OFT             13
1297 
1298 /** @} */
1299 
1300 /**
1301  * @name Block-Ack Frames and Values definitions
1302  * @{
1303  ****************************************************************************************
1304  */
1305 /*
1306 *---------------------------------------------------------------------------------------
1307 *---------------------------------Block Ack fields offsets---------------------------------
1308 *---------------------------------------------------------------------------------------
1309 */
1310 /// 802.11 BlockAck action frame definition
1311 #define MAC_BARINFO_PERTIDINFO_OFT              0
1312 #define MAC_BARINFO_PERTIDINFO_STEP             1
1313 #define MAC_BARINFO_SEQ_OFT                     2
1314 #define MAC_BARINFO_PERTIDINFO_TID_STEP         4
1315 #define MAC_CAPA_BA_OFT                         14
1316 
1317 // the length of fields
1318 #define MAC_BA_PARAMSET_LEN                     2
1319 #define MAC_BA_TIMEOUT_LEN                      2
1320 #define MAC_BA_BARINFO_LEN                      4
1321 #define MAC_BA_DELBA_REASON_LEN                 2
1322 
1323 // value of the The Fragment Number
1324 #define MAC_BARINFO_SEQ_FRAG                    0
1325 
1326 // offset of The DELPARAMSET
1327 #define MAC_DELPARAMSET_START_OFT               0
1328 #define MAC_DELPARAMSET_STEP_OFT                1
1329 
1330 // Bit position for Parameter Set field
1331 #define MAC_BA_PARAMSET_AMSDU_OFT               0
1332 #define MAC_BA_PARAMSET_AMSDU_MASK              CO_BIT(0)
1333 
1334 #define MAC_BA_PARAMSET_POLICY_OFT              1
1335 #define MAC_BA_PARAMSET_POLICY_MASK             CO_BIT(1)
1336 
1337 #define MAC_BA_PARAMSET_TID_OFT                 2
1338 #define MAC_BA_PARAMSET_TID_MASK                (CO_BIT(2)|CO_BIT(3)|CO_BIT(4)|CO_BIT(5))
1339 
1340 #define MAC_BA_PARAMSET_BUFFER_OFT              6
1341 #define MAC_BA_PARAMSET_BUFFER_MASK             0xFFC0
1342 
1343 //Bit position for Per TID Info field
1344 #define MAC_BA_BARINFO_PERTIDINFO_TID_OFT       12
1345 #define MAC_BA_BARINFO_PERTIDINFO_TID_MASK  (CO_BIT(12)|CO_BIT(13))|(CO_BIT(14)|CO_BIT(15))
1346 
1347 //Bit position for Starting Sequence Control filed
1348 #define MAC_BA_BARINFO_SEQ_FRAG_OFT             0
1349 #define MAC_BA_BARINFO_SEQ_FRAG_MASK        (CO_BIT(0)|CO_BIT(1))|(CO_BIT(2)|CO_BIT(3))
1350 
1351 #define MAC_BA_BARINFO_SEQ_STARTSEQ_OFT         4
1352 #define MAC_BA_BARINFO_SEQ_STARTSEQ_MASK        0x7FF0
1353 
1354 //Bit position for DELBA Parameter Set field
1355 #define MAC_BA_DELPARAMSET_INIT_OFT             3
1356 #define MAC_BA_DELBARINFO_INIT_MASK             CO_BIT(3)
1357 
1358 #define MAC_BA_DELPARAMSET_TID_OFT              4
1359 #define MAC_BA_DELPARAMSET_TID_MASK         (CO_BIT(4)|CO_BIT(5)|CO_BIT(6)|CO_BIT(7))
1360 
1361 /*
1362 *---------------------------------------------------------------------------------------
1363 *---------------------------------Block Ack Status Codes-----------------------------------
1364 *---------------------------------------------------------------------------------------
1365 */
1366 #define MAC_BA_ST_SUCCESS                     0
1367 #define MAC_BA_ST_REQUEST_REFUSED             37
1368 #define MAC_BA_ST_INVALID_PARAMETERS          38
1369 
1370 /*
1371 *---------------------------------------------------------------------------------------
1372 *---------------------------------Block Ack Reason Codes-----------------------------------
1373 *---------------------------------------------------------------------------------------
1374 */
1375 #define MAC_BA_RS_STA_LEAVING                 36
1376 #define MAC_BA_RS_END_BA                      37
1377 #define MAC_BA_RS_UNKNOWN_BA                  38
1378 #define MAC_BA_RS_TIMEOUT                     39
1379 
1380 /*
1381 *---------------------------------------------------------------------------------------
1382 *---------------------------------Block Ack Action Frames----------------------------------
1383 *---------------------------------------------------------------------------------------
1384 */
1385 
1386 
1387 /* CATEGORY \ ACTION values
1388 *--------------------------------------------------------------------------------------*/
1389 
1390 #define MAC_BA_ACTION_ADDBA_REQ         0
1391 #define MAC_BA_ACTION_ADDBA_RSP         1
1392 #define MAC_BA_ACTION_DELBA             2
1393 
1394 
1395 /* ADDBA_REQ offsets
1396 *--------------------------------------------------------------------------------------*/
1397 
1398 #define MAC_ADDBA_REQ_PARAMSET_OFT      3
1399 #define MAC_ADDBA_REQ_TIMEOUT_OFT       5
1400 #define MAC_ADDBA_REQ_BARINFO_OFT       7
1401 
1402 
1403 /* ADDBA_RSP offsets
1404 *--------------------------------------------------------------------------------------*/
1405 
1406 #define MAC_ADDBA_RSP_STATUS_OFT        3
1407 #define MAC_ADDBA_RSP_PARAMSET_OFT      5
1408 #define MAC_ADDBA_RSP_TIMEOUT_OFT       7
1409 
1410 
1411 /* DELBA offsets
1412 *--------------------------------------------------------------------------------------*/
1413 
1414 #define MAC_DELBA_PARAMSET_OFT          2
1415 #define MAC_DELBA_REASON_OFT            4
1416 
1417 /** @} */
1418 
1419 
1420 /**
1421  * @name TDLS Action Frames definitions
1422  * @{
1423  ****************************************************************************************
1424  */
1425 /* CATEGORY \ ACTION values
1426 *--------------------------------------------------------------------------------------*/
1427 /// 802.11 TDLS action frame definition
1428 #define MAC_TDLS_ACTION_SETUP_REQ           0
1429 #define MAC_TDLS_ACTION_SETUP_RSP           1
1430 #define MAC_TDLS_ACTION_SETUP_CFM           2
1431 #define MAC_TDLS_ACTION_TEARDOWN            3
1432 #define MAC_TDLS_ACTION_PEER_TRAFFIC_IND    4
1433 #define MAC_TDLS_ACTION_CHANSW_REQ          5
1434 #define MAC_TDLS_ACTION_CHANSW_RSP          6
1435 #define MAC_TDLS_ACTION_PEER_TRAFFIC_RSP    9
1436 #define MAC_TDLS_ACTION_DISCOVERY_REQ       10
1437 
1438 #define TDLS_CHANSW_REQ_TARGET_CH_OFFSET    2
1439 #define TDLS_CHANSW_REQ_OP_CLASS            3
1440 #define TDLS_CHANSW_REQ_IES_OFFSET          4
1441 #define TDLS_CHANSW_REQ_IE_SEC_CH_OFT_LEN   3
1442 #define TDLS_CHANSW_REQ_IE_LINK_ID_LEN      20
1443 #define TDLS_CHANSW_REQ_IE_CH_SWITCH_TIMING_LEN 6
1444 #define TDLS_CHANSW_REQ_IE_WIDE_BW_CHAN_SWITCH_LEN 5
1445 
1446 #define TDLS_CHANSW_RSP_STATUS_OFFSET       2
1447 #define TDLS_CHANSW_RSP_IES_OFFSET          4
1448 
1449 #define TDLS_CHANSW_REQUEST_ACCEPTED        0
1450 #define TDLS_CHANSW_REQUEST_DECLINED        37
1451 
1452 #define TDLS_PEER_TRAFFIC_IND_IES_OFFSET    3
1453 #define TDLS_PEER_TRAFFIC_IND_IE_LINK_ID_LEN 20
1454 #define TDLS_PEER_TRAFFIC_IND_IE_PTI_CTRL_LEN 5
1455 #define TDLS_PEER_TRAFFIC_IND_IE_TPU_BUF_STATUS_LEN 3
1456 
1457 #define TDLS_PEER_TRAFFIC_RSP_IES_OFFSET    3
1458 #define TDLS_PEER_TRAFFIC_RSP_IE_LINK_ID_LEN 20
1459 
1460 /** @} */
1461 
1462 
1463 /**
1464  * @name Link Management definitions
1465  * @{
1466  ****************************************************************************************
1467  */
1468 /// 802.11 Link Management frame definition
1469 #define MAC_HEAD_HT_OFT                  32
1470 #define MAC_MAI_MASK                     0x003C
1471 #define MAC_MAI_OFT                      2
1472 #define MAC_MAI_IND_ASELI                14
1473 #define MAC_MFB_MASK                     0xFE00
1474 #define MAC_MFB_OFT                      9
1475 #define NO_FEEDBACK                      127
1476 #define MAC_ADDR2_OFT                    10
1477 #define MCS_IDX3_MASK                    0x0000FF
1478 #define MCS_IDX2_MASK                    0x00FF00
1479 #define MCS_IDX1_MASK                    0xFF0000
1480 #define MCS_IDX2_OFT                     8
1481 #define MCS_IDX1_OFT                     16
1482 
1483 /** @} */
1484 
1485 /**
1486  * @name Spectrum and Power Management Frame definitions
1487  * @{
1488  ****************************************************************************************
1489  */
1490 /// 802.11 Spectrum and Power Management frame definition
1491 #define MAC_ACTION_FRAME_INFO_OFT           3
1492 #define MAC_ACTION_CH_SWITCH_FRAME_INFO_OFT 2
1493 #define MAC_ACTION_FRAME_PRE_INFO_LEN       3
1494 
1495 //Spectrum & Power Management Element Offset
1496 
1497 // Power Constraint Element
1498 #define MAC_INFOELT_POWER_CONSTRAINT_OFT     2
1499 
1500 #define MAC_POWER_CONSTRAINT_ELT_LEN         3
1501 
1502 // Power Capability Element
1503 #define MAC_INFOELT_MIN_TX_POWER_OFT         2
1504 #define MAC_INFOELT_MAX_TX_POWER_OFT         3
1505 
1506 #define MAC_POWER_CAPABILITY_ELT_LEN         4
1507 #define MAC_POWER_CAPABILITY_ELT_LEN_FIELD   2
1508 
1509 // TPC Report Info Element sub-offsets
1510 #define MAC_INFOELT_TX_POWER_OFT             2
1511 #define MAC_INFOELT_LINK_MARGIN_OFT          3
1512 
1513 // TPC Report and Request IE lengths
1514 #define MAC_TPC_REQUEST_ELT_LEN              2
1515 #define MAC_TPC_REPORT_ELT_LEN               4
1516 // TPC Report and Request IE's length field values
1517 #define MAC_INFOELT_LEN_VAL_TPC_REQ          0
1518 #define MAC_INFOELT_LEN_VAL_TPC_REP          2
1519 // TPC Report and Request Action frame lengths
1520 #define MAC_ACTION_FRAME_TPC_REQ_LEN         5
1521 #define MAC_ACTION_FRAME_TPC_REP_LEN         7
1522 
1523 
1524 // Supported Channels Element
1525 #define MAC_INFOELT_FIRST_CHANNEL_OFT        2
1526 #define MAC_INFOELT_NUMBER_CHANNEL_OFT       3
1527 
1528 // Channel Switch Announcement Element
1529 #define MAC_INFOELT_SWITCH_MODE_OFT          2
1530 #define MAC_INFOELT_SWITCH_NEW_CHAN_OFT      3
1531 #define MAC_INFOELT_SWITCH_COUNT_OFT         4
1532 
1533 #define MAC_CHANNEL_SWITCH_INFO_LEN          3
1534 #define MAC_CHANNEL_SWITCH_ELT_LEN           5
1535 
1536 // Extended Channel Switch Announcement Element
1537 #define MAC_INFOELT_EXT_SWITCH_MODE_OFT      2
1538 #define MAC_INFOELT_EXT_SWITCH_NEW_CLASS     3
1539 #define MAC_INFOELT_EXT_SWITCH_NEW_CHAN_OFT  4
1540 #define MAC_INFOELT_EXT_SWITCH_COUNT_OFT     5
1541 
1542 #define MAC_EXT_CHANNEL_SWITCH_INFO_LEN      4
1543 #define MAC_EXT_CHANNEL_SWITCH_ELT_LEN       6
1544 
1545 // Secondary Channel Offset Element
1546 #define MAC_INFOELT_SEC_CH_OFFSET_OFT        2
1547 
1548 #define MAC_INFOELT_SEC_CH_OFFSET_INFO_LEN   1
1549 #define MAC_INFOELT_SEC_CH_OFFSET_ELT_LEN    3
1550 
1551 #define MAC_INFOELT_SEC_CH_OFFSET_SEC_CH_OFT 2
1552 #define MAC_INFOELT_SEC_CH_OFFSET_NO_SEC_CH  0
1553 #define MAC_INFOELT_SEC_CH_OFFSET_SEC_ABOVE  1
1554 #define MAC_INFOELT_SEC_CH_OFFSET_SEC_BELOW  3
1555 
1556 // Wide BAndwidth Channel switch
1557 #define MAC_INFOELT_WIDE_BW_CHAN_SWITCH_NEW_CW_OFT 2
1558 #define MAC_INFOELT_WIDE_BW_CHAN_SWITCH_NEW_CENTER1_OFT 3
1559 #define MAC_INFOELT_WIDE_BW_CHAN_SWITCH_NEW_CENTER2_OFT 4
1560 #define MAC_INFOELT_WIDE_BW_CHAN_SWITCH_INFO_LEN 3
1561 #define MAC_INFOELT_WIDE_BW_CHAN_SWITCH_ELT_LEN  5
1562 
1563 // Measurement Request/Report Element
1564 #define MAC_INFOELT_MEASURE_TOKEN_OFT        2
1565 #define MAC_INFOELT_MEASURE_MODE_OFT         3
1566 #define MAC_INFOELT_MEASURE_TYPE_OFT         4
1567 #define MAC_INFOELT_MEASURE_CH_NBR_OFT       5
1568 #define MAC_INFOELT_MEASURE_START_TIME_OFT   6
1569 #define MAC_INFOELT_MEASURE_DURATION_OFT     14
1570 
1571 #define MAC_INFOELT_MEASURE_INFO_OFT        16
1572 
1573 #define MAC_MEAS_REQ_CNF_ELT_LEN             5
1574 #define MAC_MEAS_REQ_ELT_LEN                16
1575 #define MAC_MEAS_REQ_FRAME_LEN              19
1576 #define MAC_MEAS_REP_BASIC_ELT_LEN          17
1577 #define MAC_MEAS_REP_BASIC_FRAME_LEN        20
1578 #define MAC_MEAS_REP_CCA_ELT_LEN            17
1579 #define MAC_MEAS_REP_CCA_FRAME_LEN          20
1580 #define MAC_MEAS_REP_RPI_ELT_LEN            24
1581 #define MAC_MEAS_REP_RPI_FRAME_LEN          27
1582 #define MAC_MEAS_REP_ERR_ELT_LEN             5
1583 #define MAC_MEAS_REP_ERR_FRAME_LEN           8
1584 
1585 // Mobility Domain Element (MDE)
1586 #define MAC_INFOELT_MDE_ID_OFT               0
1587 #define MAC_INFOELT_MDE_LEN_OFT              1
1588 #define MAC_INFOELT_MDE_MDID_OFT             2
1589 #define MAC_INFOELT_MDE_FT_CAPA_POL_OFT      4
1590 #define MAC_INFOELT_MDE_MDID_LEN             2
1591 #define MAC_INFOELT_MDE_FT_CAPA_POL_LEN      1
1592 #define MAC_INFOELT_MDE_ELMT_LEN             3
1593 #define MAC_INFOELT_MDE_LEN                  5
1594 
1595 // Link Identifier Element
1596 #define MAC_INFOELT_LINK_ID_LEN              18
1597 #define MAC_INFOELT_LINK_ID_BSSID_OFT        2
1598 #define MAC_INFOELT_LINK_ID_INIT_STA_OFT     8
1599 #define MAC_INFOELT_LINK_ID_RESP_STA_OFT     14
1600 
1601 // Link Identifier Element
1602 #define MAC_INFOELT_CH_SWITCH_TIMING_LEN     4
1603 #define MAC_INFOELT_CH_SWITCH_TIMING_SWTIME_OFT 2
1604 #define MAC_INFOELT_CH_SWITCH_TIMING_SWTOUT_OFT 4
1605 
1606 // PTI Control Element
1607 #define MAC_INFOELT_PTI_CONTROL_LEN          3
1608 #define MAC_INFOELT_PTI_CONTROL_TID_OFT      2
1609 #define MAC_INFOELT_PTI_CONTROL_SEQ_CTRL_OFT 3
1610 
1611 // TPU Buffer Status Element
1612 #define MAC_INFOELT_TPU_BUF_STATUS_LEN       1
1613 #define MAC_INFOELT_TPU_BUF_STATUS_AC_STATUS 2
1614 
1615 // Spectrum management frame values:
1616 //----------------------------------
1617 
1618 //TO_DO_MMH:Remove unused fields
1619 
1620 //MAC Action Spectrum Categorie => Sub Action
1621 /// 802.11 Spectrum management frame definition
1622 #define MAC_ACTION_MEASURE_REQUEST        0
1623 #define MAC_ACTION_MEASURE_REPORT         1
1624 #define MAC_ACTION_TPC_REQUEST            2
1625 #define MAC_ACTION_TPC_REPORT             3
1626 #define MAC_ACTION_CHANNEL_SWITCH         4
1627 
1628 // Channel Switch Annoncement Mode
1629 #define MAC_SWITCH_MODE_TX_TRAFFIC_CONT   0
1630 #define MAC_SWITCH_MODE_TX_TRAFFIC_STOP   1
1631 
1632 // Measurement Request Mode
1633 #define MAC_MEASURE_MODE_ENABLE           CO_BIT(1)
1634 #define MAC_MEASURE_MODE_REQUEST          CO_BIT(2)
1635 #define MAC_MEASURE_MODE_REPORT           CO_BIT(3)
1636 
1637 // Measurement Report Mode
1638 #define MAC_MEASURE_MODE_LATE             CO_BIT(0)
1639 #define MAC_MEASURE_MODE_INCAPABLE        CO_BIT(1)
1640 #define MAC_MEASURE_MODE_REFUSED          CO_BIT(2)
1641 
1642 // Measurement Request Type
1643 #define MAC_MEASURE_TYPE_BASIC            0
1644 #define MAC_MEASURE_TYPE_CCA              1
1645 #define MAC_MEASURE_TYPE_RPI              2
1646 
1647 // Measurement Report Map Bits
1648 #define MAC_MEASURE_MAP_FREE              0x00
1649 #define MAC_MEASURE_MAP_BSS               CO_BIT(0)
1650 #define MAC_MEASURE_MAP_OFDM              CO_BIT(1)
1651 #define MAC_MEASURE_MAP_UNIDENTIFIED      CO_BIT(2)
1652 #define MAC_MEASURE_MAP_RADAR             CO_BIT(3)
1653 #define MAC_MEASURE_MAP_UNMEASURED        CO_BIT(4)
1654 #define MAC_MEASURE_MAP_MASK              0x1F
1655 
1656 /*
1657  * We set the default switch count to Zero which indicates that the switch shall occur at
1658  * any time after the frame containing the element is transmitted.
1659  * This is done to be able to give the STA time to know the new channel number in case the
1660  * channel switch fails and another new channel was decided
1661  */
1662 #define MAC_DEFAULT_SWITCH_COUNT            0
1663 #define MAC_DEFAULT_RADAR_CHECK_TIME        60
1664 
1665 enum
1666 {
1667     REMOTE_MEAS_REQ_LATE = 1,
1668     REMOTE_MEAS_REQ_INCAPABLE,
1669     REMOTE_MEAS_REQ_REFUSED
1670 };
1671 
1672 /** @} */
1673 
1674 /**
1675  * @name HT Action Frame definitions
1676  * @{
1677  ****************************************************************************************
1678  */
1679 
1680 /* HT Action Field values
1681 *--------------------------------------------------------------------------------------*/
1682 /// 802.11 HT action frame definition
1683 #define MAC_CHAN_WIDTH_HT_ACTION                0
1684 #define MAC_SMPS_HT_ACTION                      1
1685 #define MAC_PSMP_HT_ACTION                      2
1686 #define MAC_SET_PCO_PHASE_HT_ACTION             3
1687 #define MAC_CSI_HT_ACTION                       4
1688 #define MAC_NON_COMP_BEAMFORMING_HT_ACTION      5
1689 #define MAC_COMP_BEAMFORMING_HT_ACTION          6
1690 #define MAC_ASEL_INDICES_FEEDBACK_HT_ACTION     7
1691 
1692 
1693 /* HT channel width offsets
1694 *--------------------------------------------------------------------------------------*/
1695 #define MAC_CHAN_WIDTH_WIDTH_OFT                2
1696 
1697 /* HT SM Power Control field offset
1698 *--------------------------------------------------------------------------------------*/
1699 #define MAC_SM_PRW_CTRL_OFT                     2
1700 #define MAC_SMPS_ENABLE_BIT                     CO_BIT(0)
1701 #define MAC_SMPS_DYNAMIC_BIT                    CO_BIT(1)
1702 
1703 /** @} */
1704 
1705 
1706 /**
1707  * @name VHT Action Frame definitions
1708  * @{
1709  ****************************************************************************************
1710  */
1711 /* VHT Action Field values
1712 *--------------------------------------------------------------------------------------*/
1713 /// 802.11 VHT action frame definition
1714 #define MAC_COMP_BEAMFORMING_VHT_ACTION         0
1715 #define MAC_GROUP_ID_MGMT_VHT_ACTION            1
1716 #define MAC_OP_MODE_NOTIF_VHT_ACTION            2
1717 
1718 
1719 /* GroupId management offsets
1720 *--------------------------------------------------------------------------------------*/
1721 #define MAC_GROUP_ID_MGT_PAYL_LENGTH            26
1722 #define MAC_GROUP_ID_MGT_MEMBERSHIP_OFT         2
1723 #define MAC_GROUP_ID_MGT_USER_POS_OFT           10
1724 
1725 
1726 /* VHT operation mode notification offsets
1727 *--------------------------------------------------------------------------------------*/
1728 #define MAC_OP_MODE_NOTIF_OPMODE_OFT            2
1729 #define MAC_OP_MODE_NOTIF_LEN                   3
1730 #define MAC_OPMODE_BW_OFT                       0
1731 #define MAC_OPMODE_BW_MSK                       (0x3 << MAC_OPMODE_BW_OFT)
1732 #define MAC_OPMODE_RXNSS_OFT                    4
1733 #define MAC_OPMODE_RXNSS_MSK                    (0x7 << MAC_OPMODE_RXNSS_OFT)
1734 #define MAC_OPMODE_RXNSS_TYPE_BIT               CO_BIT(7)
1735 
1736 /** @} */
1737 
1738 /**
1739  * @name SA QUERY Action Frame definitions
1740  * @{
1741  ****************************************************************************************
1742  */
1743 #define MAC_SA_QUERY_ACTION_OFT 1
1744 #define MAC_SA_QUERY_REQUEST    0
1745 #define MAC_SA_QUERY_RESPONSE   1
1746 
1747 #define MAC_SA_QUERY_TR_ID_OFT  2
1748 #define MAC_SA_QUERY_TR_ID_LEN  2
1749 
1750 #define MAC_SA_QUERY_MIN_LEN  (MAC_SA_QUERY_TR_ID_OFT + MAC_SA_QUERY_TR_ID_LEN)
1751 /** @} */
1752 
1753 /**
1754  * @name Information Element Identifier definitions
1755  * @{
1756  ****************************************************************************************
1757  */
1758 /// 802.11 IE identifier
1759 #define MAC_INFOELT_ID_OFT                0
1760 #define MAC_INFOELT_LEN_OFT               1
1761 #define MAC_INFOELT_EXT_ID_OFT            2
1762 #define MAC_INFOELT_INFO_OFT              2
1763 #define MAC_INFOELT_EXT_INFO_OFT          3
1764 
1765 #define MAC_ELTID_SSID                    0
1766 #define MAC_ELTID_RATES                   1
1767 #define MAC_ELTID_FH                      2
1768 #define MAC_ELTID_DS                      3
1769 #define MAC_ELTID_CF                      4
1770 #define MAC_ELTID_TIM                     5
1771 #define MAC_ELTID_IBSS                    6
1772 #define MAC_ELTID_COUNTRY                 7             // optional
1773 #define MAC_ELTID_HOP_PARAM               8             // optional
1774 #define MAC_ELTID_HOP_TABLE               9             // optional
1775 #define MAC_ELTID_REQUEST                10             // optional
1776 #define MAC_ELTID_BSS_LOAD               11
1777 #define MAC_ELTID_EDCA_PARAM             12
1778 
1779 #define MAC_ELTID_CHALLENGE              16
1780 #define MAC_ELTID_POWER_CONSTRAINT       32             // Spectrum & Power Management
1781 #define MAC_ELTID_POWER_CAPABILITY       33             // Spectrum & Power Management
1782 #define MAC_POWER_CAPABILITY_IE_LEN      2              // Spectrum & Power Management
1783 #define MAC_ELTID_TPC_REQUEST            34             // Spectrum & Power Management
1784 #define MAC_ELTID_TPC_REPORT             35             // Spectrum & Power Management
1785 #define MAC_ELTID_SUPPORTED_CHANNELS     36             // Spectrum & Power Management
1786 #define MAC_ELTID_CHANNEL_SWITCH         37             // Spectrum & Power Management
1787 #define MAC_ELTID_MEASUREMENT_REQUEST    38             // Spectrum & Power Management
1788 #define MAC_ELTID_MEASUREMENT_REPORT     39             // Spectrum & Power Management
1789 #define MAC_ELTID_QUIET                  40             // Spectrum & Power Management
1790 #define MAC_ELTID_IBSS_DFS               41             // Spectrum & Power Management
1791 
1792 #define MAC_ELTID_ERP                    42
1793 #define MAC_ELTID_HT_CAPA                45
1794 #define MAC_ELTID_QOS_CAPA               46
1795 #define MAC_ELTID_RSN_IEEE               48
1796 #define MAC_ELTID_EXT_RATES              50
1797 #define MAC_ELTID_MDE                    54  // Mobility Domain
1798 #define MAC_ELTID_FTE                    55  // Fast BSS Transition
1799 #define MAC_ELTID_SUPP_OPER_CLASS        59
1800 #define MAC_ELTID_EXT_CHANNEL_SWITCH     60
1801 #define MAC_ELTID_SEC_CH_OFFSET          62
1802 #define MAC_ELTID_20_40_COEXISTENCE      72
1803 #define MAC_ELTID_OBSS_SCAN_PARAM        74
1804 #define MAC_ELTID_MGMT_MIC               76
1805 #define MAC_ELTID_HT_OPERATION           61
1806 #define MAC_ELTID_LINK_IDENTIFIER        101
1807 #define MAC_ELTID_CHANNEL_SWITCH_TIMING  104
1808 #define MAC_ELTID_PTI_CONTROL            105
1809 #define MAC_ELTID_TPU_BUFFER_STATUS      106
1810 #define MAC_ELTID_MESH_CONF              113
1811 #define MAC_ELTID_MESH_ID                114
1812 #define MAC_ELTID_MESH_LINK_METRIC_REP   115
1813 #define MAC_ELTID_CONGESTION_NOTIF       116
1814 #define MAC_ELTID_MESH_PEER_MGMT         117
1815 #define MAC_ELTID_MESH_CHAN_SWITCH_PARAM 118
1816 #define MAC_ELTID_MESH_AWAKE_WINDOW      119
1817 #define MAC_ELTID_MESH_GANN              125
1818 #define MAC_ELTID_MESH_RANN              126
1819 #define MAC_ELTID_EXT_CAPA               127 // This number need to be confirmed.
1820 #define MAC_ELTID_MESH_PREQ              130
1821 #define MAC_ELTID_MESH_PREP              131
1822 #define MAC_ELTID_MESH_PERR              132
1823 #define MAC_ELTID_VHT_CAPA               191
1824 #define MAC_ELTID_VHT_OPERATION          192
1825 #define MAC_ELTID_WIDE_BANDWIDTH_CHAN_SWITCH 194
1826 #define MAC_ELTID_VHT_TRANSMIT_PWR_ENVELOP   195
1827 #define MAC_ELTID_CHAN_SWITCH_WRP        196
1828 #define MAC_ELTID_OP_MODE_NOTIF          199
1829 #define MAC_ELTID_OUI                    221 // Proprietary   (0xDD)
1830 #define MAC_ELTID_EXT                    255
1831 
1832 #define MAC_OUI_TYPE_WPA                  1
1833 #define MAC_OUI_TYPE_WME                  2
1834 #define MAC_OUI_SUBTYPE_WME_INFORMATION   0
1835 #define MAC_OUI_SUBTYPE_WME_PARAMETER     1
1836 #define MAC_OUI_TYPE_WMMAC                2
1837 #define MAC_OUI_SUBTYPE_WMMAC_TSPEC       2
1838 #define MAC_OUI_SUBTYPE_WMMAC_TSDELAY     8
1839 #define MAC_OUI_SUBTYPE_WMMAC_TSINFO      10
1840 
1841 #define MAC_ELTID_EXT_HE_CAPA            35
1842 #define MAC_ELTID_EXT_HE_OPERATION       36
1843 #define MAC_ELTID_EXT_MU_EDCA            38
1844 /** @} */
1845 
1846 /**
1847  * @name Standard Status Code definitions
1848  * @{
1849  ****************************************************************************************
1850  */
1851 /// 802.11 Status Code
1852 #define MAC_ST_SUCCESSFUL                   0
1853 #define MAC_ST_FAILURE                      1
1854 #define MAC_ST_RESERVED                     2
1855 #define MAC_ST_CAPA_NOT_SUPPORTED           10
1856 #define MAC_ST_REASSOC_NOT_ASSOC            11
1857 #define MAC_ST_ASSOC_DENIED                 12
1858 #define MAC_ST_AUTH_ALGO_NOT_SUPPORTED      13
1859 #define MAC_ST_AUTH_FRAME_WRONG_SEQ         14
1860 #define MAC_ST_AUTH_CHALLENGE_FAILED        15
1861 #define MAC_ST_AUTH_TIMEOUT                 16
1862 #define MAC_ST_ASSOC_TOO_MANY_STA           17
1863 #define MAC_ST_ASSOC_RATES_NOT_SUPPORTED    18
1864 #define MAC_ST_ASSOC_PREAMBLE_NOT_SUPPORTED 19
1865 
1866 #define MAC_ST_ASSOC_SPECTRUM_REQUIRED   22
1867 #define MAC_ST_ASSOC_POWER_CAPA          23
1868 #define MAC_ST_ASSOC_SUPPORTED_CHANNEL   24
1869 #define MAC_ST_ASSOC_SLOT_NOT_SUPPORTED  25
1870 
1871 #define MAC_ST_REFUSED_TEMPORARILY       30
1872 #define MAC_ST_INVALID_MFP_POLICY        31
1873 
1874 #define MAC_ST_INVALID_IE                40             // draft 7.0 extention
1875 #define MAC_ST_GROUP_CIPHER_INVALID      41             // draft 7.0 extention
1876 #define MAC_ST_PAIRWISE_CIPHER_INVALID   42             // draft 7.0 extention
1877 #define MAC_ST_AKMP_INVALID              43             // draft 7.0 extention
1878 #define MAC_ST_UNSUPPORTED_RSNE_VERSION  44             // draft 7.0 extention
1879 #define MAC_ST_INVALID_RSNE_CAPA         45             // draft 7.0 extention
1880 #define MAC_ST_CIPHER_SUITE_REJECTED     46             // draft 7.0 extention
1881 /** @} */
1882 
1883 
1884 /**
1885  * @name Standard Reason Code definitions
1886  * @{
1887  ****************************************************************************************
1888  */
1889 /// 802.11 Reason Code
1890 #define MAC_RS_RESERVED                           0
1891 #define MAC_RS_UNSPECIFIED                        1
1892 #define MAC_RS_PREVIOUS_AUTH_NOT_VALID            2
1893 #define MAC_RS_DEAUTH_SENDER_LEFT_IBSS_ESS        3
1894 #define MAC_RS_DIASSOC_INACTIVITY                 4
1895 #define MAC_RS_DIASSOC_TOO_MANY_STA               5
1896 #define MAC_RS_CLASS_2_FORBIDDEN                  6
1897 #define MAC_RS_CLASS_3_FORBIDDEN                  7
1898 #define MAC_RS_DEAUTH_SENDER_LEFT_BSS             8
1899 #define MAC_RS_STA_REQ_ASSOC_NOT_AUTH             9
1900 #define MAC_RS_DIASSOC_POWER_CAPA                10
1901 #define MAC_RS_DIASSOC_SUPPORTED_CHANNEL         11
1902 #define MAC_RS_RESERVED_12                       12
1903 #define MAC_RS_INVALID_IE                        13
1904 #define MAC_RS_MIC_FAILURE                       14
1905 #define MAC_RS_4WAY_HANDSHAKE_TIMEOUT            15
1906 #define MAC_RS_GROUP_KEY_UPDATE_TIMEOUT          16
1907 #define MAC_RS_BAD_RSNIE                         17
1908 #define MAC_RS_GROUP_CIPHER_INVALID              18
1909 #define MAC_RS_PAIRWISE_CIPHER_INVALID           19
1910 #define MAC_RS_AKMP_INVALID                      20
1911 #define MAC_RS_UNSUPPORTED_RSNE_VERSION          21
1912 #define MAC_RS_INVALID_RSNE_CAPA                 22
1913 #define MAC_RS_802_1X_AUTH_FAIL                  23
1914 #define MAC_RS_CIPHER_SUITE_REJECTED             24
1915 #define MAC_RS_TIMEOUT                           39
1916 /** @} */
1917 
1918 
1919 /**
1920  * @name WMMIE definitions
1921  * @{
1922  ****************************************************************************************
1923  */
1924 /// WMM IE definition
1925 #define MAC_WME_PARAM_LEN          16
1926 /// Default WME information element format
1927 #define MAC_RAW_WME_INFO_ELMT_DEFAULT                                         \
1928 {                                                                             \
1929     MAC_ELTID_OUI, 0x07,                                                      \
1930     0x00, 0x50, 0xF2, MAC_OUI_TYPE_WME,         /* additionnal WPA OUI     */ \
1931     MAC_OUI_SUBTYPE_WME_INFORMATION, 0x01,      /* OUI subtype and version */ \
1932     0x00                                        /* QoS field               */ \
1933 }
1934 
1935 // Best effort
1936 #define MAC_ACI_BE                        0
1937 // Background
1938 #define MAC_ACI_BK                        1
1939 // Video
1940 #define MAC_ACI_VI                        2
1941 // Voice
1942 #define MAC_ACI_VO                        3
1943 
1944 #define MAC_ACI_OFT                       5
1945 
1946 #define MAC_ECWMIN                        4
1947 #define MAC_ECWMAX                        10
1948 
1949 #define MAC_ECW_BK_MIN                  MAC_ECWMIN
1950 #define MAC_ECW_BE_MIN                  MAC_ECWMIN
1951 //#define MAC_ECW_VI_MIN                  ((MAC_ECWMIN+1)/2 - 1)
1952 //#define MAC_ECW_VO_MIN                  ((MAC_ECWMIN+1)/4 - 1)
1953 #define MAC_ECW_VI_MIN                  ((MAC_ECWMIN) - 1)
1954 #define MAC_ECW_VO_MIN                  ((MAC_ECWMIN)/2)
1955 
1956 #define MAC_ECW_BK_MAX                  MAC_ECWMAX
1957 #define MAC_ECW_BE_MAX                  MAC_ECWMAX
1958 #define MAC_ECW_VI_MAX                  MAC_ECWMIN
1959 //#define MAC_ECW_VO_MAX                  ((MAC_ECWMIN+1)/2 - 1)
1960 #define MAC_ECW_VO_MAX                  ((MAC_ECWMIN) - 1)
1961 
1962 #define MAC_AIFSN_BK                    7
1963 #define MAC_AIFSN_BE                    3
1964 #define MAC_AIFSN_VI                    2
1965 #define MAC_AIFSN_VO                    2
1966 
1967 #define MAC_AC_BE_TXOP                  0
1968 #define MAC_AC_BK_TXOP                  0
1969 #define MAC_AC_VI_TXOP_b                188    // 6016us / 32 us
1970 #define MAC_AC_VI_TXOP_ag               94     // 3008 ms / 32 usec
1971 
1972 
1973 #define MAC_AC_VO_TXOP_b                102    // 3264us / 32 us
1974 #define MAC_AC_VO_TXOP_ag                47    // 1504us / 32 us
1975 
1976 
1977  /** @} */
1978 
1979 /**
1980  * @name RSNIE definitions
1981  * @{
1982  ****************************************************************************************
1983  */
1984 /// RSN IE definition
1985 // RSN Information element related fields
1986 #define MAC_RSNIE_WPA_OUI_LEN           4
1987 #define MAC_RSNIE_GROUP_KEY_OFT         7
1988 #define MAC_RSNIE_PAIRWISE_KEY_CNT_OFT  8
1989 #define MAC_RSNIE_PAIRWISE_KEY_OFT     13
1990 
1991 // Cipher suite selectors
1992 #define MAC_RSNIE_CIPHER_MASK    0x07
1993 #define MAC_RSNIE_CIPHER_WEP40   0x00
1994 #define MAC_RSNIE_CIPHER_TKIP    0x01
1995 #define MAC_RSNIE_CIPHER_CCMP    0x02
1996 #define MAC_RSNIE_CIPHER_WEP104  0x03
1997 #define MAC_RSNIE_CIPHER_WPI_SMS4 0x04
1998 #define MAC_RSNIE_CIPHER_AES_CMAC 0x05
1999 
2000 #define MAC_RSNIE_CIPHER_NOSEC   0xFE
2001 #define MAC_RSNIE_CIPHER_INVALID 0xFF
2002 
2003 // Authentication and key management suite selectors
2004 #define MAC_RSNIE_KEYMGT_8021X    1
2005 #define MAC_RSNIE_KEYMGT_PSK      2
2006 
2007 
2008 /** @} */
2009 
2010 /**
2011  * @name Country IE definitions
2012  * @{
2013  ****************************************************************************************
2014  */
2015 /// Country IE definition
2016 #define MAC_COUNTRY_2G4_FULL      {  3, {'x', 'x', ' '}, { 1, 14, 30}}
2017 #define MAC_COUNTRY_2G4_USA       {  6, {'U', 'S', ' '}, { 1, 11, 30}} // X'10' FCC
2018 #define MAC_COUNTRY_2G4_CANADA    {  6, {'C', 'A', ' '}, { 1, 11, 30}} // X'20' DOC/IC
2019 #define MAC_COUNTRY_2G4_EUROPE    {  6, {'E', 'U', ' '}, { 1, 13, 30}} // X'30' ETSI
2020 #define MAC_COUNTRY_2G4_SPAIN     {  6, {'S', 'P', ' '}, {10,  2, 30}} // X'31'
2021 #define MAC_COUNTRY_2G4_FRANCE    {  6, {'F', 'R', ' '}, {10,  4, 20}} // X'32'
2022 #define MAC_COUNTRY_2G4_JAPAN     {  6, {'J', 'P', ' '}, {14,  1, 30}} // X'40'
2023 #define MAC_COUNTRY_2G4_CHINA     {  6, {'C', 'N', ' '}, { 1, 13, 30}} // X'50'
2024 
2025 #define MAC_COUNTRY_5G_FULL       {  3, {'x', 'x', ' '}, {{ 36, 8, 23}}}
2026 #define MAC_COUNTRY_5G_USA        { 18, {'U', 'S', ' '}, {{ 36, 4, 16}, /**/ {52, 4, 23}, /**/ {100, 11, 23}, /**/ {149, 4, 29}, /**/ {165, 1, 30}}}
2027 #define MAC_COUNTRY_5G_FRANCE     { 12, {'F', 'R', ' '}, {{ 36, 4, 23}, /**/ {52, 4, 23}, /**/ {100, 11, 40}}}
2028 #define MAC_COUNTRY_5G_JAPAN      { 12, {'J', 'P', ' '}, {{184, 4, 24}, /**/ { 8, 3, 24}, /**/ { 34,  4, 22}}}
2029 
2030 /** @} */
2031 
2032 /**
2033  * @name Authentication Algorithm definitions
2034  * @{
2035  ****************************************************************************************
2036  */
2037 /// Authentication algorithm definition
2038 #define MAC_AUTH_ALGO_OPEN                0
2039 #define MAC_AUTH_ALGO_SHARED              1
2040 #define MAC_AUTH_ALGO_FT                  2
2041 #define MAC_AUTH_ALGO_SAE                 3
2042 
2043 
2044 #define MAC_AUTH_FIRST_SEQ                1
2045 #define MAC_AUTH_SECOND_SEQ               2
2046 #define MAC_AUTH_THIRD_SEQ                3
2047 #define MAC_AUTH_FOURTH_SEQ               4
2048 
2049 /** @} */
2050 
2051 /**
2052  * @name Security definitions
2053  * @{
2054  ****************************************************************************************
2055  */
2056 /// Crypto definition
2057 // Defines for encryption status
2058 #define MAC_ENC_NONE               0
2059 #define MAC_ENC_WEP                0x01
2060 #define MAC_ENC_WPA                0x02
2061 #define MAC_ENC_TKIP               0x04
2062 #define MAC_ENC_WPA2               0x10
2063 #define MAC_ENC_CCMP               0x20
2064 
2065 // Key Offsets
2066 #define  MAC_ENC_KEY_OFFSET         0
2067 #define  MAC_AUTHENTICATOR_KEY     16
2068 #define  MAC_SUPPLICANT_KEY        24
2069 #define  MAC_ENC_KEY_LEN           16
2070 #define  MAC_MICHAEL_KEY_LEN        8
2071 
2072 /// Word 1 of CCMP IV
2073 #define EIV_PRESENT     (0x2000)
2074 /** @} */
2075 
2076 #if 0
2077 /**
2078  * @name AKM suite
2079  * @{
2080  ****************************************************************************************
2081  */
2082 #define MAC_AKM_8021X                   0x000FAC01
2083 #define MAC_AKM_PSK                     0x000FAC02
2084 #define MAC_AKM_FT_8021X                0x000FAC03
2085 #define MAC_AKM_FT_PSK                  0x000FAC04
2086 #define MAC_AKM_8021X_SHA256            0x000FAC05
2087 #define MAC_AKM_PSK_SHA256              0x000FAC06
2088 #define MAC_AKM_TDLS                    0x000FAC07
2089 #define MAC_AKM_SAE                     0x000FAC08
2090 #define MAC_AKM_FT_OVER_SAE             0x000FAC09
2091 #define MAC_AKM_8021X_SUITE_B           0x000FAC11
2092 #define MAC_AKM_8021X_SUITE_B_192       0x000FAC12
2093 #define MAC_AKM_FILS_SHA256             0x000FAC14
2094 #define MAC_AKM_FILS_SHA384             0x000FAC15
2095 #define MAC_AKM_FT_FILS_SHA256          0x000FAC16
2096 #define MAC_AKM_FT_FILS_SHA384          0x000FAC17
2097 #endif
2098 /** @} */
2099 
2100 /**
2101  * @name Various Frame Size definitions
2102  * @{
2103  ****************************************************************************************
2104  */
2105 /// Maximum size of a beacon frame (default IE + TIM + remaining IE space)
2106 #define MAC_BEACON_SIZE             (102 + MAC_TIM_SIZE + 128)
2107 /// Maximum size of a probe request frame
2108 #define MAC_PROBEREQ_SIZE           100
2109 /// Maximum size of a probe response frame (default IE + remaining IE space)
2110 #define MAC_PROBERSP_SIZE               (102 + 128)
2111 /// Size of a NULL frame
2112 #define MAC_NULL_FRAME_SIZE         MAC_SHORT_MAC_HDR_LEN
2113 /// Size of a QoS-NULL frame
2114 #define MAC_QOS_NULL_FRAME_SIZE     MAC_SHORT_QOS_MAC_HDR_LEN
2115 /// Size of a PS poll
2116 #define MAC_PSPOLL_FRAME_SIZE       MAC_LONG_CTRLFRAME_LEN
2117 /** @} */
2118 
2119 /// Structure of a short control frame MAC header
2120 struct mac_hdr_ctrl_short
2121 {
2122     /// Frame control
2123     uint16_t fctl;
2124     /// Duration/ID
2125     uint16_t durid;
2126     /// Address 1
2127     struct mac_addr addr1;
2128 } __PACKED;
2129 
2130 /// Structure of a long control frame MAC header
2131 struct mac_hdr_ctrl
2132 {
2133     /// Frame control
2134     uint16_t fctl;
2135     /// Duration/ID
2136     uint16_t durid;
2137     /// Address 1
2138     struct mac_addr addr1;
2139     /// Address 2
2140     struct mac_addr addr2;
2141 } __PACKED;
2142 
2143 /// Structure of a long control frame MAC header
2144 struct mac_hdr
2145 {
2146     /// Frame control
2147     uint16_t fctl;
2148     /// Duration/ID
2149     uint16_t durid;
2150     /// Address 1
2151     struct mac_addr addr1;
2152     /// Address 2
2153     struct mac_addr addr2;
2154     /// Address 3
2155     struct mac_addr addr3;
2156     /// Sequence control
2157     uint16_t seq;
2158 } __PACKED;
2159 
2160 /// Structure of a long control frame MAC header
2161 struct mac_hdr_qos
2162 {
2163     /// Frame control
2164     uint16_t fctl;
2165     /// Duration/ID
2166     uint16_t durid;
2167     /// Address 1
2168     struct mac_addr addr1;
2169     /// Address 2
2170     struct mac_addr addr2;
2171     /// Address 3
2172     struct mac_addr addr3;
2173     /// Sequence control
2174     uint16_t seq;
2175     /// QoS control
2176     uint16_t qos;
2177 } __PACKED;
2178 
2179 /// Structure of a long control frame MAC header
2180 struct mac_hdr_long
2181 {
2182     /// Frame control
2183     uint16_t fctl;
2184     /// Duration/ID
2185     uint16_t durid;
2186     /// Address 1
2187     struct mac_addr addr1;
2188     /// Address 2
2189     struct mac_addr addr2;
2190     /// Address 3
2191     struct mac_addr addr3;
2192     /// Sequence control
2193     uint16_t seq;
2194     /// Address 4
2195     struct mac_addr addr4;
2196 } __PACKED;
2197 
2198 
2199 /// Structure of a long control frame MAC header
2200 struct mac_hdr_long_qos
2201 {
2202     /// Frame control
2203     uint16_t fctl;
2204     /// Duration/ID
2205     uint16_t durid;
2206     /// Address 1
2207     struct mac_addr addr1;
2208     /// Address 2
2209     struct mac_addr addr2;
2210     /// Address 3
2211     struct mac_addr addr3;
2212     /// Sequence control
2213     uint16_t seq;
2214     /// Address 4
2215     struct mac_addr addr4;
2216     /// QoS control
2217     uint16_t qos;
2218 } __PACKED;
2219 
2220 /// Structure of Ethernet Header
2221 struct mac_eth_hdr
2222 {
2223     /// Destination Address
2224     struct mac_addr da;
2225     /// Source Address
2226     struct mac_addr sa;
2227     /// Length / Type
2228     uint16_t len;
2229 } __PACKED;
2230 
2231 /// Structure of a Beacon or ProbeRsp frame
2232 struct bcn_frame
2233 {
2234     /// MAC Header
2235     struct mac_hdr h;
2236     /// Timestamp
2237     uint64_t tsf;
2238     /// Beacon interval
2239     uint16_t bcnint;
2240     /// Capability information
2241     uint16_t capa;
2242     /// Rest of the payload
2243     uint8_t variable[];
2244 } __PACKED;
2245 
2246 /// Structure of a Probe Request frame
2247 struct preq_frame
2248 {
2249     /// MAC Header
2250     struct mac_hdr h;
2251     /// Rest of the payload
2252     uint8_t payload[];
2253 } __PACKED;
2254 
2255 /// Structure of a Block Acknowledgment Request frame
2256 struct bar_frame
2257 {
2258     /// MAC Header
2259     struct mac_hdr_ctrl h;
2260     /// BAR control
2261     uint16_t bar_cntrl;
2262     /// BAR information
2263     uint16_t bar_information;
2264 } __PACKED;
2265 
2266 /// Base structure of a Block Acknowledgment frame
2267 struct ba_base
2268 {
2269     /// MAC Header
2270     struct mac_hdr_ctrl h;
2271     /// BA control
2272     uint16_t ba_cntrl;
2273 } __PACKED;
2274 
2275 /// Structure of generic BA SSC + bitmap
2276 struct ba_ssc_bitmap
2277 {
2278     /// BA Start Sequence Control
2279     uint16_t ssc;
2280     /// BA bitmap
2281     uint16_t bitmap[];
2282 } __PACKED;
2283 
2284 /// Structure of BA SSC + 32-bit bitmap
2285 struct ba_ssc_bitmap_32
2286 {
2287     /// BA Start Sequence Control
2288     uint16_t ssc;
2289     /// BA bitmap
2290     uint16_t bitmap[2];
2291 } __PACKED;
2292 
2293 /// Structure of BA SSC + 64-bit bitmap
2294 struct ba_ssc_bitmap_64
2295 {
2296     /// BA Start Sequence Control
2297     uint16_t ssc;
2298     /// BA bitmap
2299     uint16_t bitmap[4];
2300 } __PACKED;
2301 
2302 /// Structure of BA SSC + 128-bit bitmap
2303 struct ba_ssc_bitmap_128
2304 {
2305     /// BA Start Sequence Control
2306     uint16_t ssc;
2307     /// BA bitmap
2308     uint16_t bitmap[8];
2309 } __PACKED;
2310 
2311 /// Structure of BA SSC + 256-bit bitmap
2312 struct ba_ssc_bitmap_256
2313 {
2314     /// BA Start Sequence Control
2315     uint16_t ssc;
2316     /// BA bitmap
2317     uint16_t bitmap[16];
2318 } __PACKED;
2319 
2320 /// Multi-STA AID/TID info field
2321 struct ba_msta_aid_tid_info
2322 {
2323     /// BA control
2324     uint16_t aid_tid;
2325     /// BA Start Sequence Control and Bitmap
2326     struct ba_ssc_bitmap ssc_bitmap;
2327 } __PACKED;
2328 
2329 /// Structure of a Compressed Block Acknowledgment frame
2330 struct ba_comp_frame
2331 {
2332     /// MAC Header
2333     struct mac_hdr_ctrl h;
2334     /// BA control
2335     uint16_t ba_cntrl;
2336     /// BA Start Sequence Control and Bitmap
2337     struct ba_ssc_bitmap_64 ssc_bitmap;
2338 } __PACKED;
2339 
2340 /// Structure of A-MSDU Header
2341 struct amsdu_hdr
2342 {
2343     /// Destination Address
2344     struct mac_addr da;
2345     /// Source Address
2346     struct mac_addr sa;
2347     /// Length
2348     uint16_t len;
2349 } __PACKED;
2350 
2351 /// Structure of the User Info part of the HE Basic Trigger frame
2352 struct he_basic_trigger_user_info
2353 {
2354     /// First part of the user
2355     uint32_t user_info1;
2356     uint8_t ul_target_rssi;
2357     uint8_t user_info2;
2358 } __PACKED;
2359 
2360 /// Base part of the User Info field present in the HE trigger frames
2361 struct he_user_info_base
2362 {
2363     /// First part of the user
2364     uint32_t user_info1;
2365     uint8_t ul_target_rssi;
2366 } __PACKED;
2367 
2368 /// Base structure of a HE Trigger frame
2369 struct he_trigger_base
2370 {
2371     /// MAC Header
2372     struct mac_hdr_ctrl h;
2373     /// Common Info
2374     uint32_t common[2];
2375 } __PACKED;
2376 
2377 /**
2378  * @name BAR/BA Frame definitions
2379  * @{
2380  ****************************************************************************************
2381  */
2382 /// Payload length of the BAR frame
2383 #define BAR_PAYLOAD_LEN        (sizeof_b(struct bar_frame))
2384 /// Byte length of the BAR frame, including FCS
2385 #define BAR_FRM_LEN_WITH_FCS   (BAR_PAYLOAD_LEN + MAC_FCS_LEN)
2386 
2387 /// BAR frame body BAR Control field - Ack type
2388 #define BAR_CNTL_ACK_TYPE_BIT    CO_BIT(0)
2389 /// BAR frame body BAR Control field - Multi-TID flag
2390 #define BAR_CNTL_MULTI_TID_BIT   CO_BIT(1)
2391 /// BAR frame body BAR Control field - Compressed BA flag
2392 #define BAR_CNTL_COMPRESSED_BIT  CO_BIT(2)
2393 
2394 /// Offset of the TID in the BAR frame
2395 #define BAR_CNTL_TID_OFT         12
2396 /// Mask of the TID in the BAR frame
2397 #define BAR_CNTL_TID_MSK         (0xF<<BAR_CNTL_TID_OFT)
2398 
2399 /// Compressed BlockAck frame length
2400 #define BA_COMPRESSED_LEN        (sizeof_b(struct ba_comp_frame))
2401 
2402 /// TID offset in BA payload byte
2403 #define BA_PAYL_TYPE_OFT        1
2404 /// TID mask in BA payload byte
2405 #define BA_PAYL_TYPE_MSK        (0xF << BA_PAYL_TYPE_OFT)
2406 /// Basic BlockAck type
2407 #define BA_BASIC_TYPE           (0x0 << BA_PAYL_TYPE_OFT)
2408 /// Extended Compressed BlockAck type
2409 #define BA_EXT_COMPRESSED_TYPE  (0x1 << BA_PAYL_TYPE_OFT)
2410 /// Compressed BlockAck type
2411 #define BA_COMPRESSED_TYPE      (0x2 << BA_PAYL_TYPE_OFT)
2412 /// Multi-TID BlockAck type
2413 #define BA_MULTI_TID_TYPE       (0x3 << BA_PAYL_TYPE_OFT)
2414 /// GCR BlockAck type
2415 #define BA_GCR_TYPE             (0x6 << BA_PAYL_TYPE_OFT)
2416 /// GLK-GCR BlockAck type
2417 #define BA_GLK_GCR_TYPE         (0xA << BA_PAYL_TYPE_OFT)
2418 /// Multi-STA BlockAck type
2419 #define BA_MULTI_STA_TYPE       (0xB << BA_PAYL_TYPE_OFT)
2420 
2421 /// TID offset in BA payload byte
2422 #define BA_PAYL_TID_BIT_OFT     12
2423 /// TID mask in BA payload byte
2424 #define BA_PAYL_TID_BIT_MSK     (0xF << BA_PAYL_TID_BIT_OFT)
2425 /// SSN bit offset within SSC
2426 #define SN_IN_SSC_BIT_OFT       4
2427 
2428 /// Offset of AID in BA information of Multi-STA BA
2429 #define BA_MULTI_STA_AID_OFT    0
2430 /// Mask of AID in BA information of Multi-STA BA
2431 #define BA_MULTI_STA_AID_MSK    (0x7FF << BA_MULTI_STA_AID_OFT)
2432 /// Offset of AID in BA information of Multi-STA BA
2433 #define BA_MULTI_STA_ACK_BIT    CO_BIT(11)
2434 /// Offset of TID in BA information of Multi-STA BA
2435 #define BA_MULTI_STA_TID_OFT    12
2436 /// TID mask in BA payload byte
2437 #define BA_MULTI_STA_TID_MSK    (0xF << BA_MULTI_STA_TID_OFT)
2438 
2439 /** @} */
2440 
2441 /**
2442  * @name Trigger Frame definitions
2443  * @{
2444  ****************************************************************************************
2445  */
2446 /// Trigger type offset
2447 #define HE_TRIG_TYPE_OFT         0
2448 /// Trigger type mask
2449 #define HE_TRIG_TYPE_MSK         (0xF << HE_TRIG_TYPE_OFT)
2450 /// Basic trigger type
2451 #define HE_TRIG_TYPE_BASIC       (0 << HE_TRIG_TYPE_OFT)
2452 /// BSRP trigger type
2453 #define HE_TRIG_TYPE_BSRP        (4 << HE_TRIG_TYPE_OFT)
2454 /// UL length offset
2455 #define HE_TRIG_UL_LENGTH_OFT    4
2456 /// UL length mask
2457 #define HE_TRIG_UL_LENGTH_MSK    (0xFFF << HE_TRIG_UL_LENGTH_OFT)
2458 /// More TF
2459 #define HE_TRIG_MORE_TF_BIT      CO_BIT(16)
2460 /// More TF
2461 #define HE_TRIG_CS_REQUIRED_BIT  CO_BIT(17)
2462 /// UL BW offset
2463 #define HE_TRIG_UL_BW_OFT        18
2464 /// UL length mask
2465 #define HE_TRIG_UL_BW_MSK        (0x3 << HE_TRIG_UL_BW_OFT)
2466 /// GI/LTF type offset
2467 #define HE_TRIG_GI_LTF_TYPE_OFT  20
2468 /// GI/LTF type mask
2469 #define HE_TRIG_GI_LTF_TYPE_MSK  (0x3 << HE_TRIG_GI_LTF_TYPE_OFT)
2470 
2471 /// AID12 offset
2472 #define HE_TRIG_AID12_OFT        0
2473 /// AID12 mask
2474 #define HE_TRIG_AID12_MSK        (0xFFF << HE_TRIG_AID12_OFT)
2475 /// RU allocation in secondary 80MHz
2476 #define HE_TRIG_RU_IN_SEC_BIT    CO_BIT(12)
2477 /// RU allocation offset
2478 #define HE_TRIG_RU_ALLOC_OFT     13
2479 /// RU allocation mask
2480 #define HE_TRIG_RU_ALLOC_MSK     (0x7F << HE_TRIG_RU_ALLOC_OFT)
2481 /// FEC Coding
2482 #define HE_TRIG_FEC_CODING_BIT   CO_BIT(20)
2483 /// UL MCS offset
2484 #define HE_TRIG_UL_MCS_OFT       21
2485 /// UL MCS mask
2486 #define HE_TRIG_UL_MCS_MSK       (0xF << HE_TRIG_UL_MCS_OFT)
2487 /// MU spacing factor offset
2488 #define HE_TRIG_SPC_FACTOR_OFT   0
2489 /// MU spacing factor mask
2490 #define HE_TRIG_SPC_FACTOR_MSK   (0x3 << HE_TRIG_SPC_FACTOR_OFT)
2491 /// Preferred AC offset
2492 #define HE_TRIG_PREF_AC_OFT      6
2493 /// UL MCS mask
2494 #define HE_TRIG_PREF_AC_MSK      (0x3 << HE_TRIG_PREF_AC_OFT)
2495 
2496 /// HE trigger frame minimal length
2497 #define HE_TRIG_FRM_MIN_LEN      29
2498 
2499 #endif // _WIFI_MAC_FRAME_H
2500