Merge branch develop-3.10-next
[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 Open Broadcom Corporation$
5  *
6  * $Id: wl_android.h 487838 2014-06-27 05:51:44Z $
7  */
8
9 #ifndef _wl_android_
10 #define _wl_android_
11
12 #include <linux/module.h>
13 #include <linux/netdevice.h>
14 #include <wldev_common.h>
15
16 /* If any feature uses the Generic Netlink Interface, put it here to enable WL_GENL
17  * automatically
18  */
19 #if defined(WL_SDO) || defined(BT_WIFI_HANDOVER) || defined(WL_NAN)
20 #define WL_GENL
21 #endif
22
23
24 #ifdef WL_GENL
25 #include <net/genetlink.h>
26 #endif
27
28 /**
29  * Android platform dependent functions, feel free to add Android specific functions here
30  * (save the macros in dhd). Please do NOT declare functions that are NOT exposed to dhd
31  * or cfg, define them as static in wl_android.c
32  */
33
34 /**
35  * wl_android_init will be called from module init function (dhd_module_init now), similarly
36  * wl_android_exit will be called from module exit function (dhd_module_cleanup now)
37  */
38 int wl_android_init(void);
39 int wl_android_exit(void);
40 void wl_android_post_init(void);
41 int wl_android_wifi_on(struct net_device *dev);
42 int wl_android_wifi_off(struct net_device *dev);
43 int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd);
44
45 #ifdef WL_GENL
46 typedef struct bcm_event_hdr {
47         u16 event_type;
48         u16 len;
49 } bcm_event_hdr_t;
50
51 /* attributes (variables): the index in this enum is used as a reference for the type,
52  *             userspace application has to indicate the corresponding type
53  *             the policy is used for security considerations
54  */
55 enum {
56         BCM_GENL_ATTR_UNSPEC,
57         BCM_GENL_ATTR_STRING,
58         BCM_GENL_ATTR_MSG,
59         __BCM_GENL_ATTR_MAX
60 };
61 #define BCM_GENL_ATTR_MAX (__BCM_GENL_ATTR_MAX - 1)
62
63 /* commands: enumeration of all commands (functions),
64  * used by userspace application to identify command to be ececuted
65  */
66 enum {
67         BCM_GENL_CMD_UNSPEC,
68         BCM_GENL_CMD_MSG,
69         __BCM_GENL_CMD_MAX
70 };
71 #define BCM_GENL_CMD_MAX (__BCM_GENL_CMD_MAX - 1)
72
73 /* Enum values used by the BCM supplicant to identify the events */
74 enum {
75         BCM_E_UNSPEC,
76         BCM_E_SVC_FOUND,
77         BCM_E_DEV_FOUND,
78         BCM_E_DEV_LOST,
79         BCM_E_DEV_BT_WIFI_HO_REQ,
80         BCM_E_MAX
81 };
82
83 s32 wl_genl_send_msg(struct net_device *ndev, u32 event_type,
84         u8 *string, u16 len, u8 *hdr, u16 hdrlen);
85 #endif /* WL_GENL */
86 s32 wl_netlink_send_msg(int pid, int type, int seq, void *data, size_t size);
87
88 /* hostap mac mode */
89 #define MACLIST_MODE_DISABLED   0
90 #define MACLIST_MODE_DENY       1
91 #define MACLIST_MODE_ALLOW      2
92
93 /* max number of assoc list */
94 #define MAX_NUM_OF_ASSOCLIST    64
95
96 /* max number of mac filter list
97  * restrict max number to 10 as maximum cmd string size is 255
98  */
99 #define MAX_NUM_MAC_FILT        10
100
101 int wl_android_set_ap_mac_list(struct net_device *dev, int macmode, struct maclist *maclist);
102
103 /* terence:
104  * BSSCACHE: Cache bss list
105  * RSSAVG: Average RSSI of BSS list
106  * RSSIOFFSET: RSSI offset
107  */
108 //#define BSSCACHE
109 //#define RSSIAVG
110 //#define RSSIOFFSET
111 //#define RSSIOFFSET_NEW
112
113 #define RSSI_MAXVAL -2
114 #define RSSI_MINVAL -200
115
116 #if defined(ESCAN_RESULT_PATCH)
117 #define REPEATED_SCAN_RESULT_CNT        2
118 #else
119 #define REPEATED_SCAN_RESULT_CNT        1
120 #endif
121
122 #if defined(RSSIAVG)
123 #define RSSIAVG_LEN (4*REPEATED_SCAN_RESULT_CNT)
124 #define RSSICACHE_TIMEOUT 15
125
126 typedef struct wl_rssi_cache {
127         struct wl_rssi_cache *next;
128         int dirty;
129         struct timeval tv;
130         struct ether_addr BSSID;
131         int16 RSSI[RSSIAVG_LEN];
132 } wl_rssi_cache_t;
133
134 typedef struct wl_rssi_cache_ctrl {
135         wl_rssi_cache_t *m_cache_head;
136 } wl_rssi_cache_ctrl_t;
137
138 void wl_free_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
139 void wl_delete_dirty_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
140 void wl_delete_disconnected_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, u8 *bssid);
141 void wl_reset_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
142 void wl_update_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, wl_scan_results_t *ss_list);
143 int wl_update_connected_rssi_cache(struct net_device *net, wl_rssi_cache_ctrl_t *rssi_cache_ctrl, int *rssi_avg);
144 int16 wl_get_avg_rssi(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, void *addr);
145 #endif
146
147 #if defined(RSSIOFFSET)
148 #define RSSI_OFFSET     5
149 #if defined(RSSIOFFSET_NEW)
150 #define RSSI_OFFSET_MAXVAL -80
151 #define RSSI_OFFSET_MINVAL -94
152 #define RSSI_OFFSET_INTVAL ((RSSI_OFFSET_MAXVAL-RSSI_OFFSET_MINVAL)/RSSI_OFFSET)
153 #endif
154 #define BCM4330_CHIP_ID         0x4330
155 #define BCM4330B2_CHIP_REV      4
156 int wl_update_rssi_offset(struct net_device *net, int rssi);
157 #endif
158
159 #if defined(BSSCACHE)
160 #define BSSCACHE_TIMEOUT        15
161
162 typedef struct wl_bss_cache {
163         struct wl_bss_cache *next;
164         int dirty;
165         struct timeval tv;
166         wl_scan_results_t results;
167 } wl_bss_cache_t;
168
169 typedef struct wl_bss_cache_ctrl {
170         wl_bss_cache_t *m_cache_head;
171 } wl_bss_cache_ctrl_t;
172
173 void wl_free_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
174 void wl_delete_dirty_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
175 void wl_delete_disconnected_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl, u8 *bssid);
176 void wl_reset_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
177 void wl_update_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl, wl_scan_results_t *ss_list);
178 void wl_release_bss_cache_ctrl(wl_bss_cache_ctrl_t *bss_cache_ctrl);
179 #endif
180 #endif /* _wl_android_ */