• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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  * Description: Source file defined by the corresponding frame structure and operation interface (cannot be called by
15  * the HAL module).
16  */
17 
18 #ifndef __MAC_FRAME_COMMON_ROM_H__
19 #define __MAC_FRAME_COMMON_ROM_H__
20 
21 /*****************************************************************************
22   1 其他头文件包含
23 *****************************************************************************/
24 #include "oam_ext_if.h"
25 #include "wlan_types.h"
26 #include "securec.h"
27 #include "wlan_util_common_rom.h"
28 #ifdef __cplusplus
29 #if __cplusplus
30 extern "C" {
31 #endif
32 #endif
33 
34 /* 此文件中定义的结构体与协议相关,需要1字节对齐 */
35 /*****************************************************************************
36   2 宏定义
37 *****************************************************************************/
38 #define MAC_80211_FRAME_LEN 24      /* 非四地址情况下,MAC帧头的长度 */
39 
40 /* A-MSDU情况下,submsdu的偏移宏 */
41 #define MAC_SUBMSDU_HEADER_LEN 14    /* |da = 6|sa = 6|len = 2| submsdu的头的长度 */
42 
43 /* 信息元素长度定义 */
44 #define MAC_IE_HDR_LEN 2              /* 信息元素头部 1字节EID + 1字节长度 */
45 #define MAC_TIME_STAMP_LEN 8
46 #define MAC_BEACON_INTERVAL_LEN 2
47 #define MAC_CAP_INFO_LEN 2
48 #define MAC_MIN_TIM_LEN 4
49 #define MAC_AC_PARAM_LEN 4
50 
51 #define MAC_QOS_CTRL_FIELD_OFFSET 24
52 #define MAC_QOS_CTRL_FIELD_OFFSET_4ADDR 30
53 #define MAC_80211_QOS_FRAME_LEN 26
54 
55 #define MAC_SLP_RM_IE      0x20
56 
57 #define MAC_BEACON_OFFSET   (MAC_TIME_STAMP_LEN + MAC_BEACON_INTERVAL_LEN + MAC_CAP_INFO_LEN) /* beacon固定长度 */
58 #define MAC_LISTEN_INTERVAL_MAX_LEN         10  /* 定义关联STA最大LISTEN INTERVAL的值 */
59 
60 /* TCP协议类型,chartiot tcp连接端口号 */
61 #define MAC_TCP_PROTOCAL 6
62 #define MAC_UDP_PROTOCAL 17
63 
64 /* DHCP message types */
65 #define MAC_DHCP_DISCOVER 1
66 #define MAC_DHCP_OFFER 2
67 #define MAC_DHCP_REQUEST 3
68 #define MAC_DHCP_ACK 5
69 
70 /* eapol key 结构宏定义 */
71 #define WPA_REPLAY_COUNTER_LEN 8
72 #define WPA_NONCE_LEN 32
73 #define WPA_KEY_RSC_LEN 8
74 #define IEEE802_1X_TYPE_EAPOL_KEY 3
75 #define WPA_KEY_INFO_KEY_TYPE (1U << (3)) /* 1 = Pairwise, 0 = Group key */
76 #define MAC_MAX_START_SPACING 7
77 /*****************************************************************************
78   3 枚举定义
79 *****************************************************************************/
80 /* Action Frames: Category字段枚举 */
81 typedef enum {
82     MAC_ACTION_CATEGORY_SPECMGMT = 0,
83     MAC_ACTION_CATEGORY_QOS = 1,
84     MAC_ACTION_CATEGORY_DLS = 2,
85     MAC_ACTION_CATEGORY_BA = 3,
86     MAC_ACTION_CATEGORY_PUBLIC = 4,
87     MAC_ACTION_CATEGORY_RADIO_MEASURMENT = 5,
88     MAC_ACTION_CATEGORY_FAST_BSS_TRANSITION = 6,
89     MAC_ACTION_CATEGORY_HT = 7,
90     MAC_ACTION_CATEGORY_SA_QUERY = 8,
91     MAC_ACTION_CATEGORY_PROTECTED_DUAL_OF_ACTION = 9,
92     MAC_ACTION_CATEGORY_WNM = 10,
93     MAC_ACTION_CATEGORY_MESH = 13,
94     MAC_ACTION_CATEGORY_MULTIHOP = 14,
95     MAC_ACTION_CATEGORY_VHT = 21,
96     MAC_ACTION_CATEGORY_S1G = 22,
97     MAC_ACTION_CATEGORY_HE = 30,
98     MAC_ACTION_CATEGORY_PROTECTED_HE = 31,
99 #ifdef _PRE_WLAN_FEATURE_WUR_TX
100     MAC_ACTION_CATEGORY_WUR = 32,
101 #endif
102     MAC_ACTION_CATEGORY_VENDOR_SPECIFIC_PROTECTED = 126,
103     MAC_ACTION_CATEGORY_VENDOR = 127,
104 } mac_action_category_enum;
105 typedef osal_u8 mac_category_enum_uint8;
106 
107 /* ACTION帧中,各个域的偏移量 */
108 typedef enum {
109     MAC_ACTION_OFFSET_CATEGORY = 0,
110     MAC_ACTION_OFFSET_ACTION = 1,
111     MAC_ACTION_OFFSET_BODY = 2
112 } mac_action_offset_enum;
113 typedef osal_u8 mac_action_offset_enum_uint8;
114 
115 /* Public Category下的Action枚举值 */
116 typedef enum {
117     MAC_PUB_COEXT_MGMT = 0,            /* 20/40 BSS Coexistence Management */
118     MAC_PUB_EX_CH_SWITCH_ANNOUNCE = 4, /* Extended Channel Switch Announcement */
119     MAC_PUB_VENDOR_SPECIFIC = 9,
120     MAC_PUB_GAS_INIT_RESP = 11,   /* public Action: GAS Initial Response(0x0b) */
121     MAC_PUB_GAS_COMBAK_RESP = 13, /* public Action: GAS Comeback Response(0x0d) */
122     MAC_PUB_FTM_REQ = 32,
123     MAC_PUB_FTM = 33
124 } mac_public_action_type_enum;
125 typedef osal_u8 mac_public_action_type_enum_uint8;
126 
127 /* S1G下的Action值的枚举 */
128 typedef enum {
129     MAC_S1G_ACTION_AID_SWITCH_REQ = 0,
130     MAC_S1G_ACTION_AID_SWITCH_RESP = 1,
131     MAC_S1G_ACTION_SYNC_CONTROL = 2,
132     MAC_S1G_ACTION_STA_INFORMATION_ANNOUNCEMENT = 3,
133     MAC_S1G_ACTION_EDCA_PARAMETER_SET = 4,
134     MAC_S1G_ACTION_EL_OPERATION = 5,
135     MAC_S1G_ACTION_TWT_SETUP = 6,
136     MAC_S1G_ACTION_TWT_TEARDOWN = 7,
137     MAC_S1G_ACTION_SECTORIZED_GROUP_ID_LIST = 8,
138     MAC_S1G_ACTION_SECTOR_ID_FEEDBACK = 9,
139     MAC_S1G_ACTION_RESERVE = 10,
140     MAC_S1G_ACTION_TWT_INFORMATION = 11,
141     MAC_S1G_ACTION_BUTT
142 } mac_s1g_action_type_enum;
143 typedef osal_u8 mac_s1g_action_type_enum_uint8;
144 
145 /* 新增枚举类型, 在更新TWT传事件时,用于区分来源 */
146 typedef enum {
147     MAC_TWT_UPDATE_SOURCE_ASSOCIATION = 0,
148     MAC_TWT_UPDATE_SOURCE_SETUP = 1,
149     MAC_TWT_UPDATE_SOURCE_TEARDOWN = 2,
150     MAC_TWT_UPDATE_SOURCE_INFORMATION = 3,
151     MAC_TWT_UPDATE_SOURCE_MAX
152 } mac_twt_update_source_enum;
153 typedef osal_u8 mac_twt_update_source_enum_uint8;
154 
155 /* Status Codes for Authentication and Association Frames */
156 typedef enum {
157     MAC_SUCCESSFUL_STATUSCODE = 0,
158     MAC_UNSPEC_FAIL = 1,
159     MAC_UNSUP_CAP = 10,
160     MAC_REASOC_NO_ASOC = 11,
161     MAC_FAIL_OTHER = 12,
162     MAC_UNSUPT_ALG = 13,
163     MAC_AUTH_SEQ_FAIL = 14,
164     MAC_CHLNG_FAIL = 15,
165     MAC_AUTH_TIMEOUT = 16,
166     MAC_AP_FULL = 17,
167     MAC_UNSUP_RATE = 18,
168     MAC_SHORT_PREAMBLE_UNSUP = 19,
169     MAC_PBCC_UNSUP = 20,
170     MAC_CHANNEL_AGIL_UNSUP = 21,
171     MAC_MISMATCH_SPEC_MGMT = 22,
172     MAC_MISMATCH_POW_CAP = 23,
173     MAC_MISMATCH_SUPP_CHNL = 24,
174     MAC_SHORT_SLOT_UNSUP = 25,
175     MAC_OFDM_DSSS_UNSUP = 26,
176     MAC_MISMATCH_HTCAP = 27,
177     MAC_MISMATCH_PCO = 29,
178     MAC_REJECT_TEMP = 30,
179     MAC_MFP_VIOLATION = 31,
180     MAC_UNSPEC_QOS_FAIL = 32,
181     MAC_QAP_INSUFF_BANDWIDTH_FAIL = 33,
182     MAC_POOR_CHANNEL_FAIL = 34,
183     MAC_REMOTE_STA_NOT_QOS = 35,
184     MAC_REQ_DECLINED = 37,
185     MAC_INVALID_REQ_PARAMS = 38,
186     MAC_RETRY_NEW_TSPEC = 39,
187     MAC_INVALID_INFO_ELMNT = 40,
188     MAC_INVALID_GRP_CIPHER = 41,
189     MAC_INVALID_PW_CIPHER = 42,
190     MAC_INVALID_AKMP_CIPHER = 43,
191     MAC_UNSUP_RSN_INFO_VER = 44,
192     MAC_INVALID_RSN_INFO_CAP = 45,
193     MAC_CIPHER_REJ = 46,
194     MAC_RETRY_TS_LATER = 47,
195     MAC_DLS_NOT_SUPP = 48,
196     MAC_DST_STA_NOT_IN_QBSS = 49,
197     MAC_DST_STA_NOT_QSTA = 50,
198     MAC_LARGE_LISTEN_INT = 51,
199     MAC_STATUS_INVALID_PMKID = 53,
200     MAC_ANTI_CLOGGING = 76,
201     MAC_FINITE_CYCLIC_GROUP_NOT_SUPPORTED = 77,
202     MAC_MISMATCH_VHTCAP = 104,
203 
204     /* 私有的定义 */
205     MAC_JOIN_RSP_TIMEOUT = 5200,
206     MAC_AUTH_RSP2_TIMEOUT = 5201,
207     MAC_AUTH_RSP4_TIMEOUT = 5202,
208     MAC_ASOC_RSP_TIMEOUT = 5203,
209     /* 在AUTH状态外的AUTH超时 */
210     MAC_AUTH_RSP_TIMEOUT = 5204,
211     /* 驱动上报断连,但此断连是由STA主动触发时,状态码添加此偏移用于给上层做区分 */
212     MAC_REPORT_ACTIVE_DISCONN_OFFSET = 5205,
213     MAC_DISASOC_MISC_LINKLOSS = 5206,
214 #ifdef _PRE_WLAN_FEATURE_CHBA
215     /* CHBA: 添加私有code */
216     MAC_CHBA_INIT_CODE = 6200,
217     MAC_CHBA_INVAILD_CONNECT_CMD = 6201,
218     MAC_CHBA_REPEAT_CONNECT_CMD = 6202, /* 重复建链命令,且两条建链命令参数不匹配 */
219     MAC_CHBA_CREATE_NEW_USER_FAIL = 6203, /* 创建新用户失败,一般是因为超过芯片规格 */
220     MAC_CHBA_UNSUP_ASSOC_CHANNEL, /* 无法在下发的建链信道上完成建链 */
221     MAC_CHBA_COEX_FAIL, /* 不满足vap共存条件 */
222     MAC_CHBA_UNSUP_PARALLEL_CONNECT, /* 暂不支持并行建链 */
223 #endif
224     MAC_STATUS_MAX = 7000,
225 } mac_status_code_enum;
226 typedef osal_u16 mac_status_code_enum_uint16;
227 
228 /* BA会话管理确认策略 */
229 typedef enum {
230     MAC_BA_POLICY_DELAYED = 0,
231     MAC_BA_POLICY_IMMEDIATE,
232 
233     MAC_BA_POLICY_BUTT
234 } mac_ba_policy_enum;
235 typedef osal_u8 mac_ba_policy_enum_uint8;
236 
237 /* 发起DELBA帧的端点的枚举 */
238 typedef enum {
239     MAC_RECIPIENT_DELBA = 0, /* 数据的接收端 */
240     MAC_ORIGINATOR_DELBA,    /* 数据的发起端 */
241 
242     MAC_BUTT_DELBA
243 } mac_delba_initiator_enum;
244 typedef osal_u8 mac_delba_initiator_enum_uint8;
245 
246 /* 发起DELBA帧的业务类型的枚举 */
247 typedef enum {
248     MAC_DELBA_TRIGGER_COMM = 0, /* 配置命令触发 */
249     MAC_DELBA_TRIGGER_BTCOEX,   /* BT业务触发 */
250 
251     MAC_DELBA_TRIGGER_BUTT
252 } mac_delba_trigger_enum;
253 typedef osal_u8 mac_delba_trigger_enum_uint8;
254 
255 /* 802.11n下的私有请求 */
256 typedef enum {
257     MAC_A_MPDU_START = 0,
258     MAC_A_MPDU_END = 1,
259 
260     MAC_A_MPDU_BUTT
261 } mac_priv_req_11n_enum;
262 typedef osal_u8 mac_priv_req_11n_enum_uint8;
263 
264 /* BlockAck Category下的Action值的枚举 */
265 typedef enum {
266     MAC_BA_ACTION_ADDBA_REQ = 0,
267     MAC_BA_ACTION_ADDBA_RSP = 1,
268     MAC_BA_ACTION_DELBA = 2,
269 
270     MAC_BA_ACTION_BUTT
271 } mac_ba_action_type_enum;
272 typedef osal_u8 mac_ba_action_type_enum_uint8;
273 
274 /* Reason Codes for Deauthentication and Disassociation Frames */
275 typedef enum {
276     MAC_UNSPEC_REASON = 1,
277     MAC_AUTH_NOT_VALID = 2,
278     MAC_DEAUTH_LV_SS = 3,
279     MAC_INACTIVITY = 4,
280     MAC_AP_OVERLOAD = 5,
281     MAC_NOT_AUTHED = 6,
282     MAC_NOT_ASSOCED = 7,
283     MAC_DISAS_LV_SS = 8,
284     MAC_ASOC_NOT_AUTH = 9,
285     MAC_INVLD_ELEMENT = 13,
286     MAC_MIC_FAIL = 14,
287     MAC_4WAY_HANDSHAKE_TIMEOUT = 15,
288     MAC_IEEE_802_1X_AUTH_FAIL = 23,
289     MAC_UNSPEC_QOS_REASON = 32,
290     MAC_QAP_INSUFF_BANDWIDTH = 33,
291     MAC_POOR_CHANNEL = 34,
292     MAC_STA_TX_AFTER_TXOP = 35,
293     MAC_QSTA_LEAVING_NETWORK = 36,
294     MAC_QSTA_INVALID_MECHANISM = 37,
295     MAC_QSTA_SETUP_NOT_DONE = 38,
296     MAC_QSTA_TIMEOUT = 39,
297     MAC_QSTA_CIPHER_NOT_SUPP = 45
298 } mac_reason_code_enum;
299 typedef osal_u16 mac_reason_code_enum_uint16;
300 
301 /*****************************************************************************
302   信息元素(Infomation Element)的Element ID
303   协议521页,Table 8-54—Element IDs
304 *****************************************************************************/
305 typedef enum {
306     MAC_EID_SSID = 0,
307     MAC_EID_RATES = 1,
308     MAC_EID_FHPARMS = 2,
309     MAC_EID_DSPARMS = 3,
310     MAC_EID_CFPARMS = 4,
311     MAC_EID_TIM = 5,
312     MAC_EID_IBSSPARMS = 6,
313     MAC_EID_COUNTRY = 7,
314     MAC_EID_REQINFO = 10,
315     MAC_EID_QBSS_LOAD = 11,
316     MAC_EID_TSPEC = 13,
317     MAC_EID_TCLAS = 14,
318     MAC_EID_CHALLENGE = 16,
319     /* 17-31 reserved */
320     MAC_EID_PWRCNSTR = 32,
321     MAC_EID_PWRCAP = 33,
322     MAC_EID_TPCREQ = 34,
323     MAC_EID_TPCREP = 35,
324     MAC_EID_SUPPCHAN = 36,
325     MAC_EID_CHANSWITCHANN = 37, /* Channel Switch Announcement IE */
326     MAC_EID_MEASREQ = 38,
327     MAC_EID_MEASREP = 39,
328     MAC_EID_QUIET = 40,
329     MAC_EID_IBSSDFS = 41,
330     MAC_EID_ERP = 42,
331     MAC_EID_TCLAS_PROCESS = 44,
332     MAC_EID_HT_CAP = 45,
333     MAC_EID_QOS_CAP = 46,
334     MAC_EID_RESERVED_47 = 47,
335     MAC_EID_RSN = 48,
336     MAC_EID_RESERVED_49 = 49,
337     MAC_EID_XRATES = 50,
338     MAC_EID_AP_CHAN_REPORT = 51,
339     MAC_EID_NEIGHBOR_REPORT = 52,
340     MAC_EID_MOBILITY_DOMAIN = 54,
341     MAC_EID_FT = 55,
342     MAC_EID_TIMEOUT_INTERVAL = 56,
343     MAC_EID_RDE = 57,
344     MAC_EID_OPERATING_CLASS = 59,  /* Supported Operating Classes */
345     MAC_EID_EXTCHANSWITCHANN = 60, /* Extended Channel Switch Announcement IE */
346     MAC_EID_HT_OPERATION = 61,
347     MAC_EID_SEC_CH_OFFSET = 62, /* Secondary Channel Offset IE */
348     MAC_EID_WAPI = 68,          /* IE for WAPI */
349     MAC_EID_TIME_ADVERTISEMENT = 69,
350     MAC_EID_RRM = 70,                /* Radio resource measurement */
351     MAC_EID_MULTIPLE_BSSID = 71,     /* Multiple BSSID */
352     MAC_EID_2040_COEXT = 72,         /* 20/40 BSS Coexistence IE */
353     MAC_EID_2040_INTOLCHREPORT = 73, /* 20/40 BSS Intolerant Channel Report IE */
354     MAC_EID_OBSS_SCAN = 74,          /* Overlapping BSS Scan Parameters IE */
355     MAC_EID_MMIE = 76,               /* 802.11w Management MIC IE */
356     MAC_EID_EVENT_REPORT = 79,
357     MAC_EID_NONTRANS_BSSID_CAPA = 83, /* Nontransmitted BSSID Capability element */
358     MAC_EID_MULTI_BSSID_IDX = 85,    /* Multiple BSSID-Index element */
359     MAC_EID_FMS_DESCRIPTOR = 86,     /* 802.11v FMS descriptor IE */
360     MAC_EID_FMS_REQUEST = 87,        /* 802.11v FMS request IE */
361     MAC_EID_FMS_RESPONSE = 88,       /* 802.11v FMS response IE */
362     MAC_EID_BSSMAX_IDLE_PERIOD = 90, /* BSS MAX IDLE PERIOD */
363     MAC_EID_TFS_REQUEST = 91,
364     MAC_EID_TFS_RESPONSE = 92,
365     MAC_EID_TIM_BCAST_REQUEST = 94,
366     MAC_EID_TIM_BCAST_RESPONSE = 95,
367     MAC_EID_INTERWORKING = 107,
368     MAC_EID_EXT_CAPS = 127, /* Extended Capabilities IE */
369     MAC_EID_VHT_TYPE = 129,
370     MAC_EID_11NTXBF = 130, /* 802.11n txbf */
371     MAC_EID_RESERVED_133 = 133,
372     MAC_EID_TPC = 150,
373     MAC_EID_CCKM = 156,
374     MAC_EID_VHT_CAP = 191,
375     MAC_EID_VHT_OPERN = 192,         /* VHT Operation IE */
376     MAC_EID_WIDE_BW_CH_SWITCH = 194, /* Wide Bandwidth Channel Switch IE */
377     MAC_EID_OPMODE_NOTIFY = 199,     /* Operating Mode Notification IE */
378     MAC_EID_FTMP = 206,
379     MAC_EID_TWT = 216,
380     MAC_EID_FTMSI = 255,
381     MAC_EID_VENDOR = 221, /* vendor private */
382     MAC_EID_WMM = 221,
383     MAC_EID_WPA = 221,
384     MAC_EID_WPS = 221,
385     MAC_EID_P2P = 221,
386     MAC_EID_WFA_TPC_RPT = 221,
387     MAC_EID_RSNX = 244,
388     MAC_EID_HE = 255,
389 #ifdef _PRE_WLAN_FEATURE_WUR_TX
390     MAC_EID_WUR = 255,
391 #endif
392 } mac_eid_enum;
393 typedef osal_u8 mac_eid_enum_uint8;
394 
395 typedef enum {
396     MAC_EID_EXT_OWE_DH_PARAM = 32,
397     MAC_EID_EXT_HE_CAP = 35,
398     MAC_EID_EXT_HE_OPERATION = 36,
399     MAC_EID_EXT_UORA_PARAMETER_SET = 37,
400     MAC_EID_EXT_HE_EDCA = 38,
401     MAC_EID_EXT_HE_SRP = 39,
402     MAC_EID_EXT_NFR_PARAM_SET = 41,
403     MAC_EID_EXT_HE_BSS_COLOR_CHANGE_ANNOUNCEMENT = 42,
404     MAC_EID_EXT_QUIET_TIME_PERIOD_SETUP = 43,
405     MAC_EID_EXT_ESS_REPORT = 45,
406     MAC_EID_EXT_OPS = 46,
407     MAC_EID_EXT_HE_BSS_LOAD = 47,
408 #ifdef _PRE_WLAN_FEATURE_WUR_TX
409     MAC_EID_EXT_WUR_CAP = 48,
410     MAC_EID_EXT_WUR_OPERATION = 49,
411     MAC_EID_EXT_WUR_MODE = 50,
412 #endif
413     MAC_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55,
414     MAC_EID_EXT_NON_INHERITANCE = 56,
415     MAC_EID_EXT_KNOWN_BSSID = 57,
416     MAC_EID_EXT_SHORT_SSID_LIST = 58,
417     MAC_EID_EXT_HE_6GHZ_BAND_CAPABILITIES = 59,
418     MAC_EID_EXT_UL_MU_POWER_CAPABILITIES = 60,
419 
420     MAC_EID_EXT_BUT
421 } mac_eid_extension_num;
422 typedef osal_u8 mac_eid_extension_num_uint8;
423 
424 typedef enum {
425     MAC_SUB_EID_NONTRANS_BSSID_PROFILE = 0,
426     MAC_SUB_EID_VENDOR_SPECIFIC = 221,
427 
428     MAC_SUB_EID_BUTT
429 }mac_sub_eid_enum;
430 
431 /* TWT命令类型 */
432 typedef enum {
433     MAC_TWT_COMMAND_REQUEST = 0,
434     MAC_TWT_COMMAND_SUGGEST = 1,
435     MAC_TWT_COMMAND_DEMAND = 2,
436     MAC_TWT_COMMAND_GROUPING = 3,
437     MAC_TWT_COMMAND_ACCEPT = 4,
438     MAC_TWT_COMMAND_ALTERNATE = 5,
439     MAC_TWT_COMMAND_DICTATE = 6,
440     MAC_TWT_COMMAND_REJECT = 7,
441 } mac_twt_command_enum;
442 typedef osal_u8 mac_twt_command_enum_uint8;
443 
444 typedef enum {
445     MAC_VHT_ACTION_COMPRESSED_BEAMFORMING = 0,
446     MAC_VHT_ACTION_GROUPID_MANAGEMENT = 1,
447     MAC_VHT_ACTION_OPREATING_MODE_NOTIFICATION = 2,
448 
449     MAC_VHT_ACTION_BUTT
450 } mac_vht_action_type_enum;
451 typedef osal_u8 mac_vht_action_type_enum_uint8;
452 
453 /* sizes for DHCP options */
454 #define DHCP_CHADDR_LENGTH         16
455 
456 #define SERVERNAME_LEN          64
457 #define BOOTFILE_LEN            128
458 #define DHCP_OPTION_LEN         72
459 
460 /*****************************************************************************
461   7 STRUCT定义
462 *****************************************************************************/
463 /* 02 dev侧用#pragma pack(1)/#pragma pack()方式达到一字节对齐 */
464 #pragma pack(1)
465 /* 此文件中结构体与协议一致,要求1字节对齐,统一加__OAL_DECLARE_PACKED */
466 struct mac_ether_header {
467     osal_u8 ether_dhost[ETHER_ADDR_LEN];
468     osal_u8 ether_shost[ETHER_ADDR_LEN];
469     osal_u16 ether_type;
470 };
471 typedef struct mac_ether_header mac_ether_header_stru;
472 
473 struct mac_llc_snap {
474     osal_u8 llc_dsap;
475     osal_u8 llc_ssap;
476     osal_u8 control;
477     osal_u8 org_code[3];  /* 3字节存储OUI组织代码? */
478     osal_u16 ether_type;
479 };
480 typedef struct mac_llc_snap mac_llc_snap_stru;
481 
482 /* eapol帧头 */
483 struct mac_eapol_header {
484     osal_u8 version;
485     osal_u8 type;
486     osal_u16 length;
487 };
488 typedef struct mac_eapol_header mac_eapol_header_stru;
489 
490 /* IEEE 802.11, 8.5.2 EAPOL-Key frames */
491 /* EAPOL KEY 结构定义 */
492 struct mac_eapol_key {
493     osal_u8 type;
494     /* Note: key_info, key_length, and key_data_length are unaligned */
495     osal_u8 key_info[2];   /* big endian,2字节用来储存EAPOL KEY信息 */
496     osal_u8 key_length[2]; /* big endian,2字节用来储存EAPOL KEY长度 */
497     osal_u8 replay_counter[WPA_REPLAY_COUNTER_LEN];
498     osal_u8 key_nonce[WPA_NONCE_LEN];
499     osal_u8 key_iv[16];      /* 16字节储存密钥信息 */
500     osal_u8 key_rsc[WPA_KEY_RSC_LEN];
501     osal_u8 key_id[8]; /* Reserved in IEEE 802.11i/RSN,8字节 */
502     osal_u8 key_mic[16]; /* 16字节储存EAPOL KEY的完整性信息? */
503     osal_u8 key_data_length[2]; /* big endian,2字节储存EAPOL KEY数据段长度 */
504     /* followed by key_data_length bytes of key_data */
505 };
506 typedef struct mac_eapol_key mac_eapol_key_stru;
507 
508 /*
509  * Structure of the IP frame
510  */
511 struct mac_ip_header {
512     osal_u8 version_ihl;
513     osal_u8 tos;
514     osal_u16 tot_len;
515     osal_u16 id;
516     osal_u16 frag_off;
517     osal_u8 ttl;
518     osal_u8 protocol;
519     osal_u16 check;
520     osal_u32 saddr;
521     osal_u32 daddr;
522     /* The options start here. */
523 };
524 typedef struct mac_ip_header mac_ip_header_stru;
525 
526 struct mac_tcp_header {
527     osal_u16 sport;
528     osal_u16 dport;
529     osal_u32 seqnum;
530     osal_u32 acknum;
531     osal_u8 offset;
532     osal_u8 flags;
533     osal_u16 window;
534     osal_u16 check;
535     osal_u16 urgent;
536 };
537 typedef struct mac_tcp_header mac_tcp_header_stru;
538 
539 /* UDP头部结构 */
540 struct mac_udp_header {
541     osal_u16   src_port;
542     osal_u16   des_port;
543     osal_u16   udp_len;
544     osal_u16   check_sum;
545 };
546 typedef struct mac_udp_header mac_udp_header_stru;
547 
548 struct dhcp_message {
549     osal_u8 op;                           /* message type */
550     osal_u8 hwtype;                       /* hardware address type */
551     osal_u8 hwlen;                        /* hardware address length */
552     osal_u8 hwopcount;                    /* should be zero in client message */
553     osal_u32 xid;                         /* transaction id */
554     osal_u16 secs;                        /* elapsed time in sec. from boot */
555     osal_u16 flags;
556     osal_u32 ciaddr;                      /* (previously allocated) client IP */
557     osal_u32 yiaddr;                      /* 'your' client IP address */
558     osal_u32 siaddr;                      /* should be zero in client's messages */
559     osal_u32 giaddr;                      /* should be zero in client's messages */
560     osal_u8 chaddr[DHCP_CHADDR_LENGTH];      /* client's hardware address */
561     osal_u8 servername[SERVERNAME_LEN];   /* server host name */
562     osal_u8 bootfile[BOOTFILE_LEN];       /* boot file name */
563     osal_u32 cookie;
564     osal_u8 options[DHCP_OPTION_LEN];     /* message options, cookie */
565 };
566 typedef struct dhcp_message dhcp_message_stru;
567 
568 /* frame control字段结构体 */
569 struct mac_header_frame_control {
570     osal_u16 protocol_version : 2, /* 协议版本 */
571            type : 2,                /* 帧类型 */
572            sub_type : 4,            /* 子类型 */
573            to_ds : 1,               /* 发送DS */
574            from_ds : 1,             /* 来自DS */
575            more_frag : 1,           /* 分段标识 */
576            retry : 1,               /* 重传帧 */
577            power_mgmt : 1,          /* 节能管理 */
578            more_data : 1,           /* 更多数据标识 */
579            protected_frame : 1,     /* 加密标识 */
580            order : 1;               /* 次序位 */
581 };
582 typedef struct mac_header_frame_control mac_header_frame_control_stru;
583 
584 /* 基础802.11帧结构 */
585 struct mac_ieee80211_frame {
586     mac_header_frame_control_stru   frame_control;
587     osal_u16                        duration_value  : 15,
588                                     duration_flag   : 1;
589     osal_u8                         address1[WLAN_MAC_ADDR_LEN];
590     osal_u8                         address2[WLAN_MAC_ADDR_LEN];
591     osal_u8                         address3[WLAN_MAC_ADDR_LEN];
592     osal_u16                        frag_num        : 4,
593                                     seq_num         : 12;
594 };
595 typedef struct mac_ieee80211_frame mac_ieee80211_frame_stru;
596 
597 /* ps poll帧结构 */
598 struct mac_ieee80211_pspoll_frame {
599     mac_header_frame_control_stru   frame_control;
600     osal_u16                        aid_value   : 14,                   /* ps poll 下的AID字段 */
601                                     aid_flag1   : 1,
602                                     aid_flag2   : 1;
603     osal_u8                         bssid[WLAN_MAC_ADDR_LEN];
604     osal_u8                         trans_addr[WLAN_MAC_ADDR_LEN];
605 };
606 typedef struct mac_ieee80211_pspoll_frame mac_ieee80211_pspoll_frame_stru;
607 
608 /* qos帧结构 */
609 struct mac_ieee80211_qos_frame {
610     mac_header_frame_control_stru   frame_control;
611     osal_u16                      duration_value      : 15,           /* duration/id */
612                                   duration_flag       : 1;
613     osal_u8                       address1[WLAN_MAC_ADDR_LEN];
614     osal_u8                       address2[WLAN_MAC_ADDR_LEN];
615     osal_u8                       address3[WLAN_MAC_ADDR_LEN];
616     osal_u16                      frag_num        : 4,                /* sequence control */
617                                   seq_num         : 12;
618     osal_u8                       qc_tid          : 4,
619                                   qc_eosp         : 1,
620                                   qc_ack_polocy   : 2,
621                                   qc_amsdu        : 1;
622     union {
623         osal_u8                   qc_txop_limit;
624         osal_u8                   qc_ps_buf_state_resv        : 1,
625                                   qc_ps_buf_state_inducated   : 1,
626                                   qc_hi_priority_buf_ac       : 2,
627                                   qc_qosap_buf_load           : 4;
628     } qos_control;
629 };
630 typedef struct mac_ieee80211_qos_frame mac_ieee80211_qos_frame_stru;
631 
632 /* qos+HTC 帧结构 */
633 struct mac_ieee80211_qos_htc_frame {
634     mac_header_frame_control_stru frame_control;
635     osal_u16                      duration_value      : 15,           /* duration/id */
636                                   duration_flag       : 1;
637     osal_u8                       address1[WLAN_MAC_ADDR_LEN];
638     osal_u8                       address2[WLAN_MAC_ADDR_LEN];
639     osal_u8                       address3[WLAN_MAC_ADDR_LEN];
640     osal_u16                      frag_num     : 4,                /* sequence control */
641                                   seq_num      : 12;
642     osal_u8                       qc_tid          : 4,
643                                   qc_eosp         : 1,
644                                   qc_ack_polocy   : 2,
645                                   qc_amsdu        : 1;
646     union {
647         osal_u8                   qc_txop_limit;
648         osal_u8                   qc_ps_buf_state_resv        : 1,
649                                   qc_ps_buf_state_inducated   : 1,
650                                   qc_hi_priority_buf_ac       : 2,
651                                   qc_qosap_buf_load           : 4;
652     } qos_control;
653 
654     osal_u32                      htc;
655 };
656 typedef struct mac_ieee80211_qos_htc_frame mac_ieee80211_qos_htc_frame_stru;
657 
658 
659 /* TIM信息元素结构体 */
660 struct mac_tim_ie {
661     osal_u8 tim_ie; /* MAC_EID_TIM */
662     osal_u8 tim_len;
663     osal_u8 dtim_count;     /* DTIM count */
664     osal_u8 dtim_period;    /* DTIM period */
665     osal_u8 tim_bitctl;     /* bitmap control */
666     osal_u8 tim_bitmap[1]; /* variable-length bitmap */
667 };
668 typedef struct mac_tim_ie mac_tim_ie_stru;
669 
670 /* 扩展能力信息元素结构体定义 */
671 struct mac_ext_cap_ie {
672     osal_u8       coexistence_mgmt_2040 : 1,
673                 resv1             : 1,
674                 ext_chan_switch       : 1,
675                 resv2                 : 1,
676                 psmp                  : 1,
677                 resv3                 : 1,
678                 s_psmp                : 1,
679                 event                 : 1;
680     osal_u8   resv4                : 4,
681             proxyarp             : 1,
682             resv13               : 3;   /* bit13~bit15 */
683     osal_u8   resv5                : 3,
684             bss_transition       : 1,   /* bit19 */
685             resv14               : 2,   /* bit20~bit23 */
686             multiple_bssid       : 1,
687             resv15               : 1;
688     osal_u8   resv6                : 7,
689             interworking         : 1;
690     osal_u8   resv7                         : 5,
691             tdls_prhibited                : 1,
692             tdls_channel_switch_prhibited : 1,
693             resv8                         : 1;
694 
695     osal_u8   resv9                : 8;
696     osal_u8   resv10               : 8;
697 
698     osal_u8   resv11                        : 6,
699             operating_mode_notification   : 1, /* 11ac Operating Mode Notification特性标志 */
700             resv12                        : 1;
701 
702     osal_u8 resv16 : 6,
703           ftm_resp : 1, /* bit70 Fine Timing Measurement Responder */
704           ftm_int : 1; /* bit71 Fine Timing Measurement Initiator */
705 
706     osal_u8 resv17 : 5,
707           twt_requester_support : 1, /* 11ax TWT requester 特性标志 */
708           resv18 : 2;
709 };
710 typedef struct mac_ext_cap_ie mac_ext_cap_ie_stru;
711 
712 struct mac_ext_cap_get_multi_bssid_ie {
713     osal_u8     coexistence_mgmt_2040   : 1,
714                 resv0                   : 1,
715                 ext_chan_switch         : 1,
716                 resv1                   : 1,
717                 psmp                    : 1,
718                 resv2                   : 1,
719                 s_psmp                  : 1,
720                 event                   : 1;
721     osal_u8     resv3                   : 4,
722                 proxyarp                : 1,
723                 resv4                   : 3;   /* bit13~bit15 */
724     osal_u8     resv5                   : 3,
725                 bss_transition          : 1,   /* bit19 */
726                 resv6                   : 2,   /* bit20~bit23 */
727                 multiple_bssid          : 1,
728                 resv7                   : 1;
729 };
730 typedef struct mac_ext_cap_get_multi_bssid_ie mac_ext_cap_get_multi_bssid_ie_stru;
731 
732 struct mac_twt_request_type {
733     osal_u16 request : 1;
734     osal_u16 setup_command : 3;
735     osal_u16 trigger : 1;
736     osal_u16 implicit : 1;
737     osal_u16 flow_type : 1;
738     osal_u16 flow_id : 3;
739     osal_u16 intrval_exponent : 5;
740     osal_u16 protection : 1;
741 };
742 typedef struct mac_twt_request_type mac_twt_request_type_stru;
743 
744 struct mac_twt_control_field {
745     osal_u8 ndp_paging_indicator : 1;
746     osal_u8 responder_pm_mode : 1;
747     osal_u8 negotiation : 2;
748     osal_u8 twt_info_frame_disable : 1;
749     osal_u8 wake_duration_unit : 1;
750     osal_u8 resv : 2;
751 };
752 typedef struct mac_twt_control_field mac_twt_control_field_stru;
753 
754 /* 新增结构体,用以表示TWT Element */
755 struct mac_twt_ie_individual {
756     osal_u8 element_id;
757     osal_u8 len;
758     mac_twt_control_field_stru control;
759     mac_twt_request_type_stru request_type;
760     osal_u64 twt;
761     osal_u8 min_duration;
762     osal_u16 intrval_mantissa;
763     osal_u8 channel;
764 };
765 typedef struct mac_twt_ie_individual mac_twt_ie_individual_stru;
766 
767 /* 封装了twt信息元素,修改了结构体名称 */
768 struct mac_individual_twt_setup_frame {
769     osal_u8 category;
770     osal_u8 action;
771     osal_u8 dialog_token;
772     mac_twt_ie_individual_stru twt_element;
773 };
774 typedef struct mac_individual_twt_setup_frame mac_individual_twt_setup_frame_stru;
775 
776 struct mac_twt_teardown {
777     osal_u8 category;
778     osal_u8 action;
779     osal_u8 flow_id          : 3,
780             resv1            : 2,
781             nego_type        : 2,
782             teardown_all_twt : 1;
783 };
784 typedef struct mac_twt_teardown mac_twt_teardown_stru;
785 
786 struct mac_twt_information_field {
787     osal_u8 flow_id : 3;
788     osal_u8 response_requested : 1;
789     osal_u8 next_twt_request : 1;
790     osal_u8 next_twt_subfield_size : 2;
791     osal_u8 all_twt : 1;
792 };
793 typedef struct mac_twt_information_field mac_twt_information_field_stru;
794 
795 struct mac_twt_information_frame {
796     osal_u8 category;
797     osal_u8 action;
798     mac_twt_information_field_stru twt_information_filed;
799     osal_u64 next_twt;
800 };
801 typedef struct mac_twt_information_frame mac_twt_information_frame_stru;
802 
803 typedef struct {
804     mac_llc_snap_stru snap;
805     mac_ip_header_stru ip_hdr;
806     mac_udp_header_stru udp_hdr;
807     dhcp_message_stru dhcp;
808 } dhcp_record_frame;
809 
810 /* HE_Cap:he mac cap 字段,Len=6  */
811 struct mac_frame_he_mac_cap {
812     osal_u8 htc_he_support : 1, /* B0-指示站点是否支持接收Qos Data、Qos Null、管理帧携带 HE 变体的HT Control field */
813           twt_requester_support : 1, /* B1-是否支持TWT Requester */
814           twt_responder_support : 1, /* B2-是否支持TWT Responder */
815           fragmentation_support : 2, /* B3-动态分片能力 */
816           msdu_max_fragment_num : 3; /* B5-msdu最大分片数 */
817 
818     osal_u16 min_fragment_size : 2,            /* B8-最小分片的长度 */
819            trigger_mac_padding_duration : 2,    /* B10-trigger mac padding 时长 */
820            mtid_aggregation_rx_support : 3,     /* B12-接收多tid聚合支持 */
821            he_link_adaptation : 2,              /* B15-使用HE 变体的HT Control field 调整 */
822            all_ack_support : 1,                 /* B17-支持接收M-BA */
823            trs_support : 1,                         /* B18-A-Control 支持 TSR */
824            bsr_support : 1,                     /* B19-A-Control 支持BSR */
825            broadcast_twt_support : 1,           /* B20-支持广播twt */
826            ba_bitmap_support_32bit : 1,         /* B21-支持32位bitmap ba */
827            mu_cascading_support : 1,            /* B22-mu csacade */
828            ack_enabled_aggregation_support : 1; /* B23-A-MPDU ack使能 */
829 
830     osal_u8 reserved2 : 1,                      /* B24 */
831           om_control_support : 1,           /* B25-A-Control 支持OMI  */
832           ofdma_ra_support : 1,             /* B26-OFDMA 随机接入 */
833           max_ampdu_length_exponent : 2,    /* B27-A-MPDU最大长度 */
834           amsdu_fragment_support : 1,       /* B29- */
835           flex_twt_schedule_support : 1,    /* B30- */
836           rx_control_frame_to_multibss : 1; /* B31- */
837 
838     osal_u16          bsrp_bqrp_ampdu_addregation                        : 1, /* B32- */
839                     qtp_support                                        : 1,
840                     bqr_support                                        : 1,
841                     sr_responder                                       : 1,
842                     ndp_feedback_report_support                        : 1,
843                     ops_support                                        : 1,
844                     amsdu_ampdu_support                                : 1,
845                     mtid_aggregation_tx_support                        : 3,
846                     he_subchannel_sel_trans_support                        : 1, /* B42 */
847                     ru_support_2x996_tone                               : 1, /* B43 */
848                     om_control_ul_mu_data_disable_rx_support               : 1, /* B44 */
849                     dynamic_sm_ps                                          : 1, /* B45 */
850                     punctured_sounding_support                             : 1, /* B46 */
851                     ht_vht_tf_rx_support                                   : 1; /* B47 */
852 };
853 typedef struct mac_frame_he_mac_cap mac_frame_he_mac_cap_stru;
854 
855 /* HE_CAP: PHY Cap 字段 Len=9   */
856 struct mac_frame_he_phy_cap {
857     osal_u8 reserved : 1,
858           channel_width_set : 7; /* B1-7: */
859 
860     osal_u16 punctured_preamble_rx : 4,     /* B8-11: */
861            device_class : 1,                 /* B12- */
862            ldpc_coding_in_paylod : 1,        /* B13- */
863            he_su_ppdu_1xltf_08us_gi : 1,     /* B14-HE SU PPDU 1x HE-LTF + 0.8usGI  */
864            midamble_rx_max_nsts : 2,         /* B15 */
865            ndp_4xltf_32us : 1,               /* B17-ndp 4x HE-LTF + 3.2usGI */
866            stbc_tx_below_80mhz : 1,          /* B18 */
867            stbc_rx_below_80mhz : 1,          /* B19 */
868            dopper_tx : 1,                    /* B20 */
869            droper_rx : 1,                    /* B21 */
870            full_bandwidth_ul_mu_mimo : 1,    /* B22 */
871            partial_bandwidth_ul_mu_mimo : 1; /* B23 */
872 
873     osal_u8 dcm_max_constellation_tx : 2,       /* B24- */
874           dcm_max_nss_tx : 1,                   /* B26 */
875           dcm_max_constellation_rx : 2,         /* B27- */
876           dcm_max_nss_rx : 1,                   /* B29- */
877           rx_partial_bw_su_in_20mhz_he_mu_ppdu : 1, /* B30 */
878           su_beamformer : 1;                    /* B31- */
879 
880     osal_u8 su_beamformee : 1,            /* B32- */
881           mu_beamformer : 1,              /* B33- */
882           beamformee_sts_below_80mhz : 3, /* B34- */
883           beamformee_sts_over_80mhz : 3;  /* B37- */
884 
885     osal_u8 below_80mhz_sounding_dimensions_num : 3, /* B40- */
886           over_80mhz_sounding_dimensions_num : 3,    /* B43- */
887           ng16_su_feedback : 1,                      /* B46- */
888           ng16_mu_feedback : 1;                      /* B47- */
889 
890     osal_u8 codebook_42_su_feedback : 1,              /* B48- */
891           codebook_75_mu_feedback : 1,                /* B49- */
892           trigger_su_beamforming_feedback : 1,        /* B50- */
893           trigger_mu_beamforming_partial_bw_feedback : 1, /* B51 */
894           trigger_cqi_feedback : 1,                   /* B52- */
895           partial_bandwidth_extended_range : 1,       /* B53- */
896           partial_bandwidth_dl_mu_mimo : 1,           /* B54- */
897           ppe_threshold_present : 1;                  /* B55- */
898 
899     osal_u8 srp_based_sr_support : 1,      /* B56- */
900           power_boost_factor_support : 1,  /* B57- */
901           he_su_mu_ppdu_4xltf_08us_gi : 1, /* B58-he su ppdu and he mu ppdu 4x HE-LTF + 0.8usGI */
902           max_nc : 3,                      /* B59- */
903           stbc_tx_over_80mhz : 1,          /* B62- */
904           stbc_rx_over_80mhz : 1;          /* B63- */
905 
906     osal_u8 he_er_su_ppdu_4xltf_08us_gi : 1, /* B64- */
907           he_ppdu_2g_20mhz_in_40mhz : 1,     /* B65- */
908           he_ppdu_20mhz_in_160mhz : 1,       /* B66- */
909           he_ppdu_80mhz_in_160mhz : 1,       /* B67- */
910           he_er_su_ppdu_1xltf_08us_gi : 1,   /* B68- */
911           midamble_rx_2x_1x_he_ltf : 1,      /* B69- */
912           dcm_max_ru : 2;                        /* B70- */
913 
914     osal_u8 longer_16_he_sig_ofdm_symbols_support : 1,              /* B72 */
915           non_trigger_cqi_feedback : 1,                             /* B73 */
916           tx_1024_qam_below_242_tone_ru_support : 1,                /* B74 */
917           rx_1024_qam_below_242_tone_ru_support : 1,                /* B75 */
918           rx_full_bw_su_using_he_mu_ppdu_compress_he_sig_b : 1,     /* B76 */
919           rx_full_bw_su_using_he_mu_ppdu_non_compress_he_sig_b : 1, /* B77 */
920           nominal_packet_padding : 2;                               /* B78 */
921 
922     osal_u8 reserved2; /* B80 */
923 };
924 typedef struct mac_frame_he_phy_cap mac_frame_he_phy_cap_stru;
925 
926 /* HE CAP:Tx Rx MCS NSS Support */
927 struct mac_frame_he_mcs_nss_bit_map {
928     osal_u16 max_he_mcs_for_1ss : 2,
929            max_he_mcs_for_2ss : 2,
930            max_he_mcs_for_3ss : 2,
931            max_he_mcs_for_4ss : 2,
932            max_he_mcs_for_5ss : 2,
933            max_he_mcs_for_6ss : 2,
934            max_he_mcs_for_7ss : 2,
935            max_he_mcs_for_8ss : 2;
936 };
937 typedef struct mac_frame_he_mcs_nss_bit_map mac_frame_he_mcs_nss_bit_map_stru;
938 
939 struct mac_fram_he_mac_nsss_set {
940     mac_frame_he_mcs_nss_bit_map_stru rx_he_mcs_below_80mhz;
941     mac_frame_he_mcs_nss_bit_map_stru tx_he_mcs_below_80mhz;
942 };
943 typedef struct mac_fram_he_mac_nsss_set mac_fram_he_mac_nsss_set_stru;
944 
945 struct mac_frame_he_operation_param {
946     osal_u16 default_pe_duration : 3,             /* B0_2: */
947            twt_required : 1,                    /* B3: */
948            txop_duration_rts_threshold : 10,    /* B4_13: */
949            vht_operation_info_present : 1,      /* B14: */
950            co_located_bss : 1;                  /* B15 */
951 
952     osal_u8 er_su_disable : 1,            /* B16; */
953           er_6g_oper_info_present : 1,  /* B17: */
954           reserved : 6;                 /* B18_23: */
955 };
956 typedef struct mac_frame_he_operation_param mac_frame_he_operation_param_stru;
957 
958 struct mac_frame_he_bss_color_info {
959     osal_u8           bss_color                                   : 6,
960                       partial_bss_color                           : 1,
961                       bss_color_disable                           : 1;
962 };
963 typedef struct mac_frame_he_bss_color_info mac_frame_he_bss_color_info_stru;
964 
965 struct mac_frame_vht_operation_info {
966     osal_u8 channel_width;
967     osal_u8 center_freq_seg0;
968     osal_u8 center_freq_seg1;
969 };
970 typedef struct mac_frame_vht_operation_info mac_frame_vht_operation_info_stru;
971 
972 /* HE_CAP:固定长度部分 */
973 struct mac_frame_he_cap_ie {
974     mac_frame_he_mac_cap_stru he_mac_cap;
975     mac_frame_he_phy_cap_stru he_phy_cap;
976     mac_fram_he_mac_nsss_set_stru he_mcs_nss;
977     osal_u8 rsv[7]; /* 7 BYTE保留字段 */
978 };
979 typedef struct mac_frame_he_cap_ie mac_frame_he_cap_ie_stru;
980 
981 struct mac_frame_he_oper_ie {
982     mac_frame_he_operation_param_stru  he_oper_param;
983     mac_frame_he_bss_color_info_stru   bss_color;
984     mac_frame_he_mcs_nss_bit_map_stru  he_basic_mcs_nss;
985     osal_u8                            rsv[1];
986     mac_frame_vht_operation_info_stru  vht_operation_info;
987 };
988 typedef struct mac_frame_he_oper_ie mac_frame_he_oper_ie_stru;
989 /* 02 dev侧用#pragma pack(1)/#pragma pack()方式达到一字节对齐 */
990 #pragma pack()
991 
992 osal_u8 *mac_find_ie_etc(osal_u8 eid, osal_u8 *ie_addr, osal_s32 frame_len);
993 
994 /*****************************************************************************
995   10 函数声明
996 *****************************************************************************/
997 /*****************************************************************************
998  函 数 名  : mac_hdr_set_frame_control
999  功能描述  : This function sets the 'frame control' bits in the MAC header of the
1000              input frame to the given 16-bit value.
1001 
1002 *****************************************************************************/
mac_hdr_set_frame_control(osal_u8 * header,osal_u16 fc)1003 static INLINE__ osal_void mac_hdr_set_frame_control(osal_u8 *header, osal_u16 fc)
1004 {
1005     header[0] = (osal_u8)fc;
1006     header[1] = (osal_u8)(fc >> 8); /* 8:右移8位 */
1007 }
1008 
1009 /*****************************************************************************
1010  函 数 名  : mac_hdr_get_from_ds
1011  功能描述  : This function extracts the 'from ds' bit from the MAC header of the input frame.
1012              Returns the value in the LSB of the returned value.
1013 
1014 *****************************************************************************/
mac_hdr_get_from_ds(osal_u8 * header)1015 static INLINE__ osal_u8 mac_hdr_get_from_ds(osal_u8 *header)
1016 {
1017     return (osal_u8)((mac_header_frame_control_stru *)(header))->from_ds;
1018 }
1019 
1020 /*****************************************************************************
1021  函 数 名  : mac_hdr_get_to_ds
1022  功能描述  : This function extracts the 'to ds' bit from the MAC header of the input frame.
1023              Returns the value in the LSB of the returned value.
1024 
1025 *****************************************************************************/
mac_hdr_get_to_ds(osal_u8 * header)1026 static INLINE__ osal_u8 mac_hdr_get_to_ds(osal_u8 *header)
1027 {
1028     return (osal_u8)((mac_header_frame_control_stru *)(header))->to_ds;
1029 }
1030 
1031 /*****************************************************************************
1032  函 数 名  : mac_get_tid_value
1033  功能描述  : 四地址获取帧头中的tid
1034 
1035 *****************************************************************************/
mac_get_tid_value(const osal_u8 * header,oal_bool_enum_uint8 is_4addr)1036 static INLINE__ osal_u8 mac_get_tid_value(const osal_u8 *header, oal_bool_enum_uint8 is_4addr)
1037 {
1038     if (is_4addr) {
1039         return (header[MAC_QOS_CTRL_FIELD_OFFSET_4ADDR] & 0x07); /* B0 - B2 */
1040     } else {
1041         return (header[MAC_QOS_CTRL_FIELD_OFFSET] & 0x07); /* B0 - B2 */
1042     }
1043 }
1044 
1045 /*****************************************************************************
1046  函 数 名  : mac_null_data_encap
1047  功能描述  : 封装空桢
1048  输入参数  : header-80211头部指针
1049              fc frame control类型
1050              da: 目的mac地址
1051              sa: 源mac地址
1052 
1053 *****************************************************************************/
mac_null_data_encap(osal_u8 * header,osal_u16 fc,const osal_u8 * da,const osal_u8 * sa)1054 static INLINE__ osal_void mac_null_data_encap(osal_u8 *header, osal_u16 fc, const osal_u8 *da, const osal_u8 *sa)
1055 {
1056     mac_hdr_set_frame_control(header, fc);
1057 
1058     /* FROM_AP设置ADDR1为DA TO_AP设置ADDR1为BSSID */
1059     oal_set_mac_addr((header + 4), da); /* 偏移4字节 */
1060     /* FROM_AP设置ADDR2为BSSID TO_AP设置ADDR2为SA */
1061     oal_set_mac_addr((header + 10), sa); /* 偏移10字节 */
1062 
1063     if (((fc & WLAN_FRAME_FROM_AP) != 0) && (fc & WLAN_FRAME_TO_AP) == 0) {
1064         /* 设置ADDR3为SA */
1065         oal_set_mac_addr((header + 16), sa); /* 偏移16字节 */
1066     }
1067     if (((fc & WLAN_FRAME_FROM_AP) == 0) && ((fc & WLAN_FRAME_TO_AP) != 0)) {
1068         /* 设置ADDR3为DA */
1069         oal_set_mac_addr((header + 16), da); /* 偏移16字节 */
1070     }
1071 }
1072 
1073 /*****************************************************************************
1074  函 数 名  : mac_get_frame_sub_type
1075  功能描述  : 获取报文的类型和子类型
1076 
1077 *****************************************************************************/
mac_get_frame_type_and_subtype(const osal_u8 * mac_header)1078 static INLINE__ osal_u8 mac_get_frame_type_and_subtype(const osal_u8 *mac_header)
1079 {
1080     return (mac_header[0] & 0xFC);
1081 }
1082 
1083 /*****************************************************************************
1084  函 数 名  : mac_get_frame_type
1085  功能描述  : 获取报文类型
1086 
1087 *****************************************************************************/
mac_get_frame_type(const osal_u8 * mac_header)1088 static INLINE__ osal_u8 mac_get_frame_type(const osal_u8 *mac_header)
1089 {
1090     return (mac_header[0] & 0x0C);
1091 }
1092 
1093 /*****************************************************************************
1094  函 数 名  : mac_get_frame_sub_type
1095  功能描述  : 获取报文的子类型
1096 
1097 *****************************************************************************/
mac_get_frame_sub_type(const osal_u8 * mac_header)1098 static INLINE__ osal_u8 mac_get_frame_sub_type(const osal_u8 *mac_header)
1099 {
1100     return (mac_header[0] & 0xF0);
1101 }
1102 
1103 /*****************************************************************************
1104  函 数 名  : mac_frame_get_type_value
1105  功能描述  : 获取80211帧帧类型,取值0~2
1106 
1107 *****************************************************************************/
mac_frame_get_type_value(const osal_u8 * mac_header)1108 static INLINE__ osal_u8 mac_frame_get_type_value(const osal_u8 *mac_header)
1109 {
1110     return (mac_header[0] & 0x0C) >> 2; /* 右移2 bit */
1111 }
1112 
1113 /*****************************************************************************
1114  函 数 名  : mac_frame_get_subtype_value
1115  功能描述  : 获取802.11帧子类型的值(0~15)
1116              帧第一个字节的高四位
1117 
1118 *****************************************************************************/
mac_frame_get_subtype_value(const osal_u8 * mac_header)1119 static INLINE__ osal_u8 mac_frame_get_subtype_value(const osal_u8 *mac_header)
1120 {
1121     return ((mac_header[0] & 0xF0) >> 4); /* 右移4 bit */
1122 }
1123 
1124 /*****************************************************************************
1125  函 数 名  : mac_get_address1
1126  功能描述  : 拷贝地址1
1127 *****************************************************************************/
mac_get_address1(osal_u8 * mac_hdr,osal_u8 * addr)1128 static INLINE__ osal_void mac_get_address1(osal_u8 *mac_hdr, osal_u8 *addr)
1129 {
1130     /* 4:addr1相对802.11帧头的偏移量 */
1131     (osal_void)memcpy_s(addr, WLAN_MAC_ADDR_LEN, mac_hdr + 4, WLAN_MAC_ADDR_LEN);
1132 }
1133 
1134 /*****************************************************************************
1135  函 数 名  : mac_hdr_set_duration
1136  功能描述  : 设置MAC头duration字段
1137 
1138 *****************************************************************************/
mac_hdr_set_duration(osal_u8 * header,osal_u16 duration)1139 static INLINE__ osal_void mac_hdr_set_duration(osal_u8 *header, osal_u16 duration)
1140 {
1141     osal_u16 *dur = (osal_u16 *)(header + WLAN_HDR_DUR_OFFSET);
1142 
1143     *dur = duration;
1144 }
1145 #ifdef __cplusplus
1146 #if __cplusplus
1147 }
1148 #endif
1149 #endif
1150 
1151 #endif /* end of mac_frame_common_rom.h */
1152