981889711f81815f91376d3afe7cec8ebbd0cf7e
[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 367305 2012-11-07 13:49:55Z $
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 #ifdef WL_SDO
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 #if defined(CONFIG_WIFI_CONTROL_FUNC)
46 int wl_android_wifictrl_func_add(void);
47 void wl_android_wifictrl_func_del(void);
48 void* wl_android_prealloc(int section, unsigned long size);
49
50 int wifi_get_irq_number(unsigned long *irq_flags_ptr);
51 int wifi_set_power(int on, unsigned long msec);
52 int wifi_get_mac_addr(unsigned char *buf);
53 void *wifi_get_country_code(char *ccode);
54 #endif /* CONFIG_WIFI_CONTROL_FUNC */
55
56 #ifdef WL_GENL
57 typedef struct bcm_event_hdr {
58         u16 event_type;
59         u16 len;
60 } bcm_event_hdr_t;
61
62 /* attributes (variables): the index in this enum is used as a reference for the type,
63  *             userspace application has to indicate the corresponding type
64  *             the policy is used for security considerations
65  */
66 enum {
67         BCM_GENL_ATTR_UNSPEC,
68         BCM_GENL_ATTR_STRING,
69         BCM_GENL_ATTR_MSG,
70         __BCM_GENL_ATTR_MAX
71 };
72 #define BCM_GENL_ATTR_MAX (__BCM_GENL_ATTR_MAX - 1)
73
74 /* commands: enumeration of all commands (functions),
75  * used by userspace application to identify command to be ececuted
76  */
77 enum {
78         BCM_GENL_CMD_UNSPEC,
79         BCM_GENL_CMD_MSG,
80         __BCM_GENL_CMD_MAX
81 };
82 #define BCM_GENL_CMD_MAX (__BCM_GENL_CMD_MAX - 1)
83
84 /* Enum values used by the BCM supplicant to identify the events */
85 enum {
86         BCM_E_UNSPEC,
87         BCM_E_SVC_FOUND,
88         BCM_E_DEV_FOUND,
89         BCM_E_DEV_LOST,
90         BCM_E_MAX
91 };
92
93 s32 wl_genl_send_msg(struct net_device *ndev, u32 event_type,
94         u8 *string, u16 len, u8 *hdr, u16 hdrlen);
95 #endif /* WL_GENL */
96
97 /* terence:
98  * BSSCACHE: Cache bss list
99  * RSSAVG: Average RSSI of BSS list
100  * RSSIOFFSET: RSSI offset
101  */
102 #define BSSCACHE
103 #define RSSIAVG
104 #define RSSIOFFSET
105 //#define RSSIOFFSET_NEW
106
107 #define RSSI_MAXVAL -2
108 #define RSSI_MINVAL -200
109
110 #if defined(ESCAN_RESULT_PATCH)
111 #define REPEATED_SCAN_RESULT_CNT        2
112 #else
113 #define REPEATED_SCAN_RESULT_CNT        1
114 #endif
115
116 #if defined(RSSIAVG)
117 #define RSSIAVG_LEN (4*REPEATED_SCAN_RESULT_CNT)
118 #define RSSICACHE_LEN (4*REPEATED_SCAN_RESULT_CNT)
119
120 typedef struct wl_rssi_cache {
121         struct wl_rssi_cache *next;
122         int dirty;
123         struct ether_addr BSSID;
124         int16 RSSI[RSSIAVG_LEN];
125 } wl_rssi_cache_t;
126
127 typedef struct wl_rssi_cache_ctrl {
128         wl_rssi_cache_t *m_cache_head;
129 } wl_rssi_cache_ctrl_t;
130
131 void wl_free_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
132 void wl_delete_dirty_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
133 void wl_delete_disconnected_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, u8 *bssid);
134 void wl_reset_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl);
135 void wl_update_rssi_cache(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, wl_scan_results_t *ss_list);
136 int wl_update_connected_rssi_cache(struct net_device *net, wl_rssi_cache_ctrl_t *rssi_cache_ctrl, int *rssi_avg);
137 int16 wl_get_avg_rssi(wl_rssi_cache_ctrl_t *rssi_cache_ctrl, void *addr);
138 #endif
139
140 #if defined(RSSIOFFSET)
141 #define RSSI_OFFSET     5
142 #if defined(RSSIOFFSET_NEW)
143 #define RSSI_OFFSET_MAXVAL -80
144 #define RSSI_OFFSET_MINVAL -94
145 #define RSSI_OFFSET_INTVAL ((RSSI_OFFSET_MAXVAL-RSSI_OFFSET_MINVAL)/RSSI_OFFSET)
146 #endif
147 #define BCM4330_CHIP_ID         0x4330
148 #define BCM4330B2_CHIP_REV      4
149 int wl_update_rssi_offset(int rssi);
150 #endif
151
152 #if defined(BSSCACHE)
153 #define BSSCACHE_LEN    (4*REPEATED_SCAN_RESULT_CNT)
154 #define BSSCACHE_TIME   15000
155
156 typedef struct wl_bss_cache {
157         struct wl_bss_cache *next;
158         int dirty;
159         wl_scan_results_t results;
160 } wl_bss_cache_t;
161
162 typedef struct wl_bss_cache_ctrl {
163         wl_bss_cache_t *m_cache_head;
164         struct timer_list *m_timer;
165         int m_timer_expired;
166 } wl_bss_cache_ctrl_t;
167
168 void wl_free_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
169 void wl_delete_dirty_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
170 void wl_delete_disconnected_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl, u8 *bssid);
171 void wl_reset_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl);
172 void wl_update_bss_cache(wl_bss_cache_ctrl_t *bss_cache_ctrl, wl_scan_results_t *ss_list);
173 void wl_run_bss_cache_timer(wl_bss_cache_ctrl_t *bss_cache_ctrl, int kick_off);
174 void wl_release_bss_cache_ctrl(wl_bss_cache_ctrl_t *bss_cache_ctrl);
175 int wl_init_bss_cache_ctrl(wl_bss_cache_ctrl_t *bss_cache_ctrl);
176 #endif
177 #endif /* _wl_android_ */