2 * Linux cfg80211 driver - Android related functions
4 * Copyright (C) 1999-2017, 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.
25 * <<Broadcom-WL-IPTag/Open:>>
27 * $Id: wl_android.h 607319 2015-12-18 14:16:55Z $
33 #include <linux/module.h>
34 #include <linux/netdevice.h>
35 #include <wldev_common.h>
37 /* If any feature uses the Generic Netlink Interface, put it here to enable WL_GENL
40 #if defined(BT_WIFI_HANDOVER)
46 typedef struct _android_wifi_priv_cmd
{
50 } android_wifi_priv_cmd
;
53 typedef struct _compat_android_wifi_priv_cmd
{
57 } compat_android_wifi_priv_cmd
;
58 #endif /* CONFIG_COMPAT */
61 * Android platform dependent functions, feel free to add Android specific functions here
62 * (save the macros in dhd). Please do NOT declare functions that are NOT exposed to dhd
63 * or cfg, define them as static in wl_android.c
67 #define ANDROID_ERROR_LEVEL 0x0001
68 #define ANDROID_TRACE_LEVEL 0x0002
69 #define ANDROID_INFO_LEVEL 0x0004
71 #define ANDROID_ERROR(x) \
73 if (android_msg_level & ANDROID_ERROR_LEVEL) { \
74 printk(KERN_ERR "ANDROID-ERROR) "); \
78 #define ANDROID_TRACE(x) \
80 if (android_msg_level & ANDROID_TRACE_LEVEL) { \
81 printk(KERN_ERR "ANDROID-TRACE) "); \
85 #define ANDROID_INFO(x) \
87 if (android_msg_level & ANDROID_INFO_LEVEL) { \
88 printk(KERN_ERR "ANDROID-INFO) "); \
94 * wl_android_init will be called from module init function (dhd_module_init now), similarly
95 * wl_android_exit will be called from module exit function (dhd_module_cleanup now)
97 int wl_android_init(void);
98 int wl_android_exit(void);
99 void wl_android_post_init(void);
100 int wl_android_wifi_on(struct net_device
*dev
);
101 int wl_android_wifi_off(struct net_device
*dev
, bool on_failure
);
102 int wl_android_priv_cmd(struct net_device
*net
, struct ifreq
*ifr
, int cmd
);
103 int wl_handle_private_cmd(struct net_device
*net
, char *command
, u32 cmd_len
);
105 s32
wl_netlink_send_msg(int pid
, int type
, int seq
, const void *data
, size_t size
);
107 int wl_android_ext_attach_netdev(struct net_device
*net
, uint8 bssidx
);
108 int wl_android_ext_dettach_netdev(void);
109 void wl_android_ext_iapsta_disconnect_sta(struct net_device
*dev
, u32 channel
);
111 int wl_android_ext_priv_cmd(struct net_device
*net
, char *command
, int total_len
,
113 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
114 #define strnicmp(str1, str2, len) strncasecmp((str1), (str2), (len))
117 typedef enum IF_STATE
{
123 typedef enum APSTAMODE
{
132 typedef enum IFMODE
{
137 typedef enum BGNMODE
{
145 typedef enum AUTHMODE
{
153 typedef enum ENCMODE
{
162 typedef struct wl_if_info
{
163 struct net_device
*dev
;
167 char ifname
[IFNAMSIZ
+1];
168 char ssid
[DOT11_MAX_SSID_LEN
];
169 struct ether_addr bssid
;
179 typedef struct wl_apsta_params
{
180 struct wl_if_info pif
; // primary device
181 struct wl_if_info vif
; // virtual device
184 apstamode_t apstamode
;
187 /* hostap mac mode */
188 #define MACLIST_MODE_DISABLED 0
189 #define MACLIST_MODE_DENY 1
190 #define MACLIST_MODE_ALLOW 2
192 /* max number of assoc list */
193 #define MAX_NUM_OF_ASSOCLIST 64
196 #define WL_CH_BANDWIDTH_20MHZ 20
197 #define WL_CH_BANDWIDTH_40MHZ 40
198 #define WL_CH_BANDWIDTH_80MHZ 80
199 /* max number of mac filter list
200 * restrict max number to 10 as maximum cmd string size is 255
202 #define MAX_NUM_MAC_FILT 10
204 int wl_android_set_ap_mac_list(struct net_device
*dev
, int macmode
, struct maclist
*maclist
);
207 * BSSCACHE: Cache bss list
208 * RSSAVG: Average RSSI of BSS list
209 * RSSIOFFSET: RSSI offset
210 * SORT_BSS_BY_RSSI: Sort BSS by RSSI
215 //#define RSSIOFFSET_NEW
216 //#define SORT_BSS_BY_RSSI
218 #define RSSI_MAXVAL -2
219 #define RSSI_MINVAL -200
221 #if defined(ESCAN_RESULT_PATCH)
222 #define REPEATED_SCAN_RESULT_CNT 2
224 #define REPEATED_SCAN_RESULT_CNT 1
228 #define RSSIAVG_LEN (4*REPEATED_SCAN_RESULT_CNT)
229 #define RSSICACHE_TIMEOUT 15
231 typedef struct wl_rssi_cache
{
232 struct wl_rssi_cache
*next
;
235 struct ether_addr BSSID
;
236 int16 RSSI
[RSSIAVG_LEN
];
239 typedef struct wl_rssi_cache_ctrl
{
240 wl_rssi_cache_t
*m_cache_head
;
241 } wl_rssi_cache_ctrl_t
;
243 void wl_free_rssi_cache(wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
);
244 void wl_delete_dirty_rssi_cache(wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
);
245 void wl_delete_disconnected_rssi_cache(wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
, u8
*bssid
);
246 void wl_reset_rssi_cache(wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
);
247 void wl_update_rssi_cache(wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
, wl_scan_results_t
*ss_list
);
248 int wl_update_connected_rssi_cache(struct net_device
*net
, wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
, int *rssi_avg
);
249 int16
wl_get_avg_rssi(wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
, void *addr
);
252 #if defined(RSSIOFFSET)
253 #define RSSI_OFFSET 5
254 #if defined(RSSIOFFSET_NEW)
255 #define RSSI_OFFSET_MAXVAL -80
256 #define RSSI_OFFSET_MINVAL -94
257 #define RSSI_OFFSET_INTVAL ((RSSI_OFFSET_MAXVAL-RSSI_OFFSET_MINVAL)/RSSI_OFFSET)
259 #define BCM4330_CHIP_ID 0x4330
260 #define BCM4330B2_CHIP_REV 4
261 int wl_update_rssi_offset(struct net_device
*net
, int rssi
);
264 #if defined(BSSCACHE)
265 #define BSSCACHE_TIMEOUT 15
267 typedef struct wl_bss_cache
{
268 struct wl_bss_cache
*next
;
271 wl_scan_results_t results
;
274 typedef struct wl_bss_cache_ctrl
{
275 wl_bss_cache_t
*m_cache_head
;
276 } wl_bss_cache_ctrl_t
;
278 void wl_free_bss_cache(wl_bss_cache_ctrl_t
*bss_cache_ctrl
);
279 void wl_delete_dirty_bss_cache(wl_bss_cache_ctrl_t
*bss_cache_ctrl
);
280 void wl_delete_disconnected_bss_cache(wl_bss_cache_ctrl_t
*bss_cache_ctrl
, u8
*bssid
);
281 void wl_reset_bss_cache(wl_bss_cache_ctrl_t
*bss_cache_ctrl
);
282 void wl_update_bss_cache(wl_bss_cache_ctrl_t
*bss_cache_ctrl
,
284 wl_rssi_cache_ctrl_t
*rssi_cache_ctrl
,
286 wl_scan_results_t
*ss_list
);
287 void wl_release_bss_cache_ctrl(wl_bss_cache_ctrl_t
*bss_cache_ctrl
);
289 #endif /* _wl_android_ */