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 "hmac_fsm.h"
23 #include "hmac_scan.h"
24 #include "hmac_mgmt_sta.h"
25 #include "hmac_config.h"
26
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif
31 #endif
32
33 /* ****************************************************************************
34 函数实现
35 **************************************************************************** */
36 /* ****************************************************************************
37 功能描述 : 改变状态机状态
38 输入参数 : pst_hmac_vap: HMAC VAP
39 en_vap_state: 要切换到的状态
40 修改历史 :
41 1.日 期 : 2013年6月19日
42 作 者 : HiSilicon
43 修改内容 : 新生成函数
44 **************************************************************************** */
hmac_fsm_change_state(hmac_vap_stru * hmac_vap,mac_vap_state_enum_uint8 vap_state)45 hi_void hmac_fsm_change_state(hmac_vap_stru *hmac_vap, mac_vap_state_enum_uint8 vap_state)
46 {
47 mac_cfg_mode_param_stru cfg_mode;
48 mac_vap_state_enum_uint8 old_state;
49 hi_u32 ret;
50 old_state = hmac_vap->base_vap->vap_state;
51
52 /* 将vap状态改变信息上报 */
53 mac_vap_state_change(hmac_vap->base_vap, vap_state);
54
55 ret = hmac_config_vap_state_syn(hmac_vap->base_vap, sizeof(vap_state), (hi_u8 *)(&vap_state));
56 if (ret != HI_SUCCESS) {
57 oam_error_log3(hmac_vap->base_vap->vap_id, OAM_SF_ASSOC,
58 "{hmac_fsm_change_state::hmac_syn_vap_state failed[%d], old_state=%d, new_state=%d.}", ret, old_state,
59 vap_state);
60 }
61 #ifdef _PRE_WLAN_FEATURE_STA_PM
62 /*
63 * sta start未关联, HMAC_SWITCH_STA_PSM_PERIOD后投休眠票
64 * sta start关联成功, HMAC_SWITCH_STA_PSM_PERIOD开启节能定时器
65 */
66 if ((hmac_vap->base_vap->vap_mode == WLAN_VAP_MODE_BSS_STA) &&
67 ((vap_state == MAC_VAP_STATE_STA_FAKE_UP) || (vap_state == MAC_VAP_STATE_UP))) {
68 if (hmac_vap->ps_sw_timer.is_registerd == HI_TRUE) {
69 frw_timer_immediate_destroy_timer(&(hmac_vap->ps_sw_timer));
70 }
71 frw_timer_create_timer(&(hmac_vap->ps_sw_timer), hmac_set_psm_timeout, HMAC_SWITCH_STA_PSM_PERIOD,
72 (hi_void *)hmac_vap, HI_FALSE);
73 }
74 #endif
75
76 /* 设置帧过滤寄存器 */
77 hmac_set_rx_filter_value(hmac_vap->base_vap);
78
79 if ((vap_state == MAC_VAP_STATE_STA_FAKE_UP) && (hmac_vap->base_vap->vap_mode == WLAN_VAP_MODE_BSS_STA)) {
80 cfg_mode.protocol = hmac_vap->preset_para.protocol;
81 cfg_mode.band = hmac_vap->preset_para.band;
82 cfg_mode.en_bandwidth = hmac_vap->preset_para.en_bandwidth;
83
84 hmac_config_sta_update_rates(hmac_vap->base_vap, &cfg_mode);
85 }
86 }
87
88 /* ****************************************************************************
89 功能描述 : 根据STA状态机处理扫描请求
90 输入参数 : pst_hmac_vap: hmac vap
91 pst_scan_params: 扫描请求参数
92 修改历史 :
93 1.日 期 : 2019年6月13日
94 作 者 : HiSilicon
95 修改内容 : 新生成函数
96 **************************************************************************** */
hmac_fsm_handle_scan_req(const mac_vap_stru * mac_vap,mac_scan_req_stru * scan_params)97 hi_u32 hmac_fsm_handle_scan_req(const mac_vap_stru *mac_vap, mac_scan_req_stru *scan_params)
98 {
99 hmac_vap_stru *hmac_vap = HI_NULL;
100
101 /* 入参在调用处已判空,这里仅对使用的指针判空 */
102 if (mac_vap == HI_NULL) {
103 oam_error_log0(0, OAM_SF_SCAN, "{hmac_fsm_handle_scan_req::mac vap null.}");
104 return HI_ERR_CODE_PTR_NULL;
105 }
106
107 hmac_vap = hmac_vap_get_vap_stru(mac_vap->vap_id);
108 if (hmac_vap == HI_NULL) {
109 oam_error_log0(0, OAM_SF_SCAN, "{hmac_fsm_handle_scan_req::hmac_vap is null.}");
110 return HI_ERR_CODE_PTR_NULL;
111 }
112
113 if (mac_vap->vap_state == MAC_VAP_STATE_PAUSE) {
114 /* 切换vap的状态为UP状态 */
115 hmac_fsm_change_state(hmac_vap, MAC_VAP_STATE_UP);
116 }
117
118 switch (mac_vap->vap_state) {
119 case MAC_VAP_STATE_INIT:
120 case MAC_VAP_STATE_STA_FAKE_UP:
121 case MAC_VAP_STATE_STA_SCAN_COMP:
122 case MAC_VAP_STATE_STA_JOIN_COMP:
123 case MAC_VAP_STATE_STA_AUTH_COMP:
124 case MAC_VAP_STATE_UP:
125 case MAC_VAP_STATE_STA_LISTEN:
126 return hmac_scan_proc_scan_req_event(hmac_vap, scan_params);
127
128 default:
129 return hmac_scan_proc_scan_req_event_exception(hmac_vap);
130 }
131 }
132
133 #ifdef __cplusplus
134 #if __cplusplus
135 }
136 #endif
137 #endif
138