1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Header for Linux cfg80211 scan 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Copyright (C) 2020, Broadcom. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Unless you and Broadcom execute a separate written software license 7*4882a593Smuzhiyun * agreement governing use of this software, this software is licensed to you 8*4882a593Smuzhiyun * under the terms of the GNU General Public License version 2 (the "GPL"), 9*4882a593Smuzhiyun * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10*4882a593Smuzhiyun * following added to such license: 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * As a special exception, the copyright holders of this software give you 13*4882a593Smuzhiyun * permission to link this software with independent modules, and to copy and 14*4882a593Smuzhiyun * distribute the resulting executable under terms of your choice, provided that 15*4882a593Smuzhiyun * you also meet, for each linked independent module, the terms and conditions of 16*4882a593Smuzhiyun * the license of that module. An independent module is a module which is not 17*4882a593Smuzhiyun * derived from this software. The special exception does not apply to any 18*4882a593Smuzhiyun * modifications of the software. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * 21*4882a593Smuzhiyun * <<Broadcom-WL-IPTag/Dual:>> 22*4882a593Smuzhiyun */ 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun #ifndef _wl_cfgscan_h_ 25*4882a593Smuzhiyun #define _wl_cfgscan_h_ 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun #include <linux/wireless.h> 28*4882a593Smuzhiyun #include <typedefs.h> 29*4882a593Smuzhiyun #include <ethernet.h> 30*4882a593Smuzhiyun #include <wlioctl.h> 31*4882a593Smuzhiyun #include <linux/wireless.h> 32*4882a593Smuzhiyun #include <net/cfg80211.h> 33*4882a593Smuzhiyun #include <linux/rfkill.h> 34*4882a593Smuzhiyun #include <osl.h> 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) 37*4882a593Smuzhiyun #define GET_SCAN_WDEV(scan_request) \ 38*4882a593Smuzhiyun (scan_request && scan_request->dev) ? scan_request->dev->ieee80211_ptr : NULL; 39*4882a593Smuzhiyun #else 40*4882a593Smuzhiyun #define GET_SCAN_WDEV(scan_request) \ 41*4882a593Smuzhiyun scan_request ? scan_request->wdev : NULL; 42*4882a593Smuzhiyun #endif 43*4882a593Smuzhiyun #ifdef WL_SCHED_SCAN 44*4882a593Smuzhiyun #define GET_SCHED_SCAN_WDEV(scan_request) \ 45*4882a593Smuzhiyun (scan_request && scan_request->dev) ? scan_request->dev->ieee80211_ptr : NULL; 46*4882a593Smuzhiyun #endif /* WL_SCHED_SCAN */ 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun #ifdef DUAL_ESCAN_RESULT_BUFFER 49*4882a593Smuzhiyun #define wl_escan_set_sync_id(a, b) ((a) = (b)->escan_info.cur_sync_id) 50*4882a593Smuzhiyun #define wl_escan_set_type(a, b) ((a)->escan_info.escan_type\ 51*4882a593Smuzhiyun [((a)->escan_info.cur_sync_id)%SCAN_BUF_CNT] = (b)) 52*4882a593Smuzhiyun #else 53*4882a593Smuzhiyun #define wl_escan_set_sync_id(a, b) ((a) = htod16((b)->escan_sync_id_cntr++)) 54*4882a593Smuzhiyun #define wl_escan_set_type(a, b) 55*4882a593Smuzhiyun #endif /* DUAL_ESCAN_RESULT_BUFFER */ 56*4882a593Smuzhiyun extern s32 wl_escan_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev, 57*4882a593Smuzhiyun const wl_event_msg_t *e, void *data); 58*4882a593Smuzhiyun extern s32 wl_do_escan(struct bcm_cfg80211 *cfg, struct wiphy *wiphy, 59*4882a593Smuzhiyun struct net_device *ndev, struct cfg80211_scan_request *request); 60*4882a593Smuzhiyun extern s32 __wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, 61*4882a593Smuzhiyun struct cfg80211_scan_request *request, struct cfg80211_ssid *this_ssid); 62*4882a593Smuzhiyun #if defined(WL_CFG80211_P2P_DEV_IF) 63*4882a593Smuzhiyun extern s32 wl_cfg80211_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request); 64*4882a593Smuzhiyun #else 65*4882a593Smuzhiyun extern s32 wl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, 66*4882a593Smuzhiyun struct cfg80211_scan_request *request); 67*4882a593Smuzhiyun extern int wl_cfg80211_scan_stop(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev); 68*4882a593Smuzhiyun #endif /* WL_CFG80211_P2P_DEV_IF */ 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun #if defined(OEM_ANDROID) && defined(DHCP_SCAN_SUPPRESS) 71*4882a593Smuzhiyun extern void wl_cfg80211_work_handler(struct work_struct *work); 72*4882a593Smuzhiyun extern void wl_cfg80211_scan_supp_timerfunc(ulong data); 73*4882a593Smuzhiyun #endif /* DHCP_SCAN_SUPPRESS */ 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) 76*4882a593Smuzhiyun extern void wl_cfg80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev); 77*4882a593Smuzhiyun #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) */ 78*4882a593Smuzhiyun extern s32 wl_init_scan(struct bcm_cfg80211 *cfg); 79*4882a593Smuzhiyun extern int wl_cfg80211_scan_stop(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev); 80*4882a593Smuzhiyun extern s32 wl_notify_scan_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev, 81*4882a593Smuzhiyun const wl_event_msg_t *e, void *data); 82*4882a593Smuzhiyun extern void wl_cfg80211_set_passive_scan(struct net_device *dev, char *command); 83*4882a593Smuzhiyun #ifdef PNO_SUPPORT 84*4882a593Smuzhiyun extern s32 wl_notify_pfn_status(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev, 85*4882a593Smuzhiyun const wl_event_msg_t *e, void *data); 86*4882a593Smuzhiyun #endif /* PNO_SUPPORT */ 87*4882a593Smuzhiyun #ifdef GSCAN_SUPPORT 88*4882a593Smuzhiyun extern s32 wl_notify_gscan_event(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev, 89*4882a593Smuzhiyun const wl_event_msg_t *e, void *data); 90*4882a593Smuzhiyun #endif /* GSCAN_SUPPORT */ 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun #ifdef WES_SUPPORT 93*4882a593Smuzhiyun #ifdef CUSTOMER_SCAN_TIMEOUT_SETTING 94*4882a593Smuzhiyun #define CUSTOMER_WL_SCAN_TIMER_INTERVAL_MS 25000 /* Scan timeout */ 95*4882a593Smuzhiyun enum wl_custom_scan_time_type { 96*4882a593Smuzhiyun WL_CUSTOM_SCAN_CHANNEL_TIME = 0, 97*4882a593Smuzhiyun WL_CUSTOM_SCAN_UNASSOC_TIME, 98*4882a593Smuzhiyun WL_CUSTOM_SCAN_PASSIVE_TIME, 99*4882a593Smuzhiyun WL_CUSTOM_SCAN_HOME_TIME, 100*4882a593Smuzhiyun WL_CUSTOM_SCAN_HOME_AWAY_TIME 101*4882a593Smuzhiyun }; 102*4882a593Smuzhiyun extern s32 wl_cfg80211_custom_scan_time(struct net_device *dev, 103*4882a593Smuzhiyun enum wl_custom_scan_time_type type, int time); 104*4882a593Smuzhiyun #endif /* CUSTOMER_SCAN_TIMEOUT_SETTING */ 105*4882a593Smuzhiyun #endif /* WES_SUPPORT */ 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun #if defined(SUPPORT_RANDOM_MAC_SCAN) 108*4882a593Smuzhiyun int wl_cfg80211_set_random_mac(struct net_device *dev, bool enable); 109*4882a593Smuzhiyun int wl_cfg80211_random_mac_enable(struct net_device *dev); 110*4882a593Smuzhiyun int wl_cfg80211_random_mac_disable(struct net_device *dev); 111*4882a593Smuzhiyun int wl_cfg80211_scan_mac_enable(struct net_device *dev); 112*4882a593Smuzhiyun int wl_cfg80211_scan_mac_disable(struct net_device *dev); 113*4882a593Smuzhiyun int wl_cfg80211_scan_mac_config(struct net_device *dev, uint8 *rand_mac, uint8 *rand_mask); 114*4882a593Smuzhiyun #endif /* SUPPORT_RANDOM_MAC_SCAN */ 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun #ifdef WL_SCHED_SCAN 117*4882a593Smuzhiyun extern int wl_cfg80211_sched_scan_start(struct wiphy *wiphy, struct net_device *dev, 118*4882a593Smuzhiyun struct cfg80211_sched_scan_request *request); 119*4882a593Smuzhiyun #if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 11, 0)) 120*4882a593Smuzhiyun extern int wl_cfg80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev, u64 reqid); 121*4882a593Smuzhiyun #else 122*4882a593Smuzhiyun extern int wl_cfg80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev); 123*4882a593Smuzhiyun #endif /* LINUX_VER > 4.11 */ 124*4882a593Smuzhiyun #endif /* WL_SCHED_SCAN */ 125*4882a593Smuzhiyun extern s32 wl_cfgscan_listen_on_channel(struct bcm_cfg80211 *cfg, struct wireless_dev *wdev, 126*4882a593Smuzhiyun struct ieee80211_channel *channel, unsigned int duration); 127*4882a593Smuzhiyun extern void wl_cfgscan_listen_complete_work(struct work_struct *work); 128*4882a593Smuzhiyun extern s32 wl_cfgscan_notify_listen_complete(struct bcm_cfg80211 *cfg); 129*4882a593Smuzhiyun extern s32 wl_cfgscan_cancel_listen_on_channel(struct bcm_cfg80211 *cfg, bool notify_user); 130*4882a593Smuzhiyun #if defined(WL_CFG80211_P2P_DEV_IF) 131*4882a593Smuzhiyun extern s32 wl_cfgscan_remain_on_channel(struct wiphy *wiphy, bcm_struct_cfgdev *cfgdev, 132*4882a593Smuzhiyun struct ieee80211_channel *channel, unsigned int duration, u64 *cookie); 133*4882a593Smuzhiyun #else 134*4882a593Smuzhiyun extern s32 wl_cfgscan_remain_on_channel(struct wiphy *wiphy, bcm_struct_cfgdev *cfgdev, 135*4882a593Smuzhiyun struct ieee80211_channel *channel, enum nl80211_channel_type channel_type, 136*4882a593Smuzhiyun unsigned int duration, u64 *cookie); 137*4882a593Smuzhiyun #endif /* WL_CFG80211_P2P_DEV_IF */ 138*4882a593Smuzhiyun extern s32 wl_cfgscan_cancel_remain_on_channel(struct wiphy *wiphy, 139*4882a593Smuzhiyun bcm_struct_cfgdev *cfgdev, u64 cookie); 140*4882a593Smuzhiyun extern chanspec_t wl_freq_to_chanspec(int freq); 141*4882a593Smuzhiyun extern s32 wl_inform_single_bss(struct bcm_cfg80211 *cfg, wl_bss_info_t *bi, bool update_ssid); 142*4882a593Smuzhiyun #ifdef WL_GET_RCC 143*4882a593Smuzhiyun extern int wl_android_get_roam_scan_chanlist(struct bcm_cfg80211 *cfg); 144*4882a593Smuzhiyun #endif /* WL_GET_RCC */ 145*4882a593Smuzhiyun extern s32 wl_get_assoc_channels(struct bcm_cfg80211 *cfg, 146*4882a593Smuzhiyun struct net_device *dev, wlcfg_assoc_info_t *info); 147*4882a593Smuzhiyun extern void wl_cfgscan_cancel_scan(struct bcm_cfg80211 *cfg); 148*4882a593Smuzhiyun extern void wl_cfgscan_scan_abort(struct bcm_cfg80211 *cfg); 149*4882a593Smuzhiyun #ifdef DHD_GET_VALID_CHANNELS 150*4882a593Smuzhiyun typedef enum { 151*4882a593Smuzhiyun WIFI_BAND_UNSPECIFIED, 152*4882a593Smuzhiyun /* 2.4 GHz */ 153*4882a593Smuzhiyun WIFI_BAND_BG = 1, 154*4882a593Smuzhiyun /* 5 GHz without DFS */ 155*4882a593Smuzhiyun WIFI_BAND_A = 2, 156*4882a593Smuzhiyun /* 5 GHz DFS only */ 157*4882a593Smuzhiyun WIFI_BAND_A_DFS = 4, 158*4882a593Smuzhiyun /* 5 GHz with DFS */ 159*4882a593Smuzhiyun WIFI_BAND_A_WITH_DFS = 6, 160*4882a593Smuzhiyun /* 2.4 GHz + 5 GHz; no DFS */ 161*4882a593Smuzhiyun WIFI_BAND_ABG = 3, 162*4882a593Smuzhiyun /* 2.4 GHz + 5 GHz with DFS */ 163*4882a593Smuzhiyun WIFI_BAND_ABG_WITH_DFS = 7, 164*4882a593Smuzhiyun /* 6GHz */ 165*4882a593Smuzhiyun WIFI_BAND_6GHZ = 8, 166*4882a593Smuzhiyun /* 5 GHz no DFS + 6 GHz */ 167*4882a593Smuzhiyun WIFI_BAND_5GHZ_6GHZ = 10, 168*4882a593Smuzhiyun /* 2.4 GHz + 5 GHz no DFS + 6 GHz */ 169*4882a593Smuzhiyun WIFI_AND_24GHZ_5GHZ_6GHZ = 11, 170*4882a593Smuzhiyun /* 2.4 GHz + 5 GHz with DFS + 6 GHz */ 171*4882a593Smuzhiyun WIFI_BAND_24GHZ_5GHZ_WITH_DFS_6GHZ = 15 172*4882a593Smuzhiyun } wifi_band; 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun extern bool wl_cfgscan_is_dfs_set(wifi_band band); 175*4882a593Smuzhiyun extern s32 wl_cfgscan_get_band_freq_list(struct bcm_cfg80211 *cfg, int band, 176*4882a593Smuzhiyun uint32 *list, uint32 *num_channels); 177*4882a593Smuzhiyun #endif /* DHD_GET_VALID_CHANNELS */ 178*4882a593Smuzhiyun #endif /* _wl_cfgscan_h_ */ 179