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