• 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 __WAL_CFG80211_H__
20 #define __WAL_CFG80211_H__
21 
22 /* ****************************************************************************
23   1 其他头文件包含
24 **************************************************************************** */
25 #include "oal_ext_if.h"
26 #include "wal_main.h"
27 #include "hmac_ext_if.h"
28 #include "wal_ioctl.h"
29 #include "wal_hipriv.h"
30 #include "wal_scan.h"
31 #include "oal_net.h"
32 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
33 #ifndef HAVE_PCLINT_CHECK
34 #include "hi_wifi_driver_wpa_if.h"
35 #endif
36 #endif
37 #ifdef _PRE_WLAN_FEATURE_P2P
38 #include "hmac_p2p.h"
39 #endif
40 
41 #ifdef __cplusplus
42 #if __cplusplus
43 extern "C" {
44 #endif
45 #endif
46 
47 /* ****************************************************************************
48   2 宏定义
49 **************************************************************************** */
50 #define WAL_MAX_SCAN_TIME_PER_CHANNEL 400
51 #define WAL_MAX_SCAN_TIME_PER_SCAN_REQ (5 * 1000) /* wpa_s下发扫描请求,超时时间为5s,单位为ms */
52 
53 /* channel index and frequency */
54 #define WAL_MIN_CHANNEL_2G      1
55 #define WAL_MAX_CHANNEL_2G      14
56 #define WAL_FREQ_2G_INTERVAL    5
57 #define MHZ_TO_KHZ              1000
58 
59 #define WAL_MIN_FREQ_2G         (2412 + 5*(WAL_MIN_CHANNEL_2G - 1))
60 #define WAL_MAX_FREQ_2G         2484
61 
62 /* wiphy 结构体初始化变量 */
63 #define WAL_MAX_SCAN_IE_LEN                 1000
64 /* 802.11n HT 能力掩码 */
65 #define IEEE80211_HT_CAP_LDPC_CODING        0x0001
66 #define IEEE80211_HT_CAP_SUP_WIDTH_20_40    0x0002
67 #define IEEE80211_HT_CAP_SM_PS              0x000C
68 #define IEEE80211_HT_CAP_SM_PS_SHIFT        2
69 #define IEEE80211_HT_CAP_GRN_FLD            0x0010
70 #define IEEE80211_HT_CAP_SGI_20             0x0020
71 #define IEEE80211_HT_CAP_SGI_40             0x0040
72 #define IEEE80211_HT_CAP_TX_STBC            0x0080
73 #define IEEE80211_HT_CAP_RX_STBC            0x0300
74 #define IEEE80211_HT_CAP_DELAY_BA           0x0400
75 #define IEEE80211_HT_CAP_MAX_AMSDU          0x0800
76 #define IEEE80211_HT_CAP_DSSSCCK40          0x1000
77 #define IEEE80211_HT_CAP_RESERVED           0x2000
78 #define IEEE80211_HT_CAP_40MHZ_INTOLERANT   0x4000
79 #define IEEE80211_HT_CAP_LSIG_TXOP_PROT     0x8000
80 
81 /* 802.11ac VHT Capabilities */
82 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895              0x00000000
83 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991              0x00000001
84 #define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454             0x00000002
85 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ            0x00000004
86 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ   0x00000008
87 #define IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK              0x0000000C
88 #define IEEE80211_VHT_CAP_RXLDPC                            0x00000010
89 #define IEEE80211_VHT_CAP_SHORT_GI_80                       0x00000020
90 #define IEEE80211_VHT_CAP_SHORT_GI_160                      0x00000040
91 #define IEEE80211_VHT_CAP_TXSTBC                            0x00000080
92 #define IEEE80211_VHT_CAP_RXSTBC_1                          0x00000100
93 #define IEEE80211_VHT_CAP_RXSTBC_2                          0x00000200
94 #define IEEE80211_VHT_CAP_RXSTBC_3                          0x00000300
95 #define IEEE80211_VHT_CAP_RXSTBC_4                          0x00000400
96 #define IEEE80211_VHT_CAP_RXSTBC_MASK                       0x00000700
97 #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE             0x00000800
98 #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE             0x00001000
99 #define IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX           0x00006000
100 #define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX           0x00030000
101 #define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE             0x00080000
102 #define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE             0x00100000
103 #define IEEE80211_VHT_CAP_VHT_TXOP_PS                       0x00200000
104 #define IEEE80211_VHT_CAP_HTC_VHT                           0x00400000
105 #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT  23
106 #define IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK   (7 << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT)
107 #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB 0x08000000
108 #define IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB   0x0c000000
109 #define IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN                0x10000000
110 #define IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN                0x20000000
111 
112 /* management */
113 #define IEEE80211_STYPE_ASSOC_REQ       0x0000
114 #define IEEE80211_STYPE_ASSOC_RESP      0x0010
115 #define IEEE80211_STYPE_REASSOC_REQ     0x0020
116 #define IEEE80211_STYPE_REASSOC_RESP    0x0030
117 #define IEEE80211_STYPE_PROBE_REQ       0x0040
118 #define IEEE80211_STYPE_PROBE_RESP      0x0050
119 #define IEEE80211_STYPE_BEACON          0x0080
120 #define IEEE80211_STYPE_ATIM            0x0090
121 #define IEEE80211_STYPE_DISASSOC        0x00A0
122 #define IEEE80211_STYPE_AUTH            0x00B0
123 #define IEEE80211_STYPE_DEAUTH          0x00C0
124 #define IEEE80211_STYPE_ACTION          0x00D0
125 
126 #define WAL_COOKIE_ARRAY_SIZE           8       /* 采用8bit 的map 作为保存cookie 的索引状态 */
127 #define WAL_MGMT_TX_TIMEOUT_MSEC        100     /* WAL 发送管理帧超时时间 */
128 #define WAL_MGMT_TX_RETRY_CNT           8       /* WAL 发送管理帧最大重传次数 */
129 
130 #define IEEE80211_FCTL_FTYPE            0x000c
131 #define IEEE80211_FCTL_STYPE            0x00f0
132 #define IEEE80211_FTYPE_MGMT            0x0000
133 
134 #define WAL_GET_STATION_THRESHOLD       1000 /* 固定时间内允许一次抛事件读DMAC RSSI */
135 
136 typedef struct cookie_arry {
137     hi_u64  ull_cookie;
138     hi_u32  record_time;
139     hi_u32  reserved;
140 } cookie_arry_stru;
141 
142 struct MacStorage {
143     hi_u8 isStorage;
144     hi_u8 mac[ETHER_ADDR_LEN];
145 };
146 
147 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) || (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
148 #define ratetab_ent(_rate, _rateid, _flags)     \
149     {                                                               \
150         .bitrate        = (_rate),                                  \
151         .hw_value       = (_rateid),                                \
152         .flags          = (_flags),                                 \
153     }
154 
155 #define chan2g(_channel, _freq, _flags)  \
156     {                       \
157         .band                   = IEEE80211_BAND_2GHZ,          \
158         .center_freq            = (_freq),                      \
159         .hw_value               = (_channel),                   \
160         .flags                  = (_flags),                     \
161         .max_antenna_gain       = 0,                            \
162         .max_power              = 30,                           \
163     }
164 
165 #define chan5g(_channel, _flags) \
166     {                                              \
167         .band                   = IEEE80211_BAND_5GHZ,          \
168         .center_freq            = 5000 + (5 * (_channel)),      \
169         .hw_value               = (_channel),                   \
170         .flags                  = (_flags),                     \
171         .max_antenna_gain       = 0,                            \
172         .max_power              = 30,                           \
173     }
174 
175 #define chan4_9g(_channel, _flags) \
176     {                                              \
177         .band                   = IEEE80211_BAND_5GHZ,          \
178         .center_freq            = 4000 + (5 * (_channel)),      \
179         .hw_value               = (_channel),                   \
180         .flags                  = (_flags),                     \
181         .max_antenna_gain       = 0,                            \
182         .max_power              = 30,                           \
183     }
184 #else
185 error "WRONG OS VERSION"
186 #endif
187 
188 #define WAL_MIN_RTS_THRESHOLD 256
189 #define WAL_MAX_RTS_THRESHOLD 0xFFFF
190 
191 #define WAL_MAX_FRAG_THRESHOLD 7536
192 #define WAL_MIN_FRAG_THRESHOLD 256
193 
194 #define WAL_MAX_WAIT_TIME 3000
195 /* ****************************************************************************
196   3 枚举定义
197 **************************************************************************** */
198 typedef enum {
199     WAL_WIFI_MODE_STA = 0,
200     WAL_WIFI_MODE_AP = 1,
201     WAL_WIFI_MODE_STA_AP = 2,
202     /* 后续可扩展 */
203     WAL_WIFI_MODE_BUTT
204 } wal_wifi_mode_enum;
205 typedef int wal_wifi_mode_enum_int;
206 
207 typedef enum {
208     WAL_WIFI_BW_LEGACY_20M = 0,
209     WAL_WIFI_BW_HIEX_10M = 1,
210     WAL_WIFI_BW_HIEX_5M = 2,
211     WAL_WIFI_BW_BUTT
212 } wal_wifi_bw_enum;
213 typedef int wal_wifi_bw_enum_int;
214 
215 /* ****************************************************************************
216   5 函数声明
217 **************************************************************************** */
218 /* ****************************************************************************
219  功能描述  : 判断是否为probe_resp 帧
220 **************************************************************************** */
oal_ieee80211_is_probe_resp(hi_u16 fc)221 static inline hi_u32 oal_ieee80211_is_probe_resp(hi_u16 fc)
222 {
223     return (fc & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
224 }
225 
226 hi_void wal_cfg80211_exit(hi_void);
227 hi_u32 wal_cfg80211_init(hi_void);
228 hi_u32 wal_cfg80211_mgmt_tx_status(frw_event_mem_stru *event_mem);
229 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
230 hi_void wal_cfg80211_unregister_netdev(oal_net_device_stru *netdev);
231 #endif
232 hi_void wal_cfg80211_reset_bands(hi_void);
233 
234 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
235 hi_u32 wal_cfg80211_add_vap(const mac_cfg_add_vap_param_stru *add_vap_param);
236 hi_u32 wal_cfg80211_set_default_key(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u8 key_index,
237     hi_bool unicast, hi_bool multicast);
238 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
239 hi_u32 wal_cfg80211_mgmt_tx(oal_wiphy_stru *wiphy, oal_wireless_dev *wdev, struct cfg80211_mgmt_tx_params *pst_params,
240     hi_u64 *pull_cookie);
241 #else
242 hi_u32 wal_cfg80211_mgmt_tx(oal_wiphy_stru *wiphy, oal_wireless_dev *wdev, oal_ieee80211_channel *pst_chan,
243     const hi_u8 *puc_buf, hi_u32 ul_len, hi_u64 *pull_cookie);
244 #endif
245 #endif /* #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) */
246 
247 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) || defined(_PRE_HDF_LINUX)
248 hi_u32 wal_cfg80211_add_key(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u8 key_index, bool pairwise,
249     const hi_u8 *puc_mac_addr, oal_key_params_stru *params);
250 hi_u32 wal_cfg80211_remove_key(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u8 key_index, hi_bool pairwise,
251     const hi_u8 *mac_addr);
252 hi_u32 wal_cfg80211_change_virtual_intf(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, nl80211_iftype_uint8 type,
253     hi_u32 *pul_flags, oal_vif_params_stru *params);
254 hi_u32 wal_cfg80211_scan(oal_wiphy_stru *wiphy, oal_cfg80211_scan_request_stru *request);
255 hi_u32 wal_cfg80211_del_station(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev,
256     oal_station_del_parameters_stru *params);
257 #endif
258 
259 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
260 hi_s32 wal_cfg80211_stop_ap(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev);
261 hi_s32 wal_cfg80211_del_virtual_intf(oal_wiphy_stru *wiphy, oal_wireless_dev *wdev);
262 hi_s32 wal_cfg80211_set_default_key(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u8 key_index, bool unicast,
263     bool multicast);
264 #endif
265 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
266 hi_u32 wal_cfg80211_connect(oal_wiphy_stru *wiphy, oal_net_device_stru *net_device,
267     oal_cfg80211_connect_params_stru *sme);
268 hi_u32 wal_cfg80211_disconnect(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u16 us_reason_code);
269 hi_u32 wal_cfg80211_change_beacon(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev,
270     oal_beacon_data_stru *beacon_info);
271 hi_u32 wal_cfg80211_start_ap(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, oal_ap_settings_stru *ap_settings);
272 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
273 hi_s32 wal_cfg80211_connect(oal_wiphy_stru *wiphy, oal_net_device_stru *net_device,
274     oal_cfg80211_connect_params_stru *sme);
275 hi_s32 wal_cfg80211_disconnect(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, hi_u16 us_reason_code);
276 hi_s32 wal_cfg80211_change_beacon(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev,
277     oal_beacon_data_stru *beacon_info);
278 hi_s32 wal_cfg80211_start_ap(oal_wiphy_stru *wiphy, oal_net_device_stru *netdev, oal_ap_settings_stru *ap_settings);
279 #endif /* _PRE_OS_VERSION_LINUX == _PRE_OS_VERSION */
280 hi_u32 wal_cfg80211_start_scan(oal_net_device_stru *netdev, const mac_cfg80211_scan_param_stru *scan_param);
281 hi_u32 wal_cfg80211_start_sched_scan(oal_net_device_stru *netdev, mac_pno_scan_stru *pno_scan_info);
282 hi_u32 wal_cfg80211_start_req(oal_net_device_stru *netdev, const hi_void *ps_param, hi_u16 us_len,
283     wlan_cfgid_enum_uint16 wid, hi_u8 need_rsp);
284 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
285 hi_u32 wal_cfg80211_start_connect(oal_net_device_stru *netdev,
286     const mac_cfg80211_connect_param_stru *mac_cfg80211_connect_param);
287 hi_u32 wal_cfg80211_start_disconnect(oal_net_device_stru *netdev, const mac_cfg_kick_user_param_stru *disconnect_param);
288 #endif
289 #ifdef _PRE_WLAN_FEATURE_P2P
290 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
291 hi_u32 wal_set_p2p_status(oal_net_device_stru *netdev, wlan_p2p_status_enum_uint32 status);
292 #endif
293 hi_u32 wal_del_p2p_group(const mac_device_stru *mac_dev);
294 hi_s32 wal_cfg80211_remain_on_channel(oal_wiphy_stru *wiphy, oal_wireless_dev *wdev,
295     struct ieee80211_channel *chan, hi_u32 duration, hi_u64 *pull_cookie);
296 hi_s32 wal_cfg80211_cancel_remain_on_channel(oal_wiphy_stru *wiphy, oal_wireless_dev *wdev, hi_u64 ull_cookie);
297 #endif
298 #ifdef _PRE_WLAN_FEATURE_QUICK_START
299 hi_u32 hisi_quick_get_scan_enable(hi_void);
300 #endif
301 oal_ieee80211_channel *wal_get_g_wifi_2ghz_channels(hi_void);
302 hi_u32 wal_wifi_set_bw(oal_net_device_stru *netdev, wal_wifi_bw_enum_int bw);
303 
304 wal_wifi_mode_enum_int wal_get_vap_mode(hi_void);
305 
306 #ifdef __cplusplus
307 #if __cplusplus
308 }
309 #endif
310 #endif
311 
312 #endif /* end of wal_cfg80211.h */
313