1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Linux cfg80211 driver
4 *
5 * Copyright (C) 1999-2017, Broadcom Corporation
6 *
7 * Unless you and Broadcom execute a separate written software license
8 * agreement governing use of this software, this software is licensed to you
9 * under the terms of the GNU General Public License version 2 (the "GPL"),
10 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
11 * following added to such license:
12 *
13 * As a special exception, the copyright holders of this software give you
14 * permission to link this software with independent modules, and to copy and
15 * distribute the resulting executable under terms of your choice, provided that
16 * you also meet, for each linked independent module, the terms and conditions of
17 * the license of that module. An independent module is a module which is not
18 * derived from this software. The special exception does not apply to any
19 * modifications of the software.
20 *
21 * Notwithstanding the above, under no circumstances may you combine this
22 * software in any way with any other Broadcom software provided under a license
23 * other than the GPL, without Broadcom's express prior written consent.
24 *
25 *
26 * <<Broadcom-WL-IPTag/Open:>>
27 *
28 * $Id: wl_cfg80211.h 710862 2017-07-14 07:43:59Z $
29 */
30
31 /**
32 * Older Linux versions support the 'iw' interface, more recent ones the 'cfg80211' interface.
33 */
34
35 #ifndef _wl_cfg80211_h_
36 #define _wl_cfg80211_h_
37
38 #include <linux/wireless.h>
39 #include <typedefs.h>
40 #include <ethernet.h>
41 #include <wlioctl.h>
42 #include <linux/wireless.h>
43 #include <net/cfg80211.h>
44 #include <linux/rfkill.h>
45
46 #include <dngl_stats.h>
47 #include <dhd.h>
48 #include <wl_cfgp2p.h>
49 #include <wl_android.h>
50 struct wl_conf;
51 struct wl_iface;
52 struct bcm_cfg80211;
53 struct wl_security;
54 struct wl_ibss;
55
56 #if !defined(WL_CLIENT_SAE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0))
57 #define WL_CLIENT_SAE
58 #endif
59 #if defined(WL_SAE) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
60 #error "Can not support WL_SAE befor kernel 3.14"
61 #endif
62 #if defined(WL_CLIENT_SAE) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0))
63 #error "Can not support WL_CLIENT_SAE before kernel 4.9"
64 #endif
65 #if defined(WL_CLIENT_SAE) && defined(WL_SAE)
66 #error "WL_SAE is for dongle-offload and WL_CLIENT_SAE is for wpa_supplicant. Please choose one."
67 #endif
68
69 #if defined(WL_CLIENT_SAE)
70 #ifndef WL_ASSOC_MGR_CMD_SEND_AUTH
71 #define WL_ASSOC_MGR_CMD_SEND_AUTH 3
72 #endif /* WL_ASSOC_MGR_CMD_SEND_AUTH */
73 #endif
74
75 #define htod32(i) (i)
76 #define htod16(i) (i)
77 #define dtoh64(i) (i)
78 #define dtoh32(i) (i)
79 #define dtoh16(i) (i)
80 #define htodchanspec(i) (i)
81 #define dtohchanspec(i) (i)
82
83 #define WL_DBG_NONE 0
84 #define WL_DBG_P2P_ACTION (1 << 5)
85 #define WL_DBG_TRACE (1 << 4)
86 #define WL_DBG_SCAN (1 << 3)
87 #define WL_DBG_DBG (1 << 2)
88 #define WL_DBG_INFO (1 << 1)
89 #define WL_DBG_ERR (1 << 0)
90
91 #ifdef DHD_LOG_DUMP
92 extern void dhd_log_dump_write(int type, const char *fmt, ...);
93 extern char *dhd_log_dump_get_timestamp(void);
94 #ifndef _DHD_LOG_DUMP_DEFINITIONS_
95 #define DLD_BUF_TYPE_GENERAL 0
96 #define DLD_BUF_TYPE_SPECIAL 1
97 #define DHD_LOG_DUMP_WRITE(fmt, ...) dhd_log_dump_write(DLD_BUF_TYPE_GENERAL, fmt, ##__VA_ARGS__)
98 #define DHD_LOG_DUMP_WRITE_EX(fmt, ...) dhd_log_dump_write(DLD_BUF_TYPE_SPECIAL, fmt, ##__VA_ARGS__)
99 #endif /* !_DHD_LOG_DUMP_DEFINITIONS_ */
100 #endif /* DHD_LOG_DUMP */
101
102 /* 0 invalidates all debug messages. default is 1 */
103 #define WL_DBG_LEVEL 0xFF
104
105 #ifdef CUSTOMER_HW4_DEBUG
106 #define CFG80211_ERROR_TEXT "[dhd] CFG80211-INFO2) "
107 #else
108 #define CFG80211_ERROR_TEXT "[dhd] CFG80211-ERROR) "
109 #endif /* CUSTOMER_HW4_DEBUG */
110
111 #if defined(DHD_DEBUG)
112 #ifdef DHD_LOG_DUMP
113 #define WL_ERR_MSG(x, args...) \
114 do { \
115 if (wl_dbg_level & WL_DBG_ERR) { \
116 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
117 DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
118 DHD_LOG_DUMP_WRITE(x, ## args); \
119 } \
120 } while (0)
121 #define WL_ERR_MEM(args) \
122 do { \
123 if (wl_dbg_level & WL_DBG_ERR) { \
124 DHD_LOG_DUMP_WRITE("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
125 DHD_LOG_DUMP_WRITE(x, ## args); \
126 } \
127 } while (0)
128 #define WL_ERR_EX_MSG(x, args...) \
129 do { \
130 if (wl_dbg_level & WL_DBG_ERR) { \
131 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
132 DHD_LOG_DUMP_WRITE_EX("[%s] %s: ", dhd_log_dump_get_timestamp(), __func__); \
133 DHD_LOG_DUMP_WRITE_EX(x, ## args); \
134 } \
135 } while (0)
136 #define WL_ERR(x) WL_ERR_MSG x
137 #define WL_ERR_EX(args) WL_ERR_EX_MSG(args)
138 #else
139 #define WL_ERR_MSG(x, args...) \
140 do { \
141 if (wl_dbg_level & WL_DBG_ERR) { \
142 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
143 } \
144 } while (0)
145 #define WL_ERR(x) WL_ERR_MSG x
146 #define WL_ERR_MEM(args) WL_ERR(args)
147 #define WL_ERR_EX(args) WL_ERR(args)
148 #endif /* DHD_LOG_DUMP */
149 #else /* defined(DHD_DEBUG) */
150 #define WL_ERR_MSG(x, args...) \
151 do { \
152 if ((wl_dbg_level & WL_DBG_ERR) && net_ratelimit()) { \
153 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : " x, __func__, ## args); \
154 } \
155 } while (0)
156 #define WL_ERR(x) WL_ERR_MSG x
157 #define WL_ERR_MEM(args) WL_ERR(args)
158 #define WL_ERR_EX(args) WL_ERR(args)
159 #endif /* defined(DHD_DEBUG) */
160
161 #define WL_PRINT_RATE_LIMIT_PERIOD 4000000000u /* 4s in units of ns */
162 #define WL_ERR_RLMT(args) \
163 do { \
164 if (wl_dbg_level & WL_DBG_ERR) { \
165 static uint64 __err_ts = 0; \
166 static uint32 __err_cnt = 0; \
167 uint64 __cur_ts = 0; \
168 __cur_ts = local_clock(); \
169 if (__err_ts == 0 || (__cur_ts > __err_ts && \
170 (__cur_ts - __err_ts > WL_PRINT_RATE_LIMIT_PERIOD))) { \
171 __err_ts = __cur_ts; \
172 WL_ERR(args); \
173 WL_ERR(("[Repeats %u times]\n", __err_cnt)); \
174 __err_cnt = 0; \
175 } else { \
176 ++__err_cnt; \
177 } \
178 } \
179 } while (0)
180
181 #ifdef WL_INFORM
182 #undef WL_INFORM
183 #endif
184
185 #define WL_INFORM_MSG(x, args...) \
186 do { \
187 if (wl_dbg_level & WL_DBG_INFO) { \
188 printk(KERN_INFO "[dhd] CFG80211-INFO) %s : " x, __func__, ## args); \
189 } \
190 } while (0)
191 #define WL_INFORM(x) WL_INFORM_MSG x
192
193 #ifdef WL_SCAN
194 #undef WL_SCAN
195 #endif
196 #define WL_SCAN_MSG(x, args...) \
197 do { \
198 if (wl_dbg_level & WL_DBG_SCAN) { \
199 printk(KERN_INFO "[dhd] CFG80211-SCAN) %s :" x, __func__, ## args); \
200 } \
201 } while (0)
202 #define WL_SCAN(x) WL_SCAN_MSG x
203 #ifdef WL_TRACE
204 #undef WL_TRACE
205 #endif
206 #define WL_TRACE_MSG(x, args...) \
207 do { \
208 if (wl_dbg_level & WL_DBG_TRACE) { \
209 printk(KERN_INFO "[dhd] CFG80211-TRACE) %s :" x, __func__, ## args); \
210 } \
211 } while (0)
212 #define WL_TRACE(x) WL_TRACE_MSG x
213 #ifdef WL_TRACE_HW4
214 #undef WL_TRACE_HW4
215 #endif
216 #ifdef CUSTOMER_HW4_DEBUG
217 #define WL_TRACE_HW4_MSG(x, args...) \
218 do { \
219 if (wl_dbg_level & WL_DBG_ERR) { \
220 printk(KERN_INFO "[dhd] CFG80211-TRACE) %s : " x, __func__, ## args); \
221 } \
222 } while (0)
223 #define WL_TRACE_HW4(x) WL_TRACE_HW4_MSG x
224 #else
225 #define WL_TRACE_HW4 WL_TRACE
226 #endif /* CUSTOMER_HW4_DEBUG */
227 #if (WL_DBG_LEVEL > 0)
228 #define WL_DBG_MSG(x, args...) \
229 do { \
230 if (wl_dbg_level & WL_DBG_DBG) { \
231 printk(KERN_INFO "[dhd] CFG80211-DEBUG) %s :" x, __func__, ## args); \
232 } \
233 } while (0)
234 #define WL_DBG(x) WL_DBG_MSG x
235 #else /* !(WL_DBG_LEVEL > 0) */
236 #define WL_DBG(args)
237 #endif /* (WL_DBG_LEVEL > 0) */
238 #define WL_PNO(x)
239 #define WL_SD(x)
240
241 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
242 #define ieee80211_band nl80211_band
243 #define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ
244 #define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ
245 #define IEEE80211_NUM_BANDS NUM_NL80211_BANDS
246 #endif
247 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0))
248 #ifdef WLMESH_CFG80211
249 #undef WLMESH_CFG80211
250 #endif
251 #endif
252
253 #define WL_SCAN_RETRY_MAX 3
254 #define WL_NUM_PMKIDS_MAX MAXPMKID
255 #define WL_SCAN_BUF_MAX (1024 * 8)
256 #define WL_TLV_INFO_MAX 1500
257 #define WL_SCAN_IE_LEN_MAX 2048
258 #define WL_BSS_INFO_MAX 2048
259 #define WL_ASSOC_INFO_MAX 512
260 #define WL_IOCTL_LEN_MAX 2048
261 #define WL_EXTRA_BUF_MAX 2048
262 #define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
263 #define WL_AP_MAX 256
264 #define WL_FILE_NAME_MAX 256
265 #define WL_DWELL_TIME 200
266 #define WL_MED_DWELL_TIME 400
267 #define WL_MIN_DWELL_TIME 100
268 #define WL_LONG_DWELL_TIME 1000
269 #define IFACE_MAX_CNT 4
270 #define WL_SCAN_CONNECT_DWELL_TIME_MS 200
271 #define WL_SCAN_JOIN_PROBE_INTERVAL_MS 20
272 #define WL_SCAN_JOIN_ACTIVE_DWELL_TIME_MS 320
273 #define WL_SCAN_JOIN_PASSIVE_DWELL_TIME_MS 400
274 #define WL_AF_TX_MAX_RETRY 5
275
276 #define WL_AF_SEARCH_TIME_MAX 450
277 #define WL_AF_TX_EXTRA_TIME_MAX 200
278
279 #define WL_SCAN_TIMER_INTERVAL_MS 10000 /* Scan timeout */
280 #define WL_CHANNEL_SYNC_RETRY 5
281 #define WL_INVALID -1
282
283 #ifdef DHD_LOSSLESS_ROAMING
284 #define WL_ROAM_TIMEOUT_MS 1000 /* Roam timeout */
285 #endif
286 /* Bring down SCB Timeout to 20secs from 60secs default */
287 #ifndef WL_SCB_TIMEOUT
288 #define WL_SCB_TIMEOUT 20
289 #endif
290
291 #ifndef WL_SCB_ACTIVITY_TIME
292 #define WL_SCB_ACTIVITY_TIME 5
293 #endif
294
295 #ifndef WL_SCB_MAX_PROBE
296 #define WL_SCB_MAX_PROBE 3
297 #endif
298
299 #ifndef WL_MIN_PSPRETEND_THRESHOLD
300 #define WL_MIN_PSPRETEND_THRESHOLD 2
301 #endif
302
303 /* Cipher suites */
304 #define WLAN_CIPHER_SUITE_PMK 0x00904C00
305
306 #ifndef WLAN_AKM_SUITE_FT_8021X
307 #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
308 #endif /* WLAN_AKM_SUITE_FT_8021X */
309
310 #ifndef WLAN_AKM_SUITE_FT_PSK
311 #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
312 #endif /* WLAN_AKM_SUITE_FT_PSK */
313
314 #define WLAN_AKM_SUITE_SAE_SHA256 0x000FAC08
315
316 /*
317 * BRCM local.
318 * Use a high number that's unlikely to clash with linux upstream for a while until we can
319 * submit these changes to the community.
320 */
321 #define NL80211_FEATURE_FW_4WAY_HANDSHAKE (1<<31)
322
323 /* SCAN_SUPPRESS timer values in ms */
324 #define WL_SCAN_SUPPRESS_TIMEOUT 31000 /* default Framwork DHCP timeout is 30 sec */
325 #define WL_SCAN_SUPPRESS_RETRY 3000
326
327 #define WL_PM_ENABLE_TIMEOUT 10000
328
329 /* cfg80211 wowlan definitions */
330 #define WL_WOWLAN_MAX_PATTERNS 8
331 #define WL_WOWLAN_MIN_PATTERN_LEN 1
332 #define WL_WOWLAN_MAX_PATTERN_LEN 255
333 #define WL_WOWLAN_PKT_FILTER_ID_FIRST 201
334 #define WL_WOWLAN_PKT_FILTER_ID_LAST (WL_WOWLAN_PKT_FILTER_ID_FIRST + \
335 WL_WOWLAN_MAX_PATTERNS - 1)
336
337 #ifdef WLTDLS
338 #define TDLS_TUNNELED_PRB_REQ "\x7f\x50\x6f\x9a\04"
339 #define TDLS_TUNNELED_PRB_RESP "\x7f\x50\x6f\x9a\05"
340 #define TDLS_MAX_IFACE_FOR_ENABLE 1
341 #endif /* WLTDLS */
342
343
344 /* driver status */
345 enum wl_status {
346 WL_STATUS_READY = 0,
347 WL_STATUS_SCANNING,
348 WL_STATUS_SCAN_ABORTING,
349 WL_STATUS_CONNECTING,
350 WL_STATUS_CONNECTED,
351 WL_STATUS_DISCONNECTING,
352 WL_STATUS_AP_CREATING,
353 WL_STATUS_AP_CREATED,
354 /* whole sending action frame procedure:
355 * includes a) 'finding common channel' for public action request frame
356 * and b) 'sending af via 'actframe' iovar'
357 */
358 WL_STATUS_SENDING_ACT_FRM,
359 /* find a peer to go to a common channel before sending public action req frame */
360 WL_STATUS_FINDING_COMMON_CHANNEL,
361 /* waiting for next af to sync time of supplicant.
362 * it includes SENDING_ACT_FRM and WAITING_NEXT_ACT_FRM_LISTEN
363 */
364 WL_STATUS_WAITING_NEXT_ACT_FRM,
365 #ifdef WL_CFG80211_SYNC_GON
366 /* go to listen state to wait for next af after SENDING_ACT_FRM */
367 WL_STATUS_WAITING_NEXT_ACT_FRM_LISTEN,
368 #endif /* WL_CFG80211_SYNC_GON */
369 /* it will be set when upper layer requests listen and succeed in setting listen mode.
370 * if set, other scan request can abort current listen state
371 */
372 WL_STATUS_REMAINING_ON_CHANNEL,
373 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
374 /* it's fake listen state to keep current scan state.
375 * it will be set when upper layer requests listen but scan is running. then just run
376 * a expire timer without actual listen state.
377 * if set, other scan request does not need to abort scan.
378 */
379 WL_STATUS_FAKE_REMAINING_ON_CHANNEL,
380 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
381 WL_STATUS_NESTED_CONNECT
382 };
383
384 /* wi-fi mode */
385 enum wl_mode {
386 WL_MODE_BSS,
387 WL_MODE_IBSS,
388 WL_MODE_AP,
389 #ifdef WLMESH_CFG80211
390 WL_MODE_MESH
391 #endif
392 };
393
394 /* driver profile list */
395 enum wl_prof_list {
396 WL_PROF_MODE,
397 WL_PROF_SSID,
398 WL_PROF_SEC,
399 WL_PROF_IBSS,
400 WL_PROF_BAND,
401 WL_PROF_CHAN,
402 WL_PROF_BSSID,
403 WL_PROF_ACT,
404 WL_PROF_BEACONINT,
405 WL_PROF_DTIMPERIOD
406 };
407
408 /* donlge escan state */
409 enum wl_escan_state {
410 WL_ESCAN_STATE_IDLE,
411 WL_ESCAN_STATE_SCANING
412 };
413 /* fw downloading status */
414 enum wl_fw_status {
415 WL_FW_LOADING_DONE,
416 WL_NVRAM_LOADING_DONE
417 };
418
419 enum wl_management_type {
420 WL_BEACON = 0x1,
421 WL_PROBE_RESP = 0x2,
422 WL_ASSOC_RESP = 0x4
423 };
424
425 enum wl_pm_workq_act_type {
426 WL_PM_WORKQ_SHORT,
427 WL_PM_WORKQ_LONG,
428 WL_PM_WORKQ_DEL
429 };
430
431 enum wl_tdls_config {
432 TDLS_STATE_AP_CREATE,
433 TDLS_STATE_AP_DELETE,
434 TDLS_STATE_CONNECT,
435 TDLS_STATE_DISCONNECT,
436 TDLS_STATE_SETUP,
437 TDLS_STATE_TEARDOWN,
438 TDLS_STATE_IF_CREATE,
439 TDLS_STATE_IF_DELETE
440 };
441
442 /* beacon / probe_response */
443 struct beacon_proberesp {
444 __le64 timestamp;
445 __le16 beacon_int;
446 __le16 capab_info;
447 u8 variable[0];
448 } __attribute__ ((packed));
449
450 /* driver configuration */
451 struct wl_conf {
452 u32 frag_threshold;
453 u32 rts_threshold;
454 u32 retry_short;
455 u32 retry_long;
456 s32 tx_power;
457 struct ieee80211_channel channel;
458 };
459
460 typedef s32(*EVENT_HANDLER) (struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
461 const wl_event_msg_t *e, void *data);
462
463 /* bss inform structure for cfg80211 interface */
464 struct wl_cfg80211_bss_info {
465 u16 band;
466 u16 channel;
467 s16 rssi;
468 u16 frame_len;
469 u8 frame_buf[1];
470 };
471
472 /* basic structure of scan request */
473 struct wl_scan_req {
474 struct wlc_ssid ssid;
475 };
476
477 /* basic structure of information element */
478 struct wl_ie {
479 u16 offset;
480 u8 buf[WL_TLV_INFO_MAX];
481 };
482
483 /* event queue for cfg80211 main event */
484 struct wl_event_q {
485 struct list_head eq_list;
486 u32 etype;
487 wl_event_msg_t emsg;
488 s8 edata[1];
489 };
490
491 /* security information with currently associated ap */
492 struct wl_security {
493 u32 wpa_versions;
494 u32 auth_type;
495 u32 cipher_pairwise;
496 u32 cipher_group;
497 u32 wpa_auth;
498 u32 auth_assoc_res_status;
499 };
500
501 /* ibss information for currently joined ibss network */
502 struct wl_ibss {
503 u8 beacon_interval; /* in millisecond */
504 u8 atim; /* in millisecond */
505 s8 join_only;
506 u8 band;
507 u8 channel;
508 };
509
510 typedef struct wl_bss_vndr_ies {
511 u8 probe_req_ie[VNDR_IES_BUF_LEN];
512 u8 probe_res_ie[VNDR_IES_MAX_BUF_LEN];
513 u8 assoc_req_ie[VNDR_IES_BUF_LEN];
514 u8 assoc_res_ie[VNDR_IES_BUF_LEN];
515 u8 beacon_ie[VNDR_IES_MAX_BUF_LEN];
516 u32 probe_req_ie_len;
517 u32 probe_res_ie_len;
518 u32 assoc_req_ie_len;
519 u32 assoc_res_ie_len;
520 u32 beacon_ie_len;
521 } wl_bss_vndr_ies_t;
522
523 typedef struct wl_cfgbss {
524 u8 *wpa_ie;
525 u8 *rsn_ie;
526 u8 *wps_ie;
527 bool security_mode;
528 struct wl_bss_vndr_ies ies; /* Common for STA, P2P GC, GO, AP, P2P Disc Interface */
529 } wl_cfgbss_t;
530
531 /* cfg driver profile */
532 struct wl_profile {
533 u32 mode;
534 s32 band;
535 u32 channel;
536 struct wlc_ssid ssid;
537 struct wl_security sec;
538 struct wl_ibss ibss;
539 u8 bssid[ETHER_ADDR_LEN];
540 u16 beacon_interval;
541 u8 dtim_period;
542 bool active;
543 };
544
545 struct net_info {
546 struct net_device *ndev;
547 struct wireless_dev *wdev;
548 struct wl_profile profile;
549 s32 mode;
550 s32 roam_off;
551 unsigned long sme_state;
552 bool pm_restore;
553 bool pm_block;
554 s32 pm;
555 s32 bssidx;
556 wl_cfgbss_t bss;
557 u32 ulb_bw;
558 struct list_head list; /* list of all net_info structure */
559 };
560
561 /* association inform */
562 #define MAX_REQ_LINE 1024
563 struct wl_connect_info {
564 u8 req_ie[MAX_REQ_LINE];
565 s32 req_ie_len;
566 u8 resp_ie[MAX_REQ_LINE];
567 s32 resp_ie_len;
568 };
569
570 /* firmware /nvram downloading controller */
571 struct wl_fw_ctrl {
572 const struct firmware *fw_entry;
573 unsigned long status;
574 u32 ptr;
575 s8 fw_name[WL_FILE_NAME_MAX];
576 s8 nvram_name[WL_FILE_NAME_MAX];
577 };
578
579 /* assoc ie length */
580 struct wl_assoc_ielen {
581 u32 req_len;
582 u32 resp_len;
583 };
584
585 #define MIN_PMKID_LIST_V3_FW_MAJOR 13
586 #define MIN_PMKID_LIST_V3_FW_MINOR 0
587
588 #define MIN_PMKID_LIST_V2_FW_MAJOR 12
589 #define MIN_PMKID_LIST_V2_FW_MINOR 0
590
591 #define MIN_ESCAN_PARAM_V2_FW_MAJOR 14
592 #define MIN_ESCAN_PARAM_V2_FW_MINOR 0
593
594 /* wpa2 pmk list */
595 struct wl_pmk_list {
596 pmkid_list_v3_t pmkids;
597 pmkid_v3_t foo[MAXPMKID - 1];
598 };
599
600 #define KEY_PERM_PMK 0xFFFFFFFF
601
602 #ifdef DHD_MAX_IFS
603 #define WL_MAX_IFS DHD_MAX_IFS
604 #else
605 #define WL_MAX_IFS 16
606 #endif
607
608 #define ESCAN_BUF_SIZE (64 * 1024)
609
610 struct escan_info {
611 u32 escan_state;
612 #ifdef STATIC_WL_PRIV_STRUCT
613 #ifndef CONFIG_DHD_USE_STATIC_BUF
614 #error STATIC_WL_PRIV_STRUCT should be used with CONFIG_DHD_USE_STATIC_BUF
615 #endif /* CONFIG_DHD_USE_STATIC_BUF */
616 u8 *escan_buf;
617 #else
618 u8 escan_buf[ESCAN_BUF_SIZE];
619 #endif /* STATIC_WL_PRIV_STRUCT */
620 struct wiphy *wiphy;
621 struct net_device *ndev;
622 };
623
624 #ifdef ESCAN_BUF_OVERFLOW_MGMT
625 #define BUF_OVERFLOW_MGMT_COUNT 3
626 typedef struct {
627 int RSSI;
628 int length;
629 struct ether_addr BSSID;
630 } removal_element_t;
631 #endif /* ESCAN_BUF_OVERFLOW_MGMT */
632
633 struct afx_hdl {
634 wl_af_params_t *pending_tx_act_frm;
635 struct ether_addr tx_dst_addr;
636 struct net_device *dev;
637 struct work_struct work;
638 s32 bssidx;
639 u32 retry;
640 s32 peer_chan;
641 s32 peer_listen_chan; /* search channel: configured by upper layer */
642 s32 my_listen_chan; /* listen chanel: extract it from prb req or gon req */
643 bool is_listen;
644 bool ack_recv;
645 bool is_active;
646 };
647
648 struct parsed_ies {
649 wpa_ie_fixed_t *wps_ie;
650 u32 wps_ie_len;
651 wpa_ie_fixed_t *wpa_ie;
652 u32 wpa_ie_len;
653 bcm_tlv_t *wpa2_ie;
654 u32 wpa2_ie_len;
655 };
656
657
658 #ifdef P2P_LISTEN_OFFLOADING
659 typedef struct {
660 uint16 period; /* listen offload period */
661 uint16 interval; /* listen offload interval */
662 uint16 count; /* listen offload count */
663 uint16 pad; /* pad for 32bit align */
664 } wl_p2plo_listen_t;
665 #endif /* P2P_LISTEN_OFFLOADING */
666
667 #ifdef WL11U
668 /* Max length of Interworking element */
669 #define IW_IES_MAX_BUF_LEN 9
670 #endif
671 #ifdef WLFBT
672 #define FBT_KEYLEN 32
673 #endif
674 #define MAX_EVENT_BUF_NUM 16
675 typedef struct wl_eventmsg_buf {
676 u16 num;
677 struct {
678 u16 type;
679 bool set;
680 } event [MAX_EVENT_BUF_NUM];
681 } wl_eventmsg_buf_t;
682
683 typedef struct wl_if_event_info {
684 bool valid;
685 int ifidx;
686 int bssidx;
687 uint8 mac[ETHER_ADDR_LEN];
688 char name[IFNAMSIZ+1];
689 uint8 role;
690 } wl_if_event_info;
691
692
693 #ifdef SUPPORT_AP_RADIO_PWRSAVE
694 typedef struct ap_rps_info {
695 bool enable;
696 bool sta_assoc_check;
697 int pps;
698 int quiet_time;
699 int level;
700 } ap_rps_info_t;
701 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
702
703 #ifdef SUPPORT_RSSI_LOGGING
704 #define RSSILOG_FLAG_FEATURE_SW 0x1
705 #define RSSILOG_FLAG_REPORT_READY 0x2
706 typedef struct rssilog_set_param {
707 uint8 enable;
708 uint8 rssi_threshold;
709 uint8 time_threshold;
710 uint8 pad;
711 } rssilog_set_param_t;
712
713 typedef struct rssilog_get_param {
714 uint8 report_count;
715 uint8 enable;
716 uint8 rssi_threshold;
717 uint8 time_threshold;
718 } rssilog_get_param_t;
719
720 typedef struct rssi_ant_param {
721 struct ether_addr ea;
722 chanspec_t chanspec;
723 } rssi_ant_param_t;
724
725 typedef struct wl_rssi_ant_mimo {
726 uint32 version;
727 uint32 count;
728 int8 rssi_ant[WL_RSSI_ANT_MAX];
729 int8 rssi_sum;
730 int8 PAD[3];
731 } wl_rssi_ant_mimo_t;
732 #endif /* SUPPORT_RSSI_LOGGING */
733
734 #if defined(DHD_ENABLE_BIGDATA_LOGGING)
735 #define GET_BSS_INFO_LEN 90
736 #endif /* DHD_ENABLE_BIGDATA_LOGGING */
737
738
739 /* private data of cfg80211 interface */
740 struct bcm_cfg80211 {
741 struct wireless_dev *wdev; /* representing cfg cfg80211 device */
742
743 struct wireless_dev *p2p_wdev; /* representing cfg cfg80211 device for P2P */
744 struct net_device *p2p_net; /* reference to p2p0 interface */
745
746 struct wl_conf *conf;
747 struct cfg80211_scan_request *scan_request; /* scan request object */
748 EVENT_HANDLER evt_handler[WLC_E_LAST];
749 struct list_head eq_list; /* used for event queue */
750 struct list_head net_list; /* used for struct net_info */
751 spinlock_t net_list_sync; /* to protect scan status (and others if needed) */
752 spinlock_t eq_lock; /* for event queue synchronization */
753 spinlock_t cfgdrv_lock; /* to protect scan status (and others if needed) */
754 struct completion act_frm_scan;
755 struct completion iface_disable;
756 struct completion wait_next_af;
757 struct mutex usr_sync; /* maily for up/down synchronization */
758 struct mutex if_sync; /* maily for iface op synchronization */
759 struct mutex scan_complete; /* serialize scan_complete call */
760 struct wl_scan_results *bss_list;
761 struct wl_scan_results *scan_results;
762
763 /* scan request object for internal purpose */
764 struct wl_scan_req *scan_req_int;
765 /* information element object for internal purpose */
766 #if defined(STATIC_WL_PRIV_STRUCT)
767 struct wl_ie *ie;
768 #else
769 struct wl_ie ie;
770 #endif
771
772 /* association information container */
773 #if defined(STATIC_WL_PRIV_STRUCT)
774 struct wl_connect_info *conn_info;
775 #else
776 struct wl_connect_info conn_info;
777 #endif
778 #ifdef DEBUGFS_CFG80211
779 struct dentry *debugfs;
780 #endif /* DEBUGFS_CFG80211 */
781 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
782 tsk_ctl_t event_tsk; /* task of main event handler thread */
783 dhd_pub_t *pub;
784 u32 iface_cnt;
785 u32 channel; /* current channel */
786 u32 af_sent_channel; /* channel action frame is sent */
787 /* next af subtype to cancel the remained dwell time in rx process */
788 u8 next_af_subtype;
789 #ifdef WL_CFG80211_SYNC_GON
790 ulong af_tx_sent_jiffies;
791 #endif /* WL_CFG80211_SYNC_GON */
792 struct escan_info escan_info; /* escan information */
793 bool active_scan; /* current scan mode */
794 bool ibss_starter; /* indicates this sta is ibss starter */
795 bool link_up; /* link/connection up flag */
796
797 /* indicate whether chip to support power save mode */
798 bool pwr_save;
799 bool roam_on; /* on/off switch for self-roaming */
800 bool scan_tried; /* indicates if first scan attempted */
801 #if defined(BCMSDIO) || defined(BCMDBUS)
802 bool wlfc_on;
803 #endif
804 bool vsdb_mode;
805 #define WL_ROAM_OFF_ON_CONCURRENT 0x0001
806 #define WL_ROAM_REVERT_STATUS 0x0002
807 u32 roam_flags;
808 u8 *ioctl_buf; /* ioctl buffer */
809 struct mutex ioctl_buf_sync;
810 u8 *escan_ioctl_buf;
811 u8 *extra_buf; /* maily to grab assoc information */
812 struct dentry *debugfsdir;
813 struct rfkill *rfkill;
814 bool rf_blocked;
815 struct ieee80211_channel remain_on_chan;
816 enum nl80211_channel_type remain_on_chan_type;
817 u64 send_action_id;
818 u64 last_roc_id;
819 wait_queue_head_t netif_change_event;
820 wl_if_event_info if_event_info;
821 struct completion send_af_done;
822 struct afx_hdl *afx_hdl;
823 struct p2p_info *p2p;
824 bool p2p_supported;
825 void *btcoex_info;
826 timer_list_compat_t scan_timeout; /* Timer for catch scan event timeout */
827 #if defined(P2P_IE_MISSING_FIX)
828 bool p2p_prb_noti;
829 #endif
830 s32(*state_notifier) (struct bcm_cfg80211 *cfg,
831 struct net_info *_net_info, enum wl_status state, bool set);
832 unsigned long interrested_state;
833 wlc_ssid_t hostapd_ssid;
834 #ifdef WL11U
835 bool wl11u;
836 #endif /* WL11U */
837 bool sched_scan_running; /* scheduled scan req status */
838 struct cfg80211_sched_scan_request *sched_scan_req; /* scheduled scan req */
839 bool scan_suppressed;
840 timer_list_compat_t scan_supp_timer;
841 struct work_struct wlan_work;
842 struct mutex event_sync; /* maily for up/down synchronization */
843 bool disable_roam_event;
844 struct delayed_work pm_enable_work;
845 struct workqueue_struct *event_workq; /* workqueue for event */
846 struct work_struct event_work; /* work item for event */
847 struct mutex pm_sync; /* mainly for pm work synchronization */
848
849 vndr_ie_setbuf_t *ibss_vsie; /* keep the VSIE for IBSS */
850 int ibss_vsie_len;
851 #ifdef WL_RELMCAST
852 u32 rmc_event_pid;
853 u32 rmc_event_seq;
854 #endif /* WL_RELMCAST */
855 #ifdef WLAIBSS_MCHAN
856 struct ether_addr ibss_if_addr;
857 bcm_struct_cfgdev *ibss_cfgdev; /* For AIBSS */
858 #endif /* WLAIBSS_MCHAN */
859 bool bss_pending_op; /* indicate where there is a pending IF operation */
860 #ifdef WLFBT
861 uint8 fbt_key[FBT_KEYLEN];
862 #endif
863 int roam_offload;
864 #ifdef WL_CFG80211_P2P_DEV_IF
865 bool down_disc_if;
866 #endif /* WL_CFG80211_P2P_DEV_IF */
867 #ifdef P2PLISTEN_AP_SAMECHN
868 bool p2p_resp_apchn_status;
869 #endif /* P2PLISTEN_AP_SAMECHN */
870 struct wl_wsec_key wep_key;
871 #ifdef WLTDLS
872 u8 *tdls_mgmt_frame;
873 u32 tdls_mgmt_frame_len;
874 s32 tdls_mgmt_freq;
875 #endif /* WLTDLS */
876 bool need_wait_afrx;
877 #ifdef QOS_MAP_SET
878 uint8 *up_table; /* user priority table, size is UP_TABLE_MAX */
879 #endif /* QOS_MAP_SET */
880 struct ether_addr last_roamed_addr;
881 bool rcc_enabled; /* flag for Roam channel cache feature */
882 #if defined(DHD_ENABLE_BIGDATA_LOGGING)
883 char bss_info[GET_BSS_INFO_LEN];
884 wl_event_msg_t event_auth_assoc;
885 u32 assoc_reject_status;
886 u32 roam_count;
887 #endif /* DHD_ENABLE_BIGDATA_LOGGING */
888 u16 ap_oper_channel;
889 #if defined(SUPPORT_RANDOM_MAC_SCAN)
890 bool random_mac_enabled;
891 #endif /* SUPPORT_RANDOM_MAC_SCAN */
892 #ifdef DHD_LOSSLESS_ROAMING
893 timer_list_compat_t roam_timeout; /* Timer for catch roam timeout */
894 #endif
895 uint16 escan_sync_id_cntr;
896 #ifdef WLTDLS
897 uint8 tdls_supported;
898 struct mutex tdls_sync; /* protect tdls config operations */
899 #endif /* WLTDLS */
900 #ifdef MFP
901 uint8 *bip_pos;
902 int mfp_mode;
903 #endif /* MFP */
904 #ifdef SUPPORT_AP_RADIO_PWRSAVE
905 ap_rps_info_t ap_rps_info;
906 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
907 osl_t *osh;
908 #ifdef WBTEXT
909 struct list_head wbtext_bssid_list;
910 #endif /* WBTEXT */
911 struct list_head vndr_oui_list;
912
913 #ifdef STAT_REPORT
914 void *stat_report_info;
915 #endif
916 wl_wlc_version_t wlc_ver;
917 bool scan_params_v2;
918 #ifdef WLMESH_CFG80211
919 char sae_password[SAE_MAX_PASSWD_LEN];
920 uint sae_password_len;
921 #endif /* WLMESH_CFG80211 */
922 #if defined(RSSIAVG)
923 wl_rssi_cache_ctrl_t g_rssi_cache_ctrl;
924 wl_rssi_cache_ctrl_t g_connected_rssi_cache_ctrl;
925 #endif
926 #if defined(BSSCACHE)
927 wl_bss_cache_ctrl_t g_bss_cache_ctrl;
928 #endif
929 int p2p_disconnected; // terence 20130703: Fix for wrong group_capab (timing issue)
930 struct ether_addr disconnected_bssid;
931 int autochannel;
932 int best_2g_ch;
933 int best_5g_ch;
934 uint handshaking;
935 int btc_mode;
936 bool wps_done;
937 wait_queue_head_t wps_done_event;
938 struct mutex in4way_sync;
939 ulong disconnected_jiffies;
940 };
941
942 #ifdef WL_SAE
943 typedef struct wl_sae_key_info {
944 uint8 peer_mac[ETHER_ADDR_LEN];
945 uint16 pmk_len;
946 uint16 pmkid_len;
947 const uint8 *pmk;
948 const uint8 *pmkid;
949 } wl_sae_key_info_t;
950 #endif /* WL_SAE */
951
952 #if defined(STRICT_GCC_WARNINGS) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == \
953 4 && __GNUC_MINOR__ >= 6))
954 #define GCC_DIAGNOSTIC_PUSH() \
955 _Pragma("GCC diagnostic push") \
956 _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
957 #define GCC_DIAGNOSTIC_POP() \
958 _Pragma("GCC diagnostic pop")
959 #else
960 #define GCC_DIAGNOSTIC_PUSH()
961 #define GCC_DIAGNOSTIC_POP()
962 #endif /* STRICT_GCC_WARNINGS */
963
964 #define BCM_LIST_FOR_EACH_ENTRY_SAFE(pos, next, head, member) \
965 list_for_each_entry_safe((pos), (next), (head), member)
966 extern int ioctl_version;
967
next_bss(struct wl_scan_results * list,struct wl_bss_info * bss)968 static inline struct wl_bss_info *next_bss(struct wl_scan_results *list, struct wl_bss_info *bss)
969 {
970 return bss = bss ?
971 (struct wl_bss_info *)((uintptr) bss + dtoh32(bss->length)) : list->bss_info;
972 }
973
974 static inline void
wl_probe_wdev_all(struct bcm_cfg80211 * cfg)975 wl_probe_wdev_all(struct bcm_cfg80211 *cfg)
976 {
977 struct net_info *_net_info, *next;
978 unsigned long int flags;
979 int idx = 0;
980 spin_lock_irqsave(&cfg->net_list_sync, flags);
981 GCC_DIAGNOSTIC_PUSH();
982 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next,
983 &cfg->net_list, list) {
984 WL_ERR(("%s: net_list[%d] bssidx: %d, "
985 "ndev: %p, wdev: %p \n", __FUNCTION__,
986 idx++, _net_info->bssidx,
987 _net_info->ndev, _net_info->wdev));
988 }
989 GCC_DIAGNOSTIC_POP();
990 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
991 return;
992 }
993
994 static inline struct net_info *
wl_get_netinfo_by_bssidx(struct bcm_cfg80211 * cfg,s32 bssidx)995 wl_get_netinfo_by_bssidx(struct bcm_cfg80211 *cfg, s32 bssidx)
996 {
997 struct net_info *_net_info, *next, *info = NULL;
998 unsigned long int flags;
999
1000 spin_lock_irqsave(&cfg->net_list_sync, flags);
1001 GCC_DIAGNOSTIC_PUSH();
1002 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1003 if ((bssidx >= 0) && (_net_info->bssidx == bssidx)) {
1004 info = _net_info;
1005 break;
1006 }
1007 }
1008 GCC_DIAGNOSTIC_POP();
1009 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1010 return info;
1011 }
1012
1013 static inline void
wl_dealloc_netinfo_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1014 wl_dealloc_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1015 {
1016 struct net_info *_net_info, *next;
1017 unsigned long int flags;
1018
1019 #ifdef DHD_IFDEBUG
1020 WL_ERR(("dealloc_netinfo enter wdev=%p \n", wdev));
1021 #endif
1022 spin_lock_irqsave(&cfg->net_list_sync, flags);
1023 GCC_DIAGNOSTIC_PUSH();
1024 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1025 if (wdev && (_net_info->wdev == wdev)) {
1026 wl_cfgbss_t *bss = &_net_info->bss;
1027
1028 kfree(bss->wpa_ie);
1029 bss->wpa_ie = NULL;
1030 kfree(bss->rsn_ie);
1031 bss->rsn_ie = NULL;
1032 kfree(bss->wps_ie);
1033 bss->wps_ie = NULL;
1034 list_del(&_net_info->list);
1035 cfg->iface_cnt--;
1036 kfree(_net_info);
1037 }
1038 }
1039 GCC_DIAGNOSTIC_POP();
1040 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1041 #ifdef DHD_IFDEBUG
1042 WL_ERR(("dealloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
1043 #endif
1044 }
1045
1046 static inline s32
wl_alloc_netinfo(struct bcm_cfg80211 * cfg,struct net_device * ndev,struct wireless_dev * wdev,s32 mode,bool pm_block,u8 bssidx)1047 wl_alloc_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev,
1048 struct wireless_dev * wdev, s32 mode, bool pm_block, u8 bssidx)
1049 {
1050 struct net_info *_net_info;
1051 s32 err = 0;
1052 unsigned long int flags;
1053 #ifdef DHD_IFDEBUG
1054 WL_ERR(("alloc_netinfo enter bssidx=%d wdev=%p ndev=%p\n", bssidx, wdev, ndev));
1055 #endif
1056 /* Check whether there is any duplicate entry for the
1057 * same bssidx *
1058 */
1059 if ((_net_info = wl_get_netinfo_by_bssidx(cfg, bssidx))) {
1060 /* We have a duplicate entry for the same bssidx
1061 * already present which shouldn't have been the case.
1062 * Attempt recovery.
1063 */
1064 WL_ERR(("Duplicate entry for bssidx=%d present\n", bssidx));
1065 wl_probe_wdev_all(cfg);
1066 #ifdef DHD_DEBUG
1067 ASSERT(0);
1068 #endif /* DHD_DEBUG */
1069 WL_ERR(("Removing the Dup entry for bssidx=%d \n", bssidx));
1070 wl_dealloc_netinfo_by_wdev(cfg, _net_info->wdev);
1071 }
1072 if (cfg->iface_cnt == IFACE_MAX_CNT)
1073 return -ENOMEM;
1074 _net_info = kzalloc(sizeof(struct net_info), GFP_KERNEL);
1075 if (!_net_info)
1076 err = -ENOMEM;
1077 else {
1078 _net_info->mode = mode;
1079 _net_info->ndev = ndev;
1080 _net_info->wdev = wdev;
1081 _net_info->pm_restore = 0;
1082 _net_info->pm = 0;
1083 _net_info->pm_block = pm_block;
1084 _net_info->roam_off = WL_INVALID;
1085 _net_info->bssidx = bssidx;
1086 spin_lock_irqsave(&cfg->net_list_sync, flags);
1087 cfg->iface_cnt++;
1088 list_add(&_net_info->list, &cfg->net_list);
1089 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1090 }
1091 #ifdef DHD_IFDEBUG
1092 WL_ERR(("alloc_netinfo exit iface_cnt=%d \n", cfg->iface_cnt));
1093 #endif
1094 return err;
1095 }
1096
1097 static inline void
wl_delete_all_netinfo(struct bcm_cfg80211 * cfg)1098 wl_delete_all_netinfo(struct bcm_cfg80211 *cfg)
1099 {
1100 struct net_info *_net_info, *next;
1101 unsigned long int flags;
1102
1103 spin_lock_irqsave(&cfg->net_list_sync, flags);
1104 GCC_DIAGNOSTIC_PUSH();
1105 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1106 wl_cfgbss_t *bss = &_net_info->bss;
1107
1108 kfree(bss->wpa_ie);
1109 bss->wpa_ie = NULL;
1110 kfree(bss->rsn_ie);
1111 bss->rsn_ie = NULL;
1112 kfree(bss->wps_ie);
1113 bss->wps_ie = NULL;
1114 list_del(&_net_info->list);
1115 if (_net_info->wdev)
1116 kfree(_net_info->wdev);
1117 kfree(_net_info);
1118 }
1119 cfg->iface_cnt = 0;
1120 GCC_DIAGNOSTIC_POP();
1121 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1122 }
1123 static inline u32
wl_get_status_all(struct bcm_cfg80211 * cfg,s32 status)1124 wl_get_status_all(struct bcm_cfg80211 *cfg, s32 status)
1125
1126 {
1127 struct net_info *_net_info, *next;
1128 u32 cnt = 0;
1129 unsigned long int flags;
1130
1131 spin_lock_irqsave(&cfg->net_list_sync, flags);
1132 GCC_DIAGNOSTIC_PUSH();
1133 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1134 if (_net_info->ndev &&
1135 test_bit(status, &_net_info->sme_state))
1136 cnt++;
1137 }
1138 GCC_DIAGNOSTIC_POP();
1139 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1140 return cnt;
1141 }
1142 static inline void
wl_set_status_all(struct bcm_cfg80211 * cfg,s32 status,u32 op)1143 wl_set_status_all(struct bcm_cfg80211 *cfg, s32 status, u32 op)
1144 {
1145 struct net_info *_net_info, *next;
1146 unsigned long int flags;
1147
1148 spin_lock_irqsave(&cfg->net_list_sync, flags);
1149 GCC_DIAGNOSTIC_PUSH();
1150 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1151 switch (op) {
1152 case 1:
1153 break; /* set all status is not allowed */
1154 case 2:
1155 /*
1156 * Release the spinlock before calling notifier. Else there
1157 * will be nested calls
1158 */
1159 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1160 clear_bit(status, &_net_info->sme_state);
1161 if (cfg->state_notifier &&
1162 test_bit(status, &(cfg->interrested_state)))
1163 cfg->state_notifier(cfg, _net_info, status, false);
1164 return;
1165 case 4:
1166 break; /* change all status is not allowed */
1167 default:
1168 break; /* unknown operation */
1169 }
1170 }
1171 GCC_DIAGNOSTIC_POP();
1172 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1173 }
1174 static inline void
wl_set_status_by_netdev(struct bcm_cfg80211 * cfg,s32 status,struct net_device * ndev,u32 op)1175 wl_set_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
1176 struct net_device *ndev, u32 op)
1177 {
1178
1179 struct net_info *_net_info, *next;
1180 unsigned long int flags;
1181
1182 spin_lock_irqsave(&cfg->net_list_sync, flags);
1183 GCC_DIAGNOSTIC_PUSH();
1184 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1185 if (ndev && (_net_info->ndev == ndev)) {
1186 switch (op) {
1187 case 1:
1188 /*
1189 * Release the spinlock before calling notifier. Else there
1190 * will be nested calls
1191 */
1192 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1193 set_bit(status, &_net_info->sme_state);
1194 if (cfg->state_notifier &&
1195 test_bit(status, &(cfg->interrested_state)))
1196 cfg->state_notifier(cfg, _net_info, status, true);
1197 return;
1198 case 2:
1199 /*
1200 * Release the spinlock before calling notifier. Else there
1201 * will be nested calls
1202 */
1203 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1204 clear_bit(status, &_net_info->sme_state);
1205 if (cfg->state_notifier &&
1206 test_bit(status, &(cfg->interrested_state)))
1207 cfg->state_notifier(cfg, _net_info, status, false);
1208 return;
1209 case 4:
1210 change_bit(status, &_net_info->sme_state);
1211 break;
1212 }
1213 }
1214
1215 }
1216 GCC_DIAGNOSTIC_POP();
1217 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1218
1219 }
1220
1221 static inline wl_cfgbss_t *
wl_get_cfgbss_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1222 wl_get_cfgbss_by_wdev(struct bcm_cfg80211 *cfg,
1223 struct wireless_dev *wdev)
1224 {
1225 struct net_info *_net_info, *next;
1226 wl_cfgbss_t *bss = NULL;
1227 unsigned long int flags;
1228
1229 spin_lock_irqsave(&cfg->net_list_sync, flags);
1230 GCC_DIAGNOSTIC_PUSH();
1231 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1232 if (wdev && (_net_info->wdev == wdev)) {
1233 bss = &_net_info->bss;
1234 break;
1235 }
1236 }
1237 GCC_DIAGNOSTIC_POP();
1238
1239 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1240 return bss;
1241 }
1242
1243 static inline u32
wl_get_status_by_netdev(struct bcm_cfg80211 * cfg,s32 status,struct net_device * ndev)1244 wl_get_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
1245 struct net_device *ndev)
1246 {
1247 struct net_info *_net_info, *next;
1248 u32 stat = 0;
1249 unsigned long int flags;
1250
1251 spin_lock_irqsave(&cfg->net_list_sync, flags);
1252 GCC_DIAGNOSTIC_PUSH();
1253 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1254 if (ndev && (_net_info->ndev == ndev)) {
1255 stat = test_bit(status, &_net_info->sme_state);
1256 break;
1257 }
1258 }
1259 GCC_DIAGNOSTIC_POP();
1260 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1261 return stat;
1262 }
1263
1264 static inline s32
wl_get_mode_by_netdev(struct bcm_cfg80211 * cfg,struct net_device * ndev)1265 wl_get_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1266 {
1267 struct net_info *_net_info, *next;
1268 s32 mode = -1;
1269 unsigned long int flags;
1270
1271 spin_lock_irqsave(&cfg->net_list_sync, flags);
1272 GCC_DIAGNOSTIC_PUSH();
1273 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1274 if (ndev && (_net_info->ndev == ndev)) {
1275 mode = _net_info->mode;
1276 break;
1277 }
1278 }
1279 GCC_DIAGNOSTIC_POP();
1280 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1281 return mode;
1282 }
1283
1284 static inline void
wl_set_mode_by_netdev(struct bcm_cfg80211 * cfg,struct net_device * ndev,s32 mode)1285 wl_set_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev,
1286 s32 mode)
1287 {
1288 struct net_info *_net_info, *next;
1289 unsigned long int flags;
1290
1291 spin_lock_irqsave(&cfg->net_list_sync, flags);
1292 GCC_DIAGNOSTIC_PUSH();
1293 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1294 if (ndev && (_net_info->ndev == ndev))
1295 _net_info->mode = mode;
1296 }
1297 GCC_DIAGNOSTIC_POP();
1298 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1299 }
1300
1301 static inline s32
wl_get_bssidx_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1302 wl_get_bssidx_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1303 {
1304 struct net_info *_net_info, *next;
1305 s32 bssidx = -1;
1306 unsigned long int flags;
1307
1308 spin_lock_irqsave(&cfg->net_list_sync, flags);
1309 GCC_DIAGNOSTIC_PUSH();
1310 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1311 if (_net_info->wdev && (_net_info->wdev == wdev)) {
1312 bssidx = _net_info->bssidx;
1313 break;
1314 }
1315 }
1316 GCC_DIAGNOSTIC_POP();
1317 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1318 return bssidx;
1319 }
1320
1321 static inline struct wireless_dev *
wl_get_wdev_by_bssidx(struct bcm_cfg80211 * cfg,s32 bssidx)1322 wl_get_wdev_by_bssidx(struct bcm_cfg80211 *cfg, s32 bssidx)
1323 {
1324 struct net_info *_net_info, *next;
1325 struct wireless_dev *wdev = NULL;
1326 unsigned long int flags;
1327
1328 if (bssidx < 0)
1329 return NULL;
1330 spin_lock_irqsave(&cfg->net_list_sync, flags);
1331 GCC_DIAGNOSTIC_PUSH();
1332 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1333 if (_net_info->bssidx == bssidx) {
1334 wdev = _net_info->wdev;
1335 break;
1336 }
1337 }
1338 GCC_DIAGNOSTIC_POP();
1339 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1340 return wdev;
1341 }
1342
1343 static inline struct wl_profile *
wl_get_profile_by_netdev(struct bcm_cfg80211 * cfg,struct net_device * ndev)1344 wl_get_profile_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1345 {
1346 struct net_info *_net_info, *next;
1347 struct wl_profile *prof = NULL;
1348 unsigned long int flags;
1349
1350 spin_lock_irqsave(&cfg->net_list_sync, flags);
1351 GCC_DIAGNOSTIC_PUSH();
1352 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1353 if (ndev && (_net_info->ndev == ndev)) {
1354 prof = &_net_info->profile;
1355 break;
1356 }
1357 }
1358 GCC_DIAGNOSTIC_POP();
1359 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1360 return prof;
1361 }
1362 static inline struct net_info *
wl_get_netinfo_by_netdev(struct bcm_cfg80211 * cfg,struct net_device * ndev)1363 wl_get_netinfo_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
1364 {
1365 struct net_info *_net_info, *next, *info = NULL;
1366 unsigned long int flags;
1367
1368 spin_lock_irqsave(&cfg->net_list_sync, flags);
1369 GCC_DIAGNOSTIC_PUSH();
1370 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1371 if (ndev && (_net_info->ndev == ndev)) {
1372 info = _net_info;
1373 break;
1374 }
1375 }
1376 GCC_DIAGNOSTIC_POP();
1377 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1378 return info;
1379 }
1380
1381 static inline struct net_info *
wl_get_netinfo_by_wdev(struct bcm_cfg80211 * cfg,struct wireless_dev * wdev)1382 wl_get_netinfo_by_wdev(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev)
1383 {
1384 struct net_info *_net_info, *next, *info = NULL;
1385 unsigned long int flags;
1386
1387 spin_lock_irqsave(&cfg->net_list_sync, flags);
1388 GCC_DIAGNOSTIC_PUSH();
1389 BCM_LIST_FOR_EACH_ENTRY_SAFE(_net_info, next, &cfg->net_list, list) {
1390 if (wdev && (_net_info->wdev == wdev)) {
1391 info = _net_info;
1392 break;
1393 }
1394 }
1395 GCC_DIAGNOSTIC_POP();
1396 spin_unlock_irqrestore(&cfg->net_list_sync, flags);
1397 return info;
1398 }
1399
1400 #define is_p2p_group_iface(wdev) (((wdev->iftype == NL80211_IFTYPE_P2P_GO) || \
1401 (wdev->iftype == NL80211_IFTYPE_P2P_CLIENT)) ? 1 : 0)
1402 #define bcmcfg_to_wiphy(cfg) (cfg->wdev->wiphy)
1403 #define bcmcfg_to_prmry_ndev(cfg) (cfg->wdev->netdev)
1404 #define bcmcfg_to_prmry_wdev(cfg) (cfg->wdev)
1405 #define bcmcfg_to_p2p_wdev(cfg) (cfg->p2p_wdev)
1406 #define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
1407 #define ndev_to_wdev(ndev) (ndev->ieee80211_ptr)
1408 #define wdev_to_ndev(wdev) (wdev->netdev)
1409
1410 #if defined(WL_ENABLE_P2P_IF)
1411 #define ndev_to_wlc_ndev(ndev, cfg) ((ndev == cfg->p2p_net) ? \
1412 bcmcfg_to_prmry_ndev(cfg) : ndev)
1413 #else
1414 #define ndev_to_wlc_ndev(ndev, cfg) (ndev)
1415 #endif /* WL_ENABLE_P2P_IF */
1416
1417 #define wdev_to_wlc_ndev(wdev, cfg) \
1418 (wdev_to_ndev(wdev) ? \
1419 wdev_to_ndev(wdev) : bcmcfg_to_prmry_ndev(cfg))
1420 #if defined(WL_CFG80211_P2P_DEV_IF)
1421 #define cfgdev_to_wlc_ndev(cfgdev, cfg) wdev_to_wlc_ndev(cfgdev, cfg)
1422 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_wdev(cfg)
1423 #elif defined(WL_ENABLE_P2P_IF)
1424 #define cfgdev_to_wlc_ndev(cfgdev, cfg) ndev_to_wlc_ndev(cfgdev, cfg)
1425 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_ndev(cfg)
1426 #else
1427 #define cfgdev_to_wlc_ndev(cfgdev, cfg) (cfgdev)
1428 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) (cfgdev)
1429 #endif /* WL_CFG80211_P2P_DEV_IF */
1430
1431 #if defined(WL_CFG80211_P2P_DEV_IF)
1432 #define cfgdev_to_wdev(cfgdev) (cfgdev)
1433 #define ndev_to_cfgdev(ndev) ndev_to_wdev(ndev)
1434 #define cfgdev_to_ndev(cfgdev) (cfgdev ? (cfgdev->netdev) : NULL)
1435 #define wdev_to_cfgdev(cfgdev) (cfgdev)
1436 #define discover_cfgdev(cfgdev, cfg) (cfgdev->iftype == NL80211_IFTYPE_P2P_DEVICE)
1437 #else
1438 #define cfgdev_to_wdev(cfgdev) (cfgdev->ieee80211_ptr)
1439 #define wdev_to_cfgdev(cfgdev) cfgdev ? (cfgdev->netdev) : NULL
1440 #define ndev_to_cfgdev(ndev) (ndev)
1441 #define cfgdev_to_ndev(cfgdev) (cfgdev)
1442 #define discover_cfgdev(cfgdev, cfg) (cfgdev == cfg->p2p_net)
1443 #endif /* WL_CFG80211_P2P_DEV_IF */
1444
1445 #if defined(WL_CFG80211_P2P_DEV_IF)
1446 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
1447 (cfg->scan_request->wdev == cfg->p2p_wdev)) ? true : false)
1448 #elif defined(WL_ENABLE_P2P_IF)
1449 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
1450 (cfg->scan_request->dev == cfg->p2p_net)) ? true : false)
1451 #else
1452 #define scan_req_match(cfg) (((cfg) && p2p_is_on(cfg) && p2p_scan(cfg)) ? \
1453 true : false)
1454 #endif /* WL_CFG80211_P2P_DEV_IF */
1455
1456 #define PRINT_WDEV_INFO(cfgdev) \
1457 { \
1458 struct wireless_dev *wdev = cfgdev_to_wdev(cfgdev); \
1459 struct net_device *netdev = wdev ? wdev->netdev : NULL; \
1460 WL_DBG(("wdev_ptr:%p ndev_ptr:%p ifname:%s iftype:%d\n", wdev, netdev, \
1461 netdev ? netdev->name : "NULL (non-ndev device)", \
1462 wdev ? wdev->iftype : 0xff)); \
1463 }
1464
1465 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
1466 #define scan_req_iftype(req) (req->dev->ieee80211_ptr->iftype)
1467 #else
1468 #define scan_req_iftype(req) (req->wdev->iftype)
1469 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) */
1470
1471 #define wl_to_sr(w) (w->scan_req_int)
1472 #if defined(STATIC_WL_PRIV_STRUCT)
1473 #define wl_to_ie(w) (w->ie)
1474 #define wl_to_conn(w) (w->conn_info)
1475 #else
1476 #define wl_to_ie(w) (&w->ie)
1477 #define wl_to_conn(w) (&w->conn_info)
1478 #endif
1479 #define wiphy_from_scan(w) (w->escan_info.wiphy)
1480 #define wl_get_drv_status_all(cfg, stat) \
1481 (wl_get_status_all(cfg, WL_STATUS_ ## stat))
1482 #define wl_get_drv_status(cfg, stat, ndev) \
1483 (wl_get_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev))
1484 #define wl_set_drv_status(cfg, stat, ndev) \
1485 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 1))
1486 #define wl_clr_drv_status(cfg, stat, ndev) \
1487 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 2))
1488 #define wl_clr_drv_status_all(cfg, stat) \
1489 (wl_set_status_all(cfg, WL_STATUS_ ## stat, 2))
1490 #define wl_chg_drv_status(cfg, stat, ndev) \
1491 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 4))
1492
1493 #define for_each_bss(list, bss, __i) \
1494 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
1495
1496 #define for_each_ndev(cfg, iter, next) \
1497 list_for_each_entry_safe(iter, next, &cfg->net_list, list)
1498
1499 /* In case of WPS from wpa_supplicant, pairwise siute and group suite is 0.
1500 * In addtion to that, wpa_version is WPA_VERSION_1
1501 */
1502 #define is_wps_conn(_sme) \
1503 ((wl_cfgp2p_find_wpsie((u8 *)_sme->ie, _sme->ie_len) != NULL) && \
1504 (!_sme->crypto.n_ciphers_pairwise) && \
1505 (!_sme->crypto.cipher_group))
1506
1507 #ifdef WLFBT
1508 #if defined(WLAN_AKM_SUITE_FT_8021X) && defined(WLAN_AKM_SUITE_FT_PSK)
1509 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X || \
1510 sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
1511 #elif defined(WLAN_AKM_SUITE_FT_8021X)
1512 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_8021X)
1513 #elif defined(WLAN_AKM_SUITE_FT_PSK)
1514 #define IS_AKM_SUITE_FT(sec) (sec->wpa_auth == WLAN_AKM_SUITE_FT_PSK)
1515 #else
1516 #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
1517 #endif /* WLAN_AKM_SUITE_FT_8021X && WLAN_AKM_SUITE_FT_PSK */
1518 #else
1519 #define IS_AKM_SUITE_FT(sec) ({BCM_REFERENCE(sec); FALSE;})
1520 #endif /* WLFBT */
1521
1522 #define IS_AKM_SUITE_CCKM(sec) ({BCM_REFERENCE(sec); FALSE;})
1523
1524 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
1525 #define STA_INFO_BIT(info) (1ul << NL80211_STA_ ## info)
1526 #ifdef strnicmp
1527 #undef strnicmp
1528 #endif /* strnicmp */
1529 #define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
1530 #else
1531 #define STA_INFO_BIT(info) (STATION_ ## info)
1532 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
1533
1534 extern s32 wl_cfg80211_attach(struct net_device *ndev, void *context);
1535 extern void wl_cfg80211_detach(struct bcm_cfg80211 *cfg);
1536
1537 extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
1538 void *data);
1539 void wl_cfg80211_set_parent_dev(void *dev);
1540 struct device *wl_cfg80211_get_parent_dev(void);
1541
1542 /* clear IEs */
1543 extern s32 wl_cfg80211_clear_mgmt_vndr_ies(struct bcm_cfg80211 *cfg);
1544 extern s32 wl_cfg80211_clear_per_bss_ies(struct bcm_cfg80211 *cfg, s32 bssidx);
1545
1546 extern s32 wl_cfg80211_up(struct net_device *net);
1547 extern s32 wl_cfg80211_down(struct net_device *net);
1548 extern s32 wl_cfg80211_notify_ifadd(struct net_device * dev, int ifidx, char *name, uint8 *mac,
1549 uint8 bssidx);
1550 extern s32 wl_cfg80211_notify_ifdel(struct net_device * dev, int ifidx, char *name, uint8 *mac,
1551 uint8 bssidx);
1552 extern s32 wl_cfg80211_notify_ifchange(struct net_device * dev, int ifidx, char *name, uint8 *mac,
1553 uint8 bssidx);
1554 extern struct net_device* wl_cfg80211_allocate_if(struct bcm_cfg80211 *cfg, int ifidx,
1555 const char *name, uint8 *mac, uint8 bssidx, const char *dngl_name);
1556 extern int wl_cfg80211_register_if(struct bcm_cfg80211 *cfg,
1557 int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
1558 extern int wl_cfg80211_remove_if(struct bcm_cfg80211 *cfg,
1559 int ifidx, struct net_device* ndev, bool rtnl_lock_reqd);
1560 extern int wl_cfg80211_scan_stop(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev);
1561 extern void wl_cfg80211_scan_abort(struct bcm_cfg80211 *cfg);
1562 extern bool wl_cfg80211_is_concurrent_mode(struct net_device * dev);
1563 extern void* wl_cfg80211_get_dhdp(struct net_device * dev);
1564 extern bool wl_cfg80211_is_p2p_active(struct net_device * dev);
1565 extern bool wl_cfg80211_is_roam_offload(struct net_device * dev);
1566 extern bool wl_cfg80211_is_event_from_connected_bssid(struct net_device * dev,
1567 const wl_event_msg_t *e, int ifidx);
1568 extern void wl_cfg80211_dbg_level(u32 level);
1569 extern s32 wl_cfg80211_get_p2p_dev_addr(struct net_device *net, struct ether_addr *p2pdev_addr);
1570 extern s32 wl_cfg80211_set_p2p_noa(struct net_device *net, char* buf, int len);
1571 extern s32 wl_cfg80211_get_p2p_noa(struct net_device *net, char* buf, int len);
1572 extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len,
1573 enum wl_management_type type);
1574 extern s32 wl_cfg80211_set_p2p_ps(struct net_device *net, char* buf, int len);
1575 extern s32 wl_cfg80211_set_p2p_ecsa(struct net_device *net, char* buf, int len);
1576 extern s32 wl_cfg80211_increase_p2p_bw(struct net_device *net, char* buf, int len);
1577 #ifdef WLMESH_CFG80211
1578 extern s32 wl_cfg80211_set_sae_password(struct net_device *net, char* buf, int len);
1579 #endif
1580 #ifdef WL11ULB
1581 extern s32 wl_cfg80211_set_ulb_mode(struct net_device *dev, int mode);
1582 extern s32 wl_cfg80211_set_ulb_bw(struct net_device *dev,
1583 u32 ulb_bw, char *ifname);
1584 #endif /* WL11ULB */
1585 #ifdef P2PLISTEN_AP_SAMECHN
1586 extern s32 wl_cfg80211_set_p2p_resp_ap_chn(struct net_device *net, s32 enable);
1587 #endif /* P2PLISTEN_AP_SAMECHN */
1588
1589 /* btcoex functions */
1590 void* wl_cfg80211_btcoex_init(struct net_device *ndev);
1591 void wl_cfg80211_btcoex_deinit(void);
1592
1593 extern chanspec_t wl_chspec_from_legacy(chanspec_t legacy_chspec);
1594 extern chanspec_t wl_chspec_driver_to_host(chanspec_t chanspec);
1595
1596 #ifdef WL_SUPPORT_AUTO_CHANNEL
1597 #define CHANSPEC_BUF_SIZE 1024
1598 #define CHAN_SEL_IOCTL_DELAY 300
1599 #define CHAN_SEL_RETRY_COUNT 15
1600 #define CHANNEL_IS_RADAR(channel) (((channel & WL_CHAN_RADAR) || \
1601 (channel & WL_CHAN_PASSIVE)) ? true : false)
1602 #define CHANNEL_IS_2G(channel) (((channel >= 1) && (channel <= 14)) ? \
1603 true : false)
1604 #define CHANNEL_IS_5G(channel) (((channel >= 36) && (channel <= 165)) ? \
1605 true : false)
1606 extern s32 wl_cfg80211_get_best_channels(struct net_device *dev, char* command,
1607 int total_len);
1608 #endif /* WL_SUPPORT_AUTO_CHANNEL */
1609 extern int wl_cfg80211_ether_atoe(const char *a, struct ether_addr *n);
1610 extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
1611 extern s32 wl_mode_to_nl80211_iftype(s32 mode);
1612 int wl_cfg80211_do_driver_init(struct net_device *net);
1613 void wl_cfg80211_enable_trace(u32 level);
1614 extern s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify);
1615 extern s32 wl_cfg80211_if_is_group_owner(void);
1616 extern chanspec_t wl_chspec_host_to_driver(chanspec_t chanspec);
1617 extern chanspec_t wl_ch_host_to_driver(struct bcm_cfg80211 *cfg, s32 bssidx, u16 channel);
1618 extern s32 wl_set_tx_power(struct net_device *dev,
1619 enum nl80211_tx_power_setting type, s32 dbm);
1620 extern s32 wl_get_tx_power(struct net_device *dev, s32 *dbm);
1621 extern s32 wl_add_remove_eventmsg(struct net_device *ndev, u16 event, bool add);
1622 extern void wl_stop_wait_next_action_frame(struct bcm_cfg80211 *cfg, struct net_device *ndev,
1623 u8 bsscfgidx);
1624 extern void wl_cfg80211_add_to_eventbuffer(wl_eventmsg_buf_t *ev, u16 event, bool set);
1625 extern s32 wl_cfg80211_apply_eventbuffer(struct net_device *ndev,
1626 struct bcm_cfg80211 *cfg, wl_eventmsg_buf_t *ev);
1627 extern void get_primary_mac(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
1628 extern void wl_cfg80211_update_power_mode(struct net_device *dev);
1629 extern void wl_cfg80211_set_passive_scan(struct net_device *dev, char *command);
1630 extern void wl_terminate_event_handler(struct net_device *dev);
1631 #if defined(DHD_ENABLE_BIGDATA_LOGGING)
1632 extern s32 wl_cfg80211_get_bss_info(struct net_device *dev, char* cmd, int total_len);
1633 extern s32 wl_cfg80211_get_connect_failed_status(struct net_device *dev, char* cmd, int total_len);
1634 #endif /* DHD_ENABLE_BIGDATA_LOGGING */
1635 extern struct bcm_cfg80211 *wl_get_cfg(struct net_device *ndev);
1636 extern s32 wl_cfg80211_set_if_band(struct net_device *ndev, int band);
1637
1638 #define SCAN_BUF_CNT 2
1639 #define SCAN_BUF_NEXT 1
1640 #define WL_SCANTYPE_LEGACY 0x1
1641 #define WL_SCANTYPE_P2P 0x2
1642 #define wl_escan_set_sync_id(a, b) ((a) = htod16((b)->escan_sync_id_cntr++))
1643 #define wl_escan_set_type(a, b)
1644 #define wl_escan_get_buf(a, b) ((wl_scan_results_t *) (a)->escan_info.escan_buf)
1645 #define wl_escan_check_sync_id(a, b, c) 0
1646 #define wl_escan_print_sync_id(a, b, c)
1647 #define wl_escan_increment_sync_id(a, b)
1648 #define wl_escan_init_sync_id(a)
1649 extern void wl_cfg80211_ibss_vsie_set_buffer(struct net_device *dev, vndr_ie_setbuf_t *ibss_vsie,
1650 int ibss_vsie_len);
1651 extern s32 wl_cfg80211_ibss_vsie_delete(struct net_device *dev);
1652 #ifdef WL_RELMCAST
1653 extern void wl_cfg80211_set_rmc_pid(struct net_device *dev, int pid);
1654 #endif /* WL_RELMCAST */
1655 extern int wl_cfg80211_set_mgmt_vndr_ies(struct bcm_cfg80211 *cfg,
1656 bcm_struct_cfgdev *cfgdev, s32 bssidx, s32 pktflag,
1657 const u8 *vndr_ie, u32 vndr_ie_len);
1658
1659 #ifdef WLFBT
1660 extern int wl_cfg80211_get_fbt_key(struct net_device *dev, uint8 *key, int total_len);
1661 #endif
1662
1663 /* Action frame specific functions */
1664 extern u8 wl_get_action_category(void *frame, u32 frame_len);
1665 extern int wl_get_public_action(void *frame, u32 frame_len, u8 *ret_action);
1666
1667 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
1668 struct net_device *wl_cfg80211_get_remain_on_channel_ndev(struct bcm_cfg80211 *cfg);
1669 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
1670
1671 #ifdef WL_SUPPORT_ACS
1672 #define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */
1673 #define IOCTL_RETRY_COUNT 5
1674 #define CHAN_NOISE_DUMMY -80
1675 #define OBSS_TOKEN_IDX 15
1676 #define IBSS_TOKEN_IDX 15
1677 #define TX_TOKEN_IDX 14
1678 #define CTG_TOKEN_IDX 13
1679 #define PKT_TOKEN_IDX 15
1680 #define IDLE_TOKEN_IDX 12
1681 #endif /* WL_SUPPORT_ACS */
1682
1683
1684 extern int wl_cfg80211_get_ioctl_version(void);
1685 extern int wl_cfg80211_enable_roam_offload(struct net_device *dev, int enable);
1686 extern s32 wl_cfg80211_dfs_ap_move(struct net_device *ndev, char *data,
1687 char *command, int total_len);
1688 #ifdef WBTEXT
1689 extern s32 wl_cfg80211_wbtext_set_default(struct net_device *ndev);
1690 extern s32 wl_cfg80211_wbtext_config(struct net_device *ndev, char *data,
1691 char *command, int total_len);
1692 extern int wl_cfg80211_wbtext_weight_config(struct net_device *ndev, char *data,
1693 char *command, int total_len);
1694 extern int wl_cfg80211_wbtext_table_config(struct net_device *ndev, char *data,
1695 char *command, int total_len);
1696 extern s32 wl_cfg80211_wbtext_delta_config(struct net_device *ndev, char *data,
1697 char *command, int total_len);
1698 #endif /* WBTEXT */
1699 extern s32 wl_cfg80211_get_chanspecs_2g(struct net_device *ndev,
1700 void *buf, s32 buflen);
1701 extern s32 wl_cfg80211_get_chanspecs_5g(struct net_device *ndev,
1702 void *buf, s32 buflen);
1703
1704 extern s32 wl_cfg80211_bss_up(struct bcm_cfg80211 *cfg,
1705 struct net_device *ndev, s32 bsscfg_idx, s32 up);
1706 extern bool wl_cfg80211_bss_isup(struct net_device *ndev, int bsscfg_idx);
1707
1708 struct net_device *wl_cfg80211_post_ifcreate(struct net_device *ndev,
1709 wl_if_event_info *event, u8 *addr, const char *name, bool rtnl_lock_reqd);
1710 extern s32 wl_cfg80211_post_ifdel(struct net_device *ndev, bool rtnl_lock_reqd);
1711 #if defined(WL_VIRTUAL_APSTA)
1712 extern int wl_cfg80211_interface_create(struct net_device *dev, char *name);
1713 extern int wl_cfg80211_interface_delete(struct net_device *dev, char *name);
1714 #if defined(PKT_FILTER_SUPPORT) && defined(APSTA_BLOCK_ARP_DURING_DHCP)
1715 extern void wl_cfg80211_block_arp(struct net_device *dev, int enable);
1716 #endif /* PKT_FILTER_SUPPORT && APSTA_BLOCK_ARP_DURING_DHCP */
1717 #endif /* defined (WL_VIRTUAL_APSTA) */
1718
1719
1720 #ifdef WL_CFG80211_P2P_DEV_IF
1721 extern void wl_cfg80211_del_p2p_wdev(struct net_device *dev);
1722 #endif /* WL_CFG80211_P2P_DEV_IF */
1723 #if defined(WL_SUPPORT_AUTO_CHANNEL)
1724 extern int wl_cfg80211_set_spect(struct net_device *dev, int spect);
1725 extern int wl_cfg80211_get_sta_channel(struct net_device *dev);
1726 #endif /* WL_SUPPORT_AUTO_CHANNEL */
1727
1728 #ifdef P2P_LISTEN_OFFLOADING
1729 extern s32 wl_cfg80211_p2plo_listen_start(struct net_device *dev, u8 *buf, int len);
1730 extern s32 wl_cfg80211_p2plo_listen_stop(struct net_device *dev);
1731 #endif /* P2P_LISTEN_OFFLOADING */
1732
1733 #define RETURN_EIO_IF_NOT_UP(wlpriv) \
1734 do { \
1735 struct net_device *checkSysUpNDev = bcmcfg_to_prmry_ndev(wlpriv); \
1736 if (unlikely(!wl_get_drv_status(wlpriv, READY, checkSysUpNDev))) { \
1737 WL_INFORM(("device is not ready\n")); \
1738 return -EIO; \
1739 } \
1740 } while (0)
1741
1742 #ifdef QOS_MAP_SET
1743 extern uint8 *wl_get_up_table(void);
1744 #endif /* QOS_MAP_SET */
1745
1746 #define P2PO_COOKIE 65535
1747 u64 wl_cfg80211_get_new_roc_id(struct bcm_cfg80211 *cfg);
1748
1749 #if defined(SUPPORT_RANDOM_MAC_SCAN)
1750 int wl_cfg80211_set_random_mac(struct net_device *dev, bool enable);
1751 int wl_cfg80211_random_mac_enable(struct net_device *dev);
1752 int wl_cfg80211_random_mac_disable(struct net_device *dev);
1753 #endif /* SUPPORT_RANDOM_MAC_SCAN */
1754 #ifdef SUPPORT_AP_HIGHER_BEACONRATE
1755 int wl_set_ap_beacon_rate(struct net_device *dev, int val, char *ifname);
1756 int wl_get_ap_basic_rate(struct net_device *dev, char* command, char *ifname, int total_len);
1757 #endif /* SUPPORT_AP_HIGHER_BEACONRATE */
1758 #ifdef SUPPORT_AP_RADIO_PWRSAVE
1759 int wl_get_ap_rps(struct net_device *dev, char* command, char *ifname, int total_len);
1760 int wl_set_ap_rps(struct net_device *dev, bool enable, char *ifname);
1761 int wl_update_ap_rps_params(struct net_device *dev, ap_rps_info_t* rps, char *ifname);
1762 void wl_cfg80211_init_ap_rps(struct bcm_cfg80211 *cfg);
1763 #endif /* SUPPORT_AP_RADIO_PWRSAVE */
1764 #ifdef SUPPORT_RSSI_LOGGING
1765 int wl_get_rssi_logging(struct net_device *dev, void *param);
1766 int wl_set_rssi_logging(struct net_device *dev, void *param);
1767 int wl_get_rssi_per_ant(struct net_device *dev, char *ifname, char *peer_mac, void *param);
1768 #endif /* SUPPORT_RSSI_LOGGING */
1769 int wl_cfg80211_iface_count(struct net_device *dev);
1770 struct net_device* wl_get_ap_netdev(struct bcm_cfg80211 *cfg, char *ifname);
1771 struct net_device* wl_get_netdev_by_name(struct bcm_cfg80211 *cfg, char *ifname);
1772 int wl_cfg80211_get_vndr_ouilist(struct bcm_cfg80211 *cfg, uint8 *buf, int max_cnt);
1773 s32 wl_cfg80211_autochannel(struct net_device *dev, char* command, int total_len);
1774 #endif /* _wl_cfg80211_h_ */
1775