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

Archive Download this file



interactive