2 * Copyright (c) 2007-2008 Atheros Communications Inc.
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.
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.
17 /* Module Name : cmd.c */
20 /* This module contains command interface functions. */
25 /************************************************************************/
27 #include "../hal/hpreg.h"
30 u16_t
zfWlanReset(zdev_t
*dev
);
31 u32_t
zfUpdateRxRate(zdev_t
*dev
);
34 extern void zfiUsbRecv(zdev_t
*dev
, zbuf_t
*buf
);
35 extern void zfiUsbRegIn(zdev_t
*dev
, u32_t
*rsp
, u16_t rspLen
);
36 extern void zfiUsbOutComplete(zdev_t
*dev
, zbuf_t
*buf
, u8_t status
, u8_t
*hdr
);
37 extern void zfiUsbRegOutComplete(zdev_t
*dev
);
38 extern u16_t
zfHpReinit(zdev_t
*dev
, u32_t frequency
);
40 /* Get size (byte) of driver core global data structure. */
41 /* This size will be used by driver wrapper to allocate */
42 /* a memory space for driver core to store global variables */
43 u16_t
zfiGlobalDataSize(zdev_t
*dev
)
46 ret
= (sizeof(struct zsWlanDev
));
47 zm_assert((ret
>>16) == 0);
52 /* Initialize WLAN hardware and software, resource will be allocated */
53 /* for WLAN operation, must be called first before other function. */
54 extern u16_t
zfiWlanOpen(zdev_t
*dev
, struct zsCbFuncTbl
*cbFuncTbl
)
62 struct zfCbUsbFuncTbl cbUsbFuncTbl
;
63 zmw_get_wlan_dev(dev
);
65 zm_debug_msg0("start");
67 devSize
= sizeof(struct zsWlanDev
);
68 /* Zeroize zsWlanDev struct */
69 zfZeroMemory((u8_t
*)wd
, (u16_t
)devSize
);
71 #ifdef ZM_ENABLE_AGGREGATION
77 wd
->commTally
.RateCtrlTxMPDU
= 0;
78 wd
->commTally
.RateCtrlBAFail
= 0;
79 wd
->preambleTypeInUsed
= ZM_PREAMBLE_TYPE_SHORT
;
81 if (cbFuncTbl
== NULL
) {
82 /* zfcbRecvEth() is mandatory */
85 if (cbFuncTbl
->zfcbRecvEth
== NULL
) {
86 /* zfcbRecvEth() is mandatory */
89 wd
->zfcbAuthNotify
= cbFuncTbl
->zfcbAuthNotify
;
90 wd
->zfcbAuthNotify
= cbFuncTbl
->zfcbAuthNotify
;
91 wd
->zfcbAsocNotify
= cbFuncTbl
->zfcbAsocNotify
;
92 wd
->zfcbDisAsocNotify
= cbFuncTbl
->zfcbDisAsocNotify
;
93 wd
->zfcbApConnectNotify
= cbFuncTbl
->zfcbApConnectNotify
;
94 wd
->zfcbConnectNotify
= cbFuncTbl
->zfcbConnectNotify
;
95 wd
->zfcbScanNotify
= cbFuncTbl
->zfcbScanNotify
;
96 wd
->zfcbMicFailureNotify
= cbFuncTbl
->zfcbMicFailureNotify
;
97 wd
->zfcbApMicFailureNotify
= cbFuncTbl
->zfcbApMicFailureNotify
;
98 wd
->zfcbIbssPartnerNotify
= cbFuncTbl
->zfcbIbssPartnerNotify
;
99 wd
->zfcbMacAddressNotify
= cbFuncTbl
->zfcbMacAddressNotify
;
100 wd
->zfcbSendCompleteIndication
=
101 cbFuncTbl
->zfcbSendCompleteIndication
;
102 wd
->zfcbRecvEth
= cbFuncTbl
->zfcbRecvEth
;
103 wd
->zfcbRestoreBufData
= cbFuncTbl
->zfcbRestoreBufData
;
104 wd
->zfcbRecv80211
= cbFuncTbl
->zfcbRecv80211
;
105 #ifdef ZM_ENABLE_CENC
106 wd
->zfcbCencAsocNotify
= cbFuncTbl
->zfcbCencAsocNotify
;
107 #endif /* ZM_ENABLE_CENC */
108 wd
->zfcbClassifyTxPacket
= cbFuncTbl
->zfcbClassifyTxPacket
;
109 wd
->zfcbHwWatchDogNotify
= cbFuncTbl
->zfcbHwWatchDogNotify
;
112 /* add by honda 0330 */
113 cbUsbFuncTbl
.zfcbUsbRecv
= zfiUsbRecv
;
114 cbUsbFuncTbl
.zfcbUsbRegIn
= zfiUsbRegIn
;
115 cbUsbFuncTbl
.zfcbUsbOutComplete
= zfiUsbOutComplete
;
116 cbUsbFuncTbl
.zfcbUsbRegOutComplete
= zfiUsbRegOutComplete
;
117 zfwUsbRegisterCallBack(dev
, &cbUsbFuncTbl
);
118 /* Init OWN MAC address */
119 wd
->macAddr
[0] = 0x8000;
120 wd
->macAddr
[1] = 0x0000;
121 wd
->macAddr
[2] = 0x0000;
123 wd
->regulationTable
.regionCode
= 0xffff;
125 zfHpInit(dev
, wd
->frequency
);
127 /* init region code */
128 /* wd->regulationTable.regionCode = NULL1_WORLD; //Only 2.4g RegCode */
129 /* zfHpGetRegulationTablefromRegionCode(dev, NULL1_WORLD); */
130 /* zfiWlanSetDot11DMode(dev , 1); //Enable 802.11d */
131 /* Get the first channel */
132 /* wd->frequency = zfChGetFirstChannel(dev, &bPassive); */
134 /* wd->frequency = 2437; */
138 wd
->sta
.mTxRate
= 0x0;
139 wd
->sta
.uTxRate
= 0x3;
140 wd
->sta
.mmTxRate
= 0x0;
141 wd
->sta
.adapterState
= ZM_STA_STATE_DISCONNECT
;
142 wd
->sta
.capability
[0] = 0x01;
143 wd
->sta
.capability
[1] = 0x00;
145 wd
->sta
.preambleTypeHT
= 0;
146 wd
->sta
.htCtrlBandwidth
= 0;
147 wd
->sta
.htCtrlSTBC
= 0;
148 wd
->sta
.htCtrlSG
= 0;
149 wd
->sta
.defaultTA
= 0;
150 /*wd->sta.activescanTickPerChannel =
151 *ZM_TIME_ACTIVE_SCAN/ZM_MS_PER_TICK;
154 u8_t Dur
= ZM_TIME_ACTIVE_SCAN
;
155 zfwGetActiveScanDur(dev
, &Dur
);
156 wd
->sta
.activescanTickPerChannel
= Dur
/ ZM_MS_PER_TICK
;
159 wd
->sta
.passiveScanTickPerChannel
= ZM_TIME_PASSIVE_SCAN
/ZM_MS_PER_TICK
;
160 wd
->sta
.bAutoReconnect
= TRUE
;
161 wd
->sta
.dropUnencryptedPkts
= FALSE
;
163 /* set default to bypass all multicast packet for linux,
164 * window XP would set 0 by wrapper initialization
166 wd
->sta
.bAllMulticast
= 1;
168 /* Initial the RIFS Status / RIFS-like frame count / RIFS count */
169 wd
->sta
.rifsState
= ZM_RIFS_STATE_DETECTING
;
170 wd
->sta
.rifsLikeFrameCnt
= 0;
171 wd
->sta
.rifsCount
= 0;
173 wd
->sta
.osRxFilter
= 0;
174 wd
->sta
.bSafeMode
= 0;
177 zfResetSupportRate(dev
, ZM_DEFAULT_SUPPORT_RATE_DISCONNECT
);
178 wd
->beaconInterval
= 100;
179 wd
->rtsThreshold
= 2346;
180 wd
->fragThreshold
= 32767;
181 wd
->wlanMode
= ZM_MODE_INFRASTRUCTURE
;
182 wd
->txMCS
= 0xff; /* AUTO */
184 /* wd->txMT = 1; *//*OFDM */
186 wd
->maxTxPower2
= 0xff;
187 wd
->maxTxPower5
= 0xff;
188 wd
->supportMode
= 0xffffffff;
189 wd
->ws
.adhocMode
= ZM_ADHOCBAND_G
;
190 wd
->ws
.autoSetFrequency
= 0xff;
193 /* wd->bgMode = wd->ws.bgMode; */
194 wd
->ap
.ssidLen
[0] = 6;
195 wd
->ap
.ssid
[0][0] = 'Z';
196 wd
->ap
.ssid
[0][1] = 'D';
197 wd
->ap
.ssid
[0][2] = '1';
198 wd
->ap
.ssid
[0][3] = '2';
199 wd
->ap
.ssid
[0][4] = '2';
200 wd
->ap
.ssid
[0][5] = '1';
202 /* Init the country iso name as NA */
203 wd
->ws
.countryIsoName
[0] = 0;
204 wd
->ws
.countryIsoName
[1] = 0;
205 wd
->ws
.countryIsoName
[2] = '\0';
207 /* init fragmentation is disabled */
208 /* zfiWlanSetFragThreshold(dev, 0); */
210 /* airopeek : swSniffer 1=>on 0=>off */
217 /* Init HT Capability Info */
218 wd
->ap
.HTCap
.Data
.ElementID
= ZM_WLAN_EID_HT_CAPABILITY
;
219 wd
->ap
.HTCap
.Data
.Length
= 26;
220 /*wd->ap.HTCap.Data.SupChannelWidthSet = 0;
221 wd->ap.HTCap.Data.MIMOPowerSave = 3;
222 wd->ap.HTCap.Data.ShortGIfor40MHz = 0;
223 wd->ap.HTCap.Data.ShortGIfor20MHz = 0;
224 wd->ap.HTCap.Data.DSSSandCCKin40MHz = 0;
226 wd
->ap
.HTCap
.Data
.AMPDUParam
|= HTCAP_MaxRxAMPDU3
;
227 wd
->ap
.HTCap
.Data
.MCSSet
[0] = 0xFF; /* MCS 0 ~ 7 */
228 wd
->ap
.HTCap
.Data
.MCSSet
[1] = 0xFF; /* MCS 8 ~ 15 */
230 /* Init Extended HT Capability Info */
231 wd
->ap
.ExtHTCap
.Data
.ElementID
= ZM_WLAN_EID_EXTENDED_HT_CAPABILITY
;
232 wd
->ap
.ExtHTCap
.Data
.Length
= 22;
233 wd
->ap
.ExtHTCap
.Data
.ControlChannel
= 6;
234 /* wd->ap.ExtHTCap.Data.ExtChannelOffset = 3; */
235 wd
->ap
.ExtHTCap
.Data
.ChannelInfo
|= ExtHtCap_RecomTxWidthSet
;
236 /* wd->ap.ExtHTCap.Data.RIFSMode = 1; */
237 wd
->ap
.ExtHTCap
.Data
.OperatingInfo
|= 1;
240 /* Init HT Capability Info */
241 wd
->sta
.HTCap
.Data
.ElementID
= ZM_WLAN_EID_HT_CAPABILITY
;
242 wd
->sta
.HTCap
.Data
.Length
= 26;
244 /* Test with 5G-AP : 7603 */
245 /* wd->sta.HTCap.Data.SupChannelWidthSet = 1; */
246 wd
->sta
.HTCap
.Data
.HtCapInfo
|= HTCAP_SMEnabled
;
247 wd
->sta
.HTCap
.Data
.HtCapInfo
|= HTCAP_SupChannelWidthSet
;
248 wd
->sta
.HTCap
.Data
.HtCapInfo
|= HTCAP_ShortGIfor40MHz
;
249 wd
->sta
.HTCap
.Data
.HtCapInfo
|= HTCAP_DSSSandCCKin40MHz
;
250 #ifndef ZM_DISABLE_AMSDU8K_SUPPORT
251 wd
->sta
.HTCap
.Data
.HtCapInfo
|= HTCAP_MaxAMSDULength
;
253 /*wd->sta.HTCap.Data.MIMOPowerSave = 0;
254 wd->sta.HTCap.Data.ShortGIfor40MHz = 0;
255 wd->sta.HTCap.Data.ShortGIfor20MHz = 0;
256 wd->sta.HTCap.Data.DSSSandCCKin40MHz = 0;
258 wd
->sta
.HTCap
.Data
.AMPDUParam
|= HTCAP_MaxRxAMPDU3
;
259 wd
->sta
.HTCap
.Data
.MCSSet
[0] = 0xFF; /* MCS 0 ~ 7 */
260 wd
->sta
.HTCap
.Data
.MCSSet
[1] = 0xFF; /* MCS 8 ~ 15 */
261 wd
->sta
.HTCap
.Data
.PCO
|= HTCAP_TransmissionTime3
;
262 /* wd->sta.HTCap.Data.TransmissionTime = 0; */
263 /* Init Extended HT Capability Info */
264 wd
->sta
.ExtHTCap
.Data
.ElementID
= ZM_WLAN_EID_EXTENDED_HT_CAPABILITY
;
265 wd
->sta
.ExtHTCap
.Data
.Length
= 22;
266 wd
->sta
.ExtHTCap
.Data
.ControlChannel
= 6;
268 /* wd->sta.ExtHTCap.Data.ExtChannelOffset |= 3; */
269 wd
->sta
.ExtHTCap
.Data
.ChannelInfo
|= ExtHtCap_ExtChannelOffsetBelow
;
271 /* wd->sta.ExtHTCap.Data.RecomTxWidthSet = 1; */
272 /* wd->sta.ExtHTCap.Data.RIFSMode = 1; */
273 wd
->sta
.ExtHTCap
.Data
.OperatingInfo
|= 1;
278 wd
->ap
.qosMode
[0] = 1;
281 wd
->ledStruct
.ledMode
[0] = 0x2221;
282 wd
->ledStruct
.ledMode
[1] = 0x2221;
286 ZM_PERFORMANCE_INIT(dev
);
288 zfBssInfoCreate(dev
);
290 zfPowerSavingMgrInit(dev
);
295 u32_t key
[4] = {0xffffffff, 0xff, 0, 0};
296 u16_t addr
[3] = {0x8000, 0x01ab, 0x0000};
297 /*zfSetKey(dev, 0, 0, ZM_WEP64, addr, key);
298 zfSetKey(dev, 0, 0, ZM_AES, addr, key);
299 zfSetKey(dev, 64, 0, 1, wd->macAddr, key);
305 wd
->ws
.staWmeEnabled
= 1; /* Enable WME by default */
306 #define ZM_UAPSD_Q_SIZE 32 /* 2^N */
307 wd
->ap
.uapsdQ
= zfQueueCreate(dev
, ZM_UAPSD_Q_SIZE
);
308 zm_assert(wd
->ap
.uapsdQ
!= NULL
);
309 wd
->sta
.uapsdQ
= zfQueueCreate(dev
, ZM_UAPSD_Q_SIZE
);
310 zm_assert(wd
->sta
.uapsdQ
!= NULL
);
312 /* zfHpInit(dev, wd->frequency); */
315 /* zfHpSetMacAddress(dev, wd->macAddr, 0); */
316 zfHpGetMacAddress(dev
);
318 zfCoreSetFrequency(dev
, wd
->frequency
);
320 #if ZM_PCI_LOOP_BACK == 1
321 zfwWriteReg(dev
, ZM_REG_PCI_CONTROL
, 6);
322 #endif /* #if ZM_PCI_LOOP_BACK == 1 */
324 /* zfiWlanSetDot11DMode(dev , 1); // Enable 802.11d */
325 /* zfiWlanSetDot11HDFSMode(dev , 1); // Enable 802.11h DFS */
326 wd
->sta
.DFSEnable
= 1;
327 wd
->sta
.capability
[1] |= ZM_BIT_0
;
329 /* zfiWlanSetFrequency(dev, 5260000, TRUE); */
330 /* zfiWlanSetAniMode(dev , 1); // Enable ANI */
335 zm_debug_msg0("end");
340 /* WLAN hardware will be shutdown and all resource will be release */
341 u16_t
zfiWlanClose(zdev_t
*dev
)
343 zmw_get_wlan_dev(dev
);
345 zm_msg0_init(ZM_LV_0
, "enter");
347 wd
->state
= ZM_WLAN_STATE_CLOSEDED
;
349 /* zfiWlanDisable(dev, 1); */
360 zfQueueDestroy(dev
, wd
->ap
.uapsdQ
);
361 zfQueueDestroy(dev
, wd
->sta
.uapsdQ
);
363 zfBssInfoDestroy(dev
);
365 #ifdef ZM_ENABLE_AGGREGATION
367 zfAggRxFreeBuf(dev
, 1); /* 1 for release structure memory */
368 /* end of add by honda */
371 zm_msg0_init(ZM_LV_0
, "exit");
376 void zfGetWrapperSetting(zdev_t
*dev
)
381 zmw_get_wlan_dev(dev
);
383 zmw_declare_for_critical_section();
385 if ((wd
->ws
.countryIsoName
[0] != 0)
386 || (wd
->ws
.countryIsoName
[1] != 0)
387 || (wd
->ws
.countryIsoName
[2] != '\0')) {
388 zfHpGetRegulationTablefromRegionCode(dev
,
389 zfHpGetRegionCodeFromIsoName(dev
, wd
->ws
.countryIsoName
));
392 zmw_enter_critical_section(dev
);
394 wd
->wlanMode
= wd
->ws
.wlanMode
;
397 if (wd
->ws
.frequency
) {
398 wd
->frequency
= wd
->ws
.frequency
;
399 wd
->ws
.frequency
= 0;
401 wd
->frequency
= zfChGetFirstChannel(dev
, &bPassive
);
403 if (wd
->wlanMode
== ZM_MODE_IBSS
) {
404 if (wd
->ws
.adhocMode
== ZM_ADHOCBAND_A
)
405 wd
->frequency
= ZM_CH_A_36
;
407 wd
->frequency
= ZM_CH_G_6
;
411 /* honda add for debug, 2437 channel 6, 2452 channel 9 */
412 wd
->frequency
= 2437;
413 /* end of add by honda */
416 /* set preamble type */
417 switch (wd
->ws
.preambleType
) {
418 case ZM_PREAMBLE_TYPE_AUTO
:
419 case ZM_PREAMBLE_TYPE_SHORT
:
420 case ZM_PREAMBLE_TYPE_LONG
:
421 wd
->preambleType
= wd
->ws
.preambleType
;
424 wd
->preambleType
= ZM_PREAMBLE_TYPE_SHORT
;
427 wd
->ws
.preambleType
= 0;
429 if (wd
->wlanMode
== ZM_MODE_AP
) {
430 vapId
= zfwGetVapId(dev
);
432 if (vapId
== 0xffff) {
433 wd
->ap
.authAlgo
[0] = wd
->ws
.authMode
;
434 wd
->ap
.encryMode
[0] = wd
->ws
.encryMode
;
436 wd
->ap
.authAlgo
[vapId
+ 1] = wd
->ws
.authMode
;
437 wd
->ap
.encryMode
[vapId
+ 1] = wd
->ws
.encryMode
;
440 wd
->ws
.encryMode
= ZM_NO_WEP
;
442 /* Get beaconInterval from WrapperSetting */
443 if ((wd
->ws
.beaconInterval
>= 20) &&
444 (wd
->ws
.beaconInterval
<= 1000))
445 wd
->beaconInterval
= wd
->ws
.beaconInterval
;
447 wd
->beaconInterval
= 100; /* 100ms */
450 wd
->dtim
= wd
->ws
.dtim
;
455 wd
->ap
.qosMode
= wd
->ws
.apWmeEnabled
& 0x1;
456 wd
->ap
.uapsdEnabled
= (wd
->ws
.apWmeEnabled
& 0x2) >> 1;
458 wd
->sta
.authMode
= wd
->ws
.authMode
;
459 wd
->sta
.currentAuthMode
= wd
->ws
.authMode
;
460 wd
->sta
.wepStatus
= wd
->ws
.wepStatus
;
462 if (wd
->ws
.beaconInterval
)
463 wd
->beaconInterval
= wd
->ws
.beaconInterval
;
465 wd
->beaconInterval
= 0x64;
467 if (wd
->wlanMode
== ZM_MODE_IBSS
) {
468 /* 1. Set default channel 6 (2437MHz) */
469 /* wd->frequency = 2437; */
471 /* 2. Otus support 802.11g Mode */
472 if ((wd
->ws
.adhocMode
== ZM_ADHOCBAND_G
) ||
473 (wd
->ws
.adhocMode
== ZM_ADHOCBAND_BG
) ||
474 (wd
->ws
.adhocMode
== ZM_ADHOCBAND_ABG
))
475 wd
->wfc
.bIbssGMode
= 1;
477 wd
->wfc
.bIbssGMode
= 0;
479 /* 3. set short preamble */
480 /* wd->sta.preambleType = ZM_PREAMBLE_TYPE_SHORT; */
483 /* set ATIM window */
484 if (wd
->ws
.atimWindow
)
485 wd
->sta
.atimWindow
= wd
->ws
.atimWindow
;
487 /* wd->sta.atimWindow = 0x0a; */
488 wd
->sta
.atimWindow
= 0;
491 /* wd->sta.connectingHiddenAP = 1;
492 wd->ws.connectingHiddenAP;
494 wd
->sta
.dropUnencryptedPkts
= wd
->ws
.dropUnencryptedPkts
;
495 wd
->sta
.ibssJoinOnly
= wd
->ws
.ibssJoinOnly
;
497 if (wd
->ws
.bDesiredBssid
) {
498 zfMemoryCopy(wd
->sta
.desiredBssid
,
499 wd
->ws
.desiredBssid
, 6);
500 wd
->sta
.bDesiredBssid
= TRUE
;
501 wd
->ws
.bDesiredBssid
= FALSE
;
503 wd
->sta
.bDesiredBssid
= FALSE
;
506 if (wd
->ws
.ssidLen
!= 0) {
507 if ((!zfMemoryIsEqual(wd
->ws
.ssid
, wd
->sta
.ssid
,
509 (wd
->ws
.ssidLen
!= wd
->sta
.ssidLen
) ||
510 (wd
->sta
.authMode
== ZM_AUTH_MODE_WPA
) ||
511 (wd
->sta
.authMode
== ZM_AUTH_MODE_WPAPSK
) ||
512 (wd
->ws
.staWmeQosInfo
!= 0)) {
513 /* if u-APSD test(set QosInfo), clear
514 connectByReasso to do association
517 wd
->sta
.connectByReasso
= FALSE
;
518 wd
->sta
.failCntOfReasso
= 0;
519 wd
->sta
.pmkidInfo
.bssidCount
= 0;
521 wd
->sta
.ssidLen
= wd
->ws
.ssidLen
;
522 zfMemoryCopy(wd
->sta
.ssid
, wd
->ws
.ssid
,
525 if (wd
->sta
.ssidLen
< 32)
526 wd
->sta
.ssid
[wd
->sta
.ssidLen
] = 0;
534 wd
->sta
.wmeEnabled
= wd
->ws
.staWmeEnabled
;
535 wd
->sta
.wmeQosInfo
= wd
->ws
.staWmeQosInfo
;
539 zmw_leave_critical_section(dev
);
542 u16_t
zfWlanEnable(zdev_t
*dev
)
544 u8_t bssid
[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
547 zmw_get_wlan_dev(dev
);
549 zmw_declare_for_critical_section();
551 if (wd
->wlanMode
== ZM_MODE_UNKNOWN
) {
552 zm_debug_msg0("Unknown Mode...Skip...");
556 if (wd
->wlanMode
== ZM_MODE_AP
) {
559 vapId
= zfwGetVapId(dev
);
561 if (vapId
== 0xffff) {
565 /* AP default parameters */
568 wd
->bRateBasic
= 0xf;
569 wd
->gRateBasic
= 0x0;
570 /* wd->beaconInterval = 100; */
572 wd
->ap
.beaconCounter
= 0;
573 /* wd->ap.vapNumber = 1; //mark by ygwei for Vap */
575 wd
->ap
.hideSsid
[0] = 0;
576 wd
->ap
.staAgingTimeSec
= 10*60;
577 wd
->ap
.staProbingTimeSec
= 60;
579 for (i
= 0; i
< ZM_MAX_AP_SUPPORT
; i
++)
580 wd
->ap
.bcmcHead
[i
] = wd
->ap
.bcmcTail
[i
] = 0;
582 /* wd->ap.uniHead = wd->ap.uniTail = 0; */
584 /* load AP parameters */
585 wd
->bRateBasic
= wd
->ws
.bRateBasic
;
586 wd
->gRateBasic
= wd
->ws
.gRateBasic
;
587 wd
->bgMode
= wd
->ws
.bgMode
;
588 if ((wd
->ws
.ssidLen
<= 32) && (wd
->ws
.ssidLen
!= 0)) {
589 wd
->ap
.ssidLen
[0] = wd
->ws
.ssidLen
;
590 for (i
= 0; i
< wd
->ws
.ssidLen
; i
++)
591 wd
->ap
.ssid
[0][i
] = wd
->ws
.ssid
[i
];
592 wd
->ws
.ssidLen
= 0; /* Reset Wrapper Variable */
595 if (wd
->ap
.encryMode
[0] == 0)
596 wd
->ap
.capab
[0] = 0x001;
598 wd
->ap
.capab
[0] = 0x011;
599 /* set Short Slot Time bit if not 11b */
600 if (wd
->ap
.wlanType
[0] != ZM_WLAN_TYPE_PURE_B
)
601 wd
->ap
.capab
[0] |= 0x400;
603 /* wd->ap.vapNumber = 1; //mark by ygwei for Vap Test */
607 wd
->ap
.apBitmap
= 0x3;
608 wd
->ap
.capab
[1] = 0x401;
609 wd
->ap
.ssidLen
[1] = 4;
610 wd
->ap
.ssid
[1][0] = 'v';
611 wd
->ap
.ssid
[1][1] = 'a';
612 wd
->ap
.ssid
[1][2] = 'p';
613 wd
->ap
.ssid
[1][3] = '1';
614 wd
->ap
.authAlgo
[1] = wd
->ws
.authMode
;
615 wd
->ap
.encryMode
[1] = wd
->ws
.encryMode
;
616 wd
->ap
.vapNumber
= 2;
619 wd
->ap
.apBitmap
= 0x1 | (0x01 << (vapId
+1));
621 if ((wd
->ws
.ssidLen
<= 32) && (wd
->ws
.ssidLen
!= 0)) {
622 wd
->ap
.ssidLen
[vapId
+1] = wd
->ws
.ssidLen
;
623 for (i
= 0; i
< wd
->ws
.ssidLen
; i
++)
624 wd
->ap
.ssid
[vapId
+1][i
] =
626 wd
->ws
.ssidLen
= 0; /* Reset Wrapper Variable */
629 if (wd
->ap
.encryMode
[vapId
+1] == 0)
630 wd
->ap
.capab
[vapId
+1] = 0x401;
632 wd
->ap
.capab
[vapId
+1] = 0x411;
634 wd
->ap
.authAlgo
[vapId
+1] = wd
->ws
.authMode
;
635 wd
->ap
.encryMode
[vapId
+1] = wd
->ws
.encryMode
;
637 /* Need to be modified when VAP is used */
638 /* wd->ap.vapNumber = 2; */
644 zfCoreSetFrequency(dev
, wd
->frequency
);
646 zfInitMacApMode(dev
);
648 /* Disable protection mode */
649 zfApSetProtectionMode(dev
, 0);
652 } else { /*if (wd->wlanMode == ZM_MODE_AP) */
654 zfScanMgrScanStop(dev
, ZM_SCAN_MGR_SCAN_INTERNAL
);
655 zfScanMgrScanStop(dev
, ZM_SCAN_MGR_SCAN_EXTERNAL
);
657 zmw_enter_critical_section(dev
);
658 wd
->sta
.oppositeCount
= 0; /* reset opposite count */
659 /* wd->sta.bAutoReconnect = wd->sta.bAutoReconnectEnabled; */
660 /* wd->sta.scanWithSSID = 0; */
661 zfStaInitOppositeInfo(dev
);
662 zmw_leave_critical_section(dev
);
664 zfStaResetStatus(dev
, 0);
666 if ((wd
->sta
.cmDisallowSsidLength
!= 0) &&
667 (wd
->sta
.ssidLen
== wd
->sta
.cmDisallowSsidLength
) &&
668 (zfMemoryIsEqual(wd
->sta
.ssid
, wd
->sta
.cmDisallowSsid
,
670 (wd
->sta
.wepStatus
== ZM_ENCRYPTION_TKIP
)) {/*countermeasures*/
671 zm_debug_msg0("countermeasures disallow association");
673 switch (wd
->wlanMode
) {
675 /* some registers may be set here */
676 if (wd
->sta
.authMode
== ZM_AUTH_MODE_WPA2PSK
)
677 zfHpSetApStaMode(dev
,
678 ZM_HAL_80211_MODE_IBSS_WPA2PSK
);
680 zfHpSetApStaMode(dev
,
681 ZM_HAL_80211_MODE_IBSS_GENERAL
);
683 zm_msg0_mm(ZM_LV_0
, "ZM_MODE_IBSS");
684 zfIbssConnectNetwork(dev
);
687 case ZM_MODE_INFRASTRUCTURE
:
688 /* some registers may be set here */
689 zfHpSetApStaMode(dev
, ZM_HAL_80211_MODE_STA
);
691 zfInfraConnectNetwork(dev
);
695 /* some registers may be set here */
696 zfHpSetApStaMode(dev
, ZM_HAL_80211_MODE_STA
);
698 zfUpdateBssid(dev
, bssid
);
699 zfCoreSetFrequency(dev
, wd
->frequency
);
710 /* if ((wd->wlanMode != ZM_MODE_INFRASTRUCTURE) &&
711 (wd->wlanMode != ZM_MODE_AP))
713 if (wd
->wlanMode
== ZM_MODE_PSEUDO
) {
714 /* Reset Wlan status */
717 if (wd
->zfcbConnectNotify
!= NULL
)
718 wd
->zfcbConnectNotify(dev
, ZM_STATUS_MEDIA_CONNECT
,
720 zfChangeAdapterState(dev
, ZM_STA_STATE_CONNECTED
);
724 if (wd
->wlanMode
== ZM_MODE_AP
) {
725 if (wd
->zfcbConnectNotify
!= NULL
)
726 wd
->zfcbConnectNotify(dev
, ZM_STATUS_MEDIA_CONNECT
,
728 /* zfChangeAdapterState(dev, ZM_STA_STATE_CONNECTED); */
731 /* Assign default Tx Rate */
732 if (wd
->sta
.EnableHT
) {
733 u32_t oneTxStreamCap
;
734 oneTxStreamCap
= (zfHpCapability(dev
) &
735 ZM_HP_CAP_11N_ONE_TX_STREAM
);
737 wd
->CurrentTxRateKbps
= 135000;
739 wd
->CurrentTxRateKbps
= 270000;
740 wd
->CurrentRxRateKbps
= 270000;
742 wd
->CurrentTxRateKbps
= 54000;
743 wd
->CurrentRxRateKbps
= 54000;
746 wd
->state
= ZM_WLAN_STATE_ENABLED
;
751 /* Enable/disable Wlan operation */
752 u16_t
zfiWlanEnable(zdev_t
*dev
)
756 zmw_get_wlan_dev(dev
);
758 zm_msg0_mm(ZM_LV_1
, "Enable Wlan");
760 zfGetWrapperSetting(dev
);
762 zfZeroMemory((u8_t
*) &wd
->trafTally
, sizeof(struct zsTrafTally
));
764 /* Reset cmMicFailureCount to 0 for new association request */
765 if (wd
->sta
.cmMicFailureCount
== 1) {
766 zfTimerCancel(dev
, ZM_EVENT_CM_TIMER
);
767 wd
->sta
.cmMicFailureCount
= 0;
771 if ((wd
->queueFlushed
& 0x10) != 0)
774 ret
= zfWlanEnable(dev
);
778 /* Add a flag named ResetKeyCache to show if KeyCache should be cleared.
779 for hostapd in AP mode, if driver receives iwconfig ioctl
780 after setting group key, it shouldn't clear KeyCache.
782 u16_t
zfiWlanDisable(zdev_t
*dev
, u8_t ResetKeyCache
)
787 zmw_get_wlan_dev(dev
);
789 #ifdef ZM_ENABLE_IBSS_WPA2PSK
790 zmw_declare_for_critical_section();
792 wd
->state
= ZM_WLAN_STATE_DISABLED
;
794 zm_msg0_mm(ZM_LV_1
, "Disable Wlan");
796 if (wd
->wlanMode
!= ZM_MODE_AP
) {
797 isConnected
= zfStaIsConnected(dev
);
799 if ((wd
->wlanMode
== ZM_MODE_INFRASTRUCTURE
) &&
800 (wd
->sta
.currentAuthMode
!= ZM_AUTH_MODE_WPA2
)) {
801 /* send deauthentication frame */
803 /* zfiWlanDeauth(dev, NULL, 0); */
804 zfSendMmFrame(dev
, ZM_WLAN_FRAME_TYPE_DEAUTH
,
805 wd
->sta
.bssid
, 3, 0, 0);
806 /* zmw_debug_msg0("send a Deauth frame!"); */
810 /* Remove all the connected peer stations */
811 if (wd
->wlanMode
== ZM_MODE_IBSS
) {
812 wd
->sta
.ibssBssIsCreator
= 0;
813 zfTimerCancel(dev
, ZM_EVENT_IBSS_MONITOR
);
814 zfStaIbssMonitoring(dev
, 1);
817 #ifdef ZM_ENABLE_IBSS_WPA2PSK
818 zmw_enter_critical_section(dev
);
819 wd
->sta
.ibssWpa2Psk
= 0;
820 zmw_leave_critical_section(dev
);
823 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_INIT
;
825 /* reset connect timeout counter */
826 wd
->sta
.connectTimeoutCount
= 0;
828 /* reset connectState to None */
829 wd
->sta
.connectState
= ZM_STA_CONN_STATE_NONE
;
831 /* reset leap enable variable */
832 wd
->sta
.leapEnabled
= 0;
834 /* Disable the RIFS Status/RIFS-like frame count/RIFS count */
835 if (wd
->sta
.rifsState
== ZM_RIFS_STATE_DETECTED
)
836 zfHpDisableRifs(dev
);
837 wd
->sta
.rifsState
= ZM_RIFS_STATE_DETECTING
;
838 wd
->sta
.rifsLikeFrameCnt
= 0;
839 wd
->sta
.rifsCount
= 0;
841 wd
->sta
.osRxFilter
= 0;
842 wd
->sta
.bSafeMode
= 0;
844 zfChangeAdapterState(dev
, ZM_STA_STATE_DISCONNECT
);
846 zfHpResetKeyCache(dev
);
849 if (wd
->zfcbConnectNotify
!= NULL
)
850 wd
->zfcbConnectNotify(dev
,
851 ZM_STATUS_MEDIA_CONNECTION_DISABLED
,
854 if (wd
->zfcbConnectNotify
!= NULL
)
855 wd
->zfcbConnectNotify(dev
,
856 ZM_STATUS_MEDIA_DISABLED
, wd
->sta
.bssid
);
858 } else { /* if (wd->wlanMode == ZM_MODE_AP) */
859 for (i
= 0; i
< ZM_MAX_STA_SUPPORT
; i
++) {
860 /* send deauthentication frame */
861 if (wd
->ap
.staTable
[i
].valid
== 1) {
862 /* Reason : Sending station is leaving */
863 zfSendMmFrame(dev
, ZM_WLAN_FRAME_TYPE_DEAUTH
,
864 wd
->ap
.staTable
[i
].addr
, 3, 0, 0);
869 zfHpResetKeyCache(dev
);
875 zfHpDisableBeacon(dev
);
877 /* Flush VTxQ and MmQ */
879 /* Flush AP PS queues */
880 zfApFlushBufferedPsFrame(dev
);
881 /* Free buffer in defragment list*/
882 zfAgingDefragList(dev
, 1);
884 #ifdef ZM_ENABLE_AGGREGATION
886 zfAggRxFreeBuf(dev
, 0); /* 1 for release structure memory */
887 /* end of add by honda */
890 /* Clear the information for the peer stations
891 of IBSS or AP of Station mode
893 zfZeroMemory((u8_t
*)wd
->sta
.oppositeInfo
,
894 sizeof(struct zsOppositeInfo
) * ZM_MAX_OPPOSITE_COUNT
);
896 /* Turn off Software WEP/TKIP */
897 if (wd
->sta
.SWEncryptEnable
!= 0) {
898 zm_debug_msg0("Disable software encryption");
899 zfStaDisableSWEncryption(dev
);
902 /* Improve WEP/TKIP performance with HT AP,
903 detail information please look bug#32495 */
904 /* zfHpSetTTSIFSTime(dev, 0x8); */
909 u16_t
zfiWlanSuspend(zdev_t
*dev
)
911 zmw_get_wlan_dev(dev
);
912 zmw_declare_for_critical_section();
914 /* Change the HAL state to init so that any packet
915 can't be transmitted between resume & HAL reinit.
916 This would cause the chip hang issue in OTUS.
918 zmw_enter_critical_section(dev
);
919 wd
->halState
= ZM_HAL_STATE_INIT
;
920 zmw_leave_critical_section(dev
);
925 u16_t
zfiWlanResume(zdev_t
*dev
, u8_t doReconn
)
928 zmw_get_wlan_dev(dev
);
929 zmw_declare_for_critical_section();
931 /* Redownload firmware, Reinit MAC,PHY,RF */
932 zfHpReinit(dev
, wd
->frequency
);
934 /* Set channel according to AP's configuration */
935 zfCoreSetFrequencyExV2(dev
, wd
->frequency
, wd
->BandWidth40
,
936 wd
->ExtOffset
, NULL
, 1);
938 zfHpSetMacAddress(dev
, wd
->macAddr
, 0);
945 if (wd
->wlanMode
!= ZM_MODE_INFRASTRUCTURE
&&
946 wd
->wlanMode
!= ZM_MODE_IBSS
)
949 zm_msg0_mm(ZM_LV_1
, "Resume Wlan");
950 if ((zfStaIsConnected(dev
)) || (zfStaIsConnecting(dev
))) {
952 zm_msg0_mm(ZM_LV_1
, "Re-connect...");
953 zmw_enter_critical_section(dev
);
954 wd
->sta
.connectByReasso
= FALSE
;
955 zmw_leave_critical_section(dev
);
958 } else if (doReconn
== 0)
959 zfHpSetRollCallTable(dev
);
967 /************************************************************************/
969 /* FUNCTION DESCRIPTION zfiWlanFlushAllQueuedBuffers */
970 /* Flush Virtual TxQ, MmQ, PS frames and defragment list */
973 /* dev : device pointer */
979 /* Stephen Chen Atheros Communications, INC. 2007.1 */
981 /************************************************************************/
982 void zfiWlanFlushAllQueuedBuffers(zdev_t
*dev
)
984 /* Flush VTxQ and MmQ */
986 /* Flush AP PS queues */
987 zfApFlushBufferedPsFrame(dev
);
988 /* Free buffer in defragment list*/
989 zfAgingDefragList(dev
, 1);
992 /* Do WLAN site survey */
993 u16_t
zfiWlanScan(zdev_t
*dev
)
996 zmw_get_wlan_dev(dev
);
1000 zmw_declare_for_critical_section();
1002 zmw_enter_critical_section(dev
);
1004 if (wd
->wlanMode
== ZM_MODE_AP
) {
1005 wd
->heartBeatNotification
|= ZM_BSSID_LIST_SCAN
;
1006 wd
->sta
.scanFrequency
= 0;
1007 /* wd->sta.pUpdateBssList->bssCount = 0; */
1011 if (!zfStaBlockWlanScan(dev
)) {
1012 zm_debug_msg0("scan request");
1013 /*zfTimerSchedule(dev, ZM_EVENT_SCAN, ZM_TICK_ZERO);*/
1022 zmw_leave_critical_section(dev
);
1027 zmw_leave_critical_section(dev
);
1029 if (wd
->ledStruct
.LEDCtrlFlagFromReg
& ZM_LED_CTRL_FLAG_ALPHA
) {
1030 /* flag for Alpha */
1031 wd
->ledStruct
.LEDCtrlFlag
|= ZM_LED_CTRL_FLAG_ALPHA
;
1034 ret
= zfScanMgrScanStart(dev
, ZM_SCAN_MGR_SCAN_EXTERNAL
);
1036 zm_debug_msg1("ret = ", ret
);
1058 u16_t zcRateToMCS
[] =
1059 {0xff, 0, 1, 2, 3, 0xb, 0xf, 0xa, 0xe, 0x9, 0xd, 0x8, 0xc};
1060 u16_t zcRateToMT
[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
1062 u16_t
zfiWlanSetTxRate(zdev_t
*dev
, u16_t rate
)
1065 zmw_get_wlan_dev(dev
);
1068 wd
->txMCS
= zcRateToMCS
[rate
];
1069 wd
->txMT
= zcRateToMT
[rate
];
1071 } else if ((rate
<= 28) || (rate
== 13 + 32)) {
1072 wd
->txMCS
= rate
- 12 - 1;
1077 return ZM_ERR_INVALID_TX_RATE
;
1080 const u32_t zcRateIdToKbps40M
[] =
1082 1000, 2000, 5500, 11000, /* 1M, 2M, 5M, 11M , 0 1 2 3 */
1083 6000, 9000, 12000, 18000, /* 6M 9M 12M 18M , 4 5 6 7 */
1084 24000, 36000, 48000, 54000, /* 24M 36M 48M 54M , 8 9 10 11 */
1085 13500, 27000, 40500, 54000, /* MCS0 MCS1 MCS2 MCS3 , 12 13 14 15 */
1086 81000, 108000, 121500, 135000, /* MCS4 MCS5 MCS6 MCS7 , 16 17 18 19 */
1087 27000, 54000, 81000, 108000, /* MCS8 MCS9 MCS10 MCS11 , 20 21 22 23 */
1088 162000, 216000, 243000, 270000, /*MCS12 MCS13 MCS14 MCS15, 24 25 26 27*/
1089 270000, 300000, 150000 /* MCS14SG, MCS15SG, MCS7SG , 28 29 30 */
1092 const u32_t zcRateIdToKbps20M
[] =
1094 1000, 2000, 5500, 11000, /* 1M, 2M, 5M, 11M , 0 1 2 3 */
1095 6000, 9000, 12000, 18000, /* 6M 9M 12M 18M , 4 5 6 7 */
1096 24000, 36000, 48000, 54000, /* 24M 36M 48M 54M , 8 9 10 11 */
1097 6500, 13000, 19500, 26000, /* MCS0 MCS1 MCS2 MCS3 , 12 13 14 15 */
1098 39000, 52000, 58500, 65000, /* MCS4 MCS5 MCS6 MCS7 , 16 17 18 19 */
1099 13000, 26000, 39000, 52000, /* MCS8 MCS9 MCS10 MCS11 , 20 21 22 23 */
1100 78000, 104000, 117000, 130000, /* MCS12 MCS13 MCS14 MCS15, 24 25 26 27*/
1101 130000, 144400, 72200 /* MCS14SG, MCS15SG, MSG7SG , 28 29 30 */
1104 u32_t
zfiWlanQueryTxRate(zdev_t
*dev
)
1107 zmw_get_wlan_dev(dev
);
1108 zmw_declare_for_critical_section();
1110 /* If Tx rate had not been trained, return maximum Tx rate instead */
1111 if ((wd
->wlanMode
== ZM_MODE_INFRASTRUCTURE
) &&
1112 (zfStaIsConnected(dev
))) {
1113 zmw_enter_critical_section(dev
);
1114 /* Not in fixed rate mode */
1115 if (wd
->txMCS
== 0xff) {
1116 if ((wd
->sta
.oppositeInfo
[0].rcCell
.flag
&
1117 ZM_RC_TRAINED_BIT
) == 0)
1118 rateId
= wd
->sta
.oppositeInfo
[0].rcCell
. \
1119 operationRateSet
[wd
->sta
.oppositeInfo
[0]. \
1120 rcCell
.operationRateCount
-1];
1122 rateId
= wd
->sta
.oppositeInfo
[0].rcCell
. \
1123 operationRateSet
[wd
->sta
.oppositeInfo
[0]. \
1124 rcCell
.currentRateIndex
];
1126 zmw_leave_critical_section(dev
);
1129 if (rateId
!= 0xff) {
1130 if (wd
->sta
.htCtrlBandwidth
)
1131 return zcRateIdToKbps40M
[rateId
];
1133 return zcRateIdToKbps20M
[rateId
];
1135 return wd
->CurrentTxRateKbps
;
1138 void zfWlanUpdateRxRate(zdev_t
*dev
, struct zsAdditionInfo
*addInfo
)
1141 zmw_get_wlan_dev(dev
);
1142 /* zm_msg1_mm(ZM_LV_0, "addInfo->Tail.Data.RxMacStatus =",
1143 * addInfo->Tail.Data.RxMacStatus & 0x03);
1146 /* b5~b4: MPDU indication. */
1147 /* 00: Single MPDU. */
1148 /* 10: First MPDU of A-MPDU. */
1149 /* 11: Middle MPDU of A-MPDU. */
1150 /* 01: Last MPDU of A-MPDU. */
1151 /* Only First MPDU and Single MPDU have PLCP header */
1152 /* First MPDU : (mpduInd & 0x30) == 0x00 */
1153 /* Single MPDU : (mpduInd & 0x30) == 0x20 */
1154 if ((addInfo
->Tail
.Data
.RxMacStatus
& 0x10) == 0) {
1155 /* Modulation type */
1156 wd
->modulationType
= addInfo
->Tail
.Data
.RxMacStatus
& 0x03;
1157 switch (wd
->modulationType
) {
1160 wd
->rateField
= addInfo
->PlcpHeader
[0] & 0xff;
1163 /* Legacy-OFDM mode */
1165 wd
->rateField
= addInfo
->PlcpHeader
[0] & 0x0f;
1170 wd
->rateField
= addInfo
->PlcpHeader
[3];
1171 wd
->rxInfo
= addInfo
->PlcpHeader
[6];
1177 rxRateKbps
= zfUpdateRxRate(dev
);
1178 if (wd
->CurrentRxRateUpdated
== 1) {
1179 if (rxRateKbps
> wd
->CurrentRxRateKbps
)
1180 wd
->CurrentRxRateKbps
= rxRateKbps
;
1182 wd
->CurrentRxRateKbps
= rxRateKbps
;
1183 wd
->CurrentRxRateUpdated
= 1;
1189 u16_t zcIndextoRateBG
[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0, 48000,
1190 24000, 12000, 6000, 54000, 36000, 18000, 9000};
1191 u32_t zcIndextoRateN20L
[16] = {6500, 13000, 19500, 26000, 39000, 52000, 58500,
1192 65000, 13000, 26000, 39000, 52000, 78000, 104000,
1194 u32_t zcIndextoRateN20S
[16] = {7200, 14400, 21700, 28900, 43300, 57800, 65000,
1195 72200, 14400, 28900, 43300, 57800, 86700, 115600,
1197 u32_t zcIndextoRateN40L
[16] = {13500, 27000, 40500, 54000, 81000, 108000,
1198 121500, 135000, 27000, 54000, 81000, 108000,
1199 162000, 216000, 243000, 270000};
1200 u32_t zcIndextoRateN40S
[16] = {15000, 30000, 45000, 60000, 90000, 120000,
1201 135000, 150000, 30000, 60000, 90000, 120000,
1202 180000, 240000, 270000, 300000};
1205 extern u16_t zcIndextoRateBG
[16];
1206 extern u32_t zcIndextoRateN20L
[16];
1207 extern u32_t zcIndextoRateN20S
[16];
1208 extern u32_t zcIndextoRateN40L
[16];
1209 extern u32_t zcIndextoRateN40S
[16];
1211 u32_t
zfiWlanQueryRxRate(zdev_t
*dev
)
1213 zmw_get_wlan_dev(dev
);
1215 wd
->CurrentRxRateUpdated
= 0;
1216 return wd
->CurrentRxRateKbps
;
1219 u32_t
zfUpdateRxRate(zdev_t
*dev
)
1221 u8_t mcs
, bandwidth
;
1222 u32_t rxRateKbps
= 130000;
1223 zmw_get_wlan_dev(dev
);
1225 switch (wd
->modulationType
) {
1228 switch (wd
->rateField
) {
1245 /* Legacy-OFDM mode */
1247 if (wd
->rateField
<= 15)
1248 rxRateKbps
= zcIndextoRateBG
[wd
->rateField
];
1252 mcs
= wd
->rateField
& 0x7F;
1253 bandwidth
= wd
->rateField
& 0x80;
1255 if (bandwidth
!= 0) {
1256 if ((wd
->rxInfo
& 0x80) != 0) {
1257 /* Short GI 40 MHz MIMO Rate */
1258 rxRateKbps
= zcIndextoRateN40S
[mcs
];
1260 /* Long GI 40 MHz MIMO Rate */
1261 rxRateKbps
= zcIndextoRateN40L
[mcs
];
1264 if ((wd
->rxInfo
& 0x80) != 0) {
1265 /* Short GI 20 MHz MIMO Rate */
1266 rxRateKbps
= zcIndextoRateN20S
[mcs
];
1268 /* Long GI 20 MHz MIMO Rate */
1269 rxRateKbps
= zcIndextoRateN20L
[mcs
];
1277 /* zm_msg1_mm(ZM_LV_0, "wd->CurrentRxRateKbps=",
1278 wd->CurrentRxRateKbps);
1281 /* ToDo: use bandwith field to define 40MB */
1285 /* Get WLAN stastics */
1286 u16_t
zfiWlanGetStatistics(zdev_t
*dev
)
1288 /* Return link statistics */
1292 u16_t
zfiWlanReset(zdev_t
*dev
)
1294 zmw_get_wlan_dev(dev
);
1296 wd
->state
= ZM_WLAN_STATE_DISABLED
;
1298 return zfWlanReset(dev
);
1302 u16_t
zfWlanReset(zdev_t
*dev
)
1305 zmw_get_wlan_dev(dev
);
1307 zmw_declare_for_critical_section();
1309 zm_debug_msg0("zfWlanReset");
1311 isConnected
= zfStaIsConnected(dev
);
1313 /* if ( wd->wlanMode != ZM_MODE_AP ) */
1315 if ((wd
->wlanMode
== ZM_MODE_INFRASTRUCTURE
) &&
1316 (wd
->sta
.currentAuthMode
!= ZM_AUTH_MODE_WPA2
)) {
1317 /* send deauthentication frame */
1319 /* zfiWlanDeauth(dev, NULL, 0); */
1320 zfSendMmFrame(dev
, ZM_WLAN_FRAME_TYPE_DEAUTH
,
1321 wd
->sta
.bssid
, 3, 0, 0);
1322 /* zmw_debug_msg0("send a Deauth frame!"); */
1327 zfChangeAdapterState(dev
, ZM_STA_STATE_DISCONNECT
);
1328 zfHpResetKeyCache(dev
);
1331 /* zfiWlanDisable(dev); */
1332 if (wd
->zfcbConnectNotify
!= NULL
)
1333 wd
->zfcbConnectNotify(dev
,
1334 ZM_STATUS_MEDIA_CONNECTION_RESET
, wd
->sta
.bssid
);
1336 if (wd
->zfcbConnectNotify
!= NULL
)
1337 wd
->zfcbConnectNotify(dev
, ZM_STATUS_MEDIA_RESET
,
1342 zfHpDisableBeacon(dev
);
1344 /* Free buffer in defragment list*/
1345 zfAgingDefragList(dev
, 1);
1347 /* Flush VTxQ and MmQ */
1350 #ifdef ZM_ENABLE_AGGREGATION
1352 zfAggRxFreeBuf(dev
, 0); /* 1 for release structure memory */
1353 /* end of add by honda */
1356 zfStaRefreshBlockList(dev
, 1);
1358 zmw_enter_critical_section(dev
);
1360 zfTimerCancel(dev
, ZM_EVENT_IBSS_MONITOR
);
1361 zfTimerCancel(dev
, ZM_EVENT_CM_BLOCK_TIMER
);
1362 zfTimerCancel(dev
, ZM_EVENT_CM_DISCONNECT
);
1364 wd
->sta
.connectState
= ZM_STA_CONN_STATE_NONE
;
1365 wd
->sta
.connectByReasso
= FALSE
;
1366 wd
->sta
.cmDisallowSsidLength
= 0;
1367 wd
->sta
.bAutoReconnect
= 0;
1368 wd
->sta
.InternalScanReq
= 0;
1369 wd
->sta
.encryMode
= ZM_NO_WEP
;
1370 wd
->sta
.wepStatus
= ZM_ENCRYPTION_WEP_DISABLED
;
1371 wd
->sta
.wpaState
= ZM_STA_WPA_STATE_INIT
;
1372 wd
->sta
.cmMicFailureCount
= 0;
1373 wd
->sta
.ibssBssIsCreator
= 0;
1374 #ifdef ZM_ENABLE_IBSS_WPA2PSK
1375 wd
->sta
.ibssWpa2Psk
= 0;
1377 /* reset connect timeout counter */
1378 wd
->sta
.connectTimeoutCount
= 0;
1380 /* reset leap enable variable */
1381 wd
->sta
.leapEnabled
= 0;
1383 /* Reset the RIFS Status / RIFS-like frame count / RIFS count */
1384 if (wd
->sta
.rifsState
== ZM_RIFS_STATE_DETECTED
)
1385 zfHpDisableRifs(dev
);
1386 wd
->sta
.rifsState
= ZM_RIFS_STATE_DETECTING
;
1387 wd
->sta
.rifsLikeFrameCnt
= 0;
1388 wd
->sta
.rifsCount
= 0;
1390 wd
->sta
.osRxFilter
= 0;
1391 wd
->sta
.bSafeMode
= 0;
1393 /* Clear the information for the peer
1394 stations of IBSS or AP of Station mode
1396 zfZeroMemory((u8_t
*)wd
->sta
.oppositeInfo
,
1397 sizeof(struct zsOppositeInfo
) * ZM_MAX_OPPOSITE_COUNT
);
1399 zmw_leave_critical_section(dev
);
1401 zfScanMgrScanStop(dev
, ZM_SCAN_MGR_SCAN_INTERNAL
);
1402 zfScanMgrScanStop(dev
, ZM_SCAN_MGR_SCAN_EXTERNAL
);
1404 /* Turn off Software WEP/TKIP */
1405 if (wd
->sta
.SWEncryptEnable
!= 0) {
1406 zm_debug_msg0("Disable software encryption");
1407 zfStaDisableSWEncryption(dev
);
1410 /* Improve WEP/TKIP performance with HT AP,
1411 detail information please look bug#32495
1413 /* zfHpSetTTSIFSTime(dev, 0x8); */
1415 /* Keep Pseudo mode */
1416 if (wd
->wlanMode
!= ZM_MODE_PSEUDO
)
1417 wd
->wlanMode
= ZM_MODE_INFRASTRUCTURE
;
1422 /* Deauthenticate a STA */
1423 u16_t
zfiWlanDeauth(zdev_t
*dev
, u16_t
*macAddr
, u16_t reason
)
1425 zmw_get_wlan_dev(dev
);
1427 if (wd
->wlanMode
== ZM_MODE_AP
) {
1431 * we will reset all key in zfHpResetKeyCache() when call
1432 * zfiWlanDisable(), if we want to reset PairwiseKey for each
1433 * sta, need to use a nullAddr to let keyindex not match.
1434 * otherwise hardware will still find PairwiseKey when AP change
1435 * encryption mode from WPA to WEP
1439 id = zfApFindSta(dev, macAddr);
1443 u16_t nullAddr[3] = { 0x0, 0x0, 0x0 };
1445 if (wd->ap.staTable[i].encryMode != ZM_NO_WEP)
1447 zfHpSetApPairwiseKey(dev, nullAddr,
1448 ZM_NO_WEP, &key[0], &key[4], i+1);
1450 //zfHpSetApPairwiseKey(dev, (u16_t *)macAddr,
1451 // ZM_NO_WEP, &key[0], &key[4], id+1);
1452 wd->ap.staTable[id].encryMode = ZM_NO_WEP;
1453 wd->ap.staTable[id].keyIdx = 0xff;
1457 zfSendMmFrame(dev
, ZM_WLAN_FRAME_TYPE_DEAUTH
, macAddr
,
1460 zfSendMmFrame(dev
, ZM_WLAN_FRAME_TYPE_DEAUTH
,
1461 wd
->sta
.bssid
, 3, 0, 0);
1463 /* Issue DEAUTH command to FW */
1468 /* XP packet filter feature : */
1469 /* 1=>enable: All multicast address packets, not just the ones */
1470 /* enumerated in the multicast address list. */
1472 void zfiWlanSetAllMulticast(zdev_t
*dev
, u32_t setting
)
1474 zmw_get_wlan_dev(dev
);
1475 zm_msg1_mm(ZM_LV_0
, "sta.bAllMulticast = ", setting
);
1476 wd
->sta
.bAllMulticast
= (u8_t
)setting
;
1480 /* HT configure API */
1481 void zfiWlanSetHTCtrl(zdev_t
*dev
, u32_t
*setting
, u32_t forceTxTPC
)
1483 zmw_get_wlan_dev(dev
);
1485 wd
->preambleType
= (u8_t
)setting
[0];
1486 wd
->sta
.preambleTypeHT
= (u8_t
)setting
[1];
1487 wd
->sta
.htCtrlBandwidth
= (u8_t
)setting
[2];
1488 wd
->sta
.htCtrlSTBC
= (u8_t
)setting
[3];
1489 wd
->sta
.htCtrlSG
= (u8_t
)setting
[4];
1490 wd
->sta
.defaultTA
= (u8_t
)setting
[5];
1491 wd
->enableAggregation
= (u8_t
)setting
[6];
1492 wd
->enableWDS
= (u8_t
)setting
[7];
1494 wd
->forceTxTPC
= forceTxTPC
;
1497 /* FB50 in OS XP, RD private test code */
1498 void zfiWlanQueryHTCtrl(zdev_t
*dev
, u32_t
*setting
, u32_t
*forceTxTPC
)
1500 zmw_get_wlan_dev(dev
);
1502 setting
[0] = wd
->preambleType
;
1503 setting
[1] = wd
->sta
.preambleTypeHT
;
1504 setting
[2] = wd
->sta
.htCtrlBandwidth
;
1505 setting
[3] = wd
->sta
.htCtrlSTBC
;
1506 setting
[4] = wd
->sta
.htCtrlSG
;
1507 setting
[5] = wd
->sta
.defaultTA
;
1508 setting
[6] = wd
->enableAggregation
;
1509 setting
[7] = wd
->enableWDS
;
1511 *forceTxTPC
= wd
->forceTxTPC
;
1514 void zfiWlanDbg(zdev_t
*dev
, u8_t setting
)
1516 zmw_get_wlan_dev(dev
);
1518 wd
->enableHALDbgInfo
= setting
;
1521 /* FB50 in OS XP, RD private test code */
1522 void zfiWlanSetRxPacketDump(zdev_t
*dev
, u32_t setting
)
1524 zmw_get_wlan_dev(dev
);
1526 wd
->rxPacketDump
= 1; /* enable */
1528 wd
->rxPacketDump
= 0; /* disable */
1532 /* FB50 in OS XP, RD private test code */
1534 void zfiWlanResetTally(zdev_t
*dev
)
1536 zmw_get_wlan_dev(dev
);
1538 zmw_declare_for_critical_section();
1540 zmw_enter_critical_section(dev
);
1542 wd
->commTally
.txUnicastFrm
= 0; /* txUnicastFrames */
1543 wd
->commTally
.txMulticastFrm
= 0; /* txMulticastFrames */
1544 wd
->commTally
.txUnicastOctets
= 0; /* txUniOctets byte size */
1545 wd
->commTally
.txMulticastOctets
= 0; /* txMultiOctets byte size */
1546 wd
->commTally
.txFrmUpperNDIS
= 0;
1547 wd
->commTally
.txFrmDrvMgt
= 0;
1548 wd
->commTally
.RetryFailCnt
= 0;
1549 wd
->commTally
.Hw_TotalTxFrm
= 0; /* Hardware total Tx Frame */
1550 wd
->commTally
.Hw_RetryCnt
= 0; /* txMultipleRetriesFrames */
1551 wd
->commTally
.Hw_UnderrunCnt
= 0;
1552 wd
->commTally
.DriverRxFrmCnt
= 0;
1553 wd
->commTally
.rxUnicastFrm
= 0; /* rxUnicastFrames */
1554 wd
->commTally
.rxMulticastFrm
= 0; /* rxMulticastFrames */
1555 wd
->commTally
.NotifyNDISRxFrmCnt
= 0;
1556 wd
->commTally
.rxUnicastOctets
= 0; /* rxUniOctets byte size */
1557 wd
->commTally
.rxMulticastOctets
= 0; /* rxMultiOctets byte size */
1558 wd
->commTally
.DriverDiscardedFrm
= 0; /* Discard by ValidateFrame */
1559 wd
->commTally
.LessThanDataMinLen
= 0;
1560 wd
->commTally
.GreaterThanMaxLen
= 0;
1561 wd
->commTally
.DriverDiscardedFrmCauseByMulticastList
= 0;
1562 wd
->commTally
.DriverDiscardedFrmCauseByFrmCtrl
= 0;
1563 wd
->commTally
.rxNeedFrgFrm
= 0; /* need more frg frm */
1564 wd
->commTally
.DriverRxMgtFrmCnt
= 0;
1565 wd
->commTally
.rxBroadcastFrm
= 0;/* Receive broadcast frame count */
1566 wd
->commTally
.rxBroadcastOctets
= 0;/*Receive broadcast framebyte size*/
1567 wd
->commTally
.Hw_TotalRxFrm
= 0;
1568 wd
->commTally
.Hw_CRC16Cnt
= 0; /* rxPLCPCRCErrCnt */
1569 wd
->commTally
.Hw_CRC32Cnt
= 0; /* rxCRC32ErrCnt */
1570 wd
->commTally
.Hw_DecrypErr_UNI
= 0;
1571 wd
->commTally
.Hw_DecrypErr_Mul
= 0;
1572 wd
->commTally
.Hw_RxFIFOOverrun
= 0;
1573 wd
->commTally
.Hw_RxTimeOut
= 0;
1574 wd
->commTally
.LossAP
= 0;
1576 wd
->commTally
.Tx_MPDU
= 0;
1577 wd
->commTally
.BA_Fail
= 0;
1578 wd
->commTally
.Hw_Tx_AMPDU
= 0;
1579 wd
->commTally
.Hw_Tx_MPDU
= 0;
1581 wd
->commTally
.txQosDropCount
[0] = 0;
1582 wd
->commTally
.txQosDropCount
[1] = 0;
1583 wd
->commTally
.txQosDropCount
[2] = 0;
1584 wd
->commTally
.txQosDropCount
[3] = 0;
1585 wd
->commTally
.txQosDropCount
[4] = 0;
1587 wd
->commTally
.Hw_RxMPDU
= 0;
1588 wd
->commTally
.Hw_RxDropMPDU
= 0;
1589 wd
->commTally
.Hw_RxDelMPDU
= 0;
1591 wd
->commTally
.Hw_RxPhyMiscError
= 0;
1592 wd
->commTally
.Hw_RxPhyXRError
= 0;
1593 wd
->commTally
.Hw_RxPhyOFDMError
= 0;
1594 wd
->commTally
.Hw_RxPhyCCKError
= 0;
1595 wd
->commTally
.Hw_RxPhyHTError
= 0;
1596 wd
->commTally
.Hw_RxPhyTotalCount
= 0;
1598 #if (defined(GCCK) && defined(OFDM))
1599 wd
->commTally
.rx11bDataFrame
= 0;
1600 wd
->commTally
.rxOFDMDataFrame
= 0;
1603 zmw_leave_critical_section(dev
);
1606 /* FB50 in OS XP, RD private test code */
1607 void zfiWlanQueryTally(zdev_t
*dev
, struct zsCommTally
*tally
)
1609 zmw_get_wlan_dev(dev
);
1611 zmw_declare_for_critical_section();
1613 zmw_enter_critical_section(dev
);
1614 zfMemoryCopy((u8_t
*)tally
, (u8_t
*)&wd
->commTally
,
1615 sizeof(struct zsCommTally
));
1616 zmw_leave_critical_section(dev
);
1619 void zfiWlanQueryTrafTally(zdev_t
*dev
, struct zsTrafTally
*tally
)
1621 zmw_get_wlan_dev(dev
);
1623 zmw_declare_for_critical_section();
1625 zmw_enter_critical_section(dev
);
1626 zfMemoryCopy((u8_t
*)tally
, (u8_t
*)&wd
->trafTally
,
1627 sizeof(struct zsTrafTally
));
1628 zmw_leave_critical_section(dev
);
1631 void zfiWlanQueryMonHalRxInfo(zdev_t
*dev
, struct zsMonHalRxInfo
*monHalRxInfo
)
1633 zfHpQueryMonHalRxInfo(dev
, (u8_t
*)monHalRxInfo
);
1636 /* parse the modeMDKEnable to DrvCore */
1637 void zfiDKEnable(zdev_t
*dev
, u32_t enable
)
1639 zmw_get_wlan_dev(dev
);
1641 wd
->modeMDKEnable
= enable
;
1642 zm_debug_msg1("modeMDKEnable = ", wd
->modeMDKEnable
);
1646 u32_t
zfiWlanQueryPacketTypePromiscuous(zdev_t
*dev
)
1648 zmw_get_wlan_dev(dev
);
1650 return wd
->swSniffer
;
1654 void zfiWlanSetPacketTypePromiscuous(zdev_t
*dev
, u32_t setValue
)
1656 zmw_get_wlan_dev(dev
);
1658 wd
->swSniffer
= setValue
;
1659 zm_msg1_mm(ZM_LV_0
, "wd->swSniffer ", wd
->swSniffer
);
1661 /* write register for sniffer mode */
1662 zfHpSetSnifferMode(dev
, 1);
1663 zm_msg0_mm(ZM_LV_1
, "enable sniffer mode");
1665 zfHpSetSnifferMode(dev
, 0);
1666 zm_msg0_mm(ZM_LV_0
, "disalbe sniffer mode");
1670 void zfiWlanSetXLinkMode(zdev_t
*dev
, u32_t setValue
)
1672 zmw_get_wlan_dev(dev
);
1674 wd
->XLinkMode
= setValue
;
1676 /* write register for sniffer mode */
1677 zfHpSetSnifferMode(dev
, 1);
1679 zfHpSetSnifferMode(dev
, 0);
1682 extern void zfStaChannelManagement(zdev_t
*dev
, u8_t scan
);
1684 void zfiSetChannelManagement(zdev_t
*dev
, u32_t setting
)
1686 zmw_get_wlan_dev(dev
);
1690 wd
->sta
.EnableHT
= 1;
1691 wd
->BandWidth40
= 1;
1695 wd
->sta
.EnableHT
= 1;
1696 wd
->BandWidth40
= 1;
1700 wd
->sta
.EnableHT
= 1;
1701 wd
->BandWidth40
= 0;
1705 wd
->BandWidth40
= 0;
1710 zfCoreSetFrequencyEx(dev
, wd
->frequency
, wd
->BandWidth40
,
1711 wd
->ExtOffset
, NULL
);
1714 void zfiSetRifs(zdev_t
*dev
, u16_t setting
)
1716 zmw_get_wlan_dev(dev
);
1718 wd
->sta
.ie
.HtInfo
.ChannelInfo
|= ExtHtCap_RIFSMode
;
1719 wd
->sta
.EnableHT
= 1;
1724 /* zfHpSetRifs(dev, 1, 0,
1725 * (wd->sta.currentFrequency < 3000)? 1:0);
1730 /* zfHpSetRifs(dev, 1, 1,
1731 * (wd->sta.currentFrequency < 3000)? 1:0);
1736 /* zfHpSetRifs(dev, 1, 0,
1737 * (wd->sta.currentFrequency < 3000)? 1:0);
1743 void zfiCheckRifs(zdev_t
*dev
)
1745 zmw_get_wlan_dev(dev
);
1747 if (wd
->sta
.ie
.HtInfo
.ChannelInfo
& ExtHtCap_RIFSMode
)
1749 /* zfHpSetRifs(dev, wd->sta.EnableHT, wd->sta.HT2040,
1750 * (wd->sta.currentFrequency < 3000)? 1:0);
1754 void zfiSetReorder(zdev_t
*dev
, u16_t value
)
1756 zmw_get_wlan_dev(dev
);
1758 wd
->reorder
= value
;
1761 void zfiSetSeqDebug(zdev_t
*dev
, u16_t value
)
1763 zmw_get_wlan_dev(dev
);
1765 wd
->seq_debug
= value
;