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 /* ****************************************************************************
20 1 头文件包含
21 **************************************************************************** */
22 #include "oam_ext_if.h"
23 #include "mac_device.h"
24 #include "mac_resource.h"
25 #include "dmac_ext_if.h"
26 #include "hmac_device.h"
27 #include "hmac_wow.h"
28 #include "hmac_vap.h"
29 #include "wal_scan.h"
30 #include "oal_net.h"
31 #include "hcc_host.h"
32
33 #ifdef __cplusplus
34 #if __cplusplus
35 extern "C" {
36 #endif
37 #endif
38
39 #define WOW_HOST_TEST
40
41 /* ****************************************************************************
42 2 全局变量定义
43 **************************************************************************** */
44 hmac_wow_info_stru g_wow_info = { 0 };
45 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
46 oal_completion g_d2h_completion; /* 上电唤醒后wow模块device同步数据到host侧完成 */
47 #elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
48 hi_u32 g_d2h_completion; /* 上电唤醒后wow模块device同步数据到host侧完成 */
49 #endif
50 hi_u32 g_wow_enable_completion;
51 hi_u32 g_wlan_resume_wifi_init_flag = 0;
52
53 /* ****************************************************************************
54 函 数 名 : hmac_wow_set_host_state
55 功能描述 :
56 输入参数 : hi_u8 uc_sleep_state
57 输出参数 : 无
58 返 回 值 : 无
59 调用函数 :
60 被调函数 :
61
62 修改历史 :
63 1.日 期 : 2016年5月05日
64 作 者 : HiSilicon
65 修改内容 : 新生成函数
66
67 **************************************************************************** */
hmac_wow_set_host_state(hi_u8 sleep_state)68 hi_void hmac_wow_set_host_state(hi_u8 sleep_state)
69 {
70 oam_warning_log2(0, OAM_SF_WOW, "{hmac_wow_set_host_state::state[%d]->[%d]!}", g_wow_info.host_sleep_state,
71 sleep_state);
72 g_wow_info.host_sleep_state = sleep_state;
73 }
74
75 /* ****************************************************************************
76 函 数 名 : hmac_wow_get_host_state
77 功能描述 :
78 输入参数 : 无
79 输出参数 : 无
80 返 回 值 : hi_u8
81 调用函数 :
82 被调函数 :
83
84 修改历史 :
85 1.日 期 : 2016年5月05日
86 作 者 : HiSilicon
87 修改内容 : 新生成函数
88
89 **************************************************************************** */
hmac_wow_get_host_state(hi_void)90 hi_u8 hmac_wow_get_host_state(hi_void)
91 {
92 /* mutex */
93 return g_wow_info.host_sleep_state;
94 }
95
96 /* ****************************************************************************
97 函 数 名 : hmac_wow_init
98 功能描述 :
99 输入参数 : 无
100 输出参数 : 无
101 返 回 值 : 无
102 调用函数 :
103 被调函数 :
104
105 修改历史 :
106 1.日 期 : 2016年5月05日
107 作 者 : HiSilicon
108 修改内容 : 新生成函数
109
110 **************************************************************************** */
hmac_wow_init(hi_void)111 hi_void hmac_wow_init(hi_void)
112 {
113 hi_u32 ret;
114
115 if (g_wow_info.is_wow_init == HMAC_WOW_MODULE_STATE_INIT) {
116 return;
117 }
118 if (memset_s(&g_wow_info, sizeof(hmac_wow_info_stru), 0, sizeof(hmac_wow_info_stru)) != EOK) {
119 return;
120 }
121
122 if (!g_wlan_resume_wifi_init_flag) {
123 hmac_wow_set_host_state(HMAC_HOST_STATE_WAKEUP);
124 } else {
125 hmac_wow_set_host_state(HMAC_HOST_STATE_SLEPT);
126 }
127
128 g_wow_info.wow_cfg.wow_en = MAC_WOW_DISABLE;
129 g_wow_info.wow_cfg.wow_event = MAC_WOW_FIELD_MAGIC_PACKET | MAC_WOW_FIELD_NETPATTERN_TCP |
130 MAC_WOW_FIELD_NETPATTERN_UDP | MAC_WOW_FIELD_DISASSOC | MAC_WOW_FIELD_AUTH_RX;
131 hmac_wow_create_lock();
132
133 /* 下发参数到 DMAC */
134 if (!g_wlan_resume_wifi_init_flag) {
135 ret = hmac_wow_set_dmac_cfg();
136 if (ret != HI_SUCCESS) {
137 oam_warning_log0(0, OAM_SF_ANY, "hmac_wow_set_dmac_cfg return NON SUCCESS. ");
138 }
139 }
140
141 g_wow_info.is_wow_init = HMAC_WOW_MODULE_STATE_INIT;
142 }
143
144 /* ****************************************************************************
145 函 数 名 : hmac_wow_get_cfg_vap
146 功能描述 :
147 输入参数 : 无
148 输出参数 : 无
149 返 回 值 : hi_void*
150 调用函数 :
151 被调函数 :
152
153 修改历史 :
154 1.日 期 : 2016年5月05日
155 作 者 : HiSilicon
156 修改内容 : 新生成函数
157
158 **************************************************************************** */
hmac_wow_get_cfg_vap(hi_void)159 hi_void *hmac_wow_get_cfg_vap(hi_void)
160 {
161 return mac_vap_get_vap_stru(0);
162 }
163
164 /* ****************************************************************************
165 函 数 名 : hmac_wow_tx_check_filter_switch
166 功能描述 : 判断当前状态是否需要进入 wow 过滤接口
167 输入参数 :
168 输出参数 :
169 返 回 值 : hi_u32
170 调用函数 :
171 被调函数 :
172
173 修改历史 :
174 1.日 期 : 2016年4月5日
175 作 者 : HiSilicon
176 修改内容 : 新生成函数
177
178 **************************************************************************** */
hmac_wow_tx_check_filter_switch(hi_void)179 hi_u32 hmac_wow_tx_check_filter_switch(hi_void)
180 {
181 hi_u8 sleep_state;
182
183 sleep_state = hmac_wow_get_host_state();
184
185 if (g_wow_info.wow_cfg.wow_en == MAC_WOW_ENABLE) {
186 if ((sleep_state == HMAC_HOST_STATE_SLEEP_REQ) || (sleep_state == HMAC_HOST_STATE_DEV_READY_FOR_HOST_SLEEP) ||
187 (sleep_state == HMAC_HOST_STATE_HOST_READY) || (sleep_state == HMAC_HOST_STATE_SLEPT)) {
188 return HI_TRUE;
189 }
190 }
191
192 return HI_FALSE;
193 }
194
195 /* ****************************************************************************
196 函 数 名 : hmac_wow_stop_scan_assoc
197 功能描述 :
198 输入参数 : 无
199 输出参数 : 无
200 返 回 值 : 无
201 调用函数 :
202 被调函数 :
203
204 修改历史 :
205 1.日 期 : 2016年5月05日
206 作 者 : HiSilicon
207 修改内容 : 新生成函数
208
209 **************************************************************************** */
hmac_wow_stop_scan_assoc(hi_void)210 hi_void hmac_wow_stop_scan_assoc(hi_void)
211 {
212 hi_u32 netdev_index;
213 oal_net_device_stru *netdev = HI_NULL;
214
215 /* 停止扫描 */
216 for (netdev_index = 0; netdev_index < WLAN_VAP_NUM_PER_BOARD; netdev_index++) {
217 netdev = oal_get_past_net_device_by_index(netdev_index);
218 if (netdev != HI_NULL) {
219 wal_force_scan_complete(netdev);
220 }
221 }
222 }
223
224 /* ****************************************************************************
225 函 数 名 : hmac_wow_stop_upper_layer_queue
226 功能描述 :
227 输入参数 : 无
228 输出参数 : 无
229 返 回 值 : 无
230 调用函数 :
231 被调函数 :
232
233 修改历史 :
234 1.日 期 : 2016年5月05日
235 作 者 : HiSilicon
236 修改内容 : 新生成函数
237
238 **************************************************************************** */
hmac_wow_stop_upper_layer_queue(hi_void)239 hi_void hmac_wow_stop_upper_layer_queue(hi_void)
240 {
241 hi_u32 netdev_index;
242
243 for (netdev_index = 0; netdev_index < WLAN_VAP_NUM_PER_BOARD; netdev_index++) {
244 if (oal_get_past_net_device_by_index(netdev_index) != HI_NULL) {
245 /* stop the netdev's queues */
246 oal_net_tx_stop_all_queues(); /* 停止发送队列 */
247 }
248 }
249 }
250
251 /* ****************************************************************************
252 函 数 名 : hmac_wow_clear_data_channal
253 功能描述 :
254 输入参数 : 无
255 输出参数 : 无
256 返 回 值 : 无
257 调用函数 :
258 被调函数 :
259
260 修改历史 :
261 1.日 期 : 2016年5月05日
262 作 者 : HiSilicon
263 修改内容 : 新生成函数
264
265 **************************************************************************** */
hmac_wow_clear_data_channal(hi_void)266 hi_void hmac_wow_clear_data_channal(hi_void)
267 {
268 #ifdef _PRE_FEATURE_SDIO
269 hcc_clear_all_queues(hcc_host_get_handler(), HI_TRUE);
270 #endif
271 }
272
273 /* ****************************************************************************
274 函 数 名 : hmac_wow_clear_event_queue
275 功能描述 :
276 输入参数 : 无
277 输出参数 : 无
278 返 回 值 : 无
279 调用函数 :
280 被调函数 :
281
282 修改历史 :
283 1.日 期 : 2016年5月05日
284 作 者 : HiSilicon
285 修改内容 : 新生成函数
286
287 **************************************************************************** */
hmac_wow_clear_event_queue(hi_void)288 hi_void hmac_wow_clear_event_queue(hi_void)
289 {
290 /* 清理事件 */
291 }
292
293 /* ****************************************************************************
294 函 数 名 : hmac_wow_prepare_wakeup
295 功能描述 :
296 输入参数 : 无
297 输出参数 : 无
298 返 回 值 : 无
299 调用函数 :
300 被调函数 :
301
302 修改历史 :
303 1.日 期 : 2016年5月05日
304 作 者 : HiSilicon
305 修改内容 : 新生成函数
306
307 **************************************************************************** */
hmac_wow_prepare_wakeup(hi_void)308 hi_void hmac_wow_prepare_wakeup(hi_void)
309 {
310 /* wakeup 后操作 */
311 }
312
313 /* ****************************************************************************
314 函 数 名 : hmac_wow_host_sleep_cmd
315 功能描述 :
316 输入参数 : mac_vap_stru *pst_mac_vap
317 hi_u32 ul_is_host_sleep
318 输出参数 : 无
319 返 回 值 : 无
320 调用函数 :
321 被调函数 :
322
323 修改历史 :
324 1.日 期 : 2016年5月05日
325 作 者 : HiSilicon
326 修改内容 : 新生成函数
327
328 **************************************************************************** */
hmac_wow_host_sleep_cmd(mac_vap_stru * mac_vap,hi_u32 is_host_sleep)329 hi_void hmac_wow_host_sleep_cmd(mac_vap_stru *mac_vap, hi_u32 is_host_sleep)
330 {
331 hi_unref_param(mac_vap);
332
333 if (g_wow_info.wow_cfg.wow_en == MAC_WOW_DISABLE) {
334 oam_warning_log0(0, OAM_SF_WOW, "{hmac_wow_host_sleep_cmd::wow is not enabled.}");
335 return;
336 }
337
338 if (is_host_sleep == HI_TRUE) {
339 hmac_wow_host_sleep_request();
340 } else {
341 hmac_wow_host_wakeup_notify();
342 }
343 }
344
345 /* ****************************************************************************
346 函 数 名 : hmac_wow_set_wow_cmd
347 功能描述 :
348 输入参数 : hi_u32 ul_wow_event
349 输出参数 : 无
350 返 回 值 : 无
351 调用函数 :
352 被调函数 :
353
354 修改历史 :
355 1.日 期 : 2016年5月05日
356 作 者 : HiSilicon
357 修改内容 : 新生成函数
358
359 **************************************************************************** */
hmac_wow_set_wow_cmd(hi_u32 wow_event)360 hi_void hmac_wow_set_wow_cmd(hi_u32 wow_event)
361 {
362 hi_u32 ret;
363
364 if (g_wow_info.wow_cfg.wow_en == MAC_WOW_DISABLE) {
365 oam_warning_log0(0, OAM_SF_WOW, "{hmac_wow_set_wow_cmd::wow is not enabled.}");
366 return;
367 }
368
369 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_set_wow_cmd, ul_wow_event[0x%X]}", wow_event);
370
371 g_wow_info.wow_cfg.wow_event = wow_event;
372
373 /* 下发参数到 DMAC */
374 ret = hmac_wow_set_dmac_cfg();
375 if (ret != HI_SUCCESS) {
376 oam_warning_log0(0, OAM_SF_WOW, "hmac_wow_set_dmac_cfg return NON SUCCESS. ");
377 }
378 }
379
380 /* ****************************************************************************
381 函 数 名 : hmac_wow_set_wow_en_cmd
382 功能描述 :
383 输入参数 : hi_u32 ul_wow_en
384 输出参数 : 无
385 返 回 值 : 无
386 调用函数 :
387 被调函数 :
388
389 修改历史 :
390 1.日 期 : 2016年5月05日
391 作 者 : HiSilicon
392 修改内容 : 新生成函数
393
394 **************************************************************************** */
hmac_wow_set_wow_en_cmd(hi_u32 wow_en)395 hi_void hmac_wow_set_wow_en_cmd(hi_u32 wow_en)
396 {
397 hi_u32 ret;
398
399 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_set_wow_en_cmd, ul_wow_en[0x%x]}", wow_en);
400
401 g_wow_info.wow_cfg.wow_en = (hi_u8)wow_en;
402
403 if (!g_wow_info.wow_cfg.wow_en) {
404 g_wow_info.host_sleep_state = HMAC_HOST_STATE_WAKEUP;
405 }
406
407 /* 下发参数到 DMAC */
408 ret = hmac_wow_set_dmac_cfg();
409 if (ret != HI_SUCCESS) {
410 oam_warning_log0(0, OAM_SF_WOW, "hmac_wow_set_dmac_cfg return NON SUCCESS. ");
411 }
412 }
413
414 /* ****************************************************************************
415 函 数 名 : hmac_wow_add_pattern
416 功能描述 :
417 输入参数 : [1]us_pattern_index
418 [2]ul_pattern_len
419 [3]puc_pattern
420 输出参数 : 无
421 返 回 值 : hi_u32
422 **************************************************************************** */
hmac_wow_add_pattern(hi_u16 us_pattern_index,hi_u32 pattern_len,const hi_u8 * puc_pattern)423 hi_u32 hmac_wow_add_pattern(hi_u16 us_pattern_index, hi_u32 pattern_len, const hi_u8 *puc_pattern)
424 {
425 if (oal_unlikely(puc_pattern == HI_NULL)) {
426 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd::puc_pattern is null.}");
427 return HI_ERR_CODE_PTR_NULL;
428 }
429
430 if ((us_pattern_index >= WOW_NETPATTERN_MAX_NUM) || (pattern_len == 0) || (pattern_len > WOW_NETPATTERN_MAX_LEN)) {
431 oam_error_log2(0, OAM_SF_WOW, "{hmac_wow_add_pattern:: param error, index = %d, len = %d.}", us_pattern_index,
432 pattern_len);
433 return HI_FAIL;
434 }
435
436 if (memcpy_s(g_wow_info.wow_cfg.wow_pattern.ast_pattern[us_pattern_index].auc_pattern_data, WOW_NETPATTERN_MAX_LEN,
437 puc_pattern, pattern_len) != EOK) {
438 oam_error_log0(0, OAM_SF_CFG, "hmac_wow_add_pattern:: puc_pattern memcpy_s fail.");
439 return HI_FAIL;
440 }
441 g_wow_info.wow_cfg.wow_pattern.ast_pattern[us_pattern_index].pattern_len = pattern_len;
442
443 if (!((1 << us_pattern_index) & g_wow_info.wow_cfg.wow_pattern.us_pattern_map)) {
444 g_wow_info.wow_cfg.wow_pattern.us_pattern_map |= (hi_u16)(1 << us_pattern_index);
445 g_wow_info.wow_cfg.wow_pattern.us_pattern_num++;
446 }
447
448 oam_warning_log2(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd, add new pattern, len[%d], total_num[%d]}", pattern_len,
449 g_wow_info.wow_cfg.wow_pattern.us_pattern_num);
450
451 return HI_SUCCESS;
452 }
453
hmac_check_if_del_pattern(hi_u16 index,const hi_u16 * pattern_num)454 hi_void hmac_check_if_del_pattern(hi_u16 index, const hi_u16 *pattern_num)
455 {
456 /* 下面的~操作符表达式中所有变量都是无符号数,误报告警,lin_t e502告警屏蔽 */
457 if ((1 << index) & g_wow_info.wow_cfg.wow_pattern.us_pattern_map) {
458 g_wow_info.wow_cfg.wow_pattern.us_pattern_map &= ~(1 << index);
459 g_wow_info.wow_cfg.wow_pattern.us_pattern_num--;
460 g_wow_info.wow_cfg.wow_pattern.ast_pattern[index].pattern_len = 0;
461
462 /* 安全编程规则6.6例外(1) 固定长度的结构体进行内存初始化 */
463 memset_s(g_wow_info.wow_cfg.wow_pattern.ast_pattern[index].auc_pattern_data, WOW_NETPATTERN_MAX_LEN, 0,
464 WOW_NETPATTERN_MAX_LEN);
465
466 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd,del pattern,Del,totalNum=%d}", *pattern_num);
467 } else {
468 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd,No del pattern,Del,totalNum=%d}", *pattern_num);
469 }
470 }
471
472 /* ****************************************************************************
473 函 数 名 : hmac_wow_set_pattern_cmd
474 功能描述 :
475 输入参数 : hmac_cfg_wow_pattern_param_stru * pst_pattern
476 输出参数 : 无
477 返 回 值 : hi_u32
478 调用函数 :
479 被调函数 :
480
481 修改历史 :
482 1.日 期 : 2016年5月05日
483 作 者 : HiSilicon
484 修改内容 : 新生成函数
485
486 **************************************************************************** */
hmac_wow_set_pattern_cmd(const hmac_cfg_wow_pattern_param_stru * pattern)487 hi_u32 hmac_wow_set_pattern_cmd(const hmac_cfg_wow_pattern_param_stru *pattern)
488 {
489 hi_u16 *pattern_num = &g_wow_info.wow_cfg.wow_pattern.us_pattern_num;
490 hi_u16 index = pattern->us_pattern_index;
491 hi_u32 len = pattern->pattern_len;
492
493 if (pattern->us_pattern_option == MAC_WOW_PATTERN_PARAM_OPTION_ADD) {
494 if ((index >= WOW_NETPATTERN_MAX_NUM) || (len == 0) || (len > WOW_NETPATTERN_MAX_LEN)) {
495 oam_error_log2(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd::ADD::param Err,index=%d,len=%d}", index, len);
496 return HI_FAIL;
497 }
498 if (memcpy_s(g_wow_info.wow_cfg.wow_pattern.ast_pattern[index].auc_pattern_data, WOW_NETPATTERN_MAX_LEN,
499 pattern->auc_pattern_value, len) != EOK) {
500 oam_error_log0(0, OAM_SF_CFG, "hmac_wow_set_pattern_cmd:: auc_pattern_value memcpy_s fail.");
501 return HI_FAIL;
502 }
503 g_wow_info.wow_cfg.wow_pattern.ast_pattern[index].pattern_len = len;
504
505 if (!((1 << index) & g_wow_info.wow_cfg.wow_pattern.us_pattern_map)) {
506 g_wow_info.wow_cfg.wow_pattern.us_pattern_map |= (hi_u16)(1 << index);
507 g_wow_info.wow_cfg.wow_pattern.us_pattern_num++;
508 }
509
510 oam_warning_log4(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd, add new pattern,len=%d,total_num=%d,Value[%X][%X]}",
511 len, *pattern_num, pattern->auc_pattern_value[0], pattern->auc_pattern_value[1]);
512 } else if (pattern->us_pattern_option == MAC_WOW_PATTERN_PARAM_OPTION_DEL) {
513 if (index >= WOW_NETPATTERN_MAX_NUM) {
514 oam_error_log1(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd::DEL: param Err,index=%d}", len);
515 return HI_FAIL;
516 }
517 hmac_check_if_del_pattern(index, pattern_num);
518 } else if (pattern->us_pattern_option == MAC_WOW_PATTERN_PARAM_OPTION_CLR) {
519 /* 安全编程规则6.6例外(1) 固定长度的结构体进行内存初始化 */
520 /* memset按照结构体长度处理,误报lin_t419告警,告警屏蔽 */
521 memset_s(&g_wow_info.wow_cfg.wow_pattern, sizeof(g_wow_info.wow_cfg.wow_pattern), 0,
522 sizeof(g_wow_info.wow_cfg.wow_pattern));
523 oam_warning_log0(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd, pattern clear}");
524 } else {
525 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_set_pattern_cmd, error option[%d]}", pattern->us_pattern_option);
526 }
527
528 /* 下发参数到 DMAC */
529 if (hmac_wow_set_dmac_cfg() != HI_SUCCESS) {
530 oam_warning_log0(0, OAM_SF_WOW, "hmac_wow_set_dmac_cfg return NON SUCCESS. ");
531 }
532
533 return HI_SUCCESS;
534 }
535
536 /* ****************************************************************************
537 功能描述 : Host 侧发送 休眠请求异步处理
538 **************************************************************************** */
hmac_wow_host_sleep_request_asyn_handle(hi_void)539 hi_u32 hmac_wow_host_sleep_request_asyn_handle(hi_void)
540 {
541 hi_u32 ret;
542
543 hmac_wow_set_host_state(HMAC_HOST_STATE_SLEEP_REQ);
544
545 ret = hmac_wow_host_sleep_wakeup_notify(MAC_WOW_SLEEP_REQUEST);
546
547 hmac_wow_stop_scan_assoc();
548
549 hmac_wow_stop_upper_layer_queue();
550
551 return ret;
552 }
553
554 /* ****************************************************************************
555 函 数 名 : hmac_wow_host_wakeup_notify_asyn_handle
556 功能描述 :
557 输入参数 : 无
558 输出参数 : 无
559 返 回 值 : hi_u32
560 调用函数 :
561 被调函数 :
562
563 修改历史 :
564 1.日 期 : 2016年5月05日
565 作 者 : HiSilicon
566 修改内容 : 新生成函数
567
568 **************************************************************************** */
hmac_wow_host_wakeup_notify_asyn_handle(hi_void)569 hi_u32 hmac_wow_host_wakeup_notify_asyn_handle(hi_void)
570 {
571 hi_u32 ret;
572
573 /* 这里需要异步操作 或者 外部循环, 等 liteos 接口明了 */
574 hmac_wow_set_host_state(HMAC_HOST_STATE_WAKEUP);
575 ret = hmac_wow_host_sleep_wakeup_notify(MAC_WOW_WAKEUP_NOTIFY);
576 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_host_wakeup_notify_asyn_handle, ret = %d}", ret);
577
578 hmac_wow_prepare_wakeup();
579
580 return ret;
581 }
582
583 /* ****************************************************************************
584 功能描述 : Host 侧休眠请求
585 **************************************************************************** */
586 /* 此函数由 平台调用,需求为外部线程 */
hmac_wow_host_sleep_request(hi_void)587 hi_void hmac_wow_host_sleep_request(hi_void)
588 {
589 hi_u8 sleep_state;
590
591 sleep_state = hmac_wow_get_host_state();
592
593 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_host_sleep_request, cur_state = %d}", sleep_state);
594
595 if (sleep_state == HMAC_HOST_STATE_WAKEUP) {
596 hmac_wow_host_sleep_request_asyn_handle();
597
598 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
599 /* 获取锁, 被挂起 */
600 hmac_wow_obtain_lock();
601 #endif
602 } else {
603 oam_error_log2(0, OAM_SF_WOW,
604 "{hmac_wow_host_sleep_request:: ERROR_state[%d], Expect_state[%d]!}",
605 sleep_state,
606 HMAC_HOST_STATE_WAKEUP);
607 }
608 }
609
610 /* ****************************************************************************
611 函 数 名 : hmac_wow_host_wakeup_notify
612 功能描述 :
613 输入参数 : 无
614 输出参数 : 无
615 返 回 值 : hi_u32
616 调用函数 :
617 被调函数 :
618
619 修改历史 :
620 1.日 期 : 2016年5月05日
621 作 者 : HiSilicon
622 修改内容 : 新生成函数
623
624 **************************************************************************** */
625 /* 此函数由平台调用,需求为外部本线程,如果不是则需要调用线程通信接口 */
hmac_wow_host_wakeup_notify(hi_void)626 hi_void hmac_wow_host_wakeup_notify(hi_void)
627 {
628 hi_u8 sleep_state;
629
630 sleep_state = hmac_wow_get_host_state();
631
632 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_host_wakeup_notify, uc_sleep_state = %d}", sleep_state);
633 if (sleep_state == HMAC_HOST_STATE_SLEPT) {
634 hmac_wow_set_host_state(HMAC_HOST_STATE_WAKEUP);
635
636 /* for debug */
637 hmac_wow_host_wakeup_notify_asyn_handle();
638 } else {
639 oam_error_log2(0, OAM_SF_WOW, "{hmac_wow_host_wakeup_notify:: ERROR_state[%d], Expect_state[%d]!}",
640 sleep_state, HMAC_HOST_STATE_SLEPT);
641 }
642 }
643
644 /* ****************************************************************************
645 函 数 名 : hmac_wow_create_lock
646 功能描述 :
647 输入参数 : 无
648 输出参数 : 无
649 返 回 值 : 无
650 调用函数 :
651 被调函数 :
652
653 修改历史 :
654 1.日 期 : 2016年5月05日
655 作 者 : HiSilicon
656 修改内容 : 新生成函数
657
658 **************************************************************************** */
hmac_wow_create_lock(hi_void)659 hi_void hmac_wow_create_lock(hi_void)
660 {
661 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
662 OAL_INIT_COMPLETION(&g_wow_info.sleep_req_done_event);
663 #endif
664 }
665
666 /* ****************************************************************************
667 函 数 名 : hmac_wow_obtain_lock
668 功能描述 :
669 输入参数 : 无
670 输出参数 : 无
671 返 回 值 : 无
672 调用函数 :
673 被调函数 :
674
675 修改历史 :
676 1.日 期 : 2016年5月05日
677 作 者 : HiSilicon
678 修改内容 : 新生成函数
679
680 **************************************************************************** */
hmac_wow_obtain_lock(hi_void)681 hi_void hmac_wow_obtain_lock(hi_void)
682 {
683 hi_u32 ret;
684
685 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_obtain_lock, uc_sleep_state = %d}", hmac_wow_get_host_state());
686
687 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
688 ret = oal_wait_for_completion_timeout(&g_wow_info.sleep_req_done_event,
689 (hi_u32)OAL_MSECS_TO_JIFFIES(WOW_SLEEP_REQ_WAIT_TIMEOUT));
690 #elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
691 ret = hi_event_wait(get_app_event_id(), HI_EVENT_SLEEP_REQUEST_DONE, &g_wow_info.sleep_req_done_event,
692 WOW_SLEEP_REQ_WAIT_TIMEOUT, HI_EVENT_WAITMODE_OR | HI_EVENT_WAITMODE_CLR);
693 #endif
694 if (ret != 0) {
695 oam_info_log1(0, OAM_SF_WOW, "hmac_wow_obtain_lock, -> timeout[%d]!!!\n", ret);
696 }
697
698 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_obtain_lock, Exit, uc_sleep_state = %d}", hmac_wow_get_host_state());
699 }
700
701 /* ****************************************************************************
702 函 数 名 : hmac_wow_release_lock
703 功能描述 :
704 输入参数 : 无
705 输出参数 : 无
706 返 回 值 : 无
707 调用函数 :
708 被调函数 :
709
710 修改历史 :
711 1.日 期 : 2016年5月05日
712 作 者 : HiSilicon
713 修改内容 : 新生成函数
714
715 **************************************************************************** */
hmac_wow_release_lock(hi_void)716 hi_void hmac_wow_release_lock(hi_void)
717 {
718 oam_warning_log0(0, OAM_SF_WOW, "hmac_wow_release_lock Enter\n");
719 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
720 OAL_COMPLETE(&g_wow_info.sleep_req_done_event);
721 #elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
722 hi_event_send(get_app_event_id(), HI_EVENT_SLEEP_REQUEST_DONE);
723 #endif
724 }
725
hmac_wow_proc_dev_sleep_state(hi_void)726 hi_void hmac_wow_proc_dev_sleep_state(hi_void)
727 {
728 hi_u32 ret;
729 mac_vap_stru *mac_vap = HI_NULL;
730 hi_u8 dev_sleep_state = HMAC_HOST_STATE_SLEEP_REQ;
731
732 mac_vap = mac_vap_get_vap_stru(0);
733 if (oal_unlikely(mac_vap == HI_NULL)) {
734 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_proc_dev_sleep_state::pst_mac_vap is null.}");
735 return;
736 }
737
738 /* **************************************************************************
739 抛事件到DMAC层, 修改 Device 侧状态
740 ************************************************************************** */
741 ret = hmac_config_send_event(mac_vap, WLAN_CFGID_SET_DEV_STATE, sizeof(hi_u8), &dev_sleep_state);
742 if (oal_unlikely(ret != HI_SUCCESS)) {
743 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_proc_dev_sleep_state::send WLAN_CFGID_SET_DEV_STATE event fail.}");
744 }
745 }
746
747 /* ****************************************************************************
748 函 数 名 : hmac_wow_trigger_host_state
749 功能描述 :
750 输入参数 : 无
751 输出参数 : 无
752 返 回 值 : 无
753 调用函数 :
754 被调函数 :
755
756 修改历史 :
757 1.日 期 : 2016年5月05日
758 作 者 : HiSilicon
759 修改内容 : 新生成函数
760
761 **************************************************************************** */
762 /* 如果此处还没有准备好,则需要在其他地方异步 hmac_wow_release_lock(); */
hmac_wow_trigger_host_state(hi_void)763 hi_void hmac_wow_trigger_host_state(hi_void)
764 {
765 if (HMAC_HOST_STATE_DEV_READY_FOR_HOST_SLEEP == hmac_wow_get_host_state()) {
766 /* if HOST is ready */
767 hmac_wow_set_host_state(HMAC_HOST_STATE_HOST_READY);
768 hmac_wow_clear_data_channal();
769 hmac_wow_clear_event_queue();
770
771 /* 确保镜像中为 SLEPT 状态 */
772 hmac_wow_set_host_state(HMAC_HOST_STATE_SLEPT);
773
774 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
775 /* 释放锁 */
776 hmac_wow_release_lock();
777 #endif
778 }
779 }
780
781 /* ****************************************************************************
782 功能描述 : ready sleep event
783 输入参数 :
784 输出参数 : 无
785 返 回 值 : hi_u32
786 调用函数 :
787 被调函数 :
788
789 修改历史 :
790 1.日 期 : 2016年5月05日
791 作 者 : HiSilicon
792 修改内容 : 新生成函数
793
794 **************************************************************************** */
hmac_wow_proc_dev_ready_slp_event(frw_event_mem_stru * event_mem)795 hi_u32 hmac_wow_proc_dev_ready_slp_event(frw_event_mem_stru *event_mem)
796 {
797 frw_event_stru *event = HI_NULL;
798 hmac_vap_stru *hmac_vap = HI_NULL;
799
800 if (oal_unlikely(event_mem == HI_NULL)) {
801 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_proc_dev_ready_slp_event::event_mem is null.}");
802 return HI_ERR_CODE_PTR_NULL;
803 }
804
805 event = (frw_event_stru *)event_mem->puc_data;
806 hmac_vap = hmac_vap_get_vap_stru(event->event_hdr.vap_id);
807 if (oal_unlikely(hmac_vap == HI_NULL)) {
808 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_proc_dev_ready_slp_event::pst_hmac_vap is null.}");
809 return HI_ERR_CODE_PTR_NULL;
810 }
811
812 hmac_wow_proc_dev_ready_slp();
813
814 return HI_SUCCESS;
815 }
816
817 /* ****************************************************************************
818 函 数 名 : hmac_wow_proc_dev_ready_slp
819 功能描述 : Device is ready for Host's sleep request.
820 输入参数 : 无
821 输出参数 : 无
822 返 回 值 : hi_u32
823 调用函数 :
824 被调函数 :
825
826 修改历史 :
827 1.日 期 : 2016年5月05日
828 作 者 : HiSilicon
829 修改内容 : 新生成函数
830
831 **************************************************************************** */
hmac_wow_proc_dev_ready_slp(hi_void)832 hi_void hmac_wow_proc_dev_ready_slp(hi_void)
833 {
834 hi_u8 sleep_state;
835
836 sleep_state = hmac_wow_get_host_state();
837 oam_warning_log1(0, OAM_SF_WOW, "hmac_wow_proc_dev_ready_slp:: cur_state[%d]", sleep_state);
838 if (sleep_state == HMAC_HOST_STATE_SLEEP_REQ) {
839 hmac_wow_set_host_state(HMAC_HOST_STATE_DEV_READY_FOR_HOST_SLEEP);
840
841 /* 检查是否可以直接 unlock */
842 hmac_wow_trigger_host_state();
843
844 hmac_wow_proc_dev_sleep_state();
845 } else if (sleep_state == HMAC_HOST_STATE_HOST_READY) {
846 /* 确保镜像中为 SLEPT 状态 */
847 hmac_wow_set_host_state(HMAC_HOST_STATE_SLEPT);
848
849 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
850 /* 释放锁 */
851 hmac_wow_release_lock();
852 #endif
853 } else {
854 oam_error_log3(0, OAM_SF_WOW, "{hmac_wow_proc_dev_ready_slp:: ERROR_state[%d], Expect_state[%d][%d]!}",
855 sleep_state, HMAC_HOST_STATE_SLEEP_REQ, HMAC_HOST_STATE_HOST_READY);
856 }
857 }
858
859 /* ****************************************************************************
860 函 数 名 : hmac_wow_msg_handle
861 功能描述 : 处理device侧发来的msg
862 输入参数 : 无
863 输出参数 : 无
864 返 回 值 : hi_u32
865 调用函数 :
866 被调函数 :
867
868 修改历史 :
869 1.日 期 : 2016年5月05日
870 作 者 : HiSilicon
871 修改内容 : 新生成函数
872
873 **************************************************************************** */
hmac_wow_msg_handle(hi_void)874 hi_s32 hmac_wow_msg_handle(hi_void)
875 {
876 hmac_wow_msg_incr(WOW_D2H_MSG);
877 oam_warning_log3(0, OAM_SF_WOW, "{hmac_wow_msg_handle, time[%d], CNT:SLP[%d],WKUP[%d],D2H[%d]}",
878 WOW_H2D_SLP_MSG_CNT, WOW_H2D_WKUP_MSG_CNT, WOW_D2H_MSG_CNT);
879 hmac_wow_proc_dev_ready_slp();
880 return HI_SUCCESS;
881 }
882
883 /* ****************************************************************************
884 函 数 名 : hmac_wow_msg_incr
885 功能描述 : channel msg counter 处理
886 输入参数 : hi_u32 ul_msg_type 消息类型
887 输出参数 :
888 返 回 值 : hi_void
889 调用函数 :
890 被调函数 :
891
892 修改历史 :
893 1.日 期 : 2016年5月5日
894 作 者 : HiSilicon
895 修改内容 : 新生成函数
896
897 **************************************************************************** */
hmac_wow_msg_incr(hi_u32 msg_type)898 hi_void hmac_wow_msg_incr(hi_u32 msg_type)
899 {
900 switch (msg_type) {
901 case WOW_H2D_SLP_MSG:
902 g_wow_info.debug_info.int_info.h2d_slp_msg_cnt++;
903 break;
904 case WOW_H2D_WKUP_MSG:
905 g_wow_info.debug_info.int_info.h2d_wkup_msg_cnt++;
906 break;
907 case WOW_D2H_MSG:
908 g_wow_info.debug_info.int_info.d2h_msg_cnt++;
909 break;
910 default:
911 break;
912 }
913 }
914
915 /* ****************************************************************************
916 功能描述 : dmac 唤醒后同步 host data
917
918 修改历史 :
919 1.日 期 : 2016年5月05日
920 作 者 : HiSilicon
921 修改内容 : 新生成函数
922 **************************************************************************** */
hmac_wow_proc_dev_sync_host_event(frw_event_mem_stru * event_mem)923 hi_u32 hmac_wow_proc_dev_sync_host_event(frw_event_mem_stru *event_mem)
924 {
925 mac_vap_stru *mac_vap = HI_NULL;
926 hi_u32 index;
927
928 if (oal_unlikely(event_mem == HI_NULL)) {
929 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_proc_dev_sync_host_event::frw_event_mem is null.}");
930 return HI_ERR_CODE_PTR_NULL;
931 }
932
933 frw_event_stru *event = (frw_event_stru *)event_mem->puc_data;
934 mac_d2h_syn_hdr_stru *sync_info_hdr = (mac_d2h_syn_hdr_stru *)event->auc_event_data;
935 mac_d2h_syn_data_stru *sync_info_data = (mac_d2h_syn_data_stru *)(sync_info_hdr + 1);
936
937 g_wow_info.wakeup_reason = sync_info_hdr->wakeup_reason;
938
939 oam_warning_log2(0, OAM_SF_WOW, "{hmac_wow_proc_dev_sync_host_event:: block_count[%d], reason[0x%08x].}",
940 sync_info_hdr->data_blk_cnt, g_wow_info.wakeup_reason);
941
942 for (index = 0; index < sync_info_hdr->data_blk_cnt; index++, sync_info_data++) {
943 mac_vap = mac_vap_get_vap_stru(sync_info_data->vap_id);
944 if (mac_vap == HI_NULL) {
945 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_proc_dev_sync_host_event:: vap is null, index[%d].}", index);
946 continue;
947 }
948
949 if (mac_vap->vap_mode != WLAN_VAP_MODE_BSS_STA) {
950 continue;
951 }
952
953 oam_warning_log3(0, OAM_SF_WOW, "{hmac_wow_proc_dev_sync_host_event::in loop, index[%d], vap[%d], user[%d].}",
954 index, sync_info_data->vap_id, sync_info_data->user_idx);
955
956 /* 信道信息同步到hmac */
957 if (memcpy_s(&(mac_vap->channel), sizeof(mac_channel_stru), &(sync_info_data->channel),
958 sizeof(mac_channel_stru)) != EOK) {
959 oam_error_log0(0, OAM_SF_CFG, "hmac_wow_proc_dev_sync_host_event:: st_channel memcpy_s fail.");
960 return HI_FAIL;
961 }
962 oam_warning_log2(mac_vap->vap_id, OAM_SF_WOW, "{hmac_wow_proc_dev_sync_host_event:: channel[%d], width[%d].}",
963 mac_vap->channel.chan_number, mac_vap->channel.en_bandwidth);
964
965 if ((mac_vap->ch_switch_info.waiting_to_shift_channel == HI_FALSE) &&
966 (sync_info_data->ch_switch_info.waiting_to_shift_channel == HI_TRUE)) {
967 if (memcpy_s(&(mac_vap->ch_switch_info), sizeof(mac_ch_switch_info_stru),
968 &(sync_info_data->ch_switch_info), sizeof(mac_ch_switch_info_stru)) != EOK) {
969 oam_error_log0(0, OAM_SF_CFG, "hmac_wow_proc_dev_sync_host_event:: st_ch_switch_info memcpy_s fail.");
970 return HI_FAIL;
971 }
972 }
973 }
974 g_wow_info.wait_dev_data = HI_FALSE;
975
976 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
977 OAL_COMPLETE(&g_d2h_completion);
978 #elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
979 hi_event_send(get_app_event_id(), HI_EVENT_D2H_READY_EVENT);
980 #endif
981 return HI_SUCCESS;
982 }
983
984 /* ****************************************************************************
985 函 数 名 : hmac_wow_set_dmac_cfg
986 功能描述 : H2D WOW 参数下发
987 输入参数 : 无
988 输出参数 : 无
989 返 回 值 : hi_u32
990 调用函数 :
991 被调函数 :
992
993 修改历史 :
994 1.日 期 : 2016年5月05日
995 作 者 : HiSilicon
996 修改内容 : 新生成函数
997
998 **************************************************************************** */
hmac_wow_set_dmac_cfg(hi_void)999 hi_u32 hmac_wow_set_dmac_cfg(hi_void)
1000 {
1001 hi_u32 ret;
1002 mac_vap_stru *mac_vap = HI_NULL;
1003
1004 oam_warning_log2(0, OAM_SF_WOW, "hmac_wow_set_dmac_cfg, flag[%d], wow_event[0x%X]\n", g_wlan_resume_wifi_init_flag,
1005 g_wow_info.wow_cfg.wow_event);
1006
1007 if (1 == g_wlan_resume_wifi_init_flag) {
1008 return HI_SUCCESS;
1009 }
1010
1011 mac_vap = mac_vap_get_vap_stru(0);
1012 if (oal_unlikely(mac_vap == HI_NULL)) {
1013 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_set_dmac_cfg::pst_mac_vap is null.}");
1014 return HI_ERR_CODE_PTR_NULL;
1015 }
1016
1017 /* **************************************************************************
1018 抛事件到DMAC层, 同步DMAC数据
1019 ************************************************************************** */
1020 ret = hmac_config_send_event(mac_vap, WLAN_CFGID_SET_WOW_PARAM, sizeof(g_wow_info.wow_cfg),
1021 (hi_u8 *)&g_wow_info.wow_cfg);
1022 if (oal_unlikely(ret != HI_SUCCESS)) {
1023 oam_warning_log1(0, OAM_SF_WOW, "{hmac_wow_set_dmac_cfg::send_event failed[%d]}", ret);
1024 }
1025
1026 return ret;
1027 }
1028
1029 /* ****************************************************************************
1030 功能描述 : Host 侧发给 Device 侧 睡眠/ 唤醒通知
1031 **************************************************************************** */
hmac_wow_host_sleep_wakeup_notify(hi_u8 is_sleep_req)1032 hi_u32 hmac_wow_host_sleep_wakeup_notify(hi_u8 is_sleep_req)
1033 {
1034 hi_u32 ret;
1035 mac_vap_stru *mac_vap = HI_NULL;
1036 mac_h2d_syn_info_hdr_stru sync_hdr = { 0 };
1037
1038 mac_vap = mac_vap_get_vap_stru(0);
1039 if (oal_unlikely(mac_vap == HI_NULL)) {
1040 oam_error_log0(0, OAM_SF_WOW, "{hmac_wow_host_sleep_wakeup_notify::pst_mac_vap is null.}");
1041 return HI_ERR_CODE_PTR_NULL;
1042 }
1043
1044 sync_hdr.msg_type = MAC_WOW_SLEEP_NOTIFY_MSG;
1045 sync_hdr.notify_param = is_sleep_req;
1046
1047 /* **************************************************************************
1048 抛事件到DMAC层, 同步DMAC数据
1049 ************************************************************************** */
1050 ret = hmac_config_send_event(mac_vap, WLAN_CFGID_HOST_SLEEP_NOTIFY, sizeof(mac_h2d_syn_info_hdr_stru),
1051 (hi_u8 *)&sync_hdr);
1052 if (oal_unlikely(ret != HI_SUCCESS)) {
1053 oam_warning_log2(mac_vap->vap_id, OAM_SF_WOW,
1054 "{hmac_config_host_sleep_wakeup_notify::send_event failed[%d],uc_is_sleep_req = %d}", ret, is_sleep_req);
1055 }
1056
1057 return ret;
1058 }
1059
1060
1061 /* ****************************************************************************
1062 函 数 名 : wlan_suspend
1063 功能描述 : 睡眠入口
1064 输入参数 : 无
1065 输出参数 : 无
1066 返 回 值 : 无
1067 调用函数 :
1068 被调函数 :
1069
1070 修改历史 :
1071 1.日 期 : 2016年7月20日
1072 作 者 : HiSilicon
1073 修改内容 : 新生成函数
1074
1075 **************************************************************************** */
wlan_suspend(hi_void)1076 hi_void wlan_suspend(hi_void)
1077 {
1078 hi_u8 sleep_state;
1079
1080 if ((g_wow_info.wow_cfg.wow_event == MAC_WOW_FIELD_ALL_CLEAR) || (g_wow_info.wait_dev_data == HI_TRUE)) {
1081 oam_warning_log2(0, OAM_SF_WOW, "{wlan_suspend, [wow], NOT_ALLOWED, EVENT[%08X],wait[%d]}",
1082 g_wow_info.wow_cfg.wow_event, g_wow_info.wait_dev_data);
1083 return;
1084 }
1085
1086 sleep_state = hmac_wow_get_host_state();
1087 if (sleep_state != HMAC_HOST_STATE_WAKEUP) {
1088 oam_warning_log1(0, OAM_SF_WOW, "{wlan_suspend, [wow], NOT_ALLOWED, uc_sleep_state = %d}", sleep_state);
1089 return;
1090 }
1091
1092 oam_warning_log3(0, OAM_SF_WOW, "{wlan_suspend,[wow], CNT:SLP[%d],WKUP[%d],D2H[%d]}", WOW_H2D_SLP_MSG_CNT,
1093 WOW_H2D_WKUP_MSG_CNT, WOW_D2H_MSG_CNT);
1094
1095 /* 业务暂停接口 */
1096 wlan_wifi_suspend();
1097 oam_warning_log0(0, OAM_SF_WOW, "{host_pow_off.}");
1098 }
1099
1100 /* ****************************************************************************
1101 函 数 名 : wlan_wifi_suspend
1102 功能描述 : 业务暂停接口
1103 输入参数 : 无
1104 输出参数 : 无
1105 返 回 值 : 无
1106 调用函数 :
1107 被调函数 :
1108
1109 修改历史 :
1110 1.日 期 : 2016年7月20日
1111 作 者 : HiSilicon
1112 修改内容 : 新生成函数
1113
1114 **************************************************************************** */
wlan_wifi_suspend(hi_void)1115 hi_void wlan_wifi_suspend(hi_void)
1116 {
1117 /* sleep req */
1118 hmac_wow_host_sleep_request();
1119 }
1120
1121 /* ****************************************************************************
1122 函 数 名 : wlan_wifi_resume
1123 功能描述 : 业务恢复接口
1124 输入参数 : 无
1125 输出参数 : 无
1126 返 回 值 : 无
1127 调用函数 :
1128 被调函数 :
1129
1130 修改历史 :
1131 1.日 期 : 2016年7月20日
1132 作 者 : HiSilicon
1133 修改内容 : 新生成函数
1134
1135 **************************************************************************** */
wlan_wifi_resume(hi_void)1136 hi_void wlan_wifi_resume(hi_void)
1137 {
1138 oam_warning_log1(0, OAM_SF_WOW, "{wlan_wifi_resume, uc_sleep_state = %d}\n", hmac_wow_get_host_state());
1139 /* wifi resume,recovery data process */
1140 hisi_wifi_resume_process();
1141 /* wakeup notify */
1142 hmac_wow_host_wakeup_notify();
1143 }
1144
1145 /* ****************************************************************************
1146 函 数 名 : hmac_wow_check_event
1147 功能描述 : 判断当前是否需要过滤事件
1148 输入参数 :
1149 输出参数 :
1150 返 回 值 : hi_u32
1151 调用函数 :
1152 被调函数 :
1153
1154 修改历史 :
1155 1.日 期 : 2016年4月5日
1156 作 者 : HiSilicon
1157 修改内容 : 新生成函数
1158
1159 **************************************************************************** */
hmac_wow_check_event(const frw_event_hdr_stru * event_hrd,hi_u8 event_dir)1160 hi_u32 hmac_wow_check_event(const frw_event_hdr_stru *event_hrd, hi_u8 event_dir)
1161 {
1162 hi_u8 cnt;
1163
1164 if (event_hrd == HI_NULL) {
1165 return HI_FALSE;
1166 }
1167
1168 if (HI_TRUE == hmac_wow_tx_check_filter_switch() && (FRW_EVENT_PIPELINE_STAGE_1 == event_hrd->pipeline)) {
1169 switch (event_dir) {
1170 case EVENT_TX_TYPE:
1171 g_wow_info.debug_info.event_info.tx_cnt++;
1172 cnt = g_wow_info.debug_info.event_info.tx_cnt;
1173 break;
1174 case EVENT_RX_TYPE:
1175 g_wow_info.debug_info.event_info.rx_cnt++;
1176 cnt = g_wow_info.debug_info.event_info.rx_cnt;
1177 break;
1178 case EVENT_DUAL_TYPE:
1179 g_wow_info.debug_info.event_info.dual_cnt++;
1180 cnt = g_wow_info.debug_info.event_info.dual_cnt;
1181 break;
1182 case EVENT_TYPE_BUTT:
1183 default:
1184 return HI_FALSE;
1185 }
1186 oam_warning_log4(0, OAM_SF_WOW,
1187 "hmac_wow_check_event, wow_blocked, event|sub[0x%08X],dir[%d],cnt[%d]state[%d]\n",
1188 (event_hrd->type << 16) | event_hrd->sub_type, event_dir, cnt, hmac_wow_get_host_state()); /* 左移16位 */
1189 return HI_TRUE;
1190 }
1191
1192 return HI_FALSE;
1193 }
1194
1195 #ifndef _PRE_WLAN_FEATURE_QUICK_START
1196 /* ****************************************************************************
1197 函 数 名 : hisi_wlan_suspend
1198 功能描述 : 强制睡眠 API接口
1199 输入参数 : 无
1200 输出参数 : 无
1201 返 回 值 : 无
1202 调用函数 :
1203 被调函数 :
1204
1205 修改历史 :
1206 1.日 期 : 2017年01月05日
1207 作 者 : HiSilicon
1208 修改内容 : 新生成函数
1209
1210 **************************************************************************** */
hisi_wlan_suspend(hi_void)1211 hi_void hisi_wlan_suspend(hi_void)
1212 {
1213 wlan_suspend();
1214 }
1215 #endif
1216 /* ****************************************************************************
1217 函 数 名 : hisi_wlan_set_wow_event
1218 功能描述 : 设置强制睡眠功能开关接口
1219 输入参数 : ul_event 事件开关值
1220 输出参数 : 无
1221 返 回 值 : 无
1222 调用函数 :
1223 被调函数 :
1224
1225 修改历史 :
1226 1.日 期 : 2017年01月05日
1227 作 者 : HiSilicon
1228 修改内容 : 新生成函数
1229
1230 **************************************************************************** */
hisi_wlan_set_wow_event(hi_u32 event)1231 hi_void hisi_wlan_set_wow_event(hi_u32 event)
1232 {
1233 hmac_wow_set_wow_cmd(event);
1234 }
1235
1236 /* ****************************************************************************
1237 函 数 名 : hisi_wlan_add_netpattern
1238 功能描述 : 强制睡眠netpattern唤醒报文格式的添加API接口
1239 输入参数 : [1]netpattern_index: netpattern 的索引, 0~3
1240 [2]puc_netpattern_data: netpattern 的内容
1241 [3]netpattern_len : netpattern 的内容长度, 0~64
1242 输出参数 : 无
1243 返 回 值 : 0 : 成功
1244 非0: 失败
1245 **************************************************************************** */
hisi_wlan_add_netpattern(hi_u32 netpattern_index,hi_uchar * puc_netpattern_data,hi_u32 netpattern_len)1246 hi_u32 hisi_wlan_add_netpattern(hi_u32 netpattern_index, hi_uchar *puc_netpattern_data, hi_u32 netpattern_len)
1247 {
1248 hmac_cfg_wow_pattern_param_stru pattern;
1249
1250 if (memset_s(&pattern, sizeof(hmac_cfg_wow_pattern_param_stru), 0,
1251 sizeof(hmac_cfg_wow_pattern_param_stru)) != EOK) {
1252 oam_error_log0(0, OAM_SF_CFG, "hisi_wlan_add_netpattern:: memset_s fail.");
1253 return HI_FAIL;
1254 }
1255
1256 pattern.us_pattern_option = MAC_WOW_PATTERN_PARAM_OPTION_ADD;
1257 pattern.us_pattern_index = (hi_u16)netpattern_index;
1258 pattern.pattern_len = netpattern_len;
1259
1260 if ((pattern.us_pattern_index >= WOW_NETPATTERN_MAX_NUM) || (pattern.pattern_len == 0) ||
1261 (pattern.pattern_len > WOW_NETPATTERN_MAX_LEN) || (puc_netpattern_data == HI_NULL)) {
1262 oam_error_log3(0, OAM_SF_WOW,
1263 "{hisi_wlan_add_netpattern::WOW,ADD::param error, index = %d, len = %d, puc_netpattern_data[%p].}",
1264 pattern.us_pattern_index, pattern.pattern_len, (uintptr_t)puc_netpattern_data);
1265 return HI_FAIL;
1266 }
1267
1268 if (memcpy_s(&pattern.auc_pattern_value[0], WOW_NETPATTERN_MAX_LEN, puc_netpattern_data,
1269 pattern.pattern_len) != EOK) {
1270 oam_error_log0(0, OAM_SF_CFG, "hisi_wlan_add_netpattern:: puc_netpattern_data memcpy_s fail.");
1271 return HI_FAIL;
1272 }
1273
1274 return hmac_wow_set_pattern_cmd(&pattern);
1275 }
1276
1277 /* ****************************************************************************
1278 函 数 名 : hisi_wlan_del_netpattern
1279 功能描述 : 强制睡眠netpattern唤醒报文格式的删除API接口
1280 输入参数 : ul_netpattern_index: netpattern 的索引, 0~3
1281 输出参数 : 无
1282 返 回 值 : 0 : 成功
1283 非0: 失败
1284 调用函数 :
1285 被调函数 :
1286
1287 修改历史 :
1288 1.日 期 : 2017年01月05日
1289 作 者 : HiSilicon
1290 修改内容 : 新生成函数
1291
1292 **************************************************************************** */
hisi_wlan_del_netpattern(hi_u32 netpattern_index)1293 hi_u32 hisi_wlan_del_netpattern(hi_u32 netpattern_index)
1294 {
1295 hmac_cfg_wow_pattern_param_stru pattern = {0};
1296
1297 pattern.us_pattern_option = MAC_WOW_PATTERN_PARAM_OPTION_DEL;
1298 pattern.us_pattern_index = (hi_u16)netpattern_index;
1299
1300 return hmac_wow_set_pattern_cmd(&pattern);
1301 }
1302
1303 #ifdef __cplusplus
1304 #if __cplusplus
1305 }
1306 #endif
1307 #endif
1308