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