2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
17 #ifndef _wl_cfg80211_h_
18 #define _wl_cfg80211_h_
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
30 #define WL_SCAN_CHANNEL_TIME 40
31 #define WL_SCAN_UNASSOC_TIME 40
32 #define WL_SCAN_PASSIVE_TIME 120
34 #define WL_ESCAN_BUF_SIZE (1024 * 64)
35 #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
37 #define WL_ESCAN_ACTION_START 1
38 #define WL_ESCAN_ACTION_CONTINUE 2
39 #define WL_ESCAN_ACTION_ABORT 3
41 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
42 #define IE_MAX_LEN 512
45 * enum brcmf_scan_status - dongle scan status
47 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
48 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
50 enum brcmf_scan_status {
51 BRCMF_SCAN_STATUS_BUSY,
52 BRCMF_SCAN_STATUS_ABORT,
62 /* dongle configuration */
63 struct brcmf_cfg80211_conf {
69 struct ieee80211_channel channel;
72 /* basic structure of scan request */
73 struct brcmf_cfg80211_scan_req {
74 struct brcmf_ssid_le ssid_le;
77 /* basic structure of information element */
78 struct brcmf_cfg80211_ie {
80 u8 buf[WL_TLV_INFO_MAX];
83 /* security information with currently associated ap */
84 struct brcmf_cfg80211_security {
93 * struct brcmf_cfg80211_profile - profile information.
95 * @ssid: ssid of associated/associating ap.
96 * @bssid: bssid of joined/joining ibss.
97 * @sec: security information.
99 struct brcmf_cfg80211_profile {
100 struct brcmf_ssid ssid;
102 struct brcmf_cfg80211_security sec;
106 * enum brcmf_vif_status - bit indices for vif status.
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.
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
123 * struct vif_saved_ie - holds saved IEs for a virtual interface.
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.
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;
138 * struct brcmf_cfg80211_vif - virtual interface specific information.
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.
149 struct brcmf_cfg80211_vif {
150 struct brcmf_if *ifp;
151 struct wireless_dev wdev;
152 struct brcmf_cfg80211_profile profile;
155 unsigned long sme_state;
157 struct vif_saved_ie saved_ie;
158 struct list_head list;
161 /* association inform */
162 struct brcmf_cfg80211_connect_info {
169 /* assoc ie length */
170 struct brcmf_cfg80211_assoc_ielen_le {
176 struct brcmf_cfg80211_pmk_list {
177 struct pmkid_list pmkids;
178 struct pmkid foo[MAXPMKID - 1];
181 /* dongle escan state */
182 enum wl_escan_state {
184 WL_ESCAN_STATE_SCANNING
189 u8 escan_buf[WL_ESCAN_BUF_SIZE];
191 struct net_device *ndev;
195 * struct brcmf_pno_param_le - PNO scan configuration parameters
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
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
208 * @exp: exponent of 2 for maximum scan interval.
209 * @slow_freq: slow scan period.
211 struct brcmf_pno_param_le {
214 __le32 lost_network_timeout;
225 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
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.
234 struct brcmf_pno_net_param_le {
235 struct brcmf_ssid_le ssid;
244 * struct brcmf_pno_net_info_le - information per found network.
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.
253 struct brcmf_pno_net_info_le {
263 * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
265 * @version: PNO version identifier.
266 * @status: indicates completion status of PNO scan.
267 * @count: amount of brcmf_pno_net_info_le entries appended.
269 struct brcmf_pno_scanresults_le {
276 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
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.
308 struct brcmf_cfg80211_info {
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;
331 struct dentry *debugfsdir;
332 struct escan_info escan_info;
333 struct timer_list escan_timeout;
334 struct work_struct escan_timeout_work;
336 struct list_head vif_list;
340 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
345 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
347 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
350 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
352 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
356 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
358 struct brcmf_cfg80211_vif *vif;
359 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
360 return vif->wdev.netdev;
363 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
365 return wdev_to_cfg(ndev->ieee80211_ptr);
368 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
370 struct brcmf_if *ifp = netdev_priv(nd);
371 return &ifp->vif->profile;
374 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
376 struct brcmf_if *ifp = netdev_priv(ndev);
381 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
383 return &cfg->conn_info;
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);
392 #endif /* _wl_cfg80211_h_ */