2 * Driver for KeyStream wireless LAN
4 * Copyright (c) 2005-2008 KeyStream Corp.
5 * Copyright (C) 2009 Renesas Technology Corp.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
15 #include <linux/compiler.h>
20 #define HIF_DATA_REQ 0xE001
21 #define HIF_DATA_IND 0xE801
22 #define HIF_MIB_GET_REQ 0xE002
23 #define HIF_MIB_GET_CONF 0xE802
24 #define HIF_MIB_SET_REQ 0xE003
25 #define HIF_MIB_SET_CONF 0xE803
26 #define HIF_POWERMGT_REQ 0xE004
27 #define HIF_POWERMGT_CONF 0xE804
28 #define HIF_START_REQ 0xE005
29 #define HIF_START_CONF 0xE805
30 #define HIF_CONNECT_IND 0xE806
31 #define HIF_STOP_REQ 0xE006
32 #define HIF_STOP_CONF 0xE807
33 #define HIF_PS_ADH_SET_REQ 0xE007
34 #define HIF_PS_ADH_SET_CONF 0xE808
35 #define HIF_INFRA_SET_REQ 0xE008
36 #define HIF_INFRA_SET_CONF 0xE809
37 #define HIF_ADH_SET_REQ 0xE009
38 #define HIF_ADH_SET_CONF 0xE80A
39 #define HIF_AP_SET_REQ 0xE00A
40 #define HIF_AP_SET_CONF 0xE80B
41 #define HIF_ASSOC_INFO_IND 0xE80C
42 #define HIF_MIC_FAILURE_REQ 0xE00B
43 #define HIF_MIC_FAILURE_CONF 0xE80D
44 #define HIF_SCAN_REQ 0xE00C
45 #define HIF_SCAN_CONF 0xE80E
46 #define HIF_PHY_INFO_REQ 0xE00D
47 #define HIF_PHY_INFO_CONF 0xE80F
48 #define HIF_SLEEP_REQ 0xE00E
49 #define HIF_SLEEP_CONF 0xE810
50 #define HIF_PHY_INFO_IND 0xE811
51 #define HIF_SCAN_IND 0xE812
52 #define HIF_INFRA_SET2_REQ 0xE00F
53 #define HIF_INFRA_SET2_CONF 0xE813
54 #define HIF_ADH_SET2_REQ 0xE010
55 #define HIF_ADH_SET2_CONF 0xE814
57 #define HIF_REQ_MAX 0xE010
60 * HOST-MAC I/F data structure
61 * Byte alignmet Little Endian
69 struct hostif_data_request_t {
70 struct hostif_hdr header;
72 #define TYPE_DATA 0x0000
73 #define TYPE_AUTH 0x0001
78 struct hostif_data_indication_t {
79 struct hostif_hdr header;
81 /* #define TYPE_DATA 0x0000 */
82 #define TYPE_PMK1 0x0001
83 #define TYPE_GMK1 0x0002
84 #define TYPE_GMK2 0x0003
89 #define CHANNEL_LIST_MAX_SIZE 14
90 struct channel_list_t {
92 uint8_t body[CHANNEL_LIST_MAX_SIZE];
97 #define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */
98 #define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R) */
99 #define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */
100 #define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */
101 #define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */
102 #define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */
103 #define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */
104 #define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */
105 #define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */
106 #define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */
107 #define DOT11_WEP_LIST 0x13020100 /* WEP LIST */
108 #define DOT11_DESIRED_SSID 0x11090100 /* SSID */
109 #define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */
110 #define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */
112 #define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */
113 #define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Adress change (W) */
114 #define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Adress (W) */
115 #define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Adress Filter enable/disable (W) */
116 #define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */
117 #define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */
118 #define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */
119 #define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */
121 #define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */
122 #define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */
123 #define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */
124 #define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */
125 #define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */
126 #define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */
127 #define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */
128 #define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */
129 #define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */
130 #define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */
131 #define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */
132 #define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */
134 #define LOCAL_REGION 0xF10A0100 /* Region setting */
137 #define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */
138 #define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */
141 #define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */
142 #define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */
144 struct hostif_mib_get_request_t {
145 struct hostif_hdr header;
146 uint32_t mib_attribute;
149 struct hostif_mib_value_t {
152 #define MIB_VALUE_TYPE_NULL 0
153 #define MIB_VALUE_TYPE_INT 1
154 #define MIB_VALUE_TYPE_BOOL 2
155 #define MIB_VALUE_TYPE_COUNT32 3
156 #define MIB_VALUE_TYPE_OSTRING 4
160 struct hostif_mib_get_confirm_t {
161 struct hostif_hdr header;
163 #define MIB_SUCCESS 0
164 #define MIB_INVALID 1
165 #define MIB_READ_ONLY 2
166 #define MIB_WRITE_ONLY 3
167 uint32_t mib_attribute;
168 struct hostif_mib_value_t mib_value;
171 struct hostif_mib_set_request_t {
172 struct hostif_hdr header;
173 uint32_t mib_attribute;
174 struct hostif_mib_value_t mib_value;
177 struct hostif_mib_set_confirm_t {
178 struct hostif_hdr header;
180 uint32_t mib_attribute;
183 struct hostif_power_mngmt_request_t {
184 struct hostif_hdr header;
186 #define POWER_ACTIVE 1
189 #define SLEEP_FALSE 0
190 #define SLEEP_TRUE 1 /* not used */
191 uint32_t receiveDTIMs;
196 /* power management mode */
198 POWMGT_ACTIVE_MODE = 0,
203 #define RESULT_SUCCESS 0
204 #define RESULT_INVALID_PARAMETERS 1
205 #define RESULT_NOT_SUPPORTED 2
206 /* #define RESULT_ALREADY_RUNNING 3 */
207 #define RESULT_ALREADY_RUNNING 7
209 struct hostif_power_mngmt_confirm_t {
210 struct hostif_hdr header;
211 uint16_t result_code;
214 struct hostif_start_request_t {
215 struct hostif_hdr header;
217 #define MODE_PSEUDO_ADHOC 0
218 #define MODE_INFRASTRUCTURE 1
219 #define MODE_AP 2 /* not used */
223 struct hostif_start_confirm_t {
224 struct hostif_hdr header;
225 uint16_t result_code;
228 #define SSID_MAX_SIZE 32
231 uint8_t body[SSID_MAX_SIZE];
235 #define RATE_SET_MAX_SIZE 16
256 uint16_t maxDuration;
257 uint16_t durRemaining;
266 #define RSN_BODY_SIZE 64
267 uint8_t body[RSN_BODY_SIZE];
274 struct rate_set16_t {
281 uint8_t bssid[6]; /* +00 */
282 uint8_t rssi; /* +06 */
283 uint8_t sq; /* +07 */
284 uint8_t noise; /* +08 */
285 uint8_t pad0; /* +09 */
286 uint16_t beacon_period; /* +10 */
287 uint16_t capability; /* +12 */
288 #define BSS_CAP_ESS (1<<0)
289 #define BSS_CAP_IBSS (1<<1)
290 #define BSS_CAP_CF_POLABLE (1<<2)
291 #define BSS_CAP_CF_POLL_REQ (1<<3)
292 #define BSS_CAP_PRIVACY (1<<4)
293 #define BSS_CAP_SHORT_PREAMBLE (1<<5)
294 #define BSS_CAP_PBCC (1<<6)
295 #define BSS_CAP_CHANNEL_AGILITY (1<<7)
296 #define BSS_CAP_SHORT_SLOT_TIME (1<<10)
297 #define BSS_CAP_DSSS_OFDM (1<<13)
298 uint8_t frame_type; /* +14 */
299 uint8_t ch_info; /* +15 */
300 #define FRAME_TYPE_BEACON 0x80
301 #define FRAME_TYPE_PROBE_RESP 0x50
302 uint16_t body_size; /* +16 */
303 uint8_t body[1024]; /* +18 */
307 struct link_ap_info_t {
308 uint8_t bssid[6]; /* +00 */
309 uint8_t rssi; /* +06 */
310 uint8_t sq; /* +07 */
311 uint8_t noise; /* +08 */
312 uint8_t pad0; /* +09 */
313 uint16_t beacon_period; /* +10 */
314 uint16_t capability; /* +12 */
315 struct rate_set8_t rate_set; /* +14 */
316 struct FhParms_t fh_parameter; /* +24 */
317 struct DsParms_t ds_parameter; /* +29 */
318 struct CfParms_t cf_parameter; /* +30 */
319 struct IbssParms_t ibss_parameter; /* +36 */
320 struct ErpParams_t erp_parameter; /* +38 */
321 uint8_t pad1; /* +39 */
322 struct rate_set8_t ext_rate_set; /* +40 */
323 uint8_t DTIM_period; /* +50 */
324 uint8_t rsn_mode; /* +51 */
325 #define RSN_MODE_NONE 0
326 #define RSN_MODE_WPA 1
327 #define RSN_MODE_WPA2 2
329 uint8_t size; /* +52 */
330 uint8_t body[128]; /* +53 */
334 struct hostif_connect_indication_t {
335 struct hostif_hdr header;
336 uint16_t connect_code;
337 #define RESULT_CONNECT 0
338 #define RESULT_DISCONNECT 1
339 struct link_ap_info_t link_ap_info;
342 struct hostif_stop_request_t {
343 struct hostif_hdr header;
346 struct hostif_stop_confirm_t {
347 struct hostif_hdr header;
348 uint16_t result_code;
351 struct hostif_ps_adhoc_set_request_t {
352 struct hostif_hdr header;
354 #define D_11B_ONLY_MODE 0
355 #define D_11G_ONLY_MODE 1
356 #define D_11BG_COMPATIBLE_MODE 2
357 #define D_11A_ONLY_MODE 3
359 #define CTS_MODE_FALSE 0
360 #define CTS_MODE_TRUE 1
362 struct rate_set16_t rate_set;
363 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
364 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
368 struct hostif_ps_adhoc_set_confirm_t {
369 struct hostif_hdr header;
370 uint16_t result_code;
373 struct hostif_infrastructure_set_request_t {
374 struct hostif_hdr header;
377 struct rate_set16_t rate_set;
379 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
380 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
381 uint16_t beacon_lost_count;
383 #define AUTH_TYPE_OPEN_SYSTEM 0
384 #define AUTH_TYPE_SHARED_KEY 1
385 struct channel_list_t channel_list;
389 struct hostif_infrastructure_set2_request_t {
390 struct hostif_hdr header;
393 struct rate_set16_t rate_set;
395 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
396 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
397 uint16_t beacon_lost_count;
399 #define AUTH_TYPE_OPEN_SYSTEM 0
400 #define AUTH_TYPE_SHARED_KEY 1
401 struct channel_list_t channel_list;
403 uint8_t bssid[ETH_ALEN];
406 struct hostif_infrastructure_set_confirm_t {
407 struct hostif_hdr header;
408 uint16_t result_code;
411 struct hostif_adhoc_set_request_t {
412 struct hostif_hdr header;
416 struct rate_set16_t rate_set;
418 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
419 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
423 struct hostif_adhoc_set2_request_t {
424 struct hostif_hdr header;
428 struct rate_set16_t rate_set;
430 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
431 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
433 struct channel_list_t channel_list;
434 uint8_t bssid[ETH_ALEN];
437 struct hostif_adhoc_set_confirm_t {
438 struct hostif_hdr header;
439 uint16_t result_code;
442 struct last_associate_t {
447 struct association_request_t {
449 #define FRAME_TYPE_ASSOC_REQ 0x00
450 #define FRAME_TYPE_REASSOC_REQ 0x20
453 uint16_t listen_interval;
454 uint8_t ap_address[6];
455 uint16_t reqIEs_size;
458 struct association_response_t {
460 #define FRAME_TYPE_ASSOC_RESP 0x10
461 #define FRAME_TYPE_REASSOC_RESP 0x30
465 uint16_t association_id;
466 uint16_t respIEs_size;
469 struct hostif_associate_indication_t {
470 struct hostif_hdr header;
471 struct association_request_t assoc_req;
472 struct association_response_t assoc_resp;
473 /* followed by (reqIEs_size + respIEs_size) octets of data */
474 /* reqIEs data *//* respIEs data */
477 struct hostif_bss_scan_request_t {
478 struct hostif_hdr header;
480 #define ACTIVE_SCAN 0
481 #define PASSIVE_SCAN 1
483 uint32_t ch_time_min;
484 uint32_t ch_time_max;
485 struct channel_list_t channel_list;
489 struct hostif_bss_scan_confirm_t {
490 struct hostif_hdr header;
491 uint16_t result_code;
495 struct hostif_phy_information_request_t {
496 struct hostif_hdr header;
498 #define NORMAL_TYPE 0
500 uint16_t time; /* unit 100ms */
503 struct hostif_phy_information_confirm_t {
504 struct hostif_hdr header;
518 struct hostif_sleep_request_t {
519 struct hostif_hdr header;
522 struct hostif_sleep_confirm_t {
523 struct hostif_hdr header;
524 uint16_t result_code;
527 struct hostif_mic_failure_request_t {
528 struct hostif_hdr header;
529 uint16_t failure_count;
533 struct hostif_mic_failure_confirm_t {
534 struct hostif_hdr header;
535 uint16_t result_code;
538 #define BASIC_RATE 0x80
539 #define RATE_MASK 0x7F
541 #define TX_RATE_AUTO 0xff
542 #define TX_RATE_1M_FIXED 0
543 #define TX_RATE_2M_FIXED 1
544 #define TX_RATE_1_2M_AUTO 2
545 #define TX_RATE_5M_FIXED 3
546 #define TX_RATE_11M_FIXED 4
548 #define TX_RATE_FULL_AUTO 0
549 #define TX_RATE_11_AUTO 1
550 #define TX_RATE_11B_AUTO 2
551 #define TX_RATE_11BG_AUTO 3
552 #define TX_RATE_MANUAL_AUTO 4
553 #define TX_RATE_FIXED 5
556 #define TX_RATE_1M (uint8_t)(10 / 5) /* 11b 11g basic rate */
557 #define TX_RATE_2M (uint8_t)(20 / 5) /* 11b 11g basic rate */
558 #define TX_RATE_5M (uint8_t)(55 / 5) /* 11g basic rate */
559 #define TX_RATE_11M (uint8_t)(110 / 5) /* 11g basic rate */
562 #define TX_RATE_6M (uint8_t)(60 / 5) /* 11g basic rate */
563 #define TX_RATE_12M (uint8_t)(120 / 5) /* 11g basic rate */
564 #define TX_RATE_24M (uint8_t)(240 / 5) /* 11g basic rate */
565 #define TX_RATE_9M (uint8_t)(90 / 5)
566 #define TX_RATE_18M (uint8_t)(180 / 5)
567 #define TX_RATE_36M (uint8_t)(360 / 5)
568 #define TX_RATE_48M (uint8_t)(480 / 5)
569 #define TX_RATE_54M (uint8_t)(540 / 5)
571 #define IS_11B_RATE(A) (((A & RATE_MASK) == TX_RATE_1M ) || ((A & RATE_MASK) == TX_RATE_2M) || \
572 ((A & RATE_MASK) == TX_RATE_5M) || ((A & RATE_MASK) == TX_RATE_11M))
574 #define IS_OFDM_RATE(A) (((A & RATE_MASK) == TX_RATE_6M) || ((A & RATE_MASK) == TX_RATE_12M) || \
575 ((A & RATE_MASK) == TX_RATE_24M) || ((A & RATE_MASK) == TX_RATE_9M) || \
576 ((A & RATE_MASK) == TX_RATE_18M) || ((A & RATE_MASK) == TX_RATE_36M) || \
577 ((A & RATE_MASK) == TX_RATE_48M) || ((A & RATE_MASK) == TX_RATE_54M))
579 #define IS_11BG_RATE(A) (IS_11B_RATE(A) || IS_OFDM_RATE(A))
581 #define IS_OFDM_EXT_RATE(A) (((A & RATE_MASK) == TX_RATE_9M) || ((A & RATE_MASK) == TX_RATE_18M) || \
582 ((A & RATE_MASK) == TX_RATE_36M) || ((A & RATE_MASK) == TX_RATE_48M) || \
583 ((A & RATE_MASK) == TX_RATE_54M))
596 /* multicast filter */
597 #define MCAST_FILTER_MCAST 0
598 #define MCAST_FILTER_MCASTALL 1
599 #define MCAST_FILTER_PROMISC 2
601 #define NIC_MAX_MCAST_LIST 32
604 #define HIF_EVENT_MASK 0xE800
605 #define IS_HIF_IND(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800 && \
606 ((_EVENT & ~HIF_EVENT_MASK) == 0x0001 || \
607 (_EVENT & ~HIF_EVENT_MASK) == 0x0006 || \
608 (_EVENT & ~HIF_EVENT_MASK) == 0x000C || \
609 (_EVENT & ~HIF_EVENT_MASK) == 0x0011 || \
610 (_EVENT & ~HIF_EVENT_MASK) == 0x0012))
612 #define IS_HIF_CONF(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800 && \
613 (_EVENT & ~HIF_EVENT_MASK) > 0x0000 && \
614 (_EVENT & ~HIF_EVENT_MASK) < 0x0012 && \
615 !IS_HIF_IND(_EVENT) )
621 /* function prototype */
622 int hostif_data_request(struct ks_wlan_private *priv,
623 struct sk_buff *packet);
624 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
626 void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event);
627 int hostif_init(struct ks_wlan_private *priv);
628 void hostif_exit(struct ks_wlan_private *priv);
629 int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p,
631 void (*complete_handler) (void *arg1, void *arg2),
632 void *arg1, void *arg2);
633 void send_packet_complete(void *, void *);
635 void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv);
636 int ks_wlan_hw_power_save(struct ks_wlan_private *priv);
639 inline int hif_align_size(int size)
645 #ifdef DEVICE_ALIGNMENT
646 return (size % DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT -
647 (size % DEVICE_ALIGNMENT) : size;
653 #endif /* __KERNEL__ */
655 #endif /* _KS_HOSTIF_H_ */