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.
17 #define HIF_DATA_REQ 0xE001
18 #define HIF_DATA_IND 0xE801
19 #define HIF_MIB_GET_REQ 0xE002
20 #define HIF_MIB_GET_CONF 0xE802
21 #define HIF_MIB_SET_REQ 0xE003
22 #define HIF_MIB_SET_CONF 0xE803
23 #define HIF_POWERMGT_REQ 0xE004
24 #define HIF_POWERMGT_CONF 0xE804
25 #define HIF_START_REQ 0xE005
26 #define HIF_START_CONF 0xE805
27 #define HIF_CONNECT_IND 0xE806
28 #define HIF_STOP_REQ 0xE006
29 #define HIF_STOP_CONF 0xE807
30 #define HIF_PS_ADH_SET_REQ 0xE007
31 #define HIF_PS_ADH_SET_CONF 0xE808
32 #define HIF_INFRA_SET_REQ 0xE008
33 #define HIF_INFRA_SET_CONF 0xE809
34 #define HIF_ADH_SET_REQ 0xE009
35 #define HIF_ADH_SET_CONF 0xE80A
36 #define HIF_AP_SET_REQ 0xE00A
37 #define HIF_AP_SET_CONF 0xE80B
38 #define HIF_ASSOC_INFO_IND 0xE80C
39 #define HIF_MIC_FAILURE_REQ 0xE00B
40 #define HIF_MIC_FAILURE_CONF 0xE80D
41 #define HIF_SCAN_REQ 0xE00C
42 #define HIF_SCAN_CONF 0xE80E
43 #define HIF_PHY_INFO_REQ 0xE00D
44 #define HIF_PHY_INFO_CONF 0xE80F
45 #define HIF_SLEEP_REQ 0xE00E
46 #define HIF_SLEEP_CONF 0xE810
47 #define HIF_PHY_INFO_IND 0xE811
48 #define HIF_SCAN_IND 0xE812
49 #define HIF_INFRA_SET2_REQ 0xE00F
50 #define HIF_INFRA_SET2_CONF 0xE813
51 #define HIF_ADH_SET2_REQ 0xE010
52 #define HIF_ADH_SET2_CONF 0xE814
54 #define HIF_REQ_MAX 0xE010
57 * HOST-MAC I/F data structure
58 * Byte alignmet Little Endian
64 } __attribute__ ((packed));
66 struct hostif_data_request_t {
67 struct hostif_hdr header;
69 #define TYPE_DATA 0x0000
70 #define TYPE_AUTH 0x0001
73 } __attribute__ ((packed));
75 struct hostif_data_indication_t {
76 struct hostif_hdr header;
78 /* #define TYPE_DATA 0x0000 */
79 #define TYPE_PMK1 0x0001
80 #define TYPE_GMK1 0x0002
81 #define TYPE_GMK2 0x0003
84 } __attribute__ ((packed));
86 #define CHANNEL_LIST_MAX_SIZE 14
87 struct channel_list_t {
89 uint8_t body[CHANNEL_LIST_MAX_SIZE];
91 } __attribute__ ((packed));
94 #define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */
95 #define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R) */
96 #define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */
97 #define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */
98 #define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */
99 #define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */
100 #define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */
101 #define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */
102 #define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */
103 #define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */
104 #define DOT11_WEP_LIST 0x13020100 /* WEP LIST */
105 #define DOT11_DESIRED_SSID 0x11090100 /* SSID */
106 #define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */
107 #define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */
109 #define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */
110 #define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Adress change (W) */
111 #define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Adress (W) */
112 #define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Adress Filter enable/disable (W) */
113 #define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */
114 #define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */
115 #define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */
116 #define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */
118 #define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */
119 #define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */
120 #define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */
121 #define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */
122 #define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */
123 #define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */
124 #define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */
125 #define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */
126 #define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */
127 #define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */
128 #define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */
129 #define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */
131 #define LOCAL_REGION 0xF10A0100 /* Region setting */
134 #define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */
135 #define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */
138 #define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */
139 #define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */
141 struct hostif_mib_get_request_t {
142 struct hostif_hdr header;
143 uint32_t mib_attribute;
144 } __attribute__ ((packed));
146 struct hostif_mib_value_t {
149 #define MIB_VALUE_TYPE_NULL 0
150 #define MIB_VALUE_TYPE_INT 1
151 #define MIB_VALUE_TYPE_BOOL 2
152 #define MIB_VALUE_TYPE_COUNT32 3
153 #define MIB_VALUE_TYPE_OSTRING 4
155 } __attribute__ ((packed));
157 struct hostif_mib_get_confirm_t {
158 struct hostif_hdr header;
160 #define MIB_SUCCESS 0
161 #define MIB_INVALID 1
162 #define MIB_READ_ONLY 2
163 #define MIB_WRITE_ONLY 3
164 uint32_t mib_attribute;
165 struct hostif_mib_value_t mib_value;
166 } __attribute__ ((packed));
168 struct hostif_mib_set_request_t {
169 struct hostif_hdr header;
170 uint32_t mib_attribute;
171 struct hostif_mib_value_t mib_value;
172 } __attribute__ ((packed));
174 struct hostif_mib_set_confirm_t {
175 struct hostif_hdr header;
177 uint32_t mib_attribute;
178 } __attribute__ ((packed));
180 struct hostif_power_mngmt_request_t {
181 struct hostif_hdr header;
183 #define POWER_ACTIVE 1
186 #define SLEEP_FALSE 0
187 #define SLEEP_TRUE 1 /* not used */
188 uint32_t receiveDTIMs;
191 } __attribute__ ((packed));
193 /* power management mode */
195 POWMGT_ACTIVE_MODE = 0,
200 #define RESULT_SUCCESS 0
201 #define RESULT_INVALID_PARAMETERS 1
202 #define RESULT_NOT_SUPPORTED 2
203 /* #define RESULT_ALREADY_RUNNING 3 */
204 #define RESULT_ALREADY_RUNNING 7
206 struct hostif_power_mngmt_confirm_t {
207 struct hostif_hdr header;
208 uint16_t result_code;
209 } __attribute__ ((packed));
211 struct hostif_start_request_t {
212 struct hostif_hdr header;
214 #define MODE_PSEUDO_ADHOC 0
215 #define MODE_INFRASTRUCTURE 1
216 #define MODE_AP 2 /* not used */
218 } __attribute__ ((packed));
220 struct hostif_start_confirm_t {
221 struct hostif_hdr header;
222 uint16_t result_code;
223 } __attribute__ ((packed));
225 #define SSID_MAX_SIZE 32
228 uint8_t body[SSID_MAX_SIZE];
230 } __attribute__ ((packed));
232 #define RATE_SET_MAX_SIZE 16
237 } __attribute__ ((packed));
244 } __attribute__ ((packed));
248 } __attribute__ ((packed));
253 uint16_t maxDuration;
254 uint16_t durRemaining;
255 } __attribute__ ((packed));
259 } __attribute__ ((packed));
263 #define RSN_BODY_SIZE 64
264 uint8_t body[RSN_BODY_SIZE];
265 } __attribute__ ((packed));
269 } __attribute__ ((packed));
271 struct rate_set16_t {
275 } __attribute__ ((packed));
278 uint8_t bssid[6]; /* +00 */
279 uint8_t rssi; /* +06 */
280 uint8_t sq; /* +07 */
281 uint8_t noise; /* +08 */
282 uint8_t pad0; /* +09 */
283 uint16_t beacon_period; /* +10 */
284 uint16_t capability; /* +12 */
285 #define BSS_CAP_ESS (1<<0)
286 #define BSS_CAP_IBSS (1<<1)
287 #define BSS_CAP_CF_POLABLE (1<<2)
288 #define BSS_CAP_CF_POLL_REQ (1<<3)
289 #define BSS_CAP_PRIVACY (1<<4)
290 #define BSS_CAP_SHORT_PREAMBLE (1<<5)
291 #define BSS_CAP_PBCC (1<<6)
292 #define BSS_CAP_CHANNEL_AGILITY (1<<7)
293 #define BSS_CAP_SHORT_SLOT_TIME (1<<10)
294 #define BSS_CAP_DSSS_OFDM (1<<13)
295 uint8_t frame_type; /* +14 */
296 uint8_t ch_info; /* +15 */
297 #define FRAME_TYPE_BEACON 0x80
298 #define FRAME_TYPE_PROBE_RESP 0x50
299 uint16_t body_size; /* +16 */
300 uint8_t body[1024]; /* +18 */
302 } __attribute__ ((packed));
304 struct link_ap_info_t {
305 uint8_t bssid[6]; /* +00 */
306 uint8_t rssi; /* +06 */
307 uint8_t sq; /* +07 */
308 uint8_t noise; /* +08 */
309 uint8_t pad0; /* +09 */
310 uint16_t beacon_period; /* +10 */
311 uint16_t capability; /* +12 */
312 struct rate_set8_t rate_set; /* +14 */
313 struct FhParms_t fh_parameter; /* +24 */
314 struct DsParms_t ds_parameter; /* +29 */
315 struct CfParms_t cf_parameter; /* +30 */
316 struct IbssParms_t ibss_parameter; /* +36 */
317 struct ErpParams_t erp_parameter; /* +38 */
318 uint8_t pad1; /* +39 */
319 struct rate_set8_t ext_rate_set; /* +40 */
320 uint8_t DTIM_period; /* +50 */
321 uint8_t rsn_mode; /* +51 */
322 #define RSN_MODE_NONE 0
323 #define RSN_MODE_WPA 1
324 #define RSN_MODE_WPA2 2
326 uint8_t size; /* +52 */
327 uint8_t body[128]; /* +53 */
328 } __attribute__ ((packed)) rsn;
329 } __attribute__ ((packed));
331 struct hostif_connect_indication_t {
332 struct hostif_hdr header;
333 uint16_t connect_code;
334 #define RESULT_CONNECT 0
335 #define RESULT_DISCONNECT 1
336 struct link_ap_info_t link_ap_info;
337 } __attribute__ ((packed));
339 struct hostif_stop_request_t {
340 struct hostif_hdr header;
341 } __attribute__ ((packed));
343 struct hostif_stop_confirm_t {
344 struct hostif_hdr header;
345 uint16_t result_code;
346 } __attribute__ ((packed));
348 struct hostif_ps_adhoc_set_request_t {
349 struct hostif_hdr header;
351 #define D_11B_ONLY_MODE 0
352 #define D_11G_ONLY_MODE 1
353 #define D_11BG_COMPATIBLE_MODE 2
354 #define D_11A_ONLY_MODE 3
356 #define CTS_MODE_FALSE 0
357 #define CTS_MODE_TRUE 1
359 struct rate_set16_t rate_set;
360 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
361 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
363 } __attribute__ ((packed));
365 struct hostif_ps_adhoc_set_confirm_t {
366 struct hostif_hdr header;
367 uint16_t result_code;
368 } __attribute__ ((packed));
370 struct hostif_infrastructure_set_request_t {
371 struct hostif_hdr header;
374 struct rate_set16_t rate_set;
376 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
377 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
378 uint16_t beacon_lost_count;
380 #define AUTH_TYPE_OPEN_SYSTEM 0
381 #define AUTH_TYPE_SHARED_KEY 1
382 struct channel_list_t channel_list;
384 } __attribute__ ((packed));
386 struct hostif_infrastructure_set2_request_t {
387 struct hostif_hdr header;
390 struct rate_set16_t rate_set;
392 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
393 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
394 uint16_t beacon_lost_count;
396 #define AUTH_TYPE_OPEN_SYSTEM 0
397 #define AUTH_TYPE_SHARED_KEY 1
398 struct channel_list_t channel_list;
400 uint8_t bssid[ETH_ALEN];
401 } __attribute__ ((packed));
403 struct hostif_infrastructure_set_confirm_t {
404 struct hostif_hdr header;
405 uint16_t result_code;
406 } __attribute__ ((packed));
408 struct hostif_adhoc_set_request_t {
409 struct hostif_hdr header;
413 struct rate_set16_t rate_set;
415 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
416 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
418 } __attribute__ ((packed));
420 struct hostif_adhoc_set2_request_t {
421 struct hostif_hdr header;
425 struct rate_set16_t rate_set;
427 uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0
428 * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */
430 struct channel_list_t channel_list;
431 uint8_t bssid[ETH_ALEN];
432 } __attribute__ ((packed));
434 struct hostif_adhoc_set_confirm_t {
435 struct hostif_hdr header;
436 uint16_t result_code;
437 } __attribute__ ((packed));
439 struct last_associate_t {
442 } __attribute__ ((packed));
444 struct association_request_t {
446 #define FRAME_TYPE_ASSOC_REQ 0x00
447 #define FRAME_TYPE_REASSOC_REQ 0x20
450 uint16_t listen_interval;
451 uint8_t ap_address[6];
452 uint16_t reqIEs_size;
453 } __attribute__ ((packed));
455 struct association_response_t {
457 #define FRAME_TYPE_ASSOC_RESP 0x10
458 #define FRAME_TYPE_REASSOC_RESP 0x30
462 uint16_t association_id;
463 uint16_t respIEs_size;
464 } __attribute__ ((packed));
466 struct hostif_associate_indication_t {
467 struct hostif_hdr header;
468 struct association_request_t assoc_req;
469 struct association_response_t assoc_resp;
470 /* followed by (reqIEs_size + respIEs_size) octets of data */
471 /* reqIEs data *//* respIEs data */
472 } __attribute__ ((packed));
474 struct hostif_bss_scan_request_t {
475 struct hostif_hdr header;
477 #define ACTIVE_SCAN 0
478 #define PASSIVE_SCAN 1
480 uint32_t ch_time_min;
481 uint32_t ch_time_max;
482 struct channel_list_t channel_list;
484 } __attribute__ ((packed));
486 struct hostif_bss_scan_confirm_t {
487 struct hostif_hdr header;
488 uint16_t result_code;
490 } __attribute__ ((packed));
492 struct hostif_phy_information_request_t {
493 struct hostif_hdr header;
495 #define NORMAL_TYPE 0
497 uint16_t time; /* unit 100ms */
498 } __attribute__ ((packed));
500 struct hostif_phy_information_confirm_t {
501 struct hostif_hdr header;
510 } __attribute__ ((packed));
515 struct hostif_sleep_request_t {
516 struct hostif_hdr header;
517 } __attribute__ ((packed));
519 struct hostif_sleep_confirm_t {
520 struct hostif_hdr header;
521 uint16_t result_code;
522 } __attribute__ ((packed));
524 struct hostif_mic_failure_request_t {
525 struct hostif_hdr header;
526 uint16_t failure_count;
528 } __attribute__ ((packed));
530 struct hostif_mic_failure_confirm_t {
531 struct hostif_hdr header;
532 uint16_t result_code;
533 } __attribute__ ((packed));
535 #define BASIC_RATE 0x80
536 #define RATE_MASK 0x7F
538 #define TX_RATE_AUTO 0xff
539 #define TX_RATE_1M_FIXED 0
540 #define TX_RATE_2M_FIXED 1
541 #define TX_RATE_1_2M_AUTO 2
542 #define TX_RATE_5M_FIXED 3
543 #define TX_RATE_11M_FIXED 4
545 #define TX_RATE_FULL_AUTO 0
546 #define TX_RATE_11_AUTO 1
547 #define TX_RATE_11B_AUTO 2
548 #define TX_RATE_11BG_AUTO 3
549 #define TX_RATE_MANUAL_AUTO 4
550 #define TX_RATE_FIXED 5
553 #define TX_RATE_1M (uint8_t)(10/5) /* 11b 11g basic rate */
554 #define TX_RATE_2M (uint8_t)(20/5) /* 11b 11g basic rate */
555 #define TX_RATE_5M (uint8_t)(55/5) /* 11g basic rate */
556 #define TX_RATE_11M (uint8_t)(110/5) /* 11g basic rate */
559 #define TX_RATE_6M (uint8_t)(60/5) /* 11g basic rate */
560 #define TX_RATE_12M (uint8_t)(120/5) /* 11g basic rate */
561 #define TX_RATE_24M (uint8_t)(240/5) /* 11g basic rate */
562 #define TX_RATE_9M (uint8_t)(90/5)
563 #define TX_RATE_18M (uint8_t)(180/5)
564 #define TX_RATE_36M (uint8_t)(360/5)
565 #define TX_RATE_48M (uint8_t)(480/5)
566 #define TX_RATE_54M (uint8_t)(540/5)
568 #define IS_11B_RATE(A) (((A&RATE_MASK)==TX_RATE_1M)||((A&RATE_MASK)==TX_RATE_2M)||\
569 ((A&RATE_MASK)==TX_RATE_5M)||((A&RATE_MASK)==TX_RATE_11M))
571 #define IS_OFDM_RATE(A) (((A&RATE_MASK)==TX_RATE_6M)||((A&RATE_MASK)==TX_RATE_12M)||\
572 ((A&RATE_MASK)==TX_RATE_24M)||((A&RATE_MASK)==TX_RATE_9M)||\
573 ((A&RATE_MASK)==TX_RATE_18M)||((A&RATE_MASK)==TX_RATE_36M)||\
574 ((A&RATE_MASK)==TX_RATE_48M)||((A&RATE_MASK)==TX_RATE_54M))
576 #define IS_11BG_RATE(A) (IS_11B_RATE(A)||IS_OFDM_RATE(A))
578 #define IS_OFDM_EXT_RATE(A) (((A&RATE_MASK)==TX_RATE_9M)||((A&RATE_MASK)==TX_RATE_18M)||\
579 ((A&RATE_MASK)==TX_RATE_36M)||((A&RATE_MASK)==TX_RATE_48M)||\
580 ((A&RATE_MASK)==TX_RATE_54M))
593 /* multicast filter */
594 #define MCAST_FILTER_MCAST 0
595 #define MCAST_FILTER_MCASTALL 1
596 #define MCAST_FILTER_PROMISC 2
598 #define NIC_MAX_MCAST_LIST 32
601 #define HIF_EVENT_MASK 0xE800
602 #define IS_HIF_IND(_EVENT) ((_EVENT&HIF_EVENT_MASK)==0xE800 && \
603 ((_EVENT&~HIF_EVENT_MASK)==0x0001 || \
604 (_EVENT&~HIF_EVENT_MASK)==0x0006 || \
605 (_EVENT&~HIF_EVENT_MASK)==0x000C || \
606 (_EVENT&~HIF_EVENT_MASK)==0x0011 || \
607 (_EVENT&~HIF_EVENT_MASK)==0x0012))
609 #define IS_HIF_CONF(_EVENT) ((_EVENT&HIF_EVENT_MASK)==0xE800 && \
610 (_EVENT&~HIF_EVENT_MASK)>0x0000 && \
611 (_EVENT&~HIF_EVENT_MASK)<0x0012 && \
612 !IS_HIF_IND(_EVENT) )
618 /* function prototype */
619 extern int hostif_data_request(struct ks_wlan_private *priv,
620 struct sk_buff *packet);
621 extern void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
623 extern void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event);
624 extern int hostif_init(struct ks_wlan_private *priv);
625 extern void hostif_exit(struct ks_wlan_private *priv);
628 inline int hif_align_size(int size)
634 #ifdef DEVICE_ALIGNMENT
635 return (size % DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT -
636 (size % DEVICE_ALIGNMENT) : size;
642 #endif /* __KERNEL__ */
644 #endif /* _KS_HOSTIF_H_ */