Merge tag 'lsk-v4.4-16.06-android'
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / wl_android.h
1 /*
2  * Linux cfg80211 driver - Android related functions
3  *
4  * Copyright (C) 1999-2016, Broadcom Corporation
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  *      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.
23  *
24  *
25  * <<Broadcom-WL-IPTag/Open:>>
26  *
27  * $Id: wl_android.h 608194 2015-12-24 04:34:35Z $
28  */
29
30 #ifndef _wl_android_
31 #define _wl_android_
32
33 #include <linux/module.h>
34 #include <linux/netdevice.h>
35 #include <wldev_common.h>
36
37 /* If any feature uses the Generic Netlink Interface, put it here to enable WL_GENL
38  * automatically
39  */
40 #if defined(BT_WIFI_HANDOVER) || defined(WL_NAN)
41 #define WL_GENL
42 #endif
43
44
45
46 /**
47  * Android platform dependent functions, feel free to add Android specific functions here
48  * (save the macros in dhd). Please do NOT declare functions that are NOT exposed to dhd
49  * or cfg, define them as static in wl_android.c
50  */
51
52 /**
53  * wl_android_init will be called from module init function (dhd_module_init now), similarly
54  * wl_android_exit will be called from module exit function (dhd_module_cleanup now)
55  */
56 int wl_android_init(void);
57 int wl_android_exit(void);
58 void wl_android_post_init(void);
59 int wl_android_wifi_on(struct net_device *dev);
60 int wl_android_wifi_off(struct net_device *dev, bool on_failure);
61 int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd);
62
63 s32 wl_netlink_send_msg(int pid, int type, int seq, void *data, size_t size);
64
65 /* hostap mac mode */
66 #define MACLIST_MODE_DISABLED   0
67 #define MACLIST_MODE_DENY       1
68 #define MACLIST_MODE_ALLOW      2
69
70 /* max number of assoc list */
71 #define MAX_NUM_OF_ASSOCLIST    64
72
73 /* Bandwidth */
74 #define WL_CH_BANDWIDTH_20MHZ 20
75 #define WL_CH_BANDWIDTH_40MHZ 40
76 #define WL_CH_BANDWIDTH_80MHZ 80
77 /* max number of mac filter list
78  * restrict max number to 10 as maximum cmd string size is 255
79  */
80 #define MAX_NUM_MAC_FILT        10
81
82 int wl_android_set_ap_mac_list(struct net_device *dev, int macmode, struct maclist *maclist);
83 int wl_android_set_roam_offload_bssid_list(struct net_device *dev, const char *cmd);
84
85 /* terence:
86  * BSSCACHE: Cache bss list
87  * RSSAVG: Average RSSI of BSS list
88  * RSSIOFFSET: RSSI offset
89  * SORT_BSS_BY_RSSI: Sort BSS by RSSI
90  */
91 //#define BSSCACHE
92 //#define RSSIAVG
93 //#define RSSIOFFSET
94 //#define RSSIOFFSET_NEW
95 //#define SORT_BSS_BY_RSSI
96
97 #define RSSI_MAXVAL -2
98 #define RSSI_MINVAL -200
99
100 #if defined(ESCAN_RESULT_PATCH)
101 #define REPEATED_SCAN_RESULT_CNT        2
102 #else
103 #define REPEATED_SCAN_RESULT_CNT        1
104 #endif
105
106 #if defined(RSSIAVG)
107 #define RSSIAVG_LEN (4*REPEATED_SCAN_RESULT_CNT)
108 #define RSSICACHE_TIMEOUT 15
109
110 typedef struct wl_rssi_cache {
111         struct wl_rssi_cache *next;
112         int dirty;
113         struct timeval tv;
114         struct ether_addr BSSID;
115         int16 RSSI[RSSIAVG_LEN];
116 } wl_rssi_cache_t;
117
118 typedef struct wl_rssi_cache_ctrl {
119         wl_rssi_cache_t *m_cache_head;
120 } wl_rssi_cache_ctrl_t;
121
122 void wl_free_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
123 void wl_delete_dirty_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
124 void wl_delete_disconnected_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, u8 *bssid);
125 void wl_reset_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
126 void wl_update_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, wl_scan_results_t *ss_list);
127 int wl_update_connected_rssi_cache(struct net_device *net, wl_rssi_cache_ctrl_t *rssi_cache_ctrl, int *rssi_avg);
128 int16 wl_get_avg_rssi(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, void *addr);
129 #endif
130
131 #if defined(RSSIOFFSET)
132 #define RSSI_OFFSET     5
133 #if defined(RSSIOFFSET_NEW)
134 #define RSSI_OFFSET_MAXVAL -80
135 #define RSSI_OFFSET_MINVAL -94
136 #define RSSI_OFFSET_INTVAL ((RSSI_OFFSET_MAXVAL-RSSI_OFFSET_MINVAL)/RSSI_OFFSET)
137 #endif
138 #define BCM4330_CHIP_ID         0x4330
139 #define BCM4330B2_CHIP_REV      4
140 int wl_update_rssi_offset(struct net_device *net, int rssi);
141 #endif
142
143 #if defined(BSSCACHE)
144 #define BSSCACHE_TIMEOUT        15
145
146 typedef struct wl_bss_cache {
147         struct wl_bss_cache *next;
148         int dirty;
149         struct timeval tv;
150         wl_scan_results_t results;
151 } wl_bss_cache_t;
152
153 typedef struct wl_bss_cache_ctrl {
154         wl_bss_cache_t *m_cache_head;
155 } wl_bss_cache_ctrl_t;
156
157 void wl_free_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
158 void wl_delete_dirty_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
159 void wl_delete_disconnected_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl, u8 *bssid);
160 void wl_reset_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
161 void wl_update_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl,   
162 #if defined(RSSIAVG)
163         wl_rssi_cache_ctrl_t *rssi_cache_ctrl,
164 #endif
165         wl_scan_results_t *ss_list);
166 void wl_release_bss_cache_ctrl(wl_bss_cache_ctrl_t *bss_cache_ctrl);
167 #endif
168 #endif /* _wl_android_ */