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