brcmfmac: Cleanup ssid storage.
[deliverable/linux.git] / drivers / net / wireless / broadcom / brcm80211 / brcmfmac / cfg80211.h
CommitLineData
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
bfe81975
HM
17#ifndef BRCMFMAC_CFG80211_H
18#define BRCMFMAC_CFG80211_H
5b435de0 19
83cf17aa
FL
20/* for brcmu_d11inf */
21#include <brcmu_d11.h>
22
f0799895
HM
23#define WL_NUM_SCAN_MAX 10
24#define WL_NUM_PMKIDS_MAX MAXPMKID
5b435de0
AS
25#define WL_TLV_INFO_MAX 1024
26#define WL_BSS_INFO_MAX 2048
f0799895
HM
27#define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
28#define WL_EXTRA_BUF_MAX 2048
5b435de0
AS
29#define WL_ROAM_TRIGGER_LEVEL -75
30#define WL_ROAM_DELTA 20
31#define WL_BEACON_TIMEOUT 3
32
33#define WL_SCAN_CHANNEL_TIME 40
34#define WL_SCAN_UNASSOC_TIME 40
35#define WL_SCAN_PASSIVE_TIME 120
36
e756af5b 37#define WL_ESCAN_BUF_SIZE (1024 * 64)
ef8596e1 38#define WL_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */
e756af5b
HM
39
40#define WL_ESCAN_ACTION_START 1
41#define WL_ESCAN_ACTION_CONTINUE 2
42#define WL_ESCAN_ACTION_ABORT 3
43
f09d0c02 44#define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
1a873342 45#define IE_MAX_LEN 512
f09d0c02 46
9f440b7b
AS
47/* IE TLV processing */
48#define TLV_LEN_OFF 1 /* length offset */
49#define TLV_HDR_LEN 2 /* header length */
50#define TLV_BODY_OFF 2 /* body offset */
51#define TLV_OUI_LEN 3 /* oui id length */
52
53/* 802.11 Mgmt Packet flags */
54#define BRCMF_VNDR_IE_BEACON_FLAG 0x1
55#define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2
56#define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
57#define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8
58#define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10
59#define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
60/* vendor IE in IW advertisement protocol ID field */
61#define BRCMF_VNDR_IE_IWAPID_FLAG 0x40
62/* allow custom IE id */
63#define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100
64
65/* P2P Action Frames flags (spec ordered) */
66#define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000
67#define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000
68#define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000
69#define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000
70#define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000
71#define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000
72#define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000
73#define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000
74#define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000
75
76#define BRCMF_VNDR_IE_P2PAF_SHIFT 12
77
118eb304
HM
78#define BRCMF_MAX_DEFAULT_KEYS 4
79
9f440b7b 80
c1179033 81/**
1687eee2 82 * enum brcmf_scan_status - scan engine status
c1179033
AS
83 *
84 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
85 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
1687eee2 86 * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
c1179033
AS
87 */
88enum brcmf_scan_status {
89 BRCMF_SCAN_STATUS_BUSY,
90 BRCMF_SCAN_STATUS_ABORT,
1687eee2 91 BRCMF_SCAN_STATUS_SUPPRESS,
5b435de0
AS
92};
93
5b435de0
AS
94/* dongle configuration */
95struct brcmf_cfg80211_conf {
5b435de0
AS
96 u32 frag_threshold;
97 u32 rts_threshold;
98 u32 retry_short;
99 u32 retry_long;
100 s32 tx_power;
101 struct ieee80211_channel channel;
102};
103
5b435de0
AS
104/* basic structure of scan request */
105struct brcmf_cfg80211_scan_req {
106 struct brcmf_ssid_le ssid_le;
107};
108
109/* basic structure of information element */
110struct brcmf_cfg80211_ie {
111 u16 offset;
112 u8 buf[WL_TLV_INFO_MAX];
113};
114
5b435de0
AS
115/* security information with currently associated ap */
116struct brcmf_cfg80211_security {
117 u32 wpa_versions;
118 u32 auth_type;
119 u32 cipher_pairwise;
120 u32 cipher_group;
121 u32 wpa_auth;
122};
123
3bc0a96c
AS
124/**
125 * struct brcmf_cfg80211_profile - profile information.
126 *
3bc0a96c
AS
127 * @bssid: bssid of joined/joining ibss.
128 * @sec: security information.
118eb304 129 * @key: key information
3bc0a96c 130 */
5b435de0 131struct brcmf_cfg80211_profile {
5b435de0 132 u8 bssid[ETH_ALEN];
5b435de0 133 struct brcmf_cfg80211_security sec;
118eb304 134 struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];
5b435de0
AS
135};
136
c1179033
AS
137/**
138 * enum brcmf_vif_status - bit indices for vif status.
139 *
140 * @BRCMF_VIF_STATUS_READY: ready for operation.
141 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
142 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
5f4f9f11 143 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
c1179033
AS
144 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
145 */
146enum brcmf_vif_status {
147 BRCMF_VIF_STATUS_READY,
148 BRCMF_VIF_STATUS_CONNECTING,
149 BRCMF_VIF_STATUS_CONNECTED,
5f4f9f11 150 BRCMF_VIF_STATUS_DISCONNECTING,
c1179033
AS
151 BRCMF_VIF_STATUS_AP_CREATED
152};
153
8ff5dc92
AS
154/**
155 * struct vif_saved_ie - holds saved IEs for a virtual interface.
156 *
9f440b7b 157 * @probe_req_ie: IE info for probe request.
8ff5dc92
AS
158 * @probe_res_ie: IE info for probe response.
159 * @beacon_ie: IE info for beacon frame.
9f440b7b 160 * @probe_req_ie_len: IE info length for probe request.
8ff5dc92
AS
161 * @probe_res_ie_len: IE info length for probe response.
162 * @beacon_ie_len: IE info length for beacon frame.
163 */
164struct vif_saved_ie {
dae3a273 165 u8 probe_req_ie[IE_MAX_LEN];
8ff5dc92
AS
166 u8 probe_res_ie[IE_MAX_LEN];
167 u8 beacon_ie[IE_MAX_LEN];
89286dc9 168 u8 assoc_req_ie[IE_MAX_LEN];
9f440b7b 169 u32 probe_req_ie_len;
8ff5dc92
AS
170 u32 probe_res_ie_len;
171 u32 beacon_ie_len;
89286dc9 172 u32 assoc_req_ie_len;
8ff5dc92
AS
173};
174
3eacf866
AS
175/**
176 * struct brcmf_cfg80211_vif - virtual interface specific information.
177 *
178 * @ifp: lower layer interface pointer
179 * @wdev: wireless device.
6ac4f4ed 180 * @profile: profile information.
3eacf866 181 * @roam_off: roaming state.
c1179033 182 * @sme_state: SME state using enum brcmf_vif_status bits.
3eacf866
AS
183 * @pm_block: power-management blocked.
184 * @list: linked list.
0de8aace 185 * @mgmt_rx_reg: registered rx mgmt frame types.
a44aa400 186 * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).
3eacf866
AS
187 */
188struct brcmf_cfg80211_vif {
189 struct brcmf_if *ifp;
190 struct wireless_dev wdev;
6ac4f4ed 191 struct brcmf_cfg80211_profile profile;
3eacf866 192 s32 roam_off;
c1179033 193 unsigned long sme_state;
3eacf866 194 bool pm_block;
8ff5dc92 195 struct vif_saved_ie saved_ie;
3eacf866 196 struct list_head list;
0de8aace 197 u16 mgmt_rx_reg;
a44aa400 198 bool mbss;
98027769 199 int is_11d;
3eacf866
AS
200};
201
5b435de0
AS
202/* association inform */
203struct brcmf_cfg80211_connect_info {
204 u8 *req_ie;
205 s32 req_ie_len;
206 u8 *resp_ie;
207 s32 resp_ie_len;
208};
209
210/* assoc ie length */
c4e382d2
AS
211struct brcmf_cfg80211_assoc_ielen_le {
212 __le32 req_len;
213 __le32 resp_len;
5b435de0
AS
214};
215
216/* wpa2 pmk list */
217struct brcmf_cfg80211_pmk_list {
218 struct pmkid_list pmkids;
219 struct pmkid foo[MAXPMKID - 1];
220};
221
e756af5b
HM
222/* dongle escan state */
223enum wl_escan_state {
224 WL_ESCAN_STATE_IDLE,
225 WL_ESCAN_STATE_SCANNING
226};
227
228struct escan_info {
229 u32 escan_state;
230 u8 escan_buf[WL_ESCAN_BUF_SIZE];
231 struct wiphy *wiphy;
a0f472ac
AS
232 struct brcmf_if *ifp;
233 s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
9f440b7b 234 struct cfg80211_scan_request *request, u16 action);
e756af5b
HM
235};
236
e5806072
AS
237/**
238 * struct brcmf_pno_param_le - PNO scan configuration parameters
239 *
240 * @version: PNO parameters version.
241 * @scan_freq: scan frequency.
242 * @lost_network_timeout: #sec. to declare discovered network as lost.
243 * @flags: Bit field to control features of PFN such as sort criteria auto
244 * enable switch and background scan.
245 * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
246 * criteria.
247 * @bestn: number of best networks in each scan.
248 * @mscan: number of scans recorded.
249 * @repeat: minimum number of scan intervals before scan frequency changes
250 * in adaptive scan.
251 * @exp: exponent of 2 for maximum scan interval.
252 * @slow_freq: slow scan period.
253 */
254struct brcmf_pno_param_le {
255 __le32 version;
256 __le32 scan_freq;
257 __le32 lost_network_timeout;
258 __le16 flags;
259 __le16 rssi_margin;
260 u8 bestn;
261 u8 mscan;
262 u8 repeat;
263 u8 exp;
264 __le32 slow_freq;
265};
266
267/**
268 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
269 *
270 * @ssid: ssid name and its length.
271 * @flags: bit2: hidden.
272 * @infra: BSS vs IBSS.
273 * @auth: Open vs Closed.
274 * @wpa_auth: WPA type.
275 * @wsec: wsec value.
276 */
277struct brcmf_pno_net_param_le {
278 struct brcmf_ssid_le ssid;
279 __le32 flags;
280 __le32 infra;
281 __le32 auth;
282 __le32 wpa_auth;
283 __le32 wsec;
284};
285
286/**
287 * struct brcmf_pno_net_info_le - information per found network.
288 *
289 * @bssid: BSS network identifier.
290 * @channel: channel number only.
291 * @SSID_len: length of ssid.
292 * @SSID: ssid characters.
293 * @RSSI: receive signal strength (in dBm).
294 * @timestamp: age in seconds.
295 */
296struct brcmf_pno_net_info_le {
297 u8 bssid[ETH_ALEN];
298 u8 channel;
299 u8 SSID_len;
300 u8 SSID[32];
301 __le16 RSSI;
302 __le16 timestamp;
303};
304
305/**
306 * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
307 *
308 * @version: PNO version identifier.
309 * @status: indicates completion status of PNO scan.
310 * @count: amount of brcmf_pno_net_info_le entries appended.
311 */
312struct brcmf_pno_scanresults_le {
313 __le32 version;
314 __le32 status;
315 __le32 count;
316};
317
d3c0b633
AS
318/**
319 * struct brcmf_cfg80211_vif_event - virtual interface event information.
320 *
321 * @vif_wq: waitqueue awaiting interface event from firmware.
322 * @vif_event_lock: protects other members in this structure.
323 * @vif_complete: completion for net attach.
324 * @action: either add, change, or delete.
325 * @vif: virtual interface object related to the event.
326 */
327struct brcmf_cfg80211_vif_event {
328 wait_queue_head_t vif_wq;
329 struct mutex vif_event_lock;
d3c0b633
AS
330 u8 action;
331 struct brcmf_cfg80211_vif *vif;
332};
333
02030eb6 334/**
27a68fe3 335 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
02030eb6 336 *
3eacf866 337 * @wiphy: wiphy object for cfg80211 interface.
02030eb6 338 * @conf: dongle configuration.
9f440b7b 339 * @p2p: peer-to-peer specific information.
61730d4d 340 * @btcoex: Bluetooth coexistence information.
02030eb6 341 * @scan_request: cfg80211 scan request object.
02030eb6
AS
342 * @usr_sync: mainly for dongle up/down synchronization.
343 * @bss_list: bss_list holding scanned ap information.
02030eb6
AS
344 * @scan_req_int: internal scan request object.
345 * @bss_info: bss information for cfg80211 layer.
346 * @ie: information element object for internal purpose.
02030eb6
AS
347 * @conn_info: association info.
348 * @pmk_list: wpa2 pmk list.
c1179033 349 * @scan_status: scan activity on the dongle.
02030eb6
AS
350 * @pub: common driver information.
351 * @channel: current channel.
02030eb6
AS
352 * @active_scan: current scan mode.
353 * @sched_escan: e-scan for scheduled scan support running.
354 * @ibss_starter: indicates this sta is ibss starter.
02030eb6
AS
355 * @pwr_save: indicate whether dongle to support power save mode.
356 * @dongle_up: indicate whether dongle up or not.
357 * @roam_on: on/off switch for dongle self-roaming.
358 * @scan_tried: indicates if first scan attempted.
359 * @dcmd_buf: dcmd buffer.
360 * @extra_buf: mainly to grab assoc information.
361 * @debugfsdir: debugfs folder for this device.
02030eb6
AS
362 * @escan_info: escan information.
363 * @escan_timeout: Timer for catch scan timeout.
364 * @escan_timeout_work: scan timeout worker.
365 * @escan_ioctl_buf: dongle command buffer for escan commands.
3eacf866
AS
366 * @vif_list: linked list of vif instances.
367 * @vif_cnt: number of vif instances.
d3c0b633 368 * @vif_event: vif event signalling.
4eb3af7c
HM
369 * @wowl_enabled; set during suspend, is wowl used.
370 * @pre_wowl_pmmode: intermediate storage of pm mode during wowl.
02030eb6 371 */
27a68fe3 372struct brcmf_cfg80211_info {
3eacf866 373 struct wiphy *wiphy;
02030eb6 374 struct brcmf_cfg80211_conf *conf;
9f440b7b 375 struct brcmf_p2p_info p2p;
61730d4d 376 struct brcmf_btcoex_info *btcoex;
02030eb6 377 struct cfg80211_scan_request *scan_request;
02030eb6 378 struct mutex usr_sync;
f0799895 379 struct brcmf_cfg80211_scan_req scan_req_int;
02030eb6
AS
380 struct wl_cfg80211_bss_info *bss_info;
381 struct brcmf_cfg80211_ie ie;
02030eb6
AS
382 struct brcmf_cfg80211_connect_info conn_info;
383 struct brcmf_cfg80211_pmk_list *pmk_list;
c1179033 384 unsigned long scan_status;
ee928381 385 struct brcmf_pub *pub;
02030eb6 386 u32 channel;
02030eb6
AS
387 bool active_scan;
388 bool sched_escan;
389 bool ibss_starter;
02030eb6
AS
390 bool pwr_save;
391 bool dongle_up;
02030eb6
AS
392 bool scan_tried;
393 u8 *dcmd_buf;
394 u8 *extra_buf;
5b435de0 395 struct dentry *debugfsdir;
02030eb6
AS
396 struct escan_info escan_info;
397 struct timer_list escan_timeout;
398 struct work_struct escan_timeout_work;
e756af5b 399 u8 *escan_ioctl_buf;
3eacf866 400 struct list_head vif_list;
d3c0b633 401 struct brcmf_cfg80211_vif_event vif_event;
5f4f9f11 402 struct completion vif_disabled;
83cf17aa 403 struct brcmu_d11inf d11inf;
4eb3af7c
HM
404 bool wowl_enabled;
405 u32 pre_wowl_pmmode;
bf2a7e04 406 struct brcmf_assoclist_le assoclist;
5b435de0
AS
407};
408
9f440b7b
AS
409/**
410 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
411 *
412 * @id: tag identifier.
413 * @len: number of bytes in value buffer.
414 * @data: value buffer.
415 */
416struct brcmf_tlv {
417 u8 id;
418 u8 len;
419 u8 data[1];
420};
421
3eacf866 422static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
5b435de0 423{
3eacf866 424 return cfg->wiphy;
5b435de0
AS
425}
426
27a68fe3 427static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
5b435de0 428{
27a68fe3 429 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
5b435de0
AS
430}
431
27a68fe3 432static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
5b435de0 433{
27a68fe3 434 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
5b435de0
AS
435}
436
3eacf866
AS
437static inline
438struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
5b435de0 439{
3eacf866
AS
440 struct brcmf_cfg80211_vif *vif;
441 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
442 return vif->wdev.netdev;
5b435de0
AS
443}
444
27a68fe3 445static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
5b435de0
AS
446{
447 return wdev_to_cfg(ndev->ieee80211_ptr);
448}
449
6ac4f4ed
AS
450static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
451{
452 struct brcmf_if *ifp = netdev_priv(nd);
453 return &ifp->vif->profile;
454}
455
1332e26e
AS
456static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
457{
458 struct brcmf_if *ifp = netdev_priv(ndev);
459 return ifp->vif;
460}
461
5b435de0 462static inline struct
27a68fe3 463brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
5b435de0
AS
464{
465 return &cfg->conn_info;
466}
467
d9cb2596 468struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
ae7c03f6
HM
469 struct device *busdev,
470 bool p2pdev_forced);
27a68fe3 471void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
bdf5ff51
AS
472s32 brcmf_cfg80211_up(struct net_device *ndev);
473s32 brcmf_cfg80211_down(struct net_device *ndev);
a7965fbb 474enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
5b435de0 475
9f440b7b 476struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
9f440b7b
AS
477 enum nl80211_iftype type,
478 bool pm_block);
427dec5f 479void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
9f440b7b
AS
480
481s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
482 const u8 *vndr_ie_buf, u32 vndr_ie_len);
5f4f9f11 483s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
4b5800fe
JB
484const struct brcmf_tlv *
485brcmf_parse_tlvs(const void *buf, int buflen, uint key);
83cf17aa
FL
486u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
487 struct ieee80211_channel *ch);
bfe81975
HM
488bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
489 unsigned long state);
d3c0b633
AS
490void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
491 struct brcmf_cfg80211_vif *vif);
492bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
493int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg,
494 u8 action, ulong timeout);
7a5c1f64 495s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
a0f472ac
AS
496 struct brcmf_if *ifp, bool aborted,
497 bool fw_abort);
f96aa07e 498void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
18e2f61d 499void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
9df4d542 500void brcmf_cfg80211_free_netdev(struct net_device *ndev);
9f440b7b 501
bfe81975 502#endif /* BRCMFMAC_CFG80211_H */
This page took 0.343362 seconds and 5 git commands to generate.