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