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