1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Linux cfg80211 driver
4 *
5 * Copyright (C) 1999-2019, Broadcom.
6 *
7 * Unless you and Broadcom execute a separate written software license
8 * agreement governing use of this software, this software is licensed to you
9 * under the terms of the GNU General Public License version 2 (the "GPL"),
10 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
11 * following added to such license:
12 *
13 * As a special exception, the copyright holders of this software give you
14 * permission to link this software with independent modules, and to copy and
15 * distribute the resulting executable under terms of your choice, provided that
16 * you also meet, for each linked independent module, the terms and conditions of
17 * the license of that module. An independent module is a module which is not
18 * derived from this software. The special exception does not apply to any
19 * modifications of the software.
20 *
21 * Notwithstanding the above, under no circumstances may you combine this
22 * software in any way with any other Broadcom software provided under a license
23 * other than the GPL, without Broadcom's express prior written consent.
24 *
25 *
26 * <<Broadcom-WL-IPTag/Open:>>
27 *
28 * $Id: wl_cfg80211.h 825255 2019-06-13 12:26:42Z $
29 */
30
31 /**
32 * Older Linux versions support the 'iw' interface, more recent ones the 'cfg80211' interface.
33 */
34
35 #ifndef _wl_cfg80211_h_
36 #define _wl_cfg80211_h_
37
38 #include <linux/wireless.h>
39 #include <typedefs.h>
40 #include <ethernet.h>
41 #include <wlioctl.h>
42 #include <linux/wireless.h>
43 #include <net/cfg80211.h>
44 #include <linux/rfkill.h>
45 #include <osl.h>
46 #include <dngl_stats.h>
47 #include <dhd.h>
48
49 #define WL_CFG_DRV_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
50 #define WL_CFG_DRV_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
51
52 #define WL_CFG_WPS_SYNC_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
53 #define WL_CFG_WPS_SYNC_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
54
55 #define WL_CFG_NET_LIST_SYNC_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
56 #define WL_CFG_NET_LIST_SYNC_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
57
58 #define WL_CFG_EQ_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
59 #define WL_CFG_EQ_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
60
61 #define WL_CFG_BAM_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
62 #define WL_CFG_BAM_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
63
64 #define WL_CFG_VNDR_OUI_SYNC_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
65 #define WL_CFG_VNDR_OUI_SYNC_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
66
67 #include <wl_cfgp2p.h>
68 #include <wl_android.h>
69 #ifdef WL_NAN
70 #include <wl_cfgnan.h>
71 #endif /* WL_NAN */
72 struct wl_conf;
73 struct wl_iface;
74 struct bcm_cfg80211;
75 struct wl_security;
76 struct wl_ibss;
77
78 #if !defined(WL_CLIENT_SAE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0))
79 #define WL_CLIENT_SAE
80 #endif
81 #if defined(WL_SAE) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
82 #error "Can not support WL_SAE befor kernel 3.14"
83 #endif
84 #if defined(WL_CLIENT_SAE) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0))
85 #error "Can not support WL_CLIENT_SAE before kernel 3.10"
86 #endif
87 #if defined(WL_CLIENT_SAE) && defined(WL_SAE)
88 #error "WL_SAE is for dongle-offload and WL_CLIENT_SAE is for wpa_supplicant. Please choose one."
89 #endif
90
91 #if defined(WL_CLIENT_SAE)
92 #ifndef WL_ASSOC_MGR_CMD_SEND_AUTH
93 #define WL_ASSOC_MGR_CMD_SEND_AUTH 3
94 #endif /* WL_ASSOC_MGR_CMD_SEND_AUTH */
95 #endif
96
97 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) && !defined(WL_SCAN_TYPE))
98 #define WL_SCAN_TYPE
99 #endif /* WL_SCAN_TYPE */
100
101 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) && !defined(WL_FILS_ROAM_OFFLD)
102 #define WL_FILS_ROAM_OFFLD
103 #endif // endif
104
105 #ifdef WL_SAE
106 #define IS_AKM_SAE(akm) (akm == WLAN_AKM_SUITE_SAE)
107 #else
108 #define IS_AKM_SAE(akm) FALSE
109 #endif // endif
110 #ifdef WL_OWE
111 #define IS_AKM_OWE(akm) (akm == WLAN_AKM_SUITE_OWE)
112 #else
113 #define IS_AKM_OWE(akm) FALSE
114 #endif // endif
115
116 #define htod32(i) (i)
117 #define htod16(i) (i)
118 #define dtoh64(i) (i)
119 #define dtoh32(i) (i)
120 #define dtoh16(i) (i)
121 #define htodchanspec(i) (i)
122 #define dtohchanspec(i) (i)
123
124 #define WL_DBG_NONE 0
125 #define WL_DBG_P2P_ACTION (1 << 5)
126 #define WL_DBG_TRACE (1 << 4)
127 #define WL_DBG_SCAN (1 << 3)
128 #define WL_DBG_DBG (1 << 2)
129 #define WL_DBG_INFO (1 << 1)
130 #define WL_DBG_ERR (1 << 0)
131
132 #ifndef WAIT_FOR_DISCONNECT_MAX
133 #define WAIT_FOR_DISCONNECT_MAX 10
134 #endif /* WAIT_FOR_DISCONNECT_MAX */
135 #define WAIT_FOR_DISCONNECT_STATE_SYNC 10
136
137 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
138 /* Newer kernels use defines from nl80211.h */
139 #define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
140 #define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
141 #define IEEE80211_BAND_60GHZ NL80211_BAND_60GHZ
142 #define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
143 #endif /* LINUX_VER >= 4.7 */
144
145 #ifdef DHD_LOG_DUMP
146 extern void dhd_log_dump_write(int type, char *binary_data,
147 int binary_len, const char *fmt, ...);
148 extern char *dhd_log_dump_get_timestamp(void);
149 #ifndef _DHD_LOG_DUMP_DEFINITIONS_
150 #define DHD_LOG_DUMP_WRITE(fmt, ...) \
151 dhd_log_dump_write(DLD_BUF_TYPE_GENERAL, NULL, 0, fmt, ##__VA_ARGS__)
152 #define DHD_LOG_DUMP_WRITE_EX(fmt, ...) \
153 dhd_log_dump_write(DLD_BUF_TYPE_SPECIAL, NULL, 0, fmt, ##__VA_ARGS__)
154 #endif /* !_DHD_LOG_DUMP_DEFINITIONS_ */
155 #endif /* DHD_LOG_DUMP */
156
157 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || (defined(CONFIG_ARCH_MSM) && \
158 defined(CFG80211_DISCONNECTED_V2))
159 #define CFG80211_DISCONNECTED(dev, reason, ie, len, loc_gen, gfp) \
160 cfg80211_disconnected(dev, reason, ie, len, loc_gen, gfp);
161 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
162 #define CFG80211_DISCONNECTED(dev, reason, ie, len, loc_gen, gfp) \
163 BCM_REFERENCE(loc_gen); \
164 cfg80211_disconnected(dev, reason, ie, len, gfp);
165 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) */
166
167 /* 0 invalidates all debug messages. default is 1 */
168 #define WL_DBG_LEVEL 0xFF
169
170 #define CFG80211_INFO_TEXT DHD_LOG_PREFIXS "CFG80211-INFO) "
171 #define CFG80211_ERROR_TEXT DHD_LOG_PREFIXS "CFG80211-ERROR) "
172
173 #if defined(DHD_DEBUG)
174 #ifdef DHD_LOG_DUMP
175 #define WL_ERR_MSG(x, args...) \
176 do { \
177 if (wl_dbg_level & WL_DBG_ERR) { \
178 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
179 DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
180 DHD_LOG_DUMP_WRITE(x, ## args); \
181 } \
182 } while (0)
183 #define WL_ERR(x) WL_ERR_MSG x
184 #define WL_ERR_KERN_MSG(x, args...) \
185 do { \
186 if (wl_dbg_level & WL_DBG_ERR) { \
187 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
188 } \
189 } while (0)
190 #define WL_ERR_KERN(x) WL_ERR_KERN_MSG x
191 #define WL_ERR_MEM_MSG(x, args...) \
192 do { \
193 if (wl_dbg_level & WL_DBG_ERR) { \
194 DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
195 DHD_LOG_DUMP_WRITE(x, ## args); \
196 } \
197 } while (0)
198 #define WL_ERR_MEM(x) WL_ERR_MEM_MSG x
199 #define WL_INFORM_MEM_MSG(x, args...) \
200 do { \
201 if (wl_dbg_level & WL_DBG_INFO) { \
202 printk(KERN_INFO CFG80211_INFO_TEXT "%s : " x, __func__, ## args); \
203 DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
204 DHD_LOG_DUMP_WRITE(x, ## args); \
205 } \
206 } while (0)
207 #define WL_INFORM_MEM(x) WL_INFORM_MEM_MSG x
208 #define WL_ERR_EX(args) \
209 do { \
210 if (wl_dbg_level & WL_DBG_ERR) { \
211 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
212 DHD_LOG_DUMP_WRITE_EX("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
213 DHD_LOG_DUMP_WRITE_EX args; \
214 } \
215 } while (0)
216 #define WL_MEM(args) \
217 do { \
218 DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
219 DHD_LOG_DUMP_WRITE args; \
220 } while (0)
221 #else
222 #define WL_ERR_MSG(x, args...) \
223 do { \
224 if (wl_dbg_level & WL_DBG_ERR) { \
225 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
226 } \
227 } while (0)
228 #define WL_ERR(x) WL_ERR_MSG x
229 #define WL_ERR_KERN(args) WL_ERR(args)
230 #define WL_ERR_MEM(args) WL_ERR(args)
231 #define WL_INFORM_MEM(args) WL_INFORM(args)
232 #define WL_ERR_EX(args) WL_ERR(args)
233 #define WL_MEM(args) WL_DBG(args)
234 #endif /* DHD_LOG_DUMP */
235 #else /* defined(DHD_DEBUG) */
236 #define WL_ERR_MSG(x, args...) \
237 do { \
238 if ((wl_dbg_level & WL_DBG_ERR) && net_ratelimit()) { \
239 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
240 } \
241 } while (0)
242 #define WL_ERR(x) WL_ERR_MSG x
243 #define WL_ERR_KERN(args) WL_ERR(args)
244 #define WL_ERR_MEM(args) WL_ERR(args)
245 #define WL_INFORM_MEM(args) WL_INFORM(args)
246 #define WL_ERR_EX(args) WL_ERR(args)
247 #define WL_MEM(args) WL_DBG(args)
248 #endif /* defined(DHD_DEBUG) */
249
250 #define WL_PRINT_RATE_LIMIT_PERIOD 4000000000u /* 4s in units of ns */
251 #define WL_ERR_RLMT(args) \
252 do { \
253 if (wl_dbg_level & WL_DBG_ERR) { \
254 static uint64 __err_ts = 0; \
255 static uint32 __err_cnt = 0; \
256 uint64 __cur_ts = 0; \
257 __cur_ts = local_clock(); \
258 if (__err_ts == 0 || (__cur_ts > __err_ts && \
259 (__cur_ts - __err_ts > WL_PRINT_RATE_LIMIT_PERIOD))) { \
260 __err_ts = __cur_ts; \
261 WL_ERR(args); \
262 WL_ERR(("[Repeats %u times]\n", __err_cnt)); \
263 __err_cnt = 0; \
264 } else { \
265 ++__err_cnt; \
266 } \
267 } \
268 } while (0)
269
270 #ifdef WL_INFORM
271 #undef WL_INFORM
272 #endif // endif
273
274 #define WL_INFORM_MSG(x, args...) \
275 do { \
276 if (wl_dbg_level & WL_DBG_INFO) { \
277 printk(KERN_INFO DHD_LOG_PREFIXS "CFG80211-INFO) %s : " x, __func__, ## args); \
278 } \
279 } while (0)
280 #define WL_INFORM(x) WL_INFORM_MSG x
281
282 #ifdef WL_SCAN
283 #undef WL_SCAN
284 #endif // endif
285 #define WL_SCAN_MSG(x, args...) \
286 do { \
287 if (wl_dbg_level & WL_DBG_SCAN) { \
288 printk(KERN_INFO DHD_LOG_PREFIXS "CFG80211-SCAN) %s :" x, __func__, ## args); \
289 } \
290 } while (0)
291 #define WL_SCAN(x) WL_SCAN_MSG x
292 #ifdef WL_TRACE
293 #undef WL_TRACE
294 #endif // endif
295 #define WL_TRACE_MSG(x, args...) \
296 do { \
297 if (wl_dbg_level & WL_DBG_TRACE) { \
298 printk(KERN_INFO DHD_LOG_PREFIXS "CFG80211-TRACE) %s :" x, __func__, ## args); \
299 } \
300 } while (0)
301 #define WL_TRACE(x) WL_TRACE_MSG x
302 #ifdef WL_TRACE_HW4
303 #undef WL_TRACE_HW4
304 #endif // endif
305 #define WL_TRACE_HW4 WL_TRACE
306 #if (WL_DBG_LEVEL > 0)
307 #define WL_DBG_MSG(x, args...) \
308 do { \
309 if (wl_dbg_level & WL_DBG_DBG) { \
310 printk(KERN_INFO DHD_LOG_PREFIXS "CFG80211-DEBUG) %s :" x, __func__, ## args); \
311 } \
312 } while (0)
313 #define WL_DBG(x) WL_DBG_MSG x
314 #else /* !(WL_DBG_LEVEL > 0) */
315 #define WL_DBG(args)
316 #endif /* (WL_DBG_LEVEL > 0) */
317 #define WL_PNO(x)
318 #define WL_SD(x)
319
320 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
321 #define ieee80211_band nl80211_band
322 #define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
323 #define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
324 #define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
325 #endif
326
327 #define WL_SCAN_RETRY_MAX 3
328 #define WL_NUM_PMKIDS_MAX MAXPMKID
329 #define WL_SCAN_BUF_MAX (1024 * 8)
330 #define WL_TLV_INFO_MAX 1500
331 #define WL_SCAN_IE_LEN_MAX 2048
332 #define WL_BSS_INFO_MAX 2048
333 #define WL_ASSOC_INFO_MAX 512
334 #define WL_IOCTL_LEN_MAX 2048
335 #define WL_EXTRA_BUF_MAX 2048
336 #define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
337 #define WL_AP_MAX 256
338 #define WL_FILE_NAME_MAX 256
339 #define WL_DWELL_TIME 200
340 #define WL_MED_DWELL_TIME 400
341 #define WL_MIN_DWELL_TIME 100
342 #define WL_LONG_DWELL_TIME 1000
343 #define IFACE_MAX_CNT 5
344 #define WL_SCAN_CONNECT_DWELL_TIME_MS 200
345 #define WL_SCAN_JOIN_PROBE_INTERVAL_MS 20
346 #define WL_SCAN_JOIN_ACTIVE_DWELL_TIME_MS 320
347 #define WL_SCAN_JOIN_PASSIVE_DWELL_TIME_MS 400
348 #define WL_AF_TX_MAX_RETRY 5
349
350 #define WL_AF_SEARCH_TIME_MAX 450
351 #define WL_AF_TX_EXTRA_TIME_MAX 200
352
353 #define WL_SCAN_TIMER_INTERVAL_MS 10000 /* Scan timeout */
354 #ifdef WL_NAN
355 #define WL_SCAN_TIMER_INTERVAL_MS_NAN 15000 /* Scan timeout */
356 #endif /* WL_NAN */
357 #define WL_CHANNEL_SYNC_RETRY 5
358 #define WL_INVALID -1
359
360 #ifdef DHD_LOSSLESS_ROAMING
361 #define WL_ROAM_TIMEOUT_MS 1000 /* Roam timeout */
362 #endif // endif
363 /* Bring down SCB Timeout to 20secs from 60secs default */
364 #ifndef WL_SCB_TIMEOUT
365 #define WL_SCB_TIMEOUT 20
366 #endif // endif
367
368 #if defined(ROAM_ENABLE) || defined(ROAM_CHANNEL_CACHE)
369 #define ESCAN_CHANNEL_CACHE
370 #endif // endif
371
372 #ifndef WL_SCB_ACTIVITY_TIME
373 #define WL_SCB_ACTIVITY_TIME 5
374 #endif // endif
375
376 #ifndef WL_SCB_MAX_PROBE
377 #define WL_SCB_MAX_PROBE 3
378 #endif // endif
379
380 #ifndef WL_PSPRETEND_RETRY_LIMIT
381 #define WL_PSPRETEND_RETRY_LIMIT 1
382 #endif // endif
383
384 #ifndef WL_MIN_PSPRETEND_THRESHOLD
385 #define WL_MIN_PSPRETEND_THRESHOLD 2
386 #endif // endif
387
388 /* Cipher suites */
389 #ifndef WLAN_CIPHER_SUITE_PMK
390 #define WLAN_CIPHER_SUITE_PMK 0x00904C00
391 #endif /* WLAN_CIPHER_SUITE_PMK */
392
393 #ifndef WLAN_AKM_SUITE_FT_8021X
394 #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
395 #endif /* WLAN_AKM_SUITE_FT_8021X */
396
397 #ifndef WLAN_AKM_SUITE_FT_PSK
398 #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
399 #endif /* WLAN_AKM_SUITE_FT_PSK */
400
401 #define WLAN_AKM_SUITE_SAE_SHA256 0x000FAC08
402
403 #ifndef WLAN_AKM_SUITE_8021X_SUITE_B
404 #define WLAN_AKM_SUITE_8021X_SUITE_B 0x000FAC0B
405 #define WLAN_AKM_SUITE_8021X_SUITE_B_192 0x000FAC0C
406 #endif /* WLAN_AKM_SUITE_8021X_SUITE_B */
407
408 /* TODO: even in upstream linux(v5.0), FT-1X-SHA384 isn't defined and supported yet.
409 * need to revisit here to sync correct name later.
410 */
411 #ifndef WLAN_AKM_SUITE_FT_8021X_SHA384
412 #define WLAN_AKM_SUITE_FT_8021X_SHA384 0x000FAC0D
413 #endif /* WLAN_AKM_SUITE_FT_8021X_SHA384 */
414
415 #define WL_AKM_SUITE_SHA256_1X 0x000FAC05
416 #define WL_AKM_SUITE_SHA256_PSK 0x000FAC06
417
418 #ifndef WLAN_AKM_SUITE_FILS_SHA256
419 #define WLAN_AKM_SUITE_FILS_SHA256 0x000FAC0E
420 #define WLAN_AKM_SUITE_FILS_SHA384 0x000FAC0F
421 #define WLAN_AKM_SUITE_FT_FILS_SHA256 0x000FAC10
422 #define WLAN_AKM_SUITE_FT_FILS_SHA384 0x000FAC11
423 #endif /* WLAN_AKM_SUITE_FILS_SHA256 */
424
425 #define MIN_VENDOR_EXTN_IE_LEN 2
426 #ifdef WL_OWE
427 #ifndef WLAN_AKM_SUITE_OWE
428 #define WLAN_AKM_SUITE_OWE 0X000FAC12
429 #endif /* WPA_KEY_MGMT_OWE */
430 #endif /* WL_OWE */
431
432 /*
433 * BRCM local.
434 * Use a high number that's unlikely to clash with linux upstream for a while until we can
435 * submit these changes to the community.
436 */
437 #define NL80211_FEATURE_FW_4WAY_HANDSHAKE (1<<31)
438
439 /* SCAN_SUPPRESS timer values in ms */
440 #define WL_SCAN_SUPPRESS_TIMEOUT 31000 /* default Framwork DHCP timeout is 30 sec */
441 #define WL_SCAN_SUPPRESS_RETRY 3000
442
443 #define WL_PM_ENABLE_TIMEOUT 10000
444
445 /* cfg80211 wowlan definitions */
446 #define WL_WOWLAN_MAX_PATTERNS 8
447 #define WL_WOWLAN_MIN_PATTERN_LEN 1
448 #define WL_WOWLAN_MAX_PATTERN_LEN 255
449 #define WL_WOWLAN_PKT_FILTER_ID_FIRST 201
450 #define WL_WOWLAN_PKT_FILTER_ID_LAST (WL_WOWLAN_PKT_FILTER_ID_FIRST + \
451 WL_WOWLAN_MAX_PATTERNS - 1)
452 #define IBSS_COALESCE_DEFAULT 1
453 #define IBSS_INITIAL_SCAN_ALLOWED_DEFAULT 1
454
455 #ifdef WLTDLS
456 #define TDLS_TUNNELED_PRB_REQ "\x7f\x50\x6f\x9a\04"
457 #define TDLS_TUNNELED_PRB_RESP "\x7f\x50\x6f\x9a\05"
458 #define TDLS_MAX_IFACE_FOR_ENABLE 1
459 #endif /* WLTDLS */
460
461 #ifndef FILS_INDICATION_IE_TAG_FIXED_LEN
462 #define FILS_INDICATION_IE_TAG_FIXED_LEN 2
463 #endif // endif
464
465 #if defined(STRICT_GCC_WARNINGS) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == \
466 4 && __GNUC_MINOR__ >= 6))
467 #define BCM_SET_LIST_FIRST_ENTRY(entry, ptr, type, member) \
468 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST(); \
469 (entry) = list_first_entry((ptr), type, member); \
470 GCC_DIAGNOSTIC_POP(); \
471
472 #define BCM_SET_CONTAINER_OF(entry, ptr, type, member) \
473 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST(); \
474 entry = container_of((ptr), type, member); \
475 GCC_DIAGNOSTIC_POP(); \
476
477 #else
478 #define BCM_SET_LIST_FIRST_ENTRY(entry, ptr, type, member) \
479 (entry) = list_first_entry((ptr), type, member); \
480
481 #define BCM_SET_CONTAINER_OF(entry, ptr, type, member) \
482 entry = container_of((ptr), type, member); \
483
484 #endif /* STRICT_GCC_WARNINGS */
485
486 /* driver status */
487 enum wl_status {
488 WL_STATUS_READY = 0,
489 WL_STATUS_SCANNING,
490 WL_STATUS_SCAN_ABORTING,
491 WL_STATUS_CONNECTING,
492 WL_STATUS_CONNECTED,
493 WL_STATUS_DISCONNECTING,
494 WL_STATUS_AP_CREATING,
495 WL_STATUS_AP_CREATED,
496 /* whole sending action frame procedure:
497 * includes a) 'finding common channel' for public action request frame
498 * and b) 'sending af via 'actframe' iovar'
499 */
500 WL_STATUS_SENDING_ACT_FRM,
501 /* find a peer to go to a common channel before sending public action req frame */
502 WL_STATUS_FINDING_COMMON_CHANNEL,
503 /* waiting for next af to sync time of supplicant.
504 * it includes SENDING_ACT_FRM and WAITING_NEXT_ACT_FRM_LISTEN
505 */
506 WL_STATUS_WAITING_NEXT_ACT_FRM,
507 #ifdef WL_CFG80211_SYNC_GON
508 /* go to listen state to wait for next af after SENDING_ACT_FRM */
509 WL_STATUS_WAITING_NEXT_ACT_FRM_LISTEN,
510 #endif /* WL_CFG80211_SYNC_GON */
511 /* it will be set when upper layer requests listen and succeed in setting listen mode.
512 * if set, other scan request can abort current listen state
513 */
514 WL_STATUS_REMAINING_ON_CHANNEL,
515 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
516 /* it's fake listen state to keep current scan state.
517 * it will be set when upper layer requests listen but scan is running. then just run
518 * a expire timer without actual listen state.
519 * if set, other scan request does not need to abort scan.
520 */
521 WL_STATUS_FAKE_REMAINING_ON_CHANNEL,
522 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
523 WL_STATUS_NESTED_CONNECT,
524 WL_STATUS_CFG80211_CONNECT
525 };
526
527 typedef enum wl_iftype {
528 WL_IF_TYPE_STA = 0,
529 WL_IF_TYPE_AP = 1,
530 #ifdef WLMESH_CFG80211
531 WL_IF_TYPE_MESH = 2,
532 #endif /* WLMESH_CFG80211 */
533 WL_IF_TYPE_NAN_NMI = 3,
534 WL_IF_TYPE_NAN = 4,
535 WL_IF_TYPE_P2P_GO = 5,
536 WL_IF_TYPE_P2P_GC = 6,
537 WL_IF_TYPE_P2P_DISC = 7,
538 WL_IF_TYPE_IBSS = 8,
539 WL_IF_TYPE_MONITOR = 9,
540 WL_IF_TYPE_AIBSS = 10,
541 WL_IF_TYPE_MAX
542 } wl_iftype_t;
543
544 typedef enum wl_interface_state {
545 WL_IF_CREATE_REQ,
546 WL_IF_CREATE_DONE,
547 WL_IF_DELETE_REQ,
548 WL_IF_DELETE_DONE,
549 WL_IF_CHANGE_REQ,
550 WL_IF_CHANGE_DONE,
551 WL_IF_STATE_MAX, /* Retain as last one */
552 } wl_interface_state_t;
553
554 /* wi-fi mode */
555 enum wl_mode {
556 WL_MODE_BSS = 0,
557 WL_MODE_IBSS = 1,
558 WL_MODE_AP = 2,
559 WL_MODE_NAN = 4,
560 #ifdef WLMESH_CFG80211
561 WL_MODE_MESH = 5,
562 #endif /* WLMESH_CFG80211 */
563 WL_MODE_MAX
564 };
565
566 /* driver profile list */
567 enum wl_prof_list {
568 WL_PROF_MODE,
569 WL_PROF_SSID,
570 WL_PROF_SEC,
571 WL_PROF_IBSS,
572 WL_PROF_BAND,
573 WL_PROF_CHAN,
574 WL_PROF_BSSID,
575 WL_PROF_ACT,
576 WL_PROF_BEACONINT,
577 WL_PROF_DTIMPERIOD,
578 WL_PROF_LATEST_BSSID
579 };
580
581 /* donlge escan state */
582 enum wl_escan_state {
583 WL_ESCAN_STATE_IDLE,
584 WL_ESCAN_STATE_SCANING
585 };
586 /* fw downloading status */
587 enum wl_fw_status {
588 WL_FW_LOADING_DONE,
589 WL_NVRAM_LOADING_DONE
590 };
591
592 enum wl_management_type {
593 WL_BEACON = 0x1,
594 WL_PROBE_RESP = 0x2,
595 WL_ASSOC_RESP = 0x4
596 };
597
598 enum wl_pm_workq_act_type {
599 WL_PM_WORKQ_SHORT,
600 WL_PM_WORKQ_LONG,
601 WL_PM_WORKQ_DEL
602 };
603
604 enum wl_tdls_config {
605 TDLS_STATE_AP_CREATE,
606 TDLS_STATE_AP_DELETE,
607 TDLS_STATE_CONNECT,
608 TDLS_STATE_DISCONNECT,
609 TDLS_STATE_SETUP,
610 TDLS_STATE_TEARDOWN,
611 TDLS_STATE_IF_CREATE,
612 TDLS_STATE_IF_DELETE,
613 TDLS_STATE_NMI_CREATE
614 };
615
616 /* beacon / probe_response */
617 struct beacon_proberesp {
618 __le64 timestamp;
619 __le16 beacon_int;
620 __le16 capab_info;
621 u8 variable[0];
622 } __attribute__ ((packed));
623
624 /* driver configuration */
625 struct wl_conf {
626 u32 frag_threshold;
627 u32 rts_threshold;
628 u32 retry_short;
629 u32 retry_long;
630 s32 tx_power;
631 struct ieee80211_channel channel;
632 };
633
634 typedef s32(*EVENT_HANDLER) (struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
635 const wl_event_msg_t *e, void *data);
636
637 /* bss inform structure for cfg80211 interface */
638 struct wl_cfg80211_bss_info {
639 u16 band;
640 u16 channel;
641 s16 rssi;
642 u16 frame_len;
643 u8 frame_buf[1];
644 };
645
646 /* basic structure of scan request */
647 struct wl_scan_req {
648 struct wlc_ssid ssid;
649 };
650
651 /* basic structure of information element */
652 struct wl_ie {
653 u16 offset;
654 u8 buf[WL_TLV_INFO_MAX];
655 };
656
657 /* event queue for cfg80211 main event */
658 struct wl_event_q {
659 struct list_head eq_list;
660 u32 etype;
661 wl_event_msg_t emsg;
662 u32 datalen;
663 s8 edata[1];
664 };
665
666 /* security information with currently associated ap */
667 struct wl_security {
668 u32 wpa_versions;
669 u32 auth_type;
670 u32 cipher_pairwise;
671 u32 cipher_group;
672 u32 wpa_auth;
673 u32 auth_assoc_res_status;
674 };
675
676 /* ibss information for currently joined ibss network */
677 struct wl_ibss {
678 u8 beacon_interval; /* in millisecond */
679 u8 atim; /* in millisecond */
680 s8 join_only;
681 u8 band;
682 u8 channel;
683 };
684
685 typedef struct wl_bss_vndr_ies {
686 u8 probe_req_ie[VNDR_IES_BUF_LEN];
687 u8 probe_res_ie[VNDR_IES_MAX_BUF_LEN];
688 u8 assoc_req_ie[VNDR_IES_BUF_LEN];
689 u8 assoc_res_ie[VNDR_IES_BUF_LEN];
690 u8 beacon_ie[VNDR_IES_MAX_BUF_LEN];
691 u8 disassoc_ie[VNDR_IES_BUF_LEN];
692 u32 probe_req_ie_len;
693 u32 probe_res_ie_len;
694 u32 assoc_req_ie_len;
695 u32 assoc_res_ie_len;
696 u32 beacon_ie_len;
697 u32 disassoc_ie_len;
698 } wl_bss_vndr_ies_t;
699
700 typedef struct wl_cfgbss {
701 u8 *wpa_ie;
702 u8 *rsn_ie;
703 u8 *wps_ie;
704 u8 *fils_ind_ie;
705 bool security_mode;
706 struct wl_bss_vndr_ies ies; /* Common for STA, P2P GC, GO, AP, P2P Disc Interface */
707 } wl_cfgbss_t;
708
709 /* cfg driver profile */
710 struct wl_profile {
711 u32 mode;
712 s32 band;
713 u32 channel;
714 struct wlc_ssid ssid;
715 struct wl_security sec;
716 struct wl_ibss ibss;
717 u8 bssid[ETHER_ADDR_LEN];
718 u16 beacon_interval;
719 u8 dtim_period;
720 bool active;
721 u8 latest_bssid[ETHER_ADDR_LEN];
722 };
723
724 struct wl_wps_ie {
725 uint8 id; /* IE ID: 0xDD */
726 uint8 len; /* IE length */
727 uint8 OUI[3]; /* WiFi WPS specific OUI */
728 uint8 oui_type; /* Vendor specific OUI Type */
729 uint8 attrib[1]; /* variable length attributes */
730 } __attribute__ ((packed));
731 typedef struct wl_wps_ie wl_wps_ie_t;
732
733 struct wl_eap_msg {
734 uint16 attrib;
735 uint16 len;
736 uint8 type;
737 } __attribute__ ((packed));
738 typedef struct wl_eap_msg wl_eap_msg_t;
739
740 struct wl_eap_exp {
741 uint8 OUI[3];
742 uint32 oui_type;
743 uint8 opcode;
744 u8 flags;
745 u8 data[1];
746 } __attribute__ ((packed));
747 typedef struct wl_eap_exp wl_eap_exp_t;
748
749 struct net_info {
750 struct net_device *ndev;
751 struct wireless_dev *wdev;
752 struct wl_profile profile;
753 wl_iftype_t iftype;
754 s32 roam_off;
755 unsigned long sme_state;
756 bool pm_restore;
757 bool pm_block;
758 s32 pm;
759 s32 bssidx;
760 wl_cfgbss_t bss;
761 u8 ifidx;
762 struct list_head list; /* list of all net_info structure */
763 };
764
765 #ifdef WL_BCNRECV
766 /* PERIODIC Beacon receive for detecting FakeAPs */
767 typedef struct wl_bcnrecv_result {
768 uint8 SSID[DOT11_MAX_SSID_LEN]; /**< SSID String */
769 struct ether_addr BSSID; /**< Network BSSID */
770 uint8 channel; /**< Channel */
771 uint16 beacon_interval;
772 uint32 timestamp[2]; /**< Beacon Timestamp */
773 uint64 system_time;
774 } wl_bcnrecv_result_t;
775
776 typedef struct wl_bcnrecv_info {
777 uint bcnrecv_state; /* TO know the fakeap state */
778 } wl_bcnrecv_info_t;
779
780 typedef enum wl_bcnrecv_state {
781 BEACON_RECV_IDLE = 0,
782 BEACON_RECV_STARTED,
783 BEACON_RECV_STOPPED,
784 BEACON_RECV_SUSPENDED
785 } wl_bcnrecv_state_t;
786
787 typedef enum wl_bcnrecv_reason {
788 WL_BCNRECV_INVALID = 0,
789 WL_BCNRECV_USER_TRIGGER,
790 WL_BCNRECV_SUSPEND,
791 WL_BCNRECV_SCANBUSY,
792 WL_BCNRECV_CONCURRENCY,
793 WL_BCNRECV_LISTENBUSY,
794 WL_BCNRECV_ROAMABORT,
795 WL_BCNRECV_HANG
796 } wl_bcnrecv_reason_t;
797
798 typedef enum wl_bcnrecv_status {
799 WL_BCNRECV_STARTED = 0,
800 WL_BCNRECV_STOPPED,
801 WL_BCNRECV_ABORTED,
802 WL_BCNRECV_SUSPENDED,
803 WL_BCNRECV_MAX
804 } wl_bcnrecv_status_t;
805
806 typedef enum wl_bcnrecv_attr_type {
807 BCNRECV_ATTR_STATUS = 1,
808 BCNRECV_ATTR_REASON,
809 BCNRECV_ATTR_BCNINFO
810 } wl_bcnrecv_attr_type_t;
811 #endif /* WL_BCNRECV */
812 #ifdef WL_CHAN_UTIL
813 #define CU_ATTR_PERCENTAGE 1
814 #define CU_ATTR_HDR_LEN 30
815 #endif /* WL_CHAN_UTIL */
816
817 /* association inform */
818 #define MAX_REQ_LINE 1024u
819 struct wl_connect_info {
820 u8 req_ie[MAX_REQ_LINE];
821 u32 req_ie_len;
822 u8 resp_ie[MAX_REQ_LINE];
823 u32 resp_ie_len;
824 };
825 #define WL_MAX_FILS_KEY_LEN 64
826
827 struct wl_fils_info {
828 u8 fils_kek[WL_MAX_FILS_KEY_LEN];
829 u32 fils_kek_len;
830 u8 fils_pmk[WL_MAX_FILS_KEY_LEN];
831 u32 fils_pmk_len;
832 u8 fils_pmkid[WL_MAX_FILS_KEY_LEN];
833 u16 fils_erp_next_seq_num;
834 bool fils_roam_disabled;
835 u32 fils_bcn_timeout_cache;
836 };
837
838 /* firmware /nvram downloading controller */
839 struct wl_fw_ctrl {
840 const struct firmware *fw_entry;
841 unsigned long status;
842 u32 ptr;
843 s8 fw_name[WL_FILE_NAME_MAX];
844 s8 nvram_name[WL_FILE_NAME_MAX];
845 };
846
847 /* assoc ie length */
848 struct wl_assoc_ielen {
849 u32 req_len;
850 u32 resp_len;
851 };
852
853 #define MIN_PMKID_LIST_V3_FW_MAJOR 13
854 #define MIN_PMKID_LIST_V3_FW_MINOR 0
855
856 #define MIN_PMKID_LIST_V2_FW_MAJOR 12
857 #define MIN_PMKID_LIST_V2_FW_MINOR 0
858
859 #define MIN_ESCAN_PARAM_V2_FW_MAJOR 14
860 #define MIN_ESCAN_PARAM_V2_FW_MINOR 0
861
862 /* wpa2 pmk list */
863 struct wl_pmk_list {
864 pmkid_list_v3_t pmkids;
865 pmkid_v3_t foo[MAXPMKID - 1];
866 };
867
868 #define KEY_PERM_PMK 0xFFFFFFFF
869
870 #ifdef DHD_MAX_IFS
871 #define WL_MAX_IFS DHD_MAX_IFS
872 #else
873 #define WL_MAX_IFS 16
874 #endif // endif
875
876 #define MAC_RAND_BYTES 3
877 #define ESCAN_BUF_SIZE (64 * 1024)
878
879 struct escan_info {
880 u32 escan_state;
881 #ifdef STATIC_WL_PRIV_STRUCT
882 #ifndef CONFIG_DHD_USE_STATIC_BUF
883 #error STATIC_WL_PRIV_STRUCT should be used with CONFIG_DHD_USE_STATIC_BUF
884 #endif /* CONFIG_DHD_USE_STATIC_BUF */
885 #ifdef DUAL_ESCAN_RESULT_BUFFER
886 u8 *escan_buf[2];
887 #else
888 u8 *escan_buf;
889 #endif /* DUAL_ESCAN_RESULT_BUFFER */
890 #else
891 #ifdef DUAL_ESCAN_RESULT_BUFFER
892 u8 escan_buf[2][ESCAN_BUF_SIZE];
893 #else
894 u8 escan_buf[ESCAN_BUF_SIZE];
895 #endif /* DUAL_ESCAN_RESULT_BUFFER */
896 #endif /* STATIC_WL_PRIV_STRUCT */
897 #ifdef DUAL_ESCAN_RESULT_BUFFER
898 u8 cur_sync_id;
899 u8 escan_type[2];
900 #endif /* DUAL_ESCAN_RESULT_BUFFER */
901 struct wiphy *wiphy;
902 struct net_device *ndev;
903 };
904
905 #ifdef ESCAN_BUF_OVERFLOW_MGMT
906 #define BUF_OVERFLOW_MGMT_COUNT 3
907 typedef struct {
908 int RSSI;
909 int length;
910 struct ether_addr BSSID;
911 } removal_element_t;
912 #endif /* ESCAN_BUF_OVERFLOW_MGMT */
913
914 struct afx_hdl {
915 wl_af_params_t *pending_tx_act_frm;
916 struct ether_addr tx_dst_addr;
917 struct net_device *dev;
918 struct work_struct work;
919 s32 bssidx;
920 u32 retry;
921 s32 peer_chan;
922 s32 peer_listen_chan; /* search channel: configured by upper layer */
923 s32 my_listen_chan; /* listen chanel: extract it from prb req or gon req */
924 bool is_listen;
925 bool ack_recv;
926 bool is_active;
927 };
928
929 struct parsed_ies {
930 const wpa_ie_fixed_t *wps_ie;
931 u32 wps_ie_len;
932 const wpa_ie_fixed_t *wpa_ie;
933 u32 wpa_ie_len;
934 const bcm_tlv_t *wpa2_ie;
935 u32 wpa2_ie_len;
936 const bcm_tlv_t *fils_ind_ie;
937 u32 fils_ind_ie_len;
938 };
939
940 #ifdef P2P_LISTEN_OFFLOADING
941 typedef struct {
942 uint16 period; /* listen offload period */
943 uint16 interval; /* listen offload interval */
944 uint16 count; /* listen offload count */
945 uint16 pad; /* pad for 32bit align */
946 } wl_p2plo_listen_t;
947 #endif /* P2P_LISTEN_OFFLOADING */
948
949 #ifdef WL11U
950 /* Max length of Interworking element */
951 #define IW_IES_MAX_BUF_LEN 8
952 #endif // endif
953 #ifdef WLFBT
954 #define FBT_KEYLEN 32
955 #endif // endif
956 #define MAX_EVENT_BUF_NUM 16
957 typedef struct wl_eventmsg_buf {
958 u16 num;
959 struct {
960 u16 type;
961 bool set;
962 } event [MAX_EVENT_BUF_NUM];
963 } wl_eventmsg_buf_t;
964
965 typedef struct wl_if_event_info {
966 bool valid;
967 int ifidx;
968 int bssidx;
969 uint8 mac[ETHER_ADDR_LEN];
970 char name[IFNAMSIZ+1];
971 uint8 role;
972 } wl_if_event_info;
973
974 #ifdef SUPPORT_AP_RADIO_PWRSAVE
975 typedef struct ap_rps_info {
976 bool enable;
977 int sta_assoc_check;
978 int pps;
979 int quiet_time;
980 int level;
981 } ap_rps_info_t;
982 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
983
984 #ifdef SUPPORT_RSSI_SUM_REPORT
985 #define RSSILOG_FLAG_FEATURE_SW 0x1
986 #define RSSILOG_FLAG_REPORT_READY 0x2
987 typedef struct rssilog_set_param {
988 uint8 enable;
989 uint8 rssi_threshold;
990 uint8 time_threshold;
991 uint8 pad;
992 } rssilog_set_param_t;
993
994 typedef struct rssilog_get_param {
995 uint8 report_count;
996 uint8 enable;
997 uint8 rssi_threshold;
998 uint8 time_threshold;
999 } rssilog_get_param_t;
1000
1001 typedef struct rssi_ant_param {
1002 struct ether_addr ea;
1003 chanspec_t chanspec;
1004 } rssi_ant_param_t;
1005
1006 typedef struct wl_rssi_ant_mimo {
1007 uint32 version;
1008 uint32 count;
1009 int8 rssi_ant[WL_RSSI_ANT_MAX];
1010 int8 rssi_sum;
1011 int8 PAD[3];
1012 } wl_rssi_ant_mimo_t;
1013 #endif /* SUPPORT_RSSI_SUM_REPORT */
1014
1015 /* MBO-OCE prune event reason codes */
1016 #if defined(WL_MBO) || defined(WL_OCE)
1017 typedef enum wl_prune_evt_reason {
1018 WIFI_PRUNE_UNSPECIFIED = 0, /* Unspecified event reason code */
1019 WIFI_PRUNE_ASSOC_RETRY_DELAY = 1, /* MBO assoc retry delay */
1020 WIFI_PRUNE_RSSI_ASSOC_REJ = 2 /* OCE RSSI-based assoc rejection */
1021 } wl_prune_evt_reason_t;
1022 #endif /* WL_MBO || WL_OCE */
1023
1024 #ifdef WL_MBO
1025 typedef struct wl_event_mbo wl_event_mbo_t;
1026 typedef struct wl_event_mbo_cell_nw_switch wl_event_mbo_cell_nw_switch_t;
1027 typedef struct wl_btm_event_type_data wl_btm_event_type_data_t;
1028 #endif /* WL_MBO */
1029
1030 #if defined(WL_MBO) || defined(WL_OCE)
1031 typedef struct wl_bssid_prune_evt_info wl_bssid_pruned_evt_info_t;
1032 #endif /* WL_MBO || WL_OCE */
1033
1034 #ifdef WL_NAN
1035 #define NAN_MAX_NDI 1u
1036 typedef struct wl_ndi_data
1037 {
1038 u8 ifname[IFNAMSIZ];
1039 u8 in_use;
1040 u8 created;
1041 struct net_device *nan_ndev;
1042 } wl_ndi_data_t;
1043
1044 typedef struct wl_nancfg
1045 {
1046 wl_nan_ver_t version;
1047 wl_ndi_data_t ndi[NAN_MAX_NDI];
1048 struct mutex nan_sync;
1049 uint8 svc_inst_id_mask[NAN_SVC_INST_SIZE];
1050 uint8 inst_id_start;
1051 /* wait queue and condition variable for nan event */
1052 bool nan_event_recvd;
1053 wait_queue_head_t nan_event_wait;
1054 nan_stop_reason_code_t disable_reason;
1055 bool mac_rand;
1056 int range_type;
1057 uint8 max_ndp_count; /* Max no. of NDPs */
1058 nan_ndp_peer_t *nan_ndp_peer_info;
1059 nan_data_path_id ndp_id[NAN_MAX_NDP_PEER];
1060 } wl_nancfg_t;
1061
1062 #ifdef WL_NANP2P
1063 #define WL_CFG_P2P_DISC_BIT 0x1u
1064 #define WL_CFG_NAN_DISC_BIT 0x2u
1065 #define WL_NANP2P_CONC_SUPPORT (WL_CFG_P2P_DISC_BIT | WL_CFG_NAN_DISC_BIT)
1066 #endif /* WL_NAN2P */
1067 #endif /* WL_NAN */
1068
1069 #ifdef WL_IFACE_MGMT
1070 #define WL_IFACE_NOT_PRESENT -1
1071
1072 typedef enum iface_conc_policy {
1073 WL_IF_POLICY_DEFAULT = 0,
1074 WL_IF_POLICY_FCFS = 1,
1075 WL_IF_POLICY_LP = 2,
1076 WL_IF_POLICY_ROLE_PRIORITY = 3,
1077 WL_IF_POLICY_CUSTOM = 4,
1078 WL_IF_POLICY_INVALID
1079 } iface_conc_policy_t;
1080
1081 typedef struct iface_mgmt_data {
1082 uint8 policy;
1083 uint8 priority[WL_IF_TYPE_MAX];
1084 } iface_mgmt_data_t;
1085 #endif /* WL_IFACE_MGMT */
1086
1087 #ifdef WL_WPS_SYNC
1088 #define EAP_PACKET 0
1089 #define EAP_EXPANDED_TYPE 254
1090 #define EAP_EXP_OPCODE_OFFSET 7
1091 #define EAP_EXP_FRAGMENT_LEN_OFFSET 2
1092 #define EAP_EXP_FLAGS_FRAGMENTED_DATA 2
1093 #define EAP_EXP_FLAGS_MORE_DATA 1
1094 #define EAPOL_EAP_HDR_LEN 5
1095 #define EAP_EXP_HDR_MIN_LENGTH (EAPOL_EAP_HDR_LEN + EAP_EXP_OPCODE_OFFSET)
1096 #define EAP_ATTRIB_MSGTYPE 0x1022
1097 #define EAP_WSC_UPNP 0
1098 #define EAP_WSC_START 1
1099 #define EAP_WSC_ACK 2
1100 #define EAP_WSC_NACK 3
1101 #define EAP_WSC_MSG 4
1102 #define EAP_WSC_DONE 5
1103 #define EAP_WSC_MSG_M8 12
1104 #define EAP_CODE_FAILURE 4
1105 #define WL_WPS_REAUTH_TIMEOUT 10000
1106
1107 struct wl_eap_header {
1108 unsigned char code; /* EAP code */
1109 unsigned char id; /* Current request ID */
1110 unsigned short length; /* Length including header */
1111 unsigned char type; /* EAP type (optional) */
1112 unsigned char data[1]; /* Type data (optional) */
1113 } __attribute__ ((packed));
1114 typedef struct wl_eap_header wl_eap_header_t;
1115
1116 typedef enum wl_wps_state {
1117 WPS_STATE_IDLE = 0,
1118 WPS_STATE_STARTED,
1119 WPS_STATE_M8_SENT,
1120 WPS_STATE_M8_RECVD,
1121 WPS_STATE_EAP_FAIL,
1122 WPS_STATE_REAUTH_WAIT,
1123 WPS_STATE_LINKUP,
1124 WPS_STATE_LINKDOWN,
1125 WPS_STATE_DISCONNECT,
1126 WPS_STATE_DISCONNECT_CLIENT,
1127 WPS_STATE_CONNECT_FAIL,
1128 WPS_STATE_AUTHORIZE,
1129 WPS_STATE_DONE,
1130 WPS_STATE_INVALID
1131 } wl_wps_state_t;
1132
1133 #define WPS_MAX_SESSIONS 2
1134 typedef struct wl_wps_session {
1135 bool in_use;
1136 timer_list_compat_t timer;
1137 struct net_device *ndev;
1138 wl_wps_state_t state;
1139 u16 mode;
1140 u8 peer_mac[ETHER_ADDR_LEN];
1141 } wl_wps_session_t;
1142 #endif /* WL_WPS_SYNC */
1143
1144 #ifndef WL_STATIC_IFNAME_PREFIX
1145 #define WL_STATIC_IFNAME_PREFIX "wlan%d"
1146 #endif /* WL_STATIC_IFNAME */
1147
1148 typedef struct buf_data {
1149 u32 ver; /* version of struct */
1150 u32 len; /* Total len */
1151 /* size of each buffer in case of split buffers (0 - single buffer). */
1152 u32 buf_threshold;
1153 const void *data_buf[1]; /* array of user space buffer pointers. */
1154 } buf_data_t;
1155
1156 /* private data of cfg80211 interface */
1157 struct bcm_cfg80211 {
1158 struct wireless_dev *wdev; /* representing cfg cfg80211 device */
1159
1160 struct wireless_dev *p2p_wdev; /* representing cfg cfg80211 device for P2P */
1161 struct net_device *p2p_net; /* reference to p2p0 interface */
1162
1163 struct wl_conf *conf;
1164 struct cfg80211_scan_request *scan_request; /* scan request object */
1165 EVENT_HANDLER evt_handler[WLC_E_LAST];
1166 struct list_head eq_list; /* used for event queue */
1167 struct list_head net_list; /* used for struct net_info */
1168 spinlock_t net_list_sync; /* to protect scan status (and others if needed) */
1169 spinlock_t eq_lock; /* for event queue synchronization */
1170 spinlock_t cfgdrv_lock; /* to protect scan status (and others if needed) */
1171 struct completion act_frm_scan;
1172 struct completion iface_disable;
1173 struct completion wait_next_af;
1174 struct mutex usr_sync; /* maily for up/down synchronization */
1175 struct mutex if_sync; /* maily for iface op synchronization */
1176 struct mutex scan_sync; /* scan sync from different scan contexts */
1177 struct wl_scan_results *bss_list;
1178 struct wl_scan_results *scan_results;
1179
1180 /* scan request object for internal purpose */
1181 struct wl_scan_req *scan_req_int;
1182 /* information element object for internal purpose */
1183 #if defined(STATIC_WL_PRIV_STRUCT)
1184 struct wl_ie *ie;
1185 #else
1186 struct wl_ie ie;
1187 #endif // endif
1188
1189 /* association information container */
1190 #if defined(STATIC_WL_PRIV_STRUCT)
1191 struct wl_connect_info *conn_info;
1192 #else
1193 struct wl_connect_info conn_info;
1194 #endif // endif
1195 #ifdef DEBUGFS_CFG80211
1196 struct dentry *debugfs;
1197 #endif /* DEBUGFS_CFG80211 */
1198 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
1199 tsk_ctl_t event_tsk; /* task of main event handler thread */
1200 dhd_pub_t *pub;
1201 u32 iface_cnt;
1202 u32 channel; /* current channel */
1203 u32 af_sent_channel; /* channel action frame is sent */
1204 /* next af subtype to cancel the remained dwell time in rx process */
1205 u8 next_af_subtype;
1206 #ifdef WL_CFG80211_SYNC_GON
1207 ulong af_tx_sent_jiffies;
1208 #endif /* WL_CFG80211_SYNC_GON */
1209 struct escan_info escan_info; /* escan information */
1210 bool active_scan; /* current scan mode */
1211 bool ibss_starter; /* indicates this sta is ibss starter */
1212 bool link_up; /* link/connection up flag */
1213
1214 /* indicate whether chip to support power save mode */
1215 bool pwr_save;
1216 bool roam_on; /* on/off switch for self-roaming */
1217 bool scan_tried; /* indicates if first scan attempted */
1218 #if defined(BCMSDIO) || defined(BCMDBUS)
1219 bool wlfc_on;
1220 #endif // endif
1221 bool vsdb_mode;
1222 #define WL_ROAM_OFF_ON_CONCURRENT 0x0001
1223 #define WL_ROAM_REVERT_STATUS 0x0002
1224 u32 roam_flags;
1225 u8 *ioctl_buf; /* ioctl buffer */
1226 struct mutex ioctl_buf_sync;
1227 u8 *escan_ioctl_buf;
1228 u8 *extra_buf; /* maily to grab assoc information */
1229 struct dentry *debugfsdir;
1230 struct rfkill *rfkill;
1231 bool rf_blocked;
1232 struct ieee80211_channel remain_on_chan;
1233 enum nl80211_channel_type remain_on_chan_type;
1234 u64 send_action_id;
1235 u64 last_roc_id;
1236 wait_queue_head_t netif_change_event;
1237 wl_if_event_info if_event_info;
1238 struct completion send_af_done;
1239 struct afx_hdl *afx_hdl;
1240 struct p2p_info *p2p;
1241 bool p2p_supported;
1242 void *btcoex_info;
1243 timer_list_compat_t scan_timeout; /* Timer for catch scan event timeout */
1244 #ifdef WL_CFG80211_GON_COLLISION
1245 u8 block_gon_req_tx_count;
1246 u8 block_gon_req_rx_count;
1247 #endif /* WL_CFG80211_GON_COLLISION */
1248 #if defined(P2P_IE_MISSING_FIX)
1249 bool p2p_prb_noti;
1250 #endif // endif
1251 s32(*state_notifier) (struct bcm_cfg80211 *cfg,
1252 struct net_info *_net_info, enum wl_status state, bool set);
1253 unsigned long interrested_state;
1254 wlc_ssid_t hostapd_ssid;
1255 #ifdef WL11U
1256 bool wl11u;
1257 #endif /* WL11U */
1258 bool sched_scan_running; /* scheduled scan req status */
1259 struct cfg80211_sched_scan_request *sched_scan_req; /* scheduled scan req */
1260 #ifdef WL_HOST_BAND_MGMT
1261 u8 curr_band;
1262 #endif /* WL_HOST_BAND_MGMT */
1263 bool scan_suppressed;
1264 timer_list_compat_t scan_supp_timer;
1265 struct work_struct wlan_work;
1266 struct mutex event_sync; /* maily for up/down synchronization */
1267 bool disable_roam_event;
1268 struct delayed_work pm_enable_work;
1269 struct workqueue_struct *event_workq; /* workqueue for event */
1270 struct work_struct event_work; /* work item for event */
1271 struct mutex pm_sync; /* mainly for pm work synchronization */
1272
1273 vndr_ie_setbuf_t *ibss_vsie; /* keep the VSIE for IBSS */
1274 int ibss_vsie_len;
1275 #ifdef WL_RELMCAST
1276 u32 rmc_event_pid;
1277 u32 rmc_event_seq;
1278 #endif /* WL_RELMCAST */
1279 #ifdef WLAIBSS_MCHAN
1280 struct ether_addr ibss_if_addr;
1281 bcm_struct_cfgdev *ibss_cfgdev; /* For AIBSS */
1282 #endif /* WLAIBSS_MCHAN */
1283 bool bss_pending_op; /* indicate where there is a pending IF operation */
1284 #ifdef WLFBT
1285 uint8 fbt_key[FBT_KEYLEN];
1286 #endif // endif
1287 int roam_offload;
1288 #ifdef WL_NAN
1289 bool nan_enable;
1290 nan_svc_inst_t nan_inst_ctrl[NAN_ID_CTRL_SIZE];
1291 struct ether_addr initiator_ndi;
1292 uint8 nan_dp_state;
1293 bool nan_init_state; /* nan initialization state */
1294 wait_queue_head_t ndp_if_change_event;
1295 uint8 support_5g;
1296 u8 nan_nmi_mac[ETH_ALEN];
1297 u8 nan_dp_count;
1298 wl_nancfg_t nancfg;
1299 struct delayed_work nan_disable;
1300 #ifdef WL_NAN_DISC_CACHE
1301 int nan_disc_count;
1302 nan_disc_result_cache *nan_disc_cache;
1303 nan_svc_info_t svc_info[NAN_MAX_SVC_INST];
1304 nan_ranging_inst_t nan_ranging_info[NAN_MAX_RANGING_INST];
1305 #endif /* WL_NAN_DISC_CACHE */
1306 #ifdef WL_NANP2P
1307 uint8 conc_disc;
1308 bool nan_p2p_supported;
1309 #endif /* WL_NANP2P */
1310 #endif /* WL_NAN */
1311 #ifdef WL_IFACE_MGMT
1312 iface_mgmt_data_t iface_data;
1313 #endif /* WL_IFACE_MGMT */
1314 #ifdef P2PLISTEN_AP_SAMECHN
1315 bool p2p_resp_apchn_status;
1316 #endif /* P2PLISTEN_AP_SAMECHN */
1317 struct wl_wsec_key wep_key;
1318 #ifdef WLTDLS
1319 u8 *tdls_mgmt_frame;
1320 u32 tdls_mgmt_frame_len;
1321 s32 tdls_mgmt_freq;
1322 #endif /* WLTDLS */
1323 bool need_wait_afrx;
1324 #ifdef QOS_MAP_SET
1325 uint8 *up_table; /* user priority table, size is UP_TABLE_MAX */
1326 #endif /* QOS_MAP_SET */
1327 struct ether_addr last_roamed_addr;
1328 bool rcc_enabled; /* flag for Roam channel cache feature */
1329 u16 ap_oper_channel;
1330 #ifdef DHD_LOSSLESS_ROAMING
1331 timer_list_compat_t roam_timeout; /* Timer for catch roam timeout */
1332 #endif // endif
1333 #ifndef DUAL_ESCAN_RESULT_BUFFER
1334 uint16 escan_sync_id_cntr;
1335 #endif // endif
1336 #ifdef WLTDLS
1337 uint8 tdls_supported;
1338 struct mutex tdls_sync; /* protect tdls config operations */
1339 #endif /* WLTDLS */
1340 #ifdef MFP
1341 const uint8 *bip_pos;
1342 int mfp_mode;
1343 #endif /* MFP */
1344 uint8 vif_count; /* Virtual Interface count */
1345 #ifdef SUPPORT_AP_RADIO_PWRSAVE
1346 ap_rps_info_t ap_rps_info;
1347 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
1348 u16 vif_macaddr_mask;
1349 osl_t *osh;
1350 struct list_head vndr_oui_list;
1351 spinlock_t vndr_oui_sync; /* to protect vndr_oui_list */
1352 bool rssi_sum_report;
1353 int rssi; /* previous RSSI (backup) of get_station */
1354 uint64 scan_enq_time;
1355 uint64 scan_deq_time;
1356 uint64 scan_hdlr_cmplt_time;
1357 uint64 scan_cmplt_time;
1358 uint64 wl_evt_deq_time;
1359 uint64 wl_evt_hdlr_entry_time;
1360 uint64 wl_evt_hdlr_exit_time;
1361 #ifdef WL_WPS_SYNC
1362 wl_wps_session_t wps_session[WPS_MAX_SESSIONS];
1363 spinlock_t wps_sync; /* to protect wps states (and others if needed) */
1364 #endif /* WL_WPS_SYNC */
1365 struct wl_fils_info fils_info;
1366 uint8 scanmac_enabled;
1367 #ifdef WL_BCNRECV
1368 /* structure used for fake ap detection info */
1369 struct mutex bcn_sync; /* mainly for bcn resume/suspend synchronization */
1370 wl_bcnrecv_info_t bcnrecv_info;
1371 #endif /* WL_BCNRECV */
1372 struct net_device *static_ndev;
1373 uint8 static_ndev_state;
1374 bool hal_started;
1375 wl_wlc_version_t wlc_ver;
1376 bool scan_params_v2;
1377 #ifdef SUPPORT_AP_BWCTRL
1378 u32 bw_cap_5g;
1379 #endif /* SUPPORT_AP_BWCTRL */
1380 #if defined(RSSIAVG)
1381 wl_rssi_cache_ctrl_t g_rssi_cache_ctrl;
1382 wl_rssi_cache_ctrl_t g_connected_rssi_cache_ctrl;
1383 #endif
1384 #if defined(BSSCACHE)
1385 wl_bss_cache_ctrl_t g_bss_cache_ctrl;
1386 #endif
1387 int autochannel;
1388 int best_2g_ch;
1389 int best_5g_ch;
1390 };
1391 #define WL_STATIC_IFIDX (DHD_MAX_IFS + DHD_MAX_STATIC_IFS - 1)
1392 enum static_ndev_states {
1393 NDEV_STATE_NONE,
1394 NDEV_STATE_OS_IF_CREATED,
1395 NDEV_STATE_FW_IF_CREATED,
1396 NDEV_STATE_FW_IF_FAILED,
1397 NDEV_STATE_FW_IF_DELETED
1398 };
1399 #define IS_CFG80211_STATIC_IF(cfg, ndev) \
1400 ((cfg && (cfg->static_ndev == ndev)) ? true : false)
1401 #define IS_CFG80211_STATIC_IF_ACTIVE(cfg) \
1402 ((cfg && cfg->static_ndev && \
1403 (cfg->static_ndev_state & NDEV_STATE_FW_IF_CREATED)) ? true : false)
1404 #define IS_CFG80211_STATIC_IF_NAME(cfg, name) \
1405 (cfg && cfg->static_ndev && \
1406 !strncmp(cfg->static_ndev->name, name, strlen(name)))
1407
1408 #ifdef WL_SAE
1409 typedef struct wl_sae_key_info {
1410 uint8 peer_mac[ETHER_ADDR_LEN];
1411 uint16 pmk_len;
1412 uint16 pmkid_len;
1413 const uint8 *pmk;
1414 const uint8 *pmkid;
1415 } wl_sae_key_info_t;
1416 #endif /* WL_SAE */
1417
1418 typedef enum wl_concurrency_mode {
1419 CONCURRENCY_MODE_NONE = 0,
1420 CONCURRENCY_SCC_MODE,
1421 CONCURRENCY_VSDB_MODE,
1422 CONCURRENCY_RSDB_MODE
1423 } wl_concurrency_mode_t;
1424
1425 typedef struct wl_wips_event_info {
1426 uint32 timestamp;
1427 struct ether_addr bssid;
1428 uint16 misdeauth;
1429 int16 current_RSSI;
1430 int16 deauth_RSSI;
1431 } wl_wips_event_info_t;
1432
1433 s32 wl_iftype_to_mode(wl_iftype_t iftype);
1434
1435 #define BCM_LIST_FOR_EACH_ENTRY_SAFE(pos, next, head, member) \
1436 list_for_each_entry_safe((pos), (next), (head), member)
1437 extern int ioctl_version;
1438
next_bss(struct wl_scan_results * list,wl_bss_info_t * bss)1439 static inline wl_bss_info_t *next_bss(struct wl_scan_results *list, wl_bss_info_t *bss)
1440 {
1441 return bss = bss ?
1442 (wl_bss_info_t *)((uintptr) bss + dtoh32(bss->length)) : list->bss_info;
1443 }
1444
1445 static inline void
wl_probe_wdev_all(struct bcm_cfg80211 * cfg)1446 wl_probe_wdev_all(struct bcm_cfg80211 *cfg)
1447 {
1448 struct net_info *_net_info, *next;
1449 unsigned long int flags;
1450 int idx = 0;
1451 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1452 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1453 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next,
1454 &cfg->net_list, list) {
1455 GCC_DIAGNOSTIC_POP();
1456 WL_INFORM_MEM(("wl_probe_wdev_all: net_list[%d] bssidx: %d\n",
1457 idx++, _net_info->bssidx));
1458 }
1459 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1460 return;
1461 }
1462
1463 static inline struct net_info *
wl_get_netinfo_by_fw_idx(struct bcm_cfg80211 * cfg,s32 bssidx,u8 ifidx)1464 wl_get_netinfo_by_fw_idx(struct bcm_cfg80211 *cfg, s32 bssidx, u8 ifidx)
1465 {
1466 struct net_info *_net_info, *next, *info = NULL;
1467 unsigned long int flags;
1468
1469 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1470 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1471 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1472 GCC_DIAGNOSTIC_POP();
1473 if ((bssidx >= 0) && (_net_info->bssidx == bssidx) &&
1474 (_net_info->ifidx == ifidx)) {
1475 info = _net_info;
1476 break;
1477 }
1478 }
1479 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1480 return info;
1481 }
1482
1483 static inline void
wl_dealloc_netinfo_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1484 wl_dealloc_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1485 {
1486 struct net_info *_net_info, *next;
1487 unsigned long int flags;
1488
1489 #ifdef DHD_IFDEBUG
1490 WL_INFORM_MEM(("dealloc_netinfo enter wdev=%p \n", OSL_OBFUSCATE_BUF(wdev)));
1491 #endif // endif
1492 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1493 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1494 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1495 GCC_DIAGNOSTIC_POP();
1496 if (wdev && (_net_info->wdev == wdev)) {
1497 wl_cfgbss_t *bss = &_net_info->bss;
1498
1499 if (bss->wpa_ie) {
1500 MFREE(cfg->osh, bss->wpa_ie, bss->wpa_ie[1]
1501 + WPA_RSN_IE_TAG_FIXED_LEN);
1502 bss->wpa_ie = NULL;
1503 }
1504
1505 if (bss->rsn_ie) {
1506 MFREE(cfg->osh, bss->rsn_ie,
1507 bss->rsn_ie[1] + WPA_RSN_IE_TAG_FIXED_LEN);
1508 bss->rsn_ie = NULL;
1509 }
1510
1511 if (bss->wps_ie) {
1512 MFREE(cfg->osh, bss->wps_ie, bss->wps_ie[1] + 2);
1513 bss->wps_ie = NULL;
1514 }
1515 list_del(&_net_info->list);
1516 cfg->iface_cnt--;
1517 MFREE(cfg->osh, _net_info, sizeof(struct net_info));
1518 }
1519 }
1520 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1521 #ifdef DHD_IFDEBUG
1522 WL_INFORM_MEM(("dealloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
1523 #endif // endif
1524 }
1525
1526 static inline s32
wl_alloc_netinfo(struct bcm_cfg80211 * cfg,struct net_device * ndev,struct wireless_dev * wdev,wl_iftype_t iftype,bool pm_block,u8 bssidx,u8 ifidx)1527 wl_alloc_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev,
1528 struct wireless_dev * wdev, wl_iftype_t iftype, bool pm_block, u8 bssidx, u8 ifidx)
1529 {
1530 struct net_info *_net_info;
1531 s32 err = 0;
1532 unsigned long int flags;
1533 #ifdef DHD_IFDEBUG
1534 WL_INFORM_MEM(("alloc_netinfo enter bssidx=%d wdev=%p\n",
1535 bssidx, OSL_OBFUSCATE_BUF(wdev)));
1536 #endif // endif
1537 /* Check whether there is any duplicate entry for the
1538 * same bssidx && ifidx.
1539 */
1540 if ((_net_info = wl_get_netinfo_by_fw_idx(cfg, bssidx, ifidx))) {
1541 /* We have a duplicate entry for the same bssidx
1542 * already present which shouldn't have been the case.
1543 * Attempt recovery.
1544 */
1545 WL_ERR(("Duplicate entry for bssidx=%d ifidx=%d present."
1546 " Can't add new entry\n", bssidx, ifidx));
1547 wl_probe_wdev_all(cfg);
1548 #ifdef DHD_DEBUG
1549 ASSERT(0);
1550 #endif /* DHD_DEBUG */
1551 return -EINVAL;
1552 }
1553 if (cfg->iface_cnt == IFACE_MAX_CNT)
1554 return -ENOMEM;
1555 _net_info = (struct net_info *)MALLOCZ(cfg->osh, sizeof(struct net_info));
1556 if (!_net_info)
1557 err = -ENOMEM;
1558 else {
1559 _net_info->iftype = iftype;
1560 _net_info->ndev = ndev;
1561 _net_info->wdev = wdev;
1562 _net_info->pm_restore = 0;
1563 _net_info->pm = 0;
1564 _net_info->pm_block = pm_block;
1565 _net_info->roam_off = WL_INVALID;
1566 _net_info->bssidx = bssidx;
1567 _net_info->ifidx = ifidx;
1568 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1569 cfg->iface_cnt++;
1570 list_add(&_net_info->list, &cfg->net_list);
1571 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1572 }
1573 #ifdef DHD_IFDEBUG
1574 WL_DBG(("alloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
1575 #endif // endif
1576 return err;
1577 }
1578
1579 static inline void
wl_delete_all_netinfo(struct bcm_cfg80211 * cfg)1580 wl_delete_all_netinfo(struct bcm_cfg80211 *cfg)
1581 {
1582 struct net_info *_net_info, *next;
1583 unsigned long int flags;
1584
1585 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1586 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1587 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1588 wl_cfgbss_t *bss = &_net_info->bss;
1589 GCC_DIAGNOSTIC_POP();
1590
1591 if (bss->wpa_ie) {
1592 MFREE(cfg->osh, bss->wpa_ie, bss->wpa_ie[1]
1593 + WPA_RSN_IE_TAG_FIXED_LEN);
1594 bss->wpa_ie = NULL;
1595 }
1596
1597 if (bss->rsn_ie) {
1598 MFREE(cfg->osh, bss->rsn_ie, bss->rsn_ie[1]
1599 + WPA_RSN_IE_TAG_FIXED_LEN);
1600 bss->rsn_ie = NULL;
1601 }
1602
1603 if (bss->wps_ie) {
1604 MFREE(cfg->osh, bss->wps_ie, bss->wps_ie[1] + 2);
1605 bss->wps_ie = NULL;
1606 }
1607
1608 if (bss->fils_ind_ie) {
1609 MFREE(cfg->osh, bss->fils_ind_ie, bss->fils_ind_ie[1]
1610 + FILS_INDICATION_IE_TAG_FIXED_LEN);
1611 bss->fils_ind_ie = NULL;
1612 }
1613 list_del(&_net_info->list);
1614 if (_net_info->wdev) {
1615 MFREE(cfg->osh, _net_info->wdev, sizeof(struct wireless_dev));
1616 }
1617 MFREE(cfg->osh, _net_info, sizeof(struct net_info));
1618 }
1619 cfg->iface_cnt = 0;
1620 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1621 }
1622 static inline u32
wl_get_status_all(struct bcm_cfg80211 * cfg,s32 status)1623 wl_get_status_all(struct bcm_cfg80211 *cfg, s32 status)
1624
1625 {
1626 struct net_info *_net_info, *next;
1627 u32 cnt = 0;
1628 unsigned long int flags;
1629
1630 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1631 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1632 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1633 GCC_DIAGNOSTIC_POP();
1634 if (_net_info->ndev &&
1635 test_bit(status, &_net_info->sme_state))
1636 cnt++;
1637 }
1638 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1639 return cnt;
1640 }
1641 static inline void
wl_set_status_all(struct bcm_cfg80211 * cfg,s32 status,u32 op)1642 wl_set_status_all(struct bcm_cfg80211 *cfg, s32 status, u32 op)
1643 {
1644 struct net_info *_net_info, *next;
1645 unsigned long int flags;
1646
1647 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1648 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1649 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1650 GCC_DIAGNOSTIC_POP();
1651 switch (op) {
1652 case 1:
1653 break; /* set all status is not allowed */
1654 case 2:
1655 /*
1656 * Release the spinlock before calling notifier. Else there
1657 * will be nested calls
1658 */
1659 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1660 clear_bit(status, &_net_info->sme_state);
1661 if (cfg->state_notifier &&
1662 test_bit(status, &(cfg->interrested_state)))
1663 cfg->state_notifier(cfg, _net_info, status, false);
1664 return;
1665 case 4:
1666 break; /* change all status is not allowed */
1667 default:
1668 break; /* unknown operation */
1669 }
1670 }
1671 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1672 }
1673 static inline void
wl_set_status_by_netdev(struct bcm_cfg80211 * cfg,s32 status,struct net_device * ndev,u32 op)1674 wl_set_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
1675 struct net_device *ndev, u32 op)
1676 {
1677
1678 struct net_info *_net_info, *next;
1679 unsigned long int flags;
1680
1681 if (status >= BITS_PER_LONG) {
1682 /* max value for shift operation is
1683 * (BITS_PER_LONG -1) for unsigned long.
1684 * if status crosses BIT_PER_LONG, the variable
1685 * sme_state should be correspondingly updated.
1686 */
1687 ASSERT(0);
1688 return;
1689 }
1690
1691 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1692 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1693 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1694 if (ndev && (_net_info->ndev == ndev)) {
1695 GCC_DIAGNOSTIC_POP();
1696 switch (op) {
1697 case 1:
1698 /*
1699 * Release the spinlock before calling notifier. Else there
1700 * will be nested calls
1701 */
1702 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1703 set_bit(status, &_net_info->sme_state);
1704 if (cfg->state_notifier &&
1705 test_bit(status, &(cfg->interrested_state)))
1706 cfg->state_notifier(cfg, _net_info, status, true);
1707 return;
1708 case 2:
1709 /*
1710 * Release the spinlock before calling notifier. Else there
1711 * will be nested calls
1712 */
1713 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1714 clear_bit(status, &_net_info->sme_state);
1715 if (cfg->state_notifier &&
1716 test_bit(status, &(cfg->interrested_state)))
1717 cfg->state_notifier(cfg, _net_info, status, false);
1718 return;
1719 case 4:
1720 change_bit(status, &_net_info->sme_state);
1721 break;
1722 }
1723 }
1724
1725 }
1726 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1727
1728 }
1729
1730 static inline wl_cfgbss_t *
wl_get_cfgbss_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1731 wl_get_cfgbss_by_wdev(struct bcm_cfg80211 *cfg,
1732 struct wireless_dev *wdev)
1733 {
1734 struct net_info *_net_info, *next;
1735 wl_cfgbss_t *bss = NULL;
1736 unsigned long int flags;
1737
1738 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1739 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1740 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1741 GCC_DIAGNOSTIC_POP();
1742 if (wdev && (_net_info->wdev == wdev)) {
1743 bss = &_net_info->bss;
1744 break;
1745 }
1746 }
1747
1748 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1749 return bss;
1750 }
1751
1752 static inline u32
wl_get_status_by_netdev(struct bcm_cfg80211 * cfg,s32 status,struct net_device * ndev)1753 wl_get_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
1754 struct net_device *ndev)
1755 {
1756 struct net_info *_net_info, *next;
1757 u32 stat = 0;
1758 unsigned long int flags;
1759
1760 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1761 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1762 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1763 GCC_DIAGNOSTIC_POP();
1764 if (ndev && (_net_info->ndev == ndev)) {
1765 stat = test_bit(status, &_net_info->sme_state);
1766 break;
1767 }
1768 }
1769 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1770 return stat;
1771 }
1772
1773 static inline s32
wl_get_mode_by_netdev(struct bcm_cfg80211 * cfg,struct net_device * ndev)1774 wl_get_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1775 {
1776 struct net_info *_net_info, *next;
1777 s32 mode = -1;
1778 unsigned long int flags;
1779
1780 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1781 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1782 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1783 GCC_DIAGNOSTIC_POP();
1784 if (_net_info->ndev && (_net_info->ndev == ndev)) {
1785 mode = wl_iftype_to_mode(_net_info->iftype);
1786 break;
1787 }
1788 }
1789 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1790 return mode;
1791 }
1792
1793 static inline s32
wl_get_bssidx_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1794 wl_get_bssidx_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1795 {
1796 struct net_info *_net_info, *next;
1797 s32 bssidx = -1;
1798 unsigned long int flags;
1799
1800 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1801 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1802 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1803 GCC_DIAGNOSTIC_POP();
1804 if (_net_info->wdev && (_net_info->wdev == wdev)) {
1805 bssidx = _net_info->bssidx;
1806 break;
1807 }
1808 }
1809 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1810 return bssidx;
1811 }
1812
1813 static inline struct wireless_dev *
wl_get_wdev_by_fw_idx(struct bcm_cfg80211 * cfg,s32 bssidx,s32 ifidx)1814 wl_get_wdev_by_fw_idx(struct bcm_cfg80211 *cfg, s32 bssidx, s32 ifidx)
1815 {
1816 struct net_info *_net_info, *next;
1817 struct wireless_dev *wdev = NULL;
1818 unsigned long int flags;
1819
1820 if (bssidx < 0)
1821 return NULL;
1822 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1823 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1824 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1825 GCC_DIAGNOSTIC_POP();
1826 if ((_net_info->bssidx == bssidx) && (_net_info->ifidx == ifidx)) {
1827 wdev = _net_info->wdev;
1828 break;
1829 }
1830 }
1831 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1832 return wdev;
1833 }
1834
1835 static inline struct wl_profile *
wl_get_profile_by_netdev(struct bcm_cfg80211 * cfg,struct net_device * ndev)1836 wl_get_profile_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1837 {
1838 struct net_info *_net_info, *next;
1839 struct wl_profile *prof = NULL;
1840 unsigned long int flags;
1841
1842 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1843 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1844 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1845 GCC_DIAGNOSTIC_POP();
1846 if (ndev && (_net_info->ndev == ndev)) {
1847 prof = &_net_info->profile;
1848 break;
1849 }
1850 }
1851 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1852 return prof;
1853 }
1854 static inline struct net_info *
wl_get_netinfo_by_netdev(struct bcm_cfg80211 * cfg,struct net_device * ndev)1855 wl_get_netinfo_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1856 {
1857 struct net_info *_net_info, *next, *info = NULL;
1858 unsigned long int flags;
1859
1860 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1861 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1862 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1863 GCC_DIAGNOSTIC_POP();
1864 if (ndev && (_net_info->ndev == ndev)) {
1865 info = _net_info;
1866 break;
1867 }
1868 }
1869 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1870 return info;
1871 }
1872
1873 static inline struct net_info *
wl_get_netinfo_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1874 wl_get_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1875 {
1876 struct net_info *_net_info, *next, *info = NULL;
1877 unsigned long int flags;
1878
1879 WL_CFG_NET_LIST_SYNC_LOCK(&cfg->net_list_sync, flags);
1880 GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
1881 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1882 GCC_DIAGNOSTIC_POP();
1883 if (wdev && (_net_info->wdev == wdev)) {
1884 info = _net_info;
1885 break;
1886 }
1887 }
1888 WL_CFG_NET_LIST_SYNC_UNLOCK(&cfg->net_list_sync, flags);
1889 return info;
1890 }
1891
1892 static inline char *
wl_iftype_to_str(int wl_iftype)1893 wl_iftype_to_str(int wl_iftype)
1894 {
1895 switch (wl_iftype) {
1896 case (WL_IF_TYPE_STA):
1897 return "WL_IF_TYPE_STA";
1898 case (WL_IF_TYPE_AP):
1899 return "WL_IF_TYPE_AP";
1900 case (WL_IF_TYPE_NAN_NMI):
1901 return "WL_IF_TYPE_NAN_NMI";
1902 case (WL_IF_TYPE_NAN):
1903 return "WL_IF_TYPE_NAN";
1904 case (WL_IF_TYPE_P2P_GO):
1905 return "WL_IF_TYPE_P2P_GO";
1906 case (WL_IF_TYPE_P2P_GC):
1907 return "WL_IF_TYPE_P2P_GC";
1908 case (WL_IF_TYPE_P2P_DISC):
1909 return "WL_IF_TYPE_P2P_DISC";
1910 case (WL_IF_TYPE_IBSS):
1911 return "WL_IF_TYPE_IBSS";
1912 case (WL_IF_TYPE_MONITOR):
1913 return "WL_IF_TYPE_MONITOR";
1914 case (WL_IF_TYPE_AIBSS):
1915 return "WL_IF_TYPE_AIBSS";
1916 default:
1917 return "WL_IF_TYPE_UNKNOWN";
1918 }
1919 }
1920
1921 #define is_discovery_iface(iface) (((iface == WL_IF_TYPE_P2P_DISC) || \
1922 (iface == WL_IF_TYPE_NAN_NMI)) ? 1 : 0)
1923 #define is_p2p_group_iface(wdev) (((wdev->iftype == NL80211_IFTYPE_P2P_GO) || \
1924 (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)) ? 1 : 0)
1925 #define bcmcfg_to_wiphy(cfg) (cfg->wdev->wiphy)
1926 #define bcmcfg_to_prmry_ndev(cfg) (cfg->wdev->netdev)
1927 #define bcmcfg_to_prmry_wdev(cfg) (cfg->wdev)
1928 #define bcmcfg_to_p2p_wdev(cfg) (cfg->p2p_wdev)
1929 #define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
1930 #define ndev_to_wdev(ndev) (ndev->ieee80211_ptr)
1931 #define wdev_to_ndev(wdev) (wdev->netdev)
1932
1933 #ifdef WL_BLOCK_P2P_SCAN_ON_STA
1934 #define IS_P2P_IFACE(wdev) (wdev && \
1935 ((wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) || \
1936 (wdev->iftype == NL80211_IFTYPE_P2P_GO) || \
1937 (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)))
1938 #endif /* WL_BLOCK_P2P_SCAN_ON_STA */
1939
1940 #define IS_STA_IFACE(wdev) (wdev && \
1941 (wdev->iftype == NL80211_IFTYPE_STATION))
1942
1943 #define IS_AP_IFACE(wdev) (wdev && \
1944 (wdev->iftype == NL80211_IFTYPE_AP))
1945
1946 #if defined(WL_ENABLE_P2P_IF)
1947 #define ndev_to_wlc_ndev(ndev, cfg) ((ndev == cfg->p2p_net) ? \
1948 bcmcfg_to_prmry_ndev(cfg) : ndev)
1949 #else
1950 #define ndev_to_wlc_ndev(ndev, cfg) (ndev)
1951 #endif /* WL_ENABLE_P2P_IF */
1952
1953 #define wdev_to_wlc_ndev(wdev, cfg) \
1954 (wdev_to_ndev(wdev) ? \
1955 wdev_to_ndev(wdev) : bcmcfg_to_prmry_ndev(cfg))
1956 #if defined(WL_CFG80211_P2P_DEV_IF)
1957 #define cfgdev_to_wlc_ndev(cfgdev, cfg) wdev_to_wlc_ndev(cfgdev, cfg)
1958 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_wdev(cfg)
1959 #elif defined(WL_ENABLE_P2P_IF)
1960 #define cfgdev_to_wlc_ndev(cfgdev, cfg) ndev_to_wlc_ndev(cfgdev, cfg)
1961 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_ndev(cfg)
1962 #else
1963 #define cfgdev_to_wlc_ndev(cfgdev, cfg) (cfgdev)
1964 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) (cfgdev)
1965 #endif /* WL_CFG80211_P2P_DEV_IF */
1966
1967 #if defined(WL_CFG80211_P2P_DEV_IF)
1968 #define cfgdev_to_wdev(cfgdev) (cfgdev)
1969 #define ndev_to_cfgdev(ndev) ndev_to_wdev(ndev)
1970 #define cfgdev_to_ndev(cfgdev) (cfgdev ? (cfgdev->netdev) : NULL)
1971 #define wdev_to_cfgdev(cfgdev) (cfgdev)
1972 #define discover_cfgdev(cfgdev, cfg) (cfgdev->iftype == NL80211_IFTYPE_P2P_DEVICE)
1973 #else
1974 #define cfgdev_to_wdev(cfgdev) (cfgdev->ieee80211_ptr)
1975 #define wdev_to_cfgdev(cfgdev) cfgdev ? (cfgdev->netdev) : NULL
1976 #define ndev_to_cfgdev(ndev) (ndev)
1977 #define cfgdev_to_ndev(cfgdev) (cfgdev)
1978 #define discover_cfgdev(cfgdev, cfg) (cfgdev == cfg->p2p_net)
1979 #endif /* WL_CFG80211_P2P_DEV_IF */
1980
1981 #if defined(WL_CFG80211_P2P_DEV_IF)
1982 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
1983 (cfg->scan_request->wdev == cfg->p2p_wdev)) ? true : false)
1984 #elif defined(WL_ENABLE_P2P_IF)
1985 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
1986 (cfg->scan_request->dev == cfg->p2p_net)) ? true : false)
1987 #else
1988 #define scan_req_match(cfg) (((cfg) && p2p_is_on(cfg) && p2p_scan(cfg)) ? \
1989 true : false)
1990 #endif /* WL_CFG80211_P2P_DEV_IF */
1991
1992 #define PRINT_WDEV_INFO(cfgdev) \
1993 { \
1994 struct wireless_dev *wdev = cfgdev_to_wdev(cfgdev); \
1995 struct net_device *netdev = wdev ? wdev->netdev : NULL; \
1996 WL_DBG(("wdev_ptr:%p ndev_ptr:%p ifname:%s iftype:%d\n", OSL_OBFUSCATE_BUF(wdev), \
1997 OSL_OBFUSCATE_BUF(netdev), \
1998 netdev ? netdev->name : "NULL (non-ndev device)", \
1999 wdev ? wdev->iftype : 0xff)); \
2000 }
2001
2002 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
2003 #define scan_req_iftype(req) (req->dev->ieee80211_ptr->iftype)
2004 #else
2005 #define scan_req_iftype(req) (req->wdev->iftype)
2006 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) */
2007
2008 #define wl_to_sr(w) (w->scan_req_int)
2009 #if defined(STATIC_WL_PRIV_STRUCT)
2010 #define wl_to_ie(w) (w->ie)
2011 #define wl_to_conn(w) (w->conn_info)
2012 #else
2013 #define wl_to_ie(w) (&w->ie)
2014 #define wl_to_conn(w) (&w->conn_info)
2015 #endif // endif
2016 #define wl_to_fils_info(w) (&w->fils_info)
2017 #define wiphy_from_scan(w) (w->escan_info.wiphy)
2018 #define wl_get_drv_status_all(cfg, stat) \
2019 (wl_get_status_all(cfg, WL_STATUS_ ## stat))
2020 #define wl_get_drv_status(cfg, stat, ndev) \
2021 (wl_get_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev))
2022 #define wl_set_drv_status(cfg, stat, ndev) \
2023 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 1))
2024 #define wl_clr_drv_status(cfg, stat, ndev) \
2025 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 2))
2026 #define wl_clr_drv_status_all(cfg, stat) \
2027 (wl_set_status_all(cfg, WL_STATUS_ ## stat, 2))
2028 #define wl_chg_drv_status(cfg, stat, ndev) \
2029 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 4))
2030
2031 #define for_each_bss(list, bss, __i) \
2032 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
2033
2034 #define for_each_ndev(cfg, iter, next) \
2035 list_for_each_entry_safe(iter, next, &cfg->net_list, list)
2036
2037 /* In case of WPS from wpa_supplicant, pairwise siute and group suite is 0.
2038 * In addtion to that, wpa_version is WPA_VERSION_1
2039 */
2040 #define is_wps_conn(_sme) \
2041 ((wl_cfgp2p_find_wpsie(_sme->ie, _sme->ie_len) != NULL) && \
2042 (!_sme->crypto.n_ciphers_pairwise) && \
2043 (!_sme->crypto.cipher_group))
2044
2045 #ifdef WLFBT
2046 #if defined(WLAN_AKM_SUITE_FT_8021X) && defined(WLAN_AKM_SUITE_FT_PSK)
2047 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X || \
2048 sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
2049 #elif defined(WLAN_AKM_SUITE_FT_8021X)
2050 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X)
2051 #elif defined(WLAN_AKM_SUITE_FT_PSK)
2052 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
2053 #else
2054 #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
2055 #endif /* WLAN_AKM_SUITE_FT_8021X && WLAN_AKM_SUITE_FT_PSK */
2056 #else
2057 #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
2058 #endif /* WLFBT */
2059
2060 #define IS_AKM_SUITE_CCKM(sec) ({BCM_REFERENCE(sec); FALSE;})
2061
2062 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
2063 #define STA_INFO_BIT(info) (1ul << NL80211_STA_ ## info)
2064 #ifdef strnicmp
2065 #undef strnicmp
2066 #endif /* strnicmp */
2067 #define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
2068 #else
2069 #define STA_INFO_BIT(info) (STATION_ ## info)
2070 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
2071
2072 extern s32 wl_cfg80211_attach(struct net_device *ndev, void *context);
2073 extern void wl_cfg80211_detach(struct bcm_cfg80211 *cfg);
2074
2075 extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
2076 void *data);
2077 extern s32 wl_cfg80211_handle_critical_events(struct bcm_cfg80211 *cfg,
2078 const wl_event_msg_t * e);
2079
2080 void wl_cfg80211_set_parent_dev(void *dev);
2081 struct device *wl_cfg80211_get_parent_dev(void);
2082 struct bcm_cfg80211 *wl_cfg80211_get_bcmcfg(void);
2083 void wl_cfg80211_set_bcmcfg(struct bcm_cfg80211 *cfg);
2084
2085 /* clear IEs */
2086 extern s32 wl_cfg80211_clear_mgmt_vndr_ies(struct bcm_cfg80211 *cfg);
2087 extern s32 wl_cfg80211_clear_per_bss_ies(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev);
2088 extern void wl_cfg80211_clear_p2p_disc_ies(struct bcm_cfg80211 *cfg);
2089 #ifdef WL_STATIC_IF
2090 extern int32 wl_cfg80211_update_iflist_info(struct bcm_cfg80211 *cfg, struct net_device *ndev,
2091 int ifidx, uint8 *addr, int bssidx, char *name, int if_state);
2092 #endif /* WL_STATIC_IF */
2093 extern s32 wl_cfg80211_up(struct net_device *net);
2094 extern s32 wl_cfg80211_down(struct net_device *net);
2095 extern void wl_cfg80211_sta_ifdown(struct net_device *net);
2096 extern s32 wl_cfg80211_notify_ifadd(struct net_device * dev, int ifidx, char *name, uint8 *mac,
2097 uint8 bssidx, uint8 role);
2098 extern s32 wl_cfg80211_notify_ifdel(struct net_device * dev, int ifidx, char *name, uint8 *mac,
2099 uint8 bssidx);
2100 extern s32 wl_cfg80211_notify_ifchange(struct net_device * dev, int ifidx, char *name, uint8 *mac,
2101 uint8 bssidx);
2102 extern struct net_device* wl_cfg80211_allocate_if(struct bcm_cfg80211 *cfg, int ifidx,
2103 const char *name, uint8 *mac, uint8 bssidx, const char *dngl_name);
2104 extern int wl_cfg80211_register_if(struct bcm_cfg80211 *cfg,
2105 int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
2106 extern int wl_cfg80211_remove_if(struct bcm_cfg80211 *cfg,
2107 int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
2108 extern void wl_cfg80211_cleanup_if(struct net_device *dev);
2109 extern bool wl_cfg80211_is_concurrent_mode(struct net_device * dev);
2110 extern void wl_cfg80211_disassoc(struct net_device *ndev, uint32 reason);
2111 extern void wl_cfg80211_del_all_sta(struct net_device *ndev, uint32 reason);
2112 extern void* wl_cfg80211_get_dhdp(struct net_device * dev);
2113 extern bool wl_cfg80211_is_p2p_active(struct net_device * dev);
2114 extern bool wl_cfg80211_is_roam_offload(struct net_device * dev);
2115 extern bool wl_cfg80211_is_event_from_connected_bssid(struct net_device * dev,
2116 const wl_event_msg_t *e, int ifidx);
2117 extern void wl_cfg80211_dbg_level(u32 level);
2118 extern s32 wl_cfg80211_get_p2p_dev_addr(struct net_device *net, struct ether_addr *p2pdev_addr);
2119 extern s32 wl_cfg80211_set_p2p_noa(struct net_device *net, char* buf, int len);
2120 extern s32 wl_cfg80211_get_p2p_noa(struct net_device *net, char* buf, int len);
2121 extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len,
2122 enum wl_management_type type);
2123 extern s32 wl_cfg80211_set_p2p_ps(struct net_device *net, char* buf, int len);
2124 extern s32 wl_cfg80211_set_p2p_ecsa(struct net_device *net, char* buf, int len);
2125 extern s32 wl_cfg80211_increase_p2p_bw(struct net_device *net, char* buf, int len);
2126 extern bool wl_cfg80211_check_vif_in_use(struct net_device *ndev);
2127 #ifdef P2PLISTEN_AP_SAMECHN
2128 extern s32 wl_cfg80211_set_p2p_resp_ap_chn(struct net_device *net, s32 enable);
2129 #endif /* P2PLISTEN_AP_SAMECHN */
2130
2131 /* btcoex functions */
2132 void* wl_cfg80211_btcoex_init(struct net_device *ndev);
2133 void wl_cfg80211_btcoex_deinit(void);
2134
2135 extern chanspec_t wl_chspec_from_legacy(chanspec_t legacy_chspec);
2136 extern chanspec_t wl_chspec_driver_to_host(chanspec_t chanspec);
2137
2138 #ifdef WL_SUPPORT_AUTO_CHANNEL
2139 #define CHANSPEC_BUF_SIZE 1024
2140 #define CHAN_SEL_IOCTL_DELAY 300
2141 #define CHAN_SEL_RETRY_COUNT 15
2142 #define CHANNEL_IS_RADAR(channel) (((channel & WL_CHAN_RADAR) || \
2143 (channel & WL_CHAN_PASSIVE)) ? true : false)
2144 #define CHANNEL_IS_2G(channel) (((channel >= 1) && (channel <= 14)) ? \
2145 true : false)
2146 #define CHANNEL_IS_5G(channel) (((channel >= 36) && (channel <= 165)) ? \
2147 true : false)
2148 extern s32 wl_cfg80211_get_best_channels(struct net_device *dev, char* command,
2149 int total_len);
2150 #endif /* WL_SUPPORT_AUTO_CHANNEL */
2151 extern int wl_cfg80211_ether_atoe(const char *a, struct ether_addr *n);
2152 extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
2153 extern s32 wl_mode_to_nl80211_iftype(s32 mode);
2154 int wl_cfg80211_do_driver_init(struct net_device *net);
2155 void wl_cfg80211_enable_trace(u32 level);
2156 extern s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify);
2157 extern s32 wl_cfg80211_if_is_group_owner(void);
2158 extern chanspec_t wl_chspec_host_to_driver(chanspec_t chanspec);
2159 extern chanspec_t wl_ch_host_to_driver(u16 channel);
2160 extern s32 wl_set_tx_power(struct net_device *dev,
2161 enum nl80211_tx_power_setting type, s32 dbm);
2162 extern s32 wl_get_tx_power(struct net_device *dev, s32 *dbm);
2163 extern s32 wl_add_remove_eventmsg(struct net_device *ndev, u16 event, bool add);
2164 extern void wl_stop_wait_next_action_frame(struct bcm_cfg80211 *cfg, struct net_device *ndev,
2165 u8 bsscfgidx);
2166 #ifdef WL_HOST_BAND_MGMT
2167 extern s32 wl_cfg80211_set_band(struct net_device *ndev, int band);
2168 #endif /* WL_HOST_BAND_MGMT */
2169 extern void wl_cfg80211_add_to_eventbuffer(wl_eventmsg_buf_t *ev, u16 event, bool set);
2170 extern s32 wl_cfg80211_apply_eventbuffer(struct net_device *ndev,
2171 struct bcm_cfg80211 *cfg, wl_eventmsg_buf_t *ev);
2172 extern void get_primary_mac(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
2173 extern void wl_cfg80211_update_power_mode(struct net_device *dev);
2174 extern void wl_terminate_event_handler(struct net_device *dev);
2175 extern struct bcm_cfg80211 *wl_get_cfg(struct net_device *ndev);
2176 extern s32 wl_cfg80211_set_if_band(struct net_device *ndev, int band);
2177 extern s32 wl_cfg80211_set_country_code(struct net_device *dev, char *country_code,
2178 bool notify, bool user_enforced, int revinfo);
2179 extern bool wl_cfg80211_is_hal_started(struct bcm_cfg80211 *cfg);
2180 #ifdef WL_WIPSEVT
2181 extern int wl_cfg80211_wips_event(uint16 misdeauth, char* bssid);
2182 extern int wl_cfg80211_wips_event_ext(wl_wips_event_info_t *wips_event);
2183 #endif /* WL_WIPSEVT */
2184
2185 #define SCAN_BUF_CNT 2
2186 #define SCAN_BUF_NEXT 1
2187 #define WL_SCANTYPE_LEGACY 0x1
2188 #define WL_SCANTYPE_P2P 0x2
2189 #ifdef DUAL_ESCAN_RESULT_BUFFER
2190 #define wl_escan_set_sync_id(a, b) ((a) = (b)->escan_info.cur_sync_id)
2191 #define wl_escan_set_type(a, b) ((a)->escan_info.escan_type\
2192 [((a)->escan_info.cur_sync_id)%SCAN_BUF_CNT] = (b))
wl_escan_get_buf(struct bcm_cfg80211 * cfg,bool aborted)2193 static inline wl_scan_results_t *wl_escan_get_buf(struct bcm_cfg80211 *cfg, bool aborted)
2194 {
2195 u8 index;
2196 if (aborted) {
2197 if (cfg->escan_info.escan_type[0] == cfg->escan_info.escan_type[1])
2198 index = (cfg->escan_info.cur_sync_id + 1)%SCAN_BUF_CNT;
2199 else
2200 index = (cfg->escan_info.cur_sync_id)%SCAN_BUF_CNT;
2201 }
2202 else
2203 index = (cfg->escan_info.cur_sync_id)%SCAN_BUF_CNT;
2204
2205 return (wl_scan_results_t *)cfg->escan_info.escan_buf[index];
2206 }
wl_escan_check_sync_id(s32 status,u16 result_id,u16 wl_id)2207 static inline int wl_escan_check_sync_id(s32 status, u16 result_id, u16 wl_id)
2208 {
2209 if (result_id != wl_id) {
2210 WL_ERR(("ESCAN sync id mismatch :status :%d "
2211 "cur_sync_id:%d coming sync_id:%d\n",
2212 status, wl_id, result_id));
2213 return -1;
2214 }
2215 else
2216 return 0;
2217 }
wl_escan_print_sync_id(s32 status,u16 result_id,u16 wl_id)2218 static inline void wl_escan_print_sync_id(s32 status, u16 result_id, u16 wl_id)
2219 {
2220 if (result_id != wl_id) {
2221 WL_ERR(("ESCAN sync id mismatch :status :%d "
2222 "cur_sync_id:%d coming sync_id:%d\n",
2223 status, wl_id, result_id));
2224 }
2225 }
2226 #define wl_escan_increment_sync_id(a, b) ((a)->escan_info.cur_sync_id += b)
2227 #define wl_escan_init_sync_id(a) ((a)->escan_info.cur_sync_id = 0)
2228 #else
2229 #define wl_escan_set_sync_id(a, b) ((a) = htod16((b)->escan_sync_id_cntr++))
2230 #define wl_escan_set_type(a, b)
2231 #define wl_escan_get_buf(a, b) ((wl_scan_results_t *) (a)->escan_info.escan_buf)
2232 #define wl_escan_check_sync_id(a, b, c) 0
2233 #define wl_escan_print_sync_id(a, b, c)
2234 #define wl_escan_increment_sync_id(a, b)
2235 #define wl_escan_init_sync_id(a)
2236 #endif /* DUAL_ESCAN_RESULT_BUFFER */
2237 extern void wl_cfg80211_ibss_vsie_set_buffer(struct net_device *dev, vndr_ie_setbuf_t *ibss_vsie,
2238 int ibss_vsie_len);
2239 extern s32 wl_cfg80211_ibss_vsie_delete(struct net_device *dev);
2240 #ifdef WL_RELMCAST
2241 extern void wl_cfg80211_set_rmc_pid(struct net_device *dev, int pid);
2242 #endif /* WL_RELMCAST */
2243 extern int wl_cfg80211_set_mgmt_vndr_ies(struct bcm_cfg80211 *cfg,
2244 bcm_struct_cfgdev *cfgdev, s32 bssidx, s32 pktflag,
2245 const u8 *vndr_ie, u32 vndr_ie_len);
2246
2247 #ifdef WLFBT
2248 extern int wl_cfg80211_get_fbt_key(struct net_device *dev, uint8 *key, int total_len);
2249 #endif // endif
2250
2251 /* Action frame specific functions */
2252 extern u8 wl_get_action_category(void *frame, u32 frame_len);
2253 extern int wl_get_public_action(void *frame, u32 frame_len, u8 *ret_action);
2254
2255 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
2256 struct net_device *wl_cfg80211_get_remain_on_channel_ndev(struct bcm_cfg80211 *cfg);
2257 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
2258
2259 #ifdef WL_SUPPORT_ACS
2260 #define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */
2261 #define IOCTL_RETRY_COUNT 5
2262 #define CHAN_NOISE_DUMMY -80
2263 #define OBSS_TOKEN_IDX 15
2264 #define IBSS_TOKEN_IDX 15
2265 #define TX_TOKEN_IDX 14
2266 #define CTG_TOKEN_IDX 13
2267 #define PKT_TOKEN_IDX 15
2268 #define IDLE_TOKEN_IDX 12
2269 #endif /* WL_SUPPORT_ACS */
2270
2271 #ifdef BCMWAPI_WPI
2272 #define is_wapi(cipher) (cipher == WLAN_CIPHER_SUITE_SMS4) ? 1 : 0
2273 #endif /* BCMWAPI_WPI */
2274
2275 extern int wl_cfg80211_get_ioctl_version(void);
2276 extern int wl_cfg80211_enable_roam_offload(struct net_device *dev, int enable);
2277 extern s32 wl_cfg80211_dfs_ap_move(struct net_device *ndev, char *data,
2278 char *command, int total_len);
2279 extern s32 wl_cfg80211_get_chanspecs_2g(struct net_device *ndev,
2280 void *buf, s32 buflen);
2281 extern s32 wl_cfg80211_get_chanspecs_5g(struct net_device *ndev,
2282 void *buf, s32 buflen);
2283
2284 extern s32 wl_cfg80211_bss_up(struct bcm_cfg80211 *cfg,
2285 struct net_device *ndev, s32 bsscfg_idx, s32 up);
2286 extern bool wl_cfg80211_bss_isup(struct net_device *ndev, int bsscfg_idx);
2287
2288 struct net_device *wl_cfg80211_post_ifcreate(struct net_device *ndev,
2289 wl_if_event_info *event, u8 *addr, const char *name, bool rtnl_lock_reqd);
2290 extern s32 wl_cfg80211_post_ifdel(struct net_device *ndev, bool rtnl_lock_reqd, s32 ifidx);
2291 #if defined(PKT_FILTER_SUPPORT) && defined(APSTA_BLOCK_ARP_DURING_DHCP)
2292 extern void wl_cfg80211_block_arp(struct net_device *dev, int enable);
2293 #endif /* PKT_FILTER_SUPPORT && APSTA_BLOCK_ARP_DURING_DHCP */
2294
2295 #ifdef WLTDLS
2296 extern s32 wl_cfg80211_tdls_config(struct bcm_cfg80211 *cfg,
2297 enum wl_tdls_config state, bool tdls_mode);
2298 extern s32 wl_tdls_event_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
2299 const wl_event_msg_t *e, void *data);
2300 #endif /* WLTDLS */
2301
2302 #ifdef WL_NAN
2303 extern int wl_cfgvendor_send_nan_event(struct wiphy * wiphy,
2304 struct net_device *dev, int event_id,
2305 nan_event_data_t *nan_event_data);
2306 extern int wl_cfgnan_init(struct bcm_cfg80211 *cfg);
2307 extern int wl_cfgnan_deinit(struct bcm_cfg80211 *cfg, uint8 busstate);
2308 extern bool wl_cfgnan_check_state(struct bcm_cfg80211 *cfg);
2309 #ifdef RTT_SUPPORT
2310 extern s32 wl_cfgvendor_send_as_rtt_legacy_event(struct wiphy *wiphy,
2311 struct net_device *dev, wl_nan_ev_rng_rpt_ind_t *range_res,
2312 uint32 status);
2313 #endif /* RTT_SUPPORT */
2314 #ifdef WL_NANP2P
2315 extern int wl_cfg80211_set_iface_conc_disc(struct net_device *ndev,
2316 uint8 arg_val);
2317 extern uint8 wl_cfg80211_get_iface_conc_disc(struct net_device *ndev);
2318 #endif /* WL_NANP2P */
2319 #endif /* WL_NAN */
2320
2321 #ifdef WL_CFG80211_P2P_DEV_IF
2322 extern void wl_cfg80211_del_p2p_wdev(struct net_device *dev);
2323 #endif /* WL_CFG80211_P2P_DEV_IF */
2324 #if defined(WL_SUPPORT_AUTO_CHANNEL)
2325 extern int wl_cfg80211_set_spect(struct net_device *dev, int spect);
2326 extern int wl_cfg80211_get_sta_channel(struct bcm_cfg80211 *cfg);
2327 #endif /* WL_SUPPORT_AUTO_CHANNEL */
2328 #ifdef WL_CFG80211_SYNC_GON
2329 #define WL_DRV_STATUS_SENDING_AF_FRM_EXT(cfg) \
2330 (wl_get_drv_status_all(cfg, SENDING_ACT_FRM) || \
2331 wl_get_drv_status_all(cfg, WAITING_NEXT_ACT_FRM_LISTEN))
2332 #else
2333 #define WL_DRV_STATUS_SENDING_AF_FRM_EXT(cfg) wl_get_drv_status_all(cfg, SENDING_ACT_FRM)
2334 #endif /* WL_CFG80211_SYNC_GON */
2335
2336 #ifdef P2P_LISTEN_OFFLOADING
2337 extern s32 wl_cfg80211_p2plo_deinit(struct bcm_cfg80211 *cfg);
2338 #endif /* P2P_LISTEN_OFFLOADING */
2339
2340 /* Function to flush the FW log buffer content */
2341 extern void wl_flush_fw_log_buffer(struct net_device *dev, uint32 logset_mask);
2342
2343 #define RETURN_EIO_IF_NOT_UP(wlpriv) \
2344 do { \
2345 struct net_device *checkSysUpNDev = bcmcfg_to_prmry_ndev(wlpriv); \
2346 if (unlikely(!wl_get_drv_status(wlpriv, READY, checkSysUpNDev))) { \
2347 WL_INFORM(("device is not ready\n")); \
2348 return -EIO; \
2349 } \
2350 } while (0)
2351
2352 #ifdef QOS_MAP_SET
2353 extern uint8 *wl_get_up_table(void);
2354 #endif /* QOS_MAP_SET */
2355
2356 #define P2PO_COOKIE 65535
2357 u64 wl_cfg80211_get_new_roc_id(struct bcm_cfg80211 *cfg);
2358
2359 #ifdef SUPPORT_AP_HIGHER_BEACONRATE
2360 int wl_set_ap_beacon_rate(struct net_device *dev, int val, char *ifname);
2361 int wl_get_ap_basic_rate(struct net_device *dev, char* command, char *ifname, int total_len);
2362 #endif /* SUPPORT_AP_HIGHER_BEACONRATE */
2363 #ifdef SUPPORT_AP_RADIO_PWRSAVE
2364 int wl_get_ap_rps(struct net_device *dev, char* command, char *ifname, int total_len);
2365 int wl_set_ap_rps(struct net_device *dev, bool enable, char *ifname);
2366 int wl_update_ap_rps_params(struct net_device *dev, ap_rps_info_t* rps, char *ifname);
2367 void wl_cfg80211_init_ap_rps(struct bcm_cfg80211 *cfg);
2368 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
2369 #ifdef SUPPORT_RSSI_SUM_REPORT
2370 int wl_get_rssi_logging(struct net_device *dev, void *param);
2371 int wl_set_rssi_logging(struct net_device *dev, void *param);
2372 int wl_get_rssi_per_ant(struct net_device *dev, char *ifname, char *peer_mac, void *param);
2373 #endif /* SUPPORT_RSSI_SUM_REPORT */
2374 int wl_cfg80211_iface_count(struct net_device *dev);
2375 struct net_device* wl_get_ap_netdev(struct bcm_cfg80211 *cfg, char *ifname);
2376 void wl_cfg80211_cleanup_virtual_ifaces(struct bcm_cfg80211 *cfg, bool rtnl_lock_reqd);
2377 #ifdef WL_IFACE_MGMT
2378 extern int wl_cfg80211_set_iface_policy(struct net_device *ndev, char *arg, int len);
2379 extern uint8 wl_cfg80211_get_iface_policy(struct net_device *ndev);
2380 extern s32 wl_cfg80211_handle_if_role_conflict(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
2381 s32 wl_cfg80211_data_if_mgmt(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
2382 s32 wl_cfg80211_disc_if_mgmt(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype,
2383 bool *disable_nan, bool *disable_p2p);
2384 s32 wl_cfg80211_handle_discovery_config(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
2385 wl_iftype_t wl_cfg80211_get_sec_iface(struct bcm_cfg80211 *cfg);
2386 bool wl_cfg80211_is_associated_discovery(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype);
2387 #endif /* WL_IFACE_MGMT */
2388 struct wireless_dev * wl_cfg80211_add_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
2389 wl_iftype_t wl_iftype, const char *name, u8 *mac);
2390 extern s32 wl_cfg80211_del_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
2391 struct wireless_dev *wdev, char *name);
2392 s32 _wl_cfg80211_del_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
2393 struct wireless_dev *wdev, char *ifname);
2394 s32 wl_cfg80211_delete_iface(struct bcm_cfg80211 *cfg, wl_iftype_t sec_data_if_type);
2395
2396 #ifdef WL_STATIC_IF
2397 extern struct net_device *wl_cfg80211_register_static_if(struct bcm_cfg80211 *cfg,
2398 u16 iftype, char *ifname);
2399 extern void wl_cfg80211_unregister_static_if(struct bcm_cfg80211 * cfg);
2400 extern s32 wl_cfg80211_static_if_open(struct net_device *net);
2401 extern s32 wl_cfg80211_static_if_close(struct net_device *net);
2402 extern struct net_device * wl_cfg80211_post_static_ifcreate(struct bcm_cfg80211 *cfg,
2403 wl_if_event_info *event, u8 *addr, s32 iface_type);
2404 extern s32 wl_cfg80211_post_static_ifdel(struct bcm_cfg80211 *cfg, struct net_device *ndev);
2405 #endif /* WL_STATIC_IF */
2406 extern struct wireless_dev *wl_cfg80211_get_wdev_from_ifname(struct bcm_cfg80211 *cfg,
2407 const char *name);
2408 struct net_device* wl_get_netdev_by_name(struct bcm_cfg80211 *cfg, char *ifname);
2409 extern s32 wl_get_vif_macaddr(struct bcm_cfg80211 *cfg, u16 wl_iftype, u8 *mac_addr);
2410 extern s32 wl_release_vif_macaddr(struct bcm_cfg80211 *cfg, u8 *mac_addr, u16 wl_iftype);
2411 extern int wl_cfg80211_ifstats_counters(struct net_device *dev, wl_if_stats_t *if_stats);
2412 extern s32 wl_cfg80211_set_dbg_verbose(struct net_device *ndev, u32 level);
2413 extern int wl_cfg80211_deinit_p2p_discovery(struct bcm_cfg80211 * cfg);
2414 extern int wl_cfg80211_set_frameburst(struct bcm_cfg80211 *cfg, bool enable);
2415 extern int wl_cfg80211_determine_p2p_rsdb_mode(struct bcm_cfg80211 *cfg);
2416 extern uint8 wl_cfg80211_get_bus_state(struct bcm_cfg80211 *cfg);
2417 #ifdef WL_WPS_SYNC
2418 void wl_handle_wps_states(struct net_device *ndev, u8 *dump_data, u16 len, bool direction);
2419 #endif /* WL_WPS_SYNC */
2420 extern int wl_features_set(u8 *array, uint8 len, u32 ftidx);
2421 extern void *wl_read_prof(struct bcm_cfg80211 *cfg, struct net_device *ndev, s32 item);
2422 extern s32 wl_cfg80211_sup_event_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
2423 const wl_event_msg_t *event, void *data);
2424 extern s32 wl_inform_bss(struct bcm_cfg80211 *cfg);
2425 extern void wl_cfg80211_cancel_scan(struct bcm_cfg80211 *cfg);
2426 extern s32 wl_notify_escan_complete(struct bcm_cfg80211 *cfg,
2427 struct net_device *ndev, bool aborted, bool fw_abort);
2428 extern s32 cfg80211_to_wl_iftype(uint16 type, uint16 *role, uint16 *mode);
2429 extern s32 wl_cfg80211_net_attach(struct net_device *primary_ndev);
2430 extern void wl_print_verinfo(struct bcm_cfg80211 *cfg);
2431 extern const u8 *wl_find_attribute(const u8 *buf, u16 len, u16 element_id);
2432 extern int wl_cfg80211_get_concurrency_mode(struct bcm_cfg80211 *cfg);
2433 #if defined(WL_DISABLE_HE_SOFTAP) || defined(WL_DISABLE_HE_P2P)
2434 int wl_cfg80211_set_he_mode(struct net_device *dev, struct bcm_cfg80211 *cfg,
2435 s32 bssidx, u32 interface_type, bool set);
2436 #endif /* WL_DISABLE_HE_SOFTAP || WL_DISABLE_HE_P2P */
2437 extern s32 wl_cfg80211_config_suspend_events(struct net_device *ndev, bool enable);
2438 #ifdef SUPPORT_AP_SUSPEND
2439 extern int wl_set_ap_suspend(struct net_device *dev, bool enable, char *ifname);
2440 #endif /* SUPPORT_AP_SUSPEND */
2441 #ifdef SUPPORT_SOFTAP_ELNA_BYPASS
2442 int wl_set_softap_elna_bypass(struct net_device *dev, char *ifname, int enable);
2443 int wl_get_softap_elna_bypass(struct net_device *dev, char *ifname, void *param);
2444 #endif /* SUPPORT_SOFTAP_ELNA_BYPASS */
2445 #ifdef SUPPORT_AP_BWCTRL
2446 extern int wl_set_ap_bw(struct net_device *dev, u32 bw, char *ifname);
2447 extern int wl_get_ap_bw(struct net_device *dev, char* command, char *ifname, int total_len);
2448 #endif /* SUPPORT_AP_BWCTRL */
2449 bool wl_cfg80211_check_in_progress(struct net_device *dev);
2450 s32 wl_cfg80211_autochannel(struct net_device *dev, char* command, int total_len);
2451 #endif /* _wl_cfg80211_h_ */
2452