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