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_
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))
29 #define WL_ERR(fmt, ...) \
31 if (brcmf_dbg_level & WL_DBG_ERR) { \
32 if (net_ratelimit()) { \
33 pr_err("ERROR @%s : " fmt, \
34 __func__, ##__VA_ARGS__); \
40 #define WL_INFO(fmt, ...) \
42 if (brcmf_dbg_level & WL_DBG_INFO) { \
43 if (net_ratelimit()) { \
44 pr_err("INFO @%s : " fmt, \
45 __func__, ##__VA_ARGS__); \
50 #define WL_TRACE(fmt, ...) \
52 if (brcmf_dbg_level & WL_DBG_TRACE) { \
53 if (net_ratelimit()) { \
54 pr_err("TRACE @%s : " fmt, \
55 __func__, ##__VA_ARGS__); \
60 #define WL_SCAN(fmt, ...) \
62 if (brcmf_dbg_level & WL_DBG_SCAN) { \
63 if (net_ratelimit()) { \
64 pr_err("SCAN @%s : " fmt, \
65 __func__, ##__VA_ARGS__); \
70 #define WL_CONN(fmt, ...) \
72 if (brcmf_dbg_level & WL_DBG_CONN) { \
73 if (net_ratelimit()) { \
74 pr_err("CONN @%s : " fmt, \
75 __func__, ##__VA_ARGS__); \
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) */
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
97 #define WL_SCAN_CHANNEL_TIME 40
98 #define WL_SCAN_UNASSOC_TIME 40
99 #define WL_SCAN_PASSIVE_TIME 120
101 #define WL_ESCAN_BUF_SIZE (1024 * 64)
102 #define WL_ESCAN_TIMER_INTERVAL_MS 8000 /* E-Scan timeout */
104 #define WL_ESCAN_ACTION_START 1
105 #define WL_ESCAN_ACTION_CONTINUE 2
106 #define WL_ESCAN_ACTION_ABORT 3
108 #define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
109 #define IE_MAX_LEN 512
112 * enum brcmf_scan_status - dongle scan status
114 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
115 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
117 enum brcmf_scan_status {
118 BRCMF_SCAN_STATUS_BUSY,
119 BRCMF_SCAN_STATUS_ABORT,
129 /* dongle configuration */
130 struct brcmf_cfg80211_conf {
131 u32 mode; /* adhoc , infrastructure or ap */
137 struct ieee80211_channel channel;
140 /* basic structure of scan request */
141 struct brcmf_cfg80211_scan_req {
142 struct brcmf_ssid_le ssid_le;
145 /* basic structure of information element */
146 struct brcmf_cfg80211_ie {
148 u8 buf[WL_TLV_INFO_MAX];
151 /* security information with currently associated ap */
152 struct brcmf_cfg80211_security {
161 * struct brcmf_cfg80211_profile - profile information.
163 * @ssid: ssid of associated/associating ap.
164 * @bssid: bssid of joined/joining ibss.
165 * @sec: security information.
167 struct brcmf_cfg80211_profile {
168 struct brcmf_ssid ssid;
170 struct brcmf_cfg80211_security sec;
174 * enum brcmf_vif_status - bit indices for vif status.
176 * @BRCMF_VIF_STATUS_READY: ready for operation.
177 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
178 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined succesfully.
179 * @BRCMF_VIF_STATUS_AP_CREATING: interface configured for AP operation.
180 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
182 enum brcmf_vif_status {
183 BRCMF_VIF_STATUS_READY,
184 BRCMF_VIF_STATUS_CONNECTING,
185 BRCMF_VIF_STATUS_CONNECTED,
186 BRCMF_VIF_STATUS_AP_CREATING,
187 BRCMF_VIF_STATUS_AP_CREATED
191 * struct vif_saved_ie - holds saved IEs for a virtual interface.
193 * @probe_res_ie: IE info for probe response.
194 * @beacon_ie: IE info for beacon frame.
195 * @probe_res_ie_len: IE info length for probe response.
196 * @beacon_ie_len: IE info length for beacon frame.
198 struct vif_saved_ie {
199 u8 probe_res_ie[IE_MAX_LEN];
200 u8 beacon_ie[IE_MAX_LEN];
201 u32 probe_res_ie_len;
206 * struct brcmf_cfg80211_vif - virtual interface specific information.
208 * @ifp: lower layer interface pointer
209 * @wdev: wireless device.
210 * @profile: profile information.
211 * @mode: operating mode.
212 * @roam_off: roaming state.
213 * @sme_state: SME state using enum brcmf_vif_status bits.
214 * @pm_block: power-management blocked.
215 * @list: linked list.
217 struct brcmf_cfg80211_vif {
218 struct brcmf_if *ifp;
219 struct wireless_dev wdev;
220 struct brcmf_cfg80211_profile profile;
223 unsigned long sme_state;
225 struct vif_saved_ie saved_ie;
226 struct list_head list;
229 /* association inform */
230 struct brcmf_cfg80211_connect_info {
237 /* assoc ie length */
238 struct brcmf_cfg80211_assoc_ielen_le {
244 struct brcmf_cfg80211_pmk_list {
245 struct pmkid_list pmkids;
246 struct pmkid foo[MAXPMKID - 1];
249 /* dongle escan state */
250 enum wl_escan_state {
252 WL_ESCAN_STATE_SCANNING
257 u8 escan_buf[WL_ESCAN_BUF_SIZE];
259 struct net_device *ndev;
263 * struct brcmf_pno_param_le - PNO scan configuration parameters
265 * @version: PNO parameters version.
266 * @scan_freq: scan frequency.
267 * @lost_network_timeout: #sec. to declare discovered network as lost.
268 * @flags: Bit field to control features of PFN such as sort criteria auto
269 * enable switch and background scan.
270 * @rssi_margin: Margin to avoid jitter for choosing a PFN based on RSSI sort
272 * @bestn: number of best networks in each scan.
273 * @mscan: number of scans recorded.
274 * @repeat: minimum number of scan intervals before scan frequency changes
276 * @exp: exponent of 2 for maximum scan interval.
277 * @slow_freq: slow scan period.
279 struct brcmf_pno_param_le {
282 __le32 lost_network_timeout;
293 * struct brcmf_pno_net_param_le - scan parameters per preferred network.
295 * @ssid: ssid name and its length.
296 * @flags: bit2: hidden.
297 * @infra: BSS vs IBSS.
298 * @auth: Open vs Closed.
299 * @wpa_auth: WPA type.
302 struct brcmf_pno_net_param_le {
303 struct brcmf_ssid_le ssid;
312 * struct brcmf_pno_net_info_le - information per found network.
314 * @bssid: BSS network identifier.
315 * @channel: channel number only.
316 * @SSID_len: length of ssid.
317 * @SSID: ssid characters.
318 * @RSSI: receive signal strength (in dBm).
319 * @timestamp: age in seconds.
321 struct brcmf_pno_net_info_le {
331 * struct brcmf_pno_scanresults_le - result returned in PNO NET FOUND event.
333 * @version: PNO version identifier.
334 * @status: indicates completion status of PNO scan.
335 * @count: amount of brcmf_pno_net_info_le entries appended.
337 struct brcmf_pno_scanresults_le {
344 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
346 * @wiphy: wiphy object for cfg80211 interface.
347 * @conf: dongle configuration.
348 * @scan_request: cfg80211 scan request object.
349 * @usr_sync: mainly for dongle up/down synchronization.
350 * @bss_list: bss_list holding scanned ap information.
351 * @scan_req_int: internal scan request object.
352 * @bss_info: bss information for cfg80211 layer.
353 * @ie: information element object for internal purpose.
354 * @conn_info: association info.
355 * @pmk_list: wpa2 pmk list.
356 * @scan_status: scan activity on the dongle.
357 * @pub: common driver information.
358 * @channel: current channel.
359 * @active_scan: current scan mode.
360 * @sched_escan: e-scan for scheduled scan support running.
361 * @ibss_starter: indicates this sta is ibss starter.
362 * @link_up: link/connection up flag.
363 * @pwr_save: indicate whether dongle to support power save mode.
364 * @dongle_up: indicate whether dongle up or not.
365 * @roam_on: on/off switch for dongle self-roaming.
366 * @scan_tried: indicates if first scan attempted.
367 * @dcmd_buf: dcmd buffer.
368 * @extra_buf: mainly to grab assoc information.
369 * @debugfsdir: debugfs folder for this device.
370 * @escan_info: escan information.
371 * @escan_timeout: Timer for catch scan timeout.
372 * @escan_timeout_work: scan timeout worker.
373 * @escan_ioctl_buf: dongle command buffer for escan commands.
374 * @vif_list: linked list of vif instances.
375 * @vif_cnt: number of vif instances.
377 struct brcmf_cfg80211_info {
379 struct brcmf_cfg80211_conf *conf;
380 struct cfg80211_scan_request *scan_request;
381 struct mutex usr_sync;
382 struct brcmf_scan_results *bss_list;
383 struct brcmf_cfg80211_scan_req scan_req_int;
384 struct wl_cfg80211_bss_info *bss_info;
385 struct brcmf_cfg80211_ie ie;
386 struct brcmf_cfg80211_connect_info conn_info;
387 struct brcmf_cfg80211_pmk_list *pmk_list;
388 unsigned long scan_status;
389 struct brcmf_pub *pub;
401 struct dentry *debugfsdir;
402 struct escan_info escan_info;
403 struct timer_list escan_timeout;
404 struct work_struct escan_timeout_work;
406 struct list_head vif_list;
410 static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
415 static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
417 return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
420 static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
422 return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
426 struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
428 struct brcmf_cfg80211_vif *vif;
429 vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
430 return vif->wdev.netdev;
433 static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
435 return wdev_to_cfg(ndev->ieee80211_ptr);
438 static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
440 struct brcmf_if *ifp = netdev_priv(nd);
441 return &ifp->vif->profile;
444 static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
446 struct brcmf_if *ifp = netdev_priv(ndev);
451 brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
453 return &cfg->conn_info;
456 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr);
457 void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
458 s32 brcmf_cfg80211_up(struct net_device *ndev);
459 s32 brcmf_cfg80211_down(struct net_device *ndev);
461 #endif /* _wl_cfg80211_h_ */