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 * 文 件 名 : hmac_user.h
15 * 生成日期 : 2012年10月19日
16 * 功能描述 : hmac_user.c 的头文件
17 */
18
19
20 #ifndef __HMAC_USER_H__
21 #define __HMAC_USER_H__
22
23 /*****************************************************************************
24 1 其他头文件包含
25 *****************************************************************************/
26 #include "hmac_ext_if.h"
27 #include "mac_resource_ext.h"
28 #include "hmac_tid.h"
29 #include "frw_hmac.h"
30 #include "msg_user_manage_rom.h"
31
32 #ifdef __cplusplus
33 #if __cplusplus
34 extern "C" {
35 #endif
36 #endif
37
38 #undef THIS_FILE_ID
39 #define THIS_FILE_ID OAM_FILE_ID_HMAC_USER_H
40
41 /*****************************************************************************
42 2 宏定义
43 *****************************************************************************/
44 #define HMAC_ADDBA_EXCHANGE_ATTEMPTS 10 /* 试图建立ADDBA会话的最大允许次数 */
45
46 #define hmac_user_is_amsdu_support(_user, _tid) (((_user)->amsdu_supported) & (0x01 << ((_tid) & 0x07)))
47
48 #define hmac_user_set_amsdu_support(_user, _tid) (((_user)->amsdu_supported) |= (0x01 << ((_tid) & 0x07)))
49
50 #define hmac_user_set_amsdu_not_support(_user, _tid) \
51 (((_user)->amsdu_supported) &= (osal_u8)(~(0x01 << ((_tid) & 0x07))))
52
53 #define hmac_user_stats_pkt_incr(_member, _cnt) ((_member) += (_cnt))
54
55 /*****************************************************************************
56 3 枚举定义
57 *****************************************************************************/
58
59 /*****************************************************************************
60 4 全局变量声明
61 *****************************************************************************/
62
63
64 /*****************************************************************************
65 5 消息头定义
66 *****************************************************************************/
67
68
69 /*****************************************************************************
70 6 消息定义
71 *****************************************************************************/
72
73
74 /*****************************************************************************
75 7 STRUCT定义
76 *****************************************************************************/
77
78 /* SA Query 超时定时器 和 间隔定时器 的超时函数入参结构 */
79 typedef struct {
80 hmac_vap_stru *hmac_vap; /* 发送SA Query request的mac vap信息 */
81 hmac_user_stru *hmac_user; /* 目标user */
82 } hmac_maxtimeout_timer_stru;
83 typedef struct {
84 hmac_vap_stru *hmac_vap; /* 发送SA Query request的mac vap信息 */
85 hmac_user_stru *hmac_user; /* 目标user */
86 oal_bool_enum_uint8 is_protected; /* SA Query管理帧加密的使能开关 */
87 osal_u16 trans_id; /* SA Query request帧的trans id */
88 } hmac_interval_timer_stru;
89
90 /* 存储AP关联请求帧的ie信息,用于上报内核 */
91 typedef struct {
92 osal_u32 assoc_req_ie_len;
93 osal_u8 *assoc_req_ie_buff;
94 osal_u8 user_mac_addr[WLAN_MAC_ADDR_LEN];
95 } hmac_asoc_user_req_ie_stru;
96
97
98 /*****************************************************************************
99 8 UNION定义
100 *****************************************************************************/
101
102
103 /*****************************************************************************
104 9 OTHERS定义
105 *****************************************************************************/
106 /*****************************************************************************
107 函 数 名 : hmac_user_ht_support
108 功能描述 : 是否为HT用户
109 返 回 值 : OAL_TRUE是,OAL_FALSE不是
110 *****************************************************************************/
hmac_user_ht_support(const hmac_user_stru * hmac_user)111 OAL_STATIC OAL_INLINE oal_bool_enum_uint8 hmac_user_ht_support(const hmac_user_stru *hmac_user)
112 {
113 if (hmac_user->ht_hdl.ht_capable == OAL_TRUE) {
114 return OAL_TRUE;
115 }
116
117 return OAL_FALSE;
118 }
119
120 /*****************************************************************************
121 函 数 名 : hmac_user_xht_support
122 功能描述 : 是否支持ht/vht聚合
123 输入参数 : hmac_user_stru *hmac_user
124 返 回 值 : OAL_STATIC OAL_INLINE oal_bool_enum_uint8
125 *****************************************************************************/
hmac_user_xht_support(const hmac_user_stru * hmac_user)126 OAL_STATIC OAL_INLINE oal_bool_enum_uint8 hmac_user_xht_support(const hmac_user_stru *hmac_user)
127 {
128 if ((hmac_user->cur_protocol_mode >= WLAN_HT_MODE) &&
129 (hmac_user->cur_protocol_mode < WLAN_PROTOCOL_BUTT)) {
130 return OAL_TRUE;
131 }
132
133 return OAL_FALSE;
134 }
135
136 /*****************************************************************************
137 10 函数声明
138 *****************************************************************************/
139 extern osal_u32 hmac_user_set_asoc_req_ie(hmac_user_stru *hmac_user, osal_u8 *payload,
140 osal_u32 len, osal_u8 reass_flag);
141 extern osal_u32 hmac_user_free_asoc_req_ie(hmac_user_stru *hmac_user);
142 extern osal_u32 hmac_user_set_avail_num_space_stream_etc(hmac_user_stru *hmac_user,
143 wlan_nss_enum_uint8 vap_nss);
144 extern osal_u32 hmac_user_del_etc(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user);
145 extern osal_u32 hmac_user_add_etc(hmac_vap_stru *hmac_vap, osal_u8 *mac_addr, osal_u16 *pus_user_index);
146 extern osal_u32 hmac_user_add_multi_user_etc(hmac_vap_stru *hmac_vap, osal_u16 *pus_user_index);
147 extern osal_u32 hmac_user_del_multi_user_etc(hmac_vap_stru *hmac_vap);
148 extern osal_u32 hmac_user_add_notify_alg_etc(hmac_vap_stru *hmac_vap, osal_u16 user_idx);
149 extern osal_u32 hmac_update_user_last_active_time(hmac_vap_stru *hmac_vap, osal_u8 len, osal_u8 *param);
150 extern osal_void hmac_tid_clear_etc(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, osal_bool lock_free_flag);
151 extern hmac_user_stru *mac_res_get_hmac_user_etc(osal_u16 idx);
152 extern hmac_user_stru *mac_vap_get_hmac_user_by_addr_etc(hmac_vap_stru *hmac_vap, const osal_u8 *mac_addr);
153 extern osal_u32 mac_user_init_etc(hmac_user_stru *hmac_user, osal_u16 user_idx, osal_u8 *mac_addr,
154 hmac_vap_stru *hmac_vap);
155
156 // from hmac_user_rom.h
157 /*****************************************************************************
158 2 宏定义
159 *****************************************************************************/
160
161 #define HMAC_COMPATIBILITY_PKT_NUM_LIMIT 2000
162 #define HMAC_INVALID_USER_LUT_INDEX (WLAN_ACTIVE_USER_MAX_NUM) /* 无效的user lut index */
163
164 /*****************************************************************************
165 3 枚举定义
166 *****************************************************************************/
167 typedef enum {
168 HMAC_USER_PS_STATE_ACTIVE = 0,
169 HMAC_USER_PS_STATE_DOZE = 1,
170
171 HMAC_USER_PS_STATE_BUTT
172 } hmac_user_ps_state_enum;
173 typedef osal_u8 hmac_user_ps_state_enum_uint8;
174
175 typedef enum {
176 HMAC_USER_STATE_PS,
177 HMAC_USER_STATE_ACTIVE,
178
179 HMAC_USER_STATE_BUTT
180 } hmac_user_state_enum;
181 typedef osal_u8 hmac_user_state_enum_uint8;
182
183 typedef enum {
184 PSM_QUEUE_TYPE_NORMAL,
185 PSM_QUEUE_TYPE_IMPORTANT,
186
187 PSM_QUEUE_TYPE_BUTT
188 } psm_queue_type_enum;
189 typedef osal_u8 psm_queue_type_enum_uint8;
190
191 /*****************************************************************************
192 7 STRUCT定义
193 *****************************************************************************/
194 typedef struct {
195 osal_u32 uapsd_tx_enqueue_count; /* hmac_uapsd_tx_enqueue调用次数 */
196 osal_u32 uapsd_tx_dequeue_count; /* 出队帧个数统计 */
197 osal_u32 uapsd_tx_enqueue_free_count; /* 入队过程中MPDU被释放的次数,一次可能释放多个MPDU */
198 osal_u32 uapsd_rx_trigger_in_sp; /* trigger检查发现处于SP中的次数 */
199 osal_u32 uapsd_rx_trigger_state_trans; /* trigger检查中发现需要状态转换的次数 */
200 osal_u32 uapsd_rx_trigger_dup_seq; /* trigger帧是重复帧的个数 */
201 osal_u32 uapsd_send_qosnull; /* 队列为空,发送qos null data的个数 */
202 osal_u32 uapsd_send_extra_qosnull; /* 最后一个为管理帧,发送额外qosnull的个数 */
203 osal_u32 uapsd_process_queue_error; /* 队列处理过程中出错的次数 */
204 osal_u32 uapsd_flush_queue_error; /* flush队列处理过程中出错的次数 */
205 osal_u32 uapsd_send_qosnull_fail; /* 发送qosnull失败次数 */
206 } hmac_usr_uapsd_statis_stru;
207
208 typedef struct {
209 osal_u32 psm_enqueue_succ_cnt; /* psm队列成功入队帧个数 */
210 osal_u32 psm_enqueue_fail_cnt; /* psm队列入队失败被释放的帧个数 */
211 osal_u32 psm_dequeue_fail_cnt; /* psm队列出队失败的帧个数 */
212 osal_u32 psm_dequeue_succ_cnt; /* psm队列出队成功的帧个数 */
213 osal_u32 psm_send_data_fail_cnt; /* psm队列出队的数据帧发送失败个数 */
214 osal_u32 psm_send_mgmt_fail_cnt; /* psm队列出队的管理帧发送失败个数 */
215 osal_u32 psm_send_null_fail_cnt; /* AP发送null data失败的次数 */
216 osal_u32 psm_resv_pspoll_send_null; /* AP收到用户的pspoll,但是队列中没有缓存帧的次数 */
217 osal_u32 psm_rsp_pspoll_succ_cnt; /* AP收到用户的pspoll,发送缓存帧成功的次数 */
218 osal_u32 psm_rsp_pspoll_fail_cnt; /* AP收到用户的pspoll,发送缓存帧失败的次数 */
219 } hmac_user_psm_stats_stru;
220
221
222 /* 软件平均rssi统计信息结构体 */
223 typedef struct {
224 osal_s32 tx_rssi; /* 记录ACK RSSI的累计值 */
225 osal_s32 rx_rssi; /* 记录接收RSSI的累计值 */
226 osal_u16 tx_rssi_stat_count; /* 发送平均rssi统计的发包数目 */
227 osal_u16 rx_rssi_stat_count; /* 接收平均rssi统计的发包数目 */
228 } hmac_rssi_stat_info_stru;
229
230 /* 软件平均速率统计信息结构体 */
231 typedef struct {
232 osal_u32 tx_rate; /* 记录发送速率的累计值 */
233 osal_u32 rx_rate; /* 记录接收速率的累计值 */
234 osal_u16 tx_rate_stat_count; /* 发送平均rate统计的发包数目 */
235 osal_u16 rx_rate_stat_count; /* 接收平均rate统计的发包数目 */
236 } hmac_rate_stat_info_stru;
237
238 typedef struct {
239 /* 用户基本信息 */
240 wlan_protocol_enum_uint8 protocol; /* 协议模式 */
241 hal_channel_assemble_enum_uint8 en_bandwidth; /* 工作带宽 */
242
243 /* 算法用到的各个标志位 */
244 oal_bool_enum_uint8 hmac_rssi_stat_flag; /* 是否进行平均rssi统计 */
245 oal_bool_enum_uint8 hmac_rate_stat_flag; /* 是否进行平均速率统计 */
246
247 hmac_rssi_stat_info_stru dmac_rssi_stat_info; /* 软件平均rssi统计信息结构体指针 */
248 hmac_rate_stat_info_stru dmac_rate_stat_info; /* 软件平均速率统计信息结构体指针 */
249 } hmac_user_rate_info_stru;
250
251 typedef osal_u32 (*hmac_user_keepalive_timer_proc_cb)(osal_void *arg);
252 /*****************************************************************************
253 8 内联函数定义
254 *****************************************************************************/
255 /*****************************************************************************
256 函 数 名 : hmac_get_user_support_vht
257 功能描述 : 获取vht_capable字段的值
258 *****************************************************************************/
hmac_get_user_support_vht(const hmac_user_stru * user_info)259 static INLINE__ osal_u8 hmac_get_user_support_vht(const hmac_user_stru *user_info)
260 {
261 return ((user_info->vht_hdl.vht_capable == 1) ? OSAL_TRUE : OSAL_FALSE);
262 }
263
264 /*****************************************************************************
265 函 数 名 : hmac_get_user_support_ht
266 功能描述 : 获取ht_capable字段的值
267 *****************************************************************************/
hmac_get_user_support_ht(const hmac_user_stru * user_info)268 static INLINE__ osal_u8 hmac_get_user_support_ht(const hmac_user_stru *user_info)
269 {
270 return ((user_info->ht_hdl.ht_capable == 1) ? OSAL_TRUE : OSAL_FALSE);
271 }
272
273 /*****************************************************************************
274 10 函数声明
275 *****************************************************************************/
276 osal_void hmac_user_set_lut_info(hal_to_dmac_device_stru *hal_device, osal_u8 lut_index, osal_u8 *mac_addr);
277 osal_void hmac_user_del_lut_info(osal_u8 lut_index);
278 osal_u32 hmac_user_set_bandwith_handler(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user,
279 wlan_bw_cap_enum_uint8 bw_cap);
280 osal_u32 hmac_user_add_multi_user(hmac_vap_stru *hmac_vap, osal_u16 multi_user_idx);
281 osal_s32 hmac_user_add_notify_alg(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, frw_msg *msg);
282
283 osal_void hmac_user_del(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, mac_ap_type_enum_uint8 ap_type);
284 osal_void hmac_user_key_search_fail_handler(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user,
285 mac_ieee80211_frame_stru *frame_hdr);
286 osal_void hmac_user_pause(hmac_user_stru *hmac_user);
287 osal_u32 hmac_user_resume(hmac_user_stru *hmac_user);
288 osal_void hmac_user_init_slottime(const hmac_user_stru *hmac_user);
289 osal_u32 hmac_user_get_tid_by_num(hmac_user_stru *hmac_user, osal_u8 tid_num, hmac_tid_stru **tid_queue);
290
291 osal_void hmac_ap_pause_all_user(const hmac_vap_stru *hmac_vap);
292 osal_void hmac_rx_compatibility_identify(hmac_user_stru *hmac_user, osal_u32 rate_kbps);
293 osal_void hmac_rx_compatibility_show_stat(hmac_user_stru *hmac_user);
294 oal_bool_enum_uint8 hmac_psm_is_psm_empty(hmac_user_stru *hmac_user);
295 oal_bool_enum_uint8 hmac_psm_is_tid_empty(const hmac_user_stru *hmac_user);
296 osal_u32 hmac_psm_tid_mpdu_num(const hmac_user_stru *hmac_user);
297 osal_void hmac_ap_resume_all_user(hmac_vap_stru *hmac_vap);
298 osal_void hmac_user_ps_queue_overrun_notify(const hmac_vap_stru *hmac_vap);
299
300 osal_s32 hmac_user_sync(hmac_user_stru *hmac_user);
301 osal_void hmac_user_use_cnt_dec(hmac_user_stru *hmac_user);
302 osal_void hmac_user_use_cnt_inc(osal_u16 user_idx, hmac_user_stru **user);
303 osal_u32 hmac_user_keepalive_timer(osal_void *arg);
304 osal_s32 hmac_config_set_user_app_ie_cb(hmac_vap_stru *hmac_vap, frw_msg *msg);
305 oal_bool_enum_uint8 hmac_user_get_ps_mode(const hmac_user_stru *hmac_user);
306 osal_u32 hmac_alg_distance_notify_hook(hal_to_dmac_device_stru *hal_device, osal_u8 distance);
307
308 #ifdef __cplusplus
309 #if __cplusplus
310 }
311 #endif
312 #endif
313
314 #endif /* end of hmac_user.h */
315