1 /** @file moal_cfg80211.h
2 *
3 * @brief This file contains the CFG80211 specific defines.
4 *
5 * Copyright (C) 2011-2017, Marvell International Ltd.
6 *
7 * This software file (the "File") is distributed by Marvell International
8 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
9 * (the "License"). You may use, redistribute and/or modify this File in
10 * accordance with the terms and conditions of the License, a copy of which
11 * is available by writing to the Free Software Foundation, Inc.,
12 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
13 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 *
15 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
17 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
18 * this warranty disclaimer.
19 *
20 */
21
22 #ifndef _MOAL_CFG80211_H_
23 #define _MOAL_CFG80211_H_
24
25 #include "moal_main.h"
26
27 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
28 #define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR
29 #define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR
30 #endif
31
32 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
33 #define MAX_CSA_COUNTERS_NUM 2
34 #endif
35
36 /* Clear all key indexes */
37 #define KEY_INDEX_CLEAR_ALL (0x0000000F)
38
39 /** RTS/FRAG disabled value */
40 #define MLAN_FRAG_RTS_DISABLED (0xFFFFFFFF)
41
42 #ifndef WLAN_CIPHER_SUITE_SMS4
43 #define WLAN_CIPHER_SUITE_SMS4 0x00000020
44 #endif
45
46 #ifndef WLAN_CIPHER_SUITE_AES_CMAC
47 #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06
48 #endif
49
50 /* define for custom ie operation */
51 #define MLAN_CUSTOM_IE_AUTO_IDX_MASK 0xffff
52 #define MLAN_CUSTOM_IE_DELETE_MASK 0x0
53 #define MLAN_CUSTOM_IE_NEW_MASK 0x8000
54 #define IE_MASK_WPS 0x0001
55 #define IE_MASK_P2P 0x0002
56 #define IE_MASK_WFD 0x0004
57 #define IE_MASK_VENDOR 0x0008
58
59 #define MRVL_PKT_TYPE_MGMT_FRAME 0xE5
60
61 /**
62 * If multiple wiphys are registered e.g. a regular netdev with
63 * assigned ieee80211_ptr and you won't know whether it points
64 * to a wiphy your driver has registered or not. Assign this to
65 * something global to your driver to help determine whether
66 * you own this wiphy or not.
67 */
68 static const void *const mrvl_wiphy_privid = &mrvl_wiphy_privid;
69
70 /* Get the private structure from wiphy */
71 void *woal_get_wiphy_priv(struct wiphy *wiphy);
72
73 /* Get the private structure from net device */
74 void *woal_get_netdev_priv(struct net_device *dev);
75 #ifdef STA_SUPPORT
76 /** get scan interface */
77 moal_private *woal_get_scan_interface(moal_handle *handle);
78 #endif
79
80 t_u8 woal_band_cfg_to_ieee_band(t_u32 band);
81
82 int woal_cfg80211_change_virtual_intf(struct wiphy *wiphy,
83 struct net_device *dev,
84 enum nl80211_iftype type,
85 #if CFG80211_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
86 u32 *flags,
87 #endif
88 struct vif_params *params);
89
90 int woal_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed);
91
92 int woal_cfg80211_add_key(struct wiphy *wiphy,
93 struct net_device *dev, t_u8 key_index,
94 #if CFG80211_VERSION_CODE > KERNEL_VERSION(2, 6, 36)
95 bool pairwise,
96 #endif
97 const t_u8 *mac_addr, struct key_params *params);
98
99 int woal_cfg80211_del_key(struct wiphy *wiphy,
100 struct net_device *dev, t_u8 key_index,
101 #if CFG80211_VERSION_CODE > KERNEL_VERSION(2, 6, 36)
102 bool pairwise,
103 #endif
104 const t_u8 *mac_addr);
105 #ifdef STA_SUPPORT
106 /** Opportunistic Key Caching APIs support */
107 struct pmksa_entry *woal_get_pmksa_entry(moal_private *priv, const u8 *bssid);
108
109 int woal_flush_pmksa_list(moal_private *priv);
110
111 int woal_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
112 struct cfg80211_pmksa *pmksa);
113
114 int woal_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
115 struct cfg80211_pmksa *pmksa);
116
117 int woal_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev);
118 #endif
119
120 int woal_cfg80211_set_bitrate_mask(struct wiphy *wiphy,
121 struct net_device *dev,
122 const u8 *peer,
123 const struct cfg80211_bitrate_mask *mask);
124 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
125 int woal_cfg80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
126 int woal_cfg80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
127 #endif
128
129 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
130 int woal_cfg80211_set_qos_map(struct wiphy *wiphy,
131 struct net_device *dev,
132 struct cfg80211_qos_map *qos_map);
133 #endif
134
135 #ifdef STA_CFG80211
136 #ifdef STA_SUPPORT
137 int woal_set_rf_channel(moal_private *priv,
138 struct ieee80211_channel *chan,
139 enum nl80211_channel_type channel_type,
140 t_u8 wait_option);
141
142 static inline int
woal_cfg80211_scan_done(struct cfg80211_scan_request * request,bool aborted)143 woal_cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted)
144 {
145 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
146 struct cfg80211_scan_info info;
147 info.aborted = aborted;
148 cfg80211_scan_done(request, &info);
149 #else
150 cfg80211_scan_done(request, aborted);
151 #endif
152 return 0;
153 }
154
155 mlan_status woal_inform_bss_from_scan_result(moal_private *priv,
156 mlan_ssid_bssid *ssid_bssid,
157 t_u8 wait_option);
158 #endif
159 #endif
160
161 #if CFG80211_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
162 int woal_cfg80211_set_channel(struct wiphy *wiphy,
163 #if CFG80211_VERSION_CODE > KERNEL_VERSION(2, 6, 34)
164 struct net_device *dev,
165 #endif
166 struct ieee80211_channel *chan,
167 enum nl80211_channel_type channel_type);
168 #endif
169
170 #if CFG80211_VERSION_CODE > KERNEL_VERSION(2, 6, 37)
171 int woal_cfg80211_set_default_key(struct wiphy *wiphy,
172 struct net_device *dev, t_u8 key_index,
173 bool ucast, bool mcast);
174 #else
175 int woal_cfg80211_set_default_key(struct wiphy *wiphy,
176 struct net_device *dev, t_u8 key_index);
177 #endif
178
179 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
180 int woal_cfg80211_set_default_mgmt_key(struct wiphy *wiphy,
181 struct net_device *netdev,
182 t_u8 key_index);
183 #endif
184
185 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
186 int woal_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
187 struct cfg80211_gtk_rekey_data *data);
188 #endif
189
190 void woal_cfg80211_mgmt_frame_register(struct wiphy *wiphy,
191 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
192 struct wireless_dev *wdev,
193 #else
194 struct net_device *dev,
195 #endif
196 t_u16 frame_type, bool reg);
197
198 int woal_cfg80211_mgmt_tx(struct wiphy *wiphy,
199 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
200 struct wireless_dev *wdev,
201 #else
202 struct net_device *dev,
203 #endif
204 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
205 struct cfg80211_mgmt_tx_params *params,
206 #else
207 struct ieee80211_channel *chan, bool offchan,
208 #if CFG80211_VERSION_CODE < KERNEL_VERSION(3, 8, 0)
209 enum nl80211_channel_type channel_type,
210 bool channel_type_valid,
211 #endif
212 unsigned int wait, const u8 *buf, size_t len,
213 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
214 bool no_cck,
215 #endif
216 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
217 bool dont_wait_for_ack,
218 #endif
219 #endif
220 u64 * cookie);
221
222 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
223 void woal_update_radar_chans_dfs_state(struct wiphy *wiphy);
224 #endif
225
226 mlan_status woal_register_cfg80211(moal_private *priv);
227
228 extern struct ieee80211_supported_band cfg80211_band_2ghz;
229 extern struct ieee80211_supported_band cfg80211_band_5ghz;
230
231 #if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
232 int woal_cfg80211_bss_role_cfg(moal_private *priv, t_u16 action,
233 t_u8 *bss_role);
234 #endif
235 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
236 struct wireless_dev *woal_cfg80211_add_virtual_intf(struct wiphy *wiphy,
237 const char *name,
238 unsigned char
239 name_assign_type,
240 enum nl80211_iftype type,
241 #if CFG80211_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
242 u32 *flags,
243 #endif
244 struct vif_params *params);
245 #else
246 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
247 struct wireless_dev *woal_cfg80211_add_virtual_intf(struct wiphy *wiphy,
248 const char *name,
249 enum nl80211_iftype type,
250 u32 *flags,
251 struct vif_params *params);
252 #else
253 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
254 struct wireless_dev *woal_cfg80211_add_virtual_intf(struct wiphy *wiphy,
255 char *name,
256 enum nl80211_iftype type,
257 u32 *flags,
258 struct vif_params *params);
259 #else
260 #if CFG80211_VERSION_CODE > KERNEL_VERSION(2, 6, 37)
261 struct net_device *woal_cfg80211_add_virtual_intf(struct wiphy *wiphy,
262 char *name,
263 enum nl80211_iftype type,
264 u32 *flags,
265 struct vif_params *params);
266 #else
267 int woal_cfg80211_add_virtual_intf(struct wiphy *wiphy,
268 char *name, enum nl80211_iftype type,
269 u32 *flags, struct vif_params *params);
270 #endif
271 #endif
272 #endif
273 #endif
274 int woal_cfg80211_del_virt_if(struct wiphy *wiphy, struct net_device *dev);
275 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
276 int woal_cfg80211_del_virtual_intf(struct wiphy *wiphy,
277 struct wireless_dev *wdev);
278 #else
279 int woal_cfg80211_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev);
280 #endif
281
282 #if defined(WIFI_DIRECT_SUPPORT)
283 /* Group Owner Negotiation Req */
284 #define P2P_GO_NEG_REQ 0
285 /* Group Owner Negotiation Rsp */
286 #define P2P_GO_NEG_RSP 1
287 /* Group Owner Negotiation Confirm */
288 #define P2P_GO_NEG_CONF 2
289 /* P2P Invitation Request */
290 #define P2P_INVITE_REQ 3
291 /* P2P Invitation Response */
292 #define P2P_INVITE_RSP 4
293 /* Device Discoverability Request */
294 #define P2P_DEVDIS_REQ 5
295 /* Device Discoverability Response */
296 #define P2P_DEVDIS_RSP 6
297 /* Provision Discovery Request */
298 #define P2P_PROVDIS_REQ 7
299 /* Provision Discovery Response */
300 #define P2P_PROVDIS_RSP 8
301 /** P2P category */
302 #define P2P_ACT_FRAME_CATEGORY 0x04
303 /** P2P oui offset */
304 #define P2P_ACT_FRAME_OUI_OFFSET 26
305 /** P2P subtype offset */
306 #define P2P_ACT_FRAME_OUI_SUBTYPE_OFFSET 30
307 void woal_cfg80211_display_p2p_actframe(const t_u8 *buf, int len,
308 struct ieee80211_channel *chan,
309 const t_u8 flag);
310
311 /** Define kernel version for wifi direct */
312 #define WIFI_DIRECT_KERNEL_VERSION KERNEL_VERSION(2, 6, 39)
313 #if CFG80211_VERSION_CODE >= WIFI_DIRECT_KERNEL_VERSION
314 int woal_cfg80211_init_p2p_client(moal_private *priv);
315
316 int woal_cfg80211_init_p2p_go(moal_private *priv);
317
318 int woal_cfg80211_deinit_p2p(moal_private *priv);
319
320 void woal_remove_virtual_interface(moal_handle *handle);
321
322 #endif /* KERNEL_VERSION */
323 #endif /* WIFI_DIRECT_SUPPORT && V14_FEATURE */
324
325 /** Define for remain on channel duration timer */
326 #define MAX_REMAIN_ON_CHANNEL_DURATION (1000)
327 int woal_cfg80211_remain_on_channel_cfg(moal_private *priv,
328 t_u8 wait_option, t_u8 remove,
329 t_u8 *status,
330 struct ieee80211_channel *chan,
331 enum nl80211_channel_type channel_type,
332 t_u32 duration);
333
334 #ifdef UAP_CFG80211
335 int woal_uap_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
336 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
337 const u8 *mac,
338 #else
339 u8 *mac,
340 #endif
341 struct station_info *stainfo);
342
343 int woal_uap_cfg80211_dump_station(struct wiphy *wiphy,
344 struct net_device *dev, int idx,
345 t_u8 *mac, struct station_info *sinfo);
346 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
347 int woal_cfg80211_change_bss(struct wiphy *wiphy, struct net_device *dev,
348 struct bss_parameters *params);
349 #endif
350 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
351 int woal_cfg80211_set_mac_acl(struct wiphy *wiphy, struct net_device *dev,
352 const struct cfg80211_acl_data *params);
353 #endif
354 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
355 int woal_cfg80211_set_txq_params(struct wiphy *wiphy, struct net_device *dev,
356 struct ieee80211_txq_params *params);
357 #endif
358
359 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
360 int woal_cfg80211_set_coalesce(struct wiphy *wiphy,
361 struct cfg80211_coalesce *coalesce);
362 #endif
363
364 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
365 int woal_cfg80211_add_beacon(struct wiphy *wiphy,
366 struct net_device *dev,
367 struct cfg80211_ap_settings *params);
368
369 int woal_cfg80211_set_beacon(struct wiphy *wiphy,
370 struct net_device *dev,
371 struct cfg80211_beacon_data *params);
372 #else
373 int woal_cfg80211_add_beacon(struct wiphy *wiphy,
374 struct net_device *dev,
375 struct beacon_parameters *params);
376
377 int woal_cfg80211_set_beacon(struct wiphy *wiphy,
378 struct net_device *dev,
379 struct beacon_parameters *params);
380 #endif
381
382 int woal_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev);
383 int woal_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev,
384 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
385 struct station_del_parameters *param);
386 #else
387 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
388 const u8 *mac_addr);
389 #else
390 u8 *mac_addr);
391 #endif
392 #endif
393 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
394 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
395 int woal_cfg80211_start_radar_detection(struct wiphy *wiphy,
396 struct net_device *dev,
397 struct cfg80211_chan_def *chandef,
398 u32 cac_time_ms);
399 #else
400 int woal_cfg80211_start_radar_detection(struct wiphy *wiphy,
401 struct net_device *dev,
402 struct cfg80211_chan_def *chandef);
403 #endif
404
405 int woal_cfg80211_channel_switch(struct wiphy *wiphy,
406 struct net_device *dev,
407 struct cfg80211_csa_settings *params);
408
409 void woal_cac_timer_func(void *context);
410 void woal_csa_work_queue(struct work_struct *work);
411 #endif
412 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
413 void woal_cfg80211_notify_uap_channel(moal_private *priv,
414 chan_band_info * pchan_info);
415 #endif
416 #endif /* UAP_CFG80211 */
417
418 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
419 mlan_status woal_chandef_create(moal_private *priv,
420 struct cfg80211_chan_def *chandef,
421 chan_band_info * pchan_info);
422 #endif
423
424 void woal_clear_all_mgmt_ies(moal_private *priv, t_u8 wait_option);
425 int woal_cfg80211_mgmt_frame_ie(moal_private *priv,
426 const t_u8 *beacon_ies, size_t beacon_ies_len,
427 const t_u8 *proberesp_ies,
428 size_t proberesp_ies_len,
429 const t_u8 *assocresp_ies,
430 size_t assocresp_ies_len,
431 const t_u8 *probereq_ies,
432 size_t probereq_ies_len, t_u16 mask,
433 t_u8 wait_option);
434
435 int woal_get_active_intf_freq(moal_private *priv);
436
437 void woal_cfg80211_setup_ht_cap(struct ieee80211_sta_ht_cap *ht_info,
438 t_u32 dev_cap, t_u8 *mcs_set);
439 int woal_cfg80211_assoc(moal_private *priv, void *sme, t_u8 wait_option);
440
441 #if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
442 #define REGULATORY_CFG_LEN (NL80211_MAX_SUPP_REG_RULES << 1)
443 enum marvell_channel_flags {
444 MARVELL_CHANNEL_PASSIVE = BIT(0),
445 MARVELL_CHANNEL_DFS = BIT(1),
446 MARVELL_CHANNEL_NOHT40 = BIT(2),
447 MARVELL_CHANNEL_NOHT80 = BIT(3),
448 MARVELL_CHANNEL_DISABLED = BIT(7),
449 };
450 #endif
451
452 t_u8 woal_get_second_channel_offset(int chan);
453
454 #endif /* _MOAL_CFG80211_H_ */
455