Commit | Line | Data |
---|---|---|
4bd43f50 LR |
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 | /* Module Name : cmd.c */ | |
18 | /* */ | |
19 | /* Abstract */ | |
20 | /* This module contains command interface functions. */ | |
21 | /* */ | |
22 | /* NOTES */ | |
23 | /* None */ | |
24 | /* */ | |
25 | /************************************************************************/ | |
26 | #include "cprecomp.h" | |
27 | #include "../hal/hpreg.h" | |
28 | ||
29 | ||
afbd545d DZ |
30 | u16_t zfWlanReset(zdev_t *dev); |
31 | u32_t zfUpdateRxRate(zdev_t *dev); | |
4bd43f50 LR |
32 | |
33 | ||
34 | extern void zfiUsbRecv(zdev_t *dev, zbuf_t *buf); | |
afbd545d DZ |
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); | |
4bd43f50 LR |
39 | |
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 */ | |
afbd545d | 43 | u16_t zfiGlobalDataSize(zdev_t *dev) |
4bd43f50 | 44 | { |
afbd545d DZ |
45 | u32_t ret; |
46 | ret = (sizeof(struct zsWlanDev)); | |
47 | zm_assert((ret>>16) == 0); | |
48 | return (u16_t)ret; | |
4bd43f50 LR |
49 | } |
50 | ||
51 | ||
52 | /* Initialize WLAN hardware and software, resource will be allocated */ | |
53 | /* for WLAN operation, must be called first before other function. */ | |
afbd545d | 54 | extern u16_t zfiWlanOpen(zdev_t *dev, struct zsCbFuncTbl *cbFuncTbl) |
4bd43f50 | 55 | { |
afbd545d DZ |
56 | /* u16_t ret; |
57 | u32_t i; | |
58 | u8_t* ch; | |
59 | u8_t bPassive; | |
60 | */ | |
61 | u32_t devSize; | |
62 | struct zfCbUsbFuncTbl cbUsbFuncTbl; | |
63 | zmw_get_wlan_dev(dev); | |
4bd43f50 | 64 | |
afbd545d | 65 | zm_debug_msg0("start"); |
4bd43f50 | 66 | |
afbd545d DZ |
67 | devSize = sizeof(struct zsWlanDev); |
68 | /* Zeroize zsWlanDev struct */ | |
69 | zfZeroMemory((u8_t *)wd, (u16_t)devSize); | |
4bd43f50 LR |
70 | |
71 | #ifdef ZM_ENABLE_AGGREGATION | |
afbd545d | 72 | zfAggInit(dev); |
4bd43f50 LR |
73 | #endif |
74 | ||
afbd545d DZ |
75 | zfCwmInit(dev); |
76 | ||
77 | wd->commTally.RateCtrlTxMPDU = 0; | |
78 | wd->commTally.RateCtrlBAFail = 0; | |
79 | wd->preambleTypeInUsed = ZM_PREAMBLE_TYPE_SHORT; | |
80 | ||
81 | if (cbFuncTbl == NULL) { | |
82 | /* zfcbRecvEth() is mandatory */ | |
83 | zm_assert(0); | |
84 | } else { | |
85 | if (cbFuncTbl->zfcbRecvEth == NULL) { | |
86 | /* zfcbRecvEth() is mandatory */ | |
87 | zm_assert(0); | |
88 | } | |
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; | |
4bd43f50 | 105 | #ifdef ZM_ENABLE_CENC |
afbd545d DZ |
106 | wd->zfcbCencAsocNotify = cbFuncTbl->zfcbCencAsocNotify; |
107 | #endif /* ZM_ENABLE_CENC */ | |
108 | wd->zfcbClassifyTxPacket = cbFuncTbl->zfcbClassifyTxPacket; | |
109 | wd->zfcbHwWatchDogNotify = cbFuncTbl->zfcbHwWatchDogNotify; | |
110 | } | |
111 | ||
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; | |
122 | ||
123 | wd->regulationTable.regionCode = 0xffff; | |
124 | ||
125 | zfHpInit(dev, wd->frequency); | |
126 | ||
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); */ | |
4bd43f50 | 133 | #ifdef ZM_AP_DEBUG |
afbd545d | 134 | /* wd->frequency = 2437; */ |
4bd43f50 LR |
135 | #endif |
136 | ||
afbd545d DZ |
137 | /* STA mode */ |
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; | |
144 | ||
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; | |
152 | */ | |
4bd43f50 LR |
153 | { |
154 | u8_t Dur = ZM_TIME_ACTIVE_SCAN; | |
155 | zfwGetActiveScanDur(dev, &Dur); | |
afbd545d | 156 | wd->sta.activescanTickPerChannel = Dur / ZM_MS_PER_TICK; |
4bd43f50 LR |
157 | |
158 | } | |
afbd545d DZ |
159 | wd->sta.passiveScanTickPerChannel = ZM_TIME_PASSIVE_SCAN/ZM_MS_PER_TICK; |
160 | wd->sta.bAutoReconnect = TRUE; | |
161 | wd->sta.dropUnencryptedPkts = FALSE; | |
4bd43f50 | 162 | |
afbd545d DZ |
163 | /* set default to bypass all multicast packet for linux, |
164 | * window XP would set 0 by wrapper initialization | |
165 | */ | |
4bd43f50 LR |
166 | wd->sta.bAllMulticast = 1; |
167 | ||
afbd545d DZ |
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; | |
172 | ||
173 | wd->sta.osRxFilter = 0; | |
174 | wd->sta.bSafeMode = 0; | |
175 | ||
176 | /* Common */ | |
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 */ | |
183 | wd->dtim = 1; | |
184 | /* wd->txMT = 1; *//*OFDM */ | |
185 | wd->tick = 1; | |
186 | wd->maxTxPower2 = 0xff; | |
187 | wd->maxTxPower5 = 0xff; | |
188 | wd->supportMode = 0xffffffff; | |
189 | wd->ws.adhocMode = ZM_ADHOCBAND_G; | |
190 | wd->ws.autoSetFrequency = 0xff; | |
191 | ||
192 | /* AP mode */ | |
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'; | |
201 | ||
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'; | |
4bd43f50 LR |
206 | |
207 | /* init fragmentation is disabled */ | |
afbd545d | 208 | /* zfiWlanSetFragThreshold(dev, 0); */ |
4bd43f50 LR |
209 | |
210 | /* airopeek : swSniffer 1=>on 0=>off */ | |
211 | wd->swSniffer = 0; | |
afbd545d | 212 | wd->XLinkMode = 0; |
4bd43f50 | 213 | |
afbd545d | 214 | /* jhlee HT 0 */ |
4bd43f50 | 215 | #if 1 |
afbd545d DZ |
216 | /* AP Mode*/ |
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; | |
225 | */ | |
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 */ | |
229 | ||
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; | |
238 | ||
239 | /* STA Mode*/ | |
240 | /* Init HT Capability Info */ | |
241 | wd->sta.HTCap.Data.ElementID = ZM_WLAN_EID_HT_CAPABILITY; | |
242 | wd->sta.HTCap.Data.Length = 26; | |
243 | ||
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; | |
4bd43f50 | 250 | #ifndef ZM_DISABLE_AMSDU8K_SUPPORT |
afbd545d | 251 | wd->sta.HTCap.Data.HtCapInfo |= HTCAP_MaxAMSDULength; |
4bd43f50 | 252 | #endif |
afbd545d DZ |
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; | |
257 | */ | |
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; | |
267 | ||
268 | /* wd->sta.ExtHTCap.Data.ExtChannelOffset |= 3; */ | |
269 | wd->sta.ExtHTCap.Data.ChannelInfo |= ExtHtCap_ExtChannelOffsetBelow; | |
270 | ||
271 | /* wd->sta.ExtHTCap.Data.RecomTxWidthSet = 1; */ | |
272 | /* wd->sta.ExtHTCap.Data.RIFSMode = 1; */ | |
273 | wd->sta.ExtHTCap.Data.OperatingInfo |= 1; | |
4bd43f50 LR |
274 | #endif |
275 | ||
276 | #if 0 | |
afbd545d DZ |
277 | /* WME test code */ |
278 | wd->ap.qosMode[0] = 1; | |
4bd43f50 LR |
279 | #endif |
280 | ||
afbd545d DZ |
281 | wd->ledStruct.ledMode[0] = 0x2221; |
282 | wd->ledStruct.ledMode[1] = 0x2221; | |
4bd43f50 | 283 | |
afbd545d | 284 | zfTimerInit(dev); |
4bd43f50 | 285 | |
afbd545d | 286 | ZM_PERFORMANCE_INIT(dev); |
4bd43f50 | 287 | |
afbd545d DZ |
288 | zfBssInfoCreate(dev); |
289 | zfScanMgrInit(dev); | |
290 | zfPowerSavingMgrInit(dev); | |
4bd43f50 LR |
291 | |
292 | #if 0 | |
afbd545d DZ |
293 | /* Test code */ |
294 | { | |
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); | |
300 | */ | |
301 | } | |
4bd43f50 LR |
302 | #endif |
303 | ||
afbd545d DZ |
304 | /* WME settings */ |
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); | |
4bd43f50 | 311 | |
afbd545d | 312 | /* zfHpInit(dev, wd->frequency); */ |
4bd43f50 | 313 | |
afbd545d DZ |
314 | /* MAC address */ |
315 | /* zfHpSetMacAddress(dev, wd->macAddr, 0); */ | |
316 | zfHpGetMacAddress(dev); | |
4bd43f50 | 317 | |
afbd545d | 318 | zfCoreSetFrequency(dev, wd->frequency); |
4bd43f50 LR |
319 | |
320 | #if ZM_PCI_LOOP_BACK == 1 | |
afbd545d | 321 | zfwWriteReg(dev, ZM_REG_PCI_CONTROL, 6); |
4bd43f50 LR |
322 | #endif /* #if ZM_PCI_LOOP_BACK == 1 */ |
323 | ||
afbd545d DZ |
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; | |
4bd43f50 | 328 | |
afbd545d DZ |
329 | /* zfiWlanSetFrequency(dev, 5260000, TRUE); */ |
330 | /* zfiWlanSetAniMode(dev , 1); // Enable ANI */ | |
4bd43f50 | 331 | |
afbd545d DZ |
332 | /* Trgger Rx DMA */ |
333 | zfHpStartRecv(dev); | |
4bd43f50 | 334 | |
afbd545d | 335 | zm_debug_msg0("end"); |
4bd43f50 | 336 | |
afbd545d | 337 | return 0; |
4bd43f50 LR |
338 | } |
339 | ||
340 | /* WLAN hardware will be shutdown and all resource will be release */ | |
afbd545d | 341 | u16_t zfiWlanClose(zdev_t *dev) |
4bd43f50 | 342 | { |
afbd545d | 343 | zmw_get_wlan_dev(dev); |
4bd43f50 | 344 | |
afbd545d | 345 | zm_msg0_init(ZM_LV_0, "enter"); |
4bd43f50 | 346 | |
afbd545d | 347 | wd->state = ZM_WLAN_STATE_CLOSEDED; |
4bd43f50 | 348 | |
afbd545d DZ |
349 | /* zfiWlanDisable(dev, 1); */ |
350 | zfWlanReset(dev); | |
4bd43f50 | 351 | |
afbd545d | 352 | zfHpStopRecv(dev); |
4bd43f50 | 353 | |
afbd545d DZ |
354 | /* Disable MAC */ |
355 | /* Disable PHY */ | |
356 | /* Disable RF */ | |
4bd43f50 | 357 | |
afbd545d | 358 | zfHpRelease(dev); |
4bd43f50 | 359 | |
afbd545d DZ |
360 | zfQueueDestroy(dev, wd->ap.uapsdQ); |
361 | zfQueueDestroy(dev, wd->sta.uapsdQ); | |
4bd43f50 | 362 | |
afbd545d | 363 | zfBssInfoDestroy(dev); |
4bd43f50 LR |
364 | |
365 | #ifdef ZM_ENABLE_AGGREGATION | |
afbd545d DZ |
366 | /* add by honda */ |
367 | zfAggRxFreeBuf(dev, 1); /* 1 for release structure memory */ | |
368 | /* end of add by honda */ | |
4bd43f50 LR |
369 | #endif |
370 | ||
afbd545d | 371 | zm_msg0_init(ZM_LV_0, "exit"); |
4bd43f50 | 372 | |
afbd545d | 373 | return 0; |
4bd43f50 LR |
374 | } |
375 | ||
afbd545d | 376 | void zfGetWrapperSetting(zdev_t *dev) |
4bd43f50 | 377 | { |
afbd545d DZ |
378 | u8_t bPassive; |
379 | u16_t vapId = 0; | |
4bd43f50 | 380 | |
afbd545d | 381 | zmw_get_wlan_dev(dev); |
4bd43f50 | 382 | |
afbd545d | 383 | zmw_declare_for_critical_section(); |
4bd43f50 | 384 | #if 0 |
afbd545d DZ |
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)); | |
390 | } | |
4bd43f50 | 391 | #endif |
afbd545d DZ |
392 | zmw_enter_critical_section(dev); |
393 | ||
394 | wd->wlanMode = wd->ws.wlanMode; | |
395 | ||
396 | /* set channel */ | |
397 | if (wd->ws.frequency) { | |
398 | wd->frequency = wd->ws.frequency; | |
399 | wd->ws.frequency = 0; | |
400 | } else { | |
401 | wd->frequency = zfChGetFirstChannel(dev, &bPassive); | |
402 | ||
403 | if (wd->wlanMode == ZM_MODE_IBSS) { | |
404 | if (wd->ws.adhocMode == ZM_ADHOCBAND_A) | |
405 | wd->frequency = ZM_CH_A_36; | |
406 | else | |
407 | wd->frequency = ZM_CH_G_6; | |
408 | } | |
409 | } | |
4bd43f50 | 410 | #ifdef ZM_AP_DEBUG |
afbd545d DZ |
411 | /* honda add for debug, 2437 channel 6, 2452 channel 9 */ |
412 | wd->frequency = 2437; | |
413 | /* end of add by honda */ | |
4bd43f50 LR |
414 | #endif |
415 | ||
afbd545d DZ |
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; | |
422 | break; | |
423 | default: | |
424 | wd->preambleType = ZM_PREAMBLE_TYPE_SHORT; | |
425 | break; | |
426 | } | |
427 | wd->ws.preambleType = 0; | |
428 | ||
429 | if (wd->wlanMode == ZM_MODE_AP) { | |
430 | vapId = zfwGetVapId(dev); | |
431 | ||
432 | if (vapId == 0xffff) { | |
433 | wd->ap.authAlgo[0] = wd->ws.authMode; | |
434 | wd->ap.encryMode[0] = wd->ws.encryMode; | |
435 | } else { | |
436 | wd->ap.authAlgo[vapId + 1] = wd->ws.authMode; | |
437 | wd->ap.encryMode[vapId + 1] = wd->ws.encryMode; | |
438 | } | |
439 | wd->ws.authMode = 0; | |
440 | wd->ws.encryMode = ZM_NO_WEP; | |
441 | ||
442 | /* Get beaconInterval from WrapperSetting */ | |
443 | if ((wd->ws.beaconInterval >= 20) && | |
444 | (wd->ws.beaconInterval <= 1000)) | |
445 | wd->beaconInterval = wd->ws.beaconInterval; | |
446 | else | |
447 | wd->beaconInterval = 100; /* 100ms */ | |
448 | ||
449 | if (wd->ws.dtim > 0) | |
450 | wd->dtim = wd->ws.dtim; | |
451 | else | |
452 | wd->dtim = 1; | |
453 | ||
454 | ||
455 | wd->ap.qosMode = wd->ws.apWmeEnabled & 0x1; | |
456 | wd->ap.uapsdEnabled = (wd->ws.apWmeEnabled & 0x2) >> 1; | |
457 | } else { | |
458 | wd->sta.authMode = wd->ws.authMode; | |
459 | wd->sta.currentAuthMode = wd->ws.authMode; | |
460 | wd->sta.wepStatus = wd->ws.wepStatus; | |
461 | ||
462 | if (wd->ws.beaconInterval) | |
463 | wd->beaconInterval = wd->ws.beaconInterval; | |
464 | else | |
465 | wd->beaconInterval = 0x64; | |
466 | ||
467 | if (wd->wlanMode == ZM_MODE_IBSS) { | |
468 | /* 1. Set default channel 6 (2437MHz) */ | |
469 | /* wd->frequency = 2437; */ | |
470 | ||
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; | |
476 | else | |
477 | wd->wfc.bIbssGMode = 0; | |
478 | ||
479 | /* 3. set short preamble */ | |
480 | /* wd->sta.preambleType = ZM_PREAMBLE_TYPE_SHORT; */ | |
481 | } | |
482 | ||
483 | /* set ATIM window */ | |
484 | if (wd->ws.atimWindow) | |
485 | wd->sta.atimWindow = wd->ws.atimWindow; | |
486 | else { | |
487 | /* wd->sta.atimWindow = 0x0a; */ | |
488 | wd->sta.atimWindow = 0; | |
489 | } | |
490 | ||
491 | /* wd->sta.connectingHiddenAP = 1; | |
492 | wd->ws.connectingHiddenAP; | |
493 | */ | |
494 | wd->sta.dropUnencryptedPkts = wd->ws.dropUnencryptedPkts; | |
495 | wd->sta.ibssJoinOnly = wd->ws.ibssJoinOnly; | |
496 | ||
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; | |
502 | } else | |
503 | wd->sta.bDesiredBssid = FALSE; | |
504 | ||
505 | /* check ssid */ | |
506 | if (wd->ws.ssidLen != 0) { | |
507 | if ((!zfMemoryIsEqual(wd->ws.ssid, wd->sta.ssid, | |
508 | wd->sta.ssidLen)) || | |
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 | |
515 | (not reassociation) | |
516 | */ | |
517 | wd->sta.connectByReasso = FALSE; | |
518 | wd->sta.failCntOfReasso = 0; | |
519 | wd->sta.pmkidInfo.bssidCount = 0; | |
520 | ||
521 | wd->sta.ssidLen = wd->ws.ssidLen; | |
522 | zfMemoryCopy(wd->sta.ssid, wd->ws.ssid, | |
523 | wd->sta.ssidLen); | |
524 | ||
525 | if (wd->sta.ssidLen < 32) | |
526 | wd->sta.ssid[wd->sta.ssidLen] = 0; | |
527 | } | |
528 | } else { | |
529 | /* ANY BSS */ | |
530 | wd->sta.ssid[0] = 0; | |
531 | wd->sta.ssidLen = 0; | |
532 | } | |
533 | ||
534 | wd->sta.wmeEnabled = wd->ws.staWmeEnabled; | |
535 | wd->sta.wmeQosInfo = wd->ws.staWmeQosInfo; | |
536 | ||
537 | } | |
538 | ||
539 | zmw_leave_critical_section(dev); | |
4bd43f50 LR |
540 | } |
541 | ||
afbd545d | 542 | u16_t zfWlanEnable(zdev_t *dev) |
4bd43f50 | 543 | { |
afbd545d DZ |
544 | u8_t bssid[6] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; |
545 | u16_t i; | |
546 | ||
547 | zmw_get_wlan_dev(dev); | |
548 | ||
549 | zmw_declare_for_critical_section(); | |
550 | ||
551 | if (wd->wlanMode == ZM_MODE_UNKNOWN) { | |
552 | zm_debug_msg0("Unknown Mode...Skip..."); | |
553 | return 0; | |
554 | } | |
555 | ||
556 | if (wd->wlanMode == ZM_MODE_AP) { | |
557 | u16_t vapId; | |
558 | ||
559 | vapId = zfwGetVapId(dev); | |
560 | ||
561 | if (vapId == 0xffff) { | |
562 | /* AP mode */ | |
563 | zfApInitStaTbl(dev); | |
564 | ||
565 | /* AP default parameters */ | |
566 | wd->bRate = 0xf; | |
567 | wd->gRate = 0xff; | |
568 | wd->bRateBasic = 0xf; | |
569 | wd->gRateBasic = 0x0; | |
570 | /* wd->beaconInterval = 100; */ | |
571 | wd->ap.apBitmap = 1; | |
572 | wd->ap.beaconCounter = 0; | |
573 | /* wd->ap.vapNumber = 1; //mark by ygwei for Vap */ | |
574 | ||
575 | wd->ap.hideSsid[0] = 0; | |
576 | wd->ap.staAgingTimeSec = 10*60; | |
577 | wd->ap.staProbingTimeSec = 60; | |
578 | ||
579 | for (i = 0; i < ZM_MAX_AP_SUPPORT; i++) | |
580 | wd->ap.bcmcHead[i] = wd->ap.bcmcTail[i] = 0; | |
581 | ||
582 | /* wd->ap.uniHead = wd->ap.uniTail = 0; */ | |
583 | ||
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 */ | |
593 | } | |
594 | ||
595 | if (wd->ap.encryMode[0] == 0) | |
596 | wd->ap.capab[0] = 0x001; | |
597 | else | |
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; | |
602 | ||
603 | /* wd->ap.vapNumber = 1; //mark by ygwei for Vap Test */ | |
604 | } else { | |
4bd43f50 | 605 | #if 0 |
afbd545d DZ |
606 | /* VAP Test Code */ |
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; | |
4bd43f50 | 617 | #else |
afbd545d DZ |
618 | /* VAP Test Code */ |
619 | wd->ap.apBitmap = 0x1 | (0x01 << (vapId+1)); | |
620 | ||
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] = | |
625 | wd->ws.ssid[i]; | |
626 | wd->ws.ssidLen = 0; /* Reset Wrapper Variable */ | |
627 | } | |
628 | ||
629 | if (wd->ap.encryMode[vapId+1] == 0) | |
630 | wd->ap.capab[vapId+1] = 0x401; | |
631 | else | |
632 | wd->ap.capab[vapId+1] = 0x411; | |
633 | ||
634 | wd->ap.authAlgo[vapId+1] = wd->ws.authMode; | |
635 | wd->ap.encryMode[vapId+1] = wd->ws.encryMode; | |
636 | ||
637 | /* Need to be modified when VAP is used */ | |
638 | /* wd->ap.vapNumber = 2; */ | |
4bd43f50 | 639 | #endif |
afbd545d DZ |
640 | } |
641 | ||
642 | wd->ap.vapNumber++; | |
643 | ||
644 | zfCoreSetFrequency(dev, wd->frequency); | |
645 | ||
646 | zfInitMacApMode(dev); | |
647 | ||
648 | /* Disable protection mode */ | |
649 | zfApSetProtectionMode(dev, 0); | |
650 | ||
651 | zfApSendBeacon(dev); | |
652 | } else { /*if (wd->wlanMode == ZM_MODE_AP) */ | |
653 | ||
654 | zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_INTERNAL); | |
655 | zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_EXTERNAL); | |
656 | ||
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); | |
663 | ||
664 | zfStaResetStatus(dev, 0); | |
665 | ||
666 | if ((wd->sta.cmDisallowSsidLength != 0) && | |
667 | (wd->sta.ssidLen == wd->sta.cmDisallowSsidLength) && | |
668 | (zfMemoryIsEqual(wd->sta.ssid, wd->sta.cmDisallowSsid, | |
669 | wd->sta.ssidLen)) && | |
670 | (wd->sta.wepStatus == ZM_ENCRYPTION_TKIP)) {/*countermeasures*/ | |
671 | zm_debug_msg0("countermeasures disallow association"); | |
672 | } else { | |
673 | switch (wd->wlanMode) { | |
674 | case ZM_MODE_IBSS: | |
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); | |
679 | else | |
680 | zfHpSetApStaMode(dev, | |
681 | ZM_HAL_80211_MODE_IBSS_GENERAL); | |
682 | ||
683 | zm_msg0_mm(ZM_LV_0, "ZM_MODE_IBSS"); | |
684 | zfIbssConnectNetwork(dev); | |
685 | break; | |
686 | ||
687 | case ZM_MODE_INFRASTRUCTURE: | |
688 | /* some registers may be set here */ | |
689 | zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_STA); | |
690 | ||
691 | zfInfraConnectNetwork(dev); | |
692 | break; | |
693 | ||
694 | case ZM_MODE_PSEUDO: | |
695 | /* some registers may be set here */ | |
696 | zfHpSetApStaMode(dev, ZM_HAL_80211_MODE_STA); | |
697 | ||
698 | zfUpdateBssid(dev, bssid); | |
699 | zfCoreSetFrequency(dev, wd->frequency); | |
700 | break; | |
701 | ||
702 | default: | |
703 | break; | |
704 | } | |
705 | } | |
706 | ||
707 | } | |
708 | ||
709 | ||
710 | /* if ((wd->wlanMode != ZM_MODE_INFRASTRUCTURE) && | |
711 | (wd->wlanMode != ZM_MODE_AP)) | |
712 | */ | |
713 | if (wd->wlanMode == ZM_MODE_PSEUDO) { | |
714 | /* Reset Wlan status */ | |
715 | zfWlanReset(dev); | |
716 | ||
717 | if (wd->zfcbConnectNotify != NULL) | |
718 | wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECT, | |
719 | wd->sta.bssid); | |
720 | zfChangeAdapterState(dev, ZM_STA_STATE_CONNECTED); | |
721 | } | |
722 | ||
723 | ||
724 | if (wd->wlanMode == ZM_MODE_AP) { | |
725 | if (wd->zfcbConnectNotify != NULL) | |
726 | wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_CONNECT, | |
727 | wd->sta.bssid); | |
728 | /* zfChangeAdapterState(dev, ZM_STA_STATE_CONNECTED); */ | |
729 | } | |
730 | ||
731 | /* Assign default Tx Rate */ | |
732 | if (wd->sta.EnableHT) { | |
4bd43f50 | 733 | u32_t oneTxStreamCap; |
afbd545d DZ |
734 | oneTxStreamCap = (zfHpCapability(dev) & |
735 | ZM_HP_CAP_11N_ONE_TX_STREAM); | |
736 | if (oneTxStreamCap) | |
4bd43f50 LR |
737 | wd->CurrentTxRateKbps = 135000; |
738 | else | |
739 | wd->CurrentTxRateKbps = 270000; | |
afbd545d DZ |
740 | wd->CurrentRxRateKbps = 270000; |
741 | } else { | |
742 | wd->CurrentTxRateKbps = 54000; | |
743 | wd->CurrentRxRateKbps = 54000; | |
744 | } | |
4bd43f50 | 745 | |
afbd545d | 746 | wd->state = ZM_WLAN_STATE_ENABLED; |
4bd43f50 | 747 | |
afbd545d | 748 | return 0; |
4bd43f50 LR |
749 | } |
750 | ||
751 | /* Enable/disable Wlan operation */ | |
afbd545d | 752 | u16_t zfiWlanEnable(zdev_t *dev) |
4bd43f50 | 753 | { |
afbd545d | 754 | u16_t ret; |
4bd43f50 | 755 | |
afbd545d | 756 | zmw_get_wlan_dev(dev); |
4bd43f50 | 757 | |
afbd545d | 758 | zm_msg0_mm(ZM_LV_1, "Enable Wlan"); |
4bd43f50 | 759 | |
afbd545d | 760 | zfGetWrapperSetting(dev); |
4bd43f50 | 761 | |
afbd545d DZ |
762 | zfZeroMemory((u8_t *) &wd->trafTally, sizeof(struct zsTrafTally)); |
763 | ||
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; | |
768 | } | |
4bd43f50 | 769 | |
afbd545d DZ |
770 | zfFlushVtxq(dev); |
771 | if ((wd->queueFlushed & 0x10) != 0) | |
772 | zfHpUsbReset(dev); | |
4bd43f50 | 773 | |
afbd545d | 774 | ret = zfWlanEnable(dev); |
4bd43f50 | 775 | |
afbd545d | 776 | return ret; |
4bd43f50 LR |
777 | } |
778 | /* Add a flag named ResetKeyCache to show if KeyCache should be cleared. | |
779 | for hostapd in AP mode, if driver receives iwconfig ioctl | |
afbd545d DZ |
780 | after setting group key, it shouldn't clear KeyCache. |
781 | */ | |
782 | u16_t zfiWlanDisable(zdev_t *dev, u8_t ResetKeyCache) | |
4bd43f50 | 783 | { |
afbd545d DZ |
784 | u16_t i; |
785 | u8_t isConnected; | |
4bd43f50 | 786 | |
afbd545d | 787 | zmw_get_wlan_dev(dev); |
4bd43f50 LR |
788 | |
789 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
afbd545d | 790 | zmw_declare_for_critical_section(); |
4bd43f50 | 791 | #endif |
afbd545d DZ |
792 | wd->state = ZM_WLAN_STATE_DISABLED; |
793 | ||
794 | zm_msg0_mm(ZM_LV_1, "Disable Wlan"); | |
795 | ||
796 | if (wd->wlanMode != ZM_MODE_AP) { | |
797 | isConnected = zfStaIsConnected(dev); | |
798 | ||
799 | if ((wd->wlanMode == ZM_MODE_INFRASTRUCTURE) && | |
800 | (wd->sta.currentAuthMode != ZM_AUTH_MODE_WPA2)) { | |
801 | /* send deauthentication frame */ | |
802 | if (isConnected) { | |
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!"); */ | |
807 | } | |
808 | } | |
809 | ||
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); | |
815 | } | |
4bd43f50 LR |
816 | |
817 | #ifdef ZM_ENABLE_IBSS_WPA2PSK | |
afbd545d DZ |
818 | zmw_enter_critical_section(dev); |
819 | wd->sta.ibssWpa2Psk = 0; | |
820 | zmw_leave_critical_section(dev); | |
4bd43f50 LR |
821 | #endif |
822 | ||
afbd545d DZ |
823 | wd->sta.wpaState = ZM_STA_WPA_STATE_INIT; |
824 | ||
825 | /* reset connect timeout counter */ | |
826 | wd->sta.connectTimeoutCount = 0; | |
827 | ||
828 | /* reset connectState to None */ | |
829 | wd->sta.connectState = ZM_STA_CONN_STATE_NONE; | |
830 | ||
831 | /* reset leap enable variable */ | |
832 | wd->sta.leapEnabled = 0; | |
833 | ||
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; | |
840 | ||
841 | wd->sta.osRxFilter = 0; | |
842 | wd->sta.bSafeMode = 0; | |
843 | ||
844 | zfChangeAdapterState(dev, ZM_STA_STATE_DISCONNECT); | |
845 | if (ResetKeyCache) | |
846 | zfHpResetKeyCache(dev); | |
847 | ||
848 | if (isConnected) { | |
849 | if (wd->zfcbConnectNotify != NULL) | |
850 | wd->zfcbConnectNotify(dev, | |
851 | ZM_STATUS_MEDIA_CONNECTION_DISABLED, | |
852 | wd->sta.bssid); | |
853 | } else { | |
854 | if (wd->zfcbConnectNotify != NULL) | |
855 | wd->zfcbConnectNotify(dev, | |
856 | ZM_STATUS_MEDIA_DISABLED, wd->sta.bssid); | |
857 | } | |
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); | |
865 | } | |
866 | } | |
867 | ||
868 | if (ResetKeyCache) | |
869 | zfHpResetKeyCache(dev); | |
870 | ||
871 | wd->ap.vapNumber--; | |
872 | } | |
4bd43f50 | 873 | |
afbd545d DZ |
874 | /* stop beacon */ |
875 | zfHpDisableBeacon(dev); | |
876 | ||
877 | /* Flush VTxQ and MmQ */ | |
878 | zfFlushVtxq(dev); | |
879 | /* Flush AP PS queues */ | |
880 | zfApFlushBufferedPsFrame(dev); | |
881 | /* Free buffer in defragment list*/ | |
882 | zfAgingDefragList(dev, 1); | |
883 | ||
884 | #ifdef ZM_ENABLE_AGGREGATION | |
885 | /* add by honda */ | |
886 | zfAggRxFreeBuf(dev, 0); /* 1 for release structure memory */ | |
887 | /* end of add by honda */ | |
888 | #endif | |
889 | ||
890 | /* Clear the information for the peer stations | |
891 | of IBSS or AP of Station mode | |
892 | */ | |
893 | zfZeroMemory((u8_t *)wd->sta.oppositeInfo, | |
894 | sizeof(struct zsOppositeInfo) * ZM_MAX_OPPOSITE_COUNT); | |
4bd43f50 | 895 | |
afbd545d DZ |
896 | /* Turn off Software WEP/TKIP */ |
897 | if (wd->sta.SWEncryptEnable != 0) { | |
898 | zm_debug_msg0("Disable software encryption"); | |
899 | zfStaDisableSWEncryption(dev); | |
900 | } | |
901 | ||
bbc9a991 | 902 | /* Improve WEP/TKIP performance with HT AP, |
afbd545d DZ |
903 | detail information please look bug#32495 */ |
904 | /* zfHpSetTTSIFSTime(dev, 0x8); */ | |
905 | ||
906 | return 0; | |
907 | } | |
4bd43f50 | 908 | |
afbd545d DZ |
909 | u16_t zfiWlanSuspend(zdev_t *dev) |
910 | { | |
911 | zmw_get_wlan_dev(dev); | |
912 | zmw_declare_for_critical_section(); | |
913 | ||
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. | |
917 | */ | |
918 | zmw_enter_critical_section(dev); | |
919 | wd->halState = ZM_HAL_STATE_INIT; | |
920 | zmw_leave_critical_section(dev); | |
921 | ||
922 | return 0; | |
4bd43f50 LR |
923 | } |
924 | ||
afbd545d | 925 | u16_t zfiWlanResume(zdev_t *dev, u8_t doReconn) |
4bd43f50 | 926 | { |
afbd545d DZ |
927 | u16_t ret; |
928 | zmw_get_wlan_dev(dev); | |
929 | zmw_declare_for_critical_section(); | |
930 | ||
931 | /* Redownload firmware, Reinit MAC,PHY,RF */ | |
932 | zfHpReinit(dev, wd->frequency); | |
933 | ||
934 | /* Set channel according to AP's configuration */ | |
935 | zfCoreSetFrequencyExV2(dev, wd->frequency, wd->BandWidth40, | |
936 | wd->ExtOffset, NULL, 1); | |
937 | ||
938 | zfHpSetMacAddress(dev, wd->macAddr, 0); | |
939 | ||
940 | /* Start Rx */ | |
941 | zfHpStartRecv(dev); | |
942 | ||
943 | zfFlushVtxq(dev); | |
944 | ||
945 | if (wd->wlanMode != ZM_MODE_INFRASTRUCTURE && | |
946 | wd->wlanMode != ZM_MODE_IBSS) | |
947 | return 1; | |
948 | ||
949 | zm_msg0_mm(ZM_LV_1, "Resume Wlan"); | |
950 | if ((zfStaIsConnected(dev)) || (zfStaIsConnecting(dev))) { | |
951 | if (doReconn == 1) { | |
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); | |
956 | ||
957 | zfWlanEnable(dev); | |
958 | } else if (doReconn == 0) | |
959 | zfHpSetRollCallTable(dev); | |
960 | } | |
961 | ||
962 | ret = 0; | |
963 | ||
964 | return ret; | |
4bd43f50 LR |
965 | } |
966 | ||
967 | /************************************************************************/ | |
968 | /* */ | |
969 | /* FUNCTION DESCRIPTION zfiWlanFlushAllQueuedBuffers */ | |
970 | /* Flush Virtual TxQ, MmQ, PS frames and defragment list */ | |
971 | /* */ | |
972 | /* INPUTS */ | |
973 | /* dev : device pointer */ | |
974 | /* */ | |
975 | /* OUTPUTS */ | |
976 | /* None */ | |
977 | /* */ | |
978 | /* AUTHOR */ | |
979 | /* Stephen Chen Atheros Communications, INC. 2007.1 */ | |
980 | /* */ | |
981 | /************************************************************************/ | |
afbd545d | 982 | void zfiWlanFlushAllQueuedBuffers(zdev_t *dev) |
4bd43f50 | 983 | { |
afbd545d DZ |
984 | /* Flush VTxQ and MmQ */ |
985 | zfFlushVtxq(dev); | |
986 | /* Flush AP PS queues */ | |
987 | zfApFlushBufferedPsFrame(dev); | |
988 | /* Free buffer in defragment list*/ | |
989 | zfAgingDefragList(dev, 1); | |
4bd43f50 LR |
990 | } |
991 | ||
992 | /* Do WLAN site survey */ | |
afbd545d | 993 | u16_t zfiWlanScan(zdev_t *dev) |
4bd43f50 | 994 | { |
afbd545d DZ |
995 | u16_t ret = 1; |
996 | zmw_get_wlan_dev(dev); | |
997 | ||
998 | zm_debug_msg0(""); | |
999 | ||
1000 | zmw_declare_for_critical_section(); | |
1001 | ||
1002 | zmw_enter_critical_section(dev); | |
1003 | ||
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; */ | |
1008 | ret = 0; | |
1009 | } else { | |
1010 | #if 0 | |
1011 | if (!zfStaBlockWlanScan(dev)) { | |
1012 | zm_debug_msg0("scan request"); | |
1013 | /*zfTimerSchedule(dev, ZM_EVENT_SCAN, ZM_TICK_ZERO);*/ | |
1014 | ret = 0; | |
1015 | goto start_scan; | |
1016 | } | |
1017 | #else | |
1018 | goto start_scan; | |
1019 | #endif | |
1020 | } | |
1021 | ||
1022 | zmw_leave_critical_section(dev); | |
1023 | ||
1024 | return ret; | |
4bd43f50 LR |
1025 | |
1026 | start_scan: | |
afbd545d | 1027 | zmw_leave_critical_section(dev); |
4bd43f50 | 1028 | |
afbd545d DZ |
1029 | if (wd->ledStruct.LEDCtrlFlagFromReg & ZM_LED_CTRL_FLAG_ALPHA) { |
1030 | /* flag for Alpha */ | |
1031 | wd->ledStruct.LEDCtrlFlag |= ZM_LED_CTRL_FLAG_ALPHA; | |
1032 | } | |
4bd43f50 | 1033 | |
afbd545d | 1034 | ret = zfScanMgrScanStart(dev, ZM_SCAN_MGR_SCAN_EXTERNAL); |
4bd43f50 | 1035 | |
afbd545d | 1036 | zm_debug_msg1("ret = ", ret); |
4bd43f50 | 1037 | |
afbd545d | 1038 | return ret; |
4bd43f50 LR |
1039 | } |
1040 | ||
1041 | ||
afbd545d DZ |
1042 | /* rate */ |
1043 | /* 0 : AUTO */ | |
1044 | /* 1 : CCK 1M */ | |
1045 | /* 2 : CCK 2M */ | |
1046 | /* 3 : CCK 5.5M */ | |
1047 | /* 4 : CCK 11M */ | |
1048 | /* 5 : OFDM 6M */ | |
1049 | /* 6 : OFDM 9M */ | |
1050 | /* 7 : OFDM 12M */ | |
1051 | /* 8 : OFDM 18M */ | |
1052 | /* 9 : OFDM 24M */ | |
1053 | /* 10 : OFDM 36M */ | |
1054 | /* 11 : OFDM 48M */ | |
1055 | /* 12 : OFDM 54M */ | |
1056 | /* 13 : MCS 0 */ | |
1057 | /* 28 : MCS 15 */ | |
4bd43f50 LR |
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}; | |
1061 | ||
afbd545d DZ |
1062 | u16_t zfiWlanSetTxRate(zdev_t *dev, u16_t rate) |
1063 | { | |
1064 | /* jhlee HT 0 */ | |
1065 | zmw_get_wlan_dev(dev); | |
1066 | ||
1067 | if (rate <= 12) { | |
1068 | wd->txMCS = zcRateToMCS[rate]; | |
1069 | wd->txMT = zcRateToMT[rate]; | |
1070 | return ZM_SUCCESS; | |
1071 | } else if ((rate <= 28) || (rate == 13 + 32)) { | |
1072 | wd->txMCS = rate - 12 - 1; | |
1073 | wd->txMT = 2; | |
1074 | return ZM_SUCCESS; | |
1075 | } | |
1076 | ||
1077 | return ZM_ERR_INVALID_TX_RATE; | |
4bd43f50 LR |
1078 | } |
1079 | ||
1080 | const u32_t zcRateIdToKbps40M[] = | |
afbd545d DZ |
1081 | { |
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 */ | |
1090 | }; | |
4bd43f50 LR |
1091 | |
1092 | const u32_t zcRateIdToKbps20M[] = | |
4bd43f50 | 1093 | { |
afbd545d DZ |
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 */ | |
1102 | }; | |
1103 | ||
1104 | u32_t zfiWlanQueryTxRate(zdev_t *dev) | |
1105 | { | |
1106 | u8_t rateId = 0xff; | |
1107 | zmw_get_wlan_dev(dev); | |
1108 | zmw_declare_for_critical_section(); | |
1109 | ||
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]; | |
1121 | else | |
1122 | rateId = wd->sta.oppositeInfo[0].rcCell. \ | |
1123 | operationRateSet[wd->sta.oppositeInfo[0]. \ | |
1124 | rcCell.currentRateIndex]; | |
1125 | } | |
1126 | zmw_leave_critical_section(dev); | |
1127 | } | |
1128 | ||
1129 | if (rateId != 0xff) { | |
1130 | if (wd->sta.htCtrlBandwidth) | |
1131 | return zcRateIdToKbps40M[rateId]; | |
1132 | else | |
1133 | return zcRateIdToKbps20M[rateId]; | |
1134 | } else | |
1135 | return wd->CurrentTxRateKbps; | |
4bd43f50 LR |
1136 | } |
1137 | ||
afbd545d | 1138 | void zfWlanUpdateRxRate(zdev_t *dev, struct zsAdditionInfo *addInfo) |
4bd43f50 | 1139 | { |
afbd545d DZ |
1140 | u32_t rxRateKbps; |
1141 | zmw_get_wlan_dev(dev); | |
1142 | /* zm_msg1_mm(ZM_LV_0, "addInfo->Tail.Data.RxMacStatus =", | |
1143 | * addInfo->Tail.Data.RxMacStatus & 0x03); | |
1144 | */ | |
1145 | ||
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) { | |
1158 | /* CCK mode */ | |
1159 | case 0x0: | |
1160 | wd->rateField = addInfo->PlcpHeader[0] & 0xff; | |
1161 | wd->rxInfo = 0; | |
1162 | break; | |
1163 | /* Legacy-OFDM mode */ | |
1164 | case 0x1: | |
1165 | wd->rateField = addInfo->PlcpHeader[0] & 0x0f; | |
1166 | wd->rxInfo = 0; | |
1167 | break; | |
1168 | /* HT-OFDM mode */ | |
1169 | case 0x2: | |
1170 | wd->rateField = addInfo->PlcpHeader[3]; | |
1171 | wd->rxInfo = addInfo->PlcpHeader[6]; | |
1172 | break; | |
1173 | default: | |
1174 | break; | |
1175 | } | |
1176 | ||
1177 | rxRateKbps = zfUpdateRxRate(dev); | |
1178 | if (wd->CurrentRxRateUpdated == 1) { | |
1179 | if (rxRateKbps > wd->CurrentRxRateKbps) | |
1180 | wd->CurrentRxRateKbps = rxRateKbps; | |
1181 | } else { | |
1182 | wd->CurrentRxRateKbps = rxRateKbps; | |
1183 | wd->CurrentRxRateUpdated = 1; | |
1184 | } | |
1185 | } | |
4bd43f50 | 1186 | } |
afbd545d | 1187 | |
4bd43f50 LR |
1188 | #if 0 |
1189 | u16_t zcIndextoRateBG[16] = {1000, 2000, 5500, 11000, 0, 0, 0, 0, 48000, | |
afbd545d | 1190 | 24000, 12000, 6000, 54000, 36000, 18000, 9000}; |
4bd43f50 | 1191 | u32_t zcIndextoRateN20L[16] = {6500, 13000, 19500, 26000, 39000, 52000, 58500, |
afbd545d DZ |
1192 | 65000, 13000, 26000, 39000, 52000, 78000, 104000, |
1193 | 117000, 130000}; | |
4bd43f50 | 1194 | u32_t zcIndextoRateN20S[16] = {7200, 14400, 21700, 28900, 43300, 57800, 65000, |
afbd545d DZ |
1195 | 72200, 14400, 28900, 43300, 57800, 86700, 115600, |
1196 | 130000, 144400}; | |
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}; | |
4bd43f50 LR |
1203 | #endif |
1204 | ||
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]; | |
1210 | ||
afbd545d | 1211 | u32_t zfiWlanQueryRxRate(zdev_t *dev) |
4bd43f50 | 1212 | { |
afbd545d | 1213 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1214 | |
afbd545d DZ |
1215 | wd->CurrentRxRateUpdated = 0; |
1216 | return wd->CurrentRxRateKbps; | |
4bd43f50 LR |
1217 | } |
1218 | ||
afbd545d | 1219 | u32_t zfUpdateRxRate(zdev_t *dev) |
4bd43f50 | 1220 | { |
afbd545d DZ |
1221 | u8_t mcs, bandwidth; |
1222 | u32_t rxRateKbps = 130000; | |
1223 | zmw_get_wlan_dev(dev); | |
1224 | ||
1225 | switch (wd->modulationType) { | |
1226 | /* CCK mode */ | |
1227 | case 0x0: | |
1228 | switch (wd->rateField) { | |
1229 | case 0x0a: | |
1230 | rxRateKbps = 1000; | |
1231 | break; | |
1232 | case 0x14: | |
1233 | rxRateKbps = 2000; | |
1234 | ||
1235 | case 0x37: | |
1236 | rxRateKbps = 5500; | |
1237 | break; | |
1238 | case 0x6e: | |
1239 | rxRateKbps = 11000; | |
1240 | break; | |
1241 | default: | |
1242 | break; | |
1243 | } | |
1244 | break; | |
1245 | /* Legacy-OFDM mode */ | |
1246 | case 0x1: | |
1247 | if (wd->rateField <= 15) | |
1248 | rxRateKbps = zcIndextoRateBG[wd->rateField]; | |
1249 | break; | |
1250 | /* HT-OFDM mode */ | |
1251 | case 0x2: | |
1252 | mcs = wd->rateField & 0x7F; | |
1253 | bandwidth = wd->rateField & 0x80; | |
1254 | if (mcs <= 15) { | |
1255 | if (bandwidth != 0) { | |
1256 | if ((wd->rxInfo & 0x80) != 0) { | |
1257 | /* Short GI 40 MHz MIMO Rate */ | |
1258 | rxRateKbps = zcIndextoRateN40S[mcs]; | |
1259 | } else { | |
1260 | /* Long GI 40 MHz MIMO Rate */ | |
1261 | rxRateKbps = zcIndextoRateN40L[mcs]; | |
1262 | } | |
1263 | } else { | |
1264 | if ((wd->rxInfo & 0x80) != 0) { | |
1265 | /* Short GI 20 MHz MIMO Rate */ | |
1266 | rxRateKbps = zcIndextoRateN20S[mcs]; | |
1267 | } else { | |
1268 | /* Long GI 20 MHz MIMO Rate */ | |
1269 | rxRateKbps = zcIndextoRateN20L[mcs]; | |
1270 | } | |
1271 | } | |
1272 | } | |
1273 | break; | |
1274 | default: | |
1275 | break; | |
1276 | } | |
1277 | /* zm_msg1_mm(ZM_LV_0, "wd->CurrentRxRateKbps=", | |
1278 | wd->CurrentRxRateKbps); | |
1279 | */ | |
1280 | ||
1281 | /* ToDo: use bandwith field to define 40MB */ | |
1282 | return rxRateKbps; | |
4bd43f50 LR |
1283 | } |
1284 | ||
1285 | /* Get WLAN stastics */ | |
afbd545d | 1286 | u16_t zfiWlanGetStatistics(zdev_t *dev) |
4bd43f50 | 1287 | { |
afbd545d DZ |
1288 | /* Return link statistics */ |
1289 | return 0; | |
4bd43f50 LR |
1290 | } |
1291 | ||
afbd545d | 1292 | u16_t zfiWlanReset(zdev_t *dev) |
4bd43f50 | 1293 | { |
afbd545d | 1294 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1295 | |
afbd545d | 1296 | wd->state = ZM_WLAN_STATE_DISABLED; |
4bd43f50 | 1297 | |
afbd545d | 1298 | return zfWlanReset(dev); |
4bd43f50 LR |
1299 | } |
1300 | ||
1301 | /* Reset WLAN */ | |
afbd545d | 1302 | u16_t zfWlanReset(zdev_t *dev) |
4bd43f50 | 1303 | { |
afbd545d DZ |
1304 | u8_t isConnected; |
1305 | zmw_get_wlan_dev(dev); | |
1306 | ||
1307 | zmw_declare_for_critical_section(); | |
1308 | ||
1309 | zm_debug_msg0("zfWlanReset"); | |
1310 | ||
1311 | isConnected = zfStaIsConnected(dev); | |
1312 | ||
1313 | /* if ( wd->wlanMode != ZM_MODE_AP ) */ | |
1314 | { | |
1315 | if ((wd->wlanMode == ZM_MODE_INFRASTRUCTURE) && | |
1316 | (wd->sta.currentAuthMode != ZM_AUTH_MODE_WPA2)) { | |
1317 | /* send deauthentication frame */ | |
1318 | if (isConnected) { | |
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!"); */ | |
1323 | } | |
1324 | } | |
1325 | } | |
1326 | ||
1327 | zfChangeAdapterState(dev, ZM_STA_STATE_DISCONNECT); | |
1328 | zfHpResetKeyCache(dev); | |
1329 | ||
1330 | if (isConnected) { | |
1331 | /* zfiWlanDisable(dev); */ | |
1332 | if (wd->zfcbConnectNotify != NULL) | |
1333 | wd->zfcbConnectNotify(dev, | |
1334 | ZM_STATUS_MEDIA_CONNECTION_RESET, wd->sta.bssid); | |
1335 | } else { | |
1336 | if (wd->zfcbConnectNotify != NULL) | |
1337 | wd->zfcbConnectNotify(dev, ZM_STATUS_MEDIA_RESET, | |
1338 | wd->sta.bssid); | |
1339 | } | |
1340 | ||
1341 | /* stop beacon */ | |
1342 | zfHpDisableBeacon(dev); | |
1343 | ||
1344 | /* Free buffer in defragment list*/ | |
1345 | zfAgingDefragList(dev, 1); | |
1346 | ||
1347 | /* Flush VTxQ and MmQ */ | |
1348 | zfFlushVtxq(dev); | |
1349 | ||
1350 | #ifdef ZM_ENABLE_AGGREGATION | |
1351 | /* add by honda */ | |
1352 | zfAggRxFreeBuf(dev, 0); /* 1 for release structure memory */ | |
1353 | /* end of add by honda */ | |
1354 | #endif | |
1355 | ||
1356 | zfStaRefreshBlockList(dev, 1); | |
1357 | ||
1358 | zmw_enter_critical_section(dev); | |
1359 | ||
1360 | zfTimerCancel(dev, ZM_EVENT_IBSS_MONITOR); | |
1361 | zfTimerCancel(dev, ZM_EVENT_CM_BLOCK_TIMER); | |
1362 | zfTimerCancel(dev, ZM_EVENT_CM_DISCONNECT); | |
1363 | ||
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; | |
4bd43f50 | 1374 | #ifdef ZM_ENABLE_IBSS_WPA2PSK |
afbd545d | 1375 | wd->sta.ibssWpa2Psk = 0; |
4bd43f50 | 1376 | #endif |
afbd545d DZ |
1377 | /* reset connect timeout counter */ |
1378 | wd->sta.connectTimeoutCount = 0; | |
1379 | ||
1380 | /* reset leap enable variable */ | |
1381 | wd->sta.leapEnabled = 0; | |
1382 | ||
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; | |
1389 | ||
1390 | wd->sta.osRxFilter = 0; | |
1391 | wd->sta.bSafeMode = 0; | |
1392 | ||
1393 | /* Clear the information for the peer | |
1394 | stations of IBSS or AP of Station mode | |
1395 | */ | |
1396 | zfZeroMemory((u8_t *)wd->sta.oppositeInfo, | |
1397 | sizeof(struct zsOppositeInfo) * ZM_MAX_OPPOSITE_COUNT); | |
1398 | ||
1399 | zmw_leave_critical_section(dev); | |
1400 | ||
1401 | zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_INTERNAL); | |
1402 | zfScanMgrScanStop(dev, ZM_SCAN_MGR_SCAN_EXTERNAL); | |
1403 | ||
1404 | /* Turn off Software WEP/TKIP */ | |
1405 | if (wd->sta.SWEncryptEnable != 0) { | |
1406 | zm_debug_msg0("Disable software encryption"); | |
1407 | zfStaDisableSWEncryption(dev); | |
1408 | } | |
1409 | ||
bbc9a991 | 1410 | /* Improve WEP/TKIP performance with HT AP, |
afbd545d DZ |
1411 | detail information please look bug#32495 |
1412 | */ | |
1413 | /* zfHpSetTTSIFSTime(dev, 0x8); */ | |
1414 | ||
1415 | /* Keep Pseudo mode */ | |
1416 | if (wd->wlanMode != ZM_MODE_PSEUDO) | |
1417 | wd->wlanMode = ZM_MODE_INFRASTRUCTURE; | |
1418 | ||
1419 | return 0; | |
4bd43f50 LR |
1420 | } |
1421 | ||
1422 | /* Deauthenticate a STA */ | |
afbd545d | 1423 | u16_t zfiWlanDeauth(zdev_t *dev, u16_t *macAddr, u16_t reason) |
4bd43f50 | 1424 | { |
afbd545d DZ |
1425 | zmw_get_wlan_dev(dev); |
1426 | ||
1427 | if (wd->wlanMode == ZM_MODE_AP) { | |
1428 | /* u16_t id; */ | |
1429 | ||
1430 | /* | |
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 | |
1436 | */ | |
1437 | ||
1438 | /* | |
92363b52 JP |
1439 | id = zfApFindSta(dev, macAddr); |
1440 | if (id != 0xffff) | |
afbd545d DZ |
1441 | { |
1442 | u32_t key[8]; | |
1443 | u16_t nullAddr[3] = { 0x0, 0x0, 0x0 }; | |
1444 | ||
1445 | if (wd->ap.staTable[i].encryMode != ZM_NO_WEP) | |
1446 | { | |
1447 | zfHpSetApPairwiseKey(dev, nullAddr, | |
1448 | ZM_NO_WEP, &key[0], &key[4], i+1); | |
1449 | } | |
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; | |
1454 | } | |
1455 | */ | |
1456 | ||
1457 | zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH, macAddr, | |
1458 | reason, 0, 0); | |
1459 | } else | |
1460 | zfSendMmFrame(dev, ZM_WLAN_FRAME_TYPE_DEAUTH, | |
1461 | wd->sta.bssid, 3, 0, 0); | |
1462 | ||
1463 | /* Issue DEAUTH command to FW */ | |
1464 | return 0; | |
4bd43f50 LR |
1465 | } |
1466 | ||
1467 | ||
1468 | /* XP packet filter feature : */ | |
afbd545d DZ |
1469 | /* 1=>enable: All multicast address packets, not just the ones */ |
1470 | /* enumerated in the multicast address list. */ | |
4bd43f50 | 1471 | /* 0=>disable */ |
afbd545d | 1472 | void zfiWlanSetAllMulticast(zdev_t *dev, u32_t setting) |
4bd43f50 | 1473 | { |
afbd545d DZ |
1474 | zmw_get_wlan_dev(dev); |
1475 | zm_msg1_mm(ZM_LV_0, "sta.bAllMulticast = ", setting); | |
1476 | wd->sta.bAllMulticast = (u8_t)setting; | |
4bd43f50 LR |
1477 | } |
1478 | ||
1479 | ||
1480 | /* HT configure API */ | |
afbd545d | 1481 | void zfiWlanSetHTCtrl(zdev_t *dev, u32_t *setting, u32_t forceTxTPC) |
4bd43f50 | 1482 | { |
afbd545d DZ |
1483 | zmw_get_wlan_dev(dev); |
1484 | ||
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]; | |
1493 | ||
1494 | wd->forceTxTPC = forceTxTPC; | |
4bd43f50 LR |
1495 | } |
1496 | ||
1497 | /* FB50 in OS XP, RD private test code */ | |
afbd545d | 1498 | void zfiWlanQueryHTCtrl(zdev_t *dev, u32_t *setting, u32_t *forceTxTPC) |
4bd43f50 | 1499 | { |
afbd545d DZ |
1500 | zmw_get_wlan_dev(dev); |
1501 | ||
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; | |
1510 | ||
1511 | *forceTxTPC = wd->forceTxTPC; | |
4bd43f50 LR |
1512 | } |
1513 | ||
afbd545d | 1514 | void zfiWlanDbg(zdev_t *dev, u8_t setting) |
4bd43f50 | 1515 | { |
afbd545d | 1516 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1517 | |
afbd545d | 1518 | wd->enableHALDbgInfo = setting; |
4bd43f50 LR |
1519 | } |
1520 | ||
1521 | /* FB50 in OS XP, RD private test code */ | |
afbd545d | 1522 | void zfiWlanSetRxPacketDump(zdev_t *dev, u32_t setting) |
4bd43f50 | 1523 | { |
afbd545d DZ |
1524 | zmw_get_wlan_dev(dev); |
1525 | if (setting) | |
1526 | wd->rxPacketDump = 1; /* enable */ | |
1527 | else | |
1528 | wd->rxPacketDump = 0; /* disable */ | |
4bd43f50 LR |
1529 | } |
1530 | ||
1531 | ||
1532 | /* FB50 in OS XP, RD private test code */ | |
1533 | /* Tally */ | |
afbd545d | 1534 | void zfiWlanResetTally(zdev_t *dev) |
4bd43f50 | 1535 | { |
afbd545d DZ |
1536 | zmw_get_wlan_dev(dev); |
1537 | ||
1538 | zmw_declare_for_critical_section(); | |
1539 | ||
1540 | zmw_enter_critical_section(dev); | |
1541 | ||
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; | |
1575 | ||
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; | |
1580 | ||
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; | |
1586 | ||
1587 | wd->commTally.Hw_RxMPDU = 0; | |
1588 | wd->commTally.Hw_RxDropMPDU = 0; | |
1589 | wd->commTally.Hw_RxDelMPDU = 0; | |
1590 | ||
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; | |
1597 | ||
1598 | #if (defined(GCCK) && defined(OFDM)) | |
1599 | wd->commTally.rx11bDataFrame = 0; | |
1600 | wd->commTally.rxOFDMDataFrame = 0; | |
4bd43f50 LR |
1601 | #endif |
1602 | ||
afbd545d | 1603 | zmw_leave_critical_section(dev); |
4bd43f50 LR |
1604 | } |
1605 | ||
1606 | /* FB50 in OS XP, RD private test code */ | |
afbd545d | 1607 | void zfiWlanQueryTally(zdev_t *dev, struct zsCommTally *tally) |
4bd43f50 | 1608 | { |
afbd545d | 1609 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1610 | |
afbd545d | 1611 | zmw_declare_for_critical_section(); |
4bd43f50 | 1612 | |
afbd545d DZ |
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); | |
4bd43f50 | 1617 | } |
afbd545d DZ |
1618 | |
1619 | void zfiWlanQueryTrafTally(zdev_t *dev, struct zsTrafTally *tally) | |
4bd43f50 | 1620 | { |
afbd545d | 1621 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1622 | |
afbd545d | 1623 | zmw_declare_for_critical_section(); |
4bd43f50 | 1624 | |
afbd545d DZ |
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); | |
4bd43f50 LR |
1629 | } |
1630 | ||
afbd545d | 1631 | void zfiWlanQueryMonHalRxInfo(zdev_t *dev, struct zsMonHalRxInfo *monHalRxInfo) |
4bd43f50 | 1632 | { |
afbd545d | 1633 | zfHpQueryMonHalRxInfo(dev, (u8_t *)monHalRxInfo); |
4bd43f50 LR |
1634 | } |
1635 | ||
1636 | /* parse the modeMDKEnable to DrvCore */ | |
afbd545d | 1637 | void zfiDKEnable(zdev_t *dev, u32_t enable) |
4bd43f50 | 1638 | { |
afbd545d | 1639 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1640 | |
afbd545d DZ |
1641 | wd->modeMDKEnable = enable; |
1642 | zm_debug_msg1("modeMDKEnable = ", wd->modeMDKEnable); | |
4bd43f50 LR |
1643 | } |
1644 | ||
1645 | /* airoPeek */ | |
afbd545d | 1646 | u32_t zfiWlanQueryPacketTypePromiscuous(zdev_t *dev) |
4bd43f50 | 1647 | { |
afbd545d | 1648 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1649 | |
afbd545d | 1650 | return wd->swSniffer; |
4bd43f50 LR |
1651 | } |
1652 | ||
1653 | /* airoPeek */ | |
afbd545d | 1654 | void zfiWlanSetPacketTypePromiscuous(zdev_t *dev, u32_t setValue) |
4bd43f50 | 1655 | { |
afbd545d DZ |
1656 | zmw_get_wlan_dev(dev); |
1657 | ||
1658 | wd->swSniffer = setValue; | |
1659 | zm_msg1_mm(ZM_LV_0, "wd->swSniffer ", wd->swSniffer); | |
1660 | if (setValue) { | |
1661 | /* write register for sniffer mode */ | |
1662 | zfHpSetSnifferMode(dev, 1); | |
1832664a | 1663 | zm_msg0_mm(ZM_LV_1, "enable sniffer mode"); |
afbd545d DZ |
1664 | } else { |
1665 | zfHpSetSnifferMode(dev, 0); | |
1666 | zm_msg0_mm(ZM_LV_0, "disalbe sniffer mode"); | |
1667 | } | |
4bd43f50 LR |
1668 | } |
1669 | ||
afbd545d | 1670 | void zfiWlanSetXLinkMode(zdev_t *dev, u32_t setValue) |
4bd43f50 | 1671 | { |
afbd545d DZ |
1672 | zmw_get_wlan_dev(dev); |
1673 | ||
1674 | wd->XLinkMode = setValue; | |
1675 | if (setValue) { | |
1676 | /* write register for sniffer mode */ | |
1677 | zfHpSetSnifferMode(dev, 1); | |
1678 | } else | |
1679 | zfHpSetSnifferMode(dev, 0); | |
4bd43f50 LR |
1680 | } |
1681 | ||
afbd545d DZ |
1682 | extern void zfStaChannelManagement(zdev_t *dev, u8_t scan); |
1683 | ||
1684 | void zfiSetChannelManagement(zdev_t *dev, u32_t setting) | |
4bd43f50 | 1685 | { |
afbd545d DZ |
1686 | zmw_get_wlan_dev(dev); |
1687 | ||
1688 | switch (setting) { | |
1689 | case 1: | |
1690 | wd->sta.EnableHT = 1; | |
1691 | wd->BandWidth40 = 1; | |
1692 | wd->ExtOffset = 1; | |
1693 | break; | |
1694 | case 3: | |
1695 | wd->sta.EnableHT = 1; | |
1696 | wd->BandWidth40 = 1; | |
1697 | wd->ExtOffset = 3; | |
1698 | break; | |
1699 | case 0: | |
1700 | wd->sta.EnableHT = 1; | |
1701 | wd->BandWidth40 = 0; | |
1702 | wd->ExtOffset = 0; | |
1703 | break; | |
1704 | default: | |
1705 | wd->BandWidth40 = 0; | |
1706 | wd->ExtOffset = 0; | |
1707 | break; | |
1708 | } | |
1709 | ||
1710 | zfCoreSetFrequencyEx(dev, wd->frequency, wd->BandWidth40, | |
1711 | wd->ExtOffset, NULL); | |
4bd43f50 LR |
1712 | } |
1713 | ||
afbd545d | 1714 | void zfiSetRifs(zdev_t *dev, u16_t setting) |
4bd43f50 | 1715 | { |
afbd545d DZ |
1716 | zmw_get_wlan_dev(dev); |
1717 | ||
1718 | wd->sta.ie.HtInfo.ChannelInfo |= ExtHtCap_RIFSMode; | |
1719 | wd->sta.EnableHT = 1; | |
1720 | ||
1721 | switch (setting) { | |
1722 | case 0: | |
1723 | wd->sta.HT2040 = 0; | |
1724 | /* zfHpSetRifs(dev, 1, 0, | |
1725 | * (wd->sta.currentFrequency < 3000)? 1:0); | |
1726 | */ | |
1727 | break; | |
1728 | case 1: | |
1729 | wd->sta.HT2040 = 1; | |
1730 | /* zfHpSetRifs(dev, 1, 1, | |
1731 | * (wd->sta.currentFrequency < 3000)? 1:0); | |
1732 | */ | |
1733 | break; | |
1734 | default: | |
1735 | wd->sta.HT2040 = 0; | |
1736 | /* zfHpSetRifs(dev, 1, 0, | |
1737 | * (wd->sta.currentFrequency < 3000)? 1:0); | |
1738 | */ | |
1739 | break; | |
1740 | } | |
4bd43f50 LR |
1741 | } |
1742 | ||
afbd545d | 1743 | void zfiCheckRifs(zdev_t *dev) |
4bd43f50 | 1744 | { |
afbd545d | 1745 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1746 | |
afbd545d DZ |
1747 | if (wd->sta.ie.HtInfo.ChannelInfo & ExtHtCap_RIFSMode) |
1748 | ; | |
1749 | /* zfHpSetRifs(dev, wd->sta.EnableHT, wd->sta.HT2040, | |
1750 | * (wd->sta.currentFrequency < 3000)? 1:0); | |
1751 | */ | |
4bd43f50 LR |
1752 | } |
1753 | ||
afbd545d | 1754 | void zfiSetReorder(zdev_t *dev, u16_t value) |
4bd43f50 | 1755 | { |
afbd545d | 1756 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1757 | |
afbd545d | 1758 | wd->reorder = value; |
4bd43f50 LR |
1759 | } |
1760 | ||
afbd545d | 1761 | void zfiSetSeqDebug(zdev_t *dev, u16_t value) |
4bd43f50 | 1762 | { |
afbd545d | 1763 | zmw_get_wlan_dev(dev); |
4bd43f50 | 1764 | |
afbd545d | 1765 | wd->seq_debug = value; |
4bd43f50 | 1766 | } |