Commit | Line | Data |
---|---|---|
5b435de0 AS |
1 | /* |
2 | * Copyright (c) 2010 Broadcom Corporation | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | #ifndef _wl_cfg80211_h_ | |
18 | #define _wl_cfg80211_h_ | |
19 | ||
9623aba8 | 20 | #include "dhd_dbg.h" |
5b435de0 | 21 | |
9623aba8 | 22 | #define WL_CONN(fmt, ...) brcmf_dbg(CONN, fmt, ##__VA_ARGS__) |
5b435de0 | 23 | |
f0799895 HM |
24 | #define WL_NUM_SCAN_MAX 10 |
25 | #define WL_NUM_PMKIDS_MAX MAXPMKID | |
5b435de0 AS |
26 | #define WL_TLV_INFO_MAX 1024 |
27 | #define WL_BSS_INFO_MAX 2048 | |
f0799895 HM |
28 | #define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */ |
29 | #define WL_EXTRA_BUF_MAX 2048 | |
5b435de0 AS |
30 | #define WL_ROAM_TRIGGER_LEVEL -75 |
31 | #define WL_ROAM_DELTA 20 | |
32 | #define WL_BEACON_TIMEOUT 3 | |
33 | ||
34 | #define WL_SCAN_CHANNEL_TIME 40 | |
35 | #define WL_SCAN_UNASSOC_TIME 40 | |
36 | #define WL_SCAN_PASSIVE_TIME 120 | |
37 | ||
e756af5b HM |
38 | #define WL_ESCAN_BUF_SIZE (1024 * 64) |
39 | #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */ | |
40 | ||
41 | #define WL_ESCAN_ACTION_START 1 | |
42 | #define WL_ESCAN_ACTION_CONTINUE 2 | |
43 | #define WL_ESCAN_ACTION_ABORT 3 | |
44 | ||
f09d0c02 | 45 | #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */ |
1a873342 | 46 | #define IE_MAX_LEN 512 |
f09d0c02 | 47 | |
c1179033 AS |
48 | /** |
49 | * enum brcmf_scan_status - dongle scan status | |
50 | * | |
51 | * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle. | |
52 | * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle. | |
53 | */ | |
54 | enum brcmf_scan_status { | |
55 | BRCMF_SCAN_STATUS_BUSY, | |
56 | BRCMF_SCAN_STATUS_ABORT, | |
5b435de0 AS |
57 | }; |
58 | ||
59 | /* wi-fi mode */ | |
60 | enum wl_mode { | |
61 | WL_MODE_BSS, | |
62 | WL_MODE_IBSS, | |
63 | WL_MODE_AP | |
64 | }; | |
65 | ||
5b435de0 AS |
66 | /* dongle configuration */ |
67 | struct brcmf_cfg80211_conf { | |
5b435de0 AS |
68 | u32 frag_threshold; |
69 | u32 rts_threshold; | |
70 | u32 retry_short; | |
71 | u32 retry_long; | |
72 | s32 tx_power; | |
73 | struct ieee80211_channel channel; | |
74 | }; | |
75 | ||
5b435de0 AS |
76 | /* basic structure of scan request */ |
77 | struct brcmf_cfg80211_scan_req { | |
78 | struct brcmf_ssid_le ssid_le; | |
79 | }; | |
80 | ||
81 | /* basic structure of information element */ | |
82 | struct brcmf_cfg80211_ie { | |
83 | u16 offset; | |
84 | u8 buf[WL_TLV_INFO_MAX]; | |
85 | }; | |
86 | ||
5b435de0 AS |
87 | /* security information with currently associated ap */ |
88 | struct brcmf_cfg80211_security { | |
89 | u32 wpa_versions; | |
90 | u32 auth_type; | |
91 | u32 cipher_pairwise; | |
92 | u32 cipher_group; | |
93 | u32 wpa_auth; | |
94 | }; | |
95 | ||
3bc0a96c AS |
96 | /** |
97 | * struct brcmf_cfg80211_profile - profile information. | |
98 | * | |
99 | * @ssid: ssid of associated/associating ap. | |
100 | * @bssid: bssid of joined/joining ibss. | |
101 | * @sec: security information. | |
102 | */ | |
5b435de0 | 103 | struct brcmf_cfg80211_profile { |
5b435de0 AS |
104 | struct brcmf_ssid ssid; |
105 | u8 bssid[ETH_ALEN]; | |
5b435de0 | 106 | struct brcmf_cfg80211_security sec; |
5b435de0 AS |
107 | }; |
108 | ||
c1179033 AS |
109 | /** |
110 | * enum brcmf_vif_status - bit indices for vif status. | |
111 | * | |
112 | * @BRCMF_VIF_STATUS_READY: ready for operation. | |
113 | * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress. | |
114 | * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully. | |
115 | * @BRCMF_VIF_STATUS_AP_CREATING: interface configured for AP operation. | |
116 | * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started. | |
117 | */ | |
118 | enum brcmf_vif_status { | |
119 | BRCMF_VIF_STATUS_READY, | |
120 | BRCMF_VIF_STATUS_CONNECTING, | |
121 | BRCMF_VIF_STATUS_CONNECTED, | |
122 | BRCMF_VIF_STATUS_AP_CREATING, | |
123 | BRCMF_VIF_STATUS_AP_CREATED | |
124 | }; | |
125 | ||
8ff5dc92 AS |
126 | /** |
127 | * struct vif_saved_ie - holds saved IEs for a virtual interface. | |
128 | * | |
129 | * @probe_res_ie: IE info for probe response. | |
130 | * @beacon_ie: IE info for beacon frame. | |
131 | * @probe_res_ie_len: IE info length for probe response. | |
132 | * @beacon_ie_len: IE info length for beacon frame. | |
133 | */ | |
134 | struct vif_saved_ie { | |
135 | u8 probe_res_ie[IE_MAX_LEN]; | |
136 | u8 beacon_ie[IE_MAX_LEN]; | |
137 | u32 probe_res_ie_len; | |
138 | u32 beacon_ie_len; | |
139 | }; | |
140 | ||
3eacf866 AS |
141 | /** |
142 | * struct brcmf_cfg80211_vif - virtual interface specific information. | |
143 | * | |
144 | * @ifp: lower layer interface pointer | |
145 | * @wdev: wireless device. | |
6ac4f4ed | 146 | * @profile: profile information. |
3eacf866 AS |
147 | * @mode: operating mode. |
148 | * @roam_off: roaming state. | |
c1179033 | 149 | * @sme_state: SME state using enum brcmf_vif_status bits. |
3eacf866 AS |
150 | * @pm_block: power-management blocked. |
151 | * @list: linked list. | |
152 | */ | |
153 | struct brcmf_cfg80211_vif { | |
154 | struct brcmf_if *ifp; | |
155 | struct wireless_dev wdev; | |
6ac4f4ed | 156 | struct brcmf_cfg80211_profile profile; |
3eacf866 AS |
157 | s32 mode; |
158 | s32 roam_off; | |
c1179033 | 159 | unsigned long sme_state; |
3eacf866 | 160 | bool pm_block; |
8ff5dc92 | 161 | struct vif_saved_ie saved_ie; |
3eacf866 AS |
162 | struct list_head list; |
163 | }; | |
164 | ||
5b435de0 AS |
165 | /* association inform */ |
166 | struct brcmf_cfg80211_connect_info { | |
167 | u8 *req_ie; | |
168 | s32 req_ie_len; | |
169 | u8 *resp_ie; | |
170 | s32 resp_ie_len; | |
171 | }; | |
172 | ||
173 | /* assoc ie length */ | |
c4e382d2 AS |
174 | struct brcmf_cfg80211_assoc_ielen_le { |
175 | __le32 req_len; | |
176 | __le32 resp_len; | |
5b435de0 AS |
177 | }; |
178 | ||
179 | /* wpa2 pmk list */ | |
180 | struct brcmf_cfg80211_pmk_list { | |
181 | struct pmkid_list pmkids; | |
182 | struct pmkid foo[MAXPMKID - 1]; | |
183 | }; | |
184 | ||
e756af5b HM |
185 | /* dongle escan state */ |
186 | enum wl_escan_state { | |
187 | WL_ESCAN_STATE_IDLE, | |
188 | WL_ESCAN_STATE_SCANNING | |
189 | }; | |
190 | ||
191 | struct escan_info { | |
192 | u32 escan_state; | |
193 | u8 escan_buf[WL_ESCAN_BUF_SIZE]; | |
194 | struct wiphy *wiphy; | |
195 | struct net_device *ndev; | |
196 | }; | |
197 | ||
e5806072 AS |
198 | /** |
199 | * struct brcmf_pno_param_le - PNO scan configuration parameters | |
200 | * | |
201 | * @version: PNO parameters version. | |
202 | * @scan_freq: scan frequency. | |
203 | * @lost_network_timeout: #sec. to declare discovered network as lost. | |
204 | * @flags: Bit field to control features of PFN such as sort criteria auto | |
205 | * enable switch and background scan. | |
206 | * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort | |
207 | * criteria. | |
208 | * @bestn: number of best networks in each scan. | |
209 | * @mscan: number of scans recorded. | |
210 | * @repeat: minimum number of scan intervals before scan frequency changes | |
211 | * in adaptive scan. | |
212 | * @exp: exponent of 2 for maximum scan interval. | |
213 | * @slow_freq: slow scan period. | |
214 | */ | |
215 | struct brcmf_pno_param_le { | |
216 | __le32 version; | |
217 | __le32 scan_freq; | |
218 | __le32 lost_network_timeout; | |
219 | __le16 flags; | |
220 | __le16 rssi_margin; | |
221 | u8 bestn; | |
222 | u8 mscan; | |
223 | u8 repeat; | |
224 | u8 exp; | |
225 | __le32 slow_freq; | |
226 | }; | |
227 | ||
228 | /** | |
229 | * struct brcmf_pno_net_param_le - scan parameters per preferred network. | |
230 | * | |
231 | * @ssid: ssid name and its length. | |
232 | * @flags: bit2: hidden. | |
233 | * @infra: BSS vs IBSS. | |
234 | * @auth: Open vs Closed. | |
235 | * @wpa_auth: WPA type. | |
236 | * @wsec: wsec value. | |
237 | */ | |
238 | struct brcmf_pno_net_param_le { | |
239 | struct brcmf_ssid_le ssid; | |
240 | __le32 flags; | |
241 | __le32 infra; | |
242 | __le32 auth; | |
243 | __le32 wpa_auth; | |
244 | __le32 wsec; | |
245 | }; | |
246 | ||
247 | /** | |
248 | * struct brcmf_pno_net_info_le - information per found network. | |
249 | * | |
250 | * @bssid: BSS network identifier. | |
251 | * @channel: channel number only. | |
252 | * @SSID_len: length of ssid. | |
253 | * @SSID: ssid characters. | |
254 | * @RSSI: receive signal strength (in dBm). | |
255 | * @timestamp: age in seconds. | |
256 | */ | |
257 | struct brcmf_pno_net_info_le { | |
258 | u8 bssid[ETH_ALEN]; | |
259 | u8 channel; | |
260 | u8 SSID_len; | |
261 | u8 SSID[32]; | |
262 | __le16 RSSI; | |
263 | __le16 timestamp; | |
264 | }; | |
265 | ||
266 | /** | |
267 | * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event. | |
268 | * | |
269 | * @version: PNO version identifier. | |
270 | * @status: indicates completion status of PNO scan. | |
271 | * @count: amount of brcmf_pno_net_info_le entries appended. | |
272 | */ | |
273 | struct brcmf_pno_scanresults_le { | |
274 | __le32 version; | |
275 | __le32 status; | |
276 | __le32 count; | |
277 | }; | |
278 | ||
02030eb6 | 279 | /** |
27a68fe3 | 280 | * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface |
02030eb6 | 281 | * |
3eacf866 | 282 | * @wiphy: wiphy object for cfg80211 interface. |
02030eb6 AS |
283 | * @conf: dongle configuration. |
284 | * @scan_request: cfg80211 scan request object. | |
02030eb6 AS |
285 | * @usr_sync: mainly for dongle up/down synchronization. |
286 | * @bss_list: bss_list holding scanned ap information. | |
02030eb6 AS |
287 | * @scan_req_int: internal scan request object. |
288 | * @bss_info: bss information for cfg80211 layer. | |
289 | * @ie: information element object for internal purpose. | |
02030eb6 AS |
290 | * @conn_info: association info. |
291 | * @pmk_list: wpa2 pmk list. | |
c1179033 | 292 | * @scan_status: scan activity on the dongle. |
02030eb6 AS |
293 | * @pub: common driver information. |
294 | * @channel: current channel. | |
02030eb6 AS |
295 | * @active_scan: current scan mode. |
296 | * @sched_escan: e-scan for scheduled scan support running. | |
297 | * @ibss_starter: indicates this sta is ibss starter. | |
02030eb6 AS |
298 | * @pwr_save: indicate whether dongle to support power save mode. |
299 | * @dongle_up: indicate whether dongle up or not. | |
300 | * @roam_on: on/off switch for dongle self-roaming. | |
301 | * @scan_tried: indicates if first scan attempted. | |
302 | * @dcmd_buf: dcmd buffer. | |
303 | * @extra_buf: mainly to grab assoc information. | |
304 | * @debugfsdir: debugfs folder for this device. | |
02030eb6 AS |
305 | * @escan_info: escan information. |
306 | * @escan_timeout: Timer for catch scan timeout. | |
307 | * @escan_timeout_work: scan timeout worker. | |
308 | * @escan_ioctl_buf: dongle command buffer for escan commands. | |
3eacf866 AS |
309 | * @vif_list: linked list of vif instances. |
310 | * @vif_cnt: number of vif instances. | |
02030eb6 | 311 | */ |
27a68fe3 | 312 | struct brcmf_cfg80211_info { |
3eacf866 | 313 | struct wiphy *wiphy; |
02030eb6 AS |
314 | struct brcmf_cfg80211_conf *conf; |
315 | struct cfg80211_scan_request *scan_request; | |
02030eb6 AS |
316 | struct mutex usr_sync; |
317 | struct brcmf_scan_results *bss_list; | |
f0799895 | 318 | struct brcmf_cfg80211_scan_req scan_req_int; |
02030eb6 AS |
319 | struct wl_cfg80211_bss_info *bss_info; |
320 | struct brcmf_cfg80211_ie ie; | |
02030eb6 AS |
321 | struct brcmf_cfg80211_connect_info conn_info; |
322 | struct brcmf_cfg80211_pmk_list *pmk_list; | |
c1179033 | 323 | unsigned long scan_status; |
ee928381 | 324 | struct brcmf_pub *pub; |
02030eb6 | 325 | u32 channel; |
02030eb6 AS |
326 | bool active_scan; |
327 | bool sched_escan; | |
328 | bool ibss_starter; | |
02030eb6 AS |
329 | bool pwr_save; |
330 | bool dongle_up; | |
331 | bool roam_on; | |
332 | bool scan_tried; | |
333 | u8 *dcmd_buf; | |
334 | u8 *extra_buf; | |
5b435de0 | 335 | struct dentry *debugfsdir; |
02030eb6 AS |
336 | struct escan_info escan_info; |
337 | struct timer_list escan_timeout; | |
338 | struct work_struct escan_timeout_work; | |
e756af5b | 339 | u8 *escan_ioctl_buf; |
3eacf866 AS |
340 | struct list_head vif_list; |
341 | u8 vif_cnt; | |
5b435de0 AS |
342 | }; |
343 | ||
3eacf866 | 344 | static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg) |
5b435de0 | 345 | { |
3eacf866 | 346 | return cfg->wiphy; |
5b435de0 AS |
347 | } |
348 | ||
27a68fe3 | 349 | static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w) |
5b435de0 | 350 | { |
27a68fe3 | 351 | return (struct brcmf_cfg80211_info *)(wiphy_priv(w)); |
5b435de0 AS |
352 | } |
353 | ||
27a68fe3 | 354 | static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd) |
5b435de0 | 355 | { |
27a68fe3 | 356 | return (struct brcmf_cfg80211_info *)(wdev_priv(wd)); |
5b435de0 AS |
357 | } |
358 | ||
3eacf866 AS |
359 | static inline |
360 | struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg) | |
5b435de0 | 361 | { |
3eacf866 AS |
362 | struct brcmf_cfg80211_vif *vif; |
363 | vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list); | |
364 | return vif->wdev.netdev; | |
5b435de0 AS |
365 | } |
366 | ||
27a68fe3 | 367 | static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev) |
5b435de0 AS |
368 | { |
369 | return wdev_to_cfg(ndev->ieee80211_ptr); | |
370 | } | |
371 | ||
6ac4f4ed AS |
372 | static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd) |
373 | { | |
374 | struct brcmf_if *ifp = netdev_priv(nd); | |
375 | return &ifp->vif->profile; | |
376 | } | |
377 | ||
1332e26e AS |
378 | static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev) |
379 | { | |
380 | struct brcmf_if *ifp = netdev_priv(ndev); | |
381 | return ifp->vif; | |
382 | } | |
383 | ||
5b435de0 | 384 | static inline struct |
27a68fe3 | 385 | brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg) |
5b435de0 AS |
386 | { |
387 | return &cfg->conn_info; | |
388 | } | |
389 | ||
d9cb2596 AS |
390 | struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, |
391 | struct device *busdev); | |
27a68fe3 | 392 | void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg); |
bdf5ff51 AS |
393 | s32 brcmf_cfg80211_up(struct net_device *ndev); |
394 | s32 brcmf_cfg80211_down(struct net_device *ndev); | |
5b435de0 AS |
395 | |
396 | #endif /* _wl_cfg80211_h_ */ |