60b7d1c56deeefad85280e81a5f127923b506871
[safe/jmp/linux-2.6] / drivers / staging / otus / 80211core / pub_zfi.h
1 /*
2  * Copyright (c) 2007-2008 Atheros Communications Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef _PUB_DEFS_H
18 #define _PUB_DEFS_H
19
20 #include "../oal_dt.h"
21
22 /***** Section 1 : Tunable Parameters *****/
23 /* The definitions in this section are tunabel parameters */
24
25 /* Maximum number of BSS that could be scaned */
26 #define ZM_MAX_BSS                          128
27
28 /* Maximum number of WPA2 PMKID that supported */
29 #define ZM_PMKID_MAX_BSS_CNT               8
30
31 /* Enable aggregation and deaggregation */
32 #define ZM_ENABLE_AGGREGATION
33
34 #ifdef ZM_ENABLE_AGGREGATION
35     /* Enable BA failed retransmission in firmware */
36     #define ZM_ENABLE_FW_BA_RETRANSMISSION
37     #define ZM_BYPASS_AGGR_SCHEDULING
38     //#define ZM_AGGR_BIT_ON
39 #endif
40
41
42 #ifndef ZM_FB50
43 //#define ZM_FB50
44 #endif
45
46 #ifndef ZM_AP_DEBUG
47 //#define ZM_AP_DEBUG
48 #endif
49
50 //#define ZM_ENABLE_BA_RATECTRL
51
52 /***** End of section 1 *****/
53
54
55 /***** Section 2 : Public Definitions, data structures and prototypes *****/
56 /* function return status */
57 #define ZM_STATUS_SUCCESS                   0
58 #define ZM_STATUS_FAILURE                   1
59
60 // media connect status
61 #define ZM_STATUS_MEDIA_CONNECT             0x00
62 #define ZM_STATUS_MEDIA_DISCONNECT          0x01
63 #define ZM_STATUS_MEDIA_DISCONNECT_NOT_FOUND    0x02
64 #define ZM_STATUS_MEDIA_DISABLED            0x03
65 #define ZM_STATUS_MEDIA_CONNECTION_DISABLED 0x04
66 #define ZM_STATUS_MEDIA_CONNECTION_RESET    0x05
67 #define ZM_STATUS_MEDIA_RESET               0x06
68 #define ZM_STATUS_MEDIA_DISCONNECT_DEAUTH   0x07
69 #define ZM_STATUS_MEDIA_DISCONNECT_DISASOC  0x08
70 #define ZM_STATUS_MEDIA_DISCONNECT_TIMEOUT  0x09
71 #define ZM_STATUS_MEDIA_DISCONNECT_AUTH_FAILED  0x0a
72 #define ZM_STATUS_MEDIA_DISCONNECT_ASOC_FAILED  0x0b
73 #define ZM_STATUS_MEDIA_DISCONNECT_MIC_FAIL   0x0c
74 #define ZM_STATUS_MEDIA_DISCONNECT_UNREACHABLE 0x0d
75 #define ZM_STATUS_MEDIA_DISCONNECT_BEACON_MISS  0x0e
76
77 // Packet Filter
78 #define ZM_PACKET_TYPE_DIRECTED             0x00000001
79 #define ZM_PACKET_TYPE_MULTICAST            0x00000002
80 #define ZM_PACKET_TYPE_ALL_MULTICAST        0x00000004
81 #define ZM_PACKET_TYPE_BROADCAST            0x00000008
82 #define ZM_PACKET_TYPE_PROMISCUOUS          0x00000020
83
84 /* BSS mode definition */
85 /* TODO : The definitions here are coupled with XP's NDIS OID. */
86 /*        We can't be changed them freely, need to disarm this mine */
87 #define ZM_MODE_IBSS                        0
88 #define ZM_MODE_INFRASTRUCTURE              1
89 #define ZM_MODE_UNKNOWN                     2
90 #define ZM_MODE_INFRASTRUCTURE_MAX          3
91 #define ZM_MODE_AP                          4
92 #define ZM_MODE_PSEUDO                      5
93
94
95 /* Authentication mode */
96 #define ZM_AUTH_MODE_OPEN                   0
97 #define ZM_AUTH_MODE_SHARED_KEY             1
98 #define ZM_AUTH_MODE_AUTO                   2
99 #define ZM_AUTH_MODE_WPA                    3
100 #define ZM_AUTH_MODE_WPAPSK                 4
101 #define ZM_AUTH_MODE_WPA_NONE               5
102 #define ZM_AUTH_MODE_WPA2                   6
103 #define ZM_AUTH_MODE_WPA2PSK                7
104 #ifdef ZM_ENABLE_CENC
105 #define ZM_AUTH_MODE_CENC                   8
106 #endif //ZM_ENABLE_CENC
107 #define ZM_AUTH_MODE_WPA_AUTO               9
108 #define ZM_AUTH_MODE_WPAPSK_AUTO            10
109
110 // Encryption mode
111 #define ZM_NO_WEP                           0x0
112 #define ZM_AES                              0x4
113 #define ZM_TKIP                             0x2
114 #define ZM_WEP64                            0x1
115 #define ZM_WEP128                           0x5
116 #define ZM_WEP256                           0x6
117 #ifdef ZM_ENABLE_CENC
118 #define ZM_CENC                             0x7
119 #endif //ZM_ENABLE_CENC
120
121 /* Encryption type for wep status */
122 #define ZM_ENCRYPTION_WEP_DISABLED          0
123 #define ZM_ENCRYPTION_WEP_ENABLED           1
124 #define ZM_ENCRYPTION_WEP_KEY_ABSENT        2
125 #define ZM_ENCRYPTION_NOT_SUPPORTED         3
126 #define ZM_ENCRYPTION_TKIP                  4
127 #define ZM_ENCRYPTION_TKIP_KEY_ABSENT       5
128 #define ZM_ENCRYPTION_AES                   6
129 #define ZM_ENCRYPTION_AES_KEY_ABSENT        7
130
131 #ifdef ZM_ENABLE_CENC
132 #define ZM_ENCRYPTION_CENC                  8
133 #endif //ZM_ENABLE_CENC
134
135 /* security type */
136 #define ZM_SECURITY_TYPE_NONE               0
137 #define ZM_SECURITY_TYPE_WEP                1
138 #define ZM_SECURITY_TYPE_WPA                2
139
140 #ifdef ZM_ENABLE_CENC
141 #define ZM_SECURITY_TYPE_CENC               3
142 #endif //ZM_ENABLE_CENC
143
144 /* Encryption Exemption Action Type  */
145 #define ZM_ENCRYPTION_EXEMPT_NO_EXEMPTION   0
146 #define ZM_ENCRYPTION_EXEMPT_ALWAYS         1
147
148 /* MIC failure */
149 #define ZM_MIC_PAIRWISE_ERROR               0x06
150 #define ZM_MIC_GROUP_ERROR                  0x0E
151
152
153 /* power save mode */
154 #define ZM_STA_PS_NONE                    0
155 #define ZM_STA_PS_MAX                     1
156 #define ZM_STA_PS_FAST                    2
157 #define ZM_STA_PS_LIGHT                   3
158
159 /* WME AC Type */
160 #define ZM_WME_AC_BK                        0       /* Background AC */
161 #define ZM_WME_AC_BE                        1       /* Best-effort AC */
162 #define ZM_WME_AC_VIDEO                     2       /* Video AC */
163 #define ZM_WME_AC_VOICE                     3       /* Voice AC */
164
165 /* Preamble type */
166 #define ZM_PREAMBLE_TYPE_AUTO               0
167 #define ZM_PREAMBLE_TYPE_LONG               1
168 #define ZM_PREAMBLE_TYPE_SHORT              2
169
170 /* wireless modes constants */
171 #define ZM_WIRELESS_MODE_5_54        0x01   ///< 5 GHz 54 Mbps
172 #define ZM_WIRELESS_MODE_5_108       0x02   ///< 5 GHz 108 Mbps
173 #define ZM_WIRELESS_MODE_24_11       0x04   ///< 2.4 GHz 11 Mbps
174 #define ZM_WIRELESS_MODE_24_54       0x08   ///< 2.4 GHz 54 Mbps
175 #define ZM_WIRELESS_MODE_24_108      0x10   ///< 2.4 GHz 108 Mbps
176 #define ZM_WIRELESS_MODE_49_13      0x100   ///< 4.9 GHz 13.5 Mbps, quarter rate chn-bandwidth = 5
177 #define ZM_WIRELESS_MODE_49_27      0x200   ///< 4.9 GHz 27 Mbps, half rate chn-bandwidth = 10
178 #define ZM_WIRELESS_MODE_49_54      0x400   ///< 4.9 GHz 54 Mbps, full rate chn-bandwidth = 20
179 #define ZM_WIRELESS_MODE_5_300     0x1000   ///< 5 GHz 300 Mbps
180 #define ZM_WIRELESS_MODE_24_300    0x2000   ///< 2.4 GHz 300 Mbps
181 #define ZM_WIRELESS_MODE_5_130     0x4000   ///< 5 GHz 130 Mbps
182 #define ZM_WIRELESS_MODE_24_130    0x8000   ///< 2.4 GHz 130 Mbps
183
184 #define ZM_WIRELESS_MODE_24_N      (ZM_WIRELESS_MODE_24_130|ZM_WIRELESS_MODE_24_300)
185 #define ZM_WIRELESS_MODE_5_N       (ZM_WIRELESS_MODE_5_130|ZM_WIRELESS_MODE_5_300)
186 #define ZM_WIRELESS_MODE_24        (ZM_WIRELESS_MODE_24_11|ZM_WIRELESS_MODE_24_54|ZM_WIRELESS_MODE_24_N)
187 #define ZM_WIRELESS_MODE_5         (ZM_WIRELESS_MODE_5_54|ZM_WIRELESS_MODE_5_N)
188
189 /* AdHoc Mode with different band */
190 #define ZM_ADHOCBAND_A         1
191 #define ZM_ADHOCBAND_B         2
192 #define ZM_ADHOCBAND_G         3
193 #define ZM_ADHOCBAND_BG        4
194 #define ZM_ADHOCBAND_ABG       5
195
196 /* Authentication algorithm in the field algNo of authentication frames */
197 #define ZM_AUTH_ALGO_OPEN_SYSTEM      0x10000    /* Open system */
198 #define ZM_AUTH_ALGO_SHARED_KEY       0x10001    /* Shared Key */
199 #define ZM_AUTH_ALGO_LEAP             0x10080    /* Leap */
200
201 struct zsScanResult
202 {
203     u32_t reserved;
204 };
205
206
207 struct zsStastics
208 {
209     u32_t reserved;
210 };
211
212 #define ZM_MAX_SUPP_RATES_IE_SIZE       12
213 #define ZM_MAX_IE_SIZE                  50 //100
214 #define ZM_MAX_WPS_IE_SIZE              150
215 #define ZM_MAX_PROBE_FRAME_BODY_SIZE    512//300
216 #define ZM_MAX_COUNTRY_INFO_SIZE                20
217
218 #define ZM_MAX_SSID_LENGTH          32
219 struct zsBssInfo
220 {
221     u8_t   macaddr[6];
222     u8_t   bssid[6];
223     u8_t   beaconInterval[2];
224     u8_t   capability[2];
225     u8_t   timeStamp[8];
226     u8_t   ssid[ZM_MAX_SSID_LENGTH + 2];   // EID(1) + Length(1) + SSID(32)
227     u8_t   supportedRates[ZM_MAX_SUPP_RATES_IE_SIZE + 2]; // EID(1) + Length(1) + supported rates [12]
228     u8_t   channel;
229     u16_t  frequency;
230     u16_t  atimWindow;
231     u8_t   erp;
232     u8_t   extSupportedRates[ZM_MAX_SUPP_RATES_IE_SIZE + 2]; // EID(1) + Length(1) + extended supported rates [12]
233     u8_t   wpaIe[ZM_MAX_IE_SIZE + 2];
234     u8_t   wscIe[ZM_MAX_WPS_IE_SIZE + 2];
235     u8_t   rsnIe[ZM_MAX_IE_SIZE + 2];
236 #ifdef ZM_ENABLE_CENC
237     u8_t   cencIe[ZM_MAX_IE_SIZE + 2]; /* CENC */ /* half size because of memory exceed 64k boundary */
238 #endif //ZM_ENABLE_CENC
239     u8_t   securityType;
240     u8_t   signalStrength;
241     u8_t   signalQuality;
242     u16_t  sortValue;
243     u8_t   wmeSupport;
244     u8_t   flag;
245     u8_t   EnableHT;
246     u8_t   enableHT40;
247     u8_t   SG40;
248     u8_t   extChOffset;
249     u8_t   apCap; // bit0:11N AP
250     u16_t  frameBodysize;
251     u8_t   frameBody[ZM_MAX_PROBE_FRAME_BODY_SIZE];
252     u8_t   countryInfo[ZM_MAX_COUNTRY_INFO_SIZE + 2];
253     u16_t  athOwlAp;
254     u16_t  marvelAp;
255     u16_t  broadcomHTAp;
256     u32_t  tick;
257     struct zsBssInfo* next;
258 };
259
260 struct zsBssList
261 {
262     u8_t bssCount;
263     struct zsBssInfo* head;
264     struct zsBssInfo* tail;
265 };
266
267 struct zsBssListV1
268 {
269     u8_t bssCount;
270     struct zsBssInfo bssInfo[ZM_MAX_BSS];
271 };
272
273 #define ZM_KEY_FLAG_GK                 0x0001
274 #define ZM_KEY_FLAG_PK                 0X0002
275 #define ZM_KEY_FLAG_AUTHENTICATOR      0x0004
276 #define ZM_KEY_FLAG_INIT_IV            0x0008
277 #define ZM_KEY_FLAG_DEFAULT_KEY        0x0010
278
279 #ifdef ZM_ENABLE_CENC
280 #define ZM_KEY_FLAG_CENC               0x0020
281 #endif //ZM_ENABLE_CENC
282
283 // Comment: For TKIP, key[0]~key[15]  => TKIP key
284 //                    key[16]~key[23] => Tx MIC key
285 //                    key[24]~key[31] => Rx MIC key
286 struct zsKeyInfo
287 {
288     u8_t*   key;
289     u8_t    keyLength;
290     u8_t    keyIndex;
291     u8_t*   initIv;
292     u16_t   flag;
293     u8_t    vapId;
294     u16_t    vapAddr[3];
295     u16_t*   macAddr;
296 };
297
298
299
300 /*
301  * Channels are specified by frequency.
302  */
303 typedef struct {
304         u16_t   channel;        /* setting in Mhz */
305         u32_t   channelFlags;   /* see below */
306         u8_t    privFlags;
307         s8_t    maxRegTxPower;  /* max regulatory tx power in dBm */
308         s8_t    maxTxPower;     /* max true tx power in 0.25 dBm */
309         s8_t    minTxPower;     /* min true tx power in 0.25 dBm */
310 } ZM_HAL_CHANNEL;
311
312 struct zsRegulationTable
313 {
314     u16_t   regionCode;
315     u16_t   CurChIndex;
316     u16_t   allowChannelCnt;
317     ZM_HAL_CHANNEL   allowChannel[60];   /* 2.4GHz: 14 channels, 5 GHz: 31 channels */
318 };
319
320 struct zsPartnerNotifyEvent
321 {
322     u8_t bssid[6];                      // The BSSID of IBSS
323     u8_t peerMacAddr[6];                // The MAC address of peer station
324 };
325
326 #define ZM_RC_TRAINED_BIT   0x1
327 struct zsRcCell
328 {
329     u32_t txCount;
330     u32_t failCount;
331     u8_t currentRate;
332     u8_t currentRateIndex;
333     u32_t probingTime;
334     u8_t operationRateSet[24];
335     u8_t operationRateCount;
336     u16_t rxRssi;
337     u8_t flag;
338     u32_t  lasttxCount;
339     u32_t  lastTime;
340 };
341
342 struct zsOppositeInfo
343 {
344     u8_t            macAddr[6];
345     struct zsRcCell rcCell;
346     u8_t            valid;              // This indicate if this opposite is still valid
347     u8_t            aliveCounter;
348     u8_t            pkInstalled;
349
350 #ifdef ZM_ENABLE_IBSS_WPA2PSK
351     /* For WPA2PSK ! */
352     u8_t                        wpaState;
353     u8_t            camIdx;
354     u8_t            encryMode;
355     u16_t           iv16;
356     u32_t           iv32;
357 #endif
358 };
359
360 typedef void (*zfpIBSSIteratePeerStationCb)(
361     zdev_t* dev, struct zsOppositeInfo *peerInfo, void *ctx, u8_t index);
362
363 typedef u16_t (*zfpStaRxSecurityCheckCb)(zdev_t* dev, zbuf_t* buf);
364
365
366 /* Communication Tally data structure */
367 struct zsCommTally
368 {
369     u32_t txUnicastFrm;             //  0 txUnicastFrames
370     u32_t txMulticastFrm;               //  1 txMulticastFrames
371     u32_t txUnicastOctets;          //  2 txUniOctets  byte size
372     u32_t txMulticastOctets;    //  3 txMultiOctets  byte size
373     u32_t txFrmUpperNDIS;       //  4
374     u32_t txFrmDrvMgt;          //  5
375     u32_t RetryFailCnt;             //  6
376     u32_t Hw_TotalTxFrm;                //  7 Hardware total Tx Frame
377     u32_t Hw_RetryCnt;              //  8 txMultipleRetriesFrames
378     u32_t Hw_UnderrunCnt;       //  9
379
380     u32_t DriverRxFrmCnt;       // 10
381     u32_t rxUnicastFrm;             // 11 rxUnicastFrames
382     u32_t rxMulticastFrm;           // 12rxMulticastFrames
383
384     u32_t NotifyNDISRxFrmCnt;   // 14
385     u32_t rxUnicastOctets;      // 15 rxUniOctets  byte size
386     u32_t rxMulticastOctets;        // 16 rxMultiOctets  byte size
387     u32_t DriverDiscardedFrm;       // 17 Discard by ValidateFrame
388     u32_t LessThanDataMinLen;       // 18
389     u32_t GreaterThanMaxLen;        // 19
390     u32_t DriverDiscardedFrmCauseByMulticastList;
391     u32_t DriverDiscardedFrmCauseByFrmCtrl;
392     u32_t rxNeedFrgFrm;             // 22 need more frg frm
393     u32_t DriverRxMgtFrmCnt;
394     u32_t rxBroadcastFrm;           // 24 Receive broadcast frame count
395     u32_t rxBroadcastOctets;    // 25 Receive broadcast frame byte size
396     u32_t rx11bDataFrame;               // 26 Measured quality 11b data frame count
397     u32_t rxOFDMDataFrame;          // 27 Measured quality 11g data frame count
398
399
400     u32_t Hw_TotalRxFrm;        // 28
401     u32_t Hw_CRC16Cnt;              // 29 rxPLCPCRCErrCnt
402     u32_t Hw_CRC32Cnt;              // 30 rxCRC32ErrCnt
403     u32_t Hw_DecrypErr_UNI;     // 31
404     u32_t Hw_DecrypErr_Mul;     // 32
405
406     u32_t Hw_RxFIFOOverrun;     // 34
407     u32_t Hw_RxTimeOut;         // 35
408     u32_t LossAP;               // 36
409
410     u32_t Tx_MPDU;              // 37
411     u32_t BA_Fail;              // 38
412     u32_t Hw_Tx_AMPDU;          // 39
413     u32_t Hw_Tx_MPDU;           // 40
414
415     u32_t RateCtrlTxMPDU;
416     u32_t RateCtrlBAFail;
417
418     u32_t txQosDropCount[5];    //41 42 43 44 45
419
420         u32_t Hw_RxMPDU;            // 46
421         u32_t Hw_RxDropMPDU;        // 47
422         u32_t Hw_RxDelMPDU;         // 48
423
424         u32_t Hw_RxPhyMiscError;    // 49
425         u32_t Hw_RxPhyXRError;      // 50
426     u32_t Hw_RxPhyOFDMError;    // 51
427     u32_t Hw_RxPhyCCKError;     // 52
428     u32_t Hw_RxPhyHTError;      // 53
429     u32_t Hw_RxPhyTotalCount;   // 54
430
431     u32_t swRxFragmentCount;         // 55
432     u32_t swRxUnicastMicFailCount;   // 56
433     u32_t swRxMulticastMicFailCount; // 57
434     u32_t swRxDropUnencryptedCount;  // 58
435
436     u32_t txBroadcastFrm;
437     u32_t txBroadcastOctets;
438 };
439
440 /* Traffic Monitor Tally data structure */
441 struct zsTrafTally
442 {
443     u32_t rxDuplicate;
444     u32_t rxSrcIsOwnMac;
445     //u32_t rxDataFrameCount;
446     //u32_t rxDataByteCount;
447     //u32_t rxDataBytesIn1000ms;
448     //u32_t rxDataTmpFor1000ms;
449     //u32_t rxDataBytesIn2000ms;
450     //u32_t rxDataTmpFor2000ms;
451
452     //u32_t txDataFrameCount;
453     //u32_t txDataByteCount;
454     //u32_t txDataBytesIn1000ms;
455     //u32_t txDataTmpFor1000ms;
456     u32_t txDataBytesIn2000ms;
457     u32_t txDataTmpFor2000ms;
458 };
459
460 /* Hal rx packet moniter information */
461 struct zsMonHalRxInfo
462 {
463     u32_t currentRSSI[7];
464     u32_t currentRxEVM[14];
465     u32_t currentRxDataMT;
466     u32_t currentRxDataMCS;
467     u32_t currentRxDataBW;
468     u32_t currentRxDataSG;
469 };
470
471 struct zsTail
472 {
473     u8_t SignalStrength1;
474     u8_t SignalStrength2;
475     u8_t SignalStrength3;
476     u8_t SignalQuality;
477     u8_t SAIndex;
478     u8_t DAIndex;
479     u8_t ErrorIndication;
480     u8_t RxMacStatus;
481 };
482
483 union zuTail
484 {
485     struct zsTail Data;
486     u8_t Byte[8];
487 };
488
489 struct zsAdditionInfo
490 {
491     u8_t PlcpHeader[12];
492     union zuTail   Tail;
493 };
494
495
496 struct zsPmkidBssidInfo
497 {
498     u16_t      bssid[3];
499     u8_t       pmkid[16];
500 };
501
502 struct zsPmkidInfo
503 {
504            u32_t                bssidCount;
505            struct zsPmkidBssidInfo      bssidInfo[ZM_PMKID_MAX_BSS_CNT];
506 };
507
508
509 struct zsCbFuncTbl
510 {
511     u16_t (*zfcbAuthNotify)(zdev_t* dev, u16_t* macAddr);
512     u16_t (*zfcbAsocNotify)(zdev_t* dev, u16_t* macAddr, u8_t* body,
513             u16_t bodySize, u16_t port);
514     u16_t (*zfcbDisAsocNotify)(zdev_t* dev, u8_t* macAddr, u16_t port);
515     u16_t (*zfcbApConnectNotify)(zdev_t* dev, u8_t* macAddr, u16_t port);
516     void (*zfcbConnectNotify)(zdev_t* dev, u16_t status, u16_t* bssid);
517     void (*zfcbScanNotify)(zdev_t* dev, struct zsScanResult* result);
518     void (*zfcbMicFailureNotify)(zdev_t* dev, u16_t* addr, u16_t status);
519     void (*zfcbApMicFailureNotify)(zdev_t* dev, u8_t* addr, zbuf_t* buf);
520     void (*zfcbIbssPartnerNotify)(zdev_t* dev, u16_t status,
521             struct zsPartnerNotifyEvent *event);
522     void (*zfcbMacAddressNotify)(zdev_t* dev, u8_t* addr);
523     void (*zfcbSendCompleteIndication)(zdev_t* dev, zbuf_t* buf);
524     void (*zfcbRecvEth)(zdev_t* dev, zbuf_t* buf, u16_t port);
525     void (*zfcbRecv80211)(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
526     void (*zfcbRestoreBufData)(zdev_t* dev, zbuf_t* buf);
527 #ifdef ZM_ENABLE_CENC
528     u16_t (*zfcbCencAsocNotify)(zdev_t* dev, u16_t* macAddr, u8_t* body,
529             u16_t bodySize, u16_t port);
530 #endif //ZM_ENABLE_CENC
531     u8_t (*zfcbClassifyTxPacket)(zdev_t* dev, zbuf_t* buf);
532
533     void (*zfcbHwWatchDogNotify)(zdev_t* dev);
534 };
535
536 extern void zfZeroMemory(u8_t* va, u16_t length);
537 #define ZM_INIT_CB_FUNC_TABLE(p)        zfZeroMemory((u8_t *)p, sizeof(struct zsCbFuncTbl));
538
539 //extern struct zsWlanDev zgWlanDev;
540
541 /* Initialize WLAN hardware and software, resource will be allocated */
542 /* for WLAN operation, must be called first before other function.   */
543 extern u16_t zfiWlanOpen(zdev_t* dev, struct zsCbFuncTbl* cbFuncTbl);
544
545 /* WLAN hardware will be shutdown and all resource will be release */
546 extern u16_t zfiWlanClose(zdev_t* dev);
547
548 /* Enable/disable Wlan operation */
549 extern u16_t zfiWlanEnable(zdev_t* dev);
550 extern u16_t zfiWlanDisable(zdev_t* dev, u8_t ResetKeyCache);
551 extern u16_t zfiWlanResume(zdev_t* dev, u8_t doReconn);
552 extern u16_t zfiWlanSuspend(zdev_t* dev);
553
554 /* Enable/disable ISR interrupt */
555 extern u16_t zfiWlanInterruptEnable(zdev_t* dev);
556 extern u16_t zfiWlanInterruptDisable(zdev_t* dev);
557
558 /* Do WLAN site survey */
559 extern u16_t zfiWlanScan(zdev_t* dev);
560
561 /* Get WLAN stastics */
562 extern u16_t zfiWlanGetStatistics(zdev_t* dev);
563
564 /* Reset WLAN */
565 extern u16_t zfiWlanReset(zdev_t* dev);
566
567 /* Deauthenticate a STA */
568 extern u16_t zfiWlanDeauth(zdev_t* dev, u16_t* macAddr, u16_t reason);
569
570 extern u16_t zfiTxSendEth(zdev_t* dev, zbuf_t* buf, u16_t port);
571 extern u8_t zfiIsTxQueueFull(zdev_t* dev);
572 extern u16_t zfiTxSend80211Mgmt(zdev_t* dev, zbuf_t* buf, u16_t port);
573
574 extern void zfiIsrPci(zdev_t* dev);
575
576 extern u8_t zfiWlanIBSSGetPeerStationsCount(zdev_t* dev);
577 extern u8_t zfiWlanIBSSIteratePeerStations(zdev_t* dev, u8_t numToIterate, zfpIBSSIteratePeerStationCb callback, void *ctx);
578 extern void zfiWlanFlushAllQueuedBuffers(zdev_t* dev);
579
580 /* coid.c */
581 extern void zfiWlanQueryMacAddress(zdev_t* dev, u8_t* addr);
582
583 extern u16_t zfiGlobalDataSize(zdev_t* dev);
584
585 extern void zfiHeartBeat(zdev_t* dev);
586
587 extern void zfiWlanSetWlanMode(zdev_t* dev, u8_t wlanMode);
588 extern void zfiWlanSetAuthenticationMode(zdev_t* dev, u8_t authMode);
589 extern void zfiWlanSetWepStatus(zdev_t* dev, u8_t wepStatus);
590 extern void zfiWlanSetSSID(zdev_t* dev, u8_t* ssid, u8_t ssidLength);
591 extern void zfiWlanSetFragThreshold(zdev_t* dev, u16_t fragThreshold);
592 extern void zfiWlanSetRtsThreshold(zdev_t* dev, u16_t rtsThreshold);
593 extern void zfiWlanSetFrequency(zdev_t* dev, u32_t frequency, u8_t bImmediate);
594 extern void zfiWlanSetBssid(zdev_t* dev, u8_t* bssid);
595 extern void zfiWlanSetBeaconInterval(zdev_t* dev, u16_t beaconInterval,
596                               u8_t bImmediate);
597 extern void zfiWlanSetDtimCount(zdev_t* dev, u8_t  dtim);
598 extern void zfiWlanSetAtimWindow(zdev_t* dev, u16_t atimWindow, u8_t bImmediate);
599 extern void zfiWlanSetEncryMode(zdev_t* dev, u8_t encryMode);
600 extern u8_t zfiWlanSetKey(zdev_t* dev, struct zsKeyInfo keyInfo);
601 extern u8_t zfiWlanPSEUDOSetKey(zdev_t* dev, struct zsKeyInfo keyInfo);
602 extern void zfiWlanSetPowerSaveMode(zdev_t* dev, u8_t mode);
603 extern void zfiWlanQueryBssListV1(zdev_t* dev, struct zsBssListV1* bssListV1);
604 extern void zfiWlanQueryBssList(zdev_t* dev, struct zsBssList* pBssList);
605 extern void zfiWlanSetProtectionMode(zdev_t* dev, u8_t mode);
606 extern void zfiWlanFlushBssList(zdev_t* dev);
607
608 void zfiWlanDisableDfsChannel(zdev_t* dev, u8_t disableFlag);
609
610 extern u8_t zfiWlanQueryWlanMode(zdev_t* dev);
611 extern u16_t zfiWlanChannelToFrequency(zdev_t* dev, u8_t channel);
612 extern u8_t zfiWlanFrequencyToChannel(zdev_t* dev, u16_t freq);
613
614 #define ZM_WLAN_STATE_OPENED        0
615 #define ZM_WLAN_STATE_ENABLED       1
616 #define ZM_WLAN_STATE_DISABLED      2
617 #define ZM_WLAN_STATE_CLOSEDED      3
618 extern u8_t zfiWlanQueryAdapterState(zdev_t* dev);
619 extern u8_t zfiWlanQueryAuthenticationMode(zdev_t* dev, u8_t bWrapper);
620 extern u8_t zfiWlanQueryWepStatus(zdev_t* dev, u8_t bWrapper);
621 extern void zfiWlanQuerySSID(zdev_t* dev, u8_t* ssid, u8_t* pSsidLength);
622 extern u16_t zfiWlanQueryFragThreshold(zdev_t* dev);
623 extern u16_t zfiWlanQueryRtsThreshold(zdev_t* dev);
624 extern u32_t zfiWlanQueryFrequency(zdev_t* dev);
625 extern u32_t zfiWlanQueryCurrentFrequency(zdev_t* dev, u8_t qmode);
626 extern u32_t zfiWlanQueryFrequencyAttribute(zdev_t* dev, u32_t frequency);
627 extern void zfiWlanQueryFrequencyHT(zdev_t* dev, u32_t *bandWidth, u32_t *extOffset);
628 extern u8_t zfiWlanQueryCWMode(zdev_t* dev);
629 extern u32_t zfiWlanQueryCWEnable(zdev_t* dev);
630 extern void zfiWlanQueryBssid(zdev_t* dev, u8_t* bssid);
631 extern u16_t zfiWlanQueryBeaconInterval(zdev_t* dev);
632 extern u32_t zfiWlanQueryRxBeaconTotal(zdev_t* dev);
633 extern u16_t zfiWlanQueryAtimWindow(zdev_t* dev);
634 extern u8_t zfiWlanQueryEncryMode(zdev_t* dev);
635 extern u16_t zfiWlanQueryCapability(zdev_t* dev);
636 extern u16_t zfiWlanQueryAid(zdev_t* dev);
637 extern void zfiWlanQuerySupportRate(zdev_t* dev, u8_t* rateArray, u8_t* pLength);
638 extern void zfiWlanQueryExtSupportRate(zdev_t* dev, u8_t* rateArray, u8_t* pLength);
639 extern void zfiWlanQueryRsnIe(zdev_t* dev, u8_t* ie, u8_t* pLength);
640 extern void zfiWlanQueryWpaIe(zdev_t* dev, u8_t* ie, u8_t* pLength);
641 extern u8_t zfiWlanQueryHTMode(zdev_t* dev);
642 extern u8_t zfiWlanQueryBandWidth40(zdev_t* dev);
643 extern u8_t zfiWlanQueryMulticastCipherAlgo(zdev_t *dev);
644 extern u16_t zfiWlanQueryRegionCode(zdev_t* dev);
645 extern void zfiWlanSetWpaIe(zdev_t* dev, u8_t* ie, u8_t Length);
646 extern void zfiWlanSetWpaSupport(zdev_t* dev, u8_t WpaSupport);
647 extern void zfiWlanCheckStaWpaIe(zdev_t* dev);
648 extern void zfiWlanSetBasicRate(zdev_t* dev, u8_t bRateSet, u8_t gRateSet,
649                          u32_t nRateSet);
650 extern void zfiWlanSetBGMode(zdev_t* dev, u8_t mode);
651 extern void zfiWlanSetpreambleType(zdev_t* dev, u8_t type);
652 extern u8_t zfiWlanQuerypreambleType(zdev_t* dev);
653 extern u8_t zfiWlanQueryPowerSaveMode(zdev_t* dev);
654 extern void zfiWlanSetMacAddress(zdev_t* dev, u16_t* mac);
655 extern u16_t zfiWlanSetTxRate(zdev_t* dev, u16_t rate);
656 extern u32_t zfiWlanQueryTxRate(zdev_t* dev);
657 extern void zfWlanUpdateRxRate(zdev_t* dev, struct zsAdditionInfo* addInfo);
658 extern u32_t zfiWlanQueryRxRate(zdev_t* dev);
659 extern u8_t zfiWlanSetPmkidInfo(zdev_t* dev, u16_t* bssid, u8_t* pmkid);
660 extern u32_t zfiWlanQueryPmkidInfo(zdev_t* dev, u8_t* buf, u32_t len);
661 extern void zfiWlanSetAllMulticast(zdev_t* dev, u32_t setting);
662 extern void zfiWlanSetHTCtrl(zdev_t* dev, u32_t *setting, u32_t forceTxTPC);
663 extern void zfiWlanQueryHTCtrl(zdev_t* dev, u32_t *setting, u32_t *forceTxTPC);
664 extern void zfiWlanDbg(zdev_t* dev, u8_t setting);
665
666 extern void zfiWlanResetTally(zdev_t* dev);
667 extern void zfiWlanQueryTally(zdev_t* dev, struct zsCommTally *tally);
668 extern void zfiWlanQueryTrafTally(zdev_t* dev, struct zsTrafTally *tally);
669 extern void zfiWlanQueryMonHalRxInfo(zdev_t* dev, struct zsMonHalRxInfo *halRxInfo);
670
671 extern u32_t zfiFWConfig(zdev_t* dev, u32_t size);
672
673 extern void zfiDKEnable(zdev_t* dev, u32_t enable);
674
675 extern void zfiWlanSetMulticastList(zdev_t* dev, u8_t size, u8_t* pList);
676 extern void zfiWlanRemoveKey(zdev_t* dev, u8_t keyType, u8_t keyId);
677 extern u8_t zfiWlanQueryIsPKInstalled(zdev_t *dev, u8_t *staMacAddr);
678 extern u32_t zfiWlanQueryPacketTypePromiscuous(zdev_t* dev);
679 extern void zfiWlanSetPacketTypePromiscuous(zdev_t* dev, u32_t setValue);
680 extern void zfiSetChannelManagement(zdev_t* dev, u32_t setting);
681 extern void zfiSetRifs(zdev_t* dev, u16_t setting);
682 extern void zfiCheckRifs(zdev_t* dev);
683 extern void zfiSetReorder(zdev_t* dev, u16_t value);
684 extern void zfiSetSeqDebug(zdev_t* dev, u16_t value);
685
686 extern u16_t zfiConfigWdsPort(zdev_t* dev, u8_t wdsPortId, u16_t flag, u16_t* wdsAddr,
687         u16_t encType, u32_t* wdsKey);
688 extern void zfiWlanQueryRegulationTable(zdev_t* dev, struct zsRegulationTable* pEntry);
689 extern void zfiWlanSetScanTimerPerChannel(zdev_t* dev, u16_t time);
690 extern void zfiWlanSetAutoReconnect(zdev_t* dev, u8_t enable);
691 extern u32_t zfiDebugCmd(zdev_t* dev, u32_t cmd, u32_t value);
692 extern void zfiWlanSetProbingHiddenSsid(zdev_t* dev, u8_t* ssid, u8_t ssidLen,
693     u16_t entry);
694 extern void zfiWlanSetDropUnencryptedPackets(zdev_t* dev, u8_t enable);
695 extern void zfiWlanSetIBSSJoinOnly(zdev_t* dev, u8_t joinOnly);
696 extern void zfiWlanSetDefaultKeyId(zdev_t* dev, u8_t keyId);
697 extern void zfiWlanSetDisableProbingWithSsid(zdev_t* dev, u8_t mode);
698 extern void zfiWlanQueryGSN(zdev_t* dev, u8_t *gsn, u16_t vapId);
699 extern u16_t zfiStaAddIeWpaRsn(zdev_t* dev, zbuf_t* buf, u16_t offset, u8_t frameType);
700 extern u8_t zfiWlanSetDot11DMode(zdev_t* dev, u8_t mode);
701 extern u8_t zfiWlanSetDot11HDFSMode(zdev_t* dev, u8_t mode);
702 extern u8_t zfiWlanSetDot11HTPCMode(zdev_t* dev, u8_t mode);
703 extern u8_t zfiWlanSetAniMode(zdev_t* dev, u8_t mode);
704 extern void zfiWlanSetStaWme(zdev_t* dev, u8_t enable, u8_t uapsdInfo);
705 extern void zfiWlanSetApWme(zdev_t* dev, u8_t enable);
706 extern u8_t zfiWlanQuerywmeEnable(zdev_t* dev);
707 #ifdef ZM_OS_LINUX_FUNC
708 extern void zfiWlanShowTally(zdev_t* dev);
709 #endif
710 #ifdef ZM_ENABLE_CENC
711 /* CENC */
712 extern u8_t zfiWlanSetCencPairwiseKey(zdev_t* dev, u8_t keyid, u32_t *txiv, u32_t *rxiv,
713         u8_t *key, u8_t *mic);
714 extern u8_t zfiWlanSetCencGroupKey(zdev_t* dev, u8_t keyid, u32_t *rxiv,
715         u8_t *key, u8_t *mic);
716 #endif //ZM_ENABLE_CENC
717 extern void zfiWlanQuerySignalInfo(zdev_t* dev, u8_t *buffer);
718 extern void zfiWlanQueryAdHocCreatedBssDesc(zdev_t* dev, struct zsBssInfo *pBssInfo);
719 extern u8_t zfiWlanQueryAdHocIsCreator(zdev_t* dev);
720 extern u32_t zfiWlanQuerySupportMode(zdev_t* dev);
721 extern u32_t zfiWlanQueryTransmitPower(zdev_t* dev);
722 extern void zfiWlanEnableLeapConfig(zdev_t* dev, u8_t leapEnabled);
723
724 /* returned buffer allocated by driver core */
725 extern void zfiRecvEthComplete(zdev_t* dev, zbuf_t* buf);
726
727 extern void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
728
729 extern void zfiWlanSetMaxTxPower(zdev_t* dev, u8_t power2, u8_t power5);
730 extern void zfiWlanQueryMaxTxPower(zdev_t* dev, u8_t *power2, u8_t *power5);
731 extern void zfiWlanSetConnectMode(zdev_t* dev, u8_t mode);
732 extern void zfiWlanSetSupportMode(zdev_t* dev, u32_t mode);
733 extern void zfiWlanSetAdhocMode(zdev_t* dev, u32_t mode);
734 extern u32_t zfiWlanQueryAdhocMode(zdev_t* dev, u8_t bWrapper);
735 extern u8_t zfiWlanSetCountryIsoName(zdev_t* dev, u8_t *countryIsoName, u8_t length);
736 extern const char* zfiWlanQueryCountryIsoName(zdev_t* dev);
737 extern u8_t zfiWlanQueryregulatoryDomain(zdev_t* dev);
738 extern u8_t zfiWlanQueryCCS(zdev_t* dev);
739 extern void zfiWlanSetCCS(zdev_t* dev, u8_t mode);
740 extern void zfiWlanSetRegulatory(zdev_t* dev, u8_t CCS, u16_t Code, u8_t bfirstChannel);
741 extern const char* zfiHpGetisoNamefromregionCode(zdev_t* dev, u16_t regionCode);
742 extern void  zfiWlanSetLEDCtrlParam(zdev_t* dev, u8_t type, u8_t flag);
743 extern u32_t zfiWlanQueryReceivedPacket(zdev_t* dev);
744 extern void zfiWlanCheckSWEncryption(zdev_t* dev);
745 extern u16_t zfiWlanQueryAllowChannels(zdev_t *dev, u16_t *channels);
746 extern u16_t zfiWlanGetMulticastAddressCount(zdev_t* dev);
747 extern void zfiWlanGetMulticastList(zdev_t* dev, u8_t* pMCList);
748 extern void zfiWlanSetPacketFilter(zdev_t* dev, u32_t PacketFilter);
749 extern u8_t zfiCompareWithMulticastListAddress(zdev_t* dev, u16_t* dstMacAddr);
750 extern void zfiWlanSetSafeModeEnabled(zdev_t* dev, u8_t safeMode);
751 extern void zfiWlanSetIBSSAdditionalIELength(zdev_t* dev, u32_t ibssAdditionalIESize,  u8_t* ibssAdditionalIE);
752 extern void zfiWlanSetXLinkMode(zdev_t* dev, u32_t setValue);
753
754 /* hprw.c */
755 extern u32_t zfiDbgWriteFlash(zdev_t* dev, u32_t addr, u32_t val);
756 extern u32_t zfiDbgWriteReg(zdev_t* dev, u32_t addr, u32_t val);
757 extern u32_t zfiDbgReadReg(zdev_t* dev, u32_t addr);
758
759 extern u32_t zfiDbgWriteEeprom(zdev_t* dev, u32_t addr, u32_t val);
760 extern u32_t zfiDbgBlockWriteEeprom(zdev_t* dev, u32_t addr, u32_t* buf);
761 extern u32_t zfiDbgBlockWriteEeprom_v2(zdev_t* dev, u32_t addr, u32_t* buf, u32_t wrlen);
762
763 extern u16_t zfiDbgChipEraseFlash(zdev_t *dev);
764 extern u16_t zfiDbgProgramFlash(zdev_t *dev, u32_t offset, u32_t len, u32_t *data);
765 extern u32_t zfiDbgGetFlashCheckSum(zdev_t *dev, u32_t addr, u32_t len);
766 extern u32_t zfiDbgReadFlash(zdev_t *dev, u32_t addr, u32_t len);
767 extern u32_t zfiDownloadFwSet(zdev_t *dev);
768
769 extern u32_t zfiDbgDelayWriteReg(zdev_t* dev, u32_t addr, u32_t val);
770 extern u32_t zfiDbgFlushDelayWrite(zdev_t* dev);
771
772 extern u32_t zfiDbgSetIFSynthesizer(zdev_t* dev, u32_t value);
773 extern u32_t zfiDbgReadTally(zdev_t* dev);
774
775 extern u32_t zfiDbgQueryHwTxBusy(zdev_t* dev);
776
777 extern u8_t zfiWlanGetDestAddrFromBuf(zdev_t *dev, zbuf_t *buf, u16_t *macAddr);
778
779 extern u32_t zfiWlanQueryHwCapability(zdev_t* dev);
780
781 extern void zfiWlanSetDynamicSIFSParam(zdev_t* dev, u8_t val);
782
783 /***** End of section 2 *****/
784
785 /***** section 3 performace evaluation *****/
786 #ifdef ZM_ENABLE_PERFORMANCE_EVALUATION
787 extern void zfiTxPerformanceMSDU(zdev_t* dev, u32_t tick);
788 extern void zfiRxPerformanceMPDU(zdev_t* dev, zbuf_t* buf);
789 extern void zfiRxPerformanceReg(zdev_t* dev, u32_t reg, u32_t rsp);
790 #define ZM_PERFORMANCE_INIT(dev)                zfiPerformanceInit(dev);
791 #define ZM_PERFORMANCE_TX_MSDU(dev, tick)       zfiTxPerformanceMSDU(dev, tick);
792 #define ZM_PERFORMANCE_RX_MSDU(dev, tick)       zfiRxPerformanceMSDU(dev, tick);
793 #define ZM_PERFORMANCE_TX_MPDU(dev, tick)       zfiTxPerformanceMPDU(dev, tick);
794 #define ZM_PERFORMANCE_RX_MPDU(dev, buf)        zfiRxPerformanceMPDU(dev, buf);
795 #define ZM_PERFORMANCE_RX_SEQ(dev, buf)         zfiRxPerformanceSeq(dev, buf);
796 #define ZM_PERFORMANCE_REG(dev, reg, rsp)    {if(cmd[1] == reg) zfiRxPerformanceReg(dev, reg, rsp);}
797 #define ZM_PERFORMANCE_DUP(dev, buf1, buf2)     zfiRxPerformanceDup(dev, buf1, buf2);
798 #define ZM_PERFORMANCE_FREE(dev, buf)           zfiRxPerformanceFree(dev, buf);
799 #define ZM_PERFORMANCE_RX_AMSDU(dev, buf, len)  zfiRxPerformanceAMSDU(dev, buf, len);
800 #define ZM_PERFORMANCE_RX_FLUSH(dev)            zfiRxPerformanceFlush(dev);
801 #define ZM_PERFORMANCE_RX_CLEAR(dev)            zfiRxPerformanceClear(dev);
802 #define ZM_SEQ_DEBUG                            if (wd->seq_debug) DbgPrint
803 #define ZM_PERFORMANCE_RX_REORDER(dev)          zfiRxPerformanceReorder(dev);
804 #else
805 #define ZM_PERFORMANCE_INIT(dev)
806 #define ZM_PERFORMANCE_TX_MSDU(dev, tick)
807 #define ZM_PERFORMANCE_RX_MSDU(dev, tick)
808 #define ZM_PERFORMANCE_TX_MPDU(dev, tick)
809 #define ZM_PERFORMANCE_RX_MPDU(dev, buf)
810 #define ZM_PERFORMANCE_RX_SEQ(dev, buf)
811 #define ZM_PERFORMANCE_REG(dev, reg, rsp)
812 #define ZM_PERFORMANCE_DUP(dev, buf1, buf2)
813 #define ZM_PERFORMANCE_FREE(dev, buf)
814 #define ZM_PERFORMANCE_RX_AMSDU(dev, buf, len)
815 #define ZM_PERFORMANCE_RX_FLUSH(dev)
816 #define ZM_PERFORMANCE_RX_CLEAR(dev)
817 #define ZM_SEQ_DEBUG
818 #define ZM_PERFORMANCE_RX_REORDER(dev)
819 #endif
820 /***** End of section 3 *****/
821 #endif