VOID ODM_delay_us(IN u4Byte us) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) delay_us(us); #elif(DM_ODM_SUPPORT_TYPE & ODM_CE) rtw_udelay_os(us); #elif(DM_ODM_SUPPORT_TYPE & ODM_MP) PlatformStallExecution(us); #endif }
// // ODM Timer relative API. // VOID ODM_StallExecution( IN u4Byte usDelay ) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) #elif(DM_ODM_SUPPORT_TYPE & ODM_CE) #elif(DM_ODM_SUPPORT_TYPE & ODM_MP) PlatformStallExecution(usDelay); #endif }
// // ODM Timer relative API. // void ODM_StallExecution( u32 usDelay ) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) #elif(DM_ODM_SUPPORT_TYPE & ODM_CE) rtw_udelay_os(usDelay); #elif(DM_ODM_SUPPORT_TYPE & ODM_MP) PlatformStallExecution(usDelay); #endif }
// Description: According received EAPOL-key, enter the next state. // Output: void // Modify: Annie, 2005-07-02 // Discard using condition pKeyMgnt->bPTKInstalled. // Instead, I add a macro KeyMgntStateIsWaitingEAPOLKey to check the state. void Authenticator_OnEAPOLKeyRecvd( IN PADAPTER Adapter, IN PAUTH_PKEY_MGNT_TAG pKeyMgnt, IN OCTET_STRING pdu ) { PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; PAUTH_GLOBAL_KEY_TAG pGlInfo = &pMgntInfo->globalKeyInfo; PRT_WLAN_STA pEntry = pKeyMgnt->pWLanSTA; pu1Byte pSTA_addr = Frame_pSaddr(pdu); pu1Byte pAP_addr = Frame_pDaddr(pdu); PEAPOL_KEY_STRUCT eapol_key_recvd; OCTET_STRING SNonce; OCTET_STRING RSNIE; MsgType msg_type = type_unknow; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_OnEAPOLKeyRecvd()\n") ); pKeyMgnt->EvntID = ASMEID_EAPOLKeyRecvd; FillOctetString(pGlInfo->EapolKeyMsgRecvd, \ pGlInfo->EAPOLMsgRecvd.Octet+LIB1X_EAPOL_HDRLEN, \ pGlInfo->EAPOLMsgRecvd.Length-LIB1X_EAPOL_HDRLEN ); \ eapol_key_recvd = (PEAPOL_KEY_STRUCT)pGlInfo->EapolKeyMsgRecvd.Octet; //PRINT_DATA( ("EapolKeyMsgRecvd: "), pGlInfo->EapolKeyMsgRecvd.Octet, pGlInfo->EapolKeyMsgRecvd.Length); RSNIE.Octet = NULL; RSNIE.Length = 0; // Get the message number. if( Message_KeyType(pGlInfo->EapolKeyMsgRecvd) == type_Pairwise ) { if( (Message_Error(pGlInfo->EapolKeyMsgRecvd) == 1) && (Message_Request(pGlInfo->EapolKeyMsgRecvd) == 1)) { //Enter integrity failure state... Authenticator_StateINTEGRITYFAILURE(Adapter, pEntry); } if( (eapol_key_recvd->key_info[0]==0x01 && eapol_key_recvd->key_info[1]==0x09) || ( eapol_key_recvd->key_info[0]==0x01 && eapol_key_recvd->key_info[1]==0x0a) || ( eapol_key_recvd->key_info[0]==0x03 && eapol_key_recvd->key_info[1]==0x0a) || ( eapol_key_recvd->key_info[0]==0x03 && eapol_key_recvd->key_info[1]==0x09) ) { if( pMgntInfo->SecurityInfo.SecLvl == RT_SEC_LVL_WPA) RSNIE = EAPOLkeyGetRSNIE( pGlInfo->EapolKeyMsgRecvd, EID_Vendor ); else if( pMgntInfo->SecurityInfo.SecLvl == RT_SEC_LVL_WPA2) RSNIE = EAPOLkeyGetRSNIE( pGlInfo->EapolKeyMsgRecvd, EID_WPA2 ); if( RSNIE.Length != 0 ) msg_type = type_4way2nd; // with RSNIE: msg 2 (159 or 161) else msg_type = type_4way4th; // msg 4 (135) } else { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("unknow pairwise EAPOL-key: info=0x%X-0x%X\n", eapol_key_recvd->key_info[0], eapol_key_recvd->key_info[1]) ); } } else { // [AnnieNote] Windows zero-config may send 2-way message as 03-01. // //if( eapol_key_recvd->key_info[0]==0x03 && eapol_key_recvd->key_info[1]==0x11 ) // if group key index is fixed 1, key information is 03-11. // msg_type = type_2way2nd; // group key msg2 (155) //else // RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("unknow group EAPOL-key: info=0x%X-0x%X\n", eapol_key_recvd->key_info[0], eapol_key_recvd->key_info[1]) ); msg_type = type_2way2nd; } // Check state. if( KeyMgntStateIsWaitingEAPOLKey(pKeyMgnt) ) { if( (pKeyMgnt->PrState==ASMPS_PTKSTART && msg_type==type_4way2nd ) || ( pKeyMgnt->PrState==ASMPS_PTKINITNEGOTIATING && msg_type==type_4way2nd )) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Recvd 4-way message 2\n")); pKeyMgnt->TimeoutCtr = 0; // AnnieTODO: if (1)k is pairwise and (2)MICVerified , then enter ASMPS_PTKINITNEGOTIATING state // TODO: MIC Verify SNonce = Message_KeyNonce( pGlInfo->EapolKeyMsgRecvd ); CopyMem( pKeyMgnt->SNonce, SNonce.Octet, KEY_NONCE_LEN ); CalcPTK( pAP_addr, pSTA_addr, pKeyMgnt->ANonce, pKeyMgnt->SNonce, pGlInfo->PMK, PMK_LEN, pKeyMgnt->PTK_update, PTK_LEN ); if(!CheckEapolMIC(Adapter , pGlInfo->EAPOLMsgRecvd , pKeyMgnt->PTK_update , KEY_MIC_LEN )) { SendDeauthentication( Adapter, pSTA_addr , mic_failure ); PlatformStallExecution(100); RT_TRACE_F(COMP_AP, DBG_TRACE, ("AsocEntry_RemoveStation\n")); AsocEntry_RemoveStation( Adapter , pSTA_addr); RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("MIC erroe\n")); return; } Authenticator_StatePTKINITNEGOTIATING(Adapter, pEntry); } else if( pKeyMgnt->PrState==ASMPS_PTKINITNEGOTIATING && msg_type==type_4way4th ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Recvd 4-way message 4\n")); pKeyMgnt->TimeoutCtr = 0; // if (1)k is pairwise and (2)MICVerified , then enter ASMPS_PTKINITDONE state if(!CheckEapolMIC(Adapter , pGlInfo->EAPOLMsgRecvd , pKeyMgnt->PTK_update , KEY_MIC_LEN )) { SendDeauthentication( Adapter, pSTA_addr , mic_failure ); PlatformStallExecution(100); RT_TRACE_F(COMP_AP, DBG_TRACE, ("AsocEntry_RemoveStation case 2\n")); AsocEntry_RemoveStation( Adapter , pSTA_addr); RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("MIC erroe\n")); return; } PlatformMoveMemory(&pEntry->perSTAKeyInfo.RxIV, &((PEAPOL_KEY_STRUCT)eapol_key_recvd)->key_rsc[0], 6); pEntry->perSTAKeyInfo.RxIV &= UINT64_C(0x0000ffffffffffff); //RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("pEntry->perSTAKeyInfo.RxIV = 0x%16"i64fmt"x", pEntry->perSTAKeyInfo.RxIV)); Authenticator_StatePTKINITDONE(Adapter, pEntry); } else if( pKeyMgnt->GrState == ASMGS_REKEYNEGOTIATING && msg_type==type_2way2nd ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Recvd 2-way message 2\n")); pKeyMgnt->TimeoutCtr = 0; // if (1)k is group and (2)MICVerified , then enter ASMGS_REKEYESTABLISHED state // 2012/01/17 CCW If 4-way check is ok, we need not to check 2-way again. /* if(!CheckEapolMIC(Adapter , pGlInfo->EAPOLMsgRecvd , pKeyMgnt->PTK_update , KEY_MIC_LEN )) { SendDeauthentication( Adapter, pSTA_addr , mic_failure ); PlatformStallExecution(100); AsocEntry_RemoveStation( Adapter , pSTA_addr); RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("MIC erroe\n")); return; } */ Authenticator_StateREKEYESTABLISHED(Adapter, pEntry); } else { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_OnEAPOLKeyRecvd(): Unexpected case: PrState=%d, GrState=%d, msg_type=%d\n", pKeyMgnt->PrState, pKeyMgnt->GrState, msg_type ) ); } } else { RT_TRACE(COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_OnEAPOLKeyRecvd(): Unexpected State!!\n")); RT_TRACE(COMP_AUTHENTICATOR, DBG_LOUD, ("--- TimeoutCounter:%d, PairwiseKeyState:%d, GroupKeyState:%d ---\n", pKeyMgnt->TimeoutCtr, pKeyMgnt->PrState, pKeyMgnt->GrState)); } RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_OnEAPOLKeyRecvd()\n") ); }
u1Byte //bit0 = 1 => Tx OK, bit1 = 1 => Rx OK phy_PathA_IQK_8192C( IN PADAPTER pAdapter, IN BOOLEAN configPathB ) { u4Byte regEAC, regE94, regE9C, regEA4; u1Byte result = 0x00; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); RTPRINT(FINIT, INIT_IQK, ("Path A IQK!\n")); //path-A IQK setting RTPRINT(FINIT, INIT_IQK, ("Path-A IQK setting!\n")); if(pAdapter->interfaceIndex == 0) { PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1f); PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f); } else { PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x10008c22); PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x10008c22); } PHY_SetBBReg(pAdapter, rTx_IQK_PI_A, bMaskDWord, 0x82140102); PHY_SetBBReg(pAdapter, rRx_IQK_PI_A, bMaskDWord, configPathB ? 0x28160202 : IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)?0x28160202:0x28160502); //path-B IQK setting if(configPathB) { PHY_SetBBReg(pAdapter, rTx_IQK_Tone_B, bMaskDWord, 0x10008c22); PHY_SetBBReg(pAdapter, rRx_IQK_Tone_B, bMaskDWord, 0x10008c22); PHY_SetBBReg(pAdapter, rTx_IQK_PI_B, bMaskDWord, 0x82140102); if(IS_HARDWARE_TYPE_8192D(pAdapter)) PHY_SetBBReg(pAdapter, rRx_IQK_PI_B, bMaskDWord, 0x28160206); else PHY_SetBBReg(pAdapter, rRx_IQK_PI_B, bMaskDWord, 0x28160202); } //LO calibration setting RTPRINT(FINIT, INIT_IQK, ("LO calibration setting!\n")); if(IS_HARDWARE_TYPE_8192D(pAdapter)) PHY_SetBBReg(pAdapter, rIQK_AGC_Rsp, bMaskDWord, 0x00462911); else PHY_SetBBReg(pAdapter, rIQK_AGC_Rsp, bMaskDWord, 0x001028d1); //One shot, path A LOK & IQK RTPRINT(FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); PHY_SetBBReg(pAdapter, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); PHY_SetBBReg(pAdapter, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); // delay x ms RTPRINT(FINIT, INIT_IQK, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME)); PlatformStallExecution(IQK_DELAY_TIME*1000); // Check failed regEAC = PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_A_2, bMaskDWord); RTPRINT(FINIT, INIT_IQK, ("0xeac = 0x%x\n", regEAC)); regE94 = PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_A, bMaskDWord); RTPRINT(FINIT, INIT_IQK, ("0xe94 = 0x%x\n", regE94)); regE9C= PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord); RTPRINT(FINIT, INIT_IQK, ("0xe9c = 0x%x\n", regE9C)); regEA4= PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_A_2, bMaskDWord); RTPRINT(FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regEA4)); if(!(regEAC & BIT28) && (((regE94 & 0x03FF0000)>>16) != 0x142) && (((regE9C & 0x03FF0000)>>16) != 0x42) ) result |= 0x01; else //if Tx not OK, ignore Rx return result;