1 /*
2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef __MAC_DEVICE_H__
20 #define __MAC_DEVICE_H__
21
22 /* ****************************************************************************
23 1 其他头文件包含
24 **************************************************************************** */
25 #include "oal_ext_if.h"
26 #include "oam_ext_if.h"
27 #include "frw_timer.h"
28 #include "mac_vap.h"
29 #include "mac_mib.h"
30 #include "mac_cfg.h"
31
32 #ifdef __cplusplus
33 #if __cplusplus
34 extern "C" {
35 #endif
36 #endif
37
38 /* ****************************************************************************
39 2 宏定义
40 **************************************************************************** */
41 #define MAC_DATARATES_PHY_80211G_NUM 12
42 #define DMAC_BA_LUT_IDX_BMAP_LEN ((HAL_MAX_BA_LUT_SIZE + 7) >> 3)
43
44 /* DMAC SCANNER 扫描模式 */
45 #define MAC_SCAN_FUNC_MEAS 0x1
46 #define MAC_SCAN_FUNC_STATS 0x2
47 #define MAC_SCAN_FUNC_RADAR 0x4
48 #define MAC_SCAN_FUNC_BSS 0x8
49 #define MAC_SCAN_FUNC_P2P_LISTEN 0x10
50 #define MAC_SCAN_FUNC_ALL (MAC_SCAN_FUNC_MEAS | MAC_SCAN_FUNC_STATS | MAC_SCAN_FUNC_RADAR | MAC_SCAN_FUNC_BSS)
51
52 #define MAC_DEV_MAX_40M_INTOL_USER_BITMAP_LEN 4
53
54 #ifdef _PRE_WLAN_FEATURE_MESH_ROM
55 #define MAC_MIB_MESH_VENDOR_SPECIFIC 255
56 #define MAC_MIB_NEIGHBOR_OFFSET_SYNC 1
57 #define MAC_MIB_AUTH_PROTOCOL_SAE 1
58 #define MAC_MESH_MULTI_MAC_ADDR_MAX_NUM 10
59 #endif
60
61 #define MAC_FCS_MAX_CHL_NUM 2
62 #define MAC_FCS_DEFAULT_PROTECT_TIMEOUT 2000 /* 第一次发保护帧超时时间,单位:us */
63 #define MAC_FCS_DEFAULT_PROTECT_TIMEOUT2 1000 /* 第二次发保护帧超时时间,单位:us */
64 #define MAC_DBAC_ONE_PACKET_TIMEOUT 1000 /* dbac保护帧超时时间,单位:10us */
65 #define MAC_ONE_PACKET_TIMEOUT 1000 /* 非dbac保护帧超时时间,单位:10us */
66 #define MAC_FCS_CTS_MAX_DURATION 32767 /* us */
67
68 #define MAX_PNO_SSID_COUNT 16
69 #define MAX_PNO_REPEAT_TIMES 4
70 #define PNO_SCHED_SCAN_INTERVAL (30 * 1000)
71
72 /* ****************************************************************************
73 3 枚举定义
74 **************************************************************************** */
75 typedef enum {
76 MAC_CH_TYPE_NONE = 0,
77 MAC_CH_TYPE_PRIMARY = 1,
78 MAC_CH_TYPE_SECONDARY = 2,
79 } mac_ch_type_enum;
80 typedef hi_u8 mac_ch_type_enum_uint8;
81
82 typedef enum {
83 MAC_SCAN_OP_INIT_SCAN,
84 MAC_SCAN_OP_FG_SCAN_ONLY,
85 MAC_SCAN_OP_BG_SCAN_ONLY,
86
87 MAC_SCAN_OP_BUTT
88 } mac_scan_op_enum;
89 typedef hi_u8 mac_scan_op_enum_uint8;
90
91 typedef enum {
92 MAC_CHAN_NOT_SUPPORT = 0, /* 管制域不支持该信道 */
93 MAC_CHAN_AVAILABLE_ALWAYS, /* 信道一直可以使用 */
94 MAC_CHAN_AVAILABLE_TO_OPERATE, /* 经过检测(CAC, etc...)后,该信道可以使用 */
95 MAC_CHAN_DFS_REQUIRED, /* 该信道需要进行雷达检测 */
96 MAC_CHAN_BLOCK_DUE_TO_RADAR, /* 由于检测到雷达导致该信道变的不可用 */
97
98 MAC_CHAN_STATUS_BUTT
99 } mac_chan_status_enum;
100 typedef hi_u8 mac_chan_status_enum_uint8;
101
102 /* device reset同步子类型枚举 */
103 typedef enum {
104 MAC_RESET_SWITCH_SET_TYPE,
105 MAC_RESET_SWITCH_GET_TYPE,
106 MAC_RESET_STATUS_GET_TYPE,
107 MAC_RESET_STATUS_SET_TYPE,
108 MAC_RESET_SWITCH_SYS_TYPE = MAC_RESET_SWITCH_SET_TYPE,
109 MAC_RESET_STATUS_SYS_TYPE = MAC_RESET_STATUS_SET_TYPE,
110
111 MAC_RESET_SYS_TYPE_BUTT
112 } mac_reset_sys_type_enum;
113 typedef hi_u8 mac_reset_sys_type_enum_uint8;
114
115 typedef enum {
116 MAC_TRY_INIT_SCAN_VAP_UP,
117 MAC_TRY_INIT_SCAN_SET_CHANNEL,
118 MAC_TRY_INIT_SCAN_START_DBAC,
119 MAC_TRY_INIT_SCAN_RESCAN,
120
121 MAC_TRY_INIT_SCAN_BUTT
122 } mac_try_init_scan_type;
123 typedef hi_u8 mac_try_init_scan_type_enum_uint8;
124
125 typedef enum {
126 MAC_INIT_SCAN_NOT_NEED,
127 MAC_INIT_SCAN_NEED,
128 MAC_INIT_SCAN_IN_SCAN,
129 } mac_need_init_scan_res;
130 typedef hi_u8 mac_need_init_scan_res_enum_uint8;
131
132 /* 扫描状态,通过判断当前扫描的状态,判断多个扫描请求的处理策略以及上报扫描结果的策略 */
133 typedef enum {
134 MAC_SCAN_STATE_IDLE,
135 MAC_SCAN_STATE_RUNNING,
136
137 MAC_SCAN_STATE_BUTT
138 } mac_scan_state_enum;
139 typedef hi_u8 mac_scan_state_enum_uint8;
140
141 typedef enum {
142 MAC_FCS_STATE_STANDBY = 0, // free to use
143 MAC_FCS_STATE_REQUESTED, // requested by other module, but not in switching
144 MAC_FCS_STATE_IN_PROGESS, // in switching
145
146 MAC_FCS_STATE_BUTT
147 } mac_fcs_state_enum;
148 typedef hi_u8 mac_fcs_state_enum_uint8;
149
150 typedef enum {
151 MAC_FCS_SUCCESS = 0,
152 MAC_FCS_ERR_NULL_PTR,
153 MAC_FCS_ERR_INVALID_CFG,
154 MAC_FCS_ERR_BUSY,
155 MAC_FCS_ERR_UNKNOWN_ERR,
156 } mac_fcs_err_enum;
157 typedef hi_u8 mac_fcs_err_enum_uint8;
158
159 typedef enum {
160 MAC_ACS_RSN_INIT,
161 MAC_ACS_RSN_LONG_TX_BUF,
162 MAC_ACS_RSN_LARGE_PER,
163 MAC_ACS_RSN_MWO_DECT,
164 MAC_ACS_RSN_RADAR_DECT,
165
166 MAC_ACS_RSN_BUTT
167 } mac_acs_rsn_enum;
168 typedef hi_u8 mac_acs_rsn_enum_uint8;
169
170 typedef enum {
171 MAC_ACS_SW_NONE = 0x0,
172 MAC_ACS_SW_INIT = 0x1,
173 MAC_ACS_SW_DYNA = 0x2,
174 MAC_ACS_SW_BOTH = 0x3,
175
176 MAC_ACS_SW_BUTT
177 } mac_acs_sw_enum;
178 typedef hi_u8 en_mac_acs_sw_enum_uint8;
179
180 typedef enum {
181 MAC_ACS_SET_CH_DNYA = 0x0,
182 MAC_ACS_SET_CH_INIT = 0x1,
183
184 MAC_ACS_SET_CH_BUTT
185 } mac_acs_set_ch_enum;
186 typedef hi_u8 en_mac_acs_set_ch_enum_uint8;
187
188 /* 扫描完成事件返回状态码 */
189 typedef enum {
190 MAC_SCAN_SUCCESS = 0, /* 扫描成功 */
191 MAC_SCAN_TIMEOUT = 2, /* 扫描超时 */
192 MAC_SCAN_REFUSED = 3, /* 扫描被拒绝 */
193 MAC_SCAN_STATUS_BUTT, /* 无效状态码,初始化时使用此状态码 */
194 } mac_scan_status_enum;
195 typedef hi_u8 mac_scan_status_enum_uint8;
196
197 /* ****************************************************************************
198 STRUCT定义
199 **************************************************************************** */
200 typedef void (*mac_scan_cb_fn)(void *p_scan_record);
201
202 typedef struct {
203 hi_u32 offset_addr;
204 hi_u32 value[MAC_FCS_MAX_CHL_NUM];
205 } mac_fcs_reg_record_stru;
206
207 typedef struct tag_mac_fcs_mgr_stru {
208 volatile hi_u8 fcs_done;
209 mac_fcs_state_enum_uint8 fcs_state;
210 hi_u8 vap_id; /* 目标信道对应的vap id,用于设置带宽 */
211 hi_u8 uc_resv;
212 } mac_fcs_mgr_stru;
213
214 /* device reset事件同步结构体 */
215 typedef struct {
216 mac_reset_sys_type_enum_uint8 reset_sys_type; /* 复位同步类型 */
217 hi_u8 value; /* 同步信息值 */
218 hi_u8 uc_resv[2]; /* 2 byte预留字段 */
219 } mac_reset_sys_stru;
220
221 typedef struct {
222 hi_u16 us_num_networks;
223 mac_ch_type_enum_uint8 ch_type;
224 hi_u8 auc_resv;
225 } mac_ap_ch_info_stru;
226
227 typedef struct {
228 hi_u16 us_num_networks; /* 记录当前信道下扫描到的BSS个数 */
229 hi_u8 auc_resv[2]; /* 2 byte预留字段 */
230 hi_u8 auc_bssid_array[WLAN_MAX_SCAN_BSS_PER_CH][WLAN_MAC_ADDR_LEN]; /* 记录当前信道下扫描到的所有BSSID */
231 } mac_bss_id_list_stru;
232
233 /* PNO扫描信息结构体 */
234 typedef struct {
235 hi_s8 ac_match_ssid_set[MAX_PNO_SSID_COUNT][WLAN_SSID_MAX_LEN];
236 hi_u8 auc_sour_mac_addr[WLAN_MAC_ADDR_LEN]; /* probe req帧中携带的发送端地址 */
237 hi_u8 pno_scan_repeat; /* pno扫描重复次数 */
238 hi_u8 is_random_mac_addr_scan; /* 是否随机mac */
239 hi_s32 l_ssid_count; /* 下发的需要匹配的ssid集的个数 */
240 hi_s32 l_rssi_thold; /* 可上报的rssi门限 */
241 hi_u32 pno_scan_interval; /* pno扫描间隔 */
242 mac_scan_cb_fn fn_cb; /* 函数指针必须放最后否则核间通信出问题 */
243 } mac_pno_scan_stru;
244
245 /* PNO调度扫描管理结构体 */
246 typedef struct {
247 mac_pno_scan_stru pno_sched_scan_params; /* pno调度扫描请求的参数 */
248 /* frw_timeout_stru st_pno_sched_scan_timer; pno调度扫描定时器 */
249 /* pno调度扫描rtc时钟定时器,此定时器超时后,能够唤醒睡眠的device */
250 hi_void *pno_sched_scan_timer;
251 hi_u8 curr_pno_sched_scan_times; /* 当前pno调度扫描次数 */
252 hi_u8 is_found_match_ssid; /* 是否扫描到了匹配的ssid */
253 hi_u8 auc_resv[2]; /* 2 byte预留字段 */
254 } mac_pno_sched_scan_mgmt_stru;
255
256 /* 扫描参数结构体 */
257 typedef struct {
258 wlan_mib_desired_bsstype_enum_uint8 bss_type; /* 要扫描的bss类型 */
259 wlan_scan_type_enum_uint8 scan_type; /* 主动/被动 */
260 hi_u8 auc_sour_mac_addr[WLAN_MAC_ADDR_LEN]; /* probe req帧中携带的发送端地址 */
261
262 hi_u8 max_scan_cnt_per_channel : 4, /* 每个信道的扫描次数 */
263 max_send_probe_cnt_per_channel : 4; /* 每次发送扫描请求帧的个数,默认为1 */
264 hi_u8 curr_channel_scan_count : 4, /* 记录当前信道的扫描次数 */
265 is_p2p0_scan : 1, /* 是否为p2p0 发起扫描 */
266 working_in_home_chan : 1,
267 need_switch_back_home_channel : 1, /* 扫描完一个信道是否要切回工作信道 */
268 is_random_mac_addr_scan : 1; /* 是否是随机mac addr扫描 */
269 hi_u8 auc_bssid[WLAN_SCAN_REQ_MAX_BSS][WLAN_MAC_ADDR_LEN]; /* 期望的bssid */
270
271 hi_s8 ac_ssid[WLAN_SCAN_REQ_MAX_BSS][WLAN_SSID_MAX_LEN]; /* 期望的ssid */
272 hi_u8 last_channel_band;
273 hi_u8 scan_func; /* DMAC SCANNER 扫描模式 */
274 hi_u8 p2p0_listen_channel; /* 记录上层下发的p2 plisten channel */
275
276 mac_channel_stru ast_channel_list[WLAN_MAX_CHANNEL_NUM];
277 wlan_scan_mode_enum_uint8 scan_mode : 4; /* 扫描模式:前景扫描 or 背景扫描 */
278 hi_u8 vap_id : 4; /* 下发扫描请求的vap id */
279 hi_u8 channel_nums; /* 信道列表中信道的个数 */
280 hi_u8 channel_interval;
281 hi_u16 us_scan_time; /* 扫描在某一信道停留此时间后,扫描结束, 10的整数倍ms */
282
283 hi_u64 ull_cookie; /* P2P 监听下发的cookie 值 */
284 hi_u32 resv2;
285 mac_scan_cb_fn fn_cb; /* 回调函数指针 */
286 } mac_scan_req_stru;
287
288 /* 打印接收报文的rssi信息的调试开关相关的结构体 */
289 typedef struct {
290 hi_u32 rssi_debug_switch; /* 打印接收报文的rssi信息的调试开关 */
291 hi_u32 rx_comp_isr_interval; /* 间隔多少个接收完成中断打印一次rssi信息 */
292 hi_u32 curr_rx_comp_isr_count; /* 一轮间隔内,接收完成中断的产生个数 */
293 } mac_rssi_debug_switch_stru;
294
295 /* ACS 命令及回复格式 */
296 typedef struct {
297 hi_u8 cmd;
298 hi_u8 chip_id;
299 hi_u8 device_id;
300 hi_u8 uc_resv;
301
302 hi_u32 len; /* 总长度,包括上面前4个字节 */
303 hi_u32 cmd_cnt; /* 命令的计数 */
304 } mac_acs_response_hdr_stru;
305
306 typedef struct {
307 hi_u8 sw_when_connected_enable : 1;
308 hi_u8 drop_dfs_channel_enable : 1;
309 hi_u8 lte_coex_enable : 1;
310 en_mac_acs_sw_enum_uint8 acs_switch : 5;
311 } mac_acs_switch_stru;
312
313 /* DMAC SCAN 信道扫描BSS信息摘要结构 */
314 typedef struct {
315 hi_s8 rssi; /* bss的信号强度 */
316 hi_u8 channel_number; /* 信道号 */
317 hi_u8 auc_bssid[WLAN_MAC_ADDR_LEN];
318
319 /* 11n, 11ac信息 */
320 hi_u8 ht_capable; /* 是否支持ht */
321 hi_u8 vht_capable; /* 是否支持vht */
322 wlan_bw_cap_enum_uint8 bw_cap; /* 支持的带宽 0-20M 1-40M */
323 wlan_channel_bandwidth_enum_uint8 channel_bandwidth; /* 信道带宽配置 */
324 } mac_scan_bss_stats_stru;
325
326 /* DMAC SCAN 信道统计测量结果结构体 */
327 typedef struct {
328 hi_u8 channel_number; /* 信道号 */
329 hi_u8 auc_resv[3]; /* 3 byte预留字段 */
330
331 hi_u8 stats_cnt; /* 信道繁忙度统计次数 */
332 hi_u8 free_power_cnt; /* 信道空闲功率 */
333 hi_s16 s_free_power_stats_20_m;
334 hi_s16 s_free_power_stats_40_m;
335 hi_s16 s_free_power_stats_80_m;
336
337 hi_u32 total_stats_time_us;
338 hi_u32 total_free_time_20_m_us;
339 hi_u32 total_free_time_40_m_us;
340 hi_u32 total_free_time_80_m_us;
341 hi_u32 total_send_time_us;
342 hi_u32 total_recv_time_us;
343 } mac_scan_chan_stats_stru;
344
345 typedef struct {
346 hi_s8 rssi; /* bss的信号强度 */
347 hi_u8 channel_number; /* 信道号 */
348
349 hi_u8 ht_capable : 1; /* 是否支持ht */
350 hi_u8 vht_capable : 1; /* 是否支持vht */
351 wlan_bw_cap_enum_uint8 bw_cap : 3; /* 支持的带宽 0-20M 1-40M */
352 wlan_channel_bandwidth_enum_uint8 channel_bandwidth : 3; /* 信道带宽配置 */
353 } mac_scan_bss_stats_simple_stru;
354
355 /* DMAC SCAN 回调事件结构体 */
356 typedef struct {
357 hi_u8 nchans; /* 信道数量 */
358 hi_u8 nbss; /* BSS数量 */
359 hi_u8 scan_func; /* 扫描启动的功能 */
360
361 hi_u8 need_rank : 1; // kernel write, app read
362 hi_u8 obss_on : 1;
363 hi_u8 dfs_on : 1;
364 hi_u8 uc_resv : 1;
365 hi_u8 chip_id : 2;
366 hi_u8 device_id : 2;
367 } mac_scan_event_stru;
368
369 /* bss安全相关信息结构体 */
370 typedef struct {
371 hi_u8 bss_80211i_mode; /* 指示当前AP的安全方式是WPA或WPA2。BIT0: WPA; BIT1:WPA2 */
372 hi_u8 rsn_grp_policy; /* 用于存放WPA2方式下,AP的组播加密套件信息 */
373 hi_u8 auc_rsn_pairwise_policy[MAC_PAIRWISE_CIPHER_SUITES_NUM]; /* 用于存放WPA2方式下,AP的单播加密套件信息 */
374 hi_u8 auc_rsn_auth_policy[MAC_AUTHENTICATION_SUITE_NUM]; /* 用于存放WPA2方式下,AP的认证套件信息 */
375 hi_u8 auc_rsn_cap[2]; /* 2 byte 用于保存RSN能力信息,直接从帧内容中copy过来 */
376 hi_u8 auc_wpa_pairwise_policy[MAC_PAIRWISE_CIPHER_SUITES_NUM]; /* 用于存放WPA方式下,AP的单播加密套件信息 */
377 hi_u8 auc_wpa_auth_policy[MAC_AUTHENTICATION_SUITE_NUM]; /* 用于存放WPA方式下,AP的认证套件信息 */
378 hi_u8 wpa_grp_policy; /* 用于存放WPA方式下,AP的组播加密套件信息 */
379 hi_u8 grp_policy_match; /* 用于存放匹配的组播套件 */
380 hi_u8 pairwise_policy_match; /* 用于存放匹配的单播套件 */
381 hi_u8 auth_policy_match; /* 用于存放匹配的认证套件 */
382 } mac_bss_80211i_info_stru;
383
384 /* 扫描结果 */
385 typedef struct {
386 mac_scan_status_enum_uint8 scan_rsp_status;
387 hi_u8 auc_resv[7]; /* 7 byte预留字段 */
388 hi_u64 ull_cookie;
389 } mac_scan_rsp_stru;
390
391 /* 扫描到的BSS描述结构体 */
392 typedef struct {
393 /* 基本信息 */
394 wlan_mib_desired_bsstype_enum_uint8 bss_type; /* bss网络类型 */
395 hi_u8 dtim_period; /* dtime周期 */
396 hi_u8 dtim_cnt; /* dtime cnt */
397 hi_u8 ntxbf; /* 11n txbf */
398 hi_u8 new_scan_bss; /* 是否是新扫描到的BSS */
399 hi_u8 auc_resv1[1];
400 hi_s8 rssi; /* bss的信号强度 */
401 hi_char ac_ssid[WLAN_SSID_MAX_LEN]; /* 网络ssid */
402 hi_u16 us_beacon_period; /* beacon周期 */
403 hi_u16 us_cap_info; /* 基本能力信息 */
404 hi_u8 auc_mac_addr[WLAN_MAC_ADDR_LEN]; /* 基础型网络 mac地址与bssid相同 */
405 hi_u8 auc_bssid[WLAN_MAC_ADDR_LEN]; /* 网络bssid */
406 mac_channel_stru channel; /* bss所在的信道 */
407 hi_u8 wmm_cap; /* 是否支持wmm */
408 hi_u8 uapsd_cap; /* 是否支持uapsd */
409 hi_u8 desired; /* 标志位,此bss是否是期望的 */
410 hi_u8 num_supp_rates; /* 支持的速率集个数 */
411 hi_u8 auc_supp_rates[WLAN_MAX_SUPP_RATES]; /* 支持的速率集 */
412 hi_u8 need_drop; /* 判断当前扫描结果是否需要过滤 */
413 hi_u8 auc_resv2[3]; /* reserve 3byte */
414 #ifdef _PRE_WLAN_FEATURE_11D
415 hi_char ac_country[WLAN_COUNTRY_STR_LEN]; /* 国家字符串 */
416 hi_u8 auc_resv3[1];
417 #endif
418 hi_u8 is_mesh_accepting_peer; /* 是否支持Mesh连接 */
419 hi_u8 is_hisi_mesh; /* 是否是HISI-MESH节点 */
420
421 #ifdef _PRE_WLAN_FEATURE_ANY
422 hi_u8 supp_any;
423 hi_u8 is_any_sta;
424 #endif
425
426 /* 安全相关的信息 */
427 mac_bss_80211i_info_stru bss_sec_info; /* 用于保存STA模式下,扫描到的AP安全相关信息 */
428
429 /* 11n 11ac信息 */
430 hi_u8 ht_capable; /* 是否支持ht */
431 hi_u8 vht_capable; /* 是否支持vht */
432 wlan_bw_cap_enum_uint8 bw_cap; /* 支持的带宽 0-20M 1-40M */
433 wlan_channel_bandwidth_enum_uint8 channel_bandwidth; /* 信道带宽 */
434 hi_u8 coex_mgmt_supp; /* 是否支持共存管理 */
435 hi_u8 ht_ldpc; /* 是否支持ldpc */
436 hi_u8 ht_stbc; /* 是否支持stbc */
437 hi_u8 wapi;
438 hi_u32 timestamp; /* 更新此bss的时间戳 */
439
440 /* 管理帧信息 */
441 hi_u32 mgmt_len; /* 管理帧的长度 */
442 hi_u8 auc_mgmt_buff[4]; /* 4 byte 记录beacon帧或probe rsp帧 */
443 } mac_bss_dscr_stru;
444
445 typedef struct {
446 hi_u32 tx_seqnum; /* 最近一次tx上报的SN号 */
447 hi_u16 us_seqnum_used_times; /* 软件使用了ul_tx_seqnum的次数 */
448 hi_u16 us_incr_constant; /* 维护非Qos 分片帧的递增常量 */
449 } mac_tx_seqnum_struc;
450
451 typedef struct {
452 hi_u64 ull_send_action_id; /* P2P action id/cookie */
453 hi_u64 ull_last_roc_id;
454 hi_u8 p2p_device_num:4, /* 当前device下的P2P_DEVICE数量 MAX 1 */
455 p2p_goclient_num:4; /* 当前device下的P2P_CL/P2P_GO数量 MAX 1 */
456 hi_u8 p2p0_vap_idx;
457 /* P2P0/P2P_CL 共用VAP 结构,监听场景下保存VAP 进入监听前的状态 */
458 mac_vap_state_enum_uint8 last_vap_state;
459 hi_u8 p2p_ps_pause; /* P2P 节能是否处于pause状态 */
460 oal_net_device_stru *pst_p2p_net_device;
461 oal_nl80211_channel_type_uint8 listen_channel_type;
462 hi_u8 resv[3]; /* reserve 3byte */
463 oal_ieee80211_channel_stru st_listen_channel;
464 } mac_p2p_info_stru;
465
466 /* device结构体 */
467 typedef struct {
468 /* device下的vap,此处只记录VAP ID */
469 hi_u8 auc_vap_id[WLAN_SERVICE_VAP_NUM_PER_DEVICE];
470 hi_u8 vap_num : 3, /* 当前device下的业务VAP数量(AP+STA) MAX 3 */
471 sta_num : 3, /* 当前device下的STA数量 MAX 2 */
472 reset_in_progress : 1, /* 复位处理中 */
473 /* 标识是否已经被分配,(HI_TRUE初始化完成,HI_FALSE未初始化 ) */
474 device_state : 1;
475 /* 从eeprom或flash获得的mac地址,ko加载时调用hal接口赋值 */
476 hi_u8 auc_hw_addr[WLAN_MAC_ADDR_LEN];
477 /* 已配置VAP的信道号,其后的VAP配置值不能与此值矛盾,仅在非DBAC时使用 */
478 hi_u8 max_channel;
479 /* 已配置VAP的频段,其后的VAP配置值不能与此值矛盾,仅在非DBAC时使用 */
480 wlan_channel_band_enum_uint8 max_band;
481
482 /* 已配置VAP的最带带宽值,其后的VAP配置值不能与此值矛盾,仅在非DBAC时使用 */
483 wlan_channel_bandwidth_enum_uint8 max_bandwidth;
484 wlan_protocol_cap_enum_uint8 protocol_cap; /* 协议能力 */
485 wlan_band_cap_enum_uint8 band_cap; /* 频段能力 */
486 wlan_bw_cap_enum_uint8 bandwidth_cap; /* 带宽能力 */
487
488 hi_u8 wmm : 1, /* wmm使能开关 */
489 reset_switch : 1, /* 是否使能复位功能 */
490 dbac_same_ch : 1, /* 是否同信道dbac */
491 in_suspend : 1,
492 dbac_enabled : 1,
493 dbac_running : 1, /* DBAC是否在运行 */
494 dbac_has_vip_frame : 1, /* 标记DBAC运行时收到了关键帧 */
495 arpoffload_switch : 1;
496 hi_u8 ldpc_coding : 1, /* 是否支持接收LDPC编码的包 */
497 tx_stbc : 1, /* 是否支持最少2x1 STBC发送 */
498 rx_stbc : 3, /* 是否支持stbc接收 */
499 promis_switch : 1, /* 混杂模式开关 */
500 mu_bfmee : 1, /* 是否支持多用户beamformee */
501 resv : 1;
502 hi_s16 s_upc_amend; /* UPC修正值 */
503 hi_u32 duty_ratio_lp; /* 进入低功耗前发送占空比 */
504 hi_u32 rx_nondir_duty_lp; /* 进入低功耗前接收non-direct包的占空比 */
505 hi_u32 rx_dir_duty_lp; /* 进入低功耗前接收direct包的占空比 */
506 hi_u32 beacon_interval; /* device级别beacon interval,device下所有VAP约束为同一值 */
507 hi_u32 duty_ratio; /* 占空比统计 */
508
509 mac_data_rate_stru mac_rates_11g[MAC_DATARATES_PHY_80211G_NUM]; /* 11g速率 */
510 mac_pno_sched_scan_mgmt_stru *pno_sched_scan_mgmt; /* pno调度扫描管理结构体指针,内存动态申请,从而节省内存 */
511 mac_scan_req_stru scan_params; /* 最新一次的扫描参数信息 */
512 frw_timeout_stru scan_timer; /* 扫描定时器用于切换信道 */
513 frw_timeout_stru obss_scan_timer; /* obss扫描定时器,循环定时器 */
514 mac_channel_stru p2p_vap_channel; /* p2p listen时记录p2p的信道,用于p2p listen结束后恢复 */
515 frw_timeout_stru go_scan_timer;
516 frw_timeout_stru keepalive_timer; /* keepalive定时器 */
517
518 hi_u8 tid;
519 hi_u8 asoc_user_cnt; /* 关联用户数 */
520 hi_u8 wapi;
521 hi_u8 sar_pwr_limit; /* CE认证SAR标准最大功率限制 */
522 /* linux内核中的device物理信息 */
523 /* 用于存放和VAP相关的wiphy设备信息,在AP/STA模式下均要使用;可以多个VAP对应一个wiphy */
524 oal_wiphy_stru *wiphy;
525
526 /* 针对Device的成员,可移动到dmac_device OFFLOAD模式下可用DEVICE包含 */
527 hi_u8 scan_chan_idx; /* 当前扫描信道索引 */
528 /* 当前扫描状态,根据此状态处理obss扫描和host侧下发的扫描请求,以及扫描结果的上报处理 */
529 mac_scan_state_enum_uint8 curr_scan_state;
530 hi_u8 auc_original_mac_addr[WLAN_MAC_ADDR_LEN]; /* 扫描开始前保存原始的MAC地址 */
531 mac_channel_stru home_channel; /* 记录工作信道 供切回时使用 */
532 mac_scan_chan_stats_stru chan_result; /* dmac扫描时 一个信道的信道测量记录 */
533 mac_fcs_mgr_stru fcs_mgr;
534 mac_p2p_info_stru p2p_info; /* P2P 相关信息 */
535 /* 每个AP发送一次CSA帧,该计数加1。AP切换完信道后,该计数清零 */
536 hi_u8 csa_cnt;
537 hi_u8 txop_enable; /* 发送无聚合时采用TXOP模式 */
538 hi_u8 tx_ba_num; /* 发送方向BA会话个数 */
539 hi_u8 nss_num;
540 hi_u32 auc_resv; /* 预留字段 */
541 } mac_device_stru;
542
543 #pragma pack(push, 1)
544 /* 上报的扫描结果的扩展信息,放在上报host侧的管理帧netbuf的后面 */
545 typedef struct {
546 hi_s32 l_rssi; /* 信号强度 */
547 wlan_mib_desired_bsstype_enum_uint8 bss_type; /* 扫描到的bss类型 */
548 hi_u8 channel; /* 当前扫描的信道 */
549 hi_u8 auc_resv[2]; /* 2 byte预留字段 */
550 } mac_scanned_result_extend_info_stru;
551 #pragma pack(pop)
552
553 typedef struct {
554 mac_device_stru *mac_device;
555 } mac_wiphy_priv_stru;
556
557 /* ****************************************************************************
558 内联函数
559 **************************************************************************** */
560 /* ****************************************************************************
561 函 数 名 : mac_is_dbac_running
562 功能描述 : 判断对应device上dbac功能是否在运行
563 输入参数 : mac_device_stru *pst_device
564 返 回 值 : static inline hi_u8
565 修改历史 :
566 1.日 期 : 2014年7月8日
567 作 者 : HiSilicon
568 修改内容 : 新生成函数
569 **************************************************************************** */
mac_is_dbac_running(const mac_device_stru * mac_dev)570 static inline hi_u8 mac_is_dbac_running(const mac_device_stru *mac_dev)
571 {
572 return mac_dev->dbac_enabled && mac_dev->dbac_running;
573 }
574
575 /* ****************************************************************************
576 功能描述 : 数据帧是否需要入tid队列
577 输入参数 : mac_device_stru *pst_device
578 mac_vap_stru *pst_vap
579 修改历史 :
580 1.日 期 : 2014年7月8日
581 作 者 : HiSilicon
582 修改内容 : 新生成函数
583 **************************************************************************** */
mac_need_enqueue_tid_for_dbac(const mac_device_stru * mac_dev,const mac_vap_stru * mac_vap)584 static inline hi_u8 mac_need_enqueue_tid_for_dbac(const mac_device_stru *mac_dev, const mac_vap_stru *mac_vap)
585 {
586 return (mac_dev->dbac_enabled && (mac_vap->vap_state == MAC_VAP_STATE_PAUSE));
587 }
588
mac_device_is_scaning(const mac_device_stru * mac_dev)589 static inline hi_u8 mac_device_is_scaning(const mac_device_stru *mac_dev)
590 {
591 return (mac_dev->curr_scan_state == MAC_SCAN_STATE_RUNNING);
592 }
593
mac_device_is_listening(const mac_device_stru * mac_dev)594 static inline hi_u8 mac_device_is_listening(const mac_device_stru *mac_dev)
595 {
596 return ((mac_dev->curr_scan_state == MAC_SCAN_STATE_RUNNING) &&
597 (mac_dev->scan_params.scan_func & MAC_SCAN_FUNC_P2P_LISTEN));
598 }
599
mac_device_set_channel(mac_device_stru * mac_dev,const mac_cfg_channel_param_stru * channel_param)600 static inline hi_void mac_device_set_channel(mac_device_stru *mac_dev, const mac_cfg_channel_param_stru *channel_param)
601 {
602 mac_dev->max_channel = channel_param->channel;
603 mac_dev->max_band = channel_param->band;
604 mac_dev->max_bandwidth = channel_param->en_bandwidth;
605 }
606
mac_device_get_channel(const mac_device_stru * mac_dev,mac_cfg_channel_param_stru * channel_param)607 static inline hi_void mac_device_get_channel(const mac_device_stru *mac_dev, mac_cfg_channel_param_stru *channel_param)
608 {
609 channel_param->channel = mac_dev->max_channel;
610 channel_param->band = mac_dev->max_band;
611 channel_param->en_bandwidth = mac_dev->max_bandwidth;
612 }
613
614 /* ****************************************************************************
615 函数声明
616 **************************************************************************** */
617 mac_device_stru *mac_res_get_dev(hi_void);
618 const hi_u8 *mac_get_mac_bcast_addr(hi_void);
619 hi_void mac_device_init(mac_device_stru *mac_dev);
620 hi_void mac_device_set_vap_id(mac_device_stru *mac_dev, mac_vap_stru *mac_vap,
621 const mac_cfg_add_vap_param_stru *param, hi_u8 vap_idx, hi_u8 is_add_vap);
622 hi_void mac_device_find_up_vap(const mac_device_stru *mac_dev, mac_vap_stru **mac_vap);
623 hi_u8 mac_device_has_other_up_vap(const mac_device_stru *mac_dev, const mac_vap_stru *mac_vap_ref);
624 hi_u32 mac_device_calc_up_vap_num(const mac_device_stru *mac_dev);
625 hi_u32 mac_device_find_up_vap_with_mode(const mac_device_stru *mac_dev, mac_vap_stru **mac_vap,
626 wlan_vap_mode_enum_uint8 vap_mode);
627 hi_u32 mac_device_find_up_p2p_go(const mac_device_stru *mac_dev, mac_vap_stru **mac_vap);
628 hi_u32 mac_device_find_2up_vap(const mac_device_stru *mac_dev, mac_vap_stru **mac_vap1, mac_vap_stru **mac_vap2);
629 hi_u32 mac_device_is_p2p_connected(const mac_device_stru *mac_dev);
630
631 hi_void mac_fcs_release(mac_fcs_mgr_stru *fcs_mgr);
632 hi_u8 mac_fcs_get_protect_cnt(const mac_vap_stru *mac_vap);
633 hi_u32 mac_fcs_get_prot_datarate(const mac_vap_stru *mac_vap);
634 hi_u8 mac_fcs_get_fake_q_id(const mac_vap_stru *mac_vap);
635
636 hi_void mac_fcs_init(mac_fcs_mgr_stru *fcs_mgr);
637 mac_fcs_err_enum_uint8 mac_fcs_request(mac_fcs_mgr_stru *fcs_mgr);
638
639 #ifdef __cplusplus
640 #if __cplusplus
641 }
642 #endif
643 #endif
644
645 #endif /* __MAC_DEVICE_H__ */
646