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