Merge branch develop-3.10-next
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / dhd_pno.h
1 /*
2  * Header file of Broadcom Dongle Host Driver (DHD)
3  * Prefered Network Offload code and Wi-Fi Location Service(WLS) code.
4  * $Copyright Open Broadcom Corporation$
5  *
6  * $Id: dhd_pno.h 423669 2013-09-18 13:01:55Z $
7  */
8
9 #ifndef __DHD_PNO_H__
10 #define __DHD_PNO_H__
11
12 #if defined(PNO_SUPPORT)
13 #define PNO_TLV_PREFIX                  'S'
14 #define PNO_TLV_VERSION                 '1'
15 #define PNO_TLV_SUBTYPE_LEGACY_PNO '2'
16 #define PNO_TLV_RESERVED                '0'
17
18 #define PNO_BATCHING_SET "SET"
19 #define PNO_BATCHING_GET "GET"
20 #define PNO_BATCHING_STOP "STOP"
21
22 #define PNO_PARAMS_DELIMETER " "
23 #define PNO_PARAM_CHANNEL_DELIMETER ","
24 #define PNO_PARAM_VALUE_DELLIMETER '='
25 #define PNO_PARAM_SCANFREQ "SCANFREQ"
26 #define PNO_PARAM_BESTN "BESTN"
27 #define PNO_PARAM_MSCAN "MSCAN"
28 #define PNO_PARAM_CHANNEL "CHANNEL"
29 #define PNO_PARAM_RTT "RTT"
30
31 #define PNO_TLV_TYPE_SSID_IE            'S'
32 #define PNO_TLV_TYPE_TIME               'T'
33 #define PNO_TLV_FREQ_REPEAT             'R'
34 #define PNO_TLV_FREQ_EXPO_MAX           'M'
35
36 #define MAXNUM_SSID_PER_ADD     16
37 #define MAXNUM_PNO_PARAMS 2
38 #define PNO_TLV_COMMON_LENGTH   1
39 #define DEFAULT_BATCH_MSCAN 16
40
41 #define RESULTS_END_MARKER "----\n"
42 #define SCAN_END_MARKER "####\n"
43 #define AP_END_MARKER "====\n"
44
45 enum scan_status {
46         /* SCAN ABORT by other scan */
47         PNO_STATUS_ABORT,
48         /* RTT is presence or not */
49         PNO_STATUS_RTT_PRESENCE,
50         /* Disable PNO by Driver */
51         PNO_STATUS_DISABLE,
52         /* NORMAL BATCHING GET */
53         PNO_STATUS_NORMAL,
54         /* WLC_E_PFN_BEST_BATCHING */
55         PNO_STATUS_EVENT,
56         PNO_STATUS_MAX
57 };
58 #define PNO_STATUS_ABORT_MASK 0x0001
59 #define PNO_STATUS_RTT_MASK 0x0002
60 #define PNO_STATUS_DISABLE_MASK 0x0004
61 #define PNO_STATUS_OOM_MASK 0x0010
62
63 enum index_mode {
64         INDEX_OF_LEGACY_PARAMS,
65         INDEX_OF_BATCH_PARAMS,
66         INDEX_OF_HOTLIST_PARAMS,
67         INDEX_MODE_MAX
68 };
69 enum dhd_pno_status {
70         DHD_PNO_DISABLED,
71         DHD_PNO_ENABLED,
72         DHD_PNO_SUSPEND
73 };
74 typedef struct cmd_tlv {
75         char prefix;
76         char version;
77         char subtype;
78         char reserved;
79 } cmd_tlv_t;
80 typedef enum dhd_pno_mode {
81         /* Wi-Fi Legacy PNO Mode */
82         DHD_PNO_NONE_MODE = 0,
83         DHD_PNO_LEGACY_MODE = (1 << (0)),
84         /* Wi-Fi Android BATCH SCAN Mode */
85         DHD_PNO_BATCH_MODE = (1 << (1)),
86         /* Wi-Fi Android Hotlist SCAN Mode */
87         DHD_PNO_HOTLIST_MODE = (1 << (2))
88 } dhd_pno_mode_t;
89 struct dhd_pno_ssid {
90         uint32          SSID_len;
91         uchar           SSID[DOT11_MAX_SSID_LEN];
92         struct list_head list;
93 };
94 struct dhd_pno_bssid {
95         struct ether_addr       macaddr;
96         /* Bit4: suppress_lost, Bit3: suppress_found */
97         uint16                  flags;
98         struct list_head list;
99 };
100 typedef struct dhd_pno_bestnet_entry {
101         struct ether_addr BSSID;
102         uint8   SSID_len;
103         uint8   SSID[DOT11_MAX_SSID_LEN];
104         int8    RSSI;
105         uint8   channel;
106         uint32  timestamp;
107         uint16  rtt0; /* distance_cm based on RTT */
108         uint16  rtt1; /* distance_cm based on sample standard deviation */
109         unsigned long recorded_time;
110         struct list_head list;
111 } dhd_pno_bestnet_entry_t;
112 #define BESTNET_ENTRY_SIZE (sizeof(dhd_pno_bestnet_entry_t))
113
114 typedef struct dhd_pno_bestnet_header {
115         struct dhd_pno_bestnet_header *next;
116         uint8 reason;
117         uint32 tot_cnt;
118         uint32 tot_size;
119         struct list_head entry_list;
120 } dhd_pno_best_header_t;
121 #define BEST_HEADER_SIZE (sizeof(dhd_pno_best_header_t))
122
123 typedef struct dhd_pno_scan_results {
124         dhd_pno_best_header_t *bestnetheader;
125         uint8 cnt_header;
126         struct list_head list;
127 } dhd_pno_scan_results_t;
128 #define SCAN_RESULTS_SIZE (sizeof(dhd_pno_scan_results_t))
129
130 struct dhd_pno_get_batch_info {
131         /* info related to get batch */
132         char *buf;
133         bool batch_started;
134         uint32 tot_scan_cnt;
135         uint32 expired_tot_scan_cnt;
136         uint32 top_node_cnt;
137         uint32 bufsize;
138         uint32 bytes_written;
139         int reason;
140         struct list_head scan_results_list;
141         struct list_head expired_scan_results_list;
142 };
143 struct dhd_pno_legacy_params {
144         uint16 scan_fr;
145         uint16 chan_list[WL_NUMCHANNELS];
146         uint16 nchan;
147         int pno_repeat;
148         int pno_freq_expo_max;
149         int nssid;
150         struct list_head ssid_list;
151 };
152 struct dhd_pno_batch_params {
153         int32 scan_fr;
154         uint8 bestn;
155         uint8 mscan;
156         uint8 band;
157         uint16 chan_list[WL_NUMCHANNELS];
158         uint16 nchan;
159         uint16 rtt;
160         struct dhd_pno_get_batch_info get_batch;
161 };
162 struct dhd_pno_hotlist_params {
163         uint8 band;
164         int32 scan_fr;
165         uint16 chan_list[WL_NUMCHANNELS];
166         uint16 nchan;
167         uint16 nbssid;
168         struct list_head bssid_list;
169 };
170 typedef union dhd_pno_params {
171         struct dhd_pno_legacy_params params_legacy;
172         struct dhd_pno_batch_params params_batch;
173         struct dhd_pno_hotlist_params params_hotlist;
174 } dhd_pno_params_t;
175 typedef struct dhd_pno_status_info {
176         dhd_pub_t *dhd;
177         struct work_struct work;
178         struct mutex pno_mutex;
179         struct completion get_batch_done;
180         bool wls_supported; /* wifi location service supported or not */
181         enum dhd_pno_status pno_status;
182         enum dhd_pno_mode pno_mode;
183         dhd_pno_params_t pno_params_arr[INDEX_MODE_MAX];
184         struct list_head head_list;
185 } dhd_pno_status_info_t;
186
187 /* wrapper functions */
188 extern int
189 dhd_dev_pno_enable(struct net_device *dev, int enable);
190
191 extern int
192 dhd_dev_pno_stop_for_ssid(struct net_device *dev);
193
194 extern int
195 dhd_dev_pno_set_for_ssid(struct net_device *dev, wlc_ssid_t* ssids_local, int nssid,
196         uint16 scan_fr, int pno_repeat, int pno_freq_expo_max, uint16 *channel_list, int nchan);
197
198 extern int
199 dhd_dev_pno_set_for_batch(struct net_device *dev,
200         struct dhd_pno_batch_params *batch_params);
201
202 extern int
203 dhd_dev_pno_get_for_batch(struct net_device *dev, char *buf, int bufsize);
204
205 extern int
206 dhd_dev_pno_stop_for_batch(struct net_device *dev);
207
208 extern int
209 dhd_dev_pno_set_for_hotlist(struct net_device *dev, wl_pfn_bssid_t *p_pfn_bssid,
210         struct dhd_pno_hotlist_params *hotlist_params);
211
212 /* dhd pno fuctions */
213 extern int dhd_pno_stop_for_ssid(dhd_pub_t *dhd);
214 extern int dhd_pno_enable(dhd_pub_t *dhd, int enable);
215 extern int dhd_pno_set_for_ssid(dhd_pub_t *dhd, wlc_ssid_t* ssid_list, int nssid,
216         uint16  scan_fr, int pno_repeat, int pno_freq_expo_max, uint16 *channel_list, int nchan);
217
218 extern int dhd_pno_set_for_batch(dhd_pub_t *dhd, struct dhd_pno_batch_params *batch_params);
219
220 extern int dhd_pno_get_for_batch(dhd_pub_t *dhd, char *buf, int bufsize, int reason);
221
222
223 extern int dhd_pno_stop_for_batch(dhd_pub_t *dhd);
224
225 extern int dhd_pno_set_for_hotlist(dhd_pub_t *dhd, wl_pfn_bssid_t *p_pfn_bssid,
226         struct dhd_pno_hotlist_params *hotlist_params);
227
228 extern int dhd_pno_stop_for_hotlist(dhd_pub_t *dhd);
229
230 extern int dhd_pno_event_handler(dhd_pub_t *dhd, wl_event_msg_t *event, void *event_data);
231 extern int dhd_pno_init(dhd_pub_t *dhd);
232 extern int dhd_pno_deinit(dhd_pub_t *dhd);
233 #endif 
234
235 #if defined(NDISVER)
236 #if defined(PNO_SUPPORT)
237 #if (NDISVER >= 0x0630)
238 extern int dhd_pno_cfg(dhd_pub_t *dhd, wl_pfn_cfg_t *pcfg);
239 extern int dhd_pno_suspend(dhd_pub_t *dhd, int pfn_suspend);
240 extern int dhd_pno_set_add(dhd_pub_t *dhd, wl_pfn_t *netinfo, int nssid, ushort scan_fr,
241         ushort slowscan_fr, uint8 pno_repeat, uint8 pno_freq_expo_max, int16 flags);
242 extern int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled);
243 extern int dhd_pno_clean(dhd_pub_t *dhd);
244 #endif /* #if (NDISVER >= 0x0630) */
245 #endif /* #if defined(PNO_SUPPORT) */
246 #endif /* #if defined(NDISVER) */
247 #endif /* __DHD_PNO_H__ */