793575dd8ff8efbd7bf392e00d2fbbe031d3b018
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / drivers / net / wireless / bcmdhd4361 / wl_cfg80211.h
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 *
27 * $Id: wl_cfg80211.h 796900 2018-12-27 09:37:28Z $
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 */
56 struct wl_conf;
57 struct wl_iface;
58 struct bcm_cfg80211;
59 struct wl_security;
60 struct 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 */
80 #define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
81 #define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
82 #define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
83 #endif /* LINUX_VER >= 4.7 */
84
85 #ifdef DHD_LOG_DUMP
86 extern void dhd_log_dump_write(int type, char *binary_data,
87 int binary_len, const char *fmt, ...);
88 extern 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) \
112 do { \
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) \
121 do { \
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) \
128 do { \
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) \
135 do { \
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) \
144 do { \
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) \
153 do { \
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) \
159 do { \
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) \
173 do { \
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) \
188 do { \
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) \
211 do { \
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) \
222 do { \
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) \
232 do { \
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) \
243 do { \
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) \
254 do { \
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 */
394 enum 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
434 typedef 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
449 typedef 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 */
460 enum 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 */
469 enum 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,
479 WL_PROF_DTIMPERIOD
480 };
481
482 /* donlge escan state */
483 enum wl_escan_state {
484 WL_ESCAN_STATE_IDLE,
485 WL_ESCAN_STATE_SCANING
486 };
487 /* fw downloading status */
488 enum wl_fw_status {
489 WL_FW_LOADING_DONE,
490 WL_NVRAM_LOADING_DONE
491 };
492
493 enum wl_management_type {
494 WL_BEACON = 0x1,
495 WL_PROBE_RESP = 0x2,
496 WL_ASSOC_RESP = 0x4
497 };
498
499 enum wl_pm_workq_act_type {
500 WL_PM_WORKQ_SHORT,
501 WL_PM_WORKQ_LONG,
502 WL_PM_WORKQ_DEL
503 };
504
505 enum wl_tdls_config {
506 TDLS_STATE_AP_CREATE,
507 TDLS_STATE_AP_DELETE,
508 TDLS_STATE_CONNECT,
509 TDLS_STATE_DISCONNECT,
510 TDLS_STATE_SETUP,
511 TDLS_STATE_TEARDOWN,
512 TDLS_STATE_IF_CREATE,
513 TDLS_STATE_IF_DELETE,
514 TDLS_STATE_NDI_CREATE
515 };
516
517 /* beacon / probe_response */
518 struct beacon_proberesp {
519 __le64 timestamp;
520 __le16 beacon_int;
521 __le16 capab_info;
522 u8 variable[0];
523 } __attribute__ ((packed));
524
525 /* driver configuration */
526 struct wl_conf {
527 u32 frag_threshold;
528 u32 rts_threshold;
529 u32 retry_short;
530 u32 retry_long;
531 s32 tx_power;
532 struct ieee80211_channel channel;
533 };
534
535 typedef s32(*EVENT_HANDLER) (struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
536 const wl_event_msg_t *e, void *data);
537
538 /* bss inform structure for cfg80211 interface */
539 struct wl_cfg80211_bss_info {
540 u16 band;
541 u16 channel;
542 s16 rssi;
543 u16 frame_len;
544 u8 frame_buf[1];
545 };
546
547 /* basic structure of scan request */
548 struct wl_scan_req {
549 struct wlc_ssid ssid;
550 };
551
552 /* basic structure of information element */
553 struct wl_ie {
554 u16 offset;
555 u8 buf[WL_TLV_INFO_MAX];
556 };
557
558 /* event queue for cfg80211 main event */
559 struct wl_event_q {
560 struct list_head eq_list;
561 u32 etype;
562 wl_event_msg_t emsg;
563 u32 datalen;
564 s8 edata[1];
565 };
566
567 /* security information with currently associated ap */
568 struct wl_security {
569 u32 wpa_versions;
570 u32 auth_type;
571 u32 cipher_pairwise;
572 u32 cipher_group;
573 u32 wpa_auth;
574 u32 auth_assoc_res_status;
575 };
576
577 /* ibss information for currently joined ibss network */
578 struct wl_ibss {
579 u8 beacon_interval; /* in millisecond */
580 u8 atim; /* in millisecond */
581 s8 join_only;
582 u8 band;
583 u8 channel;
584 };
585
586 typedef struct wl_bss_vndr_ies {
587 u8 probe_req_ie[VNDR_IES_BUF_LEN];
588 u8 probe_res_ie[VNDR_IES_MAX_BUF_LEN];
589 u8 assoc_req_ie[VNDR_IES_BUF_LEN];
590 u8 assoc_res_ie[VNDR_IES_BUF_LEN];
591 u8 beacon_ie[VNDR_IES_MAX_BUF_LEN];
592 u32 probe_req_ie_len;
593 u32 probe_res_ie_len;
594 u32 assoc_req_ie_len;
595 u32 assoc_res_ie_len;
596 u32 beacon_ie_len;
597 } wl_bss_vndr_ies_t;
598
599 typedef struct wl_cfgbss {
600 u8 *wpa_ie;
601 u8 *rsn_ie;
602 u8 *wps_ie;
603 u8 *fils_ind_ie;
604 bool security_mode;
605 struct wl_bss_vndr_ies ies; /* Common for STA, P2P GC, GO, AP, P2P Disc Interface */
606 } wl_cfgbss_t;
607
608 /* cfg driver profile */
609 struct wl_profile {
610 u32 mode;
611 s32 band;
612 u32 channel;
613 struct wlc_ssid ssid;
614 struct wl_security sec;
615 struct wl_ibss ibss;
616 u8 bssid[ETHER_ADDR_LEN];
617 u16 beacon_interval;
618 u8 dtim_period;
619 bool active;
620 };
621
622 struct wl_wps_ie {
623 uint8 id; /* IE ID: 0xDD */
624 uint8 len; /* IE length */
625 uint8 OUI[3]; /* WiFi WPS specific OUI */
626 uint8 oui_type; /* Vendor specific OUI Type */
627 uint8 attrib[1]; /* variable length attributes */
628 } __attribute__ ((packed));
629 typedef struct wl_wps_ie wl_wps_ie_t;
630
631 struct wl_eap_msg {
632 uint16 attrib;
633 uint16 len;
634 uint8 type;
635 } __attribute__ ((packed));
636 typedef struct wl_eap_msg wl_eap_msg_t;
637
638 struct wl_eap_exp {
639 uint8 OUI[3];
640 uint32 oui_type;
641 uint8 opcode;
642 u8 flags;
643 u8 data[1];
644 } __attribute__ ((packed));
645 typedef struct wl_eap_exp wl_eap_exp_t;
646
647 struct net_info {
648 struct net_device *ndev;
649 struct wireless_dev *wdev;
650 struct wl_profile profile;
651 wl_iftype_t iftype;
652 s32 roam_off;
653 unsigned long sme_state;
654 bool pm_restore;
655 bool pm_block;
656 s32 pm;
657 s32 bssidx;
658 wl_cfgbss_t bss;
659 u8 ifidx;
660 struct list_head list; /* list of all net_info structure */
661 };
662
663 /* association inform */
664 #define MAX_REQ_LINE 1024u
665 struct wl_connect_info {
666 u8 req_ie[MAX_REQ_LINE];
667 u32 req_ie_len;
668 u8 resp_ie[MAX_REQ_LINE];
669 u32 resp_ie_len;
670 };
671
672 /* firmware /nvram downloading controller */
673 struct wl_fw_ctrl {
674 const struct firmware *fw_entry;
675 unsigned long status;
676 u32 ptr;
677 s8 fw_name[WL_FILE_NAME_MAX];
678 s8 nvram_name[WL_FILE_NAME_MAX];
679 };
680
681 /* assoc ie length */
682 struct wl_assoc_ielen {
683 u32 req_len;
684 u32 resp_len;
685 };
686
687 /* wpa2 pmk list */
688 struct wl_pmk_list {
689 pmkid_list_t pmkids;
690 pmkid_t foo[MAXPMKID - 1];
691 };
692
693 #ifdef DHD_MAX_IFS
694 #define WL_MAX_IFS DHD_MAX_IFS
695 #else
696 #define WL_MAX_IFS 16
697 #endif // endif
698
699 #define ESCAN_BUF_SIZE (64 * 1024)
700
701 struct escan_info {
702 u32 escan_state;
703 #ifdef STATIC_WL_PRIV_STRUCT
704 #ifndef CONFIG_DHD_USE_STATIC_BUF
705 #error STATIC_WL_PRIV_STRUCT should be used with CONFIG_DHD_USE_STATIC_BUF
706 #endif /* CONFIG_DHD_USE_STATIC_BUF */
707 #ifdef DUAL_ESCAN_RESULT_BUFFER
708 u8 *escan_buf[2];
709 #else
710 u8 *escan_buf;
711 #endif /* DUAL_ESCAN_RESULT_BUFFER */
712 #else
713 #ifdef DUAL_ESCAN_RESULT_BUFFER
714 u8 escan_buf[2][ESCAN_BUF_SIZE];
715 #else
716 u8 escan_buf[ESCAN_BUF_SIZE];
717 #endif /* DUAL_ESCAN_RESULT_BUFFER */
718 #endif /* STATIC_WL_PRIV_STRUCT */
719 #ifdef DUAL_ESCAN_RESULT_BUFFER
720 u8 cur_sync_id;
721 u8 escan_type[2];
722 #endif /* DUAL_ESCAN_RESULT_BUFFER */
723 struct wiphy *wiphy;
724 struct net_device *ndev;
725 };
726
727 #ifdef ESCAN_BUF_OVERFLOW_MGMT
728 #define BUF_OVERFLOW_MGMT_COUNT 3
729 typedef struct {
730 int RSSI;
731 int length;
732 struct ether_addr BSSID;
733 } removal_element_t;
734 #endif /* ESCAN_BUF_OVERFLOW_MGMT */
735
736 struct afx_hdl {
737 wl_af_params_t *pending_tx_act_frm;
738 struct ether_addr tx_dst_addr;
739 struct net_device *dev;
740 struct work_struct work;
741 s32 bssidx;
742 u32 retry;
743 s32 peer_chan;
744 s32 peer_listen_chan; /* search channel: configured by upper layer */
745 s32 my_listen_chan; /* listen chanel: extract it from prb req or gon req */
746 bool is_listen;
747 bool ack_recv;
748 bool is_active;
749 };
750
751 struct parsed_ies {
752 const wpa_ie_fixed_t *wps_ie;
753 u32 wps_ie_len;
754 const wpa_ie_fixed_t *wpa_ie;
755 u32 wpa_ie_len;
756 const bcm_tlv_t *wpa2_ie;
757 u32 wpa2_ie_len;
758 const bcm_tlv_t *fils_ind_ie;
759 u32 fils_ind_ie_len;
760 };
761
762 #ifdef P2P_LISTEN_OFFLOADING
763 typedef struct {
764 uint16 period; /* listen offload period */
765 uint16 interval; /* listen offload interval */
766 uint16 count; /* listen offload count */
767 uint16 pad; /* pad for 32bit align */
768 } wl_p2plo_listen_t;
769 #endif /* P2P_LISTEN_OFFLOADING */
770
771 #ifdef WL11U
772 /* Max length of Interworking element */
773 #define IW_IES_MAX_BUF_LEN 9
774 #endif // endif
775 #ifdef WLFBT
776 #define FBT_KEYLEN 32
777 #endif // endif
778 #define MAX_EVENT_BUF_NUM 16
779 typedef struct wl_eventmsg_buf {
780 u16 num;
781 struct {
782 u16 type;
783 bool set;
784 } event [MAX_EVENT_BUF_NUM];
785 } wl_eventmsg_buf_t;
786
787 typedef struct wl_if_event_info {
788 bool valid;
789 int ifidx;
790 int bssidx;
791 uint8 mac[ETHER_ADDR_LEN];
792 char name[IFNAMSIZ+1];
793 uint8 role;
794 } wl_if_event_info;
795
796 #ifdef SUPPORT_AP_RADIO_PWRSAVE
797 typedef struct ap_rps_info {
798 bool enable;
799 int sta_assoc_check;
800 int pps;
801 int quiet_time;
802 int level;
803 } ap_rps_info_t;
804 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
805
806 #ifdef SUPPORT_RSSI_SUM_REPORT
807 #define RSSILOG_FLAG_FEATURE_SW 0x1
808 #define RSSILOG_FLAG_REPORT_READY 0x2
809 typedef struct rssilog_set_param {
810 uint8 enable;
811 uint8 rssi_threshold;
812 uint8 time_threshold;
813 uint8 pad;
814 } rssilog_set_param_t;
815
816 typedef struct rssilog_get_param {
817 uint8 report_count;
818 uint8 enable;
819 uint8 rssi_threshold;
820 uint8 time_threshold;
821 } rssilog_get_param_t;
822
823 typedef struct rssi_ant_param {
824 struct ether_addr ea;
825 chanspec_t chanspec;
826 } rssi_ant_param_t;
827
828 typedef struct wl_rssi_ant_mimo {
829 uint32 version;
830 uint32 count;
831 int8 rssi_ant[WL_RSSI_ANT_MAX];
832 int8 rssi_sum;
833 int8 PAD[3];
834 } wl_rssi_ant_mimo_t;
835 #endif /* SUPPORT_RSSI_SUM_REPORT */
836
837 #if defined(DHD_ENABLE_BIGDATA_LOGGING)
838 #define GET_BSS_INFO_LEN 90
839 #endif /* DHD_ENABLE_BIGDATA_LOGGING */
840
841 #ifdef WES_SUPPORT
842 #ifdef CUSTOMER_SCAN_TIMEOUT_SETTING
843 #define CUSTOMER_WL_SCAN_TIMER_INTERVAL_MS 25000 /* Scan timeout */
844 enum wl_custom_scan_time_type {
845 WL_CUSTOM_SCAN_CHANNEL_TIME = 0,
846 WL_CUSTOM_SCAN_UNASSOC_TIME,
847 WL_CUSTOM_SCAN_PASSIVE_TIME,
848 WL_CUSTOM_SCAN_HOME_TIME,
849 WL_CUSTOM_SCAN_HOME_AWAY_TIME
850 };
851 extern s32 wl_cfg80211_custom_scan_time(struct net_device *dev,
852 enum wl_custom_scan_time_type type, int time);
853 #endif /* CUSTOMER_SCAN_TIMEOUT_SETTING */
854 #endif /* WES_SUPPORT */
855
856 #ifdef WL_NAN
857 #define NAN_MAX_NDI 2
858 typedef struct wl_ndi_data
859 {
860 u8 ifname[IFNAMSIZ];
861 u8 in_use;
862 u8 created;
863 } wl_ndi_data_t;
864 typedef struct wl_nancfg
865 {
866 wl_ndi_data_t ndi[NAN_MAX_NDI];
867 struct mutex nan_sync;
868 uint8 svc_inst_id_mask[NAN_SVC_INST_SIZE];
869 uint8 inst_id_start;
870 /* wait queue and condition variable for nan event */
871 bool nan_event_recvd;
872 wait_queue_head_t nan_event_wait;
873 nan_stop_reason_code_t disable_reason;
874 bool mac_rand;
875 } wl_nancfg_t;
876 #endif /* WL_NAN */
877
878 #ifdef WL_WPS_SYNC
879 #define EAP_PACKET 0
880 #define EAP_EXPANDED_TYPE 254
881 #define EAP_EXP_OPCODE_OFFSET 7
882 #define EAP_EXP_FRAGMENT_LEN_OFFSET 2
883 #define EAP_EXP_FLAGS_FRAGMENTED_DATA 2
884 #define EAP_EXP_FLAGS_MORE_DATA 1
885 #define EAPOL_EAP_HDR_LEN 5
886 #define EAP_EXP_HDR_MIN_LENGTH (EAPOL_EAP_HDR_LEN + EAP_EXP_OPCODE_OFFSET)
887 #define EAP_ATTRIB_MSGTYPE 0x1022
888 #define EAP_WSC_UPNP 0
889 #define EAP_WSC_START 1
890 #define EAP_WSC_ACK 2
891 #define EAP_WSC_NACK 3
892 #define EAP_WSC_MSG 4
893 #define EAP_WSC_DONE 5
894 #define EAP_WSC_MSG_M8 12
895 #define EAP_CODE_FAILURE 4
896 #define WL_WPS_REAUTH_TIMEOUT 10000
897
898 struct wl_eap_header {
899 unsigned char code; /* EAP code */
900 unsigned char id; /* Current request ID */
901 unsigned short length; /* Length including header */
902 unsigned char type; /* EAP type (optional) */
903 unsigned char data[1]; /* Type data (optional) */
904 } __attribute__ ((packed));
905 typedef struct wl_eap_header wl_eap_header_t;
906
907 typedef enum wl_wps_state {
908 WPS_STATE_IDLE = 0,
909 WPS_STATE_STARTED,
910 WPS_STATE_M8_RECVD,
911 WPS_STATE_EAP_FAIL,
912 WPS_STATE_REAUTH_WAIT,
913 WPS_STATE_LINKUP,
914 WPS_STATE_LINKDOWN,
915 WPS_STATE_DISCONNECT,
916 WPS_STATE_DISCONNECT_CLIENT,
917 WPS_STATE_CONNECT_FAIL,
918 WPS_STATE_AUTHORIZE,
919 WPS_STATE_DONE,
920 WPS_STATE_INVALID
921 } wl_wps_state_t;
922
923 #define WPS_MAX_SESSIONS 2
924 typedef struct wl_wps_session {
925 bool in_use;
926 struct timer_list timer;
927 struct net_device *ndev;
928 wl_wps_state_t state;
929 u16 mode;
930 u8 peer_mac[ETHER_ADDR_LEN];
931 } wl_wps_session_t;
932 #endif /* WL_WPS_SYNC */
933
934 #ifndef WL_STATIC_IFNAME_PREFIX
935 #define WL_STATIC_IFNAME_PREFIX "wlan%d"
936 #endif /* WL_STATIC_IFNAME */
937
938 /* private data of cfg80211 interface */
939 struct bcm_cfg80211 {
940 struct wireless_dev *wdev; /* representing cfg cfg80211 device */
941
942 struct wireless_dev *p2p_wdev; /* representing cfg cfg80211 device for P2P */
943 struct net_device *p2p_net; /* reference to p2p0 interface */
944
945 struct wl_conf *conf;
946 struct cfg80211_scan_request *scan_request; /* scan request object */
947 EVENT_HANDLER evt_handler[WLC_E_LAST];
948 struct list_head eq_list; /* used for event queue */
949 struct list_head net_list; /* used for struct net_info */
950 spinlock_t net_list_sync; /* to protect scan status (and others if needed) */
951 spinlock_t eq_lock; /* for event queue synchronization */
952 spinlock_t cfgdrv_lock; /* to protect scan status (and others if needed) */
953 struct completion act_frm_scan;
954 struct completion iface_disable;
955 struct completion wait_next_af;
956 struct mutex usr_sync; /* maily for up/down synchronization */
957 struct mutex if_sync; /* maily for iface op synchronization */
958 struct mutex scan_complete; /* serialize scan_complete call */
959 struct wl_scan_results *bss_list;
960 struct wl_scan_results *scan_results;
961
962 /* scan request object for internal purpose */
963 struct wl_scan_req *scan_req_int;
964 /* information element object for internal purpose */
965 #if defined(STATIC_WL_PRIV_STRUCT)
966 struct wl_ie *ie;
967 #else
968 struct wl_ie ie;
969 #endif // endif
970
971 /* association information container */
972 #if defined(STATIC_WL_PRIV_STRUCT)
973 struct wl_connect_info *conn_info;
974 #else
975 struct wl_connect_info conn_info;
976 #endif // endif
977 #ifdef DEBUGFS_CFG80211
978 struct dentry *debugfs;
979 #endif /* DEBUGFS_CFG80211 */
980 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
981 tsk_ctl_t event_tsk; /* task of main event handler thread */
982 void *pub;
983 u32 iface_cnt;
984 u32 channel; /* current channel */
985 u32 af_sent_channel; /* channel action frame is sent */
986 /* next af subtype to cancel the remained dwell time in rx process */
987 u8 next_af_subtype;
988 #ifdef WL_CFG80211_SYNC_GON
989 ulong af_tx_sent_jiffies;
990 #endif /* WL_CFG80211_SYNC_GON */
991 struct escan_info escan_info; /* escan information */
992 bool active_scan; /* current scan mode */
993 bool ibss_starter; /* indicates this sta is ibss starter */
994 bool link_up; /* link/connection up flag */
995
996 /* indicate whether chip to support power save mode */
997 bool pwr_save;
998 bool roam_on; /* on/off switch for self-roaming */
999 bool scan_tried; /* indicates if first scan attempted */
1000 #if defined(BCMSDIO) || defined(BCMPCIE)
1001 bool wlfc_on;
1002 #endif // endif
1003 bool vsdb_mode;
1004 #define WL_ROAM_OFF_ON_CONCURRENT 0x0001
1005 #define WL_ROAM_REVERT_STATUS 0x0002
1006 u32 roam_flags;
1007 u8 *ioctl_buf; /* ioctl buffer */
1008 struct mutex ioctl_buf_sync;
1009 u8 *escan_ioctl_buf;
1010 u8 *extra_buf; /* maily to grab assoc information */
1011 struct dentry *debugfsdir;
1012 struct rfkill *rfkill;
1013 bool rf_blocked;
1014 struct ieee80211_channel remain_on_chan;
1015 enum nl80211_channel_type remain_on_chan_type;
1016 u64 send_action_id;
1017 u64 last_roc_id;
1018 wait_queue_head_t netif_change_event;
1019 wl_if_event_info if_event_info;
1020 struct completion send_af_done;
1021 struct afx_hdl *afx_hdl;
1022 struct p2p_info *p2p;
1023 bool p2p_supported;
1024 void *btcoex_info;
1025 struct timer_list scan_timeout; /* Timer for catch scan event timeout */
1026 #ifdef WL_CFG80211_GON_COLLISION
1027 u8 block_gon_req_tx_count;
1028 u8 block_gon_req_rx_count;
1029 #endif /* WL_CFG80211_GON_COLLISION */
1030 #if defined(P2P_IE_MISSING_FIX)
1031 bool p2p_prb_noti;
1032 #endif // endif
1033 s32(*state_notifier) (struct bcm_cfg80211 *cfg,
1034 struct net_info *_net_info, enum wl_status state, bool set);
1035 unsigned long interrested_state;
1036 wlc_ssid_t hostapd_ssid;
1037 #ifdef WL11U
1038 bool wl11u;
1039 #endif /* WL11U */
1040 bool sched_scan_running; /* scheduled scan req status */
1041 struct cfg80211_sched_scan_request *sched_scan_req; /* scheduled scan req */
1042 #ifdef WL_HOST_BAND_MGMT
1043 u8 curr_band;
1044 #endif /* WL_HOST_BAND_MGMT */
1045 bool scan_suppressed;
1046 struct timer_list scan_supp_timer;
1047 struct work_struct wlan_work;
1048 struct mutex event_sync; /* maily for up/down synchronization */
1049 bool disable_roam_event;
1050 struct delayed_work pm_enable_work;
1051 struct workqueue_struct *event_workq; /* workqueue for event */
1052 struct work_struct event_work; /* work item for event */
1053 struct mutex pm_sync; /* mainly for pm work synchronization */
1054
1055 vndr_ie_setbuf_t *ibss_vsie; /* keep the VSIE for IBSS */
1056 int ibss_vsie_len;
1057 #ifdef WLAIBSS
1058 u32 aibss_txfail_pid;
1059 u32 aibss_txfail_seq;
1060 #endif /* WLAIBSS */
1061 #ifdef WL_RELMCAST
1062 u32 rmc_event_pid;
1063 u32 rmc_event_seq;
1064 #endif /* WL_RELMCAST */
1065 #ifdef WLAIBSS_MCHAN
1066 struct ether_addr ibss_if_addr;
1067 bcm_struct_cfgdev *ibss_cfgdev; /* For AIBSS */
1068 #endif /* WLAIBSS_MCHAN */
1069 bool bss_pending_op; /* indicate where there is a pending IF operation */
1070 #ifdef WLFBT
1071 uint8 fbt_key[FBT_KEYLEN];
1072 #endif // endif
1073 int roam_offload;
1074 #ifdef WL_NAN
1075 bool nan_enable;
1076 nan_svc_inst_t nan_inst_ctrl[NAN_ID_CTRL_SIZE];
1077 struct ether_addr initiator_ndi;
1078 uint8 nan_dp_state;
1079 bool nan_init_state; /* nan initialization state */
1080 wait_queue_head_t ndp_if_change_event;
1081 uint8 support_5g;
1082 u8 nan_nmi_mac[ETH_ALEN];
1083 u8 nan_dp_mask;
1084 wl_nancfg_t nancfg;
1085 #ifdef WL_NAN_DISC_CACHE
1086 int nan_disc_count;
1087 nan_disc_result_cache *nan_disc_cache;
1088 nan_svc_info_t svc_info[NAN_MAX_SVC_INST];
1089 nan_ranging_inst_t nan_ranging_info[NAN_MAX_RANGING_INST];
1090 #endif /* WL_NAN_DISC_CACHE */
1091 #endif /* WL_NAN */
1092 #ifdef WL_CFG80211_P2P_DEV_IF
1093 bool down_disc_if;
1094 #endif /* WL_CFG80211_P2P_DEV_IF */
1095 #ifdef P2PLISTEN_AP_SAMECHN
1096 bool p2p_resp_apchn_status;
1097 #endif /* P2PLISTEN_AP_SAMECHN */
1098 struct wl_wsec_key wep_key;
1099 #ifdef WLTDLS
1100 u8 *tdls_mgmt_frame;
1101 u32 tdls_mgmt_frame_len;
1102 s32 tdls_mgmt_freq;
1103 #endif /* WLTDLS */
1104 bool need_wait_afrx;
1105 #ifdef QOS_MAP_SET
1106 uint8 *up_table; /* user priority table, size is UP_TABLE_MAX */
1107 #endif /* QOS_MAP_SET */
1108 struct ether_addr last_roamed_addr;
1109 bool rcc_enabled; /* flag for Roam channel cache feature */
1110 #if defined(DHD_ENABLE_BIGDATA_LOGGING)
1111 char bss_info[GET_BSS_INFO_LEN];
1112 wl_event_msg_t event_auth_assoc;
1113 u32 assoc_reject_status;
1114 u32 roam_count;
1115 #endif /* DHD_ENABLE_BIGDATA_LOGGING */
1116 u16 ap_oper_channel;
1117 #if defined(DHD_RANDOM_MAC_SCAN)
1118 bool random_mac_running;
1119 #endif /* DHD_RANDOM_MAC_SCAN */
1120 #ifdef DHD_LOSSLESS_ROAMING
1121 struct timer_list roam_timeout; /* Timer for catch roam timeout */
1122 #endif // endif
1123 #ifndef DUAL_ESCAN_RESULT_BUFFER
1124 uint16 escan_sync_id_cntr;
1125 #endif // endif
1126 #ifdef WLTDLS
1127 uint8 tdls_supported;
1128 struct mutex tdls_sync; /* protect tdls config operations */
1129 #endif /* WLTDLS */
1130 #ifdef MFP
1131 const uint8 *bip_pos;
1132 int mfp_mode;
1133 #endif /* MFP */
1134 #ifdef WES_SUPPORT
1135 #ifdef CUSTOMER_SCAN_TIMEOUT_SETTING
1136 int custom_scan_channel_time;
1137 int custom_scan_unassoc_time;
1138 int custom_scan_passive_time;
1139 int custom_scan_home_time;
1140 int custom_scan_home_away_time;
1141 #endif /* CUSTOMER_SCAN_TIMEOUT_SETTING */
1142 #endif /* WES_SUPPORT */
1143 uint8 vif_count; /* Virtual Interface count */
1144 #ifdef WBTEXT
1145 struct list_head wbtext_bssid_list;
1146 #endif /* WBTEXT */
1147 #ifdef SUPPORT_AP_RADIO_PWRSAVE
1148 ap_rps_info_t ap_rps_info;
1149 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
1150 u16 vif_macaddr_mask;
1151 struct list_head vndr_oui_list;
1152 spinlock_t vndr_oui_sync; /* to protect vndr_oui_list */
1153 osl_t *osh;
1154 #ifdef BIGDATA_SOFTAP
1155 struct wl_ap_sta_info *ap_sta_info;
1156 #endif /* BIGDATA_SOFTAP */
1157 bool rssi_sum_report;
1158 int rssi; /* previous RSSI (backup) of get_station */
1159 uint64 scan_enq_time;
1160 uint64 scan_deq_time;
1161 uint64 scan_hdlr_cmplt_time;
1162 uint64 scan_cmplt_time;
1163 uint64 wl_evt_deq_time;
1164 uint64 wl_evt_hdlr_entry_time;
1165 uint64 wl_evt_hdlr_exit_time;
1166 #ifdef WL_WPS_SYNC
1167 wl_wps_session_t wps_session[WPS_MAX_SESSIONS];
1168 spinlock_t wps_sync; /* to protect wps states (and others if needed) */
1169 #endif /* WL_WPS_SYNC */
1170 #ifdef WL_BAM
1171 wl_bad_ap_mngr_t bad_ap_mngr;
1172 #endif /* WL_BAM */
1173 struct net_device *static_ndev;
1174 uint8 static_ndev_state;
1175 #ifdef SUPPORT_CUSTOM_SET_CAC
1176 int enable_cac;
1177 #endif /* SUPPORT_CUSTOM_SET_CAC */
1178 };
1179
1180 #define WL_STATIC_IFIDX (DHD_MAX_IFS + DHD_MAX_STATIC_IFS - 1)
1181 enum static_ndev_states {
1182 NDEV_STATE_NONE,
1183 NDEV_STATE_OS_IF_CREATED,
1184 NDEV_STATE_FW_IF_CREATED,
1185 NDEV_STATE_FW_IF_FAILED,
1186 NDEV_STATE_FW_IF_DELETED
1187 };
1188 #define IS_CFG80211_STATIC_IF(cfg, ndev) \
1189 ((cfg && (cfg->static_ndev == ndev)) ? true : false)
1190 #define IS_CFG80211_STATIC_IF_ACTIVE(cfg) \
1191 ((cfg && cfg->static_ndev && \
1192 (cfg->static_ndev_state & NDEV_STATE_FW_IF_CREATED)) ? true : false)
1193 #define IS_CFG80211_STATIC_IF_NAME(cfg, name) \
1194 ((cfg && !strcmp(cfg->static_ndev->name, name)))
1195
1196 s32 wl_iftype_to_mode(wl_iftype_t iftype);
1197
1198 #if defined(STRICT_GCC_WARNINGS) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == \
1199 4 && __GNUC_MINOR__ >= 6))
1200 #define GCC_DIAGNOSTIC_PUSH() \
1201 _Pragma("GCC diagnostic push") \
1202 _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1203 #define GCC_DIAGNOSTIC_POP() \
1204 _Pragma("GCC diagnostic pop")
1205 #else
1206 #define GCC_DIAGNOSTIC_PUSH()
1207 #define GCC_DIAGNOSTIC_POP()
1208 #endif /* STRICT_GCC_WARNINGS */
1209
1210 #define BCM_LIST_FOR_EACH_ENTRY_SAFE(pos, next, head, member) \
1211 list_for_each_entry_safe((pos), (next), (head), member)
1212 extern int ioctl_version;
1213
1214 static inline wl_bss_info_t *next_bss(struct wl_scan_results *list, wl_bss_info_t *bss)
1215 {
1216 return bss = bss ?
1217 (wl_bss_info_t *)((uintptr) bss + dtoh32(bss->length)) : list->bss_info;
1218 }
1219
1220 static inline void
1221 wl_probe_wdev_all(struct bcm_cfg80211 *cfg)
1222 {
1223 struct net_info *_net_info, *next;
1224 unsigned long int flags;
1225 int idx = 0;
1226 spin_lock_irqsave(&cfg->net_list_sync, flags);
1227 GCC_DIAGNOSTIC_PUSH();
1228 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next,
1229 &cfg->net_list, list) {
1230 WL_INFORM_MEM(("%s: net_list[%d] bssidx: %d\n",
1231 __FUNCTION__, idx++, _net_info->bssidx));
1232 }
1233 GCC_DIAGNOSTIC_POP();
1234 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1235 return;
1236 }
1237
1238 static inline struct net_info *
1239 wl_get_netinfo_by_fw_idx(struct bcm_cfg80211 *cfg, s32 bssidx, u8 ifidx)
1240 {
1241 struct net_info *_net_info, *next, *info = NULL;
1242 unsigned long int flags;
1243
1244 spin_lock_irqsave(&cfg->net_list_sync, flags);
1245 GCC_DIAGNOSTIC_PUSH();
1246 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1247 if ((bssidx >= 0) && (_net_info->bssidx == bssidx) &&
1248 (_net_info->ifidx == ifidx)) {
1249 info = _net_info;
1250 break;
1251 }
1252 }
1253 GCC_DIAGNOSTIC_POP();
1254 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1255 return info;
1256 }
1257
1258 static inline void
1259 wl_dealloc_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1260 {
1261 struct net_info *_net_info, *next;
1262 unsigned long int flags;
1263
1264 #ifdef DHD_IFDEBUG
1265 WL_INFORM_MEM(("dealloc_netinfo enter wdev=%p \n", OSL_OBFUSCATE_BUF(wdev)));
1266 #endif // endif
1267 spin_lock_irqsave(&cfg->net_list_sync, flags);
1268 GCC_DIAGNOSTIC_PUSH();
1269 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1270 if (wdev && (_net_info->wdev == wdev)) {
1271 wl_cfgbss_t *bss = &_net_info->bss;
1272
1273 if (bss->wpa_ie) {
1274 MFREE(cfg->osh, bss->wpa_ie, bss->wpa_ie[1]
1275 + WPA_RSN_IE_TAG_FIXED_LEN);
1276 bss->wpa_ie = NULL;
1277 }
1278
1279 if (bss->rsn_ie) {
1280 MFREE(cfg->osh, bss->rsn_ie,
1281 bss->rsn_ie[1] + WPA_RSN_IE_TAG_FIXED_LEN);
1282 bss->rsn_ie = NULL;
1283 }
1284
1285 if (bss->wps_ie) {
1286 MFREE(cfg->osh, bss->wps_ie, bss->wps_ie[1] + 2);
1287 bss->wps_ie = NULL;
1288 }
1289 list_del(&_net_info->list);
1290 cfg->iface_cnt--;
1291 MFREE(cfg->osh, _net_info, sizeof(struct net_info));
1292 }
1293 }
1294 GCC_DIAGNOSTIC_POP();
1295 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1296 #ifdef DHD_IFDEBUG
1297 WL_INFORM_MEM(("dealloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
1298 #endif // endif
1299 }
1300
1301 static inline s32
1302 wl_alloc_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev,
1303 struct wireless_dev * wdev, wl_iftype_t iftype, bool pm_block, u8 bssidx, u8 ifidx)
1304 {
1305 struct net_info *_net_info;
1306 s32 err = 0;
1307 unsigned long int flags;
1308 #ifdef DHD_IFDEBUG
1309 WL_INFORM_MEM(("alloc_netinfo enter bssidx=%d wdev=%p\n",
1310 bssidx, OSL_OBFUSCATE_BUF(wdev)));
1311 #endif // endif
1312 /* Check whether there is any duplicate entry for the
1313 * same bssidx && ifidx.
1314 */
1315 if ((_net_info = wl_get_netinfo_by_fw_idx(cfg, bssidx, ifidx))) {
1316 /* We have a duplicate entry for the same bssidx
1317 * already present which shouldn't have been the case.
1318 * Attempt recovery.
1319 */
1320 WL_ERR(("Duplicate entry for bssidx=%d ifidx=%d present."
1321 " Can't add new entry\n", bssidx, ifidx));
1322 wl_probe_wdev_all(cfg);
1323 #ifdef DHD_DEBUG
1324 ASSERT(0);
1325 #endif /* DHD_DEBUG */
1326 return -EINVAL;
1327 }
1328 if (cfg->iface_cnt == IFACE_MAX_CNT)
1329 return -ENOMEM;
1330 _net_info = (struct net_info *)MALLOCZ(cfg->osh, sizeof(struct net_info));
1331 if (!_net_info)
1332 err = -ENOMEM;
1333 else {
1334 _net_info->iftype = iftype;
1335 _net_info->ndev = ndev;
1336 _net_info->wdev = wdev;
1337 _net_info->pm_restore = 0;
1338 _net_info->pm = 0;
1339 _net_info->pm_block = pm_block;
1340 _net_info->roam_off = WL_INVALID;
1341 _net_info->bssidx = bssidx;
1342 _net_info->ifidx = ifidx;
1343 spin_lock_irqsave(&cfg->net_list_sync, flags);
1344 cfg->iface_cnt++;
1345 list_add(&_net_info->list, &cfg->net_list);
1346 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1347 }
1348 #ifdef DHD_IFDEBUG
1349 WL_DBG(("alloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
1350 #endif // endif
1351 return err;
1352 }
1353
1354 static inline void
1355 wl_delete_all_netinfo(struct bcm_cfg80211 *cfg)
1356 {
1357 struct net_info *_net_info, *next;
1358 unsigned long int flags;
1359
1360 spin_lock_irqsave(&cfg->net_list_sync, flags);
1361 GCC_DIAGNOSTIC_PUSH();
1362 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1363 wl_cfgbss_t *bss = &_net_info->bss;
1364
1365 if (bss->wpa_ie) {
1366 MFREE(cfg->osh, bss->wpa_ie, bss->wpa_ie[1]
1367 + WPA_RSN_IE_TAG_FIXED_LEN);
1368 bss->wpa_ie = NULL;
1369 }
1370
1371 if (bss->rsn_ie) {
1372 MFREE(cfg->osh, bss->rsn_ie, bss->rsn_ie[1]
1373 + WPA_RSN_IE_TAG_FIXED_LEN);
1374 bss->rsn_ie = NULL;
1375 }
1376
1377 if (bss->wps_ie) {
1378 MFREE(cfg->osh, bss->wps_ie, bss->wps_ie[1] + 2);
1379 bss->wps_ie = NULL;
1380 }
1381
1382 if (bss->fils_ind_ie) {
1383 MFREE(cfg->osh, bss->fils_ind_ie, bss->fils_ind_ie[1]
1384 + FILS_INDICATION_IE_TAG_FIXED_LEN);
1385 bss->fils_ind_ie = NULL;
1386 }
1387 list_del(&_net_info->list);
1388 if (_net_info->wdev) {
1389 MFREE(cfg->osh, _net_info->wdev, sizeof(struct wireless_dev));
1390 }
1391 MFREE(cfg->osh, _net_info, sizeof(struct net_info));
1392 }
1393 cfg->iface_cnt = 0;
1394 GCC_DIAGNOSTIC_POP();
1395 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1396 }
1397 static inline u32
1398 wl_get_status_all(struct bcm_cfg80211 *cfg, s32 status)
1399
1400 {
1401 struct net_info *_net_info, *next;
1402 u32 cnt = 0;
1403 unsigned long int flags;
1404
1405 spin_lock_irqsave(&cfg->net_list_sync, flags);
1406 GCC_DIAGNOSTIC_PUSH();
1407 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1408 if (_net_info->ndev &&
1409 test_bit(status, &_net_info->sme_state))
1410 cnt++;
1411 }
1412 GCC_DIAGNOSTIC_POP();
1413 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1414 return cnt;
1415 }
1416 static inline void
1417 wl_set_status_all(struct bcm_cfg80211 *cfg, s32 status, u32 op)
1418 {
1419 struct net_info *_net_info, *next;
1420 unsigned long int flags;
1421
1422 spin_lock_irqsave(&cfg->net_list_sync, flags);
1423 GCC_DIAGNOSTIC_PUSH();
1424 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1425 switch (op) {
1426 case 1:
1427 break; /* set all status is not allowed */
1428 case 2:
1429 /*
1430 * Release the spinlock before calling notifier. Else there
1431 * will be nested calls
1432 */
1433 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1434 clear_bit(status, &_net_info->sme_state);
1435 if (cfg->state_notifier &&
1436 test_bit(status, &(cfg->interrested_state)))
1437 cfg->state_notifier(cfg, _net_info, status, false);
1438 return;
1439 case 4:
1440 break; /* change all status is not allowed */
1441 default:
1442 break; /* unknown operation */
1443 }
1444 }
1445 GCC_DIAGNOSTIC_POP();
1446 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1447 }
1448 static inline void
1449 wl_set_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
1450 struct net_device *ndev, u32 op)
1451 {
1452
1453 struct net_info *_net_info, *next;
1454 unsigned long int flags;
1455
1456 spin_lock_irqsave(&cfg->net_list_sync, flags);
1457 GCC_DIAGNOSTIC_PUSH();
1458 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1459 if (ndev && (_net_info->ndev == ndev)) {
1460 switch (op) {
1461 case 1:
1462 /*
1463 * Release the spinlock before calling notifier. Else there
1464 * will be nested calls
1465 */
1466 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1467 set_bit(status, &_net_info->sme_state);
1468 if (cfg->state_notifier &&
1469 test_bit(status, &(cfg->interrested_state)))
1470 cfg->state_notifier(cfg, _net_info, status, true);
1471 return;
1472 case 2:
1473 /*
1474 * Release the spinlock before calling notifier. Else there
1475 * will be nested calls
1476 */
1477 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1478 clear_bit(status, &_net_info->sme_state);
1479 if (cfg->state_notifier &&
1480 test_bit(status, &(cfg->interrested_state)))
1481 cfg->state_notifier(cfg, _net_info, status, false);
1482 return;
1483 case 4:
1484 change_bit(status, &_net_info->sme_state);
1485 break;
1486 }
1487 }
1488
1489 }
1490 GCC_DIAGNOSTIC_POP();
1491 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1492
1493 }
1494
1495 static inline wl_cfgbss_t *
1496 wl_get_cfgbss_by_wdev(struct bcm_cfg80211 *cfg,
1497 struct wireless_dev *wdev)
1498 {
1499 struct net_info *_net_info, *next;
1500 wl_cfgbss_t *bss = NULL;
1501 unsigned long int flags;
1502
1503 spin_lock_irqsave(&cfg->net_list_sync, flags);
1504 GCC_DIAGNOSTIC_PUSH();
1505 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1506 if (wdev && (_net_info->wdev == wdev)) {
1507 bss = &_net_info->bss;
1508 break;
1509 }
1510 }
1511 GCC_DIAGNOSTIC_POP();
1512
1513 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1514 return bss;
1515 }
1516
1517 static inline u32
1518 wl_get_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
1519 struct net_device *ndev)
1520 {
1521 struct net_info *_net_info, *next;
1522 u32 stat = 0;
1523 unsigned long int flags;
1524
1525 spin_lock_irqsave(&cfg->net_list_sync, flags);
1526 GCC_DIAGNOSTIC_PUSH();
1527 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1528 if (ndev && (_net_info->ndev == ndev)) {
1529 stat = test_bit(status, &_net_info->sme_state);
1530 break;
1531 }
1532 }
1533 GCC_DIAGNOSTIC_POP();
1534 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1535 return stat;
1536 }
1537
1538 static inline s32
1539 wl_get_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1540 {
1541 struct net_info *_net_info, *next;
1542 s32 mode = -1;
1543 unsigned long int flags;
1544
1545 spin_lock_irqsave(&cfg->net_list_sync, flags);
1546 GCC_DIAGNOSTIC_PUSH();
1547 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1548 if (_net_info->ndev && (_net_info->ndev == ndev)) {
1549 mode = wl_iftype_to_mode(_net_info->iftype);
1550 break;
1551 }
1552 }
1553 GCC_DIAGNOSTIC_POP();
1554 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1555 return mode;
1556 }
1557
1558 static inline s32
1559 wl_get_bssidx_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1560 {
1561 struct net_info *_net_info, *next;
1562 s32 bssidx = -1;
1563 unsigned long int flags;
1564
1565 spin_lock_irqsave(&cfg->net_list_sync, flags);
1566 GCC_DIAGNOSTIC_PUSH();
1567 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1568 if (_net_info->wdev && (_net_info->wdev == wdev)) {
1569 bssidx = _net_info->bssidx;
1570 break;
1571 }
1572 }
1573 GCC_DIAGNOSTIC_POP();
1574 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1575 return bssidx;
1576 }
1577
1578 static inline struct wireless_dev *
1579 wl_get_wdev_by_fw_idx(struct bcm_cfg80211 *cfg, s32 bssidx, s32 ifidx)
1580 {
1581 struct net_info *_net_info, *next;
1582 struct wireless_dev *wdev = NULL;
1583 unsigned long int flags;
1584
1585 if (bssidx < 0)
1586 return NULL;
1587 spin_lock_irqsave(&cfg->net_list_sync, flags);
1588 GCC_DIAGNOSTIC_PUSH();
1589 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1590 if ((_net_info->bssidx == bssidx) && (_net_info->ifidx == ifidx)) {
1591 wdev = _net_info->wdev;
1592 break;
1593 }
1594 }
1595 GCC_DIAGNOSTIC_POP();
1596 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1597 return wdev;
1598 }
1599
1600 static inline struct wl_profile *
1601 wl_get_profile_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1602 {
1603 struct net_info *_net_info, *next;
1604 struct wl_profile *prof = NULL;
1605 unsigned long int flags;
1606
1607 spin_lock_irqsave(&cfg->net_list_sync, flags);
1608 GCC_DIAGNOSTIC_PUSH();
1609 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1610 if (ndev && (_net_info->ndev == ndev)) {
1611 prof = &_net_info->profile;
1612 break;
1613 }
1614 }
1615 GCC_DIAGNOSTIC_POP();
1616 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1617 return prof;
1618 }
1619 static inline struct net_info *
1620 wl_get_netinfo_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1621 {
1622 struct net_info *_net_info, *next, *info = NULL;
1623 unsigned long int flags;
1624
1625 spin_lock_irqsave(&cfg->net_list_sync, flags);
1626 GCC_DIAGNOSTIC_PUSH();
1627 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1628 if (ndev && (_net_info->ndev == ndev)) {
1629 info = _net_info;
1630 break;
1631 }
1632 }
1633 GCC_DIAGNOSTIC_POP();
1634 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1635 return info;
1636 }
1637
1638 static inline struct net_info *
1639 wl_get_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1640 {
1641 struct net_info *_net_info, *next, *info = NULL;
1642 unsigned long int flags;
1643
1644 spin_lock_irqsave(&cfg->net_list_sync, flags);
1645 GCC_DIAGNOSTIC_PUSH();
1646 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1647 if (wdev && (_net_info->wdev == wdev)) {
1648 info = _net_info;
1649 break;
1650 }
1651 }
1652 GCC_DIAGNOSTIC_POP();
1653 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1654 return info;
1655 }
1656
1657 #define is_p2p_group_iface(wdev) (((wdev->iftype == NL80211_IFTYPE_P2P_GO) || \
1658 (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)) ? 1 : 0)
1659 #define bcmcfg_to_wiphy(cfg) (cfg->wdev->wiphy)
1660 #define bcmcfg_to_prmry_ndev(cfg) (cfg->wdev->netdev)
1661 #define bcmcfg_to_prmry_wdev(cfg) (cfg->wdev)
1662 #define bcmcfg_to_p2p_wdev(cfg) (cfg->p2p_wdev)
1663 #define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
1664 #define ndev_to_wdev(ndev) (ndev->ieee80211_ptr)
1665 #define wdev_to_ndev(wdev) (wdev->netdev)
1666
1667 #if defined(WL_ENABLE_P2P_IF)
1668 #define ndev_to_wlc_ndev(ndev, cfg) ((ndev == cfg->p2p_net) ? \
1669 bcmcfg_to_prmry_ndev(cfg) : ndev)
1670 #else
1671 #define ndev_to_wlc_ndev(ndev, cfg) (ndev)
1672 #endif /* WL_ENABLE_P2P_IF */
1673
1674 #define wdev_to_wlc_ndev(wdev, cfg) \
1675 (wdev_to_ndev(wdev) ? \
1676 wdev_to_ndev(wdev) : bcmcfg_to_prmry_ndev(cfg))
1677 #if defined(WL_CFG80211_P2P_DEV_IF)
1678 #define cfgdev_to_wlc_ndev(cfgdev, cfg) wdev_to_wlc_ndev(cfgdev, cfg)
1679 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_wdev(cfg)
1680 #elif defined(WL_ENABLE_P2P_IF)
1681 #define cfgdev_to_wlc_ndev(cfgdev, cfg) ndev_to_wlc_ndev(cfgdev, cfg)
1682 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_ndev(cfg)
1683 #else
1684 #define cfgdev_to_wlc_ndev(cfgdev, cfg) (cfgdev)
1685 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) (cfgdev)
1686 #endif /* WL_CFG80211_P2P_DEV_IF */
1687
1688 #if defined(WL_CFG80211_P2P_DEV_IF)
1689 #define cfgdev_to_wdev(cfgdev) (cfgdev)
1690 #define ndev_to_cfgdev(ndev) ndev_to_wdev(ndev)
1691 #define cfgdev_to_ndev(cfgdev) (cfgdev ? (cfgdev->netdev) : NULL)
1692 #define wdev_to_cfgdev(cfgdev) (cfgdev)
1693 #define discover_cfgdev(cfgdev, cfg) (cfgdev->iftype == NL80211_IFTYPE_P2P_DEVICE)
1694 #else
1695 #define cfgdev_to_wdev(cfgdev) (cfgdev->ieee80211_ptr)
1696 #define wdev_to_cfgdev(cfgdev) cfgdev ? (cfgdev->netdev) : NULL
1697 #define ndev_to_cfgdev(ndev) (ndev)
1698 #define cfgdev_to_ndev(cfgdev) (cfgdev)
1699 #define discover_cfgdev(cfgdev, cfg) (cfgdev == cfg->p2p_net)
1700 #endif /* WL_CFG80211_P2P_DEV_IF */
1701
1702 #if defined(WL_CFG80211_P2P_DEV_IF)
1703 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
1704 (cfg->scan_request->wdev == cfg->p2p_wdev)) ? true : false)
1705 #elif defined(WL_ENABLE_P2P_IF)
1706 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
1707 (cfg->scan_request->dev == cfg->p2p_net)) ? true : false)
1708 #else
1709 #define scan_req_match(cfg) (((cfg) && p2p_is_on(cfg) && p2p_scan(cfg)) ? \
1710 true : false)
1711 #endif /* WL_CFG80211_P2P_DEV_IF */
1712
1713 #define PRINT_WDEV_INFO(cfgdev) \
1714 { \
1715 struct wireless_dev *wdev = cfgdev_to_wdev(cfgdev); \
1716 struct net_device *netdev = wdev ? wdev->netdev : NULL; \
1717 WL_DBG(("wdev_ptr:%p ndev_ptr:%p ifname:%s iftype:%d\n", OSL_OBFUSCATE_BUF(wdev), \
1718 OSL_OBFUSCATE_BUF(netdev), \
1719 netdev ? netdev->name : "NULL (non-ndev device)", \
1720 wdev ? wdev->iftype : 0xff)); \
1721 }
1722
1723 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
1724 #define scan_req_iftype(req) (req->dev->ieee80211_ptr->iftype)
1725 #else
1726 #define scan_req_iftype(req) (req->wdev->iftype)
1727 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) */
1728
1729 #define wl_to_sr(w) (w->scan_req_int)
1730 #if defined(STATIC_WL_PRIV_STRUCT)
1731 #define wl_to_ie(w) (w->ie)
1732 #define wl_to_conn(w) (w->conn_info)
1733 #else
1734 #define wl_to_ie(w) (&w->ie)
1735 #define wl_to_conn(w) (&w->conn_info)
1736 #endif // endif
1737 #define wiphy_from_scan(w) (w->escan_info.wiphy)
1738 #define wl_get_drv_status_all(cfg, stat) \
1739 (wl_get_status_all(cfg, WL_STATUS_ ## stat))
1740 #define wl_get_drv_status(cfg, stat, ndev) \
1741 (wl_get_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev))
1742 #define wl_set_drv_status(cfg, stat, ndev) \
1743 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 1))
1744 #define wl_clr_drv_status(cfg, stat, ndev) \
1745 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 2))
1746 #define wl_clr_drv_status_all(cfg, stat) \
1747 (wl_set_status_all(cfg, WL_STATUS_ ## stat, 2))
1748 #define wl_chg_drv_status(cfg, stat, ndev) \
1749 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 4))
1750
1751 #define for_each_bss(list, bss, __i) \
1752 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
1753
1754 #define for_each_ndev(cfg, iter, next) \
1755 list_for_each_entry_safe(iter, next, &cfg->net_list, list)
1756
1757 /* In case of WPS from wpa_supplicant, pairwise siute and group suite is 0.
1758 * In addtion to that, wpa_version is WPA_VERSION_1
1759 */
1760 #define is_wps_conn(_sme) \
1761 ((wl_cfgp2p_find_wpsie(_sme->ie, _sme->ie_len) != NULL) && \
1762 (!_sme->crypto.n_ciphers_pairwise) && \
1763 (!_sme->crypto.cipher_group))
1764
1765 #ifdef WLFBT
1766 #if defined(WLAN_AKM_SUITE_FT_8021X) && defined(WLAN_AKM_SUITE_FT_PSK)
1767 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X || \
1768 sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
1769 #elif defined(WLAN_AKM_SUITE_FT_8021X)
1770 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X)
1771 #elif defined(WLAN_AKM_SUITE_FT_PSK)
1772 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
1773 #else
1774 #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
1775 #endif /* WLAN_AKM_SUITE_FT_8021X && WLAN_AKM_SUITE_FT_PSK */
1776 #else
1777 #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
1778 #endif /* WLFBT */
1779
1780 #ifdef BCMCCX
1781 #define IS_AKM_SUITE_CCKM(sec) (sec->wpa_auth == WLAN_AKM_SUITE_CCKM)
1782 #else
1783 #define IS_AKM_SUITE_CCKM(sec) ({BCM_REFERENCE(sec); FALSE;})
1784 #endif /* BCMCCX */
1785
1786 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
1787 #define STA_INFO_BIT(info) (1ul << NL80211_STA_ ## info)
1788 #ifdef strnicmp
1789 #undef strnicmp
1790 #endif /* strnicmp */
1791 #define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
1792 #else
1793 #define STA_INFO_BIT(info) (STATION_ ## info)
1794 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
1795
1796 extern s32 wl_cfg80211_attach(struct net_device *ndev, void *context);
1797 extern void wl_cfg80211_detach(struct bcm_cfg80211 *cfg);
1798
1799 extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
1800 void *data);
1801 void wl_cfg80211_set_parent_dev(void *dev);
1802 struct device *wl_cfg80211_get_parent_dev(void);
1803 struct bcm_cfg80211 *wl_cfg80211_get_bcmcfg(void);
1804 void wl_cfg80211_set_bcmcfg(struct bcm_cfg80211 *cfg);
1805
1806 /* clear IEs */
1807 extern s32 wl_cfg80211_clear_mgmt_vndr_ies(struct bcm_cfg80211 *cfg);
1808 extern s32 wl_cfg80211_clear_per_bss_ies(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev);
1809 extern void wl_cfg80211_clear_p2p_disc_ies(struct bcm_cfg80211 *cfg);
1810 #ifdef WL_STATIC_IF
1811 extern int32 wl_cfg80211_update_iflist_info(struct bcm_cfg80211 *cfg, struct net_device *ndev,
1812 int ifidx, uint8 *addr, int bssidx, char *name, int if_state);
1813 #endif /* WL_STATIC_IF */
1814 extern s32 wl_cfg80211_up(struct net_device *net);
1815 extern s32 wl_cfg80211_down(struct net_device *net);
1816 extern void wl_cfg80211_sta_ifdown(struct net_device *net);
1817 extern s32 wl_cfg80211_notify_ifadd(struct net_device * dev, int ifidx, char *name, uint8 *mac,
1818 uint8 bssidx, uint8 role);
1819 extern s32 wl_cfg80211_notify_ifdel(struct net_device * dev, int ifidx, char *name, uint8 *mac,
1820 uint8 bssidx);
1821 extern s32 wl_cfg80211_notify_ifchange(struct net_device * dev, int ifidx, char *name, uint8 *mac,
1822 uint8 bssidx);
1823 extern struct net_device* wl_cfg80211_allocate_if(struct bcm_cfg80211 *cfg, int ifidx,
1824 const char *name, uint8 *mac, uint8 bssidx, const char *dngl_name);
1825 extern int wl_cfg80211_register_if(struct bcm_cfg80211 *cfg,
1826 int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
1827 extern int wl_cfg80211_remove_if(struct bcm_cfg80211 *cfg,
1828 int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
1829 extern void wl_cfg80211_cleanup_if(struct net_device *dev);
1830 extern int wl_cfg80211_scan_stop(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev);
1831 extern void wl_cfg80211_scan_abort(struct bcm_cfg80211 *cfg);
1832 extern bool wl_cfg80211_is_concurrent_mode(struct net_device * dev);
1833 extern void wl_cfg80211_disassoc(struct net_device *ndev);
1834 extern void wl_cfg80211_del_all_sta(struct net_device *ndev, uint32 reason);
1835 extern void* wl_cfg80211_get_dhdp(struct net_device * dev);
1836 extern bool wl_cfg80211_is_p2p_active(struct net_device * dev);
1837 extern bool wl_cfg80211_is_roam_offload(struct net_device * dev);
1838 extern bool wl_cfg80211_is_event_from_connected_bssid(struct net_device * dev,
1839 const wl_event_msg_t *e, int ifidx);
1840 extern void wl_cfg80211_dbg_level(u32 level);
1841 extern s32 wl_cfg80211_get_p2p_dev_addr(struct net_device *net, struct ether_addr *p2pdev_addr);
1842 extern s32 wl_cfg80211_set_p2p_noa(struct net_device *net, char* buf, int len);
1843 extern s32 wl_cfg80211_get_p2p_noa(struct net_device *net, char* buf, int len);
1844 extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len,
1845 enum wl_management_type type);
1846 extern s32 wl_cfg80211_set_p2p_ps(struct net_device *net, char* buf, int len);
1847 extern s32 wl_cfg80211_set_p2p_ecsa(struct net_device *net, char* buf, int len);
1848 extern s32 wl_cfg80211_increase_p2p_bw(struct net_device *net, char* buf, int len);
1849 #ifdef P2PLISTEN_AP_SAMECHN
1850 extern s32 wl_cfg80211_set_p2p_resp_ap_chn(struct net_device *net, s32 enable);
1851 #endif /* P2PLISTEN_AP_SAMECHN */
1852
1853 /* btcoex functions */
1854 void* wl_cfg80211_btcoex_init(struct net_device *ndev);
1855 void wl_cfg80211_btcoex_deinit(void);
1856
1857 extern chanspec_t wl_chspec_from_legacy(chanspec_t legacy_chspec);
1858 extern chanspec_t wl_chspec_driver_to_host(chanspec_t chanspec);
1859
1860 #ifdef WL_SUPPORT_AUTO_CHANNEL
1861 #define CHANSPEC_BUF_SIZE 1024
1862 #define CHAN_SEL_IOCTL_DELAY 300
1863 #define CHAN_SEL_RETRY_COUNT 15
1864 #define CHANNEL_IS_RADAR(channel) (((channel & WL_CHAN_RADAR) || \
1865 (channel & WL_CHAN_PASSIVE)) ? true : false)
1866 #define CHANNEL_IS_2G(channel) (((channel >= 1) && (channel <= 14)) ? \
1867 true : false)
1868 #define CHANNEL_IS_5G(channel) (((channel >= 36) && (channel <= 165)) ? \
1869 true : false)
1870 extern s32 wl_cfg80211_get_best_channels(struct net_device *dev, char* command,
1871 int total_len);
1872 #endif /* WL_SUPPORT_AUTO_CHANNEL */
1873 extern int wl_cfg80211_ether_atoe(const char *a, struct ether_addr *n);
1874 extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
1875 extern s32 wl_mode_to_nl80211_iftype(s32 mode);
1876 int wl_cfg80211_do_driver_init(struct net_device *net);
1877 void wl_cfg80211_enable_trace(bool set, u32 level);
1878 extern s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify);
1879 extern s32 wl_cfg80211_if_is_group_owner(void);
1880 extern chanspec_t wl_chspec_host_to_driver(chanspec_t chanspec);
1881 extern chanspec_t wl_ch_host_to_driver(u16 channel);
1882 extern s32 wl_set_tx_power(struct net_device *dev,
1883 enum nl80211_tx_power_setting type, s32 dbm);
1884 extern s32 wl_get_tx_power(struct net_device *dev, s32 *dbm);
1885 extern s32 wl_add_remove_eventmsg(struct net_device *ndev, u16 event, bool add);
1886 extern void wl_stop_wait_next_action_frame(struct bcm_cfg80211 *cfg, struct net_device *ndev,
1887 u8 bsscfgidx);
1888 #ifdef WL_HOST_BAND_MGMT
1889 extern s32 wl_cfg80211_set_band(struct net_device *ndev, int band);
1890 #endif /* WL_HOST_BAND_MGMT */
1891 extern void wl_cfg80211_add_to_eventbuffer(wl_eventmsg_buf_t *ev, u16 event, bool set);
1892 extern s32 wl_cfg80211_apply_eventbuffer(struct net_device *ndev,
1893 struct bcm_cfg80211 *cfg, wl_eventmsg_buf_t *ev);
1894 extern void get_primary_mac(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
1895 extern void wl_cfg80211_update_power_mode(struct net_device *dev);
1896 extern void wl_cfg80211_set_passive_scan(struct net_device *dev, char *command);
1897 extern void wl_terminate_event_handler(struct net_device *dev);
1898 #if defined(DHD_ENABLE_BIGDATA_LOGGING)
1899 extern s32 wl_cfg80211_get_bss_info(struct net_device *dev, char* cmd, int total_len);
1900 extern s32 wl_cfg80211_get_connect_failed_status(struct net_device *dev, char* cmd, int total_len);
1901 #endif /* DHD_ENABLE_BIGDATA_LOGGING */
1902 extern struct bcm_cfg80211 *wl_get_cfg(struct net_device *ndev);
1903 extern s32 wl_cfg80211_set_if_band(struct net_device *ndev, int band);
1904
1905 #define SCAN_BUF_CNT 2
1906 #define SCAN_BUF_NEXT 1
1907 #define WL_SCANTYPE_LEGACY 0x1
1908 #define WL_SCANTYPE_P2P 0x2
1909 #ifdef DUAL_ESCAN_RESULT_BUFFER
1910 #define wl_escan_set_sync_id(a, b) ((a) = (b)->escan_info.cur_sync_id)
1911 #define wl_escan_set_type(a, b) ((a)->escan_info.escan_type\
1912 [((a)->escan_info.cur_sync_id)%SCAN_BUF_CNT] = (b))
1913 static inline wl_scan_results_t *wl_escan_get_buf(struct bcm_cfg80211 *cfg, bool aborted)
1914 {
1915 u8 index;
1916 if (aborted) {
1917 if (cfg->escan_info.escan_type[0] == cfg->escan_info.escan_type[1])
1918 index = (cfg->escan_info.cur_sync_id + 1)%SCAN_BUF_CNT;
1919 else
1920 index = (cfg->escan_info.cur_sync_id)%SCAN_BUF_CNT;
1921 }
1922 else
1923 index = (cfg->escan_info.cur_sync_id)%SCAN_BUF_CNT;
1924
1925 return (wl_scan_results_t *)cfg->escan_info.escan_buf[index];
1926 }
1927 static inline int wl_escan_check_sync_id(s32 status, u16 result_id, u16 wl_id)
1928 {
1929 if (result_id != wl_id) {
1930 WL_ERR(("ESCAN sync id mismatch :status :%d "
1931 "cur_sync_id:%d coming sync_id:%d\n",
1932 status, wl_id, result_id));
1933 return -1;
1934 }
1935 else
1936 return 0;
1937 }
1938 static inline void wl_escan_print_sync_id(s32 status, u16 result_id, u16 wl_id)
1939 {
1940 if (result_id != wl_id) {
1941 WL_ERR(("ESCAN sync id mismatch :status :%d "
1942 "cur_sync_id:%d coming sync_id:%d\n",
1943 status, wl_id, result_id));
1944 }
1945 }
1946 #define wl_escan_increment_sync_id(a, b) ((a)->escan_info.cur_sync_id += b)
1947 #define wl_escan_init_sync_id(a) ((a)->escan_info.cur_sync_id = 0)
1948 #else
1949 #define wl_escan_set_sync_id(a, b) ((a) = htod16((b)->escan_sync_id_cntr++))
1950 #define wl_escan_set_type(a, b)
1951 #define wl_escan_get_buf(a, b) ((wl_scan_results_t *) (a)->escan_info.escan_buf)
1952 #define wl_escan_check_sync_id(a, b, c) 0
1953 #define wl_escan_print_sync_id(a, b, c)
1954 #define wl_escan_increment_sync_id(a, b)
1955 #define wl_escan_init_sync_id(a)
1956 #endif /* DUAL_ESCAN_RESULT_BUFFER */
1957 extern void wl_cfg80211_ibss_vsie_set_buffer(struct net_device *dev, vndr_ie_setbuf_t *ibss_vsie,
1958 int ibss_vsie_len);
1959 extern s32 wl_cfg80211_ibss_vsie_delete(struct net_device *dev);
1960 #ifdef WLAIBSS
1961 extern void wl_cfg80211_set_txfail_pid(struct net_device *dev, int pid);
1962 #endif /* WLAIBSS */
1963 #ifdef WL_RELMCAST
1964 extern void wl_cfg80211_set_rmc_pid(struct net_device *dev, int pid);
1965 #endif /* WL_RELMCAST */
1966 extern int wl_cfg80211_set_mgmt_vndr_ies(struct bcm_cfg80211 *cfg,
1967 bcm_struct_cfgdev *cfgdev, s32 bssidx, s32 pktflag,
1968 const u8 *vndr_ie, u32 vndr_ie_len);
1969
1970 #ifdef WLFBT
1971 extern int wl_cfg80211_get_fbt_key(struct net_device *dev, uint8 *key, int total_len);
1972 #endif // endif
1973
1974 /* Action frame specific functions */
1975 extern u8 wl_get_action_category(void *frame, u32 frame_len);
1976 extern int wl_get_public_action(void *frame, u32 frame_len, u8 *ret_action);
1977
1978 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
1979 struct net_device *wl_cfg80211_get_remain_on_channel_ndev(struct bcm_cfg80211 *cfg);
1980 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
1981
1982 #ifdef WL_SUPPORT_ACS
1983 #define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */
1984 #define IOCTL_RETRY_COUNT 5
1985 #define CHAN_NOISE_DUMMY -80
1986 #define OBSS_TOKEN_IDX 15
1987 #define IBSS_TOKEN_IDX 15
1988 #define TX_TOKEN_IDX 14
1989 #define CTG_TOKEN_IDX 13
1990 #define PKT_TOKEN_IDX 15
1991 #define IDLE_TOKEN_IDX 12
1992 #endif /* WL_SUPPORT_ACS */
1993
1994 #ifdef BCMWAPI_WPI
1995 #define is_wapi(cipher) (cipher == WLAN_CIPHER_SUITE_SMS4) ? 1 : 0
1996 #endif /* BCMWAPI_WPI */
1997
1998 extern int wl_cfg80211_get_ioctl_version(void);
1999 extern int wl_cfg80211_enable_roam_offload(struct net_device *dev, int enable);
2000 extern s32 wl_cfg80211_dfs_ap_move(struct net_device *ndev, char *data,
2001 char *command, int total_len);
2002 #ifdef WBTEXT
2003 extern s32 wl_cfg80211_wbtext_set_default(struct net_device *ndev);
2004 extern s32 wl_cfg80211_wbtext_config(struct net_device *ndev, char *data,
2005 char *command, int total_len);
2006 extern int wl_cfg80211_wbtext_weight_config(struct net_device *ndev, char *data,
2007 char *command, int total_len);
2008 extern int wl_cfg80211_wbtext_table_config(struct net_device *ndev, char *data,
2009 char *command, int total_len);
2010 extern s32 wl_cfg80211_wbtext_delta_config(struct net_device *ndev, char *data,
2011 char *command, int total_len);
2012 #endif /* WBTEXT */
2013 extern s32 wl_cfg80211_get_chanspecs_2g(struct net_device *ndev,
2014 void *buf, s32 buflen);
2015 extern s32 wl_cfg80211_get_chanspecs_5g(struct net_device *ndev,
2016 void *buf, s32 buflen);
2017
2018 extern s32 wl_cfg80211_bss_up(struct bcm_cfg80211 *cfg,
2019 struct net_device *ndev, s32 bsscfg_idx, s32 up);
2020 extern bool wl_cfg80211_bss_isup(struct net_device *ndev, int bsscfg_idx);
2021
2022 struct net_device *wl_cfg80211_post_ifcreate(struct net_device *ndev,
2023 wl_if_event_info *event, u8 *addr, const char *name, bool rtnl_lock_reqd);
2024 extern s32 wl_cfg80211_post_ifdel(struct net_device *ndev, bool rtnl_lock_reqd, s32 ifidx);
2025 #if defined(PKT_FILTER_SUPPORT) && defined(APSTA_BLOCK_ARP_DURING_DHCP)
2026 extern void wl_cfg80211_block_arp(struct net_device *dev, int enable);
2027 #endif /* PKT_FILTER_SUPPORT && APSTA_BLOCK_ARP_DURING_DHCP */
2028
2029 #ifdef WL_NAN
2030 int wl_cfgvendor_send_nan_event(struct wiphy * wiphy,
2031 struct net_device *dev, int event_id,
2032 nan_event_data_t *nan_event_data);
2033 extern int wl_cfgnan_init(struct bcm_cfg80211 *cfg);
2034 extern int wl_cfgnan_deinit(struct bcm_cfg80211 *cfg, uint8 busstate);
2035 extern bool wl_cfgnan_check_state(struct bcm_cfg80211 *cfg);
2036 #endif /* WL_NAN */
2037
2038 #ifdef WL_CFG80211_P2P_DEV_IF
2039 extern void wl_cfg80211_del_p2p_wdev(struct net_device *dev);
2040 #endif /* WL_CFG80211_P2P_DEV_IF */
2041 #if defined(WL_SUPPORT_AUTO_CHANNEL)
2042 extern int wl_cfg80211_set_spect(struct net_device *dev, int spect);
2043 extern int wl_cfg80211_get_sta_channel(struct bcm_cfg80211 *cfg);
2044 #endif /* WL_SUPPORT_AUTO_CHANNEL */
2045 #ifdef WL_CFG80211_SYNC_GON
2046 #define WL_DRV_STATUS_SENDING_AF_FRM_EXT(cfg) \
2047 (wl_get_drv_status_all(cfg, SENDING_ACT_FRM) || \
2048 wl_get_drv_status_all(cfg, WAITING_NEXT_ACT_FRM_LISTEN))
2049 #else
2050 #define WL_DRV_STATUS_SENDING_AF_FRM_EXT(cfg) wl_get_drv_status_all(cfg, SENDING_ACT_FRM)
2051 #endif /* WL_CFG80211_SYNC_GON */
2052
2053 #ifdef P2P_LISTEN_OFFLOADING
2054 extern s32 wl_cfg80211_p2plo_deinit(struct bcm_cfg80211 *cfg);
2055 #endif /* P2P_LISTEN_OFFLOADING */
2056
2057 #define RETURN_EIO_IF_NOT_UP(wlpriv) \
2058 do { \
2059 struct net_device *checkSysUpNDev = bcmcfg_to_prmry_ndev(wlpriv); \
2060 if (unlikely(!wl_get_drv_status(wlpriv, READY, checkSysUpNDev))) { \
2061 WL_INFORM(("device is not ready\n")); \
2062 return -EIO; \
2063 } \
2064 } while (0)
2065
2066 #ifdef QOS_MAP_SET
2067 extern uint8 *wl_get_up_table(void);
2068 #endif /* QOS_MAP_SET */
2069
2070 #define P2PO_COOKIE 65535
2071 u64 wl_cfg80211_get_new_roc_id(struct bcm_cfg80211 *cfg);
2072
2073 #if defined(SUPPORT_RANDOM_MAC_SCAN)
2074 int wl_cfg80211_set_random_mac(struct net_device *dev, bool enable);
2075 int wl_cfg80211_random_mac_enable(struct net_device *dev, uint8 *rand_mac, uint8 *rand_mask);
2076 int wl_cfg80211_random_mac_disable(struct net_device *dev);
2077 int wl_cfg80211_scan_mac_enable(struct net_device *dev, uint8 *rand_mac, uint8 *rand_mask);
2078 int wl_cfg80211_scan_mac_disable(struct net_device *dev);
2079 #endif /* SUPPORT_RANDOM_MAC_SCAN */
2080 #ifdef SUPPORT_AP_HIGHER_BEACONRATE
2081 int wl_set_ap_beacon_rate(struct net_device *dev, int val, char *ifname);
2082 int wl_get_ap_basic_rate(struct net_device *dev, char* command, char *ifname, int total_len);
2083 #endif /* SUPPORT_AP_HIGHER_BEACONRATE */
2084 #ifdef SUPPORT_AP_RADIO_PWRSAVE
2085 int wl_get_ap_rps(struct net_device *dev, char* command, char *ifname, int total_len);
2086 int wl_set_ap_rps(struct net_device *dev, bool enable, char *ifname);
2087 int wl_update_ap_rps_params(struct net_device *dev, ap_rps_info_t* rps, char *ifname);
2088 void wl_cfg80211_init_ap_rps(struct bcm_cfg80211 *cfg);
2089 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
2090 #ifdef SUPPORT_RSSI_SUM_REPORT
2091 int wl_get_rssi_logging(struct net_device *dev, void *param);
2092 int wl_set_rssi_logging(struct net_device *dev, void *param);
2093 int wl_get_rssi_per_ant(struct net_device *dev, char *ifname, char *peer_mac, void *param);
2094 #endif /* SUPPORT_RSSI_SUM_REPORT */
2095 #ifdef DYNAMIC_MUMIMO_CONTROL
2096 void wl_set_murx_block_eapol_status(struct bcm_cfg80211 *cfg, int enable);
2097 bool wl_get_murx_reassoc_status(struct bcm_cfg80211 *cfg);
2098 void wl_set_murx_reassoc_status(struct bcm_cfg80211 *cfg, int enable);
2099 int wl_check_bss_support_mumimo(struct net_device *dev);
2100 int wl_get_murx_bfe_cap(struct net_device *dev, int *cap);
2101 int wl_set_murx_bfe_cap(struct net_device *dev, int val, bool reassoc_req);
2102 #endif /* DYNAMIC_MUMIMO_CONTROL */
2103 int wl_cfg80211_iface_count(struct net_device *dev);
2104 struct net_device* wl_get_ap_netdev(struct bcm_cfg80211 *cfg, char *ifname);
2105 void wl_cfg80211_cleanup_virtual_ifaces(struct bcm_cfg80211 *cfg, bool rtnl_lock_reqd);
2106 struct wireless_dev * wl_cfg80211_add_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
2107 wl_iftype_t wl_iftype, const char *name, u8 *mac);
2108 extern s32 wl_cfg80211_del_if(struct bcm_cfg80211 *cfg, struct net_device *primary_ndev,
2109 struct wireless_dev *wdev, char *name);
2110 #ifdef WL_STATIC_IF
2111 extern struct net_device *wl_cfg80211_register_static_if(struct bcm_cfg80211 *cfg,
2112 u16 iftype, char *ifname);
2113 extern void wl_cfg80211_unregister_static_if(struct bcm_cfg80211 * cfg);
2114 extern s32 wl_cfg80211_static_if_open(struct net_device *net);
2115 extern s32 wl_cfg80211_static_if_close(struct net_device *net);
2116 extern struct net_device * wl_cfg80211_post_static_ifcreate(struct bcm_cfg80211 *cfg,
2117 wl_if_event_info *event, u8 *addr, s32 iface_type);
2118 extern s32 wl_cfg80211_post_static_ifdel(struct bcm_cfg80211 *cfg, struct net_device *ndev);
2119 #endif /* WL_STATIC_IF */
2120 extern struct wireless_dev *wl_cfg80211_get_wdev_from_ifname(struct bcm_cfg80211 *cfg,
2121 const char *name);
2122 struct net_device* wl_get_netdev_by_name(struct bcm_cfg80211 *cfg, char *ifname);
2123 extern s32 wl_get_vif_macaddr(struct bcm_cfg80211 *cfg, u16 wl_iftype, u8 *mac_addr);
2124 extern s32 wl_release_vif_macaddr(struct bcm_cfg80211 *cfg, u8 *mac_addr, u16 wl_iftype);
2125 extern int wl_cfg80211_ifstats_counters(struct net_device *dev, wl_if_stats_t *if_stats);
2126 extern s32 wl_cfg80211_set_dbg_verbose(struct net_device *ndev, u32 level);
2127 extern s32 wl_cfg80211_check_for_nan_support(struct bcm_cfg80211 *cfg);
2128 extern int wl_cfg80211_deinit_p2p_discovery(struct bcm_cfg80211 * cfg);
2129 extern int wl_cfg80211_set_frameburst(struct bcm_cfg80211 *cfg, bool enable);
2130 extern int wl_cfg80211_determine_p2p_rsdb_mode(struct bcm_cfg80211 *cfg);
2131 extern s32 cfg80211_to_wl_iftype(uint16 type, uint16 *role, uint16 *mode);
2132 extern s32 wl_cfg80211_net_attach(struct net_device *primary_ndev);
2133 extern uint8 wl_cfg80211_get_bus_state(struct bcm_cfg80211 *cfg);
2134 #ifdef WL_WPS_SYNC
2135 void wl_handle_wps_states(struct net_device *ndev, u8 *dump_data, u16 len, bool direction);
2136 #endif /* WL_WPS_SYNC */
2137
2138 /* Function to flush the FW log buffer content */
2139 #ifdef DHD_LOG_DUMP
2140 extern void wl_flush_fw_log_buffer(struct net_device *dev, uint32 logset_mask);
2141 #else
2142 #define wl_flush_fw_log_buffer(x, y)
2143 #endif /* DHD_LOG_DUMP */
2144 #ifdef DHD_USE_CHECK_DONGLE_IDLE
2145 int wl_check_dongle_idle(struct wiphy *wiphy);
2146 #else
2147 static inline int wl_check_dongle_idle(struct wiphy *wiphy)
2148 {
2149 return TRUE;
2150 }
2151 #endif /* DHD_USE_CHECK_DONGLE_IDLE */
2152 #ifdef DHD_ABORT_SCAN_CREATE_INTERFACE
2153 extern int wl_abort_scan_and_check(struct bcm_cfg80211 *cfg);
2154 #else
2155 static inline int wl_abort_scan_and_check(struct bcm_cfg80211 *cfg)
2156 {
2157 return TRUE;
2158 }
2159 #endif /* DHD_ABORT_SCAN_CREATE_INTERFACE */
2160 #ifdef APSTA_RESTRICTED_CHANNEL
2161 extern s32 wl_cfg80211_set_indoor_channels(struct net_device *ndev, char *command, int total_len);
2162 extern s32 wl_cfg80211_get_indoor_channels(struct net_device *ndev, char *command, int total_len);
2163 extern s32 wl_cfg80211_read_indoor_channels(struct net_device *ndev, void *buf, int buflen);
2164 extern bool wl_cfg80211_check_indoor_channels(struct net_device *ndev, int channel);
2165 #endif /* APSTA_RESTRICTED_CHANNEL */
2166 #ifdef SUPPORT_SET_CAC
2167 extern int wl_cfg80211_enable_cac(struct net_device *dev, int enable);
2168 extern void wl_cfg80211_set_cac(struct bcm_cfg80211 *cfg, int enable);
2169 #endif /* SUPPORT_SET_CAC */
2170 #endif /* _wl_cfg80211_h_ */