]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/ks7010/ks_wlan.h
Merge tag 'drm-misc-fixes-2016-12-22' of git://anongit.freedesktop.org/git/drm-misc...
[mirror_ubuntu-artful-kernel.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
d6e25e70
WS
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 36
564efd79
WS
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
13a9930d 44struct ks_wlan_parameter {
81710951
PV
45 u8 operation_mode; /* Operation Mode */
46 u8 channel; /* Channel */
47 u8 tx_rate; /* Transmit Rate */
13a9930d 48 struct {
81710951
PV
49 u8 size;
50 u8 body[16];
13a9930d 51 } rate_set;
81710951 52 u8 bssid[ETH_ALEN]; /* BSSID */
13a9930d 53 struct {
81710951
PV
54 u8 size;
55 u8 body[32 + 1];
d6e25e70 56 } ssid; /* SSID */
81710951
PV
57 u8 preamble; /* Preamble */
58 u8 powermgt; /* PowerManagementMode */
59 u32 scan_type; /* AP List Scan Type */
13a9930d
WS
60#define BEACON_LOST_COUNT_MIN 0
61#define BEACON_LOST_COUNT_MAX 65535
81710951
PV
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;
13a9930d 67 struct {
81710951
PV
68 u8 size;
69 u8 val[13 * 2 + 1];
13a9930d 70 } wep_key[4];
81710951
PV
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 */
13a9930d
WS
75};
76
77enum {
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 */
107enum {
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
13a9930d
WS
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
d6e25e70 184 SME_EVENT_SIZE /* end */
13a9930d
WS
185};
186
187/* SME Status */
188enum {
189 SME_IDLE,
190 SME_SETUP,
191 SME_DISCONNECT,
192 SME_CONNECT
193};
194
195#define SME_EVENT_BUFF_SIZE 128
196
d6e25e70
WS
197struct sme_info {
198 int sme_status;
199 int event_buff[SME_EVENT_BUFF_SIZE];
200 unsigned int qhead;
201 unsigned int qtail;
13a9930d 202#ifdef KS_WLAN_DEBUG
d6e25e70 203 /* for debug */
13a9930d
WS
204 unsigned int max_event_count;
205#endif
d6e25e70 206 spinlock_t sme_spin;
13a9930d
WS
207 unsigned long sme_flag;
208};
209
d6e25e70
WS
210struct hostt_t {
211 int buff[SME_EVENT_BUFF_SIZE];
212 unsigned int qhead;
213 unsigned int qtail;
13a9930d
WS
214};
215
216#define RSN_IE_BODY_MAX 64
217struct rsn_ie_t {
81710951
PV
218 u8 id; /* 0xdd = WPA or 0x30 = RSN */
219 u8 size; /* max ? 255 ? */
220 u8 body[RSN_IE_BODY_MAX];
2460563f 221} __packed;
13a9930d
WS
222
223#ifdef WPS
224#define WPS_IE_BODY_MAX 255
225struct wps_ie_t {
81710951
PV
226 u8 id; /* 221 'dd <len> 00 50 F2 04' */
227 u8 size; /* max ? 255 ? */
228 u8 body[WPS_IE_BODY_MAX];
2460563f 229} __packed;
13a9930d
WS
230#endif /* WPS */
231
232struct local_ap_t {
81710951
PV
233 u8 bssid[6];
234 u8 rssi;
235 u8 sq;
13a9930d 236 struct {
81710951
PV
237 u8 size;
238 u8 body[32];
239 u8 ssid_pad;
13a9930d
WS
240 } ssid;
241 struct {
81710951
PV
242 u8 size;
243 u8 body[16];
244 u8 rate_pad;
13a9930d 245 } rate_set;
81710951
PV
246 u16 capability;
247 u8 channel;
248 u8 noise;
13a9930d
WS
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
258struct local_aplist_t {
259 int size;
d6e25e70 260 struct local_ap_t ap[LOCAL_APLIST_MAX + 1];
13a9930d
WS
261};
262
d6e25e70 263struct local_gain_t {
81710951
PV
264 u8 TxMode;
265 u8 RxMode;
266 u8 TxGain;
267 u8 RxGain;
13a9930d
WS
268};
269
d6e25e70 270struct local_eeprom_sum_t {
81710951
PV
271 u8 type;
272 u8 result;
13a9930d
WS
273};
274
275enum {
276 EEPROM_OK,
277 EEPROM_CHECKSUM_NONE,
278 EEPROM_FW_NOT_SUPPORT,
279 EEPROM_NG,
280};
281
13a9930d
WS
282/* Power Save Status */
283enum {
284 PS_NONE,
285 PS_ACTIVE_SET,
286 PS_SAVE_SET,
287 PS_CONF_WAIT,
288 PS_SNOOZE,
289 PS_WAKEUP
290};
291
292struct power_save_status_t {
d6e25e70 293 atomic_t status; /* initialvalue 0 */
13a9930d 294 struct completion wakeup_wait;
d6e25e70
WS
295 atomic_t confirm_wait;
296 atomic_t snooze_guard;
13a9930d
WS
297};
298
299struct sleep_status_t {
d6e25e70
WS
300 atomic_t status; /* initialvalue 0 */
301 atomic_t doze_request;
302 atomic_t wakeup_request;
13a9930d
WS
303};
304
305/* WPA */
306struct scan_ext_t {
307 unsigned int flag;
d6e25e70 308 char ssid[IW_ESSID_MAX_SIZE + 1];
13a9930d
WS
309};
310
311enum {
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
d6e25e70 333enum {
13a9930d
WS
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
353struct wpa_key_t {
81710951
PV
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 */
d6e25e70
WS
357 struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
358 * (group) keys or unicast address for
359 * individual keys */
81710951
PV
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];
13a9930d
WS
365};
366#define WPA_KEY_INDEX_MAX 4
367#define WPA_RX_SEQ_LEN 6
368
369struct mic_failure_t {
81710951
PV
370 u16 failure; /* MIC Failure counter 0 or 1 or 2 */
371 u16 counter; /* 1sec counter 0-60 */
372 u32 last_failure_time;
d6e25e70 373 int stop; /* stop flag */
13a9930d
WS
374};
375
376struct 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
392struct pmk_list_t {
81710951 393 u16 size;
13a9930d
WS
394 struct list_head head;
395 struct pmk_t {
396 struct list_head list;
81710951
PV
397 u8 bssid[ETH_ALEN];
398 u8 pmkid[IW_PMKID_LEN];
13a9930d
WS
399 } pmk[PMK_LIST_MAX];
400};
401
402#ifdef WPS
403struct wps_status_t {
d6e25e70
WS
404 int wps_enabled;
405 int ielen;
81710951 406 u8 ie[255];
13a9930d
WS
407};
408#endif /* WPS */
409
feedcf1a 410struct ks_wlan_private {
13a9930d 411
d6e25e70 412 struct hw_info_t ks_wlan_hw; /* hardware information */
13a9930d
WS
413
414 struct net_device *net_dev;
d6e25e70 415 int reg_net; /* register_netdev */
13a9930d
WS
416 struct net_device_stats nstats;
417 struct iw_statistics wstats;
418
419 struct completion confirm_wait;
420
d6e25e70 421 /* trx device & sme */
13a9930d
WS
422 struct tx_device tx_dev;
423 struct rx_device rx_dev;
d6e25e70 424 struct sme_info sme_i;
13a9930d 425 u8 *rxp;
d6e25e70 426 unsigned int rx_size;
13a9930d
WS
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;
d6e25e70 439 /* wireless parameter */
13a9930d 440 struct ks_wlan_parameter reg;
81710951 441 u8 current_rate;
13a9930d 442
d6e25e70
WS
443 char nick[IW_ESSID_MAX_SIZE + 1];
444
445 spinlock_t multicast_spin;
13a9930d
WS
446
447 spinlock_t dev_read_lock;
d6e25e70 448 wait_queue_head_t devread_wait;
13a9930d 449
d6e25e70 450 unsigned int need_commit; /* for ioctl */
13a9930d 451
d6e25e70 452 /* DeviceIoControl */
13a9930d
WS
453 int device_open_status;
454 atomic_t event_count;
d6e25e70
WS
455 atomic_t rec_count;
456 int dev_count;
13a9930d
WS
457#define DEVICE_STOCK_COUNT 20
458 unsigned char *dev_data[DEVICE_STOCK_COUNT];
459 int dev_size[DEVICE_STOCK_COUNT];
460
d6e25e70
WS
461 /* ioctl : IOCTL_FIRMWARE_VERSION */
462 unsigned char firmware_version[128 + 1];
13a9930d
WS
463 int version_size;
464
d6e25e70 465 int mac_address_valid; /* Mac Address Status */
13a9930d
WS
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
81710951 474 u32 connect_status; /* connect status */
d6e25e70 475 int infra_status; /* Infractructure status */
13a9930d 476
81710951 477 u8 data_buff[0x1000];
13a9930d 478
81710951
PV
479 u8 scan_ssid_len;
480 u8 scan_ssid[IW_ESSID_MAX_SIZE + 1];
13a9930d
WS
481 struct local_gain_t gain;
482#ifdef WPS
483 struct net_device *l2_dev;
d6e25e70 484 int l2_fd;
13a9930d
WS
485 struct wps_status_t wps;
486#endif /* WPS */
81710951 487 u8 sleep_mode;
13a9930d 488
81710951 489 u8 region;
13a9930d 490 struct local_eeprom_sum_t eeprom_sum;
81710951 491 u8 eeprom_checksum;
13a9930d 492
d6e25e70 493 struct hostt_t hostt;
13a9930d
WS
494
495 unsigned long last_doze;
496 unsigned long last_wakeup;
497
d6e25e70 498 uint wakeup_count; /* for detect wakeup loop */
d6e25e70 499};
13a9930d 500
2751bc91
BG
501int ks_wlan_net_start(struct net_device *dev);
502int ks_wlan_net_stop(struct net_device *dev);
30776cf9 503
13a9930d 504#endif /* _KS_WLAN_H */