]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/ks7010/ks_wlan.h
Merge tag 'doc-4.10-3' of git://git.lwn.net/linux
[mirror_ubuntu-artful-kernel.git] / drivers / staging / ks7010 / ks_wlan.h
1 /*
2 * Driver for KeyStream IEEE802.11 b/g wireless LAN cards.
3 *
4 * Copyright (C) 2006-2008 KeyStream Corp.
5 * Copyright (C) 2009 Renesas Technology Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 #ifndef _KS_WLAN_H
13 #define _KS_WLAN_H
14
15 #define WPS
16
17 #include <linux/interrupt.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20
21 #include <linux/spinlock.h> /* spinlock_t */
22 #include <linux/sched.h> /* wait_queue_head_t */
23 #include <linux/types.h> /* pid_t */
24 #include <linux/netdevice.h> /* struct net_device_stats, struct sk_buff */
25 #include <linux/etherdevice.h>
26 #include <linux/wireless.h>
27 #include <linux/atomic.h> /* struct atomic_t */
28 #include <linux/timer.h> /* struct timer_list */
29 #include <linux/string.h>
30 #include <linux/completion.h> /* struct completion */
31 #include <linux/workqueue.h>
32
33 #include <linux/io.h>
34
35 #include "ks7010_sdio.h"
36
37 #ifdef KS_WLAN_DEBUG
38 #define DPRINTK(n, fmt, args...) \
39 if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, __FUNCTION__, ## args)
40 #else
41 #define DPRINTK(n, fmt, args...)
42 #endif
43
44 struct ks_wlan_parameter {
45 u8 operation_mode; /* Operation Mode */
46 u8 channel; /* Channel */
47 u8 tx_rate; /* Transmit Rate */
48 struct {
49 u8 size;
50 u8 body[16];
51 } rate_set;
52 u8 bssid[ETH_ALEN]; /* BSSID */
53 struct {
54 u8 size;
55 u8 body[32 + 1];
56 } ssid; /* SSID */
57 u8 preamble; /* Preamble */
58 u8 powermgt; /* PowerManagementMode */
59 u32 scan_type; /* AP List Scan Type */
60 #define BEACON_LOST_COUNT_MIN 0
61 #define BEACON_LOST_COUNT_MAX 65535
62 u32 beacon_lost_count; /* Beacon Lost Count */
63 u32 rts; /* RTS Threashold */
64 u32 fragment; /* Fragmentation Threashold */
65 u32 privacy_invoked;
66 u32 wep_index;
67 struct {
68 u8 size;
69 u8 val[13 * 2 + 1];
70 } wep_key[4];
71 u16 authenticate_type;
72 u16 phy_type; /* 11b/11g/11bg mode type */
73 u16 cts_mode; /* for 11g/11bg mode cts mode */
74 u16 phy_info_timer; /* phy information timer */
75 };
76
77 enum {
78 DEVICE_STATE_OFF = 0, /* this means hw_unavailable is != 0 */
79 DEVICE_STATE_PREBOOT, /* we are in a pre-boot state (empty RAM) */
80 DEVICE_STATE_BOOT, /* boot state (fw upload, run fw) */
81 DEVICE_STATE_PREINIT, /* pre-init state */
82 DEVICE_STATE_INIT, /* init state (restore MIB backup to device) */
83 DEVICE_STATE_READY, /* driver&device are in operational state */
84 DEVICE_STATE_SLEEP /* device in sleep mode */
85 };
86
87 /* SME flag */
88 #define SME_MODE_SET (1<<0)
89 #define SME_RTS (1<<1)
90 #define SME_FRAG (1<<2)
91 #define SME_WEP_FLAG (1<<3)
92 #define SME_WEP_INDEX (1<<4)
93 #define SME_WEP_VAL1 (1<<5)
94 #define SME_WEP_VAL2 (1<<6)
95 #define SME_WEP_VAL3 (1<<7)
96 #define SME_WEP_VAL4 (1<<8)
97 #define SME_WEP_VAL_MASK (SME_WEP_VAL1|SME_WEP_VAL2|SME_WEP_VAL3|SME_WEP_VAL4)
98 #define SME_RSN (1<<9)
99 #define SME_RSN_MULTICAST (1<<10)
100 #define SME_RSN_UNICAST (1<<11)
101 #define SME_RSN_AUTH (1<<12)
102
103 #define SME_AP_SCAN (1<<13)
104 #define SME_MULTICAST (1<<14)
105
106 /* SME Event */
107 enum {
108 SME_START,
109
110 SME_MULTICAST_REQUEST,
111 SME_MACADDRESS_SET_REQUEST,
112 SME_BSS_SCAN_REQUEST,
113 SME_SET_FLAG,
114 SME_SET_TXKEY,
115 SME_SET_KEY1,
116 SME_SET_KEY2,
117 SME_SET_KEY3,
118 SME_SET_KEY4,
119 SME_SET_PMK_TSC,
120 SME_SET_GMK1_TSC,
121 SME_SET_GMK2_TSC,
122 SME_SET_GMK3_TSC,
123 SME_SET_PMKSA,
124 SME_POW_MNGMT_REQUEST,
125 SME_PHY_INFO_REQUEST,
126 SME_MIC_FAILURE_REQUEST,
127 SME_GET_MAC_ADDRESS,
128 SME_GET_PRODUCT_VERSION,
129 SME_STOP_REQUEST,
130 SME_RTS_THRESHOLD_REQUEST,
131 SME_FRAGMENTATION_THRESHOLD_REQUEST,
132 SME_WEP_INDEX_REQUEST,
133 SME_WEP_KEY1_REQUEST,
134 SME_WEP_KEY2_REQUEST,
135 SME_WEP_KEY3_REQUEST,
136 SME_WEP_KEY4_REQUEST,
137 SME_WEP_FLAG_REQUEST,
138 SME_RSN_UCAST_REQUEST,
139 SME_RSN_MCAST_REQUEST,
140 SME_RSN_AUTH_REQUEST,
141 SME_RSN_ENABLED_REQUEST,
142 SME_RSN_MODE_REQUEST,
143 #ifdef WPS
144 SME_WPS_ENABLE_REQUEST,
145 SME_WPS_PROBE_REQUEST,
146 #endif
147 SME_SET_GAIN,
148 SME_GET_GAIN,
149 SME_SLEEP_REQUEST,
150 SME_SET_REGION,
151 SME_MODE_SET_REQUEST,
152 SME_START_REQUEST,
153 SME_GET_EEPROM_CKSUM,
154
155 SME_MIC_FAILURE_CONFIRM,
156 SME_START_CONFIRM,
157
158 SME_MULTICAST_CONFIRM,
159 SME_BSS_SCAN_CONFIRM,
160 SME_GET_CURRENT_AP,
161 SME_POW_MNGMT_CONFIRM,
162 SME_PHY_INFO_CONFIRM,
163 SME_STOP_CONFIRM,
164 SME_RTS_THRESHOLD_CONFIRM,
165 SME_FRAGMENTATION_THRESHOLD_CONFIRM,
166 SME_WEP_INDEX_CONFIRM,
167 SME_WEP_KEY1_CONFIRM,
168 SME_WEP_KEY2_CONFIRM,
169 SME_WEP_KEY3_CONFIRM,
170 SME_WEP_KEY4_CONFIRM,
171 SME_WEP_FLAG_CONFIRM,
172 SME_RSN_UCAST_CONFIRM,
173 SME_RSN_MCAST_CONFIRM,
174 SME_RSN_AUTH_CONFIRM,
175 SME_RSN_ENABLED_CONFIRM,
176 SME_RSN_MODE_CONFIRM,
177 SME_MODE_SET_CONFIRM,
178 SME_SLEEP_CONFIRM,
179
180 SME_RSN_SET_CONFIRM,
181 SME_WEP_SET_CONFIRM,
182 SME_TERMINATE,
183
184 SME_EVENT_SIZE /* end */
185 };
186
187 /* SME Status */
188 enum {
189 SME_IDLE,
190 SME_SETUP,
191 SME_DISCONNECT,
192 SME_CONNECT
193 };
194
195 #define SME_EVENT_BUFF_SIZE 128
196
197 struct sme_info {
198 int sme_status;
199 int event_buff[SME_EVENT_BUFF_SIZE];
200 unsigned int qhead;
201 unsigned int qtail;
202 #ifdef KS_WLAN_DEBUG
203 /* for debug */
204 unsigned int max_event_count;
205 #endif
206 spinlock_t sme_spin;
207 unsigned long sme_flag;
208 };
209
210 struct hostt_t {
211 int buff[SME_EVENT_BUFF_SIZE];
212 unsigned int qhead;
213 unsigned int qtail;
214 };
215
216 #define RSN_IE_BODY_MAX 64
217 struct rsn_ie_t {
218 u8 id; /* 0xdd = WPA or 0x30 = RSN */
219 u8 size; /* max ? 255 ? */
220 u8 body[RSN_IE_BODY_MAX];
221 } __packed;
222
223 #ifdef WPS
224 #define WPS_IE_BODY_MAX 255
225 struct wps_ie_t {
226 u8 id; /* 221 'dd <len> 00 50 F2 04' */
227 u8 size; /* max ? 255 ? */
228 u8 body[WPS_IE_BODY_MAX];
229 } __packed;
230 #endif /* WPS */
231
232 struct local_ap_t {
233 u8 bssid[6];
234 u8 rssi;
235 u8 sq;
236 struct {
237 u8 size;
238 u8 body[32];
239 u8 ssid_pad;
240 } ssid;
241 struct {
242 u8 size;
243 u8 body[16];
244 u8 rate_pad;
245 } rate_set;
246 u16 capability;
247 u8 channel;
248 u8 noise;
249 struct rsn_ie_t wpa_ie;
250 struct rsn_ie_t rsn_ie;
251 #ifdef WPS
252 struct wps_ie_t wps_ie;
253 #endif /* WPS */
254 };
255
256 #define LOCAL_APLIST_MAX 31
257 #define LOCAL_CURRENT_AP LOCAL_APLIST_MAX
258 struct local_aplist_t {
259 int size;
260 struct local_ap_t ap[LOCAL_APLIST_MAX + 1];
261 };
262
263 struct local_gain_t {
264 u8 TxMode;
265 u8 RxMode;
266 u8 TxGain;
267 u8 RxGain;
268 };
269
270 struct local_eeprom_sum_t {
271 u8 type;
272 u8 result;
273 };
274
275 enum {
276 EEPROM_OK,
277 EEPROM_CHECKSUM_NONE,
278 EEPROM_FW_NOT_SUPPORT,
279 EEPROM_NG,
280 };
281
282 /* Power Save Status */
283 enum {
284 PS_NONE,
285 PS_ACTIVE_SET,
286 PS_SAVE_SET,
287 PS_CONF_WAIT,
288 PS_SNOOZE,
289 PS_WAKEUP
290 };
291
292 struct power_save_status_t {
293 atomic_t status; /* initialvalue 0 */
294 struct completion wakeup_wait;
295 atomic_t confirm_wait;
296 atomic_t snooze_guard;
297 };
298
299 struct sleep_status_t {
300 atomic_t status; /* initialvalue 0 */
301 atomic_t doze_request;
302 atomic_t wakeup_request;
303 };
304
305 /* WPA */
306 struct scan_ext_t {
307 unsigned int flag;
308 char ssid[IW_ESSID_MAX_SIZE + 1];
309 };
310
311 enum {
312 CIPHER_NONE,
313 CIPHER_WEP40,
314 CIPHER_TKIP,
315 CIPHER_CCMP,
316 CIPHER_WEP104
317 };
318
319 #define CIPHER_ID_WPA_NONE "\x00\x50\xf2\x00"
320 #define CIPHER_ID_WPA_WEP40 "\x00\x50\xf2\x01"
321 #define CIPHER_ID_WPA_TKIP "\x00\x50\xf2\x02"
322 #define CIPHER_ID_WPA_CCMP "\x00\x50\xf2\x04"
323 #define CIPHER_ID_WPA_WEP104 "\x00\x50\xf2\x05"
324
325 #define CIPHER_ID_WPA2_NONE "\x00\x0f\xac\x00"
326 #define CIPHER_ID_WPA2_WEP40 "\x00\x0f\xac\x01"
327 #define CIPHER_ID_WPA2_TKIP "\x00\x0f\xac\x02"
328 #define CIPHER_ID_WPA2_CCMP "\x00\x0f\xac\x04"
329 #define CIPHER_ID_WPA2_WEP104 "\x00\x0f\xac\x05"
330
331 #define CIPHER_ID_LEN 4
332
333 enum {
334 KEY_MGMT_802_1X,
335 KEY_MGMT_PSK,
336 KEY_MGMT_WPANONE,
337 };
338
339 #define KEY_MGMT_ID_WPA_NONE "\x00\x50\xf2\x00"
340 #define KEY_MGMT_ID_WPA_1X "\x00\x50\xf2\x01"
341 #define KEY_MGMT_ID_WPA_PSK "\x00\x50\xf2\x02"
342 #define KEY_MGMT_ID_WPA_WPANONE "\x00\x50\xf2\xff"
343
344 #define KEY_MGMT_ID_WPA2_NONE "\x00\x0f\xac\x00"
345 #define KEY_MGMT_ID_WPA2_1X "\x00\x0f\xac\x01"
346 #define KEY_MGMT_ID_WPA2_PSK "\x00\x0f\xac\x02"
347 #define KEY_MGMT_ID_WPA2_WPANONE "\x00\x0f\xac\xff"
348
349 #define KEY_MGMT_ID_LEN 4
350
351 #define MIC_KEY_SIZE 8
352
353 struct wpa_key_t {
354 u32 ext_flags; /* IW_ENCODE_EXT_xxx */
355 u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
356 u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
357 struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
358 * (group) keys or unicast address for
359 * individual keys */
360 u16 alg;
361 u16 key_len; /* WEP: 5 or 13, TKIP: 32, CCMP: 16 */
362 u8 key_val[IW_ENCODING_TOKEN_MAX];
363 u8 tx_mic_key[MIC_KEY_SIZE];
364 u8 rx_mic_key[MIC_KEY_SIZE];
365 };
366 #define WPA_KEY_INDEX_MAX 4
367 #define WPA_RX_SEQ_LEN 6
368
369 struct mic_failure_t {
370 u16 failure; /* MIC Failure counter 0 or 1 or 2 */
371 u16 counter; /* 1sec counter 0-60 */
372 u32 last_failure_time;
373 int stop; /* stop flag */
374 };
375
376 struct wpa_status_t {
377 int wpa_enabled;
378 unsigned int rsn_enabled;
379 int version;
380 int pairwise_suite; /* unicast cipher */
381 int group_suite; /* multicast cipher */
382 int key_mgmt_suite; /* authentication key management suite */
383 int auth_alg;
384 int txkey;
385 struct wpa_key_t key[WPA_KEY_INDEX_MAX];
386 struct scan_ext_t scan_ext;
387 struct mic_failure_t mic_failure;
388 };
389
390 #include <linux/list.h>
391 #define PMK_LIST_MAX 8
392 struct pmk_list_t {
393 u16 size;
394 struct list_head head;
395 struct pmk_t {
396 struct list_head list;
397 u8 bssid[ETH_ALEN];
398 u8 pmkid[IW_PMKID_LEN];
399 } pmk[PMK_LIST_MAX];
400 };
401
402 #ifdef WPS
403 struct wps_status_t {
404 int wps_enabled;
405 int ielen;
406 u8 ie[255];
407 };
408 #endif /* WPS */
409
410 struct ks_wlan_private {
411
412 struct hw_info_t ks_wlan_hw; /* hardware information */
413
414 struct net_device *net_dev;
415 int reg_net; /* register_netdev */
416 struct net_device_stats nstats;
417 struct iw_statistics wstats;
418
419 struct completion confirm_wait;
420
421 /* trx device & sme */
422 struct tx_device tx_dev;
423 struct rx_device rx_dev;
424 struct sme_info sme_i;
425 u8 *rxp;
426 unsigned int rx_size;
427 struct tasklet_struct sme_task;
428 struct work_struct ks_wlan_wakeup_task;
429 int scan_ind_count;
430
431 unsigned char eth_addr[ETH_ALEN];
432
433 struct local_aplist_t aplist;
434 struct local_ap_t current_ap;
435 struct power_save_status_t psstatus;
436 struct sleep_status_t sleepstatus;
437 struct wpa_status_t wpa;
438 struct pmk_list_t pmklist;
439 /* wireless parameter */
440 struct ks_wlan_parameter reg;
441 u8 current_rate;
442
443 char nick[IW_ESSID_MAX_SIZE + 1];
444
445 spinlock_t multicast_spin;
446
447 spinlock_t dev_read_lock;
448 wait_queue_head_t devread_wait;
449
450 unsigned int need_commit; /* for ioctl */
451
452 /* DeviceIoControl */
453 int device_open_status;
454 atomic_t event_count;
455 atomic_t rec_count;
456 int dev_count;
457 #define DEVICE_STOCK_COUNT 20
458 unsigned char *dev_data[DEVICE_STOCK_COUNT];
459 int dev_size[DEVICE_STOCK_COUNT];
460
461 /* ioctl : IOCTL_FIRMWARE_VERSION */
462 unsigned char firmware_version[128 + 1];
463 int version_size;
464
465 int mac_address_valid; /* Mac Address Status */
466
467 int dev_state;
468
469 struct sk_buff *skb;
470 unsigned int cur_rx; /* Index into the Rx buffer of next Rx pkt. */
471 /* spinlock_t lock; */
472 #define FORCE_DISCONNECT 0x80000000
473 #define CONNECT_STATUS_MASK 0x7FFFFFFF
474 u32 connect_status; /* connect status */
475 int infra_status; /* Infractructure status */
476
477 u8 data_buff[0x1000];
478
479 u8 scan_ssid_len;
480 u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
481 struct local_gain_t gain;
482 #ifdef WPS
483 struct net_device *l2_dev;
484 int l2_fd;
485 struct wps_status_t wps;
486 #endif /* WPS */
487 u8 sleep_mode;
488
489 u8 region;
490 struct local_eeprom_sum_t eeprom_sum;
491 u8 eeprom_checksum;
492
493 struct hostt_t hostt;
494
495 unsigned long last_doze;
496 unsigned long last_wakeup;
497
498 uint wakeup_count; /* for detect wakeup loop */
499 };
500
501 int ks_wlan_net_start(struct net_device *dev);
502 int ks_wlan_net_stop(struct net_device *dev);
503
504 #endif /* _KS_WLAN_H */