2 * Linux cfg80211 driver
4 * Copyright (C) 1999-2015, Broadcom Corporation
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:
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.
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.
24 * $Id: wl_cfg80211.h 534520 2015-02-13 11:12:36Z $
28 * Older Linux versions support the 'iw' interface, more recent ones the 'cfg80211' interface.
31 #ifndef _wl_cfg80211_h_
32 #define _wl_cfg80211_h_
34 #include <linux/wireless.h>
36 #include <proto/ethernet.h>
38 #include <linux/wireless.h>
39 #include <linux/workqueue.h>
40 #include <net/cfg80211.h>
41 #include <linux/rfkill.h>
43 #include <wl_cfgp2p.h>
57 #define htodchanspec(i) (i)
58 #define dtohchanspec(i) (i)
61 #define WL_DBG_P2P_ACTION (1 << 5)
62 #define WL_DBG_TRACE (1 << 4)
63 #define WL_DBG_SCAN (1 << 3)
64 #define WL_DBG_DBG (1 << 2)
65 #define WL_DBG_INFO (1 << 1)
66 #define WL_DBG_ERR (1 << 0)
68 /* 0 invalidates all debug messages. default is 1 */
69 #define WL_DBG_LEVEL 0xFF
71 #define CFG80211_ERROR_TEXT "CFG80211-ERROR) "
73 #define MAX_WAIT_TIME 1500
74 #define DNGL_FUNC(func, parameters) func parameters;
79 #define DISCONNECT_WAIT_TIME 250
81 #if defined(DHD_DEBUG)
82 #define WL_ERR(args) \
84 if (wl_dbg_level & WL_DBG_ERR) { \
85 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
89 #else /* defined(DHD_DEBUG) */
90 #define WL_ERR(args) \
92 if ((wl_dbg_level & WL_DBG_ERR) && net_ratelimit()) { \
93 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
97 #endif /* defined(DHD_DEBUG) */
103 #define WL_INFORM(args) \
105 if (wl_dbg_level & WL_DBG_INFO) { \
106 printk(KERN_INFO "CFG80211-INFO) %s : ", __func__); \
115 #define WL_SCAN(args) \
117 if (wl_dbg_level & WL_DBG_SCAN) { \
118 printk(KERN_INFO "CFG80211-SCAN) %s :", __func__); \
125 #define WL_TRACE(args) \
127 if (wl_dbg_level & WL_DBG_TRACE) { \
128 printk(KERN_INFO "CFG80211-TRACE) %s :", __func__); \
135 #define WL_TRACE_HW4 WL_TRACE
136 #if (WL_DBG_LEVEL > 0)
137 #define WL_DBG(args) \
139 if (wl_dbg_level & WL_DBG_DBG) { \
140 printk(KERN_DEBUG "CFG80211-DEBUG) %s :", __func__); \
144 #else /* !(WL_DBG_LEVEL > 0) */
146 #endif /* (WL_DBG_LEVEL > 0) */
151 #define WL_SCAN_RETRY_MAX 3
152 #define WL_NUM_PMKIDS_MAX MAXPMKID
153 #define WL_SCAN_BUF_MAX (1024 * 8)
154 #define WL_TLV_INFO_MAX 1500
155 #define WL_SCAN_IE_LEN_MAX 2048
156 #define WL_BSS_INFO_MAX 2048
157 #define WL_ASSOC_INFO_MAX 512
158 #define WL_IOCTL_LEN_MAX 2048
159 #define WL_EXTRA_BUF_MAX 2048
160 #define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
161 #define WL_AP_MAX 256
162 #define WL_FILE_NAME_MAX 256
163 #define WL_DWELL_TIME 200
164 #define WL_MED_DWELL_TIME 400
165 #define WL_MIN_DWELL_TIME 100
166 #define WL_LONG_DWELL_TIME 1000
167 #define IFACE_MAX_CNT 2
168 #define WL_SCAN_CONNECT_DWELL_TIME_MS 200
169 #define WL_SCAN_JOIN_PROBE_INTERVAL_MS 20
170 #define WL_SCAN_JOIN_ACTIVE_DWELL_TIME_MS 320
171 #define WL_SCAN_JOIN_PASSIVE_DWELL_TIME_MS 400
172 #define WL_AF_TX_MAX_RETRY 5
174 #define WL_AF_SEARCH_TIME_MAX 450
175 #define WL_AF_TX_EXTRA_TIME_MAX 200
177 #define WL_SCAN_TIMER_INTERVAL_MS 10000 /* Scan timeout */
178 #define WL_CHANNEL_SYNC_RETRY 5
179 #define WL_INVALID -1
181 /* Bring down SCB Timeout to 20secs from 60secs default */
182 #ifndef WL_SCB_TIMEOUT
183 #define WL_SCB_TIMEOUT 20
186 /* SCAN_SUPPRESS timer values in ms */
187 #define WL_SCAN_SUPPRESS_TIMEOUT 31000 /* default Framwork DHCP timeout is 30 sec */
188 #define WL_SCAN_SUPPRESS_RETRY 3000
190 #define WL_PM_ENABLE_TIMEOUT 10000
197 WL_STATUS_SCAN_ABORTING,
198 WL_STATUS_CONNECTING,
200 WL_STATUS_DISCONNECTING,
201 WL_STATUS_AP_CREATING,
202 WL_STATUS_AP_CREATED,
203 /* whole sending action frame procedure:
204 * includes a) 'finding common channel' for public action request frame
205 * and b) 'sending af via 'actframe' iovar'
207 WL_STATUS_SENDING_ACT_FRM,
208 /* find a peer to go to a common channel before sending public action req frame */
209 WL_STATUS_FINDING_COMMON_CHANNEL,
210 /* waiting for next af to sync time of supplicant.
211 * it includes SENDING_ACT_FRM and WAITING_NEXT_ACT_FRM_LISTEN
213 WL_STATUS_WAITING_NEXT_ACT_FRM,
214 #ifdef WL_CFG80211_SYNC_GON
215 /* go to listen state to wait for next af after SENDING_ACT_FRM */
216 WL_STATUS_WAITING_NEXT_ACT_FRM_LISTEN,
217 #endif /* WL_CFG80211_SYNC_GON */
218 /* it will be set when upper layer requests listen and succeed in setting listen mode.
219 * if set, other scan request can abort current listen state
221 WL_STATUS_REMAINING_ON_CHANNEL,
222 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
223 /* it's fake listen state to keep current scan state.
224 * it will be set when upper layer requests listen but scan is running. then just run
225 * a expire timer without actual listen state.
226 * if set, other scan request does not need to abort scan.
228 WL_STATUS_FAKE_REMAINING_ON_CHANNEL
229 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
239 /* driver profile list */
253 /* donlge escan state */
254 enum wl_escan_state {
256 WL_ESCAN_STATE_SCANING
258 /* fw downloading status */
261 WL_NVRAM_LOADING_DONE
264 enum wl_management_type {
270 enum wl_handler_del_type {
277 /* beacon / probe_response */
278 struct beacon_proberesp {
283 } __attribute__ ((packed));
285 /* driver configuration */
292 struct ieee80211_channel channel;
295 typedef s32(*EVENT_HANDLER) (struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
296 const wl_event_msg_t *e, void *data);
298 /* bss inform structure for cfg80211 interface */
299 struct wl_cfg80211_bss_info {
307 /* basic structure of scan request */
309 struct wlc_ssid ssid;
312 /* basic structure of information element */
315 u8 buf[WL_TLV_INFO_MAX];
318 /* event queue for cfg80211 main event */
320 struct list_head eq_list;
326 /* security information with currently associated ap */
333 u32 auth_assoc_res_status;
336 /* ibss information for currently joined ibss network */
338 u8 beacon_interval; /* in millisecond */
339 u8 atim; /* in millisecond */
345 /* cfg driver profile */
350 struct wlc_ssid ssid;
351 struct wl_security sec;
353 u8 bssid[ETHER_ADDR_LEN];
360 struct net_device *ndev;
361 struct wireless_dev *wdev;
362 struct wl_profile profile;
365 unsigned long sme_state;
369 struct list_head list; /* list of all net_info structure */
372 /* association inform */
373 #define MAX_REQ_LINE 1024
374 struct wl_connect_info {
375 u8 req_ie[MAX_REQ_LINE];
377 u8 resp_ie[MAX_REQ_LINE];
381 /* firmware /nvram downloading controller */
383 const struct firmware *fw_entry;
384 unsigned long status;
386 s8 fw_name[WL_FILE_NAME_MAX];
387 s8 nvram_name[WL_FILE_NAME_MAX];
390 /* assoc ie length */
391 struct wl_assoc_ielen {
399 pmkid_t foo[MAXPMKID - 1];
403 #define ESCAN_BUF_SIZE (64 * 1024)
407 #if defined(STATIC_WL_PRIV_STRUCT)
408 #ifndef CONFIG_DHD_USE_STATIC_BUF
409 #error STATIC_WL_PRIV_STRUCT should be used with CONFIG_DHD_USE_STATIC_BUF
410 #endif /* CONFIG_DHD_USE_STATIC_BUF */
413 u8 escan_buf[ESCAN_BUF_SIZE];
414 #endif /* STATIC_WL_PRIV_STRUCT */
416 struct net_device *ndev;
419 #ifdef ESCAN_BUF_OVERFLOW_MGMT
420 #define BUF_OVERFLOW_MGMT_COUNT 3
424 struct ether_addr BSSID;
426 #endif /* ESCAN_BUF_OVERFLOW_MGMT */
429 /* Structure to hold WPS, WPA IEs for a AP */
430 u8 probe_res_ie[VNDR_IES_MAX_BUF_LEN];
431 u8 beacon_ie[VNDR_IES_MAX_BUF_LEN];
432 u8 assoc_res_ie[VNDR_IES_MAX_BUF_LEN];
433 u32 probe_res_ie_len;
435 u32 assoc_res_ie_len;
443 /* Structure to hold WPS IE for a STA */
444 u8 probe_req_ie[VNDR_IES_BUF_LEN];
445 u8 assoc_req_ie[VNDR_IES_BUF_LEN];
446 u32 probe_req_ie_len;
447 u32 assoc_req_ie_len;
451 wl_af_params_t *pending_tx_act_frm;
452 struct ether_addr tx_dst_addr;
453 struct net_device *dev;
454 struct work_struct work;
458 s32 peer_listen_chan; /* search channel: configured by upper layer */
459 s32 my_listen_chan; /* listen chanel: extract it from prb req or gon req */
466 wpa_ie_fixed_t *wps_ie;
468 wpa_ie_fixed_t *wpa_ie;
476 /* Max length of Interworking element */
477 #define IW_IES_MAX_BUF_LEN 9
479 #define MAX_EVENT_BUF_NUM 16
480 typedef struct wl_eventmsg_buf {
485 } event [MAX_EVENT_BUF_NUM];
488 typedef struct wl_if_event_info {
492 uint8 mac[ETHER_ADDR_LEN];
493 char name[IFNAMSIZ+1];
496 /* private data of cfg80211 interface */
497 struct bcm_cfg80211 {
498 struct wireless_dev *wdev; /* representing cfg cfg80211 device */
500 struct wireless_dev *p2p_wdev; /* representing cfg cfg80211 device for P2P */
501 struct net_device *p2p_net; /* reference to p2p0 interface */
503 struct wl_conf *conf;
504 struct cfg80211_scan_request *scan_request; /* scan request object */
505 EVENT_HANDLER evt_handler[WLC_E_LAST];
506 struct list_head eq_list; /* used for event queue */
507 struct list_head net_list; /* used for struct net_info */
508 struct list_head dealloc_list; /* used for struct net_info which can
510 spinlock_t eq_lock; /* for event queue synchronization */
511 spinlock_t cfgdrv_lock; /* to protect scan status (and others if needed) */
512 struct completion act_frm_scan;
513 struct completion iface_disable;
514 struct completion wait_next_af;
515 struct mutex usr_sync; /* maily for up/down synchronization */
516 struct wl_scan_results *bss_list;
517 struct wl_scan_results *scan_results;
519 /* scan request object for internal purpose */
520 struct wl_scan_req *scan_req_int;
521 /* information element object for internal purpose */
522 #if defined(STATIC_WL_PRIV_STRUCT)
528 /* association information container */
529 #if defined(STATIC_WL_PRIV_STRUCT)
530 struct wl_connect_info *conn_info;
532 struct wl_connect_info conn_info;
534 #ifdef DEBUGFS_CFG80211
535 struct dentry *debugfs;
536 #endif /* DEBUGFS_CFG80211 */
537 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
538 tsk_ctl_t event_tsk; /* task of main event handler thread */
541 u32 channel; /* current channel */
542 u32 af_sent_channel; /* channel action frame is sent */
543 /* next af subtype to cancel the remained dwell time in rx process */
545 #ifdef WL_CFG80211_SYNC_GON
546 ulong af_tx_sent_jiffies;
547 #endif /* WL_CFG80211_SYNC_GON */
548 struct escan_info escan_info; /* escan information */
549 bool active_scan; /* current scan mode */
550 bool ibss_starter; /* indicates this sta is ibss starter */
551 bool link_up; /* link/connection up flag */
553 /* indicate whether chip to support power save mode */
555 bool roam_on; /* on/off switch for self-roaming */
556 bool scan_tried; /* indicates if first scan attempted */
557 #if defined(BCMSDIO) || defined(BCMPCIE)
561 bool roamoff_on_concurrent;
562 u8 *ioctl_buf; /* ioctl buffer */
563 struct mutex ioctl_buf_sync;
565 u8 *extra_buf; /* maily to grab assoc information */
566 struct dentry *debugfsdir;
567 struct rfkill *rfkill;
569 struct ieee80211_channel remain_on_chan;
570 enum nl80211_channel_type remain_on_chan_type;
573 wait_queue_head_t netif_change_event;
574 wl_if_event_info if_event_info;
575 struct completion send_af_done;
576 struct completion send_disconnected;
577 struct afx_hdl *afx_hdl;
578 struct ap_info *ap_info;
579 struct sta_info *sta_info;
580 struct p2p_info *p2p;
583 struct timer_list scan_timeout; /* Timer for catch scan event timeout */
584 #if defined(P2P_IE_MISSING_FIX)
587 s32(*state_notifier) (struct bcm_cfg80211 *cfg,
588 struct net_info *_net_info, enum wl_status state, bool set);
589 unsigned long interrested_state;
590 wlc_ssid_t hostapd_ssid;
593 u8 iw_ie[IW_IES_MAX_BUF_LEN];
596 bool sched_scan_running; /* scheduled scan req status */
598 struct cfg80211_sched_scan_request *sched_scan_req; /* scheduled scan req */
599 #endif /* WL_SCHED_SCAN */
600 bool scan_suppressed;
601 struct timer_list scan_supp_timer;
602 struct work_struct wlan_work;
603 struct work_struct dealloc_work;
604 struct mutex event_sync; /* maily for up/down synchronization */
605 bool disable_roam_event;
606 bool pm_enable_work_on;
607 struct delayed_work pm_enable_work;
608 vndr_ie_setbuf_t *ibss_vsie; /* keep the VSIE for IBSS */
613 struct ether_addr ibss_if_addr;
614 bcm_struct_cfgdev *ibss_cfgdev; /* For AIBSS */
615 #endif /* WLAIBSS_MCHAN */
616 bcm_struct_cfgdev *bss_cfgdev; /* For DUAL STA/STA+AP */
618 bool bss_pending_op; /* indicate where there is a pending IF operation */
624 #ifdef P2PLISTEN_AP_SAMECHN
625 bool p2p_resp_apchn_status;
626 #endif /* P2PLISTEN_AP_SAMECHN */
629 u32 tdls_mgmt_frame_len;
631 struct rw_semaphore netif_sem;
632 struct semaphore net_wdev_sema;
636 uint8 *up_table; /* user priority table, size is UP_TABLE_MAX */
637 #endif /* QOS_MAP_SET */
638 struct ether_addr last_roamed_addr;
642 static inline struct wl_bss_info *next_bss(struct wl_scan_results *list, struct wl_bss_info *bss)
645 (struct wl_bss_info *)((uintptr) bss + dtoh32(bss->length)) : list->bss_info;
648 wl_alloc_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev,
649 struct wireless_dev * wdev, s32 mode, bool pm_block)
651 struct net_info *_net_info;
653 if (cfg->iface_cnt == IFACE_MAX_CNT)
655 _net_info = kzalloc(sizeof(struct net_info), GFP_KERNEL);
659 _net_info->mode = mode;
660 _net_info->ndev = ndev;
661 _net_info->wdev = wdev;
662 _net_info->pm_restore = 0;
664 _net_info->pm_block = pm_block;
665 _net_info->roam_off = WL_INVALID;
667 list_add(&_net_info->list, &cfg->net_list);
672 wl_remove_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev)
674 struct net_info *_net_info, *next;
675 bool dealloc_needed = false;
677 if (down_interruptible(&cfg->net_wdev_sema) < 0) {
678 WL_ERR(("%s: cannot lock semaphore\n", __func__));
682 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
683 if (ndev && (_net_info->ndev == ndev)) {
684 list_del(&_net_info->list);
686 if (_net_info->wdev) {
687 ndev->ieee80211_ptr = NULL;
689 INIT_LIST_HEAD(&_net_info->list);
690 list_add(&_net_info->list, &cfg->dealloc_list);
691 dealloc_needed = true;
696 schedule_work(&cfg->dealloc_work);
697 up(&cfg->net_wdev_sema);
700 wl_delete_all_netinfo(struct bcm_cfg80211 *cfg)
702 struct net_info *_net_info, *next;
703 if (down_interruptible(&cfg->net_wdev_sema) < 0) {
704 WL_ERR(("%s: cannot lock semaphore\n", __func__));
707 down_write(&cfg->netif_sem);
708 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
709 list_del(&_net_info->list);
710 if (_net_info->wdev) {
711 if (cfg->wdev == _net_info->wdev)
713 else if (cfg->p2p_wdev == _net_info->wdev)
714 cfg->p2p_wdev = NULL;
716 WL_ERR(("Unknown wdev freed\n"));
717 kfree(_net_info->wdev);
718 _net_info->wdev = NULL;
722 up_write(&cfg->netif_sem);
724 up(&cfg->net_wdev_sema);
727 wl_get_status_all(struct bcm_cfg80211 *cfg, s32 status)
730 struct net_info *_net_info, *next;
732 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
733 if (_net_info->ndev &&
734 test_bit(status, &_net_info->sme_state))
740 wl_set_status_all(struct bcm_cfg80211 *cfg, s32 status, u32 op)
742 struct net_info *_net_info, *next;
743 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
746 return; /* set all status is not allowed */
748 clear_bit(status, &_net_info->sme_state);
749 if (cfg->state_notifier &&
750 test_bit(status, &(cfg->interrested_state)))
751 cfg->state_notifier(cfg, _net_info, status, false);
754 return; /* change all status is not allowed */
756 return; /* unknown operation */
761 wl_set_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
762 struct net_device *ndev, u32 op)
765 struct net_info *_net_info, *next;
767 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
768 if (ndev && (_net_info->ndev == ndev)) {
771 set_bit(status, &_net_info->sme_state);
772 if (cfg->state_notifier &&
773 test_bit(status, &(cfg->interrested_state)))
774 cfg->state_notifier(cfg, _net_info, status, true);
777 clear_bit(status, &_net_info->sme_state);
778 if (cfg->state_notifier &&
779 test_bit(status, &(cfg->interrested_state)))
780 cfg->state_notifier(cfg, _net_info, status, false);
783 change_bit(status, &_net_info->sme_state);
793 wl_get_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
794 struct net_device *ndev)
796 struct net_info *_net_info, *next;
798 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
799 if (ndev && (_net_info->ndev == ndev))
800 return test_bit(status, &_net_info->sme_state);
806 wl_get_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
808 struct net_info *_net_info, *next;
810 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
811 if (ndev && (_net_info->ndev == ndev))
812 return _net_info->mode;
819 wl_set_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev,
822 struct net_info *_net_info, *next;
824 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
825 if (ndev && (_net_info->ndev == ndev))
826 _net_info->mode = mode;
829 static inline struct wl_profile *
830 wl_get_profile_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
832 struct net_info *_net_info, *next;
834 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
835 if (ndev && (_net_info->ndev == ndev))
836 return &_net_info->profile;
840 static inline struct net_info *
841 wl_get_netinfo_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
843 struct net_info *_net_info, *next;
845 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
846 if (ndev && (_net_info->ndev == ndev))
851 #define bcmcfg_to_wiphy(cfg) (cfg->wdev->wiphy)
852 #define bcmcfg_to_prmry_ndev(cfg) (cfg->wdev->netdev)
853 #define bcmcfg_to_prmry_wdev(cfg) (cfg->wdev)
854 #define bcmcfg_to_p2p_wdev(cfg) (cfg->p2p_wdev)
855 #define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
856 #define ndev_to_wdev(ndev) (ndev->ieee80211_ptr)
857 #define wdev_to_ndev(wdev) (wdev->netdev)
859 #if defined(WL_ENABLE_P2P_IF)
860 #define ndev_to_wlc_ndev(ndev, cfg) ((ndev == cfg->p2p_net) ? \
861 bcmcfg_to_prmry_ndev(cfg) : ndev)
863 #define ndev_to_wlc_ndev(ndev, cfg) (ndev)
864 #endif /* WL_ENABLE_P2P_IF */
866 #if defined(WL_CFG80211_P2P_DEV_IF)
867 #define wdev_to_wlc_ndev(wdev, cfg) \
868 ((wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) ? \
869 bcmcfg_to_prmry_ndev(cfg) : wdev_to_ndev(wdev))
870 #define cfgdev_to_wlc_ndev(cfgdev, cfg) wdev_to_wlc_ndev(cfgdev, cfg)
871 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_wdev(cfg)
872 #elif defined(WL_ENABLE_P2P_IF)
873 #define cfgdev_to_wlc_ndev(cfgdev, cfg) ndev_to_wlc_ndev(cfgdev, cfg)
874 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_ndev(cfg)
876 #define cfgdev_to_wlc_ndev(cfgdev, cfg) (cfgdev)
877 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) (cfgdev)
878 #endif /* WL_CFG80211_P2P_DEV_IF */
880 #if defined(WL_CFG80211_P2P_DEV_IF)
881 #define ndev_to_cfgdev(ndev) ndev_to_wdev(ndev)
882 #define cfgdev_to_ndev(cfgdev) cfgdev ? (cfgdev->netdev) : NULL
883 #define discover_cfgdev(cfgdev, cfg) (cfgdev->iftype == NL80211_IFTYPE_P2P_DEVICE)
885 #define ndev_to_cfgdev(ndev) (ndev)
886 #define cfgdev_to_ndev(cfgdev) (cfgdev)
887 #define discover_cfgdev(cfgdev, cfg) (cfgdev == cfg->p2p_net)
888 #endif /* WL_CFG80211_P2P_DEV_IF */
890 #if defined(WL_CFG80211_P2P_DEV_IF)
891 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
892 (cfg->scan_request->wdev == cfg->p2p_wdev)) ? true : false)
893 #elif defined(WL_ENABLE_P2P_IF)
894 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
895 (cfg->scan_request->dev == cfg->p2p_net)) ? true : false)
897 #define scan_req_match(cfg) (((cfg) && p2p_is_on(cfg) && p2p_scan(cfg)) ? \
899 #endif /* WL_CFG80211_P2P_DEV_IF */
901 #define wl_to_sr(w) (w->scan_req_int)
902 #if defined(STATIC_WL_PRIV_STRUCT)
903 #define wl_to_ie(w) (w->ie)
904 #define wl_to_conn(w) (w->conn_info)
906 #define wl_to_ie(w) (&w->ie)
907 #define wl_to_conn(w) (&w->conn_info)
909 #define wiphy_from_scan(w) (w->escan_info.wiphy)
910 #define wl_get_drv_status_all(cfg, stat) \
911 (wl_get_status_all(cfg, WL_STATUS_ ## stat))
912 #define wl_get_drv_status(cfg, stat, ndev) \
913 (wl_get_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev))
914 #define wl_set_drv_status(cfg, stat, ndev) \
915 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 1))
916 #define wl_clr_drv_status(cfg, stat, ndev) \
917 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 2))
918 #define wl_clr_drv_status_all(cfg, stat) \
919 (wl_set_status_all(cfg, WL_STATUS_ ## stat, 2))
920 #define wl_chg_drv_status(cfg, stat, ndev) \
921 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 4))
923 #define for_each_bss(list, bss, __i) \
924 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
926 #define for_each_ndev(cfg, iter, next) \
927 list_for_each_entry_safe(iter, next, &cfg->net_list, list)
930 /* In case of WPS from wpa_supplicant, pairwise siute and group suite is 0.
931 * In addtion to that, wpa_version is WPA_VERSION_1
933 #define is_wps_conn(_sme) \
934 ((wl_cfgp2p_find_wpsie((u8 *)_sme->ie, _sme->ie_len) != NULL) && \
935 (!_sme->crypto.n_ciphers_pairwise) && \
936 (!_sme->crypto.cipher_group))
938 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
939 #define STA_INFO_BIT(info) (1ul << NL80211_STA_ ## info)
940 #define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
942 #define STA_INFO_BIT(info) (STATION_ ## info)
943 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) */
944 extern s32 wl_cfg80211_attach(struct net_device *ndev, void *context);
945 extern s32 wl_cfg80211_attach_post(struct net_device *ndev);
946 extern void wl_cfg80211_detach(void *para);
948 extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
950 void wl_cfg80211_set_parent_dev(void *dev);
951 struct device *wl_cfg80211_get_parent_dev(void);
953 extern s32 wl_cfg80211_up(void *para);
954 extern s32 wl_cfg80211_down(void *para);
955 extern s32 wl_cfg80211_notify_ifadd(int ifidx, char *name, uint8 *mac, uint8 bssidx);
956 extern s32 wl_cfg80211_notify_ifdel(int ifidx, char *name, uint8 *mac, uint8 bssidx);
957 extern s32 wl_cfg80211_notify_ifchange(int ifidx, char *name, uint8 *mac, uint8 bssidx);
958 extern struct net_device* wl_cfg80211_allocate_if(struct bcm_cfg80211 *cfg, int ifidx, char *name,
959 uint8 *mac, uint8 bssidx);
960 extern int wl_cfg80211_register_if(struct bcm_cfg80211 *cfg, int ifidx, struct net_device* ndev);
961 extern int wl_cfg80211_remove_if(struct bcm_cfg80211 *cfg, int ifidx, struct net_device* ndev);
962 extern int wl_cfg80211_remove_p2p_if(struct bcm_cfg80211 *cfg, int ifidx, struct net_device* ndev);
963 extern int wl_cfg80211_scan_stop(bcm_struct_cfgdev *cfgdev);
964 extern bool wl_cfg80211_is_vsdb_mode(void);
965 extern void* wl_cfg80211_get_dhdp(void);
966 extern bool wl_cfg80211_is_p2p_active(void);
967 extern void wl_cfg80211_dbg_level(u32 level);
968 extern s32 wl_cfg80211_get_p2p_dev_addr(struct net_device *net, struct ether_addr *p2pdev_addr);
969 extern s32 wl_cfg80211_set_p2p_noa(struct net_device *net, char* buf, int len);
970 extern s32 wl_cfg80211_get_p2p_noa(struct net_device *net, char* buf, int len);
971 extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len,
972 enum wl_management_type type);
973 extern s32 wl_cfg80211_set_p2p_ps(struct net_device *net, char* buf, int len);
974 #ifdef P2PLISTEN_AP_SAMECHN
975 extern s32 wl_cfg80211_set_p2p_resp_ap_chn(struct net_device *net, s32 enable);
976 #endif /* P2PLISTEN_AP_SAMECHN */
978 /* btcoex functions */
979 void* wl_cfg80211_btcoex_init(struct net_device *ndev);
980 void wl_cfg80211_btcoex_deinit(void);
983 #ifdef WL_SUPPORT_AUTO_CHANNEL
984 #define CHANSPEC_BUF_SIZE 1024
985 #define CHAN_SEL_IOCTL_DELAY 300
986 #define CHAN_SEL_RETRY_COUNT 15
987 #define CHANNEL_IS_RADAR(channel) (((channel & WL_CHAN_RADAR) || \
988 (channel & WL_CHAN_PASSIVE)) ? true : false)
989 #define CHANNEL_IS_2G(channel) (((channel >= 1) && (channel <= 14)) ? \
991 #define CHANNEL_IS_5G(channel) (((channel >= 36) && (channel <= 165)) ? \
993 extern s32 wl_cfg80211_get_best_channels(struct net_device *dev, char* command,
995 #endif /* WL_SUPPORT_AUTO_CHANNEL */
997 extern int wl_cfg80211_ether_atoe(const char *a, struct ether_addr *n);
998 extern int wl_cfg80211_hex_str_to_bin(unsigned char *data, int dlen, char *str);
999 extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
1000 extern s32 wl_mode_to_nl80211_iftype(s32 mode);
1001 int wl_cfg80211_do_driver_init(struct net_device *net);
1002 void wl_cfg80211_enable_trace(bool set, u32 level);
1003 extern s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify);
1004 extern s32 wl_cfg80211_if_is_group_owner(void);
1005 extern chanspec_t wl_chspec_host_to_driver(chanspec_t chanspec);
1006 extern chanspec_t wl_ch_host_to_driver(u16 channel);
1007 extern s32 wl_set_tx_power(struct net_device *dev,
1008 enum nl80211_tx_power_setting type, s32 dbm);
1009 extern s32 wl_get_tx_power(struct net_device *dev, s32 *dbm);
1010 extern s32 wl_add_remove_eventmsg(struct net_device *ndev, u16 event, bool add);
1011 extern void wl_stop_wait_next_action_frame(struct bcm_cfg80211 *cfg, struct net_device *ndev);
1012 extern void wl_cfg80211_add_to_eventbuffer(wl_eventmsg_buf_t *ev, u16 event, bool set);
1013 extern s32 wl_cfg80211_apply_eventbuffer(struct net_device *ndev,
1014 struct bcm_cfg80211 *cfg, wl_eventmsg_buf_t *ev);
1015 extern void get_primary_mac(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
1016 extern void wl_cfg80211_update_power_mode(struct net_device *dev);
1017 #define SCAN_BUF_CNT 2
1018 #define SCAN_BUF_NEXT 1
1019 #define WL_SCANTYPE_LEGACY 0x1
1020 #define WL_SCANTYPE_P2P 0x2
1021 #define wl_escan_set_sync_id(a, b) ((a) = htod16(0x1234))
1022 #define wl_escan_set_type(a, b)
1023 #define wl_escan_get_buf(a, b) ((wl_scan_results_t *) (a)->escan_info.escan_buf)
1024 #define wl_escan_check_sync_id(a, b, c) 0
1025 #define wl_escan_print_sync_id(a, b, c)
1026 #define wl_escan_increment_sync_id(a, b)
1027 #define wl_escan_init_sync_id(a)
1028 extern void wl_cfg80211_ibss_vsie_set_buffer(vndr_ie_setbuf_t *ibss_vsie, int ibss_vsie_len);
1029 extern s32 wl_cfg80211_ibss_vsie_delete(struct net_device *dev);
1030 extern void wl_cfg80211_set_rmc_pid(int pid);
1033 /* Action frame specific functions */
1034 extern u8 wl_get_action_category(void *frame, u32 frame_len);
1035 extern int wl_get_public_action(void *frame, u32 frame_len, u8 *ret_action);
1037 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
1038 struct net_device *wl_cfg80211_get_remain_on_channel_ndev(struct bcm_cfg80211 *cfg);
1039 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
1041 #ifdef WL_SUPPORT_ACS
1042 #define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */
1043 #define IOCTL_RETRY_COUNT 5
1044 #define CHAN_NOISE_DUMMY -80
1045 #define OBSS_TOKEN_IDX 15
1046 #define IBSS_TOKEN_IDX 15
1047 #define TX_TOKEN_IDX 14
1048 #define CTG_TOKEN_IDX 13
1049 #define PKT_TOKEN_IDX 15
1050 #define IDLE_TOKEN_IDX 12
1051 #endif /* WL_SUPPORT_ACS */
1053 extern int wl_cfg80211_get_ioctl_version(void);
1054 extern int wl_cfg80211_enable_roam_offload(struct net_device *dev, int enable);
1057 extern int wl_cfg80211_nan_cmd_handler(struct net_device *ndev, char *cmd,
1061 #ifdef WL_CFG80211_P2P_DEV_IF
1062 extern void wl_cfg80211_del_p2p_wdev(void);
1063 #endif /* WL_CFG80211_P2P_DEV_IF */
1066 extern uint8 *wl_get_up_table(void);
1067 #endif /* QOS_MAP_SET */
1069 #endif /* _wl_cfg80211_h_ */