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: vap / user common info for host and device
15 */
16
17 #ifndef __WLAN_RESOURCE_COMMON_ROM_H__
18 #define __WLAN_RESOURCE_COMMON_ROM_H__
19
20 #include "td_type.h"
21 #include "frw_ext_common_rom.h"
22 #include "wlan_mib_type.h"
23 #include "hal_ops_common_rom.h"
24 #include "oal_types_device_rom.h"
25 #include "wlan_types_base_rom.h"
26
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif
31 #endif
32
33 #define MAC_FCS_DEFAULT_PROTECT_TIME_OUT 5120 /* us */
34 #define MAC_FCS_DEFAULT_PROTECT_TIME_OUT3 15000 /* us */
35 #define MAC_ONE_PACKET_TIME_OUT_DEFAULT 500
36 #define MAC_ONE_PACKET_TIME_OUT 1000
37 #define MAC_ONE_PACKET_TIME_OUT3 2000
38 #define MAC_FCS_CTS_MAX_DURATION 32767 /* us */
39
40 /* WIFI侧hw bypass发送长度:仅bypass iperf跑流长包 */
41 #define PF_HAL_BYPASS_LEN 1300
42
43 /* Block ack的确认类型 */
44 typedef enum {
45 MAC_BACK_BASIC = 0,
46 MAC_BACK_COMPRESSED = 2,
47 MAC_BACK_MULTI_TID = 3,
48
49 MAC_BACK_BUTT
50 } mac_back_variant_enum;
51 typedef osal_u8 mac_back_variant_enum_uint8;
52
53 // AP STA公用状态
54 typedef enum {
55 /* ap sta公共状态 */
56 MAC_VAP_STATE_INIT = 0,
57 MAC_VAP_STATE_UP = 1, /* VAP UP */
58 MAC_VAP_STATE_PAUSE = 2, /* pause , for ap &sta */
59 MAC_VAP_STATE_LISTEN = 3,
60
61 /* ap 独有状态 */
62 MAC_VAP_STATE_AP_WAIT_START = 4,
63
64 /* sta独有状态 */
65 MAC_VAP_STATE_STA_FAKE_UP = 5,
66 MAC_VAP_STATE_STA_WAIT_SCAN = 6,
67 MAC_VAP_STATE_STA_SCAN_COMP = 7,
68 MAC_VAP_STATE_STA_JOIN_COMP = 8,
69 MAC_VAP_STATE_STA_WAIT_AUTH_SEQ2 = 9,
70 MAC_VAP_STATE_STA_WAIT_AUTH_SEQ4 = 10,
71 MAC_VAP_STATE_STA_AUTH_COMP = 11,
72 MAC_VAP_STATE_STA_WAIT_ASOC = 12,
73 MAC_VAP_STATE_STA_OBSS_SCAN = 13,
74 MAC_VAP_STATE_STA_BG_SCAN = 14,
75 MAC_VAP_STATE_ROAMING = 15, /* 漫游 */
76 MAC_VAP_STATE_BUTT,
77 } mac_vap_state_enum;
78 typedef osal_u8 mac_vap_state_enum_uint8;
79
80 typedef struct _mac_sta_pm_handler {
81 oal_fsm_stru oal_fsm; /* 节能状态机 */
82 frw_timeout_stru inactive_timer; /* 定时器 */
83 frw_timeout_stru mcast_timer; /* 接收广播组播超时定时器 */
84
85 osal_u32 tx_rx_activity_cnt; /* ACTIVE统计值,由超时进入DOZE复位 */
86 osal_u32 activity_timeout; /* 睡眠超时定时器超时时间 */
87 osal_u32 ps_keepalive_cnt; /* STA侧节能状态下keepalive机制统计接收beacon数 */
88 osal_u32 ps_keepalive_max_num; /* STA侧节能状态下keepalive机制最大接收beacon数 */
89
90 osal_u8 vap_ps_mode : 3; /* sta当前省电模式 */
91 osal_u8 can_sta_sleep : 1; /* 协议允许切到doze,是否能投票睡眠 */
92 osal_u8 is_fsm_attached : 1; /* 状态机是否已经注册 */
93 osal_u8 beacon_counting : 1;
94 osal_u8 forbiden_pm : 1; /* 永久关闭低功耗重启复位仅认证使用 */
95 osal_u8 ps_poll_pending : 1; /* P2p function */
96
97 osal_u8 beacon_frame_wait : 1; /* 提示接收beacon帧 */
98 osal_u8 more_data_expected : 1; /* 提示AP中有更多的缓存帧 */
99 osal_u8 active_null_wait : 1; /* STA发送NULL帧给AP提示进入ACTIVE 状态 */
100 osal_u8 doze_null_wait : 1; /* STA发送NULL帧给AP提示进入doze状态 */
101 osal_u8 direct_change_to_active : 1; /* FAST模式下直接唤醒的数据包切active状态 */
102 osal_u8 last_ps_status : 1; /* 上一次低功耗开启与否 */
103 osal_u8 ps_back_active_pause : 1; /* ps back 延迟发送唤醒null帧 */
104 osal_u8 ps_back_doze_pause : 1; /* ps back 延迟发送睡眠null帧 */
105
106 osal_u8 timer_fail_doze_trans_cnt; /* 超时函数内发null切doze失败次数 */
107 osal_u8 state_fail_doze_trans_cnt; /* 切doze时,由于条件不满足失败计数 */
108
109 osal_u8 beacon_fail_doze_trans_cnt; /* 收beacon 投票睡眠却却无法睡下去的计数 */
110 osal_u8 doze_event; /* 记录切状态的事件类型 */
111 osal_u8 awake_event;
112 osal_u8 active_event;
113
114 osal_u8 eosp_timeout_cnt; /* uapsd省电中TBTT计数器 */
115 osal_u8 uaspd_sp_status; /* UAPSD的状态 */
116 osal_u8 doze_null_retran_cnt;
117 osal_u8 active_null_retran_cnt;
118
119 osal_u32 psm_pkt_cnt;
120
121 osal_u8 psm_timer_restart_cnt; /* 重启睡眠定时器的count */
122 osal_u16 mcast_timeout; /* 接收广播组播定时器超时时间 */
123 osal_u8 max_skip_bcn_cnt; /* 最大允许跳过beacon次数 */
124
125 osal_u8 tbtt_cnt_since_full_bcn; /* 距离上次接收完整beacon的tbtt cnt计数 */
126 osal_u16 remain_len_after_tim; /* 记录beacon中tim ie后剩余字节数 */
127
128 oal_bool_enum_uint8 flag_null_data_pending;
129 uintptr_t *_rom; /* ROM化后资源扩展指针 */
130 } mac_sta_pm_handler_stru;
131
132 /* P2P OPS 节能配置参数 */
133 typedef struct {
134 osal_u8 ops_ctrl;
135 osal_u8 ct_window;
136 osal_u8 pause_ops;
137 osal_u8 rsv[1];
138 } mac_cfg_p2p_ops_param_stru;
139
140 /* P2P NOA节能配置参数 */
141 typedef struct {
142 osal_u32 start_time;
143 osal_u32 duration;
144 osal_u32 interval;
145 osal_u8 count;
146 osal_u8 rsv[3];
147 } mac_cfg_p2p_noa_param_stru;
148
149 /* STA UAPSD 配置命令 */
150 typedef struct {
151 osal_u8 uapsd_switch;
152 osal_u8 max_sp_len;
153 osal_u8 rsv[2]; /* 保留2字节对齐 */
154 osal_u8 delivery_enabled[WLAN_WME_AC_BUTT];
155 osal_u8 trigger_enabled[WLAN_WME_AC_BUTT];
156 } mac_cfg_uapsd_sta_stru;
157
158 typedef struct {
159 osal_u16 setup_command : 3;
160 osal_u16 flow_id : 3;
161 osal_u16 flow_type : 1;
162 osal_u16 trigger : 1;
163 osal_u16 wake_duration_unit : 1; /* duration unit */
164 osal_u16 intrval_exponent : 5; /* interval_exponent */
165 osal_u16 resv : 2;
166
167 osal_u16 intrval_mantissa; /* interval_mantissa */
168
169 osal_u8 min_duration; /* wake_duration */
170 osal_u8 information_disable;
171 osal_u8 resv1[2]; /* 3保留字节 */
172
173 osal_u64 twt; /* us after TSF */
174 } mac_cfg_twt_basic_param_stru;
175
176 /* TWT参数 */
177 typedef struct {
178 osal_u8 twt_session_status;
179 osal_u8 dialog_token; /* HMAC专用 */
180 osal_u8 next_twt_size; /* TWT Information帧有用 */
181 osal_u8 twt_ps_pause; /* DMAC专用: TWT 省电队列发送是否处于pause状态, TWT SP期间置为OAL_FALSE */
182
183 osal_u32 twt_interval;
184 osal_u32 twt_duration; /* 转换后的Nominal Minimum TWT Wake Duration,单位us */
185
186 mac_cfg_twt_basic_param_stru twt_basic_param;
187 } mac_cfg_twt_stru;
188
189 typedef enum {
190 MAC_STA_PM_SWITCH_OFF = 0, /* 关闭低功耗 */
191 MAC_STA_PM_SWITCH_ON = 1, /* 打开低功耗 */
192 MAC_STA_PM_MANUAL_MODE_ON = 2, /* 开启手动sta pm mode */
193 MAC_STA_PM_MANUAL_MODE_OFF = 3, /* 关闭手动sta pm mode */
194 MAC_STA_PM_SWITCH_RESET = 4, /* 重置sta pm mode */
195 MAC_STA_PM_SWITCH_BUTT, /* 最大类型 */
196 MAC_STA_PM_DISABLE_FOREVER = 255, /* 永久关闭低功耗,仅认证使用 */
197 } mac_pm_switch_enum;
198 typedef osal_u8 mac_pm_switch_enum_uint8;
199
200 typedef enum {
201 MAC_STA_PM_CTRL_TYPE_HOST = 0, /* 低功耗控制类型 HOST */
202 MAC_STA_PM_CTRL_TYPE_MVAP = 1, /* 低功耗控制类型 多VAP共存 */
203 MAC_STA_PM_CTRL_TYPE_MONITOR = 2, /* 低功耗控制类型 MONITOR */
204 MAC_STA_PM_CTRL_TYPE_ROAM = 3, /* 低功耗控制类型 RAOM */
205 MAC_STA_PM_CTRL_TYPE_TWT = 4, /* 低功耗控制类型 TWT */
206 MAC_STA_PM_CTRL_TYPE_SDP = 5, /* 低功耗控制类型 SDP/NAN/WIFI AWARE */
207 MAC_STA_PM_CTRL_TYPE_BUTT, /* 最大类型,应小于 8 */
208 } mac_pm_ctrl_type_enum;
209 typedef osal_u8 mac_pm_ctrl_type_enum_uint8;
210
211 /* Power save modes specified by the user */
212 typedef enum {
213 NO_POWERSAVE = 0,
214 MIN_FAST_PS = 1,
215 MAX_FAST_PS = 2,
216 MIN_PSPOLL_PS = 3,
217 MAX_PSPOLL_PS = 4,
218 NUM_PS_MODE = 5
219 } ps_user_mode_enum;
220
221 /* 存储所有的nontrans_bssid_frofile的综合信息 */
222 typedef struct {
223 osal_u8 multi_bss_eid_exist : 1; /* 置1表示当前bss属于multi bss中的一员 */
224 osal_u8 maxbssid_indicator : 4; /* 2的n次幂表示集合中bss最大数目 */
225 osal_u8 resv : 3;
226 osal_u8 bssid_idx; /* 本bss属于multi-bss中的1员时,对应的bssid idx */
227 osal_u8 trans_bssid[WLAN_MAC_ADDR_LEN]; /* multi-bss中,发送beacon帧的bss对应的bssid */
228 } mac_scanned_all_bss_info;
229 typedef enum {
230 MAC_FCS_NOTIFY_TYPE_SWITCH_AWAY = 0,
231 MAC_FCS_NOTIFY_TYPE_SWITCH_BACK,
232
233 MAC_FCS_NOTIFY_TYPE_BUTT
234 } mac_fcs_notify_type_enum;
235 typedef osal_u8 mac_fcs_notify_type_enum_uint8;
236
237
238 typedef enum {
239 MAC_FCS_STATE_STANDBY = 0, // free to use
240 MAC_FCS_STATE_REQUESTED, // requested by other module, but not in switching
241 MAC_FCS_STATE_IN_PROGESS, // in switching
242
243 MAC_FCS_STATE_BUTT
244 } mac_fcs_state_enum;
245 typedef osal_u8 mac_fcs_state_enum_uint8;
246
247 typedef enum {
248 MAC_FCS_SUCCESS = 0,
249 MAC_FCS_ERR_NULL_PTR,
250 MAC_FCS_ERR_INVALID_CFG,
251 MAC_FCS_ERR_BUSY,
252 MAC_FCS_ERR_UNKNOWN_ERR,
253 } mac_fcs_err_enum;
254 typedef osal_u8 mac_fcs_err_enum_uint8;
255
256
257 typedef enum {
258 MAC_FCS_START_SWITCH_CHNL = 0,
259 MAC_FCS_START_SAME_CHNL,
260 MAC_FCS_START_SWITCH_CHNL_ENHANCED,
261 MAC_FCS_START_SAME_CHNL_ENHANCED,
262 MAC_FCS_START_SEND_ONE_PACKET,
263 MAC_FCS_START_BUTT
264 } mac_fcs_type_enum;
265 typedef osal_u8 mac_fcs_type_enum_uint8;
266
267 typedef struct {
268 mac_channel_stru dst_chl;
269 mac_channel_stru src_chl;
270 hal_one_packet_cfg_stru one_packet_cfg;
271 mac_fcs_type_enum_uint8 fcs_type;
272 osal_u8 vap_id;
273 osal_u8 resv[2]; /* 预留字节对齐 */
274 hal_to_dmac_device_stru *hal_device;
275 hal_tx_dscr_queue_header_stru *src_fake_queue; /* 记录此vap自己的fake队列指针 */
276 mac_channel_stru src_chl2;
277 hal_one_packet_cfg_stru one_packet_cfg2;
278 } mac_fcs_cfg_stru;
279
280 typedef struct {
281 mac_fcs_notify_type_enum_uint8 notify_type;
282 osal_u8 resv[3]; /* 3 BYTE保留字段 */
283 mac_fcs_cfg_stru fcs_cfg;
284 } mac_fcs_event_stru;
285
286 typedef osal_void (*mac_fcs_notify_func)(const mac_fcs_event_stru *);
287
288 typedef struct tag_mac_fcs_mgr_stru {
289 volatile oal_bool_enum_uint8 fcs_done;
290 mac_fcs_state_enum_uint8 fcs_state;
291 hal_fcs_service_type_enum_uint8 fcs_service_type;
292 osal_u8 resv;
293
294 mac_fcs_cfg_stru *fcs_cfg;
295 } mac_fcs_mgr_stru;
296
297 typedef struct {
298 osal_u8 nss_rate;
299 osal_u8 protocol_type;
300 osal_s8 rssi_dbm;
301 osal_s8 snr_ant0;
302
303 osal_u8 freq_bw;
304 osal_u8 rate;
305 osal_u16 data_cnt;
306 osal_u8 gi_type;
307 osal_u8 preamble_mode;
308 osal_u8 reserved[2]; /* 2:保持字节对齐 */
309 osal_u32 transmit_power;
310 } mac_cfg_tx_user_rate_stru;
311
312 typedef enum {
313 MAC_MEMINFO_USER = 0,
314 MAC_MEMINFO_VAP,
315 MAC_MEMINFO_POOL_INFO,
316 MAC_MEMINFO_SDIO_TRX,
317 MAC_MEMINFO_ALL,
318
319 MAC_MEMINFO_BUTT
320 } mac_meminfo_cmd_enum;
321 typedef osal_u8 mac_meminfo_cmd_enum_uint8;
322
323 typedef struct {
324 mac_meminfo_cmd_enum_uint8 meminfo_type;
325 osal_u8 object_index;
326 } mac_cfg_meminfo_stru;
327
328 #ifdef _PRE_WLAN_DFT_STAT
329 typedef struct {
330 osal_u16 user_id;
331 osal_u8 auc_resv[2];
332 osal_u32 tx_rate; /* 当前发送速率 */
333 osal_u32 rx_rate; /* 当前接收速率 */
334 } mac_cfg_query_rate_stru;
335 #endif
336
337 typedef struct {
338 osal_u8 data_retry_times;
339 osal_u8 mgmt_retry_times;
340 } mac_cfg_soft_retry_times_stru;
341
342 /* resource_rom */
343 typedef struct {
344 osal_ulong user_idx_size;
345 } mac_res_user_idx_size_stru;
346
347 typedef struct {
348 osal_u8 user_cnt_size;
349 } mac_res_user_cnt_size_stru;
350
351 typedef union {
352 struct {
353 osal_u8 trace : 1;
354 osal_u8 off : 1;
355 osal_u8 dump : 1;
356 osal_u8 icmp : 1;
357 osal_u8 auth : 1;
358 osal_u8 arp : 1;
359 osal_u8 eapol : 1;
360 osal_u8 assoc : 1;
361 } bits;
362 osal_u8 val;
363 } mac_pkt_debug_ctl_stru;
364
365 typedef enum {
366 PF_HAL_BYPASS, /* 逻辑bypass峰值性能测试,不写入FIFO队列软件产生发送完成中断 */
367 PF_FIX_AGGR, /* 固定聚合度性能测试 */
368 PF_BYPASS_SCHE, /* bypass调度 */
369 PF_FIX_RATE, /* 固定最大速率性能测试 */
370 PF_TYPE_BUTT
371 } mac_performance_mode_enum;
372
373 typedef struct {
374 osal_u8 pf_mode;
375 osal_u8 value;
376 osal_u8 resv[2];
377 } mac_performance_stru;
378
379 #define SERVICE_CONTROL_SDP BIT7
380
381 /* 32位全局变量控制32种业务场景 */
382 typedef struct {
383 osal_u32 mask;
384 osal_u32 value;
385 } service_control_msg;
386
387 /*****************************************************************************
388 功能描述 : 判断是否为相同信道
389 *****************************************************************************/
mac_fcs_is_same_channel(const mac_channel_stru * channel_dst,const mac_channel_stru * channel_src)390 static INLINE__ oal_bool_enum_uint8 mac_fcs_is_same_channel(const mac_channel_stru *channel_dst,
391 const mac_channel_stru *channel_src)
392 {
393 return channel_dst->chan_number == channel_src->chan_number ? OSAL_TRUE : OSAL_FALSE;
394 }
395
396 typedef struct {
397 osal_u16 user_id;
398 osal_u8 resv[2]; /* 预留2字节对齐 */
399 osal_u32 tx_best_rate;
400 } mac_cfg_ar_tx_params_stru;
401
402 #ifdef __cplusplus
403 #if __cplusplus
404 }
405 #endif
406 #endif
407
408 #endif /* end of wlan_resource_common.h */
409