1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef _wl_cfg80211_h_
18#define _wl_cfg80211_h_
19
20#include <linux/wireless.h>
21#include <linux/wireless.h>
22#include <net/cfg80211.h>
23#include <wlioctl.h>
24
25struct wl_conf;
26struct wl_iface;
27struct wl_priv;
28struct wl_security;
29struct wl_ibss;
30
31#define WL_DBG_NONE 0
32#define WL_DBG_DBG (1 << 2)
33#define WL_DBG_INFO (1 << 1)
34#define WL_DBG_ERR (1 << 0)
35#define WL_DBG_MASK ((WL_DBG_DBG | WL_DBG_INFO | WL_DBG_ERR) << 1)
36
37#define WL_DBG_LEVEL 1
38
39#define WL_ERR(fmt, args...) \
40do { \
41 if (wl_dbg_level & WL_DBG_ERR) { \
42 if (net_ratelimit()) { \
43 printk(KERN_ERR "ERROR @%s : " fmt, \
44 __func__, ##args); \
45 } \
46 } \
47} while (0)
48
49#define WL_INFO(fmt, args...) \
50do { \
51 if (wl_dbg_level & WL_DBG_INFO) { \
52 if (net_ratelimit()) { \
53 printk(KERN_ERR "INFO @%s : " fmt, \
54 __func__, ##args); \
55 } \
56 } \
57} while (0)
58
59#if (WL_DBG_LEVEL > 0)
60#define WL_DBG(fmt, args...) \
61do { \
62 if (wl_dbg_level & WL_DBG_DBG) { \
63 printk(KERN_ERR "DEBUG @%s :" fmt, \
64 __func__, ##args); \
65 } \
66} while (0)
67#else
68#define WL_DBG(fmt, args...) noprintk(fmt, ##args)
69#endif
70
71#define WL_SCAN_RETRY_MAX 3
72#define WL_NUM_SCAN_MAX 1
73#define WL_NUM_PMKIDS_MAX MAXPMKID
74
75
76
77#define WL_SCAN_BUF_MAX (1024 * 8)
78#define WL_TLV_INFO_MAX 1024
79#define WL_BSS_INFO_MAX 2048
80#define WL_ASSOC_INFO_MAX 512
81
82
83
84
85#define WL_IOCTL_LEN_MAX 1024
86#define WL_EXTRA_BUF_MAX 2048
87#define WL_ISCAN_BUF_MAX 2048
88
89
90
91#define WL_ISCAN_TIMER_INTERVAL_MS 3000
92#define WL_SCAN_ERSULTS_LAST (WL_SCAN_RESULTS_NO_MEM+1)
93#define WL_AP_MAX 256
94
95
96#define WL_FILE_NAME_MAX 256
97
98
99enum wl_status {
100 WL_STATUS_READY,
101 WL_STATUS_SCANNING,
102 WL_STATUS_SCAN_ABORTING,
103 WL_STATUS_CONNECTING,
104 WL_STATUS_CONNECTED
105};
106
107
108enum wl_mode {
109 WL_MODE_BSS,
110 WL_MODE_IBSS,
111 WL_MODE_AP
112};
113
114
115enum wl_prof_list {
116 WL_PROF_MODE,
117 WL_PROF_SSID,
118 WL_PROF_SEC,
119 WL_PROF_IBSS,
120 WL_PROF_BAND,
121 WL_PROF_BSSID,
122 WL_PROF_ACT,
123 WL_PROF_BEACONINT,
124 WL_PROF_DTIMPERIOD
125};
126
127
128enum wl_iscan_state {
129 WL_ISCAN_STATE_IDLE,
130 WL_ISCAN_STATE_SCANING
131};
132
133
134enum wl_fw_status {
135 WL_FW_LOADING_DONE,
136 WL_NVRAM_LOADING_DONE
137};
138
139
140struct beacon_proberesp {
141 __le64 timestamp;
142 __le16 beacon_int;
143 __le16 capab_info;
144 u8 variable[0];
145} __attribute__ ((packed));
146
147
148struct wl_conf {
149 u32 mode;
150 u32 frag_threshold;
151 u32 rts_threshold;
152 u32 retry_short;
153 u32 retry_long;
154 s32 tx_power;
155 struct ieee80211_channel channel;
156};
157
158
159struct wl_event_loop {
160 s32(*handler[WLC_E_LAST]) (struct wl_priv *wl,
161 struct net_device *ndev,
162 const wl_event_msg_t *e, void *data);
163};
164
165
166struct wl_iface {
167 struct wl_priv *wl;
168};
169
170struct wl_dev {
171 void *driver_data;
172};
173
174
175struct wl_cfg80211_bss_info {
176 u16 band;
177 u16 channel;
178 s16 rssi;
179 u16 frame_len;
180 u8 frame_buf[1];
181};
182
183
184struct wl_scan_req {
185 struct wlc_ssid ssid;
186};
187
188
189struct wl_ie {
190 u16 offset;
191 u8 buf[WL_TLV_INFO_MAX];
192};
193
194
195struct wl_event_q {
196 struct list_head eq_list;
197 u32 etype;
198 wl_event_msg_t emsg;
199 s8 edata[1];
200};
201
202
203struct wl_security {
204 u32 wpa_versions;
205 u32 auth_type;
206 u32 cipher_pairwise;
207 u32 cipher_group;
208 u32 wpa_auth;
209};
210
211
212struct wl_ibss {
213 u8 beacon_interval;
214 u8 atim;
215 s8 join_only;
216 u8 band;
217 u8 channel;
218};
219
220
221struct wl_profile {
222 u32 mode;
223 struct wlc_ssid ssid;
224 u8 bssid[ETH_ALEN];
225 u16 beacon_interval;
226 u8 dtim_period;
227 struct wl_security sec;
228 struct wl_ibss ibss;
229 s32 band;
230 bool active;
231};
232
233
234struct wl_iscan_eloop {
235 s32(*handler[WL_SCAN_ERSULTS_LAST]) (struct wl_priv *wl);
236};
237
238
239struct wl_iscan_ctrl {
240 struct net_device *dev;
241 struct timer_list timer;
242 u32 timer_ms;
243 u32 timer_on;
244 s32 state;
245 struct task_struct *tsk;
246 struct semaphore sync;
247 struct wl_iscan_eloop el;
248 void *data;
249 s8 ioctl_buf[WLC_IOCTL_SMLEN];
250 s8 scan_buf[WL_ISCAN_BUF_MAX];
251};
252
253
254struct wl_connect_info {
255 u8 *req_ie;
256 s32 req_ie_len;
257 u8 *resp_ie;
258 s32 resp_ie_len;
259};
260
261
262struct wl_fw_ctrl {
263 const struct firmware *fw_entry;
264 unsigned long status;
265 u32 ptr;
266 s8 fw_name[WL_FILE_NAME_MAX];
267 s8 nvram_name[WL_FILE_NAME_MAX];
268};
269
270
271struct wl_assoc_ielen {
272 u32 req_len;
273 u32 resp_len;
274};
275
276
277struct wl_pmk_list {
278 pmkid_list_t pmkids;
279 pmkid_t foo[MAXPMKID - 1];
280};
281
282
283struct wl_priv {
284 struct wireless_dev *wdev;
285 struct wl_conf *conf;
286 struct cfg80211_scan_request *scan_request;
287
288 struct wl_event_loop el;
289 struct list_head eq_list;
290 spinlock_t eq_lock;
291 struct mutex usr_sync;
292 struct wl_scan_results *bss_list;
293
294 struct wl_scan_results *scan_results;
295 struct wl_scan_req *scan_req_int;
296
297 struct wl_cfg80211_bss_info *bss_info;
298
299 struct wl_ie ie;
300
301 u8 bssid[ETH_ALEN];
302 struct semaphore event_sync;
303
304 struct wl_profile *profile;
305 struct wl_iscan_ctrl *iscan;
306 struct wl_connect_info conn_info;
307
308 struct wl_fw_ctrl *fw;
309
310 struct wl_pmk_list *pmk_list;
311 struct task_struct *event_tsk;
312 unsigned long status;
313 void *pub;
314 u32 channel;
315 bool iscan_on;
316 bool iscan_kickstart;
317 bool active_scan;
318 bool ibss_starter;
319 bool link_up;
320 bool pwr_save;
321
322 bool dongle_up;
323 bool roam_on;
324 bool scan_tried;
325 u8 *ioctl_buf;
326 u8 *extra_buf;
327 struct dentry *debugfsdir;
328 u8 ci[0] __attribute__ ((__aligned__(NETDEV_ALIGN)));
329};
330
331#define wl_to_dev(w) (wiphy_dev(wl->wdev->wiphy))
332#define wl_to_wiphy(w) (w->wdev->wiphy)
333#define wiphy_to_wl(w) ((struct wl_priv *)(wiphy_priv(w)))
334#define wl_to_wdev(w) (w->wdev)
335#define wdev_to_wl(w) ((struct wl_priv *)(wdev_priv(w)))
336#define wl_to_ndev(w) (w->wdev->netdev)
337#define ndev_to_wl(n) (wdev_to_wl(n->ieee80211_ptr))
338#define ci_to_wl(c) (ci->wl)
339#define wl_to_ci(w) (&w->ci)
340#define wl_to_sr(w) (w->scan_req_int)
341#define wl_to_ie(w) (&w->ie)
342#define iscan_to_wl(i) ((struct wl_priv *)(i->data))
343#define wl_to_iscan(w) (w->iscan)
344#define wl_to_conn(w) (&w->conn_info)
345
346static inline struct wl_bss_info *next_bss(struct wl_scan_results *list,
347 struct wl_bss_info *bss)
348{
349 return bss = bss ?
350 (struct wl_bss_info *)((unsigned long)bss +
351 le32_to_cpu(bss->length)) :
352 list->bss_info;
353}
354
355#define for_each_bss(list, bss, __i) \
356 for (__i = 0; __i < list->count && __i < WL_AP_MAX; __i++, bss = next_bss(list, bss))
357
358extern s32 wl_cfg80211_attach(struct net_device *ndev, void *data);
359extern void wl_cfg80211_detach(void);
360
361extern void wl_cfg80211_event(struct net_device *ndev, const wl_event_msg_t *e,
362 void *data);
363extern void wl_cfg80211_sdio_func(void *func);
364extern struct sdio_func *wl_cfg80211_get_sdio_func(void);
365extern s32 wl_cfg80211_up(void);
366extern s32 wl_cfg80211_down(void);
367extern void wl_cfg80211_dbg_level(u32 level);
368
369extern void *wl_cfg80211_request_fw(s8 *file_name);
370
371extern s32 wl_cfg80211_read_fw(s8 *buf, u32 size);
372
373extern void wl_cfg80211_release_fw(void);
374extern s8 *wl_cfg80211_get_fwname(void);
375
376extern s8 *wl_cfg80211_get_nvramname(void);
377
378
379#endif
380