bssdb.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512
  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. #include "ttype.h"
  42. #include "tmacro.h"
  43. #include "tether.h"
  44. #include "device.h"
  45. #include "80211hdr.h"
  46. #include "bssdb.h"
  47. #include "wmgr.h"
  48. #include "datarate.h"
  49. #include "desc.h"
  50. #include "wcmd.h"
  51. #include "wpa.h"
  52. #include "baseband.h"
  53. #include "rf.h"
  54. #include "card.h"
  55. #include "channel.h"
  56. #include "mac.h"
  57. #include "wpa2.h"
  58. #include "iowpa.h"
  59. /*--------------------- Static Definitions -------------------------*/
  60. /*--------------------- Static Classes ----------------------------*/
  61. /*--------------------- Static Variables --------------------------*/
  62. static const unsigned short awHWRetry0[5][5] = {
  63. {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
  64. {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
  65. {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
  66. {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
  67. {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
  68. };
  69. static const unsigned short awHWRetry1[5][5] = {
  70. {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
  71. {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
  72. {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
  73. {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M},
  74. {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
  75. };
  76. /*--------------------- Static Functions --------------------------*/
  77. void s_vCheckSensitivity(
  78. void *hDeviceContext
  79. );
  80. #ifdef Calcu_LinkQual
  81. void s_uCalculateLinkQual(
  82. void *hDeviceContext
  83. );
  84. #endif
  85. void s_vCheckPreEDThreshold(
  86. void *hDeviceContext
  87. );
  88. /*--------------------- Export Variables --------------------------*/
  89. /*--------------------- Export Functions --------------------------*/
  90. /*+
  91. *
  92. * Routine Description:
  93. * Search known BSS list for Desire SSID or BSSID.
  94. *
  95. * Return Value:
  96. * PTR to KnownBSS or NULL
  97. *
  98. -*/
  99. PKnownBSS
  100. BSSpSearchBSSList(
  101. void *hDeviceContext,
  102. unsigned char *pbyDesireBSSID,
  103. unsigned char *pbyDesireSSID,
  104. CARD_PHY_TYPE ePhyType
  105. )
  106. {
  107. struct vnt_private *pDevice = hDeviceContext;
  108. PSMgmtObject pMgmt = pDevice->pMgmt;
  109. unsigned char *pbyBSSID = NULL;
  110. PWLAN_IE_SSID pSSID = NULL;
  111. PKnownBSS pCurrBSS = NULL;
  112. PKnownBSS pSelect = NULL;
  113. unsigned char ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  114. unsigned int ii = 0;
  115. if (pbyDesireBSSID != NULL) {
  116. pr_debug("BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID);
  117. if ((!is_broadcast_ether_addr(pbyDesireBSSID)) &&
  118. (memcmp(pbyDesireBSSID, ZeroBSSID, 6) != 0))
  119. pbyBSSID = pbyDesireBSSID;
  120. }
  121. if (pbyDesireSSID != NULL) {
  122. if (((PWLAN_IE_SSID)pbyDesireSSID)->len != 0)
  123. pSSID = (PWLAN_IE_SSID) pbyDesireSSID;
  124. }
  125. if (pbyBSSID != NULL) {
  126. /* match BSSID first */
  127. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  128. pCurrBSS = &(pMgmt->sBSSList[ii]);
  129. if (!pDevice->bLinkPass)
  130. pCurrBSS->bSelected = false;
  131. if ((pCurrBSS->bActive) &&
  132. (!pCurrBSS->bSelected)) {
  133. if (ether_addr_equal(pCurrBSS->abyBSSID,
  134. pbyBSSID)) {
  135. if (pSSID != NULL) {
  136. /* compare ssid */
  137. if (!memcmp(pSSID->abySSID,
  138. ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
  139. pSSID->len)) {
  140. if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
  141. ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
  142. ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
  143. ) {
  144. pCurrBSS->bSelected = true;
  145. return pCurrBSS;
  146. }
  147. }
  148. } else {
  149. if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
  150. ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
  151. ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
  152. ) {
  153. pCurrBSS->bSelected = true;
  154. return pCurrBSS;
  155. }
  156. }
  157. }
  158. }
  159. }
  160. } else {
  161. /* ignore BSSID */
  162. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  163. pCurrBSS = &(pMgmt->sBSSList[ii]);
  164. /* 2007-0721-01<Add>by MikeLiu */
  165. pCurrBSS->bSelected = false;
  166. if (pCurrBSS->bActive) {
  167. if (pSSID != NULL) {
  168. /* matched SSID */
  169. if (!!memcmp(pSSID->abySSID,
  170. ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
  171. pSSID->len) ||
  172. (pSSID->len != ((PWLAN_IE_SSID)pCurrBSS->abySSID)->len)) {
  173. /* SSID not match skip this BSS */
  174. continue;
  175. }
  176. }
  177. if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) ||
  178. ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo))
  179. ) {
  180. /* Type not match skip this BSS */
  181. pr_debug("BSS type mismatch.... Config[%d] BSS[0x%04x]\n",
  182. pMgmt->eConfigMode,
  183. pCurrBSS->wCapInfo);
  184. continue;
  185. }
  186. if (ePhyType != PHY_TYPE_AUTO) {
  187. if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) ||
  188. ((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) {
  189. /* PhyType not match skip this BSS */
  190. pr_debug("Physical type mismatch.... ePhyType[%d] BSS[%d]\n",
  191. ePhyType,
  192. pCurrBSS->eNetworkTypeInUse);
  193. continue;
  194. }
  195. }
  196. if (pSelect == NULL) {
  197. pSelect = pCurrBSS;
  198. } else {
  199. /* compare RSSI, select signal strong one */
  200. if (pCurrBSS->uRSSI < pSelect->uRSSI)
  201. pSelect = pCurrBSS;
  202. }
  203. }
  204. }
  205. if (pSelect != NULL) {
  206. pSelect->bSelected = true;
  207. return pSelect;
  208. }
  209. }
  210. return NULL;
  211. }
  212. /*+
  213. *
  214. * Routine Description:
  215. * Clear BSS List
  216. *
  217. * Return Value:
  218. * None.
  219. *
  220. -*/
  221. void
  222. BSSvClearBSSList(
  223. void *hDeviceContext,
  224. bool bKeepCurrBSSID
  225. )
  226. {
  227. struct vnt_private *pDevice = hDeviceContext;
  228. PSMgmtObject pMgmt = pDevice->pMgmt;
  229. unsigned int ii;
  230. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  231. if (bKeepCurrBSSID) {
  232. if (pMgmt->sBSSList[ii].bActive &&
  233. ether_addr_equal(pMgmt->sBSSList[ii].abyBSSID,
  234. pMgmt->abyCurrBSSID)) {
  235. continue;
  236. }
  237. }
  238. if ((pMgmt->sBSSList[ii].bActive) && (pMgmt->sBSSList[ii].uClearCount < BSS_CLEAR_COUNT)) {
  239. pMgmt->sBSSList[ii].uClearCount++;
  240. continue;
  241. }
  242. pMgmt->sBSSList[ii].bActive = false;
  243. memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS));
  244. }
  245. BSSvClearAnyBSSJoinRecord(pDevice);
  246. }
  247. /*+
  248. *
  249. * Routine Description:
  250. * search BSS list by BSSID & SSID if matched
  251. *
  252. * Return Value:
  253. * true if found.
  254. *
  255. -*/
  256. PKnownBSS
  257. BSSpAddrIsInBSSList(
  258. void *hDeviceContext,
  259. unsigned char *abyBSSID,
  260. PWLAN_IE_SSID pSSID
  261. )
  262. {
  263. struct vnt_private *pDevice = hDeviceContext;
  264. PSMgmtObject pMgmt = pDevice->pMgmt;
  265. PKnownBSS pBSSList = NULL;
  266. unsigned int ii;
  267. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  268. pBSSList = &(pMgmt->sBSSList[ii]);
  269. if (pBSSList->bActive) {
  270. if (ether_addr_equal(pBSSList->abyBSSID, abyBSSID)) {
  271. if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len) {
  272. if (memcmp(pSSID->abySSID,
  273. ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID,
  274. pSSID->len) == 0)
  275. return pBSSList;
  276. }
  277. }
  278. }
  279. }
  280. return NULL;
  281. };
  282. /*+
  283. *
  284. * Routine Description:
  285. * Insert a BSS set into known BSS list
  286. *
  287. * Return Value:
  288. * true if success.
  289. *
  290. -*/
  291. bool
  292. BSSbInsertToBSSList(
  293. void *hDeviceContext,
  294. unsigned char *abyBSSIDAddr,
  295. __le64 qwTimestamp,
  296. unsigned short wBeaconInterval,
  297. unsigned short wCapInfo,
  298. unsigned char byCurrChannel,
  299. PWLAN_IE_SSID pSSID,
  300. PWLAN_IE_SUPP_RATES pSuppRates,
  301. PWLAN_IE_SUPP_RATES pExtSuppRates,
  302. PERPObject psERP,
  303. PWLAN_IE_RSN pRSN,
  304. PWLAN_IE_RSN_EXT pRSNWPA,
  305. PWLAN_IE_COUNTRY pIE_Country,
  306. PWLAN_IE_QUIET pIE_Quiet,
  307. unsigned int uIELength,
  308. unsigned char *pbyIEs,
  309. void *pRxPacketContext
  310. )
  311. {
  312. struct vnt_private *pDevice = hDeviceContext;
  313. PSMgmtObject pMgmt = pDevice->pMgmt;
  314. PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
  315. PKnownBSS pBSSList = NULL;
  316. unsigned int ii;
  317. bool bParsingQuiet = false;
  318. PWLAN_IE_QUIET pQuiet = NULL;
  319. pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]);
  320. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  321. pBSSList = (PKnownBSS)&(pMgmt->sBSSList[ii]);
  322. if (!pBSSList->bActive)
  323. break;
  324. }
  325. if (ii == MAX_BSS_NUM) {
  326. pr_debug("Get free KnowBSS node failed\n");
  327. return false;
  328. }
  329. /* save the BSS info */
  330. pBSSList->bActive = true;
  331. memcpy(pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN);
  332. pBSSList->qwBSSTimestamp = le64_to_cpu(qwTimestamp);
  333. pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
  334. pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
  335. pBSSList->uClearCount = 0;
  336. if (pSSID->len > WLAN_SSID_MAXLEN)
  337. pSSID->len = WLAN_SSID_MAXLEN;
  338. memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
  339. pBSSList->uChannel = byCurrChannel;
  340. if (pSuppRates->len > WLAN_RATES_MAXLEN)
  341. pSuppRates->len = WLAN_RATES_MAXLEN;
  342. memcpy(pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN);
  343. if (pExtSuppRates != NULL) {
  344. if (pExtSuppRates->len > WLAN_RATES_MAXLEN)
  345. pExtSuppRates->len = WLAN_RATES_MAXLEN;
  346. memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN);
  347. pr_debug("BSSbInsertToBSSList: pExtSuppRates->len = %d\n",
  348. pExtSuppRates->len);
  349. } else {
  350. memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
  351. }
  352. pBSSList->sERP.byERP = psERP->byERP;
  353. pBSSList->sERP.bERPExist = psERP->bERPExist;
  354. /* check if BSS is 802.11a/b/g */
  355. if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
  356. pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
  357. } else {
  358. if (pBSSList->sERP.bERPExist)
  359. pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
  360. else
  361. pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
  362. }
  363. pBSSList->byRxRate = pRxPacket->byRxRate;
  364. pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
  365. pBSSList->uRSSI = pRxPacket->uRSSI;
  366. pBSSList->bySQ = pRxPacket->bySQ;
  367. if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
  368. (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
  369. /* assoc with BSS */
  370. if (pBSSList == pMgmt->pCurrBSS)
  371. bParsingQuiet = true;
  372. }
  373. WPA_ClearRSN(pBSSList);
  374. if (pRSNWPA != NULL) {
  375. unsigned int uLen = pRSNWPA->len + 2;
  376. if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSNWPA - pbyIEs))) {
  377. pBSSList->wWPALen = uLen;
  378. memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
  379. WPA_ParseRSN(pBSSList, pRSNWPA);
  380. }
  381. }
  382. WPA2_ClearRSN(pBSSList);
  383. if (pRSN != NULL) {
  384. unsigned int uLen = pRSN->len + 2;
  385. if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSN - pbyIEs))) {
  386. pBSSList->wRSNLen = uLen;
  387. memcpy(pBSSList->byRSNIE, pRSN, uLen);
  388. WPA2vParseRSN(pBSSList, pRSN);
  389. }
  390. }
  391. if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || pBSSList->bWPA2Valid) {
  392. PSKeyItem pTransmitKey = NULL;
  393. bool bIs802_1x = false;
  394. for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii++) {
  395. if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) {
  396. bIs802_1x = true;
  397. break;
  398. }
  399. }
  400. if (bIs802_1x && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) &&
  401. (!memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) {
  402. bAdd_PMKID_Candidate((void *)pDevice, pBSSList->abyBSSID, &pBSSList->sRSNCapObj);
  403. if (pDevice->bLinkPass && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
  404. if (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) ||
  405. KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey)) {
  406. pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList;
  407. pDevice->gsPMKIDCandidate.Version = 1;
  408. }
  409. }
  410. }
  411. }
  412. if (pDevice->bUpdateBBVGA) {
  413. /* monitor if RSSI is too strong */
  414. pBSSList->byRSSIStatCnt = 0;
  415. RFvRSSITodBm(pDevice, (unsigned char)(pRxPacket->uRSSI), &pBSSList->ldBmMAX);
  416. pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX;
  417. for (ii = 1; ii < RSSI_STAT_COUNT; ii++)
  418. pBSSList->ldBmAverage[ii] = 0;
  419. }
  420. if ((pIE_Country != NULL) && pMgmt->b11hEnable) {
  421. set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse,
  422. pIE_Country);
  423. }
  424. if (bParsingQuiet && (pIE_Quiet != NULL)) {
  425. if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) &&
  426. (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) {
  427. /* valid EID */
  428. if (pQuiet == NULL) {
  429. pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
  430. CARDbSetQuiet(pMgmt->pAdapter,
  431. true,
  432. pQuiet->byQuietCount,
  433. pQuiet->byQuietPeriod,
  434. *((unsigned short *)pQuiet->abyQuietDuration),
  435. *((unsigned short *)pQuiet->abyQuietOffset)
  436. );
  437. } else {
  438. pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
  439. CARDbSetQuiet(pMgmt->pAdapter,
  440. false,
  441. pQuiet->byQuietCount,
  442. pQuiet->byQuietPeriod,
  443. *((unsigned short *)pQuiet->abyQuietDuration),
  444. *((unsigned short *)pQuiet->abyQuietOffset)
  445. );
  446. }
  447. }
  448. }
  449. if (bParsingQuiet && (pQuiet != NULL))
  450. CARDbStartQuiet(pMgmt->pAdapter);
  451. pBSSList->uIELength = uIELength;
  452. if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
  453. pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
  454. memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
  455. return true;
  456. }
  457. /*+
  458. *
  459. * Routine Description:
  460. * Update BSS set in known BSS list
  461. *
  462. * Return Value:
  463. * true if success.
  464. *
  465. -*/
  466. /* TODO: input structure modify */
  467. bool
  468. BSSbUpdateToBSSList(
  469. void *hDeviceContext,
  470. __le64 qwTimestamp,
  471. unsigned short wBeaconInterval,
  472. unsigned short wCapInfo,
  473. unsigned char byCurrChannel,
  474. bool bChannelHit,
  475. PWLAN_IE_SSID pSSID,
  476. PWLAN_IE_SUPP_RATES pSuppRates,
  477. PWLAN_IE_SUPP_RATES pExtSuppRates,
  478. PERPObject psERP,
  479. PWLAN_IE_RSN pRSN,
  480. PWLAN_IE_RSN_EXT pRSNWPA,
  481. PWLAN_IE_COUNTRY pIE_Country,
  482. PWLAN_IE_QUIET pIE_Quiet,
  483. PKnownBSS pBSSList,
  484. unsigned int uIELength,
  485. unsigned char *pbyIEs,
  486. void *pRxPacketContext
  487. )
  488. {
  489. int ii;
  490. struct vnt_private *pDevice = hDeviceContext;
  491. PSMgmtObject pMgmt = pDevice->pMgmt;
  492. PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
  493. long ldBm;
  494. bool bParsingQuiet = false;
  495. PWLAN_IE_QUIET pQuiet = NULL;
  496. if (pBSSList == NULL)
  497. return false;
  498. pBSSList->qwBSSTimestamp = le64_to_cpu(qwTimestamp);
  499. pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
  500. pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
  501. pBSSList->uClearCount = 0;
  502. pBSSList->uChannel = byCurrChannel;
  503. if (pSSID->len > WLAN_SSID_MAXLEN)
  504. pSSID->len = WLAN_SSID_MAXLEN;
  505. if ((pSSID->len != 0) && (pSSID->abySSID[0] != 0))
  506. memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
  507. memcpy(pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN);
  508. if (pExtSuppRates != NULL)
  509. memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN);
  510. else
  511. memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
  512. pBSSList->sERP.byERP = psERP->byERP;
  513. pBSSList->sERP.bERPExist = psERP->bERPExist;
  514. /* check if BSS is 802.11a/b/g */
  515. if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
  516. pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
  517. } else {
  518. if (pBSSList->sERP.bERPExist)
  519. pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
  520. else
  521. pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
  522. }
  523. pBSSList->byRxRate = pRxPacket->byRxRate;
  524. pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
  525. if (bChannelHit)
  526. pBSSList->uRSSI = pRxPacket->uRSSI;
  527. pBSSList->bySQ = pRxPacket->bySQ;
  528. if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
  529. (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
  530. /* assoc with BSS */
  531. if (pBSSList == pMgmt->pCurrBSS)
  532. bParsingQuiet = true;
  533. }
  534. WPA_ClearRSN(pBSSList); /* mike update */
  535. if (pRSNWPA != NULL) {
  536. unsigned int uLen = pRSNWPA->len + 2;
  537. if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSNWPA - pbyIEs))) {
  538. pBSSList->wWPALen = uLen;
  539. memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
  540. WPA_ParseRSN(pBSSList, pRSNWPA);
  541. }
  542. }
  543. WPA2_ClearRSN(pBSSList); /* mike update */
  544. if (pRSN != NULL) {
  545. unsigned int uLen = pRSN->len + 2;
  546. if (uLen <= (uIELength - (unsigned int)((unsigned char *)pRSN - pbyIEs))) {
  547. pBSSList->wRSNLen = uLen;
  548. memcpy(pBSSList->byRSNIE, pRSN, uLen);
  549. WPA2vParseRSN(pBSSList, pRSN);
  550. }
  551. }
  552. if (pRxPacket->uRSSI != 0) {
  553. RFvRSSITodBm(pDevice, (unsigned char)(pRxPacket->uRSSI), &ldBm);
  554. /* monitor if RSSI is too strong */
  555. pBSSList->byRSSIStatCnt++;
  556. pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT;
  557. pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm;
  558. for (ii = 0; ii < RSSI_STAT_COUNT; ii++) {
  559. if (pBSSList->ldBmAverage[ii] != 0)
  560. pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm);
  561. }
  562. }
  563. if ((pIE_Country != NULL) && pMgmt->b11hEnable) {
  564. set_country_info(pMgmt->pAdapter, pBSSList->eNetworkTypeInUse,
  565. pIE_Country);
  566. }
  567. if (bParsingQuiet && (pIE_Quiet != NULL)) {
  568. if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) &&
  569. (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) {
  570. /* valid EID */
  571. if (pQuiet == NULL) {
  572. pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
  573. CARDbSetQuiet(pMgmt->pAdapter,
  574. true,
  575. pQuiet->byQuietCount,
  576. pQuiet->byQuietPeriod,
  577. *((unsigned short *)pQuiet->abyQuietDuration),
  578. *((unsigned short *)pQuiet->abyQuietOffset)
  579. );
  580. } else {
  581. pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
  582. CARDbSetQuiet(pMgmt->pAdapter,
  583. false,
  584. pQuiet->byQuietCount,
  585. pQuiet->byQuietPeriod,
  586. *((unsigned short *)pQuiet->abyQuietDuration),
  587. *((unsigned short *)pQuiet->abyQuietOffset)
  588. );
  589. }
  590. }
  591. }
  592. if (bParsingQuiet && (pQuiet != NULL))
  593. CARDbStartQuiet(pMgmt->pAdapter);
  594. pBSSList->uIELength = uIELength;
  595. if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
  596. pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
  597. memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
  598. return true;
  599. }
  600. /*+
  601. *
  602. * Routine Description:
  603. * Search Node DB table to find the index of matched DstAddr
  604. *
  605. * Return Value:
  606. * None
  607. *
  608. -*/
  609. bool
  610. BSSDBbIsSTAInNodeDB(void *pMgmtObject, unsigned char *abyDstAddr,
  611. unsigned int *puNodeIndex)
  612. {
  613. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
  614. unsigned int ii;
  615. /* Index = 0 reserved for AP Node */
  616. for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
  617. if (pMgmt->sNodeDBTable[ii].bActive) {
  618. if (ether_addr_equal(abyDstAddr,
  619. pMgmt->sNodeDBTable[ii].abyMACAddr)) {
  620. *puNodeIndex = ii;
  621. return true;
  622. }
  623. }
  624. }
  625. return false;
  626. };
  627. /*+
  628. *
  629. * Routine Description:
  630. * Find an empty node and allocat it; if there is no empty node,
  631. * then use the most inactive one.
  632. *
  633. * Return Value:
  634. * None
  635. *
  636. -*/
  637. void
  638. BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex)
  639. {
  640. struct vnt_private *pDevice = hDeviceContext;
  641. PSMgmtObject pMgmt = pDevice->pMgmt;
  642. unsigned int ii;
  643. unsigned int BigestCount = 0;
  644. unsigned int SelectIndex;
  645. struct sk_buff *skb;
  646. /*
  647. * Index = 0 reserved for AP Node (In STA mode)
  648. * Index = 0 reserved for Broadcast/MultiCast (In AP mode)
  649. */
  650. SelectIndex = 1;
  651. for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
  652. if (pMgmt->sNodeDBTable[ii].bActive) {
  653. if (pMgmt->sNodeDBTable[ii].uInActiveCount > BigestCount) {
  654. BigestCount = pMgmt->sNodeDBTable[ii].uInActiveCount;
  655. SelectIndex = ii;
  656. }
  657. } else {
  658. break;
  659. }
  660. }
  661. /* if not found replace uInActiveCount is largest one */
  662. if (ii == (MAX_NODE_NUM + 1)) {
  663. *puNodeIndex = SelectIndex;
  664. pr_info("Replace inactive node = %d\n", SelectIndex);
  665. /* clear ps buffer */
  666. if (pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue.next != NULL) {
  667. while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue)) != NULL)
  668. dev_kfree_skb(skb);
  669. }
  670. } else {
  671. *puNodeIndex = ii;
  672. }
  673. memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB));
  674. pMgmt->sNodeDBTable[*puNodeIndex].bActive = true;
  675. pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND;
  676. /* for AP mode PS queue */
  677. skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue);
  678. pMgmt->sNodeDBTable[*puNodeIndex].byAuthSequence = 0;
  679. pMgmt->sNodeDBTable[*puNodeIndex].wEnQueueCnt = 0;
  680. pr_debug("Create node index = %d\n", ii);
  681. return;
  682. };
  683. /*+
  684. *
  685. * Routine Description:
  686. * Remove Node by NodeIndex
  687. *
  688. *
  689. * Return Value:
  690. * None
  691. *
  692. -*/
  693. void
  694. BSSvRemoveOneNode(
  695. void *hDeviceContext,
  696. unsigned int uNodeIndex
  697. )
  698. {
  699. struct vnt_private *pDevice = hDeviceContext;
  700. PSMgmtObject pMgmt = pDevice->pMgmt;
  701. unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
  702. struct sk_buff *skb;
  703. while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL)
  704. dev_kfree_skb(skb);
  705. /* clear context */
  706. memset(&pMgmt->sNodeDBTable[uNodeIndex], 0, sizeof(KnownNodeDB));
  707. /* clear tx bit map */
  708. pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[uNodeIndex].wAID >> 3] &= ~byMask[pMgmt->sNodeDBTable[uNodeIndex].wAID & 7];
  709. return;
  710. };
  711. /*+
  712. *
  713. * Routine Description:
  714. * Update AP Node content in Index 0 of KnownNodeDB
  715. *
  716. *
  717. * Return Value:
  718. * None
  719. *
  720. -*/
  721. void
  722. BSSvUpdateAPNode(
  723. void *hDeviceContext,
  724. unsigned short *pwCapInfo,
  725. PWLAN_IE_SUPP_RATES pSuppRates,
  726. PWLAN_IE_SUPP_RATES pExtSuppRates
  727. )
  728. {
  729. struct vnt_private *pDevice = hDeviceContext;
  730. PSMgmtObject pMgmt = pDevice->pMgmt;
  731. unsigned int uRateLen = WLAN_RATES_MAXLEN;
  732. memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
  733. pMgmt->sNodeDBTable[0].bActive = true;
  734. if (pDevice->eCurrentPHYType == PHY_TYPE_11B)
  735. uRateLen = WLAN_RATES_MAXLEN_11B;
  736. pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pSuppRates,
  737. (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
  738. uRateLen);
  739. pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pExtSuppRates,
  740. (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
  741. uRateLen);
  742. RATEvParseMaxRate((void *)pDevice,
  743. (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
  744. (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
  745. true,
  746. &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
  747. &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
  748. &(pMgmt->sNodeDBTable[0].wSuppRate),
  749. &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
  750. &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
  751. );
  752. memcpy(pMgmt->sNodeDBTable[0].abyMACAddr, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
  753. pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxSuppRate;
  754. pMgmt->sNodeDBTable[0].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo);
  755. pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
  756. netdev_dbg(pDevice->dev, "BSSvUpdateAPNode:MaxSuppRate is %d\n",
  757. pMgmt->sNodeDBTable[0].wMaxSuppRate);
  758. /* auto rate fallback function initiation */
  759. pr_debug("pMgmt->sNodeDBTable[0].wTxDataRate = %d\n",
  760. pMgmt->sNodeDBTable[0].wTxDataRate);
  761. };
  762. /*+
  763. *
  764. * Routine Description:
  765. * Add Multicast Node content in Index 0 of KnownNodeDB
  766. *
  767. *
  768. * Return Value:
  769. * None
  770. *
  771. -*/
  772. void
  773. BSSvAddMulticastNode(
  774. void *hDeviceContext
  775. )
  776. {
  777. struct vnt_private *pDevice = hDeviceContext;
  778. PSMgmtObject pMgmt = pDevice->pMgmt;
  779. if (!pDevice->bEnableHostWEP)
  780. memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
  781. memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN);
  782. pMgmt->sNodeDBTable[0].bActive = true;
  783. pMgmt->sNodeDBTable[0].bPSEnable = false;
  784. skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue);
  785. RATEvParseMaxRate((void *)pDevice,
  786. (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
  787. (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
  788. true,
  789. &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
  790. &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
  791. &(pMgmt->sNodeDBTable[0].wSuppRate),
  792. &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
  793. &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
  794. );
  795. pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxBasicRate;
  796. netdev_dbg(pDevice->dev,
  797. "BSSvAddMultiCastNode:pMgmt->sNodeDBTable[0].wTxDataRate is %d\n",
  798. pMgmt->sNodeDBTable[0].wTxDataRate);
  799. pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
  800. };
  801. /*+
  802. *
  803. * Routine Description:
  804. *
  805. *
  806. * Second call back function to update Node DB info & AP link status
  807. *
  808. *
  809. * Return Value:
  810. * none.
  811. *
  812. -*/
  813. void
  814. BSSvSecondCallBack(
  815. void *hDeviceContext
  816. )
  817. {
  818. struct vnt_private *pDevice = hDeviceContext;
  819. PSMgmtObject pMgmt = pDevice->pMgmt;
  820. unsigned int ii;
  821. PWLAN_IE_SSID pItemSSID, pCurrSSID;
  822. unsigned int uSleepySTACnt = 0;
  823. unsigned int uNonShortSlotSTACnt = 0;
  824. unsigned int uLongPreambleSTACnt = 0;
  825. viawget_wpa_header *wpahdr; /* DavidWang */
  826. spin_lock_irq(&pDevice->lock);
  827. pDevice->uAssocCount = 0;
  828. pDevice->byERPFlag &=
  829. ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1));
  830. if (pDevice->wUseProtectCntDown > 0) {
  831. pDevice->wUseProtectCntDown--;
  832. } else {
  833. /* disable protect mode */
  834. pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1));
  835. }
  836. if (pDevice->eCommandState == WLAN_ASSOCIATE_WAIT) {
  837. pDevice->byReAssocCount++;
  838. /* 10 sec timeout */
  839. if ((pDevice->byReAssocCount > 10) && (!pDevice->bLinkPass)) {
  840. netdev_info(pDevice->dev, "Re-association timeout!!!\n");
  841. pDevice->byReAssocCount = 0;
  842. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  843. {
  844. union iwreq_data wrqu;
  845. memset(&wrqu, 0, sizeof(wrqu));
  846. wrqu.ap_addr.sa_family = ARPHRD_ETHER;
  847. PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
  848. wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
  849. }
  850. #endif
  851. } else if (pDevice->bLinkPass)
  852. pDevice->byReAssocCount = 0;
  853. }
  854. #ifdef Calcu_LinkQual
  855. s_uCalculateLinkQual((void *)pDevice);
  856. #endif
  857. for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
  858. if (pMgmt->sNodeDBTable[ii].bActive) {
  859. /* increase in-activity counter */
  860. pMgmt->sNodeDBTable[ii].uInActiveCount++;
  861. if (ii > 0) {
  862. if (pMgmt->sNodeDBTable[ii].uInActiveCount > MAX_INACTIVE_COUNT) {
  863. BSSvRemoveOneNode(pDevice, ii);
  864. pr_debug("Inactive timeout [%d] sec, STA index = [%d] remove\n",
  865. MAX_INACTIVE_COUNT, ii);
  866. continue;
  867. }
  868. if (pMgmt->sNodeDBTable[ii].eNodeState >= NODE_ASSOC) {
  869. pDevice->uAssocCount++;
  870. /* check if Non ERP exist */
  871. if (pMgmt->sNodeDBTable[ii].uInActiveCount < ERP_RECOVER_COUNT) {
  872. if (!pMgmt->sNodeDBTable[ii].bShortPreamble) {
  873. pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1);
  874. uLongPreambleSTACnt++;
  875. }
  876. if (!pMgmt->sNodeDBTable[ii].bERPExist) {
  877. pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1);
  878. pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
  879. }
  880. if (!pMgmt->sNodeDBTable[ii].bShortSlotTime)
  881. uNonShortSlotSTACnt++;
  882. }
  883. }
  884. /* check if any STA in PS mode */
  885. if (pMgmt->sNodeDBTable[ii].bPSEnable)
  886. uSleepySTACnt++;
  887. }
  888. /* rate fallback check */
  889. if (!pDevice->bFixRate) {
  890. if (ii > 0) {
  891. /* ii = 0 for multicast node (AP & Adhoc) */
  892. RATEvTxRateFallBack((void *)pDevice, &(pMgmt->sNodeDBTable[ii]));
  893. } else {
  894. /* ii = 0 reserved for unicast AP node (Infra STA) */
  895. if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)
  896. netdev_dbg(pDevice->dev,
  897. "SecondCallback:Before:TxDataRate is %d\n",
  898. pMgmt->sNodeDBTable[0].wTxDataRate);
  899. RATEvTxRateFallBack((void *)pDevice, &(pMgmt->sNodeDBTable[ii]));
  900. netdev_dbg(pDevice->dev,
  901. "SecondCallback:After:TxDataRate is %d\n",
  902. pMgmt->sNodeDBTable[0].wTxDataRate);
  903. }
  904. }
  905. /* check if pending PS queue */
  906. if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) {
  907. pr_debug("Index= %d, Queue = %d pending\n",
  908. ii,
  909. pMgmt->sNodeDBTable[ii].wEnQueueCnt);
  910. if ((ii > 0) && (pMgmt->sNodeDBTable[ii].wEnQueueCnt > 15)) {
  911. BSSvRemoveOneNode(pDevice, ii);
  912. pr_info("Pending many queues PS STA Index = %d remove\n",
  913. ii);
  914. continue;
  915. }
  916. }
  917. }
  918. }
  919. if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->eCurrentPHYType == PHY_TYPE_11G)) {
  920. /* on/off protect mode */
  921. if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) {
  922. if (!pDevice->bProtectMode) {
  923. MACvEnableProtectMD(pDevice->PortOffset);
  924. pDevice->bProtectMode = true;
  925. }
  926. } else {
  927. if (pDevice->bProtectMode) {
  928. MACvDisableProtectMD(pDevice->PortOffset);
  929. pDevice->bProtectMode = false;
  930. }
  931. }
  932. /* on/off short slot time */
  933. if (uNonShortSlotSTACnt > 0) {
  934. if (pDevice->bShortSlotTime) {
  935. pDevice->bShortSlotTime = false;
  936. BBvSetShortSlotTime(pDevice);
  937. vUpdateIFS((void *)pDevice);
  938. }
  939. } else {
  940. if (!pDevice->bShortSlotTime) {
  941. pDevice->bShortSlotTime = true;
  942. BBvSetShortSlotTime(pDevice);
  943. vUpdateIFS((void *)pDevice);
  944. }
  945. }
  946. /* on/off barker long preamble mode */
  947. if (uLongPreambleSTACnt > 0) {
  948. if (!pDevice->bBarkerPreambleMd) {
  949. MACvEnableBarkerPreambleMd(pDevice->PortOffset);
  950. pDevice->bBarkerPreambleMd = true;
  951. }
  952. } else {
  953. if (pDevice->bBarkerPreambleMd) {
  954. MACvDisableBarkerPreambleMd(pDevice->PortOffset);
  955. pDevice->bBarkerPreambleMd = false;
  956. }
  957. }
  958. }
  959. /* check if any STA in PS mode, enable DTIM multicast deliver */
  960. if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
  961. if (uSleepySTACnt > 0)
  962. pMgmt->sNodeDBTable[0].bPSEnable = true;
  963. else
  964. pMgmt->sNodeDBTable[0].bPSEnable = false;
  965. }
  966. pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
  967. pCurrSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
  968. if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) ||
  969. (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) {
  970. /* assoc with BSS */
  971. if (pMgmt->sNodeDBTable[0].bActive) {
  972. if (pDevice->bUpdateBBVGA)
  973. s_vCheckPreEDThreshold((void *)pDevice);
  974. if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) &&
  975. (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) {
  976. pDevice->byBBVGANew = pDevice->abyBBVGA[0];
  977. bScheduleCommand((void *)pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
  978. }
  979. if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) {
  980. pMgmt->sNodeDBTable[0].bActive = false;
  981. pMgmt->eCurrMode = WMAC_MODE_STANDBY;
  982. pMgmt->eCurrState = WMAC_STATE_IDLE;
  983. netif_stop_queue(pDevice->dev);
  984. pDevice->bLinkPass = false;
  985. pDevice->bRoaming = true;
  986. pr_info("Lost AP beacon [%d] sec, disconnected !\n",
  987. pMgmt->sNodeDBTable[0].uInActiveCount);
  988. if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
  989. wpahdr = (viawget_wpa_header *)pDevice->skb->data;
  990. wpahdr->type = VIAWGET_DISASSOC_MSG;
  991. wpahdr->resp_ie_len = 0;
  992. wpahdr->req_ie_len = 0;
  993. skb_put(pDevice->skb, sizeof(viawget_wpa_header));
  994. pDevice->skb->dev = pDevice->wpadev;
  995. skb_reset_mac_header(pDevice->skb);
  996. pDevice->skb->pkt_type = PACKET_HOST;
  997. pDevice->skb->protocol = htons(ETH_P_802_2);
  998. memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
  999. netif_rx(pDevice->skb);
  1000. pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
  1001. }
  1002. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  1003. {
  1004. union iwreq_data wrqu;
  1005. memset(&wrqu, 0, sizeof(wrqu));
  1006. wrqu.ap_addr.sa_family = ARPHRD_ETHER;
  1007. PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
  1008. wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
  1009. }
  1010. #endif
  1011. }
  1012. } else if (pItemSSID->len != 0) {
  1013. if (pDevice->uAutoReConnectTime < 10) {
  1014. pDevice->uAutoReConnectTime++;
  1015. #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
  1016. /*
  1017. * network manager support need not do
  1018. * Roaming scan???
  1019. */
  1020. if (pDevice->bWPASuppWextEnabled)
  1021. pDevice->uAutoReConnectTime = 0;
  1022. #endif
  1023. } else {
  1024. /*
  1025. * mike use old encryption status
  1026. * for wpa reauthentication
  1027. */
  1028. if (pDevice->bWPADEVUp)
  1029. pDevice->eEncryptionStatus = pDevice->eOldEncryptionStatus;
  1030. pr_debug("Roaming ...\n");
  1031. BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
  1032. pMgmt->eScanType = WMAC_SCAN_ACTIVE;
  1033. bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
  1034. bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
  1035. pDevice->uAutoReConnectTime = 0;
  1036. }
  1037. }
  1038. }
  1039. if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
  1040. /* if adhoc started which essid is NULL string, rescanning */
  1041. if ((pMgmt->eCurrState == WMAC_STATE_STARTED) && (pCurrSSID->len == 0)) {
  1042. if (pDevice->uAutoReConnectTime < 10) {
  1043. pDevice->uAutoReConnectTime++;
  1044. } else {
  1045. pr_info("Adhoc re-scanning ...\n");
  1046. pMgmt->eScanType = WMAC_SCAN_ACTIVE;
  1047. bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
  1048. bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL);
  1049. pDevice->uAutoReConnectTime = 0;
  1050. }
  1051. }
  1052. if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
  1053. if (pDevice->bUpdateBBVGA)
  1054. s_vCheckPreEDThreshold((void *)pDevice);
  1055. if (pMgmt->sNodeDBTable[0].uInActiveCount >= ADHOC_LOST_BEACON_COUNT) {
  1056. pr_info("Lost other STA beacon [%d] sec, started !\n",
  1057. pMgmt->sNodeDBTable[0].uInActiveCount);
  1058. pMgmt->sNodeDBTable[0].uInActiveCount = 0;
  1059. pMgmt->eCurrState = WMAC_STATE_STARTED;
  1060. netif_stop_queue(pDevice->dev);
  1061. pDevice->bLinkPass = false;
  1062. }
  1063. }
  1064. }
  1065. spin_unlock_irq(&pDevice->lock);
  1066. pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ);
  1067. add_timer(&pMgmt->sTimerSecondCallback);
  1068. }
  1069. /*+
  1070. *
  1071. * Routine Description:
  1072. *
  1073. *
  1074. * Update Tx attemps, Tx failure counter in Node DB
  1075. *
  1076. *
  1077. * Return Value:
  1078. * none.
  1079. *
  1080. -*/
  1081. void
  1082. BSSvUpdateNodeTxCounter(
  1083. void *hDeviceContext,
  1084. unsigned char byTsr0,
  1085. unsigned char byTsr1,
  1086. unsigned char *pbyBuffer,
  1087. unsigned int uFIFOHeaderSize
  1088. )
  1089. {
  1090. struct vnt_private *pDevice = hDeviceContext;
  1091. PSMgmtObject pMgmt = pDevice->pMgmt;
  1092. unsigned int uNodeIndex = 0;
  1093. unsigned char byTxRetry = (byTsr0 & TSR0_NCR);
  1094. PSTxBufHead pTxBufHead;
  1095. PS802_11Header pMACHeader;
  1096. unsigned short wRate;
  1097. unsigned short wFallBackRate = RATE_1M;
  1098. unsigned char byFallBack;
  1099. unsigned int ii;
  1100. pTxBufHead = (PSTxBufHead) pbyBuffer;
  1101. if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_0)
  1102. byFallBack = AUTO_FB_0;
  1103. else if (pTxBufHead->wFIFOCtl & FIFOCTL_AUTO_FB_1)
  1104. byFallBack = AUTO_FB_1;
  1105. else
  1106. byFallBack = AUTO_FB_NONE;
  1107. wRate = pTxBufHead->wReserved;
  1108. /* Only Unicast using support rates */
  1109. if (pTxBufHead->wFIFOCtl & FIFOCTL_NEEDACK) {
  1110. pr_debug("wRate %04X, byTsr0 %02X, byTsr1 %02X\n",
  1111. wRate, byTsr0, byTsr1);
  1112. if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) {
  1113. pMgmt->sNodeDBTable[0].uTxAttempts += 1;
  1114. if ((byTsr1 & TSR1_TERR) == 0) {
  1115. /* transmit success, TxAttempts at least plus one */
  1116. pMgmt->sNodeDBTable[0].uTxOk[MAX_RATE]++;
  1117. if ((byFallBack == AUTO_FB_NONE) ||
  1118. (wRate < RATE_18M)) {
  1119. wFallBackRate = wRate;
  1120. } else if (byFallBack == AUTO_FB_0) {
  1121. if (byTxRetry < 5)
  1122. wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
  1123. else
  1124. wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
  1125. } else if (byFallBack == AUTO_FB_1) {
  1126. if (byTxRetry < 5)
  1127. wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
  1128. else
  1129. wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
  1130. }
  1131. pMgmt->sNodeDBTable[0].uTxOk[wFallBackRate]++;
  1132. } else {
  1133. pMgmt->sNodeDBTable[0].uTxFailures++;
  1134. }
  1135. pMgmt->sNodeDBTable[0].uTxRetry += byTxRetry;
  1136. if (byTxRetry != 0) {
  1137. pMgmt->sNodeDBTable[0].uTxFail[MAX_RATE] += byTxRetry;
  1138. if ((byFallBack == AUTO_FB_NONE) ||
  1139. (wRate < RATE_18M)) {
  1140. pMgmt->sNodeDBTable[0].uTxFail[wRate] += byTxRetry;
  1141. } else if (byFallBack == AUTO_FB_0) {
  1142. for (ii = 0; ii < byTxRetry; ii++) {
  1143. if (ii < 5)
  1144. wFallBackRate = awHWRetry0[wRate-RATE_18M][ii];
  1145. else
  1146. wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
  1147. pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
  1148. }
  1149. } else if (byFallBack == AUTO_FB_1) {
  1150. for (ii = 0; ii < byTxRetry; ii++) {
  1151. if (ii < 5)
  1152. wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
  1153. else
  1154. wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
  1155. pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
  1156. }
  1157. }
  1158. }
  1159. }
  1160. if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
  1161. (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
  1162. pMACHeader = (PS802_11Header)(pbyBuffer + uFIFOHeaderSize);
  1163. if (BSSDBbIsSTAInNodeDB((void *)pMgmt, &(pMACHeader->abyAddr1[0]), &uNodeIndex)) {
  1164. pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1;
  1165. if ((byTsr1 & TSR1_TERR) == 0) {
  1166. /* transmit success, TxAttempts at least plus one */
  1167. pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
  1168. if ((byFallBack == AUTO_FB_NONE) ||
  1169. (wRate < RATE_18M)) {
  1170. wFallBackRate = wRate;
  1171. } else if (byFallBack == AUTO_FB_0) {
  1172. if (byTxRetry < 5)
  1173. wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
  1174. else
  1175. wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
  1176. } else if (byFallBack == AUTO_FB_1) {
  1177. if (byTxRetry < 5)
  1178. wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
  1179. else
  1180. wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
  1181. }
  1182. pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wFallBackRate]++;
  1183. } else {
  1184. pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
  1185. }
  1186. pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += byTxRetry;
  1187. if (byTxRetry != 0) {
  1188. pMgmt->sNodeDBTable[uNodeIndex].uTxFail[MAX_RATE] += byTxRetry;
  1189. if ((byFallBack == AUTO_FB_NONE) ||
  1190. (wRate < RATE_18M)) {
  1191. pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate] += byTxRetry;
  1192. } else if (byFallBack == AUTO_FB_0) {
  1193. for (ii = 0; ii < byTxRetry; ii++) {
  1194. if (ii < 5)
  1195. wFallBackRate = awHWRetry0[wRate - RATE_18M][ii];
  1196. else
  1197. wFallBackRate = awHWRetry0[wRate - RATE_18M][4];
  1198. pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
  1199. }
  1200. } else if (byFallBack == AUTO_FB_1) {
  1201. for (ii = 0; ii < byTxRetry; ii++) {
  1202. if (ii < 5)
  1203. wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
  1204. else
  1205. wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
  1206. pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
  1207. }
  1208. }
  1209. }
  1210. }
  1211. }
  1212. }
  1213. }
  1214. /*+
  1215. *
  1216. * Routine Description:
  1217. * Clear Nodes & skb in DB Table
  1218. *
  1219. *
  1220. * Parameters:
  1221. * In:
  1222. * hDeviceContext - The adapter context.
  1223. * uStartIndex - starting index
  1224. * Out:
  1225. * none
  1226. *
  1227. * Return Value:
  1228. * None.
  1229. *
  1230. -*/
  1231. void
  1232. BSSvClearNodeDBTable(
  1233. void *hDeviceContext,
  1234. unsigned int uStartIndex
  1235. )
  1236. {
  1237. struct vnt_private *pDevice = hDeviceContext;
  1238. PSMgmtObject pMgmt = pDevice->pMgmt;
  1239. struct sk_buff *skb;
  1240. unsigned int ii;
  1241. for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) {
  1242. if (pMgmt->sNodeDBTable[ii].bActive) {
  1243. /* check if sTxPSQueue has been initial */
  1244. if (pMgmt->sNodeDBTable[ii].sTxPSQueue.next != NULL) {
  1245. while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL) {
  1246. pr_debug("PS skb != NULL %d\n", ii);
  1247. dev_kfree_skb(skb);
  1248. }
  1249. }
  1250. memset(&pMgmt->sNodeDBTable[ii], 0, sizeof(KnownNodeDB));
  1251. }
  1252. }
  1253. return;
  1254. };
  1255. void s_vCheckSensitivity(
  1256. void *hDeviceContext
  1257. )
  1258. {
  1259. struct vnt_private *pDevice = hDeviceContext;
  1260. PKnownBSS pBSSList = NULL;
  1261. PSMgmtObject pMgmt = pDevice->pMgmt;
  1262. int ii;
  1263. if ((pDevice->byLocalID <= REV_ID_VT3253_A1) && (pDevice->byRFType == RF_RFMD2959) &&
  1264. (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
  1265. return;
  1266. }
  1267. if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
  1268. ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
  1269. pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
  1270. if (pBSSList != NULL) {
  1271. /* Update BB Reg if RSSI is too strong */
  1272. long LocalldBmAverage = 0;
  1273. long uNumofdBm = 0;
  1274. for (ii = 0; ii < RSSI_STAT_COUNT; ii++) {
  1275. if (pBSSList->ldBmAverage[ii] != 0) {
  1276. uNumofdBm++;
  1277. LocalldBmAverage += pBSSList->ldBmAverage[ii];
  1278. }
  1279. }
  1280. if (uNumofdBm > 0) {
  1281. LocalldBmAverage = LocalldBmAverage/uNumofdBm;
  1282. for (ii = 0; ii < BB_VGA_LEVEL; ii++) {
  1283. pr_debug("LocalldBmAverage:%ld, %ld %02x\n",
  1284. LocalldBmAverage,
  1285. pDevice->ldBmThreshold[ii],
  1286. pDevice->abyBBVGA[ii]);
  1287. if (LocalldBmAverage < pDevice->ldBmThreshold[ii]) {
  1288. pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
  1289. break;
  1290. }
  1291. }
  1292. if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
  1293. pDevice->uBBVGADiffCount++;
  1294. if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD)
  1295. bScheduleCommand((void *)pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
  1296. } else {
  1297. pDevice->uBBVGADiffCount = 0;
  1298. }
  1299. }
  1300. }
  1301. }
  1302. }
  1303. void
  1304. BSSvClearAnyBSSJoinRecord(
  1305. void *hDeviceContext
  1306. )
  1307. {
  1308. struct vnt_private *pDevice = hDeviceContext;
  1309. PSMgmtObject pMgmt = pDevice->pMgmt;
  1310. unsigned int ii;
  1311. for (ii = 0; ii < MAX_BSS_NUM; ii++)
  1312. pMgmt->sBSSList[ii].bSelected = false;
  1313. }
  1314. #ifdef Calcu_LinkQual
  1315. void s_uCalculateLinkQual(
  1316. void *hDeviceContext
  1317. )
  1318. {
  1319. struct vnt_private *pDevice = hDeviceContext;
  1320. unsigned long TxOkRatio, TxCnt;
  1321. unsigned long RxOkRatio, RxCnt;
  1322. unsigned long RssiRatio;
  1323. long ldBm;
  1324. TxCnt = pDevice->scStatistic.TxNoRetryOkCount +
  1325. pDevice->scStatistic.TxRetryOkCount +
  1326. pDevice->scStatistic.TxFailCount;
  1327. RxCnt = pDevice->scStatistic.RxFcsErrCnt +
  1328. pDevice->scStatistic.RxOkCnt;
  1329. TxOkRatio = (TxCnt < 6) ? 4000 : ((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt);
  1330. RxOkRatio = (RxCnt < 6) ? 2000 : ((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt);
  1331. /* decide link quality */
  1332. if (!pDevice->bLinkPass) {
  1333. pDevice->scStatistic.LinkQuality = 0;
  1334. pDevice->scStatistic.SignalStren = 0;
  1335. } else {
  1336. RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm);
  1337. if (-ldBm < 50)
  1338. RssiRatio = 4000;
  1339. else if (-ldBm > 90)
  1340. RssiRatio = 0;
  1341. else
  1342. RssiRatio = (40-(-ldBm-50))*4000/40;
  1343. pDevice->scStatistic.SignalStren = RssiRatio/40;
  1344. pDevice->scStatistic.LinkQuality = (RssiRatio+TxOkRatio+RxOkRatio)/100;
  1345. }
  1346. pDevice->scStatistic.RxFcsErrCnt = 0;
  1347. pDevice->scStatistic.RxOkCnt = 0;
  1348. pDevice->scStatistic.TxFailCount = 0;
  1349. pDevice->scStatistic.TxNoRetryOkCount = 0;
  1350. pDevice->scStatistic.TxRetryOkCount = 0;
  1351. }
  1352. #endif
  1353. void s_vCheckPreEDThreshold(
  1354. void *hDeviceContext
  1355. )
  1356. {
  1357. struct vnt_private *pDevice = hDeviceContext;
  1358. PKnownBSS pBSSList = NULL;
  1359. PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
  1360. if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
  1361. ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
  1362. pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
  1363. if (pBSSList != NULL)
  1364. pDevice->byBBPreEDRSSI = (unsigned char) (~(pBSSList->ldBmAverRange) + 1);
  1365. }
  1366. }