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