2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/aaa_fsm.c#2 $
6 \brief This file defines the FSM for AAA MODULE.
8 This file defines the FSM for AAA MODULE.
16 * 07 17 2012 yuche.tsai
18 * Compile no error before trial run.
20 * 06 13 2012 yuche.tsai
22 * Update maintrunk driver.
23 * Add support for driver compose assoc request frame.
27 * Sync CFG80211 modification from branch 2,2.
29 * 02 22 2012 yuche.tsai
31 * Solve sigma test 5.1.3 issue, assoc response should have P2P IE.
33 * 12 02 2011 yuche.tsai
35 * Resolve inorder issue under AP mode.
37 * data frame may TX before assoc response frame.
39 * 11 18 2011 yuche.tsai
41 * CONFIG P2P support RSSI query, default turned off.
45 * Add BoW 11N support.
47 * 06 02 2011 eddie.chen
48 * [WCXRP00000759] [MT6620 Wi-Fi][DRV] Update RCPI in AAA
49 * Update RCPI when receiving Assoc request.
52 * [WCXRP00000674] [MT6620 Wi-Fi][Driver] Refine AAA authSendAuthFrame
53 * Add network type parameter to authSendAuthFrame.
55 * 04 15 2011 chinghwa.yu
56 * [WCXRP00000065] Update BoW design and settings
57 * Add BOW short range mode.
59 * 04 09 2011 chinghwa.yu
60 * [WCXRP00000065] Update BoW design and settings
61 * Change Link connection event procedure and change skb length check to 1512 bytes.
64 * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
65 * Skip to call p2pRunEventAAAComplete to avoid indicate STA connect twice.
68 * [WCXRP00000515] [MT6620 Wi-Fi][Driver] Surpress compiler warning which is identified by GNU compiler collection
69 * Remove unused variable.
71 * 02 16 2011 yuche.tsai
72 * [WCXRP00000429] [Volunteer Patch][MT6620][Driver] Hot Spot Client Limit Issue
73 * Add more check after RX assoc frame under Hot-Spot mode.
75 * 02 09 2011 yuche.tsai
76 * [WCXRP00000429] [Volunteer Patch][MT6620][Driver] Hot Spot Client Limit Issue
77 * Fix Client Limit Issue.
79 * 01 25 2011 yuche.tsai
80 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
81 * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
85 * [On behalf of Frog] Add CFG_ENABLE_WIFI_DIRECT to p2pRunEventAAAComplete
87 * 01 14 2011 yuche.tsai
88 * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
89 * Modify AAA flow according to CM's comment.
91 * 09 03 2010 kevin.huang
93 * Refine #include sequence and solve recursive/nested #include issue
95 * 08 29 2010 yuche.tsai
97 * Fix Compile warning, type cast from UINT_32 to UINT_16.
99 * 08 26 2010 yuche.tsai
101 * In P2P AT GO test mode under WinXP, we would not indicate connected event to host.
103 * 08 24 2010 cm.chang
105 * Support RLM initail channel of Ad-hoc, P2P and BOW
107 * 08 23 2010 chinghwa.yu
111 * 08 20 2010 kevin.huang
113 * Modify AAA Module for changing STA STATE 3 at p2p/bowRunEventAAAComplete()
115 * 08 17 2010 yuche.tsai
117 * Fix bug while enabling P2P GO.
119 * 08 16 2010 kevin.huang
121 * Refine AAA functions
125 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
128 * [WPD00003833][MT6620 and MT5931] Driver migration
129 * refine TX-DONE callback.
131 * 06 21 2010 yuche.tsai
132 * [WPD00003839][MT6620 5931][P2P] Feature migration
133 * modify due to P2P functino call prototype change.
135 * 06 17 2010 yuche.tsai
136 * [WPD00003839][MT6620 5931][P2P] Feature migration
137 * First draft for migration P2P FSM from FW to Driver.
139 * 04 02 2010 kevin.huang
140 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
143 * 02 26 2010 kevin.huang
144 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
145 * add support of Driver STA_RECORD_T activation
147 * 02 04 2010 kevin.huang
148 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
149 * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
152 /*******************************************************************************
153 * C O M P I L E R F L A G S
154 ********************************************************************************
157 /*******************************************************************************
158 * E X T E R N A L R E F E R E N C E S
159 ********************************************************************************
163 /*******************************************************************************
165 ********************************************************************************
168 /*******************************************************************************
170 ********************************************************************************
173 /*******************************************************************************
174 * P U B L I C D A T A
175 ********************************************************************************
178 /*******************************************************************************
179 * P R I V A T E D A T A
180 ********************************************************************************
183 /*******************************************************************************
185 ********************************************************************************
188 /*******************************************************************************
189 * F U N C T I O N D E C L A R A T I O N S
190 ********************************************************************************
193 /*******************************************************************************
195 ********************************************************************************
198 /*----------------------------------------------------------------------------*/
200 * @brief This function will send Event to AIS/BOW/P2P
202 * @param[in] rJoinStatus To indicate JOIN success or failure.
203 * @param[in] prStaRec Pointer to the STA_RECORD_T
204 * @param[in] prSwRfb Pointer to the SW_RFB_T
208 /*----------------------------------------------------------------------------*/
210 aaaFsmSendEventJoinComplete (
211 WLAN_STATUS rJoinStatus,
212 P_STA_RECORD_T prStaRec,
216 P_MSG_SAA_JOIN_COMP_T prJoinCompMsg;
221 prJoinCompMsg = cnmMemAlloc(RAM_TYPE_TCM, sizeof(MSG_SAA_JOIN_COMP_T));
222 if (!prJoinCompMsg) {
223 return WLAN_STATUS_RESOURCES;
226 if (IS_STA_IN_AIS(prStaRec)) {
227 prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_AIS_JOIN_COMPLETE;
229 else if (IS_STA_IN_P2P(prStaRec)) {
230 prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_P2P_JOIN_COMPLETE;
232 else if (IS_STA_IN_BOW(prStaRec)) {
233 prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_BOW_JOIN_COMPLETE;
239 prJoinCompMsg->rJoinStatus = rJoinStatus;
240 prJoinCompMsg->prStaRec = prStaRec;
241 prJoinCompMsg->prSwRfb = prSwRfb;
243 mboxSendMsg(MBOX_ID_0,
244 (P_MSG_HDR_T)prJoinCompMsg,
245 MSG_SEND_METHOD_BUF);
247 return WLAN_STATUS_SUCCESS;
249 } /* end of saaFsmSendEventJoinComplete() */
251 /*----------------------------------------------------------------------------*/
253 * @brief This function will handle the Start Event to AAA FSM.
255 * @param[in] prMsgHdr Message of Join Request for a particular STA.
259 /*----------------------------------------------------------------------------*/
261 aaaFsmRunEventStart (
262 IN P_MSG_HDR_T prMsgHdr
265 P_MSG_SAA_JOIN_REQ_T prJoinReqMsg;
266 P_STA_RECORD_T prStaRec;
267 P_AIS_BSS_INFO_T prAisBssInfo;
272 prJoinReqMsg = (P_MSG_SAA_JOIN_REQ_T)prMsgHdr;
273 prStaRec = prJoinReqMsg->prStaRec;
277 DBGLOG(SAA, LOUD, ("EVENT-START: Trigger SAA FSM\n"));
279 cnmMemFree(prMsgHdr);
281 //4 <1> Validation of SAA Start Event
282 if (!IS_AP_STA(prStaRec->eStaType)) {
284 DBGLOG(SAA, ERROR, ("EVENT-START: STA Type - %d was not supported.\n", prStaRec->eStaType));
286 /* Ignore the return value because don't care the prSwRfb */
287 saaFsmSendEventJoinComplete(WLAN_STATUS_FAILURE, prStaRec, NULL);
292 //4 <2> The previous JOIN process is not completed ?
293 if (prStaRec->eAuthAssocState != AA_STATE_IDLE) {
294 DBGLOG(SAA, ERROR, ("EVENT-START: Reentry of SAA Module.\n"));
295 prStaRec->eAuthAssocState = AA_STATE_IDLE;
298 //4 <3> Reset Status Code and Time
299 /* Update Station Record - Status/Reason Code */
300 prStaRec->u2StatusCode = STATUS_CODE_SUCCESSFUL;
302 /* Update the record join time. */
303 GET_CURRENT_SYSTIME(&prStaRec->rLastJoinTime);
305 prStaRec->ucTxAuthAssocRetryCount = 0;
307 if (prStaRec->prChallengeText) {
308 cnmMemFree(prStaRec->prChallengeText);
309 prStaRec->prChallengeText = (P_IE_CHALLENGE_TEXT_T)NULL;
312 cnmTimerStopTimer(&prStaRec->rTxReqDoneOrRxRespTimer);
314 prStaRec->ucStaState = STA_STATE_1;
316 /* Trigger SAA MODULE */
317 saaFsmSteps(prStaRec, SAA_STATE_SEND_AUTH1, (P_SW_RFB_T)NULL);
320 } /* end of saaFsmRunEventStart() */
325 /*----------------------------------------------------------------------------*/
327 * @brief This function will process the Rx Auth Request Frame and then
330 * @param[in] prAdapter Pointer to the Adapter structure.
331 * @param[in] prSwRfb Pointer to the SW_RFB_T structure.
335 /*----------------------------------------------------------------------------*/
337 aaaFsmRunEventRxAuth (
338 IN P_ADAPTER_T prAdapter,
339 IN P_SW_RFB_T prSwRfb
342 P_BSS_INFO_T prBssInfo;
343 P_STA_RECORD_T prStaRec = (P_STA_RECORD_T)NULL;
344 UINT_16 u2StatusCode;
345 BOOLEAN fgReplyAuth = FALSE;
346 ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex;
354 //4 <1> Check P2P network conditions
355 #if CFG_ENABLE_WIFI_DIRECT
356 if(prAdapter->fgIsP2PRegistered){
357 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
359 if (prBssInfo->fgIsNetActive) {
361 //4 <1.1> Validate Auth Frame by Auth Algorithm/Transation Seq
362 if (WLAN_STATUS_SUCCESS ==
363 authProcessRxAuth1Frame(prAdapter,
366 AUTH_ALGORITHM_NUM_OPEN_SYSTEM,
367 AUTH_TRANSACTION_SEQ_1,
370 if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
371 //4 <1.2> Validate Auth Frame for Network Specific Conditions
372 fgReplyAuth = p2pFuncValidateAuth(
381 eNetTypeIndex = NETWORK_TYPE_P2P_INDEX;
386 #endif /* CFG_ENABLE_WIFI_DIRECT */
388 //4 <2> Check BOW network conditions
389 #if CFG_ENABLE_BT_OVER_WIFI
391 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX]);
393 if ((prBssInfo->fgIsNetActive) &&
394 (OP_MODE_BOW == prBssInfo->eCurrentOPMode)) {
396 //4 <2.1> Validate Auth Frame by Auth Algorithm/Transation Seq
397 /* Check if for this BSSID */
398 if (WLAN_STATUS_SUCCESS ==
399 authProcessRxAuth1Frame(prAdapter,
402 AUTH_ALGORITHM_NUM_OPEN_SYSTEM,
403 AUTH_TRANSACTION_SEQ_1,
406 if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
408 //4 <2.2> Validate Auth Frame for Network Specific Conditions
409 fgReplyAuth = bowValidateAuth(prAdapter, prSwRfb, &prStaRec, &u2StatusCode);
416 eNetTypeIndex = NETWORK_TYPE_BOW_INDEX;
417 /* TODO(Kevin): Allocate a STA_RECORD_T for new client */
422 #endif /* CFG_ENABLE_BT_OVER_WIFI */
429 prStaRec->ucRCPI = prSwRfb->prHifRxHdr->ucRcpi;
432 //4 <3> Update STA_RECORD_T and reply Auth_2(Response to Auth_1) Frame
437 if (u2StatusCode == STATUS_CODE_SUCCESSFUL) {
438 if (prStaRec->eAuthAssocState != AA_STATE_IDLE) {
439 DBGLOG(AAA, WARN, ("Previous AuthAssocState (%d) != IDLE.\n",
440 prStaRec->eAuthAssocState));
443 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
446 prStaRec->eAuthAssocState = AA_STATE_IDLE;
448 /* NOTE(Kevin): Change to STATE_1 */
449 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
452 /* Update the record join time. */
453 GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
455 /* Update Station Record - Status/Reason Code */
456 prStaRec->u2StatusCode = u2StatusCode;
458 prStaRec->ucAuthAlgNum = AUTH_ALGORITHM_NUM_OPEN_SYSTEM;
461 /* NOTE(Kevin): We should have STA_RECORD_T if the status code was successful */
462 ASSERT(!(u2StatusCode == STATUS_CODE_SUCCESSFUL));
465 /* NOTE: Ignore the return status for AAA */
467 authSendAuthFrame(prAdapter,
471 AUTH_TRANSACTION_SEQ_2,
477 } /* end of aaaFsmRunEventRxAuth() */
480 /*----------------------------------------------------------------------------*/
482 * @brief This function will process the Rx (Re)Association Request Frame and then
485 * @param[in] prAdapter Pointer to the Adapter structure.
486 * @param[in] prSwRfb Pointer to the SW_RFB_T structure.
488 * @retval WLAN_STATUS_SUCCESS Always return success
490 /*----------------------------------------------------------------------------*/
492 aaaFsmRunEventRxAssoc (
493 IN P_ADAPTER_T prAdapter,
494 IN P_SW_RFB_T prSwRfb
497 P_BSS_INFO_T prBssInfo;
498 P_STA_RECORD_T prStaRec = (P_STA_RECORD_T)NULL;
499 UINT_16 u2StatusCode = STATUS_CODE_RESERVED;
500 BOOLEAN fgReplyAssocResp = FALSE;
507 //4 <1> Check if we have the STA_RECORD_T for incoming Assoc Req
508 prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
510 /* We should have the corresponding Sta Record. */
511 if ((!prStaRec) || (!prStaRec->fgIsInUse)) {
512 ASSERT(0); // Only for debug phase
516 if (!IS_CLIENT_STA(prStaRec)) {
520 if (prStaRec->ucStaState == STA_STATE_3) {
521 /* Do Reassocation */
523 else if ((prStaRec->ucStaState == STA_STATE_2) &&
524 (prStaRec->eAuthAssocState == AAA_STATE_SEND_AUTH2)) {
528 DBGLOG(AAA, WARN, ("Previous AuthAssocState (%d) != SEND_AUTH2.\n",
529 prStaRec->eAuthAssocState));
534 prStaRec->ucRCPI = prSwRfb->prHifRxHdr->ucRcpi;
536 //4 <2> Check P2P network conditions
537 #if CFG_ENABLE_WIFI_DIRECT
538 if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
540 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
542 if (prBssInfo->fgIsNetActive) {
544 //4 <2.1> Validate Assoc Req Frame and get Status Code
545 /* Check if for this BSSID */
546 if (WLAN_STATUS_SUCCESS ==
547 assocProcessRxAssocReqFrame(prAdapter,
551 if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
552 //4 <2.2> Validate Assoc Req Frame for Network Specific Conditions
553 fgReplyAssocResp = p2pFuncValidateAssocReq(
556 (PUINT_16)&u2StatusCode);
559 fgReplyAssocResp = TRUE;
566 #endif /* CFG_ENABLE_WIFI_DIRECT */
568 //4 <3> Check BOW network conditions
569 #if CFG_ENABLE_BT_OVER_WIFI
570 if (IS_STA_IN_BOW(prStaRec)) {
572 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX]);
574 if ((prBssInfo->fgIsNetActive) &&
575 (OP_MODE_BOW == prBssInfo->eCurrentOPMode)){
577 //4 <3.1> Validate Auth Frame by Auth Algorithm/Transation Seq
578 /* Check if for this BSSID */
579 if (WLAN_STATUS_SUCCESS ==
580 assocProcessRxAssocReqFrame(prAdapter,
584 if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
586 //4 <3.2> Validate Auth Frame for Network Specific Conditions
587 fgReplyAssocResp = bowValidateAssocReq(prAdapter, prSwRfb, &u2StatusCode);
592 fgReplyAssocResp = TRUE;
595 /* TODO(Kevin): Allocate a STA_RECORD_T for new client */
600 #endif /* CFG_ENABLE_BT_OVER_WIFI */
602 return WLAN_STATUS_SUCCESS; // To release the SW_RFB_T
606 //4 <4> Update STA_RECORD_T and reply Assoc Resp Frame
607 if (fgReplyAssocResp) {
611 if ((((P_WLAN_ASSOC_REQ_FRAME_T)(prSwRfb->pvHeader))->u2FrameCtrl & MASK_FRAME_TYPE) ==
612 MAC_FRAME_REASSOC_REQ) {
614 u2IELength = prSwRfb->u2PacketLen -
615 (UINT_16)OFFSET_OF(WLAN_REASSOC_REQ_FRAME_T, aucInfoElem[0]);
617 pucIE = ((P_WLAN_REASSOC_REQ_FRAME_T)(prSwRfb->pvHeader))->aucInfoElem;
620 u2IELength = prSwRfb->u2PacketLen -
621 (UINT_16)OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T, aucInfoElem[0]);
623 pucIE = ((P_WLAN_ASSOC_REQ_FRAME_T)(prSwRfb->pvHeader))->aucInfoElem;
626 rlmProcessAssocReq(prAdapter, prSwRfb, pucIE, u2IELength);
628 //4 <4.1> Assign Association ID
629 if (u2StatusCode == STATUS_CODE_SUCCESSFUL) {
631 #if CFG_ENABLE_WIFI_DIRECT
632 if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
633 if (p2pRunEventAAAComplete(prAdapter, prStaRec) == WLAN_STATUS_SUCCESS) {
634 prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
635 //prStaRec->eAuthAssocState = AA_STATE_IDLE;
636 prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2; // NOTE(Kevin): for TX done
638 /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
639 //cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
642 /* Client List FULL. */
643 u2StatusCode = STATUS_CODE_REQ_DECLINED;
645 prStaRec->u2AssocId = 0; /* Invalid Assocation ID */
647 /* If (Re)association fail, the peer can try Assocation w/o Auth immediately */
648 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
650 /* NOTE(Kevin): Better to change state here, not at TX Done */
651 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
656 #if CFG_ENABLE_BT_OVER_WIFI
657 if ((IS_STA_IN_BOW(prStaRec))) {
659 // if (bowRunEventAAAComplete(prAdapter, prStaRec) == WLAN_STATUS_SUCCESS) {
660 prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
661 prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2; // NOTE(Kevin): for TX done
663 /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
664 //cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
668 /* Client List FULL. */
669 u2StatusCode = STATUS_CODE_REQ_DECLINED;
671 prStaRec->u2AssocId = 0; /* Invalid Assocation ID */
673 /* If (Re)association fail, the peer can try Assocation w/o Auth immediately */
674 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
676 /* NOTE(Kevin): Better to change state here, not at TX Done */
677 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
684 prStaRec->u2AssocId = 0; /* Invalid Assocation ID */
686 /* If (Re)association fail, the peer can try Assocation w/o Auth immediately */
687 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
689 /* NOTE(Kevin): Better to change state here, not at TX Done */
690 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
693 /* Update the record join time. */
694 GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
696 /* Update Station Record - Status/Reason Code */
697 prStaRec->u2StatusCode = u2StatusCode;
699 /* NOTE: Ignore the return status for AAA */
700 //4 <4.2> Reply Assoc Resp
701 assocSendReAssocRespFrame(prAdapter, prStaRec);
705 return WLAN_STATUS_SUCCESS;
707 } /* end of aaaFsmRunEventRxAssoc() */
710 /*----------------------------------------------------------------------------*/
712 * @brief This function will handle TxDone(Auth2/AssocReq) Event of AAA FSM.
714 * @param[in] prAdapter Pointer to the Adapter structure.
715 * @param[in] prMsduInfo Pointer to the MSDU_INFO_T.
716 * @param[in] rTxDoneStatus Return TX status of the Auth1/Auth3/AssocReq frame.
718 * @retval WLAN_STATUS_SUCCESS
720 /*----------------------------------------------------------------------------*/
722 aaaFsmRunEventTxDone (
723 IN P_ADAPTER_T prAdapter,
724 IN P_MSDU_INFO_T prMsduInfo,
725 IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
728 P_STA_RECORD_T prStaRec;
729 P_BSS_INFO_T prBssInfo;
735 DBGLOG(AAA, LOUD, ("EVENT-TX DONE: Current Time = %ld\n", kalGetTimeTick()));
737 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
739 if ((!prStaRec) || (!prStaRec->fgIsInUse)) {
740 return WLAN_STATUS_SUCCESS; /* For the case of replying ERROR STATUS CODE */
743 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
745 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
747 switch (prStaRec->eAuthAssocState) {
748 case AAA_STATE_SEND_AUTH2:
750 /* Strictly check the outgoing frame is matched with current AA STATE */
751 if (authCheckTxAuthFrame(prAdapter,
753 AUTH_TRANSACTION_SEQ_2) != WLAN_STATUS_SUCCESS) {
757 if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
758 if (TX_RESULT_SUCCESS == rTxDoneStatus) {
760 /* NOTE(Kevin): Change to STATE_2 at TX Done */
761 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
765 prStaRec->eAuthAssocState = AA_STATE_IDLE;
767 /* NOTE(Kevin): Change to STATE_1 */
768 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
770 #if CFG_ENABLE_WIFI_DIRECT
771 if ((prAdapter->fgIsP2PRegistered) &&
772 (IS_STA_IN_P2P(prStaRec))) {
773 p2pRunEventAAATxFail(prAdapter, prStaRec);
775 #endif /* CFG_ENABLE_WIFI_DIRECT */
777 #if CFG_ENABLE_BT_OVER_WIFI
778 if (IS_STA_IN_BOW(prStaRec)) {
779 bowRunEventAAATxFail(prAdapter, prStaRec);
781 #endif /* CFG_ENABLE_BT_OVER_WIFI */
785 /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
790 case AAA_STATE_SEND_ASSOC2:
792 /* Strictly check the outgoing frame is matched with current SAA STATE */
793 if (assocCheckTxReAssocRespFrame(prAdapter, prMsduInfo) != WLAN_STATUS_SUCCESS) {
797 if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
798 if (TX_RESULT_SUCCESS == rTxDoneStatus) {
800 prStaRec->eAuthAssocState = AA_STATE_IDLE;
802 /* NOTE(Kevin): Change to STATE_3 at TX Done */
803 #if CFG_ENABLE_WIFI_DIRECT
804 if ((prAdapter->fgIsP2PRegistered) &&
805 (IS_STA_IN_P2P(prStaRec))) {
806 p2pRunEventAAASuccess(prAdapter, prStaRec);
808 #endif /* CFG_ENABLE_WIFI_DIRECT */
810 #if CFG_ENABLE_BT_OVER_WIFI
812 if (IS_STA_IN_BOW(prStaRec))
814 bowRunEventAAAComplete(prAdapter, prStaRec);
816 #endif /* CFG_ENABLE_BT_OVER_WIFI */
821 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
823 /* NOTE(Kevin): Change to STATE_2 */
824 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
826 #if CFG_ENABLE_WIFI_DIRECT
827 if ((prAdapter->fgIsP2PRegistered) &&
828 (IS_STA_IN_P2P(prStaRec))) {
829 p2pRunEventAAATxFail(prAdapter, prStaRec);
831 #endif /* CFG_ENABLE_WIFI_DIRECT */
833 #if CFG_ENABLE_BT_OVER_WIFI
834 if (IS_STA_IN_BOW(prStaRec)) {
835 bowRunEventAAATxFail(prAdapter, prStaRec);
837 #endif /* CFG_ENABLE_BT_OVER_WIFI */
841 /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
846 break; /* Ignore other cases */
850 return WLAN_STATUS_SUCCESS;
852 } /* end of aaaFsmRunEventTxDone() */
853 #endif /* CFG_SUPPORT_AAA */
856 #if 0 /* TODO(Kevin): for abort event, just reset the STA_RECORD_T. */
857 /*----------------------------------------------------------------------------*/
859 * \brief This function will send ABORT Event to JOIN FSM.
861 * \param[in] prAdapter Pointer to the Adapter structure.
865 /*----------------------------------------------------------------------------*/
867 saaFsmRunEventAbort (
868 IN P_MSG_HDR_T prMsgHdr
871 P_JOIN_INFO_T prJoinInfo;
872 P_STA_RECORD_T prStaRec;
874 DEBUGFUNC("joinFsmRunEventAbort");
878 prJoinInfo = &prAdapter->rJoinInfo;
880 DBGLOG(JOIN, EVENT, ("JOIN EVENT: ABORT\n"));
883 /* NOTE(Kevin): when reach here, the ARB_STATE should be in ARB_STATE_JOIN. */
884 ASSERT(prJoinInfo->prBssDesc);
886 //4 <1> Update Flags and Elements of JOIN Module.
887 /* Reset Send Auth/(Re)Assoc Frame Count */
888 prJoinInfo->ucTxAuthAssocRetryCount = 0;
890 /* Cancel all JOIN relative Timer */
891 ARB_CANCEL_TIMER(prAdapter,
892 prJoinInfo->rTxRequestTimer);
894 ARB_CANCEL_TIMER(prAdapter,
895 prJoinInfo->rRxResponseTimer);
897 ARB_CANCEL_TIMER(prAdapter,
898 prJoinInfo->rJoinTimer);
900 //4 <2> Update the associated STA_RECORD_T during JOIN.
901 /* Get a Station Record if possible, TA == BSSID for AP */
902 prStaRec = staRecGetStaRecordByAddr(prAdapter,
903 prJoinInfo->prBssDesc->aucBSSID);
906 /* Update Station Record - Class 1 Flag */
907 prStaRec->ucStaState = STA_STATE_1;
911 ASSERT(0); /* Shouldn't happened, because we already add this STA_RECORD_T at JOIN_STATE_INIT */
915 //4 <3> Pull back to IDLE.
916 joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
918 //4 <4> If we are in Roaming, recover the settings of previous BSS.
920 * Restore original setting from current BSS_INFO_T.
922 if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED) {
923 joinAdoptParametersFromCurrentBss(prAdapter);
927 } /* end of joinFsmRunEventAbort() */
931 /* TODO(Kevin): following code will be modified and move to AIS FSM */
933 /*----------------------------------------------------------------------------*/
935 * \brief This function will send Join Timeout Event to JOIN FSM.
937 * \param[in] prAdapter Pointer to the Adapter structure.
939 * \retval WLAN_STATUS_FAILURE Fail because of Join Timeout
941 /*----------------------------------------------------------------------------*/
943 joinFsmRunEventJoinTimeOut (
944 IN P_ADAPTER_T prAdapter
947 P_JOIN_INFO_T prJoinInfo;
948 P_STA_RECORD_T prStaRec;
950 DEBUGFUNC("joinFsmRunEventJoinTimeOut");
954 prJoinInfo = &prAdapter->rJoinInfo;
956 DBGLOG(JOIN, EVENT, ("JOIN EVENT: JOIN TIMEOUT\n"));
958 /* Get a Station Record if possible, TA == BSSID for AP */
959 prStaRec = staRecGetStaRecordByAddr(prAdapter,
960 prJoinInfo->prBssDesc->aucBSSID);
962 /* We have renew this Sta Record when in JOIN_STATE_INIT */
965 /* Record the Status Code of Authentication Request */
966 prStaRec->u2StatusCode = STATUS_CODE_JOIN_TIMEOUT;
968 /* Increase Failure Count */
969 prStaRec->ucJoinFailureCount++;
971 /* Reset Send Auth/(Re)Assoc Frame Count */
972 prJoinInfo->ucTxAuthAssocRetryCount = 0;
974 /* Cancel other JOIN relative Timer */
975 ARB_CANCEL_TIMER(prAdapter,
976 prJoinInfo->rTxRequestTimer);
978 ARB_CANCEL_TIMER(prAdapter,
979 prJoinInfo->rRxResponseTimer);
981 /* Restore original setting from current BSS_INFO_T */
982 if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED) {
983 joinAdoptParametersFromCurrentBss(prAdapter);
986 /* Pull back to IDLE */
987 joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
989 return WLAN_STATUS_FAILURE;
991 } /* end of joinFsmRunEventJoinTimeOut() */
993 /*----------------------------------------------------------------------------*/
995 * \brief This function will adopt the parameters from Peer BSS.
997 * \param[in] prAdapter Pointer to the Adapter structure.
1001 /*----------------------------------------------------------------------------*/
1003 joinAdoptParametersFromPeerBss (
1004 IN P_ADAPTER_T prAdapter
1007 P_JOIN_INFO_T prJoinInfo;
1008 P_BSS_DESC_T prBssDesc;
1010 DEBUGFUNC("joinAdoptParametersFromPeerBss");
1014 prJoinInfo = &prAdapter->rJoinInfo;
1015 prBssDesc = prJoinInfo->prBssDesc;
1017 //4 <1> Adopt Peer BSS' PHY TYPE
1018 prAdapter->eCurrentPhyType = prBssDesc->ePhyType;
1020 DBGLOG(JOIN, INFO, ("Target BSS[%s]'s PhyType = %s\n",
1021 prBssDesc->aucSSID, (prBssDesc->ePhyType == PHY_TYPE_ERP_INDEX) ? "ERP" : "HR_DSSS"));
1024 //4 <2> Adopt Peer BSS' Frequency(Band/Channel)
1025 DBGLOG(JOIN, INFO, ("Target BSS's Channel = %d, Band = %d\n",
1026 prBssDesc->ucChannelNum, prBssDesc->eBand));
1028 nicSwitchChannel(prAdapter,
1030 prBssDesc->ucChannelNum,
1033 prJoinInfo->fgIsParameterAdopted = TRUE;
1036 } /* end of joinAdoptParametersFromPeerBss() */
1039 /*----------------------------------------------------------------------------*/
1041 * \brief This function will adopt the parameters from current associated BSS.
1043 * \param[in] prAdapter Pointer to the Adapter structure.
1047 /*----------------------------------------------------------------------------*/
1049 joinAdoptParametersFromCurrentBss (
1050 IN P_ADAPTER_T prAdapter
1053 //P_JOIN_INFO_T prJoinInfo = &prAdapter->rJoinInfo;
1054 P_BSS_INFO_T prBssInfo;
1058 prBssInfo = &prAdapter->rBssInfo;
1060 //4 <1> Adopt current BSS' PHY TYPE
1061 prAdapter->eCurrentPhyType = prBssInfo->ePhyType;
1063 //4 <2> Adopt current BSS' Frequency(Band/Channel)
1064 DBGLOG(JOIN, INFO, ("Current BSS's Channel = %d, Band = %d\n",
1065 prBssInfo->ucChnl, prBssInfo->eBand));
1067 nicSwitchChannel(prAdapter,
1072 } /* end of joinAdoptParametersFromCurrentBss() */
1075 /*----------------------------------------------------------------------------*/
1077 * \brief This function will update all the SW variables and HW MCR registers after
1078 * the association with target BSS.
1080 * \param[in] prAdapter Pointer to the Adapter structure.
1084 /*----------------------------------------------------------------------------*/
1087 IN P_ADAPTER_T prAdapter
1090 P_JOIN_INFO_T prJoinInfo;
1091 P_BSS_DESC_T prBssDesc;
1092 P_PEER_BSS_INFO_T prPeerBssInfo;
1093 P_BSS_INFO_T prBssInfo;
1094 P_CONNECTION_SETTINGS_T prConnSettings;
1095 P_STA_RECORD_T prStaRec;
1096 P_TX_CTRL_T prTxCtrl;
1097 #if CFG_SUPPORT_802_11D
1098 P_IE_COUNTRY_T prIECountry;
1101 DEBUGFUNC("joinComplete");
1105 prJoinInfo = &prAdapter->rJoinInfo;
1106 prBssDesc = prJoinInfo->prBssDesc;
1107 prPeerBssInfo = &prAdapter->rPeerBssInfo;
1108 prBssInfo = &prAdapter->rBssInfo;
1109 prConnSettings = &prAdapter->rConnSettings;
1110 prTxCtrl = &prAdapter->rTxCtrl;
1112 //4 <1> Update Connecting & Connected Flag of BSS_DESC_T.
1113 /* Remove previous AP's Connection Flags if have */
1114 scanRemoveConnectionFlagOfBssDescByBssid(prAdapter, prBssInfo->aucBSSID);
1116 prBssDesc->fgIsConnected = TRUE; /* Mask as Connected */
1118 if (prBssDesc->fgIsHiddenSSID) {
1119 /* NOTE(Kevin): This is for the case of Passive Scan and the target BSS didn't
1120 * broadcast SSID on its Beacon Frame.
1122 COPY_SSID(prBssDesc->aucSSID,
1123 prBssDesc->ucSSIDLen,
1124 prAdapter->rConnSettings.aucSSID,
1125 prAdapter->rConnSettings.ucSSIDLen);
1127 if (prBssDesc->ucSSIDLen) {
1128 prBssDesc->fgIsHiddenSSID = FALSE;
1136 DBGLOG(JOIN, INFO, ("Hidden SSID! - Update SSID : %s\n", prBssDesc->aucSSID));
1140 //4 <2> Update BSS_INFO_T from BSS_DESC_T
1142 prBssInfo->ePhyType = prBssDesc->ePhyType;
1145 prBssInfo->eBSSType = BSS_TYPE_INFRASTRUCTURE;
1148 COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID);
1150 DBGLOG(JOIN, INFO, ("JOIN to BSSID: ["MACSTR"]\n", MAC2STR(prBssDesc->aucBSSID)));
1154 COPY_SSID(prBssInfo->aucSSID,
1155 prBssInfo->ucSSIDLen,
1157 prBssDesc->ucSSIDLen);
1159 //4 <2.E> Channel / Band information.
1160 prBssInfo->eBand = prBssDesc->eBand;
1161 prBssInfo->ucChnl = prBssDesc->ucChannelNum;
1163 //4 <2.F> RSN/WPA information.
1164 secFsmRunEventStart(prAdapter);
1165 prBssInfo->u4RsnSelectedPairwiseCipher = prBssDesc->u4RsnSelectedPairwiseCipher;
1166 prBssInfo->u4RsnSelectedGroupCipher = prBssDesc->u4RsnSelectedGroupCipher;
1167 prBssInfo->u4RsnSelectedAKMSuite = prBssDesc->u4RsnSelectedAKMSuite;
1169 if (secRsnKeyHandshakeEnabled()) {
1170 prBssInfo->fgIsWPAorWPA2Enabled = TRUE;
1173 prBssInfo->fgIsWPAorWPA2Enabled = FALSE;
1176 //4 <2.G> Beacon interval.
1177 prBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
1179 //4 <2.H> DTIM period.
1180 prBssInfo->ucDtimPeriod = prBssDesc->ucDTIMPeriod;
1182 //4 <2.I> ERP Information
1183 if ((prBssInfo->ePhyType == PHY_TYPE_ERP_INDEX) && // Our BSS's PHY_TYPE is ERP now.
1184 (prBssDesc->fgIsERPPresent)) {
1186 prBssInfo->fgIsERPPresent = TRUE;
1187 prBssInfo->ucERP = prBssDesc->ucERP; /* Save the ERP for later check */
1189 else { /* Some AP, may send ProbeResp without ERP IE. Thus prBssDesc->fgIsERPPresent is FALSE. */
1190 prBssInfo->fgIsERPPresent = FALSE;
1191 prBssInfo->ucERP = 0;
1194 #if CFG_SUPPORT_802_11D
1195 //4 <2.J> Country inforamtion of the associated AP
1196 if (prConnSettings->fgMultiDomainCapabilityEnabled) {
1197 DOMAIN_INFO_ENTRY rDomainInfo;
1198 if (domainGetDomainInfoByScanResult(prAdapter, &rDomainInfo)) {
1199 if (prBssDesc->prIECountry) {
1200 prIECountry = prBssDesc->prIECountry;
1202 domainParseCountryInfoElem(prIECountry, &prBssInfo->rDomainInfo);
1204 /* use the domain get from the BSS info */
1205 prBssInfo->fgIsCountryInfoPresent = TRUE;
1206 nicSetupOpChnlList(prAdapter, prBssInfo->rDomainInfo.u2CountryCode, FALSE);
1208 /* use the domain get from the scan result */
1209 prBssInfo->fgIsCountryInfoPresent = TRUE;
1210 nicSetupOpChnlList(prAdapter, rDomainInfo.u2CountryCode, FALSE);
1216 //4 <2.K> Signal Power of the associated AP
1217 prBssInfo->rRcpi = prBssDesc->rRcpi;
1218 prBssInfo->rRssi = RCPI_TO_dBm(prBssInfo->rRcpi);
1219 GET_CURRENT_SYSTIME(&prBssInfo->rRssiLastUpdateTime);
1221 //4 <2.L> Capability Field of the associated AP
1222 prBssInfo->u2CapInfo = prBssDesc->u2CapInfo;
1224 DBGLOG(JOIN, INFO, ("prBssInfo-> fgIsERPPresent = %d, ucERP = %02x, rRcpi = %d, rRssi = %ld\n",
1225 prBssInfo->fgIsERPPresent, prBssInfo->ucERP, prBssInfo->rRcpi, prBssInfo->rRssi));
1228 //4 <3> Update BSS_INFO_T from PEER_BSS_INFO_T & NIC RATE FUNC
1229 //4 <3.A> Association ID
1230 prBssInfo->u2AssocId = prPeerBssInfo->u2AssocId;
1232 //4 <3.B> WMM Infomation
1233 if (prAdapter->fgIsEnableWMM &&
1234 (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_SUPPORT_WMM)) {
1236 prBssInfo->fgIsWmmAssoc = TRUE;
1237 prTxCtrl->rTxQForVoipAccess = TXQ_AC3;
1239 qosWmmInfoInit(&prBssInfo->rWmmInfo, (prBssInfo->ePhyType == PHY_TYPE_HR_DSSS_INDEX) ? TRUE : FALSE);
1241 if (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_AC_PARAM_PRESENT) {
1242 kalMemCopy(&prBssInfo->rWmmInfo,
1243 &prPeerBssInfo->rWmmInfo,
1244 sizeof(WMM_INFO_T));
1247 kalMemCopy(&prBssInfo->rWmmInfo,
1248 &prPeerBssInfo->rWmmInfo,
1249 sizeof(WMM_INFO_T) - sizeof(prPeerBssInfo->rWmmInfo.arWmmAcParams));
1253 prBssInfo->fgIsWmmAssoc = FALSE;
1254 prTxCtrl->rTxQForVoipAccess = TXQ_AC1;
1256 kalMemZero(&prBssInfo->rWmmInfo, sizeof(WMM_INFO_T));
1260 //4 <3.C> Operational Rate Set & BSS Basic Rate Set
1261 prBssInfo->u2OperationalRateSet = prPeerBssInfo->u2OperationalRateSet;
1262 prBssInfo->u2BSSBasicRateSet = prPeerBssInfo->u2BSSBasicRateSet;
1265 //4 <3.D> Short Preamble
1266 if (prBssInfo->fgIsERPPresent) {
1268 /* NOTE(Kevin 2007/12/24): Truth Table.
1269 * Short Preamble Bit in
1270 * <AssocReq> <AssocResp w/i ERP> <BARKER(Long)> Final Driver Setting(Short)
1271 * TRUE FALSE FALSE FALSE(shouldn't have such case, use the AssocResp)
1272 * TRUE FALSE TRUE FALSE
1273 * FALSE FALSE FALSE FALSE(shouldn't have such case, use the AssocResp)
1274 * FALSE FALSE TRUE FALSE
1275 * TRUE TRUE FALSE TRUE(follow ERP)
1276 * TRUE TRUE TRUE FALSE(follow ERP)
1277 * FALSE TRUE FALSE FALSE(shouldn't have such case, and we should set to FALSE)
1278 * FALSE TRUE TRUE FALSE(we should set to FALSE)
1280 if ((prPeerBssInfo->fgIsShortPreambleAllowed) &&
1281 ((prConnSettings->ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
1282 ((prConnSettings->ePreambleType == PREAMBLE_TYPE_AUTO) &&
1283 (prBssDesc->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)))) {
1285 prBssInfo->fgIsShortPreambleAllowed = TRUE;
1287 if (prBssInfo->ucERP & ERP_INFO_BARKER_PREAMBLE_MODE) {
1288 prBssInfo->fgUseShortPreamble = FALSE;
1291 prBssInfo->fgUseShortPreamble = TRUE;
1295 prBssInfo->fgIsShortPreambleAllowed = FALSE;
1296 prBssInfo->fgUseShortPreamble = FALSE;
1300 /* NOTE(Kevin 2007/12/24): Truth Table.
1301 * Short Preamble Bit in
1302 * <AssocReq> <AssocResp w/o ERP> Final Driver Setting(Short)
1306 * FALSE TRUE(status success) TRUE
1307 * --> Honor the result of prPeerBssInfo.
1310 prBssInfo->fgIsShortPreambleAllowed = prBssInfo->fgUseShortPreamble =
1311 prPeerBssInfo->fgIsShortPreambleAllowed;
1314 DBGLOG(JOIN, INFO, ("prBssInfo->fgIsShortPreambleAllowed = %d, prBssInfo->fgUseShortPreamble = %d\n",
1315 prBssInfo->fgIsShortPreambleAllowed, prBssInfo->fgUseShortPreamble));
1318 //4 <3.E> Short Slot Time
1319 prBssInfo->fgUseShortSlotTime =
1320 prPeerBssInfo->fgUseShortSlotTime; /* AP support Short Slot Time */
1322 DBGLOG(JOIN, INFO, ("prBssInfo->fgUseShortSlotTime = %d\n",
1323 prBssInfo->fgUseShortSlotTime));
1325 nicSetSlotTime(prAdapter,
1326 prBssInfo->ePhyType,
1327 ((prConnSettings->fgIsShortSlotTimeOptionEnable &&
1328 prBssInfo->fgUseShortSlotTime) ? TRUE : FALSE));
1331 //4 <3.F> Update Tx Rate for Control Frame
1332 bssUpdateTxRateForControlFrame(prAdapter);
1335 //4 <3.G> Save the available Auth Types during Roaming (Design for Fast BSS Transition).
1336 //if (prAdapter->fgIsEnableRoaming) /* NOTE(Kevin): Always prepare info for roaming */
1339 if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_OPEN_SYSTEM) {
1340 prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_OPEN_SYSTEM;
1342 else if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_SHARED_KEY) {
1343 prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_SHARED_KEY;
1346 prBssInfo->ucRoamingAuthTypes = prJoinInfo->ucRoamingAuthTypes;
1349 /* Set the stable time of the associated BSS. We won't do roaming decision
1350 * during the stable time.
1352 SET_EXPIRATION_TIME(prBssInfo->rRoamingStableExpirationTime,
1353 SEC_TO_SYSTIME(ROAMING_STABLE_TIMEOUT_SEC));
1357 //4 <3.H> Update Parameter for TX Fragmentation Threshold
1359 txFragInfoUpdate(prAdapter);
1360 #endif /* CFG_TX_FRAGMENT */
1363 //4 <4> Update STA_RECORD_T
1364 /* Get a Station Record if possible */
1365 prStaRec = staRecGetStaRecordByAddr(prAdapter,
1366 prBssDesc->aucBSSID);
1369 UINT_16 u2OperationalRateSet, u2DesiredRateSet;
1371 //4 <4.A> Desired Rate Set
1372 u2OperationalRateSet = (rPhyAttributes[prBssInfo->ePhyType].u2SupportedRateSet &
1373 prBssInfo->u2OperationalRateSet);
1375 u2DesiredRateSet = (u2OperationalRateSet & prConnSettings->u2DesiredRateSet);
1376 if (u2DesiredRateSet) {
1377 prStaRec->u2DesiredRateSet = u2DesiredRateSet;
1380 /* For Error Handling - The Desired Rate Set is not covered in Operational Rate Set. */
1381 prStaRec->u2DesiredRateSet = u2OperationalRateSet;
1384 /* Try to set the best initial rate for this entry */
1385 if (!rateGetBestInitialRateIndex(prStaRec->u2DesiredRateSet,
1387 &prStaRec->ucCurrRate1Index)) {
1389 if (!rateGetLowestRateIndexFromRateSet(prStaRec->u2DesiredRateSet,
1390 &prStaRec->ucCurrRate1Index)) {
1395 DBGLOG(JOIN, INFO, ("prStaRec->ucCurrRate1Index = %d\n",
1396 prStaRec->ucCurrRate1Index));
1398 //4 <4.B> Preamble Mode
1399 prStaRec->fgIsShortPreambleOptionEnable =
1400 prBssInfo->fgUseShortPreamble;
1403 prStaRec->fgIsQoS = prBssInfo->fgIsWmmAssoc;
1413 //4 <5.A> Update BSSID & Operation Mode
1414 nicSetupBSS(prAdapter, prBssInfo);
1416 //4 <5.B> Update WLAN Table.
1417 if (nicSetHwBySta(prAdapter, prStaRec) == FALSE) {
1421 //4 <5.C> Update Desired Rate Set for BT.
1423 if (prConnSettings->fgIsEnableTxAutoFragmentForBT) {
1424 txRateSetInitForBT(prAdapter, prStaRec);
1426 #endif /* CFG_TX_FRAGMENT */
1428 //4 <5.D> TX AC Parameter and TX/RX Queue Control
1429 if (prBssInfo->fgIsWmmAssoc) {
1431 #if CFG_TX_AGGREGATE_HW_FIFO
1432 nicTxAggregateTXQ(prAdapter, FALSE);
1433 #endif /* CFG_TX_AGGREGATE_HW_FIFO */
1435 qosUpdateWMMParametersAndAssignAllowedACI(prAdapter, &prBssInfo->rWmmInfo);
1439 #if CFG_TX_AGGREGATE_HW_FIFO
1440 nicTxAggregateTXQ(prAdapter, TRUE);
1441 #endif /* CFG_TX_AGGREGATE_HW_FIFO */
1443 nicTxNonQoSAssignDefaultAdmittedTXQ(prAdapter);
1445 nicTxNonQoSUpdateTXQParameters(prAdapter,
1446 prBssInfo->ePhyType);
1449 #if CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN
1451 prTxCtrl->fgBlockTxDuringJoin = FALSE;
1453 #if !CFG_TX_AGGREGATE_HW_FIFO /* TX FIFO AGGREGATE already do flush once */
1454 nicTxFlushStopQueues(prAdapter, (UINT_8)TXQ_DATA_MASK, (UINT_8)NULL);
1455 #endif /* CFG_TX_AGGREGATE_HW_FIFO */
1457 nicTxRetransmitOfSendWaitQue(prAdapter);
1459 if (prTxCtrl->fgIsPacketInOsSendQueue) {
1460 nicTxRetransmitOfOsSendQue(prAdapter);
1463 #if CFG_SDIO_TX_ENHANCE
1464 halTxLeftClusteredMpdu(prAdapter);
1465 #endif /* CFG_SDIO_TX_ENHANCE */
1468 #endif /* CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN */
1471 //4 <6> Setup CONNECTION flag.
1472 prAdapter->eConnectionState = MEDIA_STATE_CONNECTED;
1473 prAdapter->eConnectionStateIndicated = MEDIA_STATE_CONNECTED;
1475 if (prJoinInfo->fgIsReAssoc) {
1476 prAdapter->fgBypassPortCtrlForRoaming = TRUE;
1479 prAdapter->fgBypassPortCtrlForRoaming = FALSE;
1482 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
1483 WLAN_STATUS_MEDIA_CONNECT,
1488 } /* end of joinComplete() */