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_wur_ap.h 15 * Date: 2020-07-07 16 */ 17 18 #ifndef __HMAC_WUR_AP_H__ 19 #define __HMAC_WUR_AP_H__ 20 21 #include "oal_ext_if.h" 22 #include "hmac_vap.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif 28 #endif 29 30 #ifdef _PRE_WLAN_FEATURE_WUR_TX 31 32 /* 2 宏定义 */ 33 #define HMAC_WUR_BITS_OFFSET 32 34 #define WUR_LDR 0 35 #define WUR_HDR 1 36 #define WUR_SHORT 2 37 #define WUR_TU 1024 38 #define OOS_DATA_LEN 1500 39 40 /* 3 枚举定义 */ 41 typedef enum { 42 WUR_TYPE_INVAILD = 0, 43 WUR_TYPE_BEACON_LDR = 1, 44 WUR_TYPE_BEACON_HDR = 2, 45 WUR_TYPE_FL_WAKE_LDR = 3, 46 WUR_TYPE_FL_WAKE_HDR = 4, 47 WUR_TYPE_SHORT_WAKE_LDR = 5, 48 WUR_TYPE_SHORT_WAKE_HDR = 6, 49 } hmac_wur_frame_type_enum; 50 51 typedef enum { 52 WUR_UNICAST_WAKEUP = 0, 53 WUR_MULTICAST_WAKEUP = 1, 54 WUR_BSS_PARAM_WAKEUP = 2, 55 } hmac_wur_wakeup_type_enum; 56 typedef osal_u8 hmac_wur_wakeup_type_enum_uint8; 57 58 typedef enum { 59 WUR_DESC_TYPE_BEACON = 0, 60 WUR_DESC_TYPE_FL_WAKE = 1, 61 WUR_DESC_TYPE_SHORT_WAKE = 2, 62 } tx_desc_wur_frame_type_enum; 63 64 /* 新增枚举类型, 在更新WUR传事件时,用于区分来源 */ 65 typedef enum { 66 MAC_WUR_UPDATE_SOURCE_ASSOC = 0, 67 MAC_WUR_UPDATE_SOURCE_SETUP = 1, 68 MAC_WUR_UPDATE_SOURCE_TEARDOWN = 2, 69 MAC_WUR_UPDATE_SOURCE_MAX 70 } mac_wur_update_source_enum; 71 typedef osal_u8 mac_wur_update_source_enum_uint8; 72 73 /* WUR action帧类型 */ 74 typedef enum { 75 MAC_WUR_ACTION_MODE_SETUP = 0, 76 MAC_WUR_ACTION_MODE_TEARDOWN = 1, 77 MAC_WUR_ACTION_WAKEUP_INDICATION = 2, 78 } mac_wur_action_enum; 79 typedef osal_u8 mac_wur_action_enum_uint8; 80 81 /* WUR action type字段类型 */ 82 typedef enum { 83 MAC_WUR_ENTER_WUR_MODE_REQ = 0, 84 MAC_WUR_ENTER_WUR_MODE_RSP = 1, 85 MAC_WUR_ENTER_WUR_MODE_SUSPEND_REQ = 2, 86 MAC_WUR_ENTER_WUR_MODE_SUSPEND_RSP = 3, 87 MAC_WUR_ENTER_WUR_MODE_SUSPEND = 4, 88 MAC_WUR_ENTER_WUR_MODE = 5, 89 } mac_wur_action_type_enum; 90 typedef osal_u8 mac_wur_action_type_enum_uint8; 91 92 /* WUR Mode response status字段类型 */ 93 typedef enum { 94 MAC_WUR_MODE_ACCEPT = 0, 95 MAC_WUR_MODE_DENIED_UNSPECIFIED = 1, 96 MAC_WUR_MODE_DENIED_PERIOD = 2, 97 MAC_WUR_MODE_DENIED_KEEPALIVE = 3, 98 MAC_WUR_MODE_RESERVED = 255, 99 } mac_wur_response_status_enum; 100 typedef osal_u8 mac_wur_response_status_enum_uint8; 101 102 /* WUR更新事件参数 */ 103 typedef struct { 104 mac_wur_update_source_enum_uint8 update_source; 105 osal_u8 resv; 106 osal_u16 user_idx; 107 mac_wur_param_htd_stru wur_param_htd; 108 mac_user_wur_cap_ie_stru wur_cap_ie; 109 } hmac_ctx_update_wur_stru; 110 111 typedef struct { 112 osal_u8 mac_addr[WLAN_MAC_ADDR_LEN]; /* 用户的MAC ADDR */ 113 osal_u8 resv[2]; /* 2 byte保留字段 */ 114 mac_wur_mode_setup_frame_stru wur_mode_setup; 115 } mac_cfg_wur_mode_setup_param_stru; 116 117 typedef struct { 118 osal_u8 mac_addr[WLAN_MAC_ADDR_LEN]; /* 用户的MAC ADDR */ 119 osal_u8 resv[2]; /* 2 byte保留字段 */ 120 } mac_cfg_wur_mode_teardown_param_stru; 121 122 typedef struct { 123 osal_u8 twbtt_bcn_en : 1, /* TWBTT中断硬件发WUR BEACON开关 */ 124 wur_period_en : 1, /* WUR周期中断开关 */ 125 wur_frame_type : 4, /* WUR唤醒帧类型 0无效 */ 126 wur_enable : 1, /* WUR使能开关 */ 127 rsvd : 1; 128 osal_u8 resv[3]; /* 3 byte保留字段 */ 129 mac_wur_basic_param_stru wur_basic_param; /* hmac初始化同步到dmac */ 130 } mac_cfg_wur_enable_option_param_stru; 131 132 /* 10 函数声明 */ 133 osal_void hmac_wur_set_param_en(osal_u8 wur_twbtt_bcn_en, osal_u8 wur_period_en, 134 osal_u8 wur_frame_type); 135 osal_u8 hmac_wur_get_user_status(const hmac_user_stru *hmac_user); 136 osal_u8 hmac_wur_is_ps_enqueue(const hmac_user_stru *hmac_user); 137 osal_void hmac_wur_init_user_info(hmac_user_stru *hmac_user); 138 osal_void hmac_wur_user_del_handle(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user); 139 140 osal_s32 hmac_wur_update(hmac_vap_stru *hmac_vap, hmac_ctx_update_wur_stru *crx_action_sync); 141 osal_u32 dmac_mgmt_tx_wur_mode_setup(hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user, 142 const hmac_ctx_action_event_stru *ctx_action_event, oal_netbuf_stru *netbuf); 143 osal_u32 dmac_mgmt_tx_wur_mode_teardown(hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user, 144 const hmac_ctx_action_event_stru *ctx_action_event, oal_netbuf_stru *netbuf); 145 osal_u32 hmac_wur_mode_teardown_success(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user); 146 osal_void hmac_wur_action_tx_complete_process(hmac_vap_stru *hmac_vap, oal_netbuf_stru *netbuf, 147 osal_u8 dscr_status); 148 osal_u32 hmac_wur_is_all_support_hdr(const hmac_vap_stru *hmac_vap); 149 osal_void hmac_wur_write_wake_up_frame(const hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user, 150 osal_u8 is_multi, osal_u8 wur_bss_update_cnt, osal_u8 wur_frame_type); 151 osal_void hmac_wur_unicast_wake_process(hmac_vap_stru *hmac_vap); 152 osal_void hmac_wur_multi_wake_process(hmac_vap_stru *hmac_vap); 153 osal_s32 hmac_wur_sp_start_event(hmac_vap_stru *hmac_vap, frw_msg *msg); 154 osal_s32 hmac_wur_sp_end_event(hmac_vap_stru *hmac_vap, frw_msg *msg); 155 osal_void hmac_wur_ps_enqueue_process(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 156 mac_tx_ctl_stru *tx_ctrl); 157 osal_u8 hmac_wur_is_multi_flush(const hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user); 158 osal_void hmac_wur_bss_update_process(hmac_vap_stru *hmac_vap); 159 osal_void hmac_wur_ht_oper_ie_save(hmac_vap_stru *hmac_vap, const mac_ht_opern_stru *ht_opern_tmp); 160 osal_void hmac_wur_vht_oper_ie_save(hmac_vap_stru *hmac_vap, const mac_vht_opern_stru *vht_opern_tmp); 161 osal_void hmac_wur_he_oper_ie_save(hmac_vap_stru *hmac_vap, const mac_frame_he_operation_param_stru *he_opern_param, 162 const mac_frame_he_bss_color_info_stru *he_bss_color, const mac_frame_he_mcs_nss_bit_map_stru *mcs_bit_map); 163 osal_u32 hmac_wur_psm_rx_process(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 164 oal_netbuf_stru *net_buf); 165 osal_u32 hmac_wur_mode_setup_update(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 166 osal_u8 action_type); 167 osal_u32 hmac_wur_fill_start_time(const hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user, 168 const hmac_ctx_action_event_stru *ctx_action_event, const oal_netbuf_stru *netbuf); 169 osal_u32 hmac_wur_setup_succ_update(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 170 mac_wur_mode_ie_stru *wur_mode_element, const mac_wur_param_ap_field_stru *wur_param_ap_field); 171 osal_u32 hmac_wur_encap_wake_up_frame(const hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user, 172 osal_u8 is_multi, osal_u8 wur_bss_update_cnt, osal_u8 *wur_frame_type); 173 osal_u32 hmac_wur_sp_start_process(hmac_vap_stru *hmac_vap, frw_msg *msg); 174 osal_s32 hmac_wur_sp_end_process(hmac_vap_stru *hmac_vap, frw_msg *msg); 175 osal_u32 hmac_wur_frame_tx_complete_process(osal_u8 dscr_status, mac_tx_ctl_stru *cb, 176 hal_to_dmac_device_stru *hal_device); 177 osal_s32 hmac_config_wur_send_setup(hmac_vap_stru *hmac_vap, frw_msg *msg); 178 osal_s32 hmac_config_wur_send_teardown(hmac_vap_stru *hmac_vap, frw_msg *msg); 179 osal_s32 hmac_config_wur_enable_option(hmac_vap_stru *hmac_vap, frw_msg *msg); 180 181 osal_u32 hmac_ap_wur_update_event(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 182 mac_wur_update_source_enum_uint8 wur_update_source); 183 osal_u32 hmac_mgmt_tx_wur_mode_setup(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 184 mac_wur_param_htd_stru *wur_param_htd); 185 osal_u32 hmac_mgmt_tx_wur_mode_teardown(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user); 186 osal_u32 hmac_ap_rx_wur_mode_setup_frame(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 187 osal_u8 *payload); 188 osal_u32 hmac_ap_rx_wur_mode_teardown_frame(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user); 189 osal_u32 hmac_proc_wur_cap_ie(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 190 osal_u8 *wur_cap_ie); 191 192 /* 回调函数声明 */ 193 typedef osal_u32 (*hmac_wur_psm_rx_process_cb)(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 194 oal_netbuf_stru *net_buf); 195 typedef osal_u32 (*hmac_wur_mode_setup_update_cb)(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 196 osal_u8 action_type); 197 typedef osal_u32 (*hmac_wur_fill_start_time_cb)(const hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user, 198 const hmac_ctx_action_event_stru *ctx_action_event, const oal_netbuf_stru *netbuf); 199 typedef osal_u32 (*hmac_wur_setup_succ_update_cb)(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, 200 mac_wur_mode_ie_stru *wur_mode_element, const mac_wur_param_ap_field_stru *wur_param_ap_field); 201 typedef osal_u32 (*hmac_wur_mode_teardown_success_cb)(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user); 202 typedef osal_u32 (*hmac_wur_encap_wake_up_frame_cb)(const hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user, 203 osal_u8 is_multi, osal_u8 wur_bss_update_cnt, osal_u8 *wur_frame_type); 204 typedef osal_u8 (*hmac_wur_is_multi_flush_cb)(const hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user); 205 typedef osal_s32 (*hmac_wur_sp_start_process_cb)(hmac_vap_stru *hmac_vap, frw_msg *msg); 206 typedef osal_s32 (*hmac_wur_sp_end_process_cb)(hmac_vap_stru *hmac_vap, frw_msg *msg); 207 typedef osal_u32 (*hmac_wur_frame_tx_complete_process_cb)(osal_u8 dscr_status, mac_tx_ctl_stru *cb, 208 hal_to_dmac_device_stru *hal_device); 209 210 osal_void hmac_ap_up_rx_action_wur(hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, osal_u8 *data); 211 #endif 212 213 #ifdef __cplusplus 214 #if __cplusplus 215 } 216 #endif 217 #endif 218 219 #endif /* end of hmac_wur_ap.h */