• 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  * 文 件 名   : hmac_dfs.h
15  * 生成日期   : 2014年10月16日
16  * 功能描述   : hmac_dfs.c 的头文件
17  */
18 
19 #ifndef __HMAC_DFS_H__
20 #define __HMAC_DFS_H__
21 
22 #ifdef _PRE_WLAN_FEATURE_DFS
23 
24 /*****************************************************************************
25   1 其他头文件包含
26 *****************************************************************************/
27 #include "oal_ext_if.h"
28 #include "frw_ext_if.h"
29 #include "mac_device_ext.h"
30 #include "hmac_vap.h"
31 #include "hmac_scan.h"
32 #include "hmac_feature_main.h"
33 
34 #ifdef __cplusplus
35 #if __cplusplus
36 extern "C" {
37 #endif
38 #endif
39 
40 #undef  THIS_FILE_ID
41 #define THIS_FILE_ID OAM_FILE_ID_HMAC_DFS_H
42 
43 /*****************************************************************************
44   2 宏定义
45 *****************************************************************************/
46 #define HMAC_DFS_ONE_SEC_IN_MS    1000
47 #define HMAC_DFS_ONE_MIN_IN_MS    (60 * HMAC_DFS_ONE_SEC_IN_MS)
48 
49 /* CAC检测时长,5600MHz ~ 5650MHz频段外,默认60秒 */
50 #define HMAC_DFS_CAC_OUTOF_5600_TO_5650_MHZ_TIME_MS           HMAC_DFS_ONE_MIN_IN_MS
51 
52 /* CAC检测时长,5600MHz ~ 5650MHz频段内,默认10分钟 */
53 #define HMAC_DFS_CAC_IN_5600_TO_5650_MHZ_TIME_MS              (10 * HMAC_DFS_ONE_MIN_IN_MS)
54 
55 /* Off-Channel CAC检测时长,5600MHz ~ 5650MHz频段外,默认6分钟 */
56 #define HMAC_DFS_OFF_CH_CAC_OUTOF_5600_TO_5650_MHZ_TIME_MS    (6 * HMAC_DFS_ONE_MIN_IN_MS)
57 
58 /* Off-Channel CAC检测时长,5600MHz ~ 5650MHz频段内,默认60分钟 */
59 #define HMAC_DFS_OFF_CH_CAC_IN_5600_TO_5650_MHZ_TIME_MS       (60 * HMAC_DFS_ONE_MIN_IN_MS)
60 
61 /* Non-Occupancy Period时长,默认30分钟 */
62 #define HMAC_DFS_NON_OCCUPANCY_PERIOD_TIME_MS                 (30 * HMAC_DFS_ONE_MIN_IN_MS)
63 
64 /* Off-Channel CAC在工作信道上的驻留时长 */
65 #define HMAC_DFS_OFF_CHAN_CAC_PERIOD_TIME_MS                  15
66 
67 /* Off-channel CAC在Off-channel信道上的驻留时长 */
68 #define HMAC_DFS_OFF_CHAN_CAC_DWELL_TIME_MS                   30
69 
70 #if defined (_PRE_WLAN_FEATURE_DFS_OPTIMIZE) || defined (_PRE_WLAN_FEATURE_DFS_ENABLE)
71 #define ETSI_RADAR_CHIRP_CNT       1        /* ETSI chirp雷达中断阈值 */
72 #define FCC_RADAR_CHIRP_CNT        3        /* FCC chirp雷达中断阈值 */
73 #define MKK_RADAR_CHIRP_CNT        3        /* MKK chirp雷达中断阈值 */
74 #else
75 #define ETSI_RADAR_CHIRP_CNT       3        /* ETSI chirp雷达中断阈值 */
76 #define FCC_RADAR_CHIRP_CNT        4        /* FCC chirp雷达中断阈值 */
77 #define MKK_RADAR_CHIRP_CNT        4        /* MKK chirp雷达中断阈值 */
78 #endif
79 
80 #define DFS_CAC_CTRL_TX_CLOSE_WITH_VAP_PAUSE 0
81 #define DFS_CAC_CTRL_TX_OPEN_WITH_VAP_UP 1
82 #define DFS_CAC_CTRL_TX_OPEN 2
83 #define DFS_CAC_CTRL_TX_CLOSE 3
84 /*****************************************************************************
85   3 枚举定义
86 *****************************************************************************/
87 
88 /*****************************************************************************
89   4 全局变量声明
90 *****************************************************************************/
91 
92 /*****************************************************************************
93   5 消息头定义
94 *****************************************************************************/
95 
96 /*****************************************************************************
97   6 消息定义
98 *****************************************************************************/
99 
100 /*****************************************************************************
101   7 STRUCT定义
102 *****************************************************************************/
103 typedef oal_bool_enum_uint8 (*p_dmac_radar_filter_cb)(frw_msg *msg);
104 typedef struct {
105     p_dmac_radar_filter_cb hmac_radar_filter;
106 } hmac_chan_mgmt_rom_cb;
107 
108 typedef struct {
109     oal_bool_enum_uint8  dfs_switch;                          /* DFS使能开关
110                                                                     bit0:dfs使能,
111                                                                     bit1:标示AP因为DFS特性暂时处于邋wait_start */
112     oal_bool_enum_uint8  cac_switch;
113     oal_bool_enum_uint8  offchan_cac_switch;
114     osal_u8              debug_level;                         /* bit0:打印雷达带业务,bit1:打印雷达无业务 */
115     osal_u8              offchan_flag;                        /* bit0:0表示homechan,1表示offchan;
116                                                                     bit1:0表示普通,1表示offchancac */
117     osal_u8              offchan_num;
118     osal_u8              timer_cnt;
119     osal_u8              timer_end_cnt;
120     osal_u8              cts_duration;
121     osal_u8              hmac_channel_flag;                   /* dmac用于标示当前信道off or home */
122     oal_bool_enum_uint8  dfs_init;
123     osal_u8              custom_next_chnum;                   /* 应用层指定的DFS下一跳信道号 */
124     osal_u32             dfs_cac_outof_5600_to_5650_time_ms;  /* CAC检测时长.5600MHz ~ 5650MHz频段外.默认60秒 */
125     osal_u32             dfs_cac_in_5600_to_5650_time_ms;     /* CAC检测时长.5600MHz ~ 5650MHz频段内.默认10分钟 */
126     osal_u32             off_chan_cac_outof_5600_to_5650_time_ms; /* Off-Channel CAC检测时长
127                                                                         5600MHz ~ 5650MHz频段外.默认6分钟 */
128     osal_u32             off_chan_cac_in_5600_to_5650_time_ms;    /* Off-Channel CAC检测时长
129                                                                         5600MHz ~ 5650MHz频段内.默认60分钟 */
130     osal_u16             dfs_off_chan_cac_opern_chan_dwell_time;  /* Off-channel CAC在工作信道上驻留时长 */
131     osal_u16             dfs_off_chan_cac_off_chan_dwell_time;    /* Off-channel CAC在Off-Channel信道上驻留时长 */
132     osal_u32             radar_detected_timestamp;
133     osal_s32             l_radar_th;                                 /* 设置的雷达检测门限,单位db */
134 
135     osal_u32             custom_chanlist_bitmap;                  /* 应用层同步下来的信道列表
136                                                                         (0x0000000F 36-48)   (0x000000F0 52-64)
137                                                                         (0x000FFF00 100-144) (0x01F00000 149-165) */
138     wlan_channel_bandwidth_enum_uint8   next_ch_width_type;       /* 设置的下一跳信道的带宽模式 */
139     osal_u8              uac_resv[3];
140     osal_u32             dfs_non_occupancy_period_time_ms;
141     osal_u8              _rom[4];
142 } mac_dfs_info_stru;
143 
144 typedef struct {
145     osal_u8             chan_idx;            /* 信道索引 */
146     osal_u8             device_id;           /* device id */
147     osal_u8             auc_resv[2];
148     frw_timeout_stru      dfs_nol_timer;     /* NOL节点定时器 */
149     struct osal_list_head   entry;             /* NOL链表 */
150 } mac_dfs_nol_node_stru;
151 
152 typedef struct {
153     frw_timeout_stru      dfs_cac_timer;                   /* CAC定时器 */
154     frw_timeout_stru      dfs_off_chan_cac_timer;          /* Off-Channel CAC定时器 */
155     frw_timeout_stru      dfs_chan_dwell_timer;            /* 信道驻留定时器,定时器到期,切离该信道 */
156     frw_timeout_stru      dfs_radar_timer;
157     mac_dfs_info_stru     dfs_info;
158     struct osal_list_head   dfs_nol;
159     osal_u16 dfs_timeout;
160     osal_u8 resv[2]; /* 保留2字节对齐 */
161     osal_u32 dfs_cnt; /* 检测到的雷达个数 */
162 } mac_dfs_core_stru;
163 /*****************************************************************************
164   8 UNION定义
165 *****************************************************************************/
166 
167 /*****************************************************************************
168   9 OTHERS定义
169 *****************************************************************************/
170 
171 
172 /*****************************************************************************
173   10 函数声明
174 *****************************************************************************/
175 extern osal_void hmac_dfs_init(hmac_device_stru *hmac_device);
176 extern osal_void hmac_dfs_deinit(hmac_device_stru *hmac_device);
177 extern osal_void hmac_dfs_channel_list_init_etc(hmac_device_stru *hmac_device);
178 extern osal_u32 hmac_dfs_recalculate_channel_etc(hmac_device_stru *hmac_device, osal_u8 *freq,
179     wlan_channel_bandwidth_enum_uint8 *pen_bandwidth);
180 extern osal_void hmac_dfs_cac_start_etc(hmac_device_stru *hmac_device, hmac_vap_stru *hmac_vap);
181 extern osal_void hmac_dfs_cac_stop_etc(hmac_device_stru *hmac_device, hmac_vap_stru *hmac_vap, osal_u8 cac_tx_en);
182 extern osal_void hmac_dfs_off_cac_stop_etc(hmac_device_stru *hmac_device, hmac_vap_stru *hmac_vap);
183 extern osal_s32 hmac_dfs_radar_detect_event_etc(hmac_vap_stru *hmac_vap);
184 extern osal_u32 hmac_dfs_radar_detect_event_test(osal_u8 vap_id);
185 extern osal_u32 hmac_dfs_ap_wait_start_radar_handler_etc(hmac_vap_stru *hmac_vap);
186 extern osal_u32 hmac_dfs_ap_up_radar_handler_etc(hmac_vap_stru *hmac_vap);
187 extern osal_void hmac_dfs_radar_wait_etc(hmac_device_stru *hmac_device, hmac_vap_stru *hmac_vap);
188 extern osal_void test_dfs(osal_u8 vap_id);
189 extern osal_u32 hmac_dfs_start_bss_etc(hmac_vap_stru *hmac_vap);
190 extern osal_void hmac_dfs_off_chan_cac_start_etc(hmac_device_stru *hmac_device, hmac_vap_stru *hmac_vap);
191 extern oal_bool_enum_uint8 hmac_dfs_try_cac_etc(hmac_device_stru *hmac_device, hmac_vap_stru *hmac_vap);
192 extern osal_u32 hmac_dfs_init_scan_hook_etc(hmac_scan_record_stru    *scan_record,
193     hmac_device_stru *hmac_device);
194 extern oal_bool_enum_uint8 mac_vap_get_dfs_enable(hmac_vap_stru *hmac_vap);
195 void mac_dfs_set_cac_enable(hmac_device_stru *hmac_device, oal_bool_enum_uint8 val);
196 void mac_dfs_set_offchan_cac_enable(hmac_device_stru *hmac_device, oal_bool_enum_uint8 val);
197 oal_bool_enum_uint8 mac_dfs_get_offchan_cac_enable(hmac_device_stru *hmac_device);
198 oal_bool_enum_uint8 mac_dfs_get_cac_enable(hmac_device_stru *hmac_device);
199 void mac_dfs_set_dfs_enable(hmac_device_stru *hmac_device, oal_bool_enum_uint8 val);
200 oal_bool_enum_uint8 mac_dfs_get_dfs_enable(  hmac_device_stru *hmac_device);
201 void mac_dfs_set_debug_level(hmac_device_stru *hmac_device, osal_u8 debug_lev);
202 osal_u8 mac_dfs_get_debug_level(hmac_device_stru *hmac_device);
203 osal_void hmac_dfs_radar_detect_check(hal_to_dmac_device_stru *hal_device, hmac_device_stru *hmac_device,
204     const hmac_vap_stru *hmac_vap);
205 osal_s32 hmac_cac_chan_ctrl_machw_tx_event_process(hmac_vap_stru *hmac_vap, osal_u8 cac_machw_en);
206 osal_s32 hmac_dfs_radar_detect_event(hmac_vap_stru *hmac_vap, frw_msg *msg);
207 osal_s32  hmac_config_set_country_for_dfs(hmac_vap_stru *hmac_vap, frw_msg *msg);
208 osal_void hmac_config_cali_dfs_handle(hal_to_dmac_device_stru *hal_device, hmac_vap_stru *hmac_vap,
209     const hmac_device_stru *hmac_device);
210 extern osal_void hmac_cac_chan_ctrl_machw_tx(hmac_vap_stru *hmac_vap, osal_u8 cac_machw_en);
211 osal_bool hmac_is_dfs_with_dbac_check(const hmac_vap_stru *hmac_vap, const hmac_device_stru *mac_device,
212     const osal_u8 channel);
213 oal_bool_enum_uint8  hmac_dfs_need_for_cac(hmac_device_stru *hmac_device, hmac_vap_stru *hmac_vap);
214 #ifdef __cplusplus
215 #if __cplusplus
216 }
217 #endif
218 #endif
219 
220 #endif   /* end of _PRE_WLAN_FEATURE_DFS */
221 
222 #endif /* end of hmac_dfs.h */
223