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 "wlan_mib.h"
24 #include "frw_timer.h"
25 #include "wal_main.h"
26 #include "mac_device.h"
27 #include "mac_vap.h"
28 #include "mac_ie.h"
29 #include "mac_regdomain.h"
30 #include "mac_frame.h"
31 #include "dmac_ext_if.h"
32 #include "hmac_device.h"
33 #include "hmac_ext_if.h"
34 #include "hmac_fsm.h"
35 #include "hmac_vap.h"
36 #include "hmac_rx_data.h"
37 #include "hmac_config.h"
38 #include "hmac_chan_mgmt.h"
39 #include "hmac_mgmt_bss_comm.h"
40 #include "hmac_mgmt_sta.h"
41 #include "hmac_scan.h"
42 #include "hmac_mgmt_ap.h"
43 #include "hmac_11i.h"
44 #include "hmac_encap_frame_ap.h"
45 #include "hmac_sme_sta.h"
46 #include "hmac_config.h"
47 #ifdef _PRE_WLAN_FEATURE_WOW
48 #include "hmac_wow.h"
49 #endif
50 #include "wal_event_msg.h"
51 #include "wal_customize.h"
52 #ifdef _PRE_WLAN_FEATURE_P2P
53 #include "hmac_p2p.h"
54 #endif
55 #include "hmac_tx_data.h"
56 #ifdef _PRE_WLAN_FEATURE_ANY
57 #include "hmac_any.h"
58 #endif
59 #include "hmac_event.h"
60
61 #ifdef __cplusplus
62 #if __cplusplus
63 extern "C" {
64 #endif
65 #endif
66
67 /* ****************************************************************************
68 2 全局变量定义
69 **************************************************************************** */
70 #if (_PRE_MULTI_CORE_MODE == _PRE_MULTI_CORE_MODE_OFFLOAD_DMAC)
71 /* WLAN_DTX 事件子类型表 */
72 frw_event_sub_table_item_stru g_ast_hmac_wlan_dtx_event_sub_table[DMAC_TX_WLAN_DTX_BUTT];
73 /* HMAC模块 WLAN_DRX事件处理函数注册结构定义 */
74 frw_event_sub_table_item_stru g_ast_hmac_wlan_drx_event_sub_table[DMAC_WLAN_DRX_EVENT_SUB_TYPE_BUTT];
75 /* HMAC模块 WLAN_CRX事件处理函数注册结构定义 */
76 frw_event_sub_table_item_stru g_ast_hmac_wlan_crx_event_sub_table[DMAC_WLAN_CRX_SUB_TYPE_BUTT];
77 /* HMAC模块 MISC杂散事件处理函数注册结构定义 */
78 frw_event_sub_table_item_stru g_ast_hmac_wlan_misc_event_sub_table[DMAC_MISC_SUB_TYPE_BUTT];
79 /* HMAC模块 发向HOST侧的配置事件处理函数注册结构定义 */
80 frw_event_sub_table_item_stru g_ast_hmac_wlan_ctx_event_sub_table[DMAC_TO_HMAC_SYN_BUTT];
81 /* HOST CRX子表 */
82 frw_event_sub_table_item_stru g_ast_wal_host_crx_table[WAL_HOST_CRX_SUBTYPE_BUTT];
83 #endif
84
85 /* ================ cfgid操作全局变量 =============================================== */
86 static const wal_wid_op_stru g_ast_board_wid_op[] = {
87 /* cfgid 是否复位mac 保留一字节 get函数 set函数 */
88 #if defined(_PRE_WLAN_FEATURE_SIGMA) || defined(_PRE_DEBUG_MODE)
89 {WLAN_CFGID_ADDBA_REQ, HI_FALSE, {0}, HI_NULL, hmac_config_addba_req},
90 #endif
91 {WLAN_CFGID_SET_DSCR, HI_FALSE, {0}, HI_NULL, hmac_config_set_dscr_param},
92 {WLAN_CFGID_VAP_INFO, HI_FALSE, {0}, HI_NULL, hmac_config_vap_info},
93 #ifdef _PRE_WLAN_FEATURE_HIPRIV
94 {WLAN_CFGID_AMPDU_START, HI_FALSE, {0}, HI_NULL, hmac_config_ampdu_start},
95 {WLAN_CFGID_AMSDU_AMPDU_SWITCH, HI_FALSE, {0}, HI_NULL, hmac_config_amsdu_ampdu_switch},
96 {WLAN_CFGID_DELBA_REQ, HI_FALSE, {0}, HI_NULL, hmac_config_delba_req},
97 #endif
98 {WLAN_CFGID_USER_INFO, HI_FALSE, {0}, HI_NULL, hmac_config_user_info},
99
100 #ifdef _PRE_DEBUG_MODE
101 {WLAN_CFGID_BSS_TYPE, HI_TRUE, {0}, hmac_config_get_bss_type, hmac_config_set_bss_type},
102 #endif
103 {WLAN_CFGID_ADD_VAP, HI_FALSE, {0}, HI_NULL, hmac_config_add_vap},
104 {WLAN_CFGID_START_VAP, HI_FALSE, {0}, HI_NULL, hmac_config_start_vap},
105 {WLAN_CFGID_DEL_VAP, HI_FALSE, {0}, HI_NULL, hmac_config_del_vap},
106 {WLAN_CFGID_DOWN_VAP, HI_FALSE, {0}, HI_NULL, hmac_config_down_vap},
107 {WLAN_CFGID_MODE, HI_FALSE, {0}, hmac_config_get_mode, hmac_config_set_mode},
108 #ifdef _PRE_DEBUG_MODE
109 {WLAN_CFGID_BANDWIDTH, HI_FALSE, {0}, HI_NULL, hmac_config_set_mode},
110 #endif
111 {WLAN_CFGID_CURRENT_CHANEL, HI_FALSE, {0}, hmac_config_get_freq, hmac_config_set_freq},
112 {WLAN_CFGID_STATION_ID, HI_TRUE, {0}, HI_NULL, hmac_config_set_mac_addr},
113 {WLAN_CFGID_SSID, HI_FALSE, {0}, hmac_config_get_ssid, hmac_config_set_ssid},
114 {WLAN_CFGID_SHORTGI, HI_FALSE, {0}, hmac_config_get_shortgi20, hmac_config_set_shortgi20},
115 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
116 {WLAN_CFGID_SHORT_PREAMBLE, HI_FALSE, {0}, hmac_config_get_shpreamble, hmac_config_set_shpreamble},
117 {WLAN_CFGID_PROT_MODE, HI_FALSE, {0}, hmac_config_get_prot_mode, hmac_config_set_prot_mode},
118 {WLAN_CFGID_AUTH_MODE, HI_FALSE, {0}, hmac_config_get_auth_mode, hmac_config_set_auth_mode},
119 {WLAN_CFGID_BEACON_INTERVAL, HI_FALSE, {0}, hmac_config_get_bintval, hmac_config_set_bintval},
120 #endif
121 {WLAN_CFGID_TX_POWER, HI_FALSE, {0}, hmac_config_get_txpower, hmac_config_set_txpower},
122
123 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
124 {WLAN_CFGID_DTIM_PERIOD, HI_FALSE, {0}, hmac_config_get_dtimperiod, hmac_config_set_dtimperiod},
125 #endif
126 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
127 {WLAN_CFGID_EDCA_TABLE_CWMIN, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
128 {WLAN_CFGID_EDCA_TABLE_CWMAX, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
129 {WLAN_CFGID_EDCA_TABLE_AIFSN, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
130 {WLAN_CFGID_EDCA_TABLE_TXOP_LIMIT, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
131 {WLAN_CFGID_EDCA_TABLE_MSDU_LIFETIME, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
132 {WLAN_CFGID_EDCA_TABLE_MANDATORY, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
133 {WLAN_CFGID_QEDCA_TABLE_CWMIN, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
134 {WLAN_CFGID_QEDCA_TABLE_CWMAX, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
135 {WLAN_CFGID_QEDCA_TABLE_AIFSN, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
136 {WLAN_CFGID_QEDCA_TABLE_TXOP_LIMIT, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
137 {WLAN_CFGID_QEDCA_TABLE_MSDU_LIFETIME, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
138 {WLAN_CFGID_QEDCA_TABLE_MANDATORY, HI_FALSE, {0}, hmac_config_get_wmm_params, hmac_config_set_wmm_params},
139 #endif
140 #ifdef _PRE_WLAN_FEATURE_BTCOEX
141 {WLAN_CFGID_BTCOEX_ENABLE, HI_FALSE, {0}, HI_NULL, hmac_config_set_btcoex_en},
142 #endif
143 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
144 #ifdef _PRE_WLAN_FEATURE_HIPRIV
145 {WLAN_CFGID_REPORT_VAP_INFO, HI_FALSE, {0}, HI_NULL, hmac_config_report_vap_info},
146 #endif
147 #endif
148 {WLAN_CFGID_CLEAN_SCAN_RESULT, HI_FALSE, {0}, HI_NULL, hmac_scan_clean_result},
149 #ifdef _PRE_WLAN_FEATURE_REKEY_OFFLOAD
150 {WLAN_CFGID_SET_REKEY, HI_FALSE, {0}, HI_NULL, hmac_config_set_rekey_info},
151 #endif
152 #ifdef _PRE_WLAN_RF_110X_CALI_DPD
153 #ifdef _PRE_WLAN_FEATURE_HIPRIV
154 {WLAN_CFGID_START_DPD, HI_FALSE, {0}, HI_NULL, hmac_config_start_dpd},
155 #endif
156 #endif
157 {WLAN_CFGID_SET_PM_SWITCH, HI_FALSE, {0}, HI_NULL, hmac_config_set_pm_switch},
158 {WLAN_CFGID_KICK_USER, HI_FALSE, {0}, HI_NULL, hmac_config_kick_user},
159
160 {WLAN_CFGID_COUNTRY, HI_FALSE, {0}, hmac_config_get_country, hmac_config_set_country},
161 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
162 {WLAN_CFGID_TID, HI_FALSE, {0}, hmac_config_get_tid, HI_NULL},
163 #endif
164 {WLAN_CFGID_RX_FCS_INFO, HI_FALSE, {0}, HI_NULL, hmac_config_rx_fcs_info},
165 {WLAN_CFGID_SET_RATE, HI_FALSE, {0}, HI_NULL, hmac_config_set_rate},
166 {WLAN_CFGID_SET_MCS, HI_FALSE, {0}, HI_NULL, hmac_config_set_mcs},
167 #ifdef _PRE_WLAN_FEATURE_CFG_ALG
168 {WLAN_CFGID_ALG, HI_FALSE, {0}, HI_NULL, hmac_config_alg},
169 #endif
170 #if defined (_PRE_WLAN_FEATURE_HIPRIV) || defined (_PRE_WLAN_FEATURE_SIGMA)
171 {WLAN_CFGID_FRAG_THRESHOLD_REG, HI_FALSE, {0}, HI_NULL, hmac_config_frag_threshold},
172 {WLAN_CFGID_AMPDU_TX_ON, HI_FALSE, {0}, HI_NULL, hmac_config_set_ampdu_tx_on},
173 #endif
174 #ifdef _PRE_WLAN_FEATURE_HIPRIV
175 {WLAN_CFGID_LIST_CHAN, HI_FALSE, {0}, HI_NULL, hmac_config_list_channel},
176 {WLAN_CFGID_SEND_BAR, HI_FALSE, {0}, HI_NULL, hmac_config_send_bar},
177 #endif
178 #ifdef _PRE_DEBUG_MODE
179 {WLAN_CFGID_AMPDU_END, HI_FALSE, {0}, HI_NULL, hmac_config_ampdu_end},
180 #endif
181 #ifdef _PRE_WLAN_FEATURE_HIPRIV
182 {WLAN_CFGID_SET_AGGR_NUM, HI_FALSE, {0}, HI_NULL, hmac_config_set_ampdu_aggr_num},
183 #endif
184 {WLAN_CFGID_SET_STBC_CAP, HI_FALSE, {0}, HI_NULL, hmac_config_set_stbc_cap},
185 {WLAN_CFGID_SET_BW, HI_FALSE, {0}, hmac_config_get_bw, hmac_config_set_bw},
186 #ifdef _PRE_WLAN_FEATURE_ALWAYS_TX
187 {WLAN_CFGID_SET_ALWAYS_TX, HI_FALSE, {0}, HI_NULL, hmac_config_always_tx},
188 #endif
189 {WLAN_CFGID_SET_ALWAYS_RX, HI_FALSE, {0}, HI_NULL, hmac_config_always_rx},
190 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
191 #ifdef _PRE_WLAN_FEATURE_HIPRIV
192 {WLAN_CFGID_REG_INFO, HI_FALSE, {0}, HI_NULL, hmac_config_reg_info},
193 #endif
194 #endif
195 #ifdef _PRE_WLAN_FEATURE_WOW
196 #ifdef _PRE_WLAN_FEATURE_HIPRIV
197 {WLAN_CFGID_HOST_SLEEP_EN, HI_FALSE, {0}, HI_NULL, hmac_config_host_sleep_switch},
198 {WLAN_CFGID_SET_WOW, HI_FALSE, {0}, HI_NULL, hmac_config_set_wow},
199 {WLAN_CFGID_WOW_ACTIVATE_EN, HI_FALSE, {0}, HI_NULL, hmac_config_wow_activate_switch},
200 {WLAN_CFGID_SET_WOW_PATTERN, HI_FALSE, {0}, HI_NULL, hmac_config_set_wow_pattern},
201 #endif
202 {WLAN_CFGID_SET_WOW_PARAM, HI_FALSE, {0}, HI_NULL, hmac_config_wow_set_param},
203 #endif /* end of _PRE_WLAN_FEATURE_WOW */
204
205 #ifdef _PRE_WLAN_FEATURE_PROMIS
206 {WLAN_CFGID_MONITOR_EN, HI_FALSE, {0}, HI_NULL, hmac_config_set_monitor_switch},
207 #endif
208 #ifdef _PRE_WLAN_FEATURE_HIPRIV
209 {WLAN_CFGID_REG_WRITE, HI_FALSE, {0}, HI_NULL, hmac_config_reg_write},
210 #endif
211 #ifdef _PRE_DEBUG_MODE
212 {WLAN_CFGID_TXBF_SWITCH, HI_FALSE, {0}, HI_NULL, hmac_config_txbf_switch},
213 #endif
214 {WLAN_CFGID_SCAN_ABORT, HI_FALSE, {0}, HI_NULL, hmac_config_scan_abort},
215 /* 以下为内核cfg80211配置的命令 */
216 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
217 {WLAN_CFGID_CFG80211_START_SCHED_SCAN, HI_FALSE, {0}, HI_NULL, hmac_start_sched_scan},
218 {WLAN_CFGID_CFG80211_STOP_SCHED_SCAN, HI_FALSE, {0}, HI_NULL, hmac_stop_sched_scan},
219 #endif
220 {WLAN_CFGID_CFG80211_START_SCAN, HI_FALSE, {0}, HI_NULL, hmac_process_scan_req},
221 {WLAN_CFGID_CFG80211_START_CONNECT, HI_FALSE, {0}, HI_NULL, hmac_config_connect},
222 {WLAN_CFGID_CFG80211_SET_CHANNEL, HI_FALSE, {0}, HI_NULL, hmac_config_set_channel},
223 {WLAN_CFGID_CFG80211_CONFIG_BEACON, HI_FALSE, {0}, HI_NULL, hmac_config_set_beacon},
224
225 {WLAN_CFGID_ADD_KEY, HI_FALSE, {0}, HI_NULL, hmac_config_11i_add_key},
226 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
227 {WLAN_CFGID_GET_KEY, HI_FALSE, {0}, HI_NULL, hmac_config_11i_get_key},
228 #endif
229 {WLAN_CFGID_REMOVE_KEY, HI_FALSE, {0}, HI_NULL, hmac_config_11i_remove_key},
230 {WLAN_CFGID_ALG_PARAM, HI_FALSE, {0}, HI_NULL, hmac_config_alg_param},
231
232 #ifdef _PRE_WLAN_FEATURE_EDCA_OPT_AP_DEBUG
233 #ifdef _PRE_WLAN_FEATURE_HIPRIV
234 {WLAN_CFGID_EDCA_OPT_SWITCH_STA, HI_FALSE, {0}, HI_NULL, hmac_config_set_edca_opt_switch_sta},
235 {WLAN_CFGID_EDCA_OPT_SWITCH_AP, HI_FALSE, {0}, HI_NULL, hmac_config_set_edca_opt_switch_ap},
236 #endif
237 {WLAN_CFGID_EDCA_OPT_CYCLE_AP, HI_FALSE, {0}, HI_NULL, hmac_config_set_edca_opt_cycle_ap},
238 #endif
239
240 #ifdef _PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL
241 #ifdef _PRE_WLAN_FEATURE_HIPRIV
242 {WLAN_CFGID_SET_FLOWCTL_PARAM, HI_FALSE, {0}, HI_NULL, hmac_config_set_flowctl_param},
243 {WLAN_CFGID_GET_FLOWCTL_STAT, HI_FALSE, {0}, HI_NULL, hmac_config_get_flowctl_stat},
244 #endif
245 #endif
246 #ifdef _PRE_DEBUG_MODE
247 /* START:开源APP 程序下发的私有命令 */
248 {WLAN_CFGID_GET_ASSOC_REQ_IE, HI_FALSE, {0}, hmac_config_get_assoc_req_ie, HI_NULL},
249 #endif
250 {WLAN_CFGID_SET_RTS_THRESHHOLD, HI_FALSE, {0}, HI_NULL, hmac_config_rts_threshold},
251 /* END:开源APP 程序下发的私有命令 */
252 {WLAN_CFGID_DEFAULT_KEY, HI_FALSE, {0}, HI_NULL, hmac_config_11i_set_default_key},
253
254 {WLAN_CFGID_WMM_SWITCH, HI_FALSE, {0}, HI_NULL, hmac_config_open_wmm},
255 #ifdef _PRE_WLAN_FEATURE_HIPRIV
256 {WLAN_CFGID_SET_MIB, HI_FALSE, {0}, HI_NULL, hmac_config_set_mib},
257 {WLAN_CFGID_GET_MIB, HI_FALSE, {0}, HI_NULL, hmac_config_get_mib},
258 {WLAN_CFGID_SET_RANDOM_MAC_ADDR_SCAN, HI_FALSE, {0}, HI_NULL, hmac_config_set_random_mac_addr_scan},
259 #endif
260 #ifdef _PRE_DEBUG_MODE
261 #ifdef _PRE_WLAN_FEATURE_HIPRIV
262 {WLAN_CFGID_REGDOMAIN_PWR, HI_FALSE, {0}, HI_NULL, hmac_config_set_regdomain_pwr},
263 {WLAN_CFGID_START_JOIN, HI_FALSE, {0}, HI_NULL, hmac_config_start_join},
264 {WLAN_CFGID_START_DEAUTH, HI_FALSE, {0}, HI_NULL, hmac_config_send_deauth},
265 {WLAN_CFGID_ADD_USER, HI_FALSE, {0}, HI_NULL, hmac_config_add_user},
266 {WLAN_CFGID_SET_AUTO_PROTECTION, HI_FALSE, {0}, HI_NULL, hmac_config_set_auto_protection},
267 {WLAN_CFIGD_BGSCAN_ENABLE, HI_FALSE, {0}, HI_NULL, hmac_config_bgscan_enable},
268 #endif
269 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
270 {WLAN_CFGID_REDUCE_SAR, HI_FALSE, {0}, HI_NULL, hmac_config_set_regdomain_pwr},
271 #endif
272 #ifdef _PRE_WLAN_FEATURE_HIPRIV
273 {WLAN_CFGID_HIDE_SSID, HI_FALSE, {0}, HI_NULL, hmac_config_hide_ssid},
274 {WLAN_CFGID_START_SCAN, HI_FALSE, {0}, HI_NULL, hmac_sta_initiate_scan},
275 #endif
276 {WLAN_CFGID_DYNC_TXPOWER, HI_FALSE, {0}, HI_NULL, hmac_config_dync_txpower},
277 #ifdef _PRE_WLAN_FEATURE_HIPRIV
278 {WLAN_CFGID_VAP_PKT_STAT, HI_FALSE, {0}, HI_NULL, hmac_config_vap_pkt_stat},
279 #endif
280 {WLAN_CFGID_GET_ALL_REG_VALUE, HI_FALSE, {0}, HI_NULL, hmac_config_get_all_reg_value},
281 {WLAN_CFGID_REPORT_AMPDU_STAT, HI_FALSE, {0}, HI_NULL, hmac_config_report_ampdu_stat},
282 #ifdef _PRE_DEBUG_MODE
283 {WLAN_CFGID_SCAN_TEST, HI_FALSE, {0}, HI_NULL, hmac_config_scan_test},
284 #endif
285 {WLAN_CFGID_BTCOEX_INFO, HI_FALSE, {0}, HI_NULL, hmac_config_print_btcoex_status},
286 {WLAN_CFGID_GET_MPDU_NUM, HI_FALSE, {0}, HI_NULL, hmac_config_get_mpdu_num},
287 #endif
288
289 {WLAN_CFGID_CFG80211_MGMT_TX, HI_FALSE, {0}, HI_NULL, hmac_wpas_mgmt_tx},
290 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
291 {WLAN_CFGID_QUERY_STATION_STATS, HI_FALSE, {0}, HI_NULL, hmac_config_query_station_info},
292 #endif
293 #ifdef _PRE_WLAN_FEATURE_CSI
294 {WLAN_CFGID_CSI_SWITCH, HI_FALSE, {0}, HI_NULL, hmac_config_csi_set_switch},
295 {WLAN_CFGID_CSI_SET_CONFIG, HI_FALSE, {0}, HI_NULL, hmac_config_csi_set_config},
296 #endif
297
298 #ifdef _PRE_WLAN_FEATURE_STA_PM
299 {WLAN_CFGID_SET_PS_MODE, HI_FALSE, {0}, HI_NULL, hmac_config_set_sta_pm_mode},
300 #ifdef _PRE_WLAN_FEATURE_HIPRIV
301 {WLAN_CFGID_SET_PSM_PARAM, HI_FALSE, {0}, HI_NULL, hmac_config_set_pm_param},
302 #endif
303 {WLAN_CFGID_SET_STA_PM_ON, HI_FALSE, {0}, HI_NULL, hmac_config_set_sta_pm_on},
304 #ifdef _PRE_WLAN_FEATURE_HIPRIV
305 {WLAN_CFGID_SET_PSM_OFFSET, HI_FALSE, {0}, HI_NULL, hmac_config_set_psm_offset},
306 {WLAN_CFGID_SET_STA_HW_PS_MODE, HI_FALSE, {0}, HI_NULL, hmac_config_set_sta_hw_ps_mode},
307 #endif
308 #endif
309
310 #ifdef _PRE_WLAN_FEATURE_STA_UAPSD
311 {WLAN_CFGID_SET_UAPSD_PARA, HI_FALSE, {0}, HI_NULL, hmac_config_set_uapsd_para},
312 #endif
313 #ifdef _PRE_WLAN_FEATURE_P2P
314 {WLAN_CFGID_SEND_P2P_ACTION, HI_FALSE, {0}, HI_NULL, hmac_p2p_send_action},
315 {WLAN_CFGID_SET_WPS_P2P_IE, HI_FALSE, {0}, HI_NULL, hmac_p2p_set_wps_p2p_ie},
316 {WLAN_CFGID_CFG80211_REMAIN_ON_CHANNEL, HI_FALSE, {0}, HI_NULL, hmac_p2p_config_remain_on_channel},
317 {WLAN_CFGID_CFG80211_CANCEL_REMAIN_ON_CHANNEL, HI_FALSE, {0}, HI_NULL, hmac_p2p_cancel_remain_on_channel},
318 {WLAN_CFGID_SET_P2P_PS_OPS, HI_FALSE, {0}, HI_NULL, hmac_p2p_set_ps_ops},
319 {WLAN_CFGID_SET_P2P_PS_NOA, HI_FALSE, {0}, HI_NULL, hmac_p2p_set_ps_noa},
320 {WLAN_CFGID_SET_P2P_STATUS, HI_FALSE, {0}, HI_NULL, hmac_p2p_set_status},
321 #endif
322 #ifdef _PRE_WLAN_FEATURE_ARP_OFFLOAD
323 {WLAN_CFGID_ARP_OFFLOAD_SETTING, HI_FALSE, {0}, HI_NULL, hmac_config_arp_offload_setting},
324 #ifdef _PRE_WLAN_FEATURE_HIPRIV
325 {WLAN_CFGID_ARP_OFFLOAD_SHOW_INFO, HI_FALSE, {0}, HI_NULL, hmac_config_arp_offload_show_info},
326 #endif
327 #endif
328 #ifdef _PRE_WLAN_FEATURE_DHCP_OFFLOAD
329 {WLAN_CFGID_DHCP_OFFLOAD_SETTING, HI_FALSE, {0}, HI_NULL, hmac_config_dhcp_offload_setting},
330 #endif
331 #if (_PRE_MULTI_CORE_MODE == _PRE_MULTI_CORE_MODE_OFFLOAD_DMAC)
332 {WLAN_CFGID_CFG_VAP_H2D, HI_FALSE, {0}, HI_NULL, hmac_config_cfg_vap_h2d},
333 {WLAN_CFGID_HOST_DEV_INIT, HI_FALSE, {0}, HI_NULL, hmac_config_host_dev_init},
334 {WLAN_CFGID_HOST_DEV_EXIT, HI_FALSE, {0}, HI_NULL, hmac_config_host_dev_exit}, /* liuxiaoqi */
335 #endif
336 #ifdef _PRE_DEBUG_MODE
337 {WLAN_CFGID_SET_CHN_EST_CTRL, HI_FALSE, {0}, HI_NULL, hmac_config_set_chn_est_ctrl},
338 #endif
339 {WLAN_CFGID_SET_PM_CFG_PARAM, HI_FALSE, {0}, HI_NULL, hmac_config_set_pm_cfg_param},
340 {WLAN_CFGID_SET_CUS_RF, HI_FALSE, {0}, HI_NULL, hmac_config_set_cus_rf},
341 {WLAN_CFGID_SET_CUS_DTS_CALI, HI_FALSE, {0}, HI_NULL, hmac_config_set_cus_dts_cali},
342 {WLAN_CFGID_SET_CUS_NVRAM_PARAM, HI_FALSE, {0}, HI_NULL, hmac_config_set_cus_nvram_params},
343 {WLAN_CFGID_SET_CUS_FCC_TX_PWR, HI_FALSE, {0}, HI_NULL, hmac_config_set_cus_fcc_tx_params},
344 #ifdef _PRE_XTAL_FREQUENCY_COMPESATION_ENABLE
345 {WLAN_CFGID_SET_FREQ_COMP, HI_FALSE, {0}, HI_NULL, hmac_config_set_freq_comp},
346 #endif
347 #ifdef _PRE_DEBUG_MODE
348 {WLAN_CFGID_DESTROY_VAP, HI_FALSE, {0}, HI_NULL, hmac_config_vap_destroy},
349 #endif
350 {WLAN_CFGID_SET_RETRY_LIMIT, HI_FALSE, {0}, HI_NULL, hmac_config_set_retry_limit},
351 #ifdef _PRE_WLAN_FEATURE_MESH
352 {WLAN_CFGID_SET_MESH_STA, HI_FALSE, {0}, HI_NULL, hmac_config_set_mesh_user},
353 {WLAN_CFGID_SEND_MESH_ACTION, HI_FALSE, {0}, HI_NULL, hmac_config_send_mesh_action},
354 #ifdef _PRE_WLAN_FEATURE_HIPRIV
355 {WLAN_CFGID_SET_REPORT_TIMES_LIMIT, HI_FALSE, {0}, HI_NULL, hmac_config_set_report_times_limit},
356 {WLAN_CFGID_SET_REPORT_CNT_LIMIT, HI_FALSE, {0}, HI_NULL, hmac_config_set_report_cnt_limit},
357 #endif
358 {WLAN_CFGID_MESHID, HI_FALSE, {0}, hmac_config_get_meshid, hmac_config_set_meshid},
359 {WLAN_CFGID_ACCEPT_PEER, HI_FALSE, {0}, HI_NULL, hmac_config_set_accept_peer},
360 {WLAN_CFGID_SET_BEACON_PRIORITY, HI_FALSE, {0}, HI_NULL, hmac_config_set_beacon_priority},
361 #ifdef _PRE_WLAN_FEATURE_HIPRIV
362 {WLAN_CFGID_SET_MBR_EN, HI_FALSE, {0}, HI_NULL, hmac_config_set_en_mbr},
363 #endif
364 {WLAN_CFGID_SET_MNID, HI_FALSE, {0}, HI_NULL, hmac_config_set_mnid},
365 {WLAN_CFGID_ADD_MESH_USER, HI_FALSE, {0}, HI_NULL, hmac_config_add_mesh_user},
366 {WLAN_CFGID_SET_NEW_PEER_CONFIG_EN, HI_FALSE, {0}, HI_NULL, hmac_config_new_peer_candidate_en},
367 {WLAN_CFGID_SET_MESH_ACCEPT_STA, HI_FALSE, {0}, HI_NULL, hmac_config_set_mesh_accept_sta},
368 {WLAN_CFGID_SET_MESH_USER_GTK, HI_FALSE, {0}, HI_NULL, hmac_config_set_mesh_user_gtk},
369 {WLAN_CFGID_GET_MESH_NODE_INFO, HI_FALSE, {0}, hmac_config_get_mesh_nodeinfo, HI_NULL},
370 #endif
371
372 #ifdef _PRE_WLAN_FEATURE_TX_CLASSIFY_LAN_TO_WLAN
373 {WLAN_CFGID_TX_CLASSIFY_LAN_TO_WLAN_SWITCH, HI_FALSE, {0}, HI_NULL, hmac_config_set_tx_classify_switch},
374 #endif
375 {WLAN_CFGID_RSSI, HI_FALSE, {0}, HI_NULL, hmac_config_query_rssi},
376 {WLAN_CFGID_CUSTOM_PKT, HI_FALSE, {0}, HI_NULL, hmac_send_custom_pkt},
377 #ifdef _PRE_WLAN_FEATURE_ANY
378 {WLAN_CFGID_ANY_SEND_PEER_DATA, HI_FALSE, {0}, HI_NULL, hmac_any_send_action},
379 {WLAN_CFGID_ANY_ADD_PEER_INFO, HI_FALSE, {0}, HI_NULL, hmac_any_add_peer},
380 {WLAN_CFGID_ANY_DEL_PEER_INFO, HI_FALSE, {0}, HI_NULL, hmac_any_del_peer},
381 {WLAN_CFGID_ANY_INIT, HI_FALSE, {0}, HI_NULL, hmac_any_init},
382 {WLAN_CFGID_ANY_DEINIT, HI_FALSE, {0}, HI_NULL, hmac_any_deinit},
383 {WLAN_CFGID_ANY_SCAN, HI_FALSE, {0}, HI_NULL, hmac_any_start_scan},
384 {WLAN_CFGID_ANY_FETCH_PEER_INFO, HI_FALSE, {0}, HI_NULL, hmac_any_query_peer_by_index},
385 #endif
386 #ifdef FEATURE_DAQ
387 {WLAN_CFGID_DATA_ACQ_START, HI_FALSE, {0}, HI_NULL, hmac_config_data_acq_start},
388 {WLAN_CFGID_DATA_ACQ_STATUS, HI_FALSE, {0}, HI_NULL, hmac_config_data_acq_status},
389 {WLAN_CFGID_DATA_ACQ_REPORT, HI_FALSE, {0}, HI_NULL, hmac_config_data_acq_result},
390 #endif
391 #ifdef _PRE_WLAN_FEATURE_BW_HIEX
392 {WLAN_CFGID_SET_SELFCTS, HI_FALSE, {0}, HI_NULL, hmac_config_hiex_set_selfcts},
393 #endif
394 #ifdef _PRE_WLAN_FEATURE_MFG_TEST
395 {WLAN_CFGID_CAL_BAND_POWER, HI_FALSE, {0}, HI_NULL, hmac_config_set_cal_band_power},
396 {WLAN_CFGID_CAL_RATE_POWER, HI_FALSE, {0}, HI_NULL, hmac_config_set_cal_rate_power},
397 {WLAN_CFGID_CAL_FREQ, HI_FALSE, {0}, HI_NULL, hmac_config_set_cal_freq},
398 {WLAN_CFGID_SET_EFUSE_MAC, HI_FALSE, {0}, HI_NULL, hmac_config_set_efuse_mac},
399 {WLAN_CFGID_GET_EFUSE_MAC, HI_FALSE, {0}, HI_NULL, hmac_config_get_efuse_mac},
400 {WLAN_CFGID_SET_DATAEFUSE, HI_FALSE, {0}, HI_NULL, hmac_config_set_dataefuse},
401 #endif
402 {WLAN_CFGID_SET_CCA_TH, HI_FALSE, {0}, HI_NULL, hmac_config_set_cca_th},
403 #ifdef _PRE_WLAN_FEATURE_MFG_TEST
404 {WLAN_CFGID_GET_CAL_DATA, HI_FALSE, {0}, HI_NULL, hmac_config_get_cal_data},
405 #endif
406 {WLAN_CFGID_SET_TX_PWR_OFFSET, HI_FALSE, {0}, HI_NULL, hmac_config_set_tx_pwr_offset},
407 {WLAN_CFGID_GET_EFUSE_MAC_ADDR, HI_FALSE, {0}, HI_NULL, hmac_config_get_efuse_mac_addr},
408 #if defined(_PRE_WLAN_FEATURE_HIPRIV) && defined(_PRE_WLAN_FEATURE_INTRF_MODE)
409 {WLAN_CFGID_INTRF_MODE_ON, HI_FALSE, {0}, HI_NULL, hmac_config_set_intrf_mode},
410 #endif
411 {WLAN_CFGID_NOTIFY_GET_TX_PARAMS, HI_FALSE, {0}, HI_NULL, hmac_config_notify_get_tx_params},
412 {WLAN_CFGID_MINIMIZE_BOOT_CURRET, HI_FALSE, {0}, HI_NULL, hmac_config_minimize_boot_current},
413 {WLAN_CFGID_BUTT, HI_FALSE, {0}, 0, 0},
414 };
415
416 /* ================ hmac配置同步事件 ============================================= */
417 static const hmac_config_syn_stru g_ast_hmac_config_syn[] = {
418 /* 同步ID 保留2个字节 函数操作 */
419 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
420 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
421 {WLAN_CFGID_QUERY_STATION_STATS, {0, 0}, hmac_proc_query_response_event},
422 #endif
423 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
424 {WLAN_CFGID_THRUPUT_INFO, {0, 0}, hmac_get_thruput_info},
425 #endif
426 #endif
427 #ifdef _PRE_WLAN_FEATURE_BTCOEX
428 #ifdef _PRE_WLAN_FEATURE_HIPRIV
429 {WLAN_CFGID_BTCOEX_RX_DELBA_TRIGGER, {0, 0}, hmac_btcoex_rx_delba_trigger},
430 #endif
431 #endif
432 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
433 #ifdef _PRE_WLAN_FEATURE_HIPRIV
434 {WLAN_CFGID_REG_INFO, {0, 0}, hmac_wifitest_get_reg_info},
435 #endif
436 #endif
437 {WLAN_CFGID_CFG80211_MGMT_TX_STATUS, {0, 0}, hmac_mgmt_tx_event_status},
438 #ifdef _PRE_WLAN_FEATURE_MESH
439 {WLAN_CFGID_UNICAST_DATA_TX_INFO, {0, 0}, hmac_unicast_data_tx_event_info},
440 #endif
441 #ifdef _PRE_WLAN_FEATURE_ANY
442 {WLAN_CFGID_ANY_TX_STATUS, {0, 0}, hmac_any_tx_event_status},
443 {WLAN_CFGID_ANY_FETCH_PEER_INFO, {0, 0}, hmac_any_get_peer_info},
444 #endif
445 #ifdef FEATURE_DAQ
446 {WLAN_CFGID_DATA_ACQ_STATUS, {0, 0}, hmac_get_data_acq_status},
447 {WLAN_CFGID_DATA_ACQ_REPORT, {0, 0}, hmac_get_data_acq_result},
448 #endif
449 {WLAN_CFGID_RX_FCS_INFO, {0, 0}, hmac_get_rx_fcs_info},
450 #ifdef _PRE_WLAN_FEATURE_MFG_TEST
451 {WLAN_CFGID_MFG_TEST, {0, 0}, hmac_report_mfg_test},
452 {WLAN_CFGID_REPORT_CAL_DATA, {0, 0}, hmac_report_dbg_cal_data_from_dev},
453 #endif
454 {WLAN_CFGID_GET_MAC_FROM_EFUSE, {0, 0}, hmac_report_mac_from_efuse},
455 {WLAN_CFGID_RSSI, {0, 0}, hmac_proc_query_rssi_response},
456 #if defined (_PRE_WLAN_FEATURE_HIPRIV) || defined (_PRE_WLAN_FEATURE_SIGMA)
457 {WLAN_CFGID_AMPDU_TX_ON, {0, 0}, hmac_config_set_ampdu_tx_on_from_dmac},
458 #endif
459 {WLAN_CFGID_REPORT_TX_PARAMS, {0, 0}, hmac_config_report_tx_params},
460 {WLAN_CFGID_BUTT, {0, 0}, HI_NULL},
461 };
462
463 /* ****************************************************************************
464 3 函数实现
465 **************************************************************************** */
hmac_event_fsm_table_register(hi_void)466 hi_void hmac_event_fsm_table_register(hi_void)
467 {
468 /* Part1: 以下是Hmac收的事件 */
469 /* 注册WLAN_DTX事件子表 */
470 frw_event_table_register(FRW_EVENT_TYPE_WLAN_DTX, FRW_EVENT_PIPELINE_STAGE_0, g_ast_hmac_wlan_dtx_event_sub_table);
471
472 /* 注册WLAN_DRX事件子表 */
473 frw_event_table_register(FRW_EVENT_TYPE_WLAN_DRX, FRW_EVENT_PIPELINE_STAGE_1, g_ast_hmac_wlan_drx_event_sub_table);
474
475 /* 注册HMAC模块WLAN_CRX事件子表 */
476 frw_event_table_register(FRW_EVENT_TYPE_WLAN_CRX, FRW_EVENT_PIPELINE_STAGE_1, g_ast_hmac_wlan_crx_event_sub_table);
477
478 /* 注册DMAC模块MISC事件字表 */
479 frw_event_table_register(FRW_EVENT_TYPE_DMAC_MISC, FRW_EVENT_PIPELINE_STAGE_1,
480 g_ast_hmac_wlan_misc_event_sub_table);
481
482 /* 注册统计结果查询事件子表 */
483 frw_event_table_register(FRW_EVENT_TYPE_DMAC_TO_HMAC_CFG, FRW_EVENT_PIPELINE_STAGE_1,
484 g_ast_hmac_wlan_ctx_event_sub_table);
485
486 /* Part2: 以下是Hmac收Wal 的事件 */
487 frw_event_table_register(FRW_EVENT_TYPE_HOST_CRX, FRW_EVENT_PIPELINE_STAGE_0, g_ast_wal_host_crx_table);
488 }
489
490 /* ****************************************************************************
491 功能描述 : 处理配置查询请求
492 输入参数 : event_hdr : 事件头
493 puc_req_msg : 请求消息
494 us_req_msg_len : 请求消息长度
495 输出参数 : puc_rsp_msg : 返回消息
496 pus_rsp_msg_len : 返回消息长度
497 返 回 值 : HI_SUCCESS或其它错误码
498 修改历史 :
499 1.日 期 : 2012年11月9日
500 作 者 : HiSilicon
501 修改内容 : 新生成函数
502 **************************************************************************** */
wal_config_process_query(mac_vap_stru * mac_vap,hi_u8 * req,hi_u16 req_len,hi_u8 * rsp,hi_u8 * rsp_len)503 static hi_u32 wal_config_process_query(mac_vap_stru *mac_vap, hi_u8 *req, hi_u16 req_len, hi_u8 *rsp, hi_u8 *rsp_len)
504 {
505 hi_u16 us_req_idx = 0; /* 请求消息索引 */
506 hi_u16 us_rsp_idx = 0; /* 返回消息索引 */
507 hi_u16 us_len = 0; /* WID对应返回值的长度 */
508 hi_u16 us_cfgid;
509
510 /* 查询消息格式如下: */
511 /* +-------------------------------------------------------------------+ */
512 /* | WID0 | WID1 | WID2 | ................... | */
513 /* +-------------------------------------------------------------------+ */
514 /* | 2 Bytes | 2 Bytes | 2 Bytes | ................... | */
515 /* +-------------------------------------------------------------------+ */
516 /* 返回消息格式如下: */
517 /* +-------------------------------------------------------------------+ */
518 /* | WID0 | WID0 Length | WID0 Value | ......................... | */
519 /* +-------------------------------------------------------------------+ */
520 /* | 2 Bytes | 2 Byte | WID Length | ......................... | */
521 /* +-------------------------------------------------------------------+ */
522 while (us_req_idx < req_len) {
523 /* 从查询消息中得到一个WID值 */
524 wal_msg_query_stru *query_msg = (wal_msg_query_stru *)(&req[us_req_idx]);
525 us_req_idx += WAL_MSG_WID_LENGTH; /* 指向下一个WID */
526
527 /* 获取返回消息内存 */
528 wal_msg_write_stru *rsp_msg = (wal_msg_write_stru *)(&rsp[us_rsp_idx]);
529
530 /* 寻找cfgid 对应的get函数 */
531 for (us_cfgid = 0; WLAN_CFGID_BUTT != g_ast_board_wid_op[us_cfgid].cfgid; us_cfgid++) {
532 if (query_msg->wid == g_ast_board_wid_op[us_cfgid].cfgid) {
533 break;
534 }
535 }
536
537 /* 异常情况,cfgid不在操作函数表中 */
538 if (g_ast_board_wid_op[us_cfgid].cfgid == WLAN_CFGID_BUTT) {
539 oam_warning_log1(mac_vap->vap_id, OAM_SF_ANY,
540 "{wal_config_process_query::cfgid not invalid %d!}\r\n", query_msg->wid);
541 continue;
542 }
543
544 /* 异常情况,cfgid对应的get函数为空 */
545 if (g_ast_board_wid_op[us_cfgid].get_func == HI_NULL) {
546 oam_warning_log1(mac_vap->vap_id, OAM_SF_ANY,
547 "{wal_config_process_query::g_ast_board_wid_op get_func ptr is null, wid is %d!}\r\n", query_msg->wid);
548 continue;
549 }
550
551 hi_u32 ret = g_ast_board_wid_op[us_cfgid].get_func(mac_vap, &us_len, rsp_msg->auc_value);
552 if (ret != HI_SUCCESS) {
553 oam_warning_log3(mac_vap->vap_id, OAM_SF_ANY,
554 "{wal_config_process_query::g_ast_board_wid_op[cfg_id=%d] func return fail.wid and ret value is:%d,%d}",
555 us_cfgid, query_msg->wid, ret);
556 continue;
557 }
558
559 rsp_msg->wid = query_msg->wid; /* 设置返回消息的WID */
560 rsp_msg->us_len = us_len;
561
562 us_rsp_idx += us_len + WAL_MSG_WRITE_MSG_HDR_LENGTH; /* 消息体的长度 再加上消息头的长度 */
563
564 /* 消息Response 接口容易让调用者使用超过消息数组空间长度,
565 这里需要加判断,检查长度和狗牌,后续需要整改 */
566 if (oal_unlikely(us_rsp_idx + sizeof(wal_msg_hdr_stru) >= HMAC_RSP_MSG_MAX_LEN)) {
567 oam_error_log3(mac_vap->vap_id, OAM_SF_ANY, "{wal_config_process_query::cfgid=%d,msg_len:%u over limit:%u}",
568 us_cfgid, us_rsp_idx + sizeof(wal_msg_hdr_stru), HMAC_RSP_MSG_MAX_LEN);
569 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
570 oal_print_hex_dump((hi_u8 *)rsp, HMAC_RSP_MSG_MAX_LEN, 32, "puc_rsp_msg: "); /* 32:组大小 */
571 #endif
572 break;
573 }
574 }
575
576 *rsp_len = (hi_u8)us_rsp_idx;
577
578 return HI_SUCCESS;
579 }
580
581 /* ****************************************************************************
582 功能描述 : 处理配置设置请求
583 输入参数 : event_hdr: 事件头
584 puc_req_msg : 请求消息
585 us_msg_len : 请求消息长度
586 输出参数 : HI_SUCCESS或其它错误码
587 puc_rsp_msg : 返回消息
588 pus_rsp_msg_len : 返回消息长度
589 返 回 值 : 错误码
590 修改历史 :
591 1.日 期 : 2012年11月13日
592 作 者 : HiSilicon
593 修改内容 : 新生成函数
594 **************************************************************************** */
wal_config_process_write(mac_vap_stru * mac_vap,hi_u8 * puc_req_msg,hi_u16 us_msg_len,hi_u8 * puc_rsp_msg,hi_u8 * puc_rsp_msg_len)595 static hi_u32 wal_config_process_write(mac_vap_stru *mac_vap, hi_u8 *puc_req_msg, hi_u16 us_msg_len,
596 hi_u8 *puc_rsp_msg, hi_u8 *puc_rsp_msg_len)
597 {
598 hi_u16 us_req_idx = 0;
599 hi_u16 us_rsp_idx = 0;
600 hi_u16 us_cfgid;
601 wal_msg_write_stru *write_msg = HI_NULL;
602 wal_msg_write_rsp_stru *rsp_msg = HI_NULL;
603 hi_u32 ret;
604 if (oal_unlikely((mac_vap == HI_NULL) || (puc_req_msg == HI_NULL))) {
605 oam_error_log2(0, OAM_SF_ANY, "{wal_config_process_write::pst_mac_vap/puc_req_msg null ptr error %p, %p!}\r\n",
606 (uintptr_t)mac_vap, (uintptr_t)puc_req_msg);
607 return HI_ERR_CODE_PTR_NULL;
608 }
609
610 /* 设置消息的格式如下: */
611 /* +-------------------------------------------------------------------+ */
612 /* | WID0 | WID0 Length | WID0 Value | ......................... | */
613 /* +-------------------------------------------------------------------+ */
614 /* | 2 Bytes | 2 Byte | WID Length | ......................... | */
615 /* +-------------------------------------------------------------------+ */
616 /* 返回消息的格式如下: */
617 /* +-------------------------------------------------------------------+ */
618 /* | WID0 | resv | WID0 错误码 | WID1 | resv | WID1错误码 | | */
619 /* +-------------------------------------------------------------------+ */
620 /* | 2 Bytes | 2 Bytes | 4 Byte | 2 Bytes | 2 B | 4 Bytes | | */
621 /* +-------------------------------------------------------------------+ */
622 while (us_req_idx < us_msg_len) {
623 /* 获取一个设置WID消息 */
624 write_msg = (wal_msg_write_stru *)(&puc_req_msg[us_req_idx]);
625 /* 获取返回消息内存 */
626 rsp_msg = (wal_msg_write_rsp_stru *)(&puc_rsp_msg[us_rsp_idx]);
627
628 us_req_idx += write_msg->us_len + WAL_MSG_WRITE_MSG_HDR_LENGTH; /* 指向下一个WID设置消息 */
629
630 /* 寻找cfgid 对应的write函数 */
631 for (us_cfgid = 0; g_ast_board_wid_op[us_cfgid].cfgid != WLAN_CFGID_BUTT; us_cfgid++) {
632 if (write_msg->wid == g_ast_board_wid_op[us_cfgid].cfgid) {
633 break;
634 }
635 }
636
637 /* 异常情况,cfgid不在操作函数表中 */
638 if (g_ast_board_wid_op[us_cfgid].cfgid == WLAN_CFGID_BUTT) {
639 continue;
640 }
641 ret = g_ast_board_wid_op[us_cfgid].set_func(mac_vap, write_msg->us_len, write_msg->auc_value);
642 /* 将返回错误码设置到rsp消息中 */
643 rsp_msg->wid = write_msg->wid;
644 rsp_msg->err_code = ret;
645 us_rsp_idx += sizeof(wal_msg_write_rsp_stru);
646
647 /* 消息Response 接口容易让调用者使用超过消息数组空间长度,
648 这里需要加判断,检查长度和狗牌,后续需要整改 */
649 if (oal_unlikely(us_rsp_idx + sizeof(wal_msg_hdr_stru) > HMAC_RSP_MSG_MAX_LEN)) {
650 oam_error_log3(mac_vap->vap_id, OAM_SF_ANY,
651 "{wal_config_process_write::us_cfgid:%d response msg len:%u over limit:%u}", us_cfgid,
652 us_rsp_idx + sizeof(wal_msg_hdr_stru), HMAC_RSP_MSG_MAX_LEN);
653 }
654
655 if (ret != HI_SUCCESS) {
656 oam_warning_log3(mac_vap->vap_id, OAM_SF_ANY,
657 "{config_process_write::g_ast_board_wid_op[cfg_id=%d] func return failed. wid ret value is %d,%d!}\r\n",
658 us_cfgid, write_msg->wid, ret);
659 }
660 }
661
662 *puc_rsp_msg_len = (hi_u8)us_rsp_idx;
663
664 return HI_SUCCESS;
665 }
666
wal_set_msg_response(hi_u32 request_address,hi_u8 rsp_toal_len,const hi_u8 * rsp_msg)667 hi_u32 wal_set_msg_response(hi_u32 request_address, hi_u8 rsp_toal_len, const hi_u8 *rsp_msg)
668 {
669 hi_u8 *rsp_msg_tmp = HI_NULL;
670
671 if (request_address) {
672 rsp_msg_tmp = oal_memalloc(rsp_toal_len);
673 if (rsp_msg_tmp == NULL) {
674 oam_error_log1(0, OAM_SF_ANY, "{wal_set_msg_response:: msg alloc %u failed!", rsp_toal_len);
675
676 if (wal_set_msg_response_by_addr(request_address, NULL, HI_ERR_CODE_PTR_NULL, rsp_toal_len) != HI_SUCCESS) {
677 oam_error_log0(0, OAM_SF_ANY, "{wal_set_msg_response::didn't found the request msg!");
678 }
679 } else {
680 if (memcpy_s(rsp_msg_tmp, rsp_toal_len, rsp_msg, rsp_toal_len) != EOK) {
681 oal_free(rsp_msg_tmp);
682 oam_error_log0(0, OAM_SF_CFG, "wal_set_msg_response::ac_rsp_msg memcpy_s fail.");
683 return HI_FAIL;
684 }
685
686 if (wal_set_msg_response_by_addr(request_address, rsp_msg_tmp, HI_SUCCESS, rsp_toal_len) != HI_SUCCESS) {
687 oam_error_log0(0, OAM_SF_ANY, "{wal_set_msg_response::didn't found the request msg!");
688 oal_free(rsp_msg_tmp);
689 }
690 }
691 }
692
693 /* 唤醒WAL等待的进程 */
694 wal_cfg_msg_task_sched();
695 return HI_SUCCESS;
696 }
697
698 /* ****************************************************************************
699 功能描述 : 配置包事件处理
700 输入参数 : pst_event: 事件
701 返 回 值 : HI_SUCCESS或其它错误码
702 修改历史 :
703 1.日 期 : 2012年11月6日
704 作 者 : HiSilicon
705 修改内容 : 新生成函数
706 **************************************************************************** */
wal_config_process_pkt(frw_event_mem_stru * event_mem)707 hi_u32 wal_config_process_pkt(frw_event_mem_stru *event_mem)
708 {
709 hi_u32 ret;
710 hi_u8 ac_rsp_msg[HMAC_RSP_MSG_MAX_LEN] = {0};
711 hi_u8 rsp_len = 0;
712
713 if (oal_unlikely(event_mem == HI_NULL)) {
714 oam_error_log0(0, OAM_SF_ANY, "{wal_config_process_pkt::event_mem null ptr error!}\r\n");
715 return HI_ERR_CODE_PTR_NULL;
716 }
717
718 frw_event_stru *event = (frw_event_stru *)event_mem->puc_data;
719 frw_event_hdr_stru *event_hdr = &(event->event_hdr);
720 wal_msg_stru *msg = (wal_msg_stru *)(frw_get_event_payload(event_mem) + sizeof(wal_msg_rep_hdr));
721 mac_vap_stru *mac_vap = mac_vap_get_vap_stru(event_hdr->vap_id);
722 hi_u32 request_address = ((wal_msg_rep_hdr*)event->auc_event_data)->request_address;
723
724 if (oal_unlikely(mac_vap == HI_NULL)) {
725 oam_warning_log0(event_hdr->vap_id, OAM_SF_ANY, "{wal_config_process_pkt::hmac_get_vap_by_id return err code}");
726 return HI_ERR_CODE_PTR_NULL;
727 }
728
729 /* 取返回消息 */
730 wal_msg_stru *rsp_msg = (wal_msg_stru *)ac_rsp_msg;
731
732 /* 取配置消息的长度 */
733 /* event->auc_event_data, 可变数组 */
734 hi_u16 us_msg_len = msg->msg_hdr.us_msg_len;
735
736 switch (msg->msg_hdr.msg_type) {
737 case WAL_MSG_TYPE_QUERY:
738 ret = wal_config_process_query(mac_vap, msg->auc_msg_data, us_msg_len, rsp_msg->auc_msg_data, &rsp_len);
739 if (ret != HI_SUCCESS) {
740 oam_warning_log1(mac_vap->vap_id, OAM_SF_ANY, "{wal_config_process_pkt::query Err=%d}", ret);
741 return ret;
742 }
743 break;
744
745 case WAL_MSG_TYPE_WRITE:
746 ret = wal_config_process_write(mac_vap, msg->auc_msg_data, us_msg_len, rsp_msg->auc_msg_data, &rsp_len);
747 if (ret != HI_SUCCESS) {
748 oam_warning_log1(mac_vap->vap_id, OAM_SF_ANY, "{wal_config_process_pkt::write Err=%d}", ret);
749 return ret;
750 }
751 break;
752
753 default:
754 oam_warning_log1(mac_vap->vap_id, OAM_SF_ANY, "{wal_config_process_pkt::msg_type Err=%d}",
755 msg->msg_hdr.msg_type);
756 return HI_ERR_CODE_INVALID_CONFIG;
757 }
758
759 /* response 长度要包含头长 */
760 hi_u8 rsp_toal_len = rsp_len + sizeof(wal_msg_hdr_stru);
761 if (oal_unlikely(rsp_toal_len > HMAC_RSP_MSG_MAX_LEN)) {
762 oam_error_log1(mac_vap->vap_id, OAM_SF_ANY, "{wal_config_process_pkt::invalid response len %u}", rsp_toal_len);
763 return HI_FAIL;
764 }
765
766 /* 填充返回消息头 */
767 rsp_msg->msg_hdr.msg_type = WAL_MSG_TYPE_RESPONSE;
768 rsp_msg->msg_hdr.msg_sn = msg->msg_hdr.msg_sn;
769 rsp_msg->msg_hdr.us_msg_len = rsp_len;
770
771 return wal_set_msg_response(request_address, rsp_toal_len, ac_rsp_msg);
772 }
773
774 /* ****************************************************************************
775 功能描述 : hmac配置同步事件处理入口
776 输入参数 : event_mem: 事件内存结构体
777 修改历史 :
778 1.日 期 : 2013年4月28日
779 作 者 : HiSilicon
780 修改内容 : 新生成函数
781 **************************************************************************** */
hmac_event_config_syn(frw_event_mem_stru * event_mem)782 hi_u32 hmac_event_config_syn(frw_event_mem_stru *event_mem)
783 {
784 frw_event_stru *event = HI_NULL;
785 frw_event_hdr_stru *event_hdr = HI_NULL;
786 dmac_to_hmac_cfg_msg_stru *dmac2hmac_msg = HI_NULL;
787 mac_vap_stru *mac_vap = HI_NULL;
788 hi_u32 ret;
789 hi_u16 us_cfgid;
790
791 if (oal_unlikely(event_mem == HI_NULL)) {
792 oam_error_log0(0, OAM_SF_CFG, "{hmac_event_config_syn::event_mem null.}");
793
794 return HI_ERR_CODE_PTR_NULL;
795 }
796
797 /* 获取事件 */
798 event = (frw_event_stru *)event_mem->puc_data;
799 event_hdr = &(event->event_hdr);
800 dmac2hmac_msg = (dmac_to_hmac_cfg_msg_stru *)event->auc_event_data;
801
802 oam_info_log1(event_hdr->vap_id, OAM_SF_CFG, "{hmac_event_config_syn::a dmac config syn event occur, cfg_id=%d.}",
803 dmac2hmac_msg->syn_id);
804 /* 获取dmac vap */
805 mac_vap = mac_vap_get_vap_stru(event_hdr->vap_id);
806 if (mac_vap == HI_NULL) {
807 oam_error_log0(event_hdr->vap_id, OAM_SF_CFG, "{hmac_event_config_syn::pst_mac_vap null.}");
808
809 return HI_ERR_CODE_PTR_NULL;
810 }
811
812 /* 获得cfg id对应的操作函数 */
813 for (us_cfgid = 0; WLAN_CFGID_BUTT != g_ast_hmac_config_syn[us_cfgid].cfgid; us_cfgid++) {
814 if (g_ast_hmac_config_syn[us_cfgid].cfgid == dmac2hmac_msg->syn_id) {
815 break;
816 }
817 }
818
819 /* 异常情况,cfgid在g_ast_dmac_config_syn中不存在 */
820 if (WLAN_CFGID_BUTT == g_ast_hmac_config_syn[us_cfgid].cfgid) {
821 oam_warning_log1(event_hdr->vap_id, OAM_SF_CFG, "{hmac_event_config_syn::invalid en_cfgid[%d].",
822 dmac2hmac_msg->syn_id);
823 return HI_ERR_CODE_INVALID_CONFIG;
824 }
825
826 /* 执行操作函数 */
827 ret = g_ast_hmac_config_syn[us_cfgid].set_func(mac_vap, (hi_u8)(dmac2hmac_msg->us_len),
828 (hi_u8 *)dmac2hmac_msg->auc_msg_body);
829 if (ret != HI_SUCCESS) {
830 oam_warning_log2(event_hdr->vap_id, OAM_SF_CFG,
831 "{hmac_event_config_syn::p_set_func failed, ul_ret=%d en_syn_id=%d.", ret, dmac2hmac_msg->syn_id);
832 return ret;
833 }
834
835 return HI_SUCCESS;
836 }
837
838 /* ****************************************************************************
839 功能描述 : hmac接收dmac控制事件
840 **************************************************************************** */
hmac_from_dmac_rx_control_handle(frw_event_mem_stru * event_mem)841 hi_u32 hmac_from_dmac_rx_control_handle(frw_event_mem_stru *event_mem)
842 {
843 frw_event_hdr_stru *event_hdr = HI_NULL;
844 const frw_event_sub_table_item_stru *sub_table_item = HI_NULL;
845
846 event_hdr = frw_get_event_hdr(event_mem);
847 sub_table_item = frw_get_event_sub_table(event_hdr->type, FRW_EVENT_PIPELINE_STAGE_1);
848 if (sub_table_item == NULL) {
849 return HI_FAIL;
850 }
851
852 return sub_table_item[event_hdr->sub_type].func(event_mem);
853 }
854
855 /* ****************************************************************************
856 功能描述 : hmac接收dmac数据事件
857 **************************************************************************** */
hmac_from_dmac_rx_data_handle(frw_event_mem_stru * event_mem,oal_netbuf_stru * netbuf,hi_u16 netbuf_num)858 hi_u32 hmac_from_dmac_rx_data_handle(frw_event_mem_stru *event_mem, oal_netbuf_stru *netbuf, hi_u16 netbuf_num)
859 {
860 frw_event_stru *event = frw_get_event_stru(event_mem);
861 frw_event_hdr_stru *event_hdr = frw_get_event_hdr(event_mem);
862 dmac_wlan_crx_event_stru *wlan_crx_event = (dmac_wlan_crx_event_stru *)(event->auc_event_data);
863 dmac_tx_event_stru *crx_event = (dmac_tx_event_stru *)(event->auc_event_data);
864 dmac_wlan_drx_event_stru *wlan_rx_event = (dmac_wlan_drx_event_stru *)(event->auc_event_data);
865 const frw_event_sub_table_item_stru *sub_table_item = HI_NULL;
866
867 if (event_hdr->type == FRW_EVENT_TYPE_WLAN_CRX) {
868 switch (event_hdr->sub_type) {
869 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
870 case DMAC_WLAN_CRX_INIT:
871 #endif
872 #ifdef _PRE_WLAN_FEATURE_PROMIS
873 case DMAC_WLAN_CRX_EVENT_PROMIS:
874 #endif
875 case DMAC_WLAN_CRX_RX:
876 wlan_crx_event->netbuf = (oal_dev_netbuf_stru *)netbuf;
877 break;
878 case DMAC_WLAN_CRX_NEW_PEER_REPORT:
879 case DMAC_WLAN_CRX_SCAN_RESULT:
880 crx_event->netbuf = netbuf;
881 break;
882 default:
883 hi_diag_log_msg_e1(0, "hmac_from_dmac_rx_data_handle:: invalid CRX sub-type:%d.", event_hdr->sub_type);
884 return HI_FAIL;
885 }
886
887 sub_table_item = g_ast_hmac_wlan_crx_event_sub_table;
888 } else if (event_hdr->type == FRW_EVENT_TYPE_WLAN_DRX) {
889 switch (event_hdr->sub_type) {
890 case DMAC_WLAN_DRX_EVENT_SUB_TYPE_RX_AP:
891 case DMAC_WLAN_DRX_EVENT_SUB_TYPE_RX_STA:
892 wlan_rx_event->netbuf = (oal_dev_netbuf_stru *)netbuf;
893 wlan_rx_event->us_netbuf_num = netbuf_num;
894 break;
895 default:
896 hi_diag_log_msg_e1(0, "hmac_from_dmac_rx_data_handle:: invalid DRX sub-type:%d.", event_hdr->sub_type);
897 return HI_FAIL;
898 }
899 sub_table_item = g_ast_hmac_wlan_drx_event_sub_table;
900 }
901
902 if (sub_table_item == HI_NULL) {
903 oam_warning_log0(0, 0, "hmac_from_dmac_rx_data_handle:pst_sub_table_item is null!");
904 return HI_FAIL;
905 }
906 return sub_table_item[event_hdr->sub_type].func(event_mem);
907 }
908
909 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
910 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
911 /* ****************************************************************************
912 函 数 名 : hmac_proc_query_response_event
913 功能描述 : hmac接收dmac抛回来的查询应答事件
914 输入参数 : 无
915 输出参数 : 无
916 返 回 值 :
917 调用函数 :
918 被调函数 :
919
920 修改历史 :
921 1.日 期 : 2014年11月26日
922 作 者 : HiSilicon
923 修改内容 : 新生成函数
924
925 **************************************************************************** */
hmac_proc_query_response_event(mac_vap_stru * mac_vap,hi_u8 len,const hi_u8 * puc_param)926 hi_u32 hmac_proc_query_response_event(mac_vap_stru *mac_vap, hi_u8 len, const hi_u8 *puc_param)
927 {
928 hmac_vap_stru *hmac_vap = HI_NULL;
929 dmac_query_station_info_response_event *query_station_reponse_event = HI_NULL;
930
931 hmac_vap = hmac_vap_get_vap_stru(mac_vap->vap_id);
932 if (hmac_vap == HI_NULL) {
933 oam_error_log0(mac_vap->vap_id, OAM_SF_ANY, "{hmac_query_response::pst_hmac_vap null.}");
934 return HI_ERR_CODE_PTR_NULL;
935 }
936
937 query_station_reponse_event = (dmac_query_station_info_response_event *)(puc_param);
938 if (query_station_reponse_event->query_event == OAL_QUERY_STATION_INFO_EVENT) {
939 hmac_vap->station_info.signal = (hi_s8)query_station_reponse_event->signal;
940 hmac_vap->station_info.rx_packets = query_station_reponse_event->rx_packets;
941 hmac_vap->station_info.tx_packets = query_station_reponse_event->tx_packets;
942 hmac_vap->station_info.rx_bytes = query_station_reponse_event->rx_bytes;
943 hmac_vap->station_info.tx_bytes = query_station_reponse_event->tx_bytes;
944 hmac_vap->station_info.tx_retries = query_station_reponse_event->tx_retries;
945 hmac_vap->station_info.rx_dropped_misc =
946 hmac_vap->station_info.rx_dropped_misc + query_station_reponse_event->rx_dropped_misc;
947 hmac_vap->station_info.tx_failed = query_station_reponse_event->tx_failed;
948 hmac_vap->station_info.txrate = query_station_reponse_event->txrate;
949 }
950
951 /* 唤醒wal_sdt_recv_reg_cmd等待的进程 */
952 hmac_vap->query_wait_q_flag = HI_TRUE;
953 hi_wait_queue_wake_up_interrupt(&(hmac_vap->query_wait_q));
954
955 return HI_SUCCESS;
956 }
957
958 #endif
959 #endif
960
961 /* ****************************************************************************
962 功能描述 : hmac 抛事件到 wal
963 **************************************************************************** */
hmac_send_event_to_host(const mac_vap_stru * mac_vap,const hi_u8 * param,hi_u16 len,hi_u8 sub_type)964 hi_u32 hmac_send_event_to_host(const mac_vap_stru *mac_vap, const hi_u8 *param, hi_u16 len, hi_u8 sub_type)
965 {
966 frw_event_mem_stru *event_mem = HI_NULL;
967 frw_event_stru *event = HI_NULL;
968 hi_u32 ret;
969
970 /* 抛事件到WAL */
971 event_mem = frw_event_alloc(len);
972 if ((event_mem == HI_NULL) || (event_mem->puc_data == HI_NULL)) {
973 oam_error_log0(0, OAM_SF_ANY, "{hmac_send_event_to_host::event_mem null.}");
974 return HI_FAIL;
975 }
976
977 /* 填写事件 */
978 event = (frw_event_stru *)event_mem->puc_data;
979
980 frw_event_hdr_init(&(event->event_hdr), FRW_EVENT_TYPE_HOST_CTX, sub_type, len, FRW_EVENT_PIPELINE_STAGE_0,
981 mac_vap->vap_id);
982 if (param != HI_NULL) {
983 if (memcpy_s(event->auc_event_data, len, param, len) != EOK) {
984 oam_error_log0(0, OAM_SF_CFG, "hmac_send_event_to_host::pst_peer_param memcpy fail.");
985 frw_event_free(event_mem);
986 return HI_FAIL;
987 }
988 }
989 /* 分发事件 */
990 ret = frw_event_dispatch_event(event_mem);
991 frw_event_free(event_mem);
992 return ret;
993 }
994
995 #ifdef __cplusplus
996 #if __cplusplus
997 }
998 #endif
999 #endif
1000