• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef __HMAC_VAP_H__
20 #define __HMAC_VAP_H__
21 
22 /* ****************************************************************************
23   1 其他头文件包含
24 **************************************************************************** */
25 #include "oal_ext_if.h"
26 #include "mac_vap.h"
27 #include "hmac_user.h"
28 #include "hmac_main.h"
29 #ifdef FEATURE_DAQ
30 #include "oal_data_collect.h"
31 #endif
32 
33 #ifdef __cplusplus
34 #if __cplusplus
35 extern "C" {
36 #endif
37 #endif
38 
39 /* ****************************************************************************
40   2 宏定义
41 **************************************************************************** */
42 #define hmac_vap_dft_stats_pkt_incr(_member, _cnt)
43 #define hmac_vap_stats_pkt_incr(_member, _cnt) ((_member) += (_cnt))
44 
45 #define HMAC_RSP_MSG_MAX_LEN 64 /* get wid返回消息最大长度 */
46 /* ****************************************************************************
47   3 枚举定义
48 **************************************************************************** */
49 /* ****************************************************************************
50     初始化vap特性枚举
51 **************************************************************************** */
52 typedef enum {
53     HMAC_ADDBA_MODE_AUTO,
54     HMAC_ADDBA_MODE_MANUAL,
55 
56     HMAC_ADDBA_MODE_BUTT
57 } hmac_addba_mode_enum;
58 typedef hi_u8 hmac_addba_mode_enum_uint8;
59 
60 /* ****************************************************************************
61   4 全局变量声明
62 **************************************************************************** */
63 /* ****************************************************************************
64   5 消息头定义
65 **************************************************************************** */
66 /* ****************************************************************************
67   6 消息定义
68 **************************************************************************** */
69 /* ****************************************************************************
70   7 STRUCT定义
71 **************************************************************************** */
72 /* hmac配置私有结构 */
73 typedef struct {
74     /* 用于wal_config层线程等待(wal_config-->hmac),给SDT下发读寄存器命令时用 */
75     oal_wait_queue_head_stru  wait_queue_for_sdt_reg;
76     hi_u8               wait_ack_for_sdt_reg;
77     hi_u8               auc_resv2[3]; /* 3 保留字节 */
78     hi_s8               ac_rsp_msg[HMAC_RSP_MSG_MAX_LEN];     /* get wid返回消息内存空间 */
79     hi_u32              dog_tag;
80 } hmac_vap_cfg_priv_stru;
81 
82 typedef struct {
83     oal_wait_queue_head_stru  wait_queue;
84     hi_u8                mgmt_tx_status;
85     hi_u8                mgmt_tx_complete;
86     hi_u8                mgmt_frame_id;
87     hi_u8                uc_resv;
88 } oal_mgmt_tx_stru;
89 
90 typedef enum {
91     HMAC_REPORT_DISASSOC = 0, /* Disassociation帧 */
92     HMAC_REPORT_DEAUTH = 1,   /* Deauthentication帧 */
93     HMAC_REPORT_ACTION = 2,   /* ACTION帧(目前只有SA Query Action帧) */
94 
95     DEVICE_REPORT_PROTECTED_BUTT
96 } hmac_report_disasoc_reason;
97 typedef hi_u16 hmac_report_disasoc_reason_uint16;
98 
99 /* end add */
100 typedef struct {
101     hi_list timeout_head;
102 } hmac_mgmt_timeout_stru;
103 
104 typedef struct {
105     hi_u8 user_index;
106     mac_vap_state_enum_uint8 state;
107     hi_u8 vap_id;
108     hi_u8 uc_resv;
109 } hmac_mgmt_timeout_param_stru;
110 
111 /* 修改此结构体需要同步通知SDT,否则上报无法解析 */
112 typedef struct {
113     /* **************************************************************************
114                                 收送包统计
115     ************************************************************************** */
116     /* 发往lan的数据包统计 */
117     hi_u32 rx_pkt_to_lan;   /* 接收流程发往以太网的数据包数目,MSDU */
118     hi_u32 rx_bytes_to_lan; /* 接收流程发往以太网的字节数 */
119 
120     /* **************************************************************************
121                                 发送包统计
122     ************************************************************************** */
123     /* 从lan接收到的数据包统计 */
124     hi_u32 tx_pkt_num_from_lan; /* 从lan过来的包数目,MSDU */
125     hi_u32 tx_bytes_from_lan;   /* 从lan过来的字节数 */
126 } hmac_vap_query_stats_stru;
127 /* 装备测试 */
128 typedef struct {
129     hi_u32 rx_pkct_succ_num;    /* 接收数据包数 */
130     hi_u32 dbb_num;             /* DBB版本号 */
131     hi_u32 check_fem_pa_status; /* fem和pa是否烧毁标志 */
132     hi_s16 s_rx_rssi;
133     hi_u8 get_dbb_completed_flag; /* 获取DBB版本号成功上报标志 */
134     hi_u8 check_fem_pa_flag;      /* fem和pa是否烧毁上报标志 */
135     hi_u8 get_rx_pkct_flag;       /* 接收数据包上报标志位 */
136     hi_u8 lte_gpio_check_flag;    /* 接收数据包上报标志位 */
137     hi_u8 reserved[2];            /* 2 保留字节 */
138 } hmac_atcmdsrv_get_stats_stru;
139 
140 typedef enum _hmac_tcp_opt_queue_ {
141     HMAC_TCP_ACK_QUEUE = 0,
142     HMAC_TCP_OPT_QUEUE_BUTT
143 } hmac_tcp_opt_queue;
144 
145 /* hmac vap结构体 */
146 /* 在向此结构体中增加成员的时候,请保持整个结构体8字节对齐 */
147 typedef struct hmac_vap_tag {
148     /* ap sta公共字段 */
149     oal_net_device_stru            *net_device;                   /* VAP对应的net_devices */
150 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
151     hmac_atcmdsrv_get_stats_stru     st_atcmdsrv_get_status;
152     oal_spin_lock_stru               st_lock_state;               /* 数据面和控制面对VAP状态进行互斥 */
153 #endif
154     oal_mgmt_tx_stru                mgmt_tx;
155     frw_timeout_stru                mgmt_timer;
156     hmac_mgmt_timeout_param_stru    mgmt_timetout_param;
157     frw_timeout_stru                scan_timeout;                  /* vap发起扫描时,会启动定时器,做超时保护处理 */
158     frw_timeout_stru                scanresult_clean_timeout;      /* vap扫描结束时,会启动定时器,做扫描结果老化处理 */
159 
160     wlan_auth_alg_enum_uint8        auth_mode;           /* 认证算法 */
161     hi_u8                           is80211i_mode;       /* 指示当前的方式时WPA还是WPA2, bit0 = 1,WPA; bit1 = 1, RSN */
162     hi_u8                           ba_dialog_token;     /* BA会话创建伪随机值 */
163 #ifdef _PRE_WLAN_FEATURE_PMF
164     hi_u8                           pre_assoc_status;
165 #else
166     hi_u8                           resv;
167 #endif
168 #ifdef _PRE_WLAN_FEATURE_P2P
169     oal_net_device_stru            *p2p0_net_device;              /* 指向p2p0 net device */
170     oal_net_device_stru            *del_net_device;               /* 指向需要通过cfg80211 接口删除的 net device */
171     oal_work_stru                   del_virtual_inf_worker;    /* 删除net_device 工作队列 */
172     hi_u8                           en_wait_roc_end;
173     hi_u8                           auc_resv0[3];
174     oal_completion                  st_roc_end_ready;         /* roc end completion */
175 #endif
176 #ifdef _PRE_WLAN_FEATURE_SMP_SUPPORT
177     oal_netbuf_head_stru            tx_queue_head[2];              /* 2个发送队列,2个线程pinpon操作 */
178     hi_u8                           in_queue_id;
179     hi_u8                           out_queue_id;
180     hi_u8                           auc_resv1[2];                  /* 2 保留字节 */
181     hi_atomic                       tx_event_num;                  /* frw发包事件的个数 */
182     hi_u32                          tx_quata;                      /* 发包配额,方便配置 */
183 #endif
184     hi_u16                          us_asoc_req_ie_len;
185     hi_u16                          us_del_timeout;                     /* 多长时间超时删除ba会话 如果是0则不删除 */
186 
187     hi_u8                           protocol_fall       : 1,        /* 降协议标志位 */
188                                     reassoc_flag        : 1,        /* 关联过程中判断是否为重关联动作 */
189                                     init_flag           : 1,        /* 常发关闭再次打开标志 */
190                                     ack_policy          : 1,        /* ack policy: 0:normal ack 1:normal ack */
191                                     wmm_cap             : 1,        /* 保存与STA关联的AP是否支持wmm能力信息 */
192                                     cfg_sta_pm_manual   : 1,        /* 手动设置sta pm mode的标志 */
193                                     query_wait_q_flag   : 2;        /* 查询标志,HI_TRUE查询结束,HI_FALSE未结束 */
194 
195     hi_u8                           addr_filter          : 1,
196                                     amsdu_active         : 1,
197                                     amsdu_ampdu_active   : 1,
198                                     wps_active           : 1,
199                                     tx_aggr_on           : 1,
200                                     ampdu_tx_on_switch   : 1,
201                                     pm_status_with_csi   : 1,        /* CSI打开时保存当前低功耗状态 */
202                                     is_csi_open          : 1;        /* CSI打开标志,以供判断当前是否可打开低功耗 */
203     hi_u8                           auth_cnt             : 4,        /* STA认证重试次数,最大值=3 */
204                                     asoc_cnt             : 4;        /* 关联重试次数,最大值=5 */
205     hi_u8                           rs_nrates;                       /* 速率个数 */
206 
207     hi_u8                           auc_supp_rates[WLAN_MAX_SUPP_RATES]; /* 支持的速率集 */
208     hi_u8                          *puc_asoc_req_ie_buff;
209     mac_cfg_mode_param_stru         preset_para;                         /* STA协议变更时变更前的协议模式 */
210     oal_wait_queue_head_stru        query_wait_q;
211 #ifdef FEATURE_DAQ
212     wlan_acq_result_addr_stru       acq_result_addr;
213     hi_u8                           station_info_query_completed_flag;
214     hi_u8                           acq_status_filter;
215     hi_u8                           auc_resv3[2];                         /* 2 保留字节 */
216 #endif
217     oal_station_info_stru           station_info;
218     oal_spin_lock_stru              cache_user_lock;                        /* cache_user lock */
219 #ifdef _PRE_WLAN_FEATURE_EDCA_OPT_AP
220     frw_timeout_stru                edca_opt_timer;                       /* edca参数调整定时器 */
221     hi_u16                          us_edca_opt_time_ms;                  /* edca参数调整计时器周期 ms */
222     hi_u8                           edca_opt_flag_ap;                     /* ap模式下是否使能edca优化特性 */
223     hi_u8                           edca_opt_flag_sta;                    /* sta模式下是否使能edca优化特性 */
224 #endif
225 
226 #ifdef _PRE_WLAN_FEATURE_AMPDU_VAP
227     hi_u8                           rx_ba_session_num;                    /* 该vap下,rx BA会话的数目 */
228     hi_u8                           tx_ba_session_num;                    /* 该vap下,tx BA会话的数目 */
229     hi_u8                           auc_resv4[2];                         /* 2 保留字节 */
230 #endif
231 
232 #if (_PRE_MULTI_CORE_MODE_OFFLOAD_DMAC == _PRE_MULTI_CORE_MODE)
233     mac_h2d_protection_stru         prot;
234 #endif
235 #ifdef _PRE_WLAN_FEATURE_STA_PM
236     frw_timeout_stru                ps_sw_timer;                          /* 低功耗开关 */
237 #endif
238 
239     hi_s8                           ap_rssi;
240 
241     hi_u8                           query_ap_rssi_flag : 1;     /* 取值范围:HI_TRUE、HI_FALSE */
242     hi_u8                           hmac_al_rx_flag    : 1;     /* hmac常收使能标志 */
243     hi_u8                           mac_filter_flag    : 1;     /* 常收mac地址过滤使能标志 */
244     hi_u8                           resv5              : 5;     /* 5 bit保留字段 */
245 
246     hi_u8                           max_ampdu_num;              /* ADDBA_REQ中,buffer_size的默认大小 */
247     hi_u8                           tx_traffic_classify_flag;   /* 业务识别功能开关 */
248 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
249     hi_u8                           resv[4];                    /* resv 4 bytes */
250 #endif
251     mac_vap_stru                    *base_vap;              /* MAC VAP指针,与mac资源序号对应,必须放最后,且不能修改 */
252 } hmac_vap_stru;
253 
254 /* ****************************************************************************
255   8 UNION定义
256 **************************************************************************** */
257 /* ****************************************************************************
258   9 OTHERS定义
259 **************************************************************************** */
260 /* ****************************************************************************
261   10 函数声明
262 **************************************************************************** */
263 hi_u32 hmac_vap_res_exit(hi_void);
264 hi_u32 hmac_vap_res_init(hi_void);
265 oal_net_device_stru *hmac_vap_get_net_device(hi_u8 vap_id);
266 hmac_vap_stru *hmac_vap_get_vap_stru(hi_u8 idx);
267 hi_u32 hmac_vap_destroy(hmac_vap_stru *hmac_vap);
268 hi_u32 hmac_vap_init(hmac_vap_stru *hmac_vap, hi_u8 vap_id, const mac_cfg_add_vap_param_stru *param);
269 hi_u32 hmac_vap_creat_netdev(hmac_vap_stru *hmac_vap, hi_char *puc_netdev_name, const hi_s8 *mac_addr,
270     hi_u8 mac_addr_len);
271 
272 hi_u16 hmac_vap_check_ht_capabilities_ap(const hmac_vap_stru *hmac_vap, hi_u8 *puc_payload, hi_u16 us_info_elem_offset,
273     hi_u32 msg_len, hmac_user_stru *hmac_user);
274 hi_u32 hmac_search_ht_cap_ie_ap(const hmac_vap_stru *hmac_vap, hmac_user_stru *hmac_user, hi_u8 *puc_payload,
275     hi_u16 us_current_offset, hi_bool prev_asoc_ht);
276 hi_void hmac_vap_net_startall(hi_void);
277 
278 #ifdef _PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL
279 hi_u8 hmac_flowctl_check_device_is_sta_mode(hi_void);
280 hi_void hmac_vap_net_start_subqueue(hi_u16 us_queue_idx);
281 hi_void hmac_vap_net_stop_subqueue(hi_u16 us_queue_idx);
282 #endif
283 
284 #ifdef _PRE_WLAN_FEATURE_OPMODE_NOTIFY
285 hi_u32 hmac_check_opmode_notify(hmac_vap_stru *hmac_vap, hi_u8 *puc_mac_hdr, hi_u8 *puc_payload,
286     hi_u16 us_info_elem_offset, hi_u32 msg_len, hmac_user_stru *hmac_user);
287 #endif
288 hi_void hmac_handle_disconnect_rsp(hmac_vap_stru *hmac_vap, const hmac_user_stru *hmac_user,
289     hmac_report_disasoc_reason_uint16 disasoc_reason);
290 #ifdef _PRE_WLAN_FEATURE_MESH
291 hi_u32 hmac_handle_close_peer_mesh(const hmac_vap_stru *hmac_vap, const hi_u8 *mac_addr, hi_u8 mac_addr_len,
292     hi_u16 us_disasoc_reason_code, hi_u16 us_dmac_reason_code);
293 #endif
294 hi_u32 hmac_tx_get_mac_vap(hi_u8 vap_id, mac_vap_stru **mac_vap);
295 
296 #ifdef __cplusplus
297 #if __cplusplus
298 }
299 #endif
300 #endif
301 
302 #endif /* __HMAC_VAP_H__ */
303