2 * Linux cfg80211 driver
4 * $Copyright Open Broadcom Corporation$
6 * $Id: wl_cfg80211.h 505096 2014-09-26 12:49:04Z $
10 * Older Linux versions support the 'iw' interface, more recent ones the 'cfg80211' interface.
13 #ifndef _wl_cfg80211_h_
14 #define _wl_cfg80211_h_
16 #include <linux/wireless.h>
18 #include <proto/ethernet.h>
20 #include <linux/wireless.h>
21 #include <net/cfg80211.h>
22 #include <linux/rfkill.h>
24 #include <wl_cfgp2p.h>
37 #define htodchanspec(i) (i)
38 #define dtohchanspec(i) (i)
41 #define WL_DBG_P2P_ACTION (1 << 5)
42 #define WL_DBG_TRACE (1 << 4)
43 #define WL_DBG_SCAN (1 << 3)
44 #define WL_DBG_DBG (1 << 2)
45 #define WL_DBG_INFO (1 << 1)
46 #define WL_DBG_ERR (1 << 0)
48 /* 0 invalidates all debug messages. default is 1 */
49 #define WL_DBG_LEVEL 0xFF
51 #define CFG80211_ERROR_TEXT "CFG80211-ERROR) "
53 #define MAX_WAIT_TIME 1500
54 #define DNGL_FUNC(func, parameters) func parameters;
59 #if defined(DHD_DEBUG)
60 #define WL_ERR(args) \
62 if (wl_dbg_level & WL_DBG_ERR) { \
63 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
67 #else /* defined(DHD_DEBUG) */
68 #define WL_ERR(args) \
70 if ((wl_dbg_level & WL_DBG_ERR) && net_ratelimit()) { \
71 printk(KERN_INFO CFG80211_ERROR_TEXT "%s : ", __func__); \
75 #endif /* defined(DHD_DEBUG) */
81 #define WL_INFORM(args) \
83 if (wl_dbg_level & WL_DBG_INFO) { \
84 printk(KERN_INFO "CFG80211-INFO) %s : ", __func__); \
93 #define WL_SCAN(args) \
95 if (wl_dbg_level & WL_DBG_SCAN) { \
96 printk(KERN_INFO "CFG80211-SCAN) %s :", __func__); \
103 #define WL_TRACE(args) \
105 if (wl_dbg_level & WL_DBG_TRACE) { \
106 printk(KERN_INFO "CFG80211-TRACE) %s :", __func__); \
113 #define WL_TRACE_HW4 WL_TRACE
114 #if (WL_DBG_LEVEL > 0)
115 #define WL_DBG(args) \
117 if (wl_dbg_level & WL_DBG_DBG) { \
118 printk(KERN_INFO "CFG80211-DEBUG) %s :", __func__); \
122 #else /* !(WL_DBG_LEVEL > 0) */
124 #endif /* (WL_DBG_LEVEL > 0) */
129 #define WL_SCAN_RETRY_MAX 3
130 #define WL_NUM_PMKIDS_MAX MAXPMKID
131 #define WL_SCAN_BUF_MAX (1024 * 8)
132 #define WL_TLV_INFO_MAX 1500
133 #define WL_SCAN_IE_LEN_MAX 2048
134 #define WL_BSS_INFO_MAX 2048
135 #define WL_ASSOC_INFO_MAX 512
136 #define WL_IOCTL_LEN_MAX 2048
137 #define WL_EXTRA_BUF_MAX 2048
138 #define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
139 #define WL_AP_MAX 256
140 #define WL_FILE_NAME_MAX 256
141 #define WL_DWELL_TIME 200
142 #define WL_MED_DWELL_TIME 400
143 #define WL_MIN_DWELL_TIME 100
144 #define WL_LONG_DWELL_TIME 1000
145 #define IFACE_MAX_CNT 2
146 #define WL_SCAN_CONNECT_DWELL_TIME_MS 200
147 #define WL_SCAN_JOIN_PROBE_INTERVAL_MS 20
148 #define WL_SCAN_JOIN_ACTIVE_DWELL_TIME_MS 320
149 #define WL_SCAN_JOIN_PASSIVE_DWELL_TIME_MS 400
150 #define WL_AF_TX_MAX_RETRY 5
152 #define WL_AF_SEARCH_TIME_MAX 450
153 #define WL_AF_TX_EXTRA_TIME_MAX 200
155 #define WL_SCAN_TIMER_INTERVAL_MS 10000 /* Scan timeout */
156 #define WL_CHANNEL_SYNC_RETRY 5
157 #define WL_INVALID -1
159 /* Bring down SCB Timeout to 20secs from 60secs default */
160 #ifndef WL_SCB_TIMEOUT
161 #define WL_SCB_TIMEOUT 20
164 /* SCAN_SUPPRESS timer values in ms */
165 #define WL_SCAN_SUPPRESS_TIMEOUT 31000 /* default Framwork DHCP timeout is 30 sec */
166 #define WL_SCAN_SUPPRESS_RETRY 3000
168 #define WL_PM_ENABLE_TIMEOUT 10000
171 /* Custom AIBSS beacon parameters */
172 #define AIBSS_INITIAL_MIN_BCN_DUR 500
173 #define AIBSS_MIN_BCN_DUR 5000
174 #define AIBSS_BCN_FLOOD_DUR 5000
181 WL_STATUS_SCAN_ABORTING,
182 WL_STATUS_CONNECTING,
184 WL_STATUS_DISCONNECTING,
185 WL_STATUS_AP_CREATING,
186 WL_STATUS_AP_CREATED,
187 /* whole sending action frame procedure:
188 * includes a) 'finding common channel' for public action request frame
189 * and b) 'sending af via 'actframe' iovar'
191 WL_STATUS_SENDING_ACT_FRM,
192 /* find a peer to go to a common channel before sending public action req frame */
193 WL_STATUS_FINDING_COMMON_CHANNEL,
194 /* waiting for next af to sync time of supplicant.
195 * it includes SENDING_ACT_FRM and WAITING_NEXT_ACT_FRM_LISTEN
197 WL_STATUS_WAITING_NEXT_ACT_FRM,
198 #ifdef WL_CFG80211_SYNC_GON
199 /* go to listen state to wait for next af after SENDING_ACT_FRM */
200 WL_STATUS_WAITING_NEXT_ACT_FRM_LISTEN,
201 #endif /* WL_CFG80211_SYNC_GON */
202 /* it will be set when upper layer requests listen and succeed in setting listen mode.
203 * if set, other scan request can abort current listen state
205 WL_STATUS_REMAINING_ON_CHANNEL,
206 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
207 /* it's fake listen state to keep current scan state.
208 * it will be set when upper layer requests listen but scan is running. then just run
209 * a expire timer without actual listen state.
210 * if set, other scan request does not need to abort scan.
212 WL_STATUS_FAKE_REMAINING_ON_CHANNEL
213 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
223 /* driver profile list */
237 /* donlge escan state */
238 enum wl_escan_state {
240 WL_ESCAN_STATE_SCANING
242 /* fw downloading status */
245 WL_NVRAM_LOADING_DONE
248 enum wl_management_type {
254 enum wl_handler_del_type {
261 /* beacon / probe_response */
262 struct beacon_proberesp {
267 } __attribute__ ((packed));
269 /* driver configuration */
276 struct ieee80211_channel channel;
279 typedef s32(*EVENT_HANDLER) (struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev,
280 const wl_event_msg_t *e, void *data);
282 /* bss inform structure for cfg80211 interface */
283 struct wl_cfg80211_bss_info {
291 /* basic structure of scan request */
293 struct wlc_ssid ssid;
296 /* basic structure of information element */
299 u8 buf[WL_TLV_INFO_MAX];
302 /* event queue for cfg80211 main event */
304 struct list_head eq_list;
310 /* security information with currently associated ap */
317 u32 auth_assoc_res_status;
320 /* ibss information for currently joined ibss network */
322 u8 beacon_interval; /* in millisecond */
323 u8 atim; /* in millisecond */
329 /* cfg driver profile */
334 struct wlc_ssid ssid;
335 struct wl_security sec;
337 u8 bssid[ETHER_ADDR_LEN];
344 struct net_device *ndev;
345 struct wireless_dev *wdev;
346 struct wl_profile profile;
349 unsigned long sme_state;
353 struct list_head list; /* list of all net_info structure */
356 /* association inform */
357 #define MAX_REQ_LINE 1024
358 struct wl_connect_info {
359 u8 req_ie[MAX_REQ_LINE];
361 u8 resp_ie[MAX_REQ_LINE];
365 /* firmware /nvram downloading controller */
367 const struct firmware *fw_entry;
368 unsigned long status;
370 s8 fw_name[WL_FILE_NAME_MAX];
371 s8 nvram_name[WL_FILE_NAME_MAX];
374 /* assoc ie length */
375 struct wl_assoc_ielen {
383 pmkid_t foo[MAXPMKID - 1];
387 #define ESCAN_BUF_SIZE (64 * 1024)
391 #if defined(STATIC_WL_PRIV_STRUCT)
392 #ifndef CONFIG_DHD_USE_STATIC_BUF
393 #error STATIC_WL_PRIV_STRUCT should be used with CONFIG_DHD_USE_STATIC_BUF
394 #endif /* CONFIG_DHD_USE_STATIC_BUF */
397 u8 escan_buf[ESCAN_BUF_SIZE];
398 #endif /* STATIC_WL_PRIV_STRUCT */
400 struct net_device *ndev;
403 #ifdef ESCAN_BUF_OVERFLOW_MGMT
404 #define BUF_OVERFLOW_MGMT_COUNT 3
408 struct ether_addr BSSID;
410 #endif /* ESCAN_BUF_OVERFLOW_MGMT */
413 /* Structure to hold WPS, WPA IEs for a AP */
414 u8 probe_res_ie[VNDR_IES_MAX_BUF_LEN];
415 u8 beacon_ie[VNDR_IES_MAX_BUF_LEN];
416 u8 assoc_res_ie[VNDR_IES_MAX_BUF_LEN];
417 u32 probe_res_ie_len;
419 u32 assoc_res_ie_len;
427 /* Structure to hold WPS IE for a STA */
428 u8 probe_req_ie[VNDR_IES_BUF_LEN];
429 u8 assoc_req_ie[VNDR_IES_BUF_LEN];
430 u32 probe_req_ie_len;
431 u32 assoc_req_ie_len;
435 wl_af_params_t *pending_tx_act_frm;
436 struct ether_addr tx_dst_addr;
437 struct net_device *dev;
438 struct work_struct work;
442 s32 peer_listen_chan; /* search channel: configured by upper layer */
443 s32 my_listen_chan; /* listen chanel: extract it from prb req or gon req */
450 wpa_ie_fixed_t *wps_ie;
452 wpa_ie_fixed_t *wpa_ie;
459 /* Service discovery */
461 uint8 transaction_id; /* Transaction ID */
462 uint8 protocol; /* Service protocol type */
463 uint16 query_len; /* Length of query */
464 uint16 response_len; /* Length of response */
469 uint16 period; /* extended listen period */
470 uint16 interval; /* extended listen interval */
473 #define WL_SD_STATE_IDLE 0x0000
474 #define WL_SD_SEARCH_SVC 0x0001
475 #define WL_SD_ADV_SVC 0x0002
483 #define MAX_SDO_PROTO_STR_LEN 20
484 typedef struct wl_sdo_proto {
485 char str[MAX_SDO_PROTO_STR_LEN];
489 typedef struct sd_offload {
491 enum wl_dd_state dd_state;
492 wl_sd_listen_t sd_listen;
495 typedef struct sdo_event {
497 uint16 freq; /* channel Freq */
498 uint8 count; /* Tlv count */
504 /* Max length of Interworking element */
505 #define IW_IES_MAX_BUF_LEN 9
508 #define FBT_KEYLEN 32
510 #define MAX_EVENT_BUF_NUM 16
511 typedef struct wl_eventmsg_buf {
516 } event [MAX_EVENT_BUF_NUM];
519 typedef struct wl_if_event_info {
523 uint8 mac[ETHER_ADDR_LEN];
524 char name[IFNAMSIZ+1];
527 /* private data of cfg80211 interface */
528 struct bcm_cfg80211 {
529 struct wireless_dev *wdev; /* representing cfg cfg80211 device */
531 struct wireless_dev *p2p_wdev; /* representing cfg cfg80211 device for P2P */
532 struct net_device *p2p_net; /* reference to p2p0 interface */
534 struct wl_conf *conf;
535 struct cfg80211_scan_request *scan_request; /* scan request object */
536 EVENT_HANDLER evt_handler[WLC_E_LAST];
537 struct list_head eq_list; /* used for event queue */
538 struct list_head net_list; /* used for struct net_info */
539 spinlock_t eq_lock; /* for event queue synchronization */
540 spinlock_t cfgdrv_lock; /* to protect scan status (and others if needed) */
541 struct completion act_frm_scan;
542 struct completion iface_disable;
543 struct completion wait_next_af;
544 struct mutex usr_sync; /* maily for up/down synchronization */
545 struct wl_scan_results *bss_list;
546 struct wl_scan_results *scan_results;
548 /* scan request object for internal purpose */
549 struct wl_scan_req *scan_req_int;
550 /* information element object for internal purpose */
551 #if defined(STATIC_WL_PRIV_STRUCT)
557 /* association information container */
558 #if defined(STATIC_WL_PRIV_STRUCT)
559 struct wl_connect_info *conn_info;
561 struct wl_connect_info conn_info;
563 #ifdef DEBUGFS_CFG80211
564 struct dentry *debugfs;
565 #endif /* DEBUGFS_CFG80211 */
566 struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
567 tsk_ctl_t event_tsk; /* task of main event handler thread */
570 u32 channel; /* current channel */
571 u32 af_sent_channel; /* channel action frame is sent */
572 /* next af subtype to cancel the remained dwell time in rx process */
574 #ifdef WL_CFG80211_SYNC_GON
575 ulong af_tx_sent_jiffies;
576 #endif /* WL_CFG80211_SYNC_GON */
577 struct escan_info escan_info; /* escan information */
578 bool active_scan; /* current scan mode */
579 bool ibss_starter; /* indicates this sta is ibss starter */
580 bool link_up; /* link/connection up flag */
582 /* indicate whether chip to support power save mode */
584 bool roam_on; /* on/off switch for self-roaming */
585 bool scan_tried; /* indicates if first scan attempted */
586 #if defined(BCMSDIO) || defined(BCMPCIE)
590 bool roamoff_on_concurrent;
591 u8 *ioctl_buf; /* ioctl buffer */
592 struct mutex ioctl_buf_sync;
594 u8 *extra_buf; /* maily to grab assoc information */
595 struct dentry *debugfsdir;
596 struct rfkill *rfkill;
598 struct ieee80211_channel remain_on_chan;
599 enum nl80211_channel_type remain_on_chan_type;
602 wait_queue_head_t netif_change_event;
603 wl_if_event_info if_event_info;
604 struct completion send_af_done;
605 struct afx_hdl *afx_hdl;
606 struct ap_info *ap_info;
607 struct sta_info *sta_info;
608 struct p2p_info *p2p;
611 struct timer_list scan_timeout; /* Timer for catch scan event timeout */
612 s32(*state_notifier) (struct bcm_cfg80211 *cfg,
613 struct net_info *_net_info, enum wl_status state, bool set);
614 unsigned long interrested_state;
615 wlc_ssid_t hostapd_ssid;
621 u8 iw_ie[IW_IES_MAX_BUF_LEN];
624 bool sched_scan_running; /* scheduled scan req status */
626 struct cfg80211_sched_scan_request *sched_scan_req; /* scheduled scan req */
627 #endif /* WL_SCHED_SCAN */
628 #ifdef WL_HOST_BAND_MGMT
630 #endif /* WL_HOST_BAND_MGMT */
631 bool scan_suppressed;
632 struct timer_list scan_supp_timer;
633 struct work_struct wlan_work;
634 struct mutex event_sync; /* maily for up/down synchronization */
635 bool disable_roam_event;
636 bool pm_enable_work_on;
637 struct delayed_work pm_enable_work;
638 vndr_ie_setbuf_t *ibss_vsie; /* keep the VSIE for IBSS */
641 u32 aibss_txfail_pid;
642 u32 aibss_txfail_seq;
647 struct ether_addr ibss_if_addr;
648 bcm_struct_cfgdev *ibss_cfgdev; /* For AIBSS */
649 #endif /* WLAIBSS_MCHAN */
650 bcm_struct_cfgdev *bss_cfgdev; /* For DUAL STA/STA+AP */
652 bool bss_pending_op; /* indicate where there is a pending IF operation */
654 uint8 fbt_key[FBT_KEYLEN];
658 #ifdef P2PLISTEN_AP_SAMECHN
659 bool p2p_resp_apchn_status;
660 #endif /* P2PLISTEN_AP_SAMECHN */
663 u32 tdls_mgmt_frame_len;
669 static inline struct wl_bss_info *next_bss(struct wl_scan_results *list, struct wl_bss_info *bss)
672 (struct wl_bss_info *)((uintptr) bss + dtoh32(bss->length)) : list->bss_info;
675 wl_alloc_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev,
676 struct wireless_dev * wdev, s32 mode, bool pm_block)
678 struct net_info *_net_info;
680 if (cfg->iface_cnt == IFACE_MAX_CNT)
682 _net_info = kzalloc(sizeof(struct net_info), GFP_KERNEL);
686 _net_info->mode = mode;
687 _net_info->ndev = ndev;
688 _net_info->wdev = wdev;
689 _net_info->pm_restore = 0;
691 _net_info->pm_block = pm_block;
692 _net_info->roam_off = WL_INVALID;
694 list_add(&_net_info->list, &cfg->net_list);
699 wl_dealloc_netinfo(struct bcm_cfg80211 *cfg, struct net_device *ndev)
701 struct net_info *_net_info, *next;
703 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
704 if (ndev && (_net_info->ndev == ndev)) {
705 list_del(&_net_info->list);
713 wl_delete_all_netinfo(struct bcm_cfg80211 *cfg)
715 struct net_info *_net_info, *next;
717 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
718 list_del(&_net_info->list);
720 kfree(_net_info->wdev);
726 wl_get_status_all(struct bcm_cfg80211 *cfg, s32 status)
729 struct net_info *_net_info, *next;
731 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
732 if (_net_info->ndev &&
733 test_bit(status, &_net_info->sme_state))
739 wl_set_status_all(struct bcm_cfg80211 *cfg, s32 status, u32 op)
741 struct net_info *_net_info, *next;
742 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
745 return; /* set all status is not allowed */
747 clear_bit(status, &_net_info->sme_state);
748 if (cfg->state_notifier &&
749 test_bit(status, &(cfg->interrested_state)))
750 cfg->state_notifier(cfg, _net_info, status, false);
753 return; /* change all status is not allowed */
755 return; /* unknown operation */
760 wl_set_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
761 struct net_device *ndev, u32 op)
764 struct net_info *_net_info, *next;
766 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
767 if (ndev && (_net_info->ndev == ndev)) {
770 set_bit(status, &_net_info->sme_state);
771 if (cfg->state_notifier &&
772 test_bit(status, &(cfg->interrested_state)))
773 cfg->state_notifier(cfg, _net_info, status, true);
776 clear_bit(status, &_net_info->sme_state);
777 if (cfg->state_notifier &&
778 test_bit(status, &(cfg->interrested_state)))
779 cfg->state_notifier(cfg, _net_info, status, false);
782 change_bit(status, &_net_info->sme_state);
792 wl_get_status_by_netdev(struct bcm_cfg80211 *cfg, s32 status,
793 struct net_device *ndev)
795 struct net_info *_net_info, *next;
797 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
798 if (ndev && (_net_info->ndev == ndev))
799 return test_bit(status, &_net_info->sme_state);
805 wl_get_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
807 struct net_info *_net_info, *next;
809 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
810 if (ndev && (_net_info->ndev == ndev))
811 return _net_info->mode;
818 wl_set_mode_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev,
821 struct net_info *_net_info, *next;
823 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
824 if (ndev && (_net_info->ndev == ndev))
825 _net_info->mode = mode;
828 static inline struct wl_profile *
829 wl_get_profile_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
831 struct net_info *_net_info, *next;
833 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
834 if (ndev && (_net_info->ndev == ndev))
835 return &_net_info->profile;
839 static inline struct net_info *
840 wl_get_netinfo_by_netdev(struct bcm_cfg80211 *cfg, struct net_device *ndev)
842 struct net_info *_net_info, *next;
844 list_for_each_entry_safe(_net_info, next, &cfg->net_list, list) {
845 if (ndev && (_net_info->ndev == ndev))
850 #define bcmcfg_to_wiphy(cfg) (cfg->wdev->wiphy)
851 #define bcmcfg_to_prmry_ndev(cfg) (cfg->wdev->netdev)
852 #define bcmcfg_to_prmry_wdev(cfg) (cfg->wdev)
853 #define bcmcfg_to_p2p_wdev(cfg) (cfg->p2p_wdev)
854 #define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
855 #define ndev_to_wdev(ndev) (ndev->ieee80211_ptr)
856 #define wdev_to_ndev(wdev) (wdev->netdev)
858 #if defined(WL_ENABLE_P2P_IF)
859 #define ndev_to_wlc_ndev(ndev, cfg) ((ndev == cfg->p2p_net) ? \
860 bcmcfg_to_prmry_ndev(cfg) : ndev)
862 #define ndev_to_wlc_ndev(ndev, cfg) (ndev)
863 #endif /* WL_ENABLE_P2P_IF */
865 #if defined(WL_CFG80211_P2P_DEV_IF)
866 #define wdev_to_wlc_ndev(wdev, cfg) \
867 ((wdev->iftype == NL80211_IFTYPE_P2P_DEVICE) ? \
868 bcmcfg_to_prmry_ndev(cfg) : wdev_to_ndev(wdev))
869 #define cfgdev_to_wlc_ndev(cfgdev, cfg) wdev_to_wlc_ndev(cfgdev, cfg)
870 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_wdev(cfg)
871 #elif defined(WL_ENABLE_P2P_IF)
872 #define cfgdev_to_wlc_ndev(cfgdev, cfg) ndev_to_wlc_ndev(cfgdev, cfg)
873 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) bcmcfg_to_prmry_ndev(cfg)
875 #define cfgdev_to_wlc_ndev(cfgdev, cfg) (cfgdev)
876 #define bcmcfg_to_prmry_cfgdev(cfgdev, cfg) (cfgdev)
877 #endif /* WL_CFG80211_P2P_DEV_IF */
879 #if defined(WL_CFG80211_P2P_DEV_IF)
880 #define ndev_to_cfgdev(ndev) ndev_to_wdev(ndev)
881 #define cfgdev_to_ndev(cfgdev) cfgdev ? (cfgdev->netdev) : NULL
882 #define discover_cfgdev(cfgdev, cfg) (cfgdev->iftype == NL80211_IFTYPE_P2P_DEVICE)
884 #define ndev_to_cfgdev(ndev) (ndev)
885 #define cfgdev_to_ndev(cfgdev) (cfgdev)
886 #define discover_cfgdev(cfgdev, cfg) (cfgdev == cfg->p2p_net)
887 #endif /* WL_CFG80211_P2P_DEV_IF */
889 #if defined(WL_CFG80211_P2P_DEV_IF)
890 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
891 (cfg->scan_request->wdev == cfg->p2p_wdev)) ? true : false)
892 #elif defined(WL_ENABLE_P2P_IF)
893 #define scan_req_match(cfg) (((cfg) && (cfg->scan_request) && \
894 (cfg->scan_request->dev == cfg->p2p_net)) ? true : false)
896 #define scan_req_match(cfg) (((cfg) && p2p_is_on(cfg) && p2p_scan(cfg)) ? \
898 #endif /* WL_CFG80211_P2P_DEV_IF */
900 #define wl_to_sr(w) (w->scan_req_int)
901 #if defined(STATIC_WL_PRIV_STRUCT)
902 #define wl_to_ie(w) (w->ie)
903 #define wl_to_conn(w) (w->conn_info)
905 #define wl_to_ie(w) (&w->ie)
906 #define wl_to_conn(w) (&w->conn_info)
908 #define wiphy_from_scan(w) (w->escan_info.wiphy)
909 #define wl_get_drv_status_all(cfg, stat) \
910 (wl_get_status_all(cfg, WL_STATUS_ ## stat))
911 #define wl_get_drv_status(cfg, stat, ndev) \
912 (wl_get_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev))
913 #define wl_set_drv_status(cfg, stat, ndev) \
914 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 1))
915 #define wl_clr_drv_status(cfg, stat, ndev) \
916 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 2))
917 #define wl_clr_drv_status_all(cfg, stat) \
918 (wl_set_status_all(cfg, WL_STATUS_ ## stat, 2))
919 #define wl_chg_drv_status(cfg, stat, ndev) \
920 (wl_set_status_by_netdev(cfg, WL_STATUS_ ## stat, ndev, 4))
922 #define for_each_bss(list, bss, __i) \
923 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
925 #define for_each_ndev(cfg, iter, next) \
926 list_for_each_entry_safe(iter, next, &cfg->net_list, list)
929 /* In case of WPS from wpa_supplicant, pairwise siute and group suite is 0.
930 * In addtion to that, wpa_version is WPA_VERSION_1
932 #define is_wps_conn(_sme) \
933 ((wl_cfgp2p_find_wpsie((u8 *)_sme->ie, _sme->ie_len) != NULL) && \
934 (!_sme->crypto.n_ciphers_pairwise) && \
935 (!_sme->crypto.cipher_group))
936 extern s32 wl_cfg80211_attach(struct net_device *ndev, void *context);
937 extern s32 wl_cfg80211_attach_post(struct net_device *ndev);
938 extern void wl_cfg80211_detach(void *para);
940 extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
942 void wl_cfg80211_set_parent_dev(void *dev);
943 struct device *wl_cfg80211_get_parent_dev(void);
945 extern s32 wl_cfg80211_up(void *para);
946 extern s32 wl_cfg80211_down(void *para);
947 extern s32 wl_cfg80211_notify_ifadd(int ifidx, char *name, uint8 *mac, uint8 bssidx);
948 extern s32 wl_cfg80211_notify_ifdel(int ifidx, char *name, uint8 *mac, uint8 bssidx);
949 extern s32 wl_cfg80211_notify_ifchange(int ifidx, char *name, uint8 *mac, uint8 bssidx);
950 extern struct net_device* wl_cfg80211_allocate_if(struct bcm_cfg80211 *cfg, int ifidx, char *name,
951 uint8 *mac, uint8 bssidx);
952 extern int wl_cfg80211_register_if(struct bcm_cfg80211 *cfg, int ifidx, struct net_device* ndev);
953 extern int wl_cfg80211_remove_if(struct bcm_cfg80211 *cfg, int ifidx, struct net_device* ndev);
954 extern int wl_cfg80211_scan_stop(bcm_struct_cfgdev *cfgdev);
955 extern bool wl_cfg80211_is_vsdb_mode(void);
956 extern void* wl_cfg80211_get_dhdp(void);
957 extern bool wl_cfg80211_is_p2p_active(void);
958 extern void wl_cfg80211_dbg_level(u32 level);
959 extern s32 wl_cfg80211_get_p2p_dev_addr(struct net_device *net, struct ether_addr *p2pdev_addr);
960 extern s32 wl_cfg80211_set_p2p_noa(struct net_device *net, char* buf, int len);
961 extern s32 wl_cfg80211_get_p2p_noa(struct net_device *net, char* buf, int len);
962 extern s32 wl_cfg80211_set_wps_p2p_ie(struct net_device *net, char *buf, int len,
963 enum wl_management_type type);
964 extern s32 wl_cfg80211_set_p2p_ps(struct net_device *net, char* buf, int len);
965 #ifdef P2PLISTEN_AP_SAMECHN
966 extern s32 wl_cfg80211_set_p2p_resp_ap_chn(struct net_device *net, s32 enable);
967 #endif /* P2PLISTEN_AP_SAMECHN */
969 /* btcoex functions */
970 void* wl_cfg80211_btcoex_init(struct net_device *ndev);
971 void wl_cfg80211_btcoex_deinit(void);
974 extern s32 wl_cfg80211_sdo_init(struct bcm_cfg80211 *cfg);
975 extern s32 wl_cfg80211_sdo_deinit(struct bcm_cfg80211 *cfg);
976 extern s32 wl_cfg80211_sd_offload(struct net_device *net, char *cmd, char* buf, int len);
977 extern s32 wl_cfg80211_pause_sdo(struct net_device *dev, struct bcm_cfg80211 *cfg);
978 extern s32 wl_cfg80211_resume_sdo(struct net_device *dev, struct bcm_cfg80211 *cfg);
982 #ifdef WL_SUPPORT_AUTO_CHANNEL
983 #define CHANSPEC_BUF_SIZE 1024
984 #define CHAN_SEL_IOCTL_DELAY 300
985 #define CHAN_SEL_RETRY_COUNT 15
986 #define CHANNEL_IS_RADAR(channel) (((channel & WL_CHAN_RADAR) || \
987 (channel & WL_CHAN_PASSIVE)) ? true : false)
988 #define CHANNEL_IS_2G(channel) (((channel >= 1) && (channel <= 14)) ? \
990 #define CHANNEL_IS_5G(channel) (((channel >= 36) && (channel <= 165)) ? \
992 extern s32 wl_cfg80211_get_best_channels(struct net_device *dev, char* command,
994 #endif /* WL_SUPPORT_AUTO_CHANNEL */
996 extern int wl_cfg80211_ether_atoe(const char *a, struct ether_addr *n);
997 extern int wl_cfg80211_hex_str_to_bin(unsigned char *data, int dlen, char *str);
998 extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
999 extern s32 wl_mode_to_nl80211_iftype(s32 mode);
1000 int wl_cfg80211_do_driver_init(struct net_device *net);
1001 void wl_cfg80211_enable_trace(u32 level);
1002 extern s32 wl_update_wiphybands(struct bcm_cfg80211 *cfg, bool notify);
1003 extern s32 wl_cfg80211_if_is_group_owner(void);
1004 extern chanspec_t wl_chspec_host_to_driver(chanspec_t chanspec);
1005 extern chanspec_t wl_ch_host_to_driver(u16 channel);
1006 extern s32 wl_set_tx_power(struct net_device *dev,
1007 enum nl80211_tx_power_setting type, s32 dbm);
1008 extern s32 wl_get_tx_power(struct net_device *dev, s32 *dbm);
1009 extern s32 wl_add_remove_eventmsg(struct net_device *ndev, u16 event, bool add);
1010 extern void wl_stop_wait_next_action_frame(struct bcm_cfg80211 *cfg, struct net_device *ndev);
1011 #ifdef WL_HOST_BAND_MGMT
1012 extern s32 wl_cfg80211_set_band(struct net_device *ndev, int band);
1013 #endif /* WL_HOST_BAND_MGMT */
1014 #if defined(DHCP_SCAN_SUPPRESS)
1015 extern int wl_cfg80211_scan_suppress(struct net_device *dev, int suppress);
1016 #endif /* OEM_ANDROID */
1017 extern void wl_cfg80211_add_to_eventbuffer(wl_eventmsg_buf_t *ev, u16 event, bool set);
1018 extern s32 wl_cfg80211_apply_eventbuffer(struct net_device *ndev,
1019 struct bcm_cfg80211 *cfg, wl_eventmsg_buf_t *ev);
1020 extern void get_primary_mac(struct bcm_cfg80211 *cfg, struct ether_addr *mac);
1021 extern void wl_cfg80211_update_power_mode(struct net_device *dev);
1022 #define SCAN_BUF_CNT 2
1023 #define SCAN_BUF_NEXT 1
1024 #define WL_SCANTYPE_LEGACY 0x1
1025 #define WL_SCANTYPE_P2P 0x2
1026 #define wl_escan_set_sync_id(a, b) ((a) = htod16(0x1234))
1027 #define wl_escan_set_type(a, b)
1028 #define wl_escan_get_buf(a, b) ((wl_scan_results_t *) (a)->escan_info.escan_buf)
1029 #define wl_escan_check_sync_id(a, b, c) 0
1030 #define wl_escan_print_sync_id(a, b, c)
1031 #define wl_escan_increment_sync_id(a, b)
1032 #define wl_escan_init_sync_id(a)
1033 extern void wl_cfg80211_ibss_vsie_set_buffer(vndr_ie_setbuf_t *ibss_vsie, int ibss_vsie_len);
1034 extern s32 wl_cfg80211_ibss_vsie_delete(struct net_device *dev);
1036 extern void wl_cfg80211_set_txfail_pid(int pid);
1037 #endif /* WLAIBSS */
1038 extern void wl_cfg80211_set_rmc_pid(int pid);
1041 extern void wl_cfg80211_get_fbt_key(uint8 *key);
1044 /* Action frame specific functions */
1045 extern u8 wl_get_action_category(void *frame, u32 frame_len);
1046 extern int wl_get_public_action(void *frame, u32 frame_len, u8 *ret_action);
1048 #ifdef WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST
1049 struct net_device *wl_cfg80211_get_remain_on_channel_ndev(struct bcm_cfg80211 *cfg);
1050 #endif /* WL_CFG80211_VSDB_PRIORITIZE_SCAN_REQUEST */
1052 #ifdef WL_SUPPORT_ACS
1053 #define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */
1054 #define IOCTL_RETRY_COUNT 5
1055 #define CHAN_NOISE_DUMMY -80
1056 #define OBSS_TOKEN_IDX 15
1057 #define IBSS_TOKEN_IDX 15
1058 #define TX_TOKEN_IDX 14
1059 #define CTG_TOKEN_IDX 13
1060 #define PKT_TOKEN_IDX 15
1061 #define IDLE_TOKEN_IDX 12
1062 #endif /* WL_SUPPORT_ACS */
1064 extern int wl_cfg80211_get_ioctl_version(void);
1065 extern int wl_cfg80211_enable_roam_offload(struct net_device *dev, int enable);
1068 extern int wl_cfg80211_nan_cmd_handler(struct net_device *ndev, char *cmd,
1072 #ifdef WL_CFG80211_P2P_DEV_IF
1073 extern void wl_cfg80211_del_p2p_wdev(void);
1074 #endif /* WL_CFG80211_P2P_DEV_IF */
1076 #endif /* _wl_cfg80211_h_ */