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 #include <linux/compiler.h>
16 
17 /*
18  * HOST-MAC I/F events
19  */
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_POWER_MGMT_REQ	0xE004
27 #define HIF_POWER_MGMT_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
56 
57 #define HIF_REQ_MAX		0xE010
58 
59 /*
60  * HOST-MAC I/F data structure
61  * Byte alignmet Little Endian
62  */
63 
64 struct hostif_hdr {
65 	__le16 size;
66 	__le16 event;
67 } __packed;
68 
69 struct hostif_data_request_t {
70 	struct hostif_hdr header;
71 	__le16 auth_type;
72 #define TYPE_DATA 0x0000
73 #define TYPE_AUTH 0x0001
74 	__le16 reserved;
75 	u8 data[0];
76 } __packed;
77 
78 struct hostif_data_indication_t {
79 	struct hostif_hdr header;
80 	__le16 auth_type;
81 /* #define TYPE_DATA 0x0000 */
82 #define TYPE_PMK1 0x0001
83 #define TYPE_GMK1 0x0002
84 #define TYPE_GMK2 0x0003
85 	__le16 reserved;
86 	u8 data[0];
87 } __packed;
88 
89 #define CHANNEL_LIST_MAX_SIZE 14
90 struct channel_list_t {
91 	u8 size;
92 	u8 body[CHANNEL_LIST_MAX_SIZE];
93 	u8 pad;
94 } __packed;
95 
96 /* MIB Attribute */
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 */
111 
112 #define LOCAL_AP_SEARCH_INTEAVAL          0xF1010100	/* AP search interval (R/W) */
113 #define LOCAL_CURRENTADDRESS              0xF1050100	/* MAC Address change (W) */
114 #define LOCAL_MULTICAST_ADDRESS           0xF1060100	/* Multicast Address (W) */
115 #define LOCAL_MULTICAST_FILTER            0xF1060200	/* Multicast Address 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 */
120 
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) */
133 
134 #define LOCAL_REGION                      0xF10A0100	/* Region setting */
135 
136 #ifdef WPS
137 #define LOCAL_WPS_ENABLE                  0xF10B0100	/* WiFi Protected Setup */
138 #define LOCAL_WPS_PROBE_REQ               0xF10C0100	/* WPS Probe Request */
139 #endif /* WPS */
140 
141 #define LOCAL_GAIN                        0xF10D0100	/* Carrer sense threshold for demo ato show */
142 #define LOCAL_EEPROM_SUM                  0xF10E0100	/* EEPROM checksum information */
143 
144 struct hostif_mib_get_request_t {
145 	struct hostif_hdr header;
146 	__le32 mib_attribute;
147 } __packed;
148 
149 struct hostif_mib_value_t {
150 	__le16 size;
151 	__le16 type;
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
157 	u8 body[0];
158 } __packed;
159 
160 struct hostif_mib_get_confirm_t {
161 	struct hostif_hdr header;
162 	__le32 mib_status;
163 #define MIB_SUCCESS    0
164 #define MIB_INVALID    1
165 #define MIB_READ_ONLY  2
166 #define MIB_WRITE_ONLY 3
167 	__le32 mib_attribute;
168 	struct hostif_mib_value_t mib_value;
169 } __packed;
170 
171 struct hostif_mib_set_request_t {
172 	struct hostif_hdr header;
173 	__le32 mib_attribute;
174 	struct hostif_mib_value_t mib_value;
175 } __packed;
176 
177 struct hostif_mib_set_confirm_t {
178 	struct hostif_hdr header;
179 	__le32 mib_status;
180 	__le32 mib_attribute;
181 } __packed;
182 
183 struct hostif_power_mgmt_request_t {
184 	struct hostif_hdr header;
185 	__le32 mode;
186 #define POWER_ACTIVE  1
187 #define POWER_SAVE    2
188 	__le32 wake_up;
189 #define SLEEP_FALSE 0
190 #define SLEEP_TRUE  1	/* not used */
191 	__le32 receive_dtims;
192 #define DTIM_FALSE 0
193 #define DTIM_TRUE  1
194 } __packed;
195 
196 enum power_mgmt_mode_type {
197 	POWER_MGMT_ACTIVE,
198 	POWER_MGMT_SAVE1,
199 	POWER_MGMT_SAVE2
200 };
201 
202 #define	RESULT_SUCCESS            0
203 #define	RESULT_INVALID_PARAMETERS 1
204 #define	RESULT_NOT_SUPPORTED      2
205 /* #define	RESULT_ALREADY_RUNNING    3 */
206 #define	RESULT_ALREADY_RUNNING    7
207 
208 struct hostif_power_mgmt_confirm_t {
209 	struct hostif_hdr header;
210 	__le16 result_code;
211 } __packed;
212 
213 struct hostif_start_request_t {
214 	struct hostif_hdr header;
215 	__le16 mode;
216 #define MODE_PSEUDO_ADHOC   0
217 #define MODE_INFRASTRUCTURE 1
218 #define MODE_AP             2	/* not used */
219 #define MODE_ADHOC          3
220 } __packed;
221 
222 struct hostif_start_confirm_t {
223 	struct hostif_hdr header;
224 	__le16 result_code;
225 } __packed;
226 
227 #define SSID_MAX_SIZE 32
228 struct ssid_t {
229 	u8 size;
230 	u8 body[SSID_MAX_SIZE];
231 	u8 ssid_pad;
232 } __packed;
233 
234 #define RATE_SET_MAX_SIZE 16
235 struct rate_set8_t {
236 	u8 size;
237 	u8 body[8];
238 	u8 rate_pad;
239 } __packed;
240 
241 struct fh_parms_t {
242 	__le16 dwell_time;
243 	u8 hop_set;
244 	u8 hop_pattern;
245 	u8 hop_index;
246 } __packed;
247 
248 struct ds_parms_t {
249 	u8 channel;
250 } __packed;
251 
252 struct cf_parms_t {
253 	u8 count;
254 	u8 period;
255 	__le16 max_duration;
256 	__le16 dur_remaining;
257 } __packed;
258 
259 struct ibss_parms_t {
260 	__le16 atim_window;
261 } __packed;
262 
263 struct rsn_t {
264 	u8 size;
265 #define RSN_BODY_SIZE 64
266 	u8 body[RSN_BODY_SIZE];
267 } __packed;
268 
269 struct erp_params_t {
270 	u8 erp_info;
271 } __packed;
272 
273 struct rate_set16_t {
274 	u8 size;
275 	u8 body[16];
276 	u8 rate_pad;
277 } __packed;
278 
279 struct ap_info_t {
280 	u8 bssid[6];	/* +00 */
281 	u8 rssi;	/* +06 */
282 	u8 sq;	/* +07 */
283 	u8 noise;	/* +08 */
284 	u8 pad0;	/* +09 */
285 	__le16 beacon_period;	/* +10 */
286 	__le16 capability;	/* +12 */
287 #define BSS_CAP_ESS             BIT(0)
288 #define BSS_CAP_IBSS            BIT(1)
289 #define BSS_CAP_CF_POLABLE      BIT(2)
290 #define BSS_CAP_CF_POLL_REQ     BIT(3)
291 #define BSS_CAP_PRIVACY         BIT(4)
292 #define BSS_CAP_SHORT_PREAMBLE  BIT(5)
293 #define BSS_CAP_PBCC            BIT(6)
294 #define BSS_CAP_CHANNEL_AGILITY BIT(7)
295 #define BSS_CAP_SHORT_SLOT_TIME BIT(10)
296 #define BSS_CAP_DSSS_OFDM       BIT(13)
297 	u8 frame_type;	/* +14 */
298 	u8 ch_info;	/* +15 */
299 #define FRAME_TYPE_BEACON	0x80
300 #define FRAME_TYPE_PROBE_RESP	0x50
301 	__le16 body_size;	/* +16 */
302 	u8 body[1024];	/* +18 */
303 	/* +1032 */
304 } __packed;
305 
306 struct link_ap_info_t {
307 	u8 bssid[6];	/* +00 */
308 	u8 rssi;	/* +06 */
309 	u8 sq;	/* +07 */
310 	u8 noise;	/* +08 */
311 	u8 pad0;	/* +09 */
312 	__le16 beacon_period;	/* +10 */
313 	__le16 capability;	/* +12 */
314 	struct rate_set8_t rate_set;	/* +14 */
315 	struct fh_parms_t fh_parameter;	/* +24 */
316 	struct ds_parms_t ds_parameter;	/* +29 */
317 	struct cf_parms_t cf_parameter;	/* +30 */
318 	struct ibss_parms_t ibss_parameter;	/* +36 */
319 	struct erp_params_t erp_parameter;	/* +38 */
320 	u8 pad1;	/* +39 */
321 	struct rate_set8_t ext_rate_set;	/* +40 */
322 	u8 DTIM_period;	/* +50 */
323 	u8 rsn_mode;	/* +51 */
324 #define RSN_MODE_NONE	0
325 #define RSN_MODE_WPA	1
326 #define RSN_MODE_WPA2	2
327 	struct {
328 		u8 size;	/* +52 */
329 		u8 body[128];	/* +53 */
330 	} __packed rsn;
331 } __packed;
332 
333 struct hostif_connect_indication_t {
334 	struct hostif_hdr header;
335 	__le16 connect_code;
336 #define RESULT_CONNECT    0
337 #define RESULT_DISCONNECT 1
338 	struct link_ap_info_t link_ap_info;
339 } __packed;
340 
341 struct hostif_stop_request_t {
342 	struct hostif_hdr header;
343 } __packed;
344 
345 struct hostif_stop_confirm_t {
346 	struct hostif_hdr header;
347 	__le16 result_code;
348 } __packed;
349 
350 /**
351  * struct hostif_ps_adhoc_set_request_t - pseudo adhoc mode
352  * @capability: bit5  : preamble
353  *              bit6  : pbcc - Not supported always 0
354  *              bit10 : ShortSlotTime
355  *              bit13 : DSSS-OFDM - Not supported always 0
356  */
357 struct hostif_ps_adhoc_set_request_t {
358 	struct hostif_hdr header;
359 	__le16 phy_type;
360 #define D_11B_ONLY_MODE		0
361 #define D_11G_ONLY_MODE		1
362 #define D_11BG_COMPATIBLE_MODE	2
363 #define D_11A_ONLY_MODE		3
364 	__le16 cts_mode;
365 #define CTS_MODE_FALSE	0
366 #define CTS_MODE_TRUE	1
367 	__le16 channel;
368 	struct rate_set16_t rate_set;
369 	__le16 capability;
370 	__le16 scan_type;
371 } __packed;
372 
373 struct hostif_ps_adhoc_set_confirm_t {
374 	struct hostif_hdr header;
375 	__le16 result_code;
376 } __packed;
377 
378 /**
379  * struct hostif_infrastructure_set_request_t
380  * @capability: bit5  : preamble
381  *              bit6  : pbcc - Not supported always 0
382  *              bit10 : ShortSlotTime
383  *              bit13 : DSSS-OFDM - Not supported always 0
384  */
385 struct hostif_infrastructure_set_request_t {
386 	struct hostif_hdr header;
387 	__le16 phy_type;
388 	__le16 cts_mode;
389 	struct rate_set16_t rate_set;
390 	struct ssid_t ssid;
391 	__le16 capability;
392 	__le16 beacon_lost_count;
393 	__le16 auth_type;
394 #define AUTH_TYPE_OPEN_SYSTEM 0
395 #define AUTH_TYPE_SHARED_KEY  1
396 	struct channel_list_t channel_list;
397 	__le16 scan_type;
398 } __packed;
399 
400 /**
401  * struct hostif_infrastructure_set2_request_t
402  * @capability: bit5  : preamble
403  *              bit6  : pbcc - Not supported always 0
404  *              bit10 : ShortSlotTime
405  *              bit13 : DSSS-OFDM - Not supported always 0
406  */
407 struct hostif_infrastructure_set2_request_t {
408 	struct hostif_hdr header;
409 	__le16 phy_type;
410 	__le16 cts_mode;
411 	struct rate_set16_t rate_set;
412 	struct ssid_t ssid;
413 	__le16 capability;
414 	__le16 beacon_lost_count;
415 	__le16 auth_type;
416 #define AUTH_TYPE_OPEN_SYSTEM 0
417 #define AUTH_TYPE_SHARED_KEY  1
418 	struct channel_list_t channel_list;
419 	__le16 scan_type;
420 	u8 bssid[ETH_ALEN];
421 } __packed;
422 
423 struct hostif_infrastructure_set_confirm_t {
424 	struct hostif_hdr header;
425 	__le16 result_code;
426 } __packed;
427 
428 /**
429  * struct hostif_adhoc_set_request_t
430  * @capability: bit5  : preamble
431  *              bit6  : pbcc - Not supported always 0
432  *              bit10 : ShortSlotTime
433  *              bit13 : DSSS-OFDM - Not supported always 0
434  */
435 struct hostif_adhoc_set_request_t {
436 	struct hostif_hdr header;
437 	__le16 phy_type;
438 	__le16 cts_mode;
439 	__le16 channel;
440 	struct rate_set16_t rate_set;
441 	struct ssid_t ssid;
442 	__le16 capability;
443 	__le16 scan_type;
444 } __packed;
445 
446 /**
447  * struct hostif_adhoc_set2_request_t
448  * @capability: bit5  : preamble
449  *              bit6  : pbcc - Not supported always 0
450  *              bit10 : ShortSlotTime
451  *              bit13 : DSSS-OFDM - Not supported always 0
452  */
453 struct hostif_adhoc_set2_request_t {
454 	struct hostif_hdr header;
455 	__le16 phy_type;
456 	__le16 cts_mode;
457 	__le16 reserved;
458 	struct rate_set16_t rate_set;
459 	struct ssid_t ssid;
460 	__le16 capability;
461 	__le16 scan_type;
462 	struct channel_list_t channel_list;
463 	u8 bssid[ETH_ALEN];
464 } __packed;
465 
466 struct hostif_adhoc_set_confirm_t {
467 	struct hostif_hdr header;
468 	__le16 result_code;
469 } __packed;
470 
471 struct last_associate_t {
472 	u8 type;
473 	u8 status;
474 } __packed;
475 
476 struct association_request_t {
477 	u8 type;
478 #define FRAME_TYPE_ASSOC_REQ	0x00
479 #define FRAME_TYPE_REASSOC_REQ	0x20
480 	u8 pad;
481 	__le16 capability;
482 	__le16 listen_interval;
483 	u8 ap_address[6];
484 	__le16 req_ies_size;
485 } __packed;
486 
487 struct association_response_t {
488 	u8 type;
489 #define FRAME_TYPE_ASSOC_RESP	0x10
490 #define FRAME_TYPE_REASSOC_RESP	0x30
491 	u8 pad;
492 	__le16 capability;
493 	__le16 status;
494 	__le16 association_id;
495 	__le16 resp_ies_size;
496 } __packed;
497 
498 struct hostif_associate_indication_t {
499 	struct hostif_hdr header;
500 	struct association_request_t assoc_req;
501 	struct association_response_t assoc_resp;
502 	/* followed by (req_ies_size + resp_ies_size) octets of data */
503 	/* reqIEs data *//* respIEs data */
504 } __packed;
505 
506 struct hostif_bss_scan_request_t {
507 	struct hostif_hdr header;
508 	u8 scan_type;
509 #define ACTIVE_SCAN  0
510 #define PASSIVE_SCAN 1
511 	u8 pad[3];
512 	__le32 ch_time_min;
513 	__le32 ch_time_max;
514 	struct channel_list_t channel_list;
515 	struct ssid_t ssid;
516 } __packed;
517 
518 struct hostif_bss_scan_confirm_t {
519 	struct hostif_hdr header;
520 	__le16 result_code;
521 	__le16 reserved;
522 } __packed;
523 
524 struct hostif_phy_information_request_t {
525 	struct hostif_hdr header;
526 	__le16 type;
527 #define NORMAL_TYPE	0
528 #define TIME_TYPE	1
529 	__le16 time;	/* unit 100ms */
530 } __packed;
531 
532 struct hostif_phy_information_confirm_t {
533 	struct hostif_hdr header;
534 	u8 rssi;
535 	u8 sq;
536 	u8 noise;
537 	u8 link_speed;
538 	__le32 tx_frame;
539 	__le32 rx_frame;
540 	__le32 tx_error;
541 	__le32 rx_error;
542 } __packed;
543 
544 enum sleep_mode_type {
545 	SLP_ACTIVE,
546 	SLP_SLEEP
547 };
548 
549 struct hostif_sleep_request_t {
550 	struct hostif_hdr header;
551 } __packed;
552 
553 struct hostif_sleep_confirm_t {
554 	struct hostif_hdr header;
555 	__le16 result_code;
556 } __packed;
557 
558 struct hostif_mic_failure_request_t {
559 	struct hostif_hdr header;
560 	__le16 failure_count;
561 	__le16 timer;
562 } __packed;
563 
564 struct hostif_mic_failure_confirm_t {
565 	struct hostif_hdr header;
566 	__le16 result_code;
567 } __packed;
568 
569 #define BASIC_RATE	0x80
570 #define RATE_MASK	0x7F
571 
572 #define TX_RATE_AUTO      0xff
573 #define TX_RATE_1M_FIXED  0
574 #define TX_RATE_2M_FIXED  1
575 #define TX_RATE_1_2M_AUTO 2
576 #define TX_RATE_5M_FIXED  3
577 #define TX_RATE_11M_FIXED 4
578 
579 #define TX_RATE_FULL_AUTO	0
580 #define TX_RATE_11_AUTO		1
581 #define TX_RATE_11B_AUTO	2
582 #define TX_RATE_11BG_AUTO	3
583 #define TX_RATE_MANUAL_AUTO	4
584 #define TX_RATE_FIXED		5
585 
586 /* 11b rate */
587 #define TX_RATE_1M	(uint8_t)(10 / 5)	/* 11b 11g basic rate */
588 #define TX_RATE_2M	(uint8_t)(20 / 5)	/* 11b 11g basic rate */
589 #define TX_RATE_5M	(uint8_t)(55 / 5)	/* 11g basic rate */
590 #define TX_RATE_11M	(uint8_t)(110 / 5)	/* 11g basic rate */
591 
592 /* 11g rate */
593 #define TX_RATE_6M	(uint8_t)(60 / 5)	/* 11g basic rate */
594 #define TX_RATE_12M	(uint8_t)(120 / 5)	/* 11g basic rate */
595 #define TX_RATE_24M	(uint8_t)(240 / 5)	/* 11g basic rate */
596 #define TX_RATE_9M	(uint8_t)(90 / 5)
597 #define TX_RATE_18M	(uint8_t)(180 / 5)
598 #define TX_RATE_36M	(uint8_t)(360 / 5)
599 #define TX_RATE_48M	(uint8_t)(480 / 5)
600 #define TX_RATE_54M	(uint8_t)(540 / 5)
601 
602 #define IS_11B_RATE(A) (((A & RATE_MASK) == TX_RATE_1M) || ((A & RATE_MASK) == TX_RATE_2M) || \
603 			((A & RATE_MASK) == TX_RATE_5M) || ((A & RATE_MASK) == TX_RATE_11M))
604 
605 #define IS_OFDM_RATE(A) (((A & RATE_MASK) == TX_RATE_6M) || ((A & RATE_MASK) == TX_RATE_12M) || \
606 			 ((A & RATE_MASK) == TX_RATE_24M) || ((A & RATE_MASK) == TX_RATE_9M) || \
607 			 ((A & RATE_MASK) == TX_RATE_18M) || ((A & RATE_MASK) == TX_RATE_36M) || \
608 			 ((A & RATE_MASK) == TX_RATE_48M) || ((A & RATE_MASK) == TX_RATE_54M))
609 
610 #define IS_11BG_RATE(A) (IS_11B_RATE(A) || IS_OFDM_RATE(A))
611 
612 #define IS_OFDM_EXT_RATE(A) (((A & RATE_MASK) == TX_RATE_9M) || ((A & RATE_MASK) == TX_RATE_18M) || \
613 			     ((A & RATE_MASK) == TX_RATE_36M) || ((A & RATE_MASK) == TX_RATE_48M) || \
614 			     ((A & RATE_MASK) == TX_RATE_54M))
615 
616 enum connect_status_type {
617 	CONNECT_STATUS,
618 	DISCONNECT_STATUS
619 };
620 
621 enum preamble_type {
622 	LONG_PREAMBLE,
623 	SHORT_PREAMBLE
624 };
625 
626 enum multicast_filter_type {
627 	MCAST_FILTER_MCAST,
628 	MCAST_FILTER_MCASTALL,
629 	MCAST_FILTER_PROMISC,
630 };
631 
632 #define NIC_MAX_MCAST_LIST 32
633 
634 /* macro function */
635 #define HIF_EVENT_MASK 0xE800
636 #define IS_HIF_IND(_EVENT)  ((_EVENT & HIF_EVENT_MASK) == 0xE800  && \
637 			     ((_EVENT & ~HIF_EVENT_MASK) == 0x0001 || \
638 			     (_EVENT & ~HIF_EVENT_MASK) == 0x0006 || \
639 			     (_EVENT & ~HIF_EVENT_MASK) == 0x000C || \
640 			     (_EVENT & ~HIF_EVENT_MASK) == 0x0011 || \
641 			     (_EVENT & ~HIF_EVENT_MASK) == 0x0012))
642 
643 #define IS_HIF_CONF(_EVENT) ((_EVENT & HIF_EVENT_MASK) == 0xE800  && \
644 			     (_EVENT & ~HIF_EVENT_MASK) > 0x0000  && \
645 			     (_EVENT & ~HIF_EVENT_MASK) < 0x0012  && \
646 			     !IS_HIF_IND(_EVENT))
647 
648 #ifdef __KERNEL__
649 
650 #include "ks_wlan.h"
651 
652 /* function prototype */
653 int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb);
654 void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
655 		    unsigned int size);
656 void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event);
657 int hostif_init(struct ks_wlan_private *priv);
658 void hostif_exit(struct ks_wlan_private *priv);
659 int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
660 		  void (*complete_handler)(struct ks_wlan_private *priv,
661 					   struct sk_buff *skb),
662 		  struct sk_buff *skb);
663 void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb);
664 
665 void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv);
666 int ks_wlan_hw_power_save(struct ks_wlan_private *priv);
667 
668 static
669 inline int hif_align_size(int size)
670 {
671 #ifdef	KS_ATOM
672 	if (size < 1024)
673 		size = 1024;
674 #endif
675 #ifdef	DEVICE_ALIGNMENT
676 	return (size % DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT -
677 	    (size % DEVICE_ALIGNMENT) : size;
678 #else
679 	return size;
680 #endif
681 }
682 
683 #endif /* __KERNEL__ */
684 
685 #endif /* _KS_HOSTIF_H_ */
686