]>
Commit | Line | Data |
---|---|---|
5449c685 FB |
1 | /* |
2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; if not, write to the Free Software Foundation, Inc., | |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | * | |
19 | * File: bssdb.c | |
20 | * | |
21 | * Purpose: Handles the Basic Service Set & Node Database functions | |
22 | * | |
23 | * Functions: | |
24 | * BSSpSearchBSSList - Search known BSS list for Desire SSID or BSSID | |
25 | * BSSvClearBSSList - Clear BSS List | |
26 | * BSSbInsertToBSSList - Insert a BSS set into known BSS list | |
27 | * BSSbUpdateToBSSList - Update BSS set in known BSS list | |
28 | * BSSDBbIsSTAInNodeDB - Search Node DB table to find the index of matched DstAddr | |
29 | * BSSvCreateOneNode - Allocate an Node for Node DB | |
30 | * BSSvUpdateAPNode - Update AP Node content in Index 0 of KnownNodeDB | |
31 | * BSSvSecondCallBack - One second timer callback function to update Node DB info & AP link status | |
32 | * BSSvUpdateNodeTxCounter - Update Tx attemps, Tx failure counter in Node DB for auto-fall back rate control | |
33 | * | |
34 | * Revision History: | |
35 | * | |
36 | * Author: Lyndon Chen | |
37 | * | |
38 | * Date: July 17, 2002 | |
39 | * | |
40 | */ | |
41 | ||
5449c685 | 42 | #include "ttype.h" |
5449c685 | 43 | #include "tmacro.h" |
5449c685 | 44 | #include "tether.h" |
5449c685 | 45 | #include "device.h" |
5449c685 | 46 | #include "80211hdr.h" |
5449c685 | 47 | #include "bssdb.h" |
5449c685 | 48 | #include "wmgr.h" |
5449c685 | 49 | #include "datarate.h" |
5449c685 | 50 | #include "desc.h" |
5449c685 | 51 | #include "wcmd.h" |
5449c685 | 52 | #include "wpa.h" |
5449c685 | 53 | #include "baseband.h" |
5449c685 | 54 | #include "rf.h" |
5449c685 | 55 | #include "card.h" |
5449c685 | 56 | #include "mac.h" |
5449c685 | 57 | #include "wpa2.h" |
5449c685 | 58 | #include "iowpa.h" |
5449c685 FB |
59 | |
60 | //#define PLICE_DEBUG | |
61 | /*--------------------- Static Definitions -------------------------*/ | |
62 | ||
63 | ||
64 | ||
65 | ||
66 | /*--------------------- Static Classes ----------------------------*/ | |
67 | ||
68 | /*--------------------- Static Variables --------------------------*/ | |
69 | static int msglevel =MSG_LEVEL_INFO; | |
70 | //static int msglevel =MSG_LEVEL_DEBUG; | |
71 | ||
72 | ||
73 | ||
74 | const WORD awHWRetry0[5][5] = { | |
75 | {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M}, | |
76 | {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M}, | |
77 | {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M}, | |
78 | {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M}, | |
79 | {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M} | |
80 | }; | |
81 | const WORD awHWRetry1[5][5] = { | |
82 | {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M}, | |
83 | {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M}, | |
84 | {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M}, | |
85 | {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M}, | |
86 | {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M} | |
87 | }; | |
88 | ||
89 | ||
90 | ||
91 | /*--------------------- Static Functions --------------------------*/ | |
92 | ||
93 | VOID s_vCheckSensitivity( | |
94 | IN HANDLE hDeviceContext | |
95 | ); | |
96 | ||
97 | #ifdef Calcu_LinkQual | |
98 | VOID s_uCalculateLinkQual( | |
99 | IN HANDLE hDeviceContext | |
100 | ); | |
101 | #endif | |
102 | ||
103 | ||
104 | VOID s_vCheckPreEDThreshold( | |
105 | IN HANDLE hDeviceContext | |
106 | ); | |
107 | /*--------------------- Export Variables --------------------------*/ | |
108 | ||
109 | ||
110 | /*--------------------- Export Functions --------------------------*/ | |
111 | ||
112 | ||
113 | ||
114 | ||
115 | ||
116 | /*+ | |
117 | * | |
118 | * Routine Description: | |
119 | * Search known BSS list for Desire SSID or BSSID. | |
120 | * | |
121 | * Return Value: | |
122 | * PTR to KnownBSS or NULL | |
123 | * | |
124 | -*/ | |
125 | ||
126 | PKnownBSS | |
127 | BSSpSearchBSSList( | |
128 | IN HANDLE hDeviceContext, | |
129 | IN PBYTE pbyDesireBSSID, | |
130 | IN PBYTE pbyDesireSSID, | |
612822f5 | 131 | IN CARD_PHY_TYPE ePhyType |
5449c685 FB |
132 | ) |
133 | { | |
134 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
135 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
136 | PBYTE pbyBSSID = NULL; | |
137 | PWLAN_IE_SSID pSSID = NULL; | |
138 | PKnownBSS pCurrBSS = NULL; | |
139 | PKnownBSS pSelect = NULL; | |
140 | BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00}; | |
141 | UINT ii = 0; | |
142 | // UINT jj = 0; //DavidWang | |
143 | if (pbyDesireBSSID != NULL) { | |
7e809a9b | 144 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n", |
5449c685 FB |
145 | *pbyDesireBSSID,*(pbyDesireBSSID+1),*(pbyDesireBSSID+2), |
146 | *(pbyDesireBSSID+3),*(pbyDesireBSSID+4),*(pbyDesireBSSID+5)); | |
147 | if ((!IS_BROADCAST_ADDRESS(pbyDesireBSSID)) && | |
612822f5 | 148 | (memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){ |
5449c685 FB |
149 | pbyBSSID = pbyDesireBSSID; |
150 | } | |
151 | } | |
152 | if (pbyDesireSSID != NULL) { | |
153 | if (((PWLAN_IE_SSID)pbyDesireSSID)->len != 0) { | |
154 | pSSID = (PWLAN_IE_SSID) pbyDesireSSID; | |
155 | } | |
156 | } | |
157 | ||
158 | if (pbyBSSID != NULL) { | |
159 | // match BSSID first | |
160 | for (ii = 0; ii <MAX_BSS_NUM; ii++) { | |
161 | pCurrBSS = &(pMgmt->sBSSList[ii]); | |
162 | if(pDevice->bLinkPass==FALSE) pCurrBSS->bSelected = FALSE; | |
163 | if ((pCurrBSS->bActive) && | |
164 | (pCurrBSS->bSelected == FALSE)) { | |
165 | if (IS_ETH_ADDRESS_EQUAL(pCurrBSS->abyBSSID, pbyBSSID)) { | |
166 | if (pSSID != NULL) { | |
167 | // compare ssid | |
51b6d9c2 | 168 | if ( !memcmp(pSSID->abySSID, |
5449c685 FB |
169 | ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID, |
170 | pSSID->len)) { | |
171 | if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) || | |
172 | ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || | |
173 | ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) | |
174 | ) { | |
175 | pCurrBSS->bSelected = TRUE; | |
176 | return(pCurrBSS); | |
177 | } | |
178 | } | |
179 | } else { | |
180 | if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) || | |
181 | ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) || | |
182 | ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) | |
183 | ) { | |
184 | pCurrBSS->bSelected = TRUE; | |
185 | return(pCurrBSS); | |
186 | } | |
187 | } | |
188 | } | |
189 | } | |
190 | } | |
191 | } else { | |
192 | // ignore BSSID | |
193 | for (ii = 0; ii <MAX_BSS_NUM; ii++) { | |
194 | pCurrBSS = &(pMgmt->sBSSList[ii]); | |
195 | //2007-0721-01<Add>by MikeLiu | |
196 | pCurrBSS->bSelected = FALSE; | |
197 | if (pCurrBSS->bActive) { | |
198 | ||
199 | if (pSSID != NULL) { | |
200 | // matched SSID | |
51b6d9c2 | 201 | if (! !memcmp(pSSID->abySSID, |
5449c685 FB |
202 | ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID, |
203 | pSSID->len) || | |
204 | (pSSID->len != ((PWLAN_IE_SSID)pCurrBSS->abySSID)->len)) { | |
205 | // SSID not match skip this BSS | |
206 | continue; | |
612822f5 | 207 | } |
5449c685 FB |
208 | } |
209 | if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) || | |
210 | ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) | |
612822f5 | 211 | ){ |
5449c685 | 212 | // Type not match skip this BSS |
7e809a9b | 213 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSS type mismatch.... Config[%d] BSS[0x%04x]\n", pMgmt->eConfigMode, pCurrBSS->wCapInfo); |
5449c685 FB |
214 | continue; |
215 | } | |
216 | ||
217 | if (ePhyType != PHY_TYPE_AUTO) { | |
218 | if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) || | |
219 | ((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) { | |
220 | // PhyType not match skip this BSS | |
7e809a9b | 221 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Physical type mismatch.... ePhyType[%d] BSS[%d]\n", ePhyType, pCurrBSS->eNetworkTypeInUse); |
5449c685 FB |
222 | continue; |
223 | } | |
224 | } | |
225 | /* | |
226 | if (pMgmt->eAuthenMode < WMAC_AUTH_WPA) { | |
227 | if (pCurrBSS->bWPAValid == TRUE) { | |
228 | // WPA AP will reject connection of station without WPA enable. | |
229 | continue; | |
230 | } | |
231 | } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || | |
232 | (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) { | |
233 | if (pCurrBSS->bWPAValid == FALSE) { | |
234 | // station with WPA enable can't join NonWPA AP. | |
235 | continue; | |
236 | } | |
237 | } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || | |
238 | (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { | |
239 | if (pCurrBSS->bWPA2Valid == FALSE) { | |
240 | // station with WPA2 enable can't join NonWPA2 AP. | |
241 | continue; | |
242 | } | |
243 | } | |
244 | */ | |
245 | if (pSelect == NULL) { | |
246 | pSelect = pCurrBSS; | |
247 | } else { | |
248 | // compare RSSI, select signal strong one | |
249 | if (pCurrBSS->uRSSI < pSelect->uRSSI) { | |
250 | pSelect = pCurrBSS; | |
251 | } | |
252 | } | |
253 | } | |
254 | } | |
255 | if (pSelect != NULL) { | |
256 | pSelect->bSelected = TRUE; | |
257 | /* | |
258 | if (pDevice->bRoaming == FALSE) { | |
259 | // Einsn Add @20070907 | |
51b6d9c2 JL |
260 | memset(pbyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); |
261 | memcpy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1) ; | |
5449c685 FB |
262 | }*/ |
263 | ||
264 | return(pSelect); | |
265 | } | |
266 | } | |
267 | return(NULL); | |
268 | ||
269 | } | |
270 | ||
271 | ||
272 | /*+ | |
273 | * | |
274 | * Routine Description: | |
275 | * Clear BSS List | |
276 | * | |
277 | * Return Value: | |
278 | * None. | |
279 | * | |
280 | -*/ | |
281 | ||
282 | ||
283 | VOID | |
284 | BSSvClearBSSList( | |
285 | IN HANDLE hDeviceContext, | |
286 | IN BOOL bKeepCurrBSSID | |
287 | ) | |
288 | { | |
289 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
290 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
291 | UINT ii; | |
292 | ||
293 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { | |
294 | if (bKeepCurrBSSID) { | |
295 | if (pMgmt->sBSSList[ii].bActive && | |
296 | IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyCurrBSSID)) { | |
297 | // bKeepCurrBSSID = FALSE; | |
298 | continue; | |
299 | } | |
300 | } | |
301 | ||
302 | if ((pMgmt->sBSSList[ii].bActive) && (pMgmt->sBSSList[ii].uClearCount < BSS_CLEAR_COUNT)) { | |
303 | pMgmt->sBSSList[ii].uClearCount ++; | |
304 | continue; | |
305 | } | |
306 | ||
307 | pMgmt->sBSSList[ii].bActive = FALSE; | |
308 | memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS)); | |
309 | } | |
310 | BSSvClearAnyBSSJoinRecord(pDevice); | |
311 | ||
312 | return; | |
313 | } | |
314 | ||
315 | ||
316 | ||
317 | /*+ | |
318 | * | |
319 | * Routine Description: | |
320 | * search BSS list by BSSID & SSID if matched | |
321 | * | |
322 | * Return Value: | |
323 | * TRUE if found. | |
324 | * | |
325 | -*/ | |
326 | PKnownBSS | |
327 | BSSpAddrIsInBSSList( | |
328 | IN HANDLE hDeviceContext, | |
329 | IN PBYTE abyBSSID, | |
330 | IN PWLAN_IE_SSID pSSID | |
331 | ) | |
332 | { | |
333 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
334 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
335 | PKnownBSS pBSSList = NULL; | |
336 | UINT ii; | |
337 | ||
338 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { | |
339 | pBSSList = &(pMgmt->sBSSList[ii]); | |
340 | if (pBSSList->bActive) { | |
341 | if (IS_ETH_ADDRESS_EQUAL(pBSSList->abyBSSID, abyBSSID)) { | |
342 | // if (pSSID == NULL) | |
343 | // return pBSSList; | |
344 | if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len){ | |
345 | if (memcmp(pSSID->abySSID, | |
346 | ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID, | |
347 | pSSID->len) == 0) | |
348 | return pBSSList; | |
349 | } | |
350 | } | |
351 | } | |
352 | } | |
353 | ||
354 | return NULL; | |
355 | }; | |
356 | ||
357 | ||
358 | ||
5449c685 FB |
359 | /*+ |
360 | * | |
361 | * Routine Description: | |
362 | * Insert a BSS set into known BSS list | |
363 | * | |
364 | * Return Value: | |
365 | * TRUE if success. | |
366 | * | |
367 | -*/ | |
368 | ||
369 | BOOL | |
370 | BSSbInsertToBSSList ( | |
371 | IN HANDLE hDeviceContext, | |
372 | IN PBYTE abyBSSIDAddr, | |
373 | IN QWORD qwTimestamp, | |
374 | IN WORD wBeaconInterval, | |
375 | IN WORD wCapInfo, | |
376 | IN BYTE byCurrChannel, | |
377 | IN PWLAN_IE_SSID pSSID, | |
378 | IN PWLAN_IE_SUPP_RATES pSuppRates, | |
379 | IN PWLAN_IE_SUPP_RATES pExtSuppRates, | |
380 | IN PERPObject psERP, | |
381 | IN PWLAN_IE_RSN pRSN, | |
382 | IN PWLAN_IE_RSN_EXT pRSNWPA, | |
383 | IN PWLAN_IE_COUNTRY pIE_Country, | |
384 | IN PWLAN_IE_QUIET pIE_Quiet, | |
385 | IN UINT uIELength, | |
386 | IN PBYTE pbyIEs, | |
387 | IN HANDLE pRxPacketContext | |
388 | ) | |
389 | { | |
390 | ||
391 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
392 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
393 | PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; | |
394 | PKnownBSS pBSSList = NULL; | |
395 | UINT ii; | |
396 | BOOL bParsingQuiet = FALSE; | |
397 | PWLAN_IE_QUIET pQuiet = NULL; | |
398 | ||
399 | ||
400 | ||
401 | pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]); | |
402 | ||
403 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { | |
404 | pBSSList = (PKnownBSS)&(pMgmt->sBSSList[ii]); | |
405 | if (!pBSSList->bActive) | |
406 | break; | |
407 | } | |
408 | ||
409 | if (ii == MAX_BSS_NUM){ | |
612822f5 | 410 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Get free KnowBSS node failed.\n"); |
5449c685 FB |
411 | return FALSE; |
412 | } | |
413 | // save the BSS info | |
414 | pBSSList->bActive = TRUE; | |
415 | memcpy( pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN); | |
416 | HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp)); | |
417 | LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp)); | |
418 | pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); | |
419 | pBSSList->wCapInfo = cpu_to_le16(wCapInfo); | |
420 | pBSSList->uClearCount = 0; | |
421 | ||
422 | if (pSSID->len > WLAN_SSID_MAXLEN) | |
423 | pSSID->len = WLAN_SSID_MAXLEN; | |
424 | memcpy( pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN); | |
425 | ||
426 | pBSSList->uChannel = byCurrChannel; | |
427 | ||
428 | if (pSuppRates->len > WLAN_RATES_MAXLEN) | |
429 | pSuppRates->len = WLAN_RATES_MAXLEN; | |
430 | memcpy( pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN); | |
431 | ||
432 | if (pExtSuppRates != NULL) { | |
433 | if (pExtSuppRates->len > WLAN_RATES_MAXLEN) | |
434 | pExtSuppRates->len = WLAN_RATES_MAXLEN; | |
435 | memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN); | |
7e809a9b | 436 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbInsertToBSSList: pExtSuppRates->len = %d\n", pExtSuppRates->len); |
5449c685 FB |
437 | |
438 | } else { | |
439 | memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); | |
440 | } | |
441 | pBSSList->sERP.byERP = psERP->byERP; | |
442 | pBSSList->sERP.bERPExist = psERP->bERPExist; | |
443 | ||
444 | // Check if BSS is 802.11a/b/g | |
445 | if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { | |
446 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; | |
447 | } else { | |
448 | if (pBSSList->sERP.bERPExist == TRUE) { | |
449 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; | |
450 | } else { | |
451 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; | |
452 | } | |
453 | } | |
454 | ||
455 | pBSSList->byRxRate = pRxPacket->byRxRate; | |
456 | pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF; | |
457 | pBSSList->uRSSI = pRxPacket->uRSSI; | |
458 | pBSSList->bySQ = pRxPacket->bySQ; | |
459 | ||
460 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && | |
461 | (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { | |
462 | // assoc with BSS | |
463 | if (pBSSList == pMgmt->pCurrBSS) { | |
464 | bParsingQuiet = TRUE; | |
465 | } | |
466 | } | |
467 | ||
468 | WPA_ClearRSN(pBSSList); | |
469 | ||
470 | if (pRSNWPA != NULL) { | |
471 | UINT uLen = pRSNWPA->len + 2; | |
472 | ||
473 | if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { | |
474 | pBSSList->wWPALen = uLen; | |
475 | memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); | |
476 | WPA_ParseRSN(pBSSList, pRSNWPA); | |
477 | } | |
478 | } | |
479 | ||
480 | WPA2_ClearRSN(pBSSList); | |
481 | ||
482 | if (pRSN != NULL) { | |
483 | UINT uLen = pRSN->len + 2; | |
484 | if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { | |
485 | pBSSList->wRSNLen = uLen; | |
486 | memcpy(pBSSList->byRSNIE, pRSN, uLen); | |
487 | WPA2vParseRSN(pBSSList, pRSN); | |
488 | } | |
489 | } | |
490 | ||
491 | if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pBSSList->bWPA2Valid == TRUE)) { | |
492 | ||
493 | PSKeyItem pTransmitKey = NULL; | |
494 | BOOL bIs802_1x = FALSE; | |
495 | ||
496 | for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii ++) { | |
497 | if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) { | |
498 | bIs802_1x = TRUE; | |
499 | break; | |
500 | } | |
501 | } | |
502 | if ((bIs802_1x == TRUE) && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) && | |
51b6d9c2 | 503 | ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) { |
5449c685 FB |
504 | |
505 | bAdd_PMKID_Candidate((HANDLE)pDevice, pBSSList->abyBSSID, &pBSSList->sRSNCapObj); | |
506 | ||
507 | if ((pDevice->bLinkPass == TRUE) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { | |
508 | if ((KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) == TRUE) || | |
509 | (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey) == TRUE)) { | |
510 | pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList; | |
511 | pDevice->gsPMKIDCandidate.Version = 1; | |
512 | ||
513 | } | |
514 | ||
515 | } | |
516 | } | |
517 | } | |
518 | ||
519 | if (pDevice->bUpdateBBVGA) { | |
520 | // Moniter if RSSI is too strong. | |
521 | pBSSList->byRSSIStatCnt = 0; | |
522 | RFvRSSITodBm(pDevice, (BYTE)(pRxPacket->uRSSI), &pBSSList->ldBmMAX); | |
523 | pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; | |
524 | for (ii = 1; ii < RSSI_STAT_COUNT; ii++) | |
525 | pBSSList->ldBmAverage[ii] = 0; | |
526 | } | |
527 | ||
528 | if ((pIE_Country != NULL) && | |
529 | (pMgmt->b11hEnable == TRUE)) { | |
530 | CARDvSetCountryInfo(pMgmt->pAdapter, | |
531 | pBSSList->eNetworkTypeInUse, | |
532 | pIE_Country); | |
533 | } | |
534 | ||
5449c685 FB |
535 | if ((bParsingQuiet == TRUE) && (pIE_Quiet != NULL)) { |
536 | if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) && | |
537 | (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) { | |
538 | // valid EID | |
539 | if (pQuiet == NULL) { | |
540 | pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; | |
541 | CARDbSetQuiet( pMgmt->pAdapter, | |
542 | TRUE, | |
543 | pQuiet->byQuietCount, | |
544 | pQuiet->byQuietPeriod, | |
545 | *((PWORD)pQuiet->abyQuietDuration), | |
546 | *((PWORD)pQuiet->abyQuietOffset) | |
547 | ); | |
548 | } else { | |
549 | pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; | |
550 | CARDbSetQuiet( pMgmt->pAdapter, | |
551 | FALSE, | |
552 | pQuiet->byQuietCount, | |
553 | pQuiet->byQuietPeriod, | |
554 | *((PWORD)pQuiet->abyQuietDuration), | |
555 | *((PWORD)pQuiet->abyQuietOffset) | |
556 | ); | |
557 | } | |
558 | } | |
559 | } | |
560 | ||
561 | if ((bParsingQuiet == TRUE) && | |
562 | (pQuiet != NULL)) { | |
563 | CARDbStartQuiet(pMgmt->pAdapter); | |
564 | } | |
565 | ||
566 | pBSSList->uIELength = uIELength; | |
567 | if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) | |
568 | pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; | |
51b6d9c2 | 569 | memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); |
5449c685 FB |
570 | |
571 | return TRUE; | |
572 | } | |
573 | ||
574 | ||
575 | /*+ | |
576 | * | |
577 | * Routine Description: | |
578 | * Update BSS set in known BSS list | |
579 | * | |
580 | * Return Value: | |
581 | * TRUE if success. | |
582 | * | |
583 | -*/ | |
584 | // TODO: input structure modify | |
585 | ||
586 | BOOL | |
587 | BSSbUpdateToBSSList ( | |
588 | IN HANDLE hDeviceContext, | |
589 | IN QWORD qwTimestamp, | |
590 | IN WORD wBeaconInterval, | |
591 | IN WORD wCapInfo, | |
592 | IN BYTE byCurrChannel, | |
593 | IN BOOL bChannelHit, | |
594 | IN PWLAN_IE_SSID pSSID, | |
595 | IN PWLAN_IE_SUPP_RATES pSuppRates, | |
596 | IN PWLAN_IE_SUPP_RATES pExtSuppRates, | |
597 | IN PERPObject psERP, | |
598 | IN PWLAN_IE_RSN pRSN, | |
599 | IN PWLAN_IE_RSN_EXT pRSNWPA, | |
600 | IN PWLAN_IE_COUNTRY pIE_Country, | |
601 | IN PWLAN_IE_QUIET pIE_Quiet, | |
602 | IN PKnownBSS pBSSList, | |
603 | IN UINT uIELength, | |
604 | IN PBYTE pbyIEs, | |
605 | IN HANDLE pRxPacketContext | |
606 | ) | |
607 | { | |
608 | int ii; | |
609 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
610 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
611 | PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; | |
612 | LONG ldBm; | |
613 | BOOL bParsingQuiet = FALSE; | |
614 | PWLAN_IE_QUIET pQuiet = NULL; | |
615 | ||
616 | ||
617 | ||
618 | if (pBSSList == NULL) | |
619 | return FALSE; | |
620 | ||
612822f5 | 621 | |
5449c685 FB |
622 | HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp)); |
623 | LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp)); | |
624 | pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval); | |
625 | pBSSList->wCapInfo = cpu_to_le16(wCapInfo); | |
626 | pBSSList->uClearCount = 0; | |
627 | pBSSList->uChannel = byCurrChannel; | |
7e809a9b | 628 | // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbUpdateToBSSList: pBSSList->uChannel: %d\n", pBSSList->uChannel); |
5449c685 FB |
629 | |
630 | if (pSSID->len > WLAN_SSID_MAXLEN) | |
631 | pSSID->len = WLAN_SSID_MAXLEN; | |
632 | ||
633 | if ((pSSID->len != 0) && (pSSID->abySSID[0] != 0)) | |
634 | memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN); | |
635 | memcpy(pBSSList->abySuppRates, pSuppRates,pSuppRates->len + WLAN_IEHDR_LEN); | |
636 | ||
637 | if (pExtSuppRates != NULL) { | |
638 | memcpy(pBSSList->abyExtSuppRates, pExtSuppRates,pExtSuppRates->len + WLAN_IEHDR_LEN); | |
639 | } else { | |
640 | memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); | |
641 | } | |
642 | pBSSList->sERP.byERP = psERP->byERP; | |
643 | pBSSList->sERP.bERPExist = psERP->bERPExist; | |
644 | ||
645 | // Check if BSS is 802.11a/b/g | |
646 | if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) { | |
647 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11A; | |
648 | } else { | |
649 | if (pBSSList->sERP.bERPExist == TRUE) { | |
650 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11G; | |
651 | } else { | |
652 | pBSSList->eNetworkTypeInUse = PHY_TYPE_11B; | |
653 | } | |
654 | } | |
655 | ||
656 | pBSSList->byRxRate = pRxPacket->byRxRate; | |
657 | pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF; | |
658 | if(bChannelHit) | |
659 | pBSSList->uRSSI = pRxPacket->uRSSI; | |
660 | pBSSList->bySQ = pRxPacket->bySQ; | |
661 | ||
662 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && | |
663 | (pMgmt->eCurrState == WMAC_STATE_ASSOC)) { | |
664 | // assoc with BSS | |
665 | if (pBSSList == pMgmt->pCurrBSS) { | |
666 | bParsingQuiet = TRUE; | |
667 | } | |
668 | } | |
669 | ||
612822f5 | 670 | WPA_ClearRSN(pBSSList); //mike update |
5449c685 FB |
671 | |
672 | if (pRSNWPA != NULL) { | |
673 | UINT uLen = pRSNWPA->len + 2; | |
674 | if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { | |
675 | pBSSList->wWPALen = uLen; | |
676 | memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); | |
677 | WPA_ParseRSN(pBSSList, pRSNWPA); | |
678 | } | |
679 | } | |
680 | ||
612822f5 | 681 | WPA2_ClearRSN(pBSSList); //mike update |
5449c685 FB |
682 | |
683 | if (pRSN != NULL) { | |
684 | UINT uLen = pRSN->len + 2; | |
685 | if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { | |
686 | pBSSList->wRSNLen = uLen; | |
687 | memcpy(pBSSList->byRSNIE, pRSN, uLen); | |
688 | WPA2vParseRSN(pBSSList, pRSN); | |
689 | } | |
690 | } | |
691 | ||
692 | if (pRxPacket->uRSSI != 0) { | |
693 | RFvRSSITodBm(pDevice, (BYTE)(pRxPacket->uRSSI), &ldBm); | |
694 | // Moniter if RSSI is too strong. | |
695 | pBSSList->byRSSIStatCnt++; | |
696 | pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT; | |
697 | pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm; | |
698 | for(ii=0;ii<RSSI_STAT_COUNT;ii++) { | |
699 | if (pBSSList->ldBmAverage[ii] != 0) { | |
700 | pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm); | |
701 | } | |
702 | } | |
703 | } | |
704 | ||
705 | if ((pIE_Country != NULL) && | |
706 | (pMgmt->b11hEnable == TRUE)) { | |
707 | CARDvSetCountryInfo(pMgmt->pAdapter, | |
708 | pBSSList->eNetworkTypeInUse, | |
709 | pIE_Country); | |
710 | } | |
711 | ||
712 | if ((bParsingQuiet == TRUE) && (pIE_Quiet != NULL)) { | |
713 | if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) && | |
714 | (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) { | |
715 | // valid EID | |
716 | if (pQuiet == NULL) { | |
717 | pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; | |
718 | CARDbSetQuiet( pMgmt->pAdapter, | |
719 | TRUE, | |
720 | pQuiet->byQuietCount, | |
721 | pQuiet->byQuietPeriod, | |
722 | *((PWORD)pQuiet->abyQuietDuration), | |
723 | *((PWORD)pQuiet->abyQuietOffset) | |
724 | ); | |
725 | } else { | |
726 | pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; | |
727 | CARDbSetQuiet( pMgmt->pAdapter, | |
728 | FALSE, | |
729 | pQuiet->byQuietCount, | |
730 | pQuiet->byQuietPeriod, | |
731 | *((PWORD)pQuiet->abyQuietDuration), | |
732 | *((PWORD)pQuiet->abyQuietOffset) | |
733 | ); | |
734 | } | |
735 | } | |
736 | } | |
737 | ||
738 | if ((bParsingQuiet == TRUE) && | |
739 | (pQuiet != NULL)) { | |
740 | CARDbStartQuiet(pMgmt->pAdapter); | |
741 | } | |
742 | ||
743 | pBSSList->uIELength = uIELength; | |
744 | if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) | |
745 | pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN; | |
746 | memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength); | |
747 | ||
748 | return TRUE; | |
749 | } | |
750 | ||
751 | ||
752 | ||
753 | ||
754 | ||
755 | /*+ | |
756 | * | |
757 | * Routine Description: | |
758 | * Search Node DB table to find the index of matched DstAddr | |
759 | * | |
760 | * Return Value: | |
761 | * None | |
762 | * | |
763 | -*/ | |
764 | ||
765 | BOOL | |
766 | BSSDBbIsSTAInNodeDB( | |
767 | IN PVOID pMgmtObject, | |
768 | IN PBYTE abyDstAddr, | |
769 | OUT PUINT puNodeIndex | |
770 | ) | |
771 | { | |
772 | PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; | |
773 | UINT ii; | |
774 | ||
775 | // Index = 0 reserved for AP Node | |
776 | for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { | |
777 | if (pMgmt->sNodeDBTable[ii].bActive) { | |
778 | if (IS_ETH_ADDRESS_EQUAL(abyDstAddr, pMgmt->sNodeDBTable[ii].abyMACAddr)) { | |
779 | *puNodeIndex = ii; | |
780 | return TRUE; | |
781 | } | |
782 | } | |
783 | } | |
784 | ||
785 | return FALSE; | |
786 | }; | |
787 | ||
788 | ||
789 | ||
790 | /*+ | |
791 | * | |
792 | * Routine Description: | |
793 | * Find an empty node and allocated; if no empty found, | |
794 | * instand used of most inactive one. | |
795 | * | |
796 | * Return Value: | |
797 | * None | |
798 | * | |
799 | -*/ | |
800 | VOID | |
801 | BSSvCreateOneNode( | |
802 | IN HANDLE hDeviceContext, | |
803 | OUT PUINT puNodeIndex | |
804 | ) | |
805 | { | |
806 | ||
807 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
808 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
809 | UINT ii; | |
810 | UINT BigestCount = 0; | |
811 | UINT SelectIndex; | |
812 | struct sk_buff *skb; | |
813 | // Index = 0 reserved for AP Node (In STA mode) | |
814 | // Index = 0 reserved for Broadcast/MultiCast (In AP mode) | |
815 | SelectIndex = 1; | |
816 | for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { | |
817 | if (pMgmt->sNodeDBTable[ii].bActive) { | |
818 | if (pMgmt->sNodeDBTable[ii].uInActiveCount > BigestCount) { | |
819 | BigestCount = pMgmt->sNodeDBTable[ii].uInActiveCount; | |
820 | SelectIndex = ii; | |
821 | } | |
822 | } | |
823 | else { | |
824 | break; | |
825 | } | |
826 | } | |
827 | ||
828 | // if not found replace uInActiveCount is largest one. | |
829 | if ( ii == (MAX_NODE_NUM + 1)) { | |
830 | *puNodeIndex = SelectIndex; | |
7e809a9b | 831 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Replace inactive node = %d\n", SelectIndex); |
5449c685 FB |
832 | // clear ps buffer |
833 | if (pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue.next != NULL) { | |
834 | while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue)) != NULL) | |
835 | dev_kfree_skb(skb); | |
836 | } | |
837 | } | |
838 | else { | |
839 | *puNodeIndex = ii; | |
840 | } | |
841 | ||
842 | memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB)); | |
843 | pMgmt->sNodeDBTable[*puNodeIndex].bActive = TRUE; | |
844 | pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND; | |
845 | // for AP mode PS queue | |
846 | skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue); | |
847 | pMgmt->sNodeDBTable[*puNodeIndex].byAuthSequence = 0; | |
848 | pMgmt->sNodeDBTable[*puNodeIndex].wEnQueueCnt = 0; | |
7e809a9b | 849 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create node index = %d\n", ii); |
5449c685 FB |
850 | return; |
851 | }; | |
852 | ||
853 | ||
854 | ||
855 | /*+ | |
856 | * | |
857 | * Routine Description: | |
858 | * Remove Node by NodeIndex | |
859 | * | |
860 | * | |
861 | * Return Value: | |
862 | * None | |
863 | * | |
864 | -*/ | |
865 | VOID | |
866 | BSSvRemoveOneNode( | |
867 | IN HANDLE hDeviceContext, | |
868 | IN UINT uNodeIndex | |
869 | ) | |
870 | { | |
871 | ||
872 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
873 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
874 | BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; | |
875 | struct sk_buff *skb; | |
876 | ||
877 | ||
878 | while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL) | |
879 | dev_kfree_skb(skb); | |
880 | // clear context | |
881 | memset(&pMgmt->sNodeDBTable[uNodeIndex], 0, sizeof(KnownNodeDB)); | |
882 | // clear tx bit map | |
883 | pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[uNodeIndex].wAID >> 3] &= ~byMask[pMgmt->sNodeDBTable[uNodeIndex].wAID & 7]; | |
884 | ||
885 | return; | |
886 | }; | |
887 | /*+ | |
888 | * | |
889 | * Routine Description: | |
890 | * Update AP Node content in Index 0 of KnownNodeDB | |
891 | * | |
892 | * | |
893 | * Return Value: | |
894 | * None | |
895 | * | |
896 | -*/ | |
897 | ||
898 | VOID | |
899 | BSSvUpdateAPNode( | |
900 | IN HANDLE hDeviceContext, | |
901 | IN PWORD pwCapInfo, | |
902 | IN PWLAN_IE_SUPP_RATES pSuppRates, | |
903 | IN PWLAN_IE_SUPP_RATES pExtSuppRates | |
904 | ) | |
905 | { | |
906 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
907 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
908 | UINT uRateLen = WLAN_RATES_MAXLEN; | |
909 | ||
910 | memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); | |
911 | ||
912 | pMgmt->sNodeDBTable[0].bActive = TRUE; | |
913 | if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { | |
914 | uRateLen = WLAN_RATES_MAXLEN_11B; | |
915 | } | |
916 | pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pSuppRates, | |
917 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, | |
918 | uRateLen); | |
919 | pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pExtSuppRates, | |
920 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, | |
921 | uRateLen); | |
922 | RATEvParseMaxRate((PVOID) pDevice, | |
923 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, | |
924 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, | |
925 | TRUE, | |
926 | &(pMgmt->sNodeDBTable[0].wMaxBasicRate), | |
927 | &(pMgmt->sNodeDBTable[0].wMaxSuppRate), | |
928 | &(pMgmt->sNodeDBTable[0].wSuppRate), | |
929 | &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), | |
930 | &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) | |
931 | ); | |
932 | memcpy(pMgmt->sNodeDBTable[0].abyMACAddr, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); | |
933 | pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxSuppRate; | |
934 | pMgmt->sNodeDBTable[0].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo); | |
935 | pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND; | |
936 | #ifdef PLICE_DEBUG | |
937 | printk("BSSvUpdateAPNode:MaxSuppRate is %d\n",pMgmt->sNodeDBTable[0].wMaxSuppRate); | |
938 | #endif | |
939 | // Auto rate fallback function initiation. | |
940 | // RATEbInit(pDevice); | |
7e809a9b | 941 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->sNodeDBTable[0].wTxDataRate = %d \n", pMgmt->sNodeDBTable[0].wTxDataRate); |
5449c685 FB |
942 | |
943 | }; | |
944 | ||
945 | ||
946 | ||
947 | ||
948 | ||
949 | /*+ | |
950 | * | |
951 | * Routine Description: | |
952 | * Add Multicast Node content in Index 0 of KnownNodeDB | |
953 | * | |
954 | * | |
955 | * Return Value: | |
956 | * None | |
957 | * | |
958 | -*/ | |
959 | ||
960 | ||
961 | VOID | |
962 | BSSvAddMulticastNode( | |
963 | IN HANDLE hDeviceContext | |
964 | ) | |
965 | { | |
966 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
967 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
968 | ||
969 | if (!pDevice->bEnableHostWEP) | |
970 | memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); | |
971 | memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN); | |
972 | pMgmt->sNodeDBTable[0].bActive = TRUE; | |
973 | pMgmt->sNodeDBTable[0].bPSEnable = FALSE; | |
974 | skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue); | |
975 | RATEvParseMaxRate((PVOID) pDevice, | |
976 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, | |
977 | (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, | |
978 | TRUE, | |
979 | &(pMgmt->sNodeDBTable[0].wMaxBasicRate), | |
980 | &(pMgmt->sNodeDBTable[0].wMaxSuppRate), | |
981 | &(pMgmt->sNodeDBTable[0].wSuppRate), | |
982 | &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate), | |
983 | &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate) | |
984 | ); | |
985 | pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxBasicRate; | |
986 | #ifdef PLICE_DEBUG | |
987 | printk("BSSvAddMultiCastNode:pMgmt->sNodeDBTable[0].wTxDataRate is %d\n",pMgmt->sNodeDBTable[0].wTxDataRate); | |
988 | #endif | |
989 | pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND; | |
990 | ||
991 | }; | |
992 | ||
993 | ||
994 | ||
995 | ||
996 | ||
997 | /*+ | |
998 | * | |
999 | * Routine Description: | |
1000 | * | |
1001 | * | |
1002 | * Second call back function to update Node DB info & AP link status | |
1003 | * | |
1004 | * | |
1005 | * Return Value: | |
1006 | * none. | |
1007 | * | |
1008 | -*/ | |
1009 | //2008-4-14 <add> by chester for led issue | |
1010 | #ifdef FOR_LED_ON_NOTEBOOK | |
1011 | BOOL cc=FALSE; | |
1012 | UINT status; | |
1013 | #endif | |
1014 | VOID | |
1015 | BSSvSecondCallBack( | |
1016 | IN HANDLE hDeviceContext | |
1017 | ) | |
1018 | { | |
1019 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
1020 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
1021 | UINT ii; | |
1022 | PWLAN_IE_SSID pItemSSID, pCurrSSID; | |
1023 | UINT uSleepySTACnt = 0; | |
1024 | UINT uNonShortSlotSTACnt = 0; | |
1025 | UINT uLongPreambleSTACnt = 0; | |
612822f5 | 1026 | viawget_wpa_header* wpahdr; //DavidWang |
5449c685 FB |
1027 | |
1028 | spin_lock_irq(&pDevice->lock); | |
1029 | ||
1030 | pDevice->uAssocCount = 0; | |
1031 | ||
1032 | pDevice->byERPFlag &= | |
1033 | ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1)); | |
1034 | //2008-4-14 <add> by chester for led issue | |
1035 | #ifdef FOR_LED_ON_NOTEBOOK | |
1036 | MACvGPIOIn(pDevice->PortOffset, &pDevice->byGPIO); | |
256a816b | 1037 | if ((( !(pDevice->byGPIO & GPIO0_DATA)&&(pDevice->bHWRadioOff == FALSE))||((pDevice->byGPIO & GPIO0_DATA)&&(pDevice->bHWRadioOff == TRUE)))&&(cc==FALSE)){ |
5449c685 FB |
1038 | cc=TRUE; |
1039 | } | |
1040 | else if(cc==TRUE){ | |
1041 | ||
1042 | if(pDevice->bHWRadioOff == TRUE){ | |
256a816b JL |
1043 | if ( !(pDevice->byGPIO & GPIO0_DATA)) |
1044 | //||( !(pDevice->byGPIO & GPIO0_DATA) && (pDevice->byRadioCtl & EEP_RADIOCTL_INV))) | |
5449c685 FB |
1045 | {if(status==1) goto start; |
1046 | status=1; | |
1047 | CARDbRadioPowerOff(pDevice); | |
1048 | pMgmt->sNodeDBTable[0].bActive = FALSE; | |
1049 | pMgmt->eCurrMode = WMAC_MODE_STANDBY; | |
1050 | pMgmt->eCurrState = WMAC_STATE_IDLE; | |
1051 | //netif_stop_queue(pDevice->dev); | |
1052 | pDevice->bLinkPass = FALSE; | |
1053 | ||
1054 | } | |
256a816b JL |
1055 | if (pDevice->byGPIO &GPIO0_DATA) |
1056 | //||( !(pDevice->byGPIO & GPIO0_DATA) && (pDevice->byRadioCtl & EEP_RADIOCTL_INV))) | |
5449c685 FB |
1057 | {if(status==2) goto start; |
1058 | status=2; | |
1059 | CARDbRadioPowerOn(pDevice); | |
1060 | } } | |
1061 | else{ | |
256a816b JL |
1062 | if (pDevice->byGPIO & GPIO0_DATA) |
1063 | //||( !(pDevice->byGPIO & GPIO0_DATA) && (pDevice->byRadioCtl & EEP_RADIOCTL_INV))) | |
5449c685 FB |
1064 | {if(status==3) goto start; |
1065 | status=3; | |
1066 | CARDbRadioPowerOff(pDevice); | |
1067 | pMgmt->sNodeDBTable[0].bActive = FALSE; | |
1068 | pMgmt->eCurrMode = WMAC_MODE_STANDBY; | |
1069 | pMgmt->eCurrState = WMAC_STATE_IDLE; | |
1070 | //netif_stop_queue(pDevice->dev); | |
1071 | pDevice->bLinkPass = FALSE; | |
1072 | ||
1073 | } | |
256a816b JL |
1074 | if ( !(pDevice->byGPIO & GPIO0_DATA)) |
1075 | //||( !(pDevice->byGPIO & GPIO0_DATA) && (pDevice->byRadioCtl & EEP_RADIOCTL_INV))) | |
5449c685 FB |
1076 | {if(status==4) goto start; |
1077 | status=4; | |
1078 | CARDbRadioPowerOn(pDevice); | |
1079 | } } | |
1080 | } | |
1081 | start: | |
1082 | #endif | |
1083 | ||
1084 | ||
1085 | if (pDevice->wUseProtectCntDown > 0) { | |
1086 | pDevice->wUseProtectCntDown --; | |
1087 | } | |
1088 | else { | |
1089 | // disable protect mode | |
1090 | pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1)); | |
1091 | } | |
1092 | ||
1093 | { | |
1094 | pDevice->byReAssocCount++; | |
1095 | if((pDevice->byReAssocCount > 10) && (pDevice->bLinkPass != TRUE)) { //10 sec timeout | |
1096 | printk("Re-association timeout!!!\n"); | |
1097 | pDevice->byReAssocCount = 0; | |
1098 | #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT | |
1099 | // if(pDevice->bWPASuppWextEnabled == TRUE) | |
1100 | { | |
1101 | union iwreq_data wrqu; | |
1102 | memset(&wrqu, 0, sizeof (wrqu)); | |
1103 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | |
612822f5 | 1104 | PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n"); |
5449c685 FB |
1105 | wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); |
1106 | } | |
1107 | #endif | |
1108 | } | |
1109 | else if(pDevice->bLinkPass == TRUE) | |
1110 | pDevice->byReAssocCount = 0; | |
1111 | } | |
1112 | ||
1113 | #ifdef Calcu_LinkQual | |
1114 | s_uCalculateLinkQual((HANDLE)pDevice); | |
1115 | #endif | |
1116 | ||
1117 | for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) { | |
1118 | ||
1119 | if (pMgmt->sNodeDBTable[ii].bActive) { | |
5449c685 FB |
1120 | // Increase in-activity counter |
1121 | pMgmt->sNodeDBTable[ii].uInActiveCount++; | |
1122 | ||
1123 | if (ii > 0) { | |
1124 | if (pMgmt->sNodeDBTable[ii].uInActiveCount > MAX_INACTIVE_COUNT) { | |
1125 | BSSvRemoveOneNode(pDevice, ii); | |
612822f5 | 1126 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
5449c685 FB |
1127 | "Inactive timeout [%d] sec, STA index = [%d] remove\n", MAX_INACTIVE_COUNT, ii); |
1128 | continue; | |
1129 | } | |
1130 | ||
1131 | if (pMgmt->sNodeDBTable[ii].eNodeState >= NODE_ASSOC) { | |
1132 | ||
1133 | pDevice->uAssocCount++; | |
1134 | ||
1135 | // check if Non ERP exist | |
1136 | if (pMgmt->sNodeDBTable[ii].uInActiveCount < ERP_RECOVER_COUNT) { | |
1137 | if (!pMgmt->sNodeDBTable[ii].bShortPreamble) { | |
1138 | pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1); | |
1139 | uLongPreambleSTACnt ++; | |
1140 | } | |
1141 | if (!pMgmt->sNodeDBTable[ii].bERPExist) { | |
1142 | pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1); | |
1143 | pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1); | |
1144 | } | |
1145 | if (!pMgmt->sNodeDBTable[ii].bShortSlotTime) | |
1146 | uNonShortSlotSTACnt++; | |
1147 | } | |
1148 | } | |
1149 | ||
1150 | // check if any STA in PS mode | |
1151 | if (pMgmt->sNodeDBTable[ii].bPSEnable) | |
1152 | uSleepySTACnt++; | |
1153 | ||
1154 | ||
1155 | } | |
1156 | ||
1157 | // Rate fallback check | |
5449c685 FB |
1158 | if (!pDevice->bFixRate) { |
1159 | /* | |
1160 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (ii == 0)) | |
1161 | RATEvTxRateFallBack(pDevice, &(pMgmt->sNodeDBTable[ii])); | |
1162 | */ | |
1163 | if (ii > 0) { | |
1164 | // ii = 0 for multicast node (AP & Adhoc) | |
1165 | RATEvTxRateFallBack((PVOID)pDevice, &(pMgmt->sNodeDBTable[ii])); | |
1166 | } | |
1167 | else { | |
1168 | // ii = 0 reserved for unicast AP node (Infra STA) | |
1169 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) | |
1170 | #ifdef PLICE_DEBUG | |
1171 | printk("SecondCallback:Before:TxDataRate is %d\n",pMgmt->sNodeDBTable[0].wTxDataRate); | |
1172 | #endif | |
1173 | RATEvTxRateFallBack((PVOID)pDevice, &(pMgmt->sNodeDBTable[ii])); | |
1174 | #ifdef PLICE_DEBUG | |
1175 | printk("SecondCallback:After:TxDataRate is %d\n",pMgmt->sNodeDBTable[0].wTxDataRate); | |
1176 | #endif | |
1177 | ||
1178 | } | |
1179 | ||
1180 | } | |
1181 | ||
1182 | // check if pending PS queue | |
1183 | if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) { | |
7e809a9b | 1184 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index= %d, Queue = %d pending \n", |
5449c685 FB |
1185 | ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt); |
1186 | if ((ii >0) && (pMgmt->sNodeDBTable[ii].wEnQueueCnt > 15)) { | |
1187 | BSSvRemoveOneNode(pDevice, ii); | |
7e809a9b | 1188 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Pending many queues PS STA Index = %d remove \n", ii); |
5449c685 FB |
1189 | continue; |
1190 | } | |
1191 | } | |
1192 | } | |
1193 | ||
1194 | } | |
1195 | ||
1196 | ||
1197 | if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->eCurrentPHYType == PHY_TYPE_11G)) { | |
1198 | ||
1199 | // on/off protect mode | |
1200 | if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) { | |
1201 | if (!pDevice->bProtectMode) { | |
1202 | MACvEnableProtectMD(pDevice->PortOffset); | |
1203 | pDevice->bProtectMode = TRUE; | |
1204 | } | |
1205 | } | |
1206 | else { | |
1207 | if (pDevice->bProtectMode) { | |
1208 | MACvDisableProtectMD(pDevice->PortOffset); | |
1209 | pDevice->bProtectMode = FALSE; | |
1210 | } | |
1211 | } | |
1212 | // on/off short slot time | |
1213 | ||
1214 | if (uNonShortSlotSTACnt > 0) { | |
1215 | if (pDevice->bShortSlotTime) { | |
1216 | pDevice->bShortSlotTime = FALSE; | |
1217 | BBvSetShortSlotTime(pDevice); | |
1218 | vUpdateIFS((PVOID)pDevice); | |
1219 | } | |
1220 | } | |
1221 | else { | |
1222 | if (!pDevice->bShortSlotTime) { | |
1223 | pDevice->bShortSlotTime = TRUE; | |
1224 | BBvSetShortSlotTime(pDevice); | |
1225 | vUpdateIFS((PVOID)pDevice); | |
1226 | } | |
1227 | } | |
1228 | ||
1229 | // on/off barker long preamble mode | |
1230 | ||
1231 | if (uLongPreambleSTACnt > 0) { | |
1232 | if (!pDevice->bBarkerPreambleMd) { | |
1233 | MACvEnableBarkerPreambleMd(pDevice->PortOffset); | |
1234 | pDevice->bBarkerPreambleMd = TRUE; | |
1235 | } | |
1236 | } | |
1237 | else { | |
1238 | if (pDevice->bBarkerPreambleMd) { | |
1239 | MACvDisableBarkerPreambleMd(pDevice->PortOffset); | |
1240 | pDevice->bBarkerPreambleMd = FALSE; | |
1241 | } | |
1242 | } | |
1243 | ||
1244 | } | |
1245 | ||
1246 | ||
1247 | // Check if any STA in PS mode, enable DTIM multicast deliver | |
1248 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { | |
1249 | if (uSleepySTACnt > 0) | |
1250 | pMgmt->sNodeDBTable[0].bPSEnable = TRUE; | |
1251 | else | |
1252 | pMgmt->sNodeDBTable[0].bPSEnable = FALSE; | |
1253 | } | |
1254 | ||
1255 | pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; | |
1256 | pCurrSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; | |
612822f5 | 1257 | |
5449c685 FB |
1258 | if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) || |
1259 | (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) { | |
1260 | ||
1261 | if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS | |
7e809a9b | 1262 | // DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Callback inactive Count = [%d]\n", pMgmt->sNodeDBTable[0].uInActiveCount); |
5449c685 FB |
1263 | //if (pDevice->bUpdateBBVGA) { |
1264 | // s_vCheckSensitivity((HANDLE) pDevice); | |
1265 | //} | |
612822f5 | 1266 | |
5449c685 FB |
1267 | if (pDevice->bUpdateBBVGA) { |
1268 | // s_vCheckSensitivity((HANDLE) pDevice); | |
1269 | s_vCheckPreEDThreshold((HANDLE)pDevice); | |
1270 | } | |
612822f5 | 1271 | |
5449c685 FB |
1272 | if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) && |
1273 | (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0]) ) { | |
1274 | pDevice->byBBVGANew = pDevice->abyBBVGA[0]; | |
1275 | bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL); | |
1276 | } | |
1277 | ||
5449c685 FB |
1278 | if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) { |
1279 | pMgmt->sNodeDBTable[0].bActive = FALSE; | |
1280 | pMgmt->eCurrMode = WMAC_MODE_STANDBY; | |
1281 | pMgmt->eCurrState = WMAC_STATE_IDLE; | |
1282 | netif_stop_queue(pDevice->dev); | |
1283 | pDevice->bLinkPass = FALSE; | |
1284 | pDevice->bRoaming = TRUE; | |
7e809a9b | 1285 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost AP beacon [%d] sec, disconnected !\n", pMgmt->sNodeDBTable[0].uInActiveCount); |
5449c685 FB |
1286 | if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) { |
1287 | wpahdr = (viawget_wpa_header *)pDevice->skb->data; | |
1288 | wpahdr->type = VIAWGET_DISASSOC_MSG; | |
1289 | wpahdr->resp_ie_len = 0; | |
1290 | wpahdr->req_ie_len = 0; | |
1291 | skb_put(pDevice->skb, sizeof(viawget_wpa_header)); | |
1292 | pDevice->skb->dev = pDevice->wpadev; | |
db6cb903 | 1293 | skb_reset_mac_header(pDevice->skb); |
5449c685 FB |
1294 | pDevice->skb->pkt_type = PACKET_HOST; |
1295 | pDevice->skb->protocol = htons(ETH_P_802_2); | |
1296 | memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb)); | |
1297 | netif_rx(pDevice->skb); | |
1298 | pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); | |
1299 | }; | |
1300 | #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT | |
1301 | // if(pDevice->bWPASuppWextEnabled == TRUE) | |
1302 | { | |
1303 | union iwreq_data wrqu; | |
1304 | memset(&wrqu, 0, sizeof (wrqu)); | |
1305 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | |
612822f5 | 1306 | PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n"); |
5449c685 FB |
1307 | wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL); |
1308 | } | |
1309 | #endif | |
612822f5 | 1310 | } |
5449c685 FB |
1311 | } |
1312 | else if (pItemSSID->len != 0) { | |
1313 | if (pDevice->uAutoReConnectTime < 10) { | |
1314 | pDevice->uAutoReConnectTime++; | |
612822f5 | 1315 | #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT |
5449c685 FB |
1316 | //network manager support need not do Roaming scan??? |
1317 | if(pDevice->bWPASuppWextEnabled ==TRUE) | |
1318 | pDevice->uAutoReConnectTime = 0; | |
1319 | #endif | |
5449c685 FB |
1320 | } |
1321 | else { | |
612822f5 | 1322 | //mike use old encryption status for wpa reauthen |
5449c685 FB |
1323 | if(pDevice->bWPADEVUp) |
1324 | pDevice->eEncryptionStatus = pDevice->eOldEncryptionStatus; | |
612822f5 | 1325 | |
7e809a9b | 1326 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming ...\n"); |
5449c685 | 1327 | BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass); |
612822f5 | 1328 | pMgmt->eScanType = WMAC_SCAN_ACTIVE; |
5449c685 FB |
1329 | bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID); |
1330 | bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID); | |
1331 | pDevice->uAutoReConnectTime = 0; | |
1332 | } | |
1333 | } | |
1334 | } | |
1335 | ||
1336 | if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { | |
1337 | // if adhoc started which essid is NULL string, rescaning. | |
1338 | if ((pMgmt->eCurrState == WMAC_STATE_STARTED) && (pCurrSSID->len == 0)) { | |
1339 | if (pDevice->uAutoReConnectTime < 10) { | |
1340 | pDevice->uAutoReConnectTime++; | |
1341 | } | |
1342 | else { | |
7e809a9b | 1343 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Adhoc re-scaning ...\n"); |
612822f5 | 1344 | pMgmt->eScanType = WMAC_SCAN_ACTIVE; |
5449c685 FB |
1345 | bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL); |
1346 | bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL); | |
1347 | pDevice->uAutoReConnectTime = 0; | |
1348 | }; | |
1349 | } | |
1350 | if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { | |
612822f5 | 1351 | |
5449c685 FB |
1352 | if (pDevice->bUpdateBBVGA) { |
1353 | //s_vCheckSensitivity((HANDLE) pDevice); | |
1354 | s_vCheckPreEDThreshold((HANDLE)pDevice); | |
1355 | } | |
1356 | if (pMgmt->sNodeDBTable[0].uInActiveCount >=ADHOC_LOST_BEACON_COUNT) { | |
7e809a9b | 1357 | DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost other STA beacon [%d] sec, started !\n", pMgmt->sNodeDBTable[0].uInActiveCount); |
5449c685 FB |
1358 | pMgmt->sNodeDBTable[0].uInActiveCount = 0; |
1359 | pMgmt->eCurrState = WMAC_STATE_STARTED; | |
1360 | netif_stop_queue(pDevice->dev); | |
1361 | pDevice->bLinkPass = FALSE; | |
1362 | } | |
1363 | } | |
1364 | } | |
1365 | ||
1366 | spin_unlock_irq(&pDevice->lock); | |
1367 | ||
1368 | pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ); | |
1369 | add_timer(&pMgmt->sTimerSecondCallback); | |
1370 | return; | |
1371 | } | |
1372 | ||
1373 | ||
1374 | ||
1375 | ||
1376 | /*+ | |
1377 | * | |
1378 | * Routine Description: | |
1379 | * | |
1380 | * | |
1381 | * Update Tx attemps, Tx failure counter in Node DB | |
1382 | * | |
1383 | * | |
1384 | * Return Value: | |
1385 | * none. | |
1386 | * | |
1387 | -*/ | |
1388 | ||
1389 | ||
1390 | ||
1391 | VOID | |
1392 | BSSvUpdateNodeTxCounter( | |
1393 | IN HANDLE hDeviceContext, | |
1394 | IN BYTE byTsr0, | |
1395 | IN BYTE byTsr1, | |
1396 | IN PBYTE pbyBuffer, | |
1397 | IN UINT uFIFOHeaderSize | |
1398 | ) | |
1399 | { | |
1400 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
1401 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
1402 | UINT uNodeIndex = 0; | |
1403 | BYTE byTxRetry = (byTsr0 & TSR0_NCR); | |
1404 | PSTxBufHead pTxBufHead; | |
1405 | PS802_11Header pMACHeader; | |
1406 | WORD wRate; | |
1407 | WORD wFallBackRate = RATE_1M; | |
1408 | BYTE byFallBack; | |
1409 | UINT ii; | |
1410 | // UINT txRetryTemp; | |
1411 | //PLICE_DEBUG-> | |
1412 | //txRetryTemp = byTxRetry; | |
1413 | //if (txRetryTemp== 8) | |
1414 | //txRetryTemp -=3; | |
1415 | //PLICE_DEBUG <- | |
1416 | pTxBufHead = (PSTxBufHead) pbyBuffer; | |
1417 | if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_0) { | |
1418 | byFallBack = AUTO_FB_0; | |
1419 | } else if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_1) { | |
1420 | byFallBack = AUTO_FB_1; | |
1421 | } else { | |
1422 | byFallBack = AUTO_FB_NONE; | |
1423 | } | |
1424 | wRate = pTxBufHead->wReserved; //?wRate | |
1425 | //printk("BSSvUpdateNodeTxCounter:byTxRetry is %d\n",byTxRetry); | |
1426 | ||
1427 | //printk("BSSvUpdateNodeTx:wRate is %d,byFallback is %d\n",wRate,byFallBack); | |
1428 | //#ifdef PLICE_DEBUG | |
1429 | //printk("BSSvUpdateNodeTx: wRate is %d\n",wRate); | |
1430 | ////#endif | |
1431 | // Only Unicast using support rates | |
1432 | if (pTxBufHead->wFIFOCtl & FIFOCTL_NEEDACK) { | |
7e809a9b | 1433 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wRate %04X, byTsr0 %02X, byTsr1 %02X\n", wRate, byTsr0, byTsr1); |
5449c685 FB |
1434 | if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) { |
1435 | pMgmt->sNodeDBTable[0].uTxAttempts += 1; | |
1436 | if ((byTsr1 & TSR1_TERR) == 0) { | |
1437 | // transmit success, TxAttempts at least plus one | |
1438 | pMgmt->sNodeDBTable[0].uTxOk[MAX_RATE]++; | |
1439 | if ( (byFallBack == AUTO_FB_NONE) || | |
1440 | (wRate < RATE_18M) ) { | |
1441 | wFallBackRate = wRate; | |
1442 | } else if (byFallBack == AUTO_FB_0) { | |
1443 | //PLICE_DEBUG | |
1444 | if (byTxRetry < 5) | |
1445 | //if (txRetryTemp < 5) | |
1446 | wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry]; | |
1447 | //wFallBackRate = awHWRetry0[wRate-RATE_12M][byTxRetry]; | |
1448 | //wFallBackRate = awHWRetry0[wRate-RATE_18M][txRetryTemp] +1; | |
1449 | else | |
1450 | wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; | |
1451 | //wFallBackRate = awHWRetry0[wRate-RATE_12M][4]; | |
1452 | } else if (byFallBack == AUTO_FB_1) { | |
1453 | if (byTxRetry < 5) | |
1454 | wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry]; | |
1455 | else | |
1456 | wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; | |
1457 | } | |
1458 | pMgmt->sNodeDBTable[0].uTxOk[wFallBackRate]++; | |
1459 | } else { | |
1460 | pMgmt->sNodeDBTable[0].uTxFailures ++; | |
1461 | } | |
1462 | pMgmt->sNodeDBTable[0].uTxRetry += byTxRetry; | |
1463 | if (byTxRetry != 0) { | |
1464 | pMgmt->sNodeDBTable[0].uTxFail[MAX_RATE]+=byTxRetry; | |
1465 | if ( (byFallBack == AUTO_FB_NONE) || | |
1466 | (wRate < RATE_18M) ) { | |
1467 | pMgmt->sNodeDBTable[0].uTxFail[wRate]+=byTxRetry; | |
1468 | } else if (byFallBack == AUTO_FB_0) { | |
1469 | //PLICE_DEBUG | |
1470 | for(ii=0;ii<byTxRetry;ii++) | |
1471 | //for (ii=0;ii<txRetryTemp;ii++) | |
1472 | { | |
1473 | if (ii < 5) | |
1474 | { | |
1475 | ||
1476 | //PLICE_DEBUG | |
1477 | wFallBackRate = awHWRetry0[wRate-RATE_18M][ii]; | |
1478 | //printk(" II is %d:BSSvUpdateNodeTx:wFallBackRate is %d\n",ii,wFallBackRate); | |
1479 | //wFallBackRate = awHWRetry0[wRate-RATE_12M][ii]; | |
1480 | } | |
1481 | else | |
1482 | { | |
1483 | wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; | |
1484 | //printk("ii is %d BSSvUpdateNodeTx:wFallBackRate is %d\n",ii,wFallBackRate); | |
1485 | //wFallBackRate = awHWRetry0[wRate-RATE_12M][4]; | |
1486 | } | |
1487 | pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; | |
1488 | } | |
1489 | } else if (byFallBack == AUTO_FB_1) { | |
1490 | for(ii=0;ii<byTxRetry;ii++) { | |
1491 | if (ii < 5) | |
1492 | wFallBackRate = awHWRetry1[wRate-RATE_18M][ii]; | |
1493 | else | |
1494 | wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; | |
1495 | pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; | |
1496 | } | |
1497 | } | |
1498 | } | |
1499 | }; | |
1500 | ||
1501 | if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || | |
1502 | (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { | |
1503 | ||
1504 | pMACHeader = (PS802_11Header)(pbyBuffer + uFIFOHeaderSize); | |
1505 | ||
1506 | if (BSSDBbIsSTAInNodeDB((HANDLE)pMgmt, &(pMACHeader->abyAddr1[0]), &uNodeIndex)){ | |
1507 | pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1; | |
1508 | if ((byTsr1 & TSR1_TERR) == 0) { | |
1509 | // transmit success, TxAttempts at least plus one | |
1510 | pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++; | |
1511 | if ( (byFallBack == AUTO_FB_NONE) || | |
1512 | (wRate < RATE_18M) ) { | |
1513 | wFallBackRate = wRate; | |
1514 | } else if (byFallBack == AUTO_FB_0) { | |
1515 | if (byTxRetry < 5) | |
1516 | wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry]; | |
1517 | else | |
1518 | wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; | |
1519 | } else if (byFallBack == AUTO_FB_1) { | |
1520 | if (byTxRetry < 5) | |
1521 | wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry]; | |
1522 | else | |
1523 | wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; | |
1524 | } | |
1525 | pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wFallBackRate]++; | |
1526 | } else { | |
1527 | pMgmt->sNodeDBTable[uNodeIndex].uTxFailures ++; | |
1528 | } | |
1529 | pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += byTxRetry; | |
1530 | if (byTxRetry != 0) { | |
1531 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[MAX_RATE]+=byTxRetry; | |
1532 | if ( (byFallBack == AUTO_FB_NONE) || | |
1533 | (wRate < RATE_18M) ) { | |
1534 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate]+=byTxRetry; | |
1535 | } else if (byFallBack == AUTO_FB_0) { | |
1536 | for(ii=0;ii<byTxRetry;ii++) { | |
1537 | if (ii < 5) | |
1538 | wFallBackRate = awHWRetry0[wRate-RATE_18M][ii]; | |
1539 | else | |
1540 | wFallBackRate = awHWRetry0[wRate-RATE_18M][4]; | |
1541 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; | |
1542 | } | |
1543 | } else if (byFallBack == AUTO_FB_1) { | |
1544 | for(ii=0;ii<byTxRetry;ii++) { | |
1545 | if (ii < 5) | |
1546 | wFallBackRate = awHWRetry1[wRate-RATE_18M][ii]; | |
1547 | else | |
1548 | wFallBackRate = awHWRetry1[wRate-RATE_18M][4]; | |
1549 | pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; | |
1550 | } | |
1551 | } | |
1552 | } | |
1553 | }; | |
1554 | } | |
1555 | }; | |
1556 | ||
1557 | return; | |
1558 | ||
612822f5 | 1559 | |
5449c685 FB |
1560 | } |
1561 | ||
1562 | ||
1563 | ||
1564 | ||
1565 | /*+ | |
1566 | * | |
1567 | * Routine Description: | |
1568 | * Clear Nodes & skb in DB Table | |
1569 | * | |
1570 | * | |
1571 | * Parameters: | |
1572 | * In: | |
1573 | * hDeviceContext - The adapter context. | |
1574 | * uStartIndex - starting index | |
1575 | * Out: | |
1576 | * none | |
1577 | * | |
1578 | * Return Value: | |
1579 | * None. | |
1580 | * | |
1581 | -*/ | |
1582 | ||
1583 | ||
1584 | VOID | |
1585 | BSSvClearNodeDBTable( | |
1586 | IN HANDLE hDeviceContext, | |
1587 | IN UINT uStartIndex | |
1588 | ) | |
1589 | ||
1590 | { | |
1591 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
1592 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
1593 | struct sk_buff *skb; | |
1594 | UINT ii; | |
1595 | ||
1596 | for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) { | |
1597 | if (pMgmt->sNodeDBTable[ii].bActive) { | |
1598 | // check if sTxPSQueue has been initial | |
1599 | if (pMgmt->sNodeDBTable[ii].sTxPSQueue.next != NULL) { | |
1600 | while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL){ | |
7e809a9b | 1601 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS skb != NULL %d\n", ii); |
5449c685 FB |
1602 | dev_kfree_skb(skb); |
1603 | } | |
1604 | } | |
1605 | memset(&pMgmt->sNodeDBTable[ii], 0, sizeof(KnownNodeDB)); | |
1606 | } | |
1607 | } | |
1608 | ||
1609 | return; | |
1610 | }; | |
1611 | ||
1612 | ||
1613 | VOID s_vCheckSensitivity( | |
1614 | IN HANDLE hDeviceContext | |
1615 | ) | |
1616 | { | |
1617 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
1618 | PKnownBSS pBSSList = NULL; | |
1619 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
1620 | int ii; | |
1621 | ||
1622 | if ((pDevice->byLocalID <= REV_ID_VT3253_A1) && (pDevice->byRFType == RF_RFMD2959) && | |
1623 | (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { | |
1624 | return; | |
1625 | } | |
1626 | ||
1627 | if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || | |
1628 | ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { | |
1629 | pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); | |
1630 | if (pBSSList != NULL) { | |
1631 | // Updata BB Reg if RSSI is too strong. | |
1632 | LONG LocalldBmAverage = 0; | |
1633 | LONG uNumofdBm = 0; | |
1634 | for (ii = 0; ii < RSSI_STAT_COUNT; ii++) { | |
1635 | if (pBSSList->ldBmAverage[ii] != 0) { | |
1636 | uNumofdBm ++; | |
1637 | LocalldBmAverage += pBSSList->ldBmAverage[ii]; | |
1638 | } | |
1639 | } | |
1640 | if (uNumofdBm > 0) { | |
1641 | LocalldBmAverage = LocalldBmAverage/uNumofdBm; | |
1642 | for (ii=0;ii<BB_VGA_LEVEL;ii++) { | |
7e809a9b | 1643 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LocalldBmAverage:%ld, %ld %02x\n", LocalldBmAverage, pDevice->ldBmThreshold[ii], pDevice->abyBBVGA[ii]); |
5449c685 FB |
1644 | if (LocalldBmAverage < pDevice->ldBmThreshold[ii]) { |
1645 | pDevice->byBBVGANew = pDevice->abyBBVGA[ii]; | |
1646 | break; | |
1647 | } | |
1648 | } | |
1649 | if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) { | |
1650 | pDevice->uBBVGADiffCount++; | |
1651 | if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD) | |
1652 | bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL); | |
1653 | } else { | |
1654 | pDevice->uBBVGADiffCount = 0; | |
1655 | } | |
1656 | } | |
1657 | } | |
1658 | } | |
1659 | } | |
1660 | ||
1661 | ||
1662 | VOID | |
1663 | BSSvClearAnyBSSJoinRecord ( | |
1664 | IN HANDLE hDeviceContext | |
1665 | ) | |
1666 | { | |
1667 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
1668 | PSMgmtObject pMgmt = pDevice->pMgmt; | |
1669 | UINT ii; | |
1670 | ||
1671 | for (ii = 0; ii < MAX_BSS_NUM; ii++) { | |
1672 | pMgmt->sBSSList[ii].bSelected = FALSE; | |
1673 | } | |
1674 | return; | |
1675 | } | |
1676 | ||
1677 | #ifdef Calcu_LinkQual | |
1678 | VOID s_uCalculateLinkQual( | |
1679 | IN HANDLE hDeviceContext | |
1680 | ) | |
1681 | { | |
1682 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
1683 | ULONG TxOkRatio, TxCnt; | |
1684 | ULONG RxOkRatio,RxCnt; | |
1685 | ULONG RssiRatio; | |
1686 | long ldBm; | |
1687 | ||
1688 | TxCnt = pDevice->scStatistic.TxNoRetryOkCount + | |
1689 | pDevice->scStatistic.TxRetryOkCount + | |
1690 | pDevice->scStatistic.TxFailCount; | |
1691 | RxCnt = pDevice->scStatistic.RxFcsErrCnt + | |
1692 | pDevice->scStatistic.RxOkCnt; | |
1693 | TxOkRatio = (TxCnt < 6) ? 4000:((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt); | |
1694 | RxOkRatio = (RxCnt < 6) ? 2000:((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt); | |
1695 | //decide link quality | |
1696 | if(pDevice->bLinkPass !=TRUE) | |
1697 | { | |
1698 | // printk("s_uCalculateLinkQual-->Link disconnect and Poor quality**\n"); | |
1699 | pDevice->scStatistic.LinkQuality = 0; | |
1700 | pDevice->scStatistic.SignalStren = 0; | |
1701 | } | |
1702 | else | |
1703 | { | |
1704 | RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm); | |
1705 | if(-ldBm < 50) { | |
1706 | RssiRatio = 4000; | |
1707 | } | |
1708 | else if(-ldBm > 90) { | |
1709 | RssiRatio = 0; | |
1710 | } | |
1711 | else { | |
1712 | RssiRatio = (40-(-ldBm-50))*4000/40; | |
1713 | } | |
1714 | pDevice->scStatistic.SignalStren = RssiRatio/40; | |
1715 | pDevice->scStatistic.LinkQuality = (RssiRatio+TxOkRatio+RxOkRatio)/100; | |
1716 | } | |
1717 | pDevice->scStatistic.RxFcsErrCnt = 0; | |
1718 | pDevice->scStatistic.RxOkCnt = 0; | |
1719 | pDevice->scStatistic.TxFailCount = 0; | |
1720 | pDevice->scStatistic.TxNoRetryOkCount = 0; | |
1721 | pDevice->scStatistic.TxRetryOkCount = 0; | |
1722 | return; | |
1723 | } | |
1724 | #endif | |
1725 | ||
1726 | VOID s_vCheckPreEDThreshold( | |
1727 | IN HANDLE hDeviceContext | |
1728 | ) | |
1729 | { | |
1730 | PSDevice pDevice = (PSDevice)hDeviceContext; | |
1731 | PKnownBSS pBSSList = NULL; | |
1732 | PSMgmtObject pMgmt = &(pDevice->sMgmtObj); | |
1733 | ||
1734 | if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) || | |
1735 | ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) { | |
1736 | pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); | |
1737 | if (pBSSList != NULL) { | |
1738 | pDevice->byBBPreEDRSSI = (BYTE) (~(pBSSList->ldBmAverRange) + 1); | |
1739 | //BBvUpdatePreEDThreshold(pDevice, FALSE); | |
1740 | } | |
1741 | } | |
1742 | return; | |
1743 | } | |
612822f5 | 1744 |