// // Description: According to initial gain value to determine to enable or disable EDCCA. // // Suggested by SD3 Wilson. Added by tynli. 2011.11.25. // VOID Phydm_DynamicEDCCA( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PADAPTER pAdapter = pDM_Odm->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); u1Byte RegC50, RegC58; BOOLEAN bEDCCAenable = FALSE; #if (DM_ODM_SUPPORT_TYPE & ODM_WIN) BOOLEAN bFwCurrentInPSMode=FALSE; pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_FW_PSMODE_STATUS, (pu1Byte)(&bFwCurrentInPSMode)); // Disable EDCCA mode while under LPS mode, added by Roger, 2012.09.14. if(bFwCurrentInPSMode) return; #endif // // 2013/11/14 Ken According to BB team Jame's suggestion, we need to disable soft AP mode EDCCA. // 2014/01/08 MH For Miracst AP mode test. We need to disable EDCCA. Otherwise, we may stop // to send beacon in noisy environment or platform. // if(ACTING_AS_AP(pAdapter) || ACTING_AS_AP(GetFirstAPAdapter(pAdapter))) //if(ACTING_AS_AP(pAdapter)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("At least One Port as AP disable EDCCA\n")); Phydm_DisableEDCCA(pDM_Odm); if(pHalData->bPreEdccaEnable) Phydm_DisableEDCCA(pDM_Odm); pHalData->bPreEdccaEnable = FALSE; return; } RegC50 = (u1Byte)ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskByte0); RegC58 = (u1Byte)ODM_GetBBReg(pDM_Odm, rOFDM0_XBAGCCore1, bMaskByte0); if((RegC50 > 0x28 && RegC58 > 0x28) || ((pDM_Odm->SupportICType == ODM_RTL8723A && IS_WIRELESS_MODE_G(pAdapter) && RegC50>0x26)) || (pDM_Odm->SupportICType == ODM_RTL8188E && RegC50 > 0x28)) { if(!pHalData->bPreEdccaEnable) { Phydm_EnableEDCCA(pDM_Odm); pHalData->bPreEdccaEnable = TRUE; } } else if((RegC50 < 0x25 && RegC58 < 0x25) || (pDM_Odm->SupportICType == ODM_RTL8188E && RegC50 < 0x25)) { if(pHalData->bPreEdccaEnable) { Phydm_DisableEDCCA(pDM_Odm); pHalData->bPreEdccaEnable = FALSE; } } }
// Description: // Output: // Modify: void Authenticator_StateAUTHENTICATION( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_AUTHENTICATION; // [AnnieTODO] // 1. GNoStations ++ // 2. PTK = 0 PlatformZeroMemory( pSTA->perSTAKeyInfo.PTK, PTK_LEN); PlatformZeroMemory(pSTA->perSTAKeyInfo.AESKeyBuf, AESCCMP_BLK_SIZE_TOTAL); //pSTA->perSTAKeyInfo.bPTKInstalled = FALSE; pSTA->perSTAKeyInfo.PInitAKeys = FALSE; // 3. 802.1x::PortControl = Auto pSTA->perSTAKeyInfo.portControl = pct_Auto; // 4. 802.1x::PortMode = Enabled pSTA->perSTAKeyInfo.portMode = pmt_Enable; // UCT Authenticator_StateAUTHENTICATION2( Adapter, pSTA ); }
// Description: Disconnect the station // Output: void // Modify: Annie, 2005-07-12. void Authenticator_StateDISCONNECT( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA, IN u1Byte ReasonCode ) { PAUTH_PKEY_MGNT_TAG pKeyMgnt = &pSTA->perSTAKeyInfo; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_StateDISCONNECT()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_DISCONNECTE; if( AsocEntry_IsStationAssociated( &Adapter->MgntInfo, pSTA->MacAddr ) ) { RT_TRACE(COMP_AP, DBG_LOUD, ("Authenticator_StateDISCONNECT() \n")); AP_DisassociateStation(Adapter, pKeyMgnt->pWLanSTA, ReasonCode); } // UCT //Authenticator_StateDISCONNECTED(Adapter, pSTA); // I'll call it in AP_DisassociateStation(). Marked by Annie, 2005-07-15. }
// Description: // Output: // Modify: void Authenticator_StateKEYUPDATE( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_StateKEYUPDATE()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_KEYUPDATE; // [AnnieTODO] // ANonce = Counter ++; // GNonve = Counter ++; // UCT Authenticator_StatePTKSTART(Adapter, pSTA); }
// Description: // Output: // Modify: void Authenticator_StateKEYERROR( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA, IN u1Byte ReasonCode ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_StateKEYERROR()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.GrState = ASMGS_KEYERROR; // [AnnieTODO] GKeyDoneStations -- // UCT Authenticator_StateDISCONNECT( Adapter, pSTA, ReasonCode ); RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_StateKEYERROR()\n") ); }
// Description: // Output: // Modify: void Authenticator_StateREKEYESTABLISHED( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_StateREKEYESTABLISHED()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.GrState = ASMGS_REKEYESTABLISHED; // TODO: 1. Check MIC(PTK) // TODO: 2. GKeyDoneStations --; // 3. Timeout counter is reset by Authenticator_OnEAPOLKeyRecvd(). //pSTA->perSTAKeyInfo.TimeoutCtr ... we don't need to write it here. // 4. 802.1x::PortMode = 1; pSTA->perSTAKeyInfo.portMode = pmt_Enable; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_StateREKEYESTABLISHED()\n") ); }
// Description: // Output: // Modify: void Authenticator_StateAUTHENTICATION2( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_StateAUTHENTICATION2()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_AUTHENTICATION2; // ANonce = Counter ++ Adapter->MgntInfo.globalKeyInfo.ANonce[31] ++; //... [AnnieTODO] It needs a real addition! // PSK Authenticator_StatePTKSTART(Adapter, pSTA); RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_StateAUTHENTICATION2()\n") ); }
// Description: // Output: // Modify: void Authenticator_StateINTEGRITYFAILURE( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { #if 1 //Added by Jay 0713 for process integrity failure u8Byte DiffTimeSlot; PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo); #endif if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } //pSTA->perSTAKeyInfo.PrState = ASMPS_MICFAILURE; pSTA->perSTAKeyInfo.PrState = ASMPS_INTEGRITYFAILURE; // Modified by Annie, 2005-07-18. pSTA->perSTAKeyInfo.MicErrorCnt ++; // Added by Annie for debug, 2005-07-25. #if 1 //Added by Jay 0713 for process integrity failure //RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("IntegrityFail(): AP mode, TimeSlot_lastIntegrityFailed=%"i64fmt"d\n", pSTA->perSTAKeyInfo.TimeSlot_lastIntegrityFailed )); //RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("IntegrityFail(): AP mode, CurrentTimeSlot =%"i64fmt"d\n", pMgntInfo->globalKeyInfo.CurrentTimeSlot )); DiffTimeSlot = pMgntInfo->globalKeyInfo.CurrentTimeSlot - pSTA->perSTAKeyInfo.TimeSlot_lastIntegrityFailed; pSTA->perSTAKeyInfo.TimeSlot_lastIntegrityFailed = pMgntInfo->globalKeyInfo.CurrentTimeSlot; if(DiffTimeSlot > 60) { #if SUPPORT_WPA_VERSION_D3 //update the PTK with this STA and GTK with all STAs Authenticator_StateKEYUPDATE(Adapter, pSTA); #endif } else { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("IntegrityFail(): AP mode, disconnects all associated STAs\n")); // Rewrited by Annie: use AP_DisassociateAllStation(). 2005-07-18. AP_DisassociateAllStation( Adapter, mic_failure ); pMgntInfo->globalKeyInfo.TimeSlot_IntegrityFail2 = pMgntInfo->globalKeyInfo.CurrentTimeSlot; } #else // UCT Authenticator_StateKEYUPDATE(Adapter, pSTA); #endif }
BOOLEAN IsExtAPModeExist( PADAPTER Adapter ) { PADAPTER pAdapter = GetFirstExtAdapter(Adapter); while(pAdapter != NULL) { if(ACTING_AS_AP(pAdapter)) return TRUE; pAdapter = GetNextExtAdapter(pAdapter); } return FALSE; }
PADAPTER GetFirstAPAdapter( PADAPTER pAdapter ) { PADAPTER pDefaultAdapter = GetDefaultAdapter(pAdapter); PADAPTER pAPAdapter = pDefaultAdapter; while(pAPAdapter != NULL) { if(ACTING_AS_AP(pAPAdapter)) break; pAPAdapter = GetNextExtAdapter(pAPAdapter); } return pAPAdapter; }
// Description: // Output: // Modify: void Authenticator_StateUPDATEKEYS( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_StateUPDATEKEYS()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_UPDATEKEYS; Authenticator_StatePTKSTART(Adapter, pSTA); }
VOID WPS_ConstructBeaconFrame( IN PADAPTER Adapter ) { // // Simple config IE. by CCW - copy from 818x // PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo); PSIMPLE_CONFIG_T pSimpleConfig ; OCTET_STRING SimpleConfigInfo; PMGNT_INFO pDefaultMgntInfo; if(ACTING_AS_IBSS(Adapter)) return; if(!ACTING_AS_AP(Adapter)) return; pDefaultMgntInfo = &(GetDefaultAdapter(Adapter)->MgntInfo); pSimpleConfig = GET_SIMPLE_CONFIG(pDefaultMgntInfo); if( ((pSimpleConfig->WpsIeVersion < SUPPORT_WPS_INFO_VERSION) || (wps_IsWPSIEReady(Adapter) == FALSE)) && pSimpleConfig->IELen > 0) { // Original method carrying WPS IE RT_TRACE(COMP_WPS, DBG_TRACE, ("AP Construct Beacon \n")); FillOctetString(SimpleConfigInfo, pSimpleConfig->IEBuf, pSimpleConfig->IELen); PacketMakeElement( &pMgntInfo->beaconframe, EID_Vendor, SimpleConfigInfo); } else if(pSimpleConfig->WpsIeVersion == SUPPORT_WPS_INFO_VERSION) { FillOctetString(SimpleConfigInfo, pSimpleConfig->ieBeaconBuf, pSimpleConfig->ieBeaconLen); if(pSimpleConfig->ieBeaconLen > 0) PacketAppendData(&pMgntInfo->beaconframe, SimpleConfigInfo); } }
// Description: // Output: // Modify: void Authenticator_StateDISCONNECTED( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Authenticator_StateDISCONNECTED()\n") ); if(!ACTING_AS_AP(Adapter)) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_DISCONNECTED; // [AnnieTODO] GNoStations -- // [Note] We don't have to clear PMK, ANonce and GTK here. // UCT Authenticator_StateINITIALIZE(Adapter, pSTA); }
// Description: // Output: // Modify: void Authenticator_StateREKEYNEGOTIATING( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; PAUTH_GLOBAL_KEY_TAG pGlInfo = &pMgntInfo->globalKeyInfo; PAUTH_PKEY_MGNT_TAG pKeyMgnt = &pSTA->perSTAKeyInfo; u8Byte KeyReplayCounter = 0; u1Byte temp[8] = {0}; u1Byte indexi = 0; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_StateREKEYNEGOTIATING()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pKeyMgnt->GrState = ASMGS_REKEYNEGOTIATING; // [AnnieTODO] // 1. Construct 1st message in 2-way handshake. // EAPOL(1, 1, 1, !Pair, GN, G, GNonce, MIC(PTK), GTK[GN] ) // 2. Send 1st msg in 2-way handshake. pKeyMgnt->KeyReplayCounter ++; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Send 2-way message 1\n")); for( indexi = 0 ; indexi < 8 ; indexi++) temp[indexi] = (u1Byte)((pKeyMgnt->KeyReplayCounter >>( (7-indexi) *8)) &0xff ); PlatformMoveMemory( &KeyReplayCounter , temp , 8 ); SendEapolKeyPacket( Adapter, pSTA->MacAddr, pSTA->perSTAKeyInfo.PTK, // Pointer to KCK (EAPOL-Key Confirmation Key). pSTA->perSTAKeyInfo.PTK + 16, // [AnnieWorkaround] type_Group, // EAPOL-Key Information field: Key Type bit: type_Group or type_Pairwise. FALSE, // EAPOL-Key Information field: Install Flag. TRUE, // EAPOL-Key Information field: Key Ack bit. TRUE, // EAPOL-Key Information field: Key MIC bit. If true, we will calculate EAPOL MIC and fill it into Key MIC field. TRUE, // EAPOL-Key Information field: Secure bit. FALSE, // EAPOL-Key Information field: Error bit. True for MIC failure report. FALSE, // EAPOL-Key Information field: Requst bit. KeyReplayCounter,//pSTA->perSTAKeyInfo.KeyReplayCounter, // EAPOL-KEY Replay Counter field. pGlInfo->GNonce, // EAPOL-Key Key Nonce field (32-byte). pGlInfo->KeyRSC, // EAPOL-Key Key RSC field (8-byte). NULL, // Key Data field: Pointer to RSN IE, NULL if pGlInfo->GTK // Key Data field: Pointer to GTK, NULL if Key Data Length = 0. ); pKeyMgnt->TimeSlot_lastsend = pGlInfo->CurrentTimeSlot; // added by Annie, 2005-07-12. // [Note] Don't do pKeyMgnt->TimeoutCtr++ here! // The counter is controlled in KeyMgntTimeout. RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_StateREKEYNEGOTIATING()\n") ); }
// Description: Initialize the global key data in Authenticator. // Output: void // Modify: Annie, 2005-07-02 // I check the data struct again, and discard using pMgntInfo->globalKeyInfo.groupKeyInfo. // Now Global/group key data (PMK, GTK, ANonce): all kept in pMgntInfo->globalKeyInfo. // global key state: recorded in pEntry->perSTAKeyInfo.GrState. (I think it should be kept in per station.) // void Authenticator_GlobalReset( IN PADAPTER Adapter ) { PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; PRT_SECURITY_T pSecInfo = &(pMgntInfo->SecurityInfo); PAUTH_GLOBAL_KEY_TAG pGlInfo = &(pMgntInfo->globalKeyInfo); PRT_WLAN_STA pEntry; int i; u1Byte RdmBuf[20], NonceBuf[KEY_NONCE_LEN]; static u1Byte CAM_CONST_BROAD[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; AESCCMP_BLOCK blockKey; //--- [AnnieWorkaround] See 11i D3.0 page91, GTK should be generated by PRF-X. u1Byte TmpGTK[] = "12345678123456781234567812345678"; //--- RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_GlobalReset()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pGlInfo->currentId = 0; if(pSecInfo->SecLvl == RT_SEC_LVL_WPA) pGlInfo->DescriptorType = desc_type_RSN; else pGlInfo->DescriptorType = desc_type_WPA2; GetRandomBuffer( RdmBuf ); for( i=0; i<16; i++ ) { NonceBuf[i] = RdmBuf[i]; NonceBuf[16+i] = RdmBuf[19-i]; } NonceBuf[KEY_NONCE_LEN-1] = 0; //[AnnieWorkaround] Remove it if ANonce addition is ready. 2005-11-25. RT_PRINT_DATA( COMP_AUTHENTICATOR, DBG_LOUD, "Authenticator_GlobalReset(): NonceBuf", NonceBuf, KEY_NONCE_LEN ); // 1. Install PMK if( pGlInfo->PassphraseLen < 64 ){ PasswordHash(pGlInfo->Passphrase, pGlInfo->PassphraseLen, pMgntInfo->Ssid.Octet, pMgntInfo->Ssid.Length, pGlInfo->PMK ); } else { // Add for direct to set PMK 64-Hex mode... if( pGlInfo->PassphraseLen == 64 ) PlatformMoveMemory(pGlInfo->PMK, pGlInfo->Passphrase , 32 ); } // 2. Install GTK // // 2010/12/15 Neo Jou check in // When in Linux AP mode, hostapd will set down GTK before Authenticator_GlobalReset() // Thus for Linux AP mode case, we don't reset GTK here // PlatformZeroMemory( pGlInfo->GTK, GTK_LEN ); PlatformMoveMemory( pGlInfo->GTK, TmpGTK, GTK_LEN ); pGlInfo->TxMICKey = pGlInfo->GTK + GTK_MIC_TX_POS; pGlInfo->RxMICKey = pGlInfo->GTK + GTK_MIC_RX_POS; //AP WPA AES,CCW PlatformMoveMemory( blockKey.x , pGlInfo->GTK , 16); AES_SetKey(blockKey.x, AESCCMP_BLK_SIZE*8, (pu4Byte)pGlInfo->AESGTK); // pSecInfo->GroupTransmitKeyIdx = 1; // 3. Install ANonce // CopyMem( pGlInfo->ANonce, NonceBuf, KEY_NONCE_LEN ); PlatformMoveMemory(pGlInfo->ANonce, NonceBuf, KEY_NONCE_LEN ); // 4. Install GNonce // CopyMem( pGlInfo->GNonce, NonceBuf, KEY_NONCE_LEN ); PlatformMoveMemory(pGlInfo->GNonce, NonceBuf, KEY_NONCE_LEN ); // 5. Reset KeyRSC pGlInfo->KeyRSC = 0; // 6. Reset time slot. pGlInfo->CurrentTimeSlot = 0; #if 1 //Addedby Jay 0713 pGlInfo->TimeSlot_IntegrityFail2 = 0; #endif // 7. IV #if 1 //Added by Jay 0712 for security IV pSecInfo->TxIV = DEFAULT_INIT_TX_IV; #endif pMgntInfo->bAPGlobRest = TRUE; // Reset key information of each station. for(i = 0; i < ASSOCIATE_ENTRY_NUM; i++) { pEntry = &(pMgntInfo->AsocEntry[i]); Authenticator_StateINITIALIZE(Adapter, pEntry); } pMgntInfo->bAPGlobRest = FALSE; //reset SWCamTabe and HWCamtable ,add by CCW AP_ClearAllKey(Adapter); if( (MgntActQuery_ApType(Adapter) == RT_AP_TYPE_NORMAL || MgntActQuery_ApType(Adapter) == RT_AP_TYPE_IBSS_EMULATED || MgntActQuery_ApType(Adapter) == RT_AP_TYPE_LINUX) && ( pMgntInfo->NdisVersion < RT_NDIS_VERSION_6_20 )) { switch( pSecInfo->PairwiseEncAlgorithm ) { case RT_ENC_ALG_TKIP: AP_Setkey( Adapter , CAM_CONST_BROAD, 1, // Index entry CAM_TKIP, 1, // Set Group Key pGlInfo->GTK); break; case RT_ENC_ALG_AESCCMP: AP_Setkey( Adapter , CAM_CONST_BROAD, 1, // Index entry CAM_AES, 1, // Set Group Key pGlInfo->GTK); break; case RT_ENC_ALG_WEP40: case RT_ENC_ALG_WEP104: { static u1Byte CAM_CONST_ADDR[4][6] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}; u1Byte EncAlgo = ((pSecInfo->PairwiseEncAlgorithm == RT_ENC_ALG_WEP40) ? CAM_WEP40 : CAM_WEP104); for(i = 0; i < 4; i++) { if(pSecInfo->KeyLen[i] > 0) { AP_Setkey( Adapter , CAM_CONST_ADDR[i], i, // Index entry EncAlgo, 1, pSecInfo->KeyBuf[i]); } } } break; default: break; } } RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_GlobalReset()\n") ); }
void KeyMgntTimeout( PRT_TIMER pTimer ) { PADAPTER Adapter=(PADAPTER)pTimer->Adapter; PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; PAUTH_PKEY_MGNT_TAG pKeyMgnt; int i; int AsocNum = 0; PRT_WLAN_STA pEntry; if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning!!] KeyMgntTimeout(): STA mode\n")); return; } else { //RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("KeyMgntTimeout(): AP mode, CurrentTimeSlot=%d\n", pMgntInfo->globalKeyInfo.CurrentTimeSlot )); } if( pMgntInfo->SecurityInfo.AuthMode == RT_802_11AuthModeWPAPSK || pMgntInfo->SecurityInfo.AuthMode == RT_802_11AuthModeWPA2PSK || pMgntInfo->SecurityInfo.SecLvl == RT_SEC_LVL_WPA2) { // Query all stations' state and their timeout count. for( i=0; i<ASSOCIATE_ENTRY_NUM; i++ ) { if( !pMgntInfo->AsocEntry[i].bUsed ) continue; pKeyMgnt = &pMgntInfo->AsocEntry[i].perSTAKeyInfo; // Print Dbg Message. 2005-07-25, Annie.------------ AsocNum++; pEntry = pKeyMgnt->pWLanSTA; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[STA:%d] %02X-%02X-%02X-%02X-%02X-%02X, MicErrorCnt=%d, WEPErrorCnt=%d\n", i, pEntry->MacAddr[0], pEntry->MacAddr[1], pEntry->MacAddr[2], pEntry->MacAddr[3], pEntry->MacAddr[4], pEntry->MacAddr[5], pKeyMgnt->MicErrorCnt, pKeyMgnt->WEPErrorCnt ) ); //--------------------------------------------- if( KeyMgntStateIsWaitingEAPOLKey(pKeyMgnt) && pKeyMgnt->GrState != ASMGS_REKEYESTABLISHED ) { if( pKeyMgnt->TimeoutCtr >= MAX_TIMEOUT_CNT ) { pKeyMgnt->TimeoutCtr = 0; Authenticator_OnTimeoutCountExceeded(Adapter, pKeyMgnt); } else { if( pMgntInfo->globalKeyInfo.CurrentTimeSlot != pKeyMgnt->TimeSlot_lastsend ) // consider 1st retry should wait for at least 1 second. Annie, 2005-07-12. { //RT_TRACE(COMP_AUTHENTICATOR, DBG_LOUD, ("KeyMgntTimeout(): Retry! [TimeSlot:%"i64fmt"d, TimeoutCtr:%d]\n", // pMgntInfo->globalKeyInfo.CurrentTimeSlot, (int)pKeyMgnt->TimeoutCtr )); pKeyMgnt->TimeoutCtr ++; if( pKeyMgnt->PrState == ASMPS_PTKSTART ) // waiting for 2nd msg in 4-way handshake { Authenticator_StatePTKSTART(Adapter, &pMgntInfo->AsocEntry[i]); } else if( pKeyMgnt->PrState == ASMPS_PTKINITNEGOTIATING ) // waiting for 4th msg in 4-way handshake { Authenticator_StatePTKINITNEGOTIATING(Adapter, &pMgntInfo->AsocEntry[i]); } else if( pKeyMgnt->GrState == ASMGS_REKEYNEGOTIATING ) // waiting for 2nd msg in 2-way handshake { Authenticator_StateREKEYNEGOTIATING(Adapter, &pMgntInfo->AsocEntry[i]); } } else { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("KeyMgntTimeout(): equal TimeSlot. Not to retry.\n") ); } } } } //RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("KeyMgntTimeout: AsocNum=%d, CurrentTimeSlot=%"i64fmt"d\n", AsocNum, pMgntInfo->globalKeyInfo.CurrentTimeSlot ) ); // Continue setting the timer only when RT_802_11AuthModeWPAPSK. pMgntInfo->globalKeyInfo.CurrentTimeSlot ++; PlatformSetTimer( Adapter, &pMgntInfo->globalKeyInfo.KeyMgntTimer, KEY_MGNT_INTERVAL ); } }
VOID odm_DynamicPrimaryCCA( IN PDM_ODM_T pDM_Odm ) { PADAPTER Adapter = pDM_Odm->Adapter; // for NIC #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN)) PRT_WLAN_STA pEntry; #endif PFALSE_ALARM_STATISTICS FalseAlmCnt = (PFALSE_ALARM_STATISTICS)PhyDM_Get_Structure( pDM_Odm , PHYDM_FALSEALMCNT); pPri_CCA_T PrimaryCCA = &(pDM_Odm->DM_PriCCA); BOOLEAN Is40MHz; BOOLEAN Client_40MHz = FALSE, Client_tmp = FALSE; // connected client BW BOOLEAN bConnected = FALSE; // connected or not static u1Byte Client_40MHz_pre = 0; static u8Byte lastTxOkCnt = 0; static u8Byte lastRxOkCnt = 0; static u4Byte Counter = 0; static u1Byte Delay = 1; u8Byte curTxOkCnt; u8Byte curRxOkCnt; u1Byte SecCHOffset; u1Byte i; if(!(pDM_Odm->SupportAbility & ODM_BB_PRIMARY_CCA)) return; #if((DM_ODM_SUPPORT_TYPE==ODM_ADSL) ||( DM_ODM_SUPPORT_TYPE==ODM_CE)) return; #else if(pDM_Odm->SupportICType != ODM_RTL8188E) return; Is40MHz = *(pDM_Odm->pBandWidth); SecCHOffset = *(pDM_Odm->pSecChOffset); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Second CH Offset = %d\n", SecCHOffset)); #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if(Is40MHz==1) SecCHOffset = SecCHOffset%2+1; // NIC's definition is reverse to AP 1:secondary below, 2: secondary above ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Second CH Offset = %d\n", SecCHOffset)); //3 Check Current WLAN Traffic curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - lastTxOkCnt; curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - lastRxOkCnt; lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast; lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast; #elif (DM_ODM_SUPPORT_TYPE == ODM_AP) //3 Check Current WLAN Traffic curTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast)-lastTxOkCnt; curRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast)-lastRxOkCnt; lastTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast); lastRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast); #endif //==================Debug Message==================== ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("TP = %llu\n", curTxOkCnt+curRxOkCnt)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Is40MHz = %d\n", Is40MHz)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("BW_LSC = %d\n", FalseAlmCnt->Cnt_BW_LSC)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("BW_USC = %d\n", FalseAlmCnt->Cnt_BW_USC)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("CCA OFDM = %d\n", FalseAlmCnt->Cnt_OFDM_CCA)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("CCA CCK = %d\n", FalseAlmCnt->Cnt_CCK_CCA)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("OFDM FA = %d\n", FalseAlmCnt->Cnt_Ofdm_fail)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("CCK FA = %d\n", FalseAlmCnt->Cnt_Cck_fail)); //================================================ #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if (ACTING_AS_AP(Adapter)) // primary cca process only do at AP mode #endif { #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("ACTING as AP mode=%d\n", ACTING_AS_AP(Adapter))); //3 To get entry's connection and BW infomation status. for(i=0;i<ASSOCIATE_ENTRY_NUM;i++) { if(IsAPModeExist(Adapter)&&GetFirstExtAdapter(Adapter)!=NULL) pEntry=AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i); else pEntry=AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i); if(pEntry!=NULL) { Client_tmp = pEntry->BandWidth; // client BW ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Client_BW=%d\n", Client_tmp)); if(Client_tmp>Client_40MHz) Client_40MHz = Client_tmp; // 40M/20M coexist => 40M priority is High if(pEntry->bAssociated) { bConnected=TRUE; // client is connected or not break; } } else { break; } } #elif (DM_ODM_SUPPORT_TYPE == ODM_AP) //3 To get entry's connection and BW infomation status. PSTA_INFO_T pstat; for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) { pstat = pDM_Odm->pODM_StaInfo[i]; if(IS_STA_VALID(pstat) ) { Client_tmp = pstat->tx_bw; if(Client_tmp>Client_40MHz) Client_40MHz = Client_tmp; // 40M/20M coexist => 40M priority is High bConnected = TRUE; } } #endif ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("bConnected=%d\n", bConnected)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Is Client 40MHz=%d\n", Client_40MHz)); //1 Monitor whether the interference exists or not if(PrimaryCCA->Monitor_flag == 1) { if(SecCHOffset == 1) // secondary channel is below the primary channel { if((FalseAlmCnt->Cnt_OFDM_CCA > 500)&&(FalseAlmCnt->Cnt_BW_LSC > FalseAlmCnt->Cnt_BW_USC+500)) { if(FalseAlmCnt->Cnt_Ofdm_fail > FalseAlmCnt->Cnt_OFDM_CCA>>1) { PrimaryCCA->intf_type = 1; PrimaryCCA->PriCCA_flag = 1; ODM_SetBBReg(pDM_Odm, 0xc6c, BIT8|BIT7, 2); // USC MF if(PrimaryCCA->DupRTS_flag == 1) PrimaryCCA->DupRTS_flag = 0; } else { PrimaryCCA->intf_type = 2; if(PrimaryCCA->DupRTS_flag == 0) PrimaryCCA->DupRTS_flag = 1; } } else // interferecne disappear { PrimaryCCA->DupRTS_flag = 0; PrimaryCCA->intf_flag = 0; PrimaryCCA->intf_type = 0; } } else if(SecCHOffset == 2) // secondary channel is above the primary channel
void Authenticator_StateINITIALIZE( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { PAUTH_PKEY_MGNT_TAG pKeyMgnt = &pSTA->perSTAKeyInfo; u1Byte RdmBuf[20], NonceBuf[KEY_NONCE_LEN]; u1Byte i = 0; pKeyMgnt->pWLanSTA = pSTA; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_StateINITIALIZE()\n") ); if( !ACTING_AS_AP(Adapter) && !GET_TDLS_ENABLED(&(Adapter->MgntInfo)) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } PlatformZeroMemory( pKeyMgnt->SNonce, KEY_NONCE_LEN ); pKeyMgnt->TimeoutCtr = 0; pKeyMgnt->TimeSlot_sendstart = 0; pKeyMgnt->TimeSlot_lastsend = 0; if( Adapter->MgntInfo.SecurityInfo.AuthMode == RT_802_11AuthModeWPAPSK ) { // 3. 802.1x::PortMode = Disable; pKeyMgnt->portMode = pmt_Disable; // [TODO] other auth mode // 4. 802.1x::PortSecure = 0; pKeyMgnt->portSecure= psec_Unauthorized; // [TODO] other auth mode } // 1. MSK = 0 ...? // 2. GNoStations = 0 // ...it's for group key update. I don't do it currently. Annie, 2005-07-01. // Rest ANonce GetRandomBuffer( RdmBuf ); for( i=0; i<16; i++ ) { NonceBuf[i] = RdmBuf[i]; NonceBuf[16+i] = RdmBuf[19-i]; } PlatformMoveMemory( pKeyMgnt->ANonce , NonceBuf , KEY_NONCE_LEN ); // 5. RemovePTK PlatformZeroMemory( pKeyMgnt->PTK, PTK_LEN ); pKeyMgnt->TempEncKey = NULL; pKeyMgnt->TxMICKey = NULL; pKeyMgnt->RxMICKey = NULL; //AP-WPA AES ,CCW PlatformZeroMemory( pKeyMgnt->AESKeyBuf , AESCCMP_BLK_SIZE_TOTAL ); //pKeyMgnt->bPTKInstalled = FALSE; pKeyMgnt->PInitAKeys = FALSE; pKeyMgnt->GInitAKeys = FALSE; pKeyMgnt->Pair = TRUE; // [AnnieNote] Why not FALSE?? 2005-07-18. // TODO: 6. Revome key from CAM // [AnnieNote] // (1) We can only clear the MAC address (instead of total 6 double-word) in per CAM entry. // (2) When called by Authenticator_GlobalReset(), it takes a lot of I/O, and is H/W depended. // Should we do it here? Or use workitem... ? //Remove key from SW/HW CAM table, Add by CCW AP_RemoveKey( Adapter , pSTA ); // 7. Reset ReplayCounter pKeyMgnt->KeyReplayCounter = 0; // 8. Reset SNonce PlatformZeroMemory( pKeyMgnt->SNonce, KEY_NONCE_LEN ); // 9. Initialize TimeSlot_lastIntegrityFailed. pKeyMgnt->TimeSlot_lastIntegrityFailed = 0; pKeyMgnt->RxIV = DEFAULT_INIT_RX_IV; pKeyMgnt->TxIV = DEFAULT_INIT_TX_IV; pKeyMgnt->KeyRSC = pKeyMgnt->TxIV; // Added by Annie for debug, 2005-07-25. pKeyMgnt->MicErrorCnt = 0; pKeyMgnt->WEPErrorCnt = 0; pKeyMgnt->PrState = ASMPS_INITIALIZE; pKeyMgnt->GrState = ASMGS_INITIALIZE; pSTA->keyindex = 0; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_StateINITIALIZE()\n") ); }
VOID odm_DynamicTxPower_92C( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) PADAPTER Adapter = pDM_Odm->Adapter; PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); s4Byte UndecoratedSmoothedPWDB; // 2012/01/12 MH According to Luke's suggestion, only high power will support the feature. if (pDM_Odm->ExtPA == FALSE) return; // STA not connected and AP not connected if((!pMgntInfo->bMediaConnect) && (pHalData->EntryMinUndecoratedSmoothedPWDB == 0)) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("Not connected to any \n")); pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; //the LastDTPlvl should reset when disconnect, //otherwise the tx power level wouldn't change when disconnect and connect again. // Maddest 20091220. pHalData->LastDTPLvl=TxHighPwrLevel_Normal; return; } #if (INTEL_PROXIMITY_SUPPORT == 1) // Intel set fixed tx power if(pMgntInfo->IntelProximityModeInfo.PowerOutput > 0) { switch(pMgntInfo->IntelProximityModeInfo.PowerOutput){ case 1: pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_100\n")); break; case 2: pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_70; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_70\n")); break; case 3: pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_50; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_50\n")); break; case 4: pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_35; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_35\n")); break; case 5: pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_15; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_15\n")); break; default: pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_100\n")); break; } } else #endif { if( (pMgntInfo->bDynamicTxPowerEnable != TRUE) || (pHalData->DMFlag & HAL_DM_HIPWR_DISABLE) || pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; } else { if(pMgntInfo->bMediaConnect) // Default port { if(ACTING_AS_AP(Adapter) || ACTING_AS_IBSS(Adapter)) { UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } else { UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } } else // associated entry pwdb { UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n")); } else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) && (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) ) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); } else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5)) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n")); } } } if( pHalData->DynamicTxHighPowerLvl != pHalData->LastDTPLvl ) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192C() Channel = %d \n" , pHalData->CurrentChannel)); PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel); if( (pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Normal) && (pHalData->LastDTPLvl == TxHighPwrLevel_Level1 || pHalData->LastDTPLvl == TxHighPwrLevel_Level2)) //TxHighPwrLevel_Normal odm_DynamicTxPowerRestorePowerIndex(pDM_Odm); else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x14); else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x10); } pHalData->LastDTPLvl = pHalData->DynamicTxHighPowerLvl; #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) #if (RTL8192C_SUPPORT==1) PADAPTER Adapter = pDM_Odm->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &pHalData->dmpriv; struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; int UndecoratedSmoothedPWDB; if(!pdmpriv->bDynamicTxPowerEnable) return; #ifdef CONFIG_INTEL_PROXIM if(Adapter->proximity.proxim_on== _TRUE){ struct proximity_priv *prox_priv=Adapter->proximity.proximity_priv; // Intel set fixed tx power printk("\n %s Adapter->proximity.proxim_on=%d prox_priv->proxim_modeinfo->power_output=%d \n",__FUNCTION__,Adapter->proximity.proxim_on,prox_priv->proxim_modeinfo->power_output); if(prox_priv!=NULL){ if(prox_priv->proxim_modeinfo->power_output> 0) { switch(prox_priv->proxim_modeinfo->power_output) { case 1: pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_100; printk("TxHighPwrLevel_100\n"); break; case 2: pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_70; printk("TxHighPwrLevel_70\n"); break; case 3: pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_50; printk("TxHighPwrLevel_50\n"); break; case 4: pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_35; printk("TxHighPwrLevel_35\n"); break; case 5: pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_15; printk("TxHighPwrLevel_15\n"); break; default: pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_100; printk("TxHighPwrLevel_100\n"); break; } } } } else #endif { // STA not connected and AP not connected if((check_fwstate(pmlmepriv, _FW_LINKED) != _TRUE) && (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)) { //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("Not connected to any \n")); pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; //the LastDTPlvl should reset when disconnect, //otherwise the tx power level wouldn't change when disconnect and connect again. // Maddest 20091220. pdmpriv->LastDTPLvl=TxHighPwrLevel_Normal; return; } if(check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) // Default port { #if 0 //todo: AP Mode if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE)) { UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } else { UndecoratedSmoothedPWDB = pdmpriv->UndecoratedSmoothedPWDB; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } #else UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB; #endif } else // associated entry pwdb { UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n")); } else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) && (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) ) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); } else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5)) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n")); } } if( (pdmpriv->DynamicTxHighPowerLvl != pdmpriv->LastDTPLvl) ) { PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel); if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Normal) // HP1 -> Normal or HP2 -> Normal odm_DynamicTxPowerRestorePowerIndex(pDM_Odm); else if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x14); else if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x10); } pdmpriv->LastDTPLvl = pdmpriv->DynamicTxHighPowerLvl; #endif #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) }
// Description: // Output: // Modify: void Authenticator_StatePTKINITDONE( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { PAUTH_PKEY_MGNT_TAG pKeyMgnt = &pSTA->perSTAKeyInfo; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_StatePTKINITDONE()\n") ); // TODO: SetKey to CAM if( !ACTING_AS_AP(Adapter)) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_PTKINITDONE; // TODO: Check SetKey completed, these lines were moved from Authenticator_OnEAPOLKeyRecvd() by Jay if (pSTA->perSTAKeyInfo.Pair) { u4Byte ucIndex = 0; CopyMem(pSTA->perSTAKeyInfo.PTK, pSTA->perSTAKeyInfo.PTK_update, PTK_LEN); // Added by Annie, 2005-07-12. if( Adapter->MgntInfo.SecurityInfo.PairwiseEncAlgorithm != RT_ENC_ALG_AESCCMP ) { pSTA->perSTAKeyInfo.TempEncKey = pKeyMgnt->PTK+TKIP_ENC_KEY_POS; pSTA->perSTAKeyInfo.TxMICKey = pKeyMgnt->PTK+(TKIP_MIC_KEY_POS); pSTA->perSTAKeyInfo.RxMICKey = pKeyMgnt->PTK+(TKIP_MIC_KEY_POS+TKIP_MIC_KEY_LEN); //Add for AP mode HW enc,by CCW ucIndex = AP_FindFreeEntry(Adapter , pSTA->MacAddr ); if(ucIndex == Adapter->TotalCamEntry) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] Authenticator_StatePTKINITDONE: Cam Entry is FULL!!!\n")); return; } //set key AP_Setkey( Adapter , pSTA->perSTAKeyInfo.pWLanSTA->MacAddr, ucIndex, // Entey index CAM_TKIP, 0, // Parise key pSTA->perSTAKeyInfo.TempEncKey); pSTA->keyindex = ucIndex; }else{ // AES mode AP-WPA AES,CCW AESCCMP_BLOCK blockKey; //RT_TRACE( COMP_WPAAES, DBG_LOUD, ("====> Set Station Key.")); //Add for AP mode HW enc,by CCW ucIndex = AP_FindFreeEntry(Adapter , pSTA->MacAddr); if(ucIndex == Adapter->TotalCamEntry) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] Authenticator_StatePTKINITDONE: Cam Entry is FULL!!!\n")); return; } //Set Key PlatformMoveMemory( blockKey.x , pKeyMgnt->PTK+TKIP_ENC_KEY_POS , 16); AES_SetKey(blockKey.x, AESCCMP_BLK_SIZE*8, (pu4Byte)pSTA->perSTAKeyInfo.AESKeyBuf); //set hw key AP_Setkey( Adapter , pSTA->perSTAKeyInfo.pWLanSTA->MacAddr, ucIndex, // Entey index CAM_AES, 0, // Parise key pSTA->perSTAKeyInfo.PTK+TKIP_ENC_KEY_POS); pSTA->keyindex = ucIndex; } } //pSTA->perSTAKeyInfo.bPTKInstalled = TRUE; pSTA->perSTAKeyInfo.GInitAKeys = TRUE; pSTA->perSTAKeyInfo.PInitAKeys = TRUE; // Begin 2-way handshake if( Adapter->MgntInfo.SecurityInfo.SecLvl == RT_SEC_LVL_WPA ) Authenticator_StateREKEYNEGOTIATING(Adapter, pSTA); // To do 2-way if( Adapter->MgntInfo.SecurityInfo.SecLvl == RT_SEC_LVL_WPA2 ) { Authenticator_StateREKEYESTABLISHED(Adapter, pSTA); // No to do 2-way pKeyMgnt->TimeoutCtr = 0; } RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_StatePTKINITDONE()\n") ); }
// Description: // Output: // Modify: void Authenticator_StatePTKINITNEGOTIATING( IN PADAPTER Adapter, IN PRT_WLAN_STA pSTA ) { PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; PAUTH_GLOBAL_KEY_TAG pGlInfo = &pMgntInfo->globalKeyInfo; PAUTH_PKEY_MGNT_TAG pKeyMgnt = &pSTA->perSTAKeyInfo; u8Byte KeyReplayCounter = 0; u1Byte temp[8] = {0}; u1Byte indexi = 0; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("===> Authenticator_StatePTKINITNEGOTIATING()\n") ); if( !ACTING_AS_AP(Adapter) ) { RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("[Warning] current: STA mode, return.")); return; } pSTA->perSTAKeyInfo.PrState = ASMPS_PTKINITNEGOTIATING; // [AnnieTODO] // 1. Construct 3rd message in 4-way handshake. // EAPOL(0, 1, 1, Pair,0, P, ANonce, MIC(PTK_update), 0) // 2. Send 3rd msg pKeyMgnt->KeyReplayCounter ++; RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("Send 4-way message 3\n")); //RT_TRACE(COMP_AUTHENTICATOR, DBG_LOUD , (" KeyReplayCounter = %08"i64fmt"x \n",pKeyMgnt->KeyReplayCounter )); for( indexi = 0 ; indexi < 8 ; indexi++) temp[indexi] = (u1Byte)((pKeyMgnt->KeyReplayCounter >>( (7-indexi) *8)) &0xff ); PlatformMoveMemory( &KeyReplayCounter , temp , 8 ); if( pMgntInfo->SecurityInfo.SecLvl == RT_SEC_LVL_WPA ) { SendEapolKeyPacket( Adapter, pSTA->MacAddr, pSTA->perSTAKeyInfo.PTK_update, // Pointer to KCK (EAPOL-Key Confirmation Key). pSTA->perSTAKeyInfo.PTK_update + 16, type_Pairwise, // EAPOL-Key Information field: Key Type bit: type_Group or type_Pairwise. TRUE, // EAPOL-Key Information field: Install Flag. TRUE, // EAPOL-Key Information field: Key Ack bit. TRUE, // EAPOL-Key Information field: Key MIC bit. If true, we will calculate EAPOL MIC and fill it into Key MIC field. FALSE, // EAPOL-Key Information field: Secure bit. FALSE, // EAPOL-Key Information field: Error bit. True for MIC failure report. FALSE, // EAPOL-Key Information field: Requst bit. KeyReplayCounter, //pSTA->perSTAKeyInfo.KeyReplayCounter, // EAPOL-KEY Replay Counter field. pKeyMgnt->ANonce, // EAPOL-Key Key Nonce field (32-byte). pSTA->perSTAKeyInfo.KeyRSC, // perSTA EAPOL-Key Key RSC field (8-byte). &(pMgntInfo->SecurityInfo.RSNIE), // Key Data field: Pointer to RSN IE, NULL if NULL // Key Data field: Pointer to GTK, NULL if Key Data Length = 0. ); } else if( pMgntInfo->SecurityInfo.SecLvl == RT_SEC_LVL_WPA2 ) { SendEapolKeyPacket( Adapter, pSTA->MacAddr, pSTA->perSTAKeyInfo.PTK_update, // Pointer to KCK (EAPOL-Key Confirmation Key). pSTA->perSTAKeyInfo.PTK_update + 16, type_Pairwise, // EAPOL-Key Information field: Key Type bit: type_Group or type_Pairwise. TRUE, // EAPOL-Key Information field: Install Flag. TRUE, // EAPOL-Key Information field: Key Ack bit. TRUE, // EAPOL-Key Information field: Key MIC bit. If true, we will calculate EAPOL MIC and fill it into Key MIC field. TRUE, // EAPOL-Key Information field: Secure bit. FALSE, // EAPOL-Key Information field: Error bit. True for MIC failure report. FALSE, // EAPOL-Key Information field: Requst bit. KeyReplayCounter,//pSTA->perSTAKeyInfo.KeyReplayCounter, // EAPOL-KEY Replay Counter field. pKeyMgnt->ANonce, // EAPOL-Key Key Nonce field (32-byte). pSTA->perSTAKeyInfo.KeyRSC, // perSTA EAPOL-Key Key RSC field (8-byte). &(pMgntInfo->SecurityInfo.RSNIE), // Key Data field: Pointer to RSN IE, NULL if pGlInfo->GTK // Key Data field: Pointer to GTK, NULL if Key Data Length = 0. ); } pKeyMgnt->TimeSlot_lastsend = pGlInfo->CurrentTimeSlot; // Added by Annie, 2005-07-12. // [Note] Don't do pSTA->perSTAKeyInfo.TimeoutCtr++ here! // The counter is controlled in KeyMgntTimeout. RT_TRACE( COMP_AUTHENTICATOR, DBG_LOUD, ("<=== Authenticator_StatePTKINITNEGOTIATING()\n") ); }
VOID odm_DynamicTxPower_92D( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) PADAPTER Adapter = pDM_Odm->Adapter; PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); s4Byte UndecoratedSmoothedPWDB; PADAPTER BuddyAdapter = Adapter->BuddyAdapter; BOOLEAN bGetValueFromBuddyAdapter = dm_DualMacGetParameterFromBuddyAdapter(Adapter); u1Byte HighPowerLvlBackForMac0 = TxHighPwrLevel_Level1; // 2012/01/12 MH According to Luke's suggestion, only high power will support the feature. if (pDM_Odm->ExtPA == FALSE) return; // If dynamic high power is disabled. if( (pMgntInfo->bDynamicTxPowerEnable != TRUE) || (pHalData->DMFlag & HAL_DM_HIPWR_DISABLE) || pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; return; } // STA not connected and AP not connected if((!pMgntInfo->bMediaConnect) && (pHalData->EntryMinUndecoratedSmoothedPWDB == 0)) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("Not connected to any \n")); pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; //the LastDTPlvl should reset when disconnect, //otherwise the tx power level wouldn't change when disconnect and connect again. // Maddest 20091220. pHalData->LastDTPLvl=TxHighPwrLevel_Normal; return; } if(pMgntInfo->bMediaConnect) // Default port { if(ACTING_AS_AP(Adapter) || pMgntInfo->mIbss) { UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } else { UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } } else // associated entry pwdb { UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } if(IS_HARDWARE_TYPE_8192D(Adapter) && GET_HAL_DATA(Adapter)->CurrentBandType == 1){ if(UndecoratedSmoothedPWDB >= 0x33) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n")); } else if((UndecoratedSmoothedPWDB <0x33) && (UndecoratedSmoothedPWDB >= 0x2b) ) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); } else if(UndecoratedSmoothedPWDB < 0x2b) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Normal\n")); } } else { if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n")); } else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) && (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) ) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); } else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5)) { pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n")); } } //sherry delete flag 20110517 if(bGetValueFromBuddyAdapter) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 1 \n")); if(Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() change value \n")); HighPowerLvlBackForMac0 = pHalData->DynamicTxHighPowerLvl; pHalData->DynamicTxHighPowerLvl = Adapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP; PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel); pHalData->DynamicTxHighPowerLvl = HighPowerLvlBackForMac0; Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = FALSE; } } if( (pHalData->DynamicTxHighPowerLvl != pHalData->LastDTPLvl) ) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192S() Channel = %d \n" , pHalData->CurrentChannel)); if(Adapter->DualMacSmartConcurrent == TRUE) { if(BuddyAdapter == NULL) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter == NULL case \n")); if(!Adapter->bSlaveOfDMSP) { PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel); } } else { if(pHalData->MacPhyMode92D == DUALMAC_SINGLEPHY) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMSP \n")); if(Adapter->bSlaveOfDMSP) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() bslave case \n")); BuddyAdapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = TRUE; BuddyAdapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP = pHalData->DynamicTxHighPowerLvl; } else { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() master case \n")); if(!bGetValueFromBuddyAdapter) { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 0 \n")); PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel); } } } else { ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_TXPWR,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMDP\n")); PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel); } } } else { PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel); } } pHalData->LastDTPLvl = pHalData->DynamicTxHighPowerLvl; #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) #if (RTL8192D_SUPPORT==1) PADAPTER Adapter = pDM_Odm->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); struct dm_priv *pdmpriv = &pHalData->dmpriv; DM_ODM_T *podmpriv = &pHalData->odmpriv; int UndecoratedSmoothedPWDB; #if (RTL8192D_EASY_SMART_CONCURRENT == 1) PADAPTER BuddyAdapter = Adapter->BuddyAdapter; BOOLEAN bGetValueFromBuddyAdapter = DualMacGetParameterFromBuddyAdapter(Adapter); u8 HighPowerLvlBackForMac0 = TxHighPwrLevel_Level1; #endif // If dynamic high power is disabled. if( (pdmpriv->bDynamicTxPowerEnable != _TRUE) || (!(podmpriv->SupportAbility& ODM_BB_DYNAMIC_TXPWR)) ) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; return; } // STA not connected and AP not connected if((check_fwstate(pmlmepriv, _FW_LINKED) != _TRUE) && (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)) { //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("Not connected to any \n")); pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; //the LastDTPlvl should reset when disconnect, //otherwise the tx power level wouldn't change when disconnect and connect again. // Maddest 20091220. pdmpriv->LastDTPLvl=TxHighPwrLevel_Normal; return; } if(check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) // Default port { #if 0 //todo: AP Mode if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE)) { UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } else { UndecoratedSmoothedPWDB = pdmpriv->UndecoratedSmoothedPWDB; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } #else UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB; #endif } else // associated entry pwdb { UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB)); } #if TX_POWER_FOR_5G_BAND == 1 if(pHalData->CurrentBandType92D == BAND_ON_5G){ if(UndecoratedSmoothedPWDB >= 0x33) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n")); } else if((UndecoratedSmoothedPWDB <0x33) && (UndecoratedSmoothedPWDB >= 0x2b) ) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); } else if(UndecoratedSmoothedPWDB < 0x2b) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Normal\n")); } } else #endif { if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n")); } else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) && (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) ) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); } else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5)) { pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n")); } } #if (RTL8192D_EASY_SMART_CONCURRENT == 1) if(bGetValueFromBuddyAdapter) { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 1 \n")); if(Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP) { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() change value \n")); HighPowerLvlBackForMac0 = pHalData->DynamicTxHighPowerLvl; pHalData->DynamicTxHighPowerLvl = Adapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP; PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel); pHalData->DynamicTxHighPowerLvl = HighPowerLvlBackForMac0; Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = _FALSE; } } #endif if( (pdmpriv->DynamicTxHighPowerLvl != pdmpriv->LastDTPLvl) ) { //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192S() Channel = %d \n" , pHalData->CurrentChannel)); #if (RTL8192D_EASY_SMART_CONCURRENT == 1) if(BuddyAdapter == NULL) { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter == NULL case \n")); if(!Adapter->bSlaveOfDMSP) { PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel); } } else { if(pHalData->MacPhyMode92D == DUALMAC_SINGLEPHY) { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMSP \n")); if(Adapter->bSlaveOfDMSP) { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() bslave case \n")); BuddyAdapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = _TRUE; BuddyAdapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP = pHalData->DynamicTxHighPowerLvl; } else { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() master case \n")); if(!bGetValueFromBuddyAdapter) { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 0 \n")); PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel); } } } else { //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMDP\n")); PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel); } } #else PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel); #endif } pdmpriv->LastDTPLvl = pdmpriv->DynamicTxHighPowerLvl; #endif #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) }
VOID CHNL_ChangeBwChnlFromPeerWorkitemCallBack( IN PVOID Context ) { PADAPTER Adapter = (PADAPTER)Context; CHANNEL_WIDTH ChnlBW; EXTCHNL_OFFSET ExtChnlOffset; PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; PRT_CHANNEL_INFO pChnlInfo = GET_CHNL_INFO(pMgntInfo); PADAPTER pExtAdapter = GetFirstAPAdapter(Adapter); PADAPTER pGoAdapter = GetFirstGOPort(Adapter); if(pExtAdapter != NULL) { if(pExtAdapter->bAPChannelInprogressForNewconnected) { RT_DISP(FCHNL, FCHNL_ERROR, ("%s: AP change channel in progress , return \n", __FUNCTION__)); return; } } if(pGoAdapter != NULL) { if(pGoAdapter->bAPChannelInprogressForNewconnected) { RT_DISP(FCHNL, FCHNL_ERROR, ("%s: AP change channel in progress , return \n", __FUNCTION__)); return; } } if(GetDefaultMgntInfo(Adapter)->RegMultiChannelFcsMode != 0) { if(TRUE == MultiChannel_IsFCSInProgress(Adapter)) { RT_TRACE(COMP_MULTICHANNEL, DBG_TRACE, ("CHNL_ChangeBwChnlFromPeerWorkitemCallBack(): skip change ch & bw due to MCC\n")); return; } } #if 0 if(GetDefaultAdapter(Adapter)->bInHctTest) { RT_DISP(FCHNL, FCHNL_ERROR, ("%s: hct test , return \n", __FUNCTION__)); return; } #endif chnl_GetBWFrom_IE(Adapter, &ChnlBW, &ExtChnlOffset); if( pChnlInfo->CurrentChannelBandWidth != ChnlBW || pChnlInfo->Ext20MHzChnlOffsetOf40MHz != ExtChnlOffset) { // // Leave LPS and wait until RF is already on before switching channel. 2014.09.25, by tynli. // LPSLeaveAndCheckReady(Adapter); RT_TRACE(COMP_MLME, DBG_LOUD, ("CHNL_ChangeBwChnlFromPeerWorkitemCallBack(): CurrentChannel=%d, ChnlBW=%d, ExtChnlOffset=%d\n", pMgntInfo->dot11CurrentChannelNumber, ChnlBW, ExtChnlOffset)); CHNL_SetBwChnl(Adapter, pMgntInfo->dot11CurrentChannelNumber, ChnlBW, ExtChnlOffset); // We should set RA H2C cmd because the BW in TxDesc will be filled again by Fw, we // need to inform Fw the BW changed information. 2012.11.26. by tynli. // Suggested by SD1 Alex Chou. if(!ACTING_AS_AP(Adapter) && !ACTING_AS_IBSS(Adapter)) { // we only need to set rate mask Adapter->HalFunc.UpdateHalRAMaskHandler(Adapter, pMgntInfo->mMacId, NULL, 0); } } }