From 72d78a19f5ecc7dad622422b8cff90dce34aaaee Mon Sep 17 00:00:00 2001 From: Christian B Date: Tue, 19 Dec 2017 19:46:30 +0100 Subject: [PATCH 01/12] Code cleanup --- hal/rtl8814a/rtl8814a_hal_init.c | 890 +++++++++++-------------------- 1 file changed, 322 insertions(+), 568 deletions(-) diff --git a/hal/rtl8814a/rtl8814a_hal_init.c b/hal/rtl8814a/rtl8814a_hal_init.c index 1135b1a..0d11da6 100644 --- a/hal/rtl8814a/rtl8814a_hal_init.c +++ b/hal/rtl8814a/rtl8814a_hal_init.c @@ -84,13 +84,11 @@ s32 InitLLTTable8814A( tmp1byte = rtw_read8(Adapter, REG_AUTO_LLT_8814A); rtw_write8(Adapter, REG_AUTO_LLT_8814A, tmp1byte|BIT0); - while(tmp1byte & BIT0) - { + while (tmp1byte & BIT0) { tmp1byte = rtw_read8(Adapter, REG_AUTO_LLT_8814A); rtw_mdelay_os(100); testcnt++; - if(testcnt > 100) - { + if (testcnt > 100) { Status = _FAIL; break; } @@ -133,8 +131,7 @@ _FWDownloadEnable_8814A( u8 tmp; u16 u2Tmp = 0; - if(enable) - { + if (enable) { // MCU firmware download enable. u2Tmp = rtw_read16(Adapter, REG_8051FW_CTRL_8814A); u2Tmp &= 0x3000; @@ -192,31 +189,31 @@ _BlockWrite_8814A( } //3 Phase #2 - if(remainSize_p1){ + if (remainSize_p1) { offset = blockCount_p1 * blockSize_p1; blockCount_p2=remainSize_p1/blockSize_p2; remainSize_p2=remainSize_p1%blockSize_p2; - if(blockCount_p2) + if (blockCount_p2) RT_TRACE(COMP_INIT,DBG_LOUD,("_BlockWrite_8814A[P2] ::buffSize_p2( %d) blockSize_p2( %d) blockCount_p2( %d) remainSize_p2( %d)\n",(buffSize-offset), blockSize_p2 ,blockCount_p2, remainSize_p2)); #if (DEV_BUS_TYPE == RT_USB_INTERFACE) - for(i = 0 ; i < blockCount_p2 ; i++){ + for (i = 0 ; i < blockCount_p2 ; i++){ rtw_writeN(Adapter, (FW_START_ADDRESS + offset+i*blockSize_p2), blockSize_p2,(bufferPtr + offset+i*blockSize_p2)); } #endif } //3 Phase #3 - if(remainSize_p2) { + if (remainSize_p2) { offset=(blockCount_p1 * blockSize_p1)+(blockCount_p2*blockSize_p2); blockCount_p3 = remainSize_p2 /blockSize_p3; RT_TRACE(COMP_INIT,DBG_LOUD,("_BlockWrite_8814A[P3] ::buffSize_p3( %d) blockSize_p3( %d) blockCount_p3( %d) \n",(buffSize-offset),blockSize_p3, blockCount_p3)); - for(i = 0 ; i < blockCount_p3 ; i++) { + for (i = 0 ; i < blockCount_p3 ; i++) { rtw_write8(Adapter, (FW_START_ADDRESS + offset + i), *(bufferPtr +offset+ i)); } } @@ -249,8 +246,7 @@ _FillDummy_8814A( u8 remain = (u8)(FwLen%4); remain = (remain==0)?0:(4-remain); - while(remain>0) - { + while (remain>0) { pFwBuf[FwLen] = 0; FwLen++; remain--; @@ -282,12 +278,12 @@ _WriteFW_8814A( remainSize = size % MAX_PAGE_SIZE; - for(page = 0; page < pageNums; page++){ + for (page = 0; page < pageNums; page++) { offset = page *MAX_PAGE_SIZE; _PageWrite_8814A(Adapter,page, (bufferPtr+offset),MAX_PAGE_SIZE); rtw_udelay_os(2); } - if(remainSize){ + if (remainSize) { offset = pageNums *MAX_PAGE_SIZE; page = pageNums; _PageWrite_8814A(Adapter,page, (bufferPtr+offset),remainSize); @@ -335,12 +331,10 @@ IDDMADownLoadFW_3081( u1Byte tmp; //check if ddma ch0 is idle cnt=20; - while(rtw_read32(Adapter, REG_DDMA_CH0CTRL)&DDMA_CH_OWN) - { + while (rtw_read32(Adapter, REG_DDMA_CH0CTRL)&DDMA_CH_OWN) { rtw_udelay_os(1000); cnt--; - if(cnt==0) - { + if (cnt==0) { RTW_INFO("IDDMADownLoadFW_3081, line%d: CNT fail\n", __LINE__); return _FALSE; } @@ -348,7 +342,7 @@ IDDMADownLoadFW_3081( ch0ctrl |= length & DDMA_LEN_MASK; //check if chksum continuous - if(fs == _FALSE){ + if (fs == _FALSE) { ch0ctrl |= DDMA_CH_CHKSUM_CNT; } rtw_write32(Adapter,REG_DDMA_CH0SA, source); @@ -356,54 +350,40 @@ IDDMADownLoadFW_3081( rtw_write32(Adapter,REG_DDMA_CH0CTRL, ch0ctrl); cnt=20; - while(rtw_read32(Adapter, REG_DDMA_CH0CTRL)&DDMA_CH_OWN) - { + while (rtw_read32(Adapter, REG_DDMA_CH0CTRL)&DDMA_CH_OWN) { rtw_udelay_os(1000); cnt--; - if(cnt==0) - { + if (cnt==0) { RTW_INFO("IDDMADownLoadFW_3081, line%d: CNT fail\n", __LINE__); return _FALSE; } } //check checksum - if(ls == _TRUE) - { + if (ls == _TRUE) { tmp = rtw_read8(Adapter,REG_8051FW_CTRL_8814A); - if(0==(rtw_read32(Adapter,REG_DDMA_CH0CTRL)&DDMA_CHKSUM_FAIL)) - {//chksum ok + if (0==(rtw_read32(Adapter,REG_DDMA_CH0CTRL)&DDMA_CHKSUM_FAIL)) { //chksum ok RTW_INFO("Check sum OK\n"); //imem - if(dest < OCPBASE_DMEM_3081) - { + if (dest < OCPBASE_DMEM_3081) { tmp |= IMEM_DL_RDY; rtw_write8(Adapter,REG_8051FW_CTRL_8814A, tmp|IMEM_CHKSUM_OK); RTW_INFO("imem check sum tmp %d\n",tmp); - } - //dmem - else - { + } else { //dmem tmp |= DMEM_DL_RDY; rtw_write8(Adapter,REG_8051FW_CTRL_8814A, tmp|DMEM_CHKSUM_OK); RTW_INFO("dmem check sum tmp %d\n",tmp); } - } - else - {//chksum fail + } else {//chksum fail RTW_INFO("Check sum fail\n"); ch0ctrl=rtw_read32(Adapter,REG_DDMA_CH0CTRL); rtw_write32(Adapter, REG_DDMA_CH0CTRL,ch0ctrl|DDMA_RST_CHKSUM_STS); //imem - if(dest < OCPBASE_DMEM_3081) - { + if (dest < OCPBASE_DMEM_3081) { tmp &= (~IMEM_DL_RDY); rtw_write8(Adapter,REG_8051FW_CTRL_8814A, tmp&~IMEM_CHKSUM_OK); - } - //dmem - else - { + } else { //dmem tmp &= (~DMEM_DL_RDY); rtw_write8(Adapter,REG_8051FW_CTRL_8814A, tmp&~DMEM_CHKSUM_OK); } @@ -413,7 +393,6 @@ IDDMADownLoadFW_3081( return _TRUE; } - //add by ylb 20130814 for 3081 download FW static BOOLEAN @@ -429,8 +408,7 @@ WaitDownLoadRSVDPageOK_3081( //Polling Beacon Queue to send Beacon TxBcReg = rtw_read8(Adapter, REG_MGQ_TXBD_NUM_8814A+3); count=0; - while(( count <20) && (TxBcReg & BIT4)) - { + while (( count <20) && (TxBcReg & BIT4)) { count++; rtw_udelay_os(10); TxBcReg = rtw_read8(Adapter, REG_MGQ_TXBD_NUM_8814A+3); @@ -441,21 +419,17 @@ WaitDownLoadRSVDPageOK_3081( // check rsvd page download OK. BcnValidReg = rtw_read8(Adapter, REG_FIFOPAGE_CTRL_2_8814A+1); count=0; - while(!(BcnValidReg & BIT7) && count <20) - { + while (!(BcnValidReg & BIT7) && count <20) { count++; rtw_udelay_os(50); BcnValidReg = rtw_read8(Adapter, REG_FIFOPAGE_CTRL_2_8814A+1); } //Set 1 to Clear BIT7 by SW - if(BcnValidReg & BIT7) - { + if (BcnValidReg & BIT7) { rtw_write8(Adapter, REG_FIFOPAGE_CTRL_2_8814A+1, (BcnValidReg|BIT7)); bRetValue = _TRUE; - } - else - { + } else { RTW_INFO("WaitDownLoadRSVDPageOK_3081(): Download RSVD page failed!\n"); bRetValue = _FALSE; } @@ -463,7 +437,6 @@ WaitDownLoadRSVDPageOK_3081( return bRetValue; } - VOID SetDownLoadFwRsvdPagePkt_8814A( IN PADAPTER Adapter, @@ -550,8 +523,7 @@ HalROMDownloadFWRSVDPage8814A( tmpReg422 = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL_8814A+2); rtw_write8(Adapter, REG_FWHW_TXQ_CTRL_8814A+2, tmpReg422&(~BIT6)); - if(tmpReg422&BIT6) - { + if (tmpReg422&BIT6) { RTW_INFO("HalROMDownloadFWRSVDPage8814A(): There is an Adapter is sending beacon.\n"); bSendBeacon = _TRUE; } @@ -574,8 +546,7 @@ HalROMDownloadFWRSVDPage8814A( dmem_pkt_size += (u32)FW_CHKSUM_DUMMY_SZ; iram_pkt_size += (u32)FW_CHKSUM_DUMMY_SZ; - if(dmem_pkt_size + iram_pkt_size + FWHeaderSize != Len) - { + if (dmem_pkt_size + iram_pkt_size + FWHeaderSize != Len) { RTW_INFO("ERROR: Fw Hdr size do not match the real fw size!!\n"); RTW_INFO("dmem_pkt_size = %d, iram_pkt_size = %d,FWHeaderSize = %d, Len = %d!!\n",dmem_pkt_size,iram_pkt_size,FWHeaderSize,Len); return; @@ -595,17 +566,14 @@ HalROMDownloadFWRSVDPage8814A( BeaconHeaderInTxPacketBuf = txpktbuf_bndy * PageSize; MEMOffsetInTxPacketBuf = OCPBASE_TXBUF_3081 + BeaconHeaderInTxPacketBuf + 40;//TX_INFO_SIZE_8814AE; //download DMEM - while(dmem_pkt_size > 0) - { - if(dmem_pkt_size > MaxRsvdPageBufSize) - { + while (dmem_pkt_size > 0) { + if (dmem_pkt_size > MaxRsvdPageBufSize) { filesize_ram_block = MaxRsvdPageBufSize; ls = _FALSE; last_block_size = dmem_pkt_size -MaxRsvdPageBufSize; - if(last_block_size < MaxRsvdPageBufSize) - { - if(((last_block_size + 40) & 0x3F) == 0) // Multiples of 64 + if (last_block_size < MaxRsvdPageBufSize) { + if (((last_block_size + 40) & 0x3F) == 0) // Multiples of 64 filesize_ram_block -=4; } } else { @@ -618,8 +586,7 @@ HalROMDownloadFWRSVDPage8814A( //RTW_INFO("%d packet offset %d dmem_pkt_size %d\n", __LINE__,pkt_offset, dmem_pkt_size); SetDownLoadFwRsvdPagePkt_8814A(Adapter, pbuffer+FWHeaderSize+pkt_offset, filesize_ram_block); bDownLoadRSVDPageOK = WaitDownLoadRSVDPageOK_3081(Adapter); - if(!bDownLoadRSVDPageOK) - { + if (!bDownLoadRSVDPageOK) { RTW_INFO("ERROR: DMEM bDownLoadRSVDPageOK is false!!\n"); return; } @@ -631,17 +598,14 @@ HalROMDownloadFWRSVDPage8814A( //download IRAM pkt_offset = 0; - while(iram_pkt_size > 0) - { - if(iram_pkt_size > MaxRsvdPageBufSize) - { + while (iram_pkt_size > 0) { + if (iram_pkt_size > MaxRsvdPageBufSize) { filesize_ram_block = MaxRsvdPageBufSize; ls = _FALSE; last_block_size = iram_pkt_size -MaxRsvdPageBufSize; - if(last_block_size < MaxRsvdPageBufSize) - { - if(((last_block_size + 40) & 0x3F) == 0) // Multiples of 64 + if (last_block_size < MaxRsvdPageBufSize) { + if (((last_block_size + 40) & 0x3F) == 0) // Multiples of 64 filesize_ram_block -=4; } } else { @@ -656,8 +620,7 @@ HalROMDownloadFWRSVDPage8814A( SetDownLoadFwRsvdPagePkt_8814A(Adapter, pbuffer+Len-iram_pkt_size, filesize_ram_block); bDownLoadRSVDPageOK = WaitDownLoadRSVDPageOK_3081(Adapter); - if(!bDownLoadRSVDPageOK) - { + if (!bDownLoadRSVDPageOK) { RTW_INFO("ERROR: IRAM bDownLoadRSVDPageOK is false!!\n"); return; } @@ -677,8 +640,7 @@ HalROMDownloadFWRSVDPage8814A( // prevent from setting 0x422[6] to 0 after download reserved page, or it will cause // the beacon cannot be sent by HW. // 2010.06.23. Added by tynli. - if(bSendBeacon) - { + if (bSendBeacon) { rtw_write8(Adapter, REG_FWHW_TXQ_CTRL_8814A+2, tmpReg422); } @@ -691,10 +653,8 @@ HalROMDownloadFWRSVDPage8814A( } u1bTmp=rtw_read8(Adapter, REG_8051FW_CTRL_8814A); //add by gw for flags to show the fw download ok 20130826 - if( u1bTmp&DMEM_CHKSUM_OK) - { - if(u1bTmp&IMEM_CHKSUM_OK) - { + if ( u1bTmp&DMEM_CHKSUM_OK) { + if (u1bTmp&IMEM_CHKSUM_OK) { u1Byte tem; tem=rtw_read8(Adapter, REG_8051FW_CTRL_8814A+1); rtw_write8(Adapter, REG_8051FW_CTRL_8814A+1,(tem|BIT6)); @@ -756,27 +716,23 @@ FirmwareDownload8814A( RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __FUNCTION__)); pFirmware = (PRT_FIRMWARE_8814)rtw_zmalloc(sizeof(RT_FIRMWARE_8814)); - if(!pFirmware) - { + if (!pFirmware) { rtStatus = _FAIL; goto exit; } #ifdef CONFIG_FILE_FWIMG - if(rtw_is_file_readable(rtw_fw_file_path) == _TRUE) - { + if (rtw_is_file_readable(rtw_fw_file_path) == _TRUE) { RTW_INFO("%s accquire FW from file:%s\n", __FUNCTION__, rtw_fw_file_path); pFirmware->eFWSource = FW_SOURCE_IMG_FILE; - } - else + } else #endif //CONFIG_FILE_FWIMG { RTW_INFO("%s fw source from Header\n", __FUNCTION__); pFirmware->eFWSource = FW_SOURCE_HEADER_FILE; } - switch(pFirmware->eFWSource) - { + switch (pFirmware->eFWSource) { case FW_SOURCE_IMG_FILE: #ifdef CONFIG_FILE_FWIMG rtStatus = rtw_retrieve_from_file(rtw_fw_file_path, FwBuffer8814, FW_SIZE); @@ -1102,8 +1058,7 @@ int _WriteBTFWtoTxPktBuf8812( // Acquice TX spin lock before GetFwBuf and send the packet to prevent system deadlock. // Advertised by Roger. Added by tynli. 2010.02.22. PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK); - if(MgntGetFWBuffer(Adapter, &pTcb, &pBuf)) - { + if(MgntGetFWBuffer(Adapter, &pTcb, &pBuf)) { PlatformMoveMemory(pBuf->Buffer.VirtualAddress, ReservedPagePacket, TotalPktLen); CmdSendPacket(Adapter, pTcb, pBuf, TotalPktLen, DESC_PACKET_TYPE_NORMAL, _FALSE); } @@ -1141,8 +1096,7 @@ int _WriteBTFWtoTxPktBuf8812( #if 1 // check rsvd page download OK. BcnValidReg = rtw_read8(Adapter, REG_TDECTRL+2); - while(!(BcnValidReg & BIT(0)) && count <200) - { + while (!(BcnValidReg & BIT(0)) && count <200) { count++; //PlatformSleepUs(10); rtw_msleep_os(1); @@ -1154,17 +1108,16 @@ int _WriteBTFWtoTxPktBuf8812( rtw_write8(Adapter, REG_TDECTRL+2,BcnValidReg); - }while((!(BcnValidReg&BIT(0))) && DLBcnCount<5); + } while ((!(BcnValidReg&BIT(0))) && DLBcnCount<5); #endif - if(DLBcnCount >=5){ + if(DLBcnCount >=5) { RTW_INFO(" check rsvd page download OK DLBcnCount =%d \n",DLBcnCount); rtStatus = _FAIL; goto exit; } - if(!(BcnValidReg&BIT(0))) - { + if(!(BcnValidReg&BIT(0))) { RTW_INFO("_WriteFWtoTxPktBuf(): 1 Download RSVD page failed!\n"); rtStatus = _FAIL; goto exit; @@ -1174,7 +1127,6 @@ int _WriteBTFWtoTxPktBuf8812( // 4. Set Tx boundary to the initial value //--------------------------------------------------------- - //--------------------------------------------------------- // 5. Reset beacon setting to the initial value. // After _CheckWLANFwPatchBTFwReady(). @@ -1182,8 +1134,7 @@ int _WriteBTFWtoTxPktBuf8812( exit: - if(pGenBufReservedPagePacket) - { + if(pGenBufReservedPagePacket) { RTW_INFO("_WriteBTFWtoTxPktBuf8723B => rtw_mfree pGenBufReservedPagePacket!\n"); rtw_mfree((u8*)pGenBufReservedPagePacket, TotalPktLen); } @@ -1214,22 +1165,20 @@ int ReservedPage_Compare(PADAPTER Adapter,PRT_MP_FIRMWARE pFirmware,u32 BTPatchS rtw_write8(Adapter,0x106,0x69); - for(i=0;i<(BTPatchSize/8);i++) - { + for(i=0;i<(BTPatchSize/8);i++) { rtw_write32(Adapter,0x140,address_start+5+i) ; //polling until reg 0x140[23]=1; - do{ + do { u1bTmp = rtw_read32(Adapter, 0x140); - if(u1bTmp&BIT(23)) - { + if(u1bTmp&BIT(23)) { ret = _SUCCESS; break; } count++; RTW_INFO("0x140=%x, wait for 10 ms (%d) times.\n",u1bTmp, count); rtw_msleep_os(10); // 10ms - }while(!(u1bTmp&BIT(23)) && count < 50); + } while(!(u1bTmp&BIT(23)) && count < 50); myBTFwBuffer[i*8+0]=rtw_read8(Adapter, 0x144); myBTFwBuffer[i*8+1]=rtw_read8(Adapter, 0x145); @@ -1248,36 +1197,31 @@ int ReservedPage_Compare(PADAPTER Adapter,PRT_MP_FIRMWARE pFirmware,u32 BTPatchS //polling until reg 0x140[23]=1; u1bTmp=0; count=0; - do{ + do { u1bTmp = rtw_read32(Adapter, 0x140); - if(u1bTmp&BIT(23)) - { + if(u1bTmp&BIT(23)) { ret = _SUCCESS; break; } count++; RTW_INFO("0x140=%x, wait for 10 ms (%d) times.\n",u1bTmp, count); rtw_msleep_os(10); // 10ms - }while(!(u1bTmp&BIT(23)) && count < 50); + } while (!(u1bTmp&BIT(23)) && count < 50); - for(i=0;iszFwBuffer[i]) - { + for(i=0;iszFwBuffer[i]) { RTW_INFO(" In direct myBTFwBuffer[%d]=%x , pFirmware->szFwBuffer=%x\n",i, myBTFwBuffer[i],pFirmware->szFwBuffer[i]); Adapter->mppriv.bTxBufCkFail=_TRUE; break; } } - if (myBTFwBuffer != NULL) - { + if (myBTFwBuffer != NULL) { rtw_mfree(myBTFwBuffer, BTPatchSize); } @@ -1307,15 +1251,13 @@ s32 FirmwareDownloadBT(PADAPTER padapter, PRT_MP_FIRMWARE pFirmware) } #ifdef CONFIG_FILE_FWIMG - if (rtw_is_file_readable(rtw_fw_mp_bt_file_path) == _TRUE) - { + if (rtw_is_file_readable(rtw_fw_mp_bt_file_path) == _TRUE) { RTW_INFO("%s: accquire MP BT FW from file:%s\n", __FUNCTION__, rtw_fw_mp_bt_file_path); rtStatus = rtw_retrieve_from_file(rtw_fw_mp_bt_file_path, FwBuffer, 0x8000); BTFirmwareLen = rtStatus>=0?rtStatus:0; pBTFirmwareBuf = FwBuffer; - } - else + } else #endif // CONFIG_FILE_FWIMG { #ifdef CONFIG_EMBEDDED_FWIMG @@ -1337,21 +1279,16 @@ s32 FirmwareDownloadBT(PADAPTER padapter, PRT_MP_FIRMWARE pFirmware) RTW_INFO("%s: download_time is %d\n", __FUNCTION__, download_time); // Download BT patch Fw. - for (i = (download_time-1); i >= 0; i--) - { - if (i == (download_time - 1)) - { + for (i = (download_time-1); i >= 0; i--) { + if (i == (download_time - 1)) { rtStatus = _WriteBTFWtoTxPktBuf8812(padapter, pBTFirmwareBuf+(4096*i), (BTFirmwareLen-(4096*i)), 1); RTW_INFO("%s: start %d, len %d, time 1\n", __FUNCTION__, 4096*i, BTFirmwareLen-(4096*i)); - } - else - { + } else { rtStatus = _WriteBTFWtoTxPktBuf8812(padapter, pBTFirmwareBuf+(4096*i), 4096, (download_time-i)); RTW_INFO("%s: start %d, len 4096, time %d\n", __FUNCTION__, 4096*i, download_time-i); } - if (rtStatus != _SUCCESS) - { + if (rtStatus != _SUCCESS) { RTW_INFO("%s: BT Firmware download to Tx packet buffer fail!\n", __FUNCTION__); padapter->bBTFWReady = _FALSE; return rtStatus; @@ -1392,7 +1329,7 @@ SetFwRelatedForWoWLAN8812( // 1. Before WoWLAN we need to re-download WoWLAN Fw. // status = FirmwareDownload8812(padapter, bHostIsGoingtoSleep); - if(status != _SUCCESS) { + if (status != _SUCCESS) { RTW_INFO("SetFwRelatedForWoWLAN8812(): Re-Download Firmware failed!!\n"); return; } else { @@ -1416,8 +1353,7 @@ hal_GetChnlGroup8814A( { BOOLEAN bIn24G=_TRUE; - if(Channel <= 14) - { + if (Channel <= 14) { bIn24G=_TRUE; if (1 <= Channel && Channel <= 2 ) *pGroup = 0; @@ -1425,14 +1361,13 @@ hal_GetChnlGroup8814A( else if (6 <= Channel && Channel <= 8 ) *pGroup = 2; else if (9 <= Channel && Channel <= 11) *pGroup = 3; else if (12 <= Channel && Channel <= 14) *pGroup = 4; - else - { + else { RT_DISP(FPHY, PHY_TXPWR_EFUSE, ("==>hal_GetChnlGroupJaguar in 2.4 G, but Channel %d in Group not found \n", Channel)); } } else { bIn24G=_FALSE; - if (36 <= Channel && Channel <= 42) *pGroup = 0; // 36 38 40 + if (36 <= Channel && Channel <= 42) *pGroup = 0; // 36 38 40 else if (44 <= Channel && Channel <= 48) *pGroup = 1; // 44 46 48 else if (50 <= Channel && Channel <= 58) *pGroup = 2; // 52 54 56 else if (60 <= Channel && Channel <= 64) *pGroup = 3; // 60 62 64 @@ -1455,7 +1390,6 @@ hal_GetChnlGroup8814A( return bIn24G; } - static void hal_ReadPowerValueFromPROM8814A( IN PADAPTER Adapter, @@ -1472,24 +1406,19 @@ hal_ReadPowerValueFromPROM8814A( _rtw_memset(pwrInfo5G, 0, sizeof(TxPowerInfo5G)); /* RTW_INFO("hal_ReadPowerValueFromPROM8814A(): PROMContent[0x%x]=0x%x\n", (eeAddr+1), PROMContent[eeAddr+1]); */ - if(0xFF == PROMContent[eeAddr+1]) //YJ,add,120316 + if (0xFF == PROMContent[eeAddr+1]) //YJ,add,120316 AutoLoadFail = _TRUE; - if(AutoLoadFail) - { + if (AutoLoadFail) { RTW_INFO("hal_ReadPowerValueFromPROM8814A(): Use Default value!\n"); - for(rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) - { + for(rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) { // 2.4G default value - for(group = 0 ; group < MAX_CHNL_GROUP_24G; group++) - { + for(group = 0 ; group < MAX_CHNL_GROUP_24G; group++) { pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; } - for(TxCount=0;TxCountBW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; } else { @@ -1501,13 +1430,11 @@ hal_ReadPowerValueFromPROM8814A( } // 5G default value - for(group = 0 ; group < MAX_CHNL_GROUP_5G; group++) - { + for(group = 0 ; group < MAX_CHNL_GROUP_5G; group++) { pwrInfo5G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_5G_INDEX; } - for(TxCount=0;TxCountOFDM_Diff[rfPath][0] = EEPROM_DEFAULT_5G_OFDM_DIFF; pwrInfo5G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_5G_HT20_DIFF; @@ -1527,31 +1454,25 @@ hal_ReadPowerValueFromPROM8814A( return; } - for(rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) - { + for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) { // 2.4G default value - for(group = 0 ; group < MAX_CHNL_GROUP_24G; group++) - { + for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) { pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++]; - if(pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) - { + if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) { pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; } /* RTW_INFO("8814-2G RF-%d-G-%d CCK-Addr-%x BASE=%x\n", rfPath, group, eeAddr-1, pwrInfo24G->IndexCCK_Base[rfPath][group]); */ } - for(group = 0 ; group < MAX_CHNL_GROUP_24G-1; group++) - { + for (group = 0 ; group < MAX_CHNL_GROUP_24G-1; group++) { pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; - if(pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) + if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; /* RTW_INFO("8814-2G RF-%d-G-%d BW40-Addr-%x BASE=%x\n", rfPath, group, eeAddr-1, pwrInfo24G->IndexBW40_Base[rfPath][group]); */ } - for(TxCount=0;TxCountBW40_Diff[rfPath][TxCount] = 0; { @@ -1615,23 +1536,19 @@ hal_ReadPowerValueFromPROM8814A( } //5G default value - for(group = 0 ; group < MAX_CHNL_GROUP_5G; group++) - { + for (group = 0 ; group < MAX_CHNL_GROUP_5G; group++) { pwrInfo5G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; - if(pwrInfo5G->IndexBW40_Base[rfPath][group] == 0xFF) + if (pwrInfo5G->IndexBW40_Base[rfPath][group] == 0xFF) pwrInfo5G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_DIFF; /* RTW_INFO("8814-5G RF-%d-G-%d BW40-Addr-%x BASE=%x\n", rfPath, TxCount, eeAddr-1, pwrInfo5G->IndexBW40_Base[rfPath][group]); */ } - for(TxCount=0;TxCountBW40_Diff[rfPath][TxCount]= 0; - { pwrInfo5G->BW20_Diff[rfPath][0] = (PROMContent[eeAddr]&0xf0)>>4; if(pwrInfo5G->BW20_Diff[rfPath][TxCount] & BIT3) //4bit sign number to 8 bit sign number @@ -1689,17 +1606,15 @@ hal_ReadPowerValueFromPROM8814A( rfPath, 3, eeAddr, pwrInfo5G->OFDM_Diff[rfPath][3]); */ eeAddr++; - for(TxCount=1;TxCountOFDM_Diff[rfPath][TxCount] & BIT3) //4bit sign number to 8 bit sign number + for (TxCount=1;TxCountOFDM_Diff[rfPath][TxCount] & BIT3) //4bit sign number to 8 bit sign number pwrInfo5G->OFDM_Diff[rfPath][TxCount] |= 0xF0; /* RTW_INFO("8814-5G RF-%d-SS-%d LGOD-Addr-%x DIFF=%d\n", rfPath, TxCount, eeAddr, pwrInfo5G->OFDM_Diff[rfPath][TxCount]); */ } - for(TxCount=0;TxCountBW80_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; @@ -1771,10 +1686,9 @@ hal_EfuseParseBTCoexistInfo8814A( HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); u8 tempval=0x0; - if(!AutoLoadFail) - { + if (!AutoLoadFail) { tempval = hwinfo[EEPROM_RF_BOARD_OPTION_8814]; - if( ((tempval & 0xe0)>>5) == 0x1)// [7:5] + if ( ((tempval & 0xe0)>>5) == 0x1)// [7:5] pHalData->EEPROMBluetoothCoexist = 1; else pHalData->EEPROMBluetoothCoexist = 0; @@ -1782,9 +1696,7 @@ hal_EfuseParseBTCoexistInfo8814A( tempval = hwinfo[EEPROM_RF_BT_SETTING_8814]; pHalData->EEPROMBluetoothAntNum = Ant_x1; - } - else - { + } else { pHalData->EEPROMBluetoothCoexist = 0; pHalData->EEPROMBluetoothType = BT_RTL8814A; pHalData->EEPROMBluetoothAntNum = Ant_x1; @@ -1802,11 +1714,11 @@ hal_ReadPROMVersion8814A( { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - if(AutoloadFail) { + if (AutoloadFail) { pHalData->EEPROMVersion = EEPROM_Default_Version; } else { pHalData->EEPROMVersion = *(u8 *)&PROMContent[EEPROM_VERSION_8814]; - if(pHalData->EEPROMVersion == 0xFF) + if (pHalData->EEPROMVersion == 0xFF) pHalData->EEPROMVersion = EEPROM_Default_Version; } } @@ -1828,13 +1740,11 @@ hal_ReadTxPowerInfo8814A( //if(!AutoLoadFail) // pHalData->bTXPowerDataReadFromEEPORM = _TRUE; - for(rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) - { + for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) { for (ch = 0 ; ch < CENTER_CH_2G_NUM ; ch++) { hal_GetChnlGroup8814A(ch+1, &group); - if(ch == 14-1) - { + if (ch == 14-1) { pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][5]; pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; } else { @@ -1866,8 +1776,7 @@ hal_ReadTxPowerInfo8814A( //RTW_INFO("Index5G_BW80_Base[%d][%d] = 0x%x\n",rfPath,ch,pHalData->Index5G_BW80_Base[rfPath][ch]); } - for(TxCount=0;TxCountCCK_24G_Diff[rfPath][TxCount]=pwrInfo24G.CCK_Diff[rfPath][TxCount]; pHalData->OFDM_24G_Diff[rfPath][TxCount]=pwrInfo24G.OFDM_Diff[rfPath][TxCount]; pHalData->BW20_24G_Diff[rfPath][TxCount]=pwrInfo24G.BW20_Diff[rfPath][TxCount]; @@ -1895,12 +1804,11 @@ hal_ReadTxPowerInfo8814A( // 2010/10/19 MH Add Regulator recognize for CU. - if(!AutoLoadFail) - { + if (!AutoLoadFail) { struct registry_priv *registry_par = &Adapter->registrypriv; pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_8814]&0x7); //bit0~2 - if(PROMContent[EEPROM_RF_BOARD_OPTION_8814] == 0xFF) + if (PROMContent[EEPROM_RF_BOARD_OPTION_8814] == 0xFF) pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); //bit0~2 } else { pHalData->EEPROMRegulatory = 0; @@ -1920,10 +1828,9 @@ hal_ReadBoardType8814A( HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - if(!AutoloadFail) - { + if (!AutoloadFail) { pHalData->InterfaceSel = (PROMContent[EEPROM_RF_BOARD_OPTION_8814]&0xE0)>>5; - if(PROMContent[EEPROM_RF_BOARD_OPTION_8814] == 0xFF) + if (PROMContent[EEPROM_RF_BOARD_OPTION_8814] == 0xFF) pHalData->InterfaceSel = (EEPROM_DEFAULT_BOARD_OPTION&0xE0)>>5; } else { pHalData->InterfaceSel = 0; @@ -2002,7 +1909,7 @@ hal_ReadThermalMeter_8814A( pHalData->EEPROMThermalMeter = 0xff; - if(!AutoloadFail) + if (!AutoloadFail) pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_8814]; #if 0 /* ToDo: check with RF */ @@ -2030,7 +1937,7 @@ void hal_ReadRemoteWakeup_8814A( struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); u8 tmpvalue; - if(AutoLoadFail){ + if (AutoLoadFail) { pwrctl->bHWPowerdown = _FALSE; pwrctl->bSupportRemoteWakeup = _FALSE; } else { @@ -2192,10 +2099,9 @@ hal_EfuseParseXtal_8814A( { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - if(!AutoLoadFail) - { + if (!AutoLoadFail) { pHalData->CrystalCap = hwinfo[EEPROM_XTAL_8814]; - if(pHalData->CrystalCap == 0xFF) + if (pHalData->CrystalCap == 0xFF) pHalData->CrystalCap = EEPROM_Default_CrystalCap_8814; /* what value should 8814 set? */ } else { pHalData->CrystalCap = EEPROM_Default_CrystalCap_8814; @@ -2231,12 +2137,10 @@ hal_ReadPAType_8814A( HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); u8 LNAType_AB, LNAType_CD; - if( ! AutoloadFail ) - { + if( ! AutoloadFail ) { u8 RFEType = PROMContent[EEPROM_RFE_OPTION_8814]; - if (GetRegAmplifierType2G(Adapter) == 0) // AUTO - { + if (GetRegAmplifierType2G(Adapter) == 0) { // AUTO *pPAType = EF1Byte( *(u8*)&PROMContent[EEPROM_PA_TYPE_8814] ); LNAType_AB = EF1Byte( *(u8*)&PROMContent[EEPROM_LNA_TYPE_AB_2G_8814] ); @@ -2259,8 +2163,7 @@ hal_ReadPAType_8814A( pHalData->ExternalLNA_2G = (GetRegAmplifierType2G(Adapter)&ODM_BOARD_EXT_LNA) ? 1 : 0; } - if (GetRegAmplifierType5G(Adapter) == 0) // AUTO - { + if (GetRegAmplifierType5G(Adapter) == 0) { // AUTO LNAType_AB = EF1Byte( *(u8*)&PROMContent[EEPROM_LNA_TYPE_AB_5G_8814] ); LNAType_CD = EF1Byte( *(u8*)&PROMContent[EEPROM_LNA_TYPE_CD_5G_8814] ); @@ -2286,16 +2189,15 @@ hal_ReadPAType_8814A( pHalData->ExternalLNA_2G = EEPROM_Default_LNAType; pHalData->ExternalLNA_5G = 0xFF; - if (GetRegAmplifierType2G(Adapter) == 0) - { + if (GetRegAmplifierType2G(Adapter) == 0) { pHalData->ExternalPA_2G = 0; pHalData->ExternalLNA_2G = 0; } else { pHalData->ExternalPA_2G = (GetRegAmplifierType2G(Adapter)&ODM_BOARD_EXT_PA) ? 1 : 0; pHalData->ExternalLNA_2G = (GetRegAmplifierType2G(Adapter)&ODM_BOARD_EXT_LNA) ? 1 : 0; } - if (GetRegAmplifierType5G(Adapter) == 0) - { + + if (GetRegAmplifierType5G(Adapter) == 0) { pHalData->ExternalPA_5G = 0; pHalData->ExternalLNA_5G = 0; } else { @@ -2313,7 +2215,7 @@ VOID hal_ReadAmplifierType_8814A( ) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - switch(pHalData->RFEType) + switch (pHalData->RFEType) { case 1: /* 8814AU */ pHalData->ExternalPA_5G = pHalData->ExternalLNA_5G = _TRUE; @@ -2370,14 +2272,13 @@ hal_ReadRFEType_8814A( { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - if(!AutoloadFail) - { + if (!AutoloadFail) { if ((GetRegRFEType(Adapter) != 64) || 0xFF == PROMContent[EEPROM_RFE_OPTION_8814] || PROMContent[EEPROM_RFE_OPTION_8814] & BIT7) { - if(GetRegRFEType(Adapter) != 64) + if (GetRegRFEType(Adapter) != 64) pHalData->RFEType = GetRegRFEType(Adapter); - else if(IS_HARDWARE_TYPE_8814AE(Adapter)) + else if (IS_HARDWARE_TYPE_8814AE(Adapter)) pHalData->RFEType = 0; - else if(IS_HARDWARE_TYPE_8814AU(Adapter)) + else if (IS_HARDWARE_TYPE_8814AU(Adapter)) pHalData->RFEType = 1; hal_ReadAmplifierType_8814A(Adapter); @@ -2387,11 +2288,11 @@ hal_ReadRFEType_8814A( hal_ReadAmplifierType_8814A(Adapter); } } else { - if(GetRegRFEType(Adapter) != 64) + if (GetRegRFEType(Adapter) != 64) pHalData->RFEType = GetRegRFEType(Adapter); - else if(IS_HARDWARE_TYPE_8814AE(Adapter)) + else if (IS_HARDWARE_TYPE_8814AE(Adapter)) pHalData->RFEType = 0; - else if(IS_HARDWARE_TYPE_8814AU(Adapter)) + else if (IS_HARDWARE_TYPE_8814AU(Adapter)) pHalData->RFEType = 1; hal_ReadAmplifierType_8814A(Adapter); @@ -2410,27 +2311,24 @@ hal_EfusePowerSwitch8814A( u8 EFUSE_ACCESS_ON_8814A = 0x69; u8 EFUSE_ACCESS_OFF_8814A = 0x00; - if (PwrState == _TRUE) - { + if (PwrState == _TRUE) { rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON_8814A); // Reset: 0x0000h[28], default valid tmpV16 = PlatformEFIORead2Byte(pAdapter,REG_SYS_FUNC_EN); - if( !(tmpV16 & FEN_ELDR) ){ + if ( !(tmpV16 & FEN_ELDR) ){ tmpV16 |= FEN_ELDR ; rtw_write16(pAdapter,REG_SYS_FUNC_EN,tmpV16); } // Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid tmpV16 = PlatformEFIORead2Byte(pAdapter,REG_SYS_CLKR); - if( (!(tmpV16 & LOADER_CLK_EN) ) ||(!(tmpV16 & ANA8M) ) ) - { + if ( (!(tmpV16 & LOADER_CLK_EN) ) ||(!(tmpV16 & ANA8M) ) ) { tmpV16 |= (LOADER_CLK_EN |ANA8M ) ; rtw_write16(pAdapter,REG_SYS_CLKR,tmpV16); } - if(bWrite == _TRUE) - { + if (bWrite == _TRUE) { // Enable LDO 2.5V before read/write action tempval = rtw_read8(pAdapter, EFUSE_TEST+3); tempval &= 0x0F; @@ -2440,7 +2338,7 @@ hal_EfusePowerSwitch8814A( } else { rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF_8814A); - if(bWrite == _TRUE){ + if (bWrite == _TRUE) { // Disable LDO 2.5V after read/write action tempval = rtw_read8(pAdapter, EFUSE_TEST+3); rtw_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); @@ -2479,22 +2377,19 @@ hal_EfuseReadEFuse8814A( // // Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. // - if((_offset + _size_byte)>EFUSE_MAP_LEN_8814A) - {// total E-Fuse table is 512bytes + if ((_offset + _size_byte)>EFUSE_MAP_LEN_8814A) { // total E-Fuse table is 512bytes RTW_INFO("Hal_EfuseReadEFuse8814A(): Invalid offset(%#x) with read bytes(%#x)!!\n", _offset, _size_byte); goto exit; } efuseTbl = (u8*)rtw_zmalloc(EFUSE_MAP_LEN_8814A); - if(efuseTbl == NULL) - { + if (efuseTbl == NULL) { RTW_INFO("%s: alloc efuseTbl fail!\n", __FUNCTION__); goto exit; } eFuseWord= (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_8814A, EFUSE_MAX_WORD_UNIT_8814A, 2); - if(eFuseWord == NULL) - { + if (eFuseWord == NULL) { RTW_INFO("%s: alloc eFuseWord fail!\n", __FUNCTION__); goto exit; } @@ -2510,8 +2405,7 @@ hal_EfuseReadEFuse8814A( // efuse_OneByteRead(Adapter, eFuse_Addr++, &efuseHeader, bPseudoTest); - if(efuseHeader != 0xFF) - { + if (efuseHeader != 0xFF) { efuse_utilized++; } else { RTW_INFO("EFUSE is empty\n"); @@ -2523,13 +2417,12 @@ hal_EfuseReadEFuse8814A( // // 2. Read real efuse content. Filter PG header and every section data. // - while((efuseHeader != 0xFF) && AVAILABLE_EFUSE_ADDR_8814A(eFuse_Addr)) - { + while ((efuseHeader != 0xFF) && AVAILABLE_EFUSE_ADDR_8814A(eFuse_Addr)) { //RTPRINT(FEEPROM, EFUSE_READ_ALL, ("efuse_Addr-%d efuse_data=%x\n", eFuse_Addr-1, *rtemp8)); // Check PG header for section num. - if(EXT_HEADER(efuseHeader)) //extended header - { + if (EXT_HEADER(efuseHeader)) { //extended header + offset_2_0 = GET_HDR_OFFSET_2_0(efuseHeader); //RT_DISP(FEEPROM, EFUSE_READ_ALL, ("extended header offset_2_0=%X\n", offset_2_0)); @@ -2537,14 +2430,11 @@ hal_EfuseReadEFuse8814A( //RT_DISP(FEEPROM, EFUSE_READ_ALL, ("efuse[%X]=%X\n", eFuse_Addr-1, efuseExtHdr)); - if(efuseExtHdr != 0xff) - { + if (efuseExtHdr != 0xff) { efuse_utilized++; - if(ALL_WORDS_DISABLED(efuseExtHdr)) - { + if (ALL_WORDS_DISABLED(efuseExtHdr)) { efuse_OneByteRead(Adapter, eFuse_Addr++, &efuseHeader, bPseudoTest); - if(efuseHeader != 0xff) - { + if (efuseHeader != 0xff) { efuse_utilized++; } break; @@ -2562,22 +2452,19 @@ hal_EfuseReadEFuse8814A( wden = (efuseHeader & 0x0f); } - if(offset < EFUSE_MAX_SECTION_8814A) - { + if (offset < EFUSE_MAX_SECTION_8814A) { // Get word enable value from PG header //RT_DISP(FEEPROM, EFUSE_READ_ALL, ("Offset-%X Worden=%X\n", offset, wden)); - for(i=0; i> 8) & 0xff); } @@ -2635,8 +2519,7 @@ hal_EfuseReadEFuse8814A( // // 4. Copy from Efuse map to output pointer memory!!! // - for(i=0; i<_size_byte; i++) - { + for (i = 0; i<_size_byte; i++) { pbuf[i] = efuseTbl[_offset+i]; } @@ -2647,10 +2530,10 @@ hal_EfuseReadEFuse8814A( rtw_hal_set_hwreg(Adapter, HW_VAR_EFUSE_BYTES, (u8 *)&eFuse_Addr); exit: - if(efuseTbl) + if (efuseTbl) rtw_mfree(efuseTbl, EFUSE_MAP_LEN_8814A); - if(eFuseWord) + if (eFuseWord) rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_8814A, EFUSE_MAX_WORD_UNIT_8814A, sizeof(u16)); } @@ -2765,8 +2648,7 @@ hal_EfuseWordEnableDataWrite8814A( IN PADAPTER pAdapter, RTW_INFO("word_en = %x efuse_addr=%x\n", word_en, efuse_addr); - if ( ! (word_en&BIT0)) - { + if ( ! (word_en&BIT0)) { readbackAddr = start_addr; efuse_OneByteWrite(pAdapter,start_addr++, data[0], bPseudoTest); efuse_OneByteWrite(pAdapter,start_addr++, data[1], bPseudoTest); @@ -2782,12 +2664,11 @@ hal_EfuseWordEnableDataWrite8814A( IN PADAPTER pAdapter, IS_HARDWARE_TYPE_8192E(pAdapter) || IS_HARDWARE_TYPE_8703B(pAdapter) || IS_HARDWARE_TYPE_8188F(pAdapter)) PHY_SetMacReg(pAdapter, EFUSE_TEST, BIT26, 1); // Restored to 1.5K Read, Suggested by Morris & Victor - if((data[0]!=readbackData[0])||(data[1]!=readbackData[1])){ + if ((data[0]!=readbackData[0])||(data[1]!=readbackData[1])) { badworden &= (~BIT0); } } - if ( ! (word_en&BIT1)) - { + if ( ! (word_en&BIT1)) { readbackAddr = start_addr; efuse_OneByteWrite(pAdapter,start_addr++, data[2], bPseudoTest); efuse_OneByteWrite(pAdapter,start_addr++, data[3], bPseudoTest); @@ -2807,8 +2688,7 @@ hal_EfuseWordEnableDataWrite8814A( IN PADAPTER pAdapter, badworden &=( ~BIT1); } } - if ( ! (word_en&BIT2)) - { + if ( ! (word_en&BIT2)) { readbackAddr = start_addr; efuse_OneByteWrite(pAdapter,start_addr++, data[4], bPseudoTest); efuse_OneByteWrite(pAdapter,start_addr++, data[5], bPseudoTest); @@ -2828,8 +2708,7 @@ hal_EfuseWordEnableDataWrite8814A( IN PADAPTER pAdapter, badworden &=( ~BIT2); } } - if ( ! (word_en&BIT3)) - { + if ( ! (word_en&BIT3)) { readbackAddr = start_addr; efuse_OneByteWrite(pAdapter,start_addr++, data[6], bPseudoTest); efuse_OneByteWrite(pAdapter,start_addr++, data[7], bPseudoTest); @@ -2845,7 +2724,7 @@ hal_EfuseWordEnableDataWrite8814A( IN PADAPTER pAdapter, IS_HARDWARE_TYPE_8192E(pAdapter) || IS_HARDWARE_TYPE_8703B(pAdapter) || IS_HARDWARE_TYPE_8188F(pAdapter)) PHY_SetMacReg(pAdapter, EFUSE_TEST, BIT26, 1); // Restored to 1.5K Read, Suggested by Morris & Victor - if((data[6]!=readbackData[6])||(data[7]!=readbackData[7])){ + if ((data[6]!=readbackData[6])||(data[7]!=readbackData[7])){ badworden &=( ~BIT3); } } @@ -2880,8 +2759,7 @@ static u16 hal_EfuseGetCurrentSize_8814A( PADAPTER pAdapter, BOOLEAN bPseudoTest RTW_INFO("=======> %s() \n", __func__); - if(bPseudoTest) - { + if (bPseudoTest) { efuse_addr = (u16)(fakeEfuseUsedBytes); } else { rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); @@ -2890,17 +2768,13 @@ static u16 hal_EfuseGetCurrentSize_8814A( PADAPTER pAdapter, BOOLEAN bPseudoTest while ( bContinual && efuse_OneByteRead(pAdapter, efuse_addr , &efuse_data, bPseudoTest) && - (efuse_addr < EFUSE_REAL_CONTENT_LEN_8814A)) - { - if (efuse_data != 0xFF) - { - if ((efuse_data&0x1F) == 0x0F) //extended header - { + (efuse_addr < EFUSE_REAL_CONTENT_LEN_8814A)) { + if (efuse_data != 0xFF) { + if ((efuse_data&0x1F) == 0x0F) { //extended header hoffset = efuse_data; efuse_addr++; efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); - if((efuse_data & 0x0F) == 0x0F) - { + if((efuse_data & 0x0F) == 0x0F) { efuse_addr++; continue; } else { @@ -2919,8 +2793,7 @@ static u16 hal_EfuseGetCurrentSize_8814A( PADAPTER pAdapter, BOOLEAN bPseudoTest } } - if(bPseudoTest) - { + if (bPseudoTest) { fakeEfuseUsedBytes = efuse_addr; pEfuseHal->fakeEfuseUsedBytes = efuse_addr; RTW_INFO ("%s(), return %d \n", __func__, pEfuseHal->fakeEfuseUsedBytes ); @@ -2970,8 +2843,8 @@ hal_EfusePgPacketRead_8814A( u8 tmpdata[8]; u8 tmp_header = 0; - if(data==NULL) return _FALSE; - if(offset>=EFUSE_MAX_SECTION_JAGUAR) return _FALSE; + if (data==NULL) return _FALSE; + if (offset>=EFUSE_MAX_SECTION_JAGUAR) return _FALSE; _rtw_memset((PVOID)data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); _rtw_memset((PVOID)tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); @@ -2981,20 +2854,15 @@ hal_EfusePgPacketRead_8814A( // Skip dummy parts to prevent unexpected data read from Efuse. // By pass right now. 2009.02.19. // - while(bContinual && (efuse_addr < pEfuseHal->PhysicalLen_WiFi) ) - { + while (bContinual && (efuse_addr < pEfuseHal->PhysicalLen_WiFi) ) { //------- Header Read ------------- - if(ReadState & PG_STATE_HEADER) - { - if(efuse_OneByteRead(pAdapter, efuse_addr ,&efuse_data, bPseudoTest)&&(efuse_data!=0xFF)) - { - if(ALL_WORDS_DISABLED(efuse_data)) - { + if (ReadState & PG_STATE_HEADER) { + if (efuse_OneByteRead(pAdapter, efuse_addr ,&efuse_data, bPseudoTest)&&(efuse_data!=0xFF)) { + if (ALL_WORDS_DISABLED(efuse_data)) { tmp_header = efuse_data; efuse_addr++; efuse_OneByteRead(pAdapter, efuse_addr ,&efuse_data, bPseudoTest); - if((efuse_data & 0x0F) != 0x0F) - { + if ((efuse_data & 0x0F) != 0x0F) { hoffset = ((tmp_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); hworden = efuse_data & 0x0F; } else { @@ -3009,16 +2877,16 @@ hal_EfusePgPacketRead_8814A( word_cnts = Efuse_CalculateWordCnts(hworden); bDataEmpty = _TRUE ; - if(hoffset==offset){ - for(tmpidx = 0;tmpidx< word_cnts*2 ;tmpidx++){ - if(efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx ,&efuse_data, bPseudoTest) ){ + if (hoffset==offset) { + for (tmpidx = 0;tmpidx< word_cnts*2 ;tmpidx++) { + if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx ,&efuse_data, bPseudoTest) ) { tmpdata[tmpidx] = efuse_data; - if(efuse_data!=0xff){ + if (efuse_data!=0xff) { bDataEmpty = _FALSE; } } } - if(bDataEmpty==_FALSE){ + if (bDataEmpty==_FALSE) { ReadState = PG_STATE_DATA; } else { //read next header efuse_addr = efuse_addr + (word_cnts*2)+1; @@ -3035,8 +2903,7 @@ hal_EfusePgPacketRead_8814A( } } //------- Data section Read ------------- - else if(ReadState & PG_STATE_DATA) - { + else if (ReadState & PG_STATE_DATA) { efuse_WordEnableDataRead(hworden,tmpdata,data); efuse_addr = efuse_addr + (word_cnts*2)+1; ReadState = PG_STATE_HEADER; @@ -3044,7 +2911,7 @@ hal_EfusePgPacketRead_8814A( } - if( (data[0]==0xff) &&(data[1]==0xff) && (data[2]==0xff) && (data[3]==0xff) && + if ( (data[0]==0xff) &&(data[1]==0xff) && (data[2]==0xff) && (data[3]==0xff) && (data[4]==0xff) &&(data[5]==0xff) && (data[6]==0xff) && (data[7]==0xff)) return _FALSE; else @@ -3073,8 +2940,7 @@ efuse_PgPacketCheck( { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - if (Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest) >= (EFUSE_REAL_CONTENT_LEN_8814A-EFUSE_PROTECT_BYTES_BANK_8814A)) - { + if (Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest) >= (EFUSE_REAL_CONTENT_LEN_8814A-EFUSE_PROTECT_BYTES_BANK_8814A)) { RTW_INFO("%s()error: %x >= %x\n", __func__, Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest), (EFUSE_REAL_CONTENT_LEN_8814A-EFUSE_PROTECT_BYTES_BANK_8814A)); return _FALSE; } @@ -3128,9 +2994,8 @@ hal_EfuseCheckIfDatafollowed( BOOLEAN bRet=FALSE; u8 i, efuse_data; - for(i=0; i<(word_cnts*2) ; i++) - { - if(efuse_OneByteRead(pAdapter, (startAddr+i) ,&efuse_data, bPseudoTest)&&(efuse_data != 0xFF)) + for (i = 0; i<(word_cnts*2) ; i++) { + if (efuse_OneByteRead(pAdapter, (startAddr+i) ,&efuse_data, bPseudoTest)&&(efuse_data != 0xFF)) bRet = TRUE; } @@ -3170,7 +3035,7 @@ hal_EfuseWordEnMatched( *pWden = match_word_en; - if(match_word_en != 0xf) + if (match_word_en != 0xf) return TRUE; else return FALSE; @@ -3205,10 +3070,8 @@ efuse_PgPacketPartialWrite( //EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &efuse_max_available_len, bPseudoTest); //EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max, bPseudoTest); - if(efuseType == EFUSE_WIFI) - { - if(bPseudoTest) - { + if (efuseType == EFUSE_WIFI) { + if (bPseudoTest) { #ifdef HAL_EFUSE_MEMORY startAddr = (u16)pEfuseHal->fakeEfuseUsedBytes; #else @@ -3219,17 +3082,14 @@ efuse_PgPacketPartialWrite( rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8*)&startAddr); } } else { - if(bPseudoTest) - { + if (bPseudoTest) { #ifdef HAL_EFUSE_MEMORY startAddr = (u16)pEfuseHal->fakeBTEfuseUsedBytes; #else startAddr = (u16)fakeBTEfuseUsedBytes; #endif - } - else - { + } else { rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BT_BYTES, (u8*)&startAddr); } } @@ -3240,23 +3100,19 @@ efuse_PgPacketPartialWrite( while(1) { - if(startAddr >= efuse_max_available_len) - { + if(startAddr >= efuse_max_available_len) { bRet = _FALSE; RTW_INFO("startAddr(%d) >= efuse_max_available_len(%d)\n", startAddr, efuse_max_available_len); break; } - if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data!=0xFF)) - { - if(EXT_HEADER(efuse_data)) - { + if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data!=0xFF)) { + if (EXT_HEADER(efuse_data)) { cur_header = efuse_data; startAddr++; efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest); - if (ALL_WORDS_DISABLED(efuse_data)) - { + if (ALL_WORDS_DISABLED(efuse_data)) { u16 recoveredAddr = startAddr; recoveredAddr = efuse_PgPacketExceptionHandle(pAdapter, startAddr-1); @@ -3299,7 +3155,7 @@ efuse_PgPacketPartialWrite( curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); // if same header is found but no data followed // write some part of data followed by the header. - if( (curPkt.offset == pTargetPkt->offset) && + if ( (curPkt.offset == pTargetPkt->offset) && (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1, bPseudoTest)) && hal_EfuseWordEnMatched(pTargetPkt, &curPkt, &matched_wden) ) { @@ -3307,24 +3163,20 @@ efuse_PgPacketPartialWrite( //RT_ASSERT(_FALSE, ("Error, Need to partial write data by the previous wrote header!!\n")); // Here to write partial data badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest); - if(badworden != 0x0F) - { + if(badworden != 0x0F) { u32 PgWriteSuccess=0; // if write fail on some words, write these bad words again PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); - if(!PgWriteSuccess) - { + if(!PgWriteSuccess) { bRet = _FALSE; // write fail, return break; } } // partial write ok, update the target packet for later use - for(i=0; i<4; i++) - { - if((matched_wden & (0x1<word_en |= (0x1<offset, originaldata, bPseudoTest)) - { //check if data exist + if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata, bPseudoTest)) { + //check if data exist badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pFixPkt->word_en, originaldata, bPseudoTest); - if(badworden != 0xf) // write fail - { + if (badworden != 0xf) { // write fail PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata, bPseudoTest); - if(!PgWriteSuccess) + if (!PgWriteSuccess) return _FALSE; else efuse_addr = Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest); @@ -3398,17 +3249,14 @@ efuse_PgPacketWrite2ByteHeader( RTW_INFO("Wirte 2byte header\n"); - while(efuse_addr < efuse_max_available_len) - { + while (efuse_addr < efuse_max_available_len) { pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; RTW_INFO("pg_header = 0x%x\n", pg_header); efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - while(tmp_header == 0xFF || pg_header != tmp_header) - { - if(repeatcnt++ > pEfuseHal->DataRetry) - { + while (tmp_header == 0xFF || pg_header != tmp_header) { + if (repeatcnt++ > pEfuseHal->DataRetry) { RTW_INFO("Repeat over limit for pg_header!!\n"); return _FALSE; } @@ -3418,8 +3266,7 @@ efuse_PgPacketWrite2ByteHeader( } //to write ext_header - if(tmp_header == pg_header) - { + if (tmp_header == pg_header) { efuse_addr++; pg_header_temp = pg_header; pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; @@ -3427,10 +3274,8 @@ efuse_PgPacketWrite2ByteHeader( efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - while(tmp_header == 0xFF || pg_header != tmp_header) - { - if(repeatcnt++ > pEfuseHal->DataRetry) - { + while (tmp_header == 0xFF || pg_header != tmp_header) { + if (repeatcnt++ > pEfuseHal->DataRetry) { RTW_INFO("Repeat over limit for ext_header!!\n"); return _FALSE; } @@ -3439,10 +3284,8 @@ efuse_PgPacketWrite2ByteHeader( efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); } - if((tmp_header & 0x0F) == 0x0F) //word_en PG fail - { - if(repeatcnt++ > pEfuseHal->DataRetry) - { + if ((tmp_header & 0x0F) == 0x0F) { //word_en PG fail + if (repeatcnt++ > pEfuseHal->DataRetry) { RTW_INFO("Repeat over limit for word_en!!\n"); return _FALSE; } else { @@ -3450,23 +3293,21 @@ efuse_PgPacketWrite2ByteHeader( continue; } } - else if(pg_header != tmp_header) //offset PG fail - { + else if (pg_header != tmp_header) { //offset PG fail PGPKT_STRUCT fixPkt; //RT_ASSERT(_FALSE, ("Error, efuse_PgPacketWrite2ByteHeader(), offset PG fail, need to cover the existed data!!\n")); RTW_INFO("Error condition for offset PG fail, need to cover the existed data\n"); fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); fixPkt.word_en = tmp_header & 0x0F; fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); - if(!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) return _FALSE; } else { bRet = _TRUE; break; } } - else if ((tmp_header & 0x1F) == 0x0F) //wrong extended header - { + else if ((tmp_header & 0x1F) == 0x0F) { //wrong extended header efuse_addr+=2; continue; } @@ -3510,10 +3351,8 @@ efuse_PgPacketWrite1ByteHeader( IS_HARDWARE_TYPE_8192E(pAdapter) || IS_HARDWARE_TYPE_8703B(pAdapter) || IS_HARDWARE_TYPE_8188F(pAdapter)) PHY_SetMacReg(pAdapter, EFUSE_TEST, BIT26, 1); // Restored to 1.5K Read, Suggested by Morris & Victor - while(tmp_header == 0xFF || pg_header != tmp_header) - { - if(repeatcnt++ > pEfuseHal->HeaderRetry) - { + while (tmp_header == 0xFF || pg_header != tmp_header) { + if (repeatcnt++ > pEfuseHal->HeaderRetry) { RTW_INFO("retry %d times fail!!\n", repeatcnt); return _FALSE; } @@ -3522,8 +3361,7 @@ efuse_PgPacketWrite1ByteHeader( RTW_INFO("===> efuse_PgPacketWrite1ByteHeader: Keep %d-th retrying, tmp_header = 0x%X\n", repeatcnt, tmp_header); } - if(pg_header == tmp_header) - { + if (pg_header == tmp_header) { bRet = _TRUE; } else { PGPKT_STRUCT fixPkt; @@ -3534,7 +3372,7 @@ efuse_PgPacketWrite1ByteHeader( fixPkt.offset = (tmp_header>>4) & 0x0F; fixPkt.word_en = tmp_header & 0x0F; fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); - if(!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) return _FALSE; } @@ -3552,8 +3390,7 @@ efuse_PgPacketWriteHeader( { BOOLEAN bRet=_FALSE; - if(pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) - { + if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) { bRet = efuse_PgPacketWrite2ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); } else { bRet = efuse_PgPacketWrite1ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); @@ -3577,18 +3414,15 @@ efuse_PgPacketWriteData( badworden = 0x0f; badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); - if(badworden == 0x0F) - { + if (badworden == 0x0F) { RTW_INFO("efuse_PgPacketWriteData ok!!\n"); return _TRUE; - } - else - { // Reorganize other pg packet + } else { // Reorganize other pg packet //RT_ASSERT(_FALSE, ("Error, efuse_PgPacketWriteData(), wirte data fail!!\n")); RTW_INFO("efuse_PgPacketWriteData Fail!!\n"); PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); - if(!PgWriteSuccess) + if (!PgWriteSuccess) return _FALSE; else return _TRUE; @@ -3597,7 +3431,6 @@ efuse_PgPacketWriteData( return bRet; } - int hal_EfusePgPacketWrite_8814A(IN PADAPTER pAdapter, IN u8 offset, @@ -3612,8 +3445,7 @@ hal_EfusePgPacketWrite_8814A(IN PADAPTER pAdapter, RTW_INFO("===> efuse_PgPacketWrite[%s], offset: 0x%X\n", (efuseType == EFUSE_WIFI) ? "WIFI" : "BT", offset); //4 [1] Check if the remaining space is available to write. - if(!efuse_PgPacketCheck(pAdapter, efuseType, bPseudoTest)) - { + if (!efuse_PgPacketCheck(pAdapter, efuseType, bPseudoTest)) { pAdapter->LastError = ERR_WRITE_PROTECT; RTW_INFO("efuse_PgPacketCheck(), fail!!\n"); return _FALSE; @@ -3624,24 +3456,21 @@ hal_EfusePgPacketWrite_8814A(IN PADAPTER pAdapter, //4 [3] Fix headers without data or fix bad headers, and then return the address where to get started. - if(!efuse_PgPacketPartialWrite(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) - { + if (!efuse_PgPacketPartialWrite(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) { pAdapter->LastError = ERR_INVALID_DATA; RTW_INFO("efuse_PgPacketPartialWrite(), fail!!\n"); return _FALSE; } //4 [4] Write the (extension) header. - if(!efuse_PgPacketWriteHeader(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) - { + if (!efuse_PgPacketWriteHeader(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) { pAdapter->LastError = ERR_IO_FAILURE; RTW_INFO("efuse_PgPacketWriteHeader(), fail!!\n"); return _FALSE; } //4 [5] Write the data. - if(!efuse_PgPacketWriteData(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) - { + if(!efuse_PgPacketWriteData(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) { pAdapter->LastError = ERR_IO_FAILURE; RTW_INFO("efuse_PgPacketWriteData(), fail!!\n"); return _FALSE; @@ -3762,11 +3591,9 @@ void InitPGData8814A(PADAPTER padapter) u16 val16; PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->bautoload_fail_flag) - { + if (_FALSE == pHalData->bautoload_fail_flag) { // autoload OK. - if (is_boot_from_eeprom(padapter)) - { + if (is_boot_from_eeprom(padapter)) { // Read all Content from EEPROM or EFUSE. //for (i = 0; i < HWSET_MAX_SIZE_JAGUAR; i += 2) { @@ -3896,8 +3723,7 @@ void UpdateHalRAMask8814A(PADAPTER padapter, struct sta_info *psta, u32 mac_id, mask &= rate_bitmap; #ifdef CONFIG_BT_COEXIST - if (pHalData->EEPROMBluetoothCoexist == 1) - { + if (pHalData->EEPROMBluetoothCoexist == 1) { rate_bitmap = rtw_btcoex_GetRaMask(padapter); mask &= ~rate_bitmap; } @@ -3976,8 +3802,7 @@ _InitBeaconParameters_8814A( val8 = DIS_TSF_UDT; val16 = val8 | (val8 << 8); // port0 and port1 #ifdef CONFIG_BT_COEXIST - if (pHalData->EEPROMBluetoothCoexist == 1) - { + if (pHalData->EEPROMBluetoothCoexist == 1) { // Enable prot0 beacon function for PSTDMA val16 |= EN_BCN_FUNCTION; } @@ -4036,7 +3861,7 @@ void SetBeaconRelatedRegisters8814A(PADAPTER padapter) //BCN interval #ifdef CONFIG_CONCURRENT_MODE - if (padapter->iface_type == IFACE_PORT1){ + if (padapter->iface_type == IFACE_PORT1) { bcn_ctrl_reg = REG_BCN_CTRL_1; } #endif @@ -4104,12 +3929,10 @@ SetBeamformingCLK_8812( #endif // Wait TXFF empty - for(Count = 0; Count < 100; Count++) - { + for (Count = 0; Count < 100; Count++){ u2btmp = rtw_read16(Adapter, REG_TXPKT_EMPTY); u2btmp = u2btmp & 0xfff; - if(u2btmp != 0xfff) - { + if (u2btmp != 0xfff) { rtw_mdelay_os(10); continue; } @@ -4123,8 +3946,7 @@ SetBeamformingCLK_8812( rtw_write8(Adapter, REG_TXPAUSE, 0xFF); // Wait TX State Machine OK - for(Count = 0; Count < 100; Count++) - { + for (Count = 0; Count < 100; Count++) { if (rtw_read32(Adapter, REG_SCH_TXCMD_8812A) != 0) continue; else @@ -4137,10 +3959,9 @@ SetBeamformingCLK_8812( u1btmp = rtw_read8(Adapter, REG_RXDMA_CONTROL_8812A); rtw_write8(Adapter, REG_RXDMA_CONTROL_8812A, u1btmp | BIT2); - for(Count = 0; Count < 100; Count++) - { + for (Count = 0; Count < 100; Count++) { u1btmp = rtw_read8(Adapter, REG_RXDMA_CONTROL_8812A); - if(u1btmp & BIT1) + if (u1btmp & BIT1) break; else rtw_mdelay_os(10); @@ -4183,12 +4004,12 @@ SetBeamformRfMode_8812( BeamformCap = beamforming_get_beamform_cap(pBeamInfo); - if(BeamformCap == pBeamInfo->beamforming_cap) + if (BeamformCap == pBeamInfo->beamforming_cap) return; else pBeamInfo->beamforming_cap = BeamformCap; - if(GET_RF_TYPE(Adapter) == RF_1T1R) + if (GET_RF_TYPE(Adapter) == RF_1T1R) return; bSelfBeamformer = BeamformCap & BEAMFORMER_CAP; @@ -4197,8 +4018,7 @@ SetBeamformRfMode_8812( PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_WeLut_Jaguar, 0x80000,0x1); // RF Mode table write enable PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_WeLut_Jaguar, 0x80000,0x1); // RF Mode table write enable - if(bSelfBeamformer) - { + if (bSelfBeamformer) { // Paath_A PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_ModeTableAddr, 0x78000,0x3); // Select RX mode PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_ModeTableData0, 0xfffff,0x3F7FF); // Set Table data @@ -4221,7 +4041,7 @@ SetBeamformRfMode_8812( PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_WeLut_Jaguar, 0x80000,0x0); // RF Mode table write disable PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_WeLut_Jaguar, 0x80000,0x0); // RF Mode table write disable - if(bSelfBeamformer) + if (bSelfBeamformer) PHY_SetBBReg(Adapter, rTxPath_Jaguar, bMaskByte1, 0x33); else PHY_SetBBReg(Adapter, rTxPath_Jaguar, bMaskByte1, 0x11); @@ -4252,16 +4072,13 @@ SetBeamformEnter_8812( rtw_write8(Adapter, REG_SND_PTCL_CTRL_8812A, 0xCB); // MAC addresss/Partial AID of Beamformer - if(Idx == 0) - { - for(i = 0; i < 6 ; i++) + if (Idx == 0) { + for (i = 0; i < 6 ; i++) rtw_write8(Adapter, (REG_BFMER0_INFO_8812A+i), BeamformEntry.mac_addr[i]); /* CSI report use legacy ofdm so don't need to fill P_AID.*/ /*rtw_write16(Adapter, REG_BFMER0_INFO_8812A+6, BeamformEntry.P_AID);*/ - } - else - { - for(i = 0; i < 6 ; i++) + } else { + for (i = 0; i < 6 ; i++) rtw_write8(Adapter, (REG_BFMER1_INFO_8812A+i), BeamformEntry.mac_addr[i]); /* CSI report use legacy ofdm so don't need to fill P_AID.*/ /*rtw_write16(Adapter, REG_BFMER1_INFO_8812A+6, BeamformEntry.P_AID);*/ @@ -4271,18 +4088,18 @@ SetBeamformEnter_8812( if( (BeamformEntry.beamforming_entry_cap & BEAMFORMEE_CAP_VHT_SU) || (BeamformEntry.beamforming_entry_cap & BEAMFORMER_CAP_VHT_SU) ) { - if(pHalData->rf_type == RF_2T2R) + if (pHalData->rf_type == RF_2T2R) CSI_Param = 0x01090109; else CSI_Param = 0x01080108; } else { - if(pHalData->rf_type == RF_2T2R) + if (pHalData->rf_type == RF_2T2R) CSI_Param = 0x03090309; else CSI_Param = 0x03080308; } - if(pHalData->rf_type == RF_2T2R) + if (pHalData->rf_type == RF_2T2R) rtw_write32(Adapter, 0x9B4, 0x00000000); // Nc =2 else rtw_write32(Adapter, 0x9B4, 0x01081008); // Nc =1 @@ -4292,8 +4109,7 @@ SetBeamformEnter_8812( rtw_write32(Adapter, REG_CSI_RPT_PARAM_BW80_8812A, CSI_Param); // P_AID of Beamformee & enable NDPA transmission & enable NDPA interrupt - if(Idx == 0) - { + if (Idx == 0) { rtw_write16(Adapter, REG_TXBF_CTRL_8812A, STAid); rtw_write8(Adapter, REG_TXBF_CTRL_8812A+3, rtw_read8(Adapter, REG_TXBF_CTRL_8812A+3)|BIT4|BIT6|BIT7); } else { @@ -4301,7 +4117,7 @@ SetBeamformEnter_8812( } // CSI report parameters of Beamformee - if(Idx == 0) + if (Idx == 0) { // Get BIT24 & BIT25 u8 tmp = rtw_read8(Adapter, REG_BFMEE_SEL_8812A+3) & 0x3; @@ -4333,11 +4149,10 @@ SetBeamformLeave_8812( * Clear MAC addresss of Beamformer * Clear Associated Bfmee Sel */ - if(pBeamInfo->beamforming_cap == BEAMFORMING_CAP_NONE) + if (pBeamInfo->beamforming_cap == BEAMFORMING_CAP_NONE) rtw_write8(Adapter, REG_SND_PTCL_CTRL_8812A, 0xC8); - if(Idx == 0) - { + if (Idx == 0) { rtw_write16(Adapter, REG_TXBF_CTRL_8812A, 0); rtw_write32(Adapter, REG_BFMER0_INFO_8812A, 0); @@ -4371,7 +4186,7 @@ SetBeamformStatus_8812( else BeamCtrlVal = BeamformEntry.p_aid; - if(Idx == 0) + if (Idx == 0) BeamCtrlReg = REG_TXBF_CTRL_8812A; else { @@ -4379,13 +4194,13 @@ SetBeamformStatus_8812( BeamCtrlVal |= BIT12 | BIT14|BIT15; } - if(BeamformEntry.beamforming_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSED) + if (BeamformEntry.beamforming_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSED) { - if(BeamformEntry.sound_bw == CHANNEL_WIDTH_20) + if (BeamformEntry.sound_bw == CHANNEL_WIDTH_20) BeamCtrlVal |= BIT9; - else if(BeamformEntry.sound_bw == CHANNEL_WIDTH_40) + else if (BeamformEntry.sound_bw == CHANNEL_WIDTH_40) BeamCtrlVal |= BIT10; - else if(BeamformEntry.sound_bw == CHANNEL_WIDTH_80) + else if (BeamformEntry.sound_bw == CHANNEL_WIDTH_80) BeamCtrlVal |= BIT11; } else { BeamCtrlVal &= ~(BIT9|BIT10|BIT11); @@ -4408,13 +4223,10 @@ SetBeamformFwTxBFCmd_8812( struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); struct beamforming_info *pBeamInfo = GET_BEAMFORM_INFO(pmlmepriv); - for(Idx = 0; Idx < BEAMFORMING_ENTRY_NUM; Idx++) - { - if(pBeamInfo->beamforming_entry[Idx].beamforming_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSED) - { - if(Idx == 0) - { - if(pBeamInfo->beamforming_entry[Idx].bSound) + for(Idx = 0; Idx < BEAMFORMING_ENTRY_NUM; Idx++) { + if(pBeamInfo->beamforming_entry[Idx].beamforming_entry_state == BEAMFORMING_ENTRY_STATE_PROGRESSED) { + if(Idx == 0) { + if (pBeamInfo->beamforming_entry[Idx].bSound) PageNum0 = 0xFE; else PageNum0 = 0xFF; //stop sounding @@ -4422,7 +4234,7 @@ SetBeamformFwTxBFCmd_8812( } else if(Idx == 1) { - if(pBeamInfo->beamforming_entry[Idx].bSound) + if (pBeamInfo->beamforming_entry[Idx].bSound) PageNum1 = 0xFE; else PageNum1 = 0xFF; //stop sounding @@ -4456,7 +4268,7 @@ SetBeamformDownloadNDPA_8812( //pHalData->bFwDwRsvdPageInProgress = _TRUE; - if(Idx == 0) + if (Idx == 0) Head_Page = 0xFE; else Head_Page = 0xFE; @@ -4474,8 +4286,7 @@ SetBeamformDownloadNDPA_8812( tmpReg422 = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL+2); rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+2, tmpReg422&(~BIT6)); - if(tmpReg422&BIT6) - { + if (tmpReg422&BIT6) { RTW_INFO("SetBeamformDownloadNDPA_8812(): There is an Adapter is sending beacon.\n"); bSendBeacon = _TRUE; } @@ -4490,7 +4301,7 @@ SetBeamformDownloadNDPA_8812( rtw_write8(Adapter, REG_TDECTRL+2, (BcnValidReg|BIT0)); // download NDPA rsvd page. - if(pBeamEntry->beamforming_entry_cap & BEAMFORMER_CAP_VHT_SU) + if (pBeamEntry->beamforming_entry_cap & BEAMFORMER_CAP_VHT_SU) beamforming_send_vht_ndpa_packet(Adapter,pBeamEntry->mac_addr,pBeamEntry->aid,pBeamEntry->sound_bw, BCN_QUEUE_INX); else beamforming_send_ht_ndpa_packet(Adapter,pBeamEntry->mac_addr,pBeamEntry->sound_bw, BCN_QUEUE_INX); @@ -4498,16 +4309,15 @@ SetBeamformDownloadNDPA_8812( // check rsvd page download OK. BcnValidReg = rtw_read8(Adapter, REG_TDECTRL+2); count=0; - while(!(BcnValidReg & BIT0) && count <20) - { + while(!(BcnValidReg & BIT0) && count <20) { count++; rtw_udelay_os(10); BcnValidReg = rtw_read8(Adapter, REG_TDECTRL+2); } DLBcnCount++; - } while(!(BcnValidReg&BIT0) && DLBcnCount<5); + } while (!(BcnValidReg&BIT0) && DLBcnCount<5); - if(!(BcnValidReg&BIT0)) + if (!(BcnValidReg&BIT0)) RTW_INFO("%s Download RSVD page failed!\n", __FUNCTION__); // TDECTRL[15:8] 0x209[7:0] = 0xF6 Beacon Head for TXDMA @@ -4518,8 +4328,7 @@ SetBeamformDownloadNDPA_8812( // prevent from setting 0x422[6] to 0 after download reserved page, or it will cause // the beacon cannot be sent by HW. // 2010.06.23. Added by tynli. - if(bSendBeacon) - { + if (bSendBeacon) { rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+2, tmpReg422); } @@ -4655,10 +4464,8 @@ static void hw_var_set_opmode(PADAPTER Adapter, u8 variable, u8* val) RTW_INFO("%s()-%d mode = %d\n", __FUNCTION__, __LINE__, mode); - if((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) - { - if(!check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE)) - { + if((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) { + if(!check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE)) { StopTxBeacon(Adapter); #ifdef CONFIG_PCI_HCI UpdateInterruptMask8814AE(Adapter, 0, 0, RT_BCN_INT_MASKS, 0); @@ -4893,8 +4700,7 @@ static void hw_var_set_macaddr(PADAPTER Adapter, u8 variable, u8* val) u32 reg_macid; #ifdef CONFIG_CONCURRENT_MODE - if(Adapter->iface_type == IFACE_PORT1) - { + if (Adapter->iface_type == IFACE_PORT1) { reg_macid = REG_MACID1; } else @@ -4903,8 +4709,7 @@ static void hw_var_set_macaddr(PADAPTER Adapter, u8 variable, u8* val) reg_macid = REG_MACID; } - for(idx = 0 ; idx < 6; idx++) - { + for (idx = 0 ; idx < 6; idx++) { rtw_write8(GET_PRIMARY_ADAPTER(Adapter), (reg_macid+idx), val[idx]); } @@ -4916,8 +4721,7 @@ static void hw_var_set_bssid(PADAPTER Adapter, u8 variable, u8* val) u32 reg_bssid; #ifdef CONFIG_CONCURRENT_MODE - if(Adapter->iface_type == IFACE_PORT1) - { + if (Adapter->iface_type == IFACE_PORT1) { reg_bssid = REG_BSSID1; } else @@ -4926,8 +4730,7 @@ static void hw_var_set_bssid(PADAPTER Adapter, u8 variable, u8* val) reg_bssid = REG_BSSID; } - for(idx = 0 ; idx < 6; idx++) - { + for (idx = 0 ; idx < 6; idx++) { rtw_write8(Adapter, (reg_bssid+idx), val[idx]); } @@ -4938,8 +4741,7 @@ static void hw_var_set_bcn_func(PADAPTER Adapter, u8 variable, u8* val) u32 bcn_ctrl_reg; u8 val8; #ifdef CONFIG_CONCURRENT_MODE - if(Adapter->iface_type == IFACE_PORT1) - { + if(Adapter->iface_type == IFACE_PORT1) { bcn_ctrl_reg = REG_BCN_CTRL_1; } else @@ -4948,8 +4750,7 @@ static void hw_var_set_bcn_func(PADAPTER Adapter, u8 variable, u8* val) bcn_ctrl_reg = REG_BCN_CTRL; } - if(*((u8 *)val)) - { + if(*((u8 *)val)) { rtw_write8(Adapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); } else { @@ -4958,8 +4759,7 @@ static void hw_var_set_bcn_func(PADAPTER Adapter, u8 variable, u8* val) val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT); #ifdef CONFIG_BT_COEXIST - if (GET_HAL_DATA(Adapter)->EEPROMBluetoothCoexist == 1) - { + if (GET_HAL_DATA(Adapter)->EEPROMBluetoothCoexist == 1) { // Always enable port0 beacon function for PSTDMA if (REG_BCN_CTRL == bcn_ctrl_reg) val8 |= EN_BCN_FUNCTION; @@ -4983,22 +4783,19 @@ static void hw_var_set_correct_tsf(PADAPTER Adapter, u8 variable, u8* val) //tsf = pmlmeext->TSFValue - ((u32)pmlmeext->TSFValue % (pmlmeinfo->bcn_interval*1024)) -1024; //us tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) -1024; //us - if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { + if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { //pHalData->RegTxPause |= STOP_BCNQ;BIT(6) //rtw_write8(Adapter, REG_TXPAUSE, (rtw_read8(Adapter, REG_TXPAUSE)|BIT(6))); StopTxBeacon(Adapter); } - if(Adapter->iface_type == IFACE_PORT1) - { + if(Adapter->iface_type == IFACE_PORT1) { //disable related TSF function rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1)&(~BIT(3))); rtw_write32(Adapter, REG_TSFTR1, tsf); rtw_write32(Adapter, REG_TSFTR1+4, tsf>>32); - //enable related TSF function rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1)|BIT(3)); @@ -5055,8 +4852,7 @@ static void hw_var_set_correct_tsf(PADAPTER Adapter, u8 variable, u8* val) } - if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { + if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { //pHalData->RegTxPause &= (~STOP_BCNQ); //rtw_write8(Adapter, REG_TXPAUSE, (rtw_read8(Adapter, REG_TXPAUSE)&(~BIT(6)))); ResumeTxBeacon(Adapter); @@ -5072,8 +4868,7 @@ static void hw_var_set_mlme_disconnect(PADAPTER Adapter, u8 variable, u8* val) if(check_buddy_mlmeinfo_state(Adapter, _HW_STATE_NOLINK_)) rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); - if(Adapter->iface_type == IFACE_PORT1) - { + if(Adapter->iface_type == IFACE_PORT1) { //reset TSF1 rtw_write8(Adapter, REG_DUAL_TSF_RST, BIT(1)); @@ -5138,16 +4933,14 @@ static void hw_var_set_mlme_sitesurvey(PADAPTER Adapter, u8 variable, u8* val) } #ifdef CONFIG_TDLS // TDLS will clear RCR_CBSSID_DATA bit for connection. - else if (Adapter->tdlsinfo.link_established == _TRUE) - { + else if (Adapter->tdlsinfo.link_established == _TRUE) { rcr_clear_bit = RCR_CBSSID_BCN; } #endif // CONFIG_TDLS value_rcr = rtw_read32(Adapter, REG_RCR); - if(*((u8 *)val))//under sitesurvey - { + if (*((u8 *)val)) { //under sitesurvey value_rcr &= ~(rcr_clear_bit); rtw_write32(Adapter, REG_RCR, value_rcr); @@ -5163,9 +4956,7 @@ static void hw_var_set_mlme_sitesurvey(PADAPTER Adapter, u8 variable, u8* val) if (ap_num) StopTxBeacon(Adapter); - } - else//sitesurvey done - { + } else { //sitesurvey done if(check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) #ifdef CONFIG_CONCURRENT_MODE || check_buddy_fwstate(Adapter, (_FW_LINKED|WIFI_AP_STATE)) @@ -5220,9 +5011,8 @@ static void hw_var_set_mlme_join(PADAPTER Adapter, u8 variable, u8* val) HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - if(type == 0) // prepare to join - { - if(check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE) && + if (type == 0) { // prepare to join + if (check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE) && check_buddy_fwstate(Adapter, _FW_LINKED)) { StopTxBeacon(Adapter); @@ -5232,28 +5022,23 @@ static void hw_var_set_mlme_join(PADAPTER Adapter, u8 variable, u8* val) //rtw_write32(padapter, REG_RCR, rtw_read32(padapter, REG_RCR)|RCR_ADF); rtw_write16(Adapter, REG_RXFLTMAP2,0xFFFF); - if(check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE)) - { + if(check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE)) { rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); } else { rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); } - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) - { + if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) { RetryLimit = (pHalData->CustomerID == RT_CID_CCX) ? 7 : 48; - } - else // Ad-hoc Mode - { + } else { // Ad-hoc Mode RetryLimit = 0x7; } } - else if(type == 1) //joinbss_event call back when join res < 0 - { - if(check_buddy_mlmeinfo_state(Adapter, _HW_STATE_NOLINK_)) + else if (type == 1) { //joinbss_event call back when join res < 0 + if (check_buddy_mlmeinfo_state(Adapter, _HW_STATE_NOLINK_)) rtw_write16(Adapter, REG_RXFLTMAP2,0x00); - if(check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE) && + if (check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE) && check_buddy_fwstate(Adapter, _FW_LINKED)) { ResumeTxBeacon(Adapter); @@ -5263,24 +5048,21 @@ static void hw_var_set_mlme_join(PADAPTER Adapter, u8 variable, u8* val) } } - else if(type == 2) //sta add event call back - { + else if (type == 2) { //sta add event call back //enable update TSF - if(Adapter->iface_type == IFACE_PORT1) + if (Adapter->iface_type == IFACE_PORT1) rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1)&(~BIT(4))); else rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); - if(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { //fixed beacon issue for 8191su........... rtw_write8(Adapter,0x542 ,0x02); RetryLimit = 0x7; } - - if(check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE) && + if (check_buddy_mlmeinfo_state(Adapter, WIFI_FW_AP_STATE) && check_buddy_fwstate(Adapter, _FW_LINKED)) { ResumeTxBeacon(Adapter); @@ -5426,13 +5208,10 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) input_b = BrateCfg; /* apply force and allow mask */ - if(pHalData->CurrentBandType == BAND_ON_2_4G) - { + if(pHalData->CurrentBandType == BAND_ON_2_4G) { BrateCfg |= rrsr_2g_force_mask; BrateCfg &= rrsr_2g_allow_mask; - } - else // 5G - { + } else { // 5G BrateCfg |= rrsr_5g_force_mask; BrateCfg &= rrsr_5g_allow_mask; } @@ -5476,8 +5255,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) //tsf = pmlmeext->TSFValue - ((u32)pmlmeext->TSFValue % (pmlmeinfo->bcn_interval*1024)) -1024; //us tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) -1024; //us - if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { //pHalData->RegTxPause |= STOP_BCNQ;BIT(6) //rtw_write8(padapter, REG_TXPAUSE, (rtw_read8(padapter, REG_TXPAUSE)|BIT(6))); StopTxBeacon(padapter); @@ -5493,8 +5271,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) //enable related TSF function rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)|BIT(3)); - if(((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { //pHalData->RegTxPause &= (~STOP_BCNQ); //rtw_write8(padapter, REG_TXPAUSE, (rtw_read8(padapter, REG_TXPAUSE)&(~BIT(6)))); ResumeTxBeacon(padapter); @@ -5555,8 +5332,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) u8 type = *(u8*)pval; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (type == 0) // prepare to join - { + if (type == 0) { // prepare to join //enable to rx data frame.Accept all data frame //rtw_write32(padapter, REG_RCR, rtw_read32(padapter, REG_RCR)|RCR_ADF); rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF); @@ -5568,12 +5344,9 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) val32 |= RCR_CBSSID_DATA|RCR_CBSSID_BCN; rtw_write32(padapter, REG_RCR, val32); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) - { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) { RetryLimit = (pHalData->CustomerID == RT_CID_CCX) ? 7 : 48; - } - else // Ad-hoc Mode - { + } else { // Ad-hoc Mode RetryLimit = 0x7; } } @@ -5588,8 +5361,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) val8 &= ~BIT(4); rtw_write8(padapter, REG_BCN_CTRL, val8); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { RetryLimit = 0x7; } } @@ -5600,8 +5372,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) #endif // !CONFIG_CONCURRENT_MODE #ifdef CONFIG_BT_COEXIST - if (_TRUE == pHalData->EEPROMBluetoothCoexist) - { + if (_TRUE == pHalData->EEPROMBluetoothCoexist) { switch (*pval) { case 0: @@ -5614,7 +5385,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) break; case 2: // sta add event callback - // rtw_btcoex_MediaStatusNotify(padapter, RT_MEDIA_CONNECT); + // rtw_btcoex_MediaStatusNotify(padapter, RT_MEDIA_CONNECT); break; } } @@ -5647,10 +5418,9 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) pmlmeinfo = &pmlmeext->mlmext_info; bcn_interval = *((u16*)pval); - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) - { + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { RTW_INFO("%s==> bcn_interval:%d, eraly_int:%d\n", __FUNCTION__, bcn_interval, bcn_interval>>1); - rtw_write8(padapter, REG_DRVERLYINT, bcn_interval>>1);// 50ms for sdio + rtw_write8(padapter, REG_DRVERLYINT, bcn_interval>>1); // 50ms for sdio } } #endif // CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT @@ -5690,11 +5460,9 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) u32 ulContent = 0; u32 ulEncAlgo = CAM_AES; - for (i=0; i HW_VAR_ANTENNA_DIVERSITY_SELECT , Ant_(%s)\n",(Optimum_antenna==2)?"A":"B"); - if (pHalData->CurAntenna != Optimum_antenna) - { + if (pHalData->CurAntenna != Optimum_antenna) { Ant = (Optimum_antenna==2) ? MAIN_ANT : AUX_ANT; ODM_UpdateRxIdleAnt(podmpriv, Ant); @@ -5867,8 +5634,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) // keep sn rtw_store_all_sta_hwseq(padapter); - if (pwrpriv->bkeepfwalive != _TRUE) - { + if (pwrpriv->bkeepfwalive != _TRUE) { // RX DMA stop val32 = rtw_read32(padapter, REG_RXPKT_NUM); val32 |= RW_RELEASE_EN; @@ -5879,8 +5645,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) if (val32) break; } while (--trycnt); - if (trycnt == 0) - { + if (trycnt == 0) { RTW_INFO("[HW_VAR_FIFO_CLEARN_UP] Stop RX DMA failed......\n"); } @@ -5971,8 +5736,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) { u32 usNavUpper = *((u32*)pval); - if (usNavUpper > HAL_NAV_UPPER_UNIT * 0xFF) - { + if (usNavUpper > HAL_NAV_UPPER_UNIT * 0xFF) { RTW_INFO("%s: [HW_VAR_NAV_UPPER] set value(0x%08X us) is larger than (%d * 0xFF)!\n", __FUNCTION__, usNavUpper, HAL_NAV_UPPER_UNIT); break; @@ -5987,8 +5751,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) case HW_VAR_BCN_VALID: #ifdef CONFIG_CONCURRENT_MODE - if (padapter->iface_type == IFACE_PORT1) - { + if (padapter->iface_type == IFACE_PORT1) { /* BCN_VALID, BIT31 of REG_FIFOPAGE_CTRL_2_8814A, write 1 to clear, Clear by sw */ val8 = rtw_read8(padapter, REG_FIFOPAGE_CTRL_2_8814A+3); val8 |= BIT(7); @@ -6007,8 +5770,7 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) case HW_VAR_DL_BCN_SEL: #if 0 /* for MBSSID, so far we don't need this */ #ifdef CONFIG_CONCURRENT_MODE - if (IS_HARDWARE_TYPE_8821(padapter) && padapter->iface_type == IFACE_PORT1) - { + if (IS_HARDWARE_TYPE_8821(padapter) && padapter->iface_type == IFACE_PORT1) { // SW_BCN_SEL - Port1 val8 = rtw_read8(padapter, REG_AUTO_LLT_8814A); val8 |= BIT(2); @@ -6078,10 +5840,8 @@ void SetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) break; case HW_VAR_DL_RSVD_PAGE: #ifdef CONFIG_BT_COEXIST - if (pHalData->EEPROMBluetoothCoexist == 1) - { - if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _TRUE) - { + if (pHalData->EEPROMBluetoothCoexist == 1) { + if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _TRUE) { rtl8814a_download_BTCoex_AP_mode_rsvd_page(padapter); } } @@ -6319,8 +6079,7 @@ void GetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) case HW_VAR_BCN_VALID: #ifdef CONFIG_CONCURRENT_MODE - if (padapter->iface_type == IFACE_PORT1) - { + if (padapter->iface_type == IFACE_PORT1) { /* BCN_VALID, BIT31 of REG_FIFOPAGE_CTRL_2_8814A, write 1 to clear */ val8 = rtw_read8(padapter, REG_FIFOPAGE_CTRL_2_8814A+3); *pval = (BIT(7) & val8) ? _TRUE:_FALSE; @@ -6336,14 +6095,11 @@ void GetHwReg8814A(PADAPTER padapter, u8 variable, u8 *pval) case HW_VAR_FWLPS_RF_ON: //When we halt NIC, we should check if FW LPS is leave. - if(adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off) - { + if(adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off) { // If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, // because Fw is unload. *pval = _TRUE; - } - else - { + } else { u32 valRCR; valRCR = rtw_read32(padapter, REG_RCR); valRCR &= 0x00070000; @@ -6548,8 +6304,7 @@ u8 GetHalDefVar8814A(PADAPTER padapter, HAL_DEF_VARIABLE variable, void *pval) break; case HAL_DEF_TX_PAGE_BOUNDARY: - if (!padapter->registrypriv.wifi_spec) - { + if (!padapter->registrypriv.wifi_spec) { *(u16*)pval = TX_PAGE_BOUNDARY_8814A; } else { *(u16*)pval = WMM_NORMAL_TX_PAGE_BOUNDARY_8814A; @@ -6618,8 +6373,7 @@ void rtl8812a_combo_card_WifiOnlyHwInit(PADAPTER pdapter) { u8 u1Tmp; RTW_INFO("%s !\n", __FUNCTION__); - if(IS_HARDWARE_TYPE_8812(pdapter)) - { + if(IS_HARDWARE_TYPE_8812(pdapter)) { //0x790[5:0]=0x5 u1Tmp = rtw_read8(pdapter,0x790); u1Tmp = (u1Tmp & 0xb0) | 0x05 ; From 53ebbdd11aa799e178b2b90818f0e0f9c3dddb6b Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 08:04:30 +0100 Subject: [PATCH 02/12] Code cleanup --- hal/rtl8814a/rtl8814a_cmd.c | 304 +++++++++++++++--------------------- 1 file changed, 125 insertions(+), 179 deletions(-) diff --git a/hal/rtl8814a/rtl8814a_cmd.c b/hal/rtl8814a/rtl8814a_cmd.c index ef9e01f..48c8d9b 100644 --- a/hal/rtl8814a/rtl8814a_cmd.c +++ b/hal/rtl8814a/rtl8814a_cmd.c @@ -39,14 +39,14 @@ static u8 _is_fw_read_cmd_down(_adapter* padapter, u8 msgbox_num) //RTW_INFO(" _is_fw_read_cmd_down ,reg_1cc(%x),msg_box(%d)...\n",rtw_read8(padapter,REG_HMETFR),msgbox_num); - do{ + do { valid = rtw_read8(padapter,REG_HMETFR) & BIT(msgbox_num); - if(0 == valid ){ + if (0 == valid ){ read_down = _TRUE; } else rtw_msleep_os(1); - }while( (!read_down) && (retry_cnts--)); + } while( (!read_down) && (retry_cnts--)); return read_down; @@ -74,12 +74,11 @@ s32 FillH2CCmd_8814(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer) u32 h2c_cmd_ex = 0; s32 ret = _FAIL; - padapter = GET_PRIMARY_ADAPTER(padapter); + padapter = GET_PRIMARY_ADAPTER(padapter); pHalData = GET_HAL_DATA(padapter); - - if(padapter->bFWReady == _FALSE) - { + + if(padapter->bFWReady == _FALSE) { //RTW_INFO("FillH2CCmd_8814(): return H2C cmd because fw is not ready\n"); return ret; } @@ -97,29 +96,28 @@ s32 FillH2CCmd_8814(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer) goto exit; //pay attention to if race condition happened in H2C cmd setting. - do{ + do { h2c_box_num = pHalData->LastHMEBoxNum; - if(!_is_fw_read_cmd_down(padapter, h2c_box_num)){ + if (!_is_fw_read_cmd_down(padapter, h2c_box_num)){ RTW_INFO(" fw read cmd failed...\n"); goto exit; } *(u8*)(&h2c_cmd) = ElementID; - if(CmdLen<=3) - { + if(CmdLen<=3) { _rtw_memcpy((u8*)(&h2c_cmd)+1, pCmdBuffer, CmdLen ); } - else{ + else { _rtw_memcpy((u8*)(&h2c_cmd)+1, pCmdBuffer,3); - ext_cmd_len = CmdLen-3; + ext_cmd_len = CmdLen-3; _rtw_memcpy((u8*)(&h2c_cmd_ex), pCmdBuffer+3,ext_cmd_len ); //Write Ext command msgbox_ex_addr = REG_HMEBOX_EXT0_8814A + (h2c_box_num *RTL8814_EX_MESSAGE_BOX_SIZE); #ifdef CONFIG_H2C_EF - for(cmd_idx=0;cmd_idxLastHMEBoxNum ,CmdLen,msgbox_addr,h2c_cmd,msgbox_ex_addr,h2c_cmd_ex); pHalData->LastHMEBoxNum = (h2c_box_num+1) % RTL8814_MAX_H2C_BOX_NUMS; - - }while(0); + + } while(0); ret = _SUCCESS; exit: - _exit_critical_mutex(&(adapter_to_dvobj(padapter)->h2c_fwcmd_mutex), NULL); + _exit_critical_mutex(&(adapter_to_dvobj(padapter)->h2c_fwcmd_mutex), NULL); return ret; } @@ -170,7 +168,7 @@ void rtl8814_fw_update_beacon_cmd(_adapter *padapter) { u8 param[2] = {0}; u16 txpktbuf_bndy; - + SET_8814A_H2CCMD_BCNHWSEQ_EN(param, 1); SET_8814A_H2CCMD_BCNHWSEQ_BCN_NUMBER(param, 0); SET_8814A_H2CCMD_BCNHWSEQ_HWSEQ(param, 1); @@ -181,7 +179,7 @@ void rtl8814_fw_update_beacon_cmd(_adapter *padapter) FillH2CCmd_8814(padapter, 0xC2, 2, param); else FillH2CCmd_8814(padapter, H2C_BCNHWSEQ, 2, param); - + /*RTW_INFO("%s, %d, correct beacon HW sequence, FirmwareVersion=%d, H2C_BCNHWSEQ=%d\n", __func__, __LINE__, GET_HAL_DATA(padapter)->FirmwareVersion, H2C_BCNHWSEQ);*/ } @@ -194,29 +192,27 @@ u8 Get_VHT_ENI( { u8 Ret = 0; - if(WirelessMode == WIRELESS_11_24AC) - { - if(ratr_bitmap & 0xfff00000) // Mix , 2SS + if (WirelessMode == WIRELESS_11_24AC) { + if (ratr_bitmap & 0xfff00000) // Mix , 2SS Ret = 3; else // Mix, 1SS Ret = 2; } - else if(WirelessMode == WIRELESS_11_5AC) - { + else if (WirelessMode == WIRELESS_11_5AC) { Ret = 1; // VHT } return (Ret << 4); } -BOOLEAN -Get_RA_ShortGI_8814( +BOOLEAN +Get_RA_ShortGI_8814( PADAPTER Adapter, struct sta_info *psta, u8 shortGIrate, u32 ratr_bitmap ) -{ +{ BOOLEAN bShortGI; struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -224,13 +220,13 @@ Get_RA_ShortGI_8814( bShortGI = shortGIrate; #ifdef CONFIG_80211AC_VHT - if( bShortGI && + if ( bShortGI && IsSupportedVHT(psta->wireless_mode) && (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP) && TEST_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_ENABLE_TX) ) { - if(ratr_bitmap & 0xC0000000) + if (ratr_bitmap & 0xC0000000) bShortGI = _FALSE; } #endif //CONFIG_80211AC_VHT @@ -245,19 +241,17 @@ Set_RA_LDPC_8814( BOOLEAN bLDPC ) { - if(psta == NULL) + if (psta == NULL) return; #ifdef CONFIG_80211AC_VHT - if(psta->wireless_mode == WIRELESS_11_5AC) - { - if(bLDPC && TEST_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_CAP_TX)) + if (psta->wireless_mode == WIRELESS_11_5AC) { + if (bLDPC && TEST_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_CAP_TX)) SET_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_ENABLE_TX); else CLEAR_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_ENABLE_TX); } - else if(IsSupportedHT(psta->wireless_mode) || IsSupportedVHT(psta->wireless_mode)) - { - if(bLDPC && TEST_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_CAP_TX)) + else if(IsSupportedHT(psta->wireless_mode) || IsSupportedVHT(psta->wireless_mode)) { + if (bLDPC && TEST_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_CAP_TX)) SET_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_ENABLE_TX); else CLEAR_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_ENABLE_TX); @@ -270,33 +264,31 @@ Set_RA_LDPC_8814( } -u8 +u8 Get_RA_LDPC_8814( struct sta_info *psta ) -{ +{ u8 bLDPC = 0; if (psta != NULL) { - if(psta->mac_id == 1) { + if (psta->mac_id == 1) { bLDPC = 0; } else { #ifdef CONFIG_80211AC_VHT - if(IsSupportedVHT(psta->wireless_mode)) + if (IsSupportedVHT(psta->wireless_mode)) { - if(TEST_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_CAP_TX)) + if (TEST_FLAG(psta->vhtpriv.ldpc_cap, LDPC_VHT_CAP_TX)) bLDPC = 1; else bLDPC = 0; - } - else if(IsSupportedHT(psta->wireless_mode)) - { - if(TEST_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_CAP_TX)) + } + else if (IsSupportedHT(psta->wireless_mode)) { + if (TEST_FLAG(psta->htpriv.ldpc_cap, LDPC_HT_CAP_TX)) bLDPC =1; else bLDPC =0; - } - else + } else #endif bLDPC = 0; } @@ -326,29 +318,27 @@ void rtl8814_set_raid_cmd(PADAPTER padapter, u64 bitmap, u8* arg, u8 bw) } - if(pHalData->fw_ractrl == _TRUE) - { + if (pHalData->fw_ractrl == _TRUE) { u8 H2CCommand[7] ={0}; shortGIrate = Get_RA_ShortGI_8814(padapter, psta, shortGIrate, bitmap); - + H2CCommand[0] = macid; H2CCommand[1] = (raid & 0x1F) | (shortGIrate?0x80:0x00) ; H2CCommand[2] = (psta->bw_mode & 0x3) |Get_RA_LDPC_8814(psta) |Get_VHT_ENI(0, psta->wireless_mode, bitmap); //DisableTXPowerTraining - if(pHalData->bDisableTXPowerTraining){ + if (pHalData->bDisableTXPowerTraining) { H2CCommand[2] |= BIT6; RTW_INFO("%s,Disable PWT by driver\n",__FUNCTION__); - } - else{ + } else { PDM_ODM_T pDM_OutSrc = &pHalData->odmpriv; - - if(pDM_OutSrc->bDisablePowerTraining){ + + if (pDM_OutSrc->bDisablePowerTraining){ H2CCommand[2] |= BIT6; RTW_INFO("%s, Disable PWT by DM\n",__FUNCTION__); } - } + } H2CCommand[3] = (u8)(bitmap & 0x000000ff); H2CCommand[4] = (u8)((bitmap & 0x0000ff00) >>8); @@ -360,11 +350,11 @@ void rtl8814_set_raid_cmd(PADAPTER padapter, u64 bitmap, u8* arg, u8 bw) FillH2CCmd_8814(padapter, H2C_MACID_CFG, 7, H2CCommand); - // For 3SS rate, extend H2C cmd + // For 3SS rate, extend H2C cmd H2CCommand[3] = (u8)((bitmap>>32) & 0x000000ff); H2CCommand[4] = (u8)(((bitmap>>32) & 0x0000ff00) >>8); FillH2CCmd_8814(padapter, H2C_RA_MASK_3SS, 5, H2CCommand); - + } if (shortGIrate==_TRUE) @@ -408,11 +398,9 @@ void rtl8814_set_FwPwrMode_cmd(PADAPTER padapter, u8 PSMode) break; } - if (Mode > PS_MODE_ACTIVE) - { + if (Mode > PS_MODE_ACTIVE) { #ifdef CONFIG_BT_COEXIST - if ((rtw_btcoex_IsBtControlLps(padapter) == _TRUE) && (_TRUE == pHalData->EEPROMBluetoothCoexist)) - { + if ((rtw_btcoex_IsBtControlLps(padapter) == _TRUE) && (_TRUE == pHalData->EEPROMBluetoothCoexist)) { PowerState = rtw_btcoex_RpwmVal(padapter); pwrModeByte5 = rtw_btcoex_LpsVal(padapter); } @@ -426,16 +414,14 @@ void rtl8814_set_FwPwrMode_cmd(PADAPTER padapter, u8 PSMode) #ifdef CONFIG_EXT_CLK Mode |= BIT(7);//supporting 26M XTAL CLK_Request feature. #endif //CONFIG_EXT_CLK - } - else - { + } else { PowerState = 0x0C;// AllON(0x0C), RFON(0x04), RFOFF(0x00) pwrModeByte5 = 0x40; } // 0: Active, 1: LPS, 2: WMMPS SET_8814A_H2CCMD_PWRMODE_PARM_MODE(u1H2CSetPwrMode, Mode); - + // 0:Min, 1:Max , 2:User define SET_8814A_H2CCMD_PWRMODE_PARM_RLBM(u1H2CSetPwrMode, RLBM); @@ -508,8 +494,7 @@ void ConstructBeacon(_adapter *padapter, u8 *pframe, u32 *pLength) pframe += 2; pktlen += 2; - if( (pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) - { + if ( (pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { //RTW_INFO("ie len=%d\n", cur_network->IELength); pktlen += cur_network->IELength - sizeof(NDIS_802_11_FIXED_IEs); _rtw_memcpy(pframe, cur_network->IEs+sizeof(NDIS_802_11_FIXED_IEs), pktlen); @@ -529,8 +514,7 @@ void ConstructBeacon(_adapter *padapter, u8 *pframe, u32 *pLength) // DS parameter set pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); - if( (pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) - { + if ( (pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; // IBSS Parameter Set... //ATIMWindow = cur->Configuration.ATIMWindow; @@ -543,8 +527,7 @@ void ConstructBeacon(_adapter *padapter, u8 *pframe, u32 *pLength) // EXTERNDED SUPPORTED RATE - if (rate_len > 8) - { + if (rate_len > 8) { pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); } @@ -553,8 +536,7 @@ void ConstructBeacon(_adapter *padapter, u8 *pframe, u32 *pLength) _ConstructBeacon: - if ((pktlen + TXDESC_SIZE) > 512) - { + if ((pktlen + TXDESC_SIZE) > 512) { RTW_INFO("beacon frame too large\n"); return; } @@ -620,8 +602,7 @@ void ConstructNullFunctionData( fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; - if (bForcePowerSave) - { + if (bForcePowerSave) { SetPwrMgt(fctrl); } @@ -678,7 +659,6 @@ void ConstructProbeRsp(_adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network); - //RTW_INFO("%s\n", __FUNCTION__); pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -698,7 +678,7 @@ void ConstructProbeRsp(_adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); pframe += pktlen; - if(cur_network->IELength>MAX_IE_SZ) + if (cur_network->IELength>MAX_IE_SZ) return; _rtw_memcpy(pframe, cur_network->IEs, cur_network->IELength); @@ -758,8 +738,7 @@ static void ConstructGTKResponse( //------------------------------------------------------------------------- // Qos Header: leave space for it if necessary. //------------------------------------------------------------------------- - if(pStaQos->CurrentQosMode > QOS_DISABLE) - { + if(pStaQos->CurrentQosMode > QOS_DISABLE) { SET_80211_HDR_QOS_EN(pGTKRspPkt, 1); PlatformZeroMemory(&(Buffer[*pLength]), sQoSCtlLng); *pLength += sQoSCtlLng; @@ -777,8 +756,8 @@ static void ConstructGTKResponse( EncryptionHeadOverhead = 4; break; case _TKIP_: - EncryptionHeadOverhead = 8; - break; + EncryptionHeadOverhead = 8; + break; case _AES_: EncryptionHeadOverhead = 8; break; @@ -790,29 +769,28 @@ static void ConstructGTKResponse( default: EncryptionHeadOverhead = 0; } - - if(EncryptionHeadOverhead > 0) - { + + if (EncryptionHeadOverhead > 0) { _rtw_memset(&(pframe[*pLength]), 0,EncryptionHeadOverhead); *pLength += EncryptionHeadOverhead; //SET_80211_HDR_WEP(pGTKRspPkt, 1); //Suggested by CCW. //GTK's privacy bit is done by FW //SetPrivacy(fctrl); - } + } #endif //1 //------------------------------------------------------------------------- // Frame Body. //------------------------------------------------------------------------- - pGTKRspPkt = (u8*)(pframe+ *pLength); + pGTKRspPkt = (u8*)(pframe+ *pLength); // LLC header - _rtw_memcpy(pGTKRspPkt, LLCHeader, 8); + _rtw_memcpy(pGTKRspPkt, LLCHeader, 8); *pLength += 8; // GTK element pGTKRspPkt += 8; - + //GTK frame body after LLC, part 1 - _rtw_memcpy(pGTKRspPkt, GTKbody_a, 11); + _rtw_memcpy(pGTKRspPkt, GTKbody_a, 11); *pLength += 11; pGTKRspPkt += 11; //GTK frame body after LLC, part 2 @@ -833,8 +811,7 @@ CheckFwRsvdPageContent( HAL_DATA_TYPE* pHalData = GET_HAL_DATA(Adapter); u32 MaxBcnPageNum; - if(pHalData->FwRsvdPageStartOffset != 0) - { + if(pHalData->FwRsvdPageStartOffset != 0) { /*MaxBcnPageNum = PageNum_128(pMgntInfo->MaxBeaconSize); RT_ASSERT((MaxBcnPageNum <= pHalData->FwRsvdPageStartOffset), ("CheckFwRsvdPageContent(): The reserved page content has been"\ @@ -855,21 +832,17 @@ GetTxBufferRsvdPageNum8814(_adapter *Adapter, bool bWoWLANBoundary) u8 RsvdPageNum=0; u16 TxPageBndy= LAST_ENTRY_OF_TX_PKT_BUFFER_8814A; // default reseved 1 page for the IC type which is undefined. - if(bWoWLANBoundary) - { + if(bWoWLANBoundary) { rtw_hal_get_def_var(Adapter, HAL_DEF_TX_PAGE_BOUNDARY_WOWLAN, (u8 *)&TxPageBndy); - } - else - { + } else { rtw_hal_get_def_var(Adapter, HAL_DEF_TX_PAGE_BOUNDARY, (u8 *)&TxPageBndy); } - + RsvdPageNum = LAST_ENTRY_OF_TX_PKT_BUFFER_8814A -TxPageBndy + 1; return RsvdPageNum; } - void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); @@ -882,8 +855,7 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) RTW_INFO("%s mstatus(%x)\n", __FUNCTION__,mstatus); - if(mstatus == 1) - { + if(mstatus == 1) { // We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. // Suggested by filen. Added by tynli. rtw_write16(padapter, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid)); @@ -897,7 +869,7 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) pHalData->RegCR_1 |= BIT0; rtw_write8(padapter, REG_CR+1, pHalData->RegCR_1); /*RTW_INFO("%s-%d: enable SW BCN, REG_CR=0x%x\n", __func__, __LINE__, rtw_read32(padapter, REG_CR));*/ - + // Disable Hw protection for a time which revserd for Hw sending beacon. // Fix download reserved page packet fail that access collision with the protection time. // 2010.05.11. Added by tynli. @@ -905,9 +877,8 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) //SetBcnCtrlReg(padapter, BIT4, 0); rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)&(~BIT(3))); rtw_write8(padapter, REG_BCN_CTRL, rtw_read8(padapter, REG_BCN_CTRL)|BIT(4)); - - if(pHalData->RegFwHwTxQCtrl&BIT6) - { + + if(pHalData->RegFwHwTxQCtrl&BIT6) { RTW_INFO("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n"); bSendBeacon = _TRUE; } @@ -920,22 +891,20 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); DLBcnCount = 0; poll = 0; - do - { + do { // download rsvd page. rtw_hal_set_fw_rsvd_page(padapter, _FALSE); DLBcnCount++; - do - { + do { rtw_yield_os(); //rtw_mdelay_os(10); // check rsvd page download OK. rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8*)(&bcn_valid)); poll++; } while (!bcn_valid && (poll%10) != 0 && !RTW_CANNOT_RUN(padapter)); - + } while (!bcn_valid && DLBcnCount <= 100 && !RTW_CANNOT_RUN(padapter)); - + //RT_ASSERT(bcn_valid, ("HalDownloadRSVDPage88ES(): 1 Download RSVD page failed!\n")); if (RTW_CANNOT_RUN(padapter)) ; @@ -955,21 +924,17 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) // the beacon TCB in the following code. 2011.11.23. by tynli. // //if(bcn_valid && padapter->bEnterPnpSleep) - if(0) - { - if(bSendBeacon) - { + if(0) { + if(bSendBeacon) { rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); DLBcnCount = 0; poll = 0; - do - { + do { //SetFwRsvdPagePkt_8812(padapter, _TRUE); rtw_hal_set_fw_rsvd_page(padapter, _TRUE); DLBcnCount++; - - do - { + + do { rtw_yield_os(); //rtw_mdelay_os(10); // check rsvd page download OK. @@ -977,7 +942,7 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) poll++; } while (!bcn_valid && (poll%10) != 0 && !RTW_CANNOT_RUN(padapter)); } while (!bcn_valid && DLBcnCount <= 100 && !RTW_CANNOT_RUN(padapter)); - + //RT_ASSERT(bcn_valid, ("HalDownloadRSVDPage(): 2 Download RSVD page failed!\n")); if (RTW_CANNOT_RUN(padapter)) ; @@ -996,11 +961,10 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) // To make sure that if there exists an adapter which would like to send beacon. // If exists, the origianl value of 0x422[6] will be 1, we should check this to - // prevent from setting 0x422[6] to 0 after download reserved page, or it will cause + // prevent from setting 0x422[6] to 0 after download reserved page, or it will cause // the beacon cannot be sent by HW. // 2010.06.23. Added by tynli. - if(bSendBeacon) - { + if(bSendBeacon) { rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, (pHalData->RegFwHwTxQCtrl|BIT6)); pHalData->RegFwHwTxQCtrl |= BIT6; } @@ -1008,13 +972,12 @@ void rtl8814_set_FwJoinBssReport_cmd(PADAPTER padapter, u8 mstatus) // // Update RSVD page location H2C to Fw. // - if(bcn_valid) - { + if(bcn_valid) { rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); RTW_INFO("Set RSVD page location to Fw.\n"); //FillH2CCmd88E(Adapter, H2C_88E_RSVDPAGE, H2C_RSVDPAGE_LOC_LENGTH, pMgntInfo->u1RsvdPageLoc); } - + // Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. //if(!padapter->bEnterPnpSleep) { @@ -1047,18 +1010,16 @@ void rtl8814_set_p2p_ps_offload_cmd(_adapter* padapter, u8 p2p_ps_state) case P2P_PS_ENABLE: RTW_INFO("P2P_PS_ENABLE \n"); // update CTWindow value. - if( pwdinfo->ctwindow > 0 ) - { + if( pwdinfo->ctwindow > 0 ) { SET_8814A_H2CCMD_P2P_PS_OFFLOAD_CTWINDOW_EN(p2p_ps_offload, 1); - rtw_write8(padapter, REG_P2P_CTWIN, pwdinfo->ctwindow); + rtw_write8(padapter, REG_P2P_CTWIN, pwdinfo->ctwindow); } // hw only support 2 set of NoA - for( i=0 ; inoa_num ; i++) - { + for ( i = 0 ; inoa_num ; i++) { // To control the register setting for which NOA rtw_write8(padapter, REG_NOA_DESC_SEL, (i << 4)); - if(i == 0) { + if (i == 0) { SET_8814A_H2CCMD_P2P_PS_OFFLOAD_NOA0_EN(p2p_ps_offload, 1); } else { SET_8814A_H2CCMD_P2P_PS_OFFLOAD_NOA1_EN(p2p_ps_offload, 1); @@ -1078,21 +1039,17 @@ void rtl8814_set_p2p_ps_offload_cmd(_adapter* padapter, u8 p2p_ps_state) rtw_write8(padapter, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]); } - if( (pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0) ) - { + if( (pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0) ) { // rst p2p circuit: reg 0x5F0 rtw_write8(padapter, REG_P2P_RST_8814A, BIT(0)); //rst p2p 0 circuit NOA 0 SET_8814A_H2CCMD_P2P_PS_OFFLOAD_ENABLE(p2p_ps_offload, 1); - if(pwdinfo->role == P2P_ROLE_GO) - { + if (pwdinfo->role == P2P_ROLE_GO) { // 1: Owner, 0: Client SET_8814A_H2CCMD_P2P_PS_OFFLOAD_ROLE(p2p_ps_offload, 1); SET_8814A_H2CCMD_P2P_PS_OFFLOAD_ALLSTASLEEP(p2p_ps_offload, 0); - } - else - { + } else { // 1: Owner, 0: Client SET_8814A_H2CCMD_P2P_PS_OFFLOAD_ROLE(p2p_ps_offload, 0); } @@ -1125,7 +1082,7 @@ void rtl8814_set_p2p_ps_offload_cmd(_adapter* padapter, u8 p2p_ps_state) ask FW to Reset sync register at Beacon early interrupt */ u8 rtl8814_reset_tsf(_adapter *padapter, u8 reset_port ) -{ +{ u8 buf[2]; u8 res=_SUCCESS; @@ -1180,7 +1137,7 @@ static void rtl8814_set_FwRsvdPage_cmd(PADAPTER padapter, PRSVDPAGE_LOC rsvdpage SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1H2CRsvdPageParm, rsvdpageloc->LocNullData); SET_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(u1H2CRsvdPageParm, rsvdpageloc->LocQosNull); SET_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(u1H2CRsvdPageParm, rsvdpageloc->LocBTQosNull); - + RTW_INFO_DUMP("u1H2CRsvdPageParm:", u1H2CRsvdPageParm, H2C_RSVDPAGE_LOC_LEN); FillH2CCmd_8814(padapter, H2C_RSVD_PAGE, H2C_RSVDPAGE_LOC_LEN, u1H2CRsvdPageParm); } @@ -1191,7 +1148,7 @@ static void rtl8814_set_FwAoacRsvdPage_cmd(PADAPTER padapter, PRSVDPAGE_LOC rsvd struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 res = 0, count = 0; -#ifdef CONFIG_WOWLAN +#ifdef CONFIG_WOWLAN u8 u1H2CAoacRsvdPageParm[H2C_AOAC_RSVDPAGE_LOC_LEN]={0}; RTW_INFO("8192EAOACRsvdPageLoc: RWC=%d ArpRsp=%d NbrAdv=%d GtkRsp=%d GtkInfo=%d ProbeReq=%d NetworkList=%d\n", @@ -1258,7 +1215,7 @@ void rtl8814_iqk_done(_adapter* padapter) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct submit_ctx *iqk_sctx = &pHalData->iqk_sctx; - + rtw_sctx_done(&iqk_sctx); } @@ -1299,7 +1256,7 @@ C2HTxFeedbackHandler_8814( s32 _C2HContentParsing8814( IN PADAPTER Adapter, - IN u8 c2hCmdId, + IN u8 c2hCmdId, IN u8 c2hCmdLen, IN u8 *tmpBuf ) @@ -1402,7 +1359,7 @@ C2HPacketHandler_8814( c2hCmdSeq = Buffer[1]; c2hCmdLen = Length -2; tmpBuf = Buffer+2; - + //RTW_INFO("[C2H packet], c2hCmdId=0x%x, c2hCmdSeq=0x%x, c2hCmdLen=%d\n", c2hCmdId, c2hCmdSeq, c2hCmdLen); #ifdef CONFIG_BT_COEXIST @@ -1424,7 +1381,7 @@ C2HPacketHandler_8814( #endif /* CONFIG_BT_COEXIST */ { /* handle directly */ -#ifdef CONFIG_BEAMFORMING +#ifdef CONFIG_BEAMFORMING if (c2hCmdId == C2H_TXBF) { /* enqueue */ c2h_evt = (struct c2h_evt_hdr_88xx *)rtw_zmalloc(16); @@ -1465,16 +1422,14 @@ void ConstructBtNullFunctionData( pwlanhdr = (struct rtw_ieee80211_hdr*)pframe; - if (NULL == StaAddr) - { + if (NULL == StaAddr) { _rtw_memcpy(bssid, adapter_mac_addr(padapter), ETH_ALEN); StaAddr = bssid; } - + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; - if (bForcePowerSave) - { + if (bForcePowerSave) { SetPwrMgt(fctrl); } @@ -1509,7 +1464,7 @@ void ConstructBtNullFunctionData( static void SetFwRsvdPagePkt_BTCoex(PADAPTER padapter) { PHAL_DATA_TYPE pHalData; - struct xmit_frame *pcmdframe; + struct xmit_frame *pcmdframe; struct pkt_attrib *pattrib; struct xmit_priv *pxmitpriv; struct mlme_ext_priv *pmlmeext; @@ -1554,10 +1509,9 @@ static void SetFwRsvdPagePkt_BTCoex(PADAPTER padapter) // When we count the first page size, we need to reserve description size for the RSVD // packet, it will be filled in front of the packet in TXPKTBUF. CurtPktPageNum = (u8)PageNum(TxDescLen + BeaconLength, PageSize); - + //If we don't add 1 more page, the WOWLAN function has a problem. Baron thinks it's a bug of firmware - if (CurtPktPageNum == 1) - { + if (CurtPktPageNum == 1) { CurtPktPageNum += 1; } TotalPageNum += CurtPktPageNum; @@ -1565,13 +1519,12 @@ static void SetFwRsvdPagePkt_BTCoex(PADAPTER padapter) BufIndex += (CurtPktPageNum*PageSize); // Jump to lastest page - if (BufIndex < (MaxRsvdPageBufSize - PageSize)) - { + if (BufIndex < (MaxRsvdPageBufSize - PageSize)) { BufIndex = TxDescOffset + (MaxRsvdPageBufSize - PageSize); TotalPageNum = BCNQ_PAGE_NUM_8814-1; - + } - + //3 (6) BT Qos null data RsvdPageLoc.LocBTQosNull = TotalPageNum; ConstructBtNullFunctionData( @@ -1582,7 +1535,7 @@ static void SetFwRsvdPagePkt_BTCoex(PADAPTER padapter) _TRUE, 0, 0, _FALSE); rtl8814a_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], BTQosNullLength, _FALSE, _TRUE, _FALSE); - //RTW_INFO("%s(): HW_VAR_SET_TX_CMD: BT QOS NULL DATA %p %d\n", + //RTW_INFO("%s(): HW_VAR_SET_TX_CMD: BT QOS NULL DATA %p %d\n", // __FUNCTION__, &ReservedPagePacket[BufIndex-TxDescLen], (BTQosNullLength+TxDescLen)); CurtPktPageNum = (u8)PageNum(TxDescLen + BTQosNullLength,PageSize); @@ -1590,14 +1543,11 @@ static void SetFwRsvdPagePkt_BTCoex(PADAPTER padapter) TotalPageNum += CurtPktPageNum; TotalPacketLen = BufIndex + BTQosNullLength; - if(TotalPacketLen > MaxRsvdPageBufSize) - { + if(TotalPacketLen > MaxRsvdPageBufSize) { RTW_INFO("%s(): ERROR: The rsvd page size is not enough!!TotalPacketLen %d, MaxRsvdPageBufSize %d\n",__FUNCTION__, TotalPacketLen,MaxRsvdPageBufSize); goto error; - } - else - { + } else { // update attribute pattrib = &pcmdframe->attrib; update_mgntframe_attrib(padapter, pattrib); @@ -1611,13 +1561,13 @@ static void SetFwRsvdPagePkt_BTCoex(PADAPTER padapter) } RTW_INFO("%s: Set RSVD page location to Fw ,TotalPacketLen(%d), TotalPageNum(%d)\n", __FUNCTION__,TotalPacketLen,TotalPageNum); - if(check_fwstate(pmlmepriv, _FW_LINKED)) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { rtl8814_set_FwRsvdPage_cmd(padapter, &RsvdPageLoc); #ifdef CONFIG_WOWLAN rtl8814_set_FwAoacRsvdPage_cmd(padapter, &RsvdPageLoc); #endif - } - + } + return; error: @@ -1673,24 +1623,22 @@ void rtl8812a_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter) DLBcnCount = 0; poll = 0; - do - { + do { SetFwRsvdPagePkt_BTCoex(padapter); DLBcnCount++; - do - { + do { rtw_yield_os(); //rtw_mdelay_os(10); // check rsvd page download OK. rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8*)(&bcn_valid)); poll++; } while (!bcn_valid && (poll%10) != 0 && !RTW_CANNOT_RUN(padapter)); - + } while (!bcn_valid && DLBcnCount <= 100 && !RTW_CANNOT_RUN(padapter)); if (RTW_CANNOT_RUN(padapter)) ; - else if(!bcn_valid) + else if (!bcn_valid) RTW_INFO(ADPT_FMT": 1 DL RSVD page failed! DLBcnCount:%u, poll:%u\n", ADPT_ARG(padapter) ,DLBcnCount, poll); else { @@ -1711,8 +1659,7 @@ void rtl8812a_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter) // prevent from setting 0x422[6] to 0 after download reserved page, or it will cause // the beacon cannot be sent by HW. // 2010.06.23. Added by tynli. - if(bRecover) - { + if (bRecover) { rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl | BIT(6)); pHalData->RegFwHwTxQCtrl |= BIT(6); } @@ -1727,4 +1674,3 @@ void rtl8812a_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter) } #endif // CONFIG_BT_COEXIST - From cfa89ead2f513436ae4a240a4c66df5899dab2d1 Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 08:09:53 +0100 Subject: [PATCH 03/12] Code cleanup --- hal/rtl8814a/rtl8814a_dm.c | 109 ++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 63 deletions(-) diff --git a/hal/rtl8814a/rtl8814a_dm.c b/hal/rtl8814a/rtl8814a_dm.c index 8087395..92ee51e 100644 --- a/hal/rtl8814a/rtl8814a_dm.c +++ b/hal/rtl8814a/rtl8814a_dm.c @@ -46,18 +46,15 @@ dm_CheckProtection( PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo); u1Byte CurRate, RateThreshold; - if(pMgntInfo->pHTInfo->bCurBW40MHz) + if (pMgntInfo->pHTInfo->bCurBW40MHz) RateThreshold = MGN_MCS1; else RateThreshold = MGN_MCS3; - if(Adapter->TxStats.CurrentInitTxRate <= RateThreshold) - { + if(Adapter->TxStats.CurrentInitTxRate <= RateThreshold) { pMgntInfo->bDmDisableProtect = TRUE; DbgPrint("Forced disable protect: %x\n", Adapter->TxStats.CurrentInitTxRate); - } - else - { + } else { pMgntInfo->bDmDisableProtect = FALSE; DbgPrint("Enable protect: %x\n", Adapter->TxStats.CurrentInitTxRate); } @@ -70,7 +67,7 @@ dm_CheckStatistics( ) { #if 0 - if(!Adapter->MgntInfo.bMediaConnect) + if (!Adapter->MgntInfo.bMediaConnect) return; //2008.12.10 tynli Add for getting Current_Tx_Rate_Reg flexibly. @@ -98,14 +95,13 @@ static void dm_CheckPbcGPIO(_adapter *padapter) #endif /* CONFIG_BT_COEXIST */ #if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) - + tmp1byte = rtw_read8(padapter, REG_GPIO_EXT_CTRL_8814A); //DBG_871X("CheckPbcGPIO - %x\n", tmp1byte); if (tmp1byte == 0xff) return ; - else if (tmp1byte & BIT3) - { + else if (tmp1byte & BIT3) { // Here we only set bPbcPressed to TRUE. After trigger PBC, the variable will be set to FALSE DBG_871X("CheckPbcGPIO - PBC is pressed\n"); bPbcPressed = _TRUE; @@ -113,8 +109,7 @@ static void dm_CheckPbcGPIO(_adapter *padapter) #endif - if( _TRUE == bPbcPressed) - { + if ( _TRUE == bPbcPressed) { // Here we only set bPbcPressed to true // After trigger PBC, the variable will be set to false DBG_871X("CheckPbcGPIO - PBC is pressed\n"); @@ -145,7 +140,6 @@ dm_InterruptMigration( BOOLEAN IntMtToSet = _FALSE; BOOLEAN ACIntToSet = _FALSE; - // Retrieve current interrupt migration and Tx four ACs IMR settings first. bCurrentIntMt = pHalData->bInterruptMigration; bCurrentACIntDisable = pHalData->bDisableTxInt; @@ -154,22 +148,21 @@ dm_InterruptMigration( // Currently we use busy traffic for reference instead of RxIntOK counts to prevent non-linear Rx statistics // when interrupt migration is set before. 2010.03.05. // - if(!Adapter->registrypriv.wifi_spec && + if (!Adapter->registrypriv.wifi_spec && (check_fwstate(pmlmepriv, _FW_LINKED)== _TRUE) && pmlmepriv->LinkDetectInfo.bHigherBusyTraffic) { IntMtToSet = _TRUE; // To check whether we should disable Tx interrupt or not. - if(pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic) + if (pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic) ACIntToSet = _TRUE; } //Update current settings. - if( bCurrentIntMt != IntMtToSet ){ + if ( bCurrentIntMt != IntMtToSet ) { DBG_8192C("%s(): Update interrrupt migration(%d)\n",__FUNCTION__,IntMtToSet); - if(IntMtToSet) - { + if(IntMtToSet) { // // Set interrrupt migration timer and corresponging Tx/Rx counter. // timer 25ns*0xfa0=100us for 0xf packets. @@ -177,9 +170,7 @@ dm_InterruptMigration( // rtw_write32(Adapter, REG_INT_MIG, 0xff000fa0);// 0x306:Rx, 0x307:Tx pHalData->bInterruptMigration = IntMtToSet; - } - else - { + } else { // Reset all interrupt migration settings. rtw_write32(Adapter, REG_INT_MIG, 0); pHalData->bInterruptMigration = IntMtToSet; @@ -232,7 +223,7 @@ dm_InitGPIOSetting( //============================================================ static void Init_ODM_ComInfo_8814(PADAPTER Adapter) { - PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); + PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); u32 SupportAbility = 0; @@ -243,20 +234,20 @@ static void Init_ODM_ComInfo_8814(PADAPTER Adapter) ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_IC_TYPE, ODM_RTL8814A); fab_ver = ODM_TSMC; - if(IS_A_CUT(pHalData->VersionID)) + if (IS_A_CUT(pHalData->VersionID)) cut_ver = ODM_CUT_A; - else if(IS_B_CUT(pHalData->VersionID)) + else if (IS_B_CUT(pHalData->VersionID)) cut_ver = ODM_CUT_B; - else if(IS_C_CUT(pHalData->VersionID)) + else if (IS_C_CUT(pHalData->VersionID)) cut_ver = ODM_CUT_C; - else if(IS_D_CUT(pHalData->VersionID)) + else if (IS_D_CUT(pHalData->VersionID)) cut_ver = ODM_CUT_D; - else if(IS_E_CUT(pHalData->VersionID)) + else if (IS_E_CUT(pHalData->VersionID)) cut_ver = ODM_CUT_E; else cut_ver = ODM_CUT_A; - ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_FAB_VER,fab_ver); + ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_FAB_VER,fab_ver); ODM_CmnInfoInit(pDM_Odm,ODM_CMNINFO_CUT_VER,cut_ver); ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_RF_ANTENNA_TYPE, pHalData->TRxAntDivType); @@ -268,13 +259,13 @@ static void Init_ODM_ComInfo_8814(PADAPTER Adapter) #else SupportAbility = ODM_RF_CALIBRATION| ODM_RF_TX_PWR_TRACK - ; + ; /*if(pHalData->AntDivCfg) SupportAbility |= ODM_BB_ANT_DIV;*/ - #endif + #endif ODM_CmnInfoUpdate(pDM_Odm,ODM_CMNINFO_ABILITY,SupportAbility); - + } static void Update_ODM_ComInfo_8814(PADAPTER Adapter) @@ -301,7 +292,7 @@ static void Update_ODM_ComInfo_8814(PADAPTER Adapter) SupportAbility |= ODM_BB_ADAPTIVITY; } - if(pHalData->AntDivCfg) + if (pHalData->AntDivCfg) SupportAbility |= ODM_BB_ANT_DIV; #if (MP_DRIVER==1) @@ -372,7 +363,7 @@ rtl8814_HalDmWatchDog( #ifdef CONFIG_P2P_PS // Fw is under p2p powersaving mode, driver should stop dynamic mechanism. // modifed by thomas. 2011.06.11. - if(Adapter->wdinfo.p2p_ps_mode) + if (Adapter->wdinfo.p2p_ps_mode) bFwPSAwake = _FALSE; #endif //CONFIG_P2P_PS @@ -381,7 +372,7 @@ rtl8814_HalDmWatchDog( // // Calculate Tx/Rx statistics. // - dm_CheckStatistics(Adapter); + dm_CheckStatistics(Adapter); rtw_hal_check_rxfifo_full(Adapter); // // Dynamically switch RTS/CTS protection. @@ -396,12 +387,11 @@ rtl8814_HalDmWatchDog( //if(Adapter->HalFunc.TxCheckStuckHandler(Adapter)) // PlatformScheduleWorkItem(&(GET_HAL_DATA(Adapter)->HalResetWorkItem)); #endif - + } //ODM - if (rtw_is_hw_init_completed(Adapter)) - { + if (rtw_is_hw_init_completed(Adapter)) { u8 bLinked=_FALSE; u8 bsta_state=_FALSE; u8 bBtDisabled = _TRUE; @@ -410,16 +400,16 @@ rtl8814_HalDmWatchDog( pHalData->odmpriv.SupportAbility = 0; #endif - if(rtw_linked_check(Adapter)){ + if (rtw_linked_check(Adapter)) { bLinked = _TRUE; if (check_fwstate(&Adapter->mlmepriv, WIFI_STATION_STATE)) bsta_state = _TRUE; } - + #ifdef CONFIG_CONCURRENT_MODE - if(pbuddy_adapter && rtw_linked_check(pbuddy_adapter)){ + if (pbuddy_adapter && rtw_linked_check(pbuddy_adapter)){ bLinked = _TRUE; - if(pbuddy_adapter && check_fwstate(&pbuddy_adapter->mlmepriv, WIFI_STATION_STATE)) + if (pbuddy_adapter && check_fwstate(&pbuddy_adapter->mlmepriv, WIFI_STATION_STATE)) bsta_state = _TRUE; } #endif //CONFIG_CONCURRENT_MODE @@ -433,7 +423,7 @@ rtl8814_HalDmWatchDog( ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_BT_ENABLED, ((bBtDisabled == _TRUE)?_FALSE:_TRUE)); ODM_DMWatchdog(&pHalData->odmpriv); - + } skip_dm: @@ -463,7 +453,7 @@ void rtl8814_init_dm_priv(IN PADAPTER Adapter) } Init_ODM_ComInfo_8814(Adapter); - ODM_InitAllTimers(podmpriv ); + ODM_InitAllTimers(podmpriv ); PHYDM_InitDebugSetting(podmpriv); pHalData->CurrentTxPwrIdx = 18; @@ -475,7 +465,7 @@ void rtl8814_deinit_dm_priv(IN PADAPTER Adapter) PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); PDM_ODM_T podmpriv = &pHalData->odmpriv; //_rtw_spinlock_free(&pHalData->odm_stainfo_lock); - ODM_CancelAllTimers(podmpriv); + ODM_CancelAllTimers(podmpriv); } @@ -486,17 +476,15 @@ void rtl8814_deinit_dm_priv(IN PADAPTER Adapter) void AntDivCompare8814(PADAPTER Adapter, WLAN_BSSID_EX *dst, WLAN_BSSID_EX *src) { //PADAPTER Adapter = pDM_Odm->Adapter ; - + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - if(0 != pHalData->AntDivCfg ) - { + if (0 != pHalData->AntDivCfg ) { //DBG_8192C("update_network=> orgRSSI(%d)(%d),newRSSI(%d)(%d)\n",dst->Rssi,query_rx_pwr_percentage(dst->Rssi), // src->Rssi,query_rx_pwr_percentage(src->Rssi)); //select optimum_antenna for before linked =>For antenna diversity - if(dst->Rssi >= src->Rssi )//keep org parameter - { + if (dst->Rssi >= src->Rssi ) { //keep org parameter src->Rssi = dst->Rssi; - src->PhyInfo.Optimum_antenna = dst->PhyInfo.Optimum_antenna; + src->PhyInfo.Optimum_antenna = dst->PhyInfo.Optimum_antenna; } } } @@ -504,26 +492,24 @@ void AntDivCompare8814(PADAPTER Adapter, WLAN_BSSID_EX *dst, WLAN_BSSID_EX *src) // Add new function to reset the state of antenna diversity before link. u8 AntDivBeforeLink8814(PADAPTER Adapter ) { - - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); + + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); PDM_ODM_T pDM_Odm =&pHalData->odmpriv; SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); - + // Condition that does not need to use antenna diversity. - if(pHalData->AntDivCfg==0) - { + if (pHalData->AntDivCfg==0) { //DBG_8192C("odm_AntDivBeforeLink8192C(): No AntDiv Mechanism.\n"); return _FALSE; } - if(check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) - { + if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) { return _FALSE; } - if(pDM_SWAT_Table->SWAS_NoLink_State == 0){ + if (pDM_SWAT_Table->SWAS_NoLink_State == 0) { //switch channel pDM_SWAT_Table->SWAS_NoLink_State = 1; pDM_SWAT_Table->CurAntenna = (pDM_SWAT_Table->CurAntenna==MAIN_ANT)?AUX_ANT:MAIN_ANT; @@ -532,13 +518,10 @@ u8 AntDivBeforeLink8814(PADAPTER Adapter ) rtw_antenna_select_cmd(Adapter, pDM_SWAT_Table->CurAntenna, _FALSE); //DBG_8192C("%s change antenna to ANT_( %s ).....\n",__FUNCTION__, (pDM_SWAT_Table->CurAntenna==MAIN_ANT)?"MAIN":"AUX"); return _TRUE; - } - else - { + } else { pDM_SWAT_Table->SWAS_NoLink_State = 0; return _FALSE; - } + } } #endif //CONFIG_ANTENNA_DIVERSITY - From abc37bc4e4f5dfa210d1c185469ec5b22899eaca Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 17:14:34 +0100 Subject: [PATCH 04/12] Code cleanup --- hal/rtl8814a/rtl8814a_phycfg.c | 1021 ++++++++++++++------------------ 1 file changed, 432 insertions(+), 589 deletions(-) diff --git a/hal/rtl8814a/rtl8814a_phycfg.c b/hal/rtl8814a/rtl8814a_phycfg.c index 8b3caa3..423ba9f 100644 --- a/hal/rtl8814a/rtl8814a_phycfg.c +++ b/hal/rtl8814a/rtl8814a_phycfg.c @@ -72,23 +72,20 @@ PHY_SetBBReg8814A( #if(SIC_ENABLE == 1) SIC_SetBBReg(Adapter, RegAddr, BitMask, Data); - return; + return; #endif - if(BitMask!= bMaskDWord) - {//if not "double word" write + if (BitMask!= bMaskDWord) { //if not "double word" write OriginalValue = rtw_read32(Adapter, RegAddr); BitShift = PHY_CalculateBitShift(BitMask); Data = ((OriginalValue) & (~BitMask)) |( ((Data << BitShift)) & BitMask); } rtw_write32(Adapter, RegAddr, Data); - + //RTW_INFO("BBW MASK=0x%x Addr[0x%x]=0x%x\n", BitMask, RegAddr, Data); } - - static u32 phy_RFRead_8814A( IN PADAPTER Adapter, @@ -98,10 +95,10 @@ phy_RFRead_8814A( ) { u32 DataAndAddr = 0; - u32 Readback_Value, Direct_Addr; - + u32 Readback_Value, Direct_Addr; + RegAddr &= 0xff; - switch(eRFPath){ + switch (eRFPath) { case ODM_RF_PATH_A: Direct_Addr = 0x2800+RegAddr*4; break; @@ -118,11 +115,11 @@ phy_RFRead_8814A( Direct_Addr = 0x2800+RegAddr*4; break; } - + BitMask &= bRFRegOffsetMask; - - Readback_Value = PHY_QueryBBReg(Adapter, Direct_Addr, BitMask); + + Readback_Value = PHY_QueryBBReg(Adapter, Direct_Addr, BitMask); //RTW_INFO("RFR-%d Addr[0x%x]=0x%x\n", eRFPath, RegAddr, Readback_Value); return Readback_Value; @@ -154,9 +151,9 @@ phy_RFWrite_8814A( //PHY_RFShadowWrite(Adapter, eRFPath, Offset, Data); // Put write addr in [27:20] and write data in [19:00] - DataAndAddr = ((Offset<<20) | (Data&0x000fffff)) & 0x0fffffff; + DataAndAddr = ((Offset<<20) | (Data&0x000fffff)) & 0x0fffffff; - // Write Operation + // Write Operation PHY_SetBBReg(Adapter, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); //RTW_INFO("RFW-%d Addr[0x%x]=0x%x\n", eRFPath, pPhyReg->rf3wireOffset, DataAndAddr); } @@ -170,12 +167,12 @@ PHY_QueryRFReg8814A( IN u32 BitMask ) { - u32 Readback_Value; + u32 Readback_Value; #if (DISABLE_BB_RF == 1) return 0; #endif - + Readback_Value = phy_RFRead_8814A(Adapter, eRFPath, RegAddr, BitMask); return (Readback_Value); @@ -196,7 +193,7 @@ PHY_SetRFReg8814A( return; #endif - if(BitMask == 0) + if (BitMask == 0) return; RegAddr &= 0xff; @@ -208,9 +205,8 @@ PHY_SetRFReg8814A( BitShift = PHY_CalculateBitShift(BitMask); Data = ((Original_Value) & (~BitMask)) | (Data<< BitShift); } - - phy_RFWrite_8814A(Adapter, eRFPath, RegAddr, Data); + phy_RFWrite_8814A(Adapter, eRFPath, RegAddr, Data); } @@ -246,7 +242,7 @@ phy_InitBBRFRegisterDefinition( IN PADAPTER Adapter ) { - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); // RF Interface Sowrtware Control pHalData->PHYRegDef[ODM_RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 LSBs if read 32-bit from 0x870 @@ -260,16 +256,13 @@ phy_InitBBRFRegisterDefinition( pHalData->PHYRegDef[ODM_RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) pHalData->PHYRegDef[ODM_RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) - if(IS_HARDWARE_TYPE_JAGUAR_AND_JAGUAR2(Adapter)) - { + if (IS_HARDWARE_TYPE_JAGUAR_AND_JAGUAR2(Adapter)) { pHalData->PHYRegDef[ODM_RF_PATH_A].rf3wireOffset = rA_LSSIWrite_Jaguar; //LSSI Parameter pHalData->PHYRegDef[ODM_RF_PATH_B].rf3wireOffset = rB_LSSIWrite_Jaguar; pHalData->PHYRegDef[ODM_RF_PATH_A].rfHSSIPara2 = rHSSIRead_Jaguar; //wire control parameter2 pHalData->PHYRegDef[ODM_RF_PATH_B].rfHSSIPara2 = rHSSIRead_Jaguar; //wire control parameter2 - } - else - { + } else { pHalData->PHYRegDef[ODM_RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; //LSSI Parameter pHalData->PHYRegDef[ODM_RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; @@ -277,35 +270,30 @@ phy_InitBBRFRegisterDefinition( pHalData->PHYRegDef[ODM_RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; //wire control parameter2 } - if(IS_HARDWARE_TYPE_8814A(Adapter)) - { + if (IS_HARDWARE_TYPE_8814A(Adapter)) { pHalData->PHYRegDef[ODM_RF_PATH_C].rf3wireOffset = rC_LSSIWrite_Jaguar2; //LSSI Parameter pHalData->PHYRegDef[ODM_RF_PATH_D].rf3wireOffset = rD_LSSIWrite_Jaguar2; pHalData->PHYRegDef[ODM_RF_PATH_C].rfHSSIPara2 = rHSSIRead_Jaguar; //wire control parameter2 pHalData->PHYRegDef[ODM_RF_PATH_D].rfHSSIPara2 = rHSSIRead_Jaguar; //wire control parameter2 } - - if(IS_HARDWARE_TYPE_JAGUAR_AND_JAGUAR2(Adapter)) - { - // Tranceiver Readback LSSI/HSPI mode + + if (IS_HARDWARE_TYPE_JAGUAR_AND_JAGUAR2(Adapter)) { + // Tranceiver Readback LSSI/HSPI mode pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBack = rA_SIRead_Jaguar; pHalData->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBack = rB_SIRead_Jaguar; pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBackPi = rA_PIRead_Jaguar; pHalData->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBackPi = rB_PIRead_Jaguar; - } - else - { - // Tranceiver Readback LSSI/HSPI mode + } else { + // Tranceiver Readback LSSI/HSPI mode pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; pHalData->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; pHalData->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback; } - if(IS_HARDWARE_TYPE_8814A(Adapter)) - { - // Tranceiver Readback LSSI/HSPI mode + if (IS_HARDWARE_TYPE_8814A(Adapter)) { + // Tranceiver Readback LSSI/HSPI mode pHalData->PHYRegDef[ODM_RF_PATH_C].rfLSSIReadBack = rC_SIRead_Jaguar2; pHalData->PHYRegDef[ODM_RF_PATH_D].rfLSSIReadBack = rD_SIRead_Jaguar2; pHalData->PHYRegDef[ODM_RF_PATH_C].rfLSSIReadBackPi = rC_PIRead_Jaguar2; @@ -330,9 +318,9 @@ PHY_BBConfig8814( // . APLL_EN,,APLL_320_GATEB,APLL_320BIAS, auto config by hw fsm after pfsm_go (0x4 bit 8) set TmpU1B = PlatformEFIORead1Byte(Adapter, REG_SYS_FUNC_EN_8814A); - if(IS_HARDWARE_TYPE_8814AU(Adapter)) + if (IS_HARDWARE_TYPE_8814AU(Adapter)) TmpU1B |= FEN_USBA; - else if(IS_HARDWARE_TYPE_8814AE(Adapter)) + else if (IS_HARDWARE_TYPE_8814AE(Adapter)) TmpU1B |= FEN_PCIEA; PlatformEFIOWrite1Byte(Adapter, REG_SYS_FUNC_EN, TmpU1B); @@ -344,7 +332,7 @@ PHY_BBConfig8814( PlatformEFIOWrite1Byte(Adapter, REG_RF_CTRL0_8814A , 0x07);//RF_SDMRSTB,RF_RSTB,RF_EN same with 8723a //7. 0x20[7:0] = 0x07 PathB RF Power On //8. 0x21[7:0] = 0x07 PathC RF Power On - PlatformEFIOWrite2Byte(Adapter, REG_RF_CTRL1_8814A , 0x0707);//RF_SDMRSTB,RF_RSTB,RF_EN same with 8723a + PlatformEFIOWrite2Byte(Adapter, REG_RF_CTRL1_8814A , 0x0707);//RF_SDMRSTB,RF_RSTB,RF_EN same with 8723a //9. 0x76[7:0] = 0x07 PathD RF Power On PlatformEFIOWrite1Byte(Adapter, REG_RF_CTRL3_8814A , 0x7); @@ -354,7 +342,7 @@ PHY_BBConfig8814( rtStatus = phy_BB8814A_Config_ParaFile(Adapter); hal_set_crystal_cap(Adapter, pHalData->CrystalCap); - + switch (Adapter->registrypriv.rf_config) { case RF_1T1R: case RF_2T4R: @@ -376,8 +364,8 @@ PHY_BBConfig8814( RTW_INFO("%s, unknown rf_config: %d\n", __func__, Adapter->registrypriv.rf_config); break; } - - return rtStatus; + + return rtStatus; } int phy_BB8814A_Config_ParaFile( @@ -461,22 +449,22 @@ phy_ADC_CLK_8814A( BB_REG_8FC = PHY_QueryBBReg( Adapter, 0x8fc, bMaskDWord); BB_REG_808 = PHY_QueryBBReg( Adapter, 0x808, bMaskDWord); PHY_SetBBReg(Adapter, 0x520, bMaskByte2, 0x3f); - + //1 Step 2. Backup RXIQC & RXIQC = 0 - for(Search_index = 0; Search_index<4; Search_index++){ + for (Search_index = 0; Search_index<4; Search_index++){ RXIQC[Search_index] = PHY_QueryBBReg( Adapter, RXIQC_REG[0][Search_index], bMaskDWord); PHY_SetBBReg(Adapter, RXIQC_REG[0][Search_index], bMaskDWord, 0x0); PHY_SetBBReg(Adapter, RXIQC_REG[1][Search_index], bMaskDWord, 0x0); } PHY_SetBBReg(Adapter, 0xa14, 0x00000300, 0x3); Search_index = 0; - + //1 Step 3. Monitor MAC IDLE PHY_SetBBReg(Adapter, 0x8fc, bMaskDWord, 0x0); - while(MAC_Active){ + while (MAC_Active) { MAC_Active = PHY_QueryBBReg( Adapter, 0xfa0, bMaskDWord) & (0x803e0008); Search_index++; - if(Search_index>1000){ + if (Search_index>1000) { break; } } @@ -487,56 +475,56 @@ phy_ADC_CLK_8814A( PHY_SetBBReg(Adapter, 0x764, BIT(10)|BIT(9), 0x3); PHY_SetBBReg(Adapter, 0x804, BIT(2), 0x1); - // 0xc1c/0xe1c/0x181c/0x1a1c[4] must=1 to ensure table can be written when bbrstb=0 - // 0xc60/0xe60/0x1860/0x1a60[15] always = 1 after this line - // 0xc60/0xe60/0x1860/0x1a60[14] always = 0 bcz its error in A-cut + // 0xc1c/0xe1c/0x181c/0x1a1c[4] must=1 to ensure table can be written when bbrstb=0 + // 0xc60/0xe60/0x1860/0x1a60[15] always = 1 after this line + // 0xc60/0xe60/0x1860/0x1a60[14] always = 0 bcz its error in A-cut // power_off/clk_off @ anapar_state=idle mode - PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x15800002); //0xc60 0x15808002 + PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x15800002); //0xc60 0x15808002 PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x01808003); //0xc60 0x01808003 - PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x15800002); //0xe60 0x15808002 - PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x01808003); //0xe60 0x01808003 - PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x15800002); //0x1860 0x15808002 - PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x01808003); //0x1860 0x01808003 - PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x15800002); //0x1a60 0x15808002 - PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x01808003); //0x1a60 0x01808003 - + PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x15800002); //0xe60 0x15808002 + PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x01808003); //0xe60 0x01808003 + PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x15800002); //0x1860 0x15808002 + PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x01808003); //0x1860 0x01808003 + PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x15800002); //0x1a60 0x15808002 + PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x01808003); //0x1a60 0x01808003 + PHY_SetBBReg(Adapter, 0x764, BIT(10), 0x0); PHY_SetBBReg(Adapter, 0x804, BIT(2), 0x0); - PHY_SetBBReg(Adapter, 0xc5c, bMaskDWord, 0x0D080058); //0xc5c 0x00080058 // [19] =1 to turn off ADC - PHY_SetBBReg(Adapter, 0xe5c, bMaskDWord, 0x0D080058); //0xe5c 0x00080058 // [19] =1 to turn off ADC - PHY_SetBBReg(Adapter, 0x185c, bMaskDWord, 0x0D080058); //0x185c 0x00080058 // [19] =1 to turn off ADC - PHY_SetBBReg(Adapter, 0x1a5c, bMaskDWord, 0x0D080058); //0x1a5c 0x00080058 // [19] =1 to turn off ADC - - // power_on/clk_off + PHY_SetBBReg(Adapter, 0xc5c, bMaskDWord, 0x0D080058); //0xc5c 0x00080058 // [19] =1 to turn off ADC + PHY_SetBBReg(Adapter, 0xe5c, bMaskDWord, 0x0D080058); //0xe5c 0x00080058 // [19] =1 to turn off ADC + PHY_SetBBReg(Adapter, 0x185c, bMaskDWord, 0x0D080058); //0x185c 0x00080058 // [19] =1 to turn off ADC + PHY_SetBBReg(Adapter, 0x1a5c, bMaskDWord, 0x0D080058); //0x1a5c 0x00080058 // [19] =1 to turn off ADC + + // power_on/clk_off //PHY_SetBBReg(Adapter, 0x764, BIT(10), 0x1); - PHY_SetBBReg(Adapter, 0xc5c, bMaskDWord, 0x0D000058); //0xc5c 0x0D000058 // [19] =0 to turn on ADC - PHY_SetBBReg(Adapter, 0xe5c, bMaskDWord, 0x0D000058); //0xe5c 0x0D000058 // [19] =0 to turn on ADC - PHY_SetBBReg(Adapter, 0x185c, bMaskDWord, 0x0D000058); //0x185c 0x0D000058 // [19] =0 to turn on ADC - PHY_SetBBReg(Adapter, 0x1a5c, bMaskDWord, 0x0D000058); //0x1a5c 0x0D000058 // [19] =0 to turn on ADC + PHY_SetBBReg(Adapter, 0xc5c, bMaskDWord, 0x0D000058); //0xc5c 0x0D000058 // [19] =0 to turn on ADC + PHY_SetBBReg(Adapter, 0xe5c, bMaskDWord, 0x0D000058); //0xe5c 0x0D000058 // [19] =0 to turn on ADC + PHY_SetBBReg(Adapter, 0x185c, bMaskDWord, 0x0D000058); //0x185c 0x0D000058 // [19] =0 to turn on ADC + PHY_SetBBReg(Adapter, 0x1a5c, bMaskDWord, 0x0D000058); //0x1a5c 0x0D000058 // [19] =0 to turn on ADC // power_on/clk_on @ anapar_state=BT mode - PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x05808032); //0xc60 0x05808002 - PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x05808032); //0xe60 0x05808002 - PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x05808032); //0x1860 0x05808002 - PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x05808032); //0x1a60 0x05808002 - PHY_SetBBReg(Adapter, 0x764, BIT(10), 0x1); + PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x05808032); //0xc60 0x05808002 + PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x05808032); //0xe60 0x05808002 + PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x05808032); //0x1860 0x05808002 + PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x05808032); //0x1a60 0x05808002 + PHY_SetBBReg(Adapter, 0x764, BIT(10), 0x1); PHY_SetBBReg(Adapter, 0x804, BIT(2), 0x1); - // recover original setting @ anapar_state=BT mode - PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x05808032); //0xc60 0x05808036 - PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x05808032); //0xe60 0x05808036 - PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x05808032); //0x1860 0x05808036 - PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x05808032); //0x1a60 0x05808036 + // recover original setting @ anapar_state=BT mode + PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x05808032); //0xc60 0x05808036 + PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x05808032); //0xe60 0x05808036 + PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x05808032); //0x1860 0x05808036 + PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x05808032); //0x1a60 0x05808036 - PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x05800002); //0xc60 0x05800002 + PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x05800002); //0xc60 0x05800002 PHY_SetBBReg(Adapter, 0xc60, bMaskDWord, 0x07808003); //0xc60 0x07808003 - PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x05800002); //0xe60 0x05800002 - PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x07808003); //0xe60 0x07808003 - PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x05800002); //0x1860 0x05800002 - PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x07808003); //0x1860 0x07808003 - PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x05800002); //0x1a60 0x05800002 - PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x07808003); //0x1a60 0x07808003 + PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x05800002); //0xe60 0x05800002 + PHY_SetBBReg(Adapter, 0xe60, bMaskDWord, 0x07808003); //0xe60 0x07808003 + PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x05800002); //0x1860 0x05800002 + PHY_SetBBReg(Adapter, 0x1860, bMaskDWord, 0x07808003); //0x1860 0x07808003 + PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x05800002); //0x1a60 0x05800002 + PHY_SetBBReg(Adapter, 0x1a60, bMaskDWord, 0x07808003); //0x1a60 0x07808003 PHY_SetBBReg(Adapter, 0x764, BIT(10)|BIT(9), 0x0); PHY_SetBBReg(Adapter, 0x804, BIT(2), 0x0); @@ -546,7 +534,7 @@ phy_ADC_CLK_8814A( PHY_SetBBReg(Adapter, 0x520, bMaskDWord, MAC_REG_520); PHY_SetBBReg(Adapter, 0x8fc, bMaskDWord, BB_REG_8FC); PHY_SetBBReg(Adapter, 0x808, bMaskDWord, BB_REG_808); - for(Search_index = 0; Search_index<4; Search_index++){ + for (Search_index = 0; Search_index<4; Search_index++) { PHY_SetBBReg(Adapter, RXIQC_REG[0][Search_index], bMaskDWord, RXIQC[Search_index]); PHY_SetBBReg(Adapter, RXIQC_REG[1][Search_index], bMaskDWord, 0x01000000); } @@ -581,12 +569,11 @@ PHY_RFConfig8814A( if (rtw_is_surprise_removed(Adapter)) return _FAIL; - switch(pHalData->rf_chip) - { + switch (pHalData->rf_chip) { case RF_PSEUDO_11N: RTW_INFO("%s(): RF_PSEUDO_11N\n",__FUNCTION__); break; - default: + default: rtStatus = PHY_RF6052_Config_8814A(Adapter); break; } @@ -651,11 +638,10 @@ phy_SetRFPowerState_8814E( BOOLEAN bResult = TRUE; u8 i, QueueID; PRT_POWER_SAVE_CONTROL pPSC = GET_POWER_SAVE_CONTROL(pMgntInfo); - + pHalData->SetRFPowerStateInProgress = TRUE; - switch( eRFPowerState ) - { + switch ( eRFPowerState ) { // // SW radio on/IPS site survey call will execute all flow // HW radio on @@ -670,20 +656,17 @@ phy_SetRFPowerState_8814E( { // The current RF state is OFF and the RF OFF level is halting the NIC, re-initialize the NIC. s32 rtstatus; u32 InitializeCount = 0; - do - { + do { InitializeCount++; rtstatus = NicIFEnableNIC( Adapter ); }while( (rtstatus != _SUCCESS) &&(InitializeCount <10) ); RT_ASSERT(rtstatus == _SUCCESS,("Nic Initialize Fail\n")); RT_CLEAR_PS_LEVEL(Adapter, RT_RF_OFF_LEVL_HALT_NIC); - } - else - { // This is the normal case, we just turn on the RF. + } else { // This is the normal case, we just turn on the RF. phy_SetRTL8814ERfOn(Adapter); } - - // Turn on RF we are still linked, which might happen when + + // Turn on RF we are still linked, which might happen when // we quickly turn off and on HW RF. 2006.05.12, by rcnjko. if( pMgntInfo->bMediaConnect == TRUE ) Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK); @@ -694,51 +677,42 @@ phy_SetRFPowerState_8814E( // Card Disable/SW radio off/HW radio off/IPS enter call case eRfOff: - { + { // Make sure BusyQueue is empty befor turn off RFE pwoer. - for(QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) - { - if(RTIsListEmpty(&Adapter->TcbBusyQueue[QueueID])) - { + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + if(RTIsListEmpty(&Adapter->TcbBusyQueue[QueueID])) { QueueID++; continue; } - else if(IsLowPowerState(Adapter)) - { - RT_TRACE((COMP_POWER|COMP_RF), DBG_LOUD, + else if(IsLowPowerState(Adapter)) { + RT_TRACE((COMP_POWER|COMP_RF), DBG_LOUD, ("eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n", (i+1), QueueID)); break; - } - else - { - RT_TRACE((COMP_POWER|COMP_RF), DBG_LOUD, + } else { + RT_TRACE((COMP_POWER|COMP_RF), DBG_LOUD, ("eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID)); PlatformStallExecution(10); i++; } - - if(i >= MAX_DOZE_WAITING_TIMES_9x) - { + + if (i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE((COMP_POWER|COMP_RF), DBG_WARNING, ("\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID)); break; } } - if(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC) - { // Disable all components. + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC) { // Disable all components. NicIFDisableNIC(Adapter); if(IS_HARDWARE_TYPE_8814AE(Adapter)) NicIFEnableInterrupt(Adapter); RT_SET_PS_LEVEL(Adapter, RT_RF_OFF_LEVL_HALT_NIC); - } - else - { // Normal case. + } else { // Normal case. //If Rf off reason is from IPS, Led should blink with no link, by Maddest 071015 if(pMgntInfo->RfOffReason==RF_CHANGE_BY_IPS ) - Adapter->HalFunc.LedControlHandler(Adapter,LED_CTL_NO_LINK); + Adapter->HalFunc.LedControlHandler(Adapter,LED_CTL_NO_LINK); else // Turn off LED if RF is not ON. - Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF); + Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF); } } break; @@ -748,14 +722,13 @@ phy_SetRFPowerState_8814E( bResult = FALSE; RT_ASSERT(FALSE, ("phy_SetRFPowerState_8814E(): unknow state to set: 0x%X!!!\n", eRFPowerState)); break; - } + } - if(bResult) - { + if (bResult) { // Update current RF state variable. pHalData->eRFPowerState = eRFPowerState; } - + pHalData->SetRFPowerStateInProgress = FALSE; return bResult; @@ -774,23 +747,21 @@ phy_SetRFPowerState_8814U( BOOLEAN bResult = TRUE; u8 i, QueueID; PRT_USB_DEVICE pDevice = GET_RT_USB_DEVICE(Adapter); - - if(pHalData->SetRFPowerStateInProgress == TRUE) + + if (pHalData->SetRFPowerStateInProgress == TRUE) return FALSE; - + pHalData->SetRFPowerStateInProgress = TRUE; RT_TRACE(COMP_INIT, DBG_LOUD, ("======> phy_SetRFPowerState_8814U .\n")); - switch( eRFPowerState ) - { + switch ( eRFPowerState ) { case eRfOn: - if((pHalData->eRFPowerState == eRfOff) && + if ((pHalData->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(Adapter, RT_RF_OFF_LEVL_HALT_NIC)) { // The current RF state is OFF and the RF OFF level is halting the NIC, re-initialize the NIC. - RT_TRACE(COMP_RF, DBG_LOUD, ("======> phy_SetRFPowerState_8814U-eRfOn .\n")); + RT_TRACE(COMP_RF, DBG_LOUD, ("======> phy_SetRFPowerState_8814U-eRfOn .\n")); - if(!Adapter->bInHctTest) - { + if (!Adapter->bInHctTest) { // 2010/09/01 MH For 92CU, we do not make sure the RF B short initialize sequence // So disable the different RF on/off sequence for hidden AP. NicIFEnableNIC(Adapter); @@ -798,8 +769,8 @@ phy_SetRFPowerState_8814U( } } break; - - // + + // // In current solution, RFSleep=RFOff in order to save power under 802.11 power save. // By Bruce, 2008-01-16. // @@ -808,7 +779,7 @@ phy_SetRFPowerState_8814U( // ToDo: } break; - + case eRfOff: // HW setting had been configured. // Both of these RF configures are the same, configuring twice may cause HW abnormal. @@ -816,85 +787,76 @@ phy_SetRFPowerState_8814U( break; rtw_write8(Adapter, 0xf015, 0x40); //page added for usb3 bus // Make sure BusyQueue is empty befor turn off RFE pwoer. - for(QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) - { - if(RTIsListEmpty(&Adapter->TcbBusyQueue[QueueID])) - { + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + if(RTIsListEmpty(&Adapter->TcbBusyQueue[QueueID])) { QueueID++; continue; - } - else - { + } else { RT_TRACE(COMP_POWER, DBG_LOUD, ("eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID)); PlatformSleepUs(10); i++; } - - if(i >= MAX_DOZE_WAITING_TIMES_9x) - { + + if(i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE(COMP_POWER, DBG_LOUD, ("\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID)); break; } - } + } - // - //RF Off/Sleep sequence. Designed/tested from SD4 Scott, SD1 Grent and Jonbon. - // Added by // - //================================================================== + //RF Off/Sleep sequence. Designed/tested from SD4 Scott, SD1 Grent and Jonbon. + // Added by + // + //================================================================== // CU will call card disable flow to set RF off, such that we call halt directly // and set the PS_LEVEL to HALT_NIC or we might call halt twice in N6usbHalt in some cases. - // 2010.03.05. Added by tynli. + // 2010.03.05. Added by tynli. if(pMgntInfo->RfOffReason & RF_CHANGE_BY_IPS || pMgntInfo->RfOffReason & RF_CHANGE_BY_HW || pMgntInfo->RfOffReason & RF_CHANGE_BY_SW) { //for HW/Sw radio off and IPS flow - //RT_TRACE(COMP_INIT, DBG_LOUD, ("======> CardDisableWithoutHWSM -eRfOff.\n")); - if(!Adapter->bInHctTest) - { + //RT_TRACE(COMP_INIT, DBG_LOUD, ("======> CardDisableWithoutHWSM -eRfOff.\n")); + if(!Adapter->bInHctTest) { // 2010/09/01 MH For 92CU, we do not make sure the RF B short initialize sequence // So disable the different RF on/off sequence for hidden AP. NicIFDisableNIC(Adapter); RT_SET_PS_LEVEL(Adapter, RT_RF_OFF_LEVL_HALT_NIC); } - } + } break; default: bResult = FALSE; RT_ASSERT(FALSE, ("phy_SetRFPowerState_8814U(): unknow state to set: 0x%X!!!\n", eRFPowerState)); break; - } - - if(bResult) - { + } + + if (bResult) { // Update current RF state variable. pHalData->eRFPowerState = eRFPowerState; - - switch(pHalData->rf_chip ) - { - default: - switch(pHalData->eRFPowerState) - { + + switch (pHalData->rf_chip ) { + default: + switch (pHalData->eRFPowerState) { case eRfOff: // //If Rf off reason is from IPS, Led should blink with no link, by Maddest 071015 // if(pMgntInfo->RfOffReason==RF_CHANGE_BY_IPS ) - Adapter->HalFunc.LedControlHandler(Adapter,LED_CTL_NO_LINK); + Adapter->HalFunc.LedControlHandler(Adapter,LED_CTL_NO_LINK); else // Turn off LED if RF is not ON. - Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF); + Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF); break; - + case eRfOn: - // Turn on RF we are still linked, which might happen when + // Turn on RF we are still linked, which might happen when // we quickly turn off and on HW RF. 2006.05.12, by rcnjko. if( pMgntInfo->bMediaConnect == TRUE ) - Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK); + Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK); else // Turn off LED if RF is not ON. Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK); break; - + default: // do nothing. break; @@ -903,7 +865,7 @@ phy_SetRFPowerState_8814U( break; }// Switch rf_chip } - + pHalData->SetRFPowerStateInProgress = FALSE; RT_TRACE(COMP_INIT, DBG_LOUD, ("<====== phy_SetRFPowerState_8814U .\n")); return bResult; @@ -922,23 +884,21 @@ phy_SetRFPowerState_8814Sdio( BOOLEAN bResult = TRUE; u8 i, QueueID; PRT_SDIO_DEVICE pDevice = GET_RT_SDIO_DEVICE(Adapter); - + if(pHalData->SetRFPowerStateInProgress == TRUE) return FALSE; - + pHalData->SetRFPowerStateInProgress = TRUE; RT_TRACE(COMP_INIT, DBG_LOUD, ("======> phy_SetRFPowerState_8814Sdio .\n")) - - switch( eRFPowerState ) - { + + switch ( eRFPowerState ) { case eRfOn: if((pHalData->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(Adapter, RT_RF_OFF_LEVL_HALT_NIC)) { // The current RF state is OFF and the RF OFF level is halting the NIC, re-initialize the NIC. - RT_TRACE(COMP_RF, DBG_LOUD, ("======> phy_SetRFPowerState_8814Sdio-eRfOn .\n")); + RT_TRACE(COMP_RF, DBG_LOUD, ("======> phy_SetRFPowerState_8814Sdio-eRfOn .\n")); - if(!Adapter->bInHctTest) - { + if(!Adapter->bInHctTest) { // 2010/09/01 MH For 92CU, we do not make sure the RF B short initialize sequence // So disable the different RF on/off sequence for hidden AP. NicIFEnableNIC(Adapter); @@ -955,8 +915,8 @@ phy_SetRFPowerState_8814Sdio( pHalData->bIQKInitialized = _TRUE; } break; - - // + + // // In current solution, RFSleep=RFOff in order to save power under 802.11 power save. // By Bruce, 2008-01-16. // @@ -965,7 +925,7 @@ phy_SetRFPowerState_8814Sdio( // ToDo: } break; - + case eRfOff: // HW setting had been configured. // Both of these RF configures are the same, configuring twice may cause HW abnormal. @@ -973,87 +933,78 @@ phy_SetRFPowerState_8814Sdio( break; // Make sure BusyQueue is empty befor turn off RFE pwoer. - for(QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) - { - if(RTIsListEmpty(&Adapter->TcbBusyQueue[QueueID])) - { + for(QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + if(RTIsListEmpty(&Adapter->TcbBusyQueue[QueueID])) { //DbgPrint("QueueID = %d", QueueID); QueueID++; continue; - } - else - { + } else { RT_TRACE(COMP_POWER, DBG_LOUD, ("eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID)); PlatformSleepUs(10); i++; } - - if(i >= MAX_DOZE_WAITING_TIMES_9x) - { + + if(i >= MAX_DOZE_WAITING_TIMES_9x) { RT_TRACE(COMP_POWER, DBG_LOUD, ("\n\n\n SetZebraRFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID)); break; } - } + } - // - //RF Off/Sleep sequence. Designed/tested from SD4 Scott, SD1 Grent and Jonbon. - // Added by // - //================================================================== + //RF Off/Sleep sequence. Designed/tested from SD4 Scott, SD1 Grent and Jonbon. + // Added by + // + //================================================================== // CU will call card disable flow to set RF off, such that we call halt directly // and set the PS_LEVEL to HALT_NIC or we might call halt twice in N6usbHalt in some cases. - // 2010.03.05. Added by tynli. + // 2010.03.05. Added by tynli. if(pMgntInfo->RfOffReason & RF_CHANGE_BY_IPS || pMgntInfo->RfOffReason & RF_CHANGE_BY_HW || pMgntInfo->RfOffReason & RF_CHANGE_BY_SW) { //for HW/Sw radio off and IPS flow - //RT_TRACE(COMP_INIT, DBG_LOUD, ("======> CardDisableWithoutHWSM -eRfOff.\n")); - if(!Adapter->bInHctTest) - { + //RT_TRACE(COMP_INIT, DBG_LOUD, ("======> CardDisableWithoutHWSM -eRfOff.\n")); + if(!Adapter->bInHctTest) { // 2010/09/01 MH For 92CU, we do not make sure the RF B short initialize sequence // So disable the different RF on/off sequence for hidden AP. - NicIFDisableNIC(Adapter); - + NicIFDisableNIC(Adapter); + RT_SET_PS_LEVEL(Adapter, RT_RF_OFF_LEVL_HALT_NIC); } - } + } break; default: bResult = FALSE; RT_ASSERT(FALSE, ("phy_SetRFPowerState_8814Sdio(): unknow state to set: 0x%X!!!\n", eRFPowerState)); break; - } - - if(bResult) - { + } + + if(bResult) { // Update current RF state variable. pHalData->eRFPowerState = eRFPowerState; - - switch(pHalData->rf_chip ) - { - default: - switch(pHalData->eRFPowerState) - { + + switch (pHalData->rf_chip ) { + default: + switch(pHalData->eRFPowerState) { case eRfOff: // //If Rf off reason is from IPS, Led should blink with no link, by Maddest 071015 // if(pMgntInfo->RfOffReason==RF_CHANGE_BY_IPS ) - Adapter->HalFunc.LedControlHandler(Adapter,LED_CTL_NO_LINK); + Adapter->HalFunc.LedControlHandler(Adapter,LED_CTL_NO_LINK); else // Turn off LED if RF is not ON. - Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF); + Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_POWER_OFF); break; - + case eRfOn: - // Turn on RF we are still linked, which might happen when + // Turn on RF we are still linked, which might happen when // we quickly turn off and on HW RF. 2006.05.12, by rcnjko. if( pMgntInfo->bMediaConnect == TRUE ) - Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK); + Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK); else // Turn off LED if RF is not ON. - Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK); + Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_NO_LINK); break; - + default: // do nothing. break; @@ -1062,7 +1013,7 @@ phy_SetRFPowerState_8814Sdio( break; }// Switch rf_chip } - + pHalData->SetRFPowerStateInProgress = FALSE; return bResult; @@ -1074,7 +1025,7 @@ phy_SetRFPowerState_8814Sdio( BOOLEAN PHY_SetRFPowerState8814A( - IN PADAPTER Adapter, + IN PADAPTER Adapter, IN rt_rf_power_state eRFPowerState ) { @@ -1082,8 +1033,7 @@ PHY_SetRFPowerState8814A( BOOLEAN bResult = FALSE; RT_TRACE(COMP_RF, DBG_LOUD, ("---------> PHY_SetRFPowerState8814(): eRFPowerState(%d)\n", eRFPowerState)); - if(eRFPowerState == pHalData->eRFPowerState) - { + if(eRFPowerState == pHalData->eRFPowerState) { RT_TRACE(COMP_RF, DBG_LOUD, ("<--------- PHY_SetRFPowerState8814(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState)); return bResult; } @@ -1094,7 +1044,7 @@ PHY_SetRFPowerState8814A( #elif (DEV_BUS_TYPE == RT_SDIO_INTERFACE) bResult = phy_SetRFPowerState_8814Sdio(Adapter, eRFPowerState); #endif - + RT_TRACE(COMP_RF, DBG_LOUD, ("<--------- PHY_SetRFPowerState8814(): bResult(%d)\n", bResult)); return bResult; @@ -1145,39 +1095,37 @@ PHY_SetTxPowerLevel8814( HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - u8 jaguar2Rates[][4] = { {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M}, - {MGN_6M, MGN_9M, MGN_12M, MGN_18M}, - {MGN_24M, MGN_36M, MGN_48M, MGN_54M}, + u8 jaguar2Rates[][4] = { {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M}, + {MGN_6M, MGN_9M, MGN_12M, MGN_18M}, + {MGN_24M, MGN_36M, MGN_48M, MGN_54M}, {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3}, - {MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7}, + {MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7}, {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11}, {MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15}, - {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19}, + {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19}, {MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23}, - {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3}, - {MGN_VHT1SS_MCS4, MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7}, - {MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9, MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1}, - {MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4, MGN_VHT2SS_MCS5}, + {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3}, + {MGN_VHT1SS_MCS4, MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7}, + {MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9, MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1}, + {MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4, MGN_VHT2SS_MCS5}, {MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9}, - {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3}, - {MGN_VHT3SS_MCS4, MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7}, - {MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9, 0, 0}}; + {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3}, + {MGN_VHT3SS_MCS4, MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7}, + {MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9, 0, 0}}; - - for( path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path ) - { + + for ( path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path ) { PHY_SetTxPowerLevelByPath(Adapter, Channel, (u8)path); } #if 0 //todo H2C_TXPOWER_INDEX_OFFLOAD ? - if(Adapter->MgntInfo.bScanInProgress == FALSE && pHalData->RegFWOffload == 2) - { + if (Adapter->MgntInfo.bScanInProgress == FALSE && pHalData->RegFWOffload == 2) { HalDownloadTxPowerLevel8814(Adapter, value); } #endif //0 } /************************************************************************************************************** - * Description: + * Description: * The low-level interface to get the FINAL Tx Power Index , called by both MP and Normal Driver. * * <20120830, Kordan> @@ -1186,8 +1134,8 @@ u8 PHY_GetTxPowerIndex_8814A( IN PADAPTER pAdapter, IN u8 RFPath, - IN u8 Rate, - IN u8 BandWidth, + IN u8 Rate, + IN u8 BandWidth, IN u8 Channel, struct txpwr_idx_comp *tic ) @@ -1200,7 +1148,7 @@ PHY_GetTxPowerIndex_8814A( s8 tpt_offset = 0; /* RTW_INFO( "===>%s\n", __FUNCTION__ ); */ - + txPower = (s8) PHY_GetTxPowerIndexBase( pAdapter, RFPath, Rate, BandWidth, Channel, &bIn24G ); powerDiffByRate = PHY_GetTxPowerByRate( pAdapter, (u8)(!bIn24G), RFPath, tx_num, Rate ); @@ -1212,7 +1160,7 @@ PHY_GetTxPowerIndex_8814A( /*RTW_INFO("Rate-0x%x: (TxPower, PowerDiffByRate Path-%c) = (0x%X, %d)\n", Rate, ((RFPath==0)?'A':(RFPath==1)?'B':(RFPath==2)?'C':'D'), txPower, powerDiffByRate);*/ txPower += powerDiffByRate; - + //txPower += PHY_GetTxPowerTrackingOffset( pAdapter, RFPath, Rate ); #if 0 //todo ? #if CCX_SUPPORT @@ -1229,17 +1177,17 @@ PHY_GetTxPowerIndex_8814A( tic->ebias = 0; } - if(txPower > MAX_POWER_INDEX) + if (txPower > MAX_POWER_INDEX) txPower = MAX_POWER_INDEX; - //if (Adapter->registrypriv.mp_mode==0 && + //if (Adapter->registrypriv.mp_mode==0 && //(pHalData->bautoload_fail_flag || pHalData->EfuseMap[EFUSE_INIT_MAP][EEPROM_TX_PWR_INX_JAGUAR] == 0xFF)) //txPower = 0x12; /*RTW_INFO("Final Tx Power(RF-%c, Channel: %d) = %d(0x%X)\n", ((RFPath==0)?'A':(RFPath==1)?'B':(RFPath==2)?'C':'D'), Channel, txPower, txPower);*/ - return (u8) txPower; + return (u8) txPower; } @@ -1247,7 +1195,7 @@ VOID PHY_SetTxPowerIndex_8814A( IN PADAPTER Adapter, IN u32 PowerIndex, - IN u8 RFPath, + IN u8 RFPath, IN u8 Rate ) { @@ -1273,7 +1221,7 @@ PHY_UpdateTxPowerDbm8814A( } -u32 +u32 PHY_GetTxBBSwing_8814A( IN PADAPTER Adapter, IN BAND_TYPE Band, @@ -1288,92 +1236,70 @@ PHY_GetTxBBSwing_8814A( u32 out = 0x200; const s8 AUTO = -1; - RT_TRACE(COMP_MP, DBG_LOUD, ("===> PHY_GetTxBBSwing_8814A, bbSwing_2G: %d, bbSwing_5G: %d\n", + RT_TRACE(COMP_MP, DBG_LOUD, ("===> PHY_GetTxBBSwing_8814A, bbSwing_2G: %d, bbSwing_5G: %d\n", (s4Byte)bbSwing_2G, (s4Byte)bbSwing_5G)); - if ( pHalData->bautoload_fail_flag ) - { - if ( Band == BAND_ON_2_4G ) - { + if ( pHalData->bautoload_fail_flag ) { + if ( Band == BAND_ON_2_4G ) { pRFCalibrateInfo->BBSwingDiff2G = bbSwing_2G; if (bbSwing_2G == 0) out = 0x200; // 0 dB else if (bbSwing_2G == -3) out = 0x16A; // -3 dB else if (bbSwing_2G == -6) out = 0x101; // -6 dB else if (bbSwing_2G == -9) out = 0x0B6; // -9 dB - else - { - if ( pHalData->ExternalPA_2G ) - { + else { + if ( pHalData->ExternalPA_2G ) { pRFCalibrateInfo->BBSwingDiff2G = -3; out = 0x16A; - } - else - { + } else { pRFCalibrateInfo->BBSwingDiff2G = 0; out = 0x200; } } - } - else if ( Band == BAND_ON_5G ) - { + } + else if ( Band == BAND_ON_5G ) { pRFCalibrateInfo->BBSwingDiff5G = bbSwing_5G; - if(bbSwing_5G == 0) out = 0x200; // 0 dB + if (bbSwing_5G == 0) out = 0x200; // 0 dB else if (bbSwing_5G == -3) out = 0x16A; // -3 dB else if (bbSwing_5G == -6) out = 0x101; // -6 dB else if (bbSwing_5G == -9) out = 0x0B6; // -9 dB - else - { - if (pHalData->ExternalPA_5G) - { + else { + if (pHalData->ExternalPA_5G) { pRFCalibrateInfo->BBSwingDiff5G = -3; out = 0x16A; - } - else - { + } else { pRFCalibrateInfo->BBSwingDiff5G = 0; out = 0x200; } } - } - else - { + } else { pRFCalibrateInfo->BBSwingDiff2G = -3; - pRFCalibrateInfo->BBSwingDiff5G = -3; + pRFCalibrateInfo->BBSwingDiff5G = -3; out = 0x16A; // -3 dB } - } - else - { + } else { u32 swing = 0, onePathSwing = 0; - if (Band == BAND_ON_2_4G) - { - if (GetRegTxBBSwing_2G(Adapter) == AUTO) - { + if (Band == BAND_ON_2_4G) { + if (GetRegTxBBSwing_2G(Adapter) == AUTO) { EFUSE_ShadowRead(Adapter, 1, EEPROM_TX_BBSWING_2G_8814, (u32 *)&swing); - if (swing == 0xFF) - { + if (swing == 0xFF) { if(bbSwing_2G == 0) swing = 0x00; // 0 dB else if (bbSwing_2G == -3) swing = 0x55; // -3 dB else if (bbSwing_2G == -6) swing = 0xAA; // -6 dB else if (bbSwing_2G == -9) swing = 0xFF; // -9 dB - else swing = 0x00; + else swing = 0x00; } - } + } else if (bbSwing_2G == 0) swing = 0x00; // 0 dB else if (bbSwing_2G == -3) swing = 0x55; // -3 dB else if (bbSwing_2G == -6) swing = 0xAA; // -6 dB else if (bbSwing_2G == -9) swing = 0xFF; // -9 dB else swing = 0x00; - } - else - { - if (GetRegTxBBSwing_5G(Adapter) == AUTO) - { + } else { + if (GetRegTxBBSwing_5G(Adapter) == AUTO) { EFUSE_ShadowRead(Adapter, 1, EEPROM_TX_BBSWING_5G_8814, (u32 *)&swing); - if (swing == 0xFF) - { - if(bbSwing_5G == 0) swing = 0x00; // 0 dB + if (swing == 0xFF) { + if (bbSwing_5G == 0) swing = 0x00; // 0 dB else if (bbSwing_5G == -3) swing = 0x55; // -3 dB else if (bbSwing_5G == -6) swing = 0xAA; // -6 dB else if (bbSwing_5G == -9) swing = 0xFF; // -9 dB @@ -1389,40 +1315,36 @@ PHY_GetTxBBSwing_8814A( if (RFPath == ODM_RF_PATH_A) onePathSwing = (swing & 0x3) >> 0; // 0xC6/C7[1:0] - else if(RFPath == ODM_RF_PATH_B) + else if (RFPath == ODM_RF_PATH_B) onePathSwing = (swing & 0xC) >> 2; // 0xC6/C7[3:2] - else if(RFPath == ODM_RF_PATH_C) + else if (RFPath == ODM_RF_PATH_C) onePathSwing = (swing & 0x30) >> 4; // 0xC6/C7[5:4] - else if(RFPath == ODM_RF_PATH_D) + else if (RFPath == ODM_RF_PATH_D) onePathSwing = (swing & 0xC0) >> 6; // 0xC6/C7[7:6] - if (onePathSwing == 0x0) - { - if (Band == BAND_ON_2_4G) + if (onePathSwing == 0x0) { + if (Band == BAND_ON_2_4G) pRFCalibrateInfo->BBSwingDiff2G = 0; else pRFCalibrateInfo->BBSwingDiff5G = 0; out = 0x200; // 0 dB - } - else if (onePathSwing == 0x1) - { - if (Band == BAND_ON_2_4G) + } + else if (onePathSwing == 0x1) { + if (Band == BAND_ON_2_4G) pRFCalibrateInfo->BBSwingDiff2G = -3; else pRFCalibrateInfo->BBSwingDiff5G = -3; out = 0x16A; // -3 dB - } - else if (onePathSwing == 0x2) - { - if (Band == BAND_ON_2_4G) + } + else if (onePathSwing == 0x2) { + if (Band == BAND_ON_2_4G) pRFCalibrateInfo->BBSwingDiff2G = -6; else pRFCalibrateInfo->BBSwingDiff5G = -6; out = 0x101; // -6 dB - } - else if (onePathSwing == 0x3) - { - if (Band == BAND_ON_2_4G) + } + else if (onePathSwing == 0x3) { + if (Band == BAND_ON_2_4G) pRFCalibrateInfo->BBSwingDiff2G = -9; else pRFCalibrateInfo->BBSwingDiff5G = -9; @@ -1441,28 +1363,21 @@ phy_SetBwRegAdc_8814A( IN PADAPTER Adapter, IN u8 Band, IN CHANNEL_WIDTH CurrentBW -) +) { - switch(CurrentBW) - { + switch (CurrentBW) { case CHANNEL_WIDTH_20: - if(Band == BAND_ON_5G) - { + if(Band == BAND_ON_5G) { PHY_SetBBReg(Adapter, rRFMOD_Jaguar, BIT(1)|BIT(0), 0x0); // 0x8ac[28, 21,20,16, 9:6,1,0]=10'b10_0011_0000 - } - else - { + } else { PHY_SetBBReg(Adapter, rRFMOD_Jaguar, BIT(1)|BIT(0), 0x0); // 0x8ac[28, 21,20,16, 9:6,1,0]=10'b10_0101_0000 } break; case CHANNEL_WIDTH_40: - if(Band == BAND_ON_5G) - { + if(Band == BAND_ON_5G) { PHY_SetBBReg(Adapter, rRFMOD_Jaguar, BIT(1)|BIT(0), 0x1); // 0x8ac[17, 11, 10, 7:6,1,0]=7'b100_0001 - } - else - { + } else { PHY_SetBBReg(Adapter, rRFMOD_Jaguar, BIT(1)|BIT(0), 0x1); // 0x8ac[17, 11, 10, 7:6,1,0]=7'b101_0001 } break; @@ -1483,20 +1398,19 @@ phy_SetBwRegAgc_8814A( IN PADAPTER Adapter, IN u8 Band, IN CHANNEL_WIDTH CurrentBW -) +) { u32 AgcValue = 7; - switch(CurrentBW) - { + switch (CurrentBW) { case CHANNEL_WIDTH_20: - if(Band == BAND_ON_5G) + if (Band == BAND_ON_5G) AgcValue = 6; else AgcValue = 6; break; case CHANNEL_WIDTH_40: - if(Band == BAND_ON_5G) + if (Band == BAND_ON_5G) AgcValue = 8; else AgcValue = 7; @@ -1511,7 +1425,7 @@ phy_SetBwRegAgc_8814A( break; } - PHY_SetBBReg(Adapter, rAGC_table_Jaguar, 0xf000, AgcValue); // 0x82C[15:12] = AgcValue + PHY_SetBBReg(Adapter, rAGC_table_Jaguar, 0xf000, AgcValue); // 0x82C[15:12] = AgcValue } @@ -1520,31 +1434,27 @@ phy_SwBand8814A( IN PADAPTER pAdapter, IN u8 channelToSW) { - u8 u1Btmp; + u8 u1Btmp; BOOLEAN ret_value = _TRUE; u8 Band = BAND_ON_5G, BandToSW; u1Btmp = rtw_read8(pAdapter, REG_CCK_CHECK_8814A); - if(u1Btmp & BIT7) + if (u1Btmp & BIT7) Band = BAND_ON_5G; else Band = BAND_ON_2_4G; // Use current channel to judge Band Type and switch Band if need. - if(channelToSW > 14) - { + if (channelToSW > 14) { BandToSW = BAND_ON_5G; - } - else - { + } else { BandToSW = BAND_ON_2_4G; } - if(BandToSW != Band) - { + if(BandToSW != Band) { PHY_SwitchWirelessBand8814A(pAdapter,BandToSW); } - + return ret_value; } @@ -1559,9 +1469,8 @@ PHY_SetRFEReg8814A( u8 u1tmp = 0; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - if(bInit) - { - switch(pHalData->RFEType){ + if (bInit) { + switch (pHalData->RFEType) { case 2:case 1: PHY_SetBBReg(Adapter, 0x1994, 0xf, 0xf); // 0x1994[3:0] = 0xf u1tmp = PlatformEFIORead1Byte(Adapter, REG_GPIO_IO_SEL_8814A); @@ -1574,9 +1483,8 @@ PHY_SetRFEReg8814A( break; } } - else if(Band == BAND_ON_2_4G) - { - switch(pHalData->RFEType){ + else if (Band == BAND_ON_2_4G) { + switch (pHalData->RFEType){ case 2: PHY_SetBBReg(Adapter, rA_RFE_Pinmux_Jaguar, bMaskDWord, 0x72707270); // 0xCB0 = 0x72707270 PHY_SetBBReg(Adapter, rB_RFE_Pinmux_Jaguar, bMaskDWord, 0x72707270); // 0xEB0 = 0x72707270 @@ -1600,11 +1508,9 @@ PHY_SetRFEReg8814A( PHY_SetBBReg(Adapter, rC_RFE_Pinmux_Jaguar, bMaskDWord, 0x77777777); // 0x18B4 = 0x77777777 PHY_SetBBReg(Adapter, 0x1ABC, 0x0ff00000, 0x77); // 0x1ABC[27:20] = 0x77 break; - + } - } - else - { + } else { switch(pHalData->RFEType){ case 2: PHY_SetBBReg(Adapter, rA_RFE_Pinmux_Jaguar, bMaskDWord, 0x33173717); // 0xCB0 = 0x33173717 @@ -1613,7 +1519,7 @@ PHY_SetRFEReg8814A( PHY_SetBBReg(Adapter, rD_RFE_Pinmux_Jaguar, bMaskDWord, 0x77177717); // 0x1AB4 = 0x77177717 PHY_SetBBReg(Adapter, 0x1ABC, 0x0ff00000, 0x37); // 0x1ABC[27:20] = 0x37 break; - + case 1: PHY_SetBBReg(Adapter, rA_RFE_Pinmux_Jaguar, bMaskDWord, 0x33173317); // 0xCB0 = 0x33173317 PHY_SetBBReg(Adapter, rB_RFE_Pinmux_Jaguar, bMaskDWord, 0x33173317); // 0xEB0 = 0x33173317 @@ -1634,7 +1540,7 @@ PHY_SetRFEReg8814A( } } -VOID +VOID phy_SetBBSwingByBand_8814A( IN PADAPTER Adapter, IN u8 Band, @@ -1643,29 +1549,28 @@ phy_SetBBSwingByBand_8814A( { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - s8 BBDiffBetweenBand = 0; + s8 BBDiffBetweenBand = 0; PDM_ODM_T pDM_Odm = &pHalData->odmpriv; PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - - PHY_SetBBReg(Adapter, rA_TxScale_Jaguar, 0xFFE00000, + + PHY_SetBBReg(Adapter, rA_TxScale_Jaguar, 0xFFE00000, PHY_GetTxBBSwing_8814A(Adapter, (BAND_TYPE)Band, ODM_RF_PATH_A)); // 0xC1C[31:21] - PHY_SetBBReg(Adapter, rB_TxScale_Jaguar, 0xFFE00000, + PHY_SetBBReg(Adapter, rB_TxScale_Jaguar, 0xFFE00000, PHY_GetTxBBSwing_8814A(Adapter, (BAND_TYPE)Band, ODM_RF_PATH_B)); // 0xE1C[31:21] - PHY_SetBBReg(Adapter, rC_TxScale_Jaguar2, 0xFFE00000, + PHY_SetBBReg(Adapter, rC_TxScale_Jaguar2, 0xFFE00000, PHY_GetTxBBSwing_8814A(Adapter, (BAND_TYPE)Band, ODM_RF_PATH_C)); // 0x181C[31:21] - PHY_SetBBReg(Adapter, rD_TxScale_Jaguar2, 0xFFE00000, + PHY_SetBBReg(Adapter, rD_TxScale_Jaguar2, 0xFFE00000, PHY_GetTxBBSwing_8814A(Adapter, (BAND_TYPE)Band, ODM_RF_PATH_D)); // 0x1A1C[31:21] - + // <20121005, Kordan> When TxPowerTrack is ON, we should take care of the change of BB swing. // That is, reset all info to trigger Tx power tracking. - - if (Band != PreviousBand) - { + + if (Band != PreviousBand) { BBDiffBetweenBand = (pRFCalibrateInfo->BBSwingDiff2G - pRFCalibrateInfo->BBSwingDiff5G); BBDiffBetweenBand = (Band == BAND_ON_2_4G) ? BBDiffBetweenBand : (-1 * BBDiffBetweenBand); - pRFCalibrateInfo->DefaultOfdmIndex += BBDiffBetweenBand*2; + pRFCalibrateInfo->DefaultOfdmIndex += BBDiffBetweenBand*2; } - + ODM_ClearTxPowerTrackingState(pDM_Odm); } @@ -1678,7 +1583,7 @@ PHY_SwitchWirelessBand8814A( { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); u8 PreBand = pHalData->CurrentBandType, tepReg = 0; - + RTW_INFO("==>PHY_SwitchWirelessBand8814() %s\n", ((Band==0)?"2.4G":"5G")); pHalData->CurrentBandType =(BAND_TYPE)Band; @@ -1686,14 +1591,13 @@ PHY_SwitchWirelessBand8814A( /*clear 0x1000[16], When this bit is set to 0, CCK and OFDM are disabled, and clock are gated. Otherwise, CCK and OFDM are enabled. */ tepReg = rtw_read8(Adapter, REG_SYS_CFG3_8814A+2); rtw_write8(Adapter, REG_SYS_CFG3_8814A+2, tepReg & (~BIT0)); - + // STOP Tx/Rx - //PHY_SetBBReg(Adapter, rOFDMCCKEN_Jaguar, bOFDMEN_Jaguar|bCCKEN_Jaguar, 0x00); + //PHY_SetBBReg(Adapter, rOFDMCCKEN_Jaguar, bOFDMEN_Jaguar|bCCKEN_Jaguar, 0x00); - if(Band == BAND_ON_2_4G) - {// 2.4G band + if (Band == BAND_ON_2_4G) { // 2.4G band - // AGC table select + // AGC table select PHY_SetBBReg(Adapter, rAGC_table_Jaguar2, 0x1F, 0); // 0x958[4:0] = 5b'00000 PHY_SetRFEReg8814A(Adapter, FALSE, Band); @@ -1701,8 +1605,7 @@ PHY_SwitchWirelessBand8814A( // cck_enable //PHY_SetBBReg(Adapter, rOFDMCCKEN_Jaguar, bOFDMEN_Jaguar|bCCKEN_Jaguar, 0x3); - if(Adapter->registrypriv.mp_mode == 0) - { + if (Adapter->registrypriv.mp_mode == 0) { // 0x80C & 0xa04 should use same antenna. PHY_SetBBReg(Adapter, rTxPath_Jaguar, 0xf0, 0x2); PHY_SetBBReg(Adapter, rCCK_RX_Jaguar, 0x0f000000, 0x5); @@ -1710,28 +1613,24 @@ PHY_SwitchWirelessBand8814A( PHY_SetBBReg(Adapter, rOFDMCCKEN_Jaguar, bOFDMEN_Jaguar|bCCKEN_Jaguar, 0x3); - // CCK_CHECK_en rtw_write8(Adapter, REG_CCK_CHECK_8814A, 0x0); /* after 5G swicth 2G , set A82[2] = 0 */ PHY_SetBBReg(Adapter, 0xa80, BIT18, 0x0); - - } - else //5G band - { + + } else { //5G band // CCK_CHECK_en rtw_write8(Adapter, REG_CCK_CHECK_8814A, 0x80); /* Enable CCK Tx function, even when CCK is off */ PHY_SetBBReg(Adapter, 0xa80, BIT18, 0x1); - - // AGC table select + + // AGC table select // Postpone to channel switch //PHY_SetBBReg(Adapter, rAGC_table_Jaguar2, 0x1F, 1); // 0x958[4:0] = 5b'00001 PHY_SetRFEReg8814A(Adapter, FALSE, Band); - if(Adapter->registrypriv.mp_mode == 0) - { + if (Adapter->registrypriv.mp_mode == 0) { PHY_SetBBReg(Adapter, rTxPath_Jaguar, 0xf0, 0x0); PHY_SetBBReg(Adapter, rCCK_RX_Jaguar, 0x0f000000, 0xF); } @@ -1746,13 +1645,13 @@ PHY_SwitchWirelessBand8814A( /* set 0x1000[16], When this bit is set to 0, CCK and OFDM are disabled, and clock are gated. Otherwise, CCK and OFDM are enabled.*/ tepReg = rtw_read8(Adapter, REG_SYS_CFG3_8814A+2); rtw_write8(Adapter, REG_SYS_CFG3_8814A+2, tepReg | BIT0); - + RTW_INFO("<==PHY_SwitchWirelessBand8814():Switch Band OK.\n"); - return _SUCCESS; + return _SUCCESS; } -u8 +u8 phy_GetSecondaryChnl_8814A( IN PADAPTER Adapter ) @@ -1761,40 +1660,37 @@ phy_GetSecondaryChnl_8814A( PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); //RTW_INFO("SCMapping: Case: pHalData->CurrentChannelBW %d, pHalData->nCur80MhzPrimeSC %d, pHalData->nCur40MhzPrimeSC %d \n",pHalData->CurrentChannelBW,pHalData->nCur80MhzPrimeSC,pHalData->nCur40MhzPrimeSC); - if(pHalData->CurrentChannelBW== CHANNEL_WIDTH_80) - { - if(pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) + if (pHalData->CurrentChannelBW== CHANNEL_WIDTH_80) { + if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) SCSettingOf40 = VHT_DATA_SC_40_LOWER_OF_80MHZ; - else if(pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) + else if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) SCSettingOf40 = VHT_DATA_SC_40_UPPER_OF_80MHZ; else RTW_INFO("SCMapping: DONOT CARE Mode Setting\n"); - - if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) + + if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) SCSettingOf20 = VHT_DATA_SC_20_LOWEST_OF_80MHZ; - else if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) + else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) SCSettingOf20 = VHT_DATA_SC_20_LOWER_OF_80MHZ; - else if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) + else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) SCSettingOf20 = VHT_DATA_SC_20_UPPER_OF_80MHZ; - else if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) + else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) SCSettingOf20 = VHT_DATA_SC_20_UPPERST_OF_80MHZ; - else - { - if(pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) + else { + if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) SCSettingOf20 = VHT_DATA_SC_40_LOWER_OF_80MHZ; - else if(pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) + else if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) SCSettingOf20 = VHT_DATA_SC_40_UPPER_OF_80MHZ; else RTW_INFO("SCMapping: DONOT CARE Mode Setting\n"); - } + } } - else if(pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) - { + else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { RTW_INFO("SCMapping: pHalData->CurrentChannelBW %d, pHalData->nCur40MhzPrimeSC %d \n",pHalData->CurrentChannelBW,pHalData->nCur40MhzPrimeSC); - if(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) + if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) SCSettingOf20 = VHT_DATA_SC_20_UPPER_OF_80MHZ; - else if(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) + else if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) SCSettingOf20 = VHT_DATA_SC_20_LOWER_OF_80MHZ; else RTW_INFO("SCMapping: DONOT CARE Mode Setting\n"); @@ -1809,13 +1705,12 @@ VOID phy_SetBwRegMac_8814A( IN PADAPTER Adapter, CHANNEL_WIDTH CurrentBW -) +) { u16 RegRfMod_BW, u2tmp = 0; RegRfMod_BW = PlatformEFIORead2Byte(Adapter, REG_TRXPTCL_CTL_8814A); - switch(CurrentBW) - { + switch (CurrentBW) { case CHANNEL_WIDTH_20: PlatformEFIOWrite2Byte(Adapter, REG_TRXPTCL_CTL_8814A, (RegRfMod_BW & 0xFE7F)); // BIT 7 = 0, BIT 8 = 0 break; @@ -1874,7 +1769,7 @@ void PHY_Set_SecCCATH_by_RXANT_8814A(PADAPTER pAdapter,u4Byte ulAntennaRx) case ANTENNA_AB: case ANTENNA_AC: - case ANTENNA_AD: + case ANTENNA_AD: case ANTENNA_BC: case ANTENNA_BD: case ANTENNA_CD: @@ -1908,7 +1803,7 @@ void PHY_Set_SecCCATH_by_RXANT_8814A(PADAPTER pAdapter,u4Byte ulAntennaRx) RTW_INFO("Unknown Rx antenna.\n"); break; } - } else if(pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { + } else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { if (pHalData->bSWToBW40M == FALSE) { pHalData->BackUp_BB_REG_4_2nd_CCA[0] = PHY_QueryBBReg(pAdapter, rPwed_TH_Jaguar, 0x007c0000); pHalData->BackUp_BB_REG_4_2nd_CCA[1] = PHY_QueryBBReg(pAdapter, rCCAonSec_Jaguar, 0x0000ff00); @@ -1956,11 +1851,11 @@ void PHY_Set_SecCCATH_by_RXANT_8814A(PADAPTER pAdapter,u4Byte ulAntennaRx) PHY_SetBBReg(pAdapter, rCCAonSec_Jaguar, 0x0FFF0000, 0x7aa); /* 838[27:24]=6, RF80_secondary40, 838[23:20]=6, RF80_secondary20, 838[19:16]=6, RF80_primary*/ PHY_SetBBReg(pAdapter, rL1_Weight_Jaguar, 0x0000F000, 0x7); /* 840[15:12]=7, L1_square_Pk_weight_80M*/ } - + } -VOID PHY_SetRXSC_by_TXSC_8814A(PADAPTER Adapter, u1Byte SubChnlNum) +VOID PHY_SetRXSC_by_TXSC_8814A(PADAPTER Adapter, u1Byte SubChnlNum) { PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); @@ -1979,7 +1874,7 @@ VOID PHY_SetRXSC_by_TXSC_8814A(PADAPTER Adapter, u1Byte SubChnlNum) PHY_SetBBReg(Adapter, rRFMOD_Jaguar, 0x00000003c, 0x1); else if (SubChnlNum == 10) PHY_SetBBReg(Adapter, rRFMOD_Jaguar, 0x00000003c, 0x2); - } else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { + } else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { if (SubChnlNum == 1) PHY_SetBBReg(Adapter, rRFMOD_Jaguar, 0x00000003c, 0x1); else if (SubChnlNum == 2) @@ -1999,7 +1894,7 @@ VOID phy_SpurCalibration_8814A(PADAPTER Adapter) /*RTW_INFO("%s(),RFE Type =%d, CurrentCh = %d ,ChannelBW =%d\n", __func__, pHalData->RFEType, pHalData->CurrentChannel, pHalData->CurrentChannelBW);*/ /*RTW_INFO("%s(),Before RrNBI_Setting_Jaguar= %x\n", __func__, PHY_QueryBBReg(Adapter, rNBI_Setting_Jaguar, bMaskDWord));*/ - + if (pHalData->RFEType == 0) { switch (pHalData->CurrentChannelBW) { case CHANNEL_WIDTH_40: @@ -2052,7 +1947,7 @@ VOID phy_SpurCalibration_8814A(PADAPTER Adapter) Reset_NBI_CSI = FALSE; } break; - + default: break; } @@ -2096,7 +1991,7 @@ VOID phy_SpurCalibration_8814A(PADAPTER Adapter) break; } } - + if (Reset_NBI_CSI) { PHY_SetBBReg(Adapter, rNBI_Setting_Jaguar, 0x000fe000, 0xfc >> 1); PHY_SetBBReg(Adapter, rCSI_Mask_Setting1_Jaguar, BIT(0), 0); @@ -2105,7 +2000,7 @@ VOID phy_SpurCalibration_8814A(PADAPTER Adapter) PHY_SetBBReg(Adapter, rCSI_Fix_Mask6_Jaguar, bMaskDWord, 0); PHY_SetBBReg(Adapter, rCSI_Fix_Mask7_Jaguar, bMaskDWord, 0); } - + phydm_spur_nbi_setting_8814a(pDM_Odm); /*RTW_INFO("%s(),After RrNBI_Setting_Jaguar= %x\n", __func__, PHY_QueryBBReg(Adapter, rNBI_Setting_Jaguar, bMaskDWord));*/ } @@ -2177,7 +2072,7 @@ VOID phy_SetBwMode8814A(PADAPTER Adapter) SubChnlNum = phy_GetSecondaryChnl_8814A(Adapter); rtw_write8(Adapter, REG_DATA_SC_8814A, SubChnlNum); - if(pHalData->rf_chip == RF_PSEUDO_11N) + if (pHalData->rf_chip == RF_PSEUDO_11N) { RTW_INFO("phy_SetBwMode8814A: return for PSEUDO \n"); return; @@ -2189,8 +2084,7 @@ VOID phy_SetBwMode8814A(PADAPTER Adapter) phy_SetBwRegAgc_8814A(Adapter, pHalData->CurrentBandType, pHalData->CurrentChannelBW); //3 Set Reg848 RegA00 - switch(pHalData->CurrentChannelBW) - { + switch (pHalData->CurrentChannelBW) { case CHANNEL_WIDTH_20: break; @@ -2211,14 +2105,14 @@ VOID phy_SetBwMode8814A(PADAPTER Adapter) RTW_INFO("%s():unknown Bandwidth:%#X\n", __func__, pHalData->CurrentChannelBW); break; } - + #if (MP_DRIVER == 1) if (Adapter->registrypriv.mp_mode == 1) { /* 2 Set Reg 0x8AC */ PHY_SetRXSC_by_TXSC_8814A(Adapter, (SubChnlNum & 0xf)); PHY_Set_SecCCATH_by_RXANT_8814A(Adapter, pHalData->AntennaRxPath); } -#endif +#endif /* 3 Set RF related register */ PHY_RF6052SetBandwidth8814A(Adapter, pHalData->CurrentChannelBW); @@ -2227,7 +2121,6 @@ if (Adapter->registrypriv.mp_mode == 1) { } - //1 6. Channel setting API // Add for KFree Feature Requested by RF David. @@ -2240,24 +2133,20 @@ phy_SetKfreeToRF_8814A( IN u8 Data ) { - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(GetDefaultAdapter(Adapter)); + HAL_DATA_TYPE *pHalData = GET_HAL_DATA(GetDefaultAdapter(Adapter)); PDM_ODM_T pDM_Odm = &pHalData->odmpriv; BOOLEAN bOdd; PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - if((Data%2) != 0) //odd -> positive - { + if ((Data%2) != 0) { //odd -> positive Data = Data - 1; PHY_SetRFReg(Adapter, eRFPath, rRF_TxGainOffset, BIT19, 1); bOdd = TRUE; - } - else // even -> negative - { + } else { // even -> negative PHY_SetRFReg(Adapter, eRFPath, rRF_TxGainOffset, BIT19, 0); bOdd = FALSE; } RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): RF_0x55[19]= %d\n", bOdd)); - switch(Data) - { + switch (Data) { case 2: PHY_SetRFReg(Adapter, eRFPath, rRF_TxGainOffset, BIT14, 1); pRFCalibrateInfo->KfreeOffset[eRFPath] = 0; @@ -2307,14 +2196,13 @@ phy_SetKfreeToRF_8814A( break; } - if(bOdd == FALSE) // that means Kfree offset is negative, we need to record it. - { + if (bOdd == FALSE) { // that means Kfree offset is negative, we need to record it. pRFCalibrateInfo->KfreeOffset[eRFPath] = (-1)*pRFCalibrateInfo->KfreeOffset[eRFPath]; RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): KfreeOffset = %d\n", pRFCalibrateInfo->KfreeOffset[eRFPath])); } else RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): KfreeOffset = %d\n", pRFCalibrateInfo->KfreeOffset[eRFPath])); - + } @@ -2330,60 +2218,50 @@ phy_ConfigKFree8814A( u8 targetval_C = 0xFF; u8 targetval_D = 0xFF; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - + //RTW_INFO("===>phy_ConfigKFree8814A()\n"); - - if (Adapter->registrypriv.RegPwrTrimEnable == 2) - { + + if (Adapter->registrypriv.RegPwrTrimEnable == 2) { //RTW_INFO("phy_ConfigKFree8814A(): RegPwrTrimEnable == 2, Disable \n"); return; } - else if (Adapter->registrypriv.RegPwrTrimEnable == 1 || Adapter->registrypriv.RegPwrTrimEnable == 0) - { + else if (Adapter->registrypriv.RegPwrTrimEnable == 1 || Adapter->registrypriv.RegPwrTrimEnable == 0) { RTW_INFO("phy_ConfigKFree8814A(): RegPwrTrimEnable == TRUE \n"); - if (bandType == BAND_ON_2_4G) // 2G - { + if (bandType == BAND_ON_2_4G) { // 2G RTW_INFO("phy_ConfigKFree8814A(): bandType == BAND_ON_2_4G, channelToSW= %d \n", channelToSW); - if (channelToSW <= 14 && channelToSW >= 1) - { + if (channelToSW <= 14 && channelToSW >= 1) { efuse_OneByteRead(Adapter, 0x3F4, &targetval_A, FALSE); // for Path A and B efuse_OneByteRead(Adapter, 0x3F5, &targetval_B, FALSE); // for Path C and D } - + } - else if (bandType == BAND_ON_5G) - { + else if (bandType == BAND_ON_5G) { RTW_INFO("phy_ConfigKFree8814A(): bandType == BAND_ON_5G, channelToSW= %d \n", channelToSW); - if (channelToSW >= 36 && channelToSW < 50) // 5GLB_1 - { + if (channelToSW >= 36 && channelToSW < 50) { // 5GLB_1 efuse_OneByteRead(Adapter, 0x3E0, &targetval_A, FALSE); efuse_OneByteRead(Adapter, 0x3E1, &targetval_B, FALSE); efuse_OneByteRead(Adapter, 0x3E2, &targetval_C, FALSE); efuse_OneByteRead(Adapter, 0x3E3, &targetval_D, FALSE); } - else if (channelToSW >= 50 && channelToSW <= 64) // 5GLB_2 - { + else if (channelToSW >= 50 && channelToSW <= 64) { // 5GLB_2 efuse_OneByteRead(Adapter, 0x3E4, &targetval_A, FALSE); efuse_OneByteRead(Adapter, 0x3E5, &targetval_B, FALSE); efuse_OneByteRead(Adapter, 0x3E6, &targetval_C, FALSE); efuse_OneByteRead(Adapter, 0x3E7, &targetval_D, FALSE); } - else if (channelToSW >= 100 && channelToSW <= 118) // 5GMB_1 - { + else if (channelToSW >= 100 && channelToSW <= 118) { // 5GMB_1 efuse_OneByteRead(Adapter, 0x3E8, &targetval_A, FALSE); efuse_OneByteRead(Adapter, 0x3E9, &targetval_B, FALSE); efuse_OneByteRead(Adapter, 0x3EA, &targetval_C, FALSE); efuse_OneByteRead(Adapter, 0x3EB, &targetval_D, FALSE); } - else if (channelToSW >= 120 && channelToSW <= 140) // 5GMB_2 - { + else if (channelToSW >= 120 && channelToSW <= 140) { // 5GMB_2 efuse_OneByteRead(Adapter, 0x3EC, &targetval_A, FALSE); efuse_OneByteRead(Adapter, 0x3ED, &targetval_B, FALSE); efuse_OneByteRead(Adapter, 0x3EE, &targetval_C, FALSE); efuse_OneByteRead(Adapter, 0x3EF, &targetval_D, FALSE); } - else if (channelToSW >= 149 && channelToSW <= 165) // 5GHB - { + else if (channelToSW >= 149 && channelToSW <= 165) { // 5GHB efuse_OneByteRead(Adapter, 0x3F0, &targetval_A, FALSE); efuse_OneByteRead(Adapter, 0x3F1, &targetval_B, FALSE); efuse_OneByteRead(Adapter, 0x3F2, &targetval_C, FALSE); @@ -2394,12 +2272,10 @@ phy_ConfigKFree8814A( RTW_INFO("phy_ConfigKFree8814A(): targetval_B= %#x \n", targetval_B); RTW_INFO("phy_ConfigKFree8814A(): targetval_C= %#x \n", targetval_C); RTW_INFO("phy_ConfigKFree8814A(): targetval_D= %#x \n", targetval_D); - + // Make sure the targetval is defined - if ((Adapter->registrypriv.RegPwrTrimEnable == 1) && ((targetval_A != 0xFF) || (pHalData->RfKFreeEnable == TRUE))) - { - if (bandType == BAND_ON_2_4G) // 2G - { + if ((Adapter->registrypriv.RegPwrTrimEnable == 1) && ((targetval_A != 0xFF) || (pHalData->RfKFreeEnable == TRUE))) { + if (bandType == BAND_ON_2_4G) { // 2G RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): PATH_A: %#x \n", targetval_A&0x0F)); phy_SetKfreeToRF_8814A(Adapter, ODM_RF_PATH_A, targetval_A&0x0F); RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): PATH_B: %#x \n", (targetval_A&0xF0)>>4)); @@ -2409,8 +2285,7 @@ phy_ConfigKFree8814A( RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): PATH_D: %#x \n", (targetval_B&0xF0)>>4)); phy_SetKfreeToRF_8814A(Adapter, ODM_RF_PATH_D, (targetval_B&0xF0)>>4); } - else if(bandType == BAND_ON_5G) - { + else if(bandType == BAND_ON_5G) { RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): PATH_A: %#x \n", targetval_A&0x1F)); phy_SetKfreeToRF_8814A(Adapter, ODM_RF_PATH_A, targetval_A&0x1F); RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): PATH_B: %#x \n", targetval_B&0x1F)); @@ -2420,9 +2295,7 @@ phy_ConfigKFree8814A( RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): PATH_D: %#x \n", targetval_D&0x1F)); phy_SetKfreeToRF_8814A(Adapter, ODM_RF_PATH_D, targetval_D&0x1F); } - } - else - { + } else { RT_TRACE(COMP_MP, DBG_LOUD, ("phy_ConfigKFree8814A(): targetval not defined, Don't execute KFree Process.\n")); return; } @@ -2431,7 +2304,7 @@ phy_ConfigKFree8814A( } VOID -phy_SwChnl8814A( +phy_SwChnl8814A( IN PADAPTER pAdapter ) { @@ -2442,20 +2315,18 @@ phy_SwChnl8814A( #endif u8 channelToSW = pHalData->CurrentChannel; u32 RFValToWR , RFTmpVal, BitShift, BitMask; - + //RTW_INFO("[BW:CHNL], phy_SwChnl8814A(), switch to channel %d !!\n", channelToSW); - if (phy_SwBand8814A(pAdapter, channelToSW) == FALSE) - { + if (phy_SwBand8814A(pAdapter, channelToSW) == FALSE) { RTW_INFO("error Chnl %d", channelToSW); } - if(pHalData->rf_chip == RF_PSEUDO_11N) - { + if(pHalData->rf_chip == RF_PSEUDO_11N) { RT_TRACE(COMP_MLME, DBG_LOUD, ("phy_SwChnl8814A: return for PSEUDO\n")); return; } - + #ifdef CONFIG_RF_GAIN_OFFSET /* Add for KFree Feature Requested by RF David. */ if (kfree_data->flag & KFREE_FLAG_ON) { @@ -2474,34 +2345,30 @@ phy_SwChnl8814A( } #endif - if(pHalData->RegFWOffload == 2) - { + if (pHalData->RegFWOffload == 2) { FillH2CCmd_8814(pAdapter, H2C_CHNL_SWITCH_OFFLOAD, 1, &channelToSW); - } - else - { - // fc_area - if (36 <= channelToSW && channelToSW <= 48) - PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x494); - else if (50 <= channelToSW && channelToSW <= 64) - PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x453); - else if (100 <= channelToSW && channelToSW <= 116) - PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x452); - else if (118 <= channelToSW) - PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x412); + } else { + // fc_area + if (36 <= channelToSW && channelToSW <= 48) + PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x494); + else if (50 <= channelToSW && channelToSW <= 64) + PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x453); + else if (100 <= channelToSW && channelToSW <= 116) + PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x452); + else if (118 <= channelToSW) + PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x412); else PHY_SetBBReg(pAdapter, rFc_area_Jaguar, 0x1ffe0000, 0x96a); - for(eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) - { + for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { // RF_MOD_AG if (36 <= channelToSW && channelToSW <= 64) RFValToWR = 0x101; //5'b00101 - else if (100 <= channelToSW && channelToSW <= 140) + else if (100 <= channelToSW && channelToSW <= 140) RFValToWR = 0x301; //5'b01101 - else if (140 < channelToSW) + else if (140 < channelToSW) RFValToWR = 0x501; //5'b10101 - else + else RFValToWR = 0x000; //5'b00000 // Channel to switch @@ -2528,7 +2395,7 @@ phy_SwChnl8814A( phy_SpurCalibration_8814A(pAdapter); phy_ModifyInitialGain_8814A(pAdapter); } - + /* 2.4G CCK TX DFIR */ if (channelToSW >= 1 && channelToSW <= 11) { PHY_SetBBReg(pAdapter, rCCK0_TxFilter1, bMaskDWord, 0x1a1b0030); @@ -2554,29 +2421,28 @@ PHY_SwChnlTimerCallback8814A( { PADAPTER pAdapter = (PADAPTER)pTimer->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - + RT_TRACE(COMP_SCAN, DBG_LOUD, ("==>PHY_SwChnlTimerCallback8814A(), switch to channel %d\n", pHalData->CurrentChannel)); - + if (rtw_is_drv_stopped(padapter)) return; - - if(pHalData->rf_chip == RF_PSEUDO_11N) - { + + if(pHalData->rf_chip == RF_PSEUDO_11N) { pHalData->SwChnlInProgress=FALSE; - return; //return immediately if it is peudo-phy + return; //return immediately if it is peudo-phy } PlatformAcquireSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); pHalData->SwChnlInProgress=TRUE; PlatformReleaseSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); - + phy_SwChnl8814A(pAdapter); PlatformAcquireSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); pHalData->SwChnlInProgress=FALSE; PlatformReleaseSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); - + RT_TRACE(COMP_SCAN, DBG_LOUD, ("<==PHY_SwChnlTimerCallback8814()\n")); } @@ -2590,33 +2456,31 @@ PHY_SwChnlWorkItemCallback8814A( HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); RT_TRACE(COMP_SCAN, DBG_LOUD, ("==>PHY_SwChnlWorkItemCallback8814A(), switch to channel %d\n", pHalData->CurrentChannel)); - if(pAdapter->bInSetPower && RT_USB_CANNOT_IO(pAdapter)) - { + if(pAdapter->bInSetPower && RT_USB_CANNOT_IO(pAdapter)) { RT_TRACE(COMP_SCAN, DBG_LOUD, ("<== PHY_SwChnlWorkItemCallback8814A() SwChnlInProgress FALSE driver sleep or unload\n")); - - pHalData->SwChnlInProgress = FALSE; + + pHalData->SwChnlInProgress = FALSE; return; } - + if (rtw_is_drv_stopped(padapter)) return; - - if(pHalData->rf_chip == RF_PSEUDO_11N) - { + + if(pHalData->rf_chip == RF_PSEUDO_11N) { pHalData->SwChnlInProgress=FALSE; - return; //return immediately if it is peudo-phy + return; //return immediately if it is peudo-phy } PlatformAcquireSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); pHalData->SwChnlInProgress=TRUE; PlatformReleaseSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); - + phy_SwChnl8814A(pAdapter); - PlatformAcquireSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); + PlatformAcquireSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); pHalData->SwChnlInProgress=FALSE; PlatformReleaseSpinLock(pAdapter, RT_CHANNEL_AND_BANDWIDTH_SPINLOCK); - + RT_TRACE(COMP_P2P, DBG_LOUD, ("PHY_SwChnlWorkItemCallback8814A(), switch to channel %d\n", pHalData->CurrentChannel)); RT_TRACE(COMP_SCAN, DBG_LOUD, ("<==PHY_SwChnlWorkItemCallback8814A()\n")); } @@ -2635,7 +2499,7 @@ HAL_HandleSwChnl8814A( // Call after initialization phy_SwChnl8814A(Adapter); -#if (MP_DRIVER == 1) +#if (MP_DRIVER == 1) // <20120712, Kordan> IQK on each channel, asked by James. PHY_IQCalibrate_8814A(pAdapter, FALSE); #endif @@ -2653,32 +2517,29 @@ phy_SwChnlAndSetBwMode8814A( PDM_ODM_T pDM_Odm = &pHalData->odmpriv; //RTW_INFO("phy_SwChnlAndSetBwMode8814A(): bSwChnl %d, bSetChnlBW %d \n", pHalData->bSwChnl, pHalData->bSetChnlBW); - if ( Adapter->bNotifyChannelChange ) - { - RTW_INFO( "[%s] bSwChnl=%d, ch=%d, bSetChnlBW=%d, bw=%d\n", - __FUNCTION__, + if ( Adapter->bNotifyChannelChange ) { + RTW_INFO( "[%s] bSwChnl=%d, ch=%d, bSetChnlBW=%d, bw=%d\n", + __FUNCTION__, pHalData->bSwChnl, pHalData->CurrentChannel, pHalData->bSetChnlBW, pHalData->CurrentChannelBW); } - + if (RTW_CANNOT_RUN(Adapter)) { pHalData->bSwChnlAndSetBWInProgress= FALSE; return; } - if (pHalData->bSwChnl) - { + if (pHalData->bSwChnl) { phy_SwChnl8814A(Adapter); pHalData->bSwChnl = FALSE; - } + } - if (pHalData->bSetChnlBW) - { + if (pHalData->bSetChnlBW) { phy_SetBwMode8814A(Adapter); pHalData->bSetChnlBW = FALSE; - } + } if (Adapter->registrypriv.mp_mode == 0) { ODM_ClearTxPowerTrackingState(pDM_Odm); @@ -2690,19 +2551,19 @@ phy_SwChnlAndSetBwMode8814A( } else PHY_IQCalibrate_8814A(pDM_Odm, _FALSE); #if 0 //todo -#if (AUTO_CHNL_SEL_NHM == 1) - if(IS_AUTO_CHNL_SUPPORT(Adapter) && +#if (AUTO_CHNL_SEL_NHM == 1) + if(IS_AUTO_CHNL_SUPPORT(Adapter) && P2PIsSocialChannel(pHalData->CurrentChannel)) - { + { RT_TRACE(COMP_SCAN, DBG_TRACE, ("[ACS] phy_SwChnlAndSetBwMode8723B(): CurrentChannel %d Reset NHM counter!!\n", pHalData->CurrentChannel)); - RT_TRACE(COMP_SCAN, DBG_TRACE, ("[ACS] phy_SwChnlAndSetBwMode8723B(): AutoChnlSelPeriod(%d)\n", + RT_TRACE(COMP_SCAN, DBG_TRACE, ("[ACS] phy_SwChnlAndSetBwMode8723B(): AutoChnlSelPeriod(%d)\n", GetDefaultAdapter(Adapter)->MgntInfo.AutoChnlSel.AutoChnlSelPeriod)); - // Reset NHM counter + // Reset NHM counter odm_AutoChannelSelectReset(GET_PDM_ODM(Adapter)); - + SET_AUTO_CHNL_STATE(Adapter, ACS_BEFORE_NHM);// Before NHM measurement - } + } #endif #endif //0 pHalData->bSwChnlAndSetBWInProgress= FALSE; @@ -2727,7 +2588,7 @@ PHY_SwChnlAndSetBWModeCallback8814A( // The following procedure is operted according to SwChanlCallback8190Pci(). // However, this procedure is performed synchronously which should be running under // passive level. -// +// VOID PHY_SwChnlSynchronously8814A( // Only called during initialize IN PADAPTER Adapter, @@ -2745,16 +2606,14 @@ PHY_SwChnlSynchronously8814A( // Only called during initialize // Channel Switching is in progress. if(pHalData->bSwChnlAndSetBWInProgress) return; - + //return immediately if it is peudo-phy - if(pHalData->rf_chip == RF_PSEUDO_11N) - { + if(pHalData->rf_chip == RF_PSEUDO_11N) { pHalData->bSwChnlAndSetBWInProgress=FALSE; return; } - switch(pHalData->CurrentWirelessMode) - { + switch(pHalData->CurrentWirelessMode) { case WIRELESS_MODE_A: case WIRELESS_MODE_N_5G: case WIRELESS_MODE_AC_5G: @@ -2762,9 +2621,9 @@ PHY_SwChnlSynchronously8814A( // Only called during initialize //FIX ME!!! if(channel <=14) return; - RT_ASSERT((channel>14), ("WIRELESS_MODE_A but channel<=14")); + RT_ASSERT((channel>14), ("WIRELESS_MODE_A but channel<=14")); break; - + case WIRELESS_MODE_B: case WIRELESS_MODE_G: case WIRELESS_MODE_N_24G: @@ -2779,8 +2638,8 @@ PHY_SwChnlSynchronously8814A( // Only called during initialize default: RT_ASSERT(FALSE, ("Invalid WirelessMode(%#x)!!\n", pHalData->CurrentWirelessMode)); break; - - } + + } pHalData->bSwChnlAndSetBWInProgress = TRUE; if( channel == 0) @@ -2793,7 +2652,7 @@ PHY_SwChnlSynchronously8814A( // Only called during initialize phy_SwChnlAndSetBwMode8814A(Adapter); RT_TRACE(COMP_SCAN | COMP_RM, DBG_LOUD, ("<==PHY_SwChnlSynchronously(), switch from channel %d to channel %d.\n", pHalData->CurrentChannel, channel)); - + } */ @@ -2819,17 +2678,14 @@ PHY_HandleSwChnlAndSetBW8814A( struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; //check is swchnl or setbw - if(!bSwitchChannel && !bSetBandWidth) - { + if (!bSwitchChannel && !bSetBandWidth) { RTW_INFO("PHY_HandleSwChnlAndSetBW8812: not switch channel and not set bandwidth \n"); return; } //skip change for channel or bandwidth is the same - if(bSwitchChannel) - { - if(pHalData->CurrentChannel != ChannelNum) - { + if (bSwitchChannel) { + if(pHalData->CurrentChannel != ChannelNum) { if (HAL_IsLegalChannel(Adapter, ChannelNum)) pHalData->bSwChnl = _TRUE; else @@ -2837,15 +2693,13 @@ PHY_HandleSwChnlAndSetBW8814A( } } - if(bSetBandWidth) - { - if(pHalData->bChnlBWInitialized == _FALSE) - { + if (bSetBandWidth) { + if (pHalData->bChnlBWInitialized == _FALSE) { pHalData->bChnlBWInitialized = _TRUE; pHalData->bSetChnlBW = _TRUE; } - else if((pHalData->CurrentChannelBW != ChnlWidth) || - (pHalData->nCur40MhzPrimeSC != ChnlOffsetOf40MHz) || + else if ((pHalData->CurrentChannelBW != ChnlWidth) || + (pHalData->nCur40MhzPrimeSC != ChnlOffsetOf40MHz) || (pHalData->nCur80MhzPrimeSC != ChnlOffsetOf80MHz) || (pHalData->CurrentCenterFrequencyIndex1!= CenterFrequencyIndex1)) { @@ -2853,34 +2707,29 @@ PHY_HandleSwChnlAndSetBW8814A( } } - if(!pHalData->bSetChnlBW && !pHalData->bSwChnl) - { + if (!pHalData->bSetChnlBW && !pHalData->bSwChnl) { //RTW_INFO("<= PHY_HandleSwChnlAndSetBW8812: bSwChnl %d, bSetChnlBW %d \n",pHalData->bSwChnl,pHalData->bSetChnlBW); return; } - - if(pHalData->bSwChnl) - { + if (pHalData->bSwChnl) { pHalData->CurrentChannel=ChannelNum; pHalData->CurrentCenterFrequencyIndex1 = ChannelNum; } - - if(pHalData->bSetChnlBW) - { + if (pHalData->bSetChnlBW) { pHalData->CurrentChannelBW = ChnlWidth; #if 0 - if(ExtChnlOffsetOf40MHz==EXTCHNL_OFFSET_LOWER) + if (ExtChnlOffsetOf40MHz==EXTCHNL_OFFSET_LOWER) pHalData->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; - else if(ExtChnlOffsetOf40MHz==EXTCHNL_OFFSET_UPPER) + else if (ExtChnlOffsetOf40MHz==EXTCHNL_OFFSET_UPPER) pHalData->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; else pHalData->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - if(ExtChnlOffsetOf80MHz==EXTCHNL_OFFSET_LOWER) + if (ExtChnlOffsetOf80MHz==EXTCHNL_OFFSET_LOWER) pHalData->nCur80MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; - else if(ExtChnlOffsetOf80MHz==EXTCHNL_OFFSET_UPPER) + else if (ExtChnlOffsetOf80MHz==EXTCHNL_OFFSET_UPPER) pHalData->nCur80MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; else pHalData->nCur80MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -2889,20 +2738,18 @@ PHY_HandleSwChnlAndSetBW8814A( pHalData->nCur80MhzPrimeSC = ChnlOffsetOf80MHz; #endif - pHalData->CurrentCenterFrequencyIndex1 = CenterFrequencyIndex1; + pHalData->CurrentCenterFrequencyIndex1 = CenterFrequencyIndex1; } //Switch workitem or set timer to do switch channel or setbandwidth operation if (!RTW_CANNOT_RUN(Adapter)) phy_SwChnlAndSetBwMode8814A(Adapter); else { - if(pHalData->bSwChnl) - { + if (pHalData->bSwChnl) { pHalData->CurrentChannel = tmpChannel; pHalData->CurrentCenterFrequencyIndex1 = tmpChannel; - } - if(pHalData->bSetChnlBW) - { + } + if (pHalData->bSetChnlBW) { pHalData->CurrentChannelBW = tmpBW; pHalData->nCur40MhzPrimeSC = tmpnCur40MhzPrimeSC; pHalData->nCur80MhzPrimeSC = tmpnCur80MhzPrimeSC; @@ -2923,7 +2770,7 @@ PHY_HandleSwChnlAndSetBW8814A( // // Description: // Configure H/W functionality to enable/disable Monitor mode. -// Note, because we possibly need to configure BB and RF in this function, +// Note, because we possibly need to configure BB and RF in this function, // so caller should in PASSIVE_LEVEL. 080118, by rcnjko. // VOID @@ -2936,17 +2783,14 @@ PHY_SetMonitorMode8814A( BOOLEAN bFilterOutNonAssociatedBSSID = FALSE; //2 Note: we may need to stop antenna diversity. - if(bEnableMonitorMode) - { + if(bEnableMonitorMode) { bFilterOutNonAssociatedBSSID = FALSE; RT_TRACE(COMP_RM, DBG_LOUD, ("PHY_SetMonitorMode8814A(): enable monitor mode\n")); pHalData->bInMonitorMode = TRUE; pAdapter->HalFunc.AllowAllDestAddrHandler(pAdapter, TRUE, TRUE); rtw_hal_set_hwreg(pAdapter, HW_VAR_CHECK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); - } - else - { + } else { bFilterOutNonAssociatedBSSID = TRUE; RT_TRACE(COMP_RM, DBG_LOUD, ("PHY_SetMonitorMode8814A(): disable monitor mode\n")); @@ -3010,4 +2854,3 @@ PHY_SetSwChnlBWMode8814( //RTW_INFO("<==%s()\n",__FUNCTION__); } - From 005d1b8117a5215d180de72360dd2eee57658ade Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 17:17:56 +0100 Subject: [PATCH 05/12] Code cleanup --- hal/rtl8814a/rtl8814a_rf6052.c | 48 +++++++++++++++------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/hal/rtl8814a/rtl8814a_rf6052.c b/hal/rtl8814a/rtl8814a_rf6052.c index 67091fc..f152787 100644 --- a/hal/rtl8814a/rtl8814a_rf6052.c +++ b/hal/rtl8814a/rtl8814a_rf6052.c @@ -42,8 +42,7 @@ PHY_RF6052SetBandwidth8814A( IN PADAPTER Adapter, IN CHANNEL_WIDTH Bandwidth) //20M or 40M { - switch(Bandwidth) - { + switch (Bandwidth) { case CHANNEL_WIDTH_20: /*RTW_INFO("PHY_RF6052SetBandwidth8814A(), set 20MHz\n");*/ PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 3); @@ -51,26 +50,26 @@ PHY_RF6052SetBandwidth8814A( PHY_SetRFReg(Adapter, RF_PATH_C, RF_CHNLBW_Jaguar, BIT11|BIT10, 3); PHY_SetRFReg(Adapter, RF_PATH_D, RF_CHNLBW_Jaguar, BIT11|BIT10, 3); break; - + case CHANNEL_WIDTH_40: /*RTW_INFO("PHY_RF6052SetBandwidth8814A(), set 40MHz\n");*/ - PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); - PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); - PHY_SetRFReg(Adapter, RF_PATH_C, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); - PHY_SetRFReg(Adapter, RF_PATH_D, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); + PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); + PHY_SetRFReg(Adapter, RF_PATH_C, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); + PHY_SetRFReg(Adapter, RF_PATH_D, RF_CHNLBW_Jaguar, BIT11|BIT10, 1); break; - + case CHANNEL_WIDTH_80: /*RTW_INFO("PHY_RF6052SetBandwidth8814A(), set 80MHz\n");*/ - PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 0); - PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW_Jaguar, BIT11|BIT10, 0); - PHY_SetRFReg(Adapter, RF_PATH_C, RF_CHNLBW_Jaguar, BIT11|BIT10, 0); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW_Jaguar, BIT11|BIT10, 0); + PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW_Jaguar, BIT11|BIT10, 0); + PHY_SetRFReg(Adapter, RF_PATH_C, RF_CHNLBW_Jaguar, BIT11|BIT10, 0); PHY_SetRFReg(Adapter, RF_PATH_D, RF_CHNLBW_Jaguar, BIT11|BIT10, 0); break; - + default: RTW_INFO("PHY_RF6052SetBandwidth8814A(): unknown Bandwidth: %#X\n",Bandwidth ); - break; + break; } } @@ -101,18 +100,16 @@ phy_RF6052_Config_ParaFile_8814A( //3// <2> Initialize RF //3//----------------------------------------------------------------- //for(eRFPath = RF_PATH_A; eRFPath NumTotalRFPath; eRFPath++) - for(eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) - { + for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) { /*----Initialize RF fom connfiguration file----*/ - switch(eRFPath) - { + switch (eRFPath) { case RF_PATH_A: #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, eRFPath) == _FAIL) #endif //CONFIG_LOAD_PHY_PARA_FROM_FILE { #ifdef CONFIG_EMBEDDED_FWIMG - if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) + if (HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus = _FAIL; #endif //CONFIG_EMBEDDED_FWIMG } @@ -123,7 +120,7 @@ phy_RF6052_Config_ParaFile_8814A( #endif //CONFIG_LOAD_PHY_PARA_FROM_FILE { #ifdef CONFIG_EMBEDDED_FWIMG - if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) + if (HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus = _FAIL; #endif //CONFIG_EMBEDDED_FWIMG } @@ -134,7 +131,7 @@ phy_RF6052_Config_ParaFile_8814A( #endif //CONFIG_LOAD_PHY_PARA_FROM_FILE { #ifdef CONFIG_EMBEDDED_FWIMG - if(HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) + if (HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) rtStatus = _FAIL; #endif //CONFIG_EMBEDDED_FWIMG } @@ -154,20 +151,20 @@ phy_RF6052_Config_ParaFile_8814A( break; } - if(rtStatus != _SUCCESS){ + if (rtStatus != _SUCCESS) { RTW_INFO("%s():Radio[%d] Fail!!", __FUNCTION__, eRFPath); goto phy_RF6052_Config_ParaFile_Fail; } } - + u4RegValue = PHY_QueryRFReg(Adapter, RF_PATH_A, RF_RCK1_Jaguar, bRFRegOffsetMask); PHY_SetRFReg(Adapter, RF_PATH_B, RF_RCK1_Jaguar, bRFRegOffsetMask, u4RegValue); PHY_SetRFReg(Adapter, RF_PATH_C, RF_RCK1_Jaguar, bRFRegOffsetMask, u4RegValue); PHY_SetRFReg(Adapter, RF_PATH_D, RF_RCK1_Jaguar, bRFRegOffsetMask, u4RegValue); - + //3 ----------------------------------------------------------------- - //3 Configuration of Tx Power Tracking + //3 Configuration of Tx Power Tracking //3 ----------------------------------------------------------------- #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE @@ -185,7 +182,6 @@ phy_RF6052_Config_ParaFile_Fail: return rtStatus; } - int PHY_RF6052_Config_8814A( IN PADAPTER Adapter) @@ -205,6 +201,4 @@ PHY_RF6052_Config_8814A( } - /* End of HalRf6052.c */ - From 40fcd1e3b8d795464f749bb71344c72399785229 Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 17:19:48 +0100 Subject: [PATCH 06/12] Code cleanup --- hal/rtl8814a/rtl8814a_sreset.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hal/rtl8814a/rtl8814a_sreset.c b/hal/rtl8814a/rtl8814a_sreset.c index 5d7e423..4a7947e 100644 --- a/hal/rtl8814a/rtl8814a_sreset.c +++ b/hal/rtl8814a/rtl8814a_sreset.c @@ -32,8 +32,8 @@ void rtl8814_sreset_xmit_status_check(_adapter *padapter) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; unsigned int diff_time; u32 txdma_status; - - if( (txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS)) !=0x00){ + + if ( (txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS)) !=0x00) { RTW_INFO("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status); rtw_hal_sreset_reset(padapter); } @@ -51,7 +51,7 @@ void rtl8814_sreset_xmit_status_check(_adapter *padapter) if (psrtpriv->last_tx_complete_time == 0) { psrtpriv->last_tx_complete_time = current_time; } - else{ + else { diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_complete_time); if (diff_time > 4000) { u32 ability = 0; @@ -84,9 +84,9 @@ void rtl8814_sreset_linked_status_check(_adapter *padapter) u32 rx_dma_status = 0; rx_dma_status = rtw_read32(padapter,REG_RXDMA_STATUS); - if(rx_dma_status!= 0x00){ + if (rx_dma_status!= 0x00) { RTW_INFO("%s REG_RXDMA_STATUS:0x%08x\n",__FUNCTION__,rx_dma_status); - } + } #if 0 u32 regc50,regc58,reg824,reg800; regc50 = rtw_read32(padapter,0xc50); @@ -111,4 +111,3 @@ void rtl8814_sreset_linked_status_check(_adapter *padapter) } } #endif - From 7e4846cbe7c9f3a94c7d6e1175cf55c115fe625f Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 17:28:04 +0100 Subject: [PATCH 07/12] Code cleanup --- hal/rtl8814a/rtl8814a_xmit.c | 245 +++++++++++++++-------------------- 1 file changed, 106 insertions(+), 139 deletions(-) diff --git a/hal/rtl8814a/rtl8814a_xmit.c b/hal/rtl8814a/rtl8814a_xmit.c index 85bae28..43b8268 100644 --- a/hal/rtl8814a/rtl8814a_xmit.c +++ b/hal/rtl8814a/rtl8814a_xmit.c @@ -28,22 +28,22 @@ void _dbg_dump_tx_info(_adapter *padapter,int frame_tag, u8 *ptxdesc) u8 bDumpTxDesc = _FALSE; rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(bDumpTxPkt)); - if(bDumpTxPkt ==1){//dump txdesc for data frame + if (bDumpTxPkt ==1) { //dump txdesc for data frame RTW_INFO("dump tx_desc for data frame\n"); - if((frame_tag&0x0f) == DATA_FRAMETAG){ - bDumpTxDesc = _TRUE; + if ((frame_tag&0x0f) == DATA_FRAMETAG){ + bDumpTxDesc = _TRUE; } - } - else if(bDumpTxPkt ==2){//dump txdesc for mgnt frame - RTW_INFO("dump tx_desc for mgnt frame\n"); - if((frame_tag&0x0f) == MGNT_FRAMETAG){ - bDumpTxDesc = _TRUE; - } - } - else if(bDumpTxPkt ==3){//dump early info } - - if(bDumpTxDesc){ + else if (bDumpTxPkt ==2) { //dump txdesc for mgnt frame + RTW_INFO("dump tx_desc for mgnt frame\n"); + if ((frame_tag&0x0f) == MGNT_FRAMETAG) { + bDumpTxDesc = _TRUE; + } + } + else if (bDumpTxPkt ==3) { //dump early info + } + + if (bDumpTxDesc) { // ptxdesc->txdw4 = cpu_to_le32(0x00001006);//RTS Rate=24M // ptxdesc->txdw6 = 0x6666f800; RTW_INFO("=====================================\n"); @@ -75,7 +75,7 @@ void _dbg_dump_tx_info(_adapter *padapter,int frame_tag, u8 *ptxdesc) //#define DBG_EMINFO -#if RTL8188E_EARLY_MODE_PKT_NUM_10 == 1 +#if RTL8188E_EARLY_MODE_PKT_NUM_10 == 1 #define EARLY_MODE_MAX_PKT_NUM 10 #else #define EARLY_MODE_MAX_PKT_NUM 5 @@ -100,65 +100,65 @@ InsertEMContent_8814( #endif _rtw_memset(VirtualAddress, 0, EARLY_MODE_INFO_SIZE); - if(pEMInfo->EMPktNum==0) + if (pEMInfo->EMPktNum==0) return; #ifdef DBG_EMINFO { int i; RTW_INFO("\n%s ==> pEMInfo->EMPktNum =%d\n",__FUNCTION__,pEMInfo->EMPktNum); - for(i=0;i< EARLY_MODE_MAX_PKT_NUM;i++){ + for (i = 0;i< EARLY_MODE_MAX_PKT_NUM;i++) { RTW_INFO("%s ==> pEMInfo->EMPktLen[%d] =%d\n",__FUNCTION__,i,pEMInfo->EMPktLen[i]); } } #endif - + #if RTL8188E_EARLY_MODE_PKT_NUM_10 == 1 SET_EARLYMODE_PKTNUM(VirtualAddress, pEMInfo->EMPktNum); - if(pEMInfo->EMPktNum == 1){ + if (pEMInfo->EMPktNum == 1) { dwtmp = pEMInfo->EMPktLen[0]; - }else{ + } else { dwtmp = pEMInfo->EMPktLen[0]; dwtmp += ((dwtmp%4)?(4-dwtmp%4):0)+4; dwtmp += pEMInfo->EMPktLen[1]; } SET_EARLYMODE_LEN0(VirtualAddress, dwtmp); - if(pEMInfo->EMPktNum <= 3){ + if (pEMInfo->EMPktNum <= 3) { dwtmp = pEMInfo->EMPktLen[2]; - }else{ + } else { dwtmp = pEMInfo->EMPktLen[2]; dwtmp += ((dwtmp%4)?(4-dwtmp%4):0)+4; dwtmp += pEMInfo->EMPktLen[3]; } SET_EARLYMODE_LEN1(VirtualAddress, dwtmp); - if(pEMInfo->EMPktNum <= 5){ + if (pEMInfo->EMPktNum <= 5) { dwtmp = pEMInfo->EMPktLen[4]; - }else{ + } else { dwtmp = pEMInfo->EMPktLen[4]; dwtmp += ((dwtmp%4)?(4-dwtmp%4):0)+4; dwtmp += pEMInfo->EMPktLen[5]; } SET_EARLYMODE_LEN2_1(VirtualAddress, dwtmp&0xF); SET_EARLYMODE_LEN2_2(VirtualAddress, dwtmp>>4); - if(pEMInfo->EMPktNum <= 7){ + if (pEMInfo->EMPktNum <= 7) { dwtmp = pEMInfo->EMPktLen[6]; - }else{ + } else { dwtmp = pEMInfo->EMPktLen[6]; dwtmp += ((dwtmp%4)?(4-dwtmp%4):0)+4; dwtmp += pEMInfo->EMPktLen[7]; } SET_EARLYMODE_LEN3(VirtualAddress, dwtmp); - if(pEMInfo->EMPktNum <= 9){ + if (pEMInfo->EMPktNum <= 9) { dwtmp = pEMInfo->EMPktLen[8]; - }else{ + } else { dwtmp = pEMInfo->EMPktLen[8]; dwtmp += ((dwtmp%4)?(4-dwtmp%4):0)+4; dwtmp += pEMInfo->EMPktLen[9]; } SET_EARLYMODE_LEN4(VirtualAddress, dwtmp); -#else +#else SET_EARLYMODE_PKTNUM(VirtualAddress, pEMInfo->EMPktNum); SET_EARLYMODE_LEN0(VirtualAddress, pEMInfo->EMPktLen[0]); SET_EARLYMODE_LEN1(VirtualAddress, pEMInfo->EMPktLen[1]); @@ -166,7 +166,7 @@ InsertEMContent_8814( SET_EARLYMODE_LEN2_2(VirtualAddress, pEMInfo->EMPktLen[2]>>4); SET_EARLYMODE_LEN3(VirtualAddress, pEMInfo->EMPktLen[3]); SET_EARLYMODE_LEN4(VirtualAddress, pEMInfo->EMPktLen[4]); -#endif +#endif //RT_PRINT_DATA(COMP_SEND, DBG_LOUD, "EMHdr:", VirtualAddress, 8); } @@ -179,72 +179,68 @@ void UpdateEarlyModeInfo8814(struct xmit_priv *pxmitpriv,struct xmit_buf *pxmitb int index,j; u16 offset,pktlen; PTXDESC_8814 ptxdesc; - + u8 *pmem,*pEMInfo_mem; s8 node_num_0=0,node_num_1=0; struct EMInfo eminfo; struct agg_pkt_info *paggpkt; - struct xmit_frame *pframe = (struct xmit_frame*)pxmitbuf->priv_data; - pmem= pframe->buf_addr; - - #ifdef DBG_EMINFO + struct xmit_frame *pframe = (struct xmit_frame*)pxmitbuf->priv_data; + pmem= pframe->buf_addr; + + #ifdef DBG_EMINFO RTW_INFO("\n%s ==> agg_num:%d\n",__FUNCTION__, pframe->agg_num); - for(index=0;indexagg_num;index++){ + for (index=0;indexagg_num;index++){ offset = pxmitpriv->agg_pkt[index].offset; pktlen = pxmitpriv->agg_pkt[index].pkt_len; RTW_INFO("%s ==> agg_pkt[%d].offset=%d\n",__FUNCTION__,index,offset); RTW_INFO("%s ==> agg_pkt[%d].pkt_len=%d\n",__FUNCTION__,index,pktlen); } #endif - - if( pframe->agg_num > EARLY_MODE_MAX_PKT_NUM) - { + + if ( pframe->agg_num > EARLY_MODE_MAX_PKT_NUM) { node_num_0 = pframe->agg_num; node_num_1= EARLY_MODE_MAX_PKT_NUM-1; } - - for(index=0;indexagg_num;index++){ + + for (index=0;indexagg_num;index++) { offset = pxmitpriv->agg_pkt[index].offset; - pktlen = pxmitpriv->agg_pkt[index].pkt_len; + pktlen = pxmitpriv->agg_pkt[index].pkt_len; _rtw_memset(&eminfo,0,sizeof(struct EMInfo)); - if( pframe->agg_num > EARLY_MODE_MAX_PKT_NUM){ - if(node_num_0 > EARLY_MODE_MAX_PKT_NUM){ + if ( pframe->agg_num > EARLY_MODE_MAX_PKT_NUM) { + if (node_num_0 > EARLY_MODE_MAX_PKT_NUM) { eminfo.EMPktNum = EARLY_MODE_MAX_PKT_NUM; node_num_0--; - } - else{ + } else{ eminfo.EMPktNum = node_num_1; - node_num_1--; - } + node_num_1--; + } + } else { + eminfo.EMPktNum = pframe->agg_num-(index+1); } - else{ - eminfo.EMPktNum = pframe->agg_num-(index+1); - } - for(j=0;j< eminfo.EMPktNum ;j++){ + for (j = 0;j< eminfo.EMPktNum ;j++) { eminfo.EMPktLen[j] = pxmitpriv->agg_pkt[index+1+j].pkt_len+4;// 4 bytes CRC } - - if(pmem){ - if(index==0){ + + if (pmem) { + if (index==0) { ptxdesc = (PTXDESC_8814)(pmem); - pEMInfo_mem = ((u8 *)ptxdesc)+TXDESC_SIZE; - } - else{ + pEMInfo_mem = ((u8 *)ptxdesc)+TXDESC_SIZE; + } else{ pmem = pmem + pxmitpriv->agg_pkt[index-1].offset; ptxdesc = (PTXDESC_8814)(pmem); - pEMInfo_mem = ((u8 *)ptxdesc)+TXDESC_SIZE; + pEMInfo_mem = ((u8 *)ptxdesc)+TXDESC_SIZE; } - + #ifdef DBG_EMINFO RTW_INFO("%s ==> desc.pkt_len=%d\n",__FUNCTION__,ptxdesc->pktlen); #endif InsertEMContent_8814(&eminfo,pEMInfo_mem); - } - - - } + } + + + } _rtw_memset(pxmitpriv->agg_pkt,0,sizeof(struct agg_pkt_info)*MAX_AGG_PKT_NUM); } @@ -268,7 +264,7 @@ void rtl8814a_cal_txdesc_chksum(u8 *ptxdesc) // Clear first SET_TX_DESC_TX_DESC_CHECKSUM_8814A(ptxdesc, 0); - for(index = 0 ; index < count ; index++){ + for (index = 0 ; index < count ; index++) { checksum = checksum ^ le16_to_cpu(*(usPtr + index)); } @@ -310,53 +306,47 @@ void rtl8814a_fill_fake_txdesc( } //Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. - if (IsPsPoll) - { - SET_TX_DESC_NAV_USE_HDR_8814A(pDesc, 1); - } - else - { + if (IsPsPoll) { + SET_TX_DESC_NAV_USE_HDR_8814A(pDesc, 1); + } else { SET_TX_DESC_HWSEQ_EN_8814A(pDesc, 1); // Hw set sequence number } #if 0 //todo - if(IsBTQosNull) - { + if (IsBTQosNull) { SET_TX_DESC_BT_INT_8812(pDesc, 1); } #endif //0 SET_TX_DESC_USE_RATE_8814A(pDesc, 1); - + //8814 no OWN bit? //SET_TX_DESC_OWN_8812(pDesc, 1); // // Encrypt the data frame if under security mode excepct null data. Suggested by CCW. // - if (_TRUE ==bDataFrame) - { + if (_TRUE ==bDataFrame) { u32 EncAlg; EncAlg = padapter->securitypriv.dot11PrivacyAlgrthm; - switch (EncAlg) - { + switch (EncAlg) { case _NO_PRIVACY_: - SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x0); + SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x0); break; case _WEP40_: case _WEP104_: case _TKIP_: - SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x1); + SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x1); break; case _SMS4_: - SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x2); + SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x2); break; case _AES_: SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x3); break; default: - SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x0); - break; + SET_TX_DESC_SEC_TYPE_8814A(pDesc, 0x0); + break; } } SET_TX_DESC_TX_RATE_8814A(pDesc, MRateToHwRate(pmlmeext->tx_rate)); @@ -370,15 +360,13 @@ void rtl8814a_fill_fake_txdesc( void rtl8814a_fill_txdesc_sectype(struct pkt_attrib *pattrib, u8 *ptxdesc) { - if ((pattrib->encrypt > 0) && !pattrib->bswenc) - { - switch (pattrib->encrypt) - { + if ((pattrib->encrypt > 0) && !pattrib->bswenc) { + switch (pattrib->encrypt) { //SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES case _WEP40_: case _WEP104_: case _TKIP_: - case _TKIP_WTMIC_: + case _TKIP_WTMIC_: SET_TX_DESC_SEC_TYPE_8814A(ptxdesc, 0x1); break; #ifdef CONFIG_WAPI_SUPPORT @@ -393,9 +381,9 @@ void rtl8814a_fill_txdesc_sectype(struct pkt_attrib *pattrib, u8 *ptxdesc) default: SET_TX_DESC_SEC_TYPE_8814A(ptxdesc, 0x0); break; - + } - + } } @@ -405,12 +393,11 @@ void rtl8814a_fill_txdesc_vcs(PADAPTER padapter, struct pkt_attrib *pattrib, u8 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - //RTW_INFO("vcs_mode=%d\n", pattrib->vcs_mode); + //RTW_INFO("vcs_mode=%d\n", pattrib->vcs_mode); if (pattrib->vcs_mode) { - switch(pattrib->vcs_mode) - { + switch (pattrib->vcs_mode) { case RTS_CTS: SET_TX_DESC_RTS_ENABLE_8814A(ptxdesc, 1); break; @@ -428,12 +415,12 @@ void rtl8814a_fill_txdesc_vcs(PADAPTER padapter, struct pkt_attrib *pattrib, u8 SET_TX_DESC_RTS_RATE_8814A(ptxdesc, 0x8);//RTS Rate=24M SET_TX_DESC_RTS_RATE_FB_LIMIT_8814A(ptxdesc, 0xf); - + } } -u8 +u8 BWMapping_8814( IN PADAPTER Adapter, IN struct pkt_attrib *pattrib @@ -444,18 +431,16 @@ BWMapping_8814( //RTW_INFO("BWMapping pHalData->CurrentChannelBW %d, pattrib->bwmode %d \n",pHalData->CurrentChannelBW,pattrib->bwmode); - if(pHalData->CurrentChannelBW== CHANNEL_WIDTH_80) - { - if(pattrib->bwmode == CHANNEL_WIDTH_80) + if (pHalData->CurrentChannelBW== CHANNEL_WIDTH_80) { + if (pattrib->bwmode == CHANNEL_WIDTH_80) BWSettingOfDesc= 2; - else if(pattrib->bwmode == CHANNEL_WIDTH_40) + else if (pattrib->bwmode == CHANNEL_WIDTH_40) BWSettingOfDesc = 1; else BWSettingOfDesc = 0; } - else if(pHalData->CurrentChannelBW== CHANNEL_WIDTH_40) - { - if((pattrib->bwmode == CHANNEL_WIDTH_40) || (pattrib->bwmode == CHANNEL_WIDTH_80)) + else if(pHalData->CurrentChannelBW== CHANNEL_WIDTH_40) { + if ((pattrib->bwmode == CHANNEL_WIDTH_40) || (pattrib->bwmode == CHANNEL_WIDTH_80)) BWSettingOfDesc = 1; else BWSettingOfDesc = 0; @@ -466,7 +451,7 @@ BWMapping_8814( return BWSettingOfDesc; } -u8 +u8 SCMapping_8814( IN PADAPTER Adapter, IN struct pkt_attrib *pattrib @@ -475,63 +460,48 @@ SCMapping_8814( u8 SCSettingOfDesc = 0; PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); //RTW_INFO("SCMapping: pHalData->CurrentChannelBW %d, pHalData->nCur80MhzPrimeSC %d, pHalData->nCur40MhzPrimeSC %d \n",pHalData->CurrentChannelBW,pHalData->nCur80MhzPrimeSC,pHalData->nCur40MhzPrimeSC); - - if(pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) - { - if(pattrib->bwmode == CHANNEL_WIDTH_80) - { + + if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) { + if (pattrib->bwmode == CHANNEL_WIDTH_80) { SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; } - else if(pattrib->bwmode == CHANNEL_WIDTH_40) - { - if(pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) + else if (pattrib->bwmode == CHANNEL_WIDTH_40) { + if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) SCSettingOfDesc = VHT_DATA_SC_40_LOWER_OF_80MHZ; - else if(pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) + else if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) SCSettingOfDesc = VHT_DATA_SC_40_UPPER_OF_80MHZ; else RTW_INFO("SCMapping: DONOT CARE Mode Setting\n"); - } - else - { - if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) + } else { + if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) SCSettingOfDesc = VHT_DATA_SC_20_LOWEST_OF_80MHZ; - else if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) + else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) SCSettingOfDesc = VHT_DATA_SC_20_LOWER_OF_80MHZ; - else if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) + else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) SCSettingOfDesc = VHT_DATA_SC_20_UPPER_OF_80MHZ; - else if((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) + else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) SCSettingOfDesc = VHT_DATA_SC_20_UPPERST_OF_80MHZ; else RTW_INFO("SCMapping: DONOT CARE Mode Setting\n"); } } - else if(pHalData->CurrentChannelBW== CHANNEL_WIDTH_40) - { + else if (pHalData->CurrentChannelBW== CHANNEL_WIDTH_40) { //RTW_INFO("SCMapping: HT Case: pHalData->CurrentChannelBW %d, pHalData->nCur40MhzPrimeSC %d \n",pHalData->CurrentChannelBW,pHalData->nCur40MhzPrimeSC); - if(pattrib->bwmode == CHANNEL_WIDTH_40) - { + if (pattrib->bwmode == CHANNEL_WIDTH_40) { SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; } - else if(pattrib->bwmode == CHANNEL_WIDTH_20) - { - if(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) - { + else if (pattrib->bwmode == CHANNEL_WIDTH_20) { + if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) { SCSettingOfDesc = VHT_DATA_SC_20_UPPER_OF_80MHZ; } - else if(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) - { + else if(pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) { SCSettingOfDesc = VHT_DATA_SC_20_LOWER_OF_80MHZ; - } - else - { + } else { SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; } - } - } - else - { + } else { SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; } @@ -543,13 +513,10 @@ void rtl8814a_fill_txdesc_phy(PADAPTER padapter, struct pkt_attrib *pattrib, u8 { //RTW_INFO("bwmode=%d, ch_off=%d\n", pattrib->bwmode, pattrib->ch_offset); - if(pattrib->ht_en) - { + if (pattrib->ht_en) { // Set Bandwidth and sub-channel settings. SET_TX_DESC_DATA_BW_8814A(ptxdesc, BWMapping_8814(padapter,pattrib)); SET_TX_DESC_DATA_SC_8814A(ptxdesc, SCMapping_8814(padapter,pattrib)); } } - - From df6456fc76e2c4926dfe58e443b4a7029fbd69a2 Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 17:29:35 +0100 Subject: [PATCH 08/12] Code cleanup --- hal/rtl8814a/Hal8814PwrSeq.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/hal/rtl8814a/Hal8814PwrSeq.c b/hal/rtl8814a/Hal8814PwrSeq.c index c11a36e..6370cbe 100644 --- a/hal/rtl8814a/Hal8814PwrSeq.c +++ b/hal/rtl8814a/Hal8814PwrSeq.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. @@ -21,7 +21,7 @@ #include "Hal8814PwrSeq.h" #include -/* +/* drivers should parse below arrays and do the corresponding actions */ //3 Power on Array @@ -50,7 +50,7 @@ WLAN_PWR_CFG rtl8814A_card_disable_flow[RTL8814A_TRANS_ACT_TO_CARDEMU_STEPS+RTL8 WLAN_PWR_CFG rtl8814A_card_enable_flow[RTL8814A_TRANS_ACT_TO_CARDEMU_STEPS+RTL8814A_TRANS_CARDEMU_TO_PDN_STEPS+RTL8814A_TRANS_END_STEPS]= { RTL8814A_TRANS_CARDDIS_TO_CARDEMU - RTL8814A_TRANS_CARDEMU_TO_ACT + RTL8814A_TRANS_CARDEMU_TO_ACT RTL8814A_TRANS_END }; @@ -70,29 +70,26 @@ WLAN_PWR_CFG rtl8814A_resume_flow[RTL8814A_TRANS_ACT_TO_CARDEMU_STEPS+RTL8814A_T RTL8814A_TRANS_END }; - - //3HWPDN Array WLAN_PWR_CFG rtl8814A_hwpdn_flow[RTL8814A_TRANS_ACT_TO_CARDEMU_STEPS+RTL8814A_TRANS_CARDEMU_TO_PDN_STEPS+RTL8814A_TRANS_END_STEPS]= { RTL8814A_TRANS_ACT_TO_CARDEMU - RTL8814A_TRANS_CARDEMU_TO_PDN + RTL8814A_TRANS_CARDEMU_TO_PDN RTL8814A_TRANS_END }; -//3 Enter LPS +//3 Enter LPS WLAN_PWR_CFG rtl8814A_enter_lps_flow[RTL8814A_TRANS_ACT_TO_LPS_STEPS+RTL8814A_TRANS_END_STEPS]= { //FW behavior - RTL8814A_TRANS_ACT_TO_LPS + RTL8814A_TRANS_ACT_TO_LPS RTL8814A_TRANS_END }; -//3 Leave LPS +//3 Leave LPS WLAN_PWR_CFG rtl8814A_leave_lps_flow[RTL8814A_TRANS_LPS_TO_ACT_STEPS+RTL8814A_TRANS_END_STEPS]= { //FW behavior RTL8814A_TRANS_LPS_TO_ACT RTL8814A_TRANS_END }; - From 88becaff4627231ecfc21d2170c6ebfb6961f7aa Mon Sep 17 00:00:00 2001 From: Christian B Date: Wed, 20 Dec 2017 20:23:31 +0100 Subject: [PATCH 09/12] Fix kernel v3.11 monitor mode crash --- os_dep/linux/ioctl_cfg80211.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 3b96594..8a7e088 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -796,12 +796,15 @@ check_bss: #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE) RTW_INFO("pwdev->sme_state(b)=%d\n", pwdev->sme_state); #endif + + if (NULL != pmlmepriv->assoc_req && NULL != pmlmepriv->assoc_rsp) cfg80211_connect_result(padapter->pnetdev, cur_network->network.MacAddress , pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2 , pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2 , pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6 , pmlmepriv->assoc_rsp_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 6 , WLAN_STATUS_SUCCESS, GFP_ATOMIC); + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE) RTW_INFO("pwdev->sme_state(a)=%d\n", pwdev->sme_state); #endif From 3bcd47fdd572d99733ca9b62ac3ecc4a98c19551 Mon Sep 17 00:00:00 2001 From: Christian B Date: Thu, 21 Dec 2017 08:19:01 +0100 Subject: [PATCH 10/12] Code cleanup --- hal/rtl8814a/usb/rtl8814au_xmit.c | 116 +++++++++++------------------- 1 file changed, 40 insertions(+), 76 deletions(-) diff --git a/hal/rtl8814a/usb/rtl8814au_xmit.c b/hal/rtl8814a/usb/rtl8814au_xmit.c index 5746dbb..8200263 100644 --- a/hal/rtl8814a/usb/rtl8814au_xmit.c +++ b/hal/rtl8814a/usb/rtl8814au_xmit.c @@ -60,10 +60,8 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag u8 DriverFixedRate = 0x0; #ifndef CONFIG_USE_USB_BUFFER_ALLOC_TX - if (padapter->registrypriv.mp_mode == 0) - { - if((PACKET_OFFSET_SZ != 0) && (!bagg_pkt) &&(rtw_usb_bulk_size_boundary(padapter,TXDESC_SIZE+sz)==_FALSE)) - { + if (padapter->registrypriv.mp_mode == 0) { + if((PACKET_OFFSET_SZ != 0) && (!bagg_pkt) &&(rtw_usb_bulk_size_boundary(padapter,TXDESC_SIZE+sz)==_FALSE)) { ptxdesc = (pmem+PACKET_OFFSET_SZ); //RTW_INFO("==> non-agg-pkt,shift pointer...\n"); pull = 1; @@ -84,7 +82,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag offset = TXDESC_SIZE + OFFSET_SZ; #ifdef CONFIG_TX_EARLY_MODE - if(bagg_pkt){ + if (bagg_pkt) { offset += EARLY_MODE_INFO_SIZE ;//0x28 } #endif @@ -121,7 +119,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag if (!pattrib->qos_en) { /* HW sequence, to fix to use 0 queue. todo: 4AC packets to use auto queue select */ - if(pattrib->sw_seq == _FALSE) + if (pattrib->sw_seq == _FALSE) SET_TX_DESC_HWSEQ_EN_8814A(ptxdesc, 1); // Hw set sequence number else SET_TX_DESC_SEQ_8814A(ptxdesc, pattrib->seqnum); @@ -164,8 +162,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag SET_TX_DESC_MAX_AGG_NUM_8814A(ptxdesc, 0x1f); // Set A-MPDU aggregation. SET_TX_DESC_AMPDU_DENSITY_8814A(ptxdesc, pattrib->ampdu_spacing); - } - else { + } else { SET_TX_DESC_BK_8814A(ptxdesc, 1); } @@ -173,12 +170,9 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag //DATA Rate FB LMT //SET_TX_DESC_DATA_RATE_FB_LIMIT_8814A(ptxdesc, 0x1f); - if(pHalData->CurrentBandType == BAND_ON_5G) - { + if (pHalData->CurrentBandType == BAND_ON_5G) { SET_TX_DESC_DATA_RATE_FB_LIMIT_8814A(ptxdesc, 4); - } - else - { + } else { SET_TX_DESC_DATA_RATE_FB_LIMIT_8814A(ptxdesc, 0); } @@ -211,9 +205,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag //work arond before fixing RA //SET_TX_DESC_USE_RATE_8814A(ptxdesc, 1); //SET_TX_DESC_TX_RATE_8814A(ptxdesc, 0x10); - } - else - { + } else { // EAP data packet and ARP packet and DHCP. // Use the 1M data rate to send the EAP/ARP packet. // This will maybe make the handshake smooth. @@ -231,15 +223,14 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag } } - else if((pxmitframe->frame_tag&0x0f)== MGNT_FRAMETAG) - { + else if ((pxmitframe->frame_tag&0x0f)== MGNT_FRAMETAG) { //RTW_INFO("pxmitframe->frame_tag == MGNT_FRAMETAG\n"); SET_TX_DESC_USE_RATE_8814A(ptxdesc, 1); DriverFixedRate = 0x01; #ifdef CONFIG_INTEL_PROXIM - if((padapter->proximity.proxim_on==_TRUE)&&(pattrib->intel_proxim==_TRUE)){ + if ((padapter->proximity.proxim_on==_TRUE)&&(pattrib->intel_proxim==_TRUE)){ RTW_INFO("\n %s pattrib->rate=%d\n",__FUNCTION__,pattrib->rate); SET_TX_DESC_TX_RATE_8814A(ptxdesc, pattrib->rate); } @@ -250,7 +241,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag } // VHT NDPA or HT NDPA Packet for Beamformer. - if((pattrib->subtype == WIFI_NDPA) || + if ((pattrib->subtype == WIFI_NDPA) || ((pattrib->subtype == WIFI_ACTION_NOACK) && (pattrib->order == 1))) { SET_TX_DESC_NAV_USE_HDR_8814A(ptxdesc, 1); @@ -270,9 +261,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag { SET_TX_DESC_NDPA_8814A(ptxdesc, 1); } - } - else - { + } else { SET_TX_DESC_RETRY_LIMIT_ENABLE_8814A(ptxdesc, 1); if (pattrib->retry_ctrl == _TRUE) { SET_TX_DESC_DATA_RETRY_LIMIT_8814A(ptxdesc, 6); @@ -291,8 +280,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag } #endif //CONFIG_XMIT_ACK } - else if((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) - { + else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) { RTW_INFO("pxmitframe->frame_tag == TXAGG_FRAMETAG\n"); } #ifdef CONFIG_MP_INCLUDED @@ -318,14 +306,14 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag SET_TX_DESC_PAID_8814A(ptxdesc, pattrib->txbf_p_aid); /* injected frame */ - if(pattrib->inject == 0xa5) { + if (pattrib->inject == 0xa5) { SET_TX_DESC_RETRY_LIMIT_ENABLE_8814A(ptxdesc, 1); if (pattrib->retry_ctrl == _TRUE) { SET_TX_DESC_DATA_RETRY_LIMIT_8814A(ptxdesc, 6); } else { SET_TX_DESC_DATA_RETRY_LIMIT_8814A(ptxdesc, 0); } - if(pattrib->sgi == _TRUE) { + if (pattrib->sgi == _TRUE) { SET_TX_DESC_DATA_SHORT_8814A(ptxdesc, 1); } else { SET_TX_DESC_DATA_SHORT_8814A(ptxdesc, 0); @@ -383,7 +371,7 @@ s32 rtl8814au_xmit_buf_handler(PADAPTER padapter) return _FAIL; } - if(check_pending_xmitbuf(pxmitpriv) == _FALSE) + if (check_pending_xmitbuf(pxmitpriv) == _FALSE) return _SUCCESS; #ifdef CONFIG_LPS_LCLK @@ -438,36 +426,29 @@ static s32 rtw_dump_xframe(_adapter *padapter, struct xmit_frame *pxmitframe) //RTW_INFO("rtw_dump_xframe()\n"); - for (t = 0; t < pattrib->nr_frags; t++) - { + for (t = 0; t < pattrib->nr_frags; t++) { if (inner_ret != _SUCCESS && ret == _SUCCESS) ret = _FAIL; - if (t != (pattrib->nr_frags - 1)) - { + if (t != (pattrib->nr_frags - 1)) { RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("pattrib->nr_frags=%d\n", pattrib->nr_frags)); sz = pxmitpriv->frag_len; sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 : pattrib->icv_len); - } - else //no frag - { + } else { //no frag sz = pattrib->last_txcmdsz; } pull = update_txdesc(pxmitframe, mem_addr, sz, _FALSE); - if(pull) - { + if (pull) { mem_addr += PACKET_OFFSET_SZ; //pull txdesc head //pxmitbuf ->pbuf = mem_addr; pxmitframe->buf_addr = mem_addr; w_sz = sz + TXDESC_SIZE; - } - else - { + } else { w_sz = sz + TXDESC_SIZE + PACKET_OFFSET_SZ; } @@ -512,7 +493,7 @@ static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) pattrib->pktlen + ((pattrib->bswenc) ? pattrib->icv_len : 0); - if(pattrib->encrypt ==_TKIP_) + if (pattrib->encrypt ==_TKIP_) len += 8; return len; @@ -679,12 +660,11 @@ s32 rtl8814au_xmitframe_complete(_adapter *padapter, struct xmit_priv *pxmitpriv xmitframe_phead = get_list_head(&ptxservq->sta_pending); xmitframe_plist = get_next(xmitframe_phead); - while (rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist) == _FALSE) - { + while (rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist) == _FALSE) { pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); - if(_FAIL == rtw_hal_busagg_qsel_check(padapter,pfirstframe->attrib.qsel,pxmitframe->attrib.qsel)) + if (_FAIL == rtw_hal_busagg_qsel_check(padapter,pfirstframe->attrib.qsel,pxmitframe->attrib.qsel)) break; pxmitframe->agg_num = 0; // not first frame of aggregation @@ -842,11 +822,9 @@ s32 rtl8814au_xmitframe_complete(_adapter *padapter, struct xmit_priv *pxmitpriv RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("xmitframe_complete()\n")); - if(pxmitbuf==NULL) - { + if (pxmitbuf==NULL) { pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if(!pxmitbuf) - { + if (!pxmitbuf) { return _FALSE; } } @@ -855,48 +833,40 @@ s32 rtl8814au_xmitframe_complete(_adapter *padapter, struct xmit_priv *pxmitpriv { pxmitframe = rtw_dequeue_xframe(pxmitpriv, phwxmits, hwentry); - if(pxmitframe) - { + if (pxmitframe) { pxmitframe->pxmitbuf = pxmitbuf; pxmitframe->buf_addr = pxmitbuf->pbuf; pxmitbuf->priv_data = pxmitframe; - if((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) - { - if(pxmitframe->attrib.priority<=15)//TID0~15 - { + if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + if (pxmitframe->attrib.priority<=15) { //TID0~15 res = rtw_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe); } //RTW_INFO("==> pxmitframe->attrib.priority:%d\n",pxmitframe->attrib.priority); - rtw_os_xmit_complete(padapter, pxmitframe);//always return ndis_packet after rtw_xmitframe_coalesce + rtw_os_xmit_complete(padapter, pxmitframe);//always return ndis_packet after rtw_xmitframe_coalesce } RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("xmitframe_complete(): rtw_dump_xframe\n")); - if(res == _SUCCESS) - { + if (res == _SUCCESS) { rtw_dump_xframe(padapter, pxmitframe); - } - else - { + } else { rtw_free_xmitbuf(pxmitpriv, pxmitbuf); rtw_free_xmitframe(pxmitpriv, pxmitframe); } xcnt++; - } - else - { + } else { rtw_free_xmitbuf(pxmitpriv, pxmitbuf); return _FALSE; } break; - }while(0/*xcnt < (NR_XMITFRAME >> 3)*/); + } while (0/*xcnt < (NR_XMITFRAME >> 3)*/); return _TRUE; @@ -911,8 +881,7 @@ static s32 xmitframe_direct(_adapter *padapter, struct xmit_frame *pxmitframe) res = rtw_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe); if (res == _SUCCESS) { rtw_dump_xframe(padapter, pxmitframe); - } - else{ + } else { RTW_INFO("==> %s xmitframe_coalsece failed\n",__FUNCTION__); } @@ -936,8 +905,7 @@ static s32 pre_xmitframe(_adapter *padapter, struct xmit_frame *pxmitframe) _enter_critical_bh(&pxmitpriv->lock, &irqL); - if (rtw_txframes_sta_ac_pending(padapter, pattrib) > 0) - { + if (rtw_txframes_sta_ac_pending(padapter, pattrib) > 0) { //RTW_INFO("enqueue AC(%d)\n",pattrib->priority); goto enqueue; } @@ -1000,14 +968,11 @@ s32 rtl8814au_hal_xmitframe_enqueue(_adapter *padapter, struct xmit_frame *pxmi struct xmit_priv *pxmitpriv = &padapter->xmitpriv; s32 err; - if ((err=rtw_xmitframe_enqueue(padapter, pxmitframe)) != _SUCCESS) - { + if ((err=rtw_xmitframe_enqueue(padapter, pxmitframe)) != _SUCCESS) { rtw_free_xmitframe(pxmitpriv, pxmitframe); pxmitpriv->tx_drop++; - } - else - { + } else { #ifdef PLATFORM_LINUX tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); #endif @@ -1060,7 +1025,7 @@ s32 rtl8814au_hostap_mgnt_xmit_entry(_adapter *padapter, _pkt *pkt) pxmit_skb = rtw_skb_alloc(len + TXDESC_SIZE); - if(!pxmit_skb) + if (!pxmit_skb) goto _exit; pxmitbuf = pxmit_skb->data; @@ -1079,8 +1044,7 @@ s32 rtl8814au_hostap_mgnt_xmit_entry(_adapter *padapter, _pkt *pkt) ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(OWN | FSG | LSG); - if(bmcst) - { + if (bmcst) { ptxdesc->txdw0 |= cpu_to_le32(BIT(24)); } From 1f3ca23fc8818eed94e67acbc4a7349e8f0c238b Mon Sep 17 00:00:00 2001 From: Christian B Date: Thu, 21 Dec 2017 08:19:43 +0100 Subject: [PATCH 11/12] Code cleanup --- hal/rtl8814a/usb/rtl8814au_led.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hal/rtl8814a/usb/rtl8814au_led.c b/hal/rtl8814a/usb/rtl8814au_led.c index 7bfc3ba..776cb21 100644 --- a/hal/rtl8814a/usb/rtl8814au_led.c +++ b/hal/rtl8814a/usb/rtl8814au_led.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. @@ -33,7 +33,7 @@ //================================================================================ -// LED_819xUsb routines. +// LED_819xUsb routines. //================================================================================ // @@ -42,7 +42,7 @@ // static void SwLedOn_8814AU( - PADAPTER padapter, + PADAPTER padapter, PLED_USB pLed ) { @@ -73,7 +73,7 @@ SwLedOn_8814AU( // static void SwLedOff_8814AU( - PADAPTER padapter, + PADAPTER padapter, PLED_USB pLed ) { @@ -144,4 +144,3 @@ rtl8814au_DeInitSwLeds( DeInitLed( &(ledpriv->SwLed1) ); DeInitLed( &(ledpriv->SwLed2) ); } - From 1c3935c6cb9aa9f8084af9bfcbcd0b25e61c60d3 Mon Sep 17 00:00:00 2001 From: Christian B Date: Thu, 21 Dec 2017 08:20:34 +0100 Subject: [PATCH 12/12] Code cleanup --- hal/rtl8814a/usb/rtl8814au_recv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hal/rtl8814a/usb/rtl8814au_recv.c b/hal/rtl8814a/usb/rtl8814au_recv.c index 4d38179..81193e7 100644 --- a/hal/rtl8814a/usb/rtl8814au_recv.c +++ b/hal/rtl8814a/usb/rtl8814au_recv.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * + * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. @@ -31,4 +31,3 @@ void rtl8814au_free_recv_priv(_adapter *padapter) { usb_free_recv_priv(padapter, INTERRUPT_MSG_FORMAT_LEN); } -