9 #define FPRINT(string) printk(KERN_DEBUG "%s\n", string)
10 #define FPRINT_V(string, i) printk(KERN_DEBUG "%s = %x\n", string, i)
12 #define FPRINT(string)
13 #define FPRINT_V(string, i)
14 #define VerAssert(x) printk("Maybe Unsupport mode in %s(%d)",__FILE__,__LINE__);
15 #define LongPrint(x,y) {int i;for(i=0;i<100*y;i++) printk("%s",x);}
19 //#define ZD_DEBUG //debug protocol stack
22 #define ZDEBUG(string) FPRINT(string)
23 #define ZDEBUG_V(string, i) FPRINT_V(string, i)
25 #define ZDEBUG(string) //do {} while (0)
26 #define ZDEBUG_V(string, i) //do {} while (0)
29 //#define PS_DEBUG //debug power save function
33 #define PSDEBUG(string) FPRINT(string)
34 #define PSDEBUG_V(string, i) FPRINT_V(string, i)
36 #define PSDEBUG(string) //do {} while (0)
37 #define PSDEBUG_V(string, i) //do {} while (0)
41 //#define HASH_DEBUG //debug hash function
44 #define HSDEBUG(string) FPRINT(string)
45 #define HSDEBUG_V(string, i) FPRINT_V(string, i)
47 #define HSDEBUG(string) //do {} while (0)
48 #define HSDEBUG_V(string, i) //do {} while (0)
51 //#define RATE_DEBUG //debug rate adaption function
54 #define RATEDEBUG(string) FPRINT(string)
55 #define RATEDEBUG_V(string, i) FPRINT_V(string, i)
57 #define RATEDEBUG(string) //do {} while (0)
58 #define RATEDEBUG_V(string, i) //do {} while (0)
62 //#define DEFRAG_DEBUG //debug defrag function
65 #define DFDEBUG(string) FPRINT(string)
66 #define DFDEBUG_V(string, i) FPRINT_V(string, i)
68 #define DFDEBUG(string) //do {} while (0)
69 #define DFDEBUG_V(string, i) //do {} while (0)
73 #ifdef ZDCONF_PORTING_BIGENDIAN
74 #define zd_cpu_to_le32(x) (((x & 0xff000000) >> 24) | \
75 ((x & 0x00ff0000) >> 8) | \
76 ((x & 0x0000ff00) << 8) | \
77 ((x & 0x000000ff) << 24))
79 #define zd_le32_to_cpu(x) (((x & 0xff000000) >> 24) | \
80 ((x & 0x00ff0000) >> 8) | \
81 ((x & 0x0000ff00) << 8) | \
82 ((x & 0x000000ff) << 24))
83 #define zd_le16_to_cpu(x) le16_to_cpu(x)
84 #define zd_cpu_to_le16(x) cpu_to_le16(x)
85 #else //host is little endian
86 #define zd_cpu_to_le32(x) (x)
87 #define zd_le32_to_cpu(x) (x)
88 #define zd_cpu_to_le16(x) (x)
89 #define zd_le16_to_cpu(x) (x)
92 #define CMD_RESET_80211 0x0001 //parm1: zd_80211Obj_t *
93 #define CMD_ENABLE 0x0002 //parm1: None
94 #define CMD_DISASOC 0x0003 //parm1: U8 *MacAddress, parm2: reasonCode
95 #define CMD_DEAUTH 0x0004 //parm1: U8 *MacAddress, parm2: reasonCode
96 #define CMD_PS_POLL 0x0005 //parm1: U8 *MacHeader
97 #define CMD_PASSIVE_SCAN 0x0006 //parm1: None
98 #define CMD_DISASOC_ALL 0x0007 //parm1: U8 *MacAddress, parm2: reasonCode
99 #define CMD_CONNECT 0x0008 //parm1: None, parm2: BssIndex
100 #define CMD_PROBE_REQ 0x0009 //parm1: None, parm2: WithSSID
101 #define CMD_DIS_CONNECT 0x000A
102 #define CMD_FLUSH_QUEUE 0x000B
103 #define CMD_ROAMING 0x000C
108 #define EVENT_TBCN 0x0010
109 #define EVENT_DTIM_NOTIFY 0x0011
110 #define EVENT_TX_COMPLETE 0x0012 //parm1: tx status, parm2: msgId, parm3: aid
111 #define EVENT_TCHAL_TIMEOUT 0x0013
112 #define EVENT_SCAN_TIMEOUT 0x0014
113 #define EVENT_UPDATE_TX_RATE 0x0015 //parm1: rate, parm2: aid
114 #define EVENT_SW_RESET 0x0016
115 #define EVENT_BUF_RELEASE 0x0017
116 #define EVENT_ENABLE_PROTECTION 0x0018
117 #define EVENT_AUTH_TIMEOUT 0x0019
118 #define EVENT_ASOC_TIMEOUT 0x001A
119 #define EVENT_PS_CHANGE 0x001B //parm1: PwrState
120 #define EVENT_MORE_DATA 0x001C
121 #define EVENT_ENABLE_BARKER 0x001D
122 #define EVENT_SHORT_SLOT 0x001E
125 #define DO_CHAL 0x0001
126 #define DO_SCAN 0x0002
127 #define DO_AUTH 0x0003
128 #define DO_ASOC 0x0004
130 #define SCAN_TIMEOUT 100 //ms
131 #define HOUSE_KEEPING_PERIOD 100 //ms
132 #define AUTH_TIMEOUT 512 //3000 //ms
133 #define ASOC_TIMEOUT 512 //2000 //ms
137 #define ZD_UNSPEC_REASON 1
138 #define ZD_AUTH_NOT_VALID 2
139 #define ZD_DEAUTH_LEAVE_BSS 3
141 #define ZD_INACTIVITY 4
142 #define ZD_AP_OVERLOAD 5
143 #define ZD_CLASS2_ERROR 6
144 #define ZD_CLASS3_ERROR 7
145 #define ZD_DISAS_LEAVE_CSS 8
146 #define ZD_ASOC_NOT_AUTH 9
147 #define ZD_INVALID_IE 13
148 #define ZD_MIC_FAIL 14
149 #define ZD_4WAY_SHAKE_TIMEOUT 15
150 #define ZD_GKEY_UPDATE_TIMEOUT 16
151 #define ZD_IE_IMCOMPABILITY 17
152 #define ZD_MC_CIPHER_INVALID 18
153 #define ZD_UNI_CIPHER_INVALID 19
154 #define ZD_AKMP_INVALID 20
155 #define ZD_UNSUP_RSNE_VERSION 21
156 #define ZD_INVALID_RSNE_CAP 22
157 #define ZD_8021X_AUTH_FAIL 23
160 /* association_status_notify() <- status */
161 #define STA_ASOC_REQ 0x0001
162 #define STA_REASOC_REQ 0x0002
163 #define STA_ASSOCIATED 0x0003
164 #define STA_REASSOCIATED 0x0004
165 #define STA_DISASSOCIATED 0x0005
166 #define STA_AUTH_REQ 0x0006
167 #define STA_DEAUTHED 0x0007
170 #define ZD_TX_CONFIRM 0x0001
171 #define ZD_RETRY_FAILED 0x0002
175 #define DYN_KEY_WEP64 1
176 #define DYN_KEY_WEP128 2
177 #define DYN_KEY_TKIP 4
178 #define DYN_KEY_AES 5
199 #define RATE_12M 0x06
200 #define RATE_18M 0x07
201 #define RATE_24M 0x08
202 #define RATE_36M 0x09
203 #define RATE_48M 0x0a
204 #define RATE_54M 0x0b
216 #define NUM_SUPPORTED_RATE 32
218 // pfrmDesc->ConfigSet
219 #define INTRA_BSS_SET 0x01
220 #define EAPOL_FRAME_SET 0x02
221 #define FORCE_WEP_SET 0x04
224 #define INDEPENDENT_BSS 0x0
225 #define INFRASTRUCTURE_BSS 0x1
226 #define PSEUDO_IBSS 0x3
230 #define AP_RX_FILTER 0x0400feff
231 #define STA_RX_FILTER 0x0000ffff
234 #define MIXED_MODE 0x01
235 #define PURE_G_MODE 0x02
236 #define PURE_B_MODE 0x03
237 #define PURE_A_MODE 0x04
241 #define CW_SHORT_SLOT 0x7f043f
242 #define CW_NORMAL_SLOT 0xff043f
243 #define CW_LONG_SLOT 0x7f047f
248 #define RISE_CONDITION_THRESHOLD 5
249 #define DOWN_CONDITION_THRESHOLD 3
256 #define CAM_VAP_START_AID 33
257 #define CAM_VAP_END_AID 39
260 #define HW_MIC_FINISH 0x55555555
261 #define CAM_ADDR_NOT_MATCH 40
269 enum Operation_Mode
{
279 typedef struct card_Setting_s
281 U8 EncryOnOff
; //0: encryption off, 1: encryption on
282 U8 OperationMode
; //0: IBSS, 1: AP, 2: STA, 3: WDS, 4: AP Client, 5: Virtual AP
283 U8 PreambleType
; //0: long preamble, 1: short preamble
284 U8 TxRate
; //0: 1M, 1: 2M, 2: 5.5M, 3: 11M, 4: 16.5M
285 U8 FixedRate
; // fixed Tx Rate
287 U8 AuthMode
; //0: open system only, 1: shared key only, 2: auto
288 U8 HiddenSSID
; //0: disable, 1:enable
289 U8 LimitedUser
; //limited client number max to 32 user
290 U8 RadioOn
; //0: radio off, 1: radio on
291 U8 BlockBSS
; //0: don't block intra-bss traffic, 1: block
292 U8 TxPowerLevel
; //0: 17dbm, 1: 14dbm, 2: 11dbm
294 U8 EncryMode
; //0: no wep, 2: wep63, 3:wep128
295 U8 EncryKeyId
; //encryption key id
296 U8 BcKeyId
; //broadcast key id for dynamic key
298 U8 WepKeyLen
; //WEP key length
299 U8 BcKeyLen
; //Broadcast key length
300 U8 DynKeyMode
; //Dynamic key mode, 1: WEP64, 2: WEP128, 4:TKIP
301 U16 Channel
; //channel number
302 U16 FragThreshold
; //fragment threshold, from 256~2432
303 U16 RTSThreshold
; //RTS threshold, from 256~2432
305 U16 BeaconInterval
; //default 100 ms
306 U16 DtimPeriod
; //default 1
308 // ElementID(1), Len(1), SSID
309 U8 Info_SSID
[36]; //include element ID, element Length, and element content
310 // ElementID(1), Len(1), SupportedRates(1-8)
311 U8 Info_SupportedRates
[NUM_SUPPORTED_RATE
]; //include element ID, element Length, and element content
323 U8 Ext_SupportedRates
[NUM_SUPPORTED_RATE
];
340 #define ZD_MAX_FRAG_NUM 8
342 typedef struct fragInfo_s
{
343 U8
*macHdr
[ZD_MAX_FRAG_NUM
];
344 U8
*macBody
[ZD_MAX_FRAG_NUM
];
345 U32 bodyLen
[ZD_MAX_FRAG_NUM
];
346 U32 nextBodyLen
[ZD_MAX_FRAG_NUM
];
347 #if ZDCONF_LP_SUPPORT == 1
360 U8 CalSwMic
[MIC_LNG
+1];
372 typedef struct rxInfo_s
{
382 typedef struct bss_info_s
{
388 U8 supRates
[NUM_SUPPORTED_RATE
];
389 U8 extRates
[NUM_SUPPORTED_RATE
];
390 #if ZDCONF_LP_SUPPORT == 1
391 U8 zdIE_Info_BURST
[16];
392 U8 zdIE_Info_AMSDU
[16];
394 #if ZDCONF_SES_SUPPORT == 1
395 BOOLEAN SES_Element_Valid
;
408 //for pdot11Obj->QueueFlag
409 #define TX_QUEUE_SET 0x01
410 #define MGT_QUEUE_SET 0x02
411 #define AWAKE_QUEUE_SET 0x04
415 #define CONNECT_TOUT_SET 0x0001
416 #define DIS_CONNECT_SET 0x0002
417 #define BSS_CONNECT_SET 0x0004
418 #define CHANNEL_SCAN_SET 0x0008
419 #define PS_CHANGE_SET 0x0010
420 #define PS_POLL_SET 0x0020
421 #define IBSS_CONNECT_SET 0x0040
422 #define ROAMING_SET 0x0080
425 //for pdot11Obj->ConfigFlag
426 #define ENABLE_PROTECTION_SET 0x0001
427 #define BARKER_PREAMBLE_SET 0x0002
428 #define SHORT_SLOT_TIME_SET 0x0004
429 #define NON_ERP_PRESENT_SET 0x0008
430 #define PASSIVE_CHANNEL_SCAN_SET 0x0010
431 #define ACTIVE_CHANNEL_SCAN_SET 0x0020
432 #define IBSS_CHANNEL_SCAN_SET 0x0040
433 #define SCAN_AND_CONNECT_SET 0x0080
434 #define JUST_CHANNEL_SCAN 0x1000
437 #define FBM_ANTTENA_DIVERSITY 0x00000001
438 #define FBM_802_11D 0x00000002
439 #define FBM_27_5_MBPS 0x00000004
440 #define FBM_SINGLE_LED 0x00000008
442 // Define debug command
443 #define DBG_CMD_BEACON 0x0001
445 //driver to provide callback functions for 802.11 protocol stack
446 typedef struct zd_80211Obj_s
449 U8 QueueFlag
; //Output
450 U16 ConfigFlag
; //Output
455 U8 bOverWritePhyRegFromE2P
;
477 BOOLEAN UW2453ChannelSelectAntennaAUX
[14];
478 U32 UW2453SelectAntennaAUX
;
479 BOOLEAN UW2453NoTXfollowRX
;
480 U32 UW2453RFTableIndex
;
481 U32 UWDefaultAntenna
;
482 BOOLEAN UW2453MiniCard
;
483 #if ZDCONF_LP_SUPPORT == 1
493 BOOLEAN UWPowerControlFlag
;
494 BOOLEAN PHYNEWLayout
;
495 BOOLEAN PHY_Decrease_CR128_state
;
498 void (* ReleaseBuffer
)(void *buf
); // release rx buffer
499 void (* StartTimer
)(U32 timeout
, U32 event
); // start a chanllege timer (shared key authentication)
500 void (* StopTimer
)(U32 TimerId
); // stop the challenge timer
501 void (* RxInd
)(U8
*pData
, U32 length
, void *buf
, U32 LP_MAP
); // rx indication
502 void (* TxCompleted
)(void); // tx completed
503 BOOLEAN (* SetupNextSend
)(fragInfo_t
*pFragInfo
); // send to HMAC
504 void (* SetReg
)(void *reg
, U32 offset
, U32 value
); // set HMAC register
505 U32 (* GetReg
)(void *reg
, U32 offset
); // get HMAC register
506 U16 (* StatusNotify
)(U16 status
, U8
*StaAddr
); // association notify for bridge management
507 void (* ExitCS
)(U32 flags
); // enable interrupt
508 U32 (* EnterCS
)(void); // disable interrupt
509 U32 (* Vir2PhyAddr
)(U32 virtAddr
); // translate virtual address to physical address
510 BOOLEAN (* CheckTCBAvail
)(U8 NumOfFrag
); // check TCB available
511 //void (* DelayUs)(U16 ustime);//fixed by johnson
512 void (* DelayUs
)(U32 ustime
);
514 void * (* AllocBuffer
)(U16 dataSize
, U8
**pData
); // allocate wireless forwarding buffer
516 int (* Rand
)(U32 seed
);
517 void (* AcquireDoNotSleep
)(void);
518 void (* ReleaseDoNotSleep
)(void);
521 void (* MicFailure
)(unsigned char *addr
);
522 int (* AssocRequest
)(U8
*addr
, U8
* data
, U16 size
);
523 int (* WpaIe
)(U8
*buffer
, int length
);
527 //802.11 export functions for driver use
528 extern void zd_SigProcess(void); // protocol statck entry point
529 extern BOOLEAN
zd_SendPkt(U8
*pEthHdr
, U8
*pBody
, U32 bodyLen
, void *buf
, U8 bEapol
, void *pHash
); // tx request
530 extern void zd_ReceivePkt(U8
*pHdr
, U32 hdrLen
, U8
*pBody
, U32 bodyLen
, void *buf
, U8
*pEthHdr
, rxInfo_t
*pRxInfo
, BOOLEAN LP
); // rx indication
531 extern BOOLEAN
zd_CmdProcess(U16 CmdId
, void *parm1
, U32 parm2
); //command process
532 extern void zd_EventNotify(U16 EventId
, U32 parm1
, U32 parm2
, U32 parm3
); //event notify
533 extern void zd_UpdateCardSetting(card_Setting_t
*pSetting
);
534 extern BOOLEAN
zd_CleanupTxQ(void);
535 extern BOOLEAN
zd_CleanupAwakeQ(void);
536 extern int zd_SetKeyInfo(U8
*addr
, U8 encryMode
, U8 keyLength
, U8 KeyId
, U8
*pKeyContent
);
537 extern void zd_PerSecTimer(void);
538 extern BOOLEAN
zd_CheckIvSeq(U8 aid
, U16 iv16
, U32 iv32
);
539 extern void zd_RateMoniter(void);
540 extern BOOLEAN
zd_QueryStaTable(U8
*sta
, void **ppHash
);
541 extern void zd_ConnectMon(void);
542 extern U8
zd_GetBssList(bss_info_t
*pBssList
);
543 extern U16
zd_AidLookUp(U8
*addr
);
544 extern void zd_makeRateInfoMAP(U8
*pRates
, U16
*basicRateMap
, U16
*supRateMap
);
545 extern void zd_UpdateIbssInfo(U8
*addr
, U8 maxRate
, U8 preamble
, U8 erpSta
);