Root/package/ks7010/src/ks_wlan.h

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

Archive Download this file



interactive