• 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  * Description: hmac_sta_pm_rom.c 的头文件。
15  * Create: 2020-07-03
16  */
17 
18 #ifndef HMAC_STA_PM_H
19 #define HMAC_STA_PM_H
20 
21 /*****************************************************************************
22   1 其他头文件包含
23 *****************************************************************************/
24 #include "hmac_vap.h"
25 #include "msg_psm_rom.h"
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif
31 #endif
32 
33 /*****************************************************************************
34   2 宏定义
35 *****************************************************************************/
36 #define HMAC_ALLOW_SLEEP     (1)
37 #define HMAC_DISALLOW_SLEEP  (0)
38 
39 #define HMAC_WAKUP_MSG_WAIT_TIMEOUT    (600)
40 #define HMAC_SLEEP_MSG_WAIT_TIMEOUT    (600)
41 
42 #define HMAC_SLEEP_TIMER_PERIOD        (20)  /* 睡眠定时器20ms定时 */
43 
44 #define HMAC_MSG_RETRY_NUM      (3)
45 #define HMAC_FAIL_MAX_TIMES     (3)               /* 连续多少次wakeup失败,可进入DFR流程 */
46 /*****************************************************************************
47   3 枚举定义
48 *****************************************************************************/
49 /* TIM processing result */
50 typedef enum {
51     STA_PWR_SAVE_STATE_ACTIVE = 0,         /* active状态 */
52     STA_PWR_SAVE_STATE_DOZE,               /* doze状态 */
53     STA_PWR_SAVE_STATE_AWAKE,              /* wake状态 */
54 
55     STA_PWR_SAVE_STATE_BUTT                /* 最大状态 */
56 } sta_pwr_save_state_info;
57 
58 
59 enum HMAC_PM_STAGE {
60     HMAC_PM_STAGE_INIT              = 0,  // 初始
61     HMAC_SLEEP_REQ_SND              = 1,  // sleep request发送完成
62     HMAC_SLEEP_ALLOW_RCV            = 2,  // 收到allow sleep response
63     HMAC_SLEEP_DISALLOW_RCV         = 3,  // 收到allow sleep response
64     HMAC_SLEEP_CMD_SND              = 4,  // 允许睡眠reg设置完成
65     HMAC_WKUP_REQ_SND               = 5,
66     HMAC_WKUP_RSP_RCV               = 6,
67     HMAC_WKUP_CMD_SND               = 7,
68     HMAC_PM_STAGE_BUTT
69 };
70 
71 typedef enum {
72     STA_SYS_PM_STATE = 0,
73     STA_NOT_SLEEP_REASON_DUMP,
74     STA_WAKUP_REASON_DUMP,
75     STA_11B_BCN_INFO,
76     STA_WAKEUP_TIME_DUMP,
77 
78     STA_PM_DEBUG_INFO_BUTT
79 } sta_pm_debug_info;
80 
81 typedef enum {
82     HMAC_NOT_SLEEP_INFO_START = 0,
83     HMAC_NOT_SLEEP_SCAN = HMAC_NOT_SLEEP_INFO_START,
84     HMAC_NOT_SLEEP_VAP_NUM,
85     HMAC_NOT_SLEEP_PS_MODE,
86     HMAC_NOT_SLEEP_HCC,
87     HMAC_NOT_SLEEP_FRW,
88     HMAC_NOT_SLEEP_TX_CNT,
89 
90     HMAC_NOT_SLEEP_INFO_BUTT
91 } hmac_not_sleep_type;
92 /*****************************************************************************
93   4 全局变量声明
94 *****************************************************************************/
95 
96 /*****************************************************************************
97   7 STRUCT定义
98 *****************************************************************************/
99 typedef struct {
100     osal_u8 wlan_pm_enable;             // pm使能开关
101     osal_u8 wlan_dev_state;                  // wlan sleep state
102     osal_u8 pm_stage;
103     osal_u8 wakeup_err_count;         // 连续唤醒失败次数
104     osal_u8 fail_sleep_count;         // 连续睡眠失败次数
105     osal_u8 ignor_linkloss;
106     osal_u8 rsv[2];
107     osal_u32 pm_tx_activity_cnt;
108     frw_timeout_stru watchdog_timer;  // sleep watch dog
109     osal_u32 wdg_timeout_cnt;
110 
111     osal_wait wakeup_done;
112     osal_wait sleep_request_ack;
113     osal_mutex sleep_state_mutex;
114 } hmac_sta_pm_ctrl_info;
115 /*****************************************************************************
116   8 内联函数定义
117 *****************************************************************************/
118 
119 /*****************************************************************************
120   10 函数声明
121 *****************************************************************************/
122 osal_void hmac_pm_sta_attach(hmac_vap_stru *hmac_vap);
123 osal_void hmac_set_sta_pm_on_cb(hmac_vap_stru *hmac_vap, mac_cfg_ps_open_stru *pm_cfg);
124 osal_void hmac_config_mvap_set_sta_pm_on(hmac_vap_stru *hmac_vap, oal_bool_enum mvap_up);
125 osal_s32 hmac_sta_pm_on(hmac_vap_stru *hmac_vap, mac_pm_switch_enum_uint8 enable,
126     mac_pm_ctrl_type_enum_uint8 ctrl_type);
127 
128 static osal_u32 hmac_sta_pm_init_weakref(osal_void) __attribute__ ((weakref("hmac_sta_pm_init"), used));
129 static osal_void hmac_sta_pm_deinit_weakref(osal_void) __attribute__ ((weakref("hmac_sta_pm_deinit"), used));
130 
131 osal_void hmac_sta_pm_feed_wdg(hmac_sta_pm_ctrl_info *hmac_sta_pm_ctrl);
132 osal_void hmac_sta_pm_stop_wdg(hmac_sta_pm_ctrl_info *hmac_sta_pm_ctrl);
133 osal_u32 hmac_sta_pm_ctrl_set(osal_u32 flag);
134 osal_u8 hmac_sta_pm_get_wlan_dev_state(osal_void);
135 osal_s32 hmac_sta_pm_linkloss_ignor(osal_void);
136 osal_u32 hmac_sta_pm_wakeup_dev(uintptr_t *buf, osal_u32 len, osal_u32 data_type);
137 WIFI_HMAC_TCM_TEXT hmac_sta_pm_ctrl_info *hmac_sta_pm_get_ctrl(osal_void);
138 WIFI_HMAC_TCM_TEXT osal_u32 hmac_wifi_pm_get_host_allow_sleep(osal_void);
139 
140 osal_bool hmac_sta_pm_achba_keepalive(osal_u8 enable);
141 
142 typedef osal_u8 (*hmac_sta_pm_get_wlan_dev_state_cb)(osal_void);
143 typedef osal_s32 (*hmac_sta_pm_ignor_linkloss_cb)(osal_void);
144 typedef osal_u32 (*hmac_sta_pm_wakeup_dev_cb)(uintptr_t *buf, osal_u32 len, osal_u32 data_type);
145 #ifdef __cplusplus
146 #if __cplusplus
147 }
148 #endif
149 #endif
150 
151 #endif /* end of hmac_sts_pm.h */
152