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_
22 #define WL_SCAN(fmt, ...) brcmf_dbg(SCAN, fmt, ##__VA_ARGS__)
23 #define WL_CONN(fmt, ...) brcmf_dbg(CONN, fmt, ##__VA_ARGS__)
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
35 #define WL_SCAN_CHANNEL_TIME 40
36 #define WL_SCAN_UNASSOC_TIME 40
37 #define WL_SCAN_PASSIVE_TIME 120
39 #define WL_ESCAN_BUF_SIZE (1024 * 64)
40 #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
42 #define WL_ESCAN_ACTION_START 1
43 #define WL_ESCAN_ACTION_CONTINUE 2
44 #define WL_ESCAN_ACTION_ABORT 3
46 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
47 #define IE_MAX_LEN 512
50 * enum brcmf_scan_status - dongle scan status
52 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
53 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
55 enum brcmf_scan_status {
56 BRCMF_SCAN_STATUS_BUSY,
57 BRCMF_SCAN_STATUS_ABORT,
67 /* dongle configuration */
68 struct brcmf_cfg80211_conf {
74 struct ieee80211_channel channel;
77 /* basic structure of scan request */
78 struct brcmf_cfg80211_scan_req {
79 struct brcmf_ssid_le ssid_le;
82 /* basic structure of information element */
83 struct brcmf_cfg80211_ie {
85 u8 buf[WL_TLV_INFO_MAX];
88 /* security information with currently associated ap */
89 struct brcmf_cfg80211_security {
98 * struct brcmf_cfg80211_profile - profile information.
100 * @ssid: ssid of associated/associating ap.
101 * @bssid: bssid of joined/joining ibss.
102 * @sec: security information.
104 struct brcmf_cfg80211_profile {
105 struct brcmf_ssid ssid;
107 struct brcmf_cfg80211_security sec;
111 * enum brcmf_vif_status - bit indices for vif status.
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.
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
128 * struct vif_saved_ie - holds saved IEs for a virtual interface.
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.
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;
143 * struct brcmf_cfg80211_vif - virtual interface specific information.
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.
154 struct brcmf_cfg80211_vif {
155 struct brcmf_if *ifp;
156 struct wireless_dev wdev;
157 struct brcmf_cfg80211_profile profile;
160 unsigned long sme_state;
162 struct vif_saved_ie saved_ie;
163 struct list_head list;
166 /* association inform */
167 struct brcmf_cfg80211_connect_info {
174 /* assoc ie length */
175 struct brcmf_cfg80211_assoc_ielen_le {
181 struct brcmf_cfg80211_pmk_list {
182 struct pmkid_list pmkids;
183 struct pmkid foo[MAXPMKID - 1];
186 /* dongle escan state */
187 enum wl_escan_state {
189 WL_ESCAN_STATE_SCANNING
194 u8 escan_buf[WL_ESCAN_BUF_SIZE];
196 struct net_device *ndev;
200 * struct brcmf_pno_param_le - PNO scan configuration parameters
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
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
213 * @exp: exponent of 2 for maximum scan interval.
214 * @slow_freq: slow scan period.
216 struct brcmf_pno_param_le {
219 __le32 lost_network_timeout;
230 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
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.
239 struct brcmf_pno_net_param_le {
240 struct brcmf_ssid_le ssid;
249 * struct brcmf_pno_net_info_le - information per found network.
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.
258 struct brcmf_pno_net_info_le {
268 * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
270 * @version: PNO version identifier.
271 * @status: indicates completion status of PNO scan.
272 * @count: amount of brcmf_pno_net_info_le entries appended.
274 struct brcmf_pno_scanresults_le {
281 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
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.
313 struct brcmf_cfg80211_info {
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;
336 struct dentry *debugfsdir;
337 struct escan_info escan_info;
338 struct timer_list escan_timeout;
339 struct work_struct escan_timeout_work;
341 struct list_head vif_list;
345 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
350 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
352 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
355 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
357 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
361 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
363 struct brcmf_cfg80211_vif *vif;
364 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
365 return vif->wdev.netdev;
368 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
370 return wdev_to_cfg(ndev->ieee80211_ptr);
373 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
375 struct brcmf_if *ifp = netdev_priv(nd);
376 return &ifp->vif->profile;
379 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
381 struct brcmf_if *ifp = netdev_priv(ndev);
386 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
388 return &cfg->conn_info;
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);
397 #endif /* _wl_cfg80211_h_ */