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