1 /* 2 * Wifi Virtual Interface implementaion 3 * 4 * Copyright (C) 2020, Broadcom. 5 * 6 * Unless you and Broadcom execute a separate written software license 7 * agreement governing use of this software, this software is licensed to you 8 * under the terms of the GNU General Public License version 2 (the "GPL"), 9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the 10 * following added to such license: 11 * 12 * As a special exception, the copyright holders of this software give you 13 * permission to link this software with independent modules, and to copy and 14 * distribute the resulting executable under terms of your choice, provided that 15 * you also meet, for each linked independent module, the terms and conditions of 16 * the license of that module. An independent module is a module which is not 17 * derived from this software. The special exception does not apply to any 18 * modifications of the software. 19 * 20 * 21 * <<Broadcom-WL-IPTag/Dual:>> 22 */ 23 24 #ifndef _wl_cfgvif_h_ 25 #define _wl_cfgvif_h_ 26 27 #include <linux/wireless.h> 28 #include <typedefs.h> 29 #include <ethernet.h> 30 #include <wlioctl.h> 31 #include <linux/wireless.h> 32 #include <net/cfg80211.h> 33 #include <linux/rfkill.h> 34 #include <osl.h> 35 #if defined(BCMDONGLEHOST) 36 #include <dngl_stats.h> 37 #include <dhd.h> 38 #endif /* BCMDONGLEHOST */ 39 #include <wl_cfgp2p.h> 40 #ifdef WL_NAN 41 #include <wl_cfgnan.h> 42 #endif /* WL_NAN */ 43 #ifdef WL_BAM 44 #include <wl_bam.h> 45 #endif /* WL_BAM */ 46 47 #ifdef SUPPORT_AP_RADIO_PWRSAVE 48 #define RADIO_PWRSAVE_PPS 10 49 #define RADIO_PWRSAVE_QUIET_TIME 10 50 #define RADIO_PWRSAVE_LEVEL 3 51 #define RADIO_PWRSAVE_STAS_ASSOC_CHECK 0 52 53 #define RADIO_PWRSAVE_LEVEL_MIN 1 54 #define RADIO_PWRSAVE_LEVEL_MAX 9 55 #define RADIO_PWRSAVE_PPS_MIN 1 56 #define RADIO_PWRSAVE_QUIETTIME_MIN 1 57 #define RADIO_PWRSAVE_ASSOCCHECK_MIN 0 58 #define RADIO_PWRSAVE_ASSOCCHECK_MAX 1 59 60 #define RADIO_PWRSAVE_MAJOR_VER 1 61 #define RADIO_PWRSAVE_MINOR_VER 1 62 #define RADIO_PWRSAVE_MAJOR_VER_SHIFT 8 63 #define RADIO_PWRSAVE_VERSION \ 64 ((RADIO_PWRSAVE_MAJOR_VER << RADIO_PWRSAVE_MAJOR_VER_SHIFT)| RADIO_PWRSAVE_MINOR_VER) 65 #endif /* SUPPORT_AP_RADIO_PWRSAVE */ 66 67 #ifdef WLTDLS 68 #define TDLS_TUNNELED_PRB_REQ "\x7f\x50\x6f\x9a\04" 69 #define TDLS_TUNNELED_PRB_RESP "\x7f\x50\x6f\x9a\05" 70 #define TDLS_MAX_IFACE_FOR_ENABLE 1 71 #endif /* WLTDLS */ 72 73 /* HE flag defines */ 74 #define WL_HE_FEATURES_HE_AP 0x8 75 #define WL_HE_FEATURES_HE_P2P 0x20 76 #define WL_HE_FEATURES_6G 0x80u 77 78 extern bool wl_cfg80211_check_vif_in_use(struct net_device *ndev); 79 80 extern int wl_cfg80211_set_mgmt_vndr_ies(struct bcm_cfg80211 *cfg, 81 bcm_struct_cfgdev *cfgdev, s32 bssidx, s32 pktflag, 82 const u8 *vndr_ie, u32 vndr_ie_len); 83 84 #ifdef WL_SUPPORT_ACS 85 #define ACS_MSRMNT_DELAY 1000 /* dump_obss delay in ms */ 86 #define IOCTL_RETRY_COUNT 5 87 #define CHAN_NOISE_DUMMY -80 88 #define OBSS_TOKEN_IDX 15 89 #define IBSS_TOKEN_IDX 15 90 #define TX_TOKEN_IDX 14 91 #define CTG_TOKEN_IDX 13 92 #define PKT_TOKEN_IDX 15 93 #define IDLE_TOKEN_IDX 12 94 #endif /* WL_SUPPORT_ACS */ 95 96 extern s32 wl_cfg80211_dfs_ap_move(struct net_device *ndev, char *data, 97 char *command, int total_len); 98 extern s32 wl_cfg80211_get_band_chanspecs(struct net_device *ndev, 99 void *buf, s32 buflen, chanspec_band_t band, bool acs_req); 100 101 #ifdef WLTDLS 102 extern s32 wl_cfg80211_tdls_config(struct bcm_cfg80211 *cfg, 103 enum wl_tdls_config state, bool tdls_mode); 104 extern s32 wl_tdls_event_handler(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev, 105 const wl_event_msg_t *e, void *data); 106 #endif /* WLTDLS */ 107 108 #ifdef SUPPORT_AP_HIGHER_BEACONRATE 109 int wl_set_ap_beacon_rate(struct net_device *dev, int val, char *ifname); 110 int wl_get_ap_basic_rate(struct net_device *dev, char* command, char *ifname, int total_len); 111 #endif /* SUPPORT_AP_HIGHER_BEACONRATE */ 112 #ifdef SUPPORT_AP_RADIO_PWRSAVE 113 int wl_get_ap_rps(struct net_device *dev, char* command, char *ifname, int total_len); 114 int wl_set_ap_rps(struct net_device *dev, bool enable, char *ifname); 115 int wl_update_ap_rps_params(struct net_device *dev, ap_rps_info_t* rps, char *ifname); 116 void wl_cfg80211_init_ap_rps(struct bcm_cfg80211 *cfg); 117 #endif /* SUPPORT_AP_RADIO_PWRSAVE */ 118 int wl_cfg80211_iface_count(struct net_device *dev); 119 struct net_device* wl_get_ap_netdev(struct bcm_cfg80211 *cfg, char *ifname); 120 void wl_cfg80211_cleanup_virtual_ifaces(struct bcm_cfg80211 *cfg, bool rtnl_lock_reqd); 121 #ifdef WL_IFACE_MGMT 122 extern int wl_cfg80211_set_iface_policy(struct net_device *ndev, char *arg, int len); 123 extern uint8 wl_cfg80211_get_iface_policy(struct net_device *ndev); 124 extern s32 wl_cfg80211_handle_if_role_conflict(struct bcm_cfg80211 *cfg, wl_iftype_t new_wl_iftype); 125 extern wl_iftype_t wl_cfg80211_get_sec_iface(struct bcm_cfg80211 *cfg); 126 #endif /* WL_IFACE_MGMT */ 127 128 extern s32 wl_get_vif_macaddr(struct bcm_cfg80211 *cfg, u16 wl_iftype, u8 *mac_addr); 129 extern s32 wl_release_vif_macaddr(struct bcm_cfg80211 *cfg, u8 *mac_addr, u16 wl_iftype); 130 131 int wl_cfg80211_set_he_mode(struct net_device *dev, struct bcm_cfg80211 *cfg, 132 s32 bssidx, u32 interface_type, bool set); 133 #ifdef SUPPORT_AP_SUSPEND 134 extern int wl_set_ap_suspend(struct net_device *dev, bool enable, char *ifname); 135 #endif /* SUPPORT_AP_SUSPEND */ 136 #ifdef SUPPORT_SOFTAP_ELNA_BYPASS 137 int wl_set_softap_elna_bypass(struct net_device *dev, char *ifname, int enable); 138 int wl_get_softap_elna_bypass(struct net_device *dev, char *ifname, void *param); 139 #endif /* SUPPORT_SOFTAP_ELNA_BYPASS */ 140 #ifdef SUPPORT_AP_BWCTRL 141 extern int wl_set_ap_bw(struct net_device *dev, u32 bw, char *ifname); 142 extern int wl_get_ap_bw(struct net_device *dev, char* command, char *ifname, int total_len); 143 #endif /* SUPPORT_AP_BWCTRL */ 144 extern s32 wl_get_nl80211_band(u32 wl_band); 145 extern int wl_get_bandwidth_cap(struct net_device *ndev, uint32 band, uint32 *bandwidth); 146 147 #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0)) || \ 148 defined(WL_COMPAT_WIRELESS) 149 #if (defined(CONFIG_ARCH_MSM) && defined(TDLS_MGMT_VERSION2)) || \ 150 ((LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) && \ 151 LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))) 152 extern s32 wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, 153 u8 *peer, u8 action_code, u8 dialog_token, u16 status_code, 154 u32 peer_capability, const u8 *buf, size_t len); 155 #elif ((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) && \ 156 (LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0))) 157 extern s32 wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, 158 const u8 *peer, u8 action_code, u8 dialog_token, u16 status_code, 159 u32 peer_capability, const u8 *buf, size_t len); 160 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)) 161 extern s32 wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, 162 const u8 *peer, u8 action_code, u8 dialog_token, u16 status_code, 163 u32 peer_capability, bool initiator, const u8 *buf, size_t len); 164 #else /* CONFIG_ARCH_MSM && TDLS_MGMT_VERSION2 */ 165 extern s32 wl_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, 166 u8 *peer, u8 action_code, u8 dialog_token, u16 status_code, 167 const u8 *buf, size_t len); 168 #endif /* CONFIG_ARCH_MSM && TDLS_MGMT_VERSION2 */ 169 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)) 170 extern s32 wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, 171 const u8 *peer, enum nl80211_tdls_operation oper); 172 #else 173 extern s32 wl_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, 174 u8 *peer, enum nl80211_tdls_operation oper); 175 #endif 176 #endif /* LINUX_VERSION > KERNEL_VERSION(3,2,0) || WL_COMPAT_WIRELESS */ 177 178 extern s32 wl_notify_connect_status_ap(struct bcm_cfg80211 *cfg, struct net_device *ndev, 179 const wl_event_msg_t *e, void *data); 180 extern s32 wl_cfg80211_change_virtual_iface(struct wiphy *wiphy, struct net_device *ndev, 181 enum nl80211_iftype type, 182 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) 183 u32 *flags, 184 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) */ 185 struct vif_params *params); 186 187 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) || \ 188 defined(WL_COMPAT_WIRELESS) 189 s32 190 wl_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev, 191 struct ieee80211_channel *chan, 192 enum nl80211_channel_type channel_type); 193 #endif /* ((LINUX_VERSION < VERSION(3, 6, 0)) || WL_COMPAT_WIRELESS */ 194 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)) || \ 195 defined(WL_COMPAT_WIRELESS) 196 extern s32 wl_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *dev, 197 struct cfg80211_ap_settings *info); 198 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 2) || defined(CFG80211_BKPORT_MLO) 199 extern s32 wl_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *dev, 200 unsigned int link_id); 201 #else 202 extern s32 wl_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *dev); 203 #endif 204 extern s32 wl_cfg80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, 205 struct cfg80211_beacon_data *info); 206 #else 207 extern s32 wl_cfg80211_add_set_beacon(struct wiphy *wiphy, struct net_device *dev, 208 struct beacon_parameters *info); 209 extern s32 wl_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev); 210 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) || WL_COMPAT_WIRELESS */ 211 212 extern s32 wl_ap_start_ind(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev, 213 const wl_event_msg_t *e, void *data); 214 extern s32 wl_csa_complete_ind(struct bcm_cfg80211 *cfg, bcm_struct_cfgdev *cfgdev, 215 const wl_event_msg_t *e, void *data); 216 extern s32 wl_cfg80211_set_ap_role(struct bcm_cfg80211 *cfg, struct net_device *dev); 217 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) 218 extern int wl_cfg80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, 219 struct cfg80211_csa_settings *params); 220 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0) */ 221 222 extern bcm_struct_cfgdev * 223 wl_cfg80211_add_virtual_iface(struct wiphy *wiphy, 224 #if defined(WL_CFG80211_P2P_DEV_IF) 225 const char *name, 226 #else 227 char *name, 228 #endif /* WL_CFG80211_P2P_DEV_IF */ 229 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) 230 unsigned char name_assign_type, 231 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) */ 232 enum nl80211_iftype type, 233 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) 234 u32 *flags, 235 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) */ 236 struct vif_params *params); 237 extern s32 wl_cfg80211_del_virtual_iface(struct wiphy *wiphy, bcm_struct_cfgdev *cfgdev); 238 extern s32 wl_cfg80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, 239 struct cfg80211_beacon_data *info); 240 241 extern s32 wl_get_auth_assoc_status(struct bcm_cfg80211 *cfg, struct net_device *ndev, 242 const wl_event_msg_t *e, void *data); 243 extern s32 wl_frame_get_mgmt(struct bcm_cfg80211 *cfg, u16 fc, 244 const struct ether_addr *da, const struct ether_addr *sa, 245 const struct ether_addr *bssid, u8 **pheader, u32 *body_len, u8 *pbody); 246 extern s32 wl_cfg80211_parse_ies(const u8 *ptr, u32 len, struct parsed_ies *ies); 247 extern void wl_cfg80211_ap_timeout_work(struct work_struct *work); 248 249 #if defined(WLTDLS) 250 extern bool wl_cfg80211_is_tdls_tunneled_frame(void *frame, u32 frame_len); 251 #endif /* WLTDLS */ 252 253 #ifdef SUPPORT_AP_BWCTRL 254 extern void wl_restore_ap_bw(struct bcm_cfg80211 *cfg); 255 #endif /* SUPPORT_AP_BWCTRL */ 256 257 extern int wl_chspec_chandef(chanspec_t chanspec, 258 struct cfg80211_chan_def *chandef, struct wiphy *wiphy); 259 #endif /* _wl_cfgvif_h_ */ 260