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