1 /*
2  *   Driver for KeyStream wireless LAN
3  *
4  *   Copyright (c) 2005-2008 KeyStream Corp.
5  *   Copyright (C) 2009 Renesas Technology Corp.
6  *
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.
10  */
11 
12 #ifndef _KS_HOSTIF_H_
13 #define _KS_HOSTIF_H_
14 /*
15  * HOST-MAC I/F events
16  */
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
53 
54 #define HIF_REQ_MAX		0xE010
55 
56 /*
57  * HOST-MAC I/F data structure
58  * Byte alignmet Little Endian
59  */
60 
61 struct hostif_hdr {
62 	uint16_t size;
63 	uint16_t event;
64 } __attribute__ ((packed));
65 
66 struct hostif_data_request_t {
67 	struct hostif_hdr header;
68 	uint16_t auth_type;
69 #define TYPE_DATA 0x0000
70 #define TYPE_AUTH 0x0001
71 	uint16_t reserved;
72 	uint8_t data[0];
73 } __attribute__ ((packed));
74 
75 struct hostif_data_indication_t {
76 	struct hostif_hdr header;
77 	uint16_t auth_type;
78 /* #define TYPE_DATA 0x0000 */
79 #define TYPE_PMK1 0x0001
80 #define TYPE_GMK1 0x0002
81 #define TYPE_GMK2 0x0003
82 	uint16_t reserved;
83 	uint8_t data[0];
84 } __attribute__ ((packed));
85 
86 #define CHANNEL_LIST_MAX_SIZE 14
87 struct channel_list_t {
88 	uint8_t size;
89 	uint8_t body[CHANNEL_LIST_MAX_SIZE];
90 	uint8_t pad;
91 } __attribute__ ((packed));
92 
93 /* MIB Attribute */
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 */
108 
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 */
117 
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) */
130 
131 #define LOCAL_REGION                      0xF10A0100	/* Region setting */
132 
133 #ifdef WPS
134 #define LOCAL_WPS_ENABLE                  0xF10B0100	/* WiFi Protected Setup */
135 #define LOCAL_WPS_PROBE_REQ               0xF10C0100	/* WPS Probe Request */
136 #endif /* WPS */
137 
138 #define LOCAL_GAIN                        0xF10D0100	/* Carrer sense threshold for demo ato show */
139 #define LOCAL_EEPROM_SUM                  0xF10E0100	/* EEPROM checksum information */
140 
141 struct hostif_mib_get_request_t {
142 	struct hostif_hdr header;
143 	uint32_t mib_attribute;
144 } __attribute__ ((packed));
145 
146 struct hostif_mib_value_t {
147 	uint16_t size;
148 	uint16_t type;
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
154 	uint8_t body[0];
155 } __attribute__ ((packed));
156 
157 struct hostif_mib_get_confirm_t {
158 	struct hostif_hdr header;
159 	uint32_t mib_status;
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));
167 
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));
173 
174 struct hostif_mib_set_confirm_t {
175 	struct hostif_hdr header;
176 	uint32_t mib_status;
177 	uint32_t mib_attribute;
178 } __attribute__ ((packed));
179 
180 struct hostif_power_mngmt_request_t {
181 	struct hostif_hdr header;
182 	uint32_t mode;
183 #define POWER_ACTIVE  1
184 #define POWER_SAVE    2
185 	uint32_t wake_up;
186 #define SLEEP_FALSE 0
187 #define SLEEP_TRUE  1	/* not used */
188 	uint32_t receiveDTIMs;
189 #define DTIM_FALSE 0
190 #define DTIM_TRUE  1
191 } __attribute__ ((packed));
192 
193 /* power management mode */
194 enum {
195 	POWMGT_ACTIVE_MODE = 0,
196 	POWMGT_SAVE1_MODE,
197 	POWMGT_SAVE2_MODE
198 };
199 
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
205 
206 struct hostif_power_mngmt_confirm_t {
207 	struct hostif_hdr header;
208 	uint16_t result_code;
209 } __attribute__ ((packed));
210 
211 struct hostif_start_request_t {
212 	struct hostif_hdr header;
213 	uint16_t mode;
214 #define MODE_PSEUDO_ADHOC   0
215 #define MODE_INFRASTRUCTURE 1
216 #define MODE_AP             2	/* not used */
217 #define MODE_ADHOC          3
218 } __attribute__ ((packed));
219 
220 struct hostif_start_confirm_t {
221 	struct hostif_hdr header;
222 	uint16_t result_code;
223 } __attribute__ ((packed));
224 
225 #define SSID_MAX_SIZE 32
226 struct ssid_t {
227 	uint8_t size;
228 	uint8_t body[SSID_MAX_SIZE];
229 	uint8_t ssid_pad;
230 } __attribute__ ((packed));
231 
232 #define RATE_SET_MAX_SIZE 16
233 struct rate_set8_t {
234 	uint8_t size;
235 	uint8_t body[8];
236 	uint8_t rate_pad;
237 } __attribute__ ((packed));
238 
239 struct FhParms_t {
240 	uint16_t dwellTime;
241 	uint8_t hopSet;
242 	uint8_t hopPattern;
243 	uint8_t hopIndex;
244 } __attribute__ ((packed));
245 
246 struct DsParms_t {
247 	uint8_t channel;
248 } __attribute__ ((packed));
249 
250 struct CfParms_t {
251 	uint8_t count;
252 	uint8_t period;
253 	uint16_t maxDuration;
254 	uint16_t durRemaining;
255 } __attribute__ ((packed));
256 
257 struct IbssParms_t {
258 	uint16_t atimWindow;
259 } __attribute__ ((packed));
260 
261 struct rsn_t {
262 	uint8_t size;
263 #define RSN_BODY_SIZE 64
264 	uint8_t body[RSN_BODY_SIZE];
265 } __attribute__ ((packed));
266 
267 struct ErpParams_t {
268 	uint8_t erp_info;
269 } __attribute__ ((packed));
270 
271 struct rate_set16_t {
272 	uint8_t size;
273 	uint8_t body[16];
274 	uint8_t rate_pad;
275 } __attribute__ ((packed));
276 
277 struct ap_info_t {
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 */
301 	/* +1032 */
302 } __attribute__ ((packed));
303 
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
325 	struct {
326 		uint8_t size;	/* +52 */
327 		uint8_t body[128];	/* +53 */
328 	} __attribute__ ((packed)) rsn;
329 } __attribute__ ((packed));
330 
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));
338 
339 struct hostif_stop_request_t {
340 	struct hostif_hdr header;
341 } __attribute__ ((packed));
342 
343 struct hostif_stop_confirm_t {
344 	struct hostif_hdr header;
345 	uint16_t result_code;
346 } __attribute__ ((packed));
347 
348 struct hostif_ps_adhoc_set_request_t {
349 	struct hostif_hdr header;
350 	uint16_t phy_type;
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
355 	uint16_t cts_mode;
356 #define CTS_MODE_FALSE	0
357 #define CTS_MODE_TRUE	1
358 	uint16_t channel;
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 */
362 	uint16_t scan_type;
363 } __attribute__ ((packed));
364 
365 struct hostif_ps_adhoc_set_confirm_t {
366 	struct hostif_hdr header;
367 	uint16_t result_code;
368 } __attribute__ ((packed));
369 
370 struct hostif_infrastructure_set_request_t {
371 	struct hostif_hdr header;
372 	uint16_t phy_type;
373 	uint16_t cts_mode;
374 	struct rate_set16_t rate_set;
375 	struct ssid_t ssid;
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;
379 	uint16_t auth_type;
380 #define AUTH_TYPE_OPEN_SYSTEM 0
381 #define AUTH_TYPE_SHARED_KEY  1
382 	struct channel_list_t channel_list;
383 	uint16_t scan_type;
384 } __attribute__ ((packed));
385 
386 struct hostif_infrastructure_set2_request_t {
387 	struct hostif_hdr header;
388 	uint16_t phy_type;
389 	uint16_t cts_mode;
390 	struct rate_set16_t rate_set;
391 	struct ssid_t ssid;
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;
395 	uint16_t auth_type;
396 #define AUTH_TYPE_OPEN_SYSTEM 0
397 #define AUTH_TYPE_SHARED_KEY  1
398 	struct channel_list_t channel_list;
399 	uint16_t scan_type;
400 	uint8_t bssid[ETH_ALEN];
401 } __attribute__ ((packed));
402 
403 struct hostif_infrastructure_set_confirm_t {
404 	struct hostif_hdr header;
405 	uint16_t result_code;
406 } __attribute__ ((packed));
407 
408 struct hostif_adhoc_set_request_t {
409 	struct hostif_hdr header;
410 	uint16_t phy_type;
411 	uint16_t cts_mode;
412 	uint16_t channel;
413 	struct rate_set16_t rate_set;
414 	struct ssid_t ssid;
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 */
417 	uint16_t scan_type;
418 } __attribute__ ((packed));
419 
420 struct hostif_adhoc_set2_request_t {
421 	struct hostif_hdr header;
422 	uint16_t phy_type;
423 	uint16_t cts_mode;
424 	uint16_t reserved;
425 	struct rate_set16_t rate_set;
426 	struct ssid_t ssid;
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 */
429 	uint16_t scan_type;
430 	struct channel_list_t channel_list;
431 	uint8_t bssid[ETH_ALEN];
432 } __attribute__ ((packed));
433 
434 struct hostif_adhoc_set_confirm_t {
435 	struct hostif_hdr header;
436 	uint16_t result_code;
437 } __attribute__ ((packed));
438 
439 struct last_associate_t {
440 	uint8_t type;
441 	uint8_t status;
442 } __attribute__ ((packed));
443 
444 struct association_request_t {
445 	uint8_t type;
446 #define FRAME_TYPE_ASSOC_REQ	0x00
447 #define FRAME_TYPE_REASSOC_REQ	0x20
448 	uint8_t pad;
449 	uint16_t capability;
450 	uint16_t listen_interval;
451 	uint8_t ap_address[6];
452 	uint16_t reqIEs_size;
453 } __attribute__ ((packed));
454 
455 struct association_response_t {
456 	uint8_t type;
457 #define FRAME_TYPE_ASSOC_RESP	0x10
458 #define FRAME_TYPE_REASSOC_RESP	0x30
459 	uint8_t pad;
460 	uint16_t capability;
461 	uint16_t status;
462 	uint16_t association_id;
463 	uint16_t respIEs_size;
464 } __attribute__ ((packed));
465 
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));
473 
474 struct hostif_bss_scan_request_t {
475 	struct hostif_hdr header;
476 	uint8_t scan_type;
477 #define ACTIVE_SCAN  0
478 #define PASSIVE_SCAN 1
479 	uint8_t pad[3];
480 	uint32_t ch_time_min;
481 	uint32_t ch_time_max;
482 	struct channel_list_t channel_list;
483 	struct ssid_t ssid;
484 } __attribute__ ((packed));
485 
486 struct hostif_bss_scan_confirm_t {
487 	struct hostif_hdr header;
488 	uint16_t result_code;
489 	uint16_t reserved;
490 } __attribute__ ((packed));
491 
492 struct hostif_phy_information_request_t {
493 	struct hostif_hdr header;
494 	uint16_t type;
495 #define NORMAL_TYPE	0
496 #define TIME_TYPE	1
497 	uint16_t time;	/* unit 100ms */
498 } __attribute__ ((packed));
499 
500 struct hostif_phy_information_confirm_t {
501 	struct hostif_hdr header;
502 	uint8_t rssi;
503 	uint8_t sq;
504 	uint8_t noise;
505 	uint8_t link_speed;
506 	uint32_t tx_frame;
507 	uint32_t rx_frame;
508 	uint32_t tx_error;
509 	uint32_t rx_error;
510 } __attribute__ ((packed));
511 
512 /* sleep mode */
513 #define SLP_ACTIVE  0
514 #define SLP_SLEEP   1
515 struct hostif_sleep_request_t {
516 	struct hostif_hdr header;
517 } __attribute__ ((packed));
518 
519 struct hostif_sleep_confirm_t {
520 	struct hostif_hdr header;
521 	uint16_t result_code;
522 } __attribute__ ((packed));
523 
524 struct hostif_mic_failure_request_t {
525 	struct hostif_hdr header;
526 	uint16_t failure_count;
527 	uint16_t timer;
528 } __attribute__ ((packed));
529 
530 struct hostif_mic_failure_confirm_t {
531 	struct hostif_hdr header;
532 	uint16_t result_code;
533 } __attribute__ ((packed));
534 
535 #define BASIC_RATE	0x80
536 #define RATE_MASK	0x7F
537 
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
544 
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
551 
552 /* 11b rate */
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 */
557 
558 /* 11g 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)
567 
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))
570 
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))
575 
576 #define IS_11BG_RATE(A) (IS_11B_RATE(A)||IS_OFDM_RATE(A))
577 
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))
581 
582 enum {
583 	CONNECT_STATUS = 0,
584 	DISCONNECT_STATUS
585 };
586 
587 /* preamble type */
588 enum {
589 	LONG_PREAMBLE = 0,
590 	SHORT_PREAMBLE
591 };
592 
593 /* multicast filter */
594 #define MCAST_FILTER_MCAST    0
595 #define MCAST_FILTER_MCASTALL 1
596 #define MCAST_FILTER_PROMISC  2
597 
598 #define NIC_MAX_MCAST_LIST 32
599 
600 /* macro function */
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))
608 
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) )
613 
614 #ifdef __KERNEL__
615 
616 #include "ks_wlan.h"
617 
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,
622 			   unsigned int size);
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);
626 
627 static
628 inline int hif_align_size(int size)
629 {
630 #ifdef	KS_ATOM
631 	if (size < 1024)
632 		size = 1024;
633 #endif
634 #ifdef	DEVICE_ALIGNMENT
635 	return (size % DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT -
636 	    (size % DEVICE_ALIGNMENT) : size;
637 #else
638 	return size;
639 #endif
640 }
641 
642 #endif /* __KERNEL__ */
643 
644 #endif /* _KS_HOSTIF_H_ */
645