• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __HMAC_WOW_H__
20 #define __HMAC_WOW_H__
21 
22 /* ****************************************************************************
23   1 其他头文件包含
24 **************************************************************************** */
25 #include "oal_ext_if.h"
26 #include "frw_event.h"
27 #include "mac_device.h"
28 #include "hmac_device.h"
29 #include "mac_vap.h"
30 
31 #ifdef __cplusplus
32 #if __cplusplus
33 extern "C" {
34 #endif
35 #endif
36 
37 /* ****************************************************************************
38   2 宏定义
39 **************************************************************************** */
40 #define WOW_H2D_SLP_MSG_CNT     (g_wow_info.debug_info.int_info.h2d_slp_msg_cnt)
41 #define WOW_H2D_WKUP_MSG_CNT    (g_wow_info.debug_info.int_info.h2d_wkup_msg_cnt)
42 #define WOW_D2H_MSG_CNT         (g_wow_info.debug_info.int_info.d2h_msg_cnt)
43 
44 #define WOW_H2D_SLP_MSG             0
45 #define WOW_H2D_WKUP_MSG            1
46 #define WOW_D2H_MSG                 2
47 
48 #define WOW_SLEEP_REQ_WAIT_TIMEOUT  (3000)
49 /* 寄存器时间转换ms */
50 #define calc_time_test_func(time) ((0xffffffff - (time)) * 256 / 50000)
51 /* ****************************************************************************
52   3 枚举定义
53 **************************************************************************** */
54 typedef enum {
55     HMAC_HOST_STATE_INVALID,
56     HMAC_HOST_STATE_WAKEUP,
57     HMAC_HOST_STATE_SLEEP_REQ,
58     HMAC_HOST_STATE_DEV_READY_FOR_HOST_SLEEP,
59     HMAC_HOST_STATE_HOST_READY,
60     HMAC_HOST_STATE_SLEPT,
61     HMAC_HOST_STATE_BUTT
62 } hmac_host_sleep_state_enum;
63 typedef hi_u8 hmac_host_sleep_state_enum_uint8;
64 
65 typedef enum {
66     MAC_WOW_PATTERN_PARAM_OPTION_NONE,
67     MAC_WOW_PATTERN_PARAM_OPTION_CLR,
68     MAC_WOW_PATTERN_PARAM_OPTION_ADD,
69     MAC_WOW_PATTERN_PARAM_OPTION_DEL,
70     MAC_WOW_PATTERN_PARAM_OPTION_BUTT
71 } mac_wow_pattern_param_option_enum;
72 
73 typedef enum {
74     EVENT_TX_TYPE,
75     EVENT_RX_TYPE,
76     EVENT_DUAL_TYPE,
77     EVENT_TYPE_BUTT
78 } mac_event_type_enum;
79 typedef hi_u8 mac_event_type_enum_uint8;
80 
81 typedef enum {
82     HMAC_WOW_MODULE_STATE_NOT_INIT = 0,
83     HMAC_WOW_MODULE_STATE_INIT     = 1,
84     HMAC_WOW_MODULE_BUTT
85 } hmac_wow_init_state_enum;
86 typedef hi_u8 hmac_wow_init_state_enum_uint8;
87 
88 /* ****************************************************************************
89   7 STRUCT定义
90 **************************************************************************** */
91 typedef struct {
92     hi_u16      us_pattern_option;
93     hi_u16      us_pattern_index;
94     hi_u32      pattern_len;
95     hi_u8       auc_pattern_value[WOW_NETPATTERN_MAX_LEN];
96 } hmac_cfg_wow_pattern_param_stru;
97 
98 typedef struct {
99     hi_u8                     ssid_set_flag;
100     hi_s8                      ac_ssid[WLAN_SSID_MAX_LEN]; /* 32+1 */
101     hi_u16                    us_pno_period;
102     hi_u8                     channel_num;
103     hi_u8                     auc_res[3]; /* 3 保留字节 */
104 } hmac_cfg_wow_ssid_param_stru;
105 
106 typedef struct {
107     hi_u8 tx_cnt;
108     hi_u8 rx_cnt;
109     hi_u8 dual_cnt;
110     hi_u8 res;
111 } hmac_wow_event_stru;
112 
113 typedef struct {
114     hi_u32 h2d_slp_msg_cnt;
115     hi_u32 h2d_wkup_msg_cnt;
116     hi_u32 d2h_msg_cnt;
117 } hmac_wow_int_stru;
118 
119 typedef struct {
120     hmac_wow_event_stru event_info;
121     hmac_wow_int_stru int_info;
122 } hmac_wow_debug_info_stru;
123 
124 typedef struct {
125     hmac_host_sleep_state_enum_uint8    host_sleep_state;
126     hi_u8                           is_wow_init;
127     hi_u8                           wait_dev_data;
128     hi_u8                           get_flag;
129     hi_u32                          wakeup_reason;
130     mac_wow_cfg_stu                 wow_cfg;
131 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
132     oal_completion                  sleep_req_done_event;
133 #elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
134     hi_u32                          sleep_req_done_event;
135 #endif
136     hmac_wow_debug_info_stru        debug_info;
137 } hmac_wow_info_stru;
138 
139 /* ****************************************************************************
140   10 函数声明
141 **************************************************************************** */
142 hi_void hmac_wow_set_host_state(hi_u8 sleep_state);
143 hi_u8 hmac_wow_get_host_state(hi_void);
144 hi_void hmac_wow_init(hi_void);
145 hi_void *hmac_wow_get_cfg_vap(hi_void);
146 hi_u32 hmac_wow_tx_check_filter_switch(hi_void);
147 hi_void hmac_wow_stop_scan_assoc(hi_void);
148 hi_void hmac_wow_stop_upper_layer_queue(hi_void);
149 hi_void hmac_wow_clear_data_channal(hi_void);
150 hi_void hmac_wow_clear_event_queue(hi_void);
151 hi_void hmac_wow_prepare_wakeup(hi_void);
152 hi_void hmac_wow_host_sleep_cmd(mac_vap_stru *mac_vap, hi_u32 is_host_sleep);
153 hi_void hmac_wow_set_wow_cmd(hi_u32 wow_event);
154 hi_void hmac_wow_set_wow_en_cmd(hi_u32 wow_en);
155 hi_u32 hmac_wow_add_pattern(hi_u16 us_pattern_index, hi_u32 pattern_len, const hi_u8 *puc_pattern);
156 hi_u32 hmac_wow_set_pattern_cmd(const hmac_cfg_wow_pattern_param_stru *pattern);
157 hi_void hmac_wow_host_sleep_request(hi_void);
158 hi_void hmac_wow_host_wakeup_notify(hi_void);
159 hi_void hmac_wow_create_lock(hi_void);
160 hi_void hmac_wow_obtain_lock(hi_void);
161 hi_void hmac_wow_release_lock(hi_void);
162 hi_s32 hmac_wow_completion(hi_void *data);
163 hi_void hmac_wow_trigger_host_state(hi_void);
164 hi_u32 hmac_wow_proc_dev_ready_slp_event(frw_event_mem_stru *event_mem);
165 hi_u32 hmac_wow_proc_dev_sync_host_event(frw_event_mem_stru *event_mem);
166 hi_u32 hmac_wow_set_dmac_cfg(hi_void);
167 hi_u32 hmac_wow_host_sleep_wakeup_notify(hi_u8 is_sleep_req);
168 hi_void wlan_suspend(hi_void);
169 hi_void wlan_resume(hi_void);
170 hi_void wlan_wifi_suspend(hi_void);
171 hi_void wlan_wifi_resume(hi_void);
172 hi_void hmac_wow_proc_dev_ready_slp(hi_void);
173 hi_s32 hmac_wow_msg_handle(hi_void);
174 hi_u32 hmac_wow_check_event(const frw_event_hdr_stru *event_hrd, hi_u8 event_dir);
175 hi_u32 hmac_wow_send_h2d_sync_data(hi_void);
176 hi_s32 hmac_save_wow(hi_void);
177 hi_s32 hmac_recover_wow(hi_void);
178 hi_void hmac_wow_msg_incr(hi_u32 msg_type);
179 
180 /* ****************************************************************************
181  函 数 名  : hisi_wlan_suspend
182  功能描述  : 强制睡眠 API接口
183  输入参数  : 无
184  输出参数  : 无
185  返 回 值  : 无
186  调用函数  :
187  被调函数  :
188 
189  修改历史      :
190   1.日    期   : 2017年01月05日
191     作    者   : HiSilicon
192     修改内容   : 新生成函数
193 
194 **************************************************************************** */
195 hi_void hisi_wlan_suspend(hi_void);
196 
197 /* ****************************************************************************
198  函 数 名  : hisi_wlan_set_wow_event
199  功能描述  : 设置强制睡眠功能开关接口
200  输入参数  : ul_event 事件开关值
201  输出参数  : 无
202  返 回 值  : 无
203  调用函数  :
204  被调函数  :
205 
206  修改历史      :
207   1.日    期   : 2017年01月05日
208     作    者   : HiSilicon
209     修改内容   : 新生成函数
210 
211 **************************************************************************** */
212 hi_void hisi_wlan_set_wow_event(hi_u32 event);
213 
214 /* ****************************************************************************
215  函 数 名  : hisi_wlan_add_netpattern
216  功能描述  : 强制睡眠netpattern唤醒报文格式的添加API接口
217  输入参数  : [1]netpattern_index: netpattern 的索引, 0~3
218              [2]puc_netpattern_data: netpattern 的内容
219              [3]netpattern_len: netpattern 的内容长度, 0~64
220  输出参数  : 无
221  返 回 值  : 0  : 成功
222              非0: 失败
223 **************************************************************************** */
224 hi_u32 hisi_wlan_add_netpattern(hi_u32 netpattern_index, hi_uchar *puc_netpattern_data, hi_u32 netpattern_len);
225 
226 /* ****************************************************************************
227  函 数 名  : hisi_wlan_del_netpattern
228  功能描述  : 强制睡眠netpattern唤醒报文格式的删除API接口
229  输入参数  :    ul_netpattern_index: netpattern 的索引, 0~3
230  输出参数  : 无
231  返 回 值  : 0  : 成功
232              非0: 失败
233  调用函数  :
234  被调函数  :
235 
236  修改历史      :
237   1.日    期   : 2017年01月05日
238     作    者   : HiSilicon
239     修改内容   : 新生成函数
240 
241 **************************************************************************** */
242 hi_u32 hisi_wlan_del_netpattern(hi_u32 netpattern_index);
243 
244 /* ****************************************************************************
245  函 数 名  : hisi_wlan_get_wakeup_reason
246  功能描述  : 强制睡眠唤醒原因的获取API接口
247  输入参数  : * pul_wakeup_reason[OUT]: 唤醒原因
248  输出参数  : 无
249  返 回 值  : 0  : 成功
250              非0: 失败
251  调用函数  :
252  被调函数  :
253 
254  修改历史      :
255   1.日    期   : 2017年01月05日
256     作    者   : HiSilicon
257     修改内容   : 新生成函数
258 
259 **************************************************************************** */
260 hi_u32 hisi_wlan_get_wakeup_reason(hi_u32 *pul_wakeup_reason);
261 
262 #ifdef __cplusplus
263 #if __cplusplus
264 extern "C" {
265 #endif
266 #endif
267 #endif /* __HMAC_WOW_H__ */
268