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