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
513 return WLAN_STATUS_FAILURE;
517 if (!IS_CLIENT_STA(prStaRec)) {
521 if (prStaRec->ucStaState == STA_STATE_3) {
522 /* Do Reassocation */
524 else if ((prStaRec->ucStaState == STA_STATE_2) &&
525 (prStaRec->eAuthAssocState == AAA_STATE_SEND_AUTH2)) {
529 DBGLOG(AAA, WARN, ("Previous AuthAssocState (%d) != SEND_AUTH2.\n",
530 prStaRec->eAuthAssocState));
535 prStaRec->ucRCPI = prSwRfb->prHifRxHdr->ucRcpi;
537 //4 <2> Check P2P network conditions
538 #if CFG_ENABLE_WIFI_DIRECT
539 if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
541 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX]);
543 if (prBssInfo->fgIsNetActive) {
545 //4 <2.1> Validate Assoc Req Frame and get Status Code
546 /* Check if for this BSSID */
547 if (WLAN_STATUS_SUCCESS ==
548 assocProcessRxAssocReqFrame(prAdapter,
552 if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
553 //4 <2.2> Validate Assoc Req Frame for Network Specific Conditions
554 fgReplyAssocResp = p2pFuncValidateAssocReq(
557 (PUINT_16)&u2StatusCode);
560 fgReplyAssocResp = TRUE;
567 #endif /* CFG_ENABLE_WIFI_DIRECT */
569 //4 <3> Check BOW network conditions
570 #if CFG_ENABLE_BT_OVER_WIFI
571 if (IS_STA_IN_BOW(prStaRec)) {
573 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX]);
575 if ((prBssInfo->fgIsNetActive) &&
576 (OP_MODE_BOW == prBssInfo->eCurrentOPMode)){
578 //4 <3.1> Validate Auth Frame by Auth Algorithm/Transation Seq
579 /* Check if for this BSSID */
580 if (WLAN_STATUS_SUCCESS ==
581 assocProcessRxAssocReqFrame(prAdapter,
585 if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
587 //4 <3.2> Validate Auth Frame for Network Specific Conditions
588 fgReplyAssocResp = bowValidateAssocReq(prAdapter, prSwRfb, &u2StatusCode);
593 fgReplyAssocResp = TRUE;
596 /* TODO(Kevin): Allocate a STA_RECORD_T for new client */
601 #endif /* CFG_ENABLE_BT_OVER_WIFI */
603 return WLAN_STATUS_SUCCESS; // To release the SW_RFB_T
607 //4 <4> Update STA_RECORD_T and reply Assoc Resp Frame
608 if (fgReplyAssocResp) {
612 if ((((P_WLAN_ASSOC_REQ_FRAME_T)(prSwRfb->pvHeader))->u2FrameCtrl & MASK_FRAME_TYPE) ==
613 MAC_FRAME_REASSOC_REQ) {
615 u2IELength = prSwRfb->u2PacketLen -
616 (UINT_16)OFFSET_OF(WLAN_REASSOC_REQ_FRAME_T, aucInfoElem[0]);
618 pucIE = ((P_WLAN_REASSOC_REQ_FRAME_T)(prSwRfb->pvHeader))->aucInfoElem;
621 u2IELength = prSwRfb->u2PacketLen -
622 (UINT_16)OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T, aucInfoElem[0]);
624 pucIE = ((P_WLAN_ASSOC_REQ_FRAME_T)(prSwRfb->pvHeader))->aucInfoElem;
627 rlmProcessAssocReq(prAdapter, prSwRfb, pucIE, u2IELength);
629 //4 <4.1> Assign Association ID
630 if (u2StatusCode == STATUS_CODE_SUCCESSFUL) {
632 #if CFG_ENABLE_WIFI_DIRECT
633 if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
634 if (p2pRunEventAAAComplete(prAdapter, prStaRec) == WLAN_STATUS_SUCCESS) {
635 prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
636 //prStaRec->eAuthAssocState = AA_STATE_IDLE;
637 prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2; // NOTE(Kevin): for TX done
639 /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
640 //cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
643 /* Client List FULL. */
644 u2StatusCode = STATUS_CODE_REQ_DECLINED;
646 prStaRec->u2AssocId = 0; /* Invalid Assocation ID */
648 /* If (Re)association fail, the peer can try Assocation w/o Auth immediately */
649 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
651 /* NOTE(Kevin): Better to change state here, not at TX Done */
652 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
657 #if CFG_ENABLE_BT_OVER_WIFI
658 if ((IS_STA_IN_BOW(prStaRec))) {
660 // if (bowRunEventAAAComplete(prAdapter, prStaRec) == WLAN_STATUS_SUCCESS) {
661 prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
662 prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2; // NOTE(Kevin): for TX done
664 /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
665 //cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3);
669 /* Client List FULL. */
670 u2StatusCode = STATUS_CODE_REQ_DECLINED;
672 prStaRec->u2AssocId = 0; /* Invalid Assocation ID */
674 /* If (Re)association fail, the peer can try Assocation w/o Auth immediately */
675 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
677 /* NOTE(Kevin): Better to change state here, not at TX Done */
678 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
685 prStaRec->u2AssocId = 0; /* Invalid Assocation ID */
687 /* If (Re)association fail, the peer can try Assocation w/o Auth immediately */
688 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
690 /* NOTE(Kevin): Better to change state here, not at TX Done */
691 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
694 /* Update the record join time. */
695 GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
697 /* Update Station Record - Status/Reason Code */
698 prStaRec->u2StatusCode = u2StatusCode;
700 /* NOTE: Ignore the return status for AAA */
701 //4 <4.2> Reply Assoc Resp
702 assocSendReAssocRespFrame(prAdapter, prStaRec);
706 return WLAN_STATUS_SUCCESS;
708 } /* end of aaaFsmRunEventRxAssoc() */
711 /*----------------------------------------------------------------------------*/
713 * @brief This function will handle TxDone(Auth2/AssocReq) Event of AAA FSM.
715 * @param[in] prAdapter Pointer to the Adapter structure.
716 * @param[in] prMsduInfo Pointer to the MSDU_INFO_T.
717 * @param[in] rTxDoneStatus Return TX status of the Auth1/Auth3/AssocReq frame.
719 * @retval WLAN_STATUS_SUCCESS
721 /*----------------------------------------------------------------------------*/
723 aaaFsmRunEventTxDone (
724 IN P_ADAPTER_T prAdapter,
725 IN P_MSDU_INFO_T prMsduInfo,
726 IN ENUM_TX_RESULT_CODE_T rTxDoneStatus
729 P_STA_RECORD_T prStaRec;
730 P_BSS_INFO_T prBssInfo;
736 DBGLOG(AAA, LOUD, ("EVENT-TX DONE: Current Time = %ld\n", kalGetTimeTick()));
738 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
740 if ((!prStaRec) || (!prStaRec->fgIsInUse)) {
741 return WLAN_STATUS_SUCCESS; /* For the case of replying ERROR STATUS CODE */
744 ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
746 prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
748 switch (prStaRec->eAuthAssocState) {
749 case AAA_STATE_SEND_AUTH2:
751 /* Strictly check the outgoing frame is matched with current AA STATE */
752 if (authCheckTxAuthFrame(prAdapter,
754 AUTH_TRANSACTION_SEQ_2) != WLAN_STATUS_SUCCESS) {
758 if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
759 if (TX_RESULT_SUCCESS == rTxDoneStatus) {
761 /* NOTE(Kevin): Change to STATE_2 at TX Done */
762 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
766 prStaRec->eAuthAssocState = AA_STATE_IDLE;
768 /* NOTE(Kevin): Change to STATE_1 */
769 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
771 #if CFG_ENABLE_WIFI_DIRECT
772 if ((prAdapter->fgIsP2PRegistered) &&
773 (IS_STA_IN_P2P(prStaRec))) {
774 p2pRunEventAAATxFail(prAdapter, prStaRec);
776 #endif /* CFG_ENABLE_WIFI_DIRECT */
778 #if CFG_ENABLE_BT_OVER_WIFI
779 if (IS_STA_IN_BOW(prStaRec)) {
780 bowRunEventAAATxFail(prAdapter, prStaRec);
782 #endif /* CFG_ENABLE_BT_OVER_WIFI */
786 /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
791 case AAA_STATE_SEND_ASSOC2:
793 /* Strictly check the outgoing frame is matched with current SAA STATE */
794 if (assocCheckTxReAssocRespFrame(prAdapter, prMsduInfo) != WLAN_STATUS_SUCCESS) {
798 if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
799 if (TX_RESULT_SUCCESS == rTxDoneStatus) {
801 prStaRec->eAuthAssocState = AA_STATE_IDLE;
803 /* NOTE(Kevin): Change to STATE_3 at TX Done */
804 #if CFG_ENABLE_WIFI_DIRECT
805 if ((prAdapter->fgIsP2PRegistered) &&
806 (IS_STA_IN_P2P(prStaRec))) {
807 p2pRunEventAAASuccess(prAdapter, prStaRec);
809 #endif /* CFG_ENABLE_WIFI_DIRECT */
811 #if CFG_ENABLE_BT_OVER_WIFI
813 if (IS_STA_IN_BOW(prStaRec))
815 bowRunEventAAAComplete(prAdapter, prStaRec);
817 #endif /* CFG_ENABLE_BT_OVER_WIFI */
822 prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
824 /* NOTE(Kevin): Change to STATE_2 */
825 cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
827 #if CFG_ENABLE_WIFI_DIRECT
828 if ((prAdapter->fgIsP2PRegistered) &&
829 (IS_STA_IN_P2P(prStaRec))) {
830 p2pRunEventAAATxFail(prAdapter, prStaRec);
832 #endif /* CFG_ENABLE_WIFI_DIRECT */
834 #if CFG_ENABLE_BT_OVER_WIFI
835 if (IS_STA_IN_BOW(prStaRec)) {
836 bowRunEventAAATxFail(prAdapter, prStaRec);
838 #endif /* CFG_ENABLE_BT_OVER_WIFI */
842 /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
847 break; /* Ignore other cases */
851 return WLAN_STATUS_SUCCESS;
853 } /* end of aaaFsmRunEventTxDone() */
854 #endif /* CFG_SUPPORT_AAA */
857 #if 0 /* TODO(Kevin): for abort event, just reset the STA_RECORD_T. */
858 /*----------------------------------------------------------------------------*/
860 * \brief This function will send ABORT Event to JOIN FSM.
862 * \param[in] prAdapter Pointer to the Adapter structure.
866 /*----------------------------------------------------------------------------*/
868 saaFsmRunEventAbort (
869 IN P_MSG_HDR_T prMsgHdr
872 P_JOIN_INFO_T prJoinInfo;
873 P_STA_RECORD_T prStaRec;
875 DEBUGFUNC("joinFsmRunEventAbort");
879 prJoinInfo = &prAdapter->rJoinInfo;
881 DBGLOG(JOIN, EVENT, ("JOIN EVENT: ABORT\n"));
884 /* NOTE(Kevin): when reach here, the ARB_STATE should be in ARB_STATE_JOIN. */
885 ASSERT(prJoinInfo->prBssDesc);
887 //4 <1> Update Flags and Elements of JOIN Module.
888 /* Reset Send Auth/(Re)Assoc Frame Count */
889 prJoinInfo->ucTxAuthAssocRetryCount = 0;
891 /* Cancel all JOIN relative Timer */
892 ARB_CANCEL_TIMER(prAdapter,
893 prJoinInfo->rTxRequestTimer);
895 ARB_CANCEL_TIMER(prAdapter,
896 prJoinInfo->rRxResponseTimer);
898 ARB_CANCEL_TIMER(prAdapter,
899 prJoinInfo->rJoinTimer);
901 //4 <2> Update the associated STA_RECORD_T during JOIN.
902 /* Get a Station Record if possible, TA == BSSID for AP */
903 prStaRec = staRecGetStaRecordByAddr(prAdapter,
904 prJoinInfo->prBssDesc->aucBSSID);
907 /* Update Station Record - Class 1 Flag */
908 prStaRec->ucStaState = STA_STATE_1;
912 ASSERT(0); /* Shouldn't happened, because we already add this STA_RECORD_T at JOIN_STATE_INIT */
916 //4 <3> Pull back to IDLE.
917 joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
919 //4 <4> If we are in Roaming, recover the settings of previous BSS.
921 * Restore original setting from current BSS_INFO_T.
923 if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED) {
924 joinAdoptParametersFromCurrentBss(prAdapter);
928 } /* end of joinFsmRunEventAbort() */
932 /* TODO(Kevin): following code will be modified and move to AIS FSM */
934 /*----------------------------------------------------------------------------*/
936 * \brief This function will send Join Timeout Event to JOIN FSM.
938 * \param[in] prAdapter Pointer to the Adapter structure.
940 * \retval WLAN_STATUS_FAILURE Fail because of Join Timeout
942 /*----------------------------------------------------------------------------*/
944 joinFsmRunEventJoinTimeOut (
945 IN P_ADAPTER_T prAdapter
948 P_JOIN_INFO_T prJoinInfo;
949 P_STA_RECORD_T prStaRec;
951 DEBUGFUNC("joinFsmRunEventJoinTimeOut");
955 prJoinInfo = &prAdapter->rJoinInfo;
957 DBGLOG(JOIN, EVENT, ("JOIN EVENT: JOIN TIMEOUT\n"));
959 /* Get a Station Record if possible, TA == BSSID for AP */
960 prStaRec = staRecGetStaRecordByAddr(prAdapter,
961 prJoinInfo->prBssDesc->aucBSSID);
963 /* We have renew this Sta Record when in JOIN_STATE_INIT */
966 /* Record the Status Code of Authentication Request */
967 prStaRec->u2StatusCode = STATUS_CODE_JOIN_TIMEOUT;
969 /* Increase Failure Count */
970 prStaRec->ucJoinFailureCount++;
972 /* Reset Send Auth/(Re)Assoc Frame Count */
973 prJoinInfo->ucTxAuthAssocRetryCount = 0;
975 /* Cancel other JOIN relative Timer */
976 ARB_CANCEL_TIMER(prAdapter,
977 prJoinInfo->rTxRequestTimer);
979 ARB_CANCEL_TIMER(prAdapter,
980 prJoinInfo->rRxResponseTimer);
982 /* Restore original setting from current BSS_INFO_T */
983 if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED) {
984 joinAdoptParametersFromCurrentBss(prAdapter);
987 /* Pull back to IDLE */
988 joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
990 return WLAN_STATUS_FAILURE;
992 } /* end of joinFsmRunEventJoinTimeOut() */
994 /*----------------------------------------------------------------------------*/
996 * \brief This function will adopt the parameters from Peer BSS.
998 * \param[in] prAdapter Pointer to the Adapter structure.
1002 /*----------------------------------------------------------------------------*/
1004 joinAdoptParametersFromPeerBss (
1005 IN P_ADAPTER_T prAdapter
1008 P_JOIN_INFO_T prJoinInfo;
1009 P_BSS_DESC_T prBssDesc;
1011 DEBUGFUNC("joinAdoptParametersFromPeerBss");
1015 prJoinInfo = &prAdapter->rJoinInfo;
1016 prBssDesc = prJoinInfo->prBssDesc;
1018 //4 <1> Adopt Peer BSS' PHY TYPE
1019 prAdapter->eCurrentPhyType = prBssDesc->ePhyType;
1021 DBGLOG(JOIN, INFO, ("Target BSS[%s]'s PhyType = %s\n",
1022 prBssDesc->aucSSID, (prBssDesc->ePhyType == PHY_TYPE_ERP_INDEX) ? "ERP" : "HR_DSSS"));
1025 //4 <2> Adopt Peer BSS' Frequency(Band/Channel)
1026 DBGLOG(JOIN, INFO, ("Target BSS's Channel = %d, Band = %d\n",
1027 prBssDesc->ucChannelNum, prBssDesc->eBand));
1029 nicSwitchChannel(prAdapter,
1031 prBssDesc->ucChannelNum,
1034 prJoinInfo->fgIsParameterAdopted = TRUE;
1037 } /* end of joinAdoptParametersFromPeerBss() */
1040 /*----------------------------------------------------------------------------*/
1042 * \brief This function will adopt the parameters from current associated BSS.
1044 * \param[in] prAdapter Pointer to the Adapter structure.
1048 /*----------------------------------------------------------------------------*/
1050 joinAdoptParametersFromCurrentBss (
1051 IN P_ADAPTER_T prAdapter
1054 //P_JOIN_INFO_T prJoinInfo = &prAdapter->rJoinInfo;
1055 P_BSS_INFO_T prBssInfo;
1059 prBssInfo = &prAdapter->rBssInfo;
1061 //4 <1> Adopt current BSS' PHY TYPE
1062 prAdapter->eCurrentPhyType = prBssInfo->ePhyType;
1064 //4 <2> Adopt current BSS' Frequency(Band/Channel)
1065 DBGLOG(JOIN, INFO, ("Current BSS's Channel = %d, Band = %d\n",
1066 prBssInfo->ucChnl, prBssInfo->eBand));
1068 nicSwitchChannel(prAdapter,
1073 } /* end of joinAdoptParametersFromCurrentBss() */
1076 /*----------------------------------------------------------------------------*/
1078 * \brief This function will update all the SW variables and HW MCR registers after
1079 * the association with target BSS.
1081 * \param[in] prAdapter Pointer to the Adapter structure.
1085 /*----------------------------------------------------------------------------*/
1088 IN P_ADAPTER_T prAdapter
1091 P_JOIN_INFO_T prJoinInfo;
1092 P_BSS_DESC_T prBssDesc;
1093 P_PEER_BSS_INFO_T prPeerBssInfo;
1094 P_BSS_INFO_T prBssInfo;
1095 P_CONNECTION_SETTINGS_T prConnSettings;
1096 P_STA_RECORD_T prStaRec;
1097 P_TX_CTRL_T prTxCtrl;
1098 #if CFG_SUPPORT_802_11D
1099 P_IE_COUNTRY_T prIECountry;
1102 DEBUGFUNC("joinComplete");
1106 prJoinInfo = &prAdapter->rJoinInfo;
1107 prBssDesc = prJoinInfo->prBssDesc;
1108 prPeerBssInfo = &prAdapter->rPeerBssInfo;
1109 prBssInfo = &prAdapter->rBssInfo;
1110 prConnSettings = &prAdapter->rConnSettings;
1111 prTxCtrl = &prAdapter->rTxCtrl;
1113 //4 <1> Update Connecting & Connected Flag of BSS_DESC_T.
1114 /* Remove previous AP's Connection Flags if have */
1115 scanRemoveConnectionFlagOfBssDescByBssid(prAdapter, prBssInfo->aucBSSID);
1117 prBssDesc->fgIsConnected = TRUE; /* Mask as Connected */
1119 if (prBssDesc->fgIsHiddenSSID) {
1120 /* NOTE(Kevin): This is for the case of Passive Scan and the target BSS didn't
1121 * broadcast SSID on its Beacon Frame.
1123 COPY_SSID(prBssDesc->aucSSID,
1124 prBssDesc->ucSSIDLen,
1125 prAdapter->rConnSettings.aucSSID,
1126 prAdapter->rConnSettings.ucSSIDLen);
1128 if (prBssDesc->ucSSIDLen) {
1129 prBssDesc->fgIsHiddenSSID = FALSE;
1137 DBGLOG(JOIN, INFO, ("Hidden SSID! - Update SSID : %s\n", prBssDesc->aucSSID));
1141 //4 <2> Update BSS_INFO_T from BSS_DESC_T
1143 prBssInfo->ePhyType = prBssDesc->ePhyType;
1146 prBssInfo->eBSSType = BSS_TYPE_INFRASTRUCTURE;
1149 COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID);
1151 DBGLOG(JOIN, INFO, ("JOIN to BSSID: ["MACSTR"]\n", MAC2STR(prBssDesc->aucBSSID)));
1155 COPY_SSID(prBssInfo->aucSSID,
1156 prBssInfo->ucSSIDLen,
1158 prBssDesc->ucSSIDLen);
1160 //4 <2.E> Channel / Band information.
1161 prBssInfo->eBand = prBssDesc->eBand;
1162 prBssInfo->ucChnl = prBssDesc->ucChannelNum;
1164 //4 <2.F> RSN/WPA information.
1165 secFsmRunEventStart(prAdapter);
1166 prBssInfo->u4RsnSelectedPairwiseCipher = prBssDesc->u4RsnSelectedPairwiseCipher;
1167 prBssInfo->u4RsnSelectedGroupCipher = prBssDesc->u4RsnSelectedGroupCipher;
1168 prBssInfo->u4RsnSelectedAKMSuite = prBssDesc->u4RsnSelectedAKMSuite;
1170 if (secRsnKeyHandshakeEnabled()) {
1171 prBssInfo->fgIsWPAorWPA2Enabled = TRUE;
1174 prBssInfo->fgIsWPAorWPA2Enabled = FALSE;
1177 //4 <2.G> Beacon interval.
1178 prBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
1180 //4 <2.H> DTIM period.
1181 prBssInfo->ucDtimPeriod = prBssDesc->ucDTIMPeriod;
1183 //4 <2.I> ERP Information
1184 if ((prBssInfo->ePhyType == PHY_TYPE_ERP_INDEX) && // Our BSS's PHY_TYPE is ERP now.
1185 (prBssDesc->fgIsERPPresent)) {
1187 prBssInfo->fgIsERPPresent = TRUE;
1188 prBssInfo->ucERP = prBssDesc->ucERP; /* Save the ERP for later check */
1190 else { /* Some AP, may send ProbeResp without ERP IE. Thus prBssDesc->fgIsERPPresent is FALSE. */
1191 prBssInfo->fgIsERPPresent = FALSE;
1192 prBssInfo->ucERP = 0;
1195 #if CFG_SUPPORT_802_11D
1196 //4 <2.J> Country inforamtion of the associated AP
1197 if (prConnSettings->fgMultiDomainCapabilityEnabled) {
1198 DOMAIN_INFO_ENTRY rDomainInfo;
1199 if (domainGetDomainInfoByScanResult(prAdapter, &rDomainInfo)) {
1200 if (prBssDesc->prIECountry) {
1201 prIECountry = prBssDesc->prIECountry;
1203 domainParseCountryInfoElem(prIECountry, &prBssInfo->rDomainInfo);
1205 /* use the domain get from the BSS info */
1206 prBssInfo->fgIsCountryInfoPresent = TRUE;
1207 nicSetupOpChnlList(prAdapter, prBssInfo->rDomainInfo.u2CountryCode, FALSE);
1209 /* use the domain get from the scan result */
1210 prBssInfo->fgIsCountryInfoPresent = TRUE;
1211 nicSetupOpChnlList(prAdapter, rDomainInfo.u2CountryCode, FALSE);
1217 //4 <2.K> Signal Power of the associated AP
1218 prBssInfo->rRcpi = prBssDesc->rRcpi;
1219 prBssInfo->rRssi = RCPI_TO_dBm(prBssInfo->rRcpi);
1220 GET_CURRENT_SYSTIME(&prBssInfo->rRssiLastUpdateTime);
1222 //4 <2.L> Capability Field of the associated AP
1223 prBssInfo->u2CapInfo = prBssDesc->u2CapInfo;
1225 DBGLOG(JOIN, INFO, ("prBssInfo-> fgIsERPPresent = %d, ucERP = %02x, rRcpi = %d, rRssi = %ld\n",
1226 prBssInfo->fgIsERPPresent, prBssInfo->ucERP, prBssInfo->rRcpi, prBssInfo->rRssi));
1229 //4 <3> Update BSS_INFO_T from PEER_BSS_INFO_T & NIC RATE FUNC
1230 //4 <3.A> Association ID
1231 prBssInfo->u2AssocId = prPeerBssInfo->u2AssocId;
1233 //4 <3.B> WMM Infomation
1234 if (prAdapter->fgIsEnableWMM &&
1235 (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_SUPPORT_WMM)) {
1237 prBssInfo->fgIsWmmAssoc = TRUE;
1238 prTxCtrl->rTxQForVoipAccess = TXQ_AC3;
1240 qosWmmInfoInit(&prBssInfo->rWmmInfo, (prBssInfo->ePhyType == PHY_TYPE_HR_DSSS_INDEX) ? TRUE : FALSE);
1242 if (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_AC_PARAM_PRESENT) {
1243 kalMemCopy(&prBssInfo->rWmmInfo,
1244 &prPeerBssInfo->rWmmInfo,
1245 sizeof(WMM_INFO_T));
1248 kalMemCopy(&prBssInfo->rWmmInfo,
1249 &prPeerBssInfo->rWmmInfo,
1250 sizeof(WMM_INFO_T) - sizeof(prPeerBssInfo->rWmmInfo.arWmmAcParams));
1254 prBssInfo->fgIsWmmAssoc = FALSE;
1255 prTxCtrl->rTxQForVoipAccess = TXQ_AC1;
1257 kalMemZero(&prBssInfo->rWmmInfo, sizeof(WMM_INFO_T));
1261 //4 <3.C> Operational Rate Set & BSS Basic Rate Set
1262 prBssInfo->u2OperationalRateSet = prPeerBssInfo->u2OperationalRateSet;
1263 prBssInfo->u2BSSBasicRateSet = prPeerBssInfo->u2BSSBasicRateSet;
1266 //4 <3.D> Short Preamble
1267 if (prBssInfo->fgIsERPPresent) {
1269 /* NOTE(Kevin 2007/12/24): Truth Table.
1270 * Short Preamble Bit in
1271 * <AssocReq> <AssocResp w/i ERP> <BARKER(Long)> Final Driver Setting(Short)
1272 * TRUE FALSE FALSE FALSE(shouldn't have such case, use the AssocResp)
1273 * TRUE FALSE TRUE FALSE
1274 * FALSE FALSE FALSE FALSE(shouldn't have such case, use the AssocResp)
1275 * FALSE FALSE TRUE FALSE
1276 * TRUE TRUE FALSE TRUE(follow ERP)
1277 * TRUE TRUE TRUE FALSE(follow ERP)
1278 * FALSE TRUE FALSE FALSE(shouldn't have such case, and we should set to FALSE)
1279 * FALSE TRUE TRUE FALSE(we should set to FALSE)
1281 if ((prPeerBssInfo->fgIsShortPreambleAllowed) &&
1282 ((prConnSettings->ePreambleType == PREAMBLE_TYPE_SHORT) || /* Short Preamble Option Enable is TRUE */
1283 ((prConnSettings->ePreambleType == PREAMBLE_TYPE_AUTO) &&
1284 (prBssDesc->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)))) {
1286 prBssInfo->fgIsShortPreambleAllowed = TRUE;
1288 if (prBssInfo->ucERP & ERP_INFO_BARKER_PREAMBLE_MODE) {
1289 prBssInfo->fgUseShortPreamble = FALSE;
1292 prBssInfo->fgUseShortPreamble = TRUE;
1296 prBssInfo->fgIsShortPreambleAllowed = FALSE;
1297 prBssInfo->fgUseShortPreamble = FALSE;
1301 /* NOTE(Kevin 2007/12/24): Truth Table.
1302 * Short Preamble Bit in
1303 * <AssocReq> <AssocResp w/o ERP> Final Driver Setting(Short)
1307 * FALSE TRUE(status success) TRUE
1308 * --> Honor the result of prPeerBssInfo.
1311 prBssInfo->fgIsShortPreambleAllowed = prBssInfo->fgUseShortPreamble =
1312 prPeerBssInfo->fgIsShortPreambleAllowed;
1315 DBGLOG(JOIN, INFO, ("prBssInfo->fgIsShortPreambleAllowed = %d, prBssInfo->fgUseShortPreamble = %d\n",
1316 prBssInfo->fgIsShortPreambleAllowed, prBssInfo->fgUseShortPreamble));
1319 //4 <3.E> Short Slot Time
1320 prBssInfo->fgUseShortSlotTime =
1321 prPeerBssInfo->fgUseShortSlotTime; /* AP support Short Slot Time */
1323 DBGLOG(JOIN, INFO, ("prBssInfo->fgUseShortSlotTime = %d\n",
1324 prBssInfo->fgUseShortSlotTime));
1326 nicSetSlotTime(prAdapter,
1327 prBssInfo->ePhyType,
1328 ((prConnSettings->fgIsShortSlotTimeOptionEnable &&
1329 prBssInfo->fgUseShortSlotTime) ? TRUE : FALSE));
1332 //4 <3.F> Update Tx Rate for Control Frame
1333 bssUpdateTxRateForControlFrame(prAdapter);
1336 //4 <3.G> Save the available Auth Types during Roaming (Design for Fast BSS Transition).
1337 //if (prAdapter->fgIsEnableRoaming) /* NOTE(Kevin): Always prepare info for roaming */
1340 if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_OPEN_SYSTEM) {
1341 prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_OPEN_SYSTEM;
1343 else if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_SHARED_KEY) {
1344 prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_SHARED_KEY;
1347 prBssInfo->ucRoamingAuthTypes = prJoinInfo->ucRoamingAuthTypes;
1350 /* Set the stable time of the associated BSS. We won't do roaming decision
1351 * during the stable time.
1353 SET_EXPIRATION_TIME(prBssInfo->rRoamingStableExpirationTime,
1354 SEC_TO_SYSTIME(ROAMING_STABLE_TIMEOUT_SEC));
1358 //4 <3.H> Update Parameter for TX Fragmentation Threshold
1360 txFragInfoUpdate(prAdapter);
1361 #endif /* CFG_TX_FRAGMENT */
1364 //4 <4> Update STA_RECORD_T
1365 /* Get a Station Record if possible */
1366 prStaRec = staRecGetStaRecordByAddr(prAdapter,
1367 prBssDesc->aucBSSID);
1370 UINT_16 u2OperationalRateSet, u2DesiredRateSet;
1372 //4 <4.A> Desired Rate Set
1373 u2OperationalRateSet = (rPhyAttributes[prBssInfo->ePhyType].u2SupportedRateSet &
1374 prBssInfo->u2OperationalRateSet);
1376 u2DesiredRateSet = (u2OperationalRateSet & prConnSettings->u2DesiredRateSet);
1377 if (u2DesiredRateSet) {
1378 prStaRec->u2DesiredRateSet = u2DesiredRateSet;
1381 /* For Error Handling - The Desired Rate Set is not covered in Operational Rate Set. */
1382 prStaRec->u2DesiredRateSet = u2OperationalRateSet;
1385 /* Try to set the best initial rate for this entry */
1386 if (!rateGetBestInitialRateIndex(prStaRec->u2DesiredRateSet,
1388 &prStaRec->ucCurrRate1Index)) {
1390 if (!rateGetLowestRateIndexFromRateSet(prStaRec->u2DesiredRateSet,
1391 &prStaRec->ucCurrRate1Index)) {
1396 DBGLOG(JOIN, INFO, ("prStaRec->ucCurrRate1Index = %d\n",
1397 prStaRec->ucCurrRate1Index));
1399 //4 <4.B> Preamble Mode
1400 prStaRec->fgIsShortPreambleOptionEnable =
1401 prBssInfo->fgUseShortPreamble;
1404 prStaRec->fgIsQoS = prBssInfo->fgIsWmmAssoc;
1414 //4 <5.A> Update BSSID & Operation Mode
1415 nicSetupBSS(prAdapter, prBssInfo);
1417 //4 <5.B> Update WLAN Table.
1418 if (nicSetHwBySta(prAdapter, prStaRec) == FALSE) {
1422 //4 <5.C> Update Desired Rate Set for BT.
1424 if (prConnSettings->fgIsEnableTxAutoFragmentForBT) {
1425 txRateSetInitForBT(prAdapter, prStaRec);
1427 #endif /* CFG_TX_FRAGMENT */
1429 //4 <5.D> TX AC Parameter and TX/RX Queue Control
1430 if (prBssInfo->fgIsWmmAssoc) {
1432 #if CFG_TX_AGGREGATE_HW_FIFO
1433 nicTxAggregateTXQ(prAdapter, FALSE);
1434 #endif /* CFG_TX_AGGREGATE_HW_FIFO */
1436 qosUpdateWMMParametersAndAssignAllowedACI(prAdapter, &prBssInfo->rWmmInfo);
1440 #if CFG_TX_AGGREGATE_HW_FIFO
1441 nicTxAggregateTXQ(prAdapter, TRUE);
1442 #endif /* CFG_TX_AGGREGATE_HW_FIFO */
1444 nicTxNonQoSAssignDefaultAdmittedTXQ(prAdapter);
1446 nicTxNonQoSUpdateTXQParameters(prAdapter,
1447 prBssInfo->ePhyType);
1450 #if CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN
1452 prTxCtrl->fgBlockTxDuringJoin = FALSE;
1454 #if !CFG_TX_AGGREGATE_HW_FIFO /* TX FIFO AGGREGATE already do flush once */
1455 nicTxFlushStopQueues(prAdapter, (UINT_8)TXQ_DATA_MASK, (UINT_8)NULL);
1456 #endif /* CFG_TX_AGGREGATE_HW_FIFO */
1458 nicTxRetransmitOfSendWaitQue(prAdapter);
1460 if (prTxCtrl->fgIsPacketInOsSendQueue) {
1461 nicTxRetransmitOfOsSendQue(prAdapter);
1464 #if CFG_SDIO_TX_ENHANCE
1465 halTxLeftClusteredMpdu(prAdapter);
1466 #endif /* CFG_SDIO_TX_ENHANCE */
1469 #endif /* CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN */
1472 //4 <6> Setup CONNECTION flag.
1473 prAdapter->eConnectionState = MEDIA_STATE_CONNECTED;
1474 prAdapter->eConnectionStateIndicated = MEDIA_STATE_CONNECTED;
1476 if (prJoinInfo->fgIsReAssoc) {
1477 prAdapter->fgBypassPortCtrlForRoaming = TRUE;
1480 prAdapter->fgBypassPortCtrlForRoaming = FALSE;
1483 kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
1484 WLAN_STATUS_MEDIA_CONNECT,
1489 } /* end of joinComplete() */