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