• 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: Header file of mac_user_ext.c.
15  * Create: 2020-7-8
16  */
17 #ifndef __MAC_USER_EXT_H__
18 #define __MAC_USER_EXT_H__
19 
20 /* 文件合一后去掉HMAC、DMAC两个宏 */
21 #include "mac_device_ext.h"
22 #include "frw_ext_if.h"
23 #include "wlan_spec.h"
24 #include "wlan_types_common.h"
25 #include "wlan_mib_hcm.h"
26 #include "mac_frame.h"
27 #include "mac_device_ext.h"
28 #include "oal_util.h"
29 #include "oal_ext_if.h"
30 #include "hal_ext_if.h"
31 #include "mac_user_common.h"
32 #include "wlan_resource_common.h"
33 #include "msg_rekey_offload_rom.h"
34 
35 #ifdef __cplusplus
36 #if __cplusplus
37 extern "C" {
38 #endif
39 #endif
40 
41 /* 发送BA窗口记录seq number的最大个数,必须是2的整数次幂 */
42 #define HMAC_TID_MAX_BUFS 128
43 /* 发送BA窗口记录seq number的bitmap所使用的类型长度 */
44 #define DMAC_TX_BUF_BITMAP_WORD_SIZE 32
45 /* 发送BA窗口记录seq number的bit map的长度 */
46 #define HMAC_TX_BUF_BITMAP_WORDS ((HMAC_TID_MAX_BUFS + DMAC_TX_BUF_BITMAP_WORD_SIZE - 1) / DMAC_TX_BUF_BITMAP_WORD_SIZE)
47 
48 /*****************************************************************************
49     宏定义
50 *****************************************************************************/
51 
52 /* 与发送描述符和CB字段,实际申请user idx三者同时对应,无效用户id取最大值,为全board最大用户LIMIT */
53 #define MAC_INVALID_USER_ID WLAN_USER_MAX_USER_LIMIT
54 
55 #ifdef _PRE_WLAN_FEATURE_WAPI
56 #define WAPI_KEY_LEN                    16
57 #define WAPI_PN_LEN                     16
58 #define HMAC_WAPI_MAX_KEYID             2
59 #endif
60 
61 #ifdef _PRE_WLAN_FEATURE_TX_CLASSIFY_LAN_TO_WLAN
62 #define MAX_JUDGE_CACHE_LENGTH          20  /* 业务识别-用户待识别队列长度 */
63 #define MAX_CONFIRMED_FLOW_NUM          2   /* 业务识别-用户已识别业务总数 */
64 #endif
65 /* 特性宏END,第二阶段需要挪走 */
66 
67 /*****************************************************************************
68     枚举定义
69 *****************************************************************************/
70 
71 /* 特性枚举START,第二阶段需要挪走 */
72 typedef enum {
73     WLAN_TX_TCP_DATA = 0,    /* 发送TCP data */
74     WLAN_RX_TCP_DATA = 1,    /* 接收TCP data */
75     WLAN_TX_UDP_DATA = 2,    /* 发送UDP data */
76     WLAN_RX_UDP_DATA = 3,    /* 接收UDP data */
77 
78     WLAN_TXRX_DATA_BUTT = 4,
79 } wlan_txrx_data_type_enum;
80 typedef osal_u8 wlan_txrx_data_enum_uint8;
81 
82 typedef enum {
83     BTCOEX_BLACKLIST_TPYE_FIX_BASIZE  = 0,
84     BTCOEX_BLACKLIST_TPYE_NOT_AGGR    = 1,
85 
86     BTCOEX_BLACKLIST_TPYE_BUTT
87 } btcoex_blacklist_type_enum;
88 typedef osal_u8 btcoex_blacklist_type_enum_uint8;
89 
90 /* 特性枚举END,第二阶段需要挪走 */
91 
92 /* BA会话的状态枚举 */
93 typedef enum {
94     HMAC_BA_INIT        = 0,    /* BA会话未建立 */
95     HMAC_BA_INPROGRESS,         /* BA会话建立过程中 */
96     HMAC_BA_COMPLETE,           /* BA会话建立完成 */
97     HMAC_BA_HALTED,             /* BA会话节能暂停 */
98     HMAC_BA_FAILED,             /* BA会话建立失败 */
99 
100     HMAC_BA_BUTT
101 } hmac_ba_conn_status_enum;
102 typedef osal_u8 hmac_ba_conn_status_enum_uint8;
103 
104 /*****************************************************************************
105     STRUCT定义
106 *****************************************************************************/
107 #ifdef _PRE_WLAN_FEATURE_WUR_TX
108 typedef enum {
109     HMAC_USER_WUR_MODE_OFF = 0,
110     HMAC_USER_WUR_MODE_ON = 1,
111     HMAC_USER_WUR_MODE_SUSPEND = 2
112 } hmac_user_wur_status_enum;
113 
114 /* 用户WUR能力字段信息 */
115 typedef struct {
116     osal_u8 support_2g : 1, support_5g : 1, rsvd : 6; /* 支持频段 */
117     osal_u8 transition_delay; /* 转换时延 */
118     osal_u8 vl_wur_frame_support : 1,
119             wur_group_ids_support : 2,
120             rsvd1 : 1,
121             wur_basic_ppdu_hdr_support_20mhz : 1,
122             wur_fdma_support : 1,
123 	        wur_short_wakeup_frame_support : 1,
124             rsvd2 : 1; /* 能力信息 */
125     osal_u8 rsvd3; /* 保留1字节对齐 */
126 } mac_user_wur_cap_ie_stru;
127 
128 typedef struct hmac_user_wur_info {
129     osal_u8 multi_time_cnt; /* 组播缓存/BSS参数更新,发送完WUR FL WAKE UP帧后计时 */
130     osal_u8 wur_status : 2, /* WUR服务的状态 */
131             unicast_buffered : 1, /* 用户标记单播缓存 */
132             multi_buffered : 1, /* 组播用户标记组播缓存 */
133             wur_ps_enqueue : 1, /* 是否进节能队列 */
134             send_multi_wakeup : 1, /* WUR FL WAKE UP帧已发送标记 */
135             rsvd : 2;
136     osal_u16 wur_id; /* WUR ID单播用户标识 */
137 } hmac_user_wur_info_stru;
138 #endif
139 
140 typedef struct {
141     osal_u16    spectrum_mgmt        : 1,  /* 频谱管理: 0=不支持, 1=支持 */
142                 qos                  : 1,  /* QOS: 0=非QOS站点, 1=QOS站点 */
143                 barker_preamble_mode : 1,  /* 供STA保存BSS中站点是否都支持short preamble.0=支持.1=不支持 */
144                 apsd                 : 1,  /* 自动节能: 0=不支持, 1=支持 */
145                                                /* 目前apsd只有写没有读,wifi联盟已自己定义了WMM
146                                                   节能IE代替cap apsd功能, 此处预留为后续可能出的兼容性问题提供接口 */
147                 pmf_active           : 1,  /* 管理帧加密使能开关 */
148                 erp_use_protect      : 1,  /* 供STA保存AP是否启用了ERP保护 */
149                 txbf_11n              : 1,
150                 proxy_arp            : 1,
151                 histream_cap         : 1,
152                 cap_1024qam          : 1,  /* Support 1024QAM */
153                 bss_transition       : 1,  /* Support bss transition */
154                 mdie                 : 1,  /* mobility domain IE presented, for 11r cap */
155                 enable_11k           : 1,
156                 smps_cap             : 1,  /* sta模式下,标识对端是否支持smps */
157                 dcm_cap                  : 1,
158                 use_wpa3             : 1;
159     osal_u16   resv;
160 }mac_user_cap_info_stru;
161 
162 #ifdef _PRE_WLAN_FEATURE_11AX
163 typedef struct {
164 osal_u32 max_mcs_1ss : 3,  /* 一个空间流的MCS最大支持MAP */
165          max_mcs_2ss : 3,  /* 一个空间流的MCS最大支持MAP */
166          max_mcs_3ss : 3,  /* 一个空间流的MCS最大支持MAP */
167          max_mcs_4ss : 3,  /* 一个空间流的MCS最大支持MAP */
168          max_mcs_5ss : 3,  /* 一个空间流的MCS最大支持MAP */
169          max_mcs_6ss : 3,  /* 一个空间流的MCS最大支持MAP */
170          max_mcs_7ss : 3,  /* 一个空间流的MCS最大支持MAP */
171          max_mcs_8ss : 3;  /* 一个空间流的MCS最大支持MAP */
172 } mac_max_he_mcs_map_stru;
173 typedef mac_max_he_mcs_map_stru mac_tx_max_he_mcs_map_stru;
174 typedef mac_max_he_mcs_map_stru mac_rx_max_he_mcs_map_stru;
175 #endif
176 
177 /* user结构体,对SA Query流程信息的保存结构 */
178 typedef struct {
179     osal_u32 sa_query_start_time;  /* sa_query 流程开始时间,单位ms */
180     osal_u16 sa_query_trans_id;    /* trans id */
181     osal_u16 sa_query_count;       /* number of pending SA Query requests, 0 = no SA Query in progress */
182     frw_timeout_stru sa_query_interval_timer;  /* SA Query 间隔定时器,相关dot11AssociationSAQueryRetryTimeout */
183 } mac_sa_query_stru;
184 
185 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
186 typedef struct {
187     td_u8 user_addr[WLAN_MAC_ADDR_LEN];      /* 用户mac地址 */
188     td_u8 conn_rx_rssi;
189     mac_user_asoc_state_enum_uint8 assoc_state;
190     td_u8 bcn_prio;
191     td_u8 is_mesh_user;
192     td_u8 is_initiative_role;
193 }mac_user_assoc_info_stru;
194 #endif
195 
196 #ifdef _PRE_WLAN_FEATURE_WMMAC
197 /* user结构中,ts信息的保存结果 */
198 typedef struct mac_ts {
199     osal_u32                           medium_time;
200     osal_u8                            tsid;
201     osal_u8                            up;
202     mac_wmmac_direction_enum_uint8       direction;
203     mac_ts_conn_status_enum_uint8        ts_status;
204     osal_u8                            ts_dialog_token;
205     osal_u8                            vap_id;
206     osal_u16                           mac_user_idx;
207 #if defined(_PRE_PRODUCT_ID_HOST)
208     /* 每个ts下都需要建立定时器,此处不放到hmac_user_stru */
209     frw_timeout_stru                     addts_timer;
210     osal_u8                            second_flag;
211     osal_u8                            rsv[3];
212 #endif
213 } mac_ts_stru;
214 #endif
215 
216 /*
217  * 802.1X-port 状态结构体
218  * 1X端口状态说明:
219  * 1) portvalid && keydone 都是 TRUE: 表示端口处于合法状态
220  * 2) portvalid == TRUE && keydone == FALSE:表示端口处于未知状态密钥还未生效
221  * 3) portValid == FALSE && keydone== TRUE:表示端口处于非法状态密钥获取失败
222  * 4) portValid && keyDone are FALSE: 表示端口处于合法状态密钥还未生效
223  */
224 typedef struct {
225     oal_bool_enum_uint8             keydone;                      /* 端口合法性是否允许测试 */
226     oal_bool_enum_uint8             portvalid;                    /* 端口合法性标识 */
227     osal_u8                         resv0[2];
228 } mac_8021x_port_status_stru;
229 
230 
231 /* 供AP查看STA是否被统计到对应项 */
232 typedef struct {
233     osal_u8 no_short_slot_stats_flag     : 1; /* user是否被统计到no short slot num中, 0未被统计, 1已被统计 */
234     osal_u8 no_short_preamble_stats_flag : 1; /* user是否被统计到no short preamble num中 */
235     osal_u8 no_erp_stats_flag            : 1; /* user是否被统计到no erp num中 */
236     osal_u8 no_ht_stats_flag             : 1; /* user是否被统计到no ht num中 */
237     osal_u8 no_gf_stats_flag             : 1; /* user是否被统计到no gf num中 */
238     osal_u8 only_stats_20m_flag          : 1; /* user是否被统计到no 20M only num中 */
239     osal_u8 no_40dsss_stats_flag         : 1; /* user是否被统计到no 40dsss num中 */
240     osal_u8 no_lsig_txop_stats_flag      : 1; /* user是否被统计到no lsig txop num中 */
241     osal_u8 resv0[3];
242 } mac_user_stats_flag_stru;
243 
244 /* AP侧keepalive活动的控制结构体 */
245 typedef struct {
246     osal_u8  keepalive_count_ap;        /* AP定时保活检测操作计数器 */
247     osal_u8  timer_to_keepalive_count;  /* 复用aging timer/STA省电模式定时清醒策略,定时发送keepalive帧的计数器 */
248     osal_u8  delay_flag;                /* 标志用户进入睡眠状态或者其他不能马上收帧反馈的状态 */
249     osal_u8  auc_resv[1];
250 } mac_user_keepalive;
251 
252 /* 空间流信息结构体 */
253 typedef struct {
254     osal_u16            user_idx;
255     wlan_nss_enum_uint8   avail_num_spatial_stream;            /* Tx和Rx支持Nss的交集,供算法调用 */
256     wlan_nss_enum_uint8   user_num_spatial_stream;             /* 用户支持的空间流个数 */
257 } mac_user_nss_stru;
258 
259 /* m2s user信息结构体 */
260 typedef struct {
261     osal_u16              user_idx;
262     wlan_nss_enum_uint8     user_num_spatial_stream;             /* 用户自身空间流能力 */
263     wlan_nss_enum_uint8     avail_num_spatial_stream;            /* Tx和Rx支持Nss的交集,供算法调用 */
264 
265     wlan_nss_enum_uint8     avail_bf_num_spatial_stream;         /* 用户支持的Beamforming空间流个数 */
266     wlan_bw_cap_enum_uint8  avail_bandwidth;                     /* 用户和VAP带宽能力交集,供算法调用 */
267     wlan_bw_cap_enum_uint8  cur_bandwidth;                       /* 默认值与avail_bandwidth相同,供算法调用修改 */
268     wlan_mib_mimo_power_save_enum_uint8 cur_smps_mode;
269 } mac_user_m2s_stru;
270 
271 /* ------- hmac_user_rom.h START ---------- */
272 typedef struct {
273     osal_spinlock lock_ps;                   /* 对队列和ul_mpdu_num操作时需要加锁 */
274     oal_netbuf_head_stru ps_queue_head;           /* 用户节能缓存队列头 */
275     osal_atomic mpdu_num;                          /* 用户节能缓存队列中已存在的mpdu个数 */
276     osal_u8 ps_time_count;
277     osal_u8 auc_resv[3];                            /* 保留2个字节用作对齐 */
278 } hmac_user_ps_stru;
279 
280 /* ------- hmac_user_rom.h END ---------- */
281 
282 /* ------- hmac_ext_if_hcm.h START ---------- */
283 typedef struct {
284     osal_u32 cur_rate_goodput_kbps;
285     osal_u32 rate_kbps;       /* 速率大小(单位:kbps) */
286     osal_u8 aggr_subfrm_size; /* 聚合子帧数门限值 */
287     osal_u8 per;              /* 该速率的PER(单位:%) */
288 #ifdef _PRE_WLAN_DFT_STAT
289     osal_u8 best_rate_per; /* 最优速率的PER(单位:%) */
290     osal_u8 resv[1];
291 #else
292     osal_u8 resv[2];       /* 预留2字节对齐 */
293 #endif
294 } hmac_tx_normal_rate_stats_stru;
295 
296 typedef struct {
297     osal_u16 baw_start;                              /* 第一个未确认的MPDU的序列号 */
298     osal_u16 last_seq_num;                           /* 最后一个发送的MPDU的序列号 */
299     osal_u16 baw_size;                               /* Block_Ack会话的buffer size大小 */
300     osal_u16 baw_head;                               /* bitmap中记录的第一个未确认的包的位置 */
301     osal_u16 baw_tail;                               /* bitmap中下一个未使用的位置 */
302     oal_bool_enum_uint8 is_ba;                     /* Session Valid Flag */
303     hmac_ba_conn_status_enum_uint8 ba_conn_status; /* BA会话的状态 */
304     mac_back_variant_enum_uint8 back_var;          /* BA会话的变体 */
305     osal_u8 dialog_token;                            /* ADDBA交互帧的dialog token */
306     osal_u8 ba_policy;                               /* Immediate=1 Delayed=0 */
307     oal_bool_enum_uint8 amsdu_supp;                /* BLOCK ACK支持AMSDU的标识 */
308     osal_u8 *dst_addr;                              /* BA会话接收端地址 */
309     osal_u16 ba_timeout;                             /* BA会话交互超时时间 */
310     osal_u8 ampdu_max_num;                           /* BA会话下,能够聚合的最大的mpdu的个数 */
311     osal_u8 tx_ba_lut;                               /* BA会话LUT session index */
312     osal_u16 mac_user_idx;
313     osal_u16 pre_baw_start;    /* 记录前一次判断ba窗是否卡死时的ssn */
314     osal_u16 pre_last_seq_num; /* 记录前一次判断ba窗是否卡死时的lsn */
315     osal_u16 ba_jamed_cnt;     /* BA窗卡死统计次数 */
316     osal_u32 tx_buf_bitmap[HMAC_TX_BUF_BITMAP_WORDS];
317 } hmac_ba_tx_hdl_stru;
318 
319 /* 一个站点下的每一个TID下的聚合接收的状态信息 */
320 typedef struct {
321     hmac_ba_conn_status_enum_uint8 ba_conn_status; /* BA会话的状态 */
322     osal_u8 lut_index;                               /* 接收端Session H/w LUT Index */
323     mac_ba_policy_enum_uint8 ba_policy;            /* Immediate=1 Delayed=0 */
324     osal_u8 resv;
325 } hmac_ba_rx_hdl_stru;
326 /* ------- hmac_ext_if_hcm.h END ---------- */
327 
328 /* ================= FEATURE Start 特性相关 =========================== */
329 
330 /* ================= FEATURE End   特性相关 =========================== */
331 
332 /*****************************************************************************
333     结构体定义
334 *****************************************************************************/
335 #ifdef _PRE_WLAN_FEATURE_TX_CLASSIFY_LAN_TO_WLAN
336 /* 业务识别-五元组结构体: 用于唯一地标识业务流 */
337 typedef struct {
338     osal_u32                          sip;                         /* ip */
339     osal_u32                          dip;
340 
341     osal_u16                          sport;                       /* 端口 */
342     osal_u16                          dport;
343 
344     osal_u32                          proto;                       /* 协议 */
345 } hmac_tx_flow_info_stru;
346 
347 /* 业务识别-待识别队列结构体: */
348 typedef struct {
349     hmac_tx_flow_info_stru            flow_info;
350 
351     osal_u32                          len;                        /* 来包长度 */
352     osal_u8                           flag;                       /* 有效位,用于计数 */
353 
354     osal_u8                           udp_flag;                   /* udp flag为1即为UDP帧 */
355     osal_u8                           tcp_flag;                   /* tcp flag为1即为TCP帧 */
356 
357     osal_u8                           rtpver;                     /* RTP version */
358     osal_u32                          rtpssrc;                    /* RTP SSRC */
359     osal_u32                          payload_type;               /* RTP:标记1bit、有效载荷类型(PT)7bit */
360 } hmac_tx_judge_info_stru;
361 
362 /* 业务识别-待识别队列主要业务结构体: */
363 typedef struct {
364     hmac_tx_flow_info_stru            flow_info;
365 
366     osal_u32                          average_len;                /* 业务来包平均长度 */
367     osal_u8                           flag;                       /* 有效位 */
368 
369     osal_u8                           udp_flag;                   /* udp flag为1即为UDP帧 */
370     osal_u8                           tcp_flag;                   /* tcp flag为1即为TCP帧 */
371 
372     osal_u8                           rtpver;                     /* RTP version */
373     osal_u32                          rtpssrc;                    /* RTP SSRC */
374     osal_u32                          payload_type;               /* 标记1bit、有效载荷类型(PT)7bit */
375 
376     osal_u32                          wait_check_num;             /* 待检测列表中此业务包个数 */
377 } hmac_tx_major_flow_stru;
378 
379 /* 业务识别-用户已识别结构体: */
380 typedef struct {
381     hmac_tx_flow_info_stru            cfm_flow_info;               /* 已识别业务的五元组信息 */
382 
383     osal_ulong                         last_jiffies;                /* 记录已识别业务的最新来包时间 */
384     osal_u16                          cfm_tid;                     /* 已识别业务tid */
385 
386     osal_u16                          cfm_flag;                    /* 有效位 */
387 } hmac_tx_cfm_flow_stru;
388 
389 /* 业务识别-用户待识别业务队列: */
390 typedef struct {
391     osal_ulong                         jiffies_st;      /* 记录待识别业务队列的起始时间与最新来包时间 */
392     osal_ulong                         jiffies_end;
393     osal_u32                          to_judge_num;    /* 用户待识别业务队列长度 */
394 
395     hmac_tx_judge_info_stru           judge_cache[MAX_JUDGE_CACHE_LENGTH];    /* 待识别流队列 */
396 } hmac_tx_judge_list_stru;
397 #endif
398 
399 typedef struct {
400     oal_bool_enum_uint8             in_use;             /* 缓存BUF是否被使用 */
401     osal_u8                         num_buf;         /* 占用的netbuf个数与head中的qlen作用一致 */
402     osal_u16                        seq_num;         /* MPDU对应的序列号 */
403     oal_netbuf_head_stru            netbuf_head;     /* MPDU对应的描述符首地址 */
404     osal_u32                        rx_time;         /* 报文被缓存的时间戳 */
405 } hmac_rx_buf_stru;
406 
407 typedef struct {
408     osal_void                       *ba;
409     osal_u8                         tid;
410     mac_delba_initiator_enum_uint8  direction;
411     osal_u8                         resv[1];
412     osal_u8                         vap_id;
413     osal_u16                        mac_user_idx;
414     osal_u16                        timeout_times;
415 } hmac_ba_alarm_stru;
416 
417 /* TID对应的发送BA会话的状态 */
418 typedef struct {
419     frw_timeout_stru                addba_timer;
420     hmac_ba_alarm_stru              alarm_data;
421 
422     hmac_ba_conn_status_enum_uint8  ba_status;       /* 该TID对应的BA会话的状态 */
423     osal_u8                       addba_attemps;   /* 启动建立BA会话的次数 */
424     osal_u8                       dialog_token;    /* 随机标记数 */
425     oal_bool_enum_uint8           ba_policy;       /* Immediate=1 Delayed=0 */
426     osal_spinlock                 ba_status_lock;  /* 该TID对应的BA会话的状态锁 */
427 } hmac_ba_tx_stru;
428 
429 typedef struct {
430     osal_u32    short_preamble      : 1,        /* 是否支持802.11b短前导码 0=不支持, 1=支持 */
431                 erp                 : 1,        /* AP保存STA能力使用,指示user是否有ERP能力, 0=不支持,1=支持 */
432                 short_slot_time     : 1,        /* 短时隙: 0=不支持, 1=支持 */
433                 support_11ac2g              : 1,
434                 owe : 1,
435                 bit_resv                : 27;
436 } hmac_user_cap_info_stru;
437 
438 typedef struct {
439     osal_u8     rs_nrates;                                 /* 个数 */
440     osal_u8     rs_rates[WLAN_USER_MAX_SUPP_RATES];       /* 速率 */
441 } hmac_rate_stru;
442 
443 /* Hmac侧接收侧BA会话句柄 */
444 typedef struct {
445     osal_spinlock                 ba_lock;                 /* 02用于hcc线程和事件线程并发 */
446     osal_u16                      baw_start;               /* 第一个未收到的MPDU的序列号 */
447     osal_u16                      baw_end;                 /* 最后一个可以接收的MPDU的序列号 */
448     osal_u16                      baw_tail;                /* 目前Re-Order队列中,最大的序列号 */
449     osal_u16                      baw_size : 10;           /* Block_Ack会话的buffer size大小 */
450     osal_u16                      timer_triggered : 1;     /* 上一次上报是否为定时器上报 */
451     osal_u16                      is_ba : 1;               /* Session Valid Flag */
452     osal_u16                      ba_status : 4;           /* 该TID对应的BA会话的状态 */
453 
454     /* 以下action帧相关 */
455     osal_u8                       dialog_token;     /* ADDBA交互帧的dialog token */
456     osal_u8                       back_var : 6;     /* BA会话的变体 */
457     osal_u8                       ba_policy : 1;    /* Immediate=1 Delayed=0 */
458     osal_u8                       amsdu_supp : 1;   /* BLOCK ACK支持AMSDU的标识 */
459     osal_u16                      status_code;      /* 返回状态码 */
460     osal_u8                      *transmit_addr;    /* BA会话发送端地址 */
461     osal_u32                      rx_buf_bitmap[2];
462     osal_u16                      ba_timeout;       /* BA会话交互超时时间 */
463     osal_u16                      baw_head;         /* bitmap的起始序列号 */
464     osal_u8                       ba_resp_buf_size; /* ADDBA Response帧回复的buffer size大小 */
465     osal_u8                       lut_index;        /* 接收端Session H/w LUT Index */
466 
467     osal_u8                       resv;
468     osal_u8                       mpdu_cnt;         /* 当前Re-Order队列中,MPDU的数目 */
469     hmac_rx_buf_stru              re_order_list[WLAN_AMPDU_RX_BUFFER_SIZE];  /* Re-Order队列 */
470     hmac_ba_alarm_stru            alarm_data;
471 } hmac_ba_rx_stru;
472 
473 /* user结构中,TID对应的BA信息的保存结构 */
474 typedef struct {
475     osal_u8 tid          : 4; /* 通信标识符 */
476     osal_u8 is_paused    : 2; /* TID被暂停调度 */
477     osal_u8 tx_mode      : 2; /* 发送模式: rifs,aggr,normal发送 */
478 
479     osal_u8 is_delba_ing : 1; /* 该tid是否正在发delba */
480     osal_u8 vap_id       : 7;
481 
482     osal_u8 rx_wrong_ampdu_num; /* 该tid未建立BA会话时收到的聚合子帧数(一般是DELBA失败) */
483     oal_bool_enum_uint8 ba_handle_tx_enable : 1;     /* 该tid下发送方向是否允许建BA,配置命令需求 */
484     oal_bool_enum_uint8 ba_handle_rx_enable : 1;     /* 该tid下接送方向是否允许建BA,配置命令需求 */
485     osal_u8 resv : 6;
486 
487     osal_u16 mpdu_num; /* MPDU个数 */
488     osal_u16 user_idx; /* 无效值为MAC_RES_MAC_USER_NUM */
489     osal_u32 in_num;   /* 进入队列的包的个数 */
490     osal_u32 out_num;  /* 出队列的包的个数 */
491     osal_u32 dispatch_num;  /* 发生tid队列调度的次数 */
492     osal_u32 tid_buffer_frame_len; /* 各tid缓存帧长 */
493     struct osal_list_head retry_q;
494     oal_netbuf_head_stru buff_head; /* 发送缓存队列链表 */
495     osal_void *alg_priv;                             /* TID级别算法私有结构体 */
496     hmac_ba_rx_hdl_stru ba_rx_hdl; /* dmac rx ba info */
497     hmac_ba_tx_stru ba_tx_info;
498     hmac_ba_rx_stru *ba_rx_info;             /* 由于部分处理上移,这部分内存到LocalMem中申请 */
499     frw_timeout_stru ba_timer;                /* 接收重排序缓冲超时 */
500 } hmac_tid_stru;
501 
502 typedef struct {
503     oal_netbuf_head_stru        msdu_head;         /* msdu链表头 */
504     frw_timeout_stru            amsdu_timer;
505     osal_spinlock               amsdu_lock;        /* amsdu task lock */
506 
507     osal_u16                    amsdu_size;        /* Present size of the AMSDU */
508 
509     osal_u8                     amsdu_maxnum : 4;
510     osal_u8                     msdu_num : 4;          /* Number of sub-MSDUs accumulated */
511     osal_u8                     last_pad_len;      // 51合入后可删除/* 最后一个msdu的pad长度 */
512 } hmac_amsdu_stru;
513 
514 typedef struct {
515     osal_u32 drv_rx_pkts;     /* 接收数据(硬件上报,包含rx描述符不成功的帧)数目,仅仅统计数据帧 */
516     osal_u32 drv_rx_bytes;    /* 驱动接收字节数,不包括80211头尾 */
517     osal_u32 rx_dropped_misc; /* 接收失败(决定丢弃的帧)次数 */
518 } hmac_user_query_stats_stru;
519 /* 特性结构体END,第二阶段需要挪走 */
520 
521 /* 判断重传auth帧 */
522 #define HMAC_RETRY_AUTH_PROTECT_DURATION 100                       /* auth重复帧保护时间100ms */
523 typedef struct {
524     oal_bool_enum_uint8           is_rx_auth;                    /* 是否收到过auth帧 */
525     osal_u8                       resv;                          /* 增加1字节rsv字段,保持4字节对齐 */
526     osal_u16                      rx_auth_seqnum;                /* 上一次收到auth帧的sequence num */
527     osal_u32                      rx_auth_timestamp;             /* 上一次接收auth帧的时间 */
528 } hmac_auth_re_rx_protect_stru;
529 /* 声明该结构体变量后请一定要调用 memset_s 0 */
530 typedef struct {
531     /* -->> Public Start */
532     osal_u8 device_id; /* 设备ID */
533     osal_u8 chip_id; /* 芯片ID */
534     osal_u8 resv0[2];
535     osal_atomic use_cnt; /* 用于user引用计数使用,该值在自增自减时需要使用原子操作 */
536 
537     /* 当前VAP工作在AP或STA模式,以下字段为user是STA或AP时公共字段,新添加字段请注意!!! */
538     struct osal_list_head user_dlist; /* 用于用户遍历 */
539 
540     osal_u8 user_mac_addr[WLAN_MAC_ADDR_LEN]; /* user对应的MAC地址 */
541 
542     /* user对应资源池索引值; user为STA时,表示填在管理帧中的AID,值为用户的资源池索引值1~32(协议规定范围为1~2007) */
543     osal_u16 assoc_id;
544     osal_u8 vap_id; /* vap ID */
545 
546     osal_u8 protocol_mode       : 4; /* 用户工作协议 */
547     osal_u8 avail_protocol_mode : 4; /* 用户和VAP协议模式交集, 供算法调用 */
548 
549     osal_u8 cur_protocol_mode        : 4; /* 默认值与en_avail_protocol_mode值相同, 供算法调用修改 */
550     osal_u8 is_multi_user            : 1;
551     osal_u8 avail_num_spatial_stream : 3; /* Tx和Rx支持Nss的交集,供算法调用 */
552 
553     osal_u8 user_num_spatial_stream     : 3; /* 用户支持的空间流个数 */
554     osal_u8 avail_bf_num_spatial_stream : 3; /* 用户支持的Beamforming空间流个数 */
555     osal_u8 port_valid                  : 1; /* 802.1X端口合法性标识 */
556     osal_u8 is_user_alloced             : 1; /* 标志此user资源是否已经被申请 */
557 
558     osal_u8 resv1[2];
559 
560     mac_rate_stru avail_op_rates; /* 用户和VAP可用的11a/b/g速率交集,供算法调用 */
561     mac_user_tx_param_stru user_tx_info; /* TX相关参数 */
562 
563     osal_u8 bandwidth_cap   : 4; /* 用户带宽能力信息 */
564     osal_u8 avail_bandwidth : 4; /* 用户和VAP带宽能力交集,供算法调用 */
565 
566     osal_u8 cur_bandwidth         : 4; /* 默认值与avail_bandwidth相同,供算法调用修改 */
567     osal_u8 qos_enhance_sta_state : 4; /* 判断是否是远端设备 */
568 
569     mac_user_asoc_state_enum_uint8 user_asoc_state; /* 用户关联状态 */
570     oal_bool_enum_uint8 flag_change_user_state_to_auth_complete : 1; /* 已关联状态收到auth帧,将标志置为1 */
571     osal_u8 is_wds : 1; /* 是否是wds用户 */
572     osal_u8 bit_resv : 6;
573     osal_u8 pub_resv0;
574 
575     mac_user_cap_info_stru cap_info; /* user基本能力信息位 */
576     mac_user_ht_hdl_stru ht_hdl; /* HT capability IE和 operation IE的解析信息 */
577     mac_vht_hdl_stru vht_hdl; /* VHT capability IE和 operation IE的解析信息 */
578 
579     mac_key_mgmt_stru key_info;
580 
581     /* --------- Public STA成员 Start ----------------- */
582     /* --------- Public STA成员 End ------------------- */
583 
584     /* --------- Public AP成员 Start ----------------- */
585     /* --------- Public AP成员 End ------------------- */
586 
587     /* -->> Public End */
588 
589     /* -->> Private Start */
590     /* 当前VAP工作在AP或STA模式,以下字段为user是STA或AP时公共字段,新添加字段请注意!!! */
591     osal_u8 amsdu_supported; /* 每个位代表某个TID是否支持AMSDU */
592     osal_u8 resv2;
593     osal_u16 amsdu_maxsize; /* amsdu最大长度 */
594 
595     hmac_amsdu_stru hmac_amsdu[WLAN_TID_MAX_NUM]; /* asmdu数组 */
596 
597     osal_u32 last_timestamp[WLAN_TID_MAX_NUM]; /* 时间戳用于实现5个连续报文建立BA */
598     osal_u8 *ch_text; /* WEP用的挑战明文 */
599 
600     frw_timeout_stru mgmt_timer; /* 认证关联用定时器 */
601     /* 该标志表示该TID是否可以建立BA会话,大于等于5时可以建立BA会话。该标志在用户初始化、删除BA会话时清零 */
602     osal_u8 ba_flag[WLAN_TID_MAX_NUM];
603     /* user可选速率,记录对端assoc req或者assoc rsp帧中supported rates和assoc rsp宣称的速率 */
604     hmac_rate_stru op_rates;
605     hmac_user_cap_info_stru hmac_cap_info; /* hmac侧用户能力标志位 */
606     osal_u32 rssi_last_timestamp; /* 获取user rssi所用时间戳, 1s最多更新一次rssi */
607 
608     osal_u32 rx_pkt_drop; /* 接收数据包host侧被drop的计数 */
609 
610     osal_u32 first_add_time; /* 用户创建时的时间,用于统计用户在线时长 */
611 
612     /* dmac配置同步信息 */
613     mac_user_type_enum_uint8 user_type;
614     osal_u32 tx_rate;
615     osal_u32 rx_rate;
616 
617     /* --------- Private STA成员 Start ----------------- */
618     /* 当前VAP工作在STA模式,以下字段为user是AP时独有字段,新添加字段请注意!!! */
619     mac_user_stats_flag_stru user_stats_flag; /* 当user是sta时候,指示user是否被统计到对应项 */
620     /* --------- Private STA成员 End ------------------- */
621 
622     /* --------- Private AP成员 Start ----------------- */
623     /* 当前VAP工作在AP模式,以下字段为user是STA时独有字段,新添加字段请注意!!! */
624     osal_u32 assoc_req_ie_len;
625     osal_u8 *assoc_req_ie_buff;
626     oal_bool_enum_uint8 user_vendor_vht_capable;
627     oal_bool_enum_uint8 user_vendor_novht_capable;
628     osal_u8 resv3;
629     /* --------- Private AP成员 End ------------------- */
630 
631     /* -->> Private End */
632 
633     /* -->> Features Start */
634 #ifdef _PRE_WLAN_FEATURE_PMF
635     mac_sa_query_stru sa_query_info; /* sa query流程的控制信息 */
636 #endif
637 #ifdef _PRE_WLAN_FEATURE_TX_CLASSIFY_LAN_TO_WLAN
638     osal_u8 cfm_num; /* 用户已被识别业务个数 */
639     osal_u8 resv5[3];
640     hmac_tx_cfm_flow_stru cfm_flow_list[MAX_CONFIRMED_FLOW_NUM]; /* 已识别业务 */
641     hmac_tx_judge_list_stru judge_list; /* 待识别流队列 */
642 #endif
643 
644 #ifdef _PRE_WLAN_FEATURE_WUR_TX
645     hmac_user_wur_info_stru wur_info; /* wur用户的信息 */
646     mac_user_wur_cap_ie_stru wur_cap_ie; /* 用户WUR的能力字段信息 */
647 #endif
648 #ifdef _PRE_WLAN_FEATURE_WMMAC
649     mac_ts_stru ts_info[WLAN_WME_AC_BUTT]; /* 保存ts相关信息 */
650 #endif
651 #ifdef _PRE_WLAN_FEATURE_11AX
652     mac_he_hdl_stru he_hdl; /* HE Capability IE */
653 #endif
654     /* -->> Features End */
655 
656     /* -->> Private Start */
657     /* 添加信息上报字段 */
658     hmac_user_query_stats_stru query_stats;
659 
660     osal_u8 groupid;
661     osal_u8 lut_index; /* user对应的硬件索引,活跃用户id */
662     osal_u8 resv7[2]; /* 对齐预留2字节 */
663 
664     osal_u64 last_active_timestamp; /* user最后活跃时刻时间戳,user老化和活跃用户替换使用(使用OSAL提供的时间戳函数赋值) */
665 
666     /* 当前VAP工作在AP或STA模式,以下字段为user是STA或AP时公共字段,新添加字段请注意!!! */
667     /* 发送tid缓存队列 */
668     hmac_tid_stru tx_tid_queue[WLAN_TID_MAX_NUM];
669     osal_void *alg_priv; /* 用户级别算法私有结构体 */
670     osal_u16 partial_aid;
671     osal_s16 rx_rssi; /* 用户接收RSSI统计量 */
672 
673     /* --------- Private STA成员 Start ------------------ */
674 
675     /* --------- Private STA成员 End ------------------ */
676 
677     /* --------- Private AP成员 Start ------------------ */
678     /* 当前VAP工作在AP模式,以下字段为user是STA时独有字段,新添加字段请注意!!! */
679     osal_u8 ps_mode      : 1; /* ap保留的用户节能模式,PSM用 */
680     osal_u8 active_user  : 1; /* 是否活跃用户,用户管理用 */
681     osal_u8 new_add_user : 1; /* 1: 是否是新创建用户(不执行通知算法),0为其他状态需要执行算法通知,例如替换状态 */
682     osal_u8 resv8        : 4;
683 
684     osal_u8 vip_flag              : 1; /* 只算法调度用,通过配置命令配置,TRUE: VIP用户, FALSE: 非VIP用户 */
685     osal_u8 delete_ba_flag        : 1; /* 删除ba标志,只算法通过接口修改,autorate降协议模式时置为true */
686     osal_u8 ptk_need_install      : 1; /* 需要更新单播秘钥 */
687     osal_u8 is_rx_eapol_key_open  : 1; /* 记录接收的eapol-key 是否为加密 */
688     osal_u8 eapol_key_4_4_tx_succ : 1; /* eapol-key 4/4 发送成功 */
689     osal_u8 ptk_key_idx           : 3; /* 保存单播秘钥key_idx */
690 
691     osal_u8 last_frame_pn;
692 
693     /* 用户的节能结构,单播用户与组播用户都会用 */
694     hmac_user_ps_stru ps_structure;
695     /* --------- Private AP成员 End ------------------ */
696 
697     /* -->> Private End */
698 
699     /* -->> HAL Start */
700 #ifdef _PRE_WLAN_FIT_BASED_REALTIME_CALI
701     hal_dyn_cali_usr_record_stru dyn_cali_pow[WLAN_RF_CHANNEL_NUMS];
702 #endif
703     /* 用户级别功率信息结构体 */
704     /* -->> HAL End */
705 
706     /* -->> Features Start */
707     osal_u8 resv10[3];
708     osal_u8 mgmt_frm_type;
709 
710     /* -->> Features End */
711 
712     /* -->> Features Array Start */
713     osal_void **hmac_user_feature_arr;
714     /* -->> Features Array Start */
715     hmac_auth_re_rx_protect_stru    auth_re_rx_protect;       /* 用于重传帧过滤 */
716 #ifdef _PRE_WLAN_FEATURE_WPA3
717     osal_u32 owe_ie_len;
718     osal_u8 *owe_ie;
719     osal_u16 auth_alg;
720     osal_u8 resv11[2];
721 #endif
722     osal_u8 _rom[4];
723 } hmac_user_stru;
724 
725 /* ****************************************************************************
726   9 OTHERS定义
727 **************************************************************************** */
728 /*****************************************************************************
729     函数声明
730 *****************************************************************************/
731 osal_u32 hmac_user_add_wep_key_etc(hmac_user_stru *hmac_user, osal_u8 key_index, mac_key_params_stru *key);
732 osal_u32 hmac_user_add_rsn_key_etc(hmac_user_stru *hmac_user, osal_u8 key_index, mac_key_params_stru *key);
733 osal_u32 hmac_user_add_bip_key_etc(hmac_user_stru *hmac_user, osal_u8 key_index, mac_key_params_stru *key);
734 
735 wlan_priv_key_param_stru *hmac_user_get_key_etc(hmac_user_stru *hmac_user, osal_u8 key_id);
736 
737 osal_void hmac_user_set_port_etc(hmac_user_stru *hmac_user, oal_bool_enum_uint8 port_valid);
738 
739 void hmac_user_avail_bf_num_spatial_stream_etc(hmac_user_stru *hmac_user, osal_u8 value);
740 void hmac_user_set_avail_num_spatial_stream_etc(hmac_user_stru *hmac_user, osal_u8 value);
741 void hmac_user_set_num_spatial_stream_etc(hmac_user_stru *hmac_user, osal_u8 value);
742 void hmac_user_set_bandwidth_cap_etc(hmac_user_stru *hmac_user, wlan_bw_cap_enum_uint8 bandwidth_value);
743 void hmac_user_set_bandwidth_info_etc(hmac_user_stru *hmac_user, wlan_bw_cap_enum_uint8 avail_bandwidth,
744     wlan_bw_cap_enum_uint8 cur_bandwidth);
745 void  hmac_user_get_sta_cap_bandwidth_etc(hmac_user_stru *hmac_user, wlan_bw_cap_enum_uint8 *bandwidth_cap);
746 osal_u32  mac_user_update_bandwidth(hmac_user_stru *hmac_user, wlan_bw_cap_enum_uint8 bwcap);
747 osal_u32  hmac_user_update_ap_bandwidth_cap(hmac_user_stru *hmac_user);
748 void hmac_user_set_avail_protocol_mode_etc(hmac_user_stru *hmac_user, wlan_protocol_enum_uint8 avail_protocol_mode);
749 void hmac_user_set_cur_protocol_mode_etc(hmac_user_stru *hmac_user, wlan_protocol_enum_uint8 cur_protocol_mode);
750 void hmac_user_set_cur_bandwidth_etc(hmac_user_stru *hmac_user, wlan_bw_cap_enum_uint8  cur_bandwidth);
751 void hmac_user_set_protocol_mode_etc(hmac_user_stru *hmac_user, wlan_protocol_enum_uint8 protocol_mode);
752 void hmac_user_set_asoc_state(hmac_user_stru *hmac_user, mac_user_asoc_state_enum_uint8 value);
753 void hmac_user_set_avail_op_rates_etc(hmac_user_stru *hmac_user, osal_u8 rs_nrates, osal_u8 *rs_rates);
754 void hmac_user_set_vht_hdl_etc(hmac_user_stru *hmac_user, mac_vht_hdl_stru *vht_hdl);
755 void hmac_user_get_vht_hdl_etc(hmac_user_stru *hmac_user, mac_vht_hdl_stru *vht_hdl);
756 
757 #ifdef _PRE_WLAN_FEATURE_11AX
758 void mac_user_set_he_hdl(hmac_user_stru *hmac_user, mac_he_hdl_stru *he_hdl);
759 void mac_user_get_he_hdl(hmac_user_stru *hmac_user, mac_he_hdl_stru *he_hdl);
760 #endif
761 
762 void hmac_user_set_ht_hdl_etc(hmac_user_stru *hmac_user, mac_user_ht_hdl_stru *ht_hdl);
763 void hmac_user_get_ht_hdl_etc(hmac_user_stru *hmac_user, mac_user_ht_hdl_stru *ht_hdl);
764 void hmac_user_set_ht_capable_etc(hmac_user_stru *hmac_user, oal_bool_enum_uint8 ht_capable);
765 #ifdef _PRE_WLAN_FEATURE_SMPS
766 void hmac_user_set_sm_power_save(hmac_user_stru *hmac_user, osal_u8 sm_power_save);
767 #endif
768 void hmac_user_set_pmf_active_etc(hmac_user_stru *hmac_user, oal_bool_enum_uint8 pmf_active);
769 void hmac_user_set_qos_etc(hmac_user_stru *hmac_user, oal_bool_enum_uint8 qos_mode);
770 void hmac_user_set_spectrum_mgmt_etc(hmac_user_stru *hmac_user, oal_bool_enum_uint8 spectrum_mgmt);
771 void hmac_user_set_apsd_etc(hmac_user_stru *hmac_user, oal_bool_enum_uint8 apsd);
772 
773 osal_void hmac_user_init_key_etc(hmac_user_stru *hmac_user);
774 
775 osal_void hmac_user_set_key_etc(hmac_user_stru *multiuser, wlan_cipher_key_type_enum_uint8 keytype,
776     wlan_ciper_protocol_type_enum_uint8 ciphertype, osal_u8 keyid);
777 
778 osal_u32 hmac_user_update_wep_key_etc(hmac_user_stru *hmac_user, osal_u16 multi_user_idx);
779 oal_bool_enum_uint8 hmac_addr_is_zero_etc(osal_u8 *mac);
780 oal_bool_enum_uint8 hmac_ip_is_zero_etc(osal_u8 *ip_addr);
781 osal_s32 hmac_user_sync(hmac_user_stru *hmac_user);
782 
783 /*****************************************************************************
784   10 函数声明
785 *****************************************************************************/
786 osal_u32 mac_user_update_bandwidth(hmac_user_stru *hmac_user, wlan_bw_cap_enum_uint8 bwcap);
787 osal_void hmac_user_set_assoc_id_etc(hmac_user_stru *hmac_user, osal_u16 assoc_id);
788 
789 osal_void hmac_user_set_barker_preamble_mode_etc(hmac_user_stru *hmac_user, oal_bool_enum_uint8 barker_preamble_mode);
790 
791 osal_void *mac_res_get_mac_user_etc(osal_u16 idx);
792 
793 #ifdef __cplusplus
794 #if __cplusplus
795         }
796 #endif
797 #endif
798 
799 #endif
800