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>
16 #include <linux/ieee80211.h>
21 #define HIF_DATA_REQ 0xE001
22 #define HIF_DATA_IND 0xE801
23 #define HIF_MIB_GET_REQ 0xE002
24 #define HIF_MIB_GET_CONF 0xE802
25 #define HIF_MIB_SET_REQ 0xE003
26 #define HIF_MIB_SET_CONF 0xE803
27 #define HIF_POWER_MGMT_REQ 0xE004
28 #define HIF_POWER_MGMT_CONF 0xE804
29 #define HIF_START_REQ 0xE005
30 #define HIF_START_CONF 0xE805
31 #define HIF_CONNECT_IND 0xE806
32 #define HIF_STOP_REQ 0xE006
33 #define HIF_STOP_CONF 0xE807
34 #define HIF_PS_ADH_SET_REQ 0xE007
35 #define HIF_PS_ADH_SET_CONF 0xE808
36 #define HIF_INFRA_SET_REQ 0xE008
37 #define HIF_INFRA_SET_CONF 0xE809
38 #define HIF_ADH_SET_REQ 0xE009
39 #define HIF_ADH_SET_CONF 0xE80A
40 #define HIF_AP_SET_REQ 0xE00A
41 #define HIF_AP_SET_CONF 0xE80B
42 #define HIF_ASSOC_INFO_IND 0xE80C
43 #define HIF_MIC_FAILURE_REQ 0xE00B
44 #define HIF_MIC_FAILURE_CONF 0xE80D
45 #define HIF_SCAN_REQ 0xE00C
46 #define HIF_SCAN_CONF 0xE80E
47 #define HIF_PHY_INFO_REQ 0xE00D
48 #define HIF_PHY_INFO_CONF 0xE80F
49 #define HIF_SLEEP_REQ 0xE00E
50 #define HIF_SLEEP_CONF 0xE810
51 #define HIF_PHY_INFO_IND 0xE811
52 #define HIF_SCAN_IND 0xE812
53 #define HIF_INFRA_SET2_REQ 0xE00F
54 #define HIF_INFRA_SET2_CONF 0xE813
55 #define HIF_ADH_SET2_REQ 0xE010
56 #define HIF_ADH_SET2_CONF 0xE814
58 #define HIF_REQ_MAX 0xE010
61 * HOST-MAC I/F data structure
62 * Byte alignmet Little Endian
70 struct hostif_data_request_t {
71 struct hostif_hdr header;
73 #define TYPE_DATA 0x0000
74 #define TYPE_AUTH 0x0001
79 struct hostif_data_indication_t {
80 struct hostif_hdr header;
82 /* #define TYPE_DATA 0x0000 */
83 #define TYPE_PMK1 0x0001
84 #define TYPE_GMK1 0x0002
85 #define TYPE_GMK2 0x0003
90 #define CHANNEL_LIST_MAX_SIZE 14
91 struct channel_list_t {
93 u8 body[CHANNEL_LIST_MAX_SIZE];
98 #define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */
99 #define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R) */
100 #define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */
101 #define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */
102 #define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */
103 #define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */
104 #define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */
105 #define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */
106 #define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */
107 #define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */
108 #define DOT11_WEP_LIST 0x13020100 /* WEP LIST */
109 #define DOT11_DESIRED_SSID 0x11090100 /* SSID */
110 #define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */
111 #define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */
113 #define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */
114 #define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Address change (W) */
115 #define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Address (W) */
116 #define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Address Filter enable/disable (W) */
117 #define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */
118 #define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */
119 #define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */
120 #define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */
122 #define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */
123 #define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */
124 #define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */
125 #define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */
126 #define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */
127 #define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */
128 #define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */
129 #define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */
130 #define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */
131 #define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */
132 #define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */
133 #define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */
135 #define LOCAL_REGION 0xF10A0100 /* Region setting */
138 #define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */
139 #define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */
142 #define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */
143 #define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */
145 struct hostif_mib_get_request_t {
146 struct hostif_hdr header;
147 __le32 mib_attribute;
150 struct hostif_mib_value_t {
153 #define MIB_VALUE_TYPE_NULL 0
154 #define MIB_VALUE_TYPE_INT 1
155 #define MIB_VALUE_TYPE_BOOL 2
156 #define MIB_VALUE_TYPE_COUNT32 3
157 #define MIB_VALUE_TYPE_OSTRING 4
161 struct hostif_mib_get_confirm_t {
162 struct hostif_hdr header;
164 #define MIB_SUCCESS 0
165 #define MIB_INVALID 1
166 #define MIB_READ_ONLY 2
167 #define MIB_WRITE_ONLY 3
168 __le32 mib_attribute;
169 struct hostif_mib_value_t mib_value;
172 struct hostif_mib_set_request_t {
173 struct hostif_hdr header;
174 __le32 mib_attribute;
175 struct hostif_mib_value_t mib_value;
178 struct hostif_mib_set_confirm_t {
179 struct hostif_hdr header;
181 __le32 mib_attribute;
184 struct hostif_power_mgmt_request_t {
185 struct hostif_hdr header;
187 #define POWER_ACTIVE 1
190 #define SLEEP_FALSE 0
191 #define SLEEP_TRUE 1 /* not used */
192 __le32 receive_dtims;
197 enum power_mgmt_mode_type {
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_mgmt_confirm_t {
210 struct hostif_hdr header;
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;
228 #define SSID_MAX_SIZE 32
231 u8 body[SSID_MAX_SIZE];
235 #define RATE_SET_MAX_SIZE 16
257 __le16 dur_remaining;
260 struct ibss_parms_t {
266 #define RSN_BODY_SIZE 64
267 u8 body[RSN_BODY_SIZE];
270 struct erp_params_t {
274 struct rate_set16_t {
281 u8 bssid[6]; /* +00 */
286 __le16 beacon_period; /* +10 */
287 __le16 capability; /* +12 */
288 #define BSS_CAP_ESS BIT(0)
289 #define BSS_CAP_IBSS BIT(1)
290 #define BSS_CAP_CF_POLABLE BIT(2)
291 #define BSS_CAP_CF_POLL_REQ BIT(3)
292 #define BSS_CAP_PRIVACY BIT(4)
293 #define BSS_CAP_SHORT_PREAMBLE BIT(5)
294 #define BSS_CAP_PBCC BIT(6)
295 #define BSS_CAP_CHANNEL_AGILITY BIT(7)
296 #define BSS_CAP_SHORT_SLOT_TIME BIT(10)
297 #define BSS_CAP_DSSS_OFDM BIT(13)
298 u8 frame_type; /* +14 */
299 u8 ch_info; /* +15 */
300 #define FRAME_TYPE_BEACON 0x80
301 #define FRAME_TYPE_PROBE_RESP 0x50
302 __le16 body_size; /* +16 */
303 u8 body[1024]; /* +18 */
307 struct link_ap_info_t {
308 u8 bssid[6]; /* +00 */
313 __le16 beacon_period; /* +10 */
314 __le16 capability; /* +12 */
315 struct rate_set8_t rate_set; /* +14 */
316 struct fh_parms_t fh_parameter; /* +24 */
317 struct ds_parms_t ds_parameter; /* +29 */
318 struct cf_parms_t cf_parameter; /* +30 */
319 struct ibss_parms_t ibss_parameter; /* +36 */
320 struct erp_params_t erp_parameter; /* +38 */
322 struct rate_set8_t ext_rate_set; /* +40 */
323 u8 DTIM_period; /* +50 */
324 u8 rsn_mode; /* +51 */
325 #define RSN_MODE_NONE 0
326 #define RSN_MODE_WPA 1
327 #define RSN_MODE_WPA2 2
330 u8 body[128]; /* +53 */
334 struct hostif_connect_indication_t {
335 struct hostif_hdr header;
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;
352 * struct hostif_ps_adhoc_set_request_t - pseudo adhoc mode
353 * @capability: bit5 : preamble
354 * bit6 : pbcc - Not supported always 0
355 * bit10 : ShortSlotTime
356 * bit13 : DSSS-OFDM - Not supported always 0
358 struct hostif_ps_adhoc_set_request_t {
359 struct hostif_hdr header;
361 #define D_11B_ONLY_MODE 0
362 #define D_11G_ONLY_MODE 1
363 #define D_11BG_COMPATIBLE_MODE 2
364 #define D_11A_ONLY_MODE 3
366 #define CTS_MODE_FALSE 0
367 #define CTS_MODE_TRUE 1
369 struct rate_set16_t rate_set;
374 struct hostif_ps_adhoc_set_confirm_t {
375 struct hostif_hdr header;
380 * struct hostif_infrastructure_set_request_t
381 * @capability: bit5 : preamble
382 * bit6 : pbcc - Not supported always 0
383 * bit10 : ShortSlotTime
384 * bit13 : DSSS-OFDM - Not supported always 0
386 struct hostif_infrastructure_set_request_t {
387 struct hostif_hdr header;
390 struct rate_set16_t rate_set;
393 __le16 beacon_lost_count;
395 #define AUTH_TYPE_OPEN_SYSTEM 0
396 #define AUTH_TYPE_SHARED_KEY 1
397 struct channel_list_t channel_list;
402 * struct hostif_infrastructure_set2_request_t
403 * @capability: bit5 : preamble
404 * bit6 : pbcc - Not supported always 0
405 * bit10 : ShortSlotTime
406 * bit13 : DSSS-OFDM - Not supported always 0
408 struct hostif_infrastructure_set2_request_t {
409 struct hostif_hdr header;
412 struct rate_set16_t rate_set;
415 __le16 beacon_lost_count;
417 #define AUTH_TYPE_OPEN_SYSTEM 0
418 #define AUTH_TYPE_SHARED_KEY 1
419 struct channel_list_t channel_list;
424 struct hostif_infrastructure_set_confirm_t {
425 struct hostif_hdr header;
430 * struct hostif_adhoc_set_request_t
431 * @capability: bit5 : preamble
432 * bit6 : pbcc - Not supported always 0
433 * bit10 : ShortSlotTime
434 * bit13 : DSSS-OFDM - Not supported always 0
436 struct hostif_adhoc_set_request_t {
437 struct hostif_hdr header;
441 struct rate_set16_t rate_set;
448 * struct hostif_adhoc_set2_request_t
449 * @capability: bit5 : preamble
450 * bit6 : pbcc - Not supported always 0
451 * bit10 : ShortSlotTime
452 * bit13 : DSSS-OFDM - Not supported always 0
454 struct hostif_adhoc_set2_request_t {
455 struct hostif_hdr header;
459 struct rate_set16_t rate_set;
463 struct channel_list_t channel_list;
467 struct hostif_adhoc_set_confirm_t {
468 struct hostif_hdr header;
472 struct last_associate_t {
477 struct association_request_t {
479 #define FRAME_TYPE_ASSOC_REQ 0x00
480 #define FRAME_TYPE_REASSOC_REQ 0x20
483 __le16 listen_interval;
488 struct association_response_t {
490 #define FRAME_TYPE_ASSOC_RESP 0x10
491 #define FRAME_TYPE_REASSOC_RESP 0x30
495 __le16 association_id;
496 __le16 resp_ies_size;
499 struct hostif_associate_indication_t {
500 struct hostif_hdr header;
501 struct association_request_t assoc_req;
502 struct association_response_t assoc_resp;
503 /* followed by (req_ies_size + resp_ies_size) octets of data */
504 /* reqIEs data *//* respIEs data */
507 struct hostif_bss_scan_request_t {
508 struct hostif_hdr header;
510 #define ACTIVE_SCAN 0
511 #define PASSIVE_SCAN 1
515 struct channel_list_t channel_list;
519 struct hostif_bss_scan_confirm_t {
520 struct hostif_hdr header;
525 struct hostif_phy_information_request_t {
526 struct hostif_hdr header;
528 #define NORMAL_TYPE 0
530 __le16 time; /* unit 100ms */
533 struct hostif_phy_information_confirm_t {
534 struct hostif_hdr header;
545 enum sleep_mode_type {
550 struct hostif_sleep_request_t {
551 struct hostif_hdr header;
554 struct hostif_sleep_confirm_t {
555 struct hostif_hdr header;
559 struct hostif_mic_failure_request_t {
560 struct hostif_hdr header;
561 __le16 failure_count;
565 struct hostif_mic_failure_confirm_t {
566 struct hostif_hdr header;
570 #define BASIC_RATE 0x80
571 #define RATE_MASK 0x7F
573 #define TX_RATE_AUTO 0xff
574 #define TX_RATE_1M_FIXED 0
575 #define TX_RATE_2M_FIXED 1
576 #define TX_RATE_1_2M_AUTO 2
577 #define TX_RATE_5M_FIXED 3
578 #define TX_RATE_11M_FIXED 4
580 #define TX_RATE_FULL_AUTO 0
581 #define TX_RATE_11_AUTO 1
582 #define TX_RATE_11B_AUTO 2
583 #define TX_RATE_11BG_AUTO 3
584 #define TX_RATE_MANUAL_AUTO 4
585 #define TX_RATE_FIXED 5
588 #define TX_RATE_1M (uint8_t)(10 / 5) /* 11b 11g basic rate */
589 #define TX_RATE_2M (uint8_t)(20 / 5) /* 11b 11g basic rate */
590 #define TX_RATE_5M (uint8_t)(55 / 5) /* 11g basic rate */
591 #define TX_RATE_11M (uint8_t)(110 / 5) /* 11g basic rate */
594 #define TX_RATE_6M (uint8_t)(60 / 5) /* 11g basic rate */
595 #define TX_RATE_12M (uint8_t)(120 / 5) /* 11g basic rate */
596 #define TX_RATE_24M (uint8_t)(240 / 5) /* 11g basic rate */
597 #define TX_RATE_9M (uint8_t)(90 / 5)
598 #define TX_RATE_18M (uint8_t)(180 / 5)
599 #define TX_RATE_36M (uint8_t)(360 / 5)
600 #define TX_RATE_48M (uint8_t)(480 / 5)
601 #define TX_RATE_54M (uint8_t)(540 / 5)
603 #define IS_11B_RATE(A) (((A & RATE_MASK) == TX_RATE_1M) || ((A & RATE_MASK) == TX_RATE_2M) || \
604 ((A & RATE_MASK) == TX_RATE_5M) || ((A & RATE_MASK) == TX_RATE_11M))
606 #define IS_OFDM_RATE(A) (((A & RATE_MASK) == TX_RATE_6M) || ((A & RATE_MASK) == TX_RATE_12M) || \
607 ((A & RATE_MASK) == TX_RATE_24M) || ((A & RATE_MASK) == TX_RATE_9M) || \
608 ((A & RATE_MASK) == TX_RATE_18M) || ((A & RATE_MASK) == TX_RATE_36M) || \
609 ((A & RATE_MASK) == TX_RATE_48M) || ((A & RATE_MASK) == TX_RATE_54M))
611 #define IS_11BG_RATE(A) (IS_11B_RATE(A) || IS_OFDM_RATE(A))
613 #define IS_OFDM_EXT_RATE(A) (((A & RATE_MASK) == TX_RATE_9M) || ((A & RATE_MASK) == TX_RATE_18M) || \
614 ((A & RATE_MASK) == TX_RATE_36M) || ((A & RATE_MASK) == TX_RATE_48M) || \
615 ((A & RATE_MASK) == TX_RATE_54M))
617 enum connect_status_type {
627 enum multicast_filter_type {
629 MCAST_FILTER_MCASTALL,
630 MCAST_FILTER_PROMISC,
633 #define NIC_MAX_MCAST_LIST 32
636 #define HIF_EVENT_MASK 0xE800
637 #define IS_HIF_IND(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800 && \
638 ((_EVENT & ~HIF_EVENT_MASK) == 0x0001 || \
639 (_EVENT & ~HIF_EVENT_MASK) == 0x0006 || \
640 (_EVENT & ~HIF_EVENT_MASK) == 0x000C || \
641 (_EVENT & ~HIF_EVENT_MASK) == 0x0011 || \
642 (_EVENT & ~HIF_EVENT_MASK) == 0x0012))
644 #define IS_HIF_CONF(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800 && \
645 (_EVENT & ~HIF_EVENT_MASK) > 0x0000 && \
646 (_EVENT & ~HIF_EVENT_MASK) < 0x0012 && \
653 /* function prototype */
654 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb);
655 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
657 void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event);
658 int hostif_init(struct ks_wlan_private *priv);
659 void hostif_exit(struct ks_wlan_private *priv);
660 int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
661 void (*complete_handler)(struct ks_wlan_private *priv,
662 struct sk_buff *skb),
663 struct sk_buff *skb);
664 void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb);
666 void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv);
667 int ks_wlan_hw_power_save(struct ks_wlan_private *priv);
670 inline int hif_align_size(int size)
676 #ifdef DEVICE_ALIGNMENT
677 return (size % DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT -
678 (size % DEVICE_ALIGNMENT) : size;
684 #endif /* __KERNEL__ */
686 #endif /* _KS_HOSTIF_H_ */