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