aaa_fsm.c 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/aaa_fsm.c#2
  3. */
  4. /*! \file "aaa_fsm.c"
  5. \brief This file defines the FSM for AAA MODULE.
  6. This file defines the FSM for AAA MODULE.
  7. */
  8. /*
  9. ** Log: aaa_fsm.c
  10. *
  11. * 07 17 2012 yuche.tsai
  12. * NULL
  13. * Compile no error before trial run.
  14. *
  15. * 06 13 2012 yuche.tsai
  16. * NULL
  17. * Update maintrunk driver.
  18. * Add support for driver compose assoc request frame.
  19. *
  20. * 03 02 2012 terry.wu
  21. * NULL
  22. * Sync CFG80211 modification from branch 2,2.
  23. *
  24. * 02 22 2012 yuche.tsai
  25. * NULL
  26. * Solve sigma test 5.1.3 issue, assoc response should have P2P IE.
  27. *
  28. * 12 02 2011 yuche.tsai
  29. * NULL
  30. * Resolve inorder issue under AP mode.
  31. *
  32. * data frame may TX before assoc response frame.
  33. *
  34. * 11 18 2011 yuche.tsai
  35. * NULL
  36. * CONFIG P2P support RSSI query, default turned off.
  37. *
  38. * 06 17 2011 terry.wu
  39. * NULL
  40. * Add BoW 11N support.
  41. *
  42. * 06 02 2011 eddie.chen
  43. * [WCXRP00000759] [MT6620 Wi-Fi][DRV] Update RCPI in AAA
  44. * Update RCPI when receiving Assoc request.
  45. *
  46. * 04 21 2011 terry.wu
  47. * [WCXRP00000674] [MT6620 Wi-Fi][Driver] Refine AAA authSendAuthFrame
  48. * Add network type parameter to authSendAuthFrame.
  49. *
  50. * 04 15 2011 chinghwa.yu
  51. * [WCXRP00000065] Update BoW design and settings
  52. * Add BOW short range mode.
  53. *
  54. * 04 09 2011 chinghwa.yu
  55. * [WCXRP00000065] Update BoW design and settings
  56. * Change Link connection event procedure and change skb length check to 1512 bytes.
  57. *
  58. * 03 09 2011 wh.su
  59. * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
  60. * Skip to call p2pRunEventAAAComplete to avoid indicate STA connect twice.
  61. *
  62. * 03 04 2011 terry.wu
  63. * [WCXRP00000515] [MT6620 Wi-Fi][Driver] Surpress compiler warning which is identified by GNU compiler collection
  64. * Remove unused variable.
  65. *
  66. * 02 16 2011 yuche.tsai
  67. * [WCXRP00000429] [Volunteer Patch][MT6620][Driver] Hot Spot Client Limit Issue
  68. * Add more check after RX assoc frame under Hot-Spot mode.
  69. *
  70. * 02 09 2011 yuche.tsai
  71. * [WCXRP00000429] [Volunteer Patch][MT6620][Driver] Hot Spot Client Limit Issue
  72. * Fix Client Limit Issue.
  73. *
  74. * 01 25 2011 yuche.tsai
  75. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  76. * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
  77. *
  78. * 01 15 2011 puff.wen
  79. * NULL
  80. * [On behalf of Frog] Add CFG_ENABLE_WIFI_DIRECT to p2pRunEventAAAComplete
  81. *
  82. * 01 14 2011 yuche.tsai
  83. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  84. * Modify AAA flow according to CM's comment.
  85. *
  86. * 09 03 2010 kevin.huang
  87. * NULL
  88. * Refine #include sequence and solve recursive/nested #include issue
  89. *
  90. * 08 29 2010 yuche.tsai
  91. * NULL
  92. * Fix Compile warning, type cast from UINT_32 to UINT_16.
  93. *
  94. * 08 26 2010 yuche.tsai
  95. * NULL
  96. * In P2P AT GO test mode under WinXP, we would not indicate connected event to host.
  97. *
  98. * 08 24 2010 cm.chang
  99. * NULL
  100. * Support RLM initail channel of Ad-hoc, P2P and BOW
  101. *
  102. * 08 23 2010 chinghwa.yu
  103. * NULL
  104. * Update for BOW.
  105. *
  106. * 08 20 2010 kevin.huang
  107. * NULL
  108. * Modify AAA Module for changing STA STATE 3 at p2p/bowRunEventAAAComplete()
  109. *
  110. * 08 17 2010 yuche.tsai
  111. * NULL
  112. * Fix bug while enabling P2P GO.
  113. *
  114. * 08 16 2010 kevin.huang
  115. * NULL
  116. * Refine AAA functions
  117. *
  118. * 07 08 2010 cp.wu
  119. *
  120. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  121. *
  122. * 06 21 2010 cp.wu
  123. * [WPD00003833][MT6620 and MT5931] Driver migration
  124. * refine TX-DONE callback.
  125. *
  126. * 06 21 2010 yuche.tsai
  127. * [WPD00003839][MT6620 5931][P2P] Feature migration
  128. * modify due to P2P functino call prototype change.
  129. *
  130. * 06 17 2010 yuche.tsai
  131. * [WPD00003839][MT6620 5931][P2P] Feature migration
  132. * First draft for migration P2P FSM from FW to Driver.
  133. *
  134. * 04 02 2010 kevin.huang
  135. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  136. * Modify CFG flags
  137. *
  138. * 02 26 2010 kevin.huang
  139. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  140. * add support of Driver STA_RECORD_T activation
  141. *
  142. * 02 04 2010 kevin.huang
  143. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  144. * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
  145. */
  146. /*******************************************************************************
  147. * C O M P I L E R F L A G S
  148. ********************************************************************************
  149. */
  150. /*******************************************************************************
  151. * E X T E R N A L R E F E R E N C E S
  152. ********************************************************************************
  153. */
  154. #include "precomp.h"
  155. /*******************************************************************************
  156. * C O N S T A N T S
  157. ********************************************************************************
  158. */
  159. /*******************************************************************************
  160. * D A T A T Y P E S
  161. ********************************************************************************
  162. */
  163. /*******************************************************************************
  164. * P U B L I C D A T A
  165. ********************************************************************************
  166. */
  167. /*******************************************************************************
  168. * P R I V A T E D A T A
  169. ********************************************************************************
  170. */
  171. /*******************************************************************************
  172. * M A C R O S
  173. ********************************************************************************
  174. */
  175. /*******************************************************************************
  176. * F U N C T I O N D E C L A R A T I O N S
  177. ********************************************************************************
  178. */
  179. /*******************************************************************************
  180. * F U N C T I O N S
  181. ********************************************************************************
  182. */
  183. #if 0
  184. /*----------------------------------------------------------------------------*/
  185. /*!
  186. * @brief This function will send Event to AIS/BOW/P2P
  187. *
  188. * @param[in] rJoinStatus To indicate JOIN success or failure.
  189. * @param[in] prStaRec Pointer to the STA_RECORD_T
  190. * @param[in] prSwRfb Pointer to the SW_RFB_T
  191. * @return none
  192. */
  193. /*----------------------------------------------------------------------------*/
  194. WLAN_STATUS aaaFsmSendEventJoinComplete(WLAN_STATUS rJoinStatus, P_STA_RECORD_T prStaRec, P_SW_RFB_T prSwRfb)
  195. {
  196. P_MSG_SAA_JOIN_COMP_T prJoinCompMsg;
  197. ASSERT(prStaRec);
  198. prJoinCompMsg = cnmMemAlloc(RAM_TYPE_TCM, sizeof(MSG_SAA_JOIN_COMP_T));
  199. if (!prJoinCompMsg)
  200. return WLAN_STATUS_RESOURCES;
  201. if (IS_STA_IN_AIS(prStaRec))
  202. prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_AIS_JOIN_COMPLETE;
  203. else if (IS_STA_IN_P2P(prStaRec))
  204. prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_P2P_JOIN_COMPLETE;
  205. else if (IS_STA_IN_BOW(prStaRec))
  206. prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_BOW_JOIN_COMPLETE;
  207. else
  208. ASSERT(0);
  209. prJoinCompMsg->rJoinStatus = rJoinStatus;
  210. prJoinCompMsg->prStaRec = prStaRec;
  211. prJoinCompMsg->prSwRfb = prSwRfb;
  212. mboxSendMsg(MBOX_ID_0, (P_MSG_HDR_T) prJoinCompMsg, MSG_SEND_METHOD_BUF);
  213. return WLAN_STATUS_SUCCESS;
  214. } /* end of saaFsmSendEventJoinComplete() */
  215. /*----------------------------------------------------------------------------*/
  216. /*!
  217. * @brief This function will handle the Start Event to AAA FSM.
  218. *
  219. * @param[in] prMsgHdr Message of Join Request for a particular STA.
  220. *
  221. * @return none
  222. */
  223. /*----------------------------------------------------------------------------*/
  224. VOID aaaFsmRunEventStart(IN P_MSG_HDR_T prMsgHdr)
  225. {
  226. P_MSG_SAA_JOIN_REQ_T prJoinReqMsg;
  227. P_STA_RECORD_T prStaRec;
  228. P_AIS_BSS_INFO_T prAisBssInfo;
  229. ASSERT(prMsgHdr);
  230. prJoinReqMsg = (P_MSG_SAA_JOIN_REQ_T) prMsgHdr;
  231. prStaRec = prJoinReqMsg->prStaRec;
  232. ASSERT(prStaRec);
  233. DBGLOG(SAA, LOUD, "EVENT-START: Trigger SAA FSM\n");
  234. cnmMemFree(prMsgHdr);
  235. /* 4 <1> Validation of SAA Start Event */
  236. if (!IS_AP_STA(prStaRec->eStaType)) {
  237. DBGLOG(SAA, ERROR, "EVENT-START: STA Type - %d was not supported.\n", prStaRec->eStaType);
  238. /* Ignore the return value because don't care the prSwRfb */
  239. saaFsmSendEventJoinComplete(WLAN_STATUS_FAILURE, prStaRec, NULL);
  240. return;
  241. }
  242. /* 4 <2> The previous JOIN process is not completed ? */
  243. if (prStaRec->eAuthAssocState != AA_STATE_IDLE) {
  244. DBGLOG(SAA, ERROR, "EVENT-START: Reentry of SAA Module.\n");
  245. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  246. }
  247. /* 4 <3> Reset Status Code and Time */
  248. /* Update Station Record - Status/Reason Code */
  249. prStaRec->u2StatusCode = STATUS_CODE_SUCCESSFUL;
  250. /* Update the record join time. */
  251. GET_CURRENT_SYSTIME(&prStaRec->rLastJoinTime);
  252. prStaRec->ucTxAuthAssocRetryCount = 0;
  253. if (prStaRec->prChallengeText) {
  254. cnmMemFree(prStaRec->prChallengeText);
  255. prStaRec->prChallengeText = (P_IE_CHALLENGE_TEXT_T) NULL;
  256. }
  257. cnmTimerStopTimer(&prStaRec->rTxReqDoneOrRxRespTimer);
  258. prStaRec->ucStaState = STA_STATE_1;
  259. /* Trigger SAA MODULE */
  260. saaFsmSteps(prStaRec, SAA_STATE_SEND_AUTH1, (P_SW_RFB_T) NULL);
  261. } /* end of saaFsmRunEventStart() */
  262. #endif
  263. #if CFG_SUPPORT_AAA
  264. /*----------------------------------------------------------------------------*/
  265. /*!
  266. * @brief This function will process the Rx Auth Request Frame and then
  267. * trigger AAA FSM.
  268. *
  269. * @param[in] prAdapter Pointer to the Adapter structure.
  270. * @param[in] prSwRfb Pointer to the SW_RFB_T structure.
  271. *
  272. * @return (none)
  273. */
  274. /*----------------------------------------------------------------------------*/
  275. VOID aaaFsmRunEventRxAuth(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  276. {
  277. P_BSS_INFO_T prBssInfo;
  278. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  279. UINT_16 u2StatusCode;
  280. BOOLEAN fgReplyAuth = FALSE;
  281. ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex;
  282. ASSERT(prAdapter);
  283. do {
  284. /* 4 <1> Check P2P network conditions */
  285. #if CFG_ENABLE_WIFI_DIRECT
  286. if (prAdapter->fgIsP2PRegistered) {
  287. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  288. if (prBssInfo->fgIsNetActive) {
  289. /* 4 <1.1> Validate Auth Frame by Auth Algorithm/Transation Seq */
  290. if (WLAN_STATUS_SUCCESS ==
  291. authProcessRxAuth1Frame(prAdapter,
  292. prSwRfb,
  293. prBssInfo->aucBSSID,
  294. AUTH_ALGORITHM_NUM_OPEN_SYSTEM,
  295. AUTH_TRANSACTION_SEQ_1, &u2StatusCode)) {
  296. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  297. /* 4 <1.2> Validate Auth Frame for Network Specific Conditions */
  298. fgReplyAuth = p2pFuncValidateAuth(prAdapter,
  299. prSwRfb, &prStaRec, &u2StatusCode);
  300. } else {
  301. fgReplyAuth = TRUE;
  302. }
  303. eNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
  304. break;
  305. }
  306. }
  307. }
  308. #endif /* CFG_ENABLE_WIFI_DIRECT */
  309. /* 4 <2> Check BOW network conditions */
  310. #if CFG_ENABLE_BT_OVER_WIFI
  311. {
  312. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX]);
  313. if ((prBssInfo->fgIsNetActive) && (OP_MODE_BOW == prBssInfo->eCurrentOPMode)) {
  314. /* 4 <2.1> Validate Auth Frame by Auth Algorithm/Transation Seq */
  315. /* Check if for this BSSID */
  316. if (WLAN_STATUS_SUCCESS ==
  317. authProcessRxAuth1Frame(prAdapter,
  318. prSwRfb,
  319. prBssInfo->aucBSSID,
  320. AUTH_ALGORITHM_NUM_OPEN_SYSTEM,
  321. AUTH_TRANSACTION_SEQ_1, &u2StatusCode)) {
  322. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  323. /* 4 <2.2> Validate Auth Frame for Network Specific Conditions */
  324. fgReplyAuth =
  325. bowValidateAuth(prAdapter, prSwRfb, &prStaRec, &u2StatusCode);
  326. } else {
  327. fgReplyAuth = TRUE;
  328. }
  329. eNetTypeIndex = NETWORK_TYPE_BOW_INDEX;
  330. /* TODO(Kevin): Allocate a STA_RECORD_T for new client */
  331. break;
  332. }
  333. }
  334. }
  335. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  336. return;
  337. } while (FALSE);
  338. if (prStaRec) {
  339. /* update RCPI */
  340. prStaRec->ucRCPI = prSwRfb->prHifRxHdr->ucRcpi;
  341. }
  342. /* 4 <3> Update STA_RECORD_T and reply Auth_2(Response to Auth_1) Frame */
  343. if (fgReplyAuth) {
  344. if (prStaRec) {
  345. if (u2StatusCode == STATUS_CODE_SUCCESSFUL) {
  346. if (prStaRec->eAuthAssocState != AA_STATE_IDLE) {
  347. DBGLOG(AAA, WARN, "Previous AuthAssocState (%d) != IDLE.\n",
  348. prStaRec->eAuthAssocState);
  349. }
  350. prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
  351. } else {
  352. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  353. /* NOTE(Kevin): Change to STATE_1 */
  354. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
  355. }
  356. /* Update the record join time. */
  357. GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
  358. /* Update Station Record - Status/Reason Code */
  359. prStaRec->u2StatusCode = u2StatusCode;
  360. prStaRec->ucAuthAlgNum = AUTH_ALGORITHM_NUM_OPEN_SYSTEM;
  361. } else {
  362. /* NOTE(Kevin): We should have STA_RECORD_T if the status code was successful */
  363. ASSERT(!(u2StatusCode == STATUS_CODE_SUCCESSFUL));
  364. }
  365. /* NOTE: Ignore the return status for AAA */
  366. /* 4 <4> Reply Auth */
  367. authSendAuthFrame(prAdapter, prStaRec, eNetTypeIndex, prSwRfb, AUTH_TRANSACTION_SEQ_2, u2StatusCode);
  368. }
  369. } /* end of aaaFsmRunEventRxAuth() */
  370. /*----------------------------------------------------------------------------*/
  371. /*!
  372. * @brief This function will process the Rx (Re)Association Request Frame and then
  373. * trigger AAA FSM.
  374. *
  375. * @param[in] prAdapter Pointer to the Adapter structure.
  376. * @param[in] prSwRfb Pointer to the SW_RFB_T structure.
  377. *
  378. * @retval WLAN_STATUS_SUCCESS Always return success
  379. */
  380. /*----------------------------------------------------------------------------*/
  381. WLAN_STATUS aaaFsmRunEventRxAssoc(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  382. {
  383. P_BSS_INFO_T prBssInfo;
  384. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  385. UINT_16 u2StatusCode = STATUS_CODE_RESERVED;
  386. BOOLEAN fgReplyAssocResp = FALSE;
  387. ASSERT(prAdapter);
  388. do {
  389. /* 4 <1> Check if we have the STA_RECORD_T for incoming Assoc Req */
  390. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  391. /* We should have the corresponding Sta Record. */
  392. if ((!prStaRec) || (!prStaRec->fgIsInUse)) {
  393. ASSERT(0); /* Only for debug phase */
  394. break;
  395. }
  396. if (!IS_CLIENT_STA(prStaRec))
  397. break;
  398. if (prStaRec->ucStaState == STA_STATE_3) {
  399. /* Do Reassocation */
  400. } else if ((prStaRec->ucStaState == STA_STATE_2) &&
  401. (prStaRec->eAuthAssocState == AAA_STATE_SEND_AUTH2)) {
  402. /* Normal case */
  403. } else {
  404. DBGLOG(AAA, INFO, "Previous AuthAssocState (%d) != SEND_AUTH2, ucStaState:%d.\n",
  405. prStaRec->eAuthAssocState,
  406. prStaRec->ucStaState);
  407. /* TODO: Why assoc req event is faster than tx done of auth */
  408. if (prStaRec->eAuthAssocState != AAA_STATE_SEND_AUTH2)
  409. break;
  410. }
  411. /* update RCPI */
  412. prStaRec->ucRCPI = prSwRfb->prHifRxHdr->ucRcpi;
  413. /* 4 <2> Check P2P network conditions */
  414. #if CFG_ENABLE_WIFI_DIRECT
  415. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
  416. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
  417. if (prBssInfo->fgIsNetActive) {
  418. /* 4 <2.1> Validate Assoc Req Frame and get Status Code */
  419. /* Check if for this BSSID */
  420. if (WLAN_STATUS_SUCCESS ==
  421. assocProcessRxAssocReqFrame(prAdapter, prSwRfb, &u2StatusCode)) {
  422. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  423. /* 4 <2.2> Validate Assoc Req Frame for Network Specific Conditions */
  424. fgReplyAssocResp = p2pFuncValidateAssocReq(prAdapter,
  425. prSwRfb,
  426. (PUINT_16)&u2StatusCode);
  427. } else {
  428. fgReplyAssocResp = TRUE;
  429. }
  430. break;
  431. }
  432. }
  433. }
  434. #endif /* CFG_ENABLE_WIFI_DIRECT */
  435. /* 4 <3> Check BOW network conditions */
  436. #if CFG_ENABLE_BT_OVER_WIFI
  437. if (IS_STA_IN_BOW(prStaRec)) {
  438. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX]);
  439. if ((prBssInfo->fgIsNetActive) && (OP_MODE_BOW == prBssInfo->eCurrentOPMode)) {
  440. /* 4 <3.1> Validate Auth Frame by Auth Algorithm/Transation Seq */
  441. /* Check if for this BSSID */
  442. if (WLAN_STATUS_SUCCESS ==
  443. assocProcessRxAssocReqFrame(prAdapter, prSwRfb, &u2StatusCode)) {
  444. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  445. /* 4 <3.2> Validate Auth Frame for Network Specific Conditions */
  446. fgReplyAssocResp =
  447. bowValidateAssocReq(prAdapter, prSwRfb, &u2StatusCode);
  448. } else {
  449. fgReplyAssocResp = TRUE;
  450. }
  451. /* TODO(Kevin): Allocate a STA_RECORD_T for new client */
  452. break;
  453. }
  454. }
  455. }
  456. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  457. return WLAN_STATUS_SUCCESS; /* To release the SW_RFB_T */
  458. } while (FALSE);
  459. /* 4 <4> Update STA_RECORD_T and reply Assoc Resp Frame */
  460. if (fgReplyAssocResp) {
  461. UINT_16 u2IELength;
  462. PUINT_8 pucIE;
  463. if ((((P_WLAN_ASSOC_REQ_FRAME_T) (prSwRfb->pvHeader))->u2FrameCtrl & MASK_FRAME_TYPE) ==
  464. MAC_FRAME_REASSOC_REQ) {
  465. u2IELength = prSwRfb->u2PacketLen -
  466. (UINT_16) OFFSET_OF(WLAN_REASSOC_REQ_FRAME_T, aucInfoElem[0]);
  467. pucIE = ((P_WLAN_REASSOC_REQ_FRAME_T) (prSwRfb->pvHeader))->aucInfoElem;
  468. } else {
  469. u2IELength = prSwRfb->u2PacketLen - (UINT_16) OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T, aucInfoElem[0]);
  470. pucIE = ((P_WLAN_ASSOC_REQ_FRAME_T) (prSwRfb->pvHeader))->aucInfoElem;
  471. }
  472. rlmProcessAssocReq(prAdapter, prSwRfb, pucIE, u2IELength);
  473. /* 4 <4.1> Assign Association ID */
  474. if (u2StatusCode == STATUS_CODE_SUCCESSFUL) {
  475. #if CFG_ENABLE_WIFI_DIRECT
  476. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
  477. if (p2pRunEventAAAComplete(prAdapter, prStaRec) == WLAN_STATUS_SUCCESS) {
  478. prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
  479. /* prStaRec->eAuthAssocState = AA_STATE_IDLE; */
  480. prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2;/* NOTE(Kevin): for TX done */
  481. /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
  482. /* cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3); */
  483. } else {
  484. /* Client List FULL. */
  485. u2StatusCode = STATUS_CODE_REQ_DECLINED;
  486. prStaRec->u2AssocId = 0; /* Invalid Association ID */
  487. /* If (Re)association fail, the peer can try Association w/o Auth immediately */
  488. prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
  489. /* NOTE(Kevin): Better to change state here, not at TX Done */
  490. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  491. }
  492. }
  493. #endif
  494. #if CFG_ENABLE_BT_OVER_WIFI
  495. if ((IS_STA_IN_BOW(prStaRec))) {
  496. /* if (bowRunEventAAAComplete(prAdapter, prStaRec) == WLAN_STATUS_SUCCESS) { */
  497. prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
  498. prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2; /* NOTE(Kevin): for TX done */
  499. /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
  500. /* cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3); */
  501. }
  502. #if 0
  503. else {
  504. /* Client List FULL. */
  505. u2StatusCode = STATUS_CODE_REQ_DECLINED;
  506. prStaRec->u2AssocId = 0; /* Invalid Association ID */
  507. /* If (Re)association fail, the peer can try Association w/o Auth immediately */
  508. prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
  509. /* NOTE(Kevin): Better to change state here, not at TX Done */
  510. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  511. }
  512. }
  513. #endif
  514. #endif
  515. } else {
  516. prStaRec->u2AssocId = 0; /* Invalid Association ID */
  517. /* If (Re)association fail, the peer can try Association w/o Auth immediately */
  518. prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
  519. /* NOTE(Kevin): Better to change state here, not at TX Done */
  520. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  521. }
  522. /* Update the record join time. */
  523. GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
  524. /* Update Station Record - Status/Reason Code */
  525. prStaRec->u2StatusCode = u2StatusCode;
  526. /* NOTE: Ignore the return status for AAA */
  527. /* 4 <4.2> Reply Assoc Resp */
  528. assocSendReAssocRespFrame(prAdapter, prStaRec);
  529. }
  530. return WLAN_STATUS_SUCCESS;
  531. } /* end of aaaFsmRunEventRxAssoc() */
  532. /*----------------------------------------------------------------------------*/
  533. /*!
  534. * @brief This function will handle TxDone(Auth2/AssocReq) Event of AAA FSM.
  535. *
  536. * @param[in] prAdapter Pointer to the Adapter structure.
  537. * @param[in] prMsduInfo Pointer to the MSDU_INFO_T.
  538. * @param[in] rTxDoneStatus Return TX status of the Auth1/Auth3/AssocReq frame.
  539. *
  540. * @retval WLAN_STATUS_SUCCESS
  541. */
  542. /*----------------------------------------------------------------------------*/
  543. WLAN_STATUS
  544. aaaFsmRunEventTxDone(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  545. {
  546. P_STA_RECORD_T prStaRec;
  547. P_BSS_INFO_T prBssInfo;
  548. ASSERT(prAdapter);
  549. ASSERT(prMsduInfo);
  550. DBGLOG(AAA, LOUD, "EVENT-TX DONE: Current Time = %lu\n", (unsigned long)kalGetTimeTick());
  551. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  552. if ((!prStaRec) || (!prStaRec->fgIsInUse)) {
  553. DBGLOG(AAA, INFO, "EVENT-TX DONE: Invalid StaRec");
  554. return WLAN_STATUS_SUCCESS; /* For the case of replying ERROR STATUS CODE */
  555. }
  556. ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  557. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
  558. DBGLOG(AAA, INFO, "TX DONE status: %d, AuthAssocState: %d, SeqNo: %d\n",
  559. rTxDoneStatus, prStaRec->eAuthAssocState,
  560. prMsduInfo->ucTxSeqNum);
  561. switch (prStaRec->eAuthAssocState) {
  562. case AAA_STATE_SEND_AUTH2:
  563. {
  564. /* Strictly check the outgoing frame is matched with current AA STATE */
  565. if (authCheckTxAuthFrame(prAdapter, prMsduInfo, AUTH_TRANSACTION_SEQ_2) != WLAN_STATUS_SUCCESS)
  566. break;
  567. if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
  568. if (TX_RESULT_SUCCESS == rTxDoneStatus) {
  569. /* NOTE(Kevin): Change to STATE_2 at TX Done */
  570. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  571. } else {
  572. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  573. /* NOTE(Kevin): Change to STATE_1 */
  574. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
  575. #if CFG_ENABLE_WIFI_DIRECT
  576. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec)))
  577. p2pRunEventAAATxFail(prAdapter, prStaRec);
  578. #endif /* CFG_ENABLE_WIFI_DIRECT */
  579. #if CFG_ENABLE_BT_OVER_WIFI
  580. if (IS_STA_IN_BOW(prStaRec))
  581. bowRunEventAAATxFail(prAdapter, prStaRec);
  582. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  583. }
  584. }
  585. /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
  586. }
  587. break;
  588. case AAA_STATE_SEND_ASSOC2:
  589. {
  590. /* Strictly check the outgoing frame is matched with current SAA STATE */
  591. if (assocCheckTxReAssocRespFrame(prAdapter, prMsduInfo) != WLAN_STATUS_SUCCESS)
  592. break;
  593. if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
  594. if (TX_RESULT_SUCCESS == rTxDoneStatus) {
  595. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  596. /* NOTE(Kevin): Change to STATE_3 at TX Done */
  597. #if CFG_ENABLE_WIFI_DIRECT
  598. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec)))
  599. p2pRunEventAAASuccess(prAdapter, prStaRec);
  600. #endif /* CFG_ENABLE_WIFI_DIRECT */
  601. #if CFG_ENABLE_BT_OVER_WIFI
  602. if (IS_STA_IN_BOW(prStaRec))
  603. bowRunEventAAAComplete(prAdapter, prStaRec);
  604. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  605. } else {
  606. prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
  607. /* NOTE(Kevin): Change to STATE_2 */
  608. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  609. #if CFG_ENABLE_WIFI_DIRECT
  610. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec)))
  611. p2pRunEventAAATxFail(prAdapter, prStaRec);
  612. #endif /* CFG_ENABLE_WIFI_DIRECT */
  613. #if CFG_ENABLE_BT_OVER_WIFI
  614. if (IS_STA_IN_BOW(prStaRec))
  615. bowRunEventAAATxFail(prAdapter, prStaRec);
  616. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  617. }
  618. }
  619. /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
  620. }
  621. break;
  622. default:
  623. break; /* Ignore other cases */
  624. }
  625. return WLAN_STATUS_SUCCESS;
  626. } /* end of aaaFsmRunEventTxDone() */
  627. #endif /* CFG_SUPPORT_AAA */
  628. #if 0 /* TODO(Kevin): for abort event, just reset the STA_RECORD_T. */
  629. /*----------------------------------------------------------------------------*/
  630. /*!
  631. * \brief This function will send ABORT Event to JOIN FSM.
  632. *
  633. * \param[in] prAdapter Pointer to the Adapter structure.
  634. *
  635. * \return none
  636. */
  637. /*----------------------------------------------------------------------------*/
  638. VOID saaFsmRunEventAbort(IN P_MSG_HDR_T prMsgHdr)
  639. {
  640. P_JOIN_INFO_T prJoinInfo;
  641. P_STA_RECORD_T prStaRec;
  642. DEBUGFUNC("joinFsmRunEventAbort");
  643. ASSERT(prAdapter);
  644. prJoinInfo = &prAdapter->rJoinInfo;
  645. DBGLOG(JOIN, EVENT, "JOIN EVENT: ABORT\n");
  646. /* NOTE(Kevin): when reach here, the ARB_STATE should be in ARB_STATE_JOIN. */
  647. ASSERT(prJoinInfo->prBssDesc);
  648. /* 4 <1> Update Flags and Elements of JOIN Module. */
  649. /* Reset Send Auth/(Re)Assoc Frame Count */
  650. prJoinInfo->ucTxAuthAssocRetryCount = 0;
  651. /* Cancel all JOIN relative Timer */
  652. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rTxRequestTimer);
  653. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rRxResponseTimer);
  654. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rJoinTimer);
  655. /* 4 <2> Update the associated STA_RECORD_T during JOIN. */
  656. /* Get a Station Record if possible, TA == BSSID for AP */
  657. prStaRec = staRecGetStaRecordByAddr(prAdapter, prJoinInfo->prBssDesc->aucBSSID);
  658. if (prStaRec)
  659. prStaRec->ucStaState = STA_STATE_1; /* Update Station Record - Class 1 Flag */
  660. #if DBG
  661. else
  662. ASSERT(0); /* Shouldn't happened, because we already add this STA_RECORD_T at JOIN_STATE_INIT */
  663. #endif /* DBG */
  664. /* 4 <3> Pull back to IDLE. */
  665. joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
  666. /* 4 <4> If we are in Roaming, recover the settings of previous BSS. */
  667. /* NOTE: JOIN FAIL -
  668. * Restore original setting from current BSS_INFO_T.
  669. */
  670. if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED)
  671. joinAdoptParametersFromCurrentBss(prAdapter);
  672. } /* end of joinFsmRunEventAbort() */
  673. #endif
  674. /* TODO(Kevin): following code will be modified and move to AIS FSM */
  675. #if 0
  676. /*----------------------------------------------------------------------------*/
  677. /*!
  678. * \brief This function will send Join Timeout Event to JOIN FSM.
  679. *
  680. * \param[in] prAdapter Pointer to the Adapter structure.
  681. *
  682. * \retval WLAN_STATUS_FAILURE Fail because of Join Timeout
  683. */
  684. /*----------------------------------------------------------------------------*/
  685. WLAN_STATUS joinFsmRunEventJoinTimeOut(IN P_ADAPTER_T prAdapter)
  686. {
  687. P_JOIN_INFO_T prJoinInfo;
  688. P_STA_RECORD_T prStaRec;
  689. DEBUGFUNC("joinFsmRunEventJoinTimeOut");
  690. ASSERT(prAdapter);
  691. prJoinInfo = &prAdapter->rJoinInfo;
  692. DBGLOG(JOIN, EVENT, "JOIN EVENT: JOIN TIMEOUT\n");
  693. /* Get a Station Record if possible, TA == BSSID for AP */
  694. prStaRec = staRecGetStaRecordByAddr(prAdapter, prJoinInfo->prBssDesc->aucBSSID);
  695. /* We have renew this Sta Record when in JOIN_STATE_INIT */
  696. ASSERT(prStaRec);
  697. /* Record the Status Code of Authentication Request */
  698. prStaRec->u2StatusCode = STATUS_CODE_JOIN_TIMEOUT;
  699. /* Increase Failure Count */
  700. prStaRec->ucJoinFailureCount++;
  701. /* Reset Send Auth/(Re)Assoc Frame Count */
  702. prJoinInfo->ucTxAuthAssocRetryCount = 0;
  703. /* Cancel other JOIN relative Timer */
  704. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rTxRequestTimer);
  705. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rRxResponseTimer);
  706. /* Restore original setting from current BSS_INFO_T */
  707. if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED)
  708. joinAdoptParametersFromCurrentBss(prAdapter);
  709. /* Pull back to IDLE */
  710. joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
  711. return WLAN_STATUS_FAILURE;
  712. } /* end of joinFsmRunEventJoinTimeOut() */
  713. /*----------------------------------------------------------------------------*/
  714. /*!
  715. * \brief This function will adopt the parameters from Peer BSS.
  716. *
  717. * \param[in] prAdapter Pointer to the Adapter structure.
  718. *
  719. * \return (none)
  720. */
  721. /*----------------------------------------------------------------------------*/
  722. VOID joinAdoptParametersFromPeerBss(IN P_ADAPTER_T prAdapter)
  723. {
  724. P_JOIN_INFO_T prJoinInfo;
  725. P_BSS_DESC_T prBssDesc;
  726. DEBUGFUNC("joinAdoptParametersFromPeerBss");
  727. ASSERT(prAdapter);
  728. prJoinInfo = &prAdapter->rJoinInfo;
  729. prBssDesc = prJoinInfo->prBssDesc;
  730. /* 4 <1> Adopt Peer BSS' PHY TYPE */
  731. prAdapter->eCurrentPhyType = prBssDesc->ePhyType;
  732. DBGLOG(JOIN, INFO, "Target BSS[%s]'s PhyType = %s\n",
  733. prBssDesc->aucSSID, (prBssDesc->ePhyType == PHY_TYPE_ERP_INDEX) ? "ERP" : "HR_DSSS");
  734. /* 4 <2> Adopt Peer BSS' Frequency(Band/Channel) */
  735. DBGLOG(JOIN, INFO, "Target BSS's Channel = %d, Band = %d\n", prBssDesc->ucChannelNum, prBssDesc->eBand);
  736. nicSwitchChannel(prAdapter, prBssDesc->eBand, prBssDesc->ucChannelNum, 10);
  737. prJoinInfo->fgIsParameterAdopted = TRUE;
  738. } /* end of joinAdoptParametersFromPeerBss() */
  739. /*----------------------------------------------------------------------------*/
  740. /*!
  741. * \brief This function will adopt the parameters from current associated BSS.
  742. *
  743. * \param[in] prAdapter Pointer to the Adapter structure.
  744. *
  745. * \return (none)
  746. */
  747. /*----------------------------------------------------------------------------*/
  748. VOID joinAdoptParametersFromCurrentBss(IN P_ADAPTER_T prAdapter)
  749. {
  750. /* P_JOIN_INFO_T prJoinInfo = &prAdapter->rJoinInfo; */
  751. P_BSS_INFO_T prBssInfo;
  752. ASSERT(prAdapter);
  753. prBssInfo = &prAdapter->rBssInfo;
  754. /* 4 <1> Adopt current BSS' PHY TYPE */
  755. prAdapter->eCurrentPhyType = prBssInfo->ePhyType;
  756. /* 4 <2> Adopt current BSS' Frequency(Band/Channel) */
  757. DBGLOG(JOIN, INFO, "Current BSS's Channel = %d, Band = %d\n", prBssInfo->ucChnl, prBssInfo->eBand);
  758. nicSwitchChannel(prAdapter, prBssInfo->eBand, prBssInfo->ucChnl, 10);
  759. } /* end of joinAdoptParametersFromCurrentBss() */
  760. /*----------------------------------------------------------------------------*/
  761. /*!
  762. * \brief This function will update all the SW variables and HW MCR registers after
  763. * the association with target BSS.
  764. *
  765. * \param[in] prAdapter Pointer to the Adapter structure.
  766. *
  767. * \return (none)
  768. */
  769. /*----------------------------------------------------------------------------*/
  770. VOID joinComplete(IN P_ADAPTER_T prAdapter)
  771. {
  772. P_JOIN_INFO_T prJoinInfo;
  773. P_BSS_DESC_T prBssDesc;
  774. P_PEER_BSS_INFO_T prPeerBssInfo;
  775. P_BSS_INFO_T prBssInfo;
  776. P_CONNECTION_SETTINGS_T prConnSettings;
  777. P_STA_RECORD_T prStaRec;
  778. P_TX_CTRL_T prTxCtrl;
  779. #if CFG_SUPPORT_802_11D
  780. P_IE_COUNTRY_T prIECountry;
  781. #endif
  782. DEBUGFUNC("joinComplete");
  783. ASSERT(prAdapter);
  784. prJoinInfo = &prAdapter->rJoinInfo;
  785. prBssDesc = prJoinInfo->prBssDesc;
  786. prPeerBssInfo = &prAdapter->rPeerBssInfo;
  787. prBssInfo = &prAdapter->rBssInfo;
  788. prConnSettings = &prAdapter->rConnSettings;
  789. prTxCtrl = &prAdapter->rTxCtrl;
  790. /* 4 <1> Update Connecting & Connected Flag of BSS_DESC_T. */
  791. /* Remove previous AP's Connection Flags if have */
  792. scanRemoveConnectionFlagOfBssDescByBssid(prAdapter, prBssInfo->aucBSSID);
  793. prBssDesc->fgIsConnected = TRUE; /* Mask as Connected */
  794. if (prBssDesc->fgIsHiddenSSID) {
  795. /* NOTE(Kevin): This is for the case of Passive Scan and the target BSS didn't
  796. * broadcast SSID on its Beacon Frame.
  797. */
  798. COPY_SSID(prBssDesc->aucSSID,
  799. prBssDesc->ucSSIDLen, prAdapter->rConnSettings.aucSSID, prAdapter->rConnSettings.ucSSIDLen);
  800. if (prBssDesc->ucSSIDLen)
  801. prBssDesc->fgIsHiddenSSID = FALSE;
  802. #if DBG
  803. else
  804. ASSERT(0);
  805. #endif /* DBG */
  806. DBGLOG(JOIN, INFO, "Hidden SSID! - Update SSID : %s\n", prBssDesc->aucSSID);
  807. }
  808. /* 4 <2> Update BSS_INFO_T from BSS_DESC_T */
  809. /* 4 <2.A> PHY Type */
  810. prBssInfo->ePhyType = prBssDesc->ePhyType;
  811. /* 4 <2.B> BSS Type */
  812. prBssInfo->eBSSType = BSS_TYPE_INFRASTRUCTURE;
  813. /* 4 <2.C> BSSID */
  814. COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID);
  815. DBGLOG(JOIN, INFO, "JOIN to BSSID: [%pM]\n", prBssDesc->aucBSSID);
  816. /* 4 <2.D> SSID */
  817. COPY_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen, prBssDesc->aucSSID, prBssDesc->ucSSIDLen);
  818. /* 4 <2.E> Channel / Band information. */
  819. prBssInfo->eBand = prBssDesc->eBand;
  820. prBssInfo->ucChnl = prBssDesc->ucChannelNum;
  821. /* 4 <2.F> RSN/WPA information. */
  822. secFsmRunEventStart(prAdapter);
  823. prBssInfo->u4RsnSelectedPairwiseCipher = prBssDesc->u4RsnSelectedPairwiseCipher;
  824. prBssInfo->u4RsnSelectedGroupCipher = prBssDesc->u4RsnSelectedGroupCipher;
  825. prBssInfo->u4RsnSelectedAKMSuite = prBssDesc->u4RsnSelectedAKMSuite;
  826. if (secRsnKeyHandshakeEnabled())
  827. prBssInfo->fgIsWPAorWPA2Enabled = TRUE;
  828. else
  829. prBssInfo->fgIsWPAorWPA2Enabled = FALSE;
  830. /* 4 <2.G> Beacon interval. */
  831. prBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
  832. /* 4 <2.H> DTIM period. */
  833. prBssInfo->ucDtimPeriod = prBssDesc->ucDTIMPeriod;
  834. /* 4 <2.I> ERP Information */
  835. if ((prBssInfo->ePhyType == PHY_TYPE_ERP_INDEX) && /* Our BSS's PHY_TYPE is ERP now. */
  836. (prBssDesc->fgIsERPPresent)) {
  837. prBssInfo->fgIsERPPresent = TRUE;
  838. prBssInfo->ucERP = prBssDesc->ucERP; /* Save the ERP for later check */
  839. } else { /* Some AP, may send ProbeResp without ERP IE. Thus prBssDesc->fgIsERPPresent is FALSE. */
  840. prBssInfo->fgIsERPPresent = FALSE;
  841. prBssInfo->ucERP = 0;
  842. }
  843. #if CFG_SUPPORT_802_11D
  844. /* 4 <2.J> Country inforamtion of the associated AP */
  845. if (prConnSettings->fgMultiDomainCapabilityEnabled) {
  846. DOMAIN_INFO_ENTRY rDomainInfo;
  847. if (domainGetDomainInfoByScanResult(prAdapter, &rDomainInfo)) {
  848. if (prBssDesc->prIECountry) {
  849. prIECountry = prBssDesc->prIECountry;
  850. domainParseCountryInfoElem(prIECountry, &prBssInfo->rDomainInfo);
  851. /* use the domain get from the BSS info */
  852. prBssInfo->fgIsCountryInfoPresent = TRUE;
  853. nicSetupOpChnlList(prAdapter, prBssInfo->rDomainInfo.u2CountryCode, FALSE);
  854. } else {
  855. /* use the domain get from the scan result */
  856. prBssInfo->fgIsCountryInfoPresent = TRUE;
  857. nicSetupOpChnlList(prAdapter, rDomainInfo.u2CountryCode, FALSE);
  858. }
  859. }
  860. }
  861. #endif
  862. /* 4 <2.K> Signal Power of the associated AP */
  863. prBssInfo->rRcpi = prBssDesc->rRcpi;
  864. prBssInfo->rRssi = RCPI_TO_dBm(prBssInfo->rRcpi);
  865. GET_CURRENT_SYSTIME(&prBssInfo->rRssiLastUpdateTime);
  866. /* 4 <2.L> Capability Field of the associated AP */
  867. prBssInfo->u2CapInfo = prBssDesc->u2CapInfo;
  868. DBGLOG(JOIN, INFO, "prBssInfo-> fgIsERPPresent = %d, ucERP = %02x, rRcpi = %d, rRssi = %ld\n",
  869. prBssInfo->fgIsERPPresent, prBssInfo->ucERP, prBssInfo->rRcpi, prBssInfo->rRssi);
  870. /* 4 <3> Update BSS_INFO_T from PEER_BSS_INFO_T & NIC RATE FUNC */
  871. /* 4 <3.A> Association ID */
  872. prBssInfo->u2AssocId = prPeerBssInfo->u2AssocId;
  873. /* 4 <3.B> WMM Information */
  874. if (prAdapter->fgIsEnableWMM && (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_SUPPORT_WMM)) {
  875. prBssInfo->fgIsWmmAssoc = TRUE;
  876. prTxCtrl->rTxQForVoipAccess = TXQ_AC3;
  877. qosWmmInfoInit(&prBssInfo->rWmmInfo, (prBssInfo->ePhyType == PHY_TYPE_HR_DSSS_INDEX) ? TRUE : FALSE);
  878. if (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_AC_PARAM_PRESENT) {
  879. kalMemCopy(&prBssInfo->rWmmInfo, &prPeerBssInfo->rWmmInfo, sizeof(WMM_INFO_T));
  880. } else {
  881. kalMemCopy(&prBssInfo->rWmmInfo,
  882. &prPeerBssInfo->rWmmInfo,
  883. sizeof(WMM_INFO_T) - sizeof(prPeerBssInfo->rWmmInfo.arWmmAcParams));
  884. }
  885. } else {
  886. prBssInfo->fgIsWmmAssoc = FALSE;
  887. prTxCtrl->rTxQForVoipAccess = TXQ_AC1;
  888. kalMemZero(&prBssInfo->rWmmInfo, sizeof(WMM_INFO_T));
  889. }
  890. /* 4 <3.C> Operational Rate Set & BSS Basic Rate Set */
  891. prBssInfo->u2OperationalRateSet = prPeerBssInfo->u2OperationalRateSet;
  892. prBssInfo->u2BSSBasicRateSet = prPeerBssInfo->u2BSSBasicRateSet;
  893. /* 4 <3.D> Short Preamble */
  894. if (prBssInfo->fgIsERPPresent) {
  895. /* NOTE(Kevin 2007/12/24): Truth Table.
  896. * Short Preamble Bit in
  897. * <AssocReq> <AssocResp w/i ERP> <BARKER(Long)> Final Driver Setting(Short)
  898. * TRUE FALSE FALSE FALSE(shouldn't have such case,
  899. * use the AssocResp)
  900. * TRUE FALSE TRUE FALSE
  901. * FALSE FALSE FALSE FALSE(shouldn't have such case,
  902. * use the AssocResp)
  903. * FALSE FALSE TRUE FALSE
  904. * TRUE TRUE FALSE TRUE(follow ERP)
  905. * TRUE TRUE TRUE FALSE(follow ERP)
  906. * FALSE TRUE FALSE FALSE(shouldn't have such case,
  907. * and we should set to FALSE)
  908. * FALSE TRUE TRUE FALSE(we should set to FALSE)
  909. */
  910. if ((prPeerBssInfo->fgIsShortPreambleAllowed) &&
  911. ((prConnSettings->ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
  912. ((prConnSettings->ePreambleType == PREAMBLE_TYPE_AUTO) &&
  913. (prBssDesc->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)))) {
  914. prBssInfo->fgIsShortPreambleAllowed = TRUE;
  915. if (prBssInfo->ucERP & ERP_INFO_BARKER_PREAMBLE_MODE)
  916. prBssInfo->fgUseShortPreamble = FALSE;
  917. else
  918. prBssInfo->fgUseShortPreamble = TRUE;
  919. } else {
  920. prBssInfo->fgIsShortPreambleAllowed = FALSE;
  921. prBssInfo->fgUseShortPreamble = FALSE;
  922. }
  923. } else {
  924. /* NOTE(Kevin 2007/12/24): Truth Table.
  925. * Short Preamble Bit in
  926. * <AssocReq> <AssocResp w/o ERP> Final Driver Setting(Short)
  927. * TRUE FALSE FALSE
  928. * FALSE FALSE FALSE
  929. * TRUE TRUE TRUE
  930. * FALSE TRUE(status success) TRUE
  931. * --> Honor the result of prPeerBssInfo.
  932. */
  933. prBssInfo->fgIsShortPreambleAllowed = prBssInfo->fgUseShortPreamble =
  934. prPeerBssInfo->fgIsShortPreambleAllowed;
  935. }
  936. DBGLOG(JOIN, INFO, "prBssInfo->fgIsShortPreambleAllowed = %d, prBssInfo->fgUseShortPreamble = %d\n",
  937. prBssInfo->fgIsShortPreambleAllowed, prBssInfo->fgUseShortPreamble);
  938. /* 4 <3.E> Short Slot Time */
  939. prBssInfo->fgUseShortSlotTime = prPeerBssInfo->fgUseShortSlotTime; /* AP support Short Slot Time */
  940. DBGLOG(JOIN, INFO, "prBssInfo->fgUseShortSlotTime = %d\n", prBssInfo->fgUseShortSlotTime);
  941. nicSetSlotTime(prAdapter,
  942. prBssInfo->ePhyType,
  943. ((prConnSettings->fgIsShortSlotTimeOptionEnable &&
  944. prBssInfo->fgUseShortSlotTime) ? TRUE : FALSE));
  945. /* 4 <3.F> Update Tx Rate for Control Frame */
  946. bssUpdateTxRateForControlFrame(prAdapter);
  947. /* 4 <3.G> Save the available Auth Types during Roaming (Design for Fast BSS Transition). */
  948. /* if (prAdapter->fgIsEnableRoaming) */ /* NOTE(Kevin): Always prepare info for roaming */
  949. {
  950. if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_OPEN_SYSTEM)
  951. prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_OPEN_SYSTEM;
  952. else if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_SHARED_KEY)
  953. prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_SHARED_KEY;
  954. prBssInfo->ucRoamingAuthTypes = prJoinInfo->ucRoamingAuthTypes;
  955. /* Set the stable time of the associated BSS. We won't do roaming decision
  956. * during the stable time.
  957. */
  958. SET_EXPIRATION_TIME(prBssInfo->rRoamingStableExpirationTime,
  959. SEC_TO_SYSTIME(ROAMING_STABLE_TIMEOUT_SEC));
  960. }
  961. /* 4 <3.H> Update Parameter for TX Fragmentation Threshold */
  962. #if CFG_TX_FRAGMENT
  963. txFragInfoUpdate(prAdapter);
  964. #endif /* CFG_TX_FRAGMENT */
  965. /* 4 <4> Update STA_RECORD_T */
  966. /* Get a Station Record if possible */
  967. prStaRec = staRecGetStaRecordByAddr(prAdapter, prBssDesc->aucBSSID);
  968. if (prStaRec) {
  969. UINT_16 u2OperationalRateSet, u2DesiredRateSet;
  970. /* 4 <4.A> Desired Rate Set */
  971. u2OperationalRateSet = (rPhyAttributes[prBssInfo->ePhyType].u2SupportedRateSet &
  972. prBssInfo->u2OperationalRateSet);
  973. u2DesiredRateSet = (u2OperationalRateSet & prConnSettings->u2DesiredRateSet);
  974. if (u2DesiredRateSet) {
  975. prStaRec->u2DesiredRateSet = u2DesiredRateSet;
  976. } else {
  977. /* For Error Handling - The Desired Rate Set is not covered in Operational Rate Set. */
  978. prStaRec->u2DesiredRateSet = u2OperationalRateSet;
  979. }
  980. /* Try to set the best initial rate for this entry */
  981. if (!rateGetBestInitialRateIndex(prStaRec->u2DesiredRateSet,
  982. prStaRec->rRcpi, &prStaRec->ucCurrRate1Index)) {
  983. if (!rateGetLowestRateIndexFromRateSet(prStaRec->u2DesiredRateSet, &prStaRec->ucCurrRate1Index))
  984. ASSERT(0);
  985. }
  986. DBGLOG(JOIN, INFO, "prStaRec->ucCurrRate1Index = %d\n", prStaRec->ucCurrRate1Index);
  987. /* 4 <4.B> Preamble Mode */
  988. prStaRec->fgIsShortPreambleOptionEnable = prBssInfo->fgUseShortPreamble;
  989. /* 4 <4.C> QoS Flag */
  990. prStaRec->fgIsQoS = prBssInfo->fgIsWmmAssoc;
  991. }
  992. #if DBG
  993. else
  994. ASSERT(0);
  995. #endif /* DBG */
  996. /* 4 <5> Update NIC */
  997. /* 4 <5.A> Update BSSID & Operation Mode */
  998. nicSetupBSS(prAdapter, prBssInfo);
  999. /* 4 <5.B> Update WLAN Table. */
  1000. if (nicSetHwBySta(prAdapter, prStaRec) == FALSE)
  1001. ASSERT(FALSE);
  1002. /* 4 <5.C> Update Desired Rate Set for BT. */
  1003. #if CFG_TX_FRAGMENT
  1004. if (prConnSettings->fgIsEnableTxAutoFragmentForBT)
  1005. txRateSetInitForBT(prAdapter, prStaRec);
  1006. #endif /* CFG_TX_FRAGMENT */
  1007. /* 4 <5.D> TX AC Parameter and TX/RX Queue Control */
  1008. if (prBssInfo->fgIsWmmAssoc) {
  1009. #if CFG_TX_AGGREGATE_HW_FIFO
  1010. nicTxAggregateTXQ(prAdapter, FALSE);
  1011. #endif /* CFG_TX_AGGREGATE_HW_FIFO */
  1012. qosUpdateWMMParametersAndAssignAllowedACI(prAdapter, &prBssInfo->rWmmInfo);
  1013. } else {
  1014. #if CFG_TX_AGGREGATE_HW_FIFO
  1015. nicTxAggregateTXQ(prAdapter, TRUE);
  1016. #endif /* CFG_TX_AGGREGATE_HW_FIFO */
  1017. nicTxNonQoSAssignDefaultAdmittedTXQ(prAdapter);
  1018. nicTxNonQoSUpdateTXQParameters(prAdapter, prBssInfo->ePhyType);
  1019. }
  1020. #if CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN
  1021. {
  1022. prTxCtrl->fgBlockTxDuringJoin = FALSE;
  1023. #if !CFG_TX_AGGREGATE_HW_FIFO /* TX FIFO AGGREGATE already do flush once */
  1024. nicTxFlushStopQueues(prAdapter, (UINT_8) TXQ_DATA_MASK, (UINT_8) NULL);
  1025. #endif /* CFG_TX_AGGREGATE_HW_FIFO */
  1026. nicTxRetransmitOfSendWaitQue(prAdapter);
  1027. if (prTxCtrl->fgIsPacketInOsSendQueue)
  1028. nicTxRetransmitOfOsSendQue(prAdapter);
  1029. #if CFG_SDIO_TX_ENHANCE
  1030. halTxLeftClusteredMpdu(prAdapter);
  1031. #endif /* CFG_SDIO_TX_ENHANCE */
  1032. }
  1033. #endif /* CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN */
  1034. /* 4 <6> Setup CONNECTION flag. */
  1035. prAdapter->eConnectionState = MEDIA_STATE_CONNECTED;
  1036. prAdapter->eConnectionStateIndicated = MEDIA_STATE_CONNECTED;
  1037. if (prJoinInfo->fgIsReAssoc)
  1038. prAdapter->fgBypassPortCtrlForRoaming = TRUE;
  1039. else
  1040. prAdapter->fgBypassPortCtrlForRoaming = FALSE;
  1041. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_CONNECT, (PVOID) NULL, 0);
  1042. } /* end of joinComplete() */
  1043. #endif