vntwifi.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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. *
  20. * File: vntwifi.c
  21. *
  22. * Purpose: export functions for vntwifi lib
  23. *
  24. * Functions:
  25. *
  26. * Revision History:
  27. *
  28. * Author: Yiching Chen
  29. *
  30. * Date: feb. 2, 2005
  31. *
  32. */
  33. #include "vntwifi.h"
  34. #include "IEEE11h.h"
  35. #include "country.h"
  36. #include "device.h"
  37. #include "wmgr.h"
  38. #include "datarate.h"
  39. //#define PLICE_DEBUG
  40. /*--------------------- Static Definitions -------------------------*/
  41. //static int msglevel =MSG_LEVEL_DEBUG;
  42. //static int msglevel =MSG_LEVEL_INFO;
  43. /*--------------------- Static Classes ----------------------------*/
  44. /*--------------------- Static Variables --------------------------*/
  45. /*--------------------- Static Functions --------------------------*/
  46. /*--------------------- Export Variables --------------------------*/
  47. /*--------------------- Export Functions --------------------------*/
  48. /*+
  49. *
  50. * Description:
  51. * Set Operation Mode
  52. *
  53. * Parameters:
  54. * In:
  55. * pMgmtHandle - pointer to management object
  56. * eOPMode - Opreation Mode
  57. * Out:
  58. * none
  59. *
  60. * Return Value: none
  61. *
  62. -*/
  63. void
  64. VNTWIFIvSetOPMode (
  65. void *pMgmtHandle,
  66. WMAC_CONFIG_MODE eOPMode
  67. )
  68. {
  69. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  70. pMgmt->eConfigMode = eOPMode;
  71. }
  72. /*+
  73. *
  74. * Description:
  75. * Set Operation Mode
  76. *
  77. * Parameters:
  78. * In:
  79. * pMgmtHandle - pointer to management object
  80. * wBeaconPeriod - Beacon Period
  81. * wATIMWindow - ATIM window
  82. * uChannel - channel number
  83. * Out:
  84. * none
  85. *
  86. * Return Value: none
  87. *
  88. -*/
  89. void
  90. VNTWIFIvSetIBSSParameter (
  91. void *pMgmtHandle,
  92. unsigned short wBeaconPeriod,
  93. unsigned short wATIMWindow,
  94. unsigned int uChannel
  95. )
  96. {
  97. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  98. pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
  99. pMgmt->wIBSSATIMWindow = wATIMWindow;
  100. pMgmt->uIBSSChannel = uChannel;
  101. }
  102. /*+
  103. *
  104. * Description:
  105. * Get current SSID
  106. *
  107. * Parameters:
  108. * In:
  109. * pMgmtHandle - pointer to management object
  110. * Out:
  111. * none
  112. *
  113. * Return Value: current SSID pointer.
  114. *
  115. -*/
  116. PWLAN_IE_SSID
  117. VNTWIFIpGetCurrentSSID (
  118. void *pMgmtHandle
  119. )
  120. {
  121. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  122. return((PWLAN_IE_SSID) pMgmt->abyCurrSSID);
  123. }
  124. /*+
  125. *
  126. * Description:
  127. * Get current link channel
  128. *
  129. * Parameters:
  130. * In:
  131. * pMgmtHandle - pointer to management object
  132. * Out:
  133. * none
  134. *
  135. * Return Value: current Channel.
  136. *
  137. -*/
  138. unsigned int
  139. VNTWIFIpGetCurrentChannel (
  140. void *pMgmtHandle
  141. )
  142. {
  143. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  144. if (pMgmtHandle != NULL) {
  145. return (pMgmt->uCurrChannel);
  146. }
  147. return 0;
  148. }
  149. /*+
  150. *
  151. * Description:
  152. * Get current Assoc ID
  153. *
  154. * Parameters:
  155. * In:
  156. * pMgmtHandle - pointer to management object
  157. * Out:
  158. * none
  159. *
  160. * Return Value: current Assoc ID
  161. *
  162. -*/
  163. unsigned short
  164. VNTWIFIwGetAssocID (
  165. void *pMgmtHandle
  166. )
  167. {
  168. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  169. return(pMgmt->wCurrAID);
  170. }
  171. /*+
  172. *
  173. * Description:
  174. * This routine return max support rate of IES
  175. *
  176. * Parameters:
  177. * In:
  178. * pSupportRateIEs
  179. * pExtSupportRateIEs
  180. *
  181. * Out:
  182. *
  183. * Return Value: max support rate
  184. *
  185. -*/
  186. unsigned char
  187. VNTWIFIbyGetMaxSupportRate (
  188. PWLAN_IE_SUPP_RATES pSupportRateIEs,
  189. PWLAN_IE_SUPP_RATES pExtSupportRateIEs
  190. )
  191. {
  192. unsigned char byMaxSupportRate = RATE_1M;
  193. unsigned char bySupportRate = RATE_1M;
  194. unsigned int ii = 0;
  195. if (pSupportRateIEs) {
  196. for (ii = 0; ii < pSupportRateIEs->len; ii++) {
  197. bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
  198. if (bySupportRate > byMaxSupportRate) {
  199. byMaxSupportRate = bySupportRate;
  200. }
  201. }
  202. }
  203. if (pExtSupportRateIEs) {
  204. for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
  205. bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
  206. if (bySupportRate > byMaxSupportRate) {
  207. byMaxSupportRate = bySupportRate;
  208. }
  209. }
  210. }
  211. return byMaxSupportRate;
  212. }
  213. /*+
  214. *
  215. * Description:
  216. * This routine return data rate of ACK packtet
  217. *
  218. * Parameters:
  219. * In:
  220. * byRxDataRate
  221. * pSupportRateIEs
  222. * pExtSupportRateIEs
  223. *
  224. * Out:
  225. *
  226. * Return Value: max support rate
  227. *
  228. -*/
  229. unsigned char
  230. VNTWIFIbyGetACKTxRate (
  231. unsigned char byRxDataRate,
  232. PWLAN_IE_SUPP_RATES pSupportRateIEs,
  233. PWLAN_IE_SUPP_RATES pExtSupportRateIEs
  234. )
  235. {
  236. unsigned char byMaxAckRate;
  237. unsigned char byBasicRate;
  238. unsigned int ii;
  239. if (byRxDataRate <= RATE_11M) {
  240. byMaxAckRate = RATE_1M;
  241. } else {
  242. // 24M is mandatory for 802.11a and 802.11g
  243. byMaxAckRate = RATE_24M;
  244. }
  245. if (pSupportRateIEs) {
  246. for (ii = 0; ii < pSupportRateIEs->len; ii++) {
  247. if (pSupportRateIEs->abyRates[ii] & 0x80) {
  248. byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
  249. if ((byBasicRate <= byRxDataRate) &&
  250. (byBasicRate > byMaxAckRate)) {
  251. byMaxAckRate = byBasicRate;
  252. }
  253. }
  254. }
  255. }
  256. if (pExtSupportRateIEs) {
  257. for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
  258. if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
  259. byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
  260. if ((byBasicRate <= byRxDataRate) &&
  261. (byBasicRate > byMaxAckRate)) {
  262. byMaxAckRate = byBasicRate;
  263. }
  264. }
  265. }
  266. }
  267. return byMaxAckRate;
  268. }
  269. /*+
  270. *
  271. * Description:
  272. * Set Authentication Mode
  273. *
  274. * Parameters:
  275. * In:
  276. * pMgmtHandle - pointer to management object
  277. * eAuthMode - Authentication mode
  278. * Out:
  279. * none
  280. *
  281. * Return Value: none
  282. *
  283. -*/
  284. void
  285. VNTWIFIvSetAuthenticationMode (
  286. void *pMgmtHandle,
  287. WMAC_AUTHENTICATION_MODE eAuthMode
  288. )
  289. {
  290. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  291. pMgmt->eAuthenMode = eAuthMode;
  292. if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
  293. (eAuthMode == WMAC_AUTH_AUTO)) {
  294. pMgmt->bShareKeyAlgorithm = true;
  295. } else {
  296. pMgmt->bShareKeyAlgorithm = false;
  297. }
  298. }
  299. /*+
  300. *
  301. * Description:
  302. * Set Encryption Mode
  303. *
  304. * Parameters:
  305. * In:
  306. * pMgmtHandle - pointer to management object
  307. * eAuthMode - Authentication mode
  308. * Out:
  309. * none
  310. *
  311. * Return Value: none
  312. *
  313. -*/
  314. void
  315. VNTWIFIvSetEncryptionMode (
  316. void *pMgmtHandle,
  317. WMAC_ENCRYPTION_MODE eEncryptionMode
  318. )
  319. {
  320. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  321. pMgmt->eEncryptionMode = eEncryptionMode;
  322. if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
  323. (eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
  324. (eEncryptionMode == WMAC_ENCRYPTION_AESEnabled) ) {
  325. pMgmt->bPrivacyInvoked = true;
  326. } else {
  327. pMgmt->bPrivacyInvoked = false;
  328. }
  329. }
  330. bool
  331. VNTWIFIbConfigPhyMode (
  332. void *pMgmtHandle,
  333. CARD_PHY_TYPE ePhyType
  334. )
  335. {
  336. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  337. if ((ePhyType != PHY_TYPE_AUTO) &&
  338. (ePhyType != pMgmt->eCurrentPHYMode)) {
  339. if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL)==true) {
  340. pMgmt->eCurrentPHYMode = ePhyType;
  341. } else {
  342. return(false);
  343. }
  344. }
  345. pMgmt->eConfigPHYMode = ePhyType;
  346. return(true);
  347. }
  348. void
  349. VNTWIFIbGetConfigPhyMode (
  350. void *pMgmtHandle,
  351. void *pePhyType
  352. )
  353. {
  354. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  355. if ((pMgmt != NULL) && (pePhyType != NULL)) {
  356. *(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
  357. }
  358. }
  359. /*+
  360. *
  361. * Description:
  362. * Clear BSS List Database except current assoc BSS
  363. *
  364. * Parameters:
  365. * In:
  366. * pMgmtHandle - Management Object structure
  367. * bLinkPass - Current Link status
  368. * Out:
  369. *
  370. * Return Value: None.
  371. *
  372. -*/
  373. /*+
  374. *
  375. * Description:
  376. * Query BSS List in management database
  377. *
  378. * Parameters:
  379. * In:
  380. * pMgmtHandle - Management Object structure
  381. * Out:
  382. * puBSSCount - BSS count
  383. * pvFirstBSS - pointer to first BSS
  384. *
  385. * Return Value: None.
  386. *
  387. -*/
  388. void
  389. VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, void **pvFirstBSS)
  390. {
  391. unsigned int ii = 0;
  392. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  393. PKnownBSS pBSS = NULL;
  394. unsigned int uCount = 0;
  395. *pvFirstBSS = NULL;
  396. for (ii = 0; ii < MAX_BSS_NUM; ii++) {
  397. pBSS = &(pMgmt->sBSSList[ii]);
  398. if (!pBSS->bActive) {
  399. continue;
  400. }
  401. if (*pvFirstBSS == NULL) {
  402. *pvFirstBSS = &(pMgmt->sBSSList[ii]);
  403. }
  404. uCount++;
  405. }
  406. *puBSSCount = uCount;
  407. }
  408. void
  409. VNTWIFIvGetNextBSS (
  410. void *pMgmtHandle,
  411. void *pvCurrentBSS,
  412. void **pvNextBSS
  413. )
  414. {
  415. PKnownBSS pBSS = (PKnownBSS) pvCurrentBSS;
  416. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  417. *pvNextBSS = NULL;
  418. while (*pvNextBSS == NULL) {
  419. pBSS++;
  420. if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM])) {
  421. return;
  422. }
  423. if (pBSS->bActive == true) {
  424. *pvNextBSS = pBSS;
  425. return;
  426. }
  427. }
  428. }
  429. /*+
  430. *
  431. * Description:
  432. * Update Tx attemps, Tx failure counter in Node DB
  433. *
  434. * In:
  435. * Out:
  436. * none
  437. *
  438. * Return Value: none
  439. *
  440. -*/
  441. void
  442. VNTWIFIvUpdateNodeTxCounter(
  443. void *pMgmtHandle,
  444. unsigned char *pbyDestAddress,
  445. bool bTxOk,
  446. unsigned short wRate,
  447. unsigned char *pbyTxFailCount
  448. )
  449. {
  450. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  451. unsigned int uNodeIndex = 0;
  452. unsigned int ii;
  453. if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
  454. (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
  455. if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false) {
  456. return;
  457. }
  458. }
  459. pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++;
  460. if (bTxOk == true) {
  461. // transmit success, TxAttempts at least plus one
  462. pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
  463. pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++;
  464. } else {
  465. pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
  466. }
  467. pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE];
  468. for(ii=0;ii<MAX_RATE;ii++) {
  469. pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii];
  470. }
  471. return;
  472. }
  473. void
  474. VNTWIFIvGetTxRate(
  475. void *pMgmtHandle,
  476. unsigned char *pbyDestAddress,
  477. unsigned short *pwTxDataRate,
  478. unsigned char *pbyACKRate,
  479. unsigned char *pbyCCKBasicRate,
  480. unsigned char *pbyOFDMBasicRate
  481. )
  482. {
  483. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  484. unsigned int uNodeIndex = 0;
  485. unsigned short wTxDataRate = RATE_1M;
  486. unsigned char byACKRate = RATE_1M;
  487. unsigned char byCCKBasicRate = RATE_1M;
  488. unsigned char byOFDMBasicRate = RATE_24M;
  489. PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL;
  490. PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL;
  491. if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
  492. (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
  493. // Adhoc Tx rate decided from node DB
  494. if(BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) {
  495. wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
  496. pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates);
  497. pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates);
  498. } else {
  499. if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) {
  500. wTxDataRate = RATE_2M;
  501. } else {
  502. wTxDataRate = RATE_24M;
  503. }
  504. pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
  505. pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
  506. }
  507. } else { // Infrastructure: rate decided from AP Node, index = 0
  508. wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate);
  509. #ifdef PLICE_DEBUG
  510. printk(KERN_DEBUG "GetTxRate:AP MAC is %pM,TxRate is %d\n",
  511. pMgmt->sNodeDBTable[0].abyMACAddr, wTxDataRate);
  512. #endif
  513. pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
  514. pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
  515. }
  516. byACKRate = VNTWIFIbyGetACKTxRate( (unsigned char) wTxDataRate,
  517. pSupportRateIEs,
  518. pExtSupportRateIEs
  519. );
  520. if (byACKRate > (unsigned char) wTxDataRate) {
  521. byACKRate = (unsigned char) wTxDataRate;
  522. }
  523. byCCKBasicRate = VNTWIFIbyGetACKTxRate( RATE_11M,
  524. pSupportRateIEs,
  525. pExtSupportRateIEs
  526. );
  527. byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M,
  528. pSupportRateIEs,
  529. pExtSupportRateIEs
  530. );
  531. *pwTxDataRate = wTxDataRate;
  532. *pbyACKRate = byACKRate;
  533. *pbyCCKBasicRate = byCCKBasicRate;
  534. *pbyOFDMBasicRate = byOFDMBasicRate;
  535. return;
  536. }
  537. unsigned char
  538. VNTWIFIbyGetKeyCypher(
  539. void *pMgmtHandle,
  540. bool bGroupKey
  541. )
  542. {
  543. PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
  544. if (bGroupKey == true) {
  545. return (pMgmt->byCSSGK);
  546. } else {
  547. return (pMgmt->byCSSPK);
  548. }
  549. }
  550. /*
  551. bool
  552. VNTWIFIbInit(
  553. void *pAdapterHandler,
  554. void **pMgmtHandler
  555. )
  556. {
  557. PSMgmtObject pMgmt = NULL;
  558. unsigned int ii;
  559. pMgmt = (PSMgmtObject)kmalloc(sizeof(SMgmtObject), (int)GFP_ATOMIC);
  560. if (pMgmt == NULL) {
  561. *pMgmtHandler = NULL;
  562. return false;
  563. }
  564. memset(pMgmt, 0, sizeof(SMgmtObject));
  565. pMgmt->pAdapter = (void *) pAdapterHandler;
  566. // should initial MAC address abyMACAddr
  567. for(ii=0;ii<WLAN_BSSID_LEN;ii++) {
  568. pMgmt->abyDesireBSSID[ii] = 0xFF;
  569. }
  570. pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0];
  571. pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0];
  572. pMgmt->byCSSPK = KEY_CTL_NONE;
  573. pMgmt->byCSSGK = KEY_CTL_NONE;
  574. pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI;
  575. pMgmt->cbFreeCmdQueue = CMD_Q_SIZE;
  576. pMgmt->uCmdDequeueIdx = 0;
  577. pMgmt->uCmdEnqueueIdx = 0;
  578. pMgmt->eCommandState = WLAN_CMD_STATE_IDLE;
  579. pMgmt->bCmdStop = false;
  580. pMgmt->bCmdRunning = false;
  581. *pMgmtHandler = pMgmt;
  582. return true;
  583. }
  584. */
  585. bool
  586. VNTWIFIbSetPMKIDCache (
  587. void *pMgmtObject,
  588. unsigned long ulCount,
  589. void *pPMKIDInfo
  590. )
  591. {
  592. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
  593. if (ulCount > MAX_PMKID_CACHE) {
  594. return (false);
  595. }
  596. pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount;
  597. memcpy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo)));
  598. return (true);
  599. }
  600. unsigned short
  601. VNTWIFIwGetMaxSupportRate(
  602. void *pMgmtObject
  603. )
  604. {
  605. unsigned short wRate = RATE_54M;
  606. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
  607. for(wRate = RATE_54M; wRate > RATE_1M; wRate--) {
  608. if (pMgmt->sNodeDBTable[0].wSuppRate & (1<<wRate)) {
  609. return (wRate);
  610. }
  611. }
  612. if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A) {
  613. return (RATE_6M);
  614. } else {
  615. return (RATE_1M);
  616. }
  617. }
  618. void
  619. VNTWIFIvSet11h (
  620. void *pMgmtObject,
  621. bool b11hEnable
  622. )
  623. {
  624. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
  625. pMgmt->b11hEnable = b11hEnable;
  626. }
  627. bool
  628. VNTWIFIbMeasureReport(
  629. void *pMgmtObject,
  630. bool bEndOfReport,
  631. void *pvMeasureEID,
  632. unsigned char byReportMode,
  633. unsigned char byBasicMap,
  634. unsigned char byCCAFraction,
  635. unsigned char *pbyRPIs
  636. )
  637. {
  638. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
  639. unsigned char *pbyCurrentEID = (unsigned char *) (pMgmt->pCurrMeasureEIDRep);
  640. //spin_lock_irq(&pDevice->lock);
  641. if ((pvMeasureEID != NULL) &&
  642. (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3))
  643. ) {
  644. pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP;
  645. pMgmt->pCurrMeasureEIDRep->len = 3;
  646. pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byToken;
  647. pMgmt->pCurrMeasureEIDRep->byMode = byReportMode;
  648. pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType;
  649. switch (pMgmt->pCurrMeasureEIDRep->byType) {
  650. case MEASURE_TYPE_BASIC :
  651. pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC);
  652. memcpy( &(pMgmt->pCurrMeasureEIDRep->sRep.sBasic),
  653. &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
  654. sizeof(MEASEURE_REQ));
  655. pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap;
  656. break;
  657. case MEASURE_TYPE_CCA :
  658. pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA);
  659. memcpy( &(pMgmt->pCurrMeasureEIDRep->sRep.sCCA),
  660. &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
  661. sizeof(MEASEURE_REQ));
  662. pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction;
  663. break;
  664. case MEASURE_TYPE_RPI :
  665. pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI);
  666. memcpy( &(pMgmt->pCurrMeasureEIDRep->sRep.sRPI),
  667. &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
  668. sizeof(MEASEURE_REQ));
  669. memcpy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8);
  670. break;
  671. default :
  672. break;
  673. }
  674. pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len);
  675. pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len);
  676. pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID;
  677. }
  678. if (bEndOfReport == true) {
  679. IEEE11hbMSRRepTx(pMgmt);
  680. }
  681. //spin_unlock_irq(&pDevice->lock);
  682. return (true);
  683. }
  684. bool
  685. VNTWIFIbChannelSwitch(
  686. void *pMgmtObject,
  687. unsigned char byNewChannel
  688. )
  689. {
  690. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
  691. //spin_lock_irq(&pDevice->lock);
  692. pMgmt->uCurrChannel = byNewChannel;
  693. pMgmt->bSwitchChannel = false;
  694. //spin_unlock_irq(&pDevice->lock);
  695. return true;
  696. }
  697. /*
  698. bool
  699. VNTWIFIbRadarPresent(
  700. void *pMgmtObject,
  701. unsigned char byChannel
  702. )
  703. {
  704. PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject;
  705. if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
  706. (byChannel == (unsigned char) pMgmt->uCurrChannel) &&
  707. (pMgmt->bSwitchChannel != true) &&
  708. (pMgmt->b11hEnable == true)) {
  709. if (!compare_ether_addr(pMgmt->abyIBSSDFSOwner, CARDpGetCurrentAddress(pMgmt->pAdapter))) {
  710. pMgmt->byNewChannel = CARDbyAutoChannelSelect(pMgmt->pAdapter,(unsigned char) pMgmt->uCurrChannel);
  711. pMgmt->bSwitchChannel = true;
  712. }
  713. BEACONbSendBeacon(pMgmt);
  714. CARDbChannelSwitch(pMgmt->pAdapter, 0, pMgmt->byNewChannel, 10);
  715. }
  716. return true;
  717. }
  718. */