From 1800925f87040ce26ad0eb178b198bcbf3964f6e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 22 Jul 2011 14:30:37 -0500 Subject: [PATCH 01/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part I Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8190P_def.h | 68 ++++---- drivers/staging/rtl8192e/r8190P_rtl8256.c | 186 ++++++++++++-------- drivers/staging/rtl8192e/r8190P_rtl8256.h | 11 +- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 196 +++++++++------------- drivers/staging/rtl8192e/r8192E_cmdpkt.h | 45 ++--- drivers/staging/rtl8192e/r8192E_dev.c | 20 +-- 6 files changed, 276 insertions(+), 250 deletions(-) diff --git a/drivers/staging/rtl8192e/r8190P_def.h b/drivers/staging/rtl8192e/r8190P_def.h index 2355766bb32c..b7bb71fa9ecd 100644 --- a/drivers/staging/rtl8192e/r8190P_def.h +++ b/drivers/staging/rtl8192e/r8190P_def.h @@ -39,7 +39,7 @@ enum rtl819x_loopback { #define RESET_DELAY_8185 20 -#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER) +#define RT_IBSS_INT_MASKS (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER) #define DESC90_RATE1M 0x00 #define DESC90_RATE2M 0x01 @@ -85,7 +85,7 @@ enum rtl819x_loopback { #define BT_QA_BOARD 1 #define BT_FPGA 2 -#define Rx_Smooth_Factor 20 +#define RX_SMOOTH 20 #define QSLT_BK 0x1 #define QSLT_BE 0x0 @@ -130,7 +130,7 @@ enum rtl819x_loopback { enum version_8190_loopback { - VERSION_8190_BD=0x3, + VERSION_8190_BD = 0x3, VERSION_8190_BE }; @@ -139,9 +139,9 @@ enum version_8190_loopback { #define IC_VersionCut_E 0x4 enum rf_optype { - RF_OP_By_SW_3wire = 0, - RF_OP_By_FW, - RF_OP_MAX + RF_OP_By_SW_3wire = 0, + RF_OP_By_FW, + RF_OP_MAX }; @@ -303,41 +303,41 @@ struct phy_sts_cck_819xpci { #define PHY_Beacon_RSSI_SLID_WIN_MAX 10 struct tx_desc { - u16 PktSize; - u8 Offset; - u8 Reserved1:3; - u8 CmdInit:1; - u8 LastSeg:1; - u8 FirstSeg:1; - u8 LINIP:1; - u8 OWN:1; + u16 PktSize; + u8 Offset; + u8 Reserved1:3; + u8 CmdInit:1; + u8 LastSeg:1; + u8 FirstSeg:1; + u8 LINIP:1; + u8 OWN:1; - u8 TxFWInfoSize; - u8 RATid:3; - u8 DISFB:1; - u8 USERATE:1; - u8 MOREFRAG:1; - u8 NoEnc:1; - u8 PIFS:1; - u8 QueueSelect:5; - u8 NoACM:1; - u8 Resv:2; - u8 SecCAMID:5; - u8 SecDescAssign:1; - u8 SecType:2; + u8 TxFWInfoSize; + u8 RATid:3; + u8 DISFB:1; + u8 USERATE:1; + u8 MOREFRAG:1; + u8 NoEnc:1; + u8 PIFS:1; + u8 QueueSelect:5; + u8 NoACM:1; + u8 Resv:2; + u8 SecCAMID:5; + u8 SecDescAssign:1; + u8 SecType:2; - u16 TxBufferSize; - u8 PktId:7; - u8 Resv1:1; - u8 Reserved2; + u16 TxBufferSize; + u8 PktId:7; + u8 Resv1:1; + u8 Reserved2; u32 TxBuffAddr; u32 NextDescAddress; - u32 Reserved5; - u32 Reserved6; - u32 Reserved7; + u32 Reserved5; + u32 Reserved6; + u32 Reserved7; }; diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/r8190P_rtl8256.c index e8bef59a7984..0da56c80f088 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.c @@ -22,41 +22,59 @@ #include "r8192E_phy.h" #include "r8190P_rtl8256.h" -void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth) +void PHY_SetRF8256Bandwidth(struct net_device *dev, + enum ht_channel_width Bandwidth) { u8 eRFPath; struct r8192_priv *priv = rtllib_priv(dev); - for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) { + for (eRFPath = 0; eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; switch (Bandwidth) { case HT_CHANNEL_WIDTH_20: - if (priv->card_8192_version == VERSION_8190_BD || priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x100); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3d7); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x021); + if (priv->card_8192_version == VERSION_8190_BD || + priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0b, bMask12Bits, 0x100); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x2c, bMask12Bits, 0x3d7); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0e, bMask12Bits, 0x021); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): " + "unknown hardware version\n"); } break; case HT_CHANNEL_WIDTH_20_40: - if (priv->card_8192_version == VERSION_8190_BD ||priv->card_8192_version == VERSION_8190_BE) { - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0b, bMask12Bits, 0x300); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x2c, bMask12Bits, 0x3ff); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, 0x0e, bMask12Bits, 0x0e1); + if (priv->card_8192_version == VERSION_8190_BD || + priv->card_8192_version == VERSION_8190_BE) { + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0b, bMask12Bits, 0x300); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x2c, bMask12Bits, 0x3ff); + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + 0x0e, bMask12Bits, 0x0e1); } else { - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown hardware version\n"); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): " + "unknown hardware version\n"); } break; default: - RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ); + RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown " + "Bandwidth: %#X\n", Bandwidth); break; } @@ -64,7 +82,7 @@ void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandw return; } -bool PHY_RF8256_Config(struct net_device* dev) +bool PHY_RF8256_Config(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; @@ -74,7 +92,7 @@ bool PHY_RF8256_Config(struct net_device* dev) return rtStatus; } -bool phy_RF8256_Config_ParaFile(struct net_device* dev) +bool phy_RF8256_Config_ParaFile(struct net_device *dev) { u32 u4RegValue = 0; u8 eRFPath; @@ -87,7 +105,8 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; - for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; eRFPath NumTotalRFPath; eRFPath++) { + for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; + eRFPath < priv->NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) continue; @@ -97,11 +116,13 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) switch (eRFPath) { case RF90_PATH_A: case RF90_PATH_C: - u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV); + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, + bRFSI_RFENV); break; - case RF90_PATH_B : + case RF90_PATH_B: case RF90_PATH_D: - u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16); + u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, + bRFSI_RFENV<<16); break; } @@ -109,14 +130,19 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, + b3WireAddressLength, 0x0); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, + b3WireDataLength, 0x0); - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0, bMask12Bits, 0xbf); + rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path) eRFPath, 0x0, + bMask12Bits, 0xbf); - rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, (enum rf90_radio_path)eRFPath); - if (rtStatus!= true) { - RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check Radio[%d] Fail!!\n", eRFPath); + rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF, + (enum rf90_radio_path)eRFPath); + if (rtStatus != true) { + RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check " + "Radio[%d] Fail!!\n", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -124,34 +150,61 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) RF3_Final_Value = 0; switch (eRFPath) { case RF90_PATH_A: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_B: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_C: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, + bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; case RF90_PATH_D: - while (RF3_Final_Value!=RegValueToBeCheck && RetryTimes != 0) { - ret = rtl8192_phy_ConfigRFWithHeaderFile(dev,(enum rf90_radio_path)eRFPath); - RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)eRFPath, RegOffSetToBeCheck, bMask12Bits); - RT_TRACE(COMP_RF, "RF %d %d register final value: %x\n", eRFPath, RegOffSetToBeCheck, RF3_Final_Value); + while (RF3_Final_Value != RegValueToBeCheck && + RetryTimes != 0) { + ret = rtl8192_phy_ConfigRFWithHeaderFile(dev, + (enum rf90_radio_path)eRFPath); + RF3_Final_Value = rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)eRFPath, + RegOffSetToBeCheck, bMask12Bits); + RT_TRACE(COMP_RF, "RF %d %d register final " + "value: %x\n", eRFPath, + RegOffSetToBeCheck, RF3_Final_Value); RetryTimes--; } break; @@ -160,16 +213,19 @@ bool phy_RF8256_Config_ParaFile(struct net_device* dev) switch (eRFPath) { case RF90_PATH_A: case RF90_PATH_C: - rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, + u4RegValue); break; - case RF90_PATH_B : + case RF90_PATH_B: case RF90_PATH_D: - rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, + u4RegValue); break; } if (ret) { - RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!", eRFPath); + RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():" + "Radio[%d] Fail!!", eRFPath); goto phy_RF8256_Config_ParaFile_Fail; } @@ -183,18 +239,17 @@ phy_RF8256_Config_ParaFile_Fail: return false; } -void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) +void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel) { - u32 TxAGC=0; + u32 TxAGC = 0; struct r8192_priv *priv = rtllib_priv(dev); TxAGC = powerlevel; - if (priv->bDynamicTxLowPower == true) - { + if (priv->bDynamicTxLowPower == true) { if (priv->CustomerID == RT_CID_819x_Netcore) - TxAGC = 0x22; - else - TxAGC += priv->CckPwEnl; + TxAGC = 0x22; + else + TxAGC += priv->CckPwEnl; } if (TxAGC > 0x24) TxAGC = 0x24; @@ -202,7 +257,7 @@ void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel) } -void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) +void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel) { struct r8192_priv *priv = rtllib_priv(dev); u32 writeVal, powerBase0, powerBase1, writeVal_tmp; @@ -211,13 +266,15 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) u8 byte0, byte1, byte2, byte3; powerBase0 = powerlevel + priv->LegacyHTTxPowerDiff; - powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0; + powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) | + (powerBase0 << 8) | powerBase0; powerBase1 = powerlevel; - powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1; + powerBase1 = (powerBase1 << 24) | (powerBase1 << 16) | + (powerBase1 << 8) | powerBase1; - for (index=0; index<6; index++) - { - writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1)); + for (index = 0; index < 6; index++) { + writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + + ((index < 2) ? powerBase0 : powerBase1)); byte0 = (u8)(writeVal & 0x7f); byte1 = (u8)((writeVal & 0x7f00)>>8); byte2 = (u8)((writeVal & 0x7f0000)>>16); @@ -231,20 +288,17 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel) if (byte3 > 0x24) byte3 = 0x24; - if (index == 3) - { - writeVal_tmp = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; + if (index == 3) { + writeVal_tmp = (byte3 << 24) | (byte2 << 16) | + (byte1 << 8) | byte0; priv->Pwr_Track = writeVal_tmp; } if (priv->bDynamicTxHighPower == true) - { writeVal = 0x03030303; - } else - { - writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0; - } + writeVal = (byte3 << 24) | (byte2 << 16) | + (byte1 << 8) | byte0; rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal); } diff --git a/drivers/staging/rtl8192e/r8190P_rtl8256.h b/drivers/staging/rtl8192e/r8190P_rtl8256.h index 00fe5a1bb7ec..64e831d2f4e5 100644 --- a/drivers/staging/rtl8192e/r8190P_rtl8256.h +++ b/drivers/staging/rtl8192e/r8190P_rtl8256.h @@ -21,10 +21,11 @@ #define RTL8225H #define RTL819X_TOTAL_RF_PATH 2 -extern void PHY_SetRF8256Bandwidth(struct net_device* dev , enum ht_channel_width Bandwidth); -extern bool PHY_RF8256_Config(struct net_device* dev); -extern bool phy_RF8256_Config_ParaFile(struct net_device* dev); -extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel); -extern void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel); +extern void PHY_SetRF8256Bandwidth(struct net_device *dev, + enum ht_channel_width Bandwidth); +extern bool PHY_RF8256_Config(struct net_device *dev); +extern bool phy_RF8256_Config_ParaFile(struct net_device *dev); +extern void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel); +extern void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel); #endif diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index edca4d55f582..881eb1f96d2c 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -29,14 +29,14 @@ u32 temp[10];\ \ memcpy(temp, Address, 40);\ - for (i = 0; i <40; i+=4)\ - printk("\r\n %08x", temp[i]);\ -}\ + for (i = 0; i < 40; i += 4)\ + printk(KERN_INFO "\r\n %08x", temp[i]);\ +} /*---------------------------Define functions---------------------------------*/ - extern bool cmpk_message_handle_tx( +extern bool cmpk_message_handle_tx( struct net_device *dev, - u8* code_virtual_address, + u8 *code_virtual_address, u32 packettype, u32 buffer_len) { @@ -53,7 +53,7 @@ struct tx_fwinfo_8190pci *pTxFwInfo = NULL; - RT_TRACE(COMP_CMDPKT,"%s(),buffer_len is %d\n",__func__,buffer_len); + RT_TRACE(COMP_CMDPKT, "%s(),buffer_len is %d\n", __func__, buffer_len); firmware_init_param(dev); frag_threshold = pfirmware->cmdpacket_frag_thresold; @@ -63,18 +63,19 @@ bLastIniPkt = 0; } else { - frag_length =(u16)(buffer_len - frag_offset); + frag_length = (u16)(buffer_len - frag_offset); bLastIniPkt = 1; } - skb = dev_alloc_skb(frag_length + priv->rtllib->tx_headroom + 4); + skb = dev_alloc_skb(frag_length + + priv->rtllib->tx_headroom + 4); if (skb == NULL) { rt_status = false; goto Failed; } - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; @@ -83,18 +84,18 @@ seg_ptr = skb_put(skb, priv->rtllib->tx_headroom); pTxFwInfo = (struct tx_fwinfo_8190pci *)seg_ptr; - memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); - memset(pTxFwInfo,0x12,8); + memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci)); + memset(pTxFwInfo, 0x12, 8); seg_ptr = skb_put(skb, frag_length); memcpy(seg_ptr, code_virtual_address, (u32)frag_length); - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); code_virtual_address += frag_length; frag_offset += frag_length; - }while(frag_offset < buffer_len); + } while (frag_offset < buffer_len); write_nic_byte(dev, TPPoll, TPPoll_CQ); Failed: @@ -110,7 +111,8 @@ cmpk_count_txstatistic( #ifdef ENABLE_PS enum rt_rf_power_state rtState; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) return; @@ -152,10 +154,7 @@ cmpk_count_txstatistic( -static void -cmpk_handle_tx_feedback( - struct net_device *dev, - u8 * pmsg) +static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) { struct r8192_priv *priv = rtllib_priv(dev); struct cmpk_txfb rx_tx_fb; /* */ @@ -163,41 +162,30 @@ cmpk_handle_tx_feedback( priv->stats.txfeedback++; - memcpy((u8*)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); + memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(struct cmpk_txfb)); cmpk_count_txstatistic(dev, &rx_tx_fb); } /* cmpk_Handle_Tx_Feedback */ -void -cmdpkt_beacontimerinterrupt_819xusb( - struct net_device *dev -) +void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u16 tx_rate; - { - if ((priv->rtllib->current_network.mode == IEEE_A) || - (priv->rtllib->current_network.mode == IEEE_N_5G) || - ((priv->rtllib->current_network.mode == IEEE_N_24G) && (!priv->rtllib->pHTInfo->bCurSuppCCK))) - { - tx_rate = 60; - DMESG("send beacon frame tx rate is 6Mbpm\n"); - } - else - { - tx_rate =10; - DMESG("send beacon frame tx rate is 1Mbpm\n"); - } - + if ((priv->rtllib->current_network.mode == IEEE_A) || + (priv->rtllib->current_network.mode == IEEE_N_5G) || + ((priv->rtllib->current_network.mode == IEEE_N_24G) && + (!priv->rtllib->pHTInfo->bCurSuppCCK))) { + tx_rate = 60; + DMESG("send beacon frame tx rate is 6Mbpm\n"); + } else { + tx_rate = 10; + DMESG("send beacon frame tx rate is 1Mbpm\n"); } } -static void -cmpk_handle_interrupt_status( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) { struct cmpk_intr_sta rx_intr_status; /* */ struct r8192_priv *priv = rtllib_priv(dev); @@ -206,67 +194,55 @@ cmpk_handle_interrupt_status( rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) - { + if (rx_intr_status.length != (sizeof(struct cmpk_intr_sta) - 2)) { DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); return; } - if ( priv->rtllib->iw_mode == IW_MODE_ADHOC) - { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); - DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); + DMESG("interrupt status = 0x%x\n", + rx_intr_status.interrupt_status); - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) - { + if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { priv->rtllib->bibsscoordinator = true; priv->stats.txbeaconokint++; - } - else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) - { + } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { priv->rtllib->bibsscoordinator = false; priv->stats.txbeaconerr++; } if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) - { cmdpkt_beacontimerinterrupt_819xusb(dev); - } - } - - DMESG("<---- cmpk_handle_interrupt_status()\n"); } /* cmpk_handle_interrupt_status */ -static void -cmpk_handle_query_config_rx( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) { cmpk_query_cfg_t rx_query_cfg; /* */ - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; - rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; - rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; - rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | - (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | - (pmsg[14] << 8) | (pmsg[15] << 0); + rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; + rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; + rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; + rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; + rx_query_cfg.cfg_offset = pmsg[7]; + rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | + (pmsg[10] << 8) | (pmsg[11] << 0); + rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | + (pmsg[14] << 8) | (pmsg[15] << 0); } /* cmpk_Handle_Query_Config_Rx */ -static void cmpk_count_tx_status( struct net_device *dev, - struct cmpk_tx_status *pstx_status) +static void cmpk_count_tx_status(struct net_device *dev, + struct cmpk_tx_status *pstx_status) { struct r8192_priv *priv = rtllib_priv(dev); @@ -274,12 +250,11 @@ static void cmpk_count_tx_status( struct net_device *dev, enum rt_rf_power_state rtstate; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) - { return; - } #endif priv->stats.txfeedbackok += pstx_status->txok; @@ -309,68 +284,56 @@ static void cmpk_count_tx_status( struct net_device *dev, -static void -cmpk_handle_tx_status( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) { struct cmpk_tx_status rx_tx_sts; /* */ - memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(struct cmpk_tx_status)); + memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(struct cmpk_tx_status)); cmpk_count_tx_status(dev, &rx_tx_sts); - } - -static void -cmpk_handle_tx_rate_history( - struct net_device *dev, - u8* pmsg) +static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) { struct cmpk_tx_rahis *ptxrate; - u8 i, j; + u8 i, j; u16 length = sizeof(struct cmpk_tx_rahis); - u32 *ptemp; + u32 *ptemp; struct r8192_priv *priv = rtllib_priv(dev); #ifdef ENABLE_PS - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); if (rtState == eRfOff) - { return; - } #endif ptemp = (u32 *)pmsg; - for (i = 0; i < (length/4); i++) - { + for (i = 0; i < (length / 4); i++) { u16 temp1, temp2; - temp1 = ptemp[i]&0x0000FFFF; - temp2 = ptemp[i]>>16; - ptemp[i] = (temp1<<16)|temp2; + temp1 = ptemp[i] & 0x0000FFFF; + temp2 = ptemp[i] >> 16; + ptemp[i] = (temp1 << 16) | temp2; } ptxrate = (struct cmpk_tx_rahis *)pmsg; - if (ptxrate == NULL ) - { + if (ptxrate == NULL) return; - } - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if (i < 4) priv->stats.txrate.cck[i] += ptxrate->cck[i]; - if (i< 8) + if (i < 8) priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; for (j = 0; j < 4; j++) - priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i]; + priv->stats.txrate.ht_mcs[j][i] += + ptxrate->ht_mcs[j][i]; } } @@ -389,8 +352,7 @@ cmpk_message_handle_rx( RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx()\n"); - if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL)) - { + if (pstats == NULL) { /* Print error message. */ /*RT_TRACE(COMP_SEND, DebugLevel, ("\n\r[CMPK]-->Err queue id or pointer"));*/ @@ -403,43 +365,49 @@ cmpk_message_handle_rx( element_id = pcmd_buff[0]; - while (total_length > 0 || exe_cnt++ >100) - { + while (total_length > 0 || exe_cnt++ > 100) { element_id = pcmd_buff[0]; switch (element_id) { case RX_TX_FEEDBACK: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_FEEDBACK\n"); - cmpk_handle_tx_feedback (dev, pcmd_buff); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_FEEDBACK\n"); + cmpk_handle_tx_feedback(dev, pcmd_buff); cmd_length = CMPK_RX_TX_FB_SIZE; break; case RX_INTERRUPT_STATUS: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_INTERRUPT_STATUS\n"); cmpk_handle_interrupt_status(dev, pcmd_buff); cmd_length = sizeof(struct cmpk_intr_sta); break; case BOTH_QUERY_CONFIG: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "BOTH_QUERY_CONFIG\n"); cmpk_handle_query_config_rx(dev, pcmd_buff); cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; break; case RX_TX_STATUS: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_STATUS\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_STATUS\n"); cmpk_handle_tx_status(dev, pcmd_buff); cmd_length = CMPK_RX_TX_STS_SIZE; break; case RX_TX_PER_PKT_FEEDBACK: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_PER_PKT_FEEDBACK\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_PER_PKT_FEEDBACK\n"); cmd_length = CMPK_RX_TX_FB_SIZE; break; case RX_TX_RATE_HISTORY: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():RX_TX_HISTORY\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "RX_TX_HISTORY\n"); cmpk_handle_tx_rate_history(dev, pcmd_buff); cmd_length = CMPK_TX_RAHIS_SIZE; break; default: - RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():unknow CMD Element\n"); + RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" + "unknow CMD Element\n"); return 1; } diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.h b/drivers/staging/rtl8192e/r8192E_cmdpkt.h index b55d075d6cdf..23219e17e5a1 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.h +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.h @@ -18,16 +18,16 @@ ******************************************************************************/ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H -#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) -#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) -#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) -#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) -#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) +#define CMPK_RX_TX_FB_SIZE sizeof(struct cmpk_txfb) +#define CMPK_TX_SET_CONFIG_SIZE sizeof(struct cmpk_set_cfg) +#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(struct cmpk_set_cfg) +#define CMPK_RX_TX_STS_SIZE sizeof(struct cmpk_tx_status) +#define CMPK_RX_DBG_MSG_SIZE sizeof(struct cmpk_rx_dbginfo) +#define CMPK_TX_RAHIS_SIZE sizeof(struct cmpk_tx_rahis) -#define ISR_TxBcnOk BIT27 -#define ISR_TxBcnErr BIT26 -#define ISR_BcnTimerIntr BIT13 +#define ISR_TxBcnOk BIT27 +#define ISR_TxBcnErr BIT26 +#define ISR_BcnTimerIntr BIT13 struct cmpk_txfb { @@ -110,7 +110,7 @@ struct cmpk_tx_status { u16 reserve3_23; u8 reserve3_1; u8 rate; -}__packed; +} __packed; struct cmpk_rx_dbginfo { u16 reserve1; @@ -138,19 +138,22 @@ struct cmpk_tx_rahis { } __packed; enum cmpk_element { - RX_TX_FEEDBACK = 0, - RX_INTERRUPT_STATUS = 1, - TX_SET_CONFIG = 2, - BOTH_QUERY_CONFIG = 3, - RX_TX_STATUS = 4, - RX_DBGINFO_FEEDBACK = 5, - RX_TX_PER_PKT_FEEDBACK = 6, - RX_TX_RATE_HISTORY = 7, - RX_CMD_ELE_MAX + RX_TX_FEEDBACK = 0, + RX_INTERRUPT_STATUS = 1, + TX_SET_CONFIG = 2, + BOTH_QUERY_CONFIG = 3, + RX_TX_STATUS = 4, + RX_DBGINFO_FEEDBACK = 5, + RX_TX_PER_PKT_FEEDBACK = 6, + RX_TX_RATE_HISTORY = 7, + RX_CMD_ELE_MAX }; -extern u32 cmpk_message_handle_rx(struct net_device *dev, struct rtllib_rx_stats * pstats); -extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len); +extern u32 cmpk_message_handle_rx(struct net_device *dev, + struct rtllib_rx_stats *pstats); +extern bool cmpk_message_handle_tx(struct net_device *dev, + u8 *codevirtualaddress, u32 packettype, + u32 buffer_len); #endif diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 453481959ff3..aaba5586dbef 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -1662,15 +1662,15 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; } else { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); } RT_TRACE(COMP_DBG,"Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] ); } @@ -1708,15 +1708,15 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + + (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; } else { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + + (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); } rtl819x_update_rxsignalstatistics8190pci(priv,pprevious_stats); } @@ -1755,8 +1755,8 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_ priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; } priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); + ( (priv->stats.rx_evm_percentage[nspatial_stream]* (RX_SMOOTH-1)) + + (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (RX_SMOOTH); } } } From e829d65e7855fb4c98a81dd8c210c5b6d738bde1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 1 Aug 2011 15:31:00 -0500 Subject: [PATCH 02/25] staging: rtl8192e: Modify time handling In several places, the driver keeps times (in jiffies) in two 32-bit quantities. In the rtl8192_hw_to_sleep(), there is an error in the calculation of the difference between two 64-bit quantities. Rather than fix that error, I have converted to a single 64-bit number. That makes the code be much cleaner and clearer. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 11 ++++----- drivers/staging/rtl8192e/rtl_core.h | 3 +-- drivers/staging/rtl8192e/rtl_ps.c | 27 ++++++++++------------- drivers/staging/rtl8192e/rtl_ps.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 9 ++++---- drivers/staging/rtl8192e/rtllib_rx.c | 6 ++--- drivers/staging/rtl8192e/rtllib_softmac.c | 23 +++++++------------ 7 files changed, 32 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index e633f0b074e2..f585f71e14b7 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2243,13 +2243,10 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - if (stats->bIsAMPDU && !stats->bFirstMPDU) { - stats->mac_time[0] = priv->LastRxDescTSFLow; - stats->mac_time[1] = priv->LastRxDescTSFHigh; - } else { - priv->LastRxDescTSFLow = stats->mac_time[0]; - priv->LastRxDescTSFHigh = stats->mac_time[1]; - } + if (stats->bIsAMPDU && !stats->bFirstMPDU) + stats->mac_time = priv->LastRxDescTSF; + else + priv->LastRxDescTSF = stats->mac_time; } long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 22b0a438b9dd..4f94d0a18f06 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -642,8 +642,7 @@ struct r8192_priv { int rxringcount; u16 rxbuffersize; - u32 LastRxDescTSFHigh; - u32 LastRxDescTSFLow; + u64 LastRxDescTSF; u16 EarlyRxThreshold; u32 ReceiveConfig; diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index 58966e07be78..ea9eac712530 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -78,36 +78,33 @@ void rtl8192_hw_wakeup_wq(void *data) #define MIN_SLEEP_TIME 50 #define MAX_SLEEP_TIME 10000 -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl) +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) { struct r8192_priv *priv = rtllib_priv(dev); - u32 rb = jiffies; + u32 tmp; unsigned long flags; spin_lock_irqsave(&priv->ps_lock,flags); - tl -= MSECS(8+16+7); + time -= MSECS(8+16+7); - if (((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME)) - ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) { + if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) { spin_unlock_irqrestore(&priv->ps_lock,flags); - printk("too short to sleep::%x, %x, %lx\n",tl, rb, MSECS(MIN_SLEEP_TIME)); + printk(KERN_INFO "too short to sleep::%lld < %ld\n", + time - jiffies, MSECS(MIN_SLEEP_TIME)); return; } - if (((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))|| - ((tl < rb) && (tl>MSECS(69)) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))|| - ((tlMSECS(MAX_SLEEP_TIME)))) { - printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME)); + if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) { + printk(KERN_INFO "========>too long to sleep:%lld > %ld\n", + time - jiffies, MSECS(MAX_SLEEP_TIME)); spin_unlock_irqrestore(&priv->ps_lock,flags); return; } - { - u32 tmp = (tl>rb)?(tl-rb):(rb-tl); - queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq,tmp); - } + tmp = time - jiffies; + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq,tmp); queue_delayed_work_rsl(priv->rtllib->wq, (void *)&priv->rtllib->hw_sleep_wq,0); spin_unlock_irqrestore(&priv->ps_lock,flags); diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index d97a6edd1e85..453df2cbb3d2 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -33,7 +33,7 @@ struct net_device; #define INIT_DEFAULT_CHAN 1 void rtl8192_hw_wakeup(struct net_device *dev); -void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl); +void rtl8192_hw_to_sleep(struct net_device *dev, u64 time); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); void IPSLeave_wq (void *data); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2ab1e6cb6390..2a394ee9f750 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -993,7 +993,7 @@ struct ieee_ibss_seq { * any adverse affects. */ struct rtllib_rx_stats { #if 1 - u32 mac_time[2]; + u64 mac_time; s8 rssi; u8 signal; u8 noise; @@ -1679,7 +1679,7 @@ struct rtllib_network { struct rtllib_tim_parameters tim; u8 dtim_period; u8 dtim_data; - u32 last_dtim_sta_time[2]; + u64 last_dtim_sta_time; u8 wmm_info; struct rtllib_wmm_ac_param wmm_param[4]; @@ -2305,8 +2305,7 @@ struct rtllib_device { int ps_timeout; int ps_period; struct tasklet_struct ps_task; - u32 ps_th; - u32 ps_tl; + u64 ps_time; bool polling; short raw_tx; @@ -2498,7 +2497,7 @@ struct rtllib_device { /* power save mode related */ void (*sta_wake_up) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); + void (*enter_sleep_state) (struct net_device *dev, u64 time); short (*ps_is_queue_empty) (struct net_device *dev); int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 24ad9713d0b6..9606bedf16de 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1867,8 +1867,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->dtim_period = info_element->data[1]; if (ieee->state != RTLLIB_LINKED) break; - network->last_dtim_sta_time[0] = jiffies; - network->last_dtim_sta_time[1] = stats->mac_time[1]; + network->last_dtim_sta_time = jiffies; network->dtim_data = RTLLIB_DTIM_VALID; @@ -2466,8 +2465,7 @@ static inline void update_network(struct rtllib_network *dst, dst->atim_window = src->atim_window; dst->dtim_period = src->dtim_period; dst->dtim_data = src->dtim_data; - dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0]; - dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1]; + dst->last_dtim_sta_time = src->last_dtim_sta_time; memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); dst->bssht.bdSupportHT = src->bssht.bdSupportHT; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 11433c61bdaf..29277d18f021 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2037,7 +2037,7 @@ void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) } -short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) +static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) { int timeout = ieee->ps_timeout; u8 dtim; @@ -2074,7 +2074,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if (time_l){ + if (time){ if (ieee->bAwakePktSent == true) { pPSC->LPSAwakeIntvl = 1; } else { @@ -2107,17 +2107,11 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } - *time_l = ieee->current_network.last_dtim_sta_time[0] + *time = ieee->current_network.last_dtim_sta_time + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); } } - if (time_h) { - *time_h = ieee->current_network.last_dtim_sta_time[1]; - if (time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) - *time_h += 1; - } - return 1; @@ -2126,7 +2120,7 @@ short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u32 *time_h, u32 *time_l) inline void rtllib_sta_ps(struct rtllib_device *ieee) { - u32 th,tl; + u64 time; short sleep; unsigned long flags,flags2; @@ -2146,7 +2140,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = rtllib_sta_ps_sleep(ieee,&th, &tl); + sleep = rtllib_sta_ps_sleep(ieee, &time); /* 2 wake, 1 sleep, 0 do nothing */ if (sleep == 0) { @@ -2154,7 +2148,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) } if (sleep == 1){ if (ieee->sta_sleep == LPS_IS_SLEEP){ - ieee->enter_sleep_state(ieee->dev,th,tl); + ieee->enter_sleep_state(ieee->dev, time); } else if (ieee->sta_sleep == LPS_IS_WAKE){ @@ -2164,8 +2158,7 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee,1); - ieee->ps_th = th; - ieee->ps_tl = tl; + ieee->ps_time = time; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -2241,7 +2234,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) /* Null frame with PS bit set */ if (success){ ieee->sta_sleep = LPS_IS_SLEEP; - ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); + ieee->enter_sleep_state(ieee->dev, ieee->ps_time); } /* if the card report not success we can't be sure the AP * has not RXed so we can't assume the AP believe us awake From 81e3863636b2f963d32245ce6b23b37404d0cd39 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 1 Aug 2011 15:53:53 -0500 Subject: [PATCH 03/25] staging: rtl8192e: Remove extraneous log message The driver logs all DHCP transactions and thus spams the logs. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_tx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index d03b5aa02cc9..7ccad8601821 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -632,15 +632,13 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) goto success; } - if (skb->len > 282){ + if (skb->len > 282) { if (ETH_P_IP == ether_type) { const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); if (IPPROTO_UDP == ip->protocol) { struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); if (((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { - printk("DHCP pkt src port:%d, dest port:%d!!\n", ((u8 *)udp)[1],((u8 *)udp)[3]); - bdhcp = true; ieee->LPSDelayCnt = 200; } From b9ffad087cb6b5251e342b7005862d71724baccc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 1 Aug 2011 17:59:24 -0500 Subject: [PATCH 04/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part II Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.c | 2275 +++++++++++++------------ 1 file changed, 1198 insertions(+), 1077 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index aaba5586dbef..229d6df789fd 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -37,8 +37,8 @@ void rtl8192e_start_beacon(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; u16 BcnTimeCfg = 0; - u16 BcnCW = 6; - u16 BcnIFS = 0xf; + u16 BcnCW = 6; + u16 BcnIFS = 0xf; DMESG("Enabling beacon TX"); rtl8192_irq_disable(dev); @@ -63,7 +63,7 @@ void rtl8192e_update_msr(struct net_device *dev) u8 msr; enum led_ctl_mode LedAction = LED_CTL_NO_LINK; msr = read_nic_byte(dev, MSR); - msr &= ~ MSR_LINK_MASK; + msr &= ~MSR_LINK_MASK; switch (priv->rtllib->iw_mode) { case IW_MODE_INFRA: @@ -94,250 +94,246 @@ void rtl8192e_update_msr(struct net_device *dev) priv->rtllib->LedControlHandler(dev, LedAction); } -void -rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val) +void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - switch (variable) + switch (variable) { + case HW_VAR_BSSID: + write_nic_dword(dev, BSSIDR, ((u32 *)(val))[0]); + write_nic_word(dev, BSSIDR+2, ((u16 *)(val+2))[0]); + break; + + case HW_VAR_MEDIA_STATUS: { + enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); + enum led_ctl_mode LedAction = LED_CTL_NO_LINK; + u8 btMsr = read_nic_byte(dev, MSR); - case HW_VAR_BSSID: - write_nic_dword(dev, BSSIDR, ((u32*)(val))[0]); - write_nic_word(dev, BSSIDR+2, ((u16*)(val+2))[0]); - break; + btMsr &= 0xfc; - case HW_VAR_MEDIA_STATUS: - { - enum rt_op_mode OpMode = *((enum rt_op_mode *)(val)); - enum led_ctl_mode LedAction = LED_CTL_NO_LINK; - u8 btMsr = read_nic_byte(dev, MSR); + switch (OpMode) { + case RT_OP_MODE_INFRASTRUCTURE: + btMsr |= MSR_INFRA; + LedAction = LED_CTL_LINK; + break; - btMsr &= 0xfc; + case RT_OP_MODE_IBSS: + btMsr |= MSR_ADHOC; + break; - switch (OpMode) - { - case RT_OP_MODE_INFRASTRUCTURE: - btMsr |= MSR_INFRA; - LedAction = LED_CTL_LINK; - break; - - case RT_OP_MODE_IBSS: - btMsr |= MSR_ADHOC; - break; - - case RT_OP_MODE_AP: - btMsr |= MSR_AP; - LedAction = LED_CTL_LINK; - break; - - default: - btMsr |= MSR_NOLINK; - break; - } - - write_nic_byte(dev, MSR, btMsr); + case RT_OP_MODE_AP: + btMsr |= MSR_AP; + LedAction = LED_CTL_LINK; + break; + default: + btMsr |= MSR_NOLINK; + break; } + + write_nic_byte(dev, MSR, btMsr); + + } + break; + + case HW_VAR_CECHK_BSSID: + { + u32 RegRCR, Type; + + Type = ((u8 *)(val))[0]; + RegRCR = read_nic_dword(dev, RCR); + priv->ReceiveConfig = RegRCR; + + if (Type == true) + RegRCR |= (RCR_CBSSID); + else if (Type == false) + RegRCR &= (~RCR_CBSSID); + + write_nic_dword(dev, RCR, RegRCR); + priv->ReceiveConfig = RegRCR; + + } + break; + + case HW_VAR_SLOT_TIME: + + priv->slot_time = val[0]; + write_nic_byte(dev, SLOT_TIME, val[0]); + break; - case HW_VAR_CECHK_BSSID: - { - u32 RegRCR, Type; + case HW_VAR_ACK_PREAMBLE: + { + u32 regTmp; + priv->short_preamble = (bool)(*(u8 *)val); + regTmp = priv->basic_rate; + if (priv->short_preamble) + regTmp |= BRSR_AckShortPmb; + write_nic_dword(dev, RRSR, regTmp); + break; + } - Type = ((u8*)(val))[0]; - RegRCR = read_nic_dword(dev,RCR); - priv->ReceiveConfig = RegRCR; + case HW_VAR_CPU_RST: + write_nic_dword(dev, CPU_GEN, ((u32 *)(val))[0]); + break; - if (Type == true) - RegRCR |= (RCR_CBSSID); - else if (Type == false) - RegRCR &= (~RCR_CBSSID); + case HW_VAR_AC_PARAM: + { + u8 pAcParam = *((u8 *)val); + u32 eACI = pAcParam; + u8 u1bAIFS; + u32 u4bAcParam; + u8 mode = priv->rtllib->mode; + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; - write_nic_dword(dev, RCR,RegRCR); - priv->ReceiveConfig = RegRCR; + u1bAIFS = qos_parameters->aifs[pAcParam] * + ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; + dm_init_edca_turbo(dev); + + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[pAcParam])) << + AC_PARAM_TXOP_LIMIT_OFFSET) | + (((u32)(qos_parameters->cw_max[pAcParam])) << + AC_PARAM_ECW_MAX_OFFSET) | + (((u32)(qos_parameters->cw_min[pAcParam])) << + AC_PARAM_ECW_MIN_OFFSET) | + (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); + + RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", + __func__, eACI, u4bAcParam); + switch (eACI) { + case AC1_BK: + write_nic_dword(dev, EDCAPARA_BK, u4bAcParam); + break; + + case AC0_BE: + write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); + break; + + case AC2_VI: + write_nic_dword(dev, EDCAPARA_VI, u4bAcParam); + break; + + case AC3_VO: + write_nic_dword(dev, EDCAPARA_VO, u4bAcParam); + break; + + default: + printk(KERN_INFO "SetHwReg8185(): invalid ACI: %d !\n", + eACI); + break; } + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL, + (u8 *)(&pAcParam)); break; + } - case HW_VAR_SLOT_TIME: - { + case HW_VAR_ACM_CTRL: + { + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; + u8 pAcParam = *((u8 *)val); + u32 eACI = pAcParam; + union aci_aifsn *pAciAifsn = (union aci_aifsn *) & + (qos_parameters->aifs[0]); + u8 acm = pAciAifsn->f.acm; + u8 AcmCtrl = read_nic_byte(dev, AcmHwCtrl); - priv->slot_time = val[0]; - write_nic_byte(dev, SLOT_TIME, val[0]); - - } - break; - - case HW_VAR_ACK_PREAMBLE: - { - u32 regTmp = 0; - priv->short_preamble = (bool)(*(u8*)val ); - regTmp = priv->basic_rate; - if (priv->short_preamble) - regTmp |= BRSR_AckShortPmb; - write_nic_dword(dev, RRSR, regTmp); - } - break; - - case HW_VAR_CPU_RST: - write_nic_dword(dev, CPU_GEN, ((u32*)(val))[0]); - break; - - case HW_VAR_AC_PARAM: - { - u8 pAcParam = *((u8*)val); - u32 eACI = pAcParam; - u8 u1bAIFS; - u32 u4bAcParam; - u8 mode = priv->rtllib->mode; - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - - - u1bAIFS = qos_parameters->aifs[pAcParam] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - - dm_init_edca_turbo(dev); - - u4bAcParam = ( (((u32)(qos_parameters->tx_op_limit[pAcParam])) << AC_PARAM_TXOP_LIMIT_OFFSET) | - (((u32)(qos_parameters->cw_max[pAcParam])) << AC_PARAM_ECW_MAX_OFFSET) | - (((u32)(qos_parameters->cw_min[pAcParam])) << AC_PARAM_ECW_MIN_OFFSET) | - (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET) ); - - RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n", __func__,eACI, u4bAcParam); - switch (eACI) - { - case AC1_BK: - write_nic_dword(dev, EDCAPARA_BK, u4bAcParam); - break; + RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", + __func__, eACI); + AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2) ? 0x0 : 0x1); + if (acm) { + switch (eACI) { case AC0_BE: - write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); + AcmCtrl |= AcmHw_BeqEn; break; case AC2_VI: - write_nic_dword(dev, EDCAPARA_VI, u4bAcParam); + AcmCtrl |= AcmHw_ViqEn; break; case AC3_VO: - write_nic_dword(dev, EDCAPARA_VO, u4bAcParam); + AcmCtrl |= AcmHw_VoqEn; break; default: - printk("SetHwReg8185(): invalid ACI: %d !\n", eACI); + RT_TRACE(COMP_QOS, "SetHwReg8185(): [HW_VAR_" + "ACM_CTRL] acm set failed: eACI is " + "%d\n", eACI); break; } - priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL, (u8*)(&pAcParam)); - } - break; + } else { + switch (eACI) { + case AC0_BE: + AcmCtrl &= (~AcmHw_BeqEn); + break; - case HW_VAR_ACM_CTRL: - { - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - u8 pAcParam = *((u8*)val); - u32 eACI = pAcParam; - union aci_aifsn *pAciAifsn = (union aci_aifsn *)&(qos_parameters->aifs[0]); - u8 acm = pAciAifsn->f.acm; - u8 AcmCtrl = read_nic_byte( dev, AcmHwCtrl); + case AC2_VI: + AcmCtrl &= (~AcmHw_ViqEn); + break; - RT_TRACE(COMP_DBG, "===========>%s():HW_VAR_ACM_CTRL:%x\n", __func__,eACI); - AcmCtrl = AcmCtrl | ((priv->AcmMethod == 2)?0x0:0x1); + case AC3_VO: + AcmCtrl &= (~AcmHw_BeqEn); + break; - if (acm) - { - switch (eACI) - { - case AC0_BE: - AcmCtrl |= AcmHw_BeqEn; - break; - - case AC2_VI: - AcmCtrl |= AcmHw_ViqEn; - break; - - case AC3_VO: - AcmCtrl |= AcmHw_VoqEn; - break; - - default: - RT_TRACE( COMP_QOS, "SetHwReg8185(): [HW_VAR_ACM_CTRL] acm set failed: eACI is %d\n", eACI ); - break; - } + default: + break; } - else - { - switch (eACI) - { - case AC0_BE: - AcmCtrl &= (~AcmHw_BeqEn); - break; - - case AC2_VI: - AcmCtrl &= (~AcmHw_ViqEn); - break; - - case AC3_VO: - AcmCtrl &= (~AcmHw_BeqEn); - break; - - default: - break; - } - } - - RT_TRACE( COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ); - write_nic_byte(dev, AcmHwCtrl, AcmCtrl ); } + + RT_TRACE(COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write" + " 0x%X\n", AcmCtrl); + write_nic_byte(dev, AcmHwCtrl, AcmCtrl); + break; + } + + case HW_VAR_SIFS: + write_nic_byte(dev, SIFS, val[0]); + write_nic_byte(dev, SIFS+1, val[0]); break; - case HW_VAR_SIFS: - write_nic_byte(dev, SIFS, val[0]); - write_nic_byte(dev, SIFS+1, val[0]); + case HW_VAR_RF_TIMING: + { + u8 Rf_Timing = *((u8 *)val); + write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); break; + } - case HW_VAR_RF_TIMING: - { - u8 Rf_Timing = *((u8*)val); - write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing); - } - break; - - default: + default: break; } } -static void rtl8192_read_eeprom_info(struct net_device* dev) +static void rtl8192_read_eeprom_info(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 tempval; - u8 ICVer8192, ICVer8256; - u16 i,usValue, IC_Version; - u16 EEPROMId; + u8 tempval; + u8 ICVer8192, ICVer8256; + u16 i, usValue, IC_Version; + u16 EEPROMId; u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01}; RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n"); - - EEPROMId = eprom_read(dev, 0); - if ( EEPROMId != RTL8190_EEPROM_ID ) - { - RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", EEPROMId, RTL8190_EEPROM_ID); - priv->AutoloadFailFlag=true; - } - else - { - priv->AutoloadFailFlag=false; + if (EEPROMId != RTL8190_EEPROM_ID) { + RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n", + EEPROMId, RTL8190_EEPROM_ID); + priv->AutoloadFailFlag = true; + } else { + priv->AutoloadFailFlag = false; } - if (!priv->AutoloadFailFlag) - { + if (!priv->AutoloadFailFlag) { priv->eeprom_vid = eprom_read(dev, (EEPROM_VID >> 1)); priv->eeprom_did = eprom_read(dev, (EEPROM_DID >> 1)); - usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8 ; - priv->eeprom_CustomerID = (u8)( usValue & 0xff); + usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8; + priv->eeprom_CustomerID = (u8)(usValue & 0xff); usValue = eprom_read(dev, (EEPROM_ICVersion_ChannelPlan>>1)); priv->eeprom_ChannelPlan = usValue&0xff; IC_Version = ((usValue&0xff00)>>8); @@ -346,24 +342,21 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) ICVer8256 = ((IC_Version&0xf0)>>4); RT_TRACE(COMP_INIT, "\nICVer8192 = 0x%x\n", ICVer8192); RT_TRACE(COMP_INIT, "\nICVer8256 = 0x%x\n", ICVer8256); - if (ICVer8192 == 0x2) - { + if (ICVer8192 == 0x2) { if (ICVer8256 == 0x5) - priv->card_8192_version= VERSION_8190_BE; + priv->card_8192_version = VERSION_8190_BE; } - switch (priv->card_8192_version) - { - case VERSION_8190_BD: - case VERSION_8190_BE: - break; - default: - priv->card_8192_version = VERSION_8190_BD; - break; + switch (priv->card_8192_version) { + case VERSION_8190_BD: + case VERSION_8190_BE: + break; + default: + priv->card_8192_version = VERSION_8190_BD; + break; } - RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", priv->card_8192_version); - } - else - { + RT_TRACE(COMP_INIT, "\nIC Version = 0x%x\n", + priv->card_8192_version); + } else { priv->card_8192_version = VERSION_8190_BD; priv->eeprom_vid = 0; priv->eeprom_did = 0; @@ -374,282 +367,289 @@ static void rtl8192_read_eeprom_info(struct net_device* dev) RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); RT_TRACE(COMP_INIT, "EEPROM DID = 0x%4x\n", priv->eeprom_did); - RT_TRACE(COMP_INIT,"EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); + RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", + priv->eeprom_CustomerID); - if (!priv->AutoloadFailFlag) - { - for (i = 0; i < 6; i += 2) - { - usValue = eprom_read(dev, (u16) ((EEPROM_NODE_ADDRESS_BYTE_0+i)>>1)); - *(u16*)(&dev->dev_addr[i]) = usValue; + if (!priv->AutoloadFailFlag) { + for (i = 0; i < 6; i += 2) { + usValue = eprom_read(dev, + (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1)); + *(u16 *)(&dev->dev_addr[i]) = usValue; } } else { memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); } - RT_TRACE(COMP_INIT, "Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", - dev->dev_addr[0], dev->dev_addr[1], - dev->dev_addr[2], dev->dev_addr[3], - dev->dev_addr[4], dev->dev_addr[5]); + RT_TRACE(COMP_INIT, "Permanent Address = %pM\n", + dev->dev_addr); - if (priv->card_8192_version > VERSION_8190_BD) { + if (priv->card_8192_version > VERSION_8190_BD) priv->bTXPowerDataReadFromEEPORM = true; - } else { + else priv->bTXPowerDataReadFromEEPORM = false; - } priv->rf_type = RTL819X_DEFAULT_RF_TYPE; - if (priv->card_8192_version > VERSION_8190_BD) - { - if (!priv->AutoloadFailFlag) - { - tempval = (eprom_read(dev, (EEPROM_RFInd_PowerDiff>>1))) & 0xff; + if (priv->card_8192_version > VERSION_8190_BD) { + if (!priv->AutoloadFailFlag) { + tempval = (eprom_read(dev, (EEPROM_RFInd_PowerDiff >> + 1))) & 0xff; priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; if (tempval&0x80) priv->rf_type = RF_1T2R; else priv->rf_type = RF_2T4R; - } - else - { + } else { priv->EEPROMLegacyHTTxPowerDiff = 0x04; } RT_TRACE(COMP_INIT, "EEPROMLegacyHTTxPowerDiff = %d\n", priv->EEPROMLegacyHTTxPowerDiff); if (!priv->AutoloadFailFlag) - { - priv->EEPROMThermalMeter = (u8)(((eprom_read(dev, (EEPROM_ThermalMeter>>1))) & 0xff00)>>8); - } + priv->EEPROMThermalMeter = (u8)(((eprom_read(dev, + (EEPROM_ThermalMeter>>1))) & + 0xff00)>>8); else - { priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - } - RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", priv->EEPROMThermalMeter); - priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; + RT_TRACE(COMP_INIT, "ThermalMeter = %d\n", + priv->EEPROMThermalMeter); + priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100; - if (priv->epromtype == EEPROM_93C46) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (EEPROM_TxPwDiff_CrystalCap>>1)); + if (priv->epromtype == EEPROM_93C46) { + if (!priv->AutoloadFailFlag) { + usValue = eprom_read(dev, + (EEPROM_TxPwDiff_CrystalCap >> 1)); priv->EEPROMAntPwDiff = (usValue&0x0fff); - priv->EEPROMCrystalCap = (u8)((usValue&0xf000)>>12); - } - else - { - priv->EEPROMAntPwDiff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = EEPROM_Default_TxPwDiff_CrystalCap; - } - RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", priv->EEPROMAntPwDiff); - RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", priv->EEPROMCrystalCap); + priv->EEPROMCrystalCap = (u8)((usValue & 0xf000) + >> 12); + } else { + priv->EEPROMAntPwDiff = + EEPROM_Default_AntTxPowerDiff; + priv->EEPROMCrystalCap = + EEPROM_Default_TxPwDiff_CrystalCap; + } + RT_TRACE(COMP_INIT, "EEPROMAntPwDiff = %d\n", + priv->EEPROMAntPwDiff); + RT_TRACE(COMP_INIT, "EEPROMCrystalCap = %d\n", + priv->EEPROMCrystalCap); - for (i=0; i<14; i+=2) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_CCK+i)>>1) ); + for (i = 0; i < 14; i += 2) { + if (!priv->AutoloadFailFlag) + usValue = eprom_read(dev, + (u16)((EEPROM_TxPwIndex_CCK + + i) >> 1)); + else + usValue = EEPROM_Default_TxPower; + *((u16 *)(&priv->EEPROMTxPowerLevelCCK[i])) = + usValue; + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index" + " %d = 0x%02x\n", i, + priv->EEPROMTxPowerLevelCCK[i]); + RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index" + " %d = 0x%02x\n", i+1, + priv->EEPROMTxPowerLevelCCK[i+1]); } - else - { - usValue = EEPROM_Default_TxPower; + for (i = 0; i < 14; i += 2) { + if (!priv->AutoloadFailFlag) + usValue = eprom_read(dev, + (u16)((EEPROM_TxPwIndex_OFDM_24G + + i) >> 1)); + else + usValue = EEPROM_Default_TxPower; + *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[i])) + = usValue; + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level," + " Index %d = 0x%02x\n", i, + priv->EEPROMTxPowerLevelOFDM24G[i]); + RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level," + " Index %d = 0x%02x\n", i + 1, + priv->EEPROMTxPowerLevelOFDM24G[i+1]); } - *((u16*)(&priv->EEPROMTxPowerLevelCCK[i])) = usValue; - RT_TRACE(COMP_INIT,"CCK Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK[i]); - RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelCCK[i+1]); } - for (i=0; i<14; i+=2) - { - if (!priv->AutoloadFailFlag) - { - usValue = eprom_read(dev, (u16) ((EEPROM_TxPwIndex_OFDM_24G+i)>>1) ); + if (priv->epromtype == EEPROM_93C46) { + for (i = 0; i < 14; i++) { + priv->TxPowerLevelCCK[i] = + priv->EEPROMTxPowerLevelCCK[i]; + priv->TxPowerLevelOFDM24G[i] = + priv->EEPROMTxPowerLevelOFDM24G[i]; } - else - { - usValue = EEPROM_Default_TxPower; - } - *((u16*)(&priv->EEPROMTxPowerLevelOFDM24G[i])) = usValue; - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelOFDM24G[i]); - RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i+1, priv->EEPROMTxPowerLevelOFDM24G[i+1]); - } - } - else if (priv->epromtype== EEPROM_93C56) - { - - } - if (priv->epromtype == EEPROM_93C46) - { - for (i=0; i<14; i++) - { - priv->TxPowerLevelCCK[i] = priv->EEPROMTxPowerLevelCCK[i]; - priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[i]; - } - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; - priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & 0xf); - priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & 0xf0)>>4); - priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & 0xf00)>>8); + priv->LegacyHTTxPowerDiff = + priv->EEPROMLegacyHTTxPowerDiff; + priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff & + 0xf); + priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff & + 0xf0)>>4); + priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff & + 0xf00)>>8); priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); - } - else if (priv->epromtype == EEPROM_93C56) - { + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & + 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & + 0xf0)>>4); + } else if (priv->epromtype == EEPROM_93C56) { - for (i=0; i<3; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[0]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0]; + for (i = 0; i < 3; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[0]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[0]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[0]; } - for (i=3; i<9; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[1]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[1]; + for (i = 3; i < 9; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[1]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[1]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[1]; } - for (i=9; i<14; i++) - { - priv->TxPowerLevelCCK_A[i] = priv->EEPROMRfACCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_A[i] = priv->EEPROMRfAOfdmChnlTxPwLevel[2]; - priv->TxPowerLevelCCK_C[i] = priv->EEPROMRfCCCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_C[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[2]; + for (i = 9; i < 14; i++) { + priv->TxPowerLevelCCK_A[i] = + priv->EEPROMRfACCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_A[i] = + priv->EEPROMRfAOfdmChnlTxPwLevel[2]; + priv->TxPowerLevelCCK_C[i] = + priv->EEPROMRfCCCKChnl1TxPwLevel[2]; + priv->TxPowerLevelOFDM24G_C[i] = + priv->EEPROMRfCOfdmChnlTxPwLevel[2]; } - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_A[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT,"priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_A[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C[%d] = 0x%x\n", i, priv->TxPowerLevelCCK_C[i]); - for (i=0; i<14; i++) - RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n", i, priv->TxPowerLevelOFDM24G_C[i]); - priv->LegacyHTTxPowerDiff = priv->EEPROMLegacyHTTxPowerDiff; + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A" + "[%d] = 0x%x\n", i, + priv->TxPowerLevelCCK_A[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM" + "24G_A[%d] = 0x%x\n", i, + priv->TxPowerLevelOFDM24G_A[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C" + "[%d] = 0x%x\n", i, + priv->TxPowerLevelCCK_C[i]); + for (i = 0; i < 14; i++) + RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM" + "24G_C[%d] = 0x%x\n", i, + priv->TxPowerLevelOFDM24G_C[i]); + priv->LegacyHTTxPowerDiff = + priv->EEPROMLegacyHTTxPowerDiff; priv->AntennaTxPwDiff[0] = 0; priv->AntennaTxPwDiff[1] = 0; priv->AntennaTxPwDiff[2] = 0; priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & 0xf); - priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & 0xf0)>>4); + priv->ThermalMeter[0] = (priv->EEPROMThermalMeter & + 0xf); + priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter & + 0xf0)>>4); } } - if (priv->rf_type == RF_1T2R) - { + if (priv->rf_type == RF_1T2R) { + /* no matter what checkpatch says, the braces are needed */ RT_TRACE(COMP_INIT, "\n1T2R config\n"); - } - else if (priv->rf_type == RF_2T4R) - { + } else if (priv->rf_type == RF_2T4R) { RT_TRACE(COMP_INIT, "\n2T4R config\n"); } init_rate_adaptive(dev); - - priv->rf_chip= RF_8256; + priv->rf_chip = RF_8256; if (priv->RegChannelPlan == 0xf) - { priv->ChannelPlan = priv->eeprom_ChannelPlan; - } else - { priv->ChannelPlan = priv->RegChannelPlan; - } - if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304 ) - { + if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->CustomerID = RT_CID_DLINK; - } - switch (priv->eeprom_CustomerID) - { - case EEPROM_CID_DEFAULT: - priv->CustomerID = RT_CID_DEFAULT; - break; - case EEPROM_CID_CAMEO: - priv->CustomerID = RT_CID_819x_CAMEO; - break; - case EEPROM_CID_RUNTOP: - priv->CustomerID = RT_CID_819x_RUNTOP; - break; - case EEPROM_CID_NetCore: - priv->CustomerID = RT_CID_819x_Netcore; - break; - case EEPROM_CID_TOSHIBA: - priv->CustomerID = RT_CID_TOSHIBA; - if (priv->eeprom_ChannelPlan&0x80) - priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; - else - priv->ChannelPlan = 0x0; - RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", - priv->ChannelPlan); - break; - case EEPROM_CID_Nettronix: - priv->ScanDelay = 100; - priv->CustomerID = RT_CID_Nettronix; - break; - case EEPROM_CID_Pronet: - priv->CustomerID = RT_CID_PRONET; - break; - case EEPROM_CID_DLINK: - priv->CustomerID = RT_CID_DLINK; - break; + switch (priv->eeprom_CustomerID) { + case EEPROM_CID_DEFAULT: + priv->CustomerID = RT_CID_DEFAULT; + break; + case EEPROM_CID_CAMEO: + priv->CustomerID = RT_CID_819x_CAMEO; + break; + case EEPROM_CID_RUNTOP: + priv->CustomerID = RT_CID_819x_RUNTOP; + break; + case EEPROM_CID_NetCore: + priv->CustomerID = RT_CID_819x_Netcore; + break; + case EEPROM_CID_TOSHIBA: + priv->CustomerID = RT_CID_TOSHIBA; + if (priv->eeprom_ChannelPlan&0x80) + priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; + else + priv->ChannelPlan = 0x0; + RT_TRACE(COMP_INIT, "Toshiba ChannelPlan = 0x%x\n", + priv->ChannelPlan); + break; + case EEPROM_CID_Nettronix: + priv->ScanDelay = 100; + priv->CustomerID = RT_CID_Nettronix; + break; + case EEPROM_CID_Pronet: + priv->CustomerID = RT_CID_PRONET; + break; + case EEPROM_CID_DLINK: + priv->CustomerID = RT_CID_DLINK; + break; - case EEPROM_CID_WHQL: - - - - break; - default: - break; + case EEPROM_CID_WHQL: + break; + default: + break; } if (priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) priv->ChannelPlan = 0; priv->ChannelPlan = COUNTRY_CODE_WORLD_WIDE_13; - if ( priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) + if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->rtllib->bSupportRemoteWakeUp = true; else priv->rtllib->bSupportRemoteWakeUp = false; RT_TRACE(COMP_INIT, "RegChannelPlan(%d)\n", priv->RegChannelPlan); - RT_TRACE(COMP_INIT, "ChannelPlan = %d \n", priv->ChannelPlan); + RT_TRACE(COMP_INIT, "ChannelPlan = %d\n", priv->ChannelPlan); RT_TRACE(COMP_TRACE, "<==== ReadAdapterInfo\n"); - - return ; } -void rtl8192_get_eeprom_size(struct net_device* dev) +void rtl8192_get_eeprom_size(struct net_device *dev) { - u16 curCR = 0; + u16 curCR; struct r8192_priv *priv = rtllib_priv(dev); + RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); curCR = read_nic_dword(dev, EPROM_CMD); - RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, curCR); - priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : EEPROM_93C46; - RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, priv->epromtype); + RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, + curCR); + priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : + EEPROM_93C46; + RT_TRACE(COMP_INIT, "<===========%s(), epromtype:%d\n", __func__, + priv->epromtype); rtl8192_read_eeprom_info(dev); } -static void rtl8192_hwconfig(struct net_device* dev) +static void rtl8192_hwconfig(struct net_device *dev) { u32 regRATR = 0, regRRSR = 0; u8 regBwOpMode = 0, regTmp = 0; struct r8192_priv *priv = rtllib_priv(dev); - switch (priv->rtllib->mode) - { + switch (priv->rtllib->mode) { case WIRELESS_MODE_B: regBwOpMode = BW_OPMODE_20MHZ; regRATR = RATE_ALL_CCK; regRRSR = RATE_ALL_CCK; break; case WIRELESS_MODE_A: - regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; + regBwOpMode = BW_OPMODE_5G | BW_OPMODE_20MHZ; regRATR = RATE_ALL_OFDM_AG; regRRSR = RATE_ALL_OFDM_AG; break; @@ -661,12 +661,14 @@ static void rtl8192_hwconfig(struct net_device* dev) case WIRELESS_MODE_AUTO: case WIRELESS_MODE_N_24G: regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | + RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; break; case WIRELESS_MODE_N_5G: regBwOpMode = BW_OPMODE_5G; - regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | + RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_OFDM_AG; break; default: @@ -681,9 +683,7 @@ static void rtl8192_hwconfig(struct net_device* dev) u32 ratr_value = 0; ratr_value = regRATR; if (priv->rf_type == RF_1T2R) - { ratr_value &= ~(RATE_ALL_OFDM_2SS); - } write_nic_dword(dev, RATR0, ratr_value); write_nic_byte(dev, UFWP, 1); } @@ -692,11 +692,8 @@ static void rtl8192_hwconfig(struct net_device* dev) write_nic_dword(dev, RRSR, regRRSR); write_nic_word(dev, RETRY_LIMIT, - priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | \ + priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); - - - } bool rtl8192_adapter_start(struct net_device *dev) @@ -705,7 +702,7 @@ bool rtl8192_adapter_start(struct net_device *dev) u32 ulRegRead; bool rtStatus = true; u8 tmpvalue; - u8 ICVersion,SwitchingRegulatorOutput; + u8 ICVersion, SwitchingRegulatorOutput; bool bfirmwareok = true; u32 tmpRegA, tmpRegC, TempCCk; int i = 0; @@ -715,13 +712,12 @@ bool rtl8192_adapter_start(struct net_device *dev) priv->being_init_adapter = true; start: - rtl8192_pci_resetdescring(dev); + rtl8192_pci_resetdescring(dev); priv->Rf_Mode = RF_OP_By_SW_3wire; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { - write_nic_byte(dev, ANAPAR, 0x37); - mdelay(500); - } + if (priv->ResetProgress == RESET_TYPE_NORESET) { + write_nic_byte(dev, ANAPAR, 0x37); + mdelay(500); + } priv->pFirmware->firmware_status = FW_STATUS_0_INIT; if (priv->RegRfOff == true) @@ -729,23 +725,19 @@ start: ulRegRead = read_nic_dword(dev, CPU_GEN); if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT) - { ulRegRead |= CPU_GEN_SYSTEM_RESET; - }else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) + else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) ulRegRead |= CPU_GEN_FIRMWARE_RESET; else - RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__, priv->pFirmware->firmware_status); - + RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)" + "\n", __func__, priv->pFirmware->firmware_status); write_nic_dword(dev, CPU_GEN, ulRegRead); - ICVersion = read_nic_byte(dev, IC_VERRSION); - if (ICVersion >= 0x4) - { + if (ICVersion >= 0x4) { SwitchingRegulatorOutput = read_nic_byte(dev, SWREGULATOR); - if (SwitchingRegulatorOutput != 0xb8) - { + if (SwitchingRegulatorOutput != 0xb8) { write_nic_byte(dev, SWREGULATOR, 0xa8); mdelay(1); write_nic_byte(dev, SWREGULATOR, 0xb8); @@ -753,64 +745,64 @@ start: } RT_TRACE(COMP_INIT, "BB Config Start!\n"); rtStatus = rtl8192_BBConfig(dev); - if (rtStatus != true) - { + if (rtStatus != true) { RT_TRACE(COMP_ERR, "BB Config failed\n"); return rtStatus; } - RT_TRACE(COMP_INIT,"BB Config Finished!\n"); + RT_TRACE(COMP_INIT, "BB Config Finished!\n"); priv->LoopbackMode = RTL819X_NO_LOOPBACK; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { - ulRegRead = read_nic_dword(dev, CPU_GEN); - if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) - { - ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET); - } - else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK ) - { - ulRegRead |= CPU_CCK_LOOPBACK; - } - else - { - RT_TRACE(COMP_ERR,"Serious error: wrong loopback mode setting\n"); - } + if (priv->ResetProgress == RESET_TYPE_NORESET) { + ulRegRead = read_nic_dword(dev, CPU_GEN); + if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) + ulRegRead = ((ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | + CPU_GEN_NO_LOOPBACK_SET); + else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK) + ulRegRead |= CPU_CCK_LOOPBACK; + else + RT_TRACE(COMP_ERR, "Serious error: wrong loopback" + " mode setting\n"); - write_nic_dword(dev, CPU_GEN, ulRegRead); + write_nic_dword(dev, CPU_GEN, ulRegRead); - udelay(500); + udelay(500); } rtl8192_hwconfig(dev); - write_nic_byte(dev, CMDR, CR_RE|CR_TE); + write_nic_byte(dev, CMDR, CR_RE | CR_TE); - write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); - write_nic_word(dev, MAC4, ((u16*)(dev->dev_addr + 4))[0]); + write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<dev_addr)[0]); + write_nic_word(dev, MAC4, ((u16 *)(dev->dev_addr + 4))[0]); write_nic_dword(dev, RCR, priv->ReceiveConfig); - { - write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\ - NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \ - NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) - rtl8192_SetWirelessMode(dev, priv->rtllib->mode); + rtl8192_SetWirelessMode(dev, priv->rtllib->mode); CamResetAllEntry(dev); { u8 SECR_value = 0x0; @@ -823,8 +815,8 @@ start: write_nic_word(dev, BCN_INTERVAL, 100); { int i; - for (i=0; iIC_Cut= tmpvalue; + priv->IC_Cut = tmpvalue; RT_TRACE(COMP_INIT, "priv->IC_Cut= 0x%x\n", priv->IC_Cut); - if (priv->IC_Cut>= IC_VersionCut_D) - { - if (priv->IC_Cut== IC_VersionCut_D) { + if (priv->IC_Cut >= IC_VersionCut_D) { + if (priv->IC_Cut == IC_VersionCut_D) { + /* no matter what checkpatch says, braces are needed */ RT_TRACE(COMP_INIT, "D-cut\n"); - } else if (priv->IC_Cut== IC_VersionCut_E) { + } else if (priv->IC_Cut == IC_VersionCut_E) { RT_TRACE(COMP_INIT, "E-cut\n"); } } else { @@ -878,20 +870,27 @@ start: write_nic_byte(dev, 0x87, 0x0); if (priv->RegRfOff == true) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RegRfOff ----------\n",__func__); - MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW,true); + RT_TRACE((COMP_INIT | COMP_RF | COMP_POWER), + "%s(): Turn off RF for RegRfOff ----------\n", + __func__); + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW, true); } else if (priv->rtllib->RfOffReason > RF_CHANGE_BY_PS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); - MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for" + " RfOffReason(%d) ----------\n", __func__, + priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason, + true); } else if (priv->rtllib->RfOffReason >= RF_CHANGE_BY_IPS) { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for RfOffReason(%d) ----------\n", __func__,priv->rtllib->RfOffReason); - MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,true); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for" + " RfOffReason(%d) ----------\n", __func__, + priv->rtllib->RfOffReason); + MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason, + true); } else { - RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON \n",__func__); + RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): RF-ON\n", + __func__); priv->rtllib->eRFPowerState = eRfOn; priv->rtllib->RfOffReason = 0; - - } if (priv->rtllib->FwRWRF) @@ -899,37 +898,51 @@ start: else priv->Rf_Mode = RF_OP_By_SW_3wire; - if (priv->ResetProgress == RESET_TYPE_NORESET) - { + if (priv->ResetProgress == RESET_TYPE_NORESET) { dm_initialize_txpower_tracking(dev); - if (priv->IC_Cut>= IC_VersionCut_D) { - tmpRegA= rtl8192_QueryBBReg(dev,rOFDM0_XATxIQImbalance,bMaskDWord); - tmpRegC= rtl8192_QueryBBReg(dev,rOFDM0_XCTxIQImbalance,bMaskDWord); - for (i = 0; itxbbgain_table[i].txbbgain_value) { - priv->rfa_txpowertrackingindex= (u8)i; - priv->rfa_txpowertrackingindex_real= (u8)i; - priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; + if (priv->IC_Cut >= IC_VersionCut_D) { + tmpRegA = rtl8192_QueryBBReg(dev, + rOFDM0_XATxIQImbalance, bMaskDWord); + tmpRegC = rtl8192_QueryBBReg(dev, + rOFDM0_XCTxIQImbalance, bMaskDWord); + for (i = 0; i < TxBBGainTableLength; i++) { + if (tmpRegA == + priv->txbbgain_table[i].txbbgain_value) { + priv->rfa_txpowertrackingindex = (u8)i; + priv->rfa_txpowertrackingindex_real = + (u8)i; + priv->rfa_txpowertracking_default = + priv->rfa_txpowertrackingindex; break; } } - TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); + TempCCk = rtl8192_QueryBBReg(dev, + rCCK0_TxFilter1, bMaskByte2); for (i = 0; i < CCKTxBBGainTableLength; i++) { if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) { - priv->CCKPresentAttentuation_20Mdefault =(u8) i; + priv->CCKPresentAttentuation_20Mdefault = (u8)i; break; } } priv->CCKPresentAttentuation_40Mdefault = 0; priv->CCKPresentAttentuation_difference = 0; - priv->CCKPresentAttentuation = priv->CCKPresentAttentuation_20Mdefault; - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_initial = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real__initial = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference_initial = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_initial = %d\n", priv->CCKPresentAttentuation); + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault; + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower" + "trackingindex_initial = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower" + "trackingindex_real__initial = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent" + "Attentuation_difference_initial = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent" + "Attentuation_initial = %d\n", + priv->CCKPresentAttentuation); priv->btxpower_tracking = false; } } @@ -951,8 +964,8 @@ void rtl8192_net_update(struct net_device *dev) rtl8192_config_rate(dev, &rate_config); priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; priv->basic_rate = rate_config &= 0x15f; - write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]); - write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]); + write_nic_dword(dev, BSSIDR, ((u32 *)net->bssid)[0]); + write_nic_word(dev, BSSIDR+4, ((u16 *)net->bssid)[2]); if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { write_nic_word(dev, ATIMWND, 2); @@ -971,15 +984,16 @@ void rtl8192_net_update(struct net_device *dev) void rtl8192_link_change(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; if (!priv->up) - return; + return; if (ieee->state == RTLLIB_LINKED) { rtl8192_net_update(dev); priv->ops->update_ratr_table(dev); - if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) + if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) EnableHWSecurityConfig8192(dev); } else { write_nic_byte(dev, 0x173, 0); @@ -991,8 +1005,8 @@ void rtl8192_link_change(struct net_device *dev) reg = read_nic_dword(dev, RCR); if (priv->rtllib->state == RTLLIB_LINKED) { if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn) - ; - else + ; + else priv->ReceiveConfig = reg |= RCR_CBSSID; } else priv->ReceiveConfig = reg &= ~RCR_CBSSID; @@ -1001,21 +1015,20 @@ void rtl8192_link_change(struct net_device *dev) } } -void rtl8192_AllowAllDestAddr(struct net_device* dev, - bool bAllowAllDA, bool WriteIntoReg) +void rtl8192_AllowAllDestAddr(struct net_device *dev, + bool bAllowAllDA, bool WriteIntoReg) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - if (bAllowAllDA) - priv->ReceiveConfig |= RCR_AAP; - else - priv->ReceiveConfig &= ~RCR_AAP; + if (bAllowAllDA) + priv->ReceiveConfig |= RCR_AAP; + else + priv->ReceiveConfig &= ~RCR_AAP; - if (WriteIntoReg) - write_nic_dword( dev, RCR, priv->ReceiveConfig ); + if (WriteIntoReg) + write_nic_dword(dev, RCR, priv->ReceiveConfig); } - static u8 MRateToHwRate8190Pci(u8 rate) { u8 ret = DESC90_RATE1M; @@ -1148,138 +1161,144 @@ u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) break; default: RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection:" - " %d \n", QueueID); + " %d\n", QueueID); break; } return QueueSelect; } - -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, + struct cb_desc *cb_desc, struct sk_buff *skb) { - struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); - struct tx_fwinfo_8190pci *pTxFwInfo = NULL; - pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; - memset(pTxFwInfo,0,sizeof(struct tx_fwinfo_8190pci)); - pTxFwInfo->TxHT = (cb_desc->data_rate&0x80)?1:0; - pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); - pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; - pTxFwInfo->Short = rtl8192_QueryIsShort(pTxFwInfo->TxHT, pTxFwInfo->TxRate, cb_desc); + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); + struct tx_fwinfo_8190pci *pTxFwInfo = NULL; + pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; + memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci)); + pTxFwInfo->TxHT = (cb_desc->data_rate & 0x80) ? 1 : 0; + pTxFwInfo->TxRate = MRateToHwRate8190Pci((u8)cb_desc->data_rate); + pTxFwInfo->EnableCPUDur = cb_desc->bTxEnableFwCalcDur; + pTxFwInfo->Short = rtl8192_QueryIsShort(pTxFwInfo->TxHT, + pTxFwInfo->TxRate, + cb_desc); - if (cb_desc->bAMPDUEnable) { - pTxFwInfo->AllowAggregation = 1; - pTxFwInfo->RxMF = cb_desc->ampdu_factor; - pTxFwInfo->RxAMD = cb_desc->ampdu_density; - } else { - pTxFwInfo->AllowAggregation = 0; - pTxFwInfo->RxMF = 0; - pTxFwInfo->RxAMD = 0; - } + if (cb_desc->bAMPDUEnable) { + pTxFwInfo->AllowAggregation = 1; + pTxFwInfo->RxMF = cb_desc->ampdu_factor; + pTxFwInfo->RxAMD = cb_desc->ampdu_density; + } else { + pTxFwInfo->AllowAggregation = 0; + pTxFwInfo->RxMF = 0; + pTxFwInfo->RxAMD = 0; + } - pTxFwInfo->RtsEnable = (cb_desc->bRTSEnable)?1:0; - pTxFwInfo->CtsEnable = (cb_desc->bCTSEnable)?1:0; - pTxFwInfo->RtsSTBC = (cb_desc->bRTSSTBC)?1:0; - pTxFwInfo->RtsHT= (cb_desc->rts_rate&0x80)?1:0; - pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)cb_desc->rts_rate); - pTxFwInfo->RtsBandwidth = 0; - pTxFwInfo->RtsSubcarrier = cb_desc->RTSSC; - pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT==0)?(cb_desc->bRTSUseShortPreamble?1:0):(cb_desc->bRTSUseShortGI?1:0); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) - { - if (cb_desc->bPacketBW) - { - pTxFwInfo->TxBandwidth = 1; - pTxFwInfo->TxSubCarrier = 0; - } - else - { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; - } - } else { - pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = 0; - } + pTxFwInfo->RtsEnable = (cb_desc->bRTSEnable) ? 1 : 0; + pTxFwInfo->CtsEnable = (cb_desc->bCTSEnable) ? 1 : 0; + pTxFwInfo->RtsSTBC = (cb_desc->bRTSSTBC) ? 1 : 0; + pTxFwInfo->RtsHT = (cb_desc->rts_rate&0x80) ? 1 : 0; + pTxFwInfo->RtsRate = MRateToHwRate8190Pci((u8)cb_desc->rts_rate); + pTxFwInfo->RtsBandwidth = 0; + pTxFwInfo->RtsSubcarrier = cb_desc->RTSSC; + pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? + (cb_desc->bRTSUseShortPreamble ? 1 : 0) : + (cb_desc->bRTSUseShortGI ? 1 : 0); + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { + if (cb_desc->bPacketBW) { + pTxFwInfo->TxBandwidth = 1; + pTxFwInfo->TxSubCarrier = 0; + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; + } + } else { + pTxFwInfo->TxBandwidth = 0; + pTxFwInfo->TxSubCarrier = 0; + } - memset((u8*)pdesc,0,12); - pdesc->LINIP = 0; - pdesc->CmdInit = 1; - pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; - pdesc->PktSize = (u16)skb->len-sizeof(struct tx_fwinfo_8190pci); + memset((u8 *)pdesc, 0, 12); + pdesc->LINIP = 0; + pdesc->CmdInit = 1; + pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; + pdesc->PktSize = (u16)skb->len-sizeof(struct tx_fwinfo_8190pci); - pdesc->SecCAMID= 0; - pdesc->RATid = cb_desc->RATRIndex; + pdesc->SecCAMID = 0; + pdesc->RATid = cb_desc->RATRIndex; - pdesc->NoEnc = 1; - pdesc->SecType = 0x0; - if (cb_desc->bHwSec) { - static u8 tmp =0; - if (!tmp) { - RT_TRACE(COMP_DBG, "==>================hw sec\n"); - tmp = 1; - } - switch (priv->rtllib->pairwise_key_type) { - case KEY_TYPE_WEP40: - case KEY_TYPE_WEP104: - pdesc->SecType = 0x1; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_TKIP: - pdesc->SecType = 0x2; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_CCMP: - pdesc->SecType = 0x3; - pdesc->NoEnc = 0; - break; - case KEY_TYPE_NA: - pdesc->SecType = 0x0; - pdesc->NoEnc = 1; - break; - } - } + pdesc->NoEnc = 1; + pdesc->SecType = 0x0; + if (cb_desc->bHwSec) { + static u8 tmp; + if (!tmp) { + RT_TRACE(COMP_DBG, "==>================hw sec\n"); + tmp = 1; + } + switch (priv->rtllib->pairwise_key_type) { + case KEY_TYPE_WEP40: + case KEY_TYPE_WEP104: + pdesc->SecType = 0x1; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_TKIP: + pdesc->SecType = 0x2; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_CCMP: + pdesc->SecType = 0x3; + pdesc->NoEnc = 0; + break; + case KEY_TYPE_NA: + pdesc->SecType = 0x0; + pdesc->NoEnc = 1; + break; + } + } - pdesc->PktId = 0x0; + pdesc->PktId = 0x0; - pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(cb_desc->queue_index, cb_desc->priority); - pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); + pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue( + cb_desc->queue_index, + cb_desc->priority); + pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci); - pdesc->DISFB = cb_desc->bTxDisableRateFallBack; - pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; + pdesc->DISFB = cb_desc->bTxDisableRateFallBack; + pdesc->USERATE = cb_desc->bTxUseDriverAssingedRate; - pdesc->FirstSeg =1; - pdesc->LastSeg = 1; - pdesc->TxBufferSize = skb->len; + pdesc->FirstSeg = 1; + pdesc->LastSeg = 1; + pdesc->TxBufferSize = skb->len; - pdesc->TxBuffAddr = cpu_to_le32(mapping); + pdesc->TxBuffAddr = cpu_to_le32(mapping); } -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - struct cb_desc *cb_desc, struct sk_buff* skb) +void rtl8192_tx_fill_cmd_desc(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, struct sk_buff* skb) { - struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + struct r8192_priv *priv = rtllib_priv(dev); + dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); - memset(entry,0,12); - entry->LINIP = cb_desc->bLastIniPkt; - entry->FirstSeg = 1; - entry->LastSeg = 1; - if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { - entry->CmdInit = DESC_PACKET_TYPE_INIT; - } else { - struct tx_desc * entry_tmp = (struct tx_desc *)entry; - entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; - entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; - entry_tmp->PktSize = (u16)(cb_desc->pkt_size + entry_tmp->Offset); - entry_tmp->QueueSelect = QSLT_CMD; - entry_tmp->TxFWInfoSize = 0x08; - entry_tmp->RATid = (u8)DESC_PACKET_TYPE_INIT; - } - entry->TxBufferSize = skb->len; - entry->TxBuffAddr = cpu_to_le32(mapping); - entry->OWN = 1; + memset(entry, 0, 12); + entry->LINIP = cb_desc->bLastIniPkt; + entry->FirstSeg = 1; + entry->LastSeg = 1; + if (cb_desc->bCmdOrInit == DESC_PACKET_TYPE_INIT) { + entry->CmdInit = DESC_PACKET_TYPE_INIT; + } else { + struct tx_desc * entry_tmp = (struct tx_desc *)entry; + entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL; + entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; + entry_tmp->PktSize = (u16)(cb_desc->pkt_size + + entry_tmp->Offset); + entry_tmp->QueueSelect = QSLT_CMD; + entry_tmp->TxFWInfoSize = 0x08; + entry_tmp->RATid = (u8)DESC_PACKET_TYPE_INIT; + } + entry->TxBufferSize = skb->len; + entry->TxBuffAddr = cpu_to_le32(mapping); + entry->OWN = 1; } u8 HwRateToMRate90(bool bIsHT, u8 rate) @@ -1288,156 +1307,193 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate) if (!bIsHT) { switch (rate) { - case DESC90_RATE1M: ret_rate = MGN_1M; break; - case DESC90_RATE2M: ret_rate = MGN_2M; break; - case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break; - case DESC90_RATE11M: ret_rate = MGN_11M; break; - case DESC90_RATE6M: ret_rate = MGN_6M; break; - case DESC90_RATE9M: ret_rate = MGN_9M; break; - case DESC90_RATE12M: ret_rate = MGN_12M; break; - case DESC90_RATE18M: ret_rate = MGN_18M; break; - case DESC90_RATE24M: ret_rate = MGN_24M; break; - case DESC90_RATE36M: ret_rate = MGN_36M; break; - case DESC90_RATE48M: ret_rate = MGN_48M; break; - case DESC90_RATE54M: ret_rate = MGN_54M; break; + case DESC90_RATE1M: + ret_rate = MGN_1M; + break; + case DESC90_RATE2M: + ret_rate = MGN_2M; + break; + case DESC90_RATE5_5M: + ret_rate = MGN_5_5M; + break; + case DESC90_RATE11M: + ret_rate = MGN_11M; + break; + case DESC90_RATE6M: + ret_rate = MGN_6M; + break; + case DESC90_RATE9M: + ret_rate = MGN_9M; + break; + case DESC90_RATE12M: + ret_rate = MGN_12M; + break; + case DESC90_RATE18M: + ret_rate = MGN_18M; + break; + case DESC90_RATE24M: + ret_rate = MGN_24M; + break; + case DESC90_RATE36M: + ret_rate = MGN_36M; + break; + case DESC90_RATE48M: + ret_rate = MGN_48M; + break; + case DESC90_RATE54M: + ret_rate = MGN_54M; + break; - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported" + "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; } } else { switch (rate) { - case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break; - case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break; - case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break; - case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break; - case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break; - case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break; - case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break; - case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break; - case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break; - case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break; - case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break; - case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break; - case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break; - case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break; - case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break; - case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break; - case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break; + case DESC90_RATEMCS0: + ret_rate = MGN_MCS0; + break; + case DESC90_RATEMCS1: + ret_rate = MGN_MCS1; + break; + case DESC90_RATEMCS2: + ret_rate = MGN_MCS2; + break; + case DESC90_RATEMCS3: + ret_rate = MGN_MCS3; + break; + case DESC90_RATEMCS4: + ret_rate = MGN_MCS4; + break; + case DESC90_RATEMCS5: + ret_rate = MGN_MCS5; + break; + case DESC90_RATEMCS6: + ret_rate = MGN_MCS6; + break; + case DESC90_RATEMCS7: + ret_rate = MGN_MCS7; + break; + case DESC90_RATEMCS8: + ret_rate = MGN_MCS8; + break; + case DESC90_RATEMCS9: + ret_rate = MGN_MCS9; + break; + case DESC90_RATEMCS10: + ret_rate = MGN_MCS10; + break; + case DESC90_RATEMCS11: + ret_rate = MGN_MCS11; + break; + case DESC90_RATEMCS12: + ret_rate = MGN_MCS12; + break; + case DESC90_RATEMCS13: + ret_rate = MGN_MCS13; + break; + case DESC90_RATEMCS14: + ret_rate = MGN_MCS14; + break; + case DESC90_RATEMCS15: + ret_rate = MGN_MCS15; + break; + case DESC90_RATEMCS32: + ret_rate = (0x80|0x20); + break; - default: - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT); - break; + default: + RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported " + "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); + break; } } return ret_rate; } -long -rtl8192_signal_scale_mapping(struct r8192_priv * priv, - long currsig - ) +long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) { long retsig; if (currsig >= 61 && currsig <= 100) - { retsig = 90 + ((currsig - 60) / 4); - } else if (currsig >= 41 && currsig <= 60) - { retsig = 78 + ((currsig - 40) / 2); - } else if (currsig >= 31 && currsig <= 40) - { retsig = 66 + (currsig - 30); - } else if (currsig >= 21 && currsig <= 30) - { retsig = 54 + (currsig - 20); - } else if (currsig >= 5 && currsig <= 20) - { retsig = 42 + (((currsig - 5) * 2) / 3); - } else if (currsig == 4) - { retsig = 36; - } else if (currsig == 3) - { retsig = 27; - } else if (currsig == 2) - { retsig = 18; - } else if (currsig == 1) - { retsig = 9; - } else - { retsig = currsig; - } return retsig; } -#define rx_hal_is_cck_rate(_pdrvinfo)\ - (_pdrvinfo->RxRate == DESC90_RATE1M ||\ +#define rx_hal_is_cck_rate(_pdrvinfo)\ + ((_pdrvinfo->RxRate == DESC90_RATE1M ||\ _pdrvinfo->RxRate == DESC90_RATE2M ||\ _pdrvinfo->RxRate == DESC90_RATE5_5M ||\ _pdrvinfo->RxRate == DESC90_RATE11M) &&\ - !_pdrvinfo->RxHT + !_pdrvinfo->RxHT) + void rtl8192_query_rxphystatus( - struct r8192_priv * priv, - struct rtllib_rx_stats * pstats, + struct r8192_priv *priv, + struct rtllib_rx_stats *pstats, struct rx_desc *pdesc, struct rx_fwinfo *pdrvinfo, - struct rtllib_rx_stats * precord_stats, + struct rtllib_rx_stats *precord_stats, bool bpacket_match_bssid, bool bpacket_toself, bool bPacketBeacon, bool bToSelfBA ) { - struct phy_sts_ofdm_819xpci* pofdm_buf; - struct phy_sts_cck_819xpci * pcck_buf; - struct phy_ofdm_rx_status_rxsc_sgien_exintfflag * prxsc; - u8 *prxpkt; - u8 i,max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; - char rx_pwr[4], rx_pwr_all=0; - char rx_snrX, rx_evmX; - u8 evm, pwdb_all; - u32 RSSI, total_rssi=0; - u8 is_cck_rate=0; - u8 rf_rx_num = 0; - - static u8 check_reg824 = 0; - static u32 reg824_bit9 = 0; + struct phy_sts_ofdm_819xpci *pofdm_buf; + struct phy_sts_cck_819xpci *pcck_buf; + struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc; + u8 *prxpkt; + u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; + char rx_pwr[4], rx_pwr_all = 0; + char rx_snrX, rx_evmX; + u8 evm, pwdb_all; + u32 RSSI, total_rssi = 0; + u8 is_cck_rate = 0; + u8 rf_rx_num = 0; + static u8 check_reg824; + static u32 reg824_bit9; priv->stats.numqry_phystatus++; - is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); memset(precord_stats, 0, sizeof(struct rtllib_rx_stats)); - pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; + pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = + bpacket_match_bssid; pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate; pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA; - if (check_reg824 == 0) - { - reg824_bit9 = rtl8192_QueryBBReg(priv->rtllib->dev, rFPGA0_XA_HSSIParameter2, 0x200); + if (check_reg824 == 0) { + reg824_bit9 = rtl8192_QueryBBReg(priv->rtllib->dev, + rFPGA0_XA_HSSIParameter2, 0x200); check_reg824 = 1; } - prxpkt = (u8*)pdrvinfo; + prxpkt = (u8 *)pdrvinfo; prxpkt += sizeof(struct rx_fwinfo); @@ -1449,50 +1505,54 @@ void rtl8192_query_rxphystatus( precord_stats->RxMIMOSignalQuality[0] = -1; precord_stats->RxMIMOSignalQuality[1] = -1; - if (is_cck_rate) - { - + if (is_cck_rate) { u8 report; priv->stats.numqry_phystatusCCK++; - if (!reg824_bit9) - { + if (!reg824_bit9) { report = pcck_buf->cck_agc_rpt & 0xc0; report = report>>6; - switch (report) - { - case 0x3: - rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x2: - rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x1: - rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e); - break; - case 0x0: - rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); - break; + switch (report) { + case 0x3: + rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x2: + rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x1: + rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & + 0x3e); + break; + case 0x0: + rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e); + break; } - } - else - { + } else { report = pcck_buf->cck_agc_rpt & 0x60; report = report>>5; - switch (report) - { - case 0x3: - rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x2: - rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); - break; - case 0x1: - rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x0: - rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ; - break; + switch (report) { + case 0x3: + rx_pwr_all = -35 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x2: + rx_pwr_all = -23 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x1: + rx_pwr_all = -11 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; + case 0x0: + rx_pwr_all = -8 - + ((pcck_buf->cck_agc_rpt & + 0x1f) << 1); + break; } } @@ -1500,15 +1560,12 @@ void rtl8192_query_rxphystatus( pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RecvSignalPower = rx_pwr_all; - if (bpacket_match_bssid) - { + if (bpacket_match_bssid) { u8 sq; - if (pstats->RxPWDBAll > 40) - { + if (pstats->RxPWDBAll > 40) { sq = 100; - }else - { + } else { sq = pcck_buf->sq_rpt; if (pcck_buf->sq_rpt > 64) @@ -1518,20 +1575,21 @@ void rtl8192_query_rxphystatus( else sq = ((64-sq) * 100) / 44; } - pstats->SignalQuality = precord_stats->SignalQuality = sq; - pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; - pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; + pstats->SignalQuality = sq; + precord_stats->SignalQuality = sq; + pstats->RxMIMOSignalQuality[0] = sq; + precord_stats->RxMIMOSignalQuality[0] = sq; + pstats->RxMIMOSignalQuality[1] = -1; + precord_stats->RxMIMOSignalQuality[1] = -1; } - } - else - { + } else { priv->stats.numqry_phystatusHT++; - for (i=RF90_PATH_A; ibrfpath_rxenable[i]) rf_rx_num++; - rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 110; + rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i] & 0x3F) * + 2) - 110; tmp_rxsnr = pofdm_buf->rxsnr_X[i]; rx_snrX = (char)(tmp_rxsnr); @@ -1542,284 +1600,294 @@ void rtl8192_query_rxphystatus( if (priv->brfpath_rxenable[i]) total_rssi += RSSI; - if (bpacket_match_bssid) - { - pstats->RxMIMOSignalStrength[i] =(u8) RSSI; - precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI; + if (bpacket_match_bssid) { + pstats->RxMIMOSignalStrength[i] = (u8) RSSI; + precord_stats->RxMIMOSignalStrength[i] = + (u8) RSSI; } } - rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106; + rx_pwr_all = (((pofdm_buf->pwdb_all) >> 1) & 0x7f) - 106; pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RxPower = precord_stats->RxPower = rx_pwr_all; pstats->RecvSignalPower = rx_pwr_all; - if (pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 && - pdrvinfo->RxRate<=DESC90_RATEMCS15) + if (pdrvinfo->RxHT && pdrvinfo->RxRate >= DESC90_RATEMCS8 && + pdrvinfo->RxRate <= DESC90_RATEMCS15) max_spatial_stream = 2; else max_spatial_stream = 1; - for (i=0; irxevm_X[i]; rx_evmX = (char)(tmp_rxevm); rx_evmX /= 2; evm = rtl819x_evm_dbtopercentage(rx_evmX); - if (bpacket_match_bssid) - { - if (i==0) - pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); - pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); + if (bpacket_match_bssid) { + if (i == 0) { + pstats->SignalQuality = (u8)(evm & + 0xff); + precord_stats->SignalQuality = (u8)(evm + & 0xff); + } + pstats->RxMIMOSignalQuality[i] = (u8)(evm & + 0xff); + precord_stats->RxMIMOSignalQuality[i] = (u8)(evm + & 0xff); } } rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; + prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *) + &rxsc_sgien_exflg; if (pdrvinfo->BW) priv->stats.received_bwtype[1+prxsc->rxsc]++; else priv->stats.received_bwtype[0]++; } - if (is_cck_rate) - { - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)pwdb_all)); + if (is_cck_rate) { + pstats->SignalStrength = precord_stats->SignalStrength = + (u8)(rtl8192_signal_scale_mapping(priv, + (long)pwdb_all)); - } - else - { + } else { if (rf_rx_num != 0) - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl8192_signal_scale_mapping(priv,(long)(total_rssi/=rf_rx_num))); + pstats->SignalStrength = precord_stats->SignalStrength = + (u8)(rtl8192_signal_scale_mapping(priv, + (long)(total_rssi /= rf_rx_num))); } } -void rtl8192_process_phyinfo(struct r8192_priv * priv, u8 *buffer,struct rtllib_rx_stats * pprevious_stats, struct rtllib_rx_stats * pcurrent_stats) +void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, + struct rtllib_rx_stats *prev_st, + struct rtllib_rx_stats *curr_st) { bool bcheck = false; u8 rfpath; - u32 nspatial_stream, tmp_val; - static u32 slide_rssi_index=0, slide_rssi_statistics=0; - static u32 slide_evm_index=0, slide_evm_statistics=0; - static u32 last_rssi=0, last_evm=0; - static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0; - static u32 last_beacon_adc_pwdb=0; - + u32 ij, tmp_val; + static u32 slide_rssi_index, slide_rssi_statistics; + static u32 slide_evm_index, slide_evm_statistics; + static u32 last_rssi, last_evm; + static u32 slide_beacon_adc_pwdb_index; + static u32 slide_beacon_adc_pwdb_statistics; + static u32 last_beacon_adc_pwdb; struct rtllib_hdr_3addr *hdr; - u16 sc ; - unsigned int frag,seq; + u16 sc; + unsigned int frag, seq; + hdr = (struct rtllib_hdr_3addr *)buffer; sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); seq = WLAN_GET_SEQ_SEQ(sc); - pcurrent_stats->Seq_Num = seq; - if (!pprevious_stats->bIsAMPDU) + curr_st->Seq_Num = seq; + if (!prev_st->bIsAMPDU) bcheck = true; - if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) - { + if (slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX; last_rssi = priv->stats.slide_signal_strength[slide_rssi_index]; priv->stats.slide_rssi_total -= last_rssi; } - priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; + priv->stats.slide_rssi_total += prev_st->SignalStrength; - priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; + priv->stats.slide_signal_strength[slide_rssi_index++] = + prev_st->SignalStrength; if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) slide_rssi_index = 0; tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; - priv->stats.signal_strength = rtl819x_translate_todbm(priv, (u8)tmp_val); - pcurrent_stats->rssi = priv->stats.signal_strength; - if (!pprevious_stats->bPacketMatchBSSID) - { - if (!pprevious_stats->bToSelfBA) + priv->stats.signal_strength = rtl819x_translate_todbm(priv, + (u8)tmp_val); + curr_st->rssi = priv->stats.signal_strength; + if (!prev_st->bPacketMatchBSSID) { + if (!prev_st->bToSelfBA) return; } if (!bcheck) return; - rtl819x_process_cck_rxpathsel(priv,pprevious_stats); + rtl819x_process_cck_rxpathsel(priv, prev_st); priv->stats.num_process_phyinfo++; - if (!pprevious_stats->bIsCCK && pprevious_stats->bPacketToSelf) - { - for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) - { - if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev, rfpath)) + if (!prev_st->bIsCCK && prev_st->bPacketToSelf) { + for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) { + if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev, + rfpath)) continue; - RT_TRACE(COMP_DBG,"Jacken -> pPreviousstats->RxMIMOSignalStrength[rfpath] = %d \n" ,pprevious_stats->RxMIMOSignalStrength[rfpath] ); - if (priv->stats.rx_rssi_percentage[rfpath] == 0) - { - priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; - } - if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) - { + RT_TRACE(COMP_DBG, "Jacken -> pPreviousstats->RxMIMO" + "SignalStrength[rfpath] = %d\n", + prev_st->RxMIMOSignalStrength[rfpath]); + if (priv->stats.rx_rssi_percentage[rfpath] == 0) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); - priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; + prev_st->RxMIMOSignalStrength[rfpath]; } - else - { + if (prev_st->RxMIMOSignalStrength[rfpath] > + priv->stats.rx_rssi_percentage[rfpath]) { priv->stats.rx_rssi_percentage[rfpath] = - ( (priv->stats.rx_rssi_percentage[rfpath]*(RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(RX_SMOOTH); + ((priv->stats.rx_rssi_percentage[rfpath] + * (RX_SMOOTH - 1)) + + (prev_st->RxMIMOSignalStrength + [rfpath])) / (RX_SMOOTH); + priv->stats.rx_rssi_percentage[rfpath] = + priv->stats.rx_rssi_percentage[rfpath] + + 1; + } else { + priv->stats.rx_rssi_percentage[rfpath] = + ((priv->stats.rx_rssi_percentage[rfpath] * + (RX_SMOOTH-1)) + + (prev_st->RxMIMOSignalStrength[rfpath])) / + (RX_SMOOTH); } - RT_TRACE(COMP_DBG,"Jacken -> priv->RxStats.RxRSSIPercentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] ); + RT_TRACE(COMP_DBG, "Jacken -> priv->RxStats.RxRSSI" + "Percentage[rfPath] = %d\n", + priv->stats.rx_rssi_percentage[rfpath]); } } - if (pprevious_stats->bPacketBeacon) - { - if (slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX) - { - slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; - last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index]; + if (prev_st->bPacketBeacon) { + if (slide_beacon_adc_pwdb_statistics++ >= + PHY_Beacon_RSSI_SLID_WIN_MAX) { + slide_beacon_adc_pwdb_statistics = + PHY_Beacon_RSSI_SLID_WIN_MAX; + last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb + [slide_beacon_adc_pwdb_index]; priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; } - priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll; - priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll; + priv->stats.Slide_Beacon_Total += prev_st->RxPWDBAll; + priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = + prev_st->RxPWDBAll; slide_beacon_adc_pwdb_index++; if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) slide_beacon_adc_pwdb_index = 0; - pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; - if (pprevious_stats->RxPWDBAll >= 3) - pprevious_stats->RxPWDBAll -= 3; + prev_st->RxPWDBAll = priv->stats.Slide_Beacon_Total / + slide_beacon_adc_pwdb_statistics; + if (prev_st->RxPWDBAll >= 3) + prev_st->RxPWDBAll -= 3; } RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", - pprevious_stats->bIsCCK? "CCK": "OFDM", - pprevious_stats->RxPWDBAll); + prev_st->bIsCCK ? "CCK" : "OFDM", + prev_st->RxPWDBAll); - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { + if (prev_st->bPacketToSelf || prev_st->bPacketBeacon || + prev_st->bToSelfBA) { if (priv->undecorated_smoothed_pwdb < 0) - { - priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; - } - if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) - { + priv->undecorated_smoothed_pwdb = prev_st->RxPWDBAll; + if (prev_st->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) { priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + - (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); - priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; - } - else - { + (((priv->undecorated_smoothed_pwdb) * + (RX_SMOOTH-1)) + + (prev_st->RxPWDBAll)) / (RX_SMOOTH); priv->undecorated_smoothed_pwdb = - ( ((priv->undecorated_smoothed_pwdb)*(RX_SMOOTH-1)) + - (pprevious_stats->RxPWDBAll)) /(RX_SMOOTH); + priv->undecorated_smoothed_pwdb + 1; + } else { + priv->undecorated_smoothed_pwdb = + (((priv->undecorated_smoothed_pwdb) * + (RX_SMOOTH-1)) + + (prev_st->RxPWDBAll)) / (RX_SMOOTH); } - rtl819x_update_rxsignalstatistics8190pci(priv,pprevious_stats); + rtl819x_update_rxsignalstatistics8190pci(priv, prev_st); } - if (pprevious_stats->SignalQuality == 0) - { - } - else - { - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){ - if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){ + if (prev_st->SignalQuality != 0) { + if (prev_st->bPacketToSelf || prev_st->bPacketBeacon || + prev_st->bToSelfBA) { + if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; - last_evm = priv->stats.slide_evm[slide_evm_index]; + last_evm = + priv->stats.slide_evm[slide_evm_index]; priv->stats.slide_evm_total -= last_evm; } - priv->stats.slide_evm_total += pprevious_stats->SignalQuality; + priv->stats.slide_evm_total += prev_st->SignalQuality; - priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; + priv->stats.slide_evm[slide_evm_index++] = + prev_st->SignalQuality; if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) slide_evm_index = 0; - tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; + tmp_val = priv->stats.slide_evm_total / + slide_evm_statistics; priv->stats.signal_quality = tmp_val; priv->stats.last_signal_strength_inpercent = tmp_val; } - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) - { - for (nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) - { - if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) - { - if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) - { - priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; - } - priv->stats.rx_evm_percentage[nspatial_stream] = - ( (priv->stats.rx_evm_percentage[nspatial_stream]* (RX_SMOOTH-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (RX_SMOOTH); + if (prev_st->bPacketToSelf || + prev_st->bPacketBeacon || + prev_st->bToSelfBA) { + for (ij = 0; ij < 2; ij++) { + if (prev_st->RxMIMOSignalQuality[ij] != -1) { + if (priv->stats.rx_evm_percentage[ij] == 0) + priv->stats.rx_evm_percentage[ij] = + prev_st->RxMIMOSignalQuality[ij]; + priv->stats.rx_evm_percentage[ij] = + ((priv->stats.rx_evm_percentage[ij] * + (RX_SMOOTH - 1)) + + (prev_st->RxMIMOSignalQuality[ij])) / + (RX_SMOOTH); } } } } - } - -void rtl8192_TranslateRxSignalStuff(struct net_device *dev, - struct sk_buff *skb, - struct rtllib_rx_stats * pstats, - struct rx_desc *pdesc, - struct rx_fwinfo *pdrvinfo) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - bool bpacket_match_bssid, bpacket_toself; - bool bPacketBeacon=false; - struct rtllib_hdr_3addr *hdr; - bool bToSelfBA=false; - static struct rtllib_rx_stats previous_stats; - u16 fc,type; - - - u8* tmp_buf; - u8 *praddr; - - tmp_buf = skb->data + pstats->RxDrvInfoSize + pstats->RxBufShift; - - hdr = (struct rtllib_hdr_3addr *)tmp_buf; - fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); - praddr = hdr->addr1; - - bpacket_match_bssid = ((RTLLIB_FTYPE_CTL != type) && - (!compare_ether_addr(priv->rtllib->current_network.bssid, - (fc & RTLLIB_FCTL_TODS)? hdr->addr1 : - (fc & RTLLIB_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) - && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & (!compare_ether_addr(praddr, priv->rtllib->dev->dev_addr)); - if (WLAN_FC_GET_FRAMETYPE(fc)== RTLLIB_STYPE_BEACON) - { - bPacketBeacon = true; - } - if (bpacket_match_bssid) - { - priv->stats.numpacket_matchbssid++; - } - if (bpacket_toself){ - priv->stats.numpacket_toself++; - } - rtl8192_process_phyinfo(priv, tmp_buf,&previous_stats, pstats); - rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &previous_stats, bpacket_match_bssid, - bpacket_toself ,bPacketBeacon, bToSelfBA); - rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); -} - -void rtl8192_UpdateReceivedRateHistogramStatistics( - struct net_device *dev, - struct rtllib_rx_stats* pstats - ) +void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, + struct rtllib_rx_stats *pstats, + struct rx_desc *pdesc, + struct rx_fwinfo *pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 rcvType=1; + bool bpacket_match_bssid, bpacket_toself; + bool bPacketBeacon = false; + struct rtllib_hdr_3addr *hdr; + bool bToSelfBA = false; + static struct rtllib_rx_stats previous_stats; + u16 fc, type; + u8 *tmp_buf; + u8 *praddr; + + tmp_buf = skb->data + pstats->RxDrvInfoSize + pstats->RxBufShift; + + hdr = (struct rtllib_hdr_3addr *)tmp_buf; + fc = le16_to_cpu(hdr->frame_ctl); + type = WLAN_FC_GET_TYPE(fc); + praddr = hdr->addr1; + + bpacket_match_bssid = ((RTLLIB_FTYPE_CTL != type) && + (!compare_ether_addr(priv->rtllib-> + current_network.bssid, + (fc & RTLLIB_FCTL_TODS) ? hdr->addr1 : + (fc & RTLLIB_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) + && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV)); + bpacket_toself = bpacket_match_bssid & + (!compare_ether_addr(praddr, + priv->rtllib->dev->dev_addr)); + if (WLAN_FC_GET_FRAMETYPE(fc) == RTLLIB_STYPE_BEACON) + bPacketBeacon = true; + if (bpacket_match_bssid) + priv->stats.numpacket_matchbssid++; + if (bpacket_toself) + priv->stats.numpacket_toself++; + rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats); + rtl8192_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, + &previous_stats, bpacket_match_bssid, + bpacket_toself, bPacketBeacon, bToSelfBA); + rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); +} + +void rtl8192_UpdateReceivedRateHistogramStatistics(struct net_device *dev, + struct rtllib_rx_stats *pstats) +{ + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 rcvType = 1; u32 rateIndex; u32 preamble_guardinterval; @@ -1833,45 +1901,104 @@ void rtl8192_UpdateReceivedRateHistogramStatistics( else preamble_guardinterval = 0; - switch (pstats->rate) - { - case MGN_1M: rateIndex = 0; break; - case MGN_2M: rateIndex = 1; break; - case MGN_5_5M: rateIndex = 2; break; - case MGN_11M: rateIndex = 3; break; - case MGN_6M: rateIndex = 4; break; - case MGN_9M: rateIndex = 5; break; - case MGN_12M: rateIndex = 6; break; - case MGN_18M: rateIndex = 7; break; - case MGN_24M: rateIndex = 8; break; - case MGN_36M: rateIndex = 9; break; - case MGN_48M: rateIndex = 10; break; - case MGN_54M: rateIndex = 11; break; - case MGN_MCS0: rateIndex = 12; break; - case MGN_MCS1: rateIndex = 13; break; - case MGN_MCS2: rateIndex = 14; break; - case MGN_MCS3: rateIndex = 15; break; - case MGN_MCS4: rateIndex = 16; break; - case MGN_MCS5: rateIndex = 17; break; - case MGN_MCS6: rateIndex = 18; break; - case MGN_MCS7: rateIndex = 19; break; - case MGN_MCS8: rateIndex = 20; break; - case MGN_MCS9: rateIndex = 21; break; - case MGN_MCS10: rateIndex = 22; break; - case MGN_MCS11: rateIndex = 23; break; - case MGN_MCS12: rateIndex = 24; break; - case MGN_MCS13: rateIndex = 25; break; - case MGN_MCS14: rateIndex = 26; break; - case MGN_MCS15: rateIndex = 27; break; - default: rateIndex = 28; break; + switch (pstats->rate) { + case MGN_1M: + rateIndex = 0; + break; + case MGN_2M: + rateIndex = 1; + break; + case MGN_5_5M: + rateIndex = 2; + break; + case MGN_11M: + rateIndex = 3; + break; + case MGN_6M: + rateIndex = 4; + break; + case MGN_9M: + rateIndex = 5; + break; + case MGN_12M: + rateIndex = 6; + break; + case MGN_18M: + rateIndex = 7; + break; + case MGN_24M: + rateIndex = 8; + break; + case MGN_36M: + rateIndex = 9; + break; + case MGN_48M: + rateIndex = 10; + break; + case MGN_54M: + rateIndex = 11; + break; + case MGN_MCS0: + rateIndex = 12; + break; + case MGN_MCS1: + rateIndex = 13; + break; + case MGN_MCS2: + rateIndex = 14; + break; + case MGN_MCS3: + rateIndex = 15; + break; + case MGN_MCS4: + rateIndex = 16; + break; + case MGN_MCS5: + rateIndex = 17; + break; + case MGN_MCS6: + rateIndex = 18; + break; + case MGN_MCS7: + rateIndex = 19; + break; + case MGN_MCS8: + rateIndex = 20; + break; + case MGN_MCS9: + rateIndex = 21; + break; + case MGN_MCS10: + rateIndex = 22; + break; + case MGN_MCS11: + rateIndex = 23; + break; + case MGN_MCS12: + rateIndex = 24; + break; + case MGN_MCS13: + rateIndex = 25; + break; + case MGN_MCS14: + rateIndex = 26; + break; + case MGN_MCS15: + rateIndex = 27; + break; + default: + rateIndex = 28; + break; } priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++; priv->stats.received_rate_histogram[0][rateIndex]++; priv->stats.received_rate_histogram[rcvType][rateIndex]++; } -bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats* stats, - struct rx_desc *pdesc, struct sk_buff* skb) +bool rtl8192_rx_query_status_desc(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1887,9 +2014,9 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats stats->bShift = false; if (pdesc->CRC32) { - if (pdesc->Length <500) + if (pdesc->Length < 500) priv->stats.rxcrcerrmin++; - else if (pdesc->Length >1000) + else if (pdesc->Length > 1000) priv->stats.rxcrcerrmax++; else priv->stats.rxcrcerrmid++; @@ -1903,13 +2030,15 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats pDrvInfo = (struct rx_fwinfo *)(skb->data + stats->RxBufShift); - stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, (u8)pDrvInfo->RxRate); + stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT, + (u8)pDrvInfo->RxRate); stats->bShortPreamble = pDrvInfo->SPLCP; rtl8192_UpdateReceivedRateHistogramStatistics(dev, stats); - stats->bIsAMPDU = (pDrvInfo->PartAggr==1); - stats->bFirstMPDU = (pDrvInfo->PartAggr==1) && (pDrvInfo->FirstAGGR==1); + stats->bIsAMPDU = (pDrvInfo->PartAggr == 1); + stats->bFirstMPDU = (pDrvInfo->PartAggr == 1) && + (pDrvInfo->FirstAGGR == 1); stats->TimeStampLow = pDrvInfo->TSFL; stats->TimeStampHigh = read_nic_dword(dev, TSFR+4); @@ -1921,11 +2050,13 @@ bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats stats->RxIs40MHzPacket = pDrvInfo->BW; - rtl8192_TranslateRxSignalStuff(dev,skb, stats, pdesc, pDrvInfo); + rtl8192_TranslateRxSignalStuff(dev, skb, stats, pdesc, + pDrvInfo); - if (pDrvInfo->FirstAGGR==1 || pDrvInfo->PartAggr == 1) - RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n", - pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); + if (pDrvInfo->FirstAGGR == 1 || pDrvInfo->PartAggr == 1) + RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d," + " pDrvInfo->PartAggr = %d\n", + pDrvInfo->FirstAGGR, pDrvInfo->PartAggr); skb_trim(skb, skb->len - 4/*sCrcLng*/); @@ -1948,36 +2079,24 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) OpMode = RT_OP_MODE_NO_LINK; priv->rtllib->SetHwRegHandler(dev, HW_VAR_MEDIA_STATUS, &OpMode); -#if 1 - if (!priv->rtllib->bSupportRemoteWakeUp) - { + if (!priv->rtllib->bSupportRemoteWakeUp) { u1bTmp = 0x0; write_nic_byte(dev, CMDR, u1bTmp); } -#else - cmd=read_nic_byte(dev,CMDR); - write_nic_byte(dev, CMDR, cmd &~ (CR_TE|CR_RE)); -#endif mdelay(20); - if (!reset) - { + if (!reset) { mdelay(150); priv->bHwRfOffAction = 2; - if (!priv->rtllib->bSupportRemoteWakeUp) - { - { - PHY_SetRtl8192eRfOff(dev); - } - ulRegRead = read_nic_dword(dev,CPU_GEN); - ulRegRead|=CPU_GEN_SYSTEM_RESET; - write_nic_dword(dev,CPU_GEN, ulRegRead); - } - else - { + if (!priv->rtllib->bSupportRemoteWakeUp) { + PHY_SetRtl8192eRfOff(dev); + ulRegRead = read_nic_dword(dev, CPU_GEN); + ulRegRead |= CPU_GEN_SYSTEM_RESET; + write_nic_dword(dev, CPU_GEN, ulRegRead); + } else { write_nic_dword(dev, WFCRC0, 0xffffffff); write_nic_dword(dev, WFCRC1, 0xffffffff); write_nic_dword(dev, WFCRC2, 0xffffffff); @@ -1988,59 +2107,57 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset) } } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->rtllib->skb_waitQ [i]); - } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_purge(&priv->rtllib->skb_aggQ [i]); - } + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_purge(&priv->rtllib->skb_waitQ[i]); + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_purge(&priv->rtllib->skb_aggQ[i]); skb_queue_purge(&priv->skb_queue); return; } -void rtl8192_update_ratr_table(struct net_device* dev) +void rtl8192_update_ratr_table(struct net_device *dev) { - struct r8192_priv * priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; - u8* pMcsRate = ieee->dot11HTOperationalRateSet; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + u8 *pMcsRate = ieee->dot11HTOperationalRateSet; u32 ratr_value = 0; u8 rate_index = 0; - rtl8192_config_rate(dev, (u16*)(&ratr_value)); - ratr_value |= (*(u16*)(pMcsRate)) << 12; - switch (ieee->mode) - { - case IEEE_A: - ratr_value &= 0x00000FF0; - break; - case IEEE_B: - ratr_value &= 0x0000000F; - break; - case IEEE_G: - case IEEE_G|IEEE_B: - ratr_value &= 0x00000FF7; - break; - case IEEE_N_24G: - case IEEE_N_5G: - if (ieee->pHTInfo->PeerMimoPs == 0) - ratr_value &= 0x0007F007; - else{ - if (priv->rf_type == RF_1T2R) - ratr_value &= 0x000FF007; - else - ratr_value &= 0x0F81F007; - } - break; - default: - break; + rtl8192_config_rate(dev, (u16 *)(&ratr_value)); + ratr_value |= (*(u16 *)(pMcsRate)) << 12; + switch (ieee->mode) { + case IEEE_A: + ratr_value &= 0x00000FF0; + break; + case IEEE_B: + ratr_value &= 0x0000000F; + break; + case IEEE_G: + case IEEE_G|IEEE_B: + ratr_value &= 0x00000FF7; + break; + case IEEE_N_24G: + case IEEE_N_5G: + if (ieee->pHTInfo->PeerMimoPs == 0) { + ratr_value &= 0x0007F007; + } else { + if (priv->rf_type == RF_1T2R) + ratr_value &= 0x000FF007; + else + ratr_value &= 0x0F81F007; + } + break; + default: + break; } ratr_value &= 0x0FFFFFFF; - if (ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){ + if (ieee->pHTInfo->bCurTxBW40MHz && + ieee->pHTInfo->bCurShortGI40MHz) ratr_value |= 0x80000000; - }else if (!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){ + else if (!ieee->pHTInfo->bCurTxBW40MHz && + ieee->pHTInfo->bCurShortGI20MHz) ratr_value |= 0x80000000; - } write_nic_dword(dev, RATR0+rate_index*4, ratr_value); write_nic_byte(dev, UFWP, 1); } @@ -2077,17 +2194,19 @@ rtl8192_InitializeVariables(struct net_device *dev) RCR_AAP | ((u32)7<irq_mask[0] = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK |\ - IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK |\ - IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW |\ - IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); + priv->irq_mask[0] = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | + IMR_BEDOK | IMR_BKDOK | IMR_HCCADOK | + IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | + IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | + IMR_RDU | IMR_RXFOVW | IMR_TXFOVW | + IMR_BcnInt | IMR_TBDOK | IMR_TBDER); priv->MidHighPwrTHR_L1 = 0x3B; priv->MidHighPwrTHR_L2 = 0x40; priv->PwrDomainProtect = false; - priv->bfirst_after_down = 0; + priv->bfirst_after_down = 0; } void rtl8192_EnableInterrupt(struct net_device *dev) @@ -2095,7 +2214,7 @@ void rtl8192_EnableInterrupt(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->irq_enabled = 1; - write_nic_dword(dev,INTA_MASK, priv->irq_mask[0]); + write_nic_dword(dev, INTA_MASK, priv->irq_mask[0]); } @@ -2103,7 +2222,7 @@ void rtl8192_DisableInterrupt(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - write_nic_dword(dev,INTA_MASK,0); + write_nic_dword(dev, INTA_MASK, 0); priv->irq_enabled = 0; } @@ -2118,18 +2237,21 @@ void rtl8192_ClearInterrupt(struct net_device *dev) void rtl8192_enable_rx(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - write_nic_dword(dev, RDQDA,priv->rx_ring_dma[RX_MPDU_QUEUE]); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + write_nic_dword(dev, RDQDA, priv->rx_ring_dma[RX_MPDU_QUEUE]); } -u32 TX_DESC_BASE[] = {BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA}; +static const u32 TX_DESC_BASE[] = { + BKQDA, BEQDA, VIQDA, VOQDA, HCCAQDA, CQDA, MQDA, HQDA, BQDA +}; + void rtl8192_enable_tx(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 i; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + u32 i; - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - write_nic_dword(dev, TX_DESC_BASE[i], priv->tx_ring[i].dma); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + write_nic_dword(dev, TX_DESC_BASE[i], priv->tx_ring[i].dma); } @@ -2138,16 +2260,17 @@ void rtl8192_beacon_disable(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); u32 reg; - reg = read_nic_dword(priv->rtllib->dev,INTA_MASK); + reg = read_nic_dword(priv->rtllib->dev, INTA_MASK); reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); } -void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, + u32 *p_intb) { - *p_inta = read_nic_dword(dev, ISR) ; - write_nic_dword(dev,ISR,*p_inta); + *p_inta = read_nic_dword(dev, ISR); + write_nic_dword(dev, ISR, *p_inta); } bool rtl8192_HalRxCheckStuck(struct net_device *dev) @@ -2155,61 +2278,56 @@ bool rtl8192_HalRxCheckStuck(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u16 RegRxCounter = read_nic_word(dev, 0x130); bool bStuck = false; - static u8 rx_chk_cnt = 0; + static u8 rx_chk_cnt; u32 SlotIndex = 0, TotalRxStuckCount = 0; u8 i; u8 SilentResetRxSoltNum = 4; - RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n", - __func__, RegRxCounter,priv->RxCounter); + RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d, RxCounter is %d\n", + __func__, RegRxCounter, priv->RxCounter); rx_chk_cnt++; - if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) - { + if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) { rx_chk_cnt = 0; - } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5)) && - (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) || - ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)))) { - if (rx_chk_cnt < 2) { + } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5)) + && (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) + || ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M)))) { + if (rx_chk_cnt < 2) return bStuck; - } else { + else rx_chk_cnt = 0; - } } else if ((((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M)) || ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M))) && priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { - if (rx_chk_cnt < 4) { + if (rx_chk_cnt < 4) return bStuck; - } else { + else rx_chk_cnt = 0; - } } else { - if (rx_chk_cnt < 8) { + if (rx_chk_cnt < 8) return bStuck; - } else { + else rx_chk_cnt = 0; - } } SlotIndex = (priv->SilentResetRxSlotIndex++)%SilentResetRxSoltNum; - if (priv->RxCounter==RegRxCounter) - { + if (priv->RxCounter == RegRxCounter) { priv->SilentResetRxStuckEvent[SlotIndex] = 1; - for ( i = 0; i < SilentResetRxSoltNum ; i++ ) + for (i = 0; i < SilentResetRxSoltNum; i++) TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; - if (TotalRxStuckCount == SilentResetRxSoltNum) - { - bStuck = true; - for ( i = 0; i < SilentResetRxSoltNum ; i++ ) - TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; + if (TotalRxStuckCount == SilentResetRxSoltNum) { + bStuck = true; + for (i = 0; i < SilentResetRxSoltNum; i++) + TotalRxStuckCount += + priv->SilentResetRxStuckEvent[i]; } @@ -2226,10 +2344,10 @@ bool rtl8192_HalTxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool bStuck = false; - u16 RegTxCounter = read_nic_word(dev, 0x128); + u16 RegTxCounter = read_nic_word(dev, 0x128); RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", - __func__,RegTxCounter,priv->TxCounter); + __func__, RegTxCounter, priv->TxCounter); if (priv->TxCounter == RegTxCounter) bStuck = true; @@ -2244,18 +2362,19 @@ bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP|SEC_ALG_TKIP))) { + (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP | + SEC_ALG_TKIP))) { return false; } else { return true; } } -bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev) +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev) { - bool Reval; - struct r8192_priv * priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + bool Reval; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; if (ieee->bHalfWirelessN24GMode == true) Reval = true; @@ -2269,8 +2388,9 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) { u8 tmp_Short; - tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0); - if (TxHT==1 && TxRate != DESC90_RATEMCS15) + tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) : + ((tcb_desc->bUseShortPreamble) ? 1 : 0); + if (TxHT == 1 && TxRate != DESC90_RATEMCS15) tmp_Short = 0; return tmp_Short; @@ -2278,12 +2398,12 @@ u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) void ActUpdateChannelAccessSetting( - struct net_device* dev, + struct net_device *dev, enum wireless_mode WirelessMode, struct channel_access_setting *ChnlAccessSetting ) { - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); return; @@ -2295,7 +2415,8 @@ ActUpdateChannelAccessSetting( else SIFS_Timer = priv->SifsTime; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SIFS, (u8*)&SIFS_Timer); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_SIFS, + (u8 *)&SIFS_Timer); } } From 99a1f99f0f86d84f44bad3f6acefb9077d4740a2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 26 Jul 2011 15:03:23 -0500 Subject: [PATCH 05/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part III Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_dev.h | 30 +- drivers/staging/rtl8192e/r8192E_firmware.c | 154 +-- drivers/staging/rtl8192e/r8192E_firmware.h | 4 +- drivers/staging/rtl8192e/r8192E_hw.h | 76 +- drivers/staging/rtl8192e/r8192E_hwimg.c | 1043 ++++++++++---------- 5 files changed, 667 insertions(+), 640 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/r8192E_dev.h index 4f31307c1fa7..b9b3b52f9120 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/r8192E_dev.h @@ -28,11 +28,12 @@ #include "r8190P_def.h" u8 rtl8192_QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc); -bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device* dev); +bool rtl8192_GetHalfNmodeSupportByAPs(struct net_device *dev); bool rtl8192_GetNmodeSupportBySecCfg(struct net_device *dev); bool rtl8192_HalTxCheckStuck(struct net_device *dev); bool rtl8192_HalRxCheckStuck(struct net_device *dev); -void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb); +void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, + u32 *p_intb); void rtl8192_enable_rx(struct net_device *dev); void rtl8192_enable_tx(struct net_device *dev); void rtl8192_EnableInterrupt(struct net_device *dev); @@ -40,17 +41,22 @@ void rtl8192_DisableInterrupt(struct net_device *dev); void rtl8192_ClearInterrupt(struct net_device *dev); void rtl8192_InitializeVariables(struct net_device *dev); void rtl8192e_start_beacon(struct net_device *dev); -void rtl8192e_SetHwReg(struct net_device *dev,u8 variable,u8* val); -void rtl8192_get_eeprom_size(struct net_device* dev); +void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val); +void rtl8192_get_eeprom_size(struct net_device *dev); bool rtl8192_adapter_start(struct net_device *dev); void rtl8192_link_change(struct net_device *dev); -void rtl8192_AllowAllDestAddr(struct net_device* dev, bool bAllowAllDA, bool WriteIntoReg); -void rtl8192_tx_fill_desc(struct net_device* dev, struct tx_desc * pdesc, struct cb_desc *cb_desc, - struct sk_buff* skb); -void rtl8192_tx_fill_cmd_desc(struct net_device* dev, struct tx_desc_cmd * entry, - struct cb_desc *cb_desc, struct sk_buff* skb); -bool rtl8192_rx_query_status_desc(struct net_device* dev, struct rtllib_rx_stats *stats, - struct rx_desc *pdesc, struct sk_buff* skb); +void rtl8192_AllowAllDestAddr(struct net_device *dev, bool bAllowAllDA, + bool WriteIntoReg); +void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc, + struct cb_desc *cb_desc, + struct sk_buff *skb); +void rtl8192_tx_fill_cmd_desc(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, struct sk_buff *skb); +bool rtl8192_rx_query_status_desc(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb); void rtl8192_halt_adapter(struct net_device *dev, bool reset); -void rtl8192_update_ratr_table(struct net_device* dev); +void rtl8192_update_ratr_table(struct net_device *dev); #endif diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index d284d422b64a..c2689993530f 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -28,10 +28,12 @@ extern void firmware_init_param(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; - pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); + pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD( + MAX_TRANSMIT_BUFFER_SIZE); } -bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len) +bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, + u32 buffer_len) { struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; @@ -59,46 +61,48 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buff } skb = dev_alloc_skb(frag_length + 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastIniPkt; seg_ptr = skb->data; - for (i=0 ; i < frag_length; i+=4) { - *seg_ptr++ = ((i+0)txbuf_size= (u16)i; + tcb_desc->txbuf_size = (u16)i; skb_put(skb, i); - if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->rtllib->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE, "===================> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index])) || + (priv->rtllib->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "===================> tx " + "full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ + [tcb_desc->queue_index], skb); } else { - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); } code_virtual_address += frag_length; frag_offset += frag_length; - }while(frag_offset < buffer_len); + } while (frag_offset < buffer_len); write_nic_byte(dev, TPPoll, TPPoll_CQ); return rt_status; } -bool -fwSendNullPacket( - struct net_device *dev, - u32 Length -) +bool fwSendNullPacket(struct net_device *dev, u32 Length) { bool rtStatus = true; struct r8192_priv *priv = rtllib_priv(dev); @@ -108,23 +112,25 @@ fwSendNullPacket( bool bLastInitPacket = false; - skb = dev_alloc_skb(Length+ 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + skb = dev_alloc_skb(Length + 4); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; tcb_desc->bLastIniPkt = bLastInitPacket; ptr_buf = skb_put(skb, Length); - memset(ptr_buf,0,Length); - tcb_desc->txbuf_size= (u16)Length; + memset(ptr_buf, 0, Length); + tcb_desc->txbuf_size = (u16)Length; - if (!priv->rtllib->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->rtllib->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE,"===================NULL packet================> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], skb); + if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc-> + queue_index])) || (priv->rtllib->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "===================NULL packet========" + "========> tx full!\n"); + skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], + skb); } else { - priv->rtllib->softmac_hard_start_xmit(skb,dev); + priv->rtllib->softmac_hard_start_xmit(skb, dev); } write_nic_byte(dev, TPPoll, TPPoll_CQ); @@ -142,7 +148,7 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status & CPU_GEN_PUT_CODE_OK) break; - msleep(2); + mdelay(2); } if (!(CPU_status&CPU_GEN_PUT_CODE_OK)) { @@ -153,7 +159,8 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) } CPU_status = read_nic_dword(dev, CPU_GEN); - write_nic_byte(dev, CPU_GEN, (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); + write_nic_byte(dev, CPU_GEN, + (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); mdelay(1); timeout = jiffies + MSECS(200); @@ -161,14 +168,13 @@ bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status&CPU_GEN_BOOT_RDY) break; - msleep(2); + mdelay(2); } - if (!(CPU_status&CPU_GEN_BOOT_RDY)) { + if (!(CPU_status&CPU_GEN_BOOT_RDY)) goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; - } else { + else RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n"); - } return rt_status; @@ -190,7 +196,7 @@ bool CPUcheck_firmware_ready(struct net_device *dev) CPU_status = read_nic_dword(dev, CPU_GEN); if (CPU_status&CPU_GEN_FIRM_RDY) break; - msleep(2); + mdelay(2); } if (!(CPU_status&CPU_GEN_FIRM_RDY)) @@ -207,7 +213,8 @@ CPUCheckFirmwareReady_Fail: } -inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_status) +static bool firmware_check_ready(struct net_device *dev, + u8 load_fw_status) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; @@ -222,11 +229,11 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE; rt_status = CPUcheck_maincodeok_turnonCPU(dev); - if (rt_status) { + if (rt_status) pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU; - } else { - RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnonCPU fail!\n"); - } + else + RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnon" + "CPU fail!\n"); break; @@ -235,11 +242,11 @@ inline static bool firmware_check_ready(struct net_device *dev, u8 load_fw_statu mdelay(1); rt_status = CPUcheck_firmware_ready(dev); - if (rt_status) { + if (rt_status) pfirmware->firmware_status = FW_STATUS_5_READY; - } else { - RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail(%d)!\n",rt_status); - } + else + RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail" + "(%d)!\n", rt_status); break; default: @@ -273,53 +280,64 @@ bool init_firmware(struct net_device *dev) RT_TRACE(COMP_FIRMWARE, " PlatformInitFirmware()==>\n"); - if (pfirmware->firmware_status == FW_STATUS_0_INIT ) { + if (pfirmware->firmware_status == FW_STATUS_0_INIT) { rst_opt = OPT_SYSTEM_RESET; starting_state = FW_INIT_STEP0_BOOT; - }else if (pfirmware->firmware_status == FW_STATUS_5_READY) { + } else if (pfirmware->firmware_status == FW_STATUS_5_READY) { rst_opt = OPT_FIRMWARE_RESET; starting_state = FW_INIT_STEP2_DATA; - }else { - RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined firmware state\n"); + } else { + RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined" + " firmware state\n"); } priv->firmware_source = FW_SOURCE_IMG_FILE; - for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) { + for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; + init_step++) { if (rst_opt == OPT_SYSTEM_RESET) { switch (priv->firmware_source) { case FW_SOURCE_IMG_FILE: { if (pfirmware->firmware_buf_size[init_step] == 0) { const char *fw_name[3] = { "RTL8192E/boot.img", - "RTL8192E/main.img", - "RTL8192E/data.img" - }; + "RTL8192E/main.img", + "RTL8192E/data.img" + }; const struct firmware *fw_entry; int rc; - rc = request_firmware(&fw_entry, fw_name[init_step],&priv->pdev->dev); - if (rc < 0 ) { - RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n"); + rc = request_firmware(&fw_entry, + fw_name[init_step], &priv->pdev->dev); + if (rc < 0) { + RT_TRACE(COMP_FIRMWARE, "request firm" + "ware fail!\n"); goto download_firmware_fail; } - if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) { - RT_TRACE(COMP_FIRMWARE, "img file size exceed the container struct buffer fail!\n"); + if (fw_entry->size > + sizeof(pfirmware->firmware_buf[init_step])) { + RT_TRACE(COMP_FIRMWARE, "img file size " + "exceed the container struct " + "buffer fail!\n"); goto download_firmware_fail; } if (init_step != FW_INIT_STEP1_MAIN) { - memcpy(pfirmware->firmware_buf[init_step],fw_entry->data,fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size; + memcpy(pfirmware->firmware_buf[init_step], + fw_entry->data, fw_entry->size); + pfirmware->firmware_buf_size[init_step] = + fw_entry->size; } else { - memset(pfirmware->firmware_buf[init_step],0,128); - memcpy(&pfirmware->firmware_buf[init_step][128],fw_entry->data,fw_entry->size); - pfirmware->firmware_buf_size[init_step] = fw_entry->size+128; + memset(pfirmware->firmware_buf[init_step], + 0, 128); + memcpy(&pfirmware->firmware_buf[init_step][128], + fw_entry->data, fw_entry->size); + pfirmware->firmware_buf_size[init_step] = + fw_entry->size + 128; } - if (rst_opt == OPT_SYSTEM_RESET) { + if (rst_opt == OPT_SYSTEM_RESET) release_firmware(fw_entry); - } } mapped_file = pfirmware->firmware_buf[init_step]; file_length = pfirmware->firmware_buf_size[init_step]; @@ -344,7 +362,7 @@ bool init_firmware(struct net_device *dev) file_length = pfirmware->firmware_buf_size[init_step]; } - rt_status = fw_download_code(dev,mapped_file,file_length); + rt_status = fw_download_code(dev, mapped_file, file_length); if (rt_status != true) { goto download_firmware_fail; } diff --git a/drivers/staging/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/r8192E_firmware.h index c7d4c994a295..caa878833106 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/r8192E_firmware.h @@ -21,7 +21,7 @@ #define RTL8190_CPU_START_OFFSET 0x80 -#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 ) +#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8) enum firmware_init_step { FW_INIT_STEP0_BOOT = 0, @@ -63,7 +63,7 @@ struct rt_firmware { u16 cmdpacket_frag_thresold; #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 #define MAX_FW_INIT_STEP 3 - u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; + u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE]; u16 firmware_buf_size[MAX_FW_INIT_STEP]; }; diff --git a/drivers/staging/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/r8192E_hw.h index 9a3c4084faf7..43c3fb859d10 100644 --- a/drivers/staging/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/r8192E_hw.h @@ -109,7 +109,7 @@ enum _RTL8192Pci_HW { #define MULRW_SHIFT 3 #define MXDMA2_RX_SHIFT 4 #define MXDMA2_TX_SHIFT 0 - PMR = 0x00c, + PMR = 0x00c, EPROM_CMD = 0x00e, #define EPROM_CMD_RESERVED_MASK BIT5 #define EPROM_CMD_9356SEL BIT4 @@ -141,7 +141,8 @@ enum _RTL8192Pci_HW { SIFS = 0x03E, TCR = 0x040, RCR = 0x044, -#define RCR_FILTER_MASK (BIT0|BIT1|BIT2|BIT3|BIT5|BIT12|BIT18|BIT19|BIT20|BIT21|BIT22|BIT23) +#define RCR_FILTER_MASK (BIT0 | BIT1 | BIT2 | BIT3 | BIT5 | BIT12 | \ + BIT18 | BIT19 | BIT20 | BIT21 | BIT22 | BIT23) #define RCR_ONLYERLPKT BIT31 #define RCR_ENCS2 BIT30 #define RCR_ENCS1 BIT29 @@ -337,9 +338,9 @@ enum _RTL8192Pci_HW { NHM_RPI_COUNTER5 = 0x269, NHM_RPI_COUNTER6 = 0x26A, NHM_RPI_COUNTER7 = 0x26B, - WFCRC0 = 0x2f0, - WFCRC1 = 0x2f4, - WFCRC2 = 0x2f8, + WFCRC0 = 0x2f0, + WFCRC1 = 0x2f4, + WFCRC2 = 0x2f8, BW_OPMODE = 0x300, #define BW_OPMODE_11J BIT0 @@ -365,32 +366,32 @@ enum _RTL8192Pci_HW { #define RETRY_LIMIT_LONG_SHIFT 0 TSFR = 0x308, RRSR = 0x310, -#define RRSR_RSC_OFFSET 21 +#define RRSR_RSC_OFFSET 21 #define RRSR_SHORT_OFFSET 23 #define RRSR_RSC_DUPLICATE 0x600000 #define RRSR_RSC_UPSUBCHNL 0x400000 -#define RRSR_RSC_LOWSUBCHNL 0x200000 -#define RRSR_SHORT 0x800000 -#define RRSR_1M BIT0 -#define RRSR_2M BIT1 -#define RRSR_5_5M BIT2 -#define RRSR_11M BIT3 -#define RRSR_6M BIT4 -#define RRSR_9M BIT5 -#define RRSR_12M BIT6 -#define RRSR_18M BIT7 -#define RRSR_24M BIT8 -#define RRSR_36M BIT9 -#define RRSR_48M BIT10 -#define RRSR_54M BIT11 -#define RRSR_MCS0 BIT12 -#define RRSR_MCS1 BIT13 -#define RRSR_MCS2 BIT14 -#define RRSR_MCS3 BIT15 -#define RRSR_MCS4 BIT16 -#define RRSR_MCS5 BIT17 -#define RRSR_MCS6 BIT18 -#define RRSR_MCS7 BIT19 +#define RRSR_RSC_LOWSUBCHNL 0x200000 +#define RRSR_SHORT 0x800000 +#define RRSR_1M BIT0 +#define RRSR_2M BIT1 +#define RRSR_5_5M BIT2 +#define RRSR_11M BIT3 +#define RRSR_6M BIT4 +#define RRSR_9M BIT5 +#define RRSR_12M BIT6 +#define RRSR_18M BIT7 +#define RRSR_24M BIT8 +#define RRSR_36M BIT9 +#define RRSR_48M BIT10 +#define RRSR_54M BIT11 +#define RRSR_MCS0 BIT12 +#define RRSR_MCS1 BIT13 +#define RRSR_MCS2 BIT14 +#define RRSR_MCS3 BIT15 +#define RRSR_MCS4 BIT16 +#define RRSR_MCS5 BIT17 +#define RRSR_MCS6 BIT18 +#define RRSR_MCS7 BIT19 #define BRSR_AckShortPmb BIT23 UFWP = 0x318, RATR0 = 0x320, @@ -422,12 +423,15 @@ enum _RTL8192Pci_HW { #define RATR_MCS13 0x02000000 #define RATR_MCS14 0x04000000 #define RATR_MCS15 0x08000000 -#define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M -#define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M|RATR_36M|RATR_48M|RATR_54M -#define RATE_ALL_OFDM_1SS RATR_MCS0|RATR_MCS1|RATR_MCS2|RATR_MCS3 | \ - RATR_MCS4|RATR_MCS5|RATR_MCS6 |RATR_MCS7 -#define RATE_ALL_OFDM_2SS RATR_MCS8|RATR_MCS9 |RATR_MCS10|RATR_MCS11| \ - RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15 +#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | RATR_11M) +#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \ + RATR_24M | RATR_36M | RATR_48M | RATR_54M) +#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ + RATR_MCS3 | RATR_MCS4 | RATR_MCS5 | \ + RATR_MCS6 | RATR_MCS7) +#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ + RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ + RATR_MCS14|RATR_MCS15) DRIVER_RSSI = 0x32c, @@ -442,8 +446,8 @@ enum _RTL8192Pci_HW { #define GPO 0x109 #define GPE 0x10a -#define HWSET_MAX_SIZE_92S 128 +#define HWSET_MAX_SIZE_92S 128 -#define ANAPAR_FOR_8192PciE 0x17 +#define ANAPAR_FOR_8192PciE 0x17 #endif diff --git a/drivers/staging/rtl8192e/r8192E_hwimg.c b/drivers/staging/rtl8192e/r8192E_hwimg.c index 1b42f7335d9d..08e7dbb6694b 100644 --- a/drivers/staging/rtl8192e/r8192E_hwimg.c +++ b/drivers/staging/rtl8192e/r8192E_hwimg.c @@ -2791,547 +2791,546 @@ u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE] = { 0x80,0x00,0x8f,0xd8,0x80,0x00,0x8f,0xec,0x80,0x00,0x90,0x00,0x80,0x00,0x8b,0x88, }; -u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = { -0x0, }; +u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = {0x0,}; u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE] = { -0x800,0x00000000, -0x804,0x00000001, -0x808,0x0000fc00, -0x80c,0x0000001c, -0x810,0x801010aa, -0x814,0x008514d0, -0x818,0x00000040, -0x81c,0x00000000, -0x820,0x00000004, -0x824,0x00690000, -0x828,0x00000004, -0x82c,0x00e90000, -0x830,0x00000004, -0x834,0x00690000, -0x838,0x00000004, -0x83c,0x00e90000, -0x840,0x00000000, -0x844,0x00000000, -0x848,0x00000000, -0x84c,0x00000000, -0x850,0x00000000, -0x854,0x00000000, -0x858,0x65a965a9, -0x85c,0x65a965a9, -0x860,0x001f0010, -0x864,0x007f0010, -0x868,0x001f0010, -0x86c,0x007f0010, -0x870,0x0f100f70, -0x874,0x0f100f70, -0x878,0x00000000, -0x87c,0x00000000, -0x880,0x6870e36c, -0x884,0xe3573600, -0x888,0x4260c340, -0x88c,0x0000ff00, -0x890,0x00000000, -0x894,0xfffffffe, -0x898,0x4c42382f, -0x89c,0x00656056, -0x8b0,0x00000000, -0x8e0,0x00000000, -0x8e4,0x00000000, -0x900,0x00000000, -0x904,0x00000023, -0x908,0x00000000, -0x90c,0x31121311, -0xa00,0x00d0c7d8, -0xa04,0x811f0008, -0xa08,0x80cd8300, -0xa0c,0x2e62740f, -0xa10,0x95009b78, -0xa14,0x11145008, -0xa18,0x00881117, -0xa1c,0x89140fa0, -0xa20,0x1a1b0000, -0xa24,0x090e1317, -0xa28,0x00000204, -0xa2c,0x00000000, -0xc00,0x00000040, -0xc04,0x00005433, -0xc08,0x000000e4, -0xc0c,0x6c6c6c6c, -0xc10,0x08800000, -0xc14,0x40000100, -0xc18,0x08000000, -0xc1c,0x40000100, -0xc20,0x08000000, -0xc24,0x40000100, -0xc28,0x08000000, -0xc2c,0x40000100, -0xc30,0x6de9ac44, -0xc34,0x465c52cd, -0xc38,0x497f5994, -0xc3c,0x0a969764, -0xc40,0x1f7c403f, -0xc44,0x000100b7, -0xc48,0xec020000, -0xc4c,0x00000300, -0xc50,0x69543420, -0xc54,0x433c0094, -0xc58,0x69543420, -0xc5c,0x433c0094, -0xc60,0x69543420, -0xc64,0x433c0094, -0xc68,0x69543420, -0xc6c,0x433c0094, -0xc70,0x2c7f000d, -0xc74,0x0186175b, -0xc78,0x0000001f, -0xc7c,0x00b91612, -0xc80,0x40000100, -0xc84,0x20000000, -0xc88,0x40000100, -0xc8c,0x20200000, -0xc90,0x40000100, -0xc94,0x00000000, -0xc98,0x40000100, -0xc9c,0x00000000, -0xca0,0x00492492, -0xca4,0x00000000, -0xca8,0x00000000, -0xcac,0x00000000, -0xcb0,0x00000000, -0xcb4,0x00000000, -0xcb8,0x00000000, -0xcbc,0x00492492, -0xcc0,0x00000000, -0xcc4,0x00000000, -0xcc8,0x00000000, -0xccc,0x00000000, -0xcd0,0x00000000, -0xcd4,0x00000000, -0xcd8,0x64b22427, -0xcdc,0x00766932, -0xce0,0x00222222, -0xd00,0x00000750, -0xd04,0x00000403, -0xd08,0x0000907f, -0xd0c,0x00000001, -0xd10,0xa0633333, -0xd14,0x33333c63, -0xd18,0x6a8f5b6b, -0xd1c,0x00000000, -0xd20,0x00000000, -0xd24,0x00000000, -0xd28,0x00000000, -0xd2c,0xcc979975, -0xd30,0x00000000, -0xd34,0x00000000, -0xd38,0x00000000, -0xd3c,0x00027293, -0xd40,0x00000000, -0xd44,0x00000000, -0xd48,0x00000000, -0xd4c,0x00000000, -0xd50,0x6437140a, -0xd54,0x024dbd02, -0xd58,0x00000000, -0xd5c,0x04032064, -0xe00,0x161a1a1a, -0xe04,0x12121416, -0xe08,0x00001800, -0xe0c,0x00000000, -0xe10,0x161a1a1a, -0xe14,0x12121416, -0xe18,0x161a1a1a, -0xe1c,0x12121416, + 0x800, 0x00000000, + 0x804, 0x00000001, + 0x808, 0x0000fc00, + 0x80c, 0x0000001c, + 0x810, 0x801010aa, + 0x814, 0x008514d0, + 0x818, 0x00000040, + 0x81c, 0x00000000, + 0x820, 0x00000004, + 0x824, 0x00690000, + 0x828, 0x00000004, + 0x82c, 0x00e90000, + 0x830, 0x00000004, + 0x834, 0x00690000, + 0x838, 0x00000004, + 0x83c, 0x00e90000, + 0x840, 0x00000000, + 0x844, 0x00000000, + 0x848, 0x00000000, + 0x84c, 0x00000000, + 0x850, 0x00000000, + 0x854, 0x00000000, + 0x858, 0x65a965a9, + 0x85c, 0x65a965a9, + 0x860, 0x001f0010, + 0x864, 0x007f0010, + 0x868, 0x001f0010, + 0x86c, 0x007f0010, + 0x870, 0x0f100f70, + 0x874, 0x0f100f70, + 0x878, 0x00000000, + 0x87c, 0x00000000, + 0x880, 0x6870e36c, + 0x884, 0xe3573600, + 0x888, 0x4260c340, + 0x88c, 0x0000ff00, + 0x890, 0x00000000, + 0x894, 0xfffffffe, + 0x898, 0x4c42382f, + 0x89c, 0x00656056, + 0x8b0, 0x00000000, + 0x8e0, 0x00000000, + 0x8e4, 0x00000000, + 0x900, 0x00000000, + 0x904, 0x00000023, + 0x908, 0x00000000, + 0x90c, 0x31121311, + 0xa00, 0x00d0c7d8, + 0xa04, 0x811f0008, + 0xa08, 0x80cd8300, + 0xa0c, 0x2e62740f, + 0xa10, 0x95009b78, + 0xa14, 0x11145008, + 0xa18, 0x00881117, + 0xa1c, 0x89140fa0, + 0xa20, 0x1a1b0000, + 0xa24, 0x090e1317, + 0xa28, 0x00000204, + 0xa2c, 0x00000000, + 0xc00, 0x00000040, + 0xc04, 0x00005433, + 0xc08, 0x000000e4, + 0xc0c, 0x6c6c6c6c, + 0xc10, 0x08800000, + 0xc14, 0x40000100, + 0xc18, 0x08000000, + 0xc1c, 0x40000100, + 0xc20, 0x08000000, + 0xc24, 0x40000100, + 0xc28, 0x08000000, + 0xc2c, 0x40000100, + 0xc30, 0x6de9ac44, + 0xc34, 0x465c52cd, + 0xc38, 0x497f5994, + 0xc3c, 0x0a969764, + 0xc40, 0x1f7c403f, + 0xc44, 0x000100b7, + 0xc48, 0xec020000, + 0xc4c, 0x00000300, + 0xc50, 0x69543420, + 0xc54, 0x433c0094, + 0xc58, 0x69543420, + 0xc5c, 0x433c0094, + 0xc60, 0x69543420, + 0xc64, 0x433c0094, + 0xc68, 0x69543420, + 0xc6c, 0x433c0094, + 0xc70, 0x2c7f000d, + 0xc74, 0x0186175b, + 0xc78, 0x0000001f, + 0xc7c, 0x00b91612, + 0xc80, 0x40000100, + 0xc84, 0x20000000, + 0xc88, 0x40000100, + 0xc8c, 0x20200000, + 0xc90, 0x40000100, + 0xc94, 0x00000000, + 0xc98, 0x40000100, + 0xc9c, 0x00000000, + 0xca0, 0x00492492, + 0xca4, 0x00000000, + 0xca8, 0x00000000, + 0xcac, 0x00000000, + 0xcb0, 0x00000000, + 0xcb4, 0x00000000, + 0xcb8, 0x00000000, + 0xcbc, 0x00492492, + 0xcc0, 0x00000000, + 0xcc4, 0x00000000, + 0xcc8, 0x00000000, + 0xccc, 0x00000000, + 0xcd0, 0x00000000, + 0xcd4, 0x00000000, + 0xcd8, 0x64b22427, + 0xcdc, 0x00766932, + 0xce0, 0x00222222, + 0xd00, 0x00000750, + 0xd04, 0x00000403, + 0xd08, 0x0000907f, + 0xd0c, 0x00000001, + 0xd10, 0xa0633333, + 0xd14, 0x33333c63, + 0xd18, 0x6a8f5b6b, + 0xd1c, 0x00000000, + 0xd20, 0x00000000, + 0xd24, 0x00000000, + 0xd28, 0x00000000, + 0xd2c, 0xcc979975, + 0xd30, 0x00000000, + 0xd34, 0x00000000, + 0xd38, 0x00000000, + 0xd3c, 0x00027293, + 0xd40, 0x00000000, + 0xd44, 0x00000000, + 0xd48, 0x00000000, + 0xd4c, 0x00000000, + 0xd50, 0x6437140a, + 0xd54, 0x024dbd02, + 0xd58, 0x00000000, + 0xd5c, 0x04032064, + 0xe00, 0x161a1a1a, + 0xe04, 0x12121416, + 0xe08, 0x00001800, + 0xe0c, 0x00000000, + 0xe10, 0x161a1a1a, + 0xe14, 0x12121416, + 0xe18, 0x161a1a1a, + 0xe1c, 0x12121416, }; u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x00000ee0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x009,0x000007f0, -0x00a,0x000009d0, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x00f,0x00000990, -0x012,0x00000806, -0x014,0x000005ab, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000f80, -0x01b,0x00000f5e, -0x01c,0x00000008, -0x01d,0x00000607, -0x01e,0x000006cc, -0x01f,0x00000000, -0x020,0x000001a5, -0x01f,0x00000001, -0x020,0x00000165, -0x01f,0x00000002, -0x020,0x000000c6, -0x01f,0x00000003, -0x020,0x00000086, -0x01f,0x00000004, -0x020,0x00000046, -0x01f,0x00000005, -0x020,0x000001e6, -0x01f,0x00000006, -0x020,0x000001a6, -0x01f,0x00000007, -0x020,0x00000166, -0x01f,0x00000008, -0x020,0x000000c7, -0x01f,0x00000009, -0x020,0x00000087, -0x01f,0x0000000a, -0x020,0x000000f7, -0x01f,0x0000000b, -0x020,0x000000d7, -0x01f,0x0000000c, -0x020,0x000000b7, -0x01f,0x0000000d, -0x020,0x00000097, -0x01f,0x0000000e, -0x020,0x00000077, -0x01f,0x0000000f, -0x020,0x00000057, -0x01f,0x00000010, -0x020,0x00000037, -0x01f,0x00000011, -0x020,0x000000fb, -0x01f,0x00000012, -0x020,0x000000db, -0x01f,0x00000013, -0x020,0x000000bb, -0x01f,0x00000014, -0x020,0x000000ff, -0x01f,0x00000015, -0x020,0x000000e3, -0x01f,0x00000016, -0x020,0x000000c3, -0x01f,0x00000017, -0x020,0x000000a3, -0x01f,0x00000018, -0x020,0x00000083, -0x01f,0x00000019, -0x020,0x00000063, -0x01f,0x0000001a, -0x020,0x00000043, -0x01f,0x0000001b, -0x020,0x00000023, -0x01f,0x0000001c, -0x020,0x00000003, -0x01f,0x0000001d, -0x020,0x000001e3, -0x01f,0x0000001e, -0x020,0x000001c3, -0x01f,0x0000001f, -0x020,0x000001a3, -0x01f,0x00000020, -0x020,0x00000183, -0x01f,0x00000021, -0x020,0x00000163, -0x01f,0x00000022, -0x020,0x00000143, -0x01f,0x00000023, -0x020,0x00000123, -0x01f,0x00000024, -0x020,0x00000103, -0x023,0x00000203, -0x024,0x00000100, -0x00b,0x000001ba, -0x02c,0x000003d7, -0x02d,0x00000ff0, -0x000,0x00000037, -0x004,0x00000160, -0x007,0x00000080, -0x002,0x0000088d, -0x0fe,0x00000000, -0x0fe,0x00000000, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x000,0x000000bf, -0x00d,0x0000001f, -0x00d,0x00000c9f, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x00000ee0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x009, 0x000007f0, + 0x00a, 0x000009d0, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x00f, 0x00000990, + 0x012, 0x00000806, + 0x014, 0x000005ab, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000f80, + 0x01b, 0x00000f5e, + 0x01c, 0x00000008, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x01f, 0x00000000, + 0x020, 0x000001a5, + 0x01f, 0x00000001, + 0x020, 0x00000165, + 0x01f, 0x00000002, + 0x020, 0x000000c6, + 0x01f, 0x00000003, + 0x020, 0x00000086, + 0x01f, 0x00000004, + 0x020, 0x00000046, + 0x01f, 0x00000005, + 0x020, 0x000001e6, + 0x01f, 0x00000006, + 0x020, 0x000001a6, + 0x01f, 0x00000007, + 0x020, 0x00000166, + 0x01f, 0x00000008, + 0x020, 0x000000c7, + 0x01f, 0x00000009, + 0x020, 0x00000087, + 0x01f, 0x0000000a, + 0x020, 0x000000f7, + 0x01f, 0x0000000b, + 0x020, 0x000000d7, + 0x01f, 0x0000000c, + 0x020, 0x000000b7, + 0x01f, 0x0000000d, + 0x020, 0x00000097, + 0x01f, 0x0000000e, + 0x020, 0x00000077, + 0x01f, 0x0000000f, + 0x020, 0x00000057, + 0x01f, 0x00000010, + 0x020, 0x00000037, + 0x01f, 0x00000011, + 0x020, 0x000000fb, + 0x01f, 0x00000012, + 0x020, 0x000000db, + 0x01f, 0x00000013, + 0x020, 0x000000bb, + 0x01f, 0x00000014, + 0x020, 0x000000ff, + 0x01f, 0x00000015, + 0x020, 0x000000e3, + 0x01f, 0x00000016, + 0x020, 0x000000c3, + 0x01f, 0x00000017, + 0x020, 0x000000a3, + 0x01f, 0x00000018, + 0x020, 0x00000083, + 0x01f, 0x00000019, + 0x020, 0x00000063, + 0x01f, 0x0000001a, + 0x020, 0x00000043, + 0x01f, 0x0000001b, + 0x020, 0x00000023, + 0x01f, 0x0000001c, + 0x020, 0x00000003, + 0x01f, 0x0000001d, + 0x020, 0x000001e3, + 0x01f, 0x0000001e, + 0x020, 0x000001c3, + 0x01f, 0x0000001f, + 0x020, 0x000001a3, + 0x01f, 0x00000020, + 0x020, 0x00000183, + 0x01f, 0x00000021, + 0x020, 0x00000163, + 0x01f, 0x00000022, + 0x020, 0x00000143, + 0x01f, 0x00000023, + 0x020, 0x00000123, + 0x01f, 0x00000024, + 0x020, 0x00000103, + 0x023, 0x00000203, + 0x024, 0x00000100, + 0x00b, 0x000001ba, + 0x02c, 0x000003d7, + 0x02d, 0x00000ff0, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x007, 0x00000080, + 0x002, 0x0000088d, + 0x0fe, 0x00000000, + 0x0fe, 0x00000000, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x000, 0x000000bf, + 0x00d, 0x0000001f, + 0x00d, 0x00000c9f, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x000006e0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x000,0x000000b7, -0x00a,0x00000850, -0x000,0x000000bf, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000e00, -0x01b,0x00000f5e, -0x01d,0x00000607, -0x01e,0x000006cc, -0x00b,0x000001ba, -0x023,0x00000203, -0x024,0x00000100, -0x000,0x00000037, -0x004,0x00000160, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x00d,0x00000ccc, -0x000,0x000000bf, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x000006e0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x000, 0x000000b7, + 0x00a, 0x00000850, + 0x000, 0x000000bf, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000e00, + 0x01b, 0x00000f5e, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x00b, 0x000001ba, + 0x023, 0x00000203, + 0x024, 0x00000100, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x00d, 0x00000ccc, + 0x000, 0x000000bf, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE] = { -0x0, }; + 0x0, }; u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE] = { -0x0, }; + 0x0, }; u32 Rtl8192PciEMACPHY_Array[] = { -0x03c,0xffff0000,0x00000f0f, -0x340,0xffffffff,0x161a1a1a, -0x344,0xffffffff,0x12121416, -0x348,0x0000ffff,0x00001818, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000100, + 0x03c, 0xffff0000, 0x00000f0f, + 0x340, 0xffffffff, 0x161a1a1a, + 0x344, 0xffffffff, 0x12121416, + 0x348, 0x0000ffff, 0x00001818, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000100, }; u32 Rtl8192PciEMACPHY_Array_PG[] = { -0x03c,0xffff0000,0x00000f0f, -0xe00,0xffffffff,0x06090909, -0xe04,0xffffffff,0x00030306, -0xe08,0x0000ff00,0x00000000, -0xe10,0xffffffff,0x0a0c0d0f, -0xe14,0xffffffff,0x06070809, -0xe18,0xffffffff,0x0a0c0d0f, -0xe1c,0xffffffff,0x06070809, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000800, + 0x03c, 0xffff0000, 0x00000f0f, + 0xe00, 0xffffffff, 0x06090909, + 0xe04, 0xffffffff, 0x00030306, + 0xe08, 0x0000ff00, 0x00000000, + 0xe10, 0xffffffff, 0x0a0c0d0f, + 0xe14, 0xffffffff, 0x06070809, + 0xe18, 0xffffffff, 0x0a0c0d0f, + 0xe1c, 0xffffffff, 0x06070809, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000800, }; u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLengthPciE] = { -0xc78,0x7d000001, -0xc78,0x7d010001, -0xc78,0x7d020001, -0xc78,0x7d030001, -0xc78,0x7d040001, -0xc78,0x7d050001, -0xc78,0x7c060001, -0xc78,0x7b070001, -0xc78,0x7a080001, -0xc78,0x79090001, -0xc78,0x780a0001, -0xc78,0x770b0001, -0xc78,0x760c0001, -0xc78,0x750d0001, -0xc78,0x740e0001, -0xc78,0x730f0001, -0xc78,0x72100001, -0xc78,0x71110001, -0xc78,0x70120001, -0xc78,0x6f130001, -0xc78,0x6e140001, -0xc78,0x6d150001, -0xc78,0x6c160001, -0xc78,0x6b170001, -0xc78,0x6a180001, -0xc78,0x69190001, -0xc78,0x681a0001, -0xc78,0x671b0001, -0xc78,0x661c0001, -0xc78,0x651d0001, -0xc78,0x641e0001, -0xc78,0x491f0001, -0xc78,0x48200001, -0xc78,0x47210001, -0xc78,0x46220001, -0xc78,0x45230001, -0xc78,0x44240001, -0xc78,0x43250001, -0xc78,0x28260001, -0xc78,0x27270001, -0xc78,0x26280001, -0xc78,0x25290001, -0xc78,0x242a0001, -0xc78,0x232b0001, -0xc78,0x222c0001, -0xc78,0x212d0001, -0xc78,0x202e0001, -0xc78,0x0a2f0001, -0xc78,0x08300001, -0xc78,0x06310001, -0xc78,0x05320001, -0xc78,0x04330001, -0xc78,0x03340001, -0xc78,0x02350001, -0xc78,0x01360001, -0xc78,0x00370001, -0xc78,0x00380001, -0xc78,0x00390001, -0xc78,0x003a0001, -0xc78,0x003b0001, -0xc78,0x003c0001, -0xc78,0x003d0001, -0xc78,0x003e0001, -0xc78,0x003f0001, -0xc78,0x7d400001, -0xc78,0x7d410001, -0xc78,0x7d420001, -0xc78,0x7d430001, -0xc78,0x7d440001, -0xc78,0x7d450001, -0xc78,0x7c460001, -0xc78,0x7b470001, -0xc78,0x7a480001, -0xc78,0x79490001, -0xc78,0x784a0001, -0xc78,0x774b0001, -0xc78,0x764c0001, -0xc78,0x754d0001, -0xc78,0x744e0001, -0xc78,0x734f0001, -0xc78,0x72500001, -0xc78,0x71510001, -0xc78,0x70520001, -0xc78,0x6f530001, -0xc78,0x6e540001, -0xc78,0x6d550001, -0xc78,0x6c560001, -0xc78,0x6b570001, -0xc78,0x6a580001, -0xc78,0x69590001, -0xc78,0x685a0001, -0xc78,0x675b0001, -0xc78,0x665c0001, -0xc78,0x655d0001, -0xc78,0x645e0001, -0xc78,0x495f0001, -0xc78,0x48600001, -0xc78,0x47610001, -0xc78,0x46620001, -0xc78,0x45630001, -0xc78,0x44640001, -0xc78,0x43650001, -0xc78,0x28660001, -0xc78,0x27670001, -0xc78,0x26680001, -0xc78,0x25690001, -0xc78,0x246a0001, -0xc78,0x236b0001, -0xc78,0x226c0001, -0xc78,0x216d0001, -0xc78,0x206e0001, -0xc78,0x0a6f0001, -0xc78,0x08700001, -0xc78,0x06710001, -0xc78,0x05720001, -0xc78,0x04730001, -0xc78,0x03740001, -0xc78,0x02750001, -0xc78,0x01760001, -0xc78,0x00770001, -0xc78,0x00780001, -0xc78,0x00790001, -0xc78,0x007a0001, -0xc78,0x007b0001, -0xc78,0x007c0001, -0xc78,0x007d0001, -0xc78,0x007e0001, -0xc78,0x007f0001, -0xc78,0x2e00001e, -0xc78,0x2e01001e, -0xc78,0x2e02001e, -0xc78,0x2e03001e, -0xc78,0x2e04001e, -0xc78,0x2e05001e, -0xc78,0x3006001e, -0xc78,0x3407001e, -0xc78,0x3908001e, -0xc78,0x3c09001e, -0xc78,0x3f0a001e, -0xc78,0x420b001e, -0xc78,0x440c001e, -0xc78,0x450d001e, -0xc78,0x460e001e, -0xc78,0x460f001e, -0xc78,0x4710001e, -0xc78,0x4811001e, -0xc78,0x4912001e, -0xc78,0x4a13001e, -0xc78,0x4b14001e, -0xc78,0x4b15001e, -0xc78,0x4c16001e, -0xc78,0x4d17001e, -0xc78,0x4e18001e, -0xc78,0x4f19001e, -0xc78,0x4f1a001e, -0xc78,0x501b001e, -0xc78,0x511c001e, -0xc78,0x521d001e, -0xc78,0x521e001e, -0xc78,0x531f001e, -0xc78,0x5320001e, -0xc78,0x5421001e, -0xc78,0x5522001e, -0xc78,0x5523001e, -0xc78,0x5624001e, -0xc78,0x5725001e, -0xc78,0x5726001e, -0xc78,0x5827001e, -0xc78,0x5828001e, -0xc78,0x5929001e, -0xc78,0x592a001e, -0xc78,0x5a2b001e, -0xc78,0x5b2c001e, -0xc78,0x5c2d001e, -0xc78,0x5c2e001e, -0xc78,0x5d2f001e, -0xc78,0x5e30001e, -0xc78,0x5f31001e, -0xc78,0x6032001e, -0xc78,0x6033001e, -0xc78,0x6134001e, -0xc78,0x6235001e, -0xc78,0x6336001e, -0xc78,0x6437001e, -0xc78,0x6438001e, -0xc78,0x6539001e, -0xc78,0x663a001e, -0xc78,0x673b001e, -0xc78,0x673c001e, -0xc78,0x683d001e, -0xc78,0x693e001e, -0xc78,0x6a3f001e, + 0xc78, 0x7d000001, + 0xc78, 0x7d010001, + 0xc78, 0x7d020001, + 0xc78, 0x7d030001, + 0xc78, 0x7d040001, + 0xc78, 0x7d050001, + 0xc78, 0x7c060001, + 0xc78, 0x7b070001, + 0xc78, 0x7a080001, + 0xc78, 0x79090001, + 0xc78, 0x780a0001, + 0xc78, 0x770b0001, + 0xc78, 0x760c0001, + 0xc78, 0x750d0001, + 0xc78, 0x740e0001, + 0xc78, 0x730f0001, + 0xc78, 0x72100001, + 0xc78, 0x71110001, + 0xc78, 0x70120001, + 0xc78, 0x6f130001, + 0xc78, 0x6e140001, + 0xc78, 0x6d150001, + 0xc78, 0x6c160001, + 0xc78, 0x6b170001, + 0xc78, 0x6a180001, + 0xc78, 0x69190001, + 0xc78, 0x681a0001, + 0xc78, 0x671b0001, + 0xc78, 0x661c0001, + 0xc78, 0x651d0001, + 0xc78, 0x641e0001, + 0xc78, 0x491f0001, + 0xc78, 0x48200001, + 0xc78, 0x47210001, + 0xc78, 0x46220001, + 0xc78, 0x45230001, + 0xc78, 0x44240001, + 0xc78, 0x43250001, + 0xc78, 0x28260001, + 0xc78, 0x27270001, + 0xc78, 0x26280001, + 0xc78, 0x25290001, + 0xc78, 0x242a0001, + 0xc78, 0x232b0001, + 0xc78, 0x222c0001, + 0xc78, 0x212d0001, + 0xc78, 0x202e0001, + 0xc78, 0x0a2f0001, + 0xc78, 0x08300001, + 0xc78, 0x06310001, + 0xc78, 0x05320001, + 0xc78, 0x04330001, + 0xc78, 0x03340001, + 0xc78, 0x02350001, + 0xc78, 0x01360001, + 0xc78, 0x00370001, + 0xc78, 0x00380001, + 0xc78, 0x00390001, + 0xc78, 0x003a0001, + 0xc78, 0x003b0001, + 0xc78, 0x003c0001, + 0xc78, 0x003d0001, + 0xc78, 0x003e0001, + 0xc78, 0x003f0001, + 0xc78, 0x7d400001, + 0xc78, 0x7d410001, + 0xc78, 0x7d420001, + 0xc78, 0x7d430001, + 0xc78, 0x7d440001, + 0xc78, 0x7d450001, + 0xc78, 0x7c460001, + 0xc78, 0x7b470001, + 0xc78, 0x7a480001, + 0xc78, 0x79490001, + 0xc78, 0x784a0001, + 0xc78, 0x774b0001, + 0xc78, 0x764c0001, + 0xc78, 0x754d0001, + 0xc78, 0x744e0001, + 0xc78, 0x734f0001, + 0xc78, 0x72500001, + 0xc78, 0x71510001, + 0xc78, 0x70520001, + 0xc78, 0x6f530001, + 0xc78, 0x6e540001, + 0xc78, 0x6d550001, + 0xc78, 0x6c560001, + 0xc78, 0x6b570001, + 0xc78, 0x6a580001, + 0xc78, 0x69590001, + 0xc78, 0x685a0001, + 0xc78, 0x675b0001, + 0xc78, 0x665c0001, + 0xc78, 0x655d0001, + 0xc78, 0x645e0001, + 0xc78, 0x495f0001, + 0xc78, 0x48600001, + 0xc78, 0x47610001, + 0xc78, 0x46620001, + 0xc78, 0x45630001, + 0xc78, 0x44640001, + 0xc78, 0x43650001, + 0xc78, 0x28660001, + 0xc78, 0x27670001, + 0xc78, 0x26680001, + 0xc78, 0x25690001, + 0xc78, 0x246a0001, + 0xc78, 0x236b0001, + 0xc78, 0x226c0001, + 0xc78, 0x216d0001, + 0xc78, 0x206e0001, + 0xc78, 0x0a6f0001, + 0xc78, 0x08700001, + 0xc78, 0x06710001, + 0xc78, 0x05720001, + 0xc78, 0x04730001, + 0xc78, 0x03740001, + 0xc78, 0x02750001, + 0xc78, 0x01760001, + 0xc78, 0x00770001, + 0xc78, 0x00780001, + 0xc78, 0x00790001, + 0xc78, 0x007a0001, + 0xc78, 0x007b0001, + 0xc78, 0x007c0001, + 0xc78, 0x007d0001, + 0xc78, 0x007e0001, + 0xc78, 0x007f0001, + 0xc78, 0x2e00001e, + 0xc78, 0x2e01001e, + 0xc78, 0x2e02001e, + 0xc78, 0x2e03001e, + 0xc78, 0x2e04001e, + 0xc78, 0x2e05001e, + 0xc78, 0x3006001e, + 0xc78, 0x3407001e, + 0xc78, 0x3908001e, + 0xc78, 0x3c09001e, + 0xc78, 0x3f0a001e, + 0xc78, 0x420b001e, + 0xc78, 0x440c001e, + 0xc78, 0x450d001e, + 0xc78, 0x460e001e, + 0xc78, 0x460f001e, + 0xc78, 0x4710001e, + 0xc78, 0x4811001e, + 0xc78, 0x4912001e, + 0xc78, 0x4a13001e, + 0xc78, 0x4b14001e, + 0xc78, 0x4b15001e, + 0xc78, 0x4c16001e, + 0xc78, 0x4d17001e, + 0xc78, 0x4e18001e, + 0xc78, 0x4f19001e, + 0xc78, 0x4f1a001e, + 0xc78, 0x501b001e, + 0xc78, 0x511c001e, + 0xc78, 0x521d001e, + 0xc78, 0x521e001e, + 0xc78, 0x531f001e, + 0xc78, 0x5320001e, + 0xc78, 0x5421001e, + 0xc78, 0x5522001e, + 0xc78, 0x5523001e, + 0xc78, 0x5624001e, + 0xc78, 0x5725001e, + 0xc78, 0x5726001e, + 0xc78, 0x5827001e, + 0xc78, 0x5828001e, + 0xc78, 0x5929001e, + 0xc78, 0x592a001e, + 0xc78, 0x5a2b001e, + 0xc78, 0x5b2c001e, + 0xc78, 0x5c2d001e, + 0xc78, 0x5c2e001e, + 0xc78, 0x5d2f001e, + 0xc78, 0x5e30001e, + 0xc78, 0x5f31001e, + 0xc78, 0x6032001e, + 0xc78, 0x6033001e, + 0xc78, 0x6134001e, + 0xc78, 0x6235001e, + 0xc78, 0x6336001e, + 0xc78, 0x6437001e, + 0xc78, 0x6438001e, + 0xc78, 0x6539001e, + 0xc78, 0x663a001e, + 0xc78, 0x673b001e, + 0xc78, 0x673c001e, + 0xc78, 0x683d001e, + 0xc78, 0x693e001e, + 0xc78, 0x6a3f001e, }; From b09693415b968d7bfbdf98f9efecd15b7c226dd9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 26 Jul 2011 21:46:37 -0500 Subject: [PATCH 06/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part IV Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_phy.c | 1439 +++++++++++++------------ drivers/staging/rtl8192e/r8192E_phy.h | 82 +- 2 files changed, 785 insertions(+), 736 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 9c1d16b5fb69..96ccbd5b25d1 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -47,26 +47,29 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = { /*************************Define local function prototype**********************/ -static u32 phy_FwRFSerialRead(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset); -static void phy_FwRFSerialWrite(struct net_device* dev,enum rf90_radio_path eRFPath,u32 Offset,u32 Data); +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset); +static void phy_FwRFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset, u32 Data); u32 rtl8192_CalculateBitShift(u32 dwBitMask) { u32 i; - for (i=0; i<=31; i++) - { - if (((dwBitMask>>i)&0x1) == 1) + for (i = 0; i <= 31; i++) { + if (((dwBitMask >> i) & 0x1) == 1) break; } return i; } -u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) + +u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath) { u8 ret = 1; struct r8192_priv *priv = rtllib_priv(dev); if (priv->rf_type == RF_2T4R) ret = 0; - else if (priv->rf_type == RF_1T2R) - { + else if (priv->rf_type == RF_1T2R) { if (eRFPath == RF90_PATH_A || eRFPath == RF90_PATH_B) ret = 1; else if (eRFPath == RF90_PATH_C || eRFPath == RF90_PATH_D) @@ -74,22 +77,25 @@ u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath) } return ret; } -void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData) + +void rtl8192_setBBreg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask, + u32 dwData) { u32 OriginalValue, BitShift, NewValue; - if (dwBitMask!= bMaskDWord) - { + if (dwBitMask != bMaskDWord) { OriginalValue = read_nic_dword(dev, dwRegAddr); BitShift = rtl8192_CalculateBitShift(dwBitMask); - NewValue = (((OriginalValue) & (~dwBitMask)) | (dwData << BitShift)); + NewValue = (((OriginalValue) & (~dwBitMask)) | + (dwData << BitShift)); write_nic_dword(dev, dwRegAddr, NewValue); - }else + } else write_nic_dword(dev, dwRegAddr, dwData); return; } -u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) + +u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask) { u32 Ret = 0, OriginalValue, BitShift; @@ -97,60 +103,55 @@ u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask) BitShift = rtl8192_CalculateBitShift(dwBitMask); Ret = (OriginalValue & dwBitMask) >> BitShift; - return (Ret); + return Ret; } -u32 rtl8192_phy_RFSerialRead(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset) +u32 rtl8192_phy_RFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; u32 NewOffset = 0; - struct bb_reg_definition* pPhyReg = &priv->PHYRegDef[eRFPath]; + struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - if (Offset >= 31) - { + if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); - NewOffset = Offset -30; - } - else if (Offset >= 16) - { + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath]<<16)); + NewOffset = Offset - 30; + } else if (Offset >= 16) { priv->RfReg0Value[eRFPath] |= 0x100; priv->RfReg0Value[eRFPath] &= (~0x40); - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16) ); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath]<<16)); NewOffset = Offset - 15; - } - else + } else NewOffset = Offset; - } - else - { - RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + } else { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need" + " to be 8256\n"); NewOffset = Offset; } - rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, NewOffset); + rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress, + NewOffset); rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x0); rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1); + mdelay(1); - msleep(1); + ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, + bLSSIReadBackData); - ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); - - - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { priv->RfReg0Value[eRFPath] &= 0xebf; - rtl8192_setBBreg( - dev, - pPhyReg->rf3wireOffset, - bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } @@ -160,36 +161,36 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, enum rf90_radio_path eRFPat } -void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFPath, u32 Offset, u32 Data) +void rtl8192_phy_RFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset, + u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; Offset &= 0x3f; - if (priv->rf_chip == RF_8256) - { + if (priv->rf_chip == RF_8256) { rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); - if (Offset >= 31) - { + if (Offset >= 31) { priv->RfReg0Value[eRFPath] |= 0x140; - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath] << 16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); NewOffset = Offset - 30; - } - else if (Offset >= 16) - { + } else if (Offset >= 16) { priv->RfReg0Value[eRFPath] |= 0x100; priv->RfReg0Value[eRFPath] &= (~0x40); - rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, (priv->RfReg0Value[eRFPath]<<16)); + rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, + bMaskDWord, + (priv->RfReg0Value[eRFPath] << 16)); NewOffset = Offset - 15; - } - else + } else NewOffset = Offset; - } - else - { - RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be 8256\n"); + } else { + RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be" + " 8256\n"); NewOffset = Offset; } @@ -197,14 +198,11 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFP rtl8192_setBBreg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); - - if (Offset==0x0) + if (Offset == 0x0) priv->RfReg0Value[eRFPath] = Data; - if (priv->rf_chip == RF_8256) - { - if (Offset != 0) - { + if (priv->rf_chip == RF_8256) { + if (Offset != 0) { priv->RfReg0Value[eRFPath] &= 0xebf; rtl8192_setBBreg( dev, @@ -214,11 +212,11 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, enum rf90_radio_path eRFP } rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } - return; } -void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data) +void rtl8192_phy_SetRFReg(struct net_device *dev, enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask, u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 Original_Value, BitShift, New_Value; @@ -229,36 +227,37 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, return; RT_TRACE(COMP_PHY, "FW RF CTRL is not ready now\n"); - if (priv->Rf_Mode == RF_OP_By_FW) - { - if (BitMask != bMask12Bits) - { - Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); + if (priv->Rf_Mode == RF_OP_By_FW) { + if (BitMask != bMask12Bits) { + Original_Value = phy_FwRFSerialRead(dev, eRFPath, + RegAddr); BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + New_Value = (((Original_Value) & (~BitMask)) | + (Data << BitShift)); phy_FwRFSerialWrite(dev, eRFPath, RegAddr, New_Value); - }else + } else phy_FwRFSerialWrite(dev, eRFPath, RegAddr, Data); udelay(200); - } - else - { - if (BitMask != bMask12Bits) - { - Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); + } else { + if (BitMask != bMask12Bits) { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, + RegAddr); BitShift = rtl8192_CalculateBitShift(BitMask); - New_Value = (((Original_Value) & (~BitMask)) | (Data<< BitShift)); + New_Value = (((Original_Value) & (~BitMask)) | + (Data << BitShift)); - rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, New_Value); - }else + rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, + New_Value); + } else rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, Data); } return; } -u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask) +u32 rtl8192_phy_QueryRFReg(struct net_device *dev, enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask) { u32 Original_Value, Readback_Value, BitShift; struct r8192_priv *priv = rtllib_priv(dev); @@ -267,79 +266,61 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter) return 0; down(&priv->rf_sem); - if (priv->Rf_Mode == RF_OP_By_FW) - { + if (priv->Rf_Mode == RF_OP_By_FW) { Original_Value = phy_FwRFSerialRead(dev, eRFPath, RegAddr); udelay(200); - } - else - { - Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, RegAddr); - + } else { + Original_Value = rtl8192_phy_RFSerialRead(dev, eRFPath, + RegAddr); } BitShift = rtl8192_CalculateBitShift(BitMask); Readback_Value = (Original_Value & BitMask) >> BitShift; up(&priv->rf_sem); - return (Readback_Value); + return Readback_Value; } -static u32 phy_FwRFSerialRead( - struct net_device* dev, - enum rf90_radio_path eRFPath, - u32 Offset ) +static u32 phy_FwRFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { u32 retValue = 0; u32 Data = 0; u8 time = 0; - Data |= ((Offset&0xFF)<<12); - Data |= ((eRFPath&0x3)<<20); + Data |= ((Offset & 0xFF) << 12); + Data |= ((eRFPath & 0x3) << 20); Data |= 0x80000000; - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR)&0x80000000) { if (time++ < 100) - { udelay(10); - } else break; } write_nic_dword(dev, QPNR, Data); - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR) & 0x80000000) { if (time++ < 100) - { udelay(10); - } else - return (0); + return 0; } retValue = read_nic_dword(dev, RF_DATA); - return (retValue); + return retValue; } /* phy_FwRFSerialRead */ -static void -phy_FwRFSerialWrite( - struct net_device* dev, - enum rf90_radio_path eRFPath, - u32 Offset, - u32 Data ) +static void phy_FwRFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 Offset, u32 Data) { u8 time = 0; - - Data |= ((Offset&0xFF)<<12); - Data |= ((eRFPath&0x3)<<20); + Data |= ((Offset & 0xFF) << 12); + Data |= ((eRFPath & 0x3) << 20); Data |= 0x400000; Data |= 0x80000000; - while (read_nic_dword(dev, QPNR)&0x80000000) - { + while (read_nic_dword(dev, QPNR) & 0x80000000) { if (time++ < 100) - { udelay(10); - } else break; } @@ -348,82 +329,81 @@ phy_FwRFSerialWrite( } /* phy_FwRFSerialWrite */ -void rtl8192_phy_configmac(struct net_device* dev) +void rtl8192_phy_configmac(struct net_device *dev) { u32 dwArrayLen = 0, i = 0; - u32* pdwArray = NULL; + u32 *pdwArray = NULL; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bTXPowerDataReadFromEEPORM) - { + + if (priv->bTXPowerDataReadFromEEPORM) { RT_TRACE(COMP_PHY, "Rtl819XMACPHY_Array_PG\n"); dwArrayLen = MACPHY_Array_PGLength; pdwArray = Rtl819XMACPHY_Array_PG; - } - else - { - RT_TRACE(COMP_PHY,"Read rtl819XMACPHY_Array\n"); + } else { + RT_TRACE(COMP_PHY, "Read rtl819XMACPHY_Array\n"); dwArrayLen = MACPHY_ArrayLength; pdwArray = Rtl819XMACPHY_Array; } - for (i = 0; irf_type == RF_2T4R) - { - PHY_REGArrayLen = PHY_REGArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; - } - else if (priv->rf_type == RF_1T2R) - { - PHY_REGArrayLen = PHY_REG_1T2RArrayLength; - Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; - } + + AGCTAB_ArrayLen = AGCTAB_ArrayLength; + Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array; + if (priv->rf_type == RF_2T4R) { + PHY_REGArrayLen = PHY_REGArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REGArray; + } else if (priv->rf_type == RF_1T2R) { + PHY_REGArrayLen = PHY_REG_1T2RArrayLength; + Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; } - if (ConfigType == BaseBand_Config_PHY_REG) - { - for (i=0; iPHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW; @@ -510,37 +490,45 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev) priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; } -bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath) + +bool rtl8192_phy_checkBBAndRF(struct net_device *dev, + enum hw90_block CheckBlock, + enum rf90_radio_path eRFPath) { bool ret = true; u32 i, CheckTimes = 4, dwRegRead = 0; u32 WriteAddr[4]; u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f}; + WriteAddr[HW90_BLOCK_MAC] = 0x100; WriteAddr[HW90_BLOCK_PHY0] = 0x900; WriteAddr[HW90_BLOCK_PHY1] = 0x800; WriteAddr[HW90_BLOCK_RF] = 0x3; - RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, CheckBlock); - for (i=0 ; i < CheckTimes ; i++) - { - - switch (CheckBlock) - { + RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__, + CheckBlock); + for (i = 0; i < CheckTimes; i++) { + switch (CheckBlock) { case HW90_BLOCK_MAC: - RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write 0x100 here!"); + RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write " + "0x100 here!"); break; case HW90_BLOCK_PHY0: case HW90_BLOCK_PHY1: - write_nic_dword(dev, WriteAddr[CheckBlock], WriteData[i]); + write_nic_dword(dev, WriteAddr[CheckBlock], + WriteData[i]); dwRegRead = read_nic_dword(dev, WriteAddr[CheckBlock]); break; case HW90_BLOCK_RF: WriteData[i] &= 0xfff; - rtl8192_phy_SetRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMask12Bits, WriteData[i]); + rtl8192_phy_SetRFReg(dev, eRFPath, + WriteAddr[HW90_BLOCK_RF], + bMask12Bits, WriteData[i]); mdelay(10); - dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMaskDWord); + dwRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, + WriteAddr[HW90_BLOCK_RF], + bMaskDWord); mdelay(10); break; @@ -550,9 +538,9 @@ bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock } - if (dwRegRead != WriteData[i]) - { - RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, WriteData: %x \n", dwRegRead, WriteData[i]); + if (dwRegRead != WriteData[i]) { + RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, " + "WriteData: %x\n", dwRegRead, WriteData[i]); ret = false; break; } @@ -561,27 +549,27 @@ bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock return ret; } -bool rtl8192_BB_Config_ParaFile(struct net_device* dev) +bool rtl8192_BB_Config_ParaFile(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; u8 bRegValue = 0, eCheckItem = 0; u32 dwRegValue = 0; - /************************************** - **************************************/ bRegValue = read_nic_byte(dev, BB_GLOBAL_RESET); - write_nic_byte(dev, BB_GLOBAL_RESET,(bRegValue|BB_GLOBAL_RESET_BIT)); + write_nic_byte(dev, BB_GLOBAL_RESET, (bRegValue|BB_GLOBAL_RESET_BIT)); dwRegValue = read_nic_dword(dev, CPU_GEN); write_nic_dword(dev, CPU_GEN, (dwRegValue&(~CPU_GEN_BB_RST))); - for (eCheckItem=(enum hw90_block)HW90_BLOCK_PHY0; eCheckItem<=HW90_BLOCK_PHY1; eCheckItem++) - { - rtStatus = rtl8192_phy_checkBBAndRF(dev, (enum hw90_block)eCheckItem, (enum rf90_radio_path)0); - if (rtStatus != true) - { - RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():Check PHY%d Fail!!\n", eCheckItem-1); + for (eCheckItem = (enum hw90_block)HW90_BLOCK_PHY0; + eCheckItem <= HW90_BLOCK_PHY1; eCheckItem++) { + rtStatus = rtl8192_phy_checkBBAndRF(dev, + (enum hw90_block)eCheckItem, + (enum rf90_radio_path)0); + if (rtStatus != true) { + RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():" + "Check PHY%d Fail!!\n", eCheckItem-1); return rtStatus; } } @@ -593,14 +581,11 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) rtl8192_phyConfigBB(dev, BaseBand_Config_AGC_TAB); - if (priv->IC_Cut > VERSION_8190_BD) - { + if (priv->IC_Cut > VERSION_8190_BD) { if (priv->rf_type == RF_2T4R) - { - dwRegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); - } + dwRegValue = (priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); else dwRegValue = 0x0; rtl8192_setBBreg(dev, rFPGA0_TxGainStage, @@ -608,22 +593,25 @@ bool rtl8192_BB_Config_ParaFile(struct net_device* dev) dwRegValue = priv->CrystalCap; - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, + dwRegValue); } return rtStatus; } -bool rtl8192_BBConfig(struct net_device* dev) +bool rtl8192_BBConfig(struct net_device *dev) { bool rtStatus = true; + rtl8192_InitBBRFRegDef(dev); rtStatus = rtl8192_BB_Config_ParaFile(dev); return rtStatus; } -void rtl8192_phy_getTxPower(struct net_device* dev) +void rtl8192_phy_getTxPower(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); + priv->MCSTxPowerLevelOriginalOffset[0] = read_nic_dword(dev, rTxAGC_Rate18_06); priv->MCSTxPowerLevelOriginalOffset[1] = @@ -641,44 +629,39 @@ void rtl8192_phy_getTxPower(struct net_device* dev) priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1); priv->DefaultInitialGain[2] = read_nic_byte(dev, rOFDM0_XCAGCCore1); priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1); - RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x) \n", + RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, " + "c60=0x%x, c68=0x%x)\n", priv->DefaultInitialGain[0], priv->DefaultInitialGain[1], priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]); priv->framesync = read_nic_byte(dev, rOFDM0_RxDetector3); priv->framesyncC34 = read_nic_dword(dev, rOFDM0_RxDetector2); - RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n", + RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x\n", rOFDM0_RxDetector3, priv->framesync); priv->SifsTime = read_nic_word(dev, SIFS); return; } -void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) +void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - u8 powerlevel = 0,powerlevelOFDM24G = 0; + u8 powerlevel = 0, powerlevelOFDM24G = 0; char ant_pwr_diff; u32 u4RegValue; - if (priv->epromtype == EEPROM_93C46) - { + if (priv->epromtype == EEPROM_93C46) { powerlevel = priv->TxPowerLevelCCK[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - } - else if (priv->epromtype == EEPROM_93C56) - { - if (priv->rf_type == RF_1T2R) - { + } else if (priv->epromtype == EEPROM_93C56) { + if (priv->rf_type == RF_1T2R) { powerlevel = priv->TxPowerLevelCCK_C[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_C[channel-1]; - } - else if (priv->rf_type == RF_2T4R) - { + } else if (priv->rf_type == RF_2T4R) { powerlevel = priv->TxPowerLevelCCK_A[channel-1]; powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_A[channel-1]; ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1] - -priv->TxPowerLevelOFDM24G_A[channel-1]; + - priv->TxPowerLevelOFDM24G_A[channel-1]; priv->RF_C_TxPwDiff = ant_pwr_diff; @@ -688,9 +671,9 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff); priv->AntennaTxPwDiff[0] = 0; - u4RegValue = ( priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]); + u4RegValue = (priv->AntennaTxPwDiff[2]<<8 | + priv->AntennaTxPwDiff[1]<<4 | + priv->AntennaTxPwDiff[0]); rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue); @@ -706,97 +689,105 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", __func__); + RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", + __func__); break; } return; } -bool rtl8192_phy_RFConfig(struct net_device* dev) +bool rtl8192_phy_RFConfig(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; - switch (priv->rf_chip) - { - case RF_8225: - break; - case RF_8256: - rtStatus = PHY_RF8256_Config(dev); - break; - - case RF_8258: - break; - case RF_PSEUDO_11N: + switch (priv->rf_chip) { + case RF_8225: + break; + case RF_8256: + rtStatus = PHY_RF8256_Config(dev); break; - default: - RT_TRACE(COMP_ERR, "error chip id\n"); - break; + case RF_8258: + break; + case RF_PSEUDO_11N: + break; + + default: + RT_TRACE(COMP_ERR, "error chip id\n"); + break; } return rtStatus; } -void rtl8192_phy_updateInitGain(struct net_device* dev) +void rtl8192_phy_updateInitGain(struct net_device *dev) { return; } -u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath) +u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, + enum rf90_radio_path eRFPath) { int i; u8 ret = 0; - switch (eRFPath){ - case RF90_PATH_A: - for (i = 0;iTxPowerLevelCCK[channel-1]; u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; - switch (priv->rf_chip) - { + switch (priv->rf_chip) { case RF_8225: break; @@ -818,31 +808,28 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) case RF_8258: break; default: - RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n"); + RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPower" + "Level()\n"); break; } return; } -u8 rtl8192_phy_SetSwChnlCmdArray( - struct sw_chnl_cmd* CmdTable, - u32 CmdTableIdx, - u32 CmdTableSz, - enum sw_chnl_cmd_id CmdID, - u32 Para1, - u32 Para2, - u32 msDelay - ) -{ - struct sw_chnl_cmd* pCmd; - if (CmdTable == NULL) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n"); +u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, + u32 CmdTableSz, enum sw_chnl_cmd_id CmdID, + u32 Para1, u32 Para2, u32 msDelay) +{ + struct sw_chnl_cmd *pCmd; + + if (CmdTable == NULL) { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot " + "be NULL.\n"); return false; } - if (CmdTableIdx >= CmdTableSz) - { - RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n", + if (CmdTableIdx >= CmdTableSz) { + RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid" + " index, please check size of the table, CmdTableIdx:" + "%d, CmdTableSz:%d\n", CmdTableIdx, CmdTableSz); return false; } @@ -855,7 +842,9 @@ u8 rtl8192_phy_SetSwChnlCmdArray( return true; } -u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u8* step, u32* delay) + +u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, + u8 *step, u32 *delay) { struct r8192_priv *priv = rtllib_priv(dev); struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; @@ -867,50 +856,58 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u struct sw_chnl_cmd *CurrentCmd = NULL; u8 eRFPath; - RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", __func__, *stage, *step, channel); + RT_TRACE(COMP_TRACE, "====>%s()====stage:%d, step:%d, channel:%d\n", + __func__, *stage, *step, channel); - if (!IsLegalChannel(priv->rtllib, channel)) - { - RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel); + if (!IsLegalChannel(priv->rtllib, channel)) { + RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", + channel); return true; } { PreCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_SetTxPowerLevel, 0, 0, 0); - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT, - CmdID_End, 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + MAX_PRECMD_CNT, CmdID_SetTxPowerLevel, + 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + MAX_PRECMD_CNT, CmdID_End, 0, 0, 0); PostCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT, - CmdID_End, 0, 0, 0); + rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, + MAX_POSTCMD_CNT, CmdID_End, 0, 0, 0); RfDependCmdCnt = 0; - switch ( priv->rf_chip ) - { + switch (priv->rf_chip) { case RF_8225: - if (!(channel >= 1 && channel <= 14)) - { - RT_TRACE(COMP_ERR, "illegal channel for Zebra 8225: %d\n", channel); + if (!(channel >= 1 && channel <= 14)) { + RT_TRACE(COMP_ERR, "illegal channel for Zebra " + "8225: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, + RF_CHANNEL_TABLE_ZEBRA[channel], 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; case RF_8256: - if (!(channel >= 1 && channel <= 14)) - { - RT_TRACE(COMP_ERR, "illegal channel for Zebra 8256: %d\n", channel); + if (!(channel >= 1 && channel <= 14)) { + RT_TRACE(COMP_ERR, "illegal channel for Zebra" + " 8256: %d\n", channel); return false; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, - CmdID_RF_WriteReg, rZebra1_Channel, channel, 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT, + CmdID_RF_WriteReg, rZebra1_Channel, channel, + 10); + rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, + RfDependCmdCnt++, + MAX_RFDEPENDCMD_CNT, CmdID_End, 0, 0, 0); break; @@ -918,68 +915,70 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u break; default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", + priv->rf_chip); return false; break; } - do{ - switch (*stage) - { + do { + switch (*stage) { case 0: - CurrentCmd=&PreCommonCmd[*step]; + CurrentCmd = &PreCommonCmd[*step]; break; case 1: - CurrentCmd=&RfDependCmd[*step]; + CurrentCmd = &RfDependCmd[*step]; break; case 2: - CurrentCmd=&PostCommonCmd[*step]; + CurrentCmd = &PostCommonCmd[*step]; break; } - if (CurrentCmd->CmdID==CmdID_End) - { - if ((*stage)==2) - { + if (CurrentCmd->CmdID == CmdID_End) { + if ((*stage) == 2) { return true; - } - else - { + } else { (*stage)++; - (*step)=0; + (*step) = 0; continue; } } - switch (CurrentCmd->CmdID) - { + switch (CurrentCmd->CmdID) { case CmdID_SetTxPowerLevel: if (priv->IC_Cut > (u8)VERSION_8190_BD) - rtl8192_SetTxPowerLevel(dev,channel); + rtl8192_SetTxPowerLevel(dev, channel); break; case CmdID_WritePortUlong: - write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2); + write_nic_dword(dev, CurrentCmd->Para1, + CurrentCmd->Para2); break; case CmdID_WritePortUshort: - write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2); + write_nic_word(dev, CurrentCmd->Para1, + (u16)CurrentCmd->Para2); break; case CmdID_WritePortUchar: - write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2); + write_nic_byte(dev, CurrentCmd->Para1, + (u8)CurrentCmd->Para2); break; case CmdID_RF_WriteReg: - for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) - rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path)eRFPath, CurrentCmd->Para1, bMask12Bits, CurrentCmd->Para2<<7); + for (eRFPath = 0; eRFPath < + priv->NumTotalRFPath; eRFPath++) + rtl8192_phy_SetRFReg(dev, + (enum rf90_radio_path)eRFPath, + CurrentCmd->Para1, bMask12Bits, + CurrentCmd->Para2<<7); break; default: break; } break; - }while(true); - }/*for (Number of RF paths)*/ + } while (true); + } /*for (Number of RF paths)*/ - (*delay)=CurrentCmd->msDelay; + (*delay) = CurrentCmd->msDelay; (*step)++; return false; } @@ -987,14 +986,14 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - u32 delay = 0; + u32 delay = 0; - while(!rtl8192_phy_SwChnlStepByStep(dev,channel,&priv->SwChnlStage,&priv->SwChnlStep,&delay)) - { - if (delay>0) + while (!rtl8192_phy_SwChnlStepByStep(dev, channel, &priv->SwChnlStage, + &priv->SwChnlStep, &delay)) { + if (delay > 0) msleep(delay); if (IS_NIC_DOWN(priv)) - break; + break; } } void rtl8192_SwChnl_WorkItem(struct net_device *dev) @@ -1004,44 +1003,43 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev) RT_TRACE(COMP_TRACE, "==> SwChnlCallback819xUsbWorkItem()\n"); - RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, priv->chan, priv); + RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__, + priv->chan, priv); rtl8192_phy_FinishSwChnlNow(dev , priv->chan); RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n"); } -u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel) +u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_PHY, "=====>%s()\n", __func__); - if (IS_NIC_DOWN(priv)) - { - RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n", __func__); return false; } if (priv->SwChnlInProgress) return false; - switch (priv->rtllib->mode) - { + switch (priv->rtllib->mode) { case WIRELESS_MODE_A: case WIRELESS_MODE_N_5G: - if (channel<=14){ + if (channel <= 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14"); return false; } break; case WIRELESS_MODE_B: - if (channel>14){ + if (channel > 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14"); return false; } break; case WIRELESS_MODE_G: case WIRELESS_MODE_N_24G: - if (channel>14){ + if (channel > 14) { RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14"); return false; } @@ -1052,71 +1050,77 @@ u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel) if (channel == 0) channel = 1; - priv->chan=channel; + priv->chan = channel; - priv->SwChnlStage=0; - priv->SwChnlStep=0; + priv->SwChnlStage = 0; + priv->SwChnlStep = 0; - if (!IS_NIC_DOWN(priv)){ + if (!IS_NIC_DOWN(priv)) rtl8192_SwChnl_WorkItem(dev); - } priv->SwChnlInProgress = false; return true; } -static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev ) +static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault + + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > + (CCKTxBBGainTableLength-1)) priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; + CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; + RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresent" + "Attentuation = %d\n", + priv->CCKPresentAttentuation); - RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if (priv->rtllib->current_network.channel== 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != + 14 && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else { + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } break; - case HT_CHANNEL_WIDTH_20_40: + case HT_CHANNEL_WIDTH_20_40: + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_40Mdefault + + priv->CCKPresentAttentuation_difference; + + RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresent" + "Attentuation = %d\n", + priv->CCKPresentAttentuation); + if (priv->CCKPresentAttentuation > + (CCKTxBBGainTableLength - 1)) priv->CCKPresentAttentuation = - priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; + CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; - RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != 14 + && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else { + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } break; } } @@ -1125,24 +1129,29 @@ static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) priv->bcck_in_ch14 = true; - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) + else if (priv->rtllib->current_network.channel != 14 && + priv->bcck_in_ch14) priv->bcck_in_ch14 = false; - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - if (priv->Record_CCK_20Mindex == 0) - priv->Record_CCK_20Mindex = 6; - priv->CCK_index = priv->Record_CCK_20Mindex; - RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(),CCK_index = %d\n", priv->CCK_index); - break; + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + if (priv->Record_CCK_20Mindex == 0) + priv->Record_CCK_20Mindex = 6; + priv->CCK_index = priv->Record_CCK_20Mindex; + RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_" + "Switch_ThermalMeter(),CCK_index = %d\n", + priv->CCK_index); + break; - case HT_CHANNEL_WIDTH_20_40: - priv->CCK_index = priv->Record_CCK_40Mindex; - RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(), CCK_index = %d\n", priv->CCK_index); - break; + case HT_CHANNEL_WIDTH_20_40: + priv->CCK_index = priv->Record_CCK_40Mindex; + RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_" + "Switch_ThermalMeter(), CCK_index = %d\n", + priv->CCK_index); + break; } dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); } @@ -1163,108 +1172,107 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); u8 regBwOpMode; - RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n", \ - priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz") + RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s " + "bandwidth\n", priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz") - if (priv->rf_chip== RF_PSEUDO_11N) - { - priv->SetBWModeInProgress= false; + if (priv->rf_chip == RF_PSEUDO_11N) { + priv->SetBWModeInProgress = false; return; } - if (IS_NIC_DOWN(priv)){ - RT_TRACE(COMP_ERR,"%s(): ERR!! driver is not up\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "%s(): ERR!! driver is not up\n", __func__); return; } regBwOpMode = read_nic_byte(dev, BW_OPMODE); - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - regBwOpMode |= BW_OPMODE_20MHZ; - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - break; + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + regBwOpMode |= BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; - case HT_CHANNEL_WIDTH_20_40: - regBwOpMode &= ~BW_OPMODE_20MHZ; - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - break; + case HT_CHANNEL_WIDTH_20_40: + regBwOpMode &= ~BW_OPMODE_20MHZ; + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",priv->CurrentChannelBW); - break; + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown " + "Bandwidth: %#X\n", priv->CurrentChannelBW); + break; } - switch (priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); - if (!priv->btxpower_tracking) - { - write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); - write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); - write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); - } - else - CCK_Tx_Power_Track_BW_Switch(dev); + if (!priv->btxpower_tracking) { + write_nic_dword(dev, rCCK0_TxFilter1, 0x1a1b0000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x090e1317); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000204); + } else { + CCK_Tx_Power_Track_BW_Switch(dev); + } - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 1); - break; - case HT_CHANNEL_WIDTH_20_40: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); + break; + case HT_CHANNEL_WIDTH_20_40: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); - if (!priv->btxpower_tracking) - { - write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); - write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); - write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); - } - else - CCK_Tx_Power_Track_BW_Switch(dev); + if (!priv->btxpower_tracking) { + write_nic_dword(dev, rCCK0_TxFilter1, 0x35360000); + write_nic_dword(dev, rCCK0_TxFilter2, 0x121c252e); + write_nic_dword(dev, rCCK0_DebugPort, 0x00000409); + } else { + CCK_Tx_Power_Track_BW_Switch(dev); + } - rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1)); - rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); + rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, + (priv->nCur40MhzPrimeSC>>1)); + rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, + priv->nCur40MhzPrimeSC); - - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); - break; - default: - RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n" ,priv->CurrentChannelBW); - break; + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); + break; + default: + RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown " + "Bandwidth: %#X\n", priv->CurrentChannelBW); + break; } - switch ( priv->rf_chip ) - { - case RF_8225: - break; + switch (priv->rf_chip) { + case RF_8225: + break; - case RF_8256: - PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); - break; + case RF_8256: + PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); + break; - case RF_8258: - break; + case RF_8258: + break; - case RF_PSEUDO_11N: - break; + case RF_PSEUDO_11N: + break; - default: - RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); - break; + default: + RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip); + break; } atomic_dec(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress= false; + priv->SetBWModeInProgress = false; RT_TRACE(COMP_SWBW, "<==SetBWMode819xUsb()"); } -void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) +void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1272,14 +1280,14 @@ void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, if (priv->SetBWModeInProgress) return; - atomic_inc(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress= true; + atomic_inc(&(priv->rtllib->atm_swbw)); + priv->SetBWModeInProgress = true; priv->CurrentChannelBW = Bandwidth; - if (Offset==HT_EXTCHNL_OFFSET_LOWER) + if (Offset == HT_EXTCHNL_OFFSET_LOWER) priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; - else if (Offset==HT_EXTCHNL_OFFSET_UPPER) + else if (Offset == HT_EXTCHNL_OFFSET_UPPER) priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; else priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -1288,79 +1296,107 @@ void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, } - void InitialGain819xPci(struct net_device *dev, u8 Operation) { #define SCAN_RX_INITIAL_GAIN 0x17 #define POWER_DETECTION_TH 0x08 struct r8192_priv *priv = rtllib_priv(dev); - u32 BitMask; - u8 initial_gain; + u32 BitMask; + u8 initial_gain; - if (!IS_NIC_DOWN(priv)){ - switch (Operation) - { - case IG_Backup: - RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n"); - initial_gain = SCAN_RX_INITIAL_GAIN; - BitMask = bMaskByte0; - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); - priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask); - priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask); - priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask); - priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask); - BitMask = bMaskByte2; - priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask); + if (!IS_NIC_DOWN(priv)) { + switch (Operation) { + case IG_Backup: + RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial" + " gain.\n"); + initial_gain = SCAN_RX_INITIAL_GAIN; + BitMask = bMaskByte0; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + priv->initgain_backup.xaagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, + BitMask); + priv->initgain_backup.xbagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, + BitMask); + priv->initgain_backup.xcagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, + BitMask); + priv->initgain_backup.xdagccore1 = + (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, + BitMask); + BitMask = bMaskByte2; + priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, + rCCK0_CCA, BitMask); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is" + " %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is" + " %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is" + " %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is" + " %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is" + " %x\n", priv->initgain_backup.cca); - RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain); - write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); - RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH); - write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH); - break; - case IG_Restore: - RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n"); - BitMask = 0x7f; - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); + RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x\n", + initial_gain); + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x\n", + POWER_DETECTION_TH); + write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH); + break; + case IG_Restore: + RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial " + "gain.\n"); + BitMask = 0x7f; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1); - rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1); - rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1); - BitMask = bMaskByte2; - rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, + (u32)priv->initgain_backup.xaagccore1); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, + (u32)priv->initgain_backup.xbagccore1); + rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, + (u32)priv->initgain_backup.xcagccore1); + rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, + (u32)priv->initgain_backup.xdagccore1); + BitMask = bMaskByte2; + rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, + (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50" + " is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58" + " is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60" + " is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68" + " is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a" + " is %x\n", priv->initgain_backup.cca); - rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + rtl8192_phy_setTxPower(dev, + priv->rtllib->current_network.channel); - - if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); - break; - default: - RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n"); - break; + if (dm_digtable.dig_algorithm == + DIG_ALGO_BY_FALSE_ALARM) + rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); + break; + default: + RT_TRACE(COMP_SCAN, "Unknown IG Operation.\n"); + break; } } } -extern void -PHY_SetRtl8192eRfOff(struct net_device* dev ) +void PHY_SetRtl8192eRfOff(struct net_device *dev) { rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x0); @@ -1374,14 +1410,12 @@ PHY_SetRtl8192eRfOff(struct net_device* dev ) } -bool -SetRFPowerState8190( - struct net_device* dev, - enum rt_rf_power_state eRFPowerState - ) +bool SetRFPowerState8190(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool bResult = true; u8 i = 0, QueueID = 0; struct rtl8192_tx_ring *ring = NULL; @@ -1391,137 +1425,142 @@ SetRFPowerState8190( RT_TRACE(COMP_PS, "===========> SetRFPowerState8190()!\n"); priv->SetRFPowerStateInProgress = true; - switch (priv->rf_chip) - { - case RF_8256: - switch ( eRFPowerState ) - { - case eRfOn: - RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn !\n"); - if ((priv->rtllib->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - bool rtstatus = true; - u32 InitilizeCount = 3; - do - { - InitilizeCount--; - priv->RegRfOff = false; - rtstatus = NicIFEnableNIC(dev); - }while( (rtstatus != true) &&(InitilizeCount >0) ); + switch (priv->rf_chip) { + case RF_8256: + switch (eRFPowerState) { + case eRfOn: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOn!\n"); + if ((priv->rtllib->eRFPowerState == eRfOff) && + RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { + bool rtstatus = true; + u32 InitilizeCount = 3; + do { + InitilizeCount--; + priv->RegRfOff = false; + rtstatus = NicIFEnableNIC(dev); + } while ((rtstatus != true) && + (InitilizeCount > 0)); - if (rtstatus != true) - { - RT_TRACE(COMP_ERR,"%s():Initialize Adapter fail,return\n",__func__); - priv->SetRFPowerStateInProgress = false; - return false; - } + if (rtstatus != true) { + RT_TRACE(COMP_ERR, "%s():Initialize Ada" + "pter fail,return\n", + __func__); + priv->SetRFPowerStateInProgress = false; + return false; + } - RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } else { + RT_CLEAR_PS_LEVEL(pPSC, + RT_RF_OFF_LEVL_HALT_NIC); + } else { write_nic_byte(dev, ANAPAR, 0x37); mdelay(1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x4, 0x1); priv->bHwRfOffAction = 0; - rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, 0x1); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x18, 0x3); - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, 0x3); - rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, 0x3); - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x60, 0x3); + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, + BIT4, 0x1); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, + 0x300, 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x18, 0x3); + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x3, + 0x3); + rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x3, + 0x3); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, + 0x60, 0x3); + } + + break; + + case eRfSleep: + if (priv->rtllib->eRFPowerState == eRfOff) + break; + + + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + ring = &priv->tx_ring[QueueID]; + + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } else { + RT_TRACE((COMP_POWER|COMP_RF), "eRf Off" + "/Sleep: %d times TcbBusyQueue" + "[%d] !=0 before doze!\n", + (i+1), QueueID); + udelay(10); + i++; } - break; - - case eRfSleep: - { - if (priv->rtllib->eRFPowerState == eRfOff) + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! " + "SetRFPowerState8190(): eRfOff" + ": %d times TcbBusyQueue[%d] " + "!= 0 !!!\n", + MAX_DOZE_WAITING_TIMES_9x, + QueueID); break; - - - { - for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) - { - ring = &priv->tx_ring[QueueID]; - - if (skb_queue_len(&ring->queue) == 0) { - QueueID++; - continue; - } - else - { - RT_TRACE((COMP_POWER|COMP_RF), "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); - udelay(10); - i++; - } - - if (i >= MAX_DOZE_WAITING_TIMES_9x) - { - RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! SetRFPowerState8190(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n\n\n", MAX_DOZE_WAITING_TIMES_9x, QueueID); - break; - } - } - } - - { - PHY_SetRtl8192eRfOff(dev); } } - break; + PHY_SetRtl8192eRfOff(dev); + break; - case eRfOff: - RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/Sleep !\n"); + case eRfOff: + RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/" + "Sleep !\n"); + for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { + ring = &priv->tx_ring[QueueID]; - for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) { - ring = &priv->tx_ring[QueueID]; - - if (skb_queue_len(&ring->queue) == 0) { - QueueID++; - continue; - } - else - { - RT_TRACE(COMP_POWER, - "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n", (i+1), QueueID); - udelay(10); - i++; - } - - if (i >= MAX_DOZE_WAITING_TIMES_9x) - { - RT_TRACE(COMP_POWER, "\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 && !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) - { - - NicIFDisableNIC(dev); - RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); - } - else if (!(pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC)) - { - PHY_SetRtl8192eRfOff(dev); - } + if (skb_queue_len(&ring->queue) == 0) { + QueueID++; + continue; + } else { + RT_TRACE(COMP_POWER, "eRf Off/Sleep: %d" + " times TcbBusyQueue[%d] !=0 b" + "efore doze!\n", (i+1), + QueueID); + udelay(10); + i++; } + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_POWER, "\n\n\n SetZebra: " + "RFPowerState8185B(): eRfOff:" + " %d times TcbBusyQueue[%d] " + "!= 0 !!!\n", + MAX_DOZE_WAITING_TIMES_9x, + QueueID); break; + } + } - default: - bResult = false; - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state to set: 0x%X!!!\n", eRFPowerState); - break; + if (pPSC->RegRfPsLevel & RT_RF_OFF_LEVL_HALT_NIC && + !RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { + NicIFDisableNIC(dev); + RT_SET_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); + } else if (!(pPSC->RegRfPsLevel & + RT_RF_OFF_LEVL_HALT_NIC)) { + PHY_SetRtl8192eRfOff(dev); + } + + break; + + default: + bResult = false; + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state" + " to set: 0x%X!!!\n", eRFPowerState); + break; } break; - default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); - break; + default: + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + break; } if (bResult) { @@ -1532,62 +1571,60 @@ SetRFPowerState8190( break; default: - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n"); + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown " + "RF type\n"); break; } } priv->SetRFPowerStateInProgress = false; - RT_TRACE(COMP_PS, "<=========== SetRFPowerState8190() bResult = %d!\n", bResult); + RT_TRACE(COMP_PS, "<=========== SetRFPowerState8190() bResult = %d!\n", + bResult); return bResult; } - - -bool -SetRFPowerState( - struct net_device* dev, - enum rt_rf_power_state eRFPowerState - ) +bool SetRFPowerState(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); bool bResult = false; - RT_TRACE(COMP_PS,"---------> SetRFPowerState(): eRFPowerState(%d)\n", eRFPowerState); - if (eRFPowerState == priv->rtllib->eRFPowerState && priv->bHwRfOffAction == 0) { - RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState); + RT_TRACE(COMP_PS, "---------> SetRFPowerState(): eRFPowerState(%d)\n", + eRFPowerState); + if (eRFPowerState == priv->rtllib->eRFPowerState && + priv->bHwRfOffAction == 0) { + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the " + "request for eRFPowerState(%d) is the same.\n", + eRFPowerState); return bResult; } bResult = SetRFPowerState8190(dev, eRFPowerState); - RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): bResult(%d)\n", bResult); + RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): bResult(%d)\n", + bResult); return bResult; } -extern void -PHY_ScanOperationBackup8192( - struct net_device* dev, - u8 Operation - ) +extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->up) { switch (Operation) { - case SCAN_OPT_BACKUP: - priv->rtllib->InitialGainHandler(dev,IG_Backup); - break; + case SCAN_OPT_BACKUP: + priv->rtllib->InitialGainHandler(dev, IG_Backup); + break; - case SCAN_OPT_RESTORE: - priv->rtllib->InitialGainHandler(dev,IG_Restore); - break; + case SCAN_OPT_RESTORE: + priv->rtllib->InitialGainHandler(dev, IG_Restore); + break; - default: - RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation. \n"); - break; + default: + RT_TRACE(COMP_SCAN, "Unknown Scan Backup Operation.\n"); + break; } } diff --git a/drivers/staging/rtl8192e/r8192E_phy.h b/drivers/staging/rtl8192e/r8192E_phy.h index 79adc8096bd4..86c6acd0c546 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.h +++ b/drivers/staging/rtl8192e/r8192E_phy.h @@ -25,25 +25,25 @@ #define MAX_RFDEPENDCMD_CNT 16 #define MAX_POSTCMD_CNT 16 -#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE -#define MACPHY_ArrayLength MACPHY_ArrayLengthPciE -#define RadioA_ArrayLength RadioA_ArrayLengthPciE -#define RadioB_ArrayLength RadioB_ArrayLengthPciE +#define AGCTAB_ArrayLength AGCTAB_ArrayLengthPciE +#define MACPHY_ArrayLength MACPHY_ArrayLengthPciE +#define RadioA_ArrayLength RadioA_ArrayLengthPciE +#define RadioB_ArrayLength RadioB_ArrayLengthPciE #define MACPHY_Array_PGLength MACPHY_Array_PGLengthPciE -#define RadioC_ArrayLength RadioC_ArrayLengthPciE -#define RadioD_ArrayLength RadioD_ArrayLengthPciE -#define PHY_REGArrayLength PHY_REGArrayLengthPciE -#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPciE +#define RadioC_ArrayLength RadioC_ArrayLengthPciE +#define RadioD_ArrayLength RadioD_ArrayLengthPciE +#define PHY_REGArrayLength PHY_REGArrayLengthPciE +#define PHY_REG_1T2RArrayLength PHY_REG_1T2RArrayLengthPciE #define Rtl819XMACPHY_Array_PG Rtl8192PciEMACPHY_Array_PG -#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array -#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array -#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array -#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array -#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array -#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array -#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray -#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray +#define Rtl819XMACPHY_Array Rtl8192PciEMACPHY_Array +#define Rtl819XRadioA_Array Rtl8192PciERadioA_Array +#define Rtl819XRadioB_Array Rtl8192PciERadioB_Array +#define Rtl819XRadioC_Array Rtl8192PciERadioC_Array +#define Rtl819XRadioD_Array Rtl8192PciERadioD_Array +#define Rtl819XAGCTAB_Array Rtl8192PciEAGCTAB_Array +#define Rtl819XPHY_REGArray Rtl8192PciEPHY_REGArray +#define Rtl819XPHY_REG_1T2RArray Rtl8192PciEPHY_REG_1T2RArray @@ -57,7 +57,7 @@ enum sw_chnl_cmd_id { CmdID_RF_WriteReg, }; -/*--------------------------------Define structure--------------------------------*/ +/*--------------------------------Define structure----------------------------*/ struct sw_chnl_cmd { enum sw_chnl_cmd_id CmdID; u32 Para1; @@ -97,23 +97,35 @@ enum rf90_radio_path { #define bMaskLWord 0x0000ffff #define bMaskDWord 0xffffffff -extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath); -extern void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32 dwData); -extern u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask); -extern void rtl8192_phy_SetRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data); -extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev, enum rf90_radio_path eRFPath, u32 RegAddr, u32 BitMask); -extern void rtl8192_phy_configmac(struct net_device* dev); -extern void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType); -extern bool rtl8192_phy_checkBBAndRF(struct net_device* dev, enum hw90_block CheckBlock, enum rf90_radio_path eRFPath); -extern bool rtl8192_BBConfig(struct net_device* dev); -extern void rtl8192_phy_getTxPower(struct net_device* dev); -extern void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel); -extern bool rtl8192_phy_RFConfig(struct net_device* dev); -extern void rtl8192_phy_updateInitGain(struct net_device* dev); -extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, enum rf90_radio_path eRFPath); +extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, + u32 eRFPath); +extern void rtl8192_setBBreg(struct net_device *dev, u32 dwRegAddr, + u32 dwBitMask, u32 dwData); +extern u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, + u32 dwBitMask); +extern void rtl8192_phy_SetRFReg(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask, u32 Data); +extern u32 rtl8192_phy_QueryRFReg(struct net_device *dev, + enum rf90_radio_path eRFPath, + u32 RegAddr, u32 BitMask); +extern void rtl8192_phy_configmac(struct net_device *dev); +extern void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); +extern bool rtl8192_phy_checkBBAndRF(struct net_device *dev, + enum hw90_block CheckBlock, + enum rf90_radio_path eRFPath); +extern bool rtl8192_BBConfig(struct net_device *dev); +extern void rtl8192_phy_getTxPower(struct net_device *dev); +extern void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); +extern bool rtl8192_phy_RFConfig(struct net_device *dev); +extern void rtl8192_phy_updateInitGain(struct net_device *dev); +extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, + enum rf90_radio_path eRFPath); -extern u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel); -extern void rtl8192_SetBWMode(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); +extern u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); +extern void rtl8192_SetBWMode(struct net_device *dev, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); extern void rtl8192_SetBWModeWorkItem(struct net_device *dev); extern void InitialGain819xPci(struct net_device *dev, u8 Operation); @@ -122,11 +134,11 @@ extern void PHY_SetRtl8192eRfOff(struct net_device *dev); bool SetRFPowerState( - struct net_device* dev, + struct net_device *dev, enum rt_rf_power_state eRFPowerState ); #define PHY_SetRFPowerState SetRFPowerState -extern void PHY_ScanOperationBackup8192(struct net_device* dev,u8 Operation); +extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation); #endif From 81108afb95148de7db0c11aa6e5219ba1faa55b0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 27 Jul 2011 12:32:07 -0500 Subject: [PATCH 07/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part V Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BA.h | 5 +- drivers/staging/rtl8192e/rtl819x_BAProc.c | 403 +++++----- drivers/staging/rtl8192e/rtl819x_HT.h | 25 +- drivers/staging/rtl8192e/rtl819x_HTProc.c | 876 +++++++++++----------- 4 files changed, 650 insertions(+), 659 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BA.h b/drivers/staging/rtl8192e/rtl819x_BA.h index d2020b390186..613e14c12df3 100644 --- a/drivers/staging/rtl8192e/rtl819x_BA.h +++ b/drivers/staging/rtl8192e/rtl819x_BA.h @@ -38,11 +38,10 @@ #define DELBA_REASON_TIMEOUT 39 union sequence_control { u16 ShortData; - struct - { + struct { u16 FragNum:4; u16 SeqNum:12; - }field; + } field; }; union ba_param_set { diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index aeb8a4b5d058..2e4085b88775 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -20,46 +20,44 @@ #include "rtl819x_BA.h" #include "rtl_core.h" -void ActivateBAEntry(struct rtllib_device* ieee, struct ba_record *pBA, u16 Time) +void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, + u16 Time) { pBA->bValid = true; if (Time != 0) mod_timer(&pBA->Timer, jiffies + MSECS(Time)); } -void DeActivateBAEntry( struct rtllib_device* ieee, struct ba_record *pBA) +void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) { pBA->bValid = false; del_timer_sync(&pBA->Timer); } -u8 TxTsDeleteBA( struct rtllib_device* ieee, struct tx_ts_record *pTxTs) + +u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) { struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord; struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord; - u8 bSendDELBA = false; + u8 bSendDELBA = false; - if (pPendingBa->bValid) - { + if (pPendingBa->bValid) { DeActivateBAEntry(ieee, pPendingBa); bSendDELBA = true; } - if (pAdmittedBa->bValid) - { + if (pAdmittedBa->bValid) { DeActivateBAEntry(ieee, pAdmittedBa); bSendDELBA = true; } - return bSendDELBA; } -u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) +u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) { struct ba_record *pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; - if (pBa->bValid) - { + if (pBa->bValid) { DeActivateBAEntry(ieee, pBa); bSendDELBA = true; } @@ -67,7 +65,7 @@ u8 RxTsDeleteBA( struct rtllib_device* ieee, struct rx_ts_record *pRxTs) return bSendDELBA; } -void ResetBaEntry( struct ba_record *pBA) +void ResetBaEntry(struct ba_record *pBA) { pBA->bValid = false; pBA->BaParamSet.shortData = 0; @@ -75,31 +73,35 @@ void ResetBaEntry( struct ba_record *pBA) pBA->DialogToken = 0; pBA->BaStartSeqCtrl.ShortData = 0; } -static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct ba_record *pBA, u16 StatusCode, u8 type) +static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, + struct ba_record *pBA, + u16 StatusCode, u8 type) { struct sk_buff *skb = NULL; - struct rtllib_hdr_3addr* BAReq = NULL; - u8* tag = NULL; + struct rtllib_hdr_3addr *BAReq = NULL; + u8 *tag = NULL; u16 tmp = 0; u16 len = ieee->tx_headroom + 9; - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d) sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, type, MAC_ARG(Dst), ieee->dev); - if (pBA == NULL||ieee == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" + " sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, + type, MAC_ARG(Dst), ieee->dev); + if (pBA == NULL || ieee == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is " + "NULL\n", pBA, ieee); return NULL; } - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); - if (skb == NULL) - { + skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); + if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } - memset(skb->data, 0, sizeof( struct rtllib_hdr_3addr)); + memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr)); skb_reserve(skb, ieee->tx_headroom); - BAReq = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + BAReq = (struct rtllib_hdr_3addr *)skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(BAReq->addr1, Dst, ETH_ALEN); memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -107,28 +109,26 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN); BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); - tag = (u8*)skb_put(skb, 9); + tag = (u8 *)skb_put(skb, 9); *tag ++= ACT_CAT_BA; *tag ++= type; *tag ++= pBA->DialogToken; - if (ACT_ADDBARSP == type) - { + if (ACT_ADDBARSP == type) { RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); tmp = cpu_to_le16(StatusCode); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; } tmp = cpu_to_le16(pBA->BaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; tmp = cpu_to_le16(pBA->BaTimeoutValue); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; - if (ACT_ADDBAREQ == type) - { - memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2); + if (ACT_ADDBAREQ == type) { + memcpy(tag, (u8 *)&(pBA->BaStartSeqCtrl), 2); tag += 2; } @@ -136,64 +136,65 @@ static struct sk_buff* rtllib_ADDBA(struct rtllib_device* ieee, u8* Dst, struct return skb; } -static struct sk_buff* rtllib_DELBA( - struct rtllib_device* ieee, - u8* dst, - struct ba_record *pBA, - enum tr_select TxRxSelect, - u16 ReasonCode - ) +static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, + enum tr_select TxRxSelect, u16 ReasonCode) { union delba_param_set DelbaParamSet; struct sk_buff *skb = NULL; - struct rtllib_hdr_3addr* Delba = NULL; - u8* tag = NULL; + struct rtllib_hdr_3addr *Delba = NULL; + u8 *tag = NULL; u16 tmp = 0; u16 len = 6 + ieee->tx_headroom; if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), ReasonCode(%d) sentd to:"MAC_FMT"\n", __func__, ReasonCode, MAC_ARG(dst)); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, + "========>%s(), Reason" + "Code(%d) sentd to:"MAC_FMT"\n", __func__, + ReasonCode, MAC_ARG(dst)); memset(&DelbaParamSet, 0, 2); - DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; + DelbaParamSet.field.Initiator = (TxRxSelect == TX_DIR) ? 1 : 0; DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; - skb = dev_alloc_skb(len + sizeof( struct rtllib_hdr_3addr)); - if (skb == NULL) - { + skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr)); + if (skb == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } skb_reserve(skb, ieee->tx_headroom); - Delba = ( struct rtllib_hdr_3addr *) skb_put(skb,sizeof( struct rtllib_hdr_3addr)); + Delba = (struct rtllib_hdr_3addr *) skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(Delba->addr1, dst, ETH_ALEN); memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN); Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); - tag = (u8*)skb_put(skb, 6); + tag = (u8 *)skb_put(skb, 6); *tag ++= ACT_CAT_BA; *tag ++= ACT_DELBA; tmp = cpu_to_le16(DelbaParamSet.shortData); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; tmp = cpu_to_le16(ReasonCode); - memcpy(tag, (u8*)&tmp, 2); + memcpy(tag, (u8 *)&tmp, 2); tag += 2; RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); if (net_ratelimit()) - RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n", + __func__); return skb; } -void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA) +void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -202,65 +203,66 @@ void rtllib_send_ADDBAReq(struct rtllib_device* ieee, u8* dst, struct ba_record RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n"); softmac_mgmt_xmit(skb, ieee); } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function" + " %s()\n", __func__); } return; } -void rtllib_send_ADDBARsp(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, u16 StatusCode) +void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, u16 StatusCode) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); if (skb) softmac_mgmt_xmit(skb, ieee); else - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); - + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function" + " %s()\n", __func__); return; - } -void rtllib_send_DELBA(struct rtllib_device* ieee, u8* dst, struct ba_record *pBA, enum tr_select TxRxSelect, u16 ReasonCode) +void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, enum tr_select TxRxSelect, + u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); if (skb) - { softmac_mgmt_xmit(skb, ieee); - } else - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function %s()\n", __func__); - } + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in func" + "tion %s()\n", __func__); return ; } -int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) +int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* req = NULL; + struct rtllib_hdr_3addr *req = NULL; u16 rc = 0; - u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL; + u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; struct ba_record *pBA = NULL; union ba_param_set *pBaParamSet = NULL; - u16* pBaTimeoutVal = NULL; + u16 *pBaTimeoutVal = NULL; union sequence_control *pBaStartSeqCtrl = NULL; struct rx_ts_record *pTS = NULL; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n",(int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / " + "%d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); - req = ( struct rtllib_hdr_3addr*) skb->data; - tag = (u8*)req; - dst = (u8*)(&req->addr2[0]); - tag += sizeof( struct rtllib_hdr_3addr); + req = (struct rtllib_hdr_3addr *) skb->data; + tag = (u8 *)req; + dst = (u8 *)(&req->addr2[0]); + tag += sizeof(struct rtllib_hdr_3addr); pDialogToken = tag + 2; pBaParamSet = (union ba_param_set *)(tag + 3); - pBaTimeoutVal = (u16*)(tag + 5); + pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); @@ -268,31 +270,27 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) (ieee->pHTInfo->bCurrentHTSupport == false) || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { rc = ADDBA_STATUS_REFUSED; - RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as " + "some capability is not ready(%d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); goto OnADDBAReq_Fail; } - if (!GetTs( - ieee, - (struct ts_common_info **)(&pTS), - dst, - (u8)(pBaParamSet->field.TID), - RX_DIR, - true) ) - { + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, + (u8)(pBaParamSet->field.TID), RX_DIR, true)) { rc = ADDBA_STATUS_REFUSED; RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__); goto OnADDBAReq_Fail; } pBA = &pTS->RxAdmittedBARecord; - if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { rc = ADDBA_STATUS_INVALID_PARAM; - RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in %s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in " + "%s()\n", __func__); goto OnADDBAReq_Fail; } - rtllib_FlushRxTsPendingPkts(ieee, pTS); DeActivateBAEntry(ieee, pBA); @@ -301,11 +299,11 @@ int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb) pBA->BaTimeoutValue = *pBaTimeoutVal; pBA->BaStartSeqCtrl = *pBaStartSeqCtrl; - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)|| - (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) - pBA->BaParamSet.field.BufferSize = 1; + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev) || + (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT)) + pBA->BaParamSet.field.BufferSize = 1; else - pBA->BaParamSet.field.BufferSize = 32; + pBA->BaParamSet.field.BufferSize = 32; ActivateBAEntry(ieee, pBA, 0); rtllib_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS); @@ -322,40 +320,42 @@ OnADDBAReq_Fail: rtllib_send_ADDBARsp(ieee, dst, &BA, rc); return 0; } - } -int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) +int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* rsp = NULL; + struct rtllib_hdr_3addr *rsp = NULL; struct ba_record *pPendingBA, *pAdmittedBA; struct tx_ts_record *pTS = NULL; - u8* dst = NULL, *pDialogToken = NULL, *tag = NULL; - u16* pStatusCode = NULL, *pBaTimeoutVal = NULL; + u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; + u16 *pStatusCode = NULL, *pBaTimeoutVal = NULL; union ba_param_set *pBaParamSet = NULL; u16 ReasonCode; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 9) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 9)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / " + "%d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 9)); return -1; } - rsp = ( struct rtllib_hdr_3addr*)skb->data; - tag = (u8*)rsp; - dst = (u8*)(&rsp->addr2[0]); - tag += sizeof( struct rtllib_hdr_3addr); + rsp = (struct rtllib_hdr_3addr *)skb->data; + tag = (u8 *)rsp; + dst = (u8 *)(&rsp->addr2[0]); + tag += sizeof(struct rtllib_hdr_3addr); pDialogToken = tag + 2; - pStatusCode = (u16*)(tag + 3); + pStatusCode = (u16 *)(tag + 3); pBaParamSet = (union ba_param_set *)(tag + 5); - pBaTimeoutVal = (u16*)(tag + 7); + pBaTimeoutVal = (u16 *)(tag + 7); RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); - if ( - ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false || - ieee->pHTInfo->bCurrentAMPDUEnable == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); + if (ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false || + ieee->pHTInfo->bCurrentAMPDUEnable == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capab" + "ility is not ready(%d, %d, %d)\n", + ieee->current_network.qos_data.active, + ieee->pHTInfo->bCurrentHTSupport, + ieee->pHTInfo->bCurrentAMPDUEnable); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } @@ -373,28 +373,25 @@ int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb) pAdmittedBA = &pTS->TxAdmittedBARecord; - if ((pAdmittedBA->bValid==true)) - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"); + if ((pAdmittedBA->bValid == true)) { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp." + " Drop because already admit it!\n"); return -1; - } - else if ((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"); + } else if ((pPendingBA->bValid == false) || + (*pDialogToken != pPendingBA->DialogToken)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. " + "BA invalid, DELBA!\n"); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode); + } else { + RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA " + "is admitted! Status code:%X\n", *pStatusCode); DeActivateBAEntry(ieee, pPendingBA); } - if (*pStatusCode == ADDBA_STATUS_SUCCESS) - { - if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) - { + if (*pStatusCode == ADDBA_STATUS_SUCCESS) { + if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { pTS->bAddBaReqDelayed = true; DeActivateBAEntry(ieee, pAdmittedBA); ReasonCode = DELBA_REASON_END_BA; @@ -424,68 +421,58 @@ OnADDBARsp_Reject: rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode); return 0; } - } -int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) +int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) { - struct rtllib_hdr_3addr* delba = NULL; + struct rtllib_hdr_3addr *delba = NULL; union delba_param_set *pDelBaParamSet = NULL; - u16* pReasonCode = NULL; - u8* dst = NULL; + u16 *pReasonCode = NULL; + u8 *dst = NULL; - if (skb->len < sizeof( struct rtllib_hdr_3addr) + 6) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", (int)skb->len, (int)(sizeof( struct rtllib_hdr_3addr) + 6)); + if (skb->len < sizeof(struct rtllib_hdr_3addr) + 6) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d /" + " %d)\n", (int)skb->len, + (int)(sizeof(struct rtllib_hdr_3addr) + 6)); return -1; } - if ( - ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); + if (ieee->current_network.qos_data.active == 0 || + ieee->pHTInfo->bCurrentHTSupport == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT " + "is not supported(%d, %d)\n", + ieee->current_network. qos_data.active, + ieee->pHTInfo->bCurrentHTSupport); return -1; } RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len); - delba = ( struct rtllib_hdr_3addr*)skb->data; - dst = (u8*)(&delba->addr2[0]); - delba += sizeof( struct rtllib_hdr_3addr); + delba = (struct rtllib_hdr_3addr *)skb->data; + dst = (u8 *)(&delba->addr2[0]); + delba += sizeof(struct rtllib_hdr_3addr); pDelBaParamSet = (union delba_param_set *)(delba+2); - pReasonCode = (u16*)(delba+4); + pReasonCode = (u16 *)(delba+4); - if (pDelBaParamSet->field.Initiator == 1) - { + if (pDelBaParamSet->field.Initiator == 1) { struct rx_ts_record *pRxTs; - if ( !GetTs( - ieee, - (struct ts_common_info **)&pRxTs, - dst, - (u8)pDelBaParamSet->field.TID, - RX_DIR, - false) ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in %s().dst:"MAC_FMT" TID:%d\n", __func__, MAC_ARG(dst), (u8)pDelBaParamSet->field.TID); + if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst, + (u8)pDelBaParamSet->field.TID, RX_DIR, false)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in " + "%s().dst:"MAC_FMT" TID:%d\n", __func__, + MAC_ARG(dst), + (u8)pDelBaParamSet->field.TID); return -1; } RxTsDeleteBA(ieee, pRxTs); - } - else - { + } else { struct tx_ts_record *pTxTs; - if (!GetTs( - ieee, - (struct ts_common_info **)&pTxTs, - dst, - (u8)pDelBaParamSet->field.TID, - TX_DIR, - false) ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for TXTS in %s()\n", __func__); + if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst, + (u8)pDelBaParamSet->field.TID, TX_DIR, false)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for TXTS in " + "%s()\n", __func__); return -1; } @@ -498,17 +485,12 @@ int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb) return 0; } -void -TsInitAddBA( - struct rtllib_device* ieee, - struct tx_ts_record *pTS, - u8 Policy, - u8 bOverwritePending - ) +void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, + u8 Policy, u8 bOverwritePending) { struct ba_record *pBA = &pTS->TxPendingBARecord; - if (pBA->bValid==true && bOverwritePending==false) + if (pBA->bValid == true && bOverwritePending == false) return; DeActivateBAEntry(ieee, pBA); @@ -516,7 +498,8 @@ TsInitAddBA( pBA->DialogToken++; pBA->BaParamSet.field.AMSDU_Support = 0; pBA->BaParamSet.field.BAPolicy = Policy; - pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; + pBA->BaParamSet.field.TID = + pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; pBA->BaParamSet.field.BufferSize = 32; pBA->BaTimeoutValue = 0; pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; @@ -526,34 +509,30 @@ TsInitAddBA( rtllib_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA); } -void -TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect) +void TsInitDelBA(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, + enum tr_select TxRxSelect) { - - if (TxRxSelect == TX_DIR) - { - struct tx_ts_record *pTxTs = (struct tx_ts_record *)pTsCommonInfo; + if (TxRxSelect == TX_DIR) { + struct tx_ts_record *pTxTs = + (struct tx_ts_record *)pTsCommonInfo; if (TxTsDeleteBA(ieee, pTxTs)) - rtllib_send_DELBA( - ieee, - pTsCommonInfo->Addr, - (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord), - TxRxSelect, - DELBA_REASON_END_BA); - } - else if (TxRxSelect == RX_DIR) - { - struct rx_ts_record *pRxTs = (struct rx_ts_record *)pTsCommonInfo; + rtllib_send_DELBA(ieee, pTsCommonInfo->Addr, + (pTxTs->TxAdmittedBARecord.bValid) ? + (&pTxTs->TxAdmittedBARecord) : + (&pTxTs->TxPendingBARecord), + TxRxSelect, DELBA_REASON_END_BA); + } else if (TxRxSelect == RX_DIR) { + struct rx_ts_record *pRxTs = + (struct rx_ts_record *)pTsCommonInfo; if (RxTsDeleteBA(ieee, pRxTs)) - rtllib_send_DELBA( - ieee, - pTsCommonInfo->Addr, - &pRxTs->RxAdmittedBARecord, - TxRxSelect, - DELBA_REASON_END_BA ); + rtllib_send_DELBA(ieee, pTsCommonInfo->Addr, + &pRxTs->RxAdmittedBARecord, + TxRxSelect, DELBA_REASON_END_BA); } } + void BaSetupTimeOut(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; @@ -566,27 +545,23 @@ void BaSetupTimeOut(unsigned long data) void TxBaInactTimeout(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; - struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[pTxTs->num]); + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, + TxTsRecord[pTxTs->num]); TxTsDeleteBA(ieee, pTxTs); - rtllib_send_DELBA( - ieee, - pTxTs->TsCommonInfo.Addr, - &pTxTs->TxAdmittedBARecord, - TX_DIR, - DELBA_REASON_TIMEOUT); + rtllib_send_DELBA(ieee, pTxTs->TsCommonInfo.Addr, + &pTxTs->TxAdmittedBARecord, TX_DIR, + DELBA_REASON_TIMEOUT); } void RxBaInactTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; - struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, + RxTsRecord[pRxTs->num]); RxTsDeleteBA(ieee, pRxTs); - rtllib_send_DELBA( - ieee, - pRxTs->TsCommonInfo.Addr, - &pRxTs->RxAdmittedBARecord, - RX_DIR, - DELBA_REASON_TIMEOUT); + rtllib_send_DELBA(ieee, pRxTs->TsCommonInfo.Addr, + &pRxTs->RxAdmittedBARecord, RX_DIR, + DELBA_REASON_TIMEOUT); return ; } diff --git a/drivers/staging/rtl8192e/rtl819x_HT.h b/drivers/staging/rtl8192e/rtl819x_HT.h index 891714fb1822..13f41057461a 100644 --- a/drivers/staging/rtl8192e/rtl819x_HT.h +++ b/drivers/staging/rtl8192e/rtl819x_HT.h @@ -34,10 +34,10 @@ #define sHTCLng 4 -#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff -#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 -#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP - +#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff +#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00 +#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP \ + (HT_MCS_1SS_BITMAP | HT_MCS_1SS_2SS_BITMAP) enum ht_mcs_rate { HT_MCS0 = 0x00000001, @@ -381,13 +381,12 @@ extern u8 MCS_FILTER_ALL[16]; extern u8 MCS_FILTER_1SS[16]; #define PICK_RATE(_nLegacyRate, _nMcsRate) \ - (_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate) + ((_nMcsRate == 0) ? (_nLegacyRate&0x7f) : (_nMcsRate)) #define LEGACY_WIRELESS_MODE IEEE_MODE_MASK #define CURRENT_RATE(WirelessMode, LegacyRate, HTRate) \ - ((WirelessMode & (LEGACY_WIRELESS_MODE))!=0)?\ - (LegacyRate):\ - (PICK_RATE(LegacyRate, HTRate)) + ((WirelessMode & (LEGACY_WIRELESS_MODE)) != 0) ? \ + (LegacyRate) : (PICK_RATE(LegacyRate, HTRate)) @@ -411,8 +410,8 @@ enum ht_iot_peer { HT_IOT_PEER_BROADCOM = 3, HT_IOT_PEER_RALINK = 4, HT_IOT_PEER_ATHEROS = 5, - HT_IOT_PEER_CISCO= 6, - HT_IOT_PEER_MARVELL=7, + HT_IOT_PEER_CISCO = 6, + HT_IOT_PEER_MARVELL = 7, HT_IOT_PEER_92U_SOFTAP = 8, HT_IOT_PEER_SELF_SOFTAP = 9, HT_IOT_PEER_AIRGO = 10, @@ -447,10 +446,10 @@ enum ht_iot_action { HT_IOT_ACT_TX_NO_AGGREGATION = 0x00100000, HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000, - HT_IOT_ACT_MID_HIGHPOWER = 0x00400000, - HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, + HT_IOT_ACT_MID_HIGHPOWER = 0x00400000, + HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000, - HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000, + HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000, HT_IOT_ACT_FORCED_ENABLE_BE_TXOP = 0x02000000, HT_IOT_ACT_WA_IOT_Broadcom = 0x04000000, diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 825b90805b4b..f8da913c47be 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -18,53 +18,75 @@ ******************************************************************************/ #include "rtllib.h" #include "rtl819x_HT.h" -u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +u8 MCS_FILTER_ALL[16] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; -u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +u8 MCS_FILTER_1SS[16] = { + 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +; -u16 MCS_DATA_RATE[2][2][77] = - { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260, - 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520, - 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195, - 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260, - 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429}, - {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, - 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578, - 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217, - 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289, - 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} }, - { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540, - 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080, - 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405, - 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540, - 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891}, - {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600, - 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200, - 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450, - 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600, - 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} } - }; +u16 MCS_DATA_RATE[2][2][77] = { + {{13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, + 260, 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, + 468, 520, 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, + 182, 208, 156, 195, 195, 234, 273, 273, 312, 130, 156, 181, 156, + 181, 208, 234, 208, 234, 260, 260, 286, 195, 234, 273, 234, 273, + 312, 351, 312, 351, 390, 390, 429} , + {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289, + 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, + 578, 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, + 173, 217, 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, + 231, 260, 289, 289, 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, + 433, 433, 477} } , + {{27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, + 540, 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, + 864, 972, 1080, 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, + 378, 378, 432, 324, 405, 405, 486, 567, 567, 648, 270, 324, 378, 324, + 378, 432, 486, 432, 486, 540, 540, 594, 405, 486, 567, 486, 567, 648, + 729, 648, 729, 810, 810, 891}, + {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, + 600, 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, + 960, 1080, 1200, 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, + 420, 420, 480, 360, 450, 450, 540, 630, 630, 720, 300, 360, 420, 360, + 420, 480, 540, 480, 540, 600, 600, 660, 450, 540, 630, 540, 630, 720, + 810, 720, 810, 900, 900, 990} } +}; static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf}; + static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70}; + static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e}; + static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f}; + static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf}; + static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc}; + static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e}; + static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02}; + static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0}; + static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91}; + static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94}; + static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4}; -void HTUpdateDefaultSetting(struct rtllib_device* ieee) + +void HTUpdateDefaultSetting(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->bAcceptAddbaReq = 1; - pHTInfo->bRegShortGI20MHz= 1; - pHTInfo->bRegShortGI40MHz= 1; + pHTInfo->bRegShortGI20MHz = 1; + pHTInfo->bRegShortGI40MHz = 1; pHTInfo->bRegBW40MHz = 1; @@ -94,97 +116,110 @@ void HTUpdateDefaultSetting(struct rtllib_device* ieee) pHTInfo->RxReorderWinSize = 64; pHTInfo->RxReorderPendingTime = 30; } -void HTDebugHTCapability(u8* CapIE, u8* TitleString ) + +void HTDebugHTCapability(u8 *CapIE, u8 *TitleString) { static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; struct ht_capab_ele *pCapELE; - if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) - { + if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); pCapELE = (struct ht_capab_ele *)(&CapIE[4]); - }else + } else pCapELE = (struct ht_capab_ele *)(&CapIE[0]); - RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString ); + RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", + TitleString); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO"); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\ - pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupported Channel Width = %s\n", + (pCapELE->ChlWidth) ? "20MHz" : "20/40MHz"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 20M = %s\n", + (pCapELE->ShortGI20Mhz) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport Short GI for 40M = %s\n", + (pCapELE->ShortGI40Mhz) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport TX STBC = %s\n", + (pCapELE->TxSTBC) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMSDU Size = %s\n", + (pCapELE->MaxAMSDUSize) ? "3839" : "7935"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", + (pCapELE->DssCCk) ? "YES" : "NO"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMax AMPDU Factor = %d\n", + pCapELE->MaxRxAMPDUFactor); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMPDU Density = %d\n", + pCapELE->MPDUDensity); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", + pCapELE->MCS[0], pCapELE->MCS[1], pCapELE->MCS[2], + pCapELE->MCS[3], pCapELE->MCS[4]); return; } -void HTDebugHTInfo(u8* InfoIE, u8* TitleString) + +void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) { static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; struct ht_info_ele *pHTInfoEle; - if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - { + if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) { RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__); pHTInfoEle = (struct ht_info_ele *)(&InfoIE[4]); - }else + } else pHTInfoEle = (struct ht_info_ele *)(&InfoIE[0]); - RTLLIB_DEBUG(RTLLIB_DL_HT, ". Called by %s\n", TitleString); + RTLLIB_DEBUG(RTLLIB_DL_HT, ". " + "Called by %s\n", TitleString); - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n", + pHTInfoEle->ControlChl); RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSenondary channel ="); - switch (pHTInfoEle->ExtChlOffset) - { - case 0: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n"); - break; - case 1: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n"); - break; - case 2: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n"); - break; - case 3: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n"); - break; + switch (pHTInfoEle->ExtChlOffset) { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n"); + break; } - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz"); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n", + (pHTInfoEle->RecommemdedTxWidth) ? "20Mhz" : "40Mhz"); RTLLIB_DEBUG(RTLLIB_DL_HT, "\tOperation mode for protection = "); - switch (pHTInfoEle->OptMode) - { - case 0: - RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n"); - break; - case 1: - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n"); - break; - case 2: - RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n"); - break; - case 3: - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n"); - break; + switch (pHTInfoEle->OptMode) { + case 0: + RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n"); + break; + case 1: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n"); + break; + case 2: + RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n"); + break; + case 3: + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n"); + break; } - RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\ - pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]); + RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x]" + "[%x]\n", pHTInfoEle->BasicMSC[0], pHTInfoEle->BasicMSC[1], + pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], + pHTInfoEle->BasicMSC[4]); return; } -bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) +bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->bCurrentHTSupport == false ) + if (pHTInfo->bCurrentHTSupport == false) retValue = false; else if (pHTInfo->bRegBW40MHz == false) retValue = false; @@ -198,25 +233,24 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device* ieee) return retValue; } -bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) +bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->bCurrentHTSupport == false ) + if (pHTInfo->bCurrentHTSupport == false) retValue = false; else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) retValue = false; - else if (is40MHz) - { - if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) + else if (is40MHz) { + if (((struct ht_capab_ele *) + (pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) retValue = true; else retValue = false; - } - else - { - if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) + } else { + if (((struct ht_capab_ele *) + (pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) retValue = true; else retValue = false; @@ -225,89 +259,75 @@ bool IsHTHalfNmodeSGI(struct rtllib_device* ieee, bool is40MHz) return retValue; } -u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate) +u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate) { u8 is40MHz; u8 isShortGI; - is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0; - isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0; + is40MHz = (IsHTHalfNmode40Bandwidth(ieee)) ? 1 : 0; + isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz)) ? 1 : 0; - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } -u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate) +u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0; - u8 isShortGI = (pHTInfo->bCurBW40MHz)? - ((pHTInfo->bCurShortGI40MHz)?1:0): - ((pHTInfo->bCurShortGI20MHz)?1:0); - return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)]; + u8 is40MHz = (pHTInfo->bCurBW40MHz) ? 1 : 0; + u8 isShortGI = (pHTInfo->bCurBW40MHz) ? + ((pHTInfo->bCurShortGI40MHz) ? 1 : 0) : + ((pHTInfo->bCurShortGI20MHz) ? 1 : 0); + return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)]; } -u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate) +u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate) { - u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c}; + u16 CCKOFDMRate[12] = {0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, + 0x24, 0x30, 0x48, 0x60, 0x6c}; u8 is40MHz = 0; u8 isShortGI = 0; - if (nDataRate < 12) - { + if (nDataRate < 12) { return CCKOFDMRate[nDataRate]; - } - else - { - if (nDataRate >= 0x10 && nDataRate <= 0x1f) - { + } else { + if (nDataRate >= 0x10 && nDataRate <= 0x1f) { is40MHz = 0; isShortGI = 0; - - } - else if (nDataRate >=0x20 && nDataRate <= 0x2f ) - { + } else if (nDataRate >= 0x20 && nDataRate <= 0x2f) { is40MHz = 1; isShortGI = 0; - } - else if (nDataRate >= 0x30 && nDataRate <= 0x3f ) - { + } else if (nDataRate >= 0x30 && nDataRate <= 0x3f) { is40MHz = 0; isShortGI = 1; - - } - else if (nDataRate >= 0x40 && nDataRate <= 0x4f ) - { + } else if (nDataRate >= 0x40 && nDataRate <= 0x4f) { is40MHz = 1; isShortGI = 1; - } return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf]; } } - - -bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) +bool IsHTHalfNmodeAPs(struct rtllib_device *ieee) { bool retValue = false; - struct rtllib_network* net = &ieee->current_network; + struct rtllib_network *net = &ieee->current_network; - if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - (net->ralink_cap_exist)) + if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || + (memcmp(net->bssid, PCI_RALINK, 3) == 0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || + (net->ralink_cap_exist)) + retValue = true; + else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) || + (net->broadcom_cap_exist)) retValue = true; - else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)|| - (net->broadcom_cap_exist)) - retValue = true; else if (net->bssht.bdRT2RTAggregation) retValue = true; else @@ -316,38 +336,35 @@ bool IsHTHalfNmodeAPs(struct rtllib_device* ieee) return retValue; } -void HTIOTPeerDetermine(struct rtllib_device* ieee) +void HTIOTPeerDetermine(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - struct rtllib_network* net = &ieee->current_network; - if (net->bssht.bdRT2RTAggregation){ + struct rtllib_network *net = &ieee->current_network; + if (net->bssht.bdRT2RTAggregation) { pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK; - if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){ + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE) pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE; - } - if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP){ + if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP) pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP; - } - } - else if (net->broadcom_cap_exist) + } else if (net->broadcom_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if ((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) || - (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)|| - (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)/*|| - (memcmp(net->bssid, NETGEAR834Bv2_BROADCOM, 3)==0) */) + else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) || + !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)) pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) || - (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) || - (memcmp(net->bssid, PCI_RALINK, 3)==0) || - (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) || - (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) || - net->ralink_cap_exist) + else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || + (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || + (memcmp(net->bssid, PCI_RALINK, 3) == 0) || + (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || + (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || + net->ralink_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_RALINK; - else if ((net->atheros_cap_exist )|| - (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0)|| + else if ((net->atheros_cap_exist) || + (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0) || (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0)) pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS; - else if ((memcmp(net->bssid, CISCO_BROADCOM, 3)==0)||net->cisco_cap_exist) + else if ((memcmp(net->bssid, CISCO_BROADCOM, 3) == 0) || + net->cisco_cap_exist) pHTInfo->IOTPeer = HT_IOT_PEER_CISCO; else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) || net->marvell_cap_exist) @@ -357,35 +374,35 @@ void HTIOTPeerDetermine(struct rtllib_device* ieee) else pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; - RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer); + RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n", + pHTInfo->IOTPeer); } -u8 HTIOTActIsDisableMCS14(struct rtllib_device* ieee, u8* PeerMacAddr) +u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) { return 0; - } +} -bool HTIOTActIsDisableMCS15(struct rtllib_device* ieee) +bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) { bool retValue = false; return retValue; } -bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device* ieee) +bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) { - bool retValue = false; - return retValue; + return false; } -u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device* ieee, u8* PeerMacAddr) +u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) { return false; } -bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) +bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device *ieee) { bool retValue = false; @@ -393,70 +410,65 @@ bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device* ieee) } -u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { retValue = 1; - } return retValue; } -u8 -HTIOTActWAIOTBroadcom(struct rtllib_device* ieee) +u8 HTIOTActWAIOTBroadcom(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 retValue = false; - u8 boundary=59; + u8 boundary = 59; pHTInfo->bWAIotBroadcom = false; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if (ieee->current_network.bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40) - { - if (!(pHTInfo->bRegBW40MHz)) - { - if (ieee->current_network.mode != WIRELESS_MODE_B) - { + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { + if (ieee->current_network.bssht.bdBandWidth == + HT_CHANNEL_WIDTH_20_40) { + if (!(pHTInfo->bRegBW40MHz)) { + if (ieee->current_network.mode != + WIRELESS_MODE_B) { pHTInfo->bWAIotBroadcom = true; - if (ieee->b_customer_lenovo_id == true) + if (ieee->b_customer_lenovo_id) boundary = 30; - if ( ieee->current_network.RSSI >= boundary) + if (ieee->current_network.RSSI >= + boundary) retValue = true; } - }else{ - ; } } } return retValue; } -u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - { retValue = 1; - } return retValue; } -u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *network) +u8 HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; @@ -466,54 +478,48 @@ HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, struct rtllib_network *netwo u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) { u8 retValue = 0; + if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { retValue = 1; - } return retValue; } -u8 -HTIOCActRejcectADDBARequest(struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; - -} - -u8 - HTIOTActIsEDCABiasRx(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOCActRejcectADDBARequest(struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActDisableShortGI(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsEDCABiasRx(struct rtllib_device *ieee, + struct rtllib_network *network) +{ + u8 retValue = 0; + + return retValue; +} + +u8 HTIOTActDisableShortGI(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - if (pHTInfo->IOTPeer==HT_IOT_PEER_RALINK) - { + if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK) retValue = 1; - } return retValue; } -u8 -HTIOTActDisableHighPower(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActDisableHighPower(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -void -HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) +void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; @@ -527,81 +533,77 @@ HTIOTActDetermineRaFunc(struct rtllib_device* ieee, bool bPeerRx2ss) } -u8 -HTIOTActIsDisableTx40MHz(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsDisableTx40MHz(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } -u8 -HTIOTActIsTxNoAggregation(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsTxNoAggregation(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } - -u8 -HTIOTActIsDisableTx2SS(struct rtllib_device* ieee,struct rtllib_network *network) +u8 HTIOTActIsDisableTx2SS(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; return retValue; } - -bool HTIOCActIsDisableCckRate(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOCActIsDisableCckRate(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -bool -HTIOTActIsNullDataPowerSaving(struct rtllib_device* ieee,struct rtllib_network *network) +bool HTIOTActIsNullDataPowerSaving(struct rtllib_device *ieee, + struct rtllib_network *network) { bool retValue = false; return retValue; } -void HTResetIOTSetting( - struct rt_hi_throughput *pHTInfo -) +void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo) { pHTInfo->IOTAction = 0; pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; pHTInfo->IOTRaFunc = 0; } - -void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt, bool bAssoc) +void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap, + u8 *len, u8 IsEncrypt, bool bAssoc) { struct rt_hi_throughput *pHT = ieee->pHTInfo; struct ht_capab_ele *pCapELE = NULL; - if ((posHTCap == NULL) || (pHT == NULL)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n"); + if ((posHTCap == NULL) || (pHT == NULL)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be " + "null in HTConstructCapabilityElement()\n"); return; } memset(posHTCap, 0, *len); - if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) - { + if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) { u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap)); pCapELE = (struct ht_capab_ele *)&(posHTCap[4]); *len = 30 + 2; - }else - { + } else { pCapELE = (struct ht_capab_ele *)posHTCap; *len = 26 + 2; } @@ -610,7 +612,7 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pCapELE->ChlWidth = 0; else - pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0); + pCapELE->ChlWidth = (pHT->bRegBW40MHz ? 1 : 0); pCapELE->MimoPwrSave = pHT->SelfMimoPs; pCapELE->GreenField = 0; @@ -620,21 +622,20 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* pCapELE->TxSTBC = 1; pCapELE->RxSTBC = 0; pCapELE->DelayBA = 0; - pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0; - pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0); - pCapELE->PSMP = 0; - pCapELE->LSigTxopProtect = 0; + pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE >= 7935) ? 1 : 0; + pCapELE->DssCCk = ((pHT->bRegBW40MHz) ? (pHT->bRegSuppCCK ? 1 : 0) : 0); + pCapELE->PSMP = 0; + pCapELE->LSigTxopProtect = 0; - RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk); + RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d " + "DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, + pCapELE->DssCCk); - if ( IsEncrypt) - { + if (IsEncrypt) { pCapELE->MPDUDensity = 7; pCapELE->MaxRxAMPDUFactor = 2; - } - else - { + } else { pCapELE->MaxRxAMPDUFactor = 3; pCapELE->MPDUDensity = 0; } @@ -658,67 +659,63 @@ void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* if (pHT->IOTAction & HT_IOT_ACT_DISABLE_RX_40MHZ_SHORT_GI) pCapELE->ShortGI40Mhz = 0; - if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - { + if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) { pCapELE->ChlWidth = 0; - pCapELE->MCS[1] = 0; } } - - - - - return; - } -void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt) + +void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo, + u8 *len, u8 IsEncrypt) { struct rt_hi_throughput *pHT = ieee->pHTInfo; struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo; - if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n"); + if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be " + "null in HTConstructInfoElement()\n"); return; } memset(posHTInfo, 0, *len); - if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) - { + if ((ieee->iw_mode == IW_MODE_ADHOC) || + (ieee->iw_mode == IW_MODE_MASTER)) { pHTInfoEle->ControlChl = ieee->current_network.channel; - pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: - (ieee->current_network.channel<=6)? - HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER); + pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false) ? + HT_EXTCHNL_OFFSET_NO_EXT : + (ieee->current_network.channel <= 6) + ? HT_EXTCHNL_OFFSET_UPPER : + HT_EXTCHNL_OFFSET_LOWER); pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz; - pHTInfoEle->RIFS = 0; + pHTInfoEle->RIFS = 0; pHTInfoEle->PSMPAccessOnly = 0; pHTInfoEle->SrvIntGranularity = 0; - pHTInfoEle->OptMode = pHT->CurrentOpMode; + pHTInfoEle->OptMode = pHT->CurrentOpMode; pHTInfoEle->NonGFDevPresent = 0; pHTInfoEle->DualBeacon = 0; pHTInfoEle->SecondaryBeacon = 0; pHTInfoEle->LSigTxopProtectFull = 0; - pHTInfoEle->PcoActive = 0; - pHTInfoEle->PcoPhase = 0; + pHTInfoEle->PcoActive = 0; + pHTInfoEle->PcoPhase = 0; memset(pHTInfoEle->BasicMSC, 0, 16); *len = 22 + 2; - } - else - { + } else { *len = 0; } return; } -void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len) +void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg, + u8 *len) { if (posRT2RTAgg == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in " + "HTConstructRT2RTAggElement()\n"); return; } memset(posRT2RTAgg, 0, *len); @@ -730,21 +727,20 @@ void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* *posRT2RTAgg = 0x30; - if (ieee->bSupportRemoteWakeUp) { + if (ieee->bSupportRemoteWakeUp) *posRT2RTAgg |= RT_HT_CAP_USE_WOW; - } *len = 6 + 2; return; } -u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) +u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) { - u8 i; - if (pOperateMCS == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n"); + u8 i; + if (pOperateMCS == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null" + " in HT_PickMCSRate()\n"); return false; } @@ -752,14 +748,14 @@ u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) case IEEE_A: case IEEE_B: case IEEE_G: - for (i=0;i<=15;i++) - pOperateMCS[i] = 0; + for (i = 0; i <= 15; i++) + pOperateMCS[i] = 0; break; case IEEE_N_24G: case IEEE_N_5G: - pOperateMCS[0] &=RATE_ADPT_1SS_MASK; - pOperateMCS[1] &=RATE_ADPT_2SS_MASK; - pOperateMCS[3] &=RATE_ADPT_MCS32_MASK; + pOperateMCS[0] &= RATE_ADPT_1SS_MASK; + pOperateMCS[1] &= RATE_ADPT_2SS_MASK; + pOperateMCS[3] &= RATE_ADPT_MCS32_MASK; break; default: break; @@ -769,145 +765,151 @@ u8 HT_PickMCSRate(struct rtllib_device* ieee, u8* pOperateMCS) return true; } -u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter) +u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, + u8 *pMCSFilter) { u8 i, j; u8 bitMap; u8 mcsRate = 0; u8 availableMcsRate[16]; - if (pMCSRateSet == NULL || pMCSFilter == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n"); + if (pMCSRateSet == NULL || pMCSFilter == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't " + "be null in HTGetHighestMCSRate()\n"); return false; } - for (i=0; i<16; i++) + for (i = 0; i < 16; i++) availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i]; - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if (availableMcsRate[i] != 0) break; } if (i == 16) return false; - for (i = 0; i < 16; i++) - { - if (availableMcsRate[i] != 0) - { + for (i = 0; i < 16; i++) { + if (availableMcsRate[i] != 0) { bitMap = availableMcsRate[i]; - for (j = 0; j < 8; j++) - { - if ((bitMap%2) != 0) - { - if (HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate)) + for (j = 0; j < 8; j++) { + if ((bitMap%2) != 0) { + if (HTMcsToDataRate(ieee, (8*i+j)) > + HTMcsToDataRate(ieee, mcsRate)) mcsRate = (8*i+j); } bitMap = bitMap>>1; } } } - return (mcsRate|0x80); + return mcsRate | 0x80; } -u8 HTFilterMCSRate( struct rtllib_device* ieee, u8* pSupportMCS, u8* pOperateMCS) +u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS, u8 *pOperateMCS) { - u8 i=0; - - for (i=0;i<=15;i++){ - pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i]&pSupportMCS[i]; - } - + u8 i; + for (i = 0; i <= 15; i++) + pOperateMCS[i] = ieee->Regdot11TxHTOperationalRateSet[i] & + pSupportMCS[i]; HT_PickMCSRate(ieee, pOperateMCS); if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) pOperateMCS[1] = 0; - for (i=2; i<=15; i++) + for (i = 2; i <= 15; i++) pOperateMCS[i] = 0; return true; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); + +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); + void HTOnAssocRsp(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct ht_capab_ele *pPeerHTCap = NULL; struct ht_info_ele *pPeerHTInfo = NULL; - u16 nMaxAMSDUSize = 0; - u8* pMcsFilter = NULL; + u16 nMaxAMSDUSize = 0; + u8 *pMcsFilter = NULL; - static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; - static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; + static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; + static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; - if ( pHTInfo->bCurrentHTSupport == false ) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); + if (pHTInfo->bCurrentHTSupport == false) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): " + "HT_DISABLE\n"); return; } RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n"); - if (!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap))) + if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap))) pPeerHTCap = (struct ht_capab_ele *)(&pHTInfo->PeerHTCapBuf[4]); else pPeerHTCap = (struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf); if (!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo))) - pPeerHTInfo = (struct ht_info_ele *)(&pHTInfo->PeerHTInfoBuf[4]); + pPeerHTInfo = (struct ht_info_ele *) + (&pHTInfo->PeerHTInfoBuf[4]); else pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf); - RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_HT, pPeerHTCap, sizeof(struct ht_capab_ele)); - HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); - pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); + RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA | RTLLIB_DL_HT, pPeerHTCap, + sizeof(struct ht_capab_ele)); + HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth), + (enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset)); + pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ? + true : false); - pHTInfo->bCurShortGI20MHz= - ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false); - pHTInfo->bCurShortGI40MHz= - ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false); + pHTInfo->bCurShortGI20MHz = ((pHTInfo->bRegShortGI20MHz) ? + ((pPeerHTCap->ShortGI20Mhz == 1) ? + true : false) : false); + pHTInfo->bCurShortGI40MHz = ((pHTInfo->bRegShortGI40MHz) ? + ((pPeerHTCap->ShortGI40Mhz == 1) ? + true : false) : false); - pHTInfo->bCurSuppCCK = - ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false); + pHTInfo->bCurSuppCCK = ((pHTInfo->bRegSuppCCK) ? + ((pPeerHTCap->DssCCk == 1) ? true : + false) : false); pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; - nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935; + nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize == 0) ? 3839 : 7935; - if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize ) + if (pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize) pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize; else pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable; if (ieee->rtllib_ap_sec_type && - (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))){ - if ( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) || - (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) ) + (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) { + if ((pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) || + (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN)) pHTInfo->bCurrentAMPDUEnable = false; } - if (!pHTInfo->bRegRT2RTAggregation) - { + if (!pHTInfo->bRegRT2RTAggregation) { if (pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; } else { - if (ieee->current_network.bssht.bdRT2RTAggregation) - { - if ( ieee->pairwise_key_type != KEY_TYPE_NA) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + if (ieee->current_network.bssht.bdRT2RTAggregation) { + if (ieee->pairwise_key_type != KEY_TYPE_NA) + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K; - }else - { + } else { if (pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K) - pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor; + pHTInfo->CurrentAMPDUFactor = + pPeerHTCap->MaxRxAMPDUFactor; else pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K; } @@ -916,8 +918,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; else pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity; - if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) - { + if (pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K) { pHTInfo->bCurrentAMPDUEnable = false; pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE; pHTInfo->ForcedAMSDUMaxSize = 7935; @@ -927,7 +928,7 @@ void HTOnAssocRsp(struct rtllib_device *ieee) if (pPeerHTCap->MCS[0] == 0) pPeerHTCap->MCS[0] = 0xff; - HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0)); + HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1]) != 0)); HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet); @@ -936,15 +937,14 @@ void HTOnAssocRsp(struct rtllib_device *ieee) pMcsFilter = MCS_FILTER_1SS; else pMcsFilter = MCS_FILTER_ALL; - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter); + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, + ieee->dot11HTOperationalRateSet, pMcsFilter); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - } -void HTSetConnectBwModeCallback(struct rtllib_device* ieee); -void HTInitializeHTInfo(struct rtllib_device* ieee) +void HTInitializeHTInfo(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -965,10 +965,14 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density; pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor; - memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap)); - memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo)); - memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf)); - memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf)); + memset((void *)(&(pHTInfo->SelfHTCap)), 0, + sizeof(pHTInfo->SelfHTCap)); + memset((void *)(&(pHTInfo->SelfHTInfo)), 0, + sizeof(pHTInfo->SelfHTInfo)); + memset((void *)(&(pHTInfo->PeerHTCapBuf)), 0, + sizeof(pHTInfo->PeerHTCapBuf)); + memset((void *)(&(pHTInfo->PeerHTInfoBuf)), 0, + sizeof(pHTInfo->PeerHTInfoBuf)); pHTInfo->bSwBwInProgress = false; pHTInfo->ChnlOp = CHNLOP_NONE; @@ -984,12 +988,13 @@ void HTInitializeHTInfo(struct rtllib_device* ieee) pHTInfo->IOTRaFunc = 0; { - u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); + u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]); RegHTSuppRateSets[0] = 0xFF; RegHTSuppRateSets[1] = 0xFF; RegHTSuppRateSets[4] = 0x01; } } + void HTInitializeBssDesc(struct bss_ht *pBssHT) { @@ -999,39 +1004,46 @@ void HTInitializeBssDesc(struct bss_ht *pBssHT) memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf)); pBssHT->bdHTInfoLen = 0; - pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE; + pBssHT->bdHTSpecVer = HT_SPEC_VER_IEEE; pBssHT->bdRT2RTAggregation = false; pBssHT->bdRT2RTLongSlotTime = false; pBssHT->RT2RT_HT_Mode = (enum rt_ht_capability)0; } -void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; u8 bIOTAction = 0; RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__); - /*unmark bEnableHT flag here is the same reason why unmarked in function rtllib_softmac_new_net. WB 2008.09.10*/ - if (pNetwork->bssht.bdSupportHT) - { + /* unmark bEnableHT flag here is the same reason why unmarked in + * function rtllib_softmac_new_net. WB 2008.09.10*/ + if (pNetwork->bssht.bdSupportHT) { pHTInfo->bCurrentHTSupport = true; pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer; - if (pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) - memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen); + if (pNetwork->bssht.bdHTCapLen > 0 && + pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf)) + memcpy(pHTInfo->PeerHTCapBuf, + pNetwork->bssht.bdHTCapBuf, + pNetwork->bssht.bdHTCapLen); - if (pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf)) - memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen); + if (pNetwork->bssht.bdHTInfoLen > 0 && + pNetwork->bssht.bdHTInfoLen <= + sizeof(pHTInfo->PeerHTInfoBuf)) + memcpy(pHTInfo->PeerHTInfoBuf, + pNetwork->bssht.bdHTInfoBuf, + pNetwork->bssht.bdHTInfoLen); - if (pHTInfo->bRegRT2RTAggregation) - { - pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation; - pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime; + if (pHTInfo->bRegRT2RTAggregation) { + pHTInfo->bCurrentRT2RTAggregation = + pNetwork->bssht.bdRT2RTAggregation; + pHTInfo->bCurrentRT2RTLongSlotTime = + pNetwork->bssht.bdRT2RTLongSlotTime; pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode; - } - else - { + } else { pHTInfo->bCurrentRT2RTAggregation = false; pHTInfo->bCurrentRT2RTLongSlotTime = false; pHTInfo->RT2RT_HT_Mode = (enum rt_ht_capability)0; @@ -1057,7 +1069,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO; - bIOTAction = HTIOTActIsMgntUseCCK6M(ieee,pNetwork); + bIOTAction = HTIOTActIsMgntUseCCK6M(ieee, pNetwork); if (bIOTAction) pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M; bIOTAction = HTIOTActIsCCDFsync(ieee); @@ -1072,23 +1084,22 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_net pHTInfo->IOTAction = 0; pHTInfo->IOTRaFunc = 0; } - } -void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork) +void HTUpdateSelfAndPeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - struct ht_info_ele *pPeerHTInfo = (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf; + struct ht_info_ele *pPeerHTInfo = + (struct ht_info_ele *)pNetwork->bssht.bdHTInfoBuf; - if (pHTInfo->bCurrentHTSupport) - { + if (pHTInfo->bCurrentHTSupport) { if (pNetwork->bssht.bdHTInfoLen != 0) pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode; - } } -void HTUseDefaultSetting(struct rtllib_device* ieee) +void HTUseDefaultSetting(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -1097,14 +1108,13 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK; pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz; - pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz; + pHTInfo->bCurShortGI20MHz = pHTInfo->bRegShortGI20MHz; - pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz; + pHTInfo->bCurShortGI40MHz = pHTInfo->bRegShortGI40MHz; if (ieee->iw_mode == IW_MODE_ADHOC) - { - ieee->current_network.qos_data.active = ieee->current_network.qos_data.supported; - } + ieee->current_network.qos_data.active = + ieee->current_network.qos_data.supported; pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support; pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize; @@ -1113,9 +1123,11 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity; - - HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, ieee->dot11HTOperationalRateSet); - ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL); + HTFilterMCSRate(ieee, ieee->Regdot11TxHTOperationalRateSet, + ieee->dot11HTOperationalRateSet); + ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, + ieee->dot11HTOperationalRateSet, + MCS_FILTER_ALL); ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate; } else { @@ -1124,20 +1136,49 @@ void HTUseDefaultSetting(struct rtllib_device* ieee) return; } -u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame) +u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame) { - if (ieee->pHTInfo->bCurrentHTSupport) - { - if ( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) - { - RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED EXIST!!\n"); + if (ieee->pHTInfo->bCurrentHTSupport) { + if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) { + RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED " + "EXIST!!\n"); return true; } } return false; } -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset) +void HTSetConnectBwModeCallback(struct rtllib_device *ieee) +{ + struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; + + RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); + if (pHTInfo->bCurBW40MHz) { + if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER) + ieee->set_chan(ieee->dev, + ieee->current_network.channel + 2); + else if (pHTInfo->CurSTAExtChnlOffset == + HT_EXTCHNL_OFFSET_LOWER) + ieee->set_chan(ieee->dev, + ieee->current_network.channel - 2); + else + ieee->set_chan(ieee->dev, + ieee->current_network.channel); + + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, + pHTInfo->CurSTAExtChnlOffset); + } else { + ieee->set_chan(ieee->dev, ieee->current_network.channel); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, + HT_EXTCHNL_OFFSET_NO_EXT); + } + + pHTInfo->bSwBwInProgress = false; +} + +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -1145,18 +1186,18 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwi return; if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) - Bandwidth=HT_CHANNEL_WIDTH_20; - + Bandwidth = HT_CHANNEL_WIDTH_20; if (pHTInfo->bSwBwInProgress) { - printk("%s: bSwBwInProgress!!\n", __func__); + printk(KERN_INFO "%s: bSwBwInProgress!!\n", __func__); return; } - if (Bandwidth==HT_CHANNEL_WIDTH_20_40) - { - if (ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER) + if (Bandwidth == HT_CHANNEL_WIDTH_20_40) { + if (ieee->current_network.channel < 2 && + Offset == HT_EXTCHNL_OFFSET_LOWER) Offset = HT_EXTCHNL_OFFSET_NO_EXT; - if (Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) { + if (Offset == HT_EXTCHNL_OFFSET_UPPER || + Offset == HT_EXTCHNL_OFFSET_LOWER) { pHTInfo->bCurBW40MHz = true; pHTInfo->CurSTAExtChnlOffset = Offset; } else { @@ -1168,33 +1209,10 @@ void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwi pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT; } - printk("%s():pHTInfo->bCurBW40MHz:%x\n", __func__, pHTInfo->bCurBW40MHz); + printk(KERN_INFO "%s():pHTInfo->bCurBW40MHz:%x\n", __func__, + pHTInfo->bCurBW40MHz); pHTInfo->bSwBwInProgress = true; HTSetConnectBwModeCallback(ieee); - -} - -void HTSetConnectBwModeCallback(struct rtllib_device* ieee) -{ - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - - RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__); - if (pHTInfo->bCurBW40MHz) - { - if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER) - ieee->set_chan(ieee->dev, ieee->current_network.channel+2); - else if (pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER) - ieee->set_chan(ieee->dev, ieee->current_network.channel-2); - else - ieee->set_chan(ieee->dev, ieee->current_network.channel); - - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset); - } else { - ieee->set_chan(ieee->dev, ieee->current_network.channel); - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - } - - pHTInfo->bSwBwInProgress = false; } From d76eaf7eb8fb0e710c5e1ce74fafbb63b2096a8e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 27 Jul 2011 15:15:28 -0500 Subject: [PATCH 08/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VI Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_Qos.h | 245 +++++++------- drivers/staging/rtl8192e/rtl819x_TS.h | 2 + drivers/staging/rtl8192e/rtl819x_TSProc.c | 369 ++++++++++------------ 3 files changed, 310 insertions(+), 306 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h index 0d2f8bff4748..5ecd556f0797 100644 --- a/drivers/staging/rtl8192e/rtl819x_Qos.h +++ b/drivers/staging/rtl8192e/rtl819x_Qos.h @@ -21,38 +21,38 @@ #include "rtllib_endianfree.h" -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 union qos_tsinfo { u8 charData[3]; @@ -67,14 +67,13 @@ union qos_tsinfo { u8 ucTSInfoAckPolicy:2; u8 ucSchedule:1; u8 ucReserved:7; - }field; + } field; }; union tspec_body { u8 charData[55]; - struct - { + struct { union qos_tsinfo TSInfo; u16 NominalMSDUsize; u16 MaxMSDUsize; @@ -105,9 +104,10 @@ struct wmm_tspec { }; struct octet_string { - u8 *Octet; - u16 Length; + u8 *Octet; + u16 Length; }; + #define MAX_WMMELE_LENGTH 64 #define QOS_MODE u32 @@ -143,28 +143,43 @@ enum ack_policy { }; -#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) WriteEF1Byte(_pStart, _val) +#define SET_WMM_QOS_INFO_FIELD(_pStart, _val) \ + WriteEF1Byte(_pStart, _val) -#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 4) -#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) +#define GET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 0, 4) +#define SET_WMM_QOS_INFO_FIELD_PARAMETERSET_COUNT(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 0, 4, _val) -#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 7, 1) -#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 7, 1) +#define SET_WMM_QOS_INFO_FIELD_AP_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 7, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 0, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 0, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VO_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 0, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 1, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 1, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_VI_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 1, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 2, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 2, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BE_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 2, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) LE_BITS_TO_1BYTE(_pStart, 3, 1) -#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 3, 1) +#define SET_WMM_QOS_INFO_FIELD_STA_AC_BK_UAPSD(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 3, 1, _val) -#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) LE_BITS_TO_1BYTE(_pStart, 5, 2) -#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) +#define GET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart) \ + LE_BITS_TO_1BYTE(_pStart, 5, 2) +#define SET_WMM_QOS_INFO_FIELD_STA_MAX_SP_LEN(_pStart, _val) \ + SET_BITS_TO_LE_1BYTE(_pStart, 5, 2, _val) enum qos_ie_source { QOSIE_SRC_ADDTSREQ, @@ -186,26 +201,40 @@ enum qos_ie_source { #define AC_PARAM_SIZE 4 -#define GET_WMM_AC_PARAM_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 4) ) -#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val) +#define GET_WMM_AC_PARAM_AIFSN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 0, 4)) +#define SET_WMM_AC_PARAM_AIFSN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 0, 4, _val) -#define GET_WMM_AC_PARAM_ACM(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 4, 1) ) -#define SET_WMM_AC_PARAM_ACM(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val) +#define GET_WMM_AC_PARAM_ACM(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 4, 1)) +#define SET_WMM_AC_PARAM_ACM(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 4, 1, _val) -#define GET_WMM_AC_PARAM_ACI(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 5, 2) ) -#define SET_WMM_AC_PARAM_ACI(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val) +#define GET_WMM_AC_PARAM_ACI(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 5, 2)) +#define SET_WMM_AC_PARAM_ACI(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 5, 2, _val) -#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 0, 8) ) -#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val) +#define GET_WMM_AC_PARAM_ACI_AIFSN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 0, 8)) +#define SET_WMM_AC_PARAM_ACI_AIFSN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 0, 8, _val) -#define GET_WMM_AC_PARAM_ECWMIN(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 8, 4) ) -#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val) +#define GET_WMM_AC_PARAM_ECWMIN(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 8, 4)) +#define SET_WMM_AC_PARAM_ECWMIN(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 8, 4, _val) -#define GET_WMM_AC_PARAM_ECWMAX(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 12, 4) ) -#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val) +#define GET_WMM_AC_PARAM_ECWMAX(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 12, 4)) +#define SET_WMM_AC_PARAM_ECWMAX(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 12, 4, _val) -#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) ( (u8)LE_BITS_TO_4BYTE(_pStart, 16, 16) ) -#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val) +#define GET_WMM_AC_PARAM_TXOP_LIMIT(_pStart) \ + ((u8)LE_BITS_TO_4BYTE(_pStart, 16, 16)) +#define SET_WMM_AC_PARAM_TXOP_LIMIT(_pStart, _val) \ + SET_BITS_TO_LE_4BYTE(_pStart, 16, 16, _val) @@ -255,13 +284,13 @@ struct acm { union qos_tclas { - struct _TYPE_GENERAL{ + struct _TYPE_GENERAL { u8 Priority; u8 ClassifierType; u8 Mask; } TYPE_GENERAL; - struct _TYPE0_ETH{ + struct _TYPE0_ETH { u8 Priority; u8 ClassifierType; u8 Mask; @@ -270,7 +299,7 @@ union qos_tclas { u16 Type; } TYPE0_ETH; - struct _TYPE1_IPV4{ + struct _TYPE1_IPV4 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -284,7 +313,7 @@ union qos_tclas { u8 Reserved; } TYPE1_IPV4; - struct _TYPE1_IPV6{ + struct _TYPE1_IPV6 { u8 Priority; u8 ClassifierType; u8 Mask; @@ -296,7 +325,7 @@ union qos_tclas { u8 FlowLabel[3]; } TYPE1_IPV6; - struct _TYPE2_8021Q{ + struct _TYPE2_8021Q { u8 Priority; u8 ClassifierType; u8 Mask; @@ -317,20 +346,20 @@ struct qos_tstream { }; struct sta_qos { - u8 WMMIEBuf[MAX_WMMELE_LENGTH]; - u8* WMMIE; + u8 WMMIEBuf[MAX_WMMELE_LENGTH]; + u8 *WMMIE; - QOS_MODE QosCapability; - QOS_MODE CurrentQosMode; + QOS_MODE QosCapability; + QOS_MODE CurrentQosMode; - AC_UAPSD b4ac_Uapsd; - AC_UAPSD Curr4acUapsd; - u8 bInServicePeriod; - u8 MaxSPLength; - int NumBcnBeforeTrigger; + AC_UAPSD b4ac_Uapsd; + AC_UAPSD Curr4acUapsd; + u8 bInServicePeriod; + u8 MaxSPLength; + int NumBcnBeforeTrigger; - u8 * pWMMInfoEle; - u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; + u8 *pWMMInfoEle; + u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE]; struct acm acm[4]; enum acm_method AcmMethod; @@ -347,67 +376,69 @@ struct sta_qos { }; -#define QBSS_LOAD_SIZE 5 -#define GET_QBSS_LOAD_STA_COUNT(__pStart) ReadEF2Byte(__pStart) -#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) WriteEF2Byte(__pStart, __Value) -#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) ReadEF1Byte((u8*)(__pStart) + 2) -#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) WriteEF1Byte((u8*)(__pStart) + 2, __Value) -#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) ReadEF2Byte((u8*)(__pStart) + 3) -#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) WriteEF2Byte((u8*)(__pStart) + 3, __Value) +#define QBSS_LOAD_SIZE 5 +#define GET_QBSS_LOAD_STA_COUNT(__pStart) \ + ReadEF2Byte(__pStart) +#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value) \ + WriteEF2Byte(__pStart, __Value) +#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart) \ + ReadEF1Byte((u8 *)(__pStart) + 2) +#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value) \ + WriteEF1Byte((u8 *)(__pStart) + 2, __Value) +#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart) \ + ReadEF2Byte((u8 *)(__pStart) + 3) +#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) \ + WriteEF2Byte((u8 *)(__pStart) + 3, __Value) struct bss_qos { - - QOS_MODE bdQoSMode; - u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; + QOS_MODE bdQoSMode; + u8 bdWMMIEBuf[MAX_WMMELE_LENGTH]; struct octet_string bdWMMIE; enum qos_ele_subtype EleSubType; - u8* pWMMInfoEle; - u8* pWMMParamEle; + u8 *pWMMInfoEle; + u8 *pWMMParamEle; - u8 QBssLoad[QBSS_LOAD_SIZE]; - bool bQBssLoadValid; + u8 QBssLoad[QBSS_LOAD_SIZE]; + bool bQBssLoadValid; }; #define sQoSCtlLng 2 -#define QOS_CTRL_LEN(_QosMode) ( (_QosMode > QOS_DISABLE)? sQoSCtlLng : 0 ) +#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE) ? sQoSCtlLng : 0) -#define IsACValid(ac) ( ( ac>=0 && ac<=7 )? true : false ) +#define IsACValid(ac) ((ac >= 0 && ac <= 7) ? true : false) union aci_aifsn { u8 charData; - struct - { + struct { u8 AIFSN:4; u8 acm:1; u8 ACI:2; u8 Reserved:1; - }f; + } f; }; union ecw { u8 charData; - struct - { + struct { u8 ECWmin:4; u8 ECWmax:4; - }f; + } f; }; union ac_param { u32 longData; u8 charData[4]; - struct - { + struct { union aci_aifsn AciAifsn; union ecw Ecw; u16 TXOPLimit; - }f; + } f; }; #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h index b4bebab36327..8601b1ad217d 100644 --- a/drivers/staging/rtl8192e/rtl819x_TS.h +++ b/drivers/staging/rtl8192e/rtl819x_TS.h @@ -67,5 +67,7 @@ struct rx_ts_record { u8 num; }; +void _setup_timer(struct timer_list *, void *, unsigned long); + #endif diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index a6dbd26c6910..519349f0ce4b 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -19,7 +19,6 @@ #include "rtllib.h" #include #include "rtl819x_TS.h" -extern void _setup_timer( struct timer_list*, void*, unsigned long); void TsSetupTimeOut(unsigned long data) { @@ -32,7 +31,8 @@ void TsInactTimeout(unsigned long data) void RxPktPendingTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; - struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]); + struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, + RxTsRecord[pRxTs->num]); struct rx_reorder_entry *pReorderEntry = NULL; @@ -42,51 +42,57 @@ void RxPktPendingTimeout(unsigned long data) bool bPktInBuf = false; spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - if (pRxTs->RxTimeoutIndicateSeq != 0xffff) - { - while(!list_empty(&pRxTs->RxPendingPktList)) - { - pReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTs->RxPendingPktList.prev,struct rx_reorder_entry,List); + if (pRxTs->RxTimeoutIndicateSeq != 0xffff) { + while (!list_empty(&pRxTs->RxPendingPktList)) { + pReorderEntry = (struct rx_reorder_entry *) + list_entry(pRxTs->RxPendingPktList.prev, + struct rx_reorder_entry, List); if (index == 0) pRxTs->RxIndicateSeq = pReorderEntry->SeqNum; - if ( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ) - { + if (SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) { list_del_init(&pReorderEntry->List); - if (SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) - pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096; + if (SN_EQUAL(pReorderEntry->SeqNum, + pRxTs->RxIndicateSeq)) + pRxTs->RxIndicateSeq = + (pRxTs->RxIndicateSeq + 1) % 4096; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum: %d\n",__func__, pReorderEntry->SeqNum); - stats_IndicateArray[index] = pReorderEntry->prxb; + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate" + " SeqNum: %d\n", __func__, + pReorderEntry->SeqNum); + stats_IndicateArray[index] = + pReorderEntry->prxb; index++; - list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List); - } - else - { + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); + } else { bPktInBuf = true; break; } } } - if (index>0){ + if (index > 0) { pRxTs->RxTimeoutIndicateSeq = 0xffff; - if (index > REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + if (index > REORDER_WIN_SIZE) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " Rx Reorer struct buffer full!!\n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), + flags); return; } rtllib_indicate_packets(ieee, stats_IndicateArray, index); bPktInBuf = false; } - if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)){ + if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq == 0xffff)) { pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq; - mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime)); + mod_timer(&pRxTs->RxPktPendingTimer, jiffies + + MSECS(ieee->pHTInfo->RxReorderPendingTime)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } @@ -95,13 +101,14 @@ void TsAddBaProcess(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; u8 num = pTxTs->num; - struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[num]); + struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, + TxTsRecord[num]); TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); - RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is " + "started!!\n"); } - void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); @@ -142,8 +149,7 @@ void TSInitialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List); - for (count = 0; count < TOTAL_TS_NUM; count++) - { + for (count = 0; count < TOTAL_TS_NUM; count++) { pTxTS->num = count; _setup_timer(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut, @@ -173,8 +179,7 @@ void TSInitialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List); INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List); INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List); - for (count = 0; count < TOTAL_TS_NUM; count++) - { + for (count = 0; count < TOTAL_TS_NUM; count++) { pRxTS->num = count; INIT_LIST_HEAD(&pRxTS->RxPendingPktList); @@ -195,13 +200,14 @@ void TSInitialize(struct rtllib_device *ieee) (unsigned long) pRxTS); ResetRxTsEntry(pRxTS); - list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List); + list_add_tail(&pRxTS->TsCommonInfo.List, + &ieee->Rx_TS_Unused_List); pRxTS++; } INIT_LIST_HEAD(&ieee->RxReorder_Unused_List); - for (count = 0; count < REORDER_ENTRY_NUM; count++) - { - list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + for (count = 0; count < REORDER_ENTRY_NUM; count++) { + list_add_tail(&pRxReorderEntry->List, + &ieee->RxReorder_Unused_List); if (count == (REORDER_ENTRY_NUM-1)) break; pRxReorderEntry = &ieee->RxReorderEntry[count+1]; @@ -209,55 +215,46 @@ void TSInitialize(struct rtllib_device *ieee) } -void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, u32 InactTime) +void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, + u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); - if (InactTime!=0) - mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime)); + if (InactTime != 0) + mod_timer(&pTsCommonInfo->InactTimer, jiffies + + MSECS(InactTime)); } - -struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, u8 TID, enum tr_select TxRxSelect) +struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, + u8 TID, enum tr_select TxRxSelect) { u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; - struct list_head* psearch_list; + bool search_dir[4] = {0, 0, 0, 0}; + struct list_head *psearch_list; struct ts_common_info *pRet = NULL; - if (ieee->iw_mode == IW_MODE_MASTER) - { - if (TxRxSelect == TX_DIR) - { + if (ieee->iw_mode == IW_MODE_MASTER) { + if (TxRxSelect == TX_DIR) { search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; + search_dir[DIR_BI_DIR] = true; + } else { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR] = true; } - else - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - } - } - else if (ieee->iw_mode == IW_MODE_ADHOC) - { + } else if (ieee->iw_mode == IW_MODE_ADHOC) { if (TxRxSelect == TX_DIR) - search_dir[DIR_UP] = true; + search_dir[DIR_UP] = true; else search_dir[DIR_DOWN] = true; - } - else - { - if (TxRxSelect == TX_DIR) - { - search_dir[DIR_UP] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; - } - else - { + } else { + if (TxRxSelect == TX_DIR) { + search_dir[DIR_UP] = true; + search_dir[DIR_BI_DIR] = true; + search_dir[DIR_DIRECT] = true; + } else { search_dir[DIR_DOWN] = true; - search_dir[DIR_BI_DIR]= true; - search_dir[DIR_DIRECT]= true; + search_dir[DIR_BI_DIR] = true; + search_dir[DIR_DIRECT] = true; } } @@ -266,38 +263,29 @@ struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8* Addr, else psearch_list = &ieee->Rx_TS_Admit_List; - for (dir = 0; dir <= DIR_BI_DIR; dir++) - { - if (search_dir[dir] ==false ) + for (dir = 0; dir <= DIR_BI_DIR; dir++) { + if (search_dir[dir] == false) continue; - list_for_each_entry(pRet, psearch_list, List){ + list_for_each_entry(pRet, psearch_list, List) { if (memcmp(pRet->Addr, Addr, 6) == 0) if (pRet->TSpec.f.TSInfo.field.ucTSID == TID) if (pRet->TSpec.f.TSInfo.field.ucDirection == dir) - { break; - } } if (&pRet->List != psearch_list) break; } - if (&pRet->List != psearch_list){ + if (&pRet->List != psearch_list) return pRet ; - } else return NULL; } -void MakeTSEntry( - struct ts_common_info *pTsCommonInfo, - u8* Addr, - union tspec_body *pTSPEC, - union qos_tclas *pTCLAS, - u8 TCLAS_Num, - u8 TCLAS_Proc - ) +void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, + union tspec_body *pTSPEC, union qos_tclas *pTCLAS, + u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -307,34 +295,32 @@ void MakeTSEntry( memcpy(pTsCommonInfo->Addr, Addr, 6); if (pTSPEC != NULL) - memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(union tspec_body)); + memcpy((u8 *)(&(pTsCommonInfo->TSpec)), (u8 *)pTSPEC, + sizeof(union tspec_body)); for (count = 0; count < TCLAS_Num; count++) - memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(union qos_tclas)); + memcpy((u8 *)(&(pTsCommonInfo->TClass[count])), + (u8 *)pTCLAS, sizeof(union qos_tclas)); pTsCommonInfo->TClasProc = TCLAS_Proc; pTsCommonInfo->TClasNum = TCLAS_Num; } -bool GetTs( - struct rtllib_device* ieee, - struct ts_common_info **ppTS, - u8* Addr, - u8 TID, - enum tr_select TxRxSelect, - bool bAddNewTs) +bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, + u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs) { u8 UP = 0; - if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or Multicast\n"); + if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or " + "Multicast\n"); return false; } if (ieee->current_network.qos_data.supported == 0) { UP = 0; } else { if (!IsACValid(TID)) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is not valid\n", __func__, TID); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is " + "not valid\n", __func__, TID); return false; } @@ -358,55 +344,54 @@ bool GetTs( } } - *ppTS = SearchAdmitTRStream( - ieee, - Addr, - UP, - TxRxSelect); - if (*ppTS != NULL) - { + *ppTS = SearchAdmitTRStream(ieee, Addr, UP, TxRxSelect); + if (*ppTS != NULL) { return true; - } - else - { - if (bAddNewTs == false) - { - RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed(tid:%d)\n", UP); + } else { + if (bAddNewTs == false) { + RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed" + "(tid:%d)\n", UP); return false; - } - else - { + } else { union tspec_body TSpec; union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo; - struct list_head* pUnusedList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Unused_List): - (&ieee->Rx_TS_Unused_List); + struct list_head *pUnusedList = + (TxRxSelect == TX_DIR) ? + (&ieee->Tx_TS_Unused_List) : + (&ieee->Rx_TS_Unused_List); - struct list_head* pAddmitList = - (TxRxSelect == TX_DIR)? - (&ieee->Tx_TS_Admit_List): - (&ieee->Rx_TS_Admit_List); + struct list_head *pAddmitList = + (TxRxSelect == TX_DIR) ? + (&ieee->Tx_TS_Admit_List) : + (&ieee->Rx_TS_Admit_List); - enum direction_value Dir = (ieee->iw_mode == IW_MODE_MASTER)? - ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP): - ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN); + enum direction_value Dir = + (ieee->iw_mode == IW_MODE_MASTER) ? + ((TxRxSelect == TX_DIR) ? DIR_DOWN : DIR_UP) : + ((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN); RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n"); - if (!list_empty(pUnusedList)) - { - (*ppTS) = list_entry(pUnusedList->next, struct ts_common_info, List); + if (!list_empty(pUnusedList)) { + (*ppTS) = list_entry(pUnusedList->next, + struct ts_common_info, List); list_del_init(&(*ppTS)->List); - if (TxRxSelect==TX_DIR) - { - struct tx_ts_record *tmp = container_of(*ppTS, struct tx_ts_record, TsCommonInfo); + if (TxRxSelect == TX_DIR) { + struct tx_ts_record *tmp = + container_of(*ppTS, + struct tx_ts_record, + TsCommonInfo); ResetTxTsEntry(tmp); - } - else{ - struct rx_ts_record *tmp = container_of(*ppTS, struct rx_ts_record, TsCommonInfo); + } else { + struct rx_ts_record *tmp = + container_of(*ppTS, + struct rx_ts_record, + TsCommonInfo); ResetRxTsEntry(tmp); } - RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:"MAC_FMT" ppTs=%p\n", UP, Dir, MAC_ARG(Addr), *ppTS); + RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS" + ", UP:%d, Dir:%d, addr:"MAC_FMT + " ppTs=%p\n", UP, Dir, + MAC_ARG(Addr), *ppTS); pTSInfo->field.ucTrafficType = 0; pTSInfo->field.ucTSID = UP; pTSInfo->field.ucDirection = Dir; @@ -422,99 +407,90 @@ bool GetTs( list_add_tail(&((*ppTS)->List), pAddmitList); return true; - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!", __func__,Dir); + } else { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function " + "%s() There is not enough dir=%d" + "(0=up down=1) TS record to be " + "used!!", __func__, Dir); return false; } } } } -void RemoveTsEntry( - struct rtllib_device* ieee, - struct ts_common_info *pTs, - enum tr_select TxRxSelect - ) +void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, + enum tr_select TxRxSelect) { del_timer_sync(&pTs->SetupTimer); del_timer_sync(&pTs->InactTimer); TsInitDelBA(ieee, pTs, TxRxSelect); - if (TxRxSelect == RX_DIR) - { + if (TxRxSelect == RX_DIR) { struct rx_reorder_entry *pRxReorderEntry; struct rx_ts_record *pRxTS = (struct rx_ts_record *)pTs; if (timer_pending(&pRxTS->RxPktPendingTimer)) del_timer_sync(&pRxTS->RxPktPendingTimer); - while(!list_empty(&pRxTS->RxPendingPktList)){ - pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pRxTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Delete SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + while (!list_empty(&pRxTS->RxPendingPktList)) { + pRxReorderEntry = (struct rx_reorder_entry *) + list_entry(pRxTS->RxPendingPktList.prev, + struct rx_reorder_entry, List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Delete SeqNum " + "%d!\n", __func__, + pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); { int i = 0; - struct rtllib_rxb * prxb = pRxReorderEntry->prxb; - if (unlikely(!prxb)){ + struct rtllib_rxb *prxb = pRxReorderEntry->prxb; + if (unlikely(!prxb)) return; - } - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } - list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List); + list_add_tail(&pRxReorderEntry->List, + &ieee->RxReorder_Unused_List); } - } - else{ + } else { struct tx_ts_record *pTxTS = (struct tx_ts_record *)pTs; del_timer_sync(&pTxTS->TsAddBaTimer); } } -void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) +void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr) { struct ts_common_info *pTS, *pTmpTS; - printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); + printk(KERN_INFO "===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { - printk("====>remove Tx_TS_admin_list\n"); + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { + printk(KERN_INFO "====>remove Tx_TS_admin_list\n"); RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { - if (memcmp(pTS->Addr, Addr, 6) == 0) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { + if (memcmp(pTS->Addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); @@ -522,56 +498,51 @@ void RemovePeerTS(struct rtllib_device* ieee, u8* Addr) } } -void RemoveAllTS(struct rtllib_device* ieee) +void RemoveAllTS(struct rtllib_device *ieee) { struct ts_common_info *pTS, *pTmpTS; - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) { RemoveTsEntry(ieee, pTS, TX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } - list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) - { + list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List) { RemoveTsEntry(ieee, pTS, RX_DIR); list_del_init(&pTS->List); list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List); } } -void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS) +void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS) { - if (pTxTS->bAddBaReqInProgress == false) - { + if (pTxTS->bAddBaReqInProgress == false) { pTxTS->bAddBaReqInProgress = true; - if (pTxTS->bAddBaReqDelayed) - { - RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); - mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY)); - } - else - { - RTLLIB_DEBUG(RTLLIB_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); + if (pTxTS->bAddBaReqDelayed) { + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): " + "Delayed Start ADDBA after 60 sec!!\n"); + mod_timer(&pTxTS->TsAddBaTimer, jiffies + + MSECS(TS_ADDBA_DELAY)); + } else { + RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): " + "Immediately Start ADDBA now!!\n"); mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); } - } - else - RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", __func__); + } else + RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", + __func__); } From 922d71a409714bf0bc73423d04e2849d35b4d934 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 27 Jul 2011 17:51:41 -0500 Subject: [PATCH 09/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_cam.c | 325 +++++++++++------------------ drivers/staging/rtl8192e/rtl_cam.h | 10 +- 2 files changed, 132 insertions(+), 203 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index 4a11b30d1849..a9991a0fa1c8 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -40,12 +40,12 @@ void CamResetAllEntry(struct net_device *dev) void write_cam(struct net_device *dev, u8 addr, u32 data) { write_nic_dword(dev, WCAMI, data); - write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff) ); + write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff)); } u32 read_cam(struct net_device *dev, u8 addr) { - write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff) ); + write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff)); return read_nic_dword(dev, 0xa8); } @@ -53,66 +53,53 @@ void EnableHWSecurityConfig8192(struct net_device *dev) { u8 SECR_value = 0x0; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; - if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->rtllib->auth_mode != 2)) - { + if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || + (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && + (priv->rtllib->auth_mode != 2)) { SECR_value |= SCR_RxUseDK; SECR_value |= SCR_TxUseDK; - } - else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) - { + } else if ((ieee->iw_mode == IW_MODE_ADHOC) && + (ieee->pairwise_key_type & (KEY_TYPE_CCMP | + KEY_TYPE_TKIP))) { SECR_value |= SCR_RxUseDK; SECR_value |= SCR_TxUseDK; } ieee->hwsec_active = 1; - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) - { + if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) { ieee->hwsec_active = 0; SECR_value &= ~SCR_RxDecEnable; } - RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __func__, \ - ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); - { - write_nic_byte(dev, SECR, SECR_value); - } + RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", + __func__, ieee->hwsec_active, ieee->pairwise_key_type, + SECR_value); + write_nic_byte(dev, SECR, SECR_value); } -void set_swcam(struct net_device *dev, - u8 EntryNo, - u8 KeyIndex, - u16 KeyType, - u8 *MacAddr, - u8 DefaultKey, - u32 *KeyContent, - u8 is_mesh) +void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; RT_TRACE(COMP_DBG, "===========>%s():EntryNo is %d,KeyIndex is " "%d,KeyType is %d,is_mesh is %d\n", __func__, EntryNo, KeyIndex, KeyType, is_mesh); - if (is_mesh){ - } else { - ieee->swcamtable[EntryNo].bused=true; - ieee->swcamtable[EntryNo].key_index=KeyIndex; - ieee->swcamtable[EntryNo].key_type=KeyType; - memcpy(ieee->swcamtable[EntryNo].macaddr,MacAddr,6); - ieee->swcamtable[EntryNo].useDK=DefaultKey; - memcpy(ieee->swcamtable[EntryNo].key_buf,(u8*)KeyContent,16); + if (!is_mesh) { + ieee->swcamtable[EntryNo].bused = true; + ieee->swcamtable[EntryNo].key_index = KeyIndex; + ieee->swcamtable[EntryNo].key_type = KeyType; + memcpy(ieee->swcamtable[EntryNo].macaddr, MacAddr, 6); + ieee->swcamtable[EntryNo].useDK = DefaultKey; + memcpy(ieee->swcamtable[EntryNo].key_buf, (u8 *)KeyContent, 16); } } -void setKey(struct net_device *dev, - u8 EntryNo, - u8 KeyIndex, - u16 KeyType, - u8 *MacAddr, - u8 DefaultKey, - u32 *KeyContent ) +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) { u32 TargetCommand = 0; u32 TargetContent = 0; @@ -121,17 +108,17 @@ void setKey(struct net_device *dev, struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); return ; - } - else{ + } else { down(&priv->rtllib->ips_sem); IPSLeave(dev); - up(&priv->rtllib->ips_sem); } + up(&priv->rtllib->ips_sem); + } } } priv->rtllib->is_set_key = true; @@ -139,7 +126,7 @@ void setKey(struct net_device *dev, RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d," - "KeyType:%d, MacAddr"MAC_FMT"\n", dev,EntryNo, KeyIndex, + "KeyType:%d, MacAddr"MAC_FMT"\n", dev, EntryNo, KeyIndex, KeyType, MAC_ARG(MacAddr)); if (DefaultKey) @@ -149,227 +136,167 @@ void setKey(struct net_device *dev, for (i = 0; i < CAM_CONTENT_COUNT; i++) { - TargetCommand = i+CAM_CONTENT_COUNT*EntryNo; + TargetCommand = i + CAM_CONTENT_COUNT * EntryNo; TargetCommand |= BIT31|BIT16; if (i == 0) { - TargetContent = (u32)(*(MacAddr+0)) << 16| - (u32)(*(MacAddr+1)) << 24| + TargetContent = (u32)(*(MacAddr+0)) << 16 | + (u32)(*(MacAddr+1)) << 24 | (u32)usConfig; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else if (i == 1) { - TargetContent = (u32)(*(MacAddr+2)) | - (u32)(*(MacAddr+3)) << 8| - (u32)(*(MacAddr+4)) << 16| + TargetContent = (u32)(*(MacAddr+2)) | + (u32)(*(MacAddr+3)) << 8 | + (u32)(*(MacAddr+4)) << 16 | (u32)(*(MacAddr+5)) << 24; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else { if (KeyContent != NULL) { - write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) ); + write_nic_dword(dev, WCAMI, + (u32)(*(KeyContent+i-2))); write_nic_dword(dev, RWCAM, TargetCommand); udelay(100); } } } - RT_TRACE(COMP_SEC,"=========>after set key, usconfig:%x\n", usConfig); + RT_TRACE(COMP_SEC, "=========>after set key, usconfig:%x\n", usConfig); } void CAM_read_entry(struct net_device *dev, u32 iIndex) { - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; - s32 i=100; - for (entry_i=0;entry_i=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); - RT_TRACE(COMP_SEC,"CAM_read_entry(): WRITE A0: %x \n",target_command); + RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A0: %x\n", + target_command); target_content = read_nic_dword(dev, RCAMO); - RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n",target_content); + RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x\n", + target_content); } - printk("\n"); + printk(KERN_INFO "\n"); } -void CamRestoreAllEntry( struct net_device *dev) +void CamRestoreAllEntry(struct net_device *dev) { u8 EntryId = 0; struct r8192_priv *priv = rtllib_priv(dev); - u8* MacAddr = priv->rtllib->current_network.bssid; + u8 *MacAddr = priv->rtllib->current_network.bssid; static u8 CAM_CONST_ADDR[4][6] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}}; - static u8 CAM_CONST_BROAD[] = - {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} + }; + static u8 CAM_CONST_BROAD[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; - RT_TRACE(COMP_SEC, "CamRestoreAllEntry: \n"); + RT_TRACE(COMP_SEC, "CamRestoreAllEntry:\n"); - if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40)|| - (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) - { + if ((priv->rtllib->pairwise_key_type == KEY_TYPE_WEP40) || + (priv->rtllib->pairwise_key_type == KEY_TYPE_WEP104)) { - for (EntryId=0; EntryId<4; EntryId++) - { - { - MacAddr = CAM_CONST_ADDR[EntryId]; - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId , - EntryId, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) - ); - } + for (EntryId = 0; EntryId < 4; EntryId++) { + MacAddr = CAM_CONST_ADDR[EntryId]; + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId , EntryId, + priv->rtllib->pairwise_key_type, MacAddr, + 0, (u32 *)(&priv->rtllib->swcamtable + [EntryId].key_buf[0])); } } - } - else if (priv->rtllib->pairwise_key_type == KEY_TYPE_TKIP) - { - - { - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - (u8*)dev->dev_addr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - else - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - + } else if (priv->rtllib->pairwise_key_type == KEY_TYPE_TKIP) { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + setKey(dev, 4, 0, priv->rtllib->pairwise_key_type, + (u8 *)dev->dev_addr, 0, + (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0])); + } else { + setKey(dev, 4, 0, priv->rtllib->pairwise_key_type, + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[4].key_buf[0])); } - } - else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) - { - { - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - (u8*)dev->dev_addr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); + } else if (priv->rtllib->pairwise_key_type == KEY_TYPE_CCMP) { + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + setKey(dev, 4, 0, + priv->rtllib->pairwise_key_type, + (u8 *)dev->dev_addr, 0, + (u32 *)(&priv->rtllib->swcamtable[4]. + key_buf[0])); + } else { + setKey(dev, 4, 0, + priv->rtllib->pairwise_key_type, MacAddr, + 0, (u32 *)(&priv->rtllib->swcamtable[4]. + key_buf[0])); } - else - { - setKey(dev, - 4, - 0, - priv->rtllib->pairwise_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[4].key_buf[0]) - ); - } - } } - - - if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) - { + if (priv->rtllib->group_key_type == KEY_TYPE_TKIP) { MacAddr = CAM_CONST_BROAD; - for (EntryId=1 ; EntryId<4 ; EntryId++) - { - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId, - EntryId, - priv->rtllib->group_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) - ); + for (EntryId = 1; EntryId < 4; EntryId++) { + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId, EntryId, + priv->rtllib->group_key_type, + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0]) + ); } } - if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { - if (priv->rtllib->swcamtable[0].bused ){ - setKey(dev, - 0, - 0, - priv->rtllib->group_key_type, - CAM_CONST_ADDR[0], - 0, - (u32*)(&priv->rtllib->swcamtable[0].key_buf[0]) - ); - } - else - { - RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n",__func__); + if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { + if (priv->rtllib->swcamtable[0].bused) { + setKey(dev, 0, 0, + priv->rtllib->group_key_type, + CAM_CONST_ADDR[0], 0, + (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0]) + ); + } else { + RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC TKIP " + ",but 0 entry is have no data\n", + __func__); return; } } } else if (priv->rtllib->group_key_type == KEY_TYPE_CCMP) { MacAddr = CAM_CONST_BROAD; - for (EntryId=1; EntryId<4 ; EntryId++) - { - if (priv->rtllib->swcamtable[EntryId].bused ) - { - setKey(dev, - EntryId , - EntryId, + for (EntryId = 1; EntryId < 4; EntryId++) { + if (priv->rtllib->swcamtable[EntryId].bused) { + setKey(dev, EntryId , EntryId, priv->rtllib->group_key_type, - MacAddr, - 0, - (u32*)(&priv->rtllib->swcamtable[EntryId].key_buf[0])); + MacAddr, 0, + (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0])); } } if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { if (priv->rtllib->swcamtable[0].bused) { - setKey(dev, - 0 , - 0, + setKey(dev, 0 , 0, priv->rtllib->group_key_type, - CAM_CONST_ADDR[0], - 0, - (u32*)(&priv->rtllib->swcamtable[0].key_buf[0])); + CAM_CONST_ADDR[0], 0, + (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0])); } else { - RT_TRACE(COMP_ERR,"===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n", - __func__); + RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC CCMP ," + "but 0 entry is have no data\n", + __func__); return; } } diff --git a/drivers/staging/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl_cam.h index 9e4d0edb21bb..fa607f98b172 100644 --- a/drivers/staging/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl_cam.h @@ -28,11 +28,13 @@ #include struct net_device; -void CamResetAllEntry(struct net_device* dev); +void CamResetAllEntry(struct net_device *dev); void EnableHWSecurityConfig8192(struct net_device *dev); -void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent ); -void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); -void CamPrintDbgReg(struct net_device* dev); +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); +void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, + u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh); +void CamPrintDbgReg(struct net_device *dev); u32 read_cam(struct net_device *dev, u8 addr); void write_cam(struct net_device *dev, u8 addr, u32 data); From 54586533ef1cc8fc0accea0f4e02f8099461613f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 6 Aug 2011 19:13:25 -0500 Subject: [PATCH 10/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part VIII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 2357 ++++++++++++++------------- drivers/staging/rtl8192e/rtl_core.h | 683 ++++---- 2 files changed, 1537 insertions(+), 1503 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index f585f71e14b7..68a4e858ecbc 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -41,7 +41,7 @@ #undef DEBUG_TX_ALLOC #undef DEBUG_TX_DESC -#include +#include #include #include "rtl_core.h" #include "r8192E_phy.h" @@ -58,26 +58,26 @@ int hwwep = 1; static int channels = 0x3fff; -char* ifname = "wlan%d"; +char *ifname = "wlan%d"; struct rtl819x_ops rtl819xp_ops = { - .nic_type = NIC_8192E, - .get_eeprom_size = rtl8192_get_eeprom_size, + .nic_type = NIC_8192E, + .get_eeprom_size = rtl8192_get_eeprom_size, .init_adapter_variable = rtl8192_InitializeVariables, - .initialize_adapter = rtl8192_adapter_start, - .link_change = rtl8192_link_change, - .tx_fill_descriptor = rtl8192_tx_fill_desc, - .tx_fill_cmd_descriptor = rtl8192_tx_fill_cmd_desc, + .initialize_adapter = rtl8192_adapter_start, + .link_change = rtl8192_link_change, + .tx_fill_descriptor = rtl8192_tx_fill_desc, + .tx_fill_cmd_descriptor = rtl8192_tx_fill_cmd_desc, .rx_query_status_descriptor = rtl8192_rx_query_status_desc, .rx_command_packet_handler = NULL, - .stop_adapter = rtl8192_halt_adapter, - .update_ratr_table = rtl8192_update_ratr_table, - .irq_enable = rtl8192_EnableInterrupt, - .irq_disable = rtl8192_DisableInterrupt, - .irq_clear = rtl8192_ClearInterrupt, - .rx_enable = rtl8192_enable_rx, - .tx_enable = rtl8192_enable_tx, + .stop_adapter = rtl8192_halt_adapter, + .update_ratr_table = rtl8192_update_ratr_table, + .irq_enable = rtl8192_EnableInterrupt, + .irq_disable = rtl8192_DisableInterrupt, + .irq_clear = rtl8192_ClearInterrupt, + .rx_enable = rtl8192_enable_rx, + .tx_enable = rtl8192_enable_tx, .interrupt_recognized = rtl8192_interrupt_recognized, .TxCheckStuckHandler = rtl8192_HalTxCheckStuck, .RxCheckStuckHandler = rtl8192_HalRxCheckStuck, @@ -93,130 +93,110 @@ static struct pci_device_id rtl8192_pci_id_tbl[] __devinitdata = { MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id); + const struct pci_device_id *id); static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev); static struct pci_driver rtl8192_pci_driver = { - .name = DRV_NAME, /* Driver name */ - .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ - .probe = rtl8192_pci_probe, /* probe fn */ - .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ - .suspend = rtl8192E_suspend, /* PM suspend fn */ - .resume = rtl8192E_resume, /* PM resume fn */ + .name = DRV_NAME, /* Driver name */ + .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ + .probe = rtl8192_pci_probe, /* probe fn */ + .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ + .suspend = rtl8192E_suspend, /* PM suspend fn */ + .resume = rtl8192E_resume, /* PM resume fn */ }; /**************************************************************************** -----------------------------IO STUFF------------------------- *****************************************************************************/ -bool -PlatformIOCheckPageLegalAndGetRegMask( - u32 u4bPage, - u8* pu1bPageMask -) +bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) { bool bReturn = false; + *pu1bPageMask = 0xfe; - switch (u4bPage) - { - case 1: case 2: case 3: case 4: - case 8: case 9: case 10: case 12: case 13: - bReturn = true; - *pu1bPageMask = 0xf0; - break; + switch (u4bPage) { + case 1: case 2: case 3: case 4: + case 8: case 9: case 10: case 12: case 13: + bReturn = true; + *pu1bPageMask = 0xf0; + break; - default: - bReturn = false; - break; + default: + bReturn = false; + break; } return bReturn; } -void write_nic_io_byte(struct net_device *dev, int x,u8 y) +void write_nic_io_byte(struct net_device *dev, int x, u8 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outb(y&0xff,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outb(y&0xff, dev->base_addr + x); + + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_byte(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } - - } -void write_nic_io_word(struct net_device *dev, int x,u16 y) +void write_nic_io_word(struct net_device *dev, int x, u16 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outw(y,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outw(y, dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_word(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } - } -void write_nic_io_dword(struct net_device *dev, int x,u32 y) +void write_nic_io_dword(struct net_device *dev, int x, u32 y) { u32 u4bPage = (x >> 8); u8 u1PageMask = 0; bool bIsLegalPage = false; - if (u4bPage == 0) - { - outl(y,dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + outl(y, dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); write_nic_io_dword(dev, (x & 0xff), y); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } - } + u8 read_nic_io_byte(struct net_device *dev, int x) { u32 u4bPage = (x >> 8); @@ -224,23 +204,18 @@ u8 read_nic_io_byte(struct net_device *dev, int x) bool bIsLegalPage = false; u8 Data = 0; - if (u4bPage == 0) - { - return 0xff&inb(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return 0xff&inb(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_byte(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - - }else - { - ; } } @@ -254,23 +229,19 @@ u16 read_nic_io_word(struct net_device *dev, int x) bool bIsLegalPage = false; u16 Data = 0; - if (u4bPage == 0) - { - return inw(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return inw(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_word(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } @@ -284,23 +255,19 @@ u32 read_nic_io_dword(struct net_device *dev, int x) bool bIsLegalPage = false; u32 Data = 0; - if (u4bPage == 0) - { - return inl(dev->base_addr +x); - }else - { - bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, &u1PageMask); - if (bIsLegalPage) - { + if (u4bPage == 0) { + return inl(dev->base_addr + x); + } else { + bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage, + &u1PageMask); + if (bIsLegalPage) { u8 u1bPsr = read_nic_io_byte(dev, PSR); - write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | (u8)u4bPage)); + write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) | + (u8)u4bPage)); Data = read_nic_io_dword(dev, (x & 0xff)); write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask)); - }else - { - ; } } @@ -309,36 +276,36 @@ u32 read_nic_io_dword(struct net_device *dev, int x) u8 read_nic_byte(struct net_device *dev, int x) { - return 0xff&readb((u8*)dev->mem_start +x); + return 0xff & readb((u8 *)dev->mem_start + x); } u32 read_nic_dword(struct net_device *dev, int x) { - return readl((u8*)dev->mem_start +x); + return readl((u8 *)dev->mem_start + x); } u16 read_nic_word(struct net_device *dev, int x) { - return readw((u8*)dev->mem_start +x); + return readw((u8 *)dev->mem_start + x); } -void write_nic_byte(struct net_device *dev, int x,u8 y) +void write_nic_byte(struct net_device *dev, int x, u8 y) { - writeb(y,(u8*)dev->mem_start +x); + writeb(y, (u8 *)dev->mem_start + x); udelay(20); } -void write_nic_dword(struct net_device *dev, int x,u32 y) +void write_nic_dword(struct net_device *dev, int x, u32 y) { - writel(y,(u8*)dev->mem_start +x); + writel(y, (u8 *)dev->mem_start + x); udelay(20); } -void write_nic_word(struct net_device *dev, int x,u16 y) +void write_nic_word(struct net_device *dev, int x, u16 y) { - writew(y,(u8*)dev->mem_start +x); + writew(y, (u8 *)dev->mem_start + x); udelay(20); } @@ -346,106 +313,101 @@ void write_nic_word(struct net_device *dev, int x,u16 y) /**************************************************************************** -----------------------------GENERAL FUNCTION------------------------- *****************************************************************************/ -bool -MgntActSet_RF_State( - struct net_device* dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource, - bool ProtectOrNot - ) +bool MgntActSet_RF_State(struct net_device *dev, + enum rt_rf_power_state StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device * ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; bool bActionAllowed = false; bool bConnectBySSID = false; enum rt_rf_power_state rtState; u16 RFWaitCounter = 0; unsigned long flag; - RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): StateToSet(%d)\n",StateToSet); + RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): " + "StateToSet(%d)\n", StateToSet); ProtectOrNot = false; - if (!ProtectOrNot) - { - while(true) - { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - if (priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): RF Change in progress! Wait to set..StateToSet(%d).\n", StateToSet); + if (!ProtectOrNot) { + while (true) { + spin_lock_irqsave(&priv->rf_ps_lock, flag); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); + RT_TRACE((COMP_PS | COMP_RF), + "MgntActSet_RF_State(): RF Change in " + "progress! Wait to set..StateToSet" + "(%d).\n", StateToSet); - while(priv->RFChangeInProgress) - { - RFWaitCounter ++; - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Wait 1 ms (%d times)...\n", RFWaitCounter); - mdelay(1); + while (priv->RFChangeInProgress) { + RFWaitCounter++; + RT_TRACE((COMP_PS | COMP_RF), + "MgntActSet_RF_State(): Wait 1" + " ms (%d times)...\n", + RFWaitCounter); + mdelay(1); - if (RFWaitCounter > 100) - { - RT_TRACE(COMP_ERR, "MgntActSet_RF_State(): Wait too logn to set RF\n"); - return false; + if (RFWaitCounter > 100) { + RT_TRACE(COMP_ERR, "MgntActSet_" + "RF_State(): Wait too " + "logn to set RF\n"); + return false; + } } + } else { + priv->RFChangeInProgress = true; + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); + break; } } - else - { - priv->RFChangeInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); - break; - } - } } rtState = priv->rtllib->eRFPowerState; - switch (StateToSet) - { + switch (StateToSet) { case eRfOn: - priv->rtllib->RfOffReason &= (~ChangeSource); - if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == true)){ + if ((ChangeSource == RF_CHANGE_BY_HW) && + (priv->bHwRadioOff == true)) priv->bHwRadioOff = false; - } - if (! priv->rtllib->RfOffReason) - { + if (!priv->rtllib->RfOffReason) { priv->rtllib->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && ChangeSource >=RF_CHANGE_BY_HW ) - { + if (rtState == eRfOff && + ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; - } - } - else{ - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n", priv->rtllib->RfOffReason, ChangeSource); - } + } else { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - " + "eRfon reject pMgntInfo->RfOffReason= 0x%x," + " ChangeSource=0x%X\n", + priv->rtllib->RfOffReason, ChangeSource); + } break; case eRfOff: - if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || (priv->rtllib->iw_mode == IW_MODE_ADHOC)) - { - if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || (ChangeSource > RF_CHANGE_BY_IPS)) - { + if ((priv->rtllib->iw_mode == IW_MODE_INFRA) || + (priv->rtllib->iw_mode == IW_MODE_ADHOC)) { + if ((priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) || + (ChangeSource > RF_CHANGE_BY_IPS)) { if (ieee->state == RTLLIB_LINKED) priv->blinked_ingpio = true; else priv->blinked_ingpio = false; - rtllib_MgntDisconnect(priv->rtllib,disas_lv_ss); - - - + rtllib_MgntDisconnect(priv->rtllib, + disas_lv_ss); } } - if ((ChangeSource == RF_CHANGE_BY_HW) && (priv->bHwRadioOff == false)){ + if ((ChangeSource == RF_CHANGE_BY_HW) && + (priv->bHwRadioOff == false)) priv->bHwRadioOff = true; - } priv->rtllib->RfOffReason |= ChangeSource; bActionAllowed = true; break; @@ -459,29 +421,30 @@ MgntActSet_RF_State( break; } - if (bActionAllowed) - { - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", StateToSet, priv->rtllib->RfOffReason); + if (bActionAllowed) { + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is" + " allowed.... StateToSet(%d), RfOffReason(%#X)\n", + StateToSet, priv->rtllib->RfOffReason); PHY_SetRFPowerState(dev, StateToSet); - if (StateToSet == eRfOn) - { + if (StateToSet == eRfOn) { - if (bConnectBySSID && (priv->blinked_ingpio == true)) - { - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + if (bConnectBySSID && (priv->blinked_ingpio == true)) { + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); priv->blinked_ingpio = false; - } } } else { - RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, priv->rtllib->RfOffReason); + RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): " + "Action is rejected.... StateToSet(%d), ChangeSource" + "(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, + priv->rtllib->RfOffReason); } - if (!ProtectOrNot) - { - spin_lock_irqsave(&priv->rf_ps_lock,flag); - priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + if (!ProtectOrNot) { + spin_lock_irqsave(&priv->rf_ps_lock, flag); + priv->RFChangeInProgress = false; + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); } RT_TRACE((COMP_PS && COMP_RF), "<===MgntActSet_RF_State()\n"); @@ -491,36 +454,35 @@ MgntActSet_RF_State( short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - /* For now, we reserved two free descriptor as a safety boundary - * between the tail and the head - */ - if ((prio == MGNT_QUEUE) &&(skb_queue_len(&ring->queue)>10)) - RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d queue_len=%d---------\n", - prio,ring->idx, skb_queue_len(&ring->queue)); - return skb_queue_len(&ring->queue); + /* For now, we reserved two free descriptor as a safety boundary + * between the tail and the head + */ + if ((prio == MGNT_QUEUE) && (skb_queue_len(&ring->queue) > 10)) + RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d " + "queue_len=%d---------\n", prio, ring->idx, + skb_queue_len(&ring->queue)); + return skb_queue_len(&ring->queue); } short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - if (ring->entries - skb_queue_len(&ring->queue) >= 2) { - return 1; - } else { - return 0; - } + if (ring->entries - skb_queue_len(&ring->queue) >= 2) + return 1; + return 0; } void rtl8192_tx_timeout(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - schedule_work(&priv->reset_wq); - printk("TXTIMEOUT"); + schedule_work(&priv->reset_wq); + printk(KERN_INFO "TXTIMEOUT"); } void rtl8192_irq_enable(struct net_device *dev) @@ -548,136 +510,137 @@ void rtl8192_irq_clear(struct net_device *dev) } -void rtl8192_set_chan(struct net_device *dev,short ch) +void rtl8192_set_chan(struct net_device *dev, short ch) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); - if (priv->chan_forced) - return; + RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __func__, ch); + if (priv->chan_forced) + return; - priv->chan = ch; + priv->chan = ch; - if (priv->rf_set_chan) - priv->rf_set_chan(dev,priv->chan); + if (priv->rf_set_chan) + priv->rf_set_chan(dev, priv->chan); } -void rtl8192_update_cap(struct net_device* dev, u16 cap) +void rtl8192_update_cap(struct net_device *dev, u16 cap) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; + bool ShortPreamble; - - { - bool ShortPreamble; - - if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) - { - if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) - { - ShortPreamble = true; - priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; - RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_PREAMBLE\n", __func__); - priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); - } + if (cap & WLAN_CAPABILITY_SHORT_PREAMBLE) { + if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) { + ShortPreamble = true; + priv->dot11CurrentPreambleMode = PREAMBLE_SHORT; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_" + "PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, + (unsigned char *)&ShortPreamble); } - else - { - if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) - { - ShortPreamble = false; - priv->dot11CurrentPreambleMode = PREAMBLE_LONG; - RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_PREAMBLE\n", __func__); - priv->rtllib->SetHwRegHandler( dev, HW_VAR_ACK_PREAMBLE, (unsigned char *)&ShortPreamble ); - } + } else { + if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) { + ShortPreamble = false; + priv->dot11CurrentPreambleMode = PREAMBLE_LONG; + RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_" + "PREAMBLE\n", __func__); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE, + (unsigned char *)&ShortPreamble); } } - if (net->mode & (IEEE_G|IEEE_N_24G)) - { + if (net->mode & (IEEE_G|IEEE_N_24G)) { u8 slot_time_val; u8 CurSlotTime = priv->slot_time; - if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) - { - if (CurSlotTime != SHORT_SLOT_TIME) - { + if ((cap & WLAN_CAPABILITY_SHORT_SLOT_TIME) && + (!priv->rtllib->pHTInfo->bCurrentRT2RTLongSlotTime)) { + if (CurSlotTime != SHORT_SLOT_TIME) { slot_time_val = SHORT_SLOT_TIME; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_SLOT_TIME, &slot_time_val); } - } - else - { - if (CurSlotTime != NON_SHORT_SLOT_TIME) - { + } else { + if (CurSlotTime != NON_SHORT_SLOT_TIME) { slot_time_val = NON_SHORT_SLOT_TIME; - priv->rtllib->SetHwRegHandler( dev, HW_VAR_SLOT_TIME, &slot_time_val ); + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_SLOT_TIME, &slot_time_val); } } } } static struct rtllib_qos_parameters def_qos_parameters = { - {3,3,3,3}, - {7,7,7,7}, - {2,2,2,2}, - {0,0,0,0}, - {0,0,0,0} + {3, 3, 3, 3}, + {7, 7, 7, 7}, + {2, 2, 2, 2}, + {0, 0, 0, 0}, + {0, 0, 0, 0} }; void rtl8192_update_beacon(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + update_beacon_wq.work); struct net_device *dev = priv->rtllib->dev; - struct rtllib_device* ieee = priv->rtllib; - struct rtllib_network* net = &ieee->current_network; + struct rtllib_device *ieee = priv->rtllib; + struct rtllib_network *net = &ieee->current_network; if (ieee->pHTInfo->bCurrentHTSupport) HTUpdateSelfAndPeerSetting(ieee, net); - ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; + ieee->pHTInfo->bCurrentRT2RTLongSlotTime = + net->bssht.bdRT2RTLongSlotTime; ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode; rtl8192_update_cap(dev, net->capability); } #define MOVE_INTO_HANDLER -int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO}; +int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; void rtl8192_qos_activate(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + qos_activate); struct net_device *dev = priv->rtllib->dev; #ifndef MOVE_INTO_HANDLER - struct rtllib_qos_parameters *qos_parameters = &priv->rtllib->current_network.qos_data.parameters; - u8 mode = priv->rtllib->current_network.mode; + struct rtllib_qos_parameters *qos_parameters = + &priv->rtllib->current_network.qos_data.parameters; + u8 mode = priv->rtllib->current_network.mode; u8 u1bAIFS; u32 u4bAcParam; #endif - int i; + int i; - if (priv == NULL) - return; + if (priv == NULL) + return; - mutex_lock(&priv->mutex); - if (priv->rtllib->state != RTLLIB_LINKED) + mutex_lock(&priv->mutex); + if (priv->rtllib->state != RTLLIB_LINKED) goto success; - RT_TRACE(COMP_QOS,"qos active process with associate response received\n"); + RT_TRACE(COMP_QOS, "qos active process with associate response " + "received\n"); for (i = 0; i < QOS_QUEUE_NUM; i++) { #ifndef MOVE_INTO_HANDLER - u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime; - u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)| - ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); + u1bAIFS = qos_parameters->aifs[i] * + ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; + u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i])) << + AC_PARAM_TXOP_LIMIT_OFFSET) | + (((u32)(qos_parameters->cw_max[i])) << + AC_PARAM_ECW_MAX_OFFSET) | + (((u32)(qos_parameters->cw_min[i])) << + AC_PARAM_ECW_MIN_OFFSET) | + ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); RT_TRACE(COMP_DBG, "===>ACI:%d:u4bAcParam:%x\n", i, u4bAcParam); write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam); #else - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&i)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i)); #endif } success: - mutex_unlock(&priv->mutex); + mutex_unlock(&priv->mutex); } static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, @@ -687,8 +650,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, int ret = 0; u32 size = sizeof(struct rtllib_qos_parameters); - if (priv->rtllib->state !=RTLLIB_LINKED) - return ret; + if (priv->rtllib->state != RTLLIB_LINKED) + return ret; if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) return ret; @@ -701,21 +664,22 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, if ((network->qos_data.active == 1) && (active_network == 1) && (network->flags & NETWORK_HAS_QOS_PARAMETERS) && (network->qos_data.old_param_count != - network->qos_data.param_count)) { + network->qos_data.param_count)) { network->qos_data.old_param_count = network->qos_data.param_count; - priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; queue_work_rsl(priv->priv_wq, &priv->qos_activate); - RT_TRACE (COMP_QOS, "QoS parameters change call " + RT_TRACE(COMP_QOS, "QoS parameters change call " "qos_activate\n"); } } else { - memcpy(&priv->rtllib->current_network.qos_data.parameters,\ + memcpy(&priv->rtllib->current_network.qos_data.parameters, &def_qos_parameters, size); if ((network->qos_data.active == 1) && (active_network == 1)) { queue_work_rsl(priv->priv_wq, &priv->qos_activate); - RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n"); + RT_TRACE(COMP_QOS, "QoS was disabled call qos_" + "activate\n"); } network->qos_data.active = 0; network->qos_data.supported = 0; @@ -724,13 +688,13 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, return 0; } -static int rtl8192_handle_beacon(struct net_device * dev, - struct rtllib_beacon * beacon, - struct rtllib_network * network) +static int rtl8192_handle_beacon(struct net_device *dev, + struct rtllib_beacon *beacon, + struct rtllib_network *network) { struct r8192_priv *priv = rtllib_priv(dev); - rtl8192_qos_handle_probe_response(priv,1,network); + rtl8192_qos_handle_probe_response(priv, 1, network); queue_delayed_work_rsl(priv->priv_wq, &priv->update_beacon_wq, 0); return 0; @@ -738,60 +702,60 @@ static int rtl8192_handle_beacon(struct net_device * dev, } static int rtl8192_qos_association_resp(struct r8192_priv *priv, - struct rtllib_network *network) + struct rtllib_network *network) { - int ret = 0; - unsigned long flags; - u32 size = sizeof(struct rtllib_qos_parameters); - int set_qos_param = 0; + int ret = 0; + unsigned long flags; + u32 size = sizeof(struct rtllib_qos_parameters); + int set_qos_param = 0; - if ((priv == NULL) || (network == NULL)) - return ret; + if ((priv == NULL) || (network == NULL)) + return ret; - if (priv->rtllib->state !=RTLLIB_LINKED) - return ret; + if (priv->rtllib->state != RTLLIB_LINKED) + return ret; if ((priv->rtllib->iw_mode != IW_MODE_INFRA)) - return ret; + return ret; - spin_lock_irqsave(&priv->rtllib->lock, flags); + spin_lock_irqsave(&priv->rtllib->lock, flags); if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { - memcpy(&priv->rtllib->current_network.qos_data.parameters,\ - &network->qos_data.parameters,\ - sizeof(struct rtllib_qos_parameters)); + memcpy(&priv->rtllib->current_network.qos_data.parameters, + &network->qos_data.parameters, + sizeof(struct rtllib_qos_parameters)); priv->rtllib->current_network.qos_data.active = 1; - priv->rtllib->wmm_acm = network->qos_data.wmm_acm; + priv->rtllib->wmm_acm = network->qos_data.wmm_acm; set_qos_param = 1; priv->rtllib->current_network.qos_data.old_param_count = - priv->rtllib->current_network.qos_data.param_count; + priv->rtllib->current_network.qos_data.param_count; priv->rtllib->current_network.qos_data.param_count = - network->qos_data.param_count; - } else { + network->qos_data.param_count; + } else { memcpy(&priv->rtllib->current_network.qos_data.parameters, - &def_qos_parameters, size); + &def_qos_parameters, size); priv->rtllib->current_network.qos_data.active = 0; priv->rtllib->current_network.qos_data.supported = 0; - set_qos_param = 1; - } + set_qos_param = 1; + } - spin_unlock_irqrestore(&priv->rtllib->lock, flags); + spin_unlock_irqrestore(&priv->rtllib->lock, flags); RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, - network->flags ,priv->rtllib->current_network.qos_data.active); + network->flags, priv->rtllib->current_network.qos_data.active); if (set_qos_param == 1) { dm_init_edca_turbo(priv->rtllib->dev); queue_work_rsl(priv->priv_wq, &priv->qos_activate); } - return ret; + return ret; } static int rtl8192_handle_assoc_response(struct net_device *dev, - struct rtllib_assoc_response_frame *resp, - struct rtllib_network *network) + struct rtllib_assoc_response_frame *resp, + struct rtllib_network *network) { - struct r8192_priv *priv = rtllib_priv(dev); - rtl8192_qos_association_resp(priv, network); - return 0; + struct r8192_priv *priv = rtllib_priv(dev); + rtl8192_qos_association_resp(priv, network); + return 0; } void rtl8192_prepare_beacon(struct r8192_priv *priv) @@ -831,104 +795,107 @@ void rtl8192_stop_beacon(struct net_device *dev) { } -void rtl8192_config_rate(struct net_device* dev, u16* rate_config) +void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_network *net; - u8 i=0, basic_rate = 0; - net = & priv->rtllib->current_network; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_network *net; + u8 i = 0, basic_rate = 0; + net = &priv->rtllib->current_network; - for (i = 0; i < net->rates_len; i++) { - basic_rate = net->rates[i] & 0x7f; - switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; - } - } + for (i = 0; i < net->rates_len; i++) { + basic_rate = net->rates[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } - for (i = 0; i < net->rates_ex_len; i++) { - basic_rate = net->rates_ex[i] & 0x7f; - switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; - } - } + for (i = 0; i < net->rates_ex_len; i++) { + basic_rate = net->rates_ex[i] & 0x7f; + switch (basic_rate) { + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; + } + } } -void rtl8192_refresh_supportrate(struct r8192_priv * priv) +void rtl8192_refresh_supportrate(struct r8192_priv *priv) { - struct rtllib_device* ieee = priv->rtllib; - if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) { - memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); - memcpy(ieee->Regdot11TxHTOperationalRateSet, ieee->RegHTSuppRateSet, 16); + struct rtllib_device *ieee = priv->rtllib; + if (ieee->mode == WIRELESS_MODE_N_24G || + ieee->mode == WIRELESS_MODE_N_5G) { + memcpy(ieee->Regdot11HTOperationalRateSet, + ieee->RegHTSuppRateSet, 16); + memcpy(ieee->Regdot11TxHTOperationalRateSet, + ieee->RegHTSuppRateSet, 16); } else { memset(ieee->Regdot11HTOperationalRateSet, 0, 16); @@ -936,7 +903,7 @@ void rtl8192_refresh_supportrate(struct r8192_priv * priv) return; } -u8 rtl8192_getSupportedWireleeMode(struct net_device*dev) +u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 ret = 0; @@ -958,12 +925,13 @@ u8 rtl8192_getSupportedWireleeMode(struct net_device*dev) return ret; } -void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) +void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) { struct r8192_priv *priv = rtllib_priv(dev); u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev); - if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode & bSupportMode) == 0)) { + if ((wireless_mode == WIRELESS_MODE_AUTO) || + ((wireless_mode & bSupportMode) == 0)) { if (bSupportMode & WIRELESS_MODE_N_24G) { wireless_mode = WIRELESS_MODE_N_24G; } else if (bSupportMode & WIRELESS_MODE_N_5G) { @@ -975,49 +943,55 @@ void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode) } else if ((bSupportMode & WIRELESS_MODE_B)) { wireless_mode = WIRELESS_MODE_B; } else { - RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported (%x)!!!\n", - __func__, bSupportMode); + RT_TRACE(COMP_ERR, "%s(), No valid wireless mode " + "supported (%x)!!!\n", __func__, bSupportMode); wireless_mode = WIRELESS_MODE_B; } } - if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) == (WIRELESS_MODE_G | WIRELESS_MODE_B)) + if ((wireless_mode & (WIRELESS_MODE_B | WIRELESS_MODE_G)) == + (WIRELESS_MODE_G | WIRELESS_MODE_B)) wireless_mode = WIRELESS_MODE_G; priv->rtllib->mode = wireless_mode; - ActUpdateChannelAccessSetting( dev, wireless_mode, &priv->ChannelAccessSetting); + ActUpdateChannelAccessSetting(dev, wireless_mode, + &priv->ChannelAccessSetting); - if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)){ + if ((wireless_mode == WIRELESS_MODE_N_24G) || + (wireless_mode == WIRELESS_MODE_N_5G)) { priv->rtllib->pHTInfo->bEnableHT = 1; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", __func__,wireless_mode); - }else{ + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", + __func__, wireless_mode); + } else { priv->rtllib->pHTInfo->bEnableHT = 0; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", __func__,wireless_mode); - } + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", + __func__, wireless_mode); + } RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode); rtl8192_refresh_supportrate(priv); } -int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) +int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool init_status = true; priv->bDriverIsGoingToUnload = false; priv->bdisable_nic = false; - priv->up=1; - priv->rtllib->ieee_up=1; + priv->up = 1; + priv->rtllib->ieee_up = 1; priv->up_first_time = 0; RT_TRACE(COMP_INIT, "Bringing up iface"); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); - if (init_status != true) - { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + if (init_status != true) { + RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", + __func__); priv->bfirst_init = false; return -1; } @@ -1026,16 +1000,14 @@ int _rtl8192_sta_up(struct net_device *dev,bool is_silent_reset) RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); priv->bfirst_init = false; - if (priv->polling_timer_on == 0){ + if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); - } if (priv->rtllib->state != RTLLIB_LINKED) - rtllib_softmac_start_protocol(priv->rtllib, 0); + rtllib_softmac_start_protocol(priv->rtllib, 0); rtllib_reset_queue(priv->rtllib); watch_dog_timer_callback((unsigned long) dev); - if (!netif_queue_stopped(dev)) netif_start_queue(dev); else @@ -1050,7 +1022,8 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) unsigned long flags = 0; u8 RFInProgressTimeOut = 0; - if (priv->up == 0) return -1; + if (priv->up == 0) + return -1; if (priv->rtllib->rtllib_ips_leave != NULL) priv->rtllib->rtllib_ips_leave(dev); @@ -1059,7 +1032,7 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) LeisurePSLeave(dev); priv->bDriverIsGoingToUnload = true; - priv->up=0; + priv->up = 0; priv->rtllib->ieee_up = 0; priv->bfirst_after_down = 1; RT_TRACE(COMP_DOWN, "==========>%s()\n", __func__); @@ -1067,11 +1040,10 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) netif_stop_queue(dev); priv->rtllib->wpa_ie_len = 0; - if (priv->rtllib->wpa_ie) - kfree(priv->rtllib->wpa_ie); + kfree(priv->rtllib->wpa_ie); priv->rtllib->wpa_ie = NULL; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtl8192_irq_disable(dev); del_timer_sync(&priv->watch_dog_timer); @@ -1079,40 +1051,40 @@ int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) cancel_delayed_work(&priv->rtllib->hw_wakeup_wq); rtllib_softmac_stop_protocol(priv->rtllib, 0, true); - spin_lock_irqsave(&priv->rf_ps_lock,flags); - while(priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - if (RFInProgressTimeOut > 100) - { - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); + while (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + if (RFInProgressTimeOut > 100) { + spin_lock_irqsave(&priv->rf_ps_lock, flags); break; } - RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait until rf chang is done.\n",__func__); + RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait " + "until rf chang is done.\n", __func__); mdelay(1); - RFInProgressTimeOut ++; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + RFInProgressTimeOut++; + spin_lock_irqsave(&priv->rf_ps_lock, flags); } priv->RFChangeInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); priv->ops->stop_adapter(dev, false); - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); udelay(100); - memset(&priv->rtllib->current_network, 0 , offsetof(struct rtllib_network, list)); + memset(&priv->rtllib->current_network, 0, + offsetof(struct rtllib_network, list)); RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__); return 0; } -static void rtl8192_init_priv_handler(struct net_device* dev) +static void rtl8192_init_priv_handler(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->rtllib->softmac_hard_start_xmit = rtl8192_hard_start_xmit; - priv->rtllib->set_chan = rtl8192_set_chan; - priv->rtllib->link_change = priv->ops->link_change; + priv->rtllib->set_chan = rtl8192_set_chan; + priv->rtllib->link_change = priv->ops->link_change; priv->rtllib->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit; priv->rtllib->data_hard_stop = rtl8192_data_hard_stop; priv->rtllib->data_hard_resume = rtl8192_data_hard_resume; @@ -1133,7 +1105,8 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->ps_is_queue_empty = rtl8192_is_tx_queue_empty; priv->rtllib->GetNmodeSupportBySecCfg = rtl8192_GetNmodeSupportBySecCfg; - priv->rtllib->GetHalfNmodeSupportByAPsHandler = rtl8192_GetHalfNmodeSupportByAPs; + priv->rtllib->GetHalfNmodeSupportByAPsHandler = + rtl8192_GetHalfNmodeSupportByAPs; priv->rtllib->SetHwRegHandler = rtl8192e_SetHwReg; priv->rtllib->AllowAllDestAddrHandler = rtl8192_AllowAllDestAddr; @@ -1150,10 +1123,11 @@ static void rtl8192_init_priv_handler(struct net_device* dev) priv->rtllib->rtllib_rfkill_poll = NULL; } -static void rtl8192_init_priv_constant(struct net_device* dev) +static void rtl8192_init_priv_constant(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); pPSC->RegMaxLPSAwakeIntvl = 5; @@ -1169,7 +1143,7 @@ static void rtl8192_init_priv_constant(struct net_device* dev) } -static void rtl8192_init_priv_variable(struct net_device* dev) +static void rtl8192_init_priv_variable(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 i; @@ -1193,7 +1167,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->txringcount = 64; priv->rxbuffersize = 9100; priv->rxringcount = MAX_RX_COUNT; - priv->irq_enabled=0; + priv->irq_enabled = 0; priv->chan = 1; priv->RegWirelessMode = WIRELESS_MODE_AUTO; priv->RegChannelPlan = 0xf; @@ -1205,14 +1179,15 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->bNetPromiscuousMode = false; priv->rtllib->IntelPromiscuousModeInfo.bPromiscuousOn = false; - priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame = false; - priv->rtllib->ieee_up=0; + priv->rtllib->IntelPromiscuousModeInfo.bFilterSourceStationFrame = + false; + priv->rtllib->ieee_up = 0; priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->rtllib->rts = DEFAULT_RTS_THRESHOLD; priv->rtllib->rate = 110; priv->rtllib->short_slot = 1; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; + priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->bcck_in_ch14 = false; priv->bfsync_processing = false; priv->CCKPresentAttentuation = 0; @@ -1224,11 +1199,11 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->bForcedSilentReset = 0; priv->bDisableNormalResetCheck = false; priv->force_reset = false; - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32); - memset(&priv->InterruptLog,0,sizeof(struct log_int_8190)); + memset(&priv->InterruptLog, 0, sizeof(struct log_int_8190)); priv->RxCounter = 0; - priv->rtllib->wx_set_enc = 0; + priv->rtllib->wx_set_enc = 0; priv->bHwRadioOff = false; priv->RegRfOff = 0; priv->isRFOff = false; @@ -1246,7 +1221,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->eRFPowerState = eRfOn; priv->txpower_checkcnt = 0; - priv->thermal_readback_index =0; + priv->thermal_readback_index = 0; priv->txpower_tracking_callback_cnt = 0; priv->ccktxpower_adjustcnt_ch14 = 0; priv->ccktxpower_adjustcnt_not_ch14 = 0; @@ -1255,7 +1230,8 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->rtllib->iw_mode = IW_MODE_INFRA; priv->rtllib->active_scan = 1; priv->rtllib->be_scan_inprogress = false; - priv->rtllib->modulation = RTLLIB_CCK_MODULATION | RTLLIB_OFDM_MODULATION; + priv->rtllib->modulation = RTLLIB_CCK_MODULATION | + RTLLIB_OFDM_MODULATION; priv->rtllib->host_encrypt = 1; priv->rtllib->host_decrypt = 1; @@ -1267,23 +1243,20 @@ static void rtl8192_init_priv_variable(struct net_device* dev) priv->card_type = PCI; priv->AcmControl = 0; - priv->pFirmware = (struct rt_firmware *)vmalloc(sizeof(struct rt_firmware)); + priv->pFirmware = vmalloc(sizeof(struct rt_firmware)); if (priv->pFirmware) - memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); + memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); - skb_queue_head_init(&priv->rx_queue); + skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->rtllib->skb_waitQ [i]); - } - for (i = 0; i < MAX_QUEUE_SIZE; i++) { - skb_queue_head_init(&priv->rtllib->skb_aggQ [i]); - } - + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_head_init(&priv->rtllib->skb_waitQ[i]); + for (i = 0; i < MAX_QUEUE_SIZE; i++) + skb_queue_head_init(&priv->rtllib->skb_aggQ[i]); } -static void rtl8192_init_priv_lock(struct r8192_priv * priv) +static void rtl8192_init_priv_lock(struct r8192_priv *priv) { spin_lock_init(&priv->fw_scan_lock); spin_lock_init(&priv->tx_lock); @@ -1293,57 +1266,64 @@ static void rtl8192_init_priv_lock(struct r8192_priv * priv) spin_lock_init(&priv->ps_lock); spin_lock_init(&priv->rf_lock); spin_lock_init(&priv->rt_h2c_lock); - sema_init(&priv->wx_sem,1); - sema_init(&priv->rf_sem,1); + sema_init(&priv->wx_sem, 1); + sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); } -static void rtl8192_init_priv_task(struct net_device* dev) +static void rtl8192_init_priv_task(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->priv_wq = create_workqueue(DRV_NAME); - INIT_WORK_RSL(&priv->reset_wq, (void*)rtl8192_restart, dev); - INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void*)IPSLeave_wq, dev); - INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, (void*)rtl819x_watchdog_wqcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq, (void*)dm_txpower_trackingcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq, (void*)dm_rf_pathcheck_workitemcallback, dev); - INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq, (void*)rtl8192_update_beacon, dev); - INIT_WORK_RSL(&priv->qos_activate, (void*)rtl8192_qos_activate, dev); - INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq, dev); - INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq, dev); + INIT_WORK_RSL(&priv->reset_wq, (void *)rtl8192_restart, dev); + INIT_WORK_RSL(&priv->rtllib->ips_leave_wq, (void *)IPSLeave_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->watch_dog_wq, + (void *)rtl819x_watchdog_wqcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->txpower_tracking_wq, + (void *)dm_txpower_trackingcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->rfpath_check_wq, + (void *)dm_rf_pathcheck_workitemcallback, dev); + INIT_DELAYED_WORK_RSL(&priv->update_beacon_wq, + (void *)rtl8192_update_beacon, dev); + INIT_WORK_RSL(&priv->qos_activate, (void *)rtl8192_qos_activate, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_wakeup_wq, + (void *) rtl8192_hw_wakeup_wq, dev); + INIT_DELAYED_WORK_RSL(&priv->rtllib->hw_sleep_wq, + (void *) rtl8192_hw_sleep_wq, dev); tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8192_irq_rx_tasklet, - (unsigned long)priv); + (void(*)(unsigned long))rtl8192_irq_rx_tasklet, + (unsigned long)priv); tasklet_init(&priv->irq_tx_tasklet, - (void(*)(unsigned long))rtl8192_irq_tx_tasklet, - (unsigned long)priv); - tasklet_init(&priv->irq_prepare_beacon_tasklet, - (void(*)(unsigned long))rtl8192_prepare_beacon, - (unsigned long)priv); + (void(*)(unsigned long))rtl8192_irq_tx_tasklet, + (unsigned long)priv); + tasklet_init(&priv->irq_prepare_beacon_tasklet, + (void(*)(unsigned long))rtl8192_prepare_beacon, + (unsigned long)priv); } -short rtl8192_get_channel_map(struct net_device * dev) +short rtl8192_get_channel_map(struct net_device *dev) { int i; struct r8192_priv *priv = rtllib_priv(dev); if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256) && (priv->rf_chip != RF_6052)) { - RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel map\n", __func__); + RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel " + "map\n", __func__); return -1; } if (priv->ChannelPlan > COUNTRY_CODE_MAX) { - printk("rtl819x_init:Error channel plan! Set to default.\n"); - priv->ChannelPlan= COUNTRY_CODE_FCC; + printk(KERN_INFO "rtl819x_init:Error channel plan! Set to " + "default.\n"); + priv->ChannelPlan = COUNTRY_CODE_FCC; } - RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan); + RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan); Dot11d_Init(priv->rtllib); Dot11d_Channelmap(priv->ChannelPlan, priv->rtllib); - for (i = 1; i <= 11; i++) { + for (i = 1; i <= 11; i++) (priv->rtllib->active_channel_map)[i] = 1; - } (priv->rtllib->active_channel_map)[12] = 2; (priv->rtllib->active_channel_map)[13] = 2; @@ -1354,10 +1334,9 @@ short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - memset(&(priv->stats),0,sizeof(struct rt_stats)); + memset(&(priv->stats), 0, sizeof(struct rt_stats)); rtl8192_dbgp_flag_init(dev); - rtl8192_init_priv_handler(dev); rtl8192_init_priv_constant(dev); rtl8192_init_priv_variable(dev); @@ -1380,17 +1359,17 @@ short rtl8192_init(struct net_device *dev) (unsigned long)dev); rtl8192_irq_disable(dev); - if (request_irq(dev->irq, (void*)rtl8192_interrupt_rsl, IRQF_SHARED, dev->name, dev)) - { - printk("Error allocating IRQ %d",dev->irq); + if (request_irq(dev->irq, (void *)rtl8192_interrupt_rsl, IRQF_SHARED, + dev->name, dev)) { + printk(KERN_ERR "Error allocating IRQ %d", dev->irq); return -1; } else { - priv->irq=dev->irq; - RT_TRACE(COMP_INIT, "IRQ %d\n",dev->irq); + priv->irq = dev->irq; + RT_TRACE(COMP_INIT, "IRQ %d\n", dev->irq); } if (rtl8192_pci_initdescring(dev) != 0) { - printk("Endopoints initialization failed"); + printk(KERN_ERR "Endopoints initialization failed"); return -1; } @@ -1398,51 +1377,48 @@ short rtl8192_init(struct net_device *dev) } /*************************************************************************** - -------------------------------WATCHDOG STUFF--------------------------- + -------------------------------WATCHDOG STUFF--------------------------- ***************************************************************************/ short rtl8192_is_tx_queue_empty(struct net_device *dev) { - int i=0; + int i = 0; struct r8192_priv *priv = rtllib_priv(dev); - for (i=0; i<=MGNT_QUEUE; i++) - { - if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) ) + for (i = 0; i <= MGNT_QUEUE; i++) { + if ((i == TXCMD_QUEUE) || (i == HCCA_QUEUE)) continue; - if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0){ - printk("===>tx queue is not empty:%d, %d\n", i, skb_queue_len(&(&priv->tx_ring[i])->queue)); + if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0) { + printk(KERN_INFO "===>tx queue is not empty:%d, %d\n", + i, skb_queue_len(&(&priv->tx_ring[i])->queue)); return 0; } } return 1; } -enum reset_type -rtl819x_TxCheckStuck(struct net_device *dev) +enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 QueueID; - u8 ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - bool bCheckFwTxCnt = false; + u8 QueueID; + u8 ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + bool bCheckFwTxCnt = false; struct rtl8192_tx_ring *ring = NULL; - struct sk_buff* skb = NULL; - struct cb_desc * tcb_desc = NULL; + struct sk_buff *skb = NULL; + struct cb_desc *tcb_desc = NULL; unsigned long flags = 0; - switch (priv->rtllib->ps) - { - case RTLLIB_PS_DISABLED: - ResetThreshold = NIC_SEND_HANG_THRESHOLD_NORMAL; - break; - case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): - ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - break; - default: - ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; - break; + switch (priv->rtllib->ps) { + case RTLLIB_PS_DISABLED: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_NORMAL; + break; + case (RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST): + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; + default: + ResetThreshold = NIC_SEND_HANG_THRESHOLD_POWERSAVE; + break; } - spin_lock_irqsave(&priv->irq_th_lock,flags); - for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) - { + spin_lock_irqsave(&priv->irq_th_lock, flags); + for (QueueID = 0; QueueID < MAX_TX_QUEUE; QueueID++) { if (QueueID == TXCMD_QUEUE) continue; @@ -1451,24 +1427,26 @@ rtl819x_TxCheckStuck(struct net_device *dev) ring = &priv->tx_ring[QueueID]; - if (skb_queue_len(&ring->queue) == 0) + if (skb_queue_len(&ring->queue) == 0) { continue; - else - { + } else { skb = (&ring->queue)->next; - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); tcb_desc->nStuckCount++; bCheckFwTxCnt = true; if (tcb_desc->nStuckCount > 1) - printk("%s: QueueID=%d tcb_desc->nStuckCount=%d\n",__func__,QueueID,tcb_desc->nStuckCount); + printk(KERN_INFO "%s: QueueID=%d tcb_desc->n" + "StuckCount=%d\n", __func__, QueueID, + tcb_desc->nStuckCount); } } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); if (bCheckFwTxCnt) { - if (priv->ops->TxCheckStuckHandler(dev)) - { - RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition! \n"); + if (priv->ops->TxCheckStuckHandler(dev)) { + RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no" + " Tx condition!\n"); return RESET_TYPE_SILENT; } } @@ -1480,8 +1458,7 @@ enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->ops->RxCheckStuckHandler(dev)) - { + if (priv->ops->RxCheckStuckHandler(dev)) { RT_TRACE(COMP_RESET, "RxStuck Condition\n"); return RESET_TYPE_SILENT; } @@ -1502,18 +1479,20 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) if (rfState == eRfOn) TxResetType = rtl819x_TxCheckStuck(dev); - if ( rfState == eRfOn && + if (rfState == eRfOn && (priv->rtllib->iw_mode == IW_MODE_INFRA) && - (priv->rtllib->state == RTLLIB_LINKED)) { - + (priv->rtllib->state == RTLLIB_LINKED)) RxResetType = rtl819x_RxCheckStuck(dev); - } - if (TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL){ - printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + if (TxResetType == RESET_TYPE_NORMAL || + RxResetType == RESET_TYPE_NORMAL) { + printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n", + __func__, TxResetType, RxResetType); return RESET_TYPE_NORMAL; - } else if (TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT){ - printk("%s(): TxResetType is %d, RxResetType is %d\n",__func__,TxResetType,RxResetType); + } else if (TxResetType == RESET_TYPE_SILENT || + RxResetType == RESET_TYPE_SILENT) { + printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n", + __func__, TxResetType, RxResetType); return RESET_TYPE_SILENT; } else { return RESET_TYPE_NORESET; @@ -1536,21 +1515,20 @@ void rtl819x_ifsilentreset(struct net_device *dev) u8 IsPortal = 0; - if (priv->ResetProgress==RESET_TYPE_NORESET) { + if (priv->ResetProgress == RESET_TYPE_NORESET) { - RT_TRACE(COMP_RESET,"=========>Reset progress!! \n"); + RT_TRACE(COMP_RESET, "=========>Reset progress!!\n"); priv->ResetProgress = RESET_TYPE_SILENT; - spin_lock_irqsave(&priv->rf_ps_lock,flag); - if (priv->RFChangeInProgress) - { - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_lock_irqsave(&priv->rf_ps_lock, flag); + if (priv->RFChangeInProgress) { + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); goto END; } priv->RFChangeInProgress = true; priv->bResetInProgress = true; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); RESET_START: @@ -1560,15 +1538,18 @@ RESET_START: LeisurePSLeave(dev); if (IS_NIC_DOWN(priv)) { - RT_TRACE(COMP_ERR,"%s():the driver is not up! return\n",__func__); + RT_TRACE(COMP_ERR, "%s():the driver is not up! " + "return\n", __func__); up(&priv->wx_sem); return ; } priv->up = 0; - RT_TRACE(COMP_RESET,"%s():======>start to down the driver\n",__func__); + RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n", + __func__); mdelay(1000); - RT_TRACE(COMP_RESET,"%s():111111111111111111111111======>start to down the driver\n",__func__); + RT_TRACE(COMP_RESET, "%s():111111111111111111111111======>start" + " to down the driver\n", __func__); if (!netif_queue_stopped(dev)) netif_stop_queue(dev); @@ -1581,7 +1562,7 @@ RESET_START: if (ieee->state == RTLLIB_LINKED) { SEM_DOWN_IEEE_WX(&ieee->wx_sem); - printk("ieee->state is RTLLIB_LINKED\n"); + printk(KERN_INFO "ieee->state is RTLLIB_LINKED\n"); rtllib_stop_send_beacons(priv->rtllib); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); @@ -1589,43 +1570,51 @@ RESET_START: netif_carrier_off(dev); SEM_UP_IEEE_WX(&ieee->wx_sem); } else { - printk("ieee->state is NOT LINKED\n"); - rtllib_softmac_stop_protocol(priv->rtllib, 0 ,true); + printk(KERN_INFO "ieee->state is NOT LINKED\n"); + rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); } dm_backup_dynamic_mechanism_state(dev); up(&priv->wx_sem); - RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__func__); + RT_TRACE(COMP_RESET, "%s():<==========down process is " + "finished\n", __func__); - RT_TRACE(COMP_RESET,"%s():<===========up process start\n",__func__); - reset_status = _rtl8192_up(dev,true); + RT_TRACE(COMP_RESET, "%s():<===========up process start\n", + __func__); + reset_status = _rtl8192_up(dev, true); - RT_TRACE(COMP_RESET,"%s():<===========up process is finished\n",__func__); + RT_TRACE(COMP_RESET, "%s():<===========up process is " + "finished\n", __func__); if (reset_status == -1) { if (reset_times < 3) { reset_times++; goto RESET_START; } else { - RT_TRACE(COMP_ERR," ERR!!! %s(): Reset Failed!!\n",__func__); + RT_TRACE(COMP_ERR, " ERR!!! %s(): Reset " + "Failed!!\n", __func__); } } ieee->is_silent_reset = 1; - spin_lock_irqsave(&priv->rf_ps_lock,flag); + spin_lock_irqsave(&priv->rf_ps_lock, flag); priv->RFChangeInProgress = false; - spin_unlock_irqrestore(&priv->rf_ps_lock,flag); + spin_unlock_irqrestore(&priv->rf_ps_lock, flag); EnableHWSecurityConfig8192(dev); - if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == + IW_MODE_INFRA) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); - } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_ADHOC) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + } else if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == + IW_MODE_ADHOC) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); ieee->link_change(ieee->dev); notify_wx_assoc_event(ieee); @@ -1645,27 +1634,30 @@ END: priv->ResetProgress = RESET_TYPE_NORESET; priv->reset_count++; - priv->bForcedSilentReset =false; + priv->bForcedSilentReset = false; priv->bResetInProgress = false; write_nic_byte(dev, UFWP, 1); - RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count); + RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", + priv->reset_count); } } -void rtl819x_update_rxcounts(struct r8192_priv *priv, - u32 *TotalRxBcnNum, +void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, u32 *TotalRxDataNum) { - u16 SlotIndex; - u8 i; + u16 SlotIndex; + u8 i; *TotalRxBcnNum = 0; *TotalRxDataNum = 0; - SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++)%(priv->rtllib->LinkDetectInfo.SlotNum); - priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod; - priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] = priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod; + SlotIndex = (priv->rtllib->LinkDetectInfo.SlotIndex++) % + (priv->rtllib->LinkDetectInfo.SlotNum); + priv->rtllib->LinkDetectInfo.RxBcnNum[SlotIndex] = + priv->rtllib->LinkDetectInfo.NumRecvBcnInPeriod; + priv->rtllib->LinkDetectInfo.RxDataNum[SlotIndex] = + priv->rtllib->LinkDetectInfo.NumRecvDataInPeriod; for (i = 0; i < priv->rtllib->LinkDetectInfo.SlotNum; i++) { *TotalRxBcnNum += priv->rtllib->LinkDetectInfo.RxBcnNum[i]; *TotalRxDataNum += priv->rtllib->LinkDetectInfo.RxDataNum[i]; @@ -1675,13 +1667,15 @@ void rtl819x_update_rxcounts(struct r8192_priv *priv, void rtl819x_watchdog_wqcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, watch_dog_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, watch_dog_wq); struct net_device *dev = priv->rtllib->dev; - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; enum reset_type ResetType = RESET_TYPE_NORESET; - static u8 check_reset_cnt = 0; + static u8 check_reset_cnt; unsigned long flags; - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); bool bBusyTraffic = false; bool bHigherBusyTraffic = false; bool bHigherBusyRxTraffic = false; @@ -1691,7 +1685,7 @@ void rtl819x_watchdog_wqcallback(void *data) return; if (priv->rtllib->state >= RTLLIB_LINKED) { - if (priv->rtllib->CntAfterLink<2) + if (priv->rtllib->CntAfterLink < 2) priv->rtllib->CntAfterLink++; } else { priv->rtllib->CntAfterLink = 0; @@ -1699,130 +1693,125 @@ void rtl819x_watchdog_wqcallback(void *data) hal_dm_watchdog(dev); - if (rtllib_act_scanning(priv->rtllib,false) == false){ - if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == RTLLIB_NOLINK) &&\ - (ieee->eRFPowerState == eRfOn)&&!ieee->is_set_key &&\ - (!ieee->proto_stoppping) && !ieee->wx_set_enc - ){ - if ((ieee->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE)&& - (!ieee->bNetPromiscuousMode)) - { - RT_TRACE(COMP_PS, "====================>haha:IPSEnter()\n"); + if (rtllib_act_scanning(priv->rtllib, false) == false) { + if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == + RTLLIB_NOLINK) && + (ieee->eRFPowerState == eRfOn) && !ieee->is_set_key && + (!ieee->proto_stoppping) && !ieee->wx_set_enc) { + if ((ieee->PowerSaveControl.ReturnPoint == + IPS_CALLBACK_NONE) && + (!ieee->bNetPromiscuousMode)) { + RT_TRACE(COMP_PS, "====================>haha: " + "IPSEnter()\n"); IPSEnter(dev); } } } - { - if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode == IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) - { - if ( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || - ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { - bBusyTraffic = true; - } + if ((ieee->state == RTLLIB_LINKED) && (ieee->iw_mode == + IW_MODE_INFRA) && (!ieee->bNetPromiscuousMode)) { + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 100 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 100) + bBusyTraffic = true; - if ( ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || - ieee->LinkDetectInfo.NumTxOkInPeriod > 4000 ) - { - bHigherBusyTraffic = true; - if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000) - bHigherBusyRxTraffic = true; - else - bHigherBusyRxTraffic = false; - } - - if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) - bEnterPS= false; + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 4000 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 4000) { + bHigherBusyTraffic = true; + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 5000) + bHigherBusyRxTraffic = true; else - bEnterPS= true; + bHigherBusyRxTraffic = false; + } - if (ieee->current_network.beacon_interval < 95) - bEnterPS= false; + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) + bEnterPS = false; + else + bEnterPS = true; - if (bEnterPS) - LeisurePSEnter(dev); - else - LeisurePSLeave(dev); + if (ieee->current_network.beacon_interval < 95) + bEnterPS = false; - } else { - RT_TRACE(COMP_LPS,"====>no link LPS leave\n"); + if (bEnterPS) + LeisurePSEnter(dev); + else LeisurePSLeave(dev); + + } else { + RT_TRACE(COMP_LPS, "====>no link LPS leave\n"); + LeisurePSLeave(dev); + } + + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; + ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + + ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; + ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + + if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) { + u32 TotalRxBcnNum = 0; + u32 TotalRxDataNum = 0; + + rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); + + if ((TotalRxBcnNum+TotalRxDataNum) == 0) + priv->check_roaming_cnt++; + else + priv->check_roaming_cnt = 0; + + + if (priv->check_roaming_cnt > 0) { + if (ieee->eRFPowerState == eRfOff) + RT_TRACE(COMP_ERR, "========>%s()\n", __func__); + + printk(KERN_INFO "===>%s(): AP is power off, chan:%d," + " connect another one\n", __func__, priv->chan); + + ieee->state = RTLLIB_ASSOCIATING; + + RemovePeerTS(priv->rtllib, + priv->rtllib->current_network.bssid); + ieee->is_roaming = true; + ieee->is_set_key = false; + ieee->link_change(dev); + if (ieee->LedControlHandler) + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); + + notify_wx_assoc_event(ieee); + + if (!(ieee->rtllib_ap_sec_type(ieee) & + (SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + + priv->check_roaming_cnt = 0; } - - ieee->LinkDetectInfo.NumRxOkInPeriod = 0; - ieee->LinkDetectInfo.NumTxOkInPeriod = 0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; - ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - - ieee->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; - ieee->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; } - { - if (ieee->state == RTLLIB_LINKED && ieee->iw_mode == IW_MODE_INFRA) - { - u32 TotalRxBcnNum = 0; - u32 TotalRxDataNum = 0; - - rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); - - if ((TotalRxBcnNum+TotalRxDataNum) == 0) - priv->check_roaming_cnt ++; - else - priv->check_roaming_cnt = 0; - - - if (priv->check_roaming_cnt > 0) - { - if ( ieee->eRFPowerState == eRfOff) - RT_TRACE(COMP_ERR,"========>%s()\n",__func__); - - printk("===>%s(): AP is power off,chan:%d, connect another one\n",__func__, priv->chan); - - ieee->state = RTLLIB_ASSOCIATING; - - RemovePeerTS(priv->rtllib,priv->rtllib->current_network.bssid); - ieee->is_roaming = true; - ieee->is_set_key = false; - ieee->link_change(dev); - if (ieee->LedControlHandler) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); - - notify_wx_assoc_event(ieee); - - if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); - - priv->check_roaming_cnt = 0; - } - } - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - - } - - spin_lock_irqsave(&priv->tx_lock,flags); + spin_lock_irqsave(&priv->tx_lock, flags); if ((check_reset_cnt++ >= 3) && (!ieee->is_roaming) && - (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) - { + (!priv->RFChangeInProgress) && (!pPSC->bSwRfProcessing)) { ResetType = rtl819x_ifcheck_resetornot(dev); check_reset_cnt = 3; } - spin_unlock_irqrestore(&priv->tx_lock,flags); + spin_unlock_irqrestore(&priv->tx_lock, flags); - if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) - { + if (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL) { priv->ResetProgress = RESET_TYPE_NORMAL; - RT_TRACE(COMP_RESET,"%s(): NOMAL RESET\n",__func__); + RT_TRACE(COMP_RESET, "%s(): NOMAL RESET\n", __func__); return; } - if ( ((priv->force_reset) || (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT))) - { + if (((priv->force_reset) || (!priv->bDisableNormalResetCheck && + ResetType == RESET_TYPE_SILENT))) rtl819x_ifsilentreset(dev); - } priv->force_reset = false; priv->bForcedSilentReset = false; priv->bResetInProgress = false; @@ -1831,9 +1820,10 @@ void rtl819x_watchdog_wqcallback(void *data) void watch_dog_timer_callback(unsigned long data) { - struct r8192_priv *priv = rtllib_priv((struct net_device *) data); - queue_delayed_work_rsl(priv->priv_wq,&priv->watch_dog_wq,0); - mod_timer(&priv->watch_dog_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); + queue_delayed_work_rsl(priv->priv_wq, &priv->watch_dog_wq, 0); + mod_timer(&priv->watch_dog_timer, jiffies + + MSECS(RTLLIB_WATCH_DOG_TIME)); } /**************************************************************************** @@ -1841,61 +1831,65 @@ void watch_dog_timer_callback(unsigned long data) *****************************************************************************/ void rtl8192_rx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->ops->rx_enable(dev); } void rtl8192_tx_enable(struct net_device *dev) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); priv->ops->tx_enable(dev); - rtllib_reset_queue(priv->rtllib); + rtllib_reset_queue(priv->rtllib); } static void rtl8192_free_rx_ring(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - int i,rx_queue_idx; + struct r8192_priv *priv = rtllib_priv(dev); + int i, rx_queue_idx; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ - for (i = 0; i < priv->rxringcount; i++) { + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; + rx_queue_idx++) { + for (i = 0; i < priv->rxringcount; i++) { struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i]; - if (!skb) - continue; + if (!skb) + continue; - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); - kfree_skb(skb); - } + pci_unmap_single(priv->pdev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, PCI_DMA_FROMDEVICE); + kfree_skb(skb); + } - pci_free_consistent(priv->pdev, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, - priv->rx_ring[rx_queue_idx], priv->rx_ring_dma[rx_queue_idx]); + pci_free_consistent(priv->pdev, + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount, + priv->rx_ring[rx_queue_idx], + priv->rx_ring_dma[rx_queue_idx]); priv->rx_ring[rx_queue_idx] = NULL; } } static void rtl8192_free_tx_ring(struct net_device *dev, unsigned int prio) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } - pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, - ring->desc, ring->dma); - ring->desc = NULL; + pci_free_consistent(priv->pdev, sizeof(*ring->desc)*ring->entries, + ring->desc, ring->dma); + ring->desc = NULL; } void rtl8192_data_hard_stop(struct net_device *dev) @@ -1907,14 +1901,17 @@ void rtl8192_data_hard_resume(struct net_device *dev) { } -void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, + int rate) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || priv->bResetInProgress){ + if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) || + priv->bResetInProgress) { kfree_skb(skb); return; } @@ -1922,15 +1919,16 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat assert(queue_index != TXCMD_QUEUE); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); skb_push(skb, priv->rtllib->tx_headroom); ret = rtl8192_tx(dev, skb); if (ret != 0) { kfree_skb(skb); }; - if (queue_index!=MGNT_QUEUE) { - priv->rtllib->stats.tx_bytes+=(skb->len - priv->rtllib->tx_headroom); + if (queue_index != MGNT_QUEUE) { + priv->rtllib->stats.tx_bytes += (skb->len - + priv->rtllib->tx_headroom); priv->rtllib->stats.tx_packets++; } @@ -1938,21 +1936,23 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rat return; } -int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) +int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); int ret; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - if (queue_index != TXCMD_QUEUE){ - if ((priv->rtllib->eRFPowerState == eRfOff) ||IS_NIC_DOWN(priv) || priv->bResetInProgress){ + if (queue_index != TXCMD_QUEUE) { + if ((priv->rtllib->eRFPowerState == eRfOff) || + IS_NIC_DOWN(priv) || priv->bResetInProgress) { kfree_skb(skb); return 0; } } - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); if (queue_index == TXCMD_QUEUE) { rtl8192_tx_cmd(dev, skb); ret = 0; @@ -1977,81 +1977,82 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev) void rtl8192_tx_isr(struct net_device *dev, int prio) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; + struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb; + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb; - if (prio != BEACON_QUEUE) { - if (entry->OWN) - return; - ring->idx = (ring->idx + 1) % ring->entries; - } + if (prio != BEACON_QUEUE) { + if (entry->OWN) + return; + ring->idx = (ring->idx + 1) % ring->entries; + } - skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - - kfree_skb(skb); - } - if (prio != BEACON_QUEUE) { - tasklet_schedule(&priv->irq_tx_tasklet); - } + skb = __skb_dequeue(&ring->queue); + pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + } + if (prio != BEACON_QUEUE) + tasklet_schedule(&priv->irq_tx_tasklet); } void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtl8192_tx_ring *ring; - struct tx_desc_cmd * entry; - unsigned int idx; - struct cb_desc *tcb_desc; - unsigned long flags; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtl8192_tx_ring *ring; + struct tx_desc_cmd *entry; + unsigned int idx; + struct cb_desc *tcb_desc; + unsigned long flags; - spin_lock_irqsave(&priv->irq_th_lock,flags); - ring = &priv->tx_ring[TXCMD_QUEUE]; + spin_lock_irqsave(&priv->irq_th_lock, flags); + ring = &priv->tx_ring[TXCMD_QUEUE]; - idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - entry = (struct tx_desc_cmd *) &ring->desc[idx]; + idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; + entry = (struct tx_desc_cmd *) &ring->desc[idx]; - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); + priv->ops->tx_fill_cmd_descriptor(dev, entry, tcb_desc, skb); - __skb_queue_tail(&ring->queue, skb); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + __skb_queue_tail(&ring->queue, skb); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); - return; + return; } -short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) +short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring; unsigned long flags; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct tx_desc *pdesc = NULL; - struct rtllib_hdr_1addr * header = NULL; - u16 fc=0, type=0,stype=0; - bool multi_addr=false,broad_addr=false,uni_addr=false; - u8* pda_addr = NULL; + struct rtllib_hdr_1addr *header = NULL; + u16 fc = 0, type = 0, stype = 0; + bool multi_addr = false, broad_addr = false, uni_addr = false; + u8 *pda_addr = NULL; int idx; u32 fwinfo_size = 0; - if (priv->bdisable_nic){ - RT_TRACE(COMP_ERR,"%s: ERR!! Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n", __func__, skb->len, tcb_desc->queue_index); - return skb->len; + if (priv->bdisable_nic) { + RT_TRACE(COMP_ERR, "%s: ERR!! Nic is disabled! Can't tx packet" + " len=%d qidx=%d!!!\n", __func__, skb->len, + tcb_desc->queue_index); + return skb->len; } priv->rtllib->bAwakePktSent = true; fwinfo_size = sizeof(struct tx_fwinfo_8190pci); - header = (struct rtllib_hdr_1addr *)(((u8*)skb->data) + fwinfo_size); + header = (struct rtllib_hdr_1addr *)(((u8 *)skb->data) + fwinfo_size); fc = header->frame_ctl; type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); @@ -2061,9 +2062,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) multi_addr = true; else if (is_broadcast_ether_addr(pda_addr)) broad_addr = true; - else { + else uni_addr = true; - } if (uni_addr) priv->stats.txbytesunicast += skb->len - fwinfo_size; @@ -2072,36 +2072,34 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb) else priv->stats.txbytesbroadcast += skb->len - fwinfo_size; - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); ring = &priv->tx_ring[tcb_desc->queue_index]; - if (tcb_desc->queue_index != BEACON_QUEUE) { + if (tcb_desc->queue_index != BEACON_QUEUE) idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries; - } else { + else idx = 0; - } pdesc = &ring->desc[idx]; if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) { - RT_TRACE(COMP_ERR,"No more TX desc@%d, ring->idx = %d,idx = %d, skblen = 0x%x queuelen=%d", \ - tcb_desc->queue_index,ring->idx, idx,skb->len, skb_queue_len(&ring->queue)); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d, idx = " + "%d, skblen = 0x%x queuelen=%d", + tcb_desc->queue_index, ring->idx, idx, skb->len, + skb_queue_len(&ring->queue)); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); return skb->len; } - if (tcb_desc->queue_index == MGNT_QUEUE){ - } - - if (type == RTLLIB_FTYPE_DATA){ + if (type == RTLLIB_FTYPE_DATA) { if (priv->rtllib->LedControlHandler) priv->rtllib->LedControlHandler(dev, LED_CTL_TX); } priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, skb); __skb_queue_tail(&ring->queue, skb); pdesc->OWN = 1; - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); dev->trans_start = jiffies; - write_nic_word(dev,TPPoll,0x01<queue_index); + write_nic_word(dev, TPPoll, 0x01 << tcb_desc->queue_index); return 0; } @@ -2111,16 +2109,21 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) struct rx_desc *entry = NULL; int i, rx_queue_idx; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { priv->rx_ring[rx_queue_idx] = pci_alloc_consistent(priv->pdev, - sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, &priv->rx_ring_dma[rx_queue_idx]); + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount, + &priv->rx_ring_dma[rx_queue_idx]); - if (!priv->rx_ring[rx_queue_idx] || (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { - RT_TRACE(COMP_ERR,"Cannot allocate RX ring\n"); + if (!priv->rx_ring[rx_queue_idx] || + (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate RX ring\n"); return -ENOMEM; } - memset(priv->rx_ring[rx_queue_idx], 0, sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount); + memset(priv->rx_ring[rx_queue_idx], 0, + sizeof(*priv->rx_ring[rx_queue_idx]) * + priv->rxringcount); priv->rx_idx[rx_queue_idx] = 0; for (i = 0; i < priv->rxringcount; i++) { @@ -2132,8 +2135,10 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) skb->dev = dev; priv->rx_buf[rx_queue_idx][i] = skb; mapping = (dma_addr_t *)skb->cb; - *mapping = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); + *mapping = pci_map_single(priv->pdev, + skb_tail_pointer_rsl(skb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); entry->BufferAddress = cpu_to_le32(*mapping); @@ -2147,68 +2152,69 @@ short rtl8192_alloc_rx_desc_ring(struct net_device *dev) } static int rtl8192_alloc_tx_desc_ring(struct net_device *dev, - unsigned int prio, unsigned int entries) + unsigned int prio, unsigned int entries) { - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct tx_desc *ring; - dma_addr_t dma; - int i; + struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + struct tx_desc *ring; + dma_addr_t dma; + int i; - ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); - if (!ring || (unsigned long)ring & 0xFF) { - RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", prio); - return -ENOMEM; - } + ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); + if (!ring || (unsigned long)ring & 0xFF) { + RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n", + prio); + return -ENOMEM; + } - memset(ring, 0, sizeof(*ring)*entries); - priv->tx_ring[prio].desc = ring; - priv->tx_ring[prio].dma = dma; - priv->tx_ring[prio].idx = 0; - priv->tx_ring[prio].entries = entries; - skb_queue_head_init(&priv->tx_ring[prio].queue); + memset(ring, 0, sizeof(*ring)*entries); + priv->tx_ring[prio].desc = ring; + priv->tx_ring[prio].dma = dma; + priv->tx_ring[prio].idx = 0; + priv->tx_ring[prio].entries = entries; + skb_queue_head_init(&priv->tx_ring[prio].queue); - for (i = 0; i < entries; i++) - ring[i].NextDescAddress = - cpu_to_le32((u32)dma + ((i + 1) % entries) * sizeof(*ring)); + for (i = 0; i < entries; i++) + ring[i].NextDescAddress = + cpu_to_le32((u32)dma + ((i + 1) % entries) * + sizeof(*ring)); - return 0; + return 0; } short rtl8192_pci_initdescring(struct net_device *dev) { - u32 ret; - int i; - struct r8192_priv *priv = rtllib_priv(dev); + u32 ret; + int i; + struct r8192_priv *priv = rtllib_priv(dev); - ret = rtl8192_alloc_rx_desc_ring(dev); - if (ret) { - return ret; - } + ret = rtl8192_alloc_rx_desc_ring(dev); + if (ret) + return ret; + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount); + if (ret) + goto err_free_rings; + } - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if ((ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount))) - goto err_free_rings; - } - - return 0; + return 0; err_free_rings: - rtl8192_free_rx_ring(dev); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) - if (priv->tx_ring[i].desc) - rtl8192_free_tx_ring(dev, i); - return 1; + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + if (priv->tx_ring[i].desc) + rtl8192_free_tx_ring(dev, i); + return 1; } void rtl8192_pci_resetdescring(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - int i,rx_queue_idx; - unsigned long flags = 0; + struct r8192_priv *priv = rtllib_priv(dev); + int i, rx_queue_idx; + unsigned long flags = 0; - for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx ++){ + for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { if (priv->rx_ring[rx_queue_idx]) { struct rx_desc *entry = NULL; for (i = 0; i < priv->rxringcount; i++) { @@ -2219,27 +2225,30 @@ void rtl8192_pci_resetdescring(struct net_device *dev) } } - spin_lock_irqsave(&priv->irq_th_lock,flags); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if (priv->tx_ring[i].desc) { - struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; + spin_lock_irqsave(&priv->irq_th_lock, flags); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { + if (priv->tx_ring[i].desc) { + struct rtl8192_tx_ring *ring = &priv->tx_ring[i]; - while (skb_queue_len(&ring->queue)) { - struct tx_desc *entry = &ring->desc[ring->idx]; - struct sk_buff *skb = __skb_dequeue(&ring->queue); + while (skb_queue_len(&ring->queue)) { + struct tx_desc *entry = &ring->desc[ring->idx]; + struct sk_buff *skb = + __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, le32_to_cpu(entry->TxBuffAddr), - skb->len, PCI_DMA_TODEVICE); - kfree_skb(skb); - ring->idx = (ring->idx + 1) % ring->entries; - } - ring->idx = 0; - } - } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + pci_unmap_single(priv->pdev, + le32_to_cpu(entry->TxBuffAddr), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + ring->idx = 0; + } + } + spin_unlock_irqrestore(&priv->irq_th_lock, flags); } -void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats) +void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev, + struct rtllib_rx_stats *stats) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2249,7 +2258,7 @@ void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stat priv->LastRxDescTSF = stats->mac_time; } -long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ) +long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index) { long signal_power; @@ -2262,48 +2271,41 @@ long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index void rtl819x_update_rxsignalstatistics8190pci( - struct r8192_priv * priv, - struct rtllib_rx_stats * pprevious_stats + struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats ) { int weighting = 0; if (priv->stats.recv_signal_power == 0) - priv->stats.recv_signal_power = pprevious_stats->RecvSignalPower; + priv->stats.recv_signal_power = + pprevious_stats->RecvSignalPower; if (pprevious_stats->RecvSignalPower > priv->stats.recv_signal_power) weighting = 5; - else if (pprevious_stats->RecvSignalPower < priv->stats.recv_signal_power) + else if (pprevious_stats->RecvSignalPower < + priv->stats.recv_signal_power) weighting = (-5); - priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + pprevious_stats->RecvSignalPower + weighting) / 6; + priv->stats.recv_signal_power = (priv->stats.recv_signal_power * 5 + + pprevious_stats->RecvSignalPower + + weighting) / 6; } -void -rtl819x_process_cck_rxpathsel( - struct r8192_priv * priv, - struct rtllib_rx_stats * pprevious_stats - ) +void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats) { } -u8 rtl819x_query_rxpwrpercentage( - char antpower - ) +u8 rtl819x_query_rxpwrpercentage(char antpower) { if ((antpower <= -100) || (antpower >= 20)) - { return 0; - } else if (antpower >= 0) - { return 100; - } else - { - return (100+antpower); - } + return 100 + antpower; } /* QueryRxPwrPercentage */ @@ -2321,16 +2323,16 @@ rtl819x_evm_dbtopercentage( if (ret_val <= -33) ret_val = -33; ret_val = 0 - ret_val; - ret_val*=3; + ret_val *= 3; if (ret_val == 99) ret_val = 100; - return(ret_val); + return ret_val; } void rtl8192_record_rxdesc_forlateruse( - struct rtllib_rx_stats * psrc_stats, - struct rtllib_rx_stats * ptarget_stats + struct rtllib_rx_stats *psrc_stats, + struct rtllib_rx_stats *ptarget_stats ) { ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; @@ -2344,8 +2346,8 @@ void rtl8192_rx_normal(struct net_device *dev) struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_hdr_1addr *rtllib_hdr = NULL; bool unicast_packet = false; - bool bLedBlinking=true; - u16 fc=0, type=0; + bool bLedBlinking = true; + u16 fc = 0, type = 0; u32 skb_len = 0; int rx_queue_idx = RX_MPDU_QUEUE; @@ -2360,8 +2362,10 @@ void rtl8192_rx_normal(struct net_device *dev) stats.nic_type = NIC_8192E; while (count--) { - struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; - struct sk_buff *skb = priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]]; + struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx] + [priv->rx_idx[rx_queue_idx]]; + struct sk_buff *skb = priv->rx_buf[rx_queue_idx] + [priv->rx_idx[rx_queue_idx]]; if (pdesc->OWN) { return; @@ -2369,11 +2373,11 @@ void rtl8192_rx_normal(struct net_device *dev) struct sk_buff *new_skb; if (!priv->ops->rx_query_status_descriptor(dev, &stats, - pdesc, skb)) + pdesc, skb)) goto done; new_skb = dev_alloc_skb(priv->rxbuffersize); /* if allocation of new skb failed - drop current packet - * and reuse skb */ + * and reuse skb */ if (unlikely(!new_skb)) goto done; @@ -2384,11 +2388,11 @@ void rtl8192_rx_normal(struct net_device *dev) skb_put(skb, pdesc->Length); skb_reserve(skb, stats.RxDrvInfoSize + - stats.RxBufShift); + stats.RxBufShift); skb_trim(skb, skb->len - 4/*sCrcLng*/); rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data; if (!is_broadcast_ether_addr(rtllib_hdr->addr1) && - !is_multicast_ether_addr(rtllib_hdr->addr1)) { + !is_multicast_ether_addr(rtllib_hdr->addr1)) { /* unicast packet */ unicast_packet = true; } @@ -2400,18 +2404,18 @@ void rtl8192_rx_normal(struct net_device *dev) if (bLedBlinking) if (priv->rtllib->LedControlHandler) priv->rtllib->LedControlHandler(dev, - LED_CTL_RX); + LED_CTL_RX); if (stats.bCRC) { if (type != RTLLIB_FTYPE_MGMT) - priv->stats.rxdatacrcerr ++; + priv->stats.rxdatacrcerr++; else - priv->stats.rxmgmtcrcerr ++; + priv->stats.rxmgmtcrcerr++; } skb_len = skb->len; - if (!rtllib_rx(priv->rtllib, skb, &stats)){ + if (!rtllib_rx(priv->rtllib, skb, &stats)) { dev_kfree_skb_any(skb); } else { priv->stats.rxok++; @@ -2422,8 +2426,12 @@ void rtl8192_rx_normal(struct net_device *dev) skb = new_skb; skb->dev = dev; - priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; - *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer_rsl(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE); + priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = + skb; + *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, + skb_tail_pointer_rsl(skb), + priv->rxbuffersize, + PCI_DMA_FROMDEVICE); } done: @@ -2432,7 +2440,8 @@ done: pdesc->Length = priv->rxbuffersize; if (priv->rx_idx[rx_queue_idx] == priv->rxringcount-1) pdesc->EOR = 1; - priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % priv->rxringcount; + priv->rx_idx[rx_queue_idx] = (priv->rx_idx[rx_queue_idx] + 1) % + priv->rxringcount; } } @@ -2449,18 +2458,19 @@ void rtl8192_tx_resume(struct net_device *dev) struct sk_buff *skb; int queue_index; - for (queue_index = BK_QUEUE; queue_index < MAX_QUEUE_SIZE;queue_index++) { - while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index]))&& - (priv->rtllib->check_nic_enough_desc(dev,queue_index) > 0)) { + for (queue_index = BK_QUEUE; + queue_index < MAX_QUEUE_SIZE; queue_index++) { + while ((!skb_queue_empty(&ieee->skb_waitQ[queue_index])) && + (priv->rtllib->check_nic_enough_desc(dev, queue_index) > 0)) { skb = skb_dequeue(&ieee->skb_waitQ[queue_index]); - ieee->softmac_data_hard_start_xmit(skb,dev,0/* rate useless now*/); + ieee->softmac_data_hard_start_xmit(skb, dev, 0); } } } void rtl8192_irq_tx_tasklet(struct r8192_priv *priv) { - rtl8192_tx_resume(priv->rtllib->dev); + rtl8192_tx_resume(priv->rtllib->dev); } void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) @@ -2470,13 +2480,14 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) if (MAX_RX_QUEUE > 1) rtl8192_rx_cmd(priv->rtllib->dev); - write_nic_dword(priv->rtllib->dev, INTA_MASK,read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); + write_nic_dword(priv->rtllib->dev, INTA_MASK, + read_nic_dword(priv->rtllib->dev, INTA_MASK) | IMR_RDU); } /**************************************************************************** ---------------------------- NIC START/CLOSE STUFF--------------------------- *****************************************************************************/ -void rtl8192_cancel_deferred_work(struct r8192_priv * priv) +void rtl8192_cancel_deferred_work(struct r8192_priv *priv) { cancel_delayed_work(&priv->watch_dog_wq); cancel_delayed_work(&priv->update_beacon_wq); @@ -2485,7 +2496,7 @@ void rtl8192_cancel_deferred_work(struct r8192_priv * priv) cancel_work_sync(&priv->qos_activate); } -int _rtl8192_up(struct net_device *dev,bool is_silent_reset) +int _rtl8192_up(struct net_device *dev, bool is_silent_reset) { if (_rtl8192_sta_up(dev, is_silent_reset) == -1) return -1; @@ -2510,8 +2521,9 @@ int rtl8192_up(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->up == 1) return -1; - return _rtl8192_up(dev,false); + if (priv->up == 1) + return -1; + return _rtl8192_up(dev, false); } @@ -2521,13 +2533,13 @@ int rtl8192_close(struct net_device *dev) int ret; if ((rtllib_act_scanning(priv->rtllib, false)) && - !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { rtllib_stop_scan(priv->rtllib); } down(&priv->wx_sem); - ret = rtl8192_down(dev,true); + ret = rtl8192_down(dev, true); up(&priv->wx_sem); @@ -2547,16 +2559,18 @@ void rtl8192_commit(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->up == 0) return ; + if (priv->up == 0) + return; rtllib_softmac_stop_protocol(priv->rtllib, 0 , true); rtl8192_irq_disable(dev); priv->ops->stop_adapter(dev, true); - _rtl8192_up(dev,false); + _rtl8192_up(dev, false); } void rtl8192_restart(void *data) { - struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, reset_wq); + struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, + reset_wq); struct net_device *dev = priv->rtllib->dev; down(&priv->wx_sem); @@ -2571,14 +2585,7 @@ static void r8192_set_multicast(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); short promisc; - - - promisc = (dev->flags & IFF_PROMISC) ? 1:0; - - if (promisc != priv->promisc) { - ; - } - + promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->promisc = promisc; } @@ -2604,117 +2611,118 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct iwreq *wrq = (struct iwreq *)rq; - int ret=-1; + int ret = -1; struct rtllib_device *ieee = priv->rtllib; u32 key[4]; - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 zero_addr[6] = {0}; struct iw_point *p = &wrq->u.data; + struct ieee_param *ipw = NULL; down(&priv->wx_sem); switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - { - struct ieee_param *ipw = NULL; - if (p->length < sizeof(struct ieee_param) || !p->pointer){ - ret = -EINVAL; - goto out; - } + case RTL_IOCTL_WPA_SUPPLICANT: + if (p->length < sizeof(struct ieee_param) || !p->pointer) { + ret = -EINVAL; + goto out; + } - ipw = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); - if (ipw == NULL){ - ret = -ENOMEM; - goto out; - } - if (copy_from_user(ipw, p->pointer, p->length)) { - kfree(ipw); - ret = -EFAULT; - goto out; - } - - if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) - { - if (ipw->u.crypt.set_tx) - { - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->pairwise_key_type = KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->pairwise_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->pairwise_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->pairwise_key_type = KEY_TYPE_WEP40; - } - else - ieee->pairwise_key_type = KEY_TYPE_NA; - - if (ieee->pairwise_key_type) - { - if (memcmp(ieee->ap_mac_addr, zero_addr, 6) == 0) - ieee->iw_mode = IW_MODE_ADHOC; - - memcpy((u8*)key, ipw->u.crypt.key, 16); - EnableHWSecurityConfig8192(dev); - set_swcam(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); - setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - if (ieee->iw_mode == IW_MODE_ADHOC){ - set_swcam(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key,0); - setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key); - } - } - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ - write_nic_byte(dev, 0x173, 1); - } + ipw = kmalloc(p->length, GFP_KERNEL); + if (ipw == NULL) { + ret = -ENOMEM; + goto out; + } + if (copy_from_user(ipw, p->pointer, p->length)) { + kfree(ipw); + ret = -EFAULT; + goto out; + } + if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) { + if (ipw->u.crypt.set_tx) { + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->pairwise_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->pairwise_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->pairwise_key_type = + KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->pairwise_key_type = + KEY_TYPE_WEP40; + } else { + ieee->pairwise_key_type = KEY_TYPE_NA; } - else - { - memcpy((u8*)key, ipw->u.crypt.key, 16); - if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) - ieee->group_key_type= KEY_TYPE_CCMP; - else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) - ieee->group_key_type = KEY_TYPE_TKIP; - else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) - { - if (ipw->u.crypt.key_len == 13) - ieee->group_key_type = KEY_TYPE_WEP104; - else if (ipw->u.crypt.key_len == 5) - ieee->group_key_type = KEY_TYPE_WEP40; - } - else - ieee->group_key_type = KEY_TYPE_NA; - if (ieee->group_key_type) - { - set_swcam( dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, - ieee->group_key_type, - broadcast_addr, - 0, - key, - 0); - setKey( dev, - ipw->u.crypt.idx, - ipw->u.crypt.idx, - ieee->group_key_type, - broadcast_addr, - 0, - key); + if (ieee->pairwise_key_type) { + if (memcmp(ieee->ap_mac_addr, zero_addr, + 6) == 0) + ieee->iw_mode = IW_MODE_ADHOC; + memcpy((u8 *)key, ipw->u.crypt.key, 16); + EnableHWSecurityConfig8192(dev); + set_swcam(dev, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key, 0); + setKey(dev, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, 0, key); + if (ieee->iw_mode == IW_MODE_ADHOC) { + set_swcam(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key, 0); + setKey(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key); } } + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) + && ieee->pHTInfo->bCurrentHTSupport) { + write_nic_byte(dev, 0x173, 1); + } + + } else { + memcpy((u8 *)key, ipw->u.crypt.key, 16); + if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) + ieee->group_key_type = KEY_TYPE_CCMP; + else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0) + ieee->group_key_type = KEY_TYPE_TKIP; + else if (strcmp(ipw->u.crypt.alg, "WEP") == 0) { + if (ipw->u.crypt.key_len == 13) + ieee->group_key_type = + KEY_TYPE_WEP104; + else if (ipw->u.crypt.key_len == 5) + ieee->group_key_type = + KEY_TYPE_WEP40; + } else + ieee->group_key_type = KEY_TYPE_NA; + + if (ieee->group_key_type) { + set_swcam(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, 0, key, 0); + setKey(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->group_key_type, + broadcast_addr, 0, key); + } } - - ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, 0); - kfree(ipw); - break; } - default: - ret = -EOPNOTSUPP; - break; + + ret = rtllib_wpa_supplicant_ioctl(priv->rtllib, &wrq->u.data, + 0); + kfree(ipw); + break; + default: + ret = -EOPNOTSUPP; + break; } out: @@ -2727,40 +2735,48 @@ void FairBeacon(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_network *net = &priv->rtllib->current_network; - static u8 i=100; - static u8 forceturn =0; - u16 beaconint = net->beacon_interval; + static u8 i = 100; + static u8 forceturn; + u16 beaconint = net->beacon_interval; if (priv->rtllib->iw_mode != IW_MODE_ADHOC) return; - if (priv->bIbssCoordinator){ + if (priv->bIbssCoordinator) { i--; - if (forceturn ==2){ - forceturn =0; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - i=100; + if (forceturn == 2) { + forceturn = 0; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + i = 100; } - if (i<=94){ - beaconint=beaconint+2; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - forceturn =1; + if (i <= 94) { + beaconint = beaconint+2; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + forceturn = 1; } } else { i++; - if (forceturn ==1){ - forceturn =0; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - i=100; + if (forceturn == 1) { + forceturn = 0; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + i = 100; } - if (i>=106){ - beaconint=beaconint-2; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_BEACON_INTERVAL, (u8*)(&beaconint)); - forceturn =2; + if (i >= 106) { + beaconint = beaconint-2; + priv->rtllib->SetHwRegHandler(dev, + HW_VAR_BEACON_INTERVAL, + (u8 *)(&beaconint)); + forceturn = 2; } } } @@ -2775,71 +2791,67 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) u32 intb; intb = 0; - if (priv->irq_enabled == 0){ + if (priv->irq_enabled == 0) goto done; - } - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); priv->ops->interrupt_recognized(dev, &inta, &intb); priv->stats.shints++; if (!inta) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } if (inta == 0xffff) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } priv->stats.ints++; if (!netif_running(dev)) { - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } - if (inta & IMR_TBDOK){ + if (inta & IMR_TBDOK) { RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconokint++; } - if (inta & IMR_TBDER){ + if (inta & IMR_TBDER) { RT_TRACE(COMP_INTR, "beacon ok interrupt!\n"); priv->stats.txbeaconerr++; } - if (inta & IMR_BDOK) { + if (inta & IMR_BDOK) RT_TRACE(COMP_INTR, "beacon interrupt!\n"); - } - if (inta & IMR_MGNTDOK ) { + if (inta & IMR_MGNTDOK) { RT_TRACE(COMP_INTR, "Manage ok interrupt!\n"); priv->stats.txmanageokint++; - rtl8192_tx_isr(dev,MGNT_QUEUE); - spin_unlock_irqrestore(&priv->irq_th_lock,flags); - if (priv->rtllib->ack_tx_to_ieee){ - if (rtl8192_is_tx_queue_empty(dev)){ + rtl8192_tx_isr(dev, MGNT_QUEUE); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); + if (priv->rtllib->ack_tx_to_ieee) { + if (rtl8192_is_tx_queue_empty(dev)) { priv->rtllib->ack_tx_to_ieee = 0; rtllib_ps_tx_ack(priv->rtllib, 1); } } - spin_lock_irqsave(&priv->irq_th_lock,flags); + spin_lock_irqsave(&priv->irq_th_lock, flags); } if (inta & IMR_COMDOK) { priv->stats.txcmdpktokint++; - rtl8192_tx_isr(dev,TXCMD_QUEUE); + rtl8192_tx_isr(dev, TXCMD_QUEUE); } - if (inta & IMR_HIGHDOK) { - rtl8192_tx_isr(dev,HIGH_QUEUE); - } + if (inta & IMR_HIGHDOK) + rtl8192_tx_isr(dev, HIGH_QUEUE); - if (inta & IMR_ROK) - { + if (inta & IMR_ROK) { priv->stats.rxint++; priv->InterruptLog.nIMR_ROK++; tasklet_schedule(&priv->irq_rx_tasklet); @@ -2853,7 +2865,8 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) if (inta & IMR_RDU) { RT_TRACE(COMP_INTR, "rx descriptor unavailable!\n"); priv->stats.rxrdu++; - write_nic_dword(dev,INTA_MASK,read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); + write_nic_dword(dev, INTA_MASK, + read_nic_dword(dev, INTA_MASK) & ~IMR_RDU); tasklet_schedule(&priv->irq_rx_tasklet); } @@ -2863,37 +2876,38 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) tasklet_schedule(&priv->irq_rx_tasklet); } - if (inta & IMR_TXFOVW) priv->stats.txoverflow++; + if (inta & IMR_TXFOVW) + priv->stats.txoverflow++; if (inta & IMR_BKDOK) { RT_TRACE(COMP_INTR, "BK Tx OK interrupt!\n"); priv->stats.txbkokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,BK_QUEUE); + rtl8192_tx_isr(dev, BK_QUEUE); } if (inta & IMR_BEDOK) { RT_TRACE(COMP_INTR, "BE TX OK interrupt!\n"); priv->stats.txbeokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,BE_QUEUE); + rtl8192_tx_isr(dev, BE_QUEUE); } if (inta & IMR_VIDOK) { RT_TRACE(COMP_INTR, "VI TX OK interrupt!\n"); priv->stats.txviokint++; priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,VI_QUEUE); + rtl8192_tx_isr(dev, VI_QUEUE); } if (inta & IMR_VODOK) { priv->stats.txvookint++; RT_TRACE(COMP_INTR, "Vo TX OK interrupt!\n"); priv->rtllib->LinkDetectInfo.NumTxOkInPeriod++; - rtl8192_tx_isr(dev,VO_QUEUE); + rtl8192_tx_isr(dev, VO_QUEUE); } - spin_unlock_irqrestore(&priv->irq_th_lock,flags); + spin_unlock_irqrestore(&priv->irq_th_lock, flags); done: @@ -2903,7 +2917,7 @@ done: /**************************************************************************** - ---------------------------- PCI_STUFF--------------------------- + ---------------------------- PCI_STUFF--------------------------- *****************************************************************************/ #ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops rtl8192_netdev_ops = { @@ -2920,73 +2934,71 @@ static const struct net_device_ops rtl8192_netdev_ops = { #endif static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id) + const struct pci_device_id *id) { unsigned long ioaddr = 0; struct net_device *dev = NULL; - struct r8192_priv *priv= NULL; + struct r8192_priv *priv = NULL; struct rtl819x_ops *ops = (struct rtl819x_ops *)(id->driver_data); unsigned long pmem_start, pmem_len, pmem_flags; int err = 0; bool bdma64 = false; u8 revision_id; - RT_TRACE(COMP_INIT,"Configuring chip resources"); + RT_TRACE(COMP_INIT, "Configuring chip resources"); - if ( pci_enable_device (pdev) ){ - RT_TRACE(COMP_ERR,"Failed to enable PCI device"); + if (pci_enable_device(pdev)) { + RT_TRACE(COMP_ERR, "Failed to enable PCI device"); return -EIO; } pci_set_master(pdev); - { - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { - printk( "Unable to obtain 32bit DMA for consistent allocations\n"); - pci_disable_device(pdev); - return -ENOMEM; - } + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { + printk(KERN_INFO "Unable to obtain 32bit DMA for consistent allocations\n"); + pci_disable_device(pdev); + return -ENOMEM; } } dev = alloc_rtllib(sizeof(struct r8192_priv)); if (!dev) return -ENOMEM; - if (bdma64){ + if (bdma64) dev->features |= NETIF_F_HIGHDMA; - } pci_set_drvdata(pdev, dev); SET_NETDEV_DEV(dev, &pdev->dev); priv = rtllib_priv(dev); priv->rtllib = (struct rtllib_device *)netdev_priv_rsl(dev); - priv->pdev=pdev; - priv->rtllib->pdev=pdev; - if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK)&&(pdev->subsystem_device == 0x3304)) + priv->pdev = pdev; + priv->rtllib->pdev = pdev; + if ((pdev->subsystem_vendor == PCI_VENDOR_ID_DLINK) && + (pdev->subsystem_device == 0x3304)) priv->rtllib->bSupportRemoteWakeUp = 1; else priv->rtllib->bSupportRemoteWakeUp = 0; pmem_start = pci_resource_start(pdev, 1); pmem_len = pci_resource_len(pdev, 1); - pmem_flags = pci_resource_flags (pdev, 1); + pmem_flags = pci_resource_flags(pdev, 1); if (!(pmem_flags & IORESOURCE_MEM)) { - RT_TRACE(COMP_ERR,"region #1 not a MMIO resource, aborting"); + RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting"); goto fail; } - printk("Memory mapped space start: 0x%08lx \n", pmem_start); + printk(KERN_INFO "Memory mapped space start: 0x%08lx\n", pmem_start); if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) { - RT_TRACE(COMP_ERR,"request_mem_region failed!"); + RT_TRACE(COMP_ERR, "request_mem_region failed!"); goto fail; } - ioaddr = (unsigned long)ioremap_nocache( pmem_start, pmem_len); - if ( ioaddr == (unsigned long)NULL ){ - RT_TRACE(COMP_ERR,"ioremap failed!"); + ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len); + if (ioaddr == (unsigned long)NULL) { + RT_TRACE(COMP_ERR, "ioremap failed!"); goto fail1; } @@ -3018,19 +3030,21 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, dev->hard_start_xmit = rtllib_xmit; #endif - dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; + dev->wireless_handlers = (struct iw_handler_def *) + &r8192_wx_handlers_def; dev->ethtool_ops = &rtl819x_ethtool_ops; dev->type = ARPHRD_ETHER; - dev->watchdog_timeo = HZ*3; + dev->watchdog_timeo = HZ * 3; - if (dev_alloc_name(dev, ifname) < 0){ - RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); - dev_alloc_name(dev, ifname); - } + if (dev_alloc_name(dev, ifname) < 0) { + RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying " + "wlan%%d...\n"); + dev_alloc_name(dev, ifname); + } RT_TRACE(COMP_INIT, "Driver probe completed1\n"); - if (rtl8192_init(dev)!=0){ + if (rtl8192_init(dev) != 0) { RT_TRACE(COMP_ERR, "Initialization failed"); goto fail1; } @@ -3039,33 +3053,31 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev, netif_stop_queue(dev); register_netdev(dev); - RT_TRACE(COMP_INIT, "dev name: %s\n",dev->name); + RT_TRACE(COMP_INIT, "dev name: %s\n", dev->name); err = rtl_debug_module_init(priv, dev->name); - if (err) { - RT_TRACE(COMP_DBG, "failed to create debugfs files. Ignoring error: %d\n", err); - } + if (err) + RT_TRACE(COMP_DBG, "failed to create debugfs files. Ignoring " + "error: %d\n", err); rtl8192_proc_init_one(dev); - if (priv->polling_timer_on == 0){ + if (priv->polling_timer_on == 0) check_rfctrl_gpio_timer((unsigned long)dev); - } RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; fail1: - if ( dev->mem_start != (unsigned long)NULL ){ - iounmap( (void *)dev->mem_start ); - release_mem_region( pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1) ); + if (dev->mem_start != (unsigned long)NULL) { + iounmap((void *)dev->mem_start); + release_mem_region(pci_resource_start(pdev, 1), + pci_resource_len(pdev, 1)); } fail: - if (dev){ - + if (dev) { if (priv->irq) { free_irq(dev->irq, dev); - dev->irq=0; + dev->irq = 0; } free_rtllib(dev); } @@ -3082,7 +3094,9 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv ; - if (dev){ + u32 i; + + if (dev) { unregister_netdev(dev); priv = rtllib_priv(dev); @@ -3092,63 +3106,59 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) priv->polling_timer_on = 0; rtl_debug_module_remove(priv); rtl8192_proc_remove_one(dev); - rtl8192_down(dev,true); + rtl8192_down(dev, true); deinit_hal_dm(dev); if (priv->pFirmware) { vfree(priv->pFirmware); priv->pFirmware = NULL; } destroy_workqueue(priv->priv_wq); - { - u32 i; - rtl8192_free_rx_ring(dev); - for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - rtl8192_free_tx_ring(dev, i); - } - } + rtl8192_free_rx_ring(dev); + for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) + rtl8192_free_tx_ring(dev, i); - if (priv->irq){ - - printk("Freeing irq %d\n",dev->irq); + if (priv->irq) { + printk(KERN_INFO "Freeing irq %d\n", dev->irq); free_irq(dev->irq, dev); - priv->irq=0; - + priv->irq = 0; } free_rtllib(dev); - if (priv->scan_cmd) - kfree(priv->scan_cmd); + kfree(priv->scan_cmd); if (dev->mem_start != 0) { iounmap((void *)dev->mem_start); release_mem_region(pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1)); + pci_resource_len(pdev, 1)); } - } else{ - priv=rtllib_priv(dev); - } + } else { + priv = rtllib_priv(dev); + } pci_disable_device(pdev); RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } -bool NicIFEnableNIC(struct net_device* dev) +bool NicIFEnableNIC(struct net_device *dev) { bool init_status = true; - struct r8192_priv * priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct r8192_priv *priv = rtllib_priv(dev); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); - if (IS_NIC_DOWN(priv)){ - RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",__func__); + if (IS_NIC_DOWN(priv)) { + RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n", + __func__); priv->bdisable_nic = false; return RT_STATUS_FAILURE; } - RT_TRACE(COMP_PS, "===========>%s()\n",__func__); + RT_TRACE(COMP_PS, "===========>%s()\n", __func__); priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (init_status != true) { - RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n",__func__); + RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", + __func__); priv->bdisable_nic = false; return -1; } @@ -3158,15 +3168,15 @@ bool NicIFEnableNIC(struct net_device* dev) rtl8192_irq_enable(dev); priv->bdisable_nic = false; - RT_TRACE(COMP_PS,"<===========%s()\n",__func__); + RT_TRACE(COMP_PS, "<===========%s()\n", __func__); return init_status; } -bool NicIFDisableNIC(struct net_device* dev) +bool NicIFDisableNIC(struct net_device *dev) { bool status = true; - struct r8192_priv * priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); u8 tmp_state = 0; - RT_TRACE(COMP_PS, "=========>%s()\n",__func__); + RT_TRACE(COMP_PS, "=========>%s()\n", __func__); priv->bdisable_nic = true; tmp_state = priv->rtllib->state; rtllib_softmac_stop_protocol(priv->rtllib, 0, false); @@ -3175,7 +3185,7 @@ bool NicIFDisableNIC(struct net_device* dev) rtl8192_irq_disable(dev); priv->ops->stop_adapter(dev, false); - RT_TRACE(COMP_PS, "<=========%s()\n",__func__); + RT_TRACE(COMP_PS, "<=========%s()\n", __func__); return status; } @@ -3220,14 +3230,14 @@ static int __init rtl8192_pci_module_init(void) } rtl8192_proc_module_init(); - if (0!=pci_register_driver(&rtl8192_pci_driver)) { + if (0 != pci_register_driver(&rtl8192_pci_driver)) { DMESG("No device found"); /*pci_unregister_driver (&rtl8192_pci_driver);*/ return -ENODEV; } return 0; err_out: - return error; + return error; } @@ -3247,17 +3257,18 @@ static void __exit rtl8192_pci_module_exit(void) void check_rfctrl_gpio_timer(unsigned long data) { - struct r8192_priv * priv = rtllib_priv((struct net_device *)data); + struct r8192_priv *priv = rtllib_priv((struct net_device *)data); priv->polling_timer_on = 1; - queue_delayed_work_rsl(priv->priv_wq,&priv->gpio_change_rf_wq,0); + queue_delayed_work_rsl(priv->priv_wq, &priv->gpio_change_rf_wq, 0); - mod_timer(&priv->gpio_polling_timer, jiffies + MSECS(RTLLIB_WATCH_DOG_TIME)); + mod_timer(&priv->gpio_polling_timer, jiffies + + MSECS(RTLLIB_WATCH_DOG_TIME)); } /*************************************************************************** - ------------------- module init / exit stubs ---------------- + ------------------- module init / exit stubs ---------------- ****************************************************************************/ module_init(rtl8192_pci_module_init); module_exit(rtl8192_pci_module_exit); @@ -3267,10 +3278,10 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_VERSION(DRV_VERSION); MODULE_LICENSE("GPL"); -module_param(ifname, charp, S_IRUGO|S_IWUSR ); -module_param(hwwep,int, S_IRUGO|S_IWUSR); -module_param(channels,int, S_IRUGO|S_IWUSR); +module_param(ifname, charp, S_IRUGO|S_IWUSR); +module_param(hwwep, int, S_IRUGO|S_IWUSR); +module_param(channels, int, S_IRUGO|S_IWUSR); -MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default"); -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support(default use hw. set 0 to use software security)"); -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); +MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default"); +MODULE_PARM_DESC(hwwep, " Try to use hardware WEP support(default use hw. set 0 to use software security)"); +MODULE_PARM_DESC(channels, " Channel bitmask for specific locales. NYI"); diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 4f94d0a18f06..03a86fe283c0 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "rtllib.h" #include "dot11d.h" @@ -62,28 +62,35 @@ #include "rtl_pci.h" #include "rtl_cam.h" -#define DRV_COPYRIGHT "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation" +#define DRV_COPYRIGHT \ + "Copyright(c) 2008 - 2010 Realsil Semiconductor Corporation" #define DRV_AUTHOR "" #define DRV_VERSION "0014.0401.2010" #define DRV_NAME "rtl819xE" -#define IS_HARDWARE_TYPE_819xP(_priv) ((((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8190P)||\ - (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192E)) -#define IS_HARDWARE_TYPE_8192SE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192SE) -#define IS_HARDWARE_TYPE_8192CE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CE) -#define IS_HARDWARE_TYPE_8192CU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192CU) -#define IS_HARDWARE_TYPE_8192DE(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DE) -#define IS_HARDWARE_TYPE_8192DU(_priv) (((struct r8192_priv *)rtllib_priv(dev))->card_8192==NIC_8192DU) +#define IS_HARDWARE_TYPE_819xP(_priv) \ + ((((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8190P) || \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192E)) +#define IS_HARDWARE_TYPE_8192SE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE) +#define IS_HARDWARE_TYPE_8192CE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CE) +#define IS_HARDWARE_TYPE_8192CU(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192CU) +#define IS_HARDWARE_TYPE_8192DE(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DE) +#define IS_HARDWARE_TYPE_8192DU(_priv) \ + (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192DU) #define RTL_PCI_DEVICE(vend, dev, cfg) \ .vendor = (vend), .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice =PCI_ANY_ID , \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \ .driver_data = (kernel_ulong_t)&(cfg) #define irqreturn_type irqreturn_t -#define rtl8192_interrupt(x,y,z) rtl8192_interrupt_rsl(x,y) +#define rtl8192_interrupt(x, y, z) rtl8192_interrupt_rsl(x, y) #define RTL_MAX_SCAN_SIZE 128 @@ -100,8 +107,9 @@ #define IS_ADAPTER_SENDS_BEACON(dev) 0 -#define IS_UNDER_11N_AES_MODE(_rtllib) ((_rtllib->pHTInfo->bCurrentHTSupport == true) &&\ - (_rtllib->pairwise_key_type == KEY_TYPE_CCMP)) +#define IS_UNDER_11N_AES_MODE(_rtllib) \ + ((_rtllib->pHTInfo->bCurrentHTSupport == true) && \ + (_rtllib->pairwise_key_type == KEY_TYPE_CCMP)) #define HAL_MEMORY_MAPPED_IO_RANGE_8190PCI 0x1000 #define HAL_HW_PCI_REVISION_ID_8190PCI 0x00 @@ -120,36 +128,38 @@ #define HAL_HW_PCI_8198_DEVICE_ID 0x8198 #define HAL_HW_PCI_8190_DEVICE_ID 0x8190 #define HAL_HW_PCI_8192_DEVICE_ID 0x8192 -#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 +#define HAL_HW_PCI_8192SE_DEVICE_ID 0x8192 #define HAL_HW_PCI_8174_DEVICE_ID 0x8174 #define HAL_HW_PCI_8173_DEVICE_ID 0x8173 #define HAL_HW_PCI_8172_DEVICE_ID 0x8172 #define HAL_HW_PCI_8171_DEVICE_ID 0x8171 -#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 -#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 -#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 -#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 -#define HAL_HW_PCI_700F_DEVICE_ID 0x700F -#define HAL_HW_PCI_701F_DEVICE_ID 0x701F -#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 +#define HAL_HW_PCI_0045_DEVICE_ID 0x0045 +#define HAL_HW_PCI_0046_DEVICE_ID 0x0046 +#define HAL_HW_PCI_0044_DEVICE_ID 0x0044 +#define HAL_HW_PCI_0047_DEVICE_ID 0x0047 +#define HAL_HW_PCI_700F_DEVICE_ID 0x700F +#define HAL_HW_PCI_701F_DEVICE_ID 0x701F +#define HAL_HW_PCI_DLINK_DEVICE_ID 0x3304 #define HAL_HW_PCI_8192CET_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 -#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 -#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 -#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 -#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D -#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D +#define HAL_HW_PCI_8192CE_DEVICE_ID 0x8178 +#define HAL_HW_PCI_8191CE_DEVICE_ID 0x8177 +#define HAL_HW_PCI_8188CE_DEVICE_ID 0x8176 +#define HAL_HW_PCI_8192CU_DEVICE_ID 0x8191 +#define HAL_HW_PCI_8192DE_DEVICE_ID 0x092D +#define HAL_HW_PCI_8192DU_DEVICE_ID 0x092D #define RTL819X_DEFAULT_RF_TYPE RF_1T2R #define RTLLIB_WATCH_DOG_TIME 2000 -#define MAX_DEV_ADDR_SIZE 8 /* support till 64 bit bus width OS */ +#define MAX_DEV_ADDR_SIZE 8 /*support till 64 bit bus width OS*/ #define MAX_FIRMWARE_INFORMATION_SIZE 32 #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE) #define ENCRYPTION_MAX_OVERHEAD 128 #define MAX_FRAGMENT_COUNT 8 -#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT) +#define MAX_TRANSMIT_BUFFER_SIZE \ + (1600 + (MAX_802_11_HEADER_LENGTH + ENCRYPTION_MAX_OVERHEAD) * \ + MAX_FRAGMENT_COUNT) #define scrclng 4 @@ -164,13 +174,13 @@ #define PHY_RSSI_SLID_WIN_MAX 100 -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) -#define TxBBGainTableLength 37 -#define CCKTxBBGainTableLength 23 +#define TxBBGainTableLength 37 +#define CCKTxBBGainTableLength 23 #define CHANNEL_PLAN_LEN 10 -#define sCrcLng 4 +#define sCrcLng 4 #define NIC_SEND_HANG_THRESHOLD_NORMAL 4 #define NIC_SEND_HANG_THRESHOLD_POWERSAVE 8 @@ -179,30 +189,30 @@ #define MAX_RX_QUEUE 1 -#define MAX_RX_COUNT 64 -#define MAX_TX_QUEUE_COUNT 9 +#define MAX_RX_COUNT 64 +#define MAX_TX_QUEUE_COUNT 9 enum RTL819x_PHY_PARAM { - RTL819X_PHY_MACPHY_REG = 0, - RTL819X_PHY_MACPHY_REG_PG = 1, - RTL8188C_PHY_MACREG =2, - RTL8192C_PHY_MACREG =3, + RTL819X_PHY_MACPHY_REG = 0, + RTL819X_PHY_MACPHY_REG_PG = 1, + RTL8188C_PHY_MACREG = 2, + RTL8192C_PHY_MACREG = 3, RTL819X_PHY_REG = 4, RTL819X_PHY_REG_1T2R = 5, - RTL819X_PHY_REG_to1T1R = 6, - RTL819X_PHY_REG_to1T2R = 7, - RTL819X_PHY_REG_to2T2R = 8, + RTL819X_PHY_REG_to1T1R = 6, + RTL819X_PHY_REG_to1T2R = 7, + RTL819X_PHY_REG_to2T2R = 8, RTL819X_PHY_REG_PG = 9, RTL819X_AGC_TAB = 10, - RTL819X_PHY_RADIO_A =11, - RTL819X_PHY_RADIO_A_1T =12, - RTL819X_PHY_RADIO_A_2T =13, - RTL819X_PHY_RADIO_B =14, - RTL819X_PHY_RADIO_B_GM =15, - RTL819X_PHY_RADIO_C =16, - RTL819X_PHY_RADIO_D =17, - RTL819X_EEPROM_MAP =18, - RTL819X_EFUSE_MAP =19, + RTL819X_PHY_RADIO_A = 11, + RTL819X_PHY_RADIO_A_1T = 12, + RTL819X_PHY_RADIO_A_2T = 13, + RTL819X_PHY_RADIO_B = 14, + RTL819X_PHY_RADIO_B_GM = 15, + RTL819X_PHY_RADIO_C = 16, + RTL819X_PHY_RADIO_D = 17, + RTL819X_EEPROM_MAP = 18, + RTL819X_EFUSE_MAP = 19, }; enum RTL_DEBUG { @@ -212,27 +222,27 @@ enum RTL_DEBUG { COMP_RECV = BIT3, COMP_SEND = BIT4, COMP_CMD = BIT5, - COMP_POWER = BIT6, - COMP_EPROM = BIT7, + COMP_POWER = BIT6, + COMP_EPROM = BIT7, COMP_SWBW = BIT8, COMP_SEC = BIT9, COMP_LPS = BIT10, COMP_QOS = BIT11, COMP_RATE = BIT12, - COMP_RXDESC = BIT13, + COMP_RXDESC = BIT13, COMP_PHY = BIT14, COMP_DIG = BIT15, COMP_TXAGC = BIT16, - COMP_HALDM = BIT17, + COMP_HALDM = BIT17, COMP_POWER_TRACKING = BIT18, - COMP_CH = BIT19, - COMP_RF = BIT20, - COMP_FIRMWARE = BIT21, - COMP_HT = BIT22, + COMP_CH = BIT19, + COMP_RF = BIT20, + COMP_FIRMWARE = BIT21, + COMP_HT = BIT22, COMP_RESET = BIT23, - COMP_CMDPKT = BIT24, + COMP_CMDPKT = BIT24, COMP_SCAN = BIT25, - COMP_PS = BIT26, + COMP_PS = BIT26, COMP_DOWN = BIT27, COMP_INTR = BIT28, COMP_LED = BIT29, @@ -245,11 +255,11 @@ enum nic_t { NIC_8192E = 1, NIC_8190P = 2, NIC_8192SE = 4, - NIC_8192CE = 5, - NIC_8192CU = 6, - NIC_8192DE = 7, - NIC_8192DU = 8, - }; + NIC_8192CE = 5, + NIC_8192CU = 6, + NIC_8192DE = 7, + NIC_8192DU = 8, +}; enum rt_eeprom_type { EEPROM_93C46, @@ -258,7 +268,7 @@ enum rt_eeprom_type { }; enum dcmg_txcmd_op { - TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, + TXCMD_TXRA_HISTORY_CTRL = 0xFF900000, TXCMD_RESET_TX_PKT_BUFF = 0xFF900001, TXCMD_RESET_RX_PKT_BUFF = 0xFF900002, TXCMD_SET_TX_DURATION = 0xFF900003, @@ -268,18 +278,18 @@ enum dcmg_txcmd_op { }; enum rt_rf_type_819xu { - RF_TYPE_MIN = 0, - RF_8225, - RF_8256, - RF_8258, - RF_6052=4, - RF_PSEUDO_11N = 5, + RF_TYPE_MIN = 0, + RF_8225, + RF_8256, + RF_8258, + RF_6052 = 4, + RF_PSEUDO_11N = 5, }; enum rf_step { - RF_STEP_INIT = 0, - RF_STEP_NORMAL, - RF_STEP_MAX + RF_STEP_INIT = 0, + RF_STEP_NORMAL, + RF_STEP_MAX }; enum rt_status { @@ -290,32 +300,32 @@ enum rt_status { }; enum rt_customer_id { - RT_CID_DEFAULT = 0, + RT_CID_DEFAULT = 0, RT_CID_8187_ALPHA0 = 1, RT_CID_8187_SERCOMM_PS = 2, RT_CID_8187_HW_LED = 3, RT_CID_8187_NETGEAR = 4, - RT_CID_WHQL = 5, + RT_CID_WHQL = 5, RT_CID_819x_CAMEO = 6, RT_CID_819x_RUNTOP = 7, RT_CID_819x_Senao = 8, - RT_CID_TOSHIBA = 9, + RT_CID_TOSHIBA = 9, RT_CID_819x_Netcore = 10, - RT_CID_Nettronix = 11, - RT_CID_DLINK = 12, - RT_CID_PRONET = 13, - RT_CID_COREGA = 14, + RT_CID_Nettronix = 11, + RT_CID_DLINK = 12, + RT_CID_PRONET = 13, + RT_CID_COREGA = 14, RT_CID_819x_ALPHA = 15, RT_CID_819x_Sitecom = 16, - RT_CID_CCX = 17, + RT_CID_CCX = 17, RT_CID_819x_Lenovo = 18, - RT_CID_819x_QMI = 19, + RT_CID_819x_QMI = 19, RT_CID_819x_Edimax_Belkin = 20, RT_CID_819x_Sercomm_Belkin = 21, RT_CID_819x_CAMEO1 = 22, RT_CID_819x_MSI = 23, RT_CID_819x_Acer = 24, - RT_CID_819x_HP =27, + RT_CID_819x_HP = 27, RT_CID_819x_CLEVO = 28, RT_CID_819x_Arcadyan_Belkin = 29, RT_CID_819x_SAMSUNG = 30, @@ -329,8 +339,8 @@ enum reset_type { }; enum ic_inferiority_8192s { - IC_INFERIORITY_A = 0, - IC_INFERIORITY_B = 1, + IC_INFERIORITY_A = 0, + IC_INFERIORITY_B = 1, }; enum pci_bridge_vendor { @@ -350,20 +360,20 @@ struct buffer { }; struct rtl_reg_debug { - unsigned int cmd; - struct { - unsigned char type; - unsigned char addr; - unsigned char page; - unsigned char length; - } head; - unsigned char buf[0xff]; + unsigned int cmd; + struct { + unsigned char type; + unsigned char addr; + unsigned char page; + unsigned char length; + } head; + unsigned char buf[0xff]; }; struct rt_tx_rahis { - u32 cck[4]; - u32 ofdm[8]; - u32 ht_mcs[4][16]; + u32 cck[4]; + u32 ofdm[8]; + u32 ht_mcs[4][16]; }; struct rt_smooth_data_4rf { @@ -449,7 +459,7 @@ struct rt_stats { unsigned long txerrunicast; unsigned long txretrycount; unsigned long txfeedbackretry; - u8 last_packet_rate; + u8 last_packet_rate; unsigned long slide_signal_strength[100]; unsigned long slide_evm[100]; unsigned long slide_rssi_total; @@ -496,51 +506,63 @@ struct ccktxbbgain { }; struct init_gain { - u8 xaagccore1; - u8 xbagccore1; - u8 xcagccore1; - u8 xdagccore1; - u8 cca; + u8 xaagccore1; + u8 xbagccore1; + u8 xcagccore1; + u8 xdagccore1; + u8 cca; }; struct tx_ring { - u32 * desc; + u32 *desc; u8 nStuckCount; - struct tx_ring * next; + struct tx_ring *next; } __packed; struct rtl8192_tx_ring { - struct tx_desc *desc; - dma_addr_t dma; - unsigned int idx; - unsigned int entries; - struct sk_buff_head queue; + struct tx_desc *desc; + dma_addr_t dma; + unsigned int idx; + unsigned int entries; + struct sk_buff_head queue; }; -struct rtl819x_ops{ +struct rtl819x_ops { enum nic_t nic_type; - void (* get_eeprom_size)(struct net_device* dev); - void (* init_adapter_variable)(struct net_device* dev); - void (* init_before_adapter_start)(struct net_device* dev); - bool (* initialize_adapter)(struct net_device* dev); - void (*link_change)(struct net_device* dev); - void (* tx_fill_descriptor)(struct net_device* dev, struct tx_desc *tx_desc, struct cb_desc *cb_desc, struct sk_buff *skb); - void (* tx_fill_cmd_descriptor)(struct net_device* dev, struct tx_desc_cmd * entry, struct cb_desc *cb_desc, struct sk_buff *skb); - bool (* rx_query_status_descriptor)(struct net_device* dev, struct rtllib_rx_stats* stats, struct rx_desc *pdesc, struct sk_buff* skb); - bool (* rx_command_packet_handler)(struct net_device *dev, struct sk_buff* skb, struct rx_desc *pdesc); - void (* stop_adapter)(struct net_device *dev, bool reset); - void (* update_ratr_table)(struct net_device* dev); - void (* irq_enable)(struct net_device* dev); - void (* irq_disable)(struct net_device* dev); - void (* irq_clear)(struct net_device* dev); - void (* rx_enable)(struct net_device* dev); - void (* tx_enable)(struct net_device* dev); - void (* interrupt_recognized)(struct net_device *dev, u32 *p_inta, u32 *p_intb); - bool (* TxCheckStuckHandler)(struct net_device* dev); - bool (* RxCheckStuckHandler)(struct net_device* dev); + void (*get_eeprom_size)(struct net_device *dev); + void (*init_adapter_variable)(struct net_device *dev); + void (*init_before_adapter_start)(struct net_device *dev); + bool (*initialize_adapter)(struct net_device *dev); + void (*link_change)(struct net_device *dev); + void (*tx_fill_descriptor)(struct net_device *dev, + struct tx_desc *tx_desc, + struct cb_desc *cb_desc, + struct sk_buff *skb); + void (*tx_fill_cmd_descriptor)(struct net_device *dev, + struct tx_desc_cmd *entry, + struct cb_desc *cb_desc, + struct sk_buff *skb); + bool (*rx_query_status_descriptor)(struct net_device *dev, + struct rtllib_rx_stats *stats, + struct rx_desc *pdesc, + struct sk_buff *skb); + bool (*rx_command_packet_handler)(struct net_device *dev, + struct sk_buff *skb, + struct rx_desc *pdesc); + void (*stop_adapter)(struct net_device *dev, bool reset); + void (*update_ratr_table)(struct net_device *dev); + void (*irq_enable)(struct net_device *dev); + void (*irq_disable)(struct net_device *dev); + void (*irq_clear)(struct net_device *dev); + void (*rx_enable)(struct net_device *dev); + void (*tx_enable)(struct net_device *dev); + void (*interrupt_recognized)(struct net_device *dev, + u32 *p_inta, u32 *p_intb); + bool (*TxCheckStuckHandler)(struct net_device *dev); + bool (*RxCheckStuckHandler)(struct net_device *dev); }; struct r8192_priv { @@ -630,8 +652,8 @@ struct r8192_priv { struct iw_statistics wstats; struct proc_dir_entry *dir_dev; - short (*rf_set_sens)(struct net_device *dev,short sens); - u8 (*rf_set_chan)(struct net_device *dev,u8 ch); + short (*rf_set_sens)(struct net_device *dev, short sens); + u8 (*rf_set_chan)(struct net_device *dev, u8 ch); void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); @@ -672,227 +694,229 @@ struct r8192_priv { /**********************************************************/ - enum card_type {PCI,MINIPCI,CARDBUS,USB}card_type; + enum card_type { + PCI, MINIPCI, + CARDBUS, USB + } card_type; struct work_struct qos_activate; - u8 bIbssCoordinator; + u8 bIbssCoordinator; short promisc; short crcmon; - int txbeaconcount; + int txbeaconcount; short chan; short sens; short max_sens; - u32 rx_prevlen; + u32 rx_prevlen; - u8 ScanDelay; - bool ps_force; + u8 ScanDelay; + bool ps_force; - u32 irq_mask[2]; + u32 irq_mask[2]; - u8 Rf_Mode; + u8 Rf_Mode; enum nic_t card_8192; - u8 card_8192_version; + u8 card_8192_version; short enable_gpio0; - u8 rf_type; - u8 IC_Cut; - char nick[IW_ESSID_MAX_SIZE + 1]; + u8 rf_type; + u8 IC_Cut; + char nick[IW_ESSID_MAX_SIZE + 1]; - u8 RegBcnCtrlVal; - bool bHwAntDiv; + u8 RegBcnCtrlVal; + bool bHwAntDiv; - bool bTKIPinNmodeFromReg; - bool bWEPinNmodeFromReg; + bool bTKIPinNmodeFromReg; + bool bWEPinNmodeFromReg; - bool bLedOpenDrain; + bool bLedOpenDrain; - u8 check_roaming_cnt; + u8 check_roaming_cnt; - bool bIgnoreSilentReset; - u32 SilentResetRxSoltNum; - u32 SilentResetRxSlotIndex; - u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; + bool bIgnoreSilentReset; + u32 SilentResetRxSoltNum; + u32 SilentResetRxSlotIndex; + u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; - void *scan_cmd; - u8 hwscan_bw_40; + void *scan_cmd; + u8 hwscan_bw_40; - u16 nrxAMPDU_size; - u8 nrxAMPDU_aggr_num; + u16 nrxAMPDU_size; + u8 nrxAMPDU_aggr_num; - u32 last_rxdesc_tsf_high; - u32 last_rxdesc_tsf_low; + u32 last_rxdesc_tsf_high; + u32 last_rxdesc_tsf_low; + u16 basic_rate; + u8 short_preamble; + u8 dot11CurrentPreambleMode; + u8 slot_time; + u16 SifsTime; - u16 basic_rate; - u8 short_preamble; - u8 dot11CurrentPreambleMode; - u8 slot_time; - u16 SifsTime; + u8 RegWirelessMode; - u8 RegWirelessMode; + u8 firmware_version; + u16 FirmwareSubVersion; + u16 rf_pathmap; + bool AutoloadFailFlag; - u8 firmware_version; - u16 FirmwareSubVersion; - u16 rf_pathmap; - bool AutoloadFailFlag; + u8 RegPciASPM; + u8 RegAMDPciASPM; + u8 RegHwSwRfOffD3; + u8 RegSupportPciASPM; + bool bSupportASPM; - u8 RegPciASPM; - u8 RegAMDPciASPM; - u8 RegHwSwRfOffD3; - u8 RegSupportPciASPM; - bool bSupportASPM; + u32 RfRegChnlVal[2]; - u32 RfRegChnlVal[2]; + u8 ShowRateMode; + u8 RATRTableBitmap; - u8 ShowRateMode; - u8 RATRTableBitmap; - - u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; - u16 EfuseUsedBytes; - u8 EfuseUsedPercentage; + u8 EfuseMap[2][HWSET_MAX_SIZE_92S]; + u16 EfuseUsedBytes; + u8 EfuseUsedPercentage; short epromtype; - u16 eeprom_vid; - u16 eeprom_did; - u16 eeprom_svid; - u16 eeprom_smid; - u8 eeprom_CustomerID; - u16 eeprom_ChannelPlan; - u8 eeprom_version; + u16 eeprom_vid; + u16 eeprom_did; + u16 eeprom_svid; + u16 eeprom_smid; + u8 eeprom_CustomerID; + u16 eeprom_ChannelPlan; + u8 eeprom_version; - u8 EEPROMRegulatory; - u8 EEPROMPwrGroup[2][3]; - u8 EEPROMOptional; + u8 EEPROMRegulatory; + u8 EEPROMPwrGroup[2][3]; + u8 EEPROMOptional; - u8 EEPROMTxPowerLevelCCK[14]; - u8 EEPROMTxPowerLevelOFDM24G[14]; - u8 EEPROMTxPowerLevelOFDM5G[24]; - u8 EEPROMRfACCKChnl1TxPwLevel[3]; - u8 EEPROMRfAOfdmChnlTxPwLevel[3]; - u8 EEPROMRfCCCKChnl1TxPwLevel[3]; - u8 EEPROMRfCOfdmChnlTxPwLevel[3]; - u16 EEPROMTxPowerDiff; - u16 EEPROMAntPwDiff; - u8 EEPROMThermalMeter; - u8 EEPROMPwDiff; - u8 EEPROMCrystalCap; + u8 EEPROMTxPowerLevelCCK[14]; + u8 EEPROMTxPowerLevelOFDM24G[14]; + u8 EEPROMTxPowerLevelOFDM5G[24]; + u8 EEPROMRfACCKChnl1TxPwLevel[3]; + u8 EEPROMRfAOfdmChnlTxPwLevel[3]; + u8 EEPROMRfCCCKChnl1TxPwLevel[3]; + u8 EEPROMRfCOfdmChnlTxPwLevel[3]; + u16 EEPROMTxPowerDiff; + u16 EEPROMAntPwDiff; + u8 EEPROMThermalMeter; + u8 EEPROMPwDiff; + u8 EEPROMCrystalCap; - u8 EEPROMBluetoothCoexist; - u8 EEPROMBluetoothType; - u8 EEPROMBluetoothAntNum; - u8 EEPROMBluetoothAntIsolation; - u8 EEPROMBluetoothRadioShared; + u8 EEPROMBluetoothCoexist; + u8 EEPROMBluetoothType; + u8 EEPROMBluetoothAntNum; + u8 EEPROMBluetoothAntIsolation; + u8 EEPROMBluetoothRadioShared; - u8 EEPROMSupportWoWLAN; - u8 EEPROMBoardType; - u8 EEPROM_Def_Ver; - u8 EEPROMHT2T_TxPwr[6]; - u8 EEPROMTSSI_A; - u8 EEPROMTSSI_B; - u8 EEPROMTxPowerLevelCCK_V1[3]; - u8 EEPROMLegacyHTTxPowerDiff; + u8 EEPROMSupportWoWLAN; + u8 EEPROMBoardType; + u8 EEPROM_Def_Ver; + u8 EEPROMHT2T_TxPwr[6]; + u8 EEPROMTSSI_A; + u8 EEPROMTSSI_B; + u8 EEPROMTxPowerLevelCCK_V1[3]; + u8 EEPROMLegacyHTTxPowerDiff; - u8 BluetoothCoexist; + u8 BluetoothCoexist; - u8 CrystalCap; - u8 ThermalMeter[2]; + u8 CrystalCap; + u8 ThermalMeter[2]; - u16 FwCmdIOMap; - u32 FwCmdIOParam; + u16 FwCmdIOMap; + u32 FwCmdIOParam; - u8 SwChnlInProgress; - u8 SwChnlStage; - u8 SwChnlStep; - u8 SetBWModeInProgress; + u8 SwChnlInProgress; + u8 SwChnlStage; + u8 SwChnlStep; + u8 SetBWModeInProgress; - u8 nCur40MhzPrimeSC; + u8 nCur40MhzPrimeSC; - u32 RfReg0Value[4]; - u8 NumTotalRFPath; - bool brfpath_rxenable[4]; + u32 RfReg0Value[4]; + u8 NumTotalRFPath; + bool brfpath_rxenable[4]; - bool bTXPowerDataReadFromEEPORM; + bool bTXPowerDataReadFromEEPORM; - u16 RegChannelPlan; - u16 ChannelPlan; - bool bChnlPlanFromHW; + u16 RegChannelPlan; + u16 ChannelPlan; + bool bChnlPlanFromHW; - bool RegRfOff; - bool isRFOff; - bool bInPowerSaveMode; - u8 bHwRfOffAction; + bool RegRfOff; + bool isRFOff; + bool bInPowerSaveMode; + u8 bHwRfOffAction; - bool aspm_clkreq_enable; - u32 pci_bridge_vendor; - u8 RegHostPciASPMSetting; - u8 RegDevicePciASPMSetting; + bool aspm_clkreq_enable; + u32 pci_bridge_vendor; + u8 RegHostPciASPMSetting; + u8 RegDevicePciASPMSetting; - bool RFChangeInProgress; - bool SetRFPowerStateInProgress; - bool bdisable_nic; + bool RFChangeInProgress; + bool SetRFPowerStateInProgress; + bool bdisable_nic; - u8 pwrGroupCnt; + u8 pwrGroupCnt; - u8 ThermalValue_LCK; - u8 ThermalValue_IQK; - bool bRfPiEnable; + u8 ThermalValue_LCK; + u8 ThermalValue_IQK; + bool bRfPiEnable; - u32 APKoutput[2][2]; - bool bAPKdone; + u32 APKoutput[2][2]; + bool bAPKdone; - long RegE94; - long RegE9C; - long RegEB4; - long RegEBC; + long RegE94; + long RegE9C; + long RegEB4; + long RegEBC; - u32 RegC04; - u32 Reg874; - u32 RegC08; - u32 ADDA_backup[16]; - u32 IQK_MAC_backup[3]; + u32 RegC04; + u32 Reg874; + u32 RegC08; + u32 ADDA_backup[16]; + u32 IQK_MAC_backup[3]; - bool SetFwCmdInProgress; - u8 CurrentFwCmdIO; + bool SetFwCmdInProgress; + u8 CurrentFwCmdIO; - u8 rssi_level; + u8 rssi_level; - bool bInformFWDriverControlDM; - u8 PwrGroupHT20[2][14]; - u8 PwrGroupHT40[2][14]; + bool bInformFWDriverControlDM; + u8 PwrGroupHT20[2][14]; + u8 PwrGroupHT40[2][14]; - u8 ThermalValue; - long EntryMinUndecoratedSmoothedPWDB; - long EntryMaxUndecoratedSmoothedPWDB; - u8 DynamicTxHighPowerLvl; - u8 LastDTPLvl; - u32 CurrentRATR0; + u8 ThermalValue; + long EntryMinUndecoratedSmoothedPWDB; + long EntryMaxUndecoratedSmoothedPWDB; + u8 DynamicTxHighPowerLvl; + u8 LastDTPLvl; + u32 CurrentRATR0; struct false_alarm_stats FalseAlmCnt; - u8 DMFlag; - u8 DM_Type; + u8 DMFlag; + u8 DM_Type; - u8 CckPwEnl; - u16 TSSI_13dBm; - u32 Pwr_Track; - u8 CCKPresentAttentuation_20Mdefault; - u8 CCKPresentAttentuation_40Mdefault; - char CCKPresentAttentuation_difference; - char CCKPresentAttentuation; - u8 bCckHighPower; - long undecorated_smoothed_pwdb; - long undecorated_smoothed_cck_adc_pwdb[4]; + u8 CckPwEnl; + u16 TSSI_13dBm; + u32 Pwr_Track; + u8 CCKPresentAttentuation_20Mdefault; + u8 CCKPresentAttentuation_40Mdefault; + char CCKPresentAttentuation_difference; + char CCKPresentAttentuation; + u8 bCckHighPower; + long undecorated_smoothed_pwdb; + long undecorated_smoothed_cck_adc_pwdb[4]; - u32 MCSTxPowerLevelOriginalOffset[6]; - u32 CCKTxPowerLevelOriginalOffset; - u8 TxPowerLevelCCK[14]; - u8 TxPowerLevelCCK_A[14]; - u8 TxPowerLevelCCK_C[14]; + u32 MCSTxPowerLevelOriginalOffset[6]; + u32 CCKTxPowerLevelOriginalOffset; + u8 TxPowerLevelCCK[14]; + u8 TxPowerLevelCCK_A[14]; + u8 TxPowerLevelCCK_C[14]; u8 TxPowerLevelOFDM24G[14]; u8 TxPowerLevelOFDM5G[14]; u8 TxPowerLevelOFDM24G_A[14]; @@ -962,7 +986,7 @@ struct r8192_priv { u8 framesyncMonitor; bool bDMInitialGainEnable; - bool MutualAuthenticationFail; + bool MutualAuthenticationFail; bool bDisableFrameBursting; @@ -1016,41 +1040,42 @@ struct r8192_priv { extern const struct ethtool_ops rtl819x_ethtool_ops; void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb); -short rtl8192_tx(struct net_device *dev, struct sk_buff* skb); +short rtl8192_tx(struct net_device *dev, struct sk_buff *skb); u8 read_nic_io_byte(struct net_device *dev, int x); u32 read_nic_io_dword(struct net_device *dev, int x); u16 read_nic_io_word(struct net_device *dev, int x) ; -void write_nic_io_byte(struct net_device *dev, int x,u8 y); -void write_nic_io_word(struct net_device *dev, int x,u16 y); -void write_nic_io_dword(struct net_device *dev, int x,u32 y); +void write_nic_io_byte(struct net_device *dev, int x, u8 y); +void write_nic_io_word(struct net_device *dev, int x, u16 y); +void write_nic_io_dword(struct net_device *dev, int x, u32 y); u8 read_nic_byte(struct net_device *dev, int x); u32 read_nic_dword(struct net_device *dev, int x); u16 read_nic_word(struct net_device *dev, int x) ; -void write_nic_byte(struct net_device *dev, int x,u8 y); -void write_nic_word(struct net_device *dev, int x,u16 y); -void write_nic_dword(struct net_device *dev, int x,u32 y); +void write_nic_byte(struct net_device *dev, int x, u8 y); +void write_nic_word(struct net_device *dev, int x, u16 y); +void write_nic_dword(struct net_device *dev, int x, u32 y); void force_pci_posting(struct net_device *dev); void rtl8192_rx_enable(struct net_device *); void rtl8192_tx_enable(struct net_device *); -int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev); -void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate); +int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev); +void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, + int rate); void rtl8192_data_hard_stop(struct net_device *dev); void rtl8192_data_hard_resume(struct net_device *dev); void rtl8192_restart(void *data); void rtl819x_watchdog_wqcallback(void *data); -void rtl8192_hw_sleep_wq (void *data); +void rtl8192_hw_sleep_wq(void *data); void watch_dog_timer_callback(unsigned long data); void rtl8192_irq_rx_tasklet(struct r8192_priv *priv); void rtl8192_irq_tx_tasklet(struct r8192_priv *priv); -int rtl8192_down(struct net_device *dev,bool shutdownrf); +int rtl8192_down(struct net_device *dev, bool shutdownrf); int rtl8192_up(struct net_device *dev); void rtl8192_commit(struct net_device *dev); -void rtl8192_set_chan(struct net_device *dev,short ch); +void rtl8192_set_chan(struct net_device *dev, short ch); void check_rfctrl_gpio_timer(unsigned long data); @@ -1059,44 +1084,42 @@ irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs); short rtl8192_pci_initdescring(struct net_device *dev); -void rtl8192_cancel_deferred_work(struct r8192_priv * priv); +void rtl8192_cancel_deferred_work(struct r8192_priv *priv); -int _rtl8192_up(struct net_device *dev,bool is_silent_reset); +int _rtl8192_up(struct net_device *dev, bool is_silent_reset); short rtl8192_is_tx_queue_empty(struct net_device *dev); void rtl8192_irq_disable(struct net_device *dev); void rtl8192_tx_timeout(struct net_device *dev); void rtl8192_pci_resetdescring(struct net_device *dev); -void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode); +void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode); void rtl8192_irq_enable(struct net_device *dev); -void rtl8192_config_rate(struct net_device* dev, u16* rate_config); -void rtl8192_update_cap(struct net_device* dev, u16 cap); +void rtl8192_config_rate(struct net_device *dev, u16 *rate_config); +void rtl8192_update_cap(struct net_device *dev, u16 cap); void rtl8192_irq_disable(struct net_device *dev); -void rtl819x_UpdateRxPktTimeStamp (struct net_device *dev, struct rtllib_rx_stats *stats); -long rtl819x_translate_todbm(struct r8192_priv * priv, u8 signal_strength_index ); -void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); +void rtl819x_UpdateRxPktTimeStamp(struct net_device *dev, + struct rtllib_rx_stats *stats); +long rtl819x_translate_todbm(struct r8192_priv *priv, u8 signal_strength_index); +void rtl819x_update_rxsignalstatistics8190pci(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats); u8 rtl819x_evm_dbtopercentage(char value); -void rtl819x_process_cck_rxpathsel(struct r8192_priv * priv,struct rtllib_rx_stats * pprevious_stats); -u8 rtl819x_query_rxpwrpercentage( char antpower ); -void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats * psrc_stats,struct rtllib_rx_stats * ptarget_stats); +void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, + struct rtllib_rx_stats *pprevious_stats); +u8 rtl819x_query_rxpwrpercentage(char antpower); +void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats, + struct rtllib_rx_stats *ptarget_stats); -bool NicIFEnableNIC(struct net_device* dev); -bool NicIFDisableNIC(struct net_device* dev); +bool NicIFEnableNIC(struct net_device *dev); +bool NicIFDisableNIC(struct net_device *dev); -bool -MgntActSet_RF_State( - struct net_device* dev, - enum rt_rf_power_state StateToSet, - RT_RF_CHANGE_SOURCE ChangeSource, - bool ProtectOrNot - ); -void -ActUpdateChannelAccessSetting( - struct net_device* dev, - enum wireless_mode WirelessMode, - struct channel_access_setting *ChnlAccessSetting - ); +bool MgntActSet_RF_State(struct net_device *dev, + enum rt_rf_power_state StateToSet, + RT_RF_CHANGE_SOURCE ChangeSource, + bool ProtectOrNot); +void ActUpdateChannelAccessSetting(struct net_device *dev, + enum wireless_mode WirelessMode, + struct channel_access_setting *ChnlAccessSetting); #endif From 88a9fd04faea535aab4828bd8d1c5ed9f7e90202 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 6 Aug 2011 21:21:07 -0500 Subject: [PATCH 11/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part IX Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_crypto.h | 80 +-- drivers/staging/rtl8192e/rtl_debug.c | 712 +++++++++++++------------- drivers/staging/rtl8192e/rtl_debug.h | 236 ++++----- 3 files changed, 511 insertions(+), 517 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_crypto.h b/drivers/staging/rtl8192e/rtl_crypto.h index 7b4551db961d..ee57c0f4fa69 100644 --- a/drivers/staging/rtl8192e/rtl_crypto.h +++ b/drivers/staging/rtl8192e/rtl_crypto.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #define crypto_register_alg crypto_register_alg_rsl #define crypto_unregister_alg crypto_unregister_alg_rsl @@ -73,7 +73,7 @@ struct cipher_alg { unsigned int cia_min_keysize; unsigned int cia_max_keysize; int (*cia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); }; @@ -84,16 +84,16 @@ struct digest_alg { void (*dia_update)(void *ctx, const u8 *data, unsigned int len); void (*dia_final)(void *ctx, u8 *out); int (*dia_setkey)(void *ctx, const u8 *key, - unsigned int keylen, u32 *flags); + unsigned int keylen, u32 *flags); }; struct compress_alg { int (*coa_init)(void *ctx); void (*coa_exit)(void *ctx); int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + u8 *dst, unsigned int *dlen); }; #define cra_cipher cra_u.cipher @@ -139,15 +139,15 @@ struct cipher_tfm { unsigned int cit_ivsize; u32 cit_mode; int (*cit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); int (*cit_encrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes); int (*cit_encrypt_iv)(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv); + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv); int (*cit_decrypt)(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, @@ -162,21 +162,21 @@ struct cipher_tfm { struct digest_tfm { void (*dit_init)(struct crypto_tfm *tfm); void (*dit_update)(struct crypto_tfm *tfm, - struct scatterlist *sg, unsigned int nsg); + struct scatterlist *sg, unsigned int nsg); void (*dit_final)(struct crypto_tfm *tfm, u8 *out); void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg, - unsigned int nsg, u8 *out); + unsigned int nsg, u8 *out); int (*dit_setkey)(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen); + const u8 *key, unsigned int keylen); }; struct compress_tfm { int (*cot_compress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); int (*cot_decompress)(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen); + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen); }; #define crt_cipher crt_u.cipher @@ -274,8 +274,8 @@ static inline void crypto_digest_init(struct crypto_tfm *tfm) } static inline void crypto_digest_update(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg) + struct scatterlist *sg, + unsigned int nsg) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_update(tfm, sg, nsg); @@ -288,15 +288,15 @@ static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out) } static inline void crypto_digest_digest(struct crypto_tfm *tfm, - struct scatterlist *sg, - unsigned int nsg, u8 *out) + struct scatterlist *sg, + unsigned int nsg, u8 *out) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); tfm->crt_digest.dit_digest(tfm, sg, nsg, out); } static inline int crypto_digest_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST); if (tfm->crt_digest.dit_setkey == NULL) @@ -305,25 +305,25 @@ static inline int crypto_digest_setkey(struct crypto_tfm *tfm, } static inline int crypto_cipher_setkey(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) + const u8 *key, unsigned int keylen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_setkey(tfm, key, keylen); } static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -331,18 +331,18 @@ static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, } static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes); } static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, - struct scatterlist *dst, - struct scatterlist *src, - unsigned int nbytes, u8 *iv) + struct scatterlist *dst, + struct scatterlist *src, + unsigned int nbytes, u8 *iv) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB); @@ -350,30 +350,30 @@ static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, } static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm, - const u8 *src, unsigned int len) + const u8 *src, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(tfm->crt_cipher.cit_iv, src, len); } static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm, - u8 *dst, unsigned int len) + u8 *dst, unsigned int len) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(dst, tfm->crt_cipher.cit_iv, len); } static inline int crypto_comp_compress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen); } static inline int crypto_comp_decompress(struct crypto_tfm *tfm, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) + const u8 *src, unsigned int slen, + u8 *dst, unsigned int *dlen) { BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS); return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen); diff --git a/drivers/staging/rtl8192e/rtl_debug.c b/drivers/staging/rtl8192e/rtl_debug.c index 5c2d01c8b457..22bc2dd6e438 100644 --- a/drivers/staging/rtl8192e/rtl_debug.c +++ b/drivers/staging/rtl8192e/rtl_debug.c @@ -53,12 +53,10 @@ u32 DBGP_Type[DBGP_TYPE_MAX]; *---------------------------------------------------------------------------*/ void rtl8192_dbgp_flag_init(struct net_device *dev) { - u8 i; + u8 i; for (i = 0; i < DBGP_TYPE_MAX; i++) - { DBGP_Type[i] = 0; - } } /* DBGP_Flag_Init */ @@ -67,19 +65,19 @@ void rtl8192_dbgp_flag_init(struct net_device *dev) void print_buffer(u32 *buffer, int len) { int i; - u8 *buf =(u8*)buffer; + u8 *buf = (u8 *)buffer; - printk("ASCII BUFFER DUMP (len: %x):\n",len); + printk(KERN_INFO "ASCII BUFFER DUMP (len: %x):\n", len); - for (i=0;i ", n); + printk(KERN_INFO "\nD: %2x> ", n); for (i = 0; i < 16 && n <= max; i++, n++) - printk("%2x ", read_nic_byte(dev, n)); + printk(KERN_INFO "%2x ", read_nic_byte(dev, n)); } - printk("\n"); + printk(KERN_INFO "\n"); } /**************************************************************************** -----------------------------PROCFS STUFF------------------------- *****************************************************************************/ /*This part is related to PROC, which will record some statistics. */ -static struct proc_dir_entry *rtl8192_proc = NULL; +static struct proc_dir_entry *rtl8192_proc; static int proc_get_stats_ap(char *page, char **start, off_t offset, int count, @@ -123,24 +121,21 @@ static int proc_get_stats_ap(char *page, char **start, struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; struct rtllib_network *target; - int len = 0; - list_for_each_entry(target, &ieee->network_list, list) { + list_for_each_entry(target, &ieee->network_list, list) { len += snprintf(page + len, count - len, - "%s ", target->ssid); + "%s ", target->ssid); - if (target->wpa_ie_len>0 || target->rsn_ie_len>0){ - len += snprintf(page + len, count - len, - "WPA\n"); - } - else{ - len += snprintf(page + len, count - len, - "non_WPA\n"); - } + if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) + len += snprintf(page + len, count - len, + "WPA\n"); + else + len += snprintf(page + len, count - len, + "non_WPA\n"); - } + } *eof = 1; return len; @@ -153,25 +148,25 @@ static int proc_get_registers_0(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x000; - { - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;n++,i++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } + len += snprintf(page + len, count - len, + "\n####################page %x##################\n ", + (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; n++, i++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -183,25 +178,27 @@ static int proc_get_registers_1(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x100; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -213,25 +210,27 @@ static int proc_get_registers_2(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x200; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0 >> 8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " + "0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -243,25 +242,27 @@ static int proc_get_registers_3(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x300; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -273,117 +274,125 @@ static int proc_get_registers_4(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x400; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + "\n####################page %x##################\n ", + (page0>>8)); len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); + "%2.2x ", read_nic_byte(dev, + (page0 | n))); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } static int proc_get_registers_5(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x500; + int max = 0xff; + page0 = 0x500; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0 >> 8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_6(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x600; + int max = 0xff; + page0 = 0x600; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0>>8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B " + "0C 0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_7(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { - struct net_device *dev = data; + struct net_device *dev = data; - int len = 0; - int i,n,page0; + int len = 0; + int i, n, page0; - int max=0xff; - page0 = 0x700; + int max = 0xff; + page0 = 0x700; - /* This dump the current register page */ - len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); + /* This dump the current register page */ len += snprintf(page + len, count - len, - "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F"); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, - "\nD: %2x > ",n); - for (i=0;i<16 && n<=max;i++,n++) - len += snprintf(page + len, count - len, - "%2.2x ",read_nic_byte(dev,(page0|n))); - } - len += snprintf(page + len, count - len,"\n"); - *eof = 1; - return len; + "\n####################page %x##################\n ", + (page0 >> 8)); + len += snprintf(page + len, count - len, + "\nD: OF > 00 01 02 03 04 05 06 07 08 09 0A 0B 0C " + "0D 0E 0F"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, + "\nD: %2x > ", n); + for (i = 0; i < 16 && n <= max; i++, n++) + len += snprintf(page + len, count - len, + "%2.2x ", read_nic_byte(dev, + (page0 | n))); + } + len += snprintf(page + len, count - len, "\n"); + *eof = 1; + return len; } static int proc_get_registers_8(char *page, char **start, @@ -393,22 +402,23 @@ static int proc_get_registers_8(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x800; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0 >> 8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; @@ -420,22 +430,23 @@ static int proc_get_registers_9(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0x900; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -446,22 +457,23 @@ static int proc_get_registers_a(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xa00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -472,22 +484,23 @@ static int proc_get_registers_b(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xb00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0 >> 8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -498,22 +511,23 @@ static int proc_get_registers_c(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xc00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -524,22 +538,23 @@ static int proc_get_registers_d(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xd00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -550,22 +565,23 @@ static int proc_get_registers_e(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n,page0; + int i, n, page0; - int max=0xff; + int max = 0xff; page0 = 0xe00; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n####################page %x##################\n ", (page0>>8)); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n####################page %x##################\n", + (page0>>8)); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord)); + "%8.8x ", rtl8192_QueryBBReg(dev, + (page0 | n), bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -577,21 +593,22 @@ static int proc_get_reg_rf_a(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-A ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_A,n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_A, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -603,21 +620,22 @@ static int proc_get_reg_rf_b(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-B ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_B, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_B, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -629,21 +647,22 @@ static int proc_get_reg_rf_c(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### RF-C ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + "\n#################### RF-C ##################\n"); + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_C, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_C, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -655,21 +674,22 @@ static int proc_get_reg_rf_d(char *page, char **start, struct net_device *dev = data; int len = 0; - int i,n; + int i, n; - int max=0xff; + int max = 0xff; /* This dump the current register page */ len += snprintf(page + len, count - len, "\n#################### RF-D ##################\n "); - for (n=0;n<=max;) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",n); - for (i=0;i<4 && n<=max;n+=4,i++) + for (n = 0; n <= max;) { + len += snprintf(page + len, count - len, "\nD: %2x > ", n); + for (i = 0; i < 4 && n <= max; n += 4, i++) len += snprintf(page + len, count - len, - "%8.8x ",rtl8192_phy_QueryRFReg(dev, (enum rf90_radio_path)RF90_PATH_D, n, bMaskDWord)); + "%8.8x ", rtl8192_phy_QueryRFReg(dev, + (enum rf90_radio_path)RF90_PATH_D, n, + bMaskDWord)); } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -679,41 +699,38 @@ static int proc_get_cam_register_1(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (0-10) ##################\n "); - for (j=0; j<11; j++) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i+CAM_CONTENT_COUNT*j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -723,41 +740,38 @@ static int proc_get_cam_register_2(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (11-21) ##################\n "); - for (j=11; j<22; j++) - { - len += snprintf(page + len, count - len, "\nD: %2x > ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i + CAM_CONTENT_COUNT * j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -767,41 +781,38 @@ static int proc_get_cam_register_3(char *page, char **start, int *eof, void *data) { struct net_device *dev = data; - u32 target_command=0; - u32 target_content=0; - u8 entry_i=0; + u32 target_command = 0; + u32 target_content = 0; + u8 entry_i = 0; u32 ulStatus; int len = 0; - int i=100, j = 0; + int i = 100, j = 0; /* This dump the current register page */ len += snprintf(page + len, count - len, - "\n#################### SECURITY CAM (22-31) ##################\n "); - for (j=22; j ",j); - for (entry_i=0;entry_i ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i + CAM_CONTENT_COUNT * j; + target_command = target_command | BIT31; - while((i--)>=0) - { + while ((i--) >= 0) { ulStatus = read_nic_dword(dev, RWCAM); - if (ulStatus & BIT31){ + if (ulStatus & BIT31) continue; - } - else{ + else break; - } } write_nic_dword(dev, RWCAM, target_command); target_content = read_nic_dword(dev, RCAMO); - len += snprintf(page + len, count - len,"%8.8x ",target_content); + len += snprintf(page + len, count - len, "%8.8x ", + target_content); } } - len += snprintf(page + len, count - len,"\n"); + len += snprintf(page + len, count - len, "\n"); *eof = 1; return len; } @@ -877,7 +888,7 @@ static int proc_get_stats_rx(char *page, char **start, void rtl8192_proc_module_init(void) { RT_TRACE(COMP_INIT, "Initializing proc filesystem"); - rtl8192_proc=create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); + rtl8192_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net); } @@ -891,7 +902,7 @@ void rtl8192_proc_remove_one(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - printk("dev name %s\n",dev->name); + printk(KERN_INFO "dev name %s\n", dev->name); if (priv->dir_dev) { remove_proc_entry("stats-tx", priv->dir_dev); @@ -929,194 +940,169 @@ void rtl8192_proc_init_one(struct net_device *dev) { struct proc_dir_entry *e; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); + priv->dir_dev = create_proc_entry(dev->name, S_IFDIR | S_IRUGO | S_IXUGO, rtl8192_proc); if (!priv->dir_dev) { - RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", - dev->name); + RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192" + "/%s\n", dev->name); return; } e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_rx, dev); - if (!e) { - RT_TRACE(COMP_ERR,"Unable to initialize " + if (!e) + RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-rx\n", dev->name); - } - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_tx, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-tx\n", dev->name); - } e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_stats_ap, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/stats-ap\n", dev->name); - } e = create_proc_read_entry("registers-0", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_0, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-0\n", dev->name); - } e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_1, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-1\n", dev->name); - } e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_2, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-2\n", dev->name); - } e = create_proc_read_entry("registers-3", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_3, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-3\n", dev->name); - } e = create_proc_read_entry("registers-4", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_4, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-4\n", dev->name); - } e = create_proc_read_entry("registers-5", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_5, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-5\n", dev->name); - } e = create_proc_read_entry("registers-6", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_6, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-6\n", dev->name); - } e = create_proc_read_entry("registers-7", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_7, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-7\n", dev->name); - } e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_8, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-8\n", dev->name); - } e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_9, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-9\n", dev->name); - } e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_a, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-a\n", dev->name); - } e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_b, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-b\n", dev->name); - } e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_c, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-c\n", dev->name); - } e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_d, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-d\n", dev->name); - } e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_registers_e, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/registers-e\n", dev->name); - } e = create_proc_read_entry("RF-A", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_a, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-A\n", dev->name); - } e = create_proc_read_entry("RF-B", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_b, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-B\n", dev->name); - } e = create_proc_read_entry("RF-C", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_c, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-C\n", dev->name); - } e = create_proc_read_entry("RF-D", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_reg_rf_d, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/RF-D\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-1", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_1, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-1\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-2", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_2, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-2\n", dev->name); - } e = create_proc_read_entry("SEC-CAM-3", S_IFREG | S_IRUGO, priv->dir_dev, proc_get_cam_register_3, dev); - if (!e) { + if (!e) RT_TRACE(COMP_ERR, "Unable to initialize " "/proc/net/rtl8192/%s/SEC-CAM-3\n", dev->name); - } } diff --git a/drivers/staging/rtl8192e/rtl_debug.h b/drivers/staging/rtl8192e/rtl_debug.h index 415dfca6b37d..50fb9a9b828a 100644 --- a/drivers/staging/rtl8192e/rtl_debug.h +++ b/drivers/staging/rtl8192e/rtl_debug.h @@ -36,31 +36,30 @@ struct net_device; #define DBG_LOUD 4 -#define RT_ASSERT(_Exp,Fmt) \ - if (!(_Exp)) \ - { \ - printk("Rtl819x: "); \ - printk Fmt; \ +#define RT_ASSERT(_Exp, Fmt) \ + if (!(_Exp)) { \ + printk("Rtl819x: "); \ + printk Fmt; \ } enum dbgp_flag { FQoS = 0, - FTX = 1, - FRX = 2, + FTX = 1, + FRX = 2, FSEC = 3, FMGNT = 4, FMLME = 5, FRESOURCE = 6, - FBEACON = 7, + FBEACON = 7, FISR = 8, FPHY = 9, - FMP = 10, - FEEPROM = 11, + FMP = 10, + FEEPROM = 11, FPWR = 12, - FDM = 13, - FDBGCtrl = 14, + FDM = 13, + FDBGCtrl = 14, FC2H = 15, - FBT = 16, + FBT = 16, FINIT = 17, FIOCTL = 18, DBGP_TYPE_MAX @@ -76,10 +75,10 @@ enum dbgp_flag { #define RX_PHY_STS BIT1 #define RX_PHY_SS BIT2 #define RX_PHY_SQ BIT3 -#define RX_PHY_ASTS BIT4 +#define RX_PHY_ASTS BIT4 #define RX_ERR_LEN BIT5 #define RX_DEFRAG BIT6 -#define RX_ERR_RATE BIT7 +#define RX_ERR_RATE BIT7 @@ -93,68 +92,68 @@ enum dbgp_flag { #define ISR_CHK BIT0 -#define PHY_BBR BIT0 -#define PHY_BBW BIT1 -#define PHY_RFR BIT2 -#define PHY_RFW BIT3 +#define PHY_BBR BIT0 +#define PHY_BBW BIT1 +#define PHY_RFR BIT2 +#define PHY_RFW BIT3 #define PHY_MACR BIT4 #define PHY_MACW BIT5 #define PHY_ALLR BIT6 #define PHY_ALLW BIT7 #define PHY_TXPWR BIT8 -#define PHY_PWRDIFF BIT9 +#define PHY_PWRDIFF BIT9 #define MP_RX BIT0 -#define MP_SWICH_CH BIT1 +#define MP_SWICH_CH BIT1 #define EEPROM_W BIT0 #define EFUSE_PG BIT1 -#define EFUSE_READ_ALL BIT2 +#define EFUSE_READ_ALL BIT2 -#define LPS BIT0 -#define IPS BIT1 +#define LPS BIT0 +#define IPS BIT1 #define PWRSW BIT2 #define PWRHW BIT3 #define PWRHAL BIT4 #define WA_IOT BIT0 -#define DM_PWDB BIT1 +#define DM_PWDB BIT1 #define DM_Monitor BIT2 #define DM_DIG BIT3 -#define DM_EDCA_Turbo BIT4 +#define DM_EDCA_Turbo BIT4 -#define DbgCtrl_Trace BIT0 -#define DbgCtrl_InbandNoise BIT1 +#define DbgCtrl_Trace BIT0 +#define DbgCtrl_InbandNoise BIT1 #define BT_TRACE BIT0 #define BT_RFPoll BIT1 -#define C2H_Summary BIT0 -#define C2H_PacketData BIT1 -#define C2H_ContentData BIT2 +#define C2H_Summary BIT0 +#define C2H_PacketData BIT1 +#define C2H_ContentData BIT2 #define BT_TRACE BIT0 #define BT_RFPoll BIT1 #define INIT_EEPROM BIT0 -#define INIT_TxPower BIT1 +#define INIT_TxPower BIT1 #define INIT_IQK BIT2 #define INIT_RF BIT3 -#define IOCTL_TRACE BIT0 -#define IOCTL_BT_EVENT BIT1 +#define IOCTL_TRACE BIT0 +#define IOCTL_BT_EVENT BIT1 #define IOCTL_BT_EVENT_DETAIL BIT2 #define IOCTL_BT_TX_ACLDATA BIT3 #define IOCTL_BT_TX_ACLDATA_DETAIL BIT4 #define IOCTL_BT_RX_ACLDATA BIT5 -#define IOCTL_BT_RX_ACLDATA_DETAIL BIT6 +#define IOCTL_BT_RX_ACLDATA_DETAIL BIT6 #define IOCTL_BT_HCICMD BIT7 #define IOCTL_BT_HCICMD_DETAIL BIT8 -#define IOCTL_IRP BIT9 -#define IOCTL_IRP_DETAIL BIT10 -#define IOCTL_CALLBACK_FUN BIT11 -#define IOCTL_STATE BIT12 -#define IOCTL_BT_TP BIT13 -#define IOCTL_BT_LOGO BIT14 +#define IOCTL_IRP BIT9 +#define IOCTL_IRP_DETAIL BIT10 +#define IOCTL_CALLBACK_FUN BIT11 +#define IOCTL_STATE BIT12 +#define IOCTL_BT_TP BIT13 +#define IOCTL_BT_LOGO BIT14 /* 2007/07/13 MH ------For DeBuG Print modeue------*/ /*------------------------------Define structure----------------------------*/ @@ -164,97 +163,98 @@ enum dbgp_flag { #define DEBUG_PRINT 1 #if (DEBUG_PRINT == 1) -#define RTPRINT(dbgtype, dbgflag, printstr) \ -{ \ - if (DBGP_Type[dbgtype] & dbgflag)\ - { \ +#define RTPRINT(dbgtype, dbgflag, printstr) \ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ printk printstr; \ - } \ + } \ } -#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\ -{\ - if (DBGP_Type[dbgtype] & dbgflag)\ - {\ - int __i; \ - u8* ptr = (u8*)_Ptr; \ - printk printstr; \ - printk(" "); \ - for ( __i=0; __i<6; __i++ ) \ - printk("%02X%s", ptr[__i], (__i==5)?"":"-"); \ - printk("\n"); \ - }\ +#define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr) \ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ + int __i; \ + u8 *ptr = (u8 *)_Ptr; \ + printk printstr; \ + printk(" "); \ + for (__i = 0; __i < 6; __i++) \ + printk("%02X%s", ptr[__i], \ + (__i == 5) ? "" : "-"); \ + printk("\n"); \ + } \ } #define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)\ -{\ - if (DBGP_Type[dbgtype] & dbgflag)\ - {\ - int __i; \ - u8* ptr = (u8*)_HexData; \ - printk(_TitleString); \ - for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ - { \ - printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" ");\ - if (((__i + 1) % 16) == 0) printk("\n");\ - } \ - printk("\n"); \ - }\ +{ \ + if (DBGP_Type[dbgtype] & dbgflag) { \ + int __i; \ + u8 *ptr = (u8 *)_HexData; \ + printk(_TitleString); \ + for (__i = 0; __i < (int)_HexDataLen; __i++) { \ + printk("%02X%s", ptr[__i], (((__i + 1) \ + % 4) == 0) ? " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ + } \ } #else #define RTPRINT(dbgtype, dbgflag, printstr) #define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr) -#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen) +#define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen) #endif extern u32 DBGP_Type[DBGP_TYPE_MAX]; -#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \ +#define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData, _HexDataLen) \ do {\ - if (((_Comp) & rt_global_debug_component ) && (_Level <= rt_global_debug_component )) \ - { \ - int __i; \ - u8* ptr = (u8*)_HexData; \ - printk("Rtl819x: "); \ - printk(_TitleString); \ - for ( __i=0; __i<(int)_HexDataLen; __i++ ) \ - { \ - printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" "); \ - if (((__i + 1) % 16) == 0) printk("\n"); \ - } \ - printk("\n"); \ + if (((_Comp) & rt_global_debug_component) && \ + (_Level <= rt_global_debug_component)) { \ + int __i; \ + u8* ptr = (u8 *)_HexData; \ + printk(KERN_INFO "Rtl819x: "); \ + printk(_TitleString); \ + for (__i = 0; __i < (int)_HexDataLen; __i++) { \ + printk("%02X%s", ptr[__i], (((__i + 1) % \ + 4) == 0) ? " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ } \ -}while(0); +} while (0); -#define DMESG(x,a...) -#define DMESGW(x,a...) -#define DMESGE(x,a...) +#define DMESG(x, a...) +#define DMESGW(x, a...) +#define DMESGE(x, a...) extern u32 rt_global_debug_component; #define RT_TRACE(component, x, args...) \ -do { if (rt_global_debug_component & component) \ - printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ - ##args);\ -}while(0); +do { \ + if (rt_global_debug_component & component) \ + printk(KERN_DEBUG DRV_NAME ":" x "\n" , \ + ##args);\ +} while (0); #define assert(expr) \ - if (!(expr)) { \ - printk( "Assertion failed! %s,%s,%s,line=%d\n", \ - #expr,__FILE__,__func__,__LINE__); \ - } + if (!(expr)) { \ + printk(KERN_INFO "Assertion failed! %s,%s,%s,line=%d\n", \ + #expr, __FILE__, __func__, __LINE__); \ + } #define RT_DEBUG_DATA(level, data, datalen) \ - do{ if ((rt_global_debug_component & (level)) == (level)) \ - { \ - int _i; \ - u8* _pdata = (u8*) data; \ - printk(KERN_DEBUG DRV_NAME ": %s()\n", __func__); \ - for (_i=0; _i<(int)(datalen); _i++) \ - { \ - printk("%2x ", _pdata[_i]); \ - if ((_i+1)%16 == 0) printk("\n"); \ - } \ - printk("\n"); \ - } \ - } while (0) + do { \ + if ((rt_global_debug_component & (level)) == (level)) {\ + int _i; \ + u8 *_pdata = (u8 *)data; \ + printk(KERN_DEBUG DRV_NAME ": %s()\n", __func__); \ + for (_i = 0; _i < (int)(datalen); _i++) { \ + printk(KERN_INFO "%2x ", _pdata[_i]); \ + if ((_i+1) % 16 == 0) \ + printk("\n"); \ + } \ + printk(KERN_INFO "\n"); \ + } \ + } while (0) struct rtl_fs_debug { const char *name; @@ -270,16 +270,23 @@ void dump_eprom(struct net_device *dev); void rtl8192_dump_reg(struct net_device *dev); /* debugfs stuff */ -static inline int rtl_debug_module_init(struct r8192_priv *priv, const char *name) { +static inline int rtl_debug_module_init(struct r8192_priv *priv, + const char *name) +{ return 0; } -static inline void rtl_debug_module_remove(struct r8192_priv *priv) { +static inline void rtl_debug_module_remove(struct r8192_priv *priv) +{ } -static inline int rtl_create_debugfs_root(void) { + +static inline int rtl_create_debugfs_root(void) +{ return 0; } -static inline void rtl_remove_debugfs_root(void) { + +static inline void rtl_remove_debugfs_root(void) +{ } /* proc stuff */ @@ -288,4 +295,5 @@ void rtl8192_proc_remove_one(struct net_device *dev); void rtl8192_proc_module_init(void); void rtl8192_proc_module_remove(void); void rtl8192_dbgp_flag_init(struct net_device *dev); + #endif From b2a3fff4bfd113e0309bc6bd7734b9ce9cdd1943 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 7 Aug 2011 15:05:00 -0500 Subject: [PATCH 12/25] staging: rtl8192e: Cleanup checkpatch -f errors - Part X With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtl_dm.c will need refactoring. In addition, some of the variables will need renaming. Those changes can be deferred. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_dm.c | 2442 +++++++++++++---------------- drivers/staging/rtl8192e/rtl_dm.h | 61 +- 2 files changed, 1128 insertions(+), 1375 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 3ab71c78634a..291ec3e9d22c 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -25,37 +25,37 @@ #include "r8192E_cmdpkt.h" /*---------------------------Define Local Constant---------------------------*/ -static u32 edca_setting_DL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4332 - }; - -static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x5e4322, - 0x604322, - 0xa44f, - 0x5e4322, - 0x5e4322 +static u32 edca_setting_DL[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0x5e4322, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4332 }; -static u32 edca_setting_UL[HT_IOT_PEER_MAX] = -{ 0x5e4322, - 0xa44f, - 0x5ea44f, - 0x5e4322, - 0x604322, - 0x5e4322, - 0x5e4322, - 0x5e4332 +static u32 edca_setting_DL_GMode[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x5e4322, + 0x604322, + 0xa44f, + 0x5e4322, + 0x5e4322 +}; + +static u32 edca_setting_UL[HT_IOT_PEER_MAX] = { + 0x5e4322, + 0xa44f, + 0x5ea44f, + 0x5e4322, + 0x604322, + 0x5e4322, + 0x5e4322, + 0x5e4332 }; #define RTK_UL_EDCA 0xa44f @@ -65,7 +65,10 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = /*------------------------Define global variable-----------------------------*/ struct dig_t dm_digtable; -u8 dm_shadow[16][256] = {{0}}; +u8 dm_shadow[16][256] = { + {0} +}; + struct drx_path_sel DM_RxPathSelTable; /*------------------------Define global variable-----------------------------*/ @@ -74,46 +77,12 @@ struct drx_path_sel DM_RxPathSelTable; /*------------------------Define local variable------------------------------*/ -/*--------------------Define export function prototype-----------------------*/ -extern void init_hal_dm(struct net_device *dev); -extern void deinit_hal_dm(struct net_device *dev); - -extern void hal_dm_watchdog(struct net_device *dev); - - -extern void init_rate_adaptive(struct net_device *dev); -extern void dm_txpower_trackingcallback(void *data); - -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); -extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); -extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); -extern void dm_init_edca_turbo(struct net_device *dev); -extern void dm_rf_operation_test_callback(unsigned long data); -extern void dm_rf_pathcheck_workitemcallback(void *data); -extern void dm_fsync_timer_callback(unsigned long data); -extern void dm_check_fsync(struct net_device *dev); -extern void dm_shadow_init(struct net_device *dev); -extern void dm_initialize_txpower_tracking(struct net_device *dev); - -extern void dm_CheckRfCtrlGPIO(void *data); - - -/*--------------------Define export function prototype-----------------------*/ - /*---------------------Define local function prototype-----------------------*/ static void dm_check_rate_adaptive(struct net_device *dev); -static void dm_init_bandwidth_autoswitch (struct net_device *dev); -static void dm_bandwidth_autoswitch ( struct net_device *dev); +static void dm_init_bandwidth_autoswitch(struct net_device *dev); +static void dm_bandwidth_autoswitch(struct net_device *dev); static void dm_check_txpower_tracking(struct net_device *dev); @@ -130,7 +99,7 @@ static void dm_bb_initialgain_backup(struct net_device *dev); static void dm_dig_init(struct net_device *dev); static void dm_ctrl_initgain_byrssi(struct net_device *dev); static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev); -static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device *dev); +static void dm_ctrl_initgain_byrssi_by_driverrssi(struct net_device *dev); static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device *dev); static void dm_initial_gain(struct net_device *dev); static void dm_pd_th(struct net_device *dev); @@ -179,14 +148,14 @@ init_hal_dm(struct net_device *dev) dm_dig_init(dev); dm_init_edca_turbo(dev); - dm_init_bandwidth_autoswitch (dev); + dm_init_bandwidth_autoswitch(dev); dm_init_fsync(dev); dm_init_rxpath_selection(dev); dm_init_ctstoself(dev); - if (IS_HARDWARE_TYPE_8192SE(dev)) - dm_Init_WA_Broadcom_IOT(dev); + if (IS_HARDWARE_TYPE_8192SE(dev)) + dm_Init_WA_Broadcom_IOT(dev); - INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO,dev); + INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev); } extern void deinit_hal_dm(struct net_device *dev) @@ -213,7 +182,7 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_check_txpower_tracking(dev); dm_ctrl_initgain_byrssi(dev); - dm_bandwidth_autoswitch (dev); + dm_bandwidth_autoswitch(dev); dm_check_rx_path_selection(dev); dm_check_fsync(dev); @@ -226,28 +195,27 @@ void dm_check_ac_dc_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; - char *argv[] = {ac_dc_check_script_path,DRV_NAME,NULL}; + char *argv[] = {ac_dc_check_script_path, DRV_NAME, NULL}; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; - if (priv->ResetProgress == RESET_TYPE_SILENT) - { - RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); + if (priv->ResetProgress == RESET_TYPE_SILENT) { + RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF), + "GPIOChangeRFWorkItemCallBack(): Silent Reseting!!!!!!!\n"); return; } - if (priv->rtllib->state != RTLLIB_LINKED) { + if (priv->rtllib->state != RTLLIB_LINKED) return; - } - call_usermodehelper(ac_dc_check_script_path,argv,envp,1); + call_usermodehelper(ac_dc_check_script_path, argv, envp, 1); return; }; -extern void init_rate_adaptive(struct net_device * dev) +extern void init_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -269,17 +237,14 @@ extern void init_rate_adaptive(struct net_device * dev) pra->ping_rssi_thresh_for_ra = 15; - if (priv->rf_type == RF_2T4R) - { + if (priv->rf_type == RF_2T4R) { pra->upper_rssi_threshold_ratr = 0x8f0f0000; pra->middle_rssi_threshold_ratr = 0x8f0ff000; pra->low_rssi_threshold_ratr = 0x8f0ff001; pra->low_rssi_threshold_ratr_40M = 0x8f0ff005; pra->low_rssi_threshold_ratr_20M = 0x8f0ff001; pra->ping_rssi_ratr = 0x0000000d; - } - else if (priv->rf_type == RF_1T2R) - { + } else if (priv->rf_type == RF_1T2R) { pra->upper_rssi_threshold_ratr = 0x000fc000; pra->middle_rssi_threshold_ratr = 0x000ff000; pra->low_rssi_threshold_ratr = 0x000ff001; @@ -291,17 +256,17 @@ extern void init_rate_adaptive(struct net_device * dev) } -static void dm_check_rate_adaptive(struct net_device * dev) +static void dm_check_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive; - u32 currentRATR, targetRATR = 0; - u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; - bool bshort_gi_enabled = false; - static u8 ping_rssi_state=0; + u32 currentRATR, targetRATR = 0; + u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0; + bool bshort_gi_enabled = false; + static u8 ping_rssi_state; - if (IS_NIC_DOWN(priv)){ + if (IS_NIC_DOWN(priv)) { RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n"); return; } @@ -309,83 +274,66 @@ static void dm_check_rate_adaptive(struct net_device * dev) if (pra->rate_adaptive_disabled) return; - if ( !(priv->rtllib->mode == WIRELESS_MODE_N_24G || - priv->rtllib->mode == WIRELESS_MODE_N_5G)) - return; + if (!(priv->rtllib->mode == WIRELESS_MODE_N_24G || + priv->rtllib->mode == WIRELESS_MODE_N_5G)) + return; - if ( priv->rtllib->state == RTLLIB_LINKED ) - { + if (priv->rtllib->state == RTLLIB_LINKED) { bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) || (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz); pra->upper_rssi_threshold_ratr = - (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); pra->middle_rssi_threshold_ratr = - (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; - } - else - { + (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); + } else { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); } pra->ping_rssi_ratr = - (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ; + (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); - if (pra->ratr_state == DM_RATR_STA_HIGH) - { + if (pra->ratr_state == DM_RATR_STA_HIGH) { HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); - } - else if (pra->ratr_state == DM_RATR_STA_LOW) - { + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); + } else if (pra->ratr_state == DM_RATR_STA_LOW) { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M); - } - else - { + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low2high_rssi_thresh_for_ra40M) : (pra->low2high_rssi_thresh_for_ra20M); + } else { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)? - (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M); + LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } - if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) - { + if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_HIGH; targetRATR = pra->upper_rssi_threshold_ratr; - }else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) - { + } else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) { pra->ratr_state = DM_RATR_STA_MIDDLE; targetRATR = pra->middle_rssi_threshold_ratr; - }else - { + } else { pra->ratr_state = DM_RATR_STA_LOW; targetRATR = pra->low_rssi_threshold_ratr; } - if (pra->ping_rssi_enable) - { - if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) - { - if ( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || - ping_rssi_state ) - { + if (pra->ping_rssi_enable) { + if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) { + if ((priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) || + ping_rssi_state) { pra->ratr_state = DM_RATR_STA_LOW; targetRATR = pra->ping_rssi_ratr; ping_rssi_state = 1; } - } - else - { + } else { ping_rssi_state = 0; } } @@ -394,30 +342,26 @@ static void dm_check_rate_adaptive(struct net_device * dev) targetRATR &= 0xf00fffff; currentRATR = read_nic_dword(dev, RATR0); - if ( targetRATR != currentRATR ) - { + if (targetRATR != currentRATR) { u32 ratr_value; ratr_value = targetRATR; - RT_TRACE(COMP_RATE,"currentRATR = %x, targetRATR = %x\n", currentRATR, targetRATR); + RT_TRACE(COMP_RATE, + "currentRATR = %x, targetRATR = %x\n", + currentRATR, targetRATR); if (priv->rf_type == RF_1T2R) - { ratr_value &= ~(RATE_ALL_OFDM_2SS); - } write_nic_dword(dev, RATR0, ratr_value); write_nic_byte(dev, UFWP, 1); pra->last_ratr = targetRATR; } - } - else - { + } else { pra->ratr_state = DM_RATR_STA_MAX; } - } -static void dm_init_bandwidth_autoswitch (struct net_device * dev) +static void dm_init_bandwidth_autoswitch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -425,22 +369,23 @@ static void dm_init_bandwidth_autoswitch (struct net_device * dev) priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW; priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; priv->rtllib->bandwidth_auto_switch.bautoswitch_enable = false; - } - -static void dm_bandwidth_autoswitch (struct net_device * dev) +static void dm_bandwidth_autoswitch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->rtllib->bandwidth_auto_switch.bautoswitch_enable){ + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 || + !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable) { return; - }else{ - if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false){ - if (priv->undecorated_smoothed_pwdb <= priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz) + } else { + if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false) { + if (priv->undecorated_smoothed_pwdb <= + priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz) priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = true; - }else{ - if (priv->undecorated_smoothed_pwdb >= priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz) + } else { + if (priv->undecorated_smoothed_pwdb >= + priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz) priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false; } @@ -468,6 +413,7 @@ static u32 OFDMSwingTable[OFDM_Table_Length] = { 0x12000048, 0x10000040 }; + static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, @@ -497,25 +443,27 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} }; + #define Pw_Track_Flag 0x11d #define Tssi_Mea_Value 0x13c #define Tssi_Report_Value1 0x134 #define Tssi_Report_Value2 0x13e #define FW_Busy_Flag 0x13f -static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) - { +static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) +{ struct r8192_priv *priv = rtllib_priv(dev); - bool bHighpowerstate, viviflag = false; + bool bHighpowerstate, viviflag = false; struct dcmd_txcmd tx_cmd; - u8 powerlevelOFDM24G; - int i =0, j = 0, k = 0; - u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0}; - u32 Value; - u8 Pwr_Flag; - u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0; - u32 delta=0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); + u8 powerlevelOFDM24G; + int i = 0, j = 0, k = 0; + u8 RF_Type, tmp_report[5] = {0, 0, 0, 0, 0}; + u32 Value; + u8 Pwr_Flag; + u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver = 0; + u32 delta = 0; + + RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); write_nic_byte(dev, Pw_Track_Flag, 0); write_nic_byte(dev, FW_Busy_Flag, 0); priv->rtllib->bdynamic_txpower_enable = false; @@ -525,305 +473,312 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev) RF_Type = priv->rf_type; Value = (RF_Type<<8) | powerlevelOFDM24G; - RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G); + RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", + powerlevelOFDM24G); - for (j = 0; j<=30; j++) -{ + for (j = 0; j <= 30; j++) { - tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; - tx_cmd.Length = 4; - tx_cmd.Value = Value; - cmpk_message_handle_tx(dev, (u8*)&tx_cmd, DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); - mdelay(1); - for (i = 0;i <= 30; i++) - { - Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag); + tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING; + tx_cmd.Length = 4; + tx_cmd.Value = Value; + cmpk_message_handle_tx(dev, (u8 *)&tx_cmd, + DESC_PACKET_TYPE_INIT, + sizeof(struct dcmd_txcmd)); + mdelay(1); + for (i = 0; i <= 30; i++) { + Pwr_Flag = read_nic_byte(dev, Pw_Track_Flag); - if (Pwr_Flag == 0) - { - mdelay(1); + if (Pwr_Flag == 0) { + mdelay(1); - if (priv->bResetInProgress) - { - RT_TRACE(COMP_POWER_TRACKING, "we are in slient reset progress, so return\n"); - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - return; + if (priv->bResetInProgress) { + RT_TRACE(COMP_POWER_TRACKING, + "we are in slient reset progress, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + if ((priv->rtllib->eRFPowerState != eRfOn)) { + RT_TRACE(COMP_POWER_TRACKING, + "we are in power save, so return\n"); + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + return; + } + + continue; } - if ((priv->rtllib->eRFPowerState != eRfOn)) - { - RT_TRACE(COMP_POWER_TRACKING, "we are in power save, so return\n"); + + Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value); + + if (Avg_TSSI_Meas == 0) { write_nic_byte(dev, Pw_Track_Flag, 0); write_nic_byte(dev, FW_Busy_Flag, 0); return; } - continue; - } + for (k = 0; k < 5; k++) { + if (k != 4) + tmp_report[k] = read_nic_byte(dev, + Tssi_Report_Value1+k); + else + tmp_report[k] = read_nic_byte(dev, + Tssi_Report_Value2); - Avg_TSSI_Meas = read_nic_word(dev, Tssi_Mea_Value); + RT_TRACE(COMP_POWER_TRACKING, + "TSSI_report_value = %d\n", + tmp_report[k]); - if (Avg_TSSI_Meas == 0) - { - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - return; - } + if (tmp_report[k] <= 20) { + viviflag = true; + break; + } + } - for (k = 0;k < 5; k++) - { - if (k !=4) - tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value1+k); + if (viviflag == true) { + write_nic_byte(dev, Pw_Track_Flag, 0); + viviflag = false; + RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); + for (k = 0; k < 5; k++) + tmp_report[k] = 0; + break; + } + + for (k = 0; k < 5; k++) + Avg_TSSI_Meas_from_driver += tmp_report[k]; + + Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; + RT_TRACE(COMP_POWER_TRACKING, + "Avg_TSSI_Meas_from_driver = %d\n", + Avg_TSSI_Meas_from_driver); + TSSI_13dBm = priv->TSSI_13dBm; + RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); + + if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) + delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; else - tmp_report[k] = read_nic_byte(dev, Tssi_Report_Value2); + delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]); + if (delta <= E_FOR_TX_POWER_TRACK) { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, + "tx power track is done\n"); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex_real = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation_difference = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation = %d\n", + priv->CCKPresentAttentuation); + return; + } else { + if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) { + if (RF_Type == RF_2T4R) { - { - if (tmp_report[k] <= 20) - { - viviflag =true; - break; - } - } - } + if ((priv->rfa_txpowertrackingindex > 0) && + (priv->rfc_txpowertrackingindex > 0)) { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } - if (viviflag ==true) - { + priv->rfc_txpowertrackingindex--; + if (priv->rfc_txpowertrackingindex_real > 4) { + priv->rfc_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } + } else { + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[4].txbbgain_value); + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + } + } else { + if (priv->rfa_txpowertrackingindex > 0) { + priv->rfa_txpowertrackingindex--; + if (priv->rfa_txpowertrackingindex_real > 4) { + priv->rfa_txpowertrackingindex_real--; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } + } else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, priv->txbbgain_table[4].txbbgain_value); + + } + } else { + if (RF_Type == RF_2T4R) { + if ((priv->rfa_txpowertrackingindex < + TxBBGainTableLength - 1) && + (priv->rfc_txpowertrackingindex < + TxBBGainTableLength - 1)) { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table + [priv->rfa_txpowertrackingindex_real].txbbgain_value); + priv->rfc_txpowertrackingindex++; + priv->rfc_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); + } else { + rtl8192_setBBreg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + rtl8192_setBBreg(dev, + rOFDM0_XCTxIQImbalance, + bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } + } else { + if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { + priv->rfa_txpowertrackingindex++; + priv->rfa_txpowertrackingindex_real++; + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); + } else + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, + bMaskDWord, + priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); + } + } + if (RF_Type == RF_2T4R) { + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; + } else { + priv->CCKPresentAttentuation_difference + = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; + } + + if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_20Mdefault + + priv->CCKPresentAttentuation_difference; + else + priv->CCKPresentAttentuation = + priv->CCKPresentAttentuation_40Mdefault + + priv->CCKPresentAttentuation_difference; + + if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) + priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; + if (priv->CCKPresentAttentuation < 0) + priv->CCKPresentAttentuation = 0; + + if (priv->CCKPresentAttentuation > -1 && + priv->CCKPresentAttentuation < CCKTxBBGainTableLength) { + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { + priv->bcck_in_ch14 = true; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) { + priv->bcck_in_ch14 = false; + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } else + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); + } + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex = %d\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, + "priv->rfa_txpowertrackingindex_real = %d\n", + priv->rfa_txpowertrackingindex_real); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation_difference = %d\n", + priv->CCKPresentAttentuation_difference); + RT_TRACE(COMP_POWER_TRACKING, + "priv->CCKPresentAttentuation = %d\n", + priv->CCKPresentAttentuation); + + if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) { + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); + write_nic_byte(dev, FW_Busy_Flag, 0); + RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); + return; + } + } write_nic_byte(dev, Pw_Track_Flag, 0); - viviflag = false; - RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n"); - for (k = 0;k < 5; k++) + Avg_TSSI_Meas_from_driver = 0; + for (k = 0; k < 5; k++) tmp_report[k] = 0; break; } - - for (k = 0;k < 5; k++) - { - Avg_TSSI_Meas_from_driver += tmp_report[k]; - } - - Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5; - RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver); - TSSI_13dBm = priv->TSSI_13dBm; - RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm); - - if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) - delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; - else - delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; - - if (delta <= E_FOR_TX_POWER_TRACK) - { - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n"); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - return; - } - else - { - if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) - { - if (RF_Type == RF_2T4R) - { - - if ((priv->rfa_txpowertrackingindex > 0) &&(priv->rfc_txpowertrackingindex > 0)) - { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) - { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - - priv->rfc_txpowertrackingindex--; - if (priv->rfc_txpowertrackingindex_real > 4) - { - priv->rfc_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - } - else - { - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - else - { - { - { - if (priv->rfa_txpowertrackingindex > 0) - { - priv->rfa_txpowertrackingindex--; - if (priv->rfa_txpowertrackingindex_real > 4) - { - priv->rfa_txpowertrackingindex_real--; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - } - else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[4].txbbgain_value); - } - } - - } - } - else - { - if (RF_Type == RF_2T4R) - { - if ((priv->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&(priv->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) - { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - priv->rfc_txpowertrackingindex++; - priv->rfc_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value); - } - else - { - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - else - { - { - { - if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) - { - priv->rfa_txpowertrackingindex++; - priv->rfa_txpowertrackingindex_real++; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value); - } - else - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value); - } - } - } - } - if (RF_Type == RF_2T4R){ - priv->CCKPresentAttentuation_difference - = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; - }else{ - { - priv->CCKPresentAttentuation_difference - = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; - } - } - - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_20Mdefault + priv->CCKPresentAttentuation_difference; - else - priv->CCKPresentAttentuation - = priv->CCKPresentAttentuation_40Mdefault + priv->CCKPresentAttentuation_difference; - - if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1)) - priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1; - if (priv->CCKPresentAttentuation < 0) - priv->CCKPresentAttentuation = 0; - - if (priv->CCKPresentAttentuation > -1&&priv->CCKPresentAttentuation < CCKTxBBGainTableLength) - { - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = true; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { - priv->bcck_in_ch14 = false; - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - else - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); - } - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation_difference = %d\n", priv->CCKPresentAttentuation_difference); - RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresentAttentuation = %d\n", priv->CCKPresentAttentuation); - - if (priv->CCKPresentAttentuation_difference <= -12||priv->CCKPresentAttentuation_difference >= 24) - { - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); - write_nic_byte(dev, FW_Busy_Flag, 0); - RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n"); - return; - } - - + write_nic_byte(dev, FW_Busy_Flag, 0); } - write_nic_byte(dev, Pw_Track_Flag, 0); - Avg_TSSI_Meas_from_driver = 0; - for (k = 0;k < 5; k++) - tmp_report[k] = 0; - break; - } - write_nic_byte(dev, FW_Busy_Flag, 0); -} - priv->rtllib->bdynamic_txpower_enable = true; - write_nic_byte(dev, Pw_Track_Flag, 0); + priv->rtllib->bdynamic_txpower_enable = true; + write_nic_byte(dev, Pw_Track_Flag, 0); } -static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) +static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev) { #define ThermalMeterVal 9 struct r8192_priv *priv = rtllib_priv(dev); u32 tmpRegA, TempCCk; u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval; - int i =0, CCKSwingNeedUpdate=0; + int i = 0, CCKSwingNeedUpdate = 0; - if (!priv->btxpower_trackingInit) - { - tmpRegA= rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); - for (i=0; iOFDM_index[0]= (u8)i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n", + if (!priv->btxpower_trackingInit) { + tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); + for (i = 0; i < OFDM_Table_Length; i++) { + if (tmpRegA == OFDMSwingTable[i]) { + priv->OFDM_index[0] = (u8)i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n", rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index[0]); } } TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); - for (i=0 ; iCCK_index =(u8) i; - RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n", - rCCK0_TxFilter1, TempCCk, priv->CCK_index); - break; - } -} + for (i = 0; i < CCK_Table_length; i++) { + if (TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0]) { + priv->CCK_index = (u8) i; + RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x" + " = 0x%x, CCK_index = 0x%x\n", + rCCK0_TxFilter1, TempCCk, + priv->CCK_index); + break; + } + } priv->btxpower_trackingInit = true; return; } tmpRegA = rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, 0x12, 0x078); - RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA); + RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d\n", tmpRegA); if (tmpRegA < 3 || tmpRegA > 13) return; if (tmpRegA >= 12) tmpRegA = 12; - RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA); + RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d\n", tmpRegA); priv->ThermalMeter[0] = ThermalMeterVal; priv->ThermalMeter[1] = ThermalMeterVal; - if (priv->ThermalMeter[0] >= (u8)tmpRegA) - { - tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA); + if (priv->ThermalMeter[0] >= (u8)tmpRegA) { + tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0] - + (u8)tmpRegA); tmpCCK40Mindex = tmpCCK20Mindex - 6; if (tmpOFDMindex >= OFDM_Table_Length) tmpOFDMindex = OFDM_Table_Length-1; @@ -831,9 +786,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) tmpCCK20Mindex = CCK_Table_length-1; if (tmpCCK40Mindex >= CCK_Table_length) tmpCCK40Mindex = CCK_Table_length-1; - } - else - { + } else { tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]); if (tmpval >= 6) tmpOFDMindex = tmpCCK20Mindex = 0; @@ -848,43 +801,42 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev) priv->Record_CCK_20Mindex = tmpCCK20Mindex; priv->Record_CCK_40Mindex = tmpCCK40Mindex; - RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n", - priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); + RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40" + "Mindex = %d / %d.\n", + priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex); - if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) - { + if (priv->rtllib->current_network.channel == 14 && + !priv->bcck_in_ch14) { priv->bcck_in_ch14 = true; CCKSwingNeedUpdate = 1; - } - else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) - { + } else if (priv->rtllib->current_network.channel != 14 && + priv->bcck_in_ch14) { priv->bcck_in_ch14 = false; CCKSwingNeedUpdate = 1; } - if (priv->CCK_index != tmpCCKindex) -{ + if (priv->CCK_index != tmpCCKindex) { priv->CCK_index = tmpCCKindex; CCKSwingNeedUpdate = 1; } if (CCKSwingNeedUpdate) - { dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); - } - if (priv->OFDM_index[0] != tmpOFDMindex) - { + if (priv->OFDM_index[0] != tmpOFDMindex) { priv->OFDM_index[0] = tmpOFDMindex; - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index[0]]); + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, + OFDMSwingTable[priv->OFDM_index[0]]); RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n", - priv->OFDM_index[0], OFDMSwingTable[priv->OFDM_index[0]]); + priv->OFDM_index[0], + OFDMSwingTable[priv->OFDM_index[0]]); } priv->txpower_count = 0; } void dm_txpower_trackingcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,txpower_tracking_wq); + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, txpower_tracking_wq); struct net_device *dev = priv->rtllib->dev; if (priv->IC_Cut >= IC_VersionCut_D) @@ -898,80 +850,80 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); - priv->txbbgain_table[0].txbb_iq_amplifygain = 12; - priv->txbbgain_table[0].txbbgain_value=0x7f8001fe; - priv->txbbgain_table[1].txbb_iq_amplifygain = 11; - priv->txbbgain_table[1].txbbgain_value=0x788001e2; - priv->txbbgain_table[2].txbb_iq_amplifygain = 10; - priv->txbbgain_table[2].txbbgain_value=0x71c001c7; - priv->txbbgain_table[3].txbb_iq_amplifygain = 9; - priv->txbbgain_table[3].txbbgain_value=0x6b8001ae; - priv->txbbgain_table[4].txbb_iq_amplifygain = 8; - priv->txbbgain_table[4].txbbgain_value=0x65400195; - priv->txbbgain_table[5].txbb_iq_amplifygain = 7; - priv->txbbgain_table[5].txbbgain_value=0x5fc0017f; - priv->txbbgain_table[6].txbb_iq_amplifygain = 6; - priv->txbbgain_table[6].txbbgain_value=0x5a400169; - priv->txbbgain_table[7].txbb_iq_amplifygain = 5; - priv->txbbgain_table[7].txbbgain_value=0x55400155; - priv->txbbgain_table[8].txbb_iq_amplifygain = 4; - priv->txbbgain_table[8].txbbgain_value=0x50800142; - priv->txbbgain_table[9].txbb_iq_amplifygain = 3; - priv->txbbgain_table[9].txbbgain_value=0x4c000130; - priv->txbbgain_table[10].txbb_iq_amplifygain = 2; - priv->txbbgain_table[10].txbbgain_value=0x47c0011f; - priv->txbbgain_table[11].txbb_iq_amplifygain = 1; - priv->txbbgain_table[11].txbbgain_value=0x43c0010f; - priv->txbbgain_table[12].txbb_iq_amplifygain = 0; - priv->txbbgain_table[12].txbbgain_value=0x40000100; - priv->txbbgain_table[13].txbb_iq_amplifygain = -1; - priv->txbbgain_table[13].txbbgain_value=0x3c8000f2; - priv->txbbgain_table[14].txbb_iq_amplifygain = -2; - priv->txbbgain_table[14].txbbgain_value=0x390000e4; - priv->txbbgain_table[15].txbb_iq_amplifygain = -3; - priv->txbbgain_table[15].txbbgain_value=0x35c000d7; - priv->txbbgain_table[16].txbb_iq_amplifygain = -4; - priv->txbbgain_table[16].txbbgain_value=0x32c000cb; - priv->txbbgain_table[17].txbb_iq_amplifygain = -5; - priv->txbbgain_table[17].txbbgain_value=0x300000c0; - priv->txbbgain_table[18].txbb_iq_amplifygain = -6; - priv->txbbgain_table[18].txbbgain_value=0x2d4000b5; - priv->txbbgain_table[19].txbb_iq_amplifygain = -7; - priv->txbbgain_table[19].txbbgain_value=0x2ac000ab; - priv->txbbgain_table[20].txbb_iq_amplifygain = -8; - priv->txbbgain_table[20].txbbgain_value=0x288000a2; - priv->txbbgain_table[21].txbb_iq_amplifygain = -9; - priv->txbbgain_table[21].txbbgain_value=0x26000098; - priv->txbbgain_table[22].txbb_iq_amplifygain = -10; - priv->txbbgain_table[22].txbbgain_value=0x24000090; - priv->txbbgain_table[23].txbb_iq_amplifygain = -11; - priv->txbbgain_table[23].txbbgain_value=0x22000088; - priv->txbbgain_table[24].txbb_iq_amplifygain = -12; - priv->txbbgain_table[24].txbbgain_value=0x20000080; - priv->txbbgain_table[25].txbb_iq_amplifygain = -13; - priv->txbbgain_table[25].txbbgain_value=0x1a00006c; - priv->txbbgain_table[26].txbb_iq_amplifygain = -14; - priv->txbbgain_table[26].txbbgain_value=0x1c800072; - priv->txbbgain_table[27].txbb_iq_amplifygain = -15; - priv->txbbgain_table[27].txbbgain_value=0x18000060; - priv->txbbgain_table[28].txbb_iq_amplifygain = -16; - priv->txbbgain_table[28].txbbgain_value=0x19800066; - priv->txbbgain_table[29].txbb_iq_amplifygain = -17; - priv->txbbgain_table[29].txbbgain_value=0x15800056; - priv->txbbgain_table[30].txbb_iq_amplifygain = -18; - priv->txbbgain_table[30].txbbgain_value=0x26c0005b; - priv->txbbgain_table[31].txbb_iq_amplifygain = -19; - priv->txbbgain_table[31].txbbgain_value=0x14400051; - priv->txbbgain_table[32].txbb_iq_amplifygain = -20; - priv->txbbgain_table[32].txbbgain_value=0x24400051; - priv->txbbgain_table[33].txbb_iq_amplifygain = -21; - priv->txbbgain_table[33].txbbgain_value=0x1300004c; - priv->txbbgain_table[34].txbb_iq_amplifygain = -22; - priv->txbbgain_table[34].txbbgain_value=0x12000048; - priv->txbbgain_table[35].txbb_iq_amplifygain = -23; - priv->txbbgain_table[35].txbbgain_value=0x11000044; - priv->txbbgain_table[36].txbb_iq_amplifygain = -24; - priv->txbbgain_table[36].txbbgain_value=0x10000040; + priv->txbbgain_table[0].txbb_iq_amplifygain = 12; + priv->txbbgain_table[0].txbbgain_value = 0x7f8001fe; + priv->txbbgain_table[1].txbb_iq_amplifygain = 11; + priv->txbbgain_table[1].txbbgain_value = 0x788001e2; + priv->txbbgain_table[2].txbb_iq_amplifygain = 10; + priv->txbbgain_table[2].txbbgain_value = 0x71c001c7; + priv->txbbgain_table[3].txbb_iq_amplifygain = 9; + priv->txbbgain_table[3].txbbgain_value = 0x6b8001ae; + priv->txbbgain_table[4].txbb_iq_amplifygain = 8; + priv->txbbgain_table[4].txbbgain_value = 0x65400195; + priv->txbbgain_table[5].txbb_iq_amplifygain = 7; + priv->txbbgain_table[5].txbbgain_value = 0x5fc0017f; + priv->txbbgain_table[6].txbb_iq_amplifygain = 6; + priv->txbbgain_table[6].txbbgain_value = 0x5a400169; + priv->txbbgain_table[7].txbb_iq_amplifygain = 5; + priv->txbbgain_table[7].txbbgain_value = 0x55400155; + priv->txbbgain_table[8].txbb_iq_amplifygain = 4; + priv->txbbgain_table[8].txbbgain_value = 0x50800142; + priv->txbbgain_table[9].txbb_iq_amplifygain = 3; + priv->txbbgain_table[9].txbbgain_value = 0x4c000130; + priv->txbbgain_table[10].txbb_iq_amplifygain = 2; + priv->txbbgain_table[10].txbbgain_value = 0x47c0011f; + priv->txbbgain_table[11].txbb_iq_amplifygain = 1; + priv->txbbgain_table[11].txbbgain_value = 0x43c0010f; + priv->txbbgain_table[12].txbb_iq_amplifygain = 0; + priv->txbbgain_table[12].txbbgain_value = 0x40000100; + priv->txbbgain_table[13].txbb_iq_amplifygain = -1; + priv->txbbgain_table[13].txbbgain_value = 0x3c8000f2; + priv->txbbgain_table[14].txbb_iq_amplifygain = -2; + priv->txbbgain_table[14].txbbgain_value = 0x390000e4; + priv->txbbgain_table[15].txbb_iq_amplifygain = -3; + priv->txbbgain_table[15].txbbgain_value = 0x35c000d7; + priv->txbbgain_table[16].txbb_iq_amplifygain = -4; + priv->txbbgain_table[16].txbbgain_value = 0x32c000cb; + priv->txbbgain_table[17].txbb_iq_amplifygain = -5; + priv->txbbgain_table[17].txbbgain_value = 0x300000c0; + priv->txbbgain_table[18].txbb_iq_amplifygain = -6; + priv->txbbgain_table[18].txbbgain_value = 0x2d4000b5; + priv->txbbgain_table[19].txbb_iq_amplifygain = -7; + priv->txbbgain_table[19].txbbgain_value = 0x2ac000ab; + priv->txbbgain_table[20].txbb_iq_amplifygain = -8; + priv->txbbgain_table[20].txbbgain_value = 0x288000a2; + priv->txbbgain_table[21].txbb_iq_amplifygain = -9; + priv->txbbgain_table[21].txbbgain_value = 0x26000098; + priv->txbbgain_table[22].txbb_iq_amplifygain = -10; + priv->txbbgain_table[22].txbbgain_value = 0x24000090; + priv->txbbgain_table[23].txbb_iq_amplifygain = -11; + priv->txbbgain_table[23].txbbgain_value = 0x22000088; + priv->txbbgain_table[24].txbb_iq_amplifygain = -12; + priv->txbbgain_table[24].txbbgain_value = 0x20000080; + priv->txbbgain_table[25].txbb_iq_amplifygain = -13; + priv->txbbgain_table[25].txbbgain_value = 0x1a00006c; + priv->txbbgain_table[26].txbb_iq_amplifygain = -14; + priv->txbbgain_table[26].txbbgain_value = 0x1c800072; + priv->txbbgain_table[27].txbb_iq_amplifygain = -15; + priv->txbbgain_table[27].txbbgain_value = 0x18000060; + priv->txbbgain_table[28].txbb_iq_amplifygain = -16; + priv->txbbgain_table[28].txbbgain_value = 0x19800066; + priv->txbbgain_table[29].txbb_iq_amplifygain = -17; + priv->txbbgain_table[29].txbbgain_value = 0x15800056; + priv->txbbgain_table[30].txbb_iq_amplifygain = -18; + priv->txbbgain_table[30].txbbgain_value = 0x26c0005b; + priv->txbbgain_table[31].txbb_iq_amplifygain = -19; + priv->txbbgain_table[31].txbbgain_value = 0x14400051; + priv->txbbgain_table[32].txbb_iq_amplifygain = -20; + priv->txbbgain_table[32].txbbgain_value = 0x24400051; + priv->txbbgain_table[33].txbb_iq_amplifygain = -21; + priv->txbbgain_table[33].txbbgain_value = 0x1300004c; + priv->txbbgain_table[34].txbb_iq_amplifygain = -22; + priv->txbbgain_table[34].txbbgain_value = 0x12000048; + priv->txbbgain_table[35].txbb_iq_amplifygain = -23; + priv->txbbgain_table[35].txbbgain_value = 0x11000044; + priv->txbbgain_table[36].txbb_iq_amplifygain = -24; + priv->txbbgain_table[36].txbbgain_value = 0x10000040; priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36; priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35; @@ -1404,7 +1356,8 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) priv->btxpower_tracking = false; priv->txpower_count = 0; priv->btxpower_trackingInit = false; - RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", priv->btxpower_tracking); + RT_TRACE(COMP_POWER_TRACKING, "pMgntInfo->bTXPowerTracking = %d\n", + priv->btxpower_tracking); } void dm_initialize_txpower_tracking(struct net_device *dev) @@ -1419,55 +1372,53 @@ void dm_initialize_txpower_tracking(struct net_device *dev) static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 tx_power_track_counter = 0; - RT_TRACE(COMP_POWER_TRACKING,"%s()\n",__func__); - if (read_nic_byte(dev, 0x11e) ==1) + static u32 tx_power_track_counter; + RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__); + if (read_nic_byte(dev, 0x11e) == 1) return; if (!priv->btxpower_tracking) return; tx_power_track_counter++; - if (tx_power_track_counter >= 180) - { - queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); - tx_power_track_counter =0; - } + if (tx_power_track_counter >= 180) { + queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0); + tx_power_track_counter = 0; + } } static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 TM_Trigger=0; + static u8 TM_Trigger; u8 TxPowerCheckCnt = 0; if (IS_HARDWARE_TYPE_8192SE(dev)) TxPowerCheckCnt = 5; else TxPowerCheckCnt = 2; - if (!priv->btxpower_tracking){ - return; - } else { - if (priv->txpower_count <= TxPowerCheckCnt) { + if (!priv->btxpower_tracking) { + return; + } else { + if (priv->txpower_count <= TxPowerCheckCnt) { priv->txpower_count++; return; } } - if (!TM_Trigger) - { - { + if (!TM_Trigger) { + { rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d); rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4f); - } + } TM_Trigger = 1; return; } else { - printk("===============>Schedule TxPowerTrackingWorkItem\n"); + printk(KERN_INFO "===============>Schedule TxPowerTrackingWorkItem\n"); - queue_delayed_work_rsl(priv->priv_wq,&priv->txpower_tracking_wq,0); + queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0); TM_Trigger = 0; } @@ -1488,40 +1439,38 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14) u32 TempVal; struct r8192_priv *priv = rtllib_priv(dev); TempVal = 0; - if (!bInCH14){ - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + if (!bInCH14) { + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); - } - else - { - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); + } else { + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16 )+ - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); - rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal); + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+ + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24)); + rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); TempVal = 0; - TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + - (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; + TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] + + (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ; - rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal); + rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); } @@ -1533,8 +1482,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH struct r8192_priv *priv = rtllib_priv(dev); TempVal = 0; - if (!bInCH14) - { + if (!bInCH14) { TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ; rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); @@ -1543,7 +1491,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH TempVal = 0; TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", @@ -1555,9 +1503,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, TempVal); - } - else - { + } else { TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ; @@ -1567,7 +1513,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH TempVal = 0; TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) + - (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+ + (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+ (CCKSwingTable_Ch14[priv->CCK_index][5]<<24); rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", @@ -1577,7 +1523,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ; rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); - RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n", + RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort, TempVal); } } @@ -1601,17 +1547,26 @@ static void dm_txpower_reset_recovery( struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n"); - rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv->rfa_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",priv->CCKPresentAttentuation); - dm_cck_txpower_adjust(dev,priv->bcck_in_ch14); + rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n", + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n", + priv->rfa_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n", + priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n", + priv->CCKPresentAttentuation); + dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); - rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv->rfc_txpowertrackingindex); - RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); + rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n", + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n", + priv->rfc_txpowertrackingindex); + RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n", + priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain); } @@ -1619,30 +1574,25 @@ extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u32 reg_ratr = priv->rate_adaptive.last_ratr; + u32 ratr_value; - if (IS_NIC_DOWN(priv)){ + if (IS_NIC_DOWN(priv)) { RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n"); return; } if (priv->rate_adaptive.rate_adaptive_disabled) return; - if ( !(priv->rtllib->mode==WIRELESS_MODE_N_24G || - priv->rtllib->mode==WIRELESS_MODE_N_5G)) - return; - { - u32 ratr_value; - ratr_value = reg_ratr; - if (priv->rf_type == RF_1T2R) - { - ratr_value &=~ (RATE_ALL_OFDM_2SS); - } - write_nic_dword(dev, RATR0, ratr_value); - write_nic_byte(dev, UFWP, 1); - } - if (priv->btxpower_trackingInit && priv->btxpower_tracking){ + if (!(priv->rtllib->mode == WIRELESS_MODE_N_24G || + priv->rtllib->mode == WIRELESS_MODE_N_5G)) + return; + ratr_value = reg_ratr; + if (priv->rf_type == RF_1T2R) + ratr_value &= ~(RATE_ALL_OFDM_2SS); + write_nic_dword(dev, RATR0, ratr_value); + write_nic_byte(dev, UFWP, 1); + if (priv->btxpower_trackingInit && priv->btxpower_tracking) dm_txpower_reset_recovery(dev); - } dm_bb_initialgain_restore(dev); @@ -1664,11 +1614,11 @@ static void dm_bb_initialgain_restore(struct net_device *dev) bit_mask = bMaskByte2; rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", priv->initgain_backup.cca); rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); } @@ -1701,93 +1651,66 @@ static void dm_bb_initialgain_backup(struct net_device *dev) bit_mask = bMaskByte2; priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1); - RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", priv->initgain_backup.xaagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", priv->initgain_backup.xbagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", priv->initgain_backup.xcagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", priv->initgain_backup.xdagccore1); + RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", priv->initgain_backup.cca); } extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value) + u32 dm_type, u32 dm_value) { - if (dm_type == DIG_TYPE_THRESH_HIGH) - { + if (dm_type == DIG_TYPE_THRESH_HIGH) { dm_digtable.rssi_high_thresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_LOW) - { + } else if (dm_type == DIG_TYPE_THRESH_LOW) { dm_digtable.rssi_low_thresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) - { + } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { dm_digtable.rssi_high_power_highthresh = dm_value; - } - else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) - { + } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) { dm_digtable.rssi_high_power_highthresh = dm_value; - } - else if (dm_type == DIG_TYPE_ENABLE) - { + } else if (dm_type == DIG_TYPE_ENABLE) { dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = true; - } - else if (dm_type == DIG_TYPE_DISABLE) - { + } else if (dm_type == DIG_TYPE_DISABLE) { dm_digtable.dig_state = DM_STA_DIG_MAX; dm_digtable.dig_enable_flag = false; - } - else if (dm_type == DIG_TYPE_DBG_MODE) - { + } else if (dm_type == DIG_TYPE_DBG_MODE) { if (dm_value >= DM_DBG_MAX) dm_value = DM_DBG_OFF; dm_digtable.dbg_mode = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RSSI) - { + } else if (dm_type == DIG_TYPE_RSSI) { if (dm_value > 100) dm_value = 30; dm_digtable.rssi_val = (long)dm_value; - } - else if (dm_type == DIG_TYPE_ALGORITHM) - { + } else if (dm_type == DIG_TYPE_ALGORITHM) { if (dm_value >= DIG_ALGO_MAX) dm_value = DIG_ALGO_BY_FALSE_ALARM; if (dm_digtable.dig_algorithm != (u8)dm_value) dm_digtable.dig_algorithm_switch = 1; dm_digtable.dig_algorithm = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_BACKOFF) - { + } else if (dm_type == DIG_TYPE_BACKOFF) { if (dm_value > 30) dm_value = 30; dm_digtable.backoff_val = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RX_GAIN_MIN) - { + } else if (dm_type == DIG_TYPE_RX_GAIN_MIN) { if (dm_value == 0) dm_value = 0x1; dm_digtable.rx_gain_range_min = (u8)dm_value; - } - else if (dm_type == DIG_TYPE_RX_GAIN_MAX) - { + } else if (dm_type == DIG_TYPE_RX_GAIN_MAX) { if (dm_value > 0x50) dm_value = 0x50; dm_digtable.rx_gain_range_max = (u8)dm_value; } } -extern void -dm_change_fsync_setting( - struct net_device *dev, +extern void dm_change_fsync_setting(struct net_device *dev, s32 DM_Type, s32 DM_Value) { struct r8192_priv *priv = rtllib_priv(dev); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; priv->framesyncMonitor = (u8)DM_Value; @@ -1804,68 +1727,47 @@ dm_change_rxpath_selection_setting( struct rate_adaptive *pRA = (struct rate_adaptive *)&(priv->rate_adaptive); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; DM_RxPathSelTable.Enable = (u8)DM_Value; - } - else if (DM_Type == 1) - { + } else if (DM_Type == 1) { if (DM_Value > 1) DM_Value = 1; DM_RxPathSelTable.DbgMode = (u8)DM_Value; - } - else if (DM_Type == 2) - { + } else if (DM_Type == 2) { if (DM_Value > 40) DM_Value = 40; DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; - } - else if (DM_Type == 3) - { + } else if (DM_Type == 3) { if (DM_Value > 25) DM_Value = 25; DM_RxPathSelTable.diff_TH = (u8)DM_Value; - } - else if (DM_Type == 4) - { + } else if (DM_Type == 4) { if (DM_Value >= CCK_Rx_Version_MAX) DM_Value = CCK_Rx_Version_1; - DM_RxPathSelTable.cck_method= (u8)DM_Value; - } - else if (DM_Type == 10) - { + DM_RxPathSelTable.cck_method = (u8)DM_Value; + } else if (DM_Type == 10) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; - } - else if (DM_Type == 11) - { + } else if (DM_Type == 11) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; - } - else if (DM_Type == 12) - { + } else if (DM_Type == 12) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; - } - else if (DM_Type == 13) - { + } else if (DM_Type == 13) { if (DM_Value > 100) DM_Value = 50; DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; - } - else if (DM_Type == 20) - { + } else if (DM_Type == 20) { if (DM_Value > 1) DM_Value = 1; pRA->ping_rssi_enable = (u8)DM_Value; - } - else if (DM_Type == 21) - { + } else if (DM_Type == 21) { if (DM_Value > 30) DM_Value = 30; pRA->ping_rssi_thresh_for_ra = DM_Value; @@ -1919,16 +1821,16 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) struct false_alarm_stats *FalseAlmCnt = &(priv->FalseAlmCnt); ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); + ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter3, bMaskDWord); FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; ret_value = rtl8192_QueryBBReg(dev, 0xc64, bMaskDWord); FalseAlmCnt->Cnt_Cck_fail = (ret_value&0xffff); @@ -1939,7 +1841,8 @@ void dm_FalseAlarmCounterStatistics(struct net_device *dev) FalseAlmCnt->Cnt_Cck_fail); RT_TRACE(COMP_DIG, "Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d, Cnt_all = %d\n", - FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail , FalseAlmCnt->Cnt_all); + FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail, + FalseAlmCnt->Cnt_all); } static void dm_ctrl_initgain_byrssi(struct net_device *dev) @@ -1979,16 +1882,15 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi( { struct r8192_priv *priv = rtllib_priv(dev); u8 i; - static u8 fw_dig=0; + static u8 fw_dig; if (dm_digtable.dig_enable_flag == false) return; if (dm_digtable.dig_algorithm_switch) fw_dig = 0; - if (fw_dig <= 3) - { - for (i=0; i<3; i++) + if (fw_dig <= 3) { + for (i = 0; i < 3; i++) rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); fw_dig++; dm_digtable.dig_state = DM_STA_DIG_OFF; @@ -2015,16 +1917,15 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 reset_cnt = 0; + static u32 reset_cnt; u8 i; if (dm_digtable.dig_enable_flag == false) return; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { dm_digtable.dig_state = DM_STA_DIG_MAX; - for (i=0; i<3; i++) + for (i = 0; i < 3; i++) rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); dm_digtable.dig_algorithm_switch = 0; } @@ -2034,20 +1935,13 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) && (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh)) - { return; - } - if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) - { + if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) { if (dm_digtable.dig_state == DM_STA_DIG_OFF && (priv->reset_count == reset_cnt)) - { return; - } else - { reset_cnt = priv->reset_count; - } dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX; dm_digtable.dig_state = DM_STA_DIG_OFF; @@ -2060,30 +1954,23 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x17); if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); write_nic_byte(dev, 0xa0a, 0x08); return; - } - if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) ) - { + if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh)) { u8 reset_flag = 0; if (dm_digtable.dig_state == DM_STA_DIG_ON && - (priv->reset_count == reset_cnt)) - { + (priv->reset_count == reset_cnt)) { dm_ctrl_initgain_byrssi_highpwr(dev); return; - } - else - { + } else { if (priv->reset_count != reset_cnt) reset_flag = 1; @@ -2092,54 +1979,41 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( dm_digtable.dig_state = DM_STA_DIG_ON; - if (reset_flag == 1) - { + if (reset_flag == 1) { write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x2c); write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x2c); - } - else - { - write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20); - write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20); + } else { + write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20); + write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20); } if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); write_nic_byte(dev, 0xa0a, 0xcd); - rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); - } - dm_ctrl_initgain_byrssi_highpwr(dev); - } -static void dm_ctrl_initgain_byrssi_highpwr( - struct net_device * dev) +static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u32 reset_cnt_highpwr = 0; + static u32 reset_cnt_highpwr; if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) && (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh)) - { return; - } - if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) - { + if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) { if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON && (priv->reset_count == reset_cnt_highpwr)) return; @@ -2147,84 +2021,64 @@ static void dm_ctrl_initgain_byrssi_highpwr( dm_digtable.dig_highpwr_state = DM_STA_DIG_ON; if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - } else write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); - } - else - { - if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF&& + } else { + if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF && (priv->reset_count == reset_cnt_highpwr)) return; else dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF; if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh && - priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) - { + priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) { if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); else write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); } } - reset_cnt_highpwr = priv->reset_count; - } - -static void dm_initial_gain( - struct net_device * dev) +static void dm_initial_gain(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain=0; - static u8 initialized=0, force_write=0; - static u32 reset_cnt=0; + u8 initial_gain = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (rtllib_act_scanning(priv->rtllib,true) == true) - { + if (rtllib_act_scanning(priv->rtllib, true) == true) { force_write = 1; return; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; else dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; - } - else - { + } else { if (dm_digtable.cur_ig_value == 0) dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; else dm_digtable.cur_ig_value = dm_digtable.pre_ig_value; } - } - else - { + } else { dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; dm_digtable.pre_ig_value = 0; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } @@ -2232,82 +2086,70 @@ static void dm_initial_gain( if (dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1)) force_write = 1; - { - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) - || !initialized || force_write) - { - initial_gain = (u8)dm_digtable.cur_ig_value; - write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); - write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); - dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; - initialized = 1; - force_write = 0; - } + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) + || !initialized || force_write) { + initial_gain = (u8)dm_digtable.cur_ig_value; + write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain); + write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain); + dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; + initialized = 1; + force_write = 0; } } void dm_initial_gain_STABeforeConnect( - struct net_device * dev) + struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain=0; - static u8 initialized=0, force_write=0; + u8 initial_gain = 0; + static u8 initialized, force_write; RT_TRACE(COMP_DIG, "PreSTAConnectState = %x, CurSTAConnectState = %x\n", dm_digtable.PreSTAConnectState, dm_digtable.CurSTAConnectState); if ((dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) || - (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) - { + (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) { + if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) { if (priv->rtllib->eRFPowerState != eRfOn) return; - if (dm_digtable.Backoff_Enable_Flag == true) - { - if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) - { - if ((dm_digtable.backoff_val -6) < dm_digtable.BackoffVal_range_min) + if (dm_digtable.Backoff_Enable_Flag == true) { + if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) { + if ((dm_digtable.backoff_val - 6) < dm_digtable.BackoffVal_range_min) dm_digtable.backoff_val = dm_digtable.BackoffVal_range_min; else dm_digtable.backoff_val -= 6; - } - else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) - { - if ((dm_digtable.backoff_val+6) > dm_digtable.BackoffVal_range_max) + } else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) { + if ((dm_digtable.backoff_val + 6) > dm_digtable.BackoffVal_range_max) dm_digtable.backoff_val = dm_digtable.BackoffVal_range_max; else - dm_digtable.backoff_val +=6; + dm_digtable.backoff_val += 6; } - } - else - dm_digtable.backoff_val =DM_DIG_BACKOFF; + } else + dm_digtable.backoff_val = DM_DIG_BACKOFF; if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; else - dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val; + dm_digtable.cur_ig_value = dm_digtable.rssi_val + 10 - + dm_digtable.backoff_val; if (priv->FalseAlmCnt.Cnt_all > 10000) - dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value>0x33)?dm_digtable.cur_ig_value:0x33; + dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value > 0x33) ? + dm_digtable.cur_ig_value : 0x33; if (priv->FalseAlmCnt.Cnt_all > 16000) dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - } - else - { + } else { return; } - } - else - { + } else { dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_ENABLE); @@ -2317,44 +2159,44 @@ void dm_initial_gain_STABeforeConnect( return; } - if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bMaskByte0)) + if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, + rOFDM0_XAAGCCore1, bMaskByte0)) force_write = 1; - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || !initialized || force_write) - { + if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || + !initialized || force_write) { priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_DISABLE); initial_gain = (u8)dm_digtable.cur_ig_value; - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, initial_gain); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, initial_gain); + rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, + initial_gain); + rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, + initial_gain); dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; initialized = 1; force_write = 0; } - RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, backoff_val = %d\n", - dm_digtable.cur_ig_value, dm_digtable.pre_ig_value, dm_digtable.backoff_val); + RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, " + "backoff_val = %d\n", dm_digtable.cur_ig_value, + dm_digtable.pre_ig_value, dm_digtable.backoff_val); } -static void dm_pd_th( - struct net_device * dev) +static void dm_pd_th(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 initialized=0, force_write=0; - static u32 reset_cnt = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh) dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER; else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) @@ -2364,123 +2206,88 @@ static void dm_pd_th( dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER; else dm_digtable.curpd_thstate = dm_digtable.prepd_thstate; - } - else - { + } else { dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; } - } - else - { + } else { dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } - { - if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || - (initialized<=3) || force_write) - { - if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); - } - else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); - } - else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) - { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) - { - write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); - } - else - write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); - } - dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; - if (initialized <= 3) - initialized++; - force_write = 0; + if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || + (initialized <= 3) || force_write) { + if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x42); + } else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x44); + } else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) { + if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10); + else + write_nic_byte(dev, rOFDM0_RxDetector1, 0x43); } + dm_digtable.prepd_thstate = dm_digtable.curpd_thstate; + if (initialized <= 3) + initialized++; + force_write = 0; } } -static void dm_cs_ratio( - struct net_device * dev) +static void dm_cs_ratio(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - static u8 initialized=0,force_write=0; - static u32 reset_cnt = 0; + static u8 initialized, force_write; + static u32 reset_cnt; - if (dm_digtable.dig_algorithm_switch) - { + if (dm_digtable.dig_algorithm_switch) { initialized = 0; reset_cnt = 0; } - if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) - { - if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) - { + if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) { + if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) { if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)) dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; - else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) ) + else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh)) dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER; else dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state; - } - else - { + } else { dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; } - } - else - { + } else { dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER; } - if (priv->reset_count != reset_cnt) - { + if (priv->reset_count != reset_cnt) { force_write = 1; reset_cnt = priv->reset_count; } - { - if ((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || - !initialized || force_write) - { - if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) - { - write_nic_byte(dev, 0xa0a, 0x08); - } - else if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) - { - write_nic_byte(dev, 0xa0a, 0xcd); - } - dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; - initialized = 1; - force_write = 0; - } + if ((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) || + !initialized || force_write) { + if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER) + write_nic_byte(dev, 0xa0a, 0x08); + else if (dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER) + write_nic_byte(dev, 0xa0a, 0xcd); + dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state; + initialized = 1; + force_write = 0; } } -extern void dm_init_edca_turbo(struct net_device * dev) +extern void dm_init_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2489,98 +2296,89 @@ extern void dm_init_edca_turbo(struct net_device * dev) priv->bis_cur_rdlstate = false; } -static void dm_check_edca_turbo( - struct net_device * dev) +static void dm_check_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; if (priv->rtllib->iw_mode == IW_MODE_ADHOC) - { goto dm_CheckEdcaTurbo_EXIT; - } if (priv->rtllib->state != RTLLIB_LINKED) - { goto dm_CheckEdcaTurbo_EXIT; - } if (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) - { goto dm_CheckEdcaTurbo_EXIT; - } { - u8* peername[11] = {"unknown", "realtek_90", "realtek_92se","broadcom", "ralink", "atheros", "cisco", "marvell", "92u_softap", "self_softap"}; - static int wb_tmp = 0; - if (wb_tmp == 0){ - printk("%s():iot peer is %s, bssid:"MAC_FMT"\n",__func__,peername[pHTInfo->IOTPeer], MAC_ARG(priv->rtllib->current_network.bssid)); + u8 *peername[11] = { + "unknown", "realtek_90", "realtek_92se", "broadcom", + "ralink", "atheros", "cisco", "marvell", "92u_softap", + "self_softap" + }; + static int wb_tmp; + if (wb_tmp == 0) { + printk(KERN_INFO "%s():iot peer is %s, bssid:" + MAC_FMT"\n", __func__, + peername[pHTInfo->IOTPeer], + MAC_ARG(priv->rtllib->current_network.bssid)); wb_tmp = 1; } } - if (!priv->rtllib->bis_any_nonbepkts) - { + if (!priv->rtllib->bis_any_nonbepkts) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) - { - if (curTxOkCnt > 4*curRxOkCnt) - { - if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); + if (pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX) { + if (curTxOkCnt > 4*curRxOkCnt) { + if (priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_UL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = false; } - } - else - { - if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { + } else { + if (!priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL_GMode[pHTInfo->IOTPeer]); else - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL[pHTInfo->IOTPeer]); priv->bis_cur_rdlstate = true; } } priv->bcurrent_turbo_EDCA = true; - } - else - { - if (curRxOkCnt > 4*curTxOkCnt) - { - if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - if (priv->rtllib->mode == WIRELESS_MODE_G) - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL_GMode[pHTInfo->IOTPeer]); - else - write_nic_dword(dev, EDCAPARA_BE, edca_setting_DL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = true; - } - } - else - { - if (priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) - { - write_nic_dword(dev, EDCAPARA_BE, edca_setting_UL[pHTInfo->IOTPeer]); - priv->bis_cur_rdlstate = false; + } else { + if (curRxOkCnt > 4*curTxOkCnt) { + if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) { + if (priv->rtllib->mode == WIRELESS_MODE_G) + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL_GMode[pHTInfo->IOTPeer]); + else + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_DL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = true; + } + } else { + if (priv->bis_cur_rdlstate || + !priv->bcurrent_turbo_EDCA) { + write_nic_dword(dev, EDCAPARA_BE, + edca_setting_UL[pHTInfo->IOTPeer]); + priv->bis_cur_rdlstate = false; + } + } + priv->bcurrent_turbo_EDCA = true; } - - priv->bcurrent_turbo_EDCA = true; - } - } - else - { - if (priv->bcurrent_turbo_EDCA) - { - - u8 tmp = AC0_BE; - priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8*)(&tmp) ); + } else { + if (priv->bcurrent_turbo_EDCA) { + u8 tmp = AC0_BE; + priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&tmp)); priv->bcurrent_turbo_EDCA = false; } } @@ -2592,25 +2390,23 @@ dm_CheckEdcaTurbo_EXIT: lastRxOkCnt = priv->stats.rxbytesunicast; } -extern void DM_CTSToSelfSetting(struct net_device * dev,u32 DM_Type, u32 DM_Value) +extern void DM_CTSToSelfSetting(struct net_device *dev, u32 DM_Type, + u32 DM_Value) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - if (DM_Type == 0) - { + if (DM_Type == 0) { if (DM_Value > 1) DM_Value = 1; priv->rtllib->bCTSToSelfEnable = (bool)DM_Value; - } - else if (DM_Type == 1) - { + } else if (DM_Type == 1) { if (DM_Value >= 50) DM_Value = 50; priv->rtllib->CTSToSelfTH = (u8)DM_Value; } } -static void dm_init_ctstoself(struct net_device * dev) +static void dm_init_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); @@ -2622,28 +2418,22 @@ static void dm_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; - static unsigned long lastTxOkCnt = 0; - static unsigned long lastRxOkCnt = 0; - unsigned long curTxOkCnt = 0; - unsigned long curRxOkCnt = 0; + static unsigned long lastTxOkCnt; + static unsigned long lastRxOkCnt; + unsigned long curTxOkCnt = 0; + unsigned long curRxOkCnt = 0; - if (priv->rtllib->bCTSToSelfEnable != true) - { + if (priv->rtllib->bCTSToSelfEnable != true) { pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; return; } - if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { + if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; if (curRxOkCnt > 4*curTxOkCnt) - { pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; - } else - { pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF; - } lastTxOkCnt = priv->stats.txbytesunicast; lastRxOkCnt = priv->stats.rxbytesunicast; @@ -2651,8 +2441,7 @@ static void dm_ctstoself(struct net_device *dev) } -static void -dm_Init_WA_Broadcom_IOT(struct net_device * dev) +static void dm_Init_WA_Broadcom_IOT(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo; @@ -2665,78 +2454,65 @@ static void dm_check_pbc_gpio(struct net_device *dev) { } - extern void dm_CheckRfCtrlGPIO(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,gpio_change_rf_wq); - struct net_device *dev = priv->rtllib->dev; + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, gpio_change_rf_wq); + struct net_device *dev = priv->rtllib->dev; u8 tmp1byte; enum rt_rf_power_state eRfPowerStateToSet; bool bActuallySet = false; - char *argv[3]; static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; - bActuallySet=false; + bActuallySet = false; if ((priv->up_first_time == 1) || (priv->being_init_adapter)) - { return; - } - if (priv->bfirst_after_down){ + if (priv->bfirst_after_down) { priv->bfirst_after_down = 1; return; } + tmp1byte = read_nic_byte(dev, GPI); + eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; - { - tmp1byte = read_nic_byte(dev,GPI); - - eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff; - - if ( (priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) - { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); - printk("gpiochangeRF - HW Radio ON\n"); - priv->bHwRadioOff = false; - bActuallySet = true; - } - else if ( (priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) - { - RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); - printk("gpiochangeRF - HW Radio OFF\n"); - priv->bHwRadioOff = true; - bActuallySet = true; - } - - if (bActuallySet) - { - mdelay(1000); - priv->bHwRfOffAction = 1; - MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW,true); - { - if (priv->bHwRadioOff == true) - argv[1] = "RFOFF"; - else - argv[1] = "RFON"; - - argv[0] = RadioPowerPath; - argv[2] = NULL; - call_usermodehelper(RadioPowerPath,argv,envp,1); - } - - } + if ((priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n"); + printk(KERN_INFO "gpiochangeRF - HW Radio ON\n"); + priv->bHwRadioOff = false; + bActuallySet = true; + } else if ((priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) { + RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n"); + printk(KERN_INFO "gpiochangeRF - HW Radio OFF\n"); + priv->bHwRadioOff = true; + bActuallySet = true; } + if (bActuallySet) { + mdelay(1000); + priv->bHwRfOffAction = 1; + MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW, true); + if (priv->bHwRadioOff == true) + argv[1] = "RFOFF"; + else + argv[1] = "RFON"; + + argv[0] = RadioPowerPath; + argv[2] = NULL; + call_usermodehelper(RadioPowerPath, argv, envp, 1); + } } void dm_rf_pathcheck_workitemcallback(void *data) { - struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv,rfpath_check_wq); - struct net_device *dev =priv->rtllib->dev; + struct r8192_priv *priv = container_of_dwork_rsl(data, + struct r8192_priv, + rfpath_check_wq); + struct net_device *dev = priv->rtllib->dev; u8 rfpath = 0, i; rfpath = read_nic_byte(dev, 0xc04); @@ -2753,10 +2529,11 @@ void dm_rf_pathcheck_workitemcallback(void *data) dm_rxpath_sel_byrssi(dev); } -static void dm_init_rxpath_selection(struct net_device * dev) +static void dm_init_rxpath_selection(struct net_device *dev) { u8 i; struct r8192_priv *priv = rtllib_priv(dev); + DM_RxPathSelTable.Enable = 1; DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; @@ -2766,119 +2543,92 @@ static void dm_init_rxpath_selection(struct net_device * dev) DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; DM_RxPathSelTable.DbgMode = DM_DBG_OFF; DM_RxPathSelTable.disabledRF = 0; - for (i=0; i<4; i++) - { + for (i = 0; i < 4; i++) { DM_RxPathSelTable.rf_rssi[i] = 50; DM_RxPathSelTable.cck_pwdb_sta[i] = -64; DM_RxPathSelTable.rf_enable_rssi_th[i] = 100; } } -static void dm_rxpath_sel_byrssi(struct net_device * dev) +#define PWDB_IN_RANGE ((cur_cck_pwdb < tmp_cck_max_pwdb) && \ + (cur_cck_pwdb > tmp_cck_sec_pwdb)) + +static void dm_rxpath_sel_byrssi(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - u8 i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0; - u8 tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0; - u8 cck_default_Rx=0x2; - u8 cck_optional_Rx=0x3; - long tmp_cck_max_pwdb=0, tmp_cck_min_pwdb=0, tmp_cck_sec_pwdb=0; - u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0; - u8 cur_rf_rssi; - long cur_cck_pwdb; - static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0; - u8 update_cck_rx_path; + u8 i, max_rssi_index = 0, min_rssi_index = 0; + u8 sec_rssi_index = 0, rf_num = 0; + u8 tmp_max_rssi = 0, tmp_min_rssi = 0, tmp_sec_rssi = 0; + u8 cck_default_Rx = 0x2; + u8 cck_optional_Rx = 0x3; + long tmp_cck_max_pwdb = 0, tmp_cck_min_pwdb = 0, tmp_cck_sec_pwdb = 0; + u8 cck_rx_ver2_max_index = 0, cck_rx_ver2_min_index = 0; + u8 cck_rx_ver2_sec_index = 0; + u8 cur_rf_rssi; + long cur_cck_pwdb; + static u8 disabled_rf_cnt, cck_Rx_Path_initialized; + u8 update_cck_rx_path; if (priv->rf_type != RF_2T4R) return; - if (!cck_Rx_Path_initialized) - { + if (!cck_Rx_Path_initialized) { DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf); cck_Rx_Path_initialized = 1; } DM_RxPathSelTable.disabledRF = 0xf; - DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(dev, 0xc04)); + DM_RxPathSelTable.disabledRF &= ~(read_nic_byte(dev, 0xc04)); if (priv->rtllib->mode == WIRELESS_MODE_B) - { DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; - } - for (i=0; istats.rx_rssi_percentage[i]; - if (priv->brfpath_rxenable[i]) - { + if (priv->brfpath_rxenable[i]) { rf_num++; cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; - if (rf_num == 1) - { + if (rf_num == 1) { max_rssi_index = min_rssi_index = sec_rssi_index = i; tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi; - } - else if (rf_num == 2) - { - if (cur_rf_rssi >= tmp_max_rssi) - { + } else if (rf_num == 2) { + if (cur_rf_rssi >= tmp_max_rssi) { tmp_max_rssi = cur_rf_rssi; max_rssi_index = i; - } - else - { + } else { tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi; sec_rssi_index = min_rssi_index = i; } - } - else - { - if (cur_rf_rssi > tmp_max_rssi) - { + } else { + if (cur_rf_rssi > tmp_max_rssi) { tmp_sec_rssi = tmp_max_rssi; sec_rssi_index = max_rssi_index; tmp_max_rssi = cur_rf_rssi; max_rssi_index = i; - } - else if (cur_rf_rssi == tmp_max_rssi) - { + } else if (cur_rf_rssi == tmp_max_rssi) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; - } - else if ((cur_rf_rssi < tmp_max_rssi) &&(cur_rf_rssi > tmp_sec_rssi)) - { + } else if ((cur_rf_rssi < tmp_max_rssi) && + (cur_rf_rssi > tmp_sec_rssi)) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; - } - else if (cur_rf_rssi == tmp_sec_rssi) - { - if (tmp_sec_rssi == tmp_min_rssi) - { + } else if (cur_rf_rssi == tmp_sec_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_sec_rssi = cur_rf_rssi; sec_rssi_index = i; } - else - { - } - } - else if ((cur_rf_rssi < tmp_sec_rssi) && (cur_rf_rssi > tmp_min_rssi)) - { - } - else if (cur_rf_rssi == tmp_min_rssi) - { - if (tmp_sec_rssi == tmp_min_rssi) - { + } else if ((cur_rf_rssi < tmp_sec_rssi) && + (cur_rf_rssi > tmp_min_rssi)) { + ; + } else if (cur_rf_rssi == tmp_min_rssi) { + if (tmp_sec_rssi == tmp_min_rssi) { tmp_min_rssi = cur_rf_rssi; min_rssi_index = i; } - else - { - } - } - else if (cur_rf_rssi < tmp_min_rssi) - { + } else if (cur_rf_rssi < tmp_min_rssi) { tmp_min_rssi = cur_rf_rssi; min_rssi_index = i; } @@ -2887,79 +2637,63 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) } rf_num = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { - for (i=0; ibrfpath_rxenable[i]) - { + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { + for (i = 0; i < RF90_PATH_MAX; i++) { + if (priv->brfpath_rxenable[i]) { rf_num++; - cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i]; + cur_cck_pwdb = + DM_RxPathSelTable.cck_pwdb_sta[i]; - if (rf_num == 1) - { - cck_rx_ver2_max_index = cck_rx_ver2_min_index = cck_rx_ver2_sec_index = i; - tmp_cck_max_pwdb = tmp_cck_min_pwdb = tmp_cck_sec_pwdb = cur_cck_pwdb; - } - else if (rf_num == 2) - { - if (cur_cck_pwdb >= tmp_cck_max_pwdb) - { + if (rf_num == 1) { + cck_rx_ver2_max_index = i; + cck_rx_ver2_min_index = i; + cck_rx_ver2_sec_index = i; + tmp_cck_max_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + tmp_cck_sec_pwdb = cur_cck_pwdb; + } else if (rf_num == 2) { + if (cur_cck_pwdb >= tmp_cck_max_pwdb) { tmp_cck_max_pwdb = cur_cck_pwdb; cck_rx_ver2_max_index = i; + } else { + tmp_cck_sec_pwdb = cur_cck_pwdb; + tmp_cck_min_pwdb = cur_cck_pwdb; + cck_rx_ver2_sec_index = i; + cck_rx_ver2_min_index = i; } - else - { - tmp_cck_sec_pwdb = tmp_cck_min_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_min_index = i; - } - } - else - { - if (cur_cck_pwdb > tmp_cck_max_pwdb) - { - tmp_cck_sec_pwdb = tmp_cck_max_pwdb; - cck_rx_ver2_sec_index = cck_rx_ver2_max_index; + } else { + if (cur_cck_pwdb > tmp_cck_max_pwdb) { + tmp_cck_sec_pwdb = + tmp_cck_max_pwdb; + cck_rx_ver2_sec_index = + cck_rx_ver2_max_index; tmp_cck_max_pwdb = cur_cck_pwdb; cck_rx_ver2_max_index = i; - } - else if (cur_cck_pwdb == tmp_cck_max_pwdb) - { + } else if (cur_cck_pwdb == + tmp_cck_max_pwdb) { tmp_cck_sec_pwdb = cur_cck_pwdb; cck_rx_ver2_sec_index = i; - } - else if ((cur_cck_pwdb < tmp_cck_max_pwdb) &&(cur_cck_pwdb > tmp_cck_sec_pwdb)) - { + } else if (PWDB_IN_RANGE) { tmp_cck_sec_pwdb = cur_cck_pwdb; cck_rx_ver2_sec_index = i; - } - else if (cur_cck_pwdb == tmp_cck_sec_pwdb) - { - if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { - tmp_cck_sec_pwdb = cur_cck_pwdb; - cck_rx_ver2_sec_index = i; + } else if (cur_cck_pwdb == + tmp_cck_sec_pwdb) { + if (tmp_cck_sec_pwdb == + tmp_cck_min_pwdb) { + tmp_cck_sec_pwdb = + cur_cck_pwdb; + cck_rx_ver2_sec_index = + i; } - else - { - } - } - else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && (cur_cck_pwdb > tmp_cck_min_pwdb)) - { - } - else if (cur_cck_pwdb == tmp_cck_min_pwdb) - { - if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) - { + } else if ((cur_cck_pwdb < tmp_cck_sec_pwdb) && + (cur_cck_pwdb > tmp_cck_min_pwdb)) { + ; + } else if (cur_cck_pwdb == tmp_cck_min_pwdb) { + if (tmp_cck_sec_pwdb == tmp_cck_min_pwdb) { tmp_cck_min_pwdb = cur_cck_pwdb; cck_rx_ver2_min_index = i; } - else - { - } - } - else if (cur_cck_pwdb < tmp_cck_min_pwdb) - { + } else if (cur_cck_pwdb < tmp_cck_min_pwdb) { tmp_cck_min_pwdb = cur_cck_pwdb; cck_rx_ver2_min_index = i; } @@ -2969,27 +2703,26 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) } } - update_cck_rx_path = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) - { + if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { cck_default_Rx = cck_rx_ver2_max_index; cck_optional_Rx = cck_rx_ver2_sec_index; if (tmp_cck_max_pwdb != -64) update_cck_rx_path = 1; } - if (tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2) - { - if ((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH) - { - DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<= + DM_RxPathSelTable.diff_TH) { + DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = + tmp_max_rssi+5; + rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, + 0x1<>i) & 0x1) - { - if (tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i]) - { - rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<>i) & 0x1) { + if (tmp_max_rssi >= + DM_RxPathSelTable.rf_enable_rssi_th[i]) { + rtl8192_setBBreg(dev, + rOFDM0_TRxPathEnable, 0x1 << i, + 0x1); + rtl8192_setBBreg(dev, + rOFDM1_TRxPathEnable, + 0x1 << i, 0x1); + DM_RxPathSelTable.rf_enable_rssi_th[i] + = 100; disabled_rf_cnt--; } } @@ -3024,11 +2760,12 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev) static void dm_check_rx_path_selection(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - queue_delayed_work_rsl(priv->priv_wq,&priv->rfpath_check_wq,0); + + queue_delayed_work_rsl(priv->priv_wq, &priv->rfpath_check_wq, 0); } -static void dm_init_fsync (struct net_device *dev) +static void dm_init_fsync(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -3037,13 +2774,14 @@ static void dm_init_fsync (struct net_device *dev) priv->rtllib->fsync_rssi_threshold = 30; priv->rtllib->bfsync_enable = false; priv->rtllib->fsync_multiple_timeinterval = 3; - priv->rtllib->fsync_firstdiff_ratethreshold= 100; - priv->rtllib->fsync_seconddiff_ratethreshold= 200; + priv->rtllib->fsync_firstdiff_ratethreshold = 100; + priv->rtllib->fsync_seconddiff_ratethreshold = 200; priv->rtllib->fsync_state = Default_Fsync; priv->framesyncMonitor = 1; init_timer(&priv->fsync_timer); - setup_timer(&priv->fsync_timer, dm_fsync_timer_callback,(unsigned long) dev); + setup_timer(&priv->fsync_timer, dm_fsync_timer_callback, + (unsigned long) dev); } @@ -3057,95 +2795,91 @@ extern void dm_fsync_timer_callback(unsigned long data) { struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = rtllib_priv((struct net_device *)data); - u32 rate_index, rate_count = 0, rate_count_diff=0; + u32 rate_index, rate_count = 0, rate_count_diff = 0; bool bSwitchFromCountDiff = false; bool bDoubleTimeInterval = false; - if ( priv->rtllib->state == RTLLIB_LINKED && - priv->rtllib->bfsync_enable && - (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) - { + if (priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->bfsync_enable && + (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) { u32 rate_bitmap; - for (rate_index = 0; rate_index <= 27; rate_index++) - { + for (rate_index = 0; rate_index <= 27; rate_index++) { rate_bitmap = 1 << rate_index; if (priv->rtllib->fsync_rate_bitmap & rate_bitmap) - rate_count+= priv->stats.received_rate_histogram[1][rate_index]; + rate_count += + priv->stats.received_rate_histogram[1] + [rate_index]; } if (rate_count < priv->rate_record) - rate_count_diff = 0xffffffff - rate_count + priv->rate_record; + rate_count_diff = 0xffffffff - rate_count + + priv->rate_record; else rate_count_diff = rate_count - priv->rate_record; - if (rate_count_diff < priv->rateCountDiffRecord) - { + if (rate_count_diff < priv->rateCountDiffRecord) { - u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff; - if (DiffNum >= priv->rtllib->fsync_seconddiff_ratethreshold) + u32 DiffNum = priv->rateCountDiffRecord - + rate_count_diff; + if (DiffNum >= + priv->rtllib->fsync_seconddiff_ratethreshold) priv->ContiuneDiffCount++; else priv->ContiuneDiffCount = 0; - if (priv->ContiuneDiffCount >=2) - { + if (priv->ContiuneDiffCount >= 2) { bSwitchFromCountDiff = true; priv->ContiuneDiffCount = 0; } - } - else - { + } else { priv->ContiuneDiffCount = 0; } - if (rate_count_diff <= priv->rtllib->fsync_firstdiff_ratethreshold) - { + if (rate_count_diff <= + priv->rtllib->fsync_firstdiff_ratethreshold) { bSwitchFromCountDiff = true; priv->ContiuneDiffCount = 0; } priv->rate_record = rate_count; priv->rateCountDiffRecord = rate_count_diff; - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); - if (priv->undecorated_smoothed_pwdb > priv->rtllib->fsync_rssi_threshold && bSwitchFromCountDiff) - { + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rate" + "Countdiff %d bSwitchFsync %d\n", priv->rate_record, + rate_count, rate_count_diff, priv->bswitch_fsync); + if (priv->undecorated_smoothed_pwdb > + priv->rtllib->fsync_rssi_threshold && + bSwitchFromCountDiff) { bDoubleTimeInterval = true; priv->bswitch_fsync = !priv->bswitch_fsync; - if (priv->bswitch_fsync) - { - write_nic_byte(dev,0xC36, 0x1c); + if (priv->bswitch_fsync) { + write_nic_byte(dev, 0xC36, 0x1c); write_nic_byte(dev, 0xC3e, 0x90); - } - else - { + } else { write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); } - } - else if (priv->undecorated_smoothed_pwdb <= priv->rtllib->fsync_rssi_threshold) - { - if (priv->bswitch_fsync) - { + } else if (priv->undecorated_smoothed_pwdb <= + priv->rtllib->fsync_rssi_threshold) { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); } } - if (bDoubleTimeInterval){ + if (bDoubleTimeInterval) { if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval*priv->rtllib->fsync_multiple_timeinterval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval * + priv->rtllib->fsync_multiple_timeinterval); add_timer(&priv->fsync_timer); - } - else{ + } else { if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval); add_timer(&priv->fsync_timer); } - } - else - { - if (priv->bswitch_fsync) - { + } else { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); write_nic_byte(dev, 0xC3e, 0x96); @@ -3154,7 +2888,9 @@ extern void dm_fsync_timer_callback(unsigned long data) write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); } RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount); - RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync); + RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d " + "bSwitchFsync %d\n", priv->rate_record, rate_count, + rate_count_diff, priv->bswitch_fsync); } static void dm_StartHWFsync(struct net_device *dev) @@ -3163,7 +2899,8 @@ static void dm_StartHWFsync(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf); - priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, + (u8 *)(&rf_timing)); write_nic_byte(dev, 0xc3b, 0x41); } @@ -3171,9 +2908,10 @@ static void dm_EndHWFsync(struct net_device *dev) { u8 rf_timing = 0xaa; struct r8192_priv *priv = rtllib_priv(dev); - RT_TRACE(COMP_HALDM,"%s\n", __func__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); - priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8*)(&rf_timing)); + priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8 *) + (&rf_timing)); write_nic_byte(dev, 0xc3b, 0x49); } @@ -3184,8 +2922,7 @@ static void dm_EndSWFsync(struct net_device *dev) RT_TRACE(COMP_HALDM, "%s\n", __func__); del_timer_sync(&(priv->fsync_timer)); - if (priv->bswitch_fsync) - { + if (priv->bswitch_fsync) { priv->bswitch_fsync = false; write_nic_byte(dev, 0xC36, 0x5c); @@ -3203,31 +2940,30 @@ static void dm_StartSWFsync(struct net_device *dev) u32 rateIndex; u32 rateBitmap; - RT_TRACE(COMP_HALDM,"%s\n", __func__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); priv->rate_record = 0; priv->ContiuneDiffCount = 0; priv->rateCountDiffRecord = 0; priv->bswitch_fsync = false; - if (priv->rtllib->mode == WIRELESS_MODE_N_24G) - { - priv->rtllib->fsync_firstdiff_ratethreshold= 600; + if (priv->rtllib->mode == WIRELESS_MODE_N_24G) { + priv->rtllib->fsync_firstdiff_ratethreshold = 600; priv->rtllib->fsync_seconddiff_ratethreshold = 0xffff; - } - else - { - priv->rtllib->fsync_firstdiff_ratethreshold= 200; + } else { + priv->rtllib->fsync_firstdiff_ratethreshold = 200; priv->rtllib->fsync_seconddiff_ratethreshold = 200; } - for (rateIndex = 0; rateIndex <= 27; rateIndex++) - { + for (rateIndex = 0; rateIndex <= 27; rateIndex++) { rateBitmap = 1 << rateIndex; - if (priv->rtllib->fsync_rate_bitmap & rateBitmap) - priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex]; + if (priv->rtllib->fsync_rate_bitmap & rateBitmap) + priv->rate_record += + priv->stats.received_rate_histogram[1] + [rateIndex]; } if (timer_pending(&priv->fsync_timer)) del_timer_sync(&priv->fsync_timer); - priv->fsync_timer.expires = jiffies + MSECS(priv->rtllib->fsync_time_interval); + priv->fsync_timer.expires = jiffies + + MSECS(priv->rtllib->fsync_time_interval); add_timer(&priv->fsync_timer); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd); @@ -3236,61 +2972,59 @@ static void dm_StartSWFsync(struct net_device *dev) void dm_check_fsync(struct net_device *dev) { -#define RegC38_Default 0 +#define RegC38_Default 0 #define RegC38_NonFsync_Other_AP 1 #define RegC38_Fsync_AP_BCM 2 struct r8192_priv *priv = rtllib_priv(dev); - static u8 reg_c38_State=RegC38_Default; - static u32 reset_cnt=0; + static u8 reg_c38_State = RegC38_Default; + static u32 reset_cnt; - RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->rtllib->fsync_rssi_threshold, priv->rtllib->fsync_time_interval, priv->rtllib->fsync_multiple_timeinterval); - RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap, priv->rtllib->fsync_firstdiff_ratethreshold, priv->rtllib->fsync_seconddiff_ratethreshold); + RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval " + "%d\n", priv->rtllib->fsync_rssi_threshold, + priv->rtllib->fsync_time_interval, + priv->rtllib->fsync_multiple_timeinterval); + RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d Second" + "DiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap, + priv->rtllib->fsync_firstdiff_ratethreshold, + priv->rtllib->fsync_seconddiff_ratethreshold); - if ( priv->rtllib->state == RTLLIB_LINKED && - priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) - { - if (priv->rtllib->bfsync_enable == 0) - { - switch (priv->rtllib->fsync_state) - { - case Default_Fsync: - dm_StartHWFsync(dev); - priv->rtllib->fsync_state = HW_Fsync; - break; - case SW_Fsync: - dm_EndSWFsync(dev); - dm_StartHWFsync(dev); - priv->rtllib->fsync_state = HW_Fsync; - break; - case HW_Fsync: - default: - break; + if (priv->rtllib->state == RTLLIB_LINKED && + priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { + if (priv->rtllib->bfsync_enable == 0) { + switch (priv->rtllib->fsync_state) { + case Default_Fsync: + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case SW_Fsync: + dm_EndSWFsync(dev); + dm_StartHWFsync(dev); + priv->rtllib->fsync_state = HW_Fsync; + break; + case HW_Fsync: + default: + break; } - } - else - { - switch (priv->rtllib->fsync_state) - { - case Default_Fsync: - dm_StartSWFsync(dev); - priv->rtllib->fsync_state = SW_Fsync; - break; - case HW_Fsync: - dm_EndHWFsync(dev); - dm_StartSWFsync(dev); - priv->rtllib->fsync_state = SW_Fsync; - break; - case SW_Fsync: - default: - break; + } else { + switch (priv->rtllib->fsync_state) { + case Default_Fsync: + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case HW_Fsync: + dm_EndHWFsync(dev); + dm_StartSWFsync(dev); + priv->rtllib->fsync_state = SW_Fsync; + break; + case SW_Fsync: + default: + break; } } - if (priv->framesyncMonitor) - { - if (reg_c38_State != RegC38_Fsync_AP_BCM) - { - write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); + if (priv->framesyncMonitor) { + if (reg_c38_State != RegC38_Fsync_AP_BCM) { + write_nic_byte(dev, rOFDM0_RxDetector3, 0x95); reg_c38_State = RegC38_Fsync_AP_BCM; } @@ -3312,21 +3046,30 @@ void dm_check_fsync(struct net_device *dev) if (priv->framesyncMonitor) { if (priv->rtllib->state == RTLLIB_LINKED) { - if (priv->undecorated_smoothed_pwdb <= RegC38_TH) { - if (reg_c38_State != RegC38_NonFsync_Other_AP) { - write_nic_byte(dev, rOFDM0_RxDetector3, 0x90); + if (priv->undecorated_smoothed_pwdb <= + RegC38_TH) { + if (reg_c38_State != + RegC38_NonFsync_Other_AP) { + write_nic_byte(dev, + rOFDM0_RxDetector3, + 0x90); - reg_c38_State = RegC38_NonFsync_Other_AP; + reg_c38_State = + RegC38_NonFsync_Other_AP; } - } else if (priv->undecorated_smoothed_pwdb >= (RegC38_TH+5)) { + } else if (priv->undecorated_smoothed_pwdb >= + (RegC38_TH+5)) { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, + rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } } else { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } @@ -3334,13 +3077,15 @@ void dm_check_fsync(struct net_device *dev) } if (priv->framesyncMonitor) { if (priv->reset_count != reset_cnt) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; reset_cnt = priv->reset_count; } } else { if (reg_c38_State) { - write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync); + write_nic_byte(dev, rOFDM0_RxDetector3, + priv->framesync); reg_c38_State = RegC38_Default; } } @@ -3353,15 +3098,18 @@ extern void dm_shadow_init(struct net_device *dev) for (page = 0; page < 5; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page * 256); for (page = 8; page < 11; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page * 256); for (page = 12; page < 15; page++) for (offset = 0; offset < 256; offset++) - dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256); + dm_shadow[page][offset] = read_nic_byte(dev, + offset+page*256); } @@ -3380,93 +3128,75 @@ static void dm_init_dynamic_txpower(struct net_device *dev) static void dm_dynamic_txpower(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - unsigned int txhipower_threshhold=0; - unsigned int txlowpower_threshold=0; - if (priv->rtllib->bdynamic_txpower_enable != true) - { + unsigned int txhipower_threshhold = 0; + unsigned int txlowpower_threshold = 0; + if (priv->rtllib->bdynamic_txpower_enable != true) { priv->bDynamicTxHighPower = false; priv->bDynamicTxLowPower = false; return; } - if ((priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) && (priv->rtllib->mode == IEEE_G)){ + if ((priv->rtllib->pHTInfo->IOTPeer == HT_IOT_PEER_ATHEROS) && + (priv->rtllib->mode == IEEE_G)) { txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH; txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW; - } - else - { + } else { txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH; txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; } + RT_TRACE(COMP_TXAGC, "priv->undecorated_smoothed_pwdb = %ld\n", + priv->undecorated_smoothed_pwdb); - RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb); - - if (priv->rtllib->state == RTLLIB_LINKED) - { - if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) - { + if (priv->rtllib->state == RTLLIB_LINKED) { + if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) { priv->bDynamicTxHighPower = true; priv->bDynamicTxLowPower = false; - } - else - { - if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true) - { + } else { + if (priv->undecorated_smoothed_pwdb < + txlowpower_threshold && + priv->bDynamicTxHighPower == true) priv->bDynamicTxHighPower = false; - } if (priv->undecorated_smoothed_pwdb < 35) - { priv->bDynamicTxLowPower = true; - } else if (priv->undecorated_smoothed_pwdb >= 40) - { priv->bDynamicTxLowPower = false; - } } - } - else - { + } else { priv->bDynamicTxHighPower = false; priv->bDynamicTxLowPower = false; } - if ( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) || - (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) ) - { - RT_TRACE(COMP_TXAGC,"SetTxPowerLevel8190() channel = %d \n" , priv->rtllib->current_network.channel); + if ((priv->bDynamicTxHighPower != priv->bLastDTPFlag_High) || + (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low)) { + RT_TRACE(COMP_TXAGC, "SetTxPowerLevel8190() channel = %d\n", + priv->rtllib->current_network.channel); - rtl8192_phy_setTxPower(dev,priv->rtllib->current_network.channel); + rtl8192_phy_setTxPower(dev, + priv->rtllib->current_network.channel); } priv->bLastDTPFlag_High = priv->bDynamicTxHighPower; priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower; } -static void dm_check_txrateandretrycount(struct net_device * dev) +static void dm_check_txrateandretrycount(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg); + ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, + Current_Tx_Rate_Reg); - ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg); + ieee->softmac_stats.last_packet_rate = read_nic_byte(dev, + Initial_Tx_Rate_Reg); - ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg); + ieee->softmac_stats.txretrycount = read_nic_dword(dev, + Tx_Retry_Count_Reg); } static void dm_send_rssi_tofw(struct net_device *dev) { - struct dcmd_txcmd tx_cmd; struct r8192_priv *priv = rtllib_priv(dev); write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb); - return; - tx_cmd.Op = TXCMD_SET_RX_RSSI; - tx_cmd.Length = 4; - tx_cmd.Value = priv->undecorated_smoothed_pwdb; - - cmpk_message_handle_tx(dev, (u8*)&tx_cmd, - DESC_PACKET_TYPE_INIT, sizeof(struct dcmd_txcmd)); } - -/*---------------------------Define function prototype------------------------*/ diff --git a/drivers/staging/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl_dm.h index 64fa749cfb4d..ab44a9a6927c 100644 --- a/drivers/staging/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl_dm.h @@ -59,15 +59,15 @@ #define WAIotTHVal 25 -#define E_FOR_TX_POWER_TRACK 300 +#define E_FOR_TX_POWER_TRACK 300 #define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 #define TX_POWER_NEAR_FIELD_THRESH_LOW 62 -#define TX_POWER_ATHEROAP_THRESH_HIGH 78 +#define TX_POWER_ATHEROAP_THRESH_HIGH 78 #define TX_POWER_ATHEROAP_THRESH_LOW 72 -#define Current_Tx_Rate_Reg 0x1e0 -#define Initial_Tx_Rate_Reg 0x1e1 -#define Tx_Retry_Count_Reg 0x1ac +#define Current_Tx_Rate_Reg 0x1e0 +#define Initial_Tx_Rate_Reg 0x1e1 +#define Tx_Retry_Count_Reg 0x1ac #define RegC38_TH 20 #define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 @@ -227,7 +227,7 @@ struct drx_path_sel { enum dm_cck_rx_path_method { CCK_Rx_Version_1 = 0, - CCK_Rx_Version_2= 1, + CCK_Rx_Version_2 = 1, CCK_Rx_Version_MAX }; @@ -256,7 +256,10 @@ extern u8 test_flag; /*------------------------Export Marco Definition---------------------------*/ -#define DM_APInitGainChangeNotify(Event) {dm_digtable.CurAPConnectState = Event;} +#define DM_APInitGainChangeNotify(Event) \ + { \ + dm_digtable.CurAPConnectState = Event; \ + } /*------------------------Export Marco Definition---------------------------*/ @@ -271,19 +274,19 @@ extern void hal_dm_watchdog(struct net_device *dev); extern void init_rate_adaptive(struct net_device *dev); extern void dm_txpower_trackingcallback(void *data); -extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14); +extern void dm_cck_txpower_adjust(struct net_device *dev, bool binch14); extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, - u32 dm_value); + u32 dm_type, + u32 dm_value); extern void DM_ChangeFsyncSetting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value); + s32 DM_Type, + s32 DM_Value); extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, - u32 force_value); + u32 force_type, + u32 force_value); extern void dm_init_edca_turbo(struct net_device *dev); extern void dm_rf_operation_test_callback(unsigned long data); extern void dm_rf_pathcheck_workitemcallback(void *data); @@ -291,11 +294,31 @@ extern void dm_fsync_timer_callback(unsigned long data); extern void dm_check_fsync(struct net_device *dev); extern void dm_shadow_init(struct net_device *dev); extern void dm_initialize_txpower_tracking(struct net_device *dev); - +extern void dm_CheckRfCtrlGPIO(void *data); +extern void dm_InitRateAdaptiveMask(struct net_device *dev); +extern void init_hal_dm(struct net_device *dev); +extern void deinit_hal_dm(struct net_device *dev); +extern void hal_dm_watchdog(struct net_device *dev); +extern void init_rate_adaptive(struct net_device *dev); +extern void dm_txpower_trackingcallback(void *data); +extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); +extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); +extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, + u32 dm_value); +extern void DM_ChangeFsyncSetting(struct net_device *dev, + s32 DM_Type, + s32 DM_Value); +extern void dm_force_tx_fw_info(struct net_device *dev, + u32 force_type, + u32 force_value); +extern void dm_init_edca_turbo(struct net_device *dev); +extern void dm_rf_operation_test_callback(unsigned long data); +extern void dm_rf_pathcheck_workitemcallback(void *data); +extern void dm_fsync_timer_callback(unsigned long data); +extern void dm_check_fsync(struct net_device *dev); +extern void dm_shadow_init(struct net_device *dev); +extern void dm_initialize_txpower_tracking(struct net_device *dev); extern void dm_CheckRfCtrlGPIO(void *data); -extern void dm_InitRateAdaptiveMask(struct net_device * dev); - #endif /*__R8192UDM_H__ */ - -/* End of r8192U_dm.h */ From fbf76538736ddc5c4f23a67e2f9278c3921c393c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 7 Aug 2011 16:42:31 -0500 Subject: [PATCH 13/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XI Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_eeprom.c | 69 ++++++----- drivers/staging/rtl8192e/rtl_eeprom.h | 2 +- drivers/staging/rtl8192e/rtllib_crypt.c | 6 +- drivers/staging/rtl8192e/rtllib_crypt.h | 8 +- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 30 +++-- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 118 ++++++++++--------- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 74 ++++++------ drivers/staging/rtl8192e/rtllib_endianfree.h | 66 ++++++----- 8 files changed, 194 insertions(+), 179 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl_eeprom.c index 14a8c1d13e2e..df72a6007d08 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl_eeprom.c @@ -29,11 +29,11 @@ void eprom_cs(struct net_device *dev, short bit) { if (bit) write_nic_byte(dev, EPROM_CMD, - (1<epromtype==EEPROM_93C56){ - addr_str[7]=addr & 1; - addr_str[6]=addr & (1<<1); - addr_str[5]=addr & (1<<2); - addr_str[4]=addr & (1<<3); - addr_str[3]=addr & (1<<4); - addr_str[2]=addr & (1<<5); - addr_str[1]=addr & (1<<6); - addr_str[0]=addr & (1<<7); - addr_len=8; - }else{ - addr_str[5]=addr & 1; - addr_str[4]=addr & (1<<1); - addr_str[3]=addr & (1<<2); - addr_str[2]=addr & (1<<3); - addr_str[1]=addr & (1<<4); - addr_str[0]=addr & (1<<5); - addr_len=6; + if (priv->epromtype == EEPROM_93C56) { + addr_str[7] = addr & 1; + addr_str[6] = addr & (1<<1); + addr_str[5] = addr & (1<<2); + addr_str[4] = addr & (1<<3); + addr_str[3] = addr & (1<<4); + addr_str[2] = addr & (1<<5); + addr_str[1] = addr & (1<<6); + addr_str[0] = addr & (1<<7); + addr_len = 8; + } else { + addr_str[5] = addr & 1; + addr_str[4] = addr & (1<<1); + addr_str[3] = addr & (1<<2); + addr_str[2] = addr & (1<<3); + addr_str[1] = addr & (1<<4); + addr_str[0] = addr & (1<<5); + addr_len = 6; } eprom_cs(dev, 1); eprom_ck_cycle(dev); @@ -127,7 +126,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) eprom_w(dev, 0); - for (i = 0; i < 16; i++){ + for (i = 0; i < 16; i++) { eprom_ck_cycle(dev); ret |= (eprom_r(dev)<<(15-i)); } diff --git a/drivers/staging/rtl8192e/rtl_eeprom.h b/drivers/staging/rtl8192e/rtl_eeprom.h index f765efbf8092..9452e1683a72 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.h +++ b/drivers/staging/rtl8192e/rtl_eeprom.h @@ -26,4 +26,4 @@ #define EPROM_DELAY 10 -u32 eprom_read(struct net_device *dev,u32 addr); +u32 eprom_read(struct net_device *dev, u32 addr); diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c b/drivers/staging/rtl8192e/rtllib_crypt.c index 225d28a77548..acda37b81848 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.c +++ b/drivers/staging/rtl8192e/rtllib_crypt.c @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include "rtllib.h" @@ -152,7 +152,7 @@ int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops) } -struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name) +struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name) { unsigned long flags; struct list_head *ptr; diff --git a/drivers/staging/rtl8192e/rtllib_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h index b01410550c43..49b90b73ed9c 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt.h +++ b/drivers/staging/rtl8192e/rtllib_crypt.h @@ -61,8 +61,8 @@ struct rtllib_crypto_ops { /* maximum number of bytes added by encryption; encrypt buf is * allocated with extra_prefix_len bytes, copy of in_buf, and * extra_postfix_len; encrypt need not use all this space, but - * the result must start at the beginning of the struct buffer and correct - * length must be returned */ + * the result must start at the beginning of the struct buffer and + * correct length must be returned */ int extra_prefix_len, extra_postfix_len; struct module *owner; @@ -77,9 +77,9 @@ struct rtllib_crypt_data { int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops); int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops); -struct rtllib_crypto_ops * rtllib_get_crypto_ops(const char *name); +struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name); void rtllib_crypt_deinit_entries(struct rtllib_device *, int); void rtllib_crypt_deinit_handler(unsigned long); void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee, - struct rtllib_crypt_data **crypt); + struct rtllib_crypt_data **crypt); #endif diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 9e640c24b89b..306d6ff707af 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include "rtllib.h" @@ -56,10 +56,10 @@ struct rtllib_ccmp_data { void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { - crypto_cipher_encrypt_one((void*)tfm, ct, pt); + crypto_cipher_encrypt_one((void *)tfm, ct, pt); } -static void * rtllib_ccmp_init(int key_idx) +static void *rtllib_ccmp_init(int key_idx) { struct rtllib_ccmp_data *priv; @@ -69,7 +69,7 @@ static void * rtllib_ccmp_init(int key_idx) memset(priv, 0, sizeof(*priv)); priv->key_idx = key_idx; - priv->tfm = (void*)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tfm)) { printk(KERN_DEBUG "rtllib_crypt_ccmp: could not allocate " "crypto API aes\n"); @@ -81,7 +81,7 @@ static void * rtllib_ccmp_init(int key_idx) fail: if (priv) { if (priv->tfm) - crypto_free_cipher((void*)priv->tfm); + crypto_free_cipher((void *)priv->tfm); kfree(priv); } @@ -93,7 +93,7 @@ static void rtllib_ccmp_deinit(void *priv) { struct rtllib_ccmp_data *_priv = priv; if (_priv && _priv->tfm) - crypto_free_cipher((void*)_priv->tfm); + crypto_free_cipher((void *)_priv->tfm); kfree(priv); } @@ -124,7 +124,7 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, /* qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x08)); - */ + */ qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x80)); aad_len = 22; @@ -192,7 +192,8 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int data_len, i; u8 *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); if (skb_headroom(skb) < CCMP_HDR_LEN || skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len) @@ -232,7 +233,8 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) mic = skb_put(skb, CCMP_MIC_LEN); - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); + ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, + b0, b, s0); blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; last = data_len % AES_BLOCK_LEN; @@ -262,7 +264,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) struct rtllib_ccmp_data *key = priv; u8 keyidx, *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); u8 pn[6]; if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) { @@ -308,7 +311,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return -4; } if (!tcb_desc->bHwSec) { - size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN; + size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - + CCMP_MIC_LEN; u8 *mic = skb->data + skb->len - CCMP_MIC_LEN; u8 *b0 = key->rx_b0; u8 *b = key->rx_b; @@ -376,7 +380,7 @@ static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv) data->rx_pn[4] = seq[1]; data->rx_pn[5] = seq[0]; } - crypto_cipher_setkey((void*)data->tfm, data->key, CCMP_TK_LEN); + crypto_cipher_setkey((void *)data->tfm, data->key, CCMP_TK_LEN); } else if (len == 0) data->key_set = 0; else @@ -410,7 +414,7 @@ static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv) } -static char * rtllib_ccmp_print_stats(char *p, void *priv) +static char *rtllib_ccmp_print_stats(char *p, void *priv) { struct rtllib_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index 89da28de571e..c4e490e57ad3 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -18,15 +18,13 @@ #include #include #include -#include -#include "rtllib.h" - - +#include #include #include - #include +#include "rtllib.h" + struct rtllib_tkip_data { #define TKIP_KEY_LEN 32 u8 key[TKIP_KEY_LEN]; @@ -39,7 +37,7 @@ struct rtllib_tkip_data { u32 rx_iv32; u16 rx_iv16; - bool initialized; + bool initialized; u16 rx_ttak[5]; int rx_phase1_done; u32 rx_iv32_new; @@ -58,7 +56,7 @@ struct rtllib_tkip_data { u8 rx_hdr[16], tx_hdr[16]; }; -static void * rtllib_tkip_init(int key_idx) +static void *rtllib_tkip_init(int key_idx) { struct rtllib_tkip_data *priv; @@ -181,8 +179,7 @@ static inline u16 Mk16_le(u16 *v) } -static const u16 Sbox[256] = -{ +static const u16 Sbox[256] = { 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, @@ -303,7 +300,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int len; u8 *pos; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; u8 rc4key[16], *icv; @@ -322,7 +320,8 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->tx_iv32); tkey->tx_phase1_done = 1; } - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); + tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, + tkey->tx_iv16); } else tkey->tx_phase1_done = 1; @@ -360,7 +359,7 @@ static int rtllib_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); - ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); + ret = crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); } tkey->tx_iv16++; @@ -384,7 +383,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 iv32; u16 iv16; struct rtllib_hdr_4addr *hdr; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; u8 rc4key[16]; u8 icv[4]; @@ -422,23 +422,25 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24); pos += 8; - if (!tcb_desc->bHwSec || (skb->cb[0] == 1)) - { + if (!tcb_desc->bHwSec || (skb->cb[0] == 1)) { if ((iv32 < tkey->rx_iv32 || - (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16))&&tkey->initialized) { + (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) && + tkey->initialized) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT - " previous TSC %08x%04x received TSC " - "%08x%04x\n", MAC_ARG(hdr->addr2), - tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); + printk(KERN_DEBUG "TKIP: replay detected: STA=" + MAC_FMT + " previous TSC %08x%04x received TSC " + "%08x%04x\n", MAC_ARG(hdr->addr2), + tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; return -4; } - tkey->initialized = true; + tkey->initialized = true; if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) { - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32); + tkip_mixing_phase1(tkey->rx_ttak, tkey->key, + hdr->addr2, iv32); tkey->rx_phase1_done = 1; } tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16); @@ -451,7 +453,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from " MAC_FMT "\n", + "received packet from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); } return -7; @@ -465,8 +467,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(icv, pos + plen, 4) != 0) { if (iv32 != tkey->rx_iv32) { - /* Previously cached Phase1 result was already lost, so - * it needs to be recalculated for the next packet. */ + /* Previously cached Phase1 result was already + * lost, so it needs to be recalculated for the + * next packet. */ tkey->rx_phase1_done = 0; } if (net_ratelimit()) { @@ -493,26 +496,26 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } -static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, - u8 * data, size_t data_len, u8 * mic) +static int michael_mic(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) { - struct hash_desc desc; - struct scatterlist sg[2]; + struct hash_desc desc; + struct scatterlist sg[2]; - if (tfm_michael == NULL) { - printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); - return -1; - } - sg_init_table(sg, 2); - sg_set_buf(&sg[0], hdr, 16); - sg_set_buf(&sg[1], data, data_len); + if (tfm_michael == NULL) { + printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); + return -1; + } + sg_init_table(sg, 2); + sg_set_buf(&sg[0], hdr, 16); + sg_set_buf(&sg[1], data, data_len); - if (crypto_hash_setkey(tfm_michael, key, 8)) - return -1; + if (crypto_hash_setkey(tfm_michael, key, 8)) + return -1; - desc.tfm = tfm_michael; - desc.flags = 0; - return crypto_hash_digest(&desc, sg, data_len + 16, mic); + desc.tfm = tfm_michael; + desc.flags = 0; + return crypto_hash_digest(&desc, sg, data_len + 16, mic); } static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) @@ -563,12 +566,11 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv) michael_mic_hdr(skb, tkey->tx_hdr); - if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } pos = skb_put(skb, 8); if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) + skb->data + hdr_len, skb->len - 8 - hdr_len, pos)) return -1; return 0; @@ -597,7 +599,8 @@ static void rtllib_michael_mic_failure(struct net_device *dev, } static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, - int hdr_len, void *priv, struct rtllib_device* ieee) + int hdr_len, void *priv, + struct rtllib_device *ieee) { struct rtllib_tkip_data *tkey = priv; u8 mic[8]; @@ -609,29 +612,30 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, return -1; michael_mic_hdr(skb, tkey->rx_hdr); - if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (RTLLIB_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; - if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0)||(ieee->force_mic_error)) { + if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0) || + (ieee->force_mic_error)) { struct rtllib_hdr_4addr *hdr; hdr = (struct rtllib_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " "MSDU from " MAC_FMT " keyidx=%d\n", skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), keyidx); - printk("%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ - ieee->force_mic_error); + printk(KERN_DEBUG "%d, force_mic_error = %d\n", + (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ + ieee->force_mic_error); if (skb->dev) { - printk("skb->dev != NULL\n"); + printk(KERN_INFO "skb->dev != NULL\n"); rtllib_michael_mic_failure(skb->dev, hdr, keyidx); - } + } tkey->dot11RSNAStatsTKIPLocalMICFailures++; - ieee->force_mic_error = false; + ieee->force_mic_error = false; return -1; } @@ -711,7 +715,7 @@ static int rtllib_tkip_get_key(void *key, int len, u8 *seq, void *priv) } -static char * rtllib_tkip_print_stats(char *p, void *priv) +static char *rtllib_tkip_print_stats(char *p, void *priv) { struct rtllib_tkip_data *tkip = priv; p += sprintf(p, "key[%d] alg=TKIP key_set=%d " @@ -751,7 +755,7 @@ static struct rtllib_crypto_ops rtllib_crypt_tkip = { .print_stats = rtllib_tkip_print_stats, .extra_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_postfix_len = 8 + 4, /* MIC + ICV */ - .owner = THIS_MODULE, + .owner = THIS_MODULE, }; @@ -768,5 +772,5 @@ void __exit rtllib_crypto_tkip_exit(void) void rtllib_tkip_null(void) { - return; + return; } diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c index 78a749f5efa9..c59bf10fe780 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "rtllib.h" #include @@ -29,12 +29,12 @@ struct prism2_wep_data { u8 key[WEP_KEY_LEN + 1]; u8 key_len; u8 key_idx; - struct crypto_blkcipher *tx_tfm; - struct crypto_blkcipher *rx_tfm; + struct crypto_blkcipher *tx_tfm; + struct crypto_blkcipher *rx_tfm; }; -static void * prism2_wep_init(int keyidx) +static void *prism2_wep_init(int keyidx) { struct prism2_wep_data *priv; @@ -45,19 +45,19 @@ static void * prism2_wep_init(int keyidx) priv->key_idx = keyidx; priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->tx_tfm)) { - printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->tx_tfm = NULL; - goto fail; - } - priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->rx_tfm)) { - printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->rx_tfm = NULL; - goto fail; - } + if (IS_ERR(priv->tx_tfm)) { + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->tx_tfm = NULL; + goto fail; + } + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(priv->rx_tfm)) { + printk(KERN_DEBUG "rtllib_crypt_wep: could not allocate " + "crypto API arc4\n"); + priv->rx_tfm = NULL; + goto fail; + } /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); @@ -66,12 +66,12 @@ static void * prism2_wep_init(int keyidx) fail: if (priv) { - if (priv->tx_tfm) - crypto_free_blkcipher(priv->tx_tfm); - if (priv->rx_tfm) - crypto_free_blkcipher(priv->rx_tfm); - kfree(priv); - } + if (priv->tx_tfm) + crypto_free_blkcipher(priv->tx_tfm); + if (priv->rx_tfm) + crypto_free_blkcipher(priv->rx_tfm); + kfree(priv); + } return NULL; } @@ -81,11 +81,11 @@ static void prism2_wep_deinit(void *priv) struct prism2_wep_data *_priv = priv; if (_priv) { - if (_priv->tx_tfm) - crypto_free_blkcipher(_priv->tx_tfm); - if (_priv->rx_tfm) - crypto_free_blkcipher(_priv->rx_tfm); - } + if (_priv->tx_tfm) + crypto_free_blkcipher(_priv->tx_tfm); + if (_priv->rx_tfm) + crypto_free_blkcipher(_priv->rx_tfm); + } kfree(priv); } @@ -101,14 +101,17 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, len; u8 key[WEP_KEY_LEN + 3]; u8 *pos; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->tx_tfm}; u32 crc; u8 *icv; struct scatterlist sg; if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 || skb->len < hdr_len){ - printk("Error!!!headroom=%d tailroom=%d skblen=%d hdr_len=%d\n",skb_headroom(skb),skb_tailroom(skb),skb->len,hdr_len); + printk(KERN_ERR "Error!!! headroom=%d tailroom=%d skblen=%d" + " hdr_len=%d\n", skb_headroom(skb), skb_tailroom(skb), + skb->len, hdr_len); return -1; } len = skb->len - hdr_len; @@ -157,8 +160,8 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) } -/* Perform WEP decryption on given struct buffer. Buffer includes whole WEP part of - * the frame: IV (4 bytes), encrypted payload (including SNAP header), +/* Perform WEP decryption on given struct buffer. Buffer includes whole WEP + * part of the frame: IV (4 bytes), encrypted payload (including SNAP header), * ICV (4 bytes). len includes both IV and ICV. * * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on @@ -170,7 +173,8 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 klen, plen; u8 key[WEP_KEY_LEN + 3]; u8 keyidx, *pos; - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = wep->rx_tfm}; u32 crc; u8 icv[4]; @@ -245,7 +249,7 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) } -static char * prism2_wep_print_stats(char *p, void *priv) +static char *prism2_wep_print_stats(char *p, void *priv) { struct prism2_wep_data *wep = priv; p += sprintf(p, "key[%d] alg=WEP len=%d\n", @@ -284,5 +288,5 @@ void __exit rtllib_crypto_wep_exit(void) void rtllib_wep_null(void) { - return; + return; } diff --git a/drivers/staging/rtl8192e/rtllib_endianfree.h b/drivers/staging/rtl8192e/rtllib_endianfree.h index 46d8f1962484..b268605a52aa 100644 --- a/drivers/staging/rtl8192e/rtllib_endianfree.h +++ b/drivers/staging/rtl8192e/rtllib_endianfree.h @@ -14,26 +14,28 @@ #define BYTE_ORDER __MACHINE_LITTLE_ENDIAN #if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) ((u16)(_val)) -#define EF4Byte(_val) ((u32)(_val)) +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) ((u16)(_val)) +#define EF4Byte(_val) ((u32)(_val)) #else -#define EF1Byte(_val) ((u8)(_val)) -#define EF2Byte(_val) (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) -#define EF4Byte(_val) (((((u32)(_val))&0x000000ff)<<24)|\ - ((((u32)(_val))&0x0000ff00)<<8)|\ - ((((u32)(_val))&0x00ff0000)>>8)|\ - ((((u32)(_val))&0xff000000)>>24)) +#define EF1Byte(_val) ((u8)(_val)) +#define EF2Byte(_val) \ + (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8)) +#define EF4Byte(_val) \ + (((((u32)(_val))&0x000000ff)<<24)|\ + ((((u32)(_val))&0x0000ff00)<<8)|\ + ((((u32)(_val))&0x00ff0000)>>8)|\ + ((((u32)(_val))&0xff000000)>>24)) #endif #define ReadEF1Byte(_ptr) EF1Byte(*((u8 *)(_ptr))) #define ReadEF2Byte(_ptr) EF2Byte(*((u16 *)(_ptr))) #define ReadEF4Byte(_ptr) EF4Byte(*((u32 *)(_ptr))) -#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr)))=EF1Byte(_val) -#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr)))=EF2Byte(_val) -#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr)))=EF4Byte(_val) +#define WriteEF1Byte(_ptr, _val) (*((u8 *)(_ptr))) = EF1Byte(_val) +#define WriteEF2Byte(_ptr, _val) (*((u16 *)(_ptr))) = EF2Byte(_val) +#define WriteEF4Byte(_ptr, _val) (*((u32 *)(_ptr))) = EF4Byte(_val) #if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN #define H2N1BYTE(_val) ((u8)(_val)) #define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\ @@ -63,13 +65,14 @@ #endif #define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen))) -#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) +#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) \ + (BIT_LEN_MASK_32(__BitLen) << (__BitOffset)) #define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart)))) #define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_32(__BitLen) \ ) @@ -78,7 +81,7 @@ ( \ LE_P4BYTE_TO_HOST_4BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen)) \ ) #define SET_BITS_TO_LE_4BYTE(__pStart, __BitOffset, __BitLen, __Value) \ @@ -86,8 +89,8 @@ EF4Byte( \ LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \ | \ - ( (((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset) ) \ - ); + ((((u32)__Value) & BIT_LEN_MASK_32(__BitLen)) << (__BitOffset)) \ + ); #define BIT_LEN_MASK_16(__BitLen) \ @@ -101,7 +104,7 @@ #define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_16(__BitLen) \ ) @@ -110,16 +113,16 @@ ( \ LE_P2BYTE_TO_HOST_2BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen)) \ ) #define SET_BITS_TO_LE_2BYTE(__pStart, __BitOffset, __BitLen, __Value) \ *((u16 *)(__pStart)) = \ EF2Byte( \ LE_BITS_CLEARED_TO_2BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << (__BitOffset) ) \ - ); + | ((((u16)__Value) & BIT_LEN_MASK_16(__BitLen)) << \ + (__BitOffset)) \ + ); #define BIT_LEN_MASK_8(__BitLen) \ (0xFF >> (8 - (__BitLen))) @@ -132,7 +135,7 @@ #define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ ( \ - ( LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset) ) \ + (LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset)) \ & \ BIT_LEN_MASK_8(__BitLen) \ ) @@ -141,16 +144,17 @@ ( \ LE_P1BYTE_TO_HOST_1BYTE(__pStart) \ & \ - ( ~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) ) \ + (~BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen)) \ ) -#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ - *((u8 *)(__pStart)) = \ - EF1Byte( \ +#define SET_BITS_TO_LE_1BYTE(__pStart, __BitOffset, __BitLen, __Value) \ + *((u8 *)(__pStart)) = EF1Byte( \ LE_BITS_CLEARED_TO_1BYTE(__pStart, __BitOffset, __BitLen) \ - | \ - ( (((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << (__BitOffset) ) \ - ); + | ((((u8)__Value) & BIT_LEN_MASK_8(__BitLen)) << \ + (__BitOffset)) \ + ); -#define N_BYTE_ALIGMENT(__Value, __Aligment) ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / __Aligment) * __Aligment)) +#define N_BYTE_ALIGMENT(__Value, __Aligment) \ + ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / \ + __Aligment) * __Aligment)) #endif From d57429f05eac870a1c099045bf2735edf3aa70ab Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 7 Aug 2011 21:12:29 -0500 Subject: [PATCH 14/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XII This patch removes all the errors and most of the warnings generated by checkpatch -f. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib.h | 1211 ++++++++++++---------- drivers/staging/rtl8192e/rtllib_module.c | 30 +- drivers/staging/rtl8192e/rtllib_tx.c | 1 - 3 files changed, 655 insertions(+), 587 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2a394ee9f750..c7b3641f30b6 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -64,14 +64,14 @@ /** * container_of - cast a member of a structure out to the containing structure * - * @ptr: the pointer to the member. + * @ptr: the pointer to the member. * @type: the type of the container struct this is embedded in. * @member: the name of the member within the struct. * */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member)*__mptr = (ptr); \ + (type *)((char *)__mptr - offsetof(type, member)); }) #endif #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb) @@ -79,21 +79,24 @@ #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) - #define queue_delayed_work_rsl(x,y,z) queue_delayed_work(x,y,z) - #define INIT_DELAYED_WORK_RSL(x,y,z) INIT_DELAYED_WORK(x,y) +#define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z) +#define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y) - #define queue_work_rsl(x,y) queue_work(x,y) - #define INIT_WORK_RSL(x,y,z) INIT_WORK(x,y) +#define queue_work_rsl(x, y) queue_work(x, y) +#define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y) - #define container_of_work_rsl(x,y,z) container_of(x,y,z) - #define container_of_dwork_rsl(x,y,z) container_of(container_of(x, struct delayed_work, work), y, z) +#define container_of_work_rsl(x, y, z) container_of(x, y, z) +#define container_of_dwork_rsl(x, y, z) \ + container_of(container_of(x, struct delayed_work, work), y, z) - #define iwe_stream_add_event_rsl(info,start,stop,iwe,len) iwe_stream_add_event(info,start,stop,iwe,len) +#define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \ + iwe_stream_add_event(info, start, stop, iwe, len) - #define iwe_stream_add_point_rsl(info,start,stop,iwe,p) iwe_stream_add_point(info,start,stop,iwe,p) +#define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \ + iwe_stream_add_point(info, start, stop, iwe, p) - #define usb_alloc_urb_rsl(x,y) usb_alloc_urb(x,y) - #define usb_submit_urb_rsl(x,y) usb_submit_urb(x,y) +#define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y) +#define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y) static inline void *netdev_priv_rsl(struct net_device *dev) { @@ -108,18 +111,18 @@ static inline void *netdev_priv_rsl(struct net_device *dev) /* added for rtl819x tx procedure */ #define MAX_QUEUE_SIZE 0x10 -#define BK_QUEUE 0 -#define BE_QUEUE 1 -#define VI_QUEUE 2 -#define VO_QUEUE 3 -#define HCCA_QUEUE 4 -#define TXCMD_QUEUE 5 -#define MGNT_QUEUE 6 -#define HIGH_QUEUE 7 -#define BEACON_QUEUE 8 +#define BK_QUEUE 0 +#define BE_QUEUE 1 +#define VI_QUEUE 2 +#define VO_QUEUE 3 +#define HCCA_QUEUE 4 +#define TXCMD_QUEUE 5 +#define MGNT_QUEUE 6 +#define HIGH_QUEUE 7 +#define BEACON_QUEUE 8 -#define LOW_QUEUE BE_QUEUE -#define NORMAL_QUEUE MGNT_QUEUE +#define LOW_QUEUE BE_QUEUE +#define NORMAL_QUEUE MGNT_QUEUE #ifndef IW_MODE_MESH #define IW_MODE_MESH 7 @@ -139,8 +142,10 @@ static inline void *netdev_priv_rsl(struct net_device *dev) #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 #define RT_RF_LPS_DISALBE_2R BIT30 #define RT_RF_LPS_LEVEL_ASPM BIT31 -#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) -#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel &= (~(_PS_FLAG))) +#define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \ + ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) +#define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \ + (pPSC->CurPsLevel &= (~(_PS_FLAG))) #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG) /* defined for skb cb field */ @@ -203,36 +208,36 @@ struct cb_desc { }; /*--------------------------Define -------------------------------------------*/ -#define MGN_1M 0x02 -#define MGN_2M 0x04 -#define MGN_5_5M 0x0b -#define MGN_11M 0x16 +#define MGN_1M 0x02 +#define MGN_2M 0x04 +#define MGN_5_5M 0x0b +#define MGN_11M 0x16 -#define MGN_6M 0x0c -#define MGN_9M 0x12 -#define MGN_12M 0x18 -#define MGN_18M 0x24 -#define MGN_24M 0x30 -#define MGN_36M 0x48 -#define MGN_48M 0x60 -#define MGN_54M 0x6c +#define MGN_6M 0x0c +#define MGN_9M 0x12 +#define MGN_12M 0x18 +#define MGN_18M 0x24 +#define MGN_24M 0x30 +#define MGN_36M 0x48 +#define MGN_48M 0x60 +#define MGN_54M 0x6c -#define MGN_MCS0 0x80 -#define MGN_MCS1 0x81 -#define MGN_MCS2 0x82 -#define MGN_MCS3 0x83 -#define MGN_MCS4 0x84 -#define MGN_MCS5 0x85 -#define MGN_MCS6 0x86 -#define MGN_MCS7 0x87 -#define MGN_MCS8 0x88 -#define MGN_MCS9 0x89 -#define MGN_MCS10 0x8a -#define MGN_MCS11 0x8b -#define MGN_MCS12 0x8c -#define MGN_MCS13 0x8d -#define MGN_MCS14 0x8e -#define MGN_MCS15 0x8f +#define MGN_MCS0 0x80 +#define MGN_MCS1 0x81 +#define MGN_MCS2 0x82 +#define MGN_MCS3 0x83 +#define MGN_MCS4 0x84 +#define MGN_MCS5 0x85 +#define MGN_MCS6 0x86 +#define MGN_MCS7 0x87 +#define MGN_MCS8 0x88 +#define MGN_MCS9 0x89 +#define MGN_MCS10 0x8a +#define MGN_MCS11 0x8b +#define MGN_MCS12 0x8c +#define MGN_MCS13 0x8d +#define MGN_MCS14 0x8e +#define MGN_MCS15 0x8f #define MGN_MCS0_SG 0x90 #define MGN_MCS1_SG 0x91 #define MGN_MCS2_SG 0x92 @@ -251,7 +256,7 @@ struct cb_desc { #define MGN_MCS15_SG 0x9f -enum _ReasonCode{ +enum _ReasonCode { unspec_reason = 0x1, auth_not_valid = 0x2, deauth_lv_ss = 0x3, @@ -273,7 +278,7 @@ enum _ReasonCode{ invalid_AKMP = 0x14, unsup_RSNIEver = 0x15, invalid_RSNIE = 0x16, - auth_802_1x_fail= 0x17, + auth_802_1x_fail = 0x17, ciper_reject = 0x18, QoS_unspec = 0x20, @@ -282,7 +287,7 @@ enum _ReasonCode{ no_facility = 0x23, req_declined = 0x25, invalid_param = 0x26, - req_not_honored= 0x27, + req_not_honored = 0x27, TS_not_created = 0x2F, DL_not_allowed = 0x30, dest_not_exist = 0x31, @@ -308,10 +313,9 @@ enum hal_def_variable { HW_DEF_GPIO, HAL_DEF_PCI_SUPPORT_ASPM, HAL_DEF_THERMAL_VALUE, - HAL_DEF_USB_IN_TOKEN_REV, + HAL_DEF_USB_IN_TOKEN_REV, }; - enum hw_variables { HW_VAR_ETHER_ADDR, HW_VAR_MULTICAST_REG, @@ -355,14 +359,14 @@ enum hw_variables { HW_VAR_RF_STATE, HW_VAR_RF_OFF_BY_HW, HW_VAR_BUS_SPEED, - HW_VAR_SET_DEV_POWER, + HW_VAR_SET_DEV_POWER, HW_VAR_RCR, HW_VAR_RATR_0, HW_VAR_RRSR, HW_VAR_CPU_RST, HW_VAR_CECHK_BSSID, - HW_VAR_LBK_MODE, + HW_VAR_LBK_MODE, HW_VAR_AES_11N_FIX, HW_VAR_USB_RX_AGGR, HW_VAR_USER_CONTROL_TURBO_MODE, @@ -400,7 +404,7 @@ enum hw_variables { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_INT_MIGRATION, HW_VAR_INT_AC, - HW_VAR_RF_TIMING, + HW_VAR_RF_TIMING, }; enum rt_op_mode { @@ -411,7 +415,10 @@ enum rt_op_mode { }; -#define aSifsTime (((priv->rtllib->current_network.mode == IEEE_A)||(priv->rtllib->current_network.mode == IEEE_N_24G)||(priv->rtllib->current_network.mode == IEEE_N_5G))? 16 : 10) +#define aSifsTime \ + (((priv->rtllib->current_network.mode == IEEE_A) \ + || (priv->rtllib->current_network.mode == IEEE_N_24G) \ + || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10) #define MGMT_QUEUE_NUM 5 @@ -452,13 +459,14 @@ enum rt_op_mode { #define IEEE_CRYPT_ALG_NAME_LEN 16 #define MAX_IE_LEN 0xff -#define RT_ASSERT_RET(_Exp) do {} while(0) -#define RT_ASSERT_RET_VALUE(_Exp,Ret) do {} while(0) +#define RT_ASSERT_RET(_Exp) do {} while (0) +#define RT_ASSERT_RET_VALUE(_Exp, Ret) \ + do {} while (0) struct ieee_param { u32 cmd; u8 sta_addr[ETH_ALEN]; - union { + union { struct { u8 name; u32 value; @@ -468,7 +476,7 @@ struct ieee_param { u8 reserved[32]; u8 data[0]; } wpa_ie; - struct{ + struct { int command; int reason_code; } mlme; @@ -510,8 +518,8 @@ struct ieee_param { #define RTLLIB_3ADDR_LEN 24 #define RTLLIB_4ADDR_LEN 30 #define RTLLIB_FCS_LEN 4 -#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) -#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) +#define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) +#define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) #define RTLLIB_MGMT_HDR_LEN 24 #define RTLLIB_DATA_HDR3_LEN 24 #define RTLLIB_DATA_HDR4_LEN 30 @@ -583,57 +591,59 @@ struct ieee_param { #define RTLLIB_SCTL_SEQ 0xFFF0 /* QOS control */ -#define RTLLIB_QCTL_TID 0x000F +#define RTLLIB_QCTL_TID 0x000F #define FC_QOS_BIT BIT7 -#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) -#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) -#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) -#define Frame_Order(pframe) (*(u16*)pframe&RTLLIB_FCTL_ORDER) -#define SN_LESS(a, b) (((a-b)&0x800)!=0) +#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false) +#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT))) +#define IsQoSDataFrame(pframe) \ + ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \ + (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) +#define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER) +#define SN_LESS(a, b) (((a-b)&0x800) != 0) #define SN_EQUAL(a, b) (a == b) #define MAX_DEV_ADDR_SIZE 8 enum act_category { - ACT_CAT_QOS = 1, - ACT_CAT_DLS = 2, - ACT_CAT_BA = 3, - ACT_CAT_HT = 7, - ACT_CAT_WMM = 17, + ACT_CAT_QOS = 1, + ACT_CAT_DLS = 2, + ACT_CAT_BA = 3, + ACT_CAT_HT = 7, + ACT_CAT_WMM = 17, }; enum ts_action { - ACT_ADDTSREQ = 0, - ACT_ADDTSRSP = 1, - ACT_DELTS = 2, - ACT_SCHEDULE = 3, + ACT_ADDTSREQ = 0, + ACT_ADDTSRSP = 1, + ACT_DELTS = 2, + ACT_SCHEDULE = 3, }; enum ba_action { - ACT_ADDBAREQ = 0, - ACT_ADDBARSP = 1, - ACT_DELBA = 2, + ACT_ADDBAREQ = 0, + ACT_ADDBARSP = 1, + ACT_DELBA = 2, }; enum init_gain_op_type { - IG_Backup=0, + IG_Backup = 0, IG_Restore, IG_Max }; enum led_ctl_mode { - LED_CTL_POWER_ON = 1, - LED_CTL_LINK = 2, - LED_CTL_NO_LINK = 3, - LED_CTL_TX = 4, - LED_CTL_RX = 5, - LED_CTL_SITE_SURVEY = 6, - LED_CTL_POWER_OFF = 7, - LED_CTL_START_TO_LINK = 8, - LED_CTL_START_WPS = 9, - LED_CTL_STOP_WPS = 10, - LED_CTL_START_WPS_BOTTON = 11, - LED_CTL_STOP_WPS_FAIL = 12, + LED_CTL_POWER_ON = 1, + LED_CTL_LINK = 2, + LED_CTL_NO_LINK = 3, + LED_CTL_TX = 4, + LED_CTL_RX = 5, + LED_CTL_SITE_SURVEY = 6, + LED_CTL_POWER_OFF = 7, + LED_CTL_START_TO_LINK = 8, + LED_CTL_START_WPS = 9, + LED_CTL_STOP_WPS = 10, + LED_CTL_START_WPS_BOTTON = 11, + LED_CTL_STOP_WPS_FAIL = 12, LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, }; @@ -670,25 +680,29 @@ enum wireless_network_type { /* debug macros */ extern u32 rtllib_debug_level; #define RTLLIB_DEBUG(level, fmt, args...) \ -do { if (rtllib_debug_level & (level)) \ - printk(KERN_DEBUG "rtllib: " fmt, ## args); } while (0) +do { \ + if (rtllib_debug_level & (level)) \ + printk(KERN_DEBUG "rtllib: " fmt, ## args); \ +} while (0) + #define RTLLIB_DEBUG_DATA(level, data, datalen) \ - do{ if ((rtllib_debug_level & (level)) == (level)) \ - { \ + do { \ + if ((rtllib_debug_level & (level)) == (level)) { \ int i; \ - u8* pdata = (u8*) data; \ + u8 *pdata = (u8 *)data; \ printk(KERN_DEBUG "rtllib: %s()\n", __func__); \ - for (i=0; i<(int)(datalen); i++) \ - { \ + for (i = 0; i < (int)(datalen); i++) { \ printk("%2.2x ", pdata[i]); \ - if ((i+1)%16 == 0) printk("\n"); \ + if ((i+1)%16 == 0) \ + printk("\n"); \ } \ printk("\n"); \ } \ } while (0) #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5] +#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \ + ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] /* * To use the debug system; @@ -714,22 +728,22 @@ do { if (rtllib_debug_level & (level)) \ * */ -#define RTLLIB_DL_INFO (1<<0) -#define RTLLIB_DL_WX (1<<1) -#define RTLLIB_DL_SCAN (1<<2) -#define RTLLIB_DL_STATE (1<<3) -#define RTLLIB_DL_MGMT (1<<4) -#define RTLLIB_DL_FRAG (1<<5) -#define RTLLIB_DL_EAP (1<<6) -#define RTLLIB_DL_DROP (1<<7) +#define RTLLIB_DL_INFO (1<<0) +#define RTLLIB_DL_WX (1<<1) +#define RTLLIB_DL_SCAN (1<<2) +#define RTLLIB_DL_STATE (1<<3) +#define RTLLIB_DL_MGMT (1<<4) +#define RTLLIB_DL_FRAG (1<<5) +#define RTLLIB_DL_EAP (1<<6) +#define RTLLIB_DL_DROP (1<<7) -#define RTLLIB_DL_TX (1<<8) -#define RTLLIB_DL_RX (1<<9) +#define RTLLIB_DL_TX (1<<8) +#define RTLLIB_DL_RX (1<<9) #define RTLLIB_DL_HT (1<<10) #define RTLLIB_DL_BA (1<<11) #define RTLLIB_DL_TS (1<<12) -#define RTLLIB_DL_QOS (1<<13) +#define RTLLIB_DL_QOS (1<<13) #define RTLLIB_DL_REORDER (1<<14) #define RTLLIB_DL_IOT (1<<15) #define RTLLIB_DL_IPS (1<<16) @@ -753,25 +767,24 @@ do { if (rtllib_debug_level & (level)) \ /* Added by Annie, 2005-11-22. */ #define MAX_STR_LEN 64 -/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ -#define PRINTABLE(_ch) (_ch>'!' && _ch<'~') -#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ - if ((_Comp) & level) \ - { \ - int __i; \ - u8 struct buffer[MAX_STR_LEN]; \ - int length = (_Len\n", _Len, struct buffer); \ - } +/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */ +#define PRINTABLE(_ch) (_ch > '!' && _ch < '~') +#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ + if ((_Comp) & level) { \ + int __i; \ + u8 struct buffer[MAX_STR_LEN]; \ + int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\ + memset(struct buffer, 0, MAX_STR_LEN); \ + memcpy(struct buffer, (u8 *)_Ptr, length); \ + for (__i = 0; __i < MAX_STR_LEN; __i++) { \ + if (!PRINTABLE(struct buffer[__i])) \ + struct buffer[__i] = '?'; \ + } \ + struct buffer[length] = '\0'; \ + printk(KERN_INFO "Rtl819x: "); \ + printk(_TitleString); \ + printk(": %d, <%s>\n", _Len, struct buffer); \ + } #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ #define ETH_P_IP 0x0800 /* Internet Protocol packet */ @@ -790,17 +803,17 @@ do { if (rtllib_debug_level & (level)) \ struct rtllib_snap_hdr { - u8 dsap; /* always 0xAA */ - u8 ssap; /* always 0xAA */ - u8 ctrl; /* always 0x03 */ - u8 oui[P80211_OUI_LEN]; /* organizational universal id */ + u8 dsap; /* always 0xAA */ + u8 ssap; /* always 0xAA */ + u8 ctrl; /* always 0x03 */ + u8 oui[P80211_OUI_LEN]; /* organizational universal id */ -} __attribute__ ((packed)); +} __packed; -enum _REG_PREAMBLE_MODE{ +enum _REG_PREAMBLE_MODE { PREAMBLE_LONG = 1, PREAMBLE_AUTO = 2, - PREAMBLE_SHORT= 3, + PREAMBLE_SHORT = 3, }; #define SNAP_SIZE sizeof(struct rtllib_snap_hdr) @@ -841,65 +854,65 @@ enum _REG_PREAMBLE_MODE{ /* Status codes */ enum rtllib_statuscode { - WLAN_STATUS_SUCCESS = 0, - WLAN_STATUS_UNSPECIFIED_FAILURE = 1, - WLAN_STATUS_CAPS_UNSUPPORTED = 10, - WLAN_STATUS_REASSOC_NO_ASSOC = 11, - WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, - WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, - WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, - WLAN_STATUS_CHALLENGE_FAIL = 15, - WLAN_STATUS_AUTH_TIMEOUT = 16, - WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, - WLAN_STATUS_ASSOC_DENIED_RATES = 18, - /* 802.11b */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, - WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, - WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, - /* 802.11h */ - WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, - WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, - WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, - /* 802.11g */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, - WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, - /* 802.11i */ - WLAN_STATUS_INVALID_IE = 40, - WLAN_STATUS_INVALID_GROUP_CIPHER = 41, - WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, - WLAN_STATUS_INVALID_AKMP = 43, - WLAN_STATUS_UNSUPP_RSN_VERSION = 44, - WLAN_STATUS_INVALID_RSN_IE_CAP = 45, - WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, + WLAN_STATUS_SUCCESS = 0, + WLAN_STATUS_UNSPECIFIED_FAILURE = 1, + WLAN_STATUS_CAPS_UNSUPPORTED = 10, + WLAN_STATUS_REASSOC_NO_ASSOC = 11, + WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, + WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, + WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, + WLAN_STATUS_CHALLENGE_FAIL = 15, + WLAN_STATUS_AUTH_TIMEOUT = 16, + WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, + WLAN_STATUS_ASSOC_DENIED_RATES = 18, + /* 802.11b */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, + WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, + WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, + /* 802.11h */ + WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, + WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, + WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, + /* 802.11g */ + WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, + WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, + /* 802.11i */ + WLAN_STATUS_INVALID_IE = 40, + WLAN_STATUS_INVALID_GROUP_CIPHER = 41, + WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, + WLAN_STATUS_INVALID_AKMP = 43, + WLAN_STATUS_UNSUPP_RSN_VERSION = 44, + WLAN_STATUS_INVALID_RSN_IE_CAP = 45, + WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, }; /* Reason codes */ enum rtllib_reasoncode { - WLAN_REASON_UNSPECIFIED = 1, - WLAN_REASON_PREV_AUTH_NOT_VALID = 2, - WLAN_REASON_DEAUTH_LEAVING = 3, - WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, - WLAN_REASON_DISASSOC_AP_BUSY = 5, - WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, - WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, - WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, - /* 802.11h */ - WLAN_REASON_DISASSOC_BAD_POWER = 10, - WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, - /* 802.11i */ - WLAN_REASON_INVALID_IE = 13, - WLAN_REASON_MIC_FAILURE = 14, - WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, - WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, - WLAN_REASON_IE_DIFFERENT = 17, - WLAN_REASON_INVALID_GROUP_CIPHER = 18, - WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, - WLAN_REASON_INVALID_AKMP = 20, - WLAN_REASON_UNSUPP_RSN_VERSION = 21, - WLAN_REASON_INVALID_RSN_IE_CAP = 22, - WLAN_REASON_IEEE8021X_FAILED = 23, - WLAN_REASON_CIPHER_SUITE_REJECTED = 24, + WLAN_REASON_UNSPECIFIED = 1, + WLAN_REASON_PREV_AUTH_NOT_VALID = 2, + WLAN_REASON_DEAUTH_LEAVING = 3, + WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, + WLAN_REASON_DISASSOC_AP_BUSY = 5, + WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, + WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, + WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, + /* 802.11h */ + WLAN_REASON_DISASSOC_BAD_POWER = 10, + WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, + /* 802.11i */ + WLAN_REASON_INVALID_IE = 13, + WLAN_REASON_MIC_FAILURE = 14, + WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, + WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, + WLAN_REASON_IE_DIFFERENT = 17, + WLAN_REASON_INVALID_GROUP_CIPHER = 18, + WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, + WLAN_REASON_INVALID_AKMP = 20, + WLAN_REASON_UNSUPP_RSN_VERSION = 21, + WLAN_REASON_INVALID_RSN_IE_CAP = 22, + WLAN_REASON_IEEE8021X_FAILED = 23, + WLAN_REASON_CIPHER_SUITE_REJECTED = 24, }; #define RTLLIB_STATMASK_SIGNAL (1<<0) @@ -915,13 +928,13 @@ enum rtllib_reasoncode { #define RTLLIB_52GHZ_BAND (1<<1) #define RTLLIB_CCK_RATE_LEN 4 -#define RTLLIB_CCK_RATE_1MB 0x02 -#define RTLLIB_CCK_RATE_2MB 0x04 -#define RTLLIB_CCK_RATE_5MB 0x0B -#define RTLLIB_CCK_RATE_11MB 0x16 +#define RTLLIB_CCK_RATE_1MB 0x02 +#define RTLLIB_CCK_RATE_2MB 0x04 +#define RTLLIB_CCK_RATE_5MB 0x0B +#define RTLLIB_CCK_RATE_11MB 0x16 #define RTLLIB_OFDM_RATE_LEN 8 -#define RTLLIB_OFDM_RATE_6MB 0x0C -#define RTLLIB_OFDM_RATE_9MB 0x12 +#define RTLLIB_OFDM_RATE_6MB 0x0C +#define RTLLIB_OFDM_RATE_9MB 0x12 #define RTLLIB_OFDM_RATE_12MB 0x18 #define RTLLIB_OFDM_RATE_18MB 0x24 #define RTLLIB_OFDM_RATE_24MB 0x30 @@ -943,12 +956,12 @@ enum rtllib_reasoncode { #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10) #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11) -#define RTLLIB_CCK_RATES_MASK 0x0000000F +#define RTLLIB_CCK_RATES_MASK 0x0000000F #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \ RTLLIB_CCK_RATE_2MB_MASK) #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \ - RTLLIB_CCK_RATE_5MB_MASK | \ - RTLLIB_CCK_RATE_11MB_MASK) + RTLLIB_CCK_RATE_5MB_MASK | \ + RTLLIB_CCK_RATE_11MB_MASK) #define RTLLIB_OFDM_RATES_MASK 0x00000FF0 #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \ @@ -961,11 +974,11 @@ enum rtllib_reasoncode { RTLLIB_OFDM_RATE_48MB_MASK | \ RTLLIB_OFDM_RATE_54MB_MASK) #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \ - RTLLIB_CCK_DEFAULT_RATES_MASK) + RTLLIB_CCK_DEFAULT_RATES_MASK) #define RTLLIB_NUM_OFDM_RATES 8 -#define RTLLIB_NUM_CCK_RATES 4 -#define RTLLIB_OFDM_SHIFT_MASK_A 4 +#define RTLLIB_NUM_CCK_RATES 4 +#define RTLLIB_OFDM_SHIFT_MASK_A 4 /* this is stolen and modified from the madwifi driver*/ @@ -992,7 +1005,6 @@ struct ieee_ibss_seq { * information for frames received. Not setting these will not cause * any adverse affects. */ struct rtllib_rx_stats { -#if 1 u64 mac_time; s8 rssi; u8 signal; @@ -1038,7 +1050,7 @@ struct rtllib_rx_stats { bool bPacketMatchBSSID; bool bIsCCK; bool bPacketToSelf; - u8* virtual_address; + u8 *virtual_address; u16 packetlength; u16 fraglength; u16 fragoffset; @@ -1049,8 +1061,6 @@ struct rtllib_rx_stats { char cck_adc_pwdb[4]; u16 Seq_Num; u8 nTotalAggPkt; -#endif - }; /* IEEE 802.11 requires that STA supports concurrent reception of at least @@ -1096,14 +1106,14 @@ struct rtllib_device; #include "rtllib_crypt.h" -#define SEC_KEY_1 (1<<0) -#define SEC_KEY_2 (1<<1) -#define SEC_KEY_3 (1<<2) -#define SEC_KEY_4 (1<<3) +#define SEC_KEY_1 (1<<0) +#define SEC_KEY_2 (1<<1) +#define SEC_KEY_3 (1<<2) +#define SEC_KEY_4 (1<<3) #define SEC_ACTIVE_KEY (1<<4) #define SEC_AUTH_MODE (1<<5) #define SEC_UNICAST_GROUP (1<<6) -#define SEC_LEVEL (1<<7) +#define SEC_LEVEL (1<<7) #define SEC_ENABLED (1<<8) #define SEC_ENCRYPT (1<<9) @@ -1113,28 +1123,28 @@ struct rtllib_device; #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ -#define SEC_ALG_NONE 0 -#define SEC_ALG_WEP 1 -#define SEC_ALG_TKIP 2 -#define SEC_ALG_CCMP 4 +#define SEC_ALG_NONE 0 +#define SEC_ALG_WEP 1 +#define SEC_ALG_TKIP 2 +#define SEC_ALG_CCMP 4 #define WEP_KEYS 4 #define WEP_KEY_LEN 13 -#define SCM_KEY_LEN 32 +#define SCM_KEY_LEN 32 #define SCM_TEMPORAL_KEY_LENGTH 16 struct rtllib_security { u16 active_key:2, - enabled:1, + enabled:1, auth_mode:2, - auth_algo:4, - unicast_uses_group:1, + auth_algo:4, + unicast_uses_group:1, encrypt:1; u8 key_sizes[WEP_KEYS]; u8 keys[WEP_KEYS][SCM_KEY_LEN]; u8 level; u16 flags; -} __attribute__ ((packed)); +} __packed; /* @@ -1143,75 +1153,75 @@ struct rtllib_security { Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |------|------|---------|---------|---------|------|---------|------| Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - | | tion | (BSSID) | | | ence | data | | + | | tion | (BSSID) | | | ence | data | | `-------------------------------------------------------------------' Total: 28-2340 bytes */ /* Management Frame Information Element Types */ enum rtllib_mfie { - MFIE_TYPE_SSID = 0, - MFIE_TYPE_RATES = 1, - MFIE_TYPE_FH_SET = 2, - MFIE_TYPE_DS_SET = 3, - MFIE_TYPE_CF_SET = 4, - MFIE_TYPE_TIM = 5, - MFIE_TYPE_IBSS_SET = 6, - MFIE_TYPE_COUNTRY = 7, - MFIE_TYPE_HOP_PARAMS = 8, - MFIE_TYPE_HOP_TABLE = 9, - MFIE_TYPE_REQUEST = 10, - MFIE_TYPE_CHALLENGE = 16, - MFIE_TYPE_POWER_CONSTRAINT = 32, - MFIE_TYPE_POWER_CAPABILITY = 33, - MFIE_TYPE_TPC_REQUEST = 34, - MFIE_TYPE_TPC_REPORT = 35, - MFIE_TYPE_SUPP_CHANNELS = 36, - MFIE_TYPE_CSA = 37, - MFIE_TYPE_MEASURE_REQUEST = 38, - MFIE_TYPE_MEASURE_REPORT = 39, - MFIE_TYPE_QUIET = 40, - MFIE_TYPE_IBSS_DFS = 41, - MFIE_TYPE_ERP = 42, - MFIE_TYPE_HT_CAP= 45, + MFIE_TYPE_SSID = 0, + MFIE_TYPE_RATES = 1, + MFIE_TYPE_FH_SET = 2, + MFIE_TYPE_DS_SET = 3, + MFIE_TYPE_CF_SET = 4, + MFIE_TYPE_TIM = 5, + MFIE_TYPE_IBSS_SET = 6, + MFIE_TYPE_COUNTRY = 7, + MFIE_TYPE_HOP_PARAMS = 8, + MFIE_TYPE_HOP_TABLE = 9, + MFIE_TYPE_REQUEST = 10, + MFIE_TYPE_CHALLENGE = 16, + MFIE_TYPE_POWER_CONSTRAINT = 32, + MFIE_TYPE_POWER_CAPABILITY = 33, + MFIE_TYPE_TPC_REQUEST = 34, + MFIE_TYPE_TPC_REPORT = 35, + MFIE_TYPE_SUPP_CHANNELS = 36, + MFIE_TYPE_CSA = 37, + MFIE_TYPE_MEASURE_REQUEST = 38, + MFIE_TYPE_MEASURE_REPORT = 39, + MFIE_TYPE_QUIET = 40, + MFIE_TYPE_IBSS_DFS = 41, + MFIE_TYPE_ERP = 42, + MFIE_TYPE_HT_CAP = 45, MFIE_TYPE_RSN = 48, MFIE_TYPE_RATES_EX = 50, - MFIE_TYPE_HT_INFO= 61, - MFIE_TYPE_AIRONET=133, + MFIE_TYPE_HT_INFO = 61, + MFIE_TYPE_AIRONET = 133, MFIE_TYPE_GENERIC = 221, - MFIE_TYPE_QOS_PARAMETER = 222, + MFIE_TYPE_QOS_PARAMETER = 222, }; /* Minimal header; can be used for passing 802.11 frames with sufficient * information to determine what type of underlying data type is actually * stored in the data. */ struct rtllib_pspoll_hdr { - __le16 frame_ctl; - __le16 aid; + __le16 frame_ctl; + __le16 aid; u8 bssid[ETH_ALEN]; - u8 ta[ETH_ALEN]; -} __attribute__ ((packed)); + u8 ta[ETH_ALEN]; +} __packed; struct rtllib_hdr { - __le16 frame_ctl; - __le16 duration_id; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 payload[0]; +} __packed; struct rtllib_hdr_1addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 payload[0]; +} __packed; struct rtllib_hdr_2addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 payload[0]; +} __packed; struct rtllib_hdr_3addr { __le16 frame_ctl; @@ -1220,8 +1230,8 @@ struct rtllib_hdr_3addr { u8 addr2[ETH_ALEN]; u8 addr3[ETH_ALEN]; __le16 seq_ctl; - u8 payload[0]; -} __attribute__ ((packed)); + u8 payload[0]; +} __packed; struct rtllib_hdr_4addr { __le16 frame_ctl; @@ -1231,8 +1241,8 @@ struct rtllib_hdr_4addr { u8 addr3[ETH_ALEN]; __le16 seq_ctl; u8 addr4[ETH_ALEN]; - u8 payload[0]; -} __attribute__ ((packed)); + u8 payload[0]; +} __packed; struct rtllib_hdr_3addrqos { __le16 frame_ctl; @@ -1243,7 +1253,7 @@ struct rtllib_hdr_3addrqos { __le16 seq_ctl; __le16 qos_ctl; u8 payload[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_hdr_4addrqos { __le16 frame_ctl; @@ -1255,13 +1265,13 @@ struct rtllib_hdr_4addrqos { u8 addr4[ETH_ALEN]; __le16 qos_ctl; u8 payload[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_info_element { u8 id; u8 len; u8 data[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_authentication { struct rtllib_hdr_3addr header; @@ -1270,33 +1280,33 @@ struct rtllib_authentication { __le16 status; /*challenge*/ struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); +} __packed; struct rtllib_disauth { - struct rtllib_hdr_3addr header; - __le16 reason; -} __attribute__ ((packed)); + struct rtllib_hdr_3addr header; + __le16 reason; +} __packed; struct rtllib_disassoc { - struct rtllib_hdr_3addr header; - __le16 reason; -} __attribute__ ((packed)); + struct rtllib_hdr_3addr header; + __le16 reason; +} __packed; struct rtllib_probe_request { struct rtllib_hdr_3addr header; /* SSID, supported rates */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_probe_response { struct rtllib_hdr_3addr header; u32 time_stamp[2]; __le16 beacon_interval; __le16 capability; - /* SSID, supported rates, FH params, DS params, - * CF params, IBSS params, TIM (if beacon), RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + /* SSID, supported rates, FH params, DS params, + * CF params, IBSS params, TIM (if beacon), RSN */ + struct rtllib_info_element info_element[0]; +} __packed; /* Alias beacon for probe_response */ #define rtllib_beacon rtllib_probe_response @@ -1306,8 +1316,8 @@ struct rtllib_assoc_request_frame { __le16 capability; __le16 listen_interval; /* SSID, supported rates, RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_reassoc_request_frame { struct rtllib_hdr_3addr header; @@ -1315,8 +1325,8 @@ struct rtllib_reassoc_request_frame { __le16 listen_interval; u8 current_ap[ETH_ALEN]; /* SSID, supported rates, RSN */ - struct rtllib_info_element info_element[0]; -} __attribute__ ((packed)); + struct rtllib_info_element info_element[0]; +} __packed; struct rtllib_assoc_response_frame { struct rtllib_hdr_3addr header; @@ -1324,7 +1334,7 @@ struct rtllib_assoc_response_frame { __le16 status; __le16 aid; struct rtllib_info_element info_element[0]; /* supported rates */ -} __attribute__ ((packed)); +} __packed; struct rtllib_txb { u8 nr_frags; @@ -1341,7 +1351,7 @@ struct rtllib_txb { struct rtllib_drv_agg_txb { u8 nr_drv_agg_frames; struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; -}__attribute__((packed)); +} __packed; #define MAX_SUBFRAME_COUNT 64 struct rtllib_rxb { @@ -1349,7 +1359,7 @@ struct rtllib_rxb { struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; u8 dst[ETH_ALEN]; u8 src[ETH_ALEN]; -}__attribute__((packed)); +} __packed; union frameqos { u16 shortdata; @@ -1360,7 +1370,7 @@ union frameqos { u16 ack_policy:2; u16 reserved:1; u16 txop:8; - }field; + } field; }; /* SWEEP TABLE ENTRIES NUMBER*/ @@ -1370,15 +1380,15 @@ union frameqos { * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the * main rates information element... */ -#define MAX_RATES_LENGTH ((u8)12) -#define MAX_RATES_EX_LENGTH ((u8)16) -#define MAX_NETWORK_COUNT 96 +#define MAX_RATES_LENGTH ((u8)12) +#define MAX_RATES_EX_LENGTH ((u8)16) +#define MAX_NETWORK_COUNT 96 -#define MAX_CHANNEL_NUMBER 161 +#define MAX_CHANNEL_NUMBER 161 #define RTLLIB_SOFTMAC_SCAN_TIME 100 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) -#define CRC_LENGTH 4U +#define CRC_LENGTH 4U #define MAX_WPA_IE_LEN 64 #define MAX_WZC_IE_LEN 256 @@ -1390,69 +1400,69 @@ union frameqos { /* QoS structure */ #define NETWORK_HAS_QOS_PARAMETERS (1<<3) #define NETWORK_HAS_QOS_INFORMATION (1<<4) -#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ - NETWORK_HAS_QOS_INFORMATION) +#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ + NETWORK_HAS_QOS_INFORMATION) /* 802.11h */ #define NETWORK_HAS_POWER_CONSTRAINT (1<<5) -#define NETWORK_HAS_CSA (1<<6) -#define NETWORK_HAS_QUIET (1<<7) -#define NETWORK_HAS_IBSS_DFS (1<<8) -#define NETWORK_HAS_TPC_REPORT (1<<9) +#define NETWORK_HAS_CSA (1<<6) +#define NETWORK_HAS_QUIET (1<<7) +#define NETWORK_HAS_IBSS_DFS (1<<8) +#define NETWORK_HAS_TPC_REPORT (1<<9) -#define NETWORK_HAS_ERP_VALUE (1<<10) +#define NETWORK_HAS_ERP_VALUE (1<<10) + +#define QOS_QUEUE_NUM 4 +#define QOS_OUI_LEN 3 +#define QOS_OUI_TYPE 2 +#define QOS_ELEMENT_ID 221 +#define QOS_OUI_INFO_SUB_TYPE 0 +#define QOS_OUI_PARAM_SUB_TYPE 1 +#define QOS_VERSION_1 1 +#define QOS_AIFSN_MIN_VALUE 2 -#define QOS_QUEUE_NUM 4 -#define QOS_OUI_LEN 3 -#define QOS_OUI_TYPE 2 -#define QOS_ELEMENT_ID 221 -#define QOS_OUI_INFO_SUB_TYPE 0 -#define QOS_OUI_PARAM_SUB_TYPE 1 -#define QOS_VERSION_1 1 -#define QOS_AIFSN_MIN_VALUE 2 -#if 1 struct rtllib_qos_information_element { - u8 elementID; - u8 length; - u8 qui[QOS_OUI_LEN]; - u8 qui_type; - u8 qui_subtype; - u8 version; - u8 ac_info; -} __attribute__ ((packed)); + u8 elementID; + u8 length; + u8 qui[QOS_OUI_LEN]; + u8 qui_type; + u8 qui_subtype; + u8 version; + u8 ac_info; +} __packed; struct rtllib_qos_ac_parameter { - u8 aci_aifsn; - u8 ecw_min_max; - __le16 tx_op_limit; -} __attribute__ ((packed)); + u8 aci_aifsn; + u8 ecw_min_max; + __le16 tx_op_limit; +} __packed; struct rtllib_qos_parameter_info { - struct rtllib_qos_information_element info_element; - u8 reserved; - struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); + struct rtllib_qos_information_element info_element; + u8 reserved; + struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; +} __packed; struct rtllib_qos_parameters { - __le16 cw_min[QOS_QUEUE_NUM]; - __le16 cw_max[QOS_QUEUE_NUM]; - u8 aifs[QOS_QUEUE_NUM]; - u8 flag[QOS_QUEUE_NUM]; - __le16 tx_op_limit[QOS_QUEUE_NUM]; -} __attribute__ ((packed)); + __le16 cw_min[QOS_QUEUE_NUM]; + __le16 cw_max[QOS_QUEUE_NUM]; + u8 aifs[QOS_QUEUE_NUM]; + u8 flag[QOS_QUEUE_NUM]; + __le16 tx_op_limit[QOS_QUEUE_NUM]; +} __packed; struct rtllib_qos_data { - struct rtllib_qos_parameters parameters; + struct rtllib_qos_parameters parameters; unsigned int wmm_acm; - int active; - int supported; - u8 param_count; - u8 old_param_count; + int active; + int supported; + u8 param_count; + u8 old_param_count; }; struct rtllib_tim_parameters { - u8 tim_count; - u8 tim_period; -} __attribute__ ((packed)); + u8 tim_count; + u8 tim_period; +} __packed; struct rtllib_wmm_ac_param { u8 ac_aci_acm_aifsn; @@ -1464,7 +1474,7 @@ struct rtllib_wmm_ts_info { u8 ac_dir_tid; u8 ac_up_psb; u8 reserved; -} __attribute__ ((packed)); +} __packed; struct rtllib_wmm_tspec_elem { struct rtllib_wmm_ts_info ts_info; @@ -1483,8 +1493,8 @@ struct rtllib_wmm_tspec_elem { u32 min_phy_rate; u16 surp_band_allow; u16 medium_time; -}__attribute__((packed)); -#endif +} __packed; + enum eap_type { EAP_PACKET = 0, EAPOL_START, @@ -1503,15 +1513,17 @@ static const char *eap_types[] = { static inline const char *eap_get_type(int type) { - return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type]; + return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : + eap_types[type]; } -static inline u8 Frame_QoSTID(u8* buf) +static inline u8 Frame_QoSTID(u8 *buf) { struct rtllib_hdr_3addr *hdr; u16 fc; hdr = (struct rtllib_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); - return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS)&&(fc & RTLLIB_FCTL_FROMDS))? 30 : 24)))->field.tid; + return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) && + (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid; } @@ -1521,9 +1533,9 @@ struct eapol { u8 version; u8 type; u16 length; -} __attribute__ ((packed)); +} __packed; -struct rtllib_softmac_stats{ +struct rtllib_softmac_stats { unsigned int rx_ass_ok; unsigned int rx_ass_err; unsigned int rx_probe_rq; @@ -1551,7 +1563,7 @@ struct rtllib_softmac_stats{ struct rtllib_info_element_hdr { u8 id; u8 len; -} __attribute__ ((packed)); +} __packed; /* * These are the data types that can make up management packets @@ -1564,7 +1576,7 @@ struct rtllib_info_element_hdr { u16 listen_interval; struct { u16 association_id:14, reserved:2; - } __attribute__ ((packed)); + } __packed; u32 time_stamp[2]; u16 reason; u16 status; @@ -1611,13 +1623,14 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; 0) #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ -#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address plus ether type*/ +#define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address + * plus ether type*/ struct ether_header { u8 ether_dhost[ETHER_ADDR_LEN]; u8 ether_shost[ETHER_ADDR_LEN]; u16 ether_type; -} __attribute__((packed)); +} __packed; #ifndef ETHERTYPE_PAE #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ @@ -1676,13 +1689,13 @@ struct rtllib_network { u8 wzc_ie[MAX_WZC_IE_LEN]; size_t wzc_ie_len; - struct rtllib_tim_parameters tim; + struct rtllib_tim_parameters tim; u8 dtim_period; u8 dtim_data; u64 last_dtim_sta_time; - u8 wmm_info; - struct rtllib_wmm_ac_param wmm_param[4]; + u8 wmm_info; + struct rtllib_wmm_ac_param wmm_param[4]; u8 Turbo_Enable; u16 CountryIeLen; u8 CountryIeBuf[MAX_IE_LEN]; @@ -1743,13 +1756,13 @@ enum rtllib_state { }; #else enum rtllib_state { - RTLLIB_UNINITIALIZED = 0, - RTLLIB_INITIALIZED, - RTLLIB_ASSOCIATING, - RTLLIB_ASSOCIATED, - RTLLIB_AUTHENTICATING, - RTLLIB_AUTHENTICATED, - RTLLIB_SHUTDOWN + RTLLIB_UNINITIALIZED = 0, + RTLLIB_INITIALIZED, + RTLLIB_ASSOCIATING, + RTLLIB_ASSOCIATED, + RTLLIB_AUTHENTICATING, + RTLLIB_AUTHENTICATED, + RTLLIB_SHUTDOWN }; #endif @@ -1763,14 +1776,16 @@ enum rtllib_state { #define RTLLIB_24GHZ_MIN_CHANNEL 1 #define RTLLIB_24GHZ_MAX_CHANNEL 14 #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ - RTLLIB_24GHZ_MIN_CHANNEL + 1) + RTLLIB_24GHZ_MIN_CHANNEL + 1) #define RTLLIB_52GHZ_MIN_CHANNEL 34 #define RTLLIB_52GHZ_MAX_CHANNEL 165 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \ - RTLLIB_52GHZ_MIN_CHANNEL + 1) + RTLLIB_52GHZ_MIN_CHANNEL + 1) #ifndef eqMacAddr -#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) +#define eqMacAddr(a, b) \ + (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && \ + (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0) #endif struct tx_pending { int frag; @@ -1791,7 +1806,7 @@ struct bandwidth_autoswitch { struct rx_reorder_entry { struct list_head List; u16 SeqNum; - struct rtllib_rxb* prxb; + struct rtllib_rxb *prxb; }; enum fsync_state { Default_Fsync, @@ -1936,7 +1951,7 @@ enum country_code_type { }; enum scan_op_backup_opt { - SCAN_OPT_BACKUP=0, + SCAN_OPT_BACKUP = 0, SCAN_OPT_RESTORE, SCAN_OPT_MAX }; @@ -1949,10 +1964,10 @@ enum fw_cmd_io_type { FW_CMD_HIGH_PWR_ENABLE = 4, FW_CMD_HIGH_PWR_DISABLE = 5, FW_CMD_RA_RESET = 6, - FW_CMD_RA_ACTIVE= 7, - FW_CMD_RA_REFRESH_N= 8, - FW_CMD_RA_REFRESH_BG= 9, - FW_CMD_RA_INIT= 10, + FW_CMD_RA_ACTIVE = 7, + FW_CMD_RA_REFRESH_N = 8, + FW_CMD_RA_REFRESH_BG = 9, + FW_CMD_RA_INIT = 10, FW_CMD_IQK_ENABLE = 11, FW_CMD_TXPWR_TRACK_ENABLE = 12, FW_CMD_TXPWR_TRACK_DISABLE = 13, @@ -2046,17 +2061,17 @@ enum ratr_table_mode_8192s { #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { - u8 bUsed; - u8 Bssid[6]; - u8 PMKID[16]; - u8 SsidBuf[33]; - u8* ssid_octet; - u16 ssid_length; + u8 bUsed; + u8 Bssid[6]; + u8 PMKID[16]; + u8 SsidBuf[33]; + u8 *ssid_octet; + u16 ssid_length; }; struct rt_intel_promisc_mode { - bool bPromiscuousOn; - bool bFilterSourceStationFrame; + bool bPromiscuousOn; + bool bFilterSourceStationFrame; }; @@ -2070,14 +2085,14 @@ struct rt_intel_promisc_mode { enum { NO_USE = 0, USED = 1, - HW_SEC = 2, + HW_SEC = 2, SW_SEC = 3, }; enum { LPS_IS_WAKE = 0, LPS_IS_SLEEP = 1, - LPS_WAIT_NULL_DATA_SEND =2, + LPS_WAIT_NULL_DATA_SEND = 2, }; struct rtllib_device { @@ -2113,7 +2128,7 @@ struct rtllib_device { u8 hwsec_active; bool is_silent_reset; - bool force_mic_error; + bool force_mic_error; bool is_roaming; bool ieee_up; bool cannot_notify; @@ -2135,10 +2150,10 @@ struct rtllib_device { u8 Regdot11TxHTOperationalRateSet[16]; u8 dot11HTOperationalRateSet[16]; u8 RegHTSuppRateSet[16]; - u8 HTCurrentOperaRate; - u8 HTHighestOperaRate; - u8 MinSpaceCfg; - u8 MaxMssDensity; + u8 HTCurrentOperaRate; + u8 HTHighestOperaRate; + u8 MinSpaceCfg; + u8 MaxMssDensity; u8 bTxDisableRateFallBack; u8 bTxUseDriverAssingedRate; u8 bTxEnableFwCalcDur; @@ -2193,15 +2208,15 @@ struct rtllib_device { int host_encrypt; int host_encrypt_msdu; int host_decrypt; - /* host performs multicast decryption */ - int host_mc_decrypt; + /* host performs multicast decryption */ + int host_mc_decrypt; - /* host should strip IV and ICV from protected frames */ - /* meaningful only when hardware decryption is being used */ - int host_strip_iv_icv; + /* host should strip IV and ICV from protected frames */ + /* meaningful only when hardware decryption is being used */ + int host_strip_iv_icv; - int host_open_frag; - int host_build_iv; + int host_open_frag; + int host_build_iv; int ieee802_1x; /* is IEEE 802.1X used */ /* WPA data */ @@ -2224,7 +2239,7 @@ struct rtllib_device { int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY]; struct timer_list crypt_deinit_timer; - int crypt_quiesced; + int crypt_quiesced; int bcrx_sta_key; /* use individual keys to override default keys even * with RX of broad/multicast frames */ @@ -2238,10 +2253,10 @@ struct rtllib_device { #define DEFAULT_RTS_THRESHOLD 2346U #define MIN_RTS_THRESHOLD 1 #define MAX_RTS_THRESHOLD 2346U - u16 rts; /* RTS threshold */ + u16 rts; /* RTS threshold */ - /* Association info */ - u8 bssid[ETH_ALEN]; + /* Association info */ + u8 bssid[ETH_ALEN]; /* This stores infos for the current network. * Either the network we are associated in INFRASTRUCTURE @@ -2260,20 +2275,20 @@ struct rtllib_device { int mode; /* A, B, G */ int modulation; /* CCK, OFDM */ int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ - int abg_true; /* ABG flag */ + int abg_true; /* ABG flag */ /* used for forcing the ibss workqueue to terminate * without wait for the syncro scan to terminate */ short sync_scan_hurryup; u16 scan_watch_dog; - int perfect_rssi; - int worst_rssi; + int perfect_rssi; + int worst_rssi; - u16 prev_seq_ctl; /* used to drop duplicate frames */ + u16 prev_seq_ctl; /* used to drop duplicate frames */ /* map of allowed channels. 0 is dummy */ - void* pDot11dInfo; + void *pDot11dInfo; bool bGlobalDomain; u8 active_channel_map[MAX_CHANNEL_NUMBER+1]; @@ -2417,11 +2432,11 @@ struct rtllib_device { struct net_device *dev); int (*reset_port)(struct net_device *dev); - int (*is_queue_full) (struct net_device * dev, int pri); + int (*is_queue_full)(struct net_device *dev, int pri); - int (*handle_management) (struct net_device * dev, - struct rtllib_network * network, u16 type); - int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); + int (*handle_management)(struct net_device *dev, + struct rtllib_network *network, u16 type); + int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb); /* Softmac-generated frames (mamagement) are TXed via this * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is @@ -2440,7 +2455,7 @@ struct rtllib_device { * This function can't sleep. */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, - struct net_device *dev,int rate); + struct net_device *dev, int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating @@ -2455,7 +2470,7 @@ struct rtllib_device { * This function can sleep. the driver should ensure * the radio has been swithced before return. */ - void (*set_chan)(struct net_device *dev,short ch); + void (*set_chan)(struct net_device *dev, short ch); /* These are not used if the ieee stack takes care of * scanning (IEEE_SOFTMAC_SCAN feature set). @@ -2492,41 +2507,55 @@ struct rtllib_device { * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ - void (*start_send_beacons) (struct net_device *dev); - void (*stop_send_beacons) (struct net_device *dev); + void (*start_send_beacons)(struct net_device *dev); + void (*stop_send_beacons)(struct net_device *dev); /* power save mode related */ - void (*sta_wake_up) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u64 time); - short (*ps_is_queue_empty) (struct net_device *dev); - int (*handle_beacon) (struct net_device * dev, struct rtllib_beacon * beacon, struct rtllib_network * network); - int (*handle_assoc_response) (struct net_device * dev, struct rtllib_assoc_response_frame * resp, struct rtllib_network * network); + void (*sta_wake_up)(struct net_device *dev); + void (*enter_sleep_state)(struct net_device *dev, u64 time); + short (*ps_is_queue_empty)(struct net_device *dev); + int (*handle_beacon)(struct net_device *dev, + struct rtllib_beacon *beacon, + struct rtllib_network *network); + int (*handle_assoc_response)(struct net_device *dev, + struct rtllib_assoc_response_frame *resp, + struct rtllib_network *network); /* check whether Tx hw resouce available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); short (*get_nic_desc_num)(struct net_device *dev, int queue_index); - void (*SetBWModeHandler)(struct net_device *dev, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); - bool (*GetNmodeSupportBySecCfg)(struct net_device* dev); - void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode); - bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev); + void (*SetBWModeHandler)(struct net_device *dev, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); + bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); + void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); + bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev); u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value); void (*InitialGainHandler)(struct net_device *dev, u8 Operation); - bool (*SetFwCmdHandler)(struct net_device *dev, enum fw_cmd_io_type FwCmdIO); - void (*UpdateHalRAMaskHandler)(struct net_device* dev, bool bMulticast, u8 macId, u8 MimoPs, u8 WirelessMode, u8 bCurTxBW40MHz, u8 rssi_level); - void (*UpdateBeaconInterruptHandler)(struct net_device* dev, bool start); - void (*UpdateInterruptMaskHandler)(struct net_device* dev, u32 AddMSR, u32 RemoveMSR); + bool (*SetFwCmdHandler)(struct net_device *dev, + enum fw_cmd_io_type FwCmdIO); + void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast, + u8 macId, u8 MimoPs, u8 WirelessMode, + u8 bCurTxBW40MHz, u8 rssi_level); + void (*UpdateBeaconInterruptHandler)(struct net_device *dev, + bool start); + void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR, + u32 RemoveMSR); u16 (*rtl_11n_user_show_rates)(struct net_device *dev); - void (*ScanOperationBackupHandler)(struct net_device *dev, u8 Operation); - void (*LedControlHandler)(struct net_device * dev, enum led_ctl_mode LedAction); - void (*SetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); - void (*GetHwRegHandler)(struct net_device *dev,u8 variable,u8* val); + void (*ScanOperationBackupHandler)(struct net_device *dev, + u8 Operation); + void (*LedControlHandler)(struct net_device *dev, + enum led_ctl_mode LedAction); + void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); + void (*GetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); - void (*AllowAllDestAddrHandler)(struct net_device *dev, bool bAllowAllDA, bool WriteIntoReg); + void (*AllowAllDestAddrHandler)(struct net_device *dev, + bool bAllowAllDA, bool WriteIntoReg); - void (*rtllib_ips_leave_wq) (struct net_device *dev); - void (*rtllib_ips_leave)(struct net_device *dev); + void (*rtllib_ips_leave_wq) (struct net_device *dev); + void (*rtllib_ips_leave)(struct net_device *dev); void (*LeisurePSLeave)(struct net_device *dev); void (*rtllib_rfkill_poll)(struct net_device *dev); @@ -2535,9 +2564,9 @@ struct rtllib_device { u8 priv[0]; }; -#define IEEE_A (1<<0) -#define IEEE_B (1<<1) -#define IEEE_G (1<<2) +#define IEEE_A (1<<0) +#define IEEE_B (1<<1) +#define IEEE_G (1<<2) #define IEEE_N_24G (1<<4) #define IEEE_N_5G (1<<5) #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) @@ -2650,45 +2679,45 @@ extern inline int rtllib_get_hdrlen(u16 fc) static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr) { - switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { - case RTLLIB_1ADDR_LEN: - return ((struct rtllib_hdr_1addr *)hdr)->payload; - case RTLLIB_2ADDR_LEN: - return ((struct rtllib_hdr_2addr *)hdr)->payload; - case RTLLIB_3ADDR_LEN: - return ((struct rtllib_hdr_3addr *)hdr)->payload; - case RTLLIB_4ADDR_LEN: - return ((struct rtllib_hdr_4addr *)hdr)->payload; - } - return NULL; + switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { + case RTLLIB_1ADDR_LEN: + return ((struct rtllib_hdr_1addr *)hdr)->payload; + case RTLLIB_2ADDR_LEN: + return ((struct rtllib_hdr_2addr *)hdr)->payload; + case RTLLIB_3ADDR_LEN: + return ((struct rtllib_hdr_3addr *)hdr)->payload; + case RTLLIB_4ADDR_LEN: + return ((struct rtllib_hdr_4addr *)hdr)->payload; + } + return NULL; } static inline int rtllib_is_ofdm_rate(u8 rate) { - switch (rate & ~RTLLIB_BASIC_RATE_MASK) { - case RTLLIB_OFDM_RATE_6MB: - case RTLLIB_OFDM_RATE_9MB: - case RTLLIB_OFDM_RATE_12MB: - case RTLLIB_OFDM_RATE_18MB: - case RTLLIB_OFDM_RATE_24MB: - case RTLLIB_OFDM_RATE_36MB: - case RTLLIB_OFDM_RATE_48MB: - case RTLLIB_OFDM_RATE_54MB: - return 1; - } - return 0; + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_OFDM_RATE_6MB: + case RTLLIB_OFDM_RATE_9MB: + case RTLLIB_OFDM_RATE_12MB: + case RTLLIB_OFDM_RATE_18MB: + case RTLLIB_OFDM_RATE_24MB: + case RTLLIB_OFDM_RATE_36MB: + case RTLLIB_OFDM_RATE_48MB: + case RTLLIB_OFDM_RATE_54MB: + return 1; + } + return 0; } static inline int rtllib_is_cck_rate(u8 rate) { - switch (rate & ~RTLLIB_BASIC_RATE_MASK) { - case RTLLIB_CCK_RATE_1MB: - case RTLLIB_CCK_RATE_2MB: - case RTLLIB_CCK_RATE_5MB: - case RTLLIB_CCK_RATE_11MB: - return 1; - } - return 0; + switch (rate & ~RTLLIB_BASIC_RATE_MASK) { + case RTLLIB_CCK_RATE_1MB: + case RTLLIB_CCK_RATE_2MB: + case RTLLIB_CCK_RATE_5MB: + case RTLLIB_CCK_RATE_11MB: + return 1; + } + return 0; } @@ -2716,8 +2745,8 @@ extern void rtllib_rx_mgt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *stats); extern void rtllib_rx_probe_rq(struct rtllib_device *ieee, - struct sk_buff *skb); -extern int IsLegalChannel( struct rtllib_device *rtllib, u8 channel); + struct sk_buff *skb); +extern int IsLegalChannel(struct rtllib_device *rtllib, u8 channel); /* rtllib_wx.c */ extern int rtllib_wx_get_scan(struct rtllib_device *ieee, @@ -2731,30 +2760,33 @@ extern int rtllib_wx_get_encode(struct rtllib_device *ieee, union iwreq_data *wrqu, char *key); #if WIRELESS_EXT >= 18 extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); #endif extern int rtllib_wx_set_auth(struct rtllib_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra); + struct iw_request_info *info, + struct iw_param *data, char *extra); extern int rtllib_wx_set_mlme(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len); /* rtllib_softmac.c */ extern short rtllib_is_54g(struct rtllib_network *net); extern short rtllib_is_shortslot(struct rtllib_network net); -extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, u16 type, - u16 stype); -extern void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net); +extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype); +extern void rtllib_softmac_new_net(struct rtllib_device *ieee, + struct rtllib_network *net); void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn); -extern void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee); +extern void rtllib_softmac_xmit(struct rtllib_txb *txb, + struct rtllib_device *ieee); extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); extern void notify_wx_assoc_event(struct rtllib_device *ieee); @@ -2772,21 +2804,28 @@ extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee); extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee); extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee); -extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr); +extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, + short pwr); extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee); extern void rtllib_check_all_nets(struct rtllib_device *ieee); extern void rtllib_start_protocol(struct rtllib_device *ieee); extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown); -extern void rtllib_EnableNetMonitorMode(struct net_device* dev, bool bInitState); -extern void rtllib_DisableNetMonitorMode(struct net_device* dev, bool bInitState); -extern void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, bool bInitState); -extern void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, bool bInitState); +extern void rtllib_EnableNetMonitorMode(struct net_device *dev, + bool bInitState); +extern void rtllib_DisableNetMonitorMode(struct net_device *dev, + bool bInitState); +extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, + bool bInitState); +extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, + bool bInitState); extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh); -extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown); -extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,u8 mesh_flag); +extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, + u8 mesh_flag, u8 shutdown); +extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee, + u8 mesh_flag); extern void rtllib_reset_queue(struct rtllib_device *ieee); extern void rtllib_wake_queue(struct rtllib_device *ieee); @@ -2796,13 +2835,16 @@ extern void rtllib_stop_all_queues(struct rtllib_device *ieee); extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee); extern void rtllib_start_send_beacons(struct rtllib_device *ieee); extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); -extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh); +extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, + struct iw_point *p, u8 is_mesh); extern void notify_wx_assoc_event(struct rtllib_device *ieee); extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success); -extern void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee); -extern u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst); +extern void softmac_mgmt_xmit(struct sk_buff *skb, + struct rtllib_device *ieee); +extern u16 rtllib_query_seqnum(struct rtllib_device *ieee, + struct sk_buff *skb, u8 *dst); extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee); /* rtllib_crypt_ccmp&tkip&wep.c */ @@ -2813,42 +2855,49 @@ extern void rtllib_ccmp_null(void); /* rtllib_softmac_wx.c */ extern int rtllib_wx_get_wap(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *ext); + struct iw_request_info *info, + union iwreq_data *wrqu, char *ext); extern int rtllib_wx_set_wap(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra); + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra); -extern int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int rtllib_wx_get_essid(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern int rtllib_wx_set_rate(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); extern int rtllib_wx_get_rate(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_mode(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_scan(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern int rtllib_wx_set_essid(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *extra); -extern int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_get_mode(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_set_freq(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +extern int rtllib_wx_get_freq(struct rtllib_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern void rtllib_wx_sync_scan_wq(void *data); extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee, @@ -2875,49 +2924,62 @@ extern int rtllib_wx_get_rts(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); #define MAX_RECEIVE_BUFFER_SIZE 9100 -extern void HTDebugHTCapability(u8* CapIE, u8* TitleString ); -extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString); +extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); +extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); -void HTSetConnectBwMode(struct rtllib_device* ieee, enum ht_channel_width Bandwidth, enum ht_extchnl_offset Offset); -extern void HTUpdateDefaultSetting(struct rtllib_device* ieee); -extern void HTConstructCapabilityElement(struct rtllib_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt,bool bAssoc); -extern void HTConstructInfoElement(struct rtllib_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt); -extern void HTConstructRT2RTAggElement(struct rtllib_device* ieee, u8* posRT2RTAgg, u8* len); +void HTSetConnectBwMode(struct rtllib_device *ieee, + enum ht_channel_width Bandwidth, + enum ht_extchnl_offset Offset); +extern void HTUpdateDefaultSetting(struct rtllib_device *ieee); +extern void HTConstructCapabilityElement(struct rtllib_device *ieee, + u8 *posHTCap, u8 *len, + u8 isEncrypt, bool bAssoc); +extern void HTConstructInfoElement(struct rtllib_device *ieee, + u8 *posHTInfo, u8 *len, u8 isEncrypt); +extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee, + u8 *posRT2RTAgg, u8* len); extern void HTOnAssocRsp(struct rtllib_device *ieee); -extern void HTInitializeHTInfo(struct rtllib_device* ieee); +extern void HTInitializeHTInfo(struct rtllib_device *ieee); extern void HTInitializeBssDesc(struct bss_ht *pBssHT); -extern void HTResetSelfAndSavePeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); -extern void HTUpdateSelfAndPeerSetting(struct rtllib_device* ieee, struct rtllib_network * pNetwork); -extern u8 HTGetHighestMCSRate(struct rtllib_device* ieee, u8* pMCSRateSet, u8* pMCSFilter); +extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork); +extern void HTUpdateSelfAndPeerSetting(struct rtllib_device *ieee, + struct rtllib_network *pNetwork); +extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, + u8 *pMCSFilter); extern u8 MCS_FILTER_ALL[]; extern u16 MCS_DATA_RATE[2][2][77] ; -extern u8 HTCCheck(struct rtllib_device* ieee, u8* pFrame); +extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame); extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo); -extern bool IsHTHalfNmodeAPs(struct rtllib_device* ieee); -extern u16 HTHalfMcsToDataRate(struct rtllib_device* ieee, u8 nMcsRate); -extern u16 HTMcsToDataRate( struct rtllib_device* ieee, u8 nMcsRate); -extern u16 TxCountToDataRate( struct rtllib_device* ieee, u8 nDataRate); -extern int rtllib_rx_ADDBAReq( struct rtllib_device* ieee, struct sk_buff *skb); -extern int rtllib_rx_ADDBARsp( struct rtllib_device* ieee, struct sk_buff *skb); -extern int rtllib_rx_DELBA(struct rtllib_device* ieee,struct sk_buff *skb); -extern void TsInitAddBA( struct rtllib_device* ieee, struct tx_ts_record *pTS, u8 Policy, u8 bOverwritePending); -extern void TsInitDelBA( struct rtllib_device* ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect); +extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee); +extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); +extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); +extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate); +extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb); +extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb); +extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb); +extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, + u8 Policy, u8 bOverwritePending); +extern void TsInitDelBA(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, + enum tr_select TxRxSelect); extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); extern void RxBaInactTimeout(unsigned long data); -extern void ResetBaEntry( struct ba_record *pBA); +extern void ResetBaEntry(struct ba_record *pBA); extern bool GetTs( - struct rtllib_device* ieee, - struct ts_common_info **ppTS, - u8* Addr, - u8 TID, - enum tr_select TxRxSelect, - bool bAddNewTs - ); + struct rtllib_device *ieee, + struct ts_common_info **ppTS, + u8 *Addr, + u8 TID, + enum tr_select TxRxSelect, + bool bAddNewTs +); extern void TSInitialize(struct rtllib_device *ieee); -extern void TsStartAddBaProcess(struct rtllib_device* ieee, struct tx_ts_record *pTxTS); -extern void RemovePeerTS(struct rtllib_device* ieee, u8* Addr); -extern void RemoveAllTS(struct rtllib_device* ieee); +extern void TsStartAddBaProcess(struct rtllib_device *ieee, + struct tx_ts_record *pTxTS); +extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr); +extern void RemoveAllTS(struct rtllib_device *ieee); void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); extern const long rtllib_wlan_frequencies[]; @@ -2932,7 +2994,8 @@ extern inline int rtllib_get_scans(struct rtllib_device *ieee) return ieee->scans; } -static inline const char *escape_essid(const char *essid, u8 essid_len) { +static inline const char *escape_essid(const char *essid, u8 essid_len) +{ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; const char *s = essid; char *d = escaped; @@ -2956,7 +3019,9 @@ static inline const char *escape_essid(const char *essid, u8 essid_len) { return escaped; } -#define CONVERT_RATE(_ieee, _MGN_RATE) (_MGN_RATE #include #include -#include +#include #include #include "rtllib.h" @@ -56,11 +56,11 @@ #define DRV_NAME "rtllib_92e" -void _setup_timer( struct timer_list* ptimer, void* fun, unsigned long data ) +void _setup_timer(struct timer_list* ptimer, void *fun, unsigned long data) { - ptimer->function = fun; - ptimer->data = data; - init_timer( ptimer ); + ptimer->function = fun; + ptimer->data = data; + init_timer(ptimer); } static inline int rtllib_networks_allocate(struct rtllib_device *ieee) @@ -98,14 +98,15 @@ static inline void rtllib_networks_initialize(struct rtllib_device *ieee) INIT_LIST_HEAD(&ieee->network_free_list); INIT_LIST_HEAD(&ieee->network_list); for (i = 0; i < MAX_NETWORK_COUNT; i++) - list_add_tail(&ieee->networks[i].list, &ieee->network_free_list); + list_add_tail(&ieee->networks[i].list, + &ieee->network_free_list); } struct net_device *alloc_rtllib(int sizeof_priv) { struct rtllib_device *ieee = NULL; struct net_device *dev; - int i,err; + int i, err; RTLLIB_DEBUG_INFO("Initializing...\n"); @@ -159,12 +160,11 @@ struct net_device *alloc_rtllib(int sizeof_priv) ieee->raw_tx = 0; ieee->hwsec_active = 0; - memset(ieee->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32); rtllib_softmac_init(ieee); - ieee->pHTInfo = (struct rt_hi_throughput*)kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); - if (ieee->pHTInfo == NULL) - { + ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL); + if (ieee->pHTInfo == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for HTInfo\n"); return NULL; } @@ -192,10 +192,10 @@ struct net_device *alloc_rtllib(int sizeof_priv) return NULL; } - void free_rtllib(struct net_device *dev) { - struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + struct rtllib_device *ieee = (struct rtllib_device *) + netdev_priv_rsl(dev); int i; if (ieee->pHTInfo != NULL) { kfree(ieee->pHTInfo); @@ -219,11 +219,11 @@ void free_rtllib(struct net_device *dev) free_netdev(dev); } -u32 rtllib_debug_level = 0; +u32 rtllib_debug_level; static int debug = \ RTLLIB_DL_ERR ; -struct proc_dir_entry *rtllib_proc = NULL; +struct proc_dir_entry *rtllib_proc; static int show_debug_level(char *page, char **start, off_t offset, int count, int *eof, void *data) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 7ccad8601821..134e69f4ee5b 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -286,7 +286,6 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -#define SN_LESS(a, b) (((a-b)&0x800)!=0) void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, struct cb_desc * tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; From 87d30617c676a18e3c706150f191f2da16047bd4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 8 Aug 2011 12:06:19 -0500 Subject: [PATCH 15/25] staging: rtl8192e: Cleanup checkpatch -f errors - Part XIII With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtl_dm.c will need refactoring. In addition, some of the variables will need renaming. Those changes can be deferred. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_module.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 1490 +++++++++++----------- 2 files changed, 714 insertions(+), 778 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index a2c22cf990d0..dd0d8db01bda 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -56,7 +56,7 @@ #define DRV_NAME "rtllib_92e" -void _setup_timer(struct timer_list* ptimer, void *fun, unsigned long data) +void _setup_timer(struct timer_list *ptimer, void *fun, unsigned long data) { ptimer->function = fun; ptimer->data = data; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 9606bedf16de..205c57508497 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -39,18 +39,18 @@ #include #include #include -#include +#include #include #include "rtllib.h" #include "dot11d.h" static inline void rtllib_monitor_rx(struct rtllib_device *ieee, - struct sk_buff *skb,struct rtllib_rx_stats *rx_status, + struct sk_buff *skb, struct rtllib_rx_stats *rx_status, size_t hdr_length) { skb->dev = ieee->dev; - skb_reset_mac_header(skb); + skb_reset_mac_header(skb); skb_pull(skb, hdr_length); skb->pkt_type = PACKET_OTHERHOST; skb->protocol = __constant_htons(ETH_P_80211_RAW); @@ -61,7 +61,7 @@ static inline void rtllib_monitor_rx(struct rtllib_device *ieee, /* Called only as a tasklet (software IRQ) */ static struct rtllib_frag_entry * rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq, - unsigned int frag, u8 tid,u8 *src, u8 *dst) + unsigned int frag, u8 tid, u8 *src, u8 *dst) { struct rtllib_frag_entry *entry; int i; @@ -103,18 +103,18 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } if (frag == 0) { @@ -125,7 +125,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, 2 /* alignment */ + 8 /* WEP */ + ETH_ALEN /* WDS */ + - (RTLLIB_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */); + (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0) /* QOS Control */); if (skb == NULL) return NULL; @@ -146,7 +146,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee, } else { /* received a fragment of a frame for which the head fragment * should have already been received */ - entry = rtllib_frag_cache_find(ieee, seq, frag, tid,hdr->addr2, + entry = rtllib_frag_cache_find(ieee, seq, frag, tid, hdr->addr2, hdr->addr1); if (entry != NULL) { entry->last_frag = frag; @@ -170,21 +170,21 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)hdr; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } - entry = rtllib_frag_cache_find(ieee, seq, -1, tid,hdr->addr2, + entry = rtllib_frag_cache_find(ieee, seq, -1, tid, hdr->addr2, hdr->addr1); if (entry == NULL) { @@ -198,8 +198,6 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee, return 0; } - - /* rtllib_rx_frame_mgtmt * * Responsible for handling management control frames @@ -217,7 +215,7 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_hdr_3addr * hdr = (struct rtllib_hdr_3addr *)skb->data; rx_stats->len = skb->len; - rtllib_rx_mgt(ieee,skb,rx_stats); + rtllib_rx_mgt(ieee, skb, rx_stats); if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN))) { dev_kfree_skb_any(skb); return 0; @@ -231,11 +229,13 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb, /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static unsigned char rfc1042_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +static unsigned char rfc1042_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 +}; /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static unsigned char bridge_tunnel_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; +static unsigned char bridge_tunnel_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 +}; /* No encapsulation header if EtherType < 0x600 (=length) */ /* Called by rtllib_rx_frame_decrypt */ @@ -280,8 +280,8 @@ static int rtllib_is_eapol_frame(struct rtllib_device *ieee, /* Called only as a tasklet (software IRQ), by rtllib_rx */ static inline int -rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, - struct rtllib_crypt_data *crypt) +rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_crypt_data *crypt) { struct rtllib_hdr_4addr *hdr; int res, hdrlen; @@ -289,9 +289,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) return 0; - if (ieee->hwsec_active) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + if (ieee->hwsec_active) { + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) @@ -322,7 +321,7 @@ rtllib_rx_frame_decrypt(struct rtllib_device* ieee, struct sk_buff *skb, /* Called only as a tasklet (software IRQ), by rtllib_rx */ static inline int -rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, +rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, int keyidx, struct rtllib_crypt_data *crypt) { struct rtllib_hdr_4addr *hdr; @@ -330,9 +329,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) return 0; - if (ieee->hwsec_active) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); + if (ieee->hwsec_active) { + struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; if (ieee->need_sw_enc) @@ -343,7 +341,7 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device* ieee, struct sk_buff *skb, hdrlen = rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); - res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv,ieee); + res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv, ieee); atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" @@ -371,18 +369,18 @@ static int is_duplicate_packet(struct rtllib_device *ieee, struct rtllib_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS)&&RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; - tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) { + hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header; + tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else if (RTLLIB_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct rtllib_hdr_3addrqos*)header; - tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; - tid = UP2AC(tid); - tid ++; + hdr_3addrqos = (struct rtllib_hdr_3addrqos *)header; + tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & RTLLIB_QCTL_TID; + tid = UP2AC(tid); + tid++; } else { - tid = 0; + tid = 0; } switch (ieee->iw_mode) { @@ -427,10 +425,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee, if ((*last_seq == seq) && time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) { - if (*last_frag == frag){ + if (*last_frag == frag) goto drop; - - } if (*last_frag + 1 != frag) /* out-of-order fragment */ goto drop; @@ -445,28 +441,18 @@ drop: return 1; } -bool -AddReorderEntry( - struct rx_ts_record *pTS, - struct rx_reorder_entry *pReorderEntry - ) + +bool AddReorderEntry(struct rx_ts_record *pTS, struct rx_reorder_entry *pReorderEntry) { struct list_head *pList = &pTS->RxPendingPktList; - while(pList->next != &pTS->RxPendingPktList) - { - if ( SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) - { + while (pList->next != &pTS->RxPendingPktList) { + if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) pList = pList->next; - } - else if ( SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next,struct rx_reorder_entry,List))->SeqNum) ) - { + else if (SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) return false; - } else - { break; - } } pReorderEntry->List.next = pList->next; pReorderEntry->List.next->prev = &pReorderEntry->List; @@ -476,24 +462,24 @@ AddReorderEntry( return true; } -void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prxbIndicateArray,u8 index) +void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index) { struct net_device_stats *stats = &ieee->stats; - u8 i = 0 , j=0; + u8 i = 0 , j = 0; u16 ethertype; for (j = 0; j < index; j++) { - struct rtllib_rxb* prxb = prxbIndicateArray[j]; - for (i = 0; inr_subframes; i++) { + struct rtllib_rxb *prxb = prxbIndicateArray[j]; + for (i = 0; i < prxb->nr_subframes; i++) { struct sk_buff *sub_skb = prxb->subframes[i]; /* convert hdr + possible LLC headers into Ethernet header */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and - * replace EtherType */ + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation + * and replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN); memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); @@ -506,7 +492,7 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN); } - /* Indicat the packets to upper layer */ + /* Indicat the packets to upper layer */ if (sub_skb) { stats->rx_packets++; stats->rx_bytes += sub_skb->len; @@ -526,24 +512,21 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb** prx } } -void -rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) +void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS) { struct rx_reorder_entry *pRxReorderEntry; - struct rtllib_rxb* RfdArray[REORDER_WIN_SIZE]; - u8 RfdCnt = 0; - + struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE]; + u8 RfdCnt = 0; del_timer_sync(&pTS->RxPktPendingTimer); - while(!list_empty(&pTS->RxPendingPktList)) - { - if (RfdCnt >= REORDER_WIN_SIZE){ - printk("-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__); + while (!list_empty(&pTS->RxPendingPktList)) { + if (RfdCnt >= REORDER_WIN_SIZE) { + printk(KERN_INFO "-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__); break; } - pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum); + pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum); list_del_init(&pRxReorderEntry->List); RfdArray[RfdCnt] = pRxReorderEntry->prxb; @@ -556,41 +539,38 @@ rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS pTS->RxIndicateSeq = 0xffff; } - -void RxReorderIndicatePacket( struct rtllib_device *ieee, - struct rtllib_rxb* prxb, - struct rx_ts_record *pTS, - u16 SeqNum) +void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb, + struct rx_ts_record *pTS, u16 SeqNum) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; - struct rtllib_rxb* prxbIndicateArray[REORDER_WIN_SIZE]; - u8 WinSize = pHTInfo->RxReorderWinSize; - u16 WinEnd = 0; - u8 index = 0; - bool bMatchWinStart = false, bPktInBuf = false; + struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE]; + u8 WinSize = pHTInfo->RxReorderWinSize; + u16 WinEnd = 0; + u8 index = 0; + bool bMatchWinStart = false, bPktInBuf = false; unsigned long flags; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Seq is %d, pTS->RxIndicateSeq" + " is %d, WinSize is %d\n", __func__, SeqNum, + pTS->RxIndicateSeq, WinSize); spin_lock_irqsave(&(ieee->reorder_spinlock), flags); - WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096; + WinEnd = (pTS->RxIndicateSeq + WinSize - 1) % 4096; /* Rx Reorder initialize condition.*/ - if (pTS->RxIndicateSeq == 0xffff) { + if (pTS->RxIndicateSeq == 0xffff) pTS->RxIndicateSeq = SeqNum; - } /* Drop out the packet which SeqNum is smaller than WinStart */ if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n", + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); pHTInfo->RxReorderDropCounter++; { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } @@ -607,33 +587,38 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; bMatchWinStart = true; } else if (SN_LESS(WinEnd, SeqNum)) { - if (SeqNum >= (WinSize - 1)) { - pTS->RxIndicateSeq = SeqNum + 1 -WinSize; - } else { - pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1; - } - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + if (SeqNum >= (WinSize - 1)) + pTS->RxIndicateSeq = SeqNum + 1 - WinSize; + else + pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1; + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d," + " NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); } /* * Indication process. - * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets - * with the SeqNum smaller than latest WinStart and struct buffer other packets. + * After Packet dropping and Sliding Window shifting as above, we can + * now just indicate the packets with the SeqNum smaller than latest + * WinStart and struct buffer other packets. */ /* For Rx Reorder condition: * 1. All packets with SeqNum smaller than WinStart => Indicate - * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. + * 2. All packets with SeqNum larger than or equal to + * WinStart => Buffer it. */ if (bMatchWinStart) { /* Current packet is going to be indicated.*/ - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\ + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! " + "IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum); prxbIndicateArray[0] = prxb; index = 1; } else { /* Current packet is going to be inserted into pending list.*/ if (!list_empty(&ieee->RxReorder_Unused_List)) { - pReorderEntry = (struct rx_reorder_entry *)list_entry(ieee->RxReorder_Unused_List.next,struct rx_reorder_entry,List); + pReorderEntry = (struct rx_reorder_entry *) + list_entry(ieee->RxReorder_Unused_List.next, + struct rx_reorder_entry, List); list_del_init(&pReorderEntry->List); /* Make a reorder entry and insert into a the packet list.*/ @@ -641,34 +626,40 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pReorderEntry->prxb = prxb; if (!AddReorderEntry(pTS, pReorderEntry)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", - __func__, pTS->RxIndicateSeq, SeqNum); - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); - { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, + "%s(): Duplicate packet is " + "dropped!! IndicateSeq: %d, " + "NewSeq: %d\n", + __func__, pTS->RxIndicateSeq, + SeqNum); + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } } else { RTLLIB_DEBUG(RTLLIB_DL_REORDER, - "Pkt insert into struct buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); + "Pkt insert into struct buffer!! " + "IndicateSeq: %d, NewSeq: %d\n", + pTS->RxIndicateSeq, SeqNum); } - } - else { + } else { /* - * Packets are dropped if there is not enough reorder entries. - * This part shall be modified!! We can just indicate all the - * packets in struct buffer and get reorder entries. + * Packets are dropped if there are not enough reorder + * entries. This part should be modified!! We can just + * indicate all the packets in struct buffer and get + * reorder entries. */ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " There is no reorder entry!! Packet is " + "dropped!!\n"); { int i; - for (i =0; i < prxb->nr_subframes; i++) { + for (i = 0; i < prxb->nr_subframes; i++) dev_kfree_skb(prxb->subframes[i]); - } kfree(prxb); prxb = NULL; } @@ -676,16 +667,17 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, } /* Check if there is any packet need indicate.*/ - while(!list_empty(&pTS->RxPendingPktList)) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); + while (!list_empty(&pTS->RxPendingPktList)) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): start RREORDER indicate\n", __func__); - pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,struct rx_reorder_entry,List); - if ( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || - SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) - { + pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, + struct rx_reorder_entry, List); + if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || + SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) { /* This protect struct buffer from overflow. */ if (index >= REORDER_WIN_SIZE) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicate" + "Packet(): Buffer overflow!!\n"); bPktInBuf = true; break; } @@ -696,74 +688,76 @@ void RxReorderIndicatePacket( struct rtllib_device *ieee, pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096; prxbIndicateArray[index] = pReorderEntry->prxb; - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum %d!\n",__func__, pReorderEntry->SeqNum); + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum" + " %d!\n", __func__, pReorderEntry->SeqNum); index++; - list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); + list_add_tail(&pReorderEntry->List, + &ieee->RxReorder_Unused_List); } else { bPktInBuf = true; break; } } - /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/ - if (index>0) { - if (timer_pending(&pTS->RxPktPendingTimer)){ + /* Handling pending timer. Set this timer to prevent from long time + * Rx buffering.*/ + if (index > 0) { + if (timer_pending(&pTS->RxPktPendingTimer)) del_timer_sync(&pTS->RxPktPendingTimer); - } pTS->RxTimeoutIndicateSeq = 0xffff; - if (index>REORDER_WIN_SIZE){ - RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer struct buffer full!! \n"); - spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); + if (index > REORDER_WIN_SIZE) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" + " Rx Reorer struct buffer full!!\n"); + spin_unlock_irqrestore(&(ieee->reorder_spinlock), + flags); return; } rtllib_indicate_packets(ieee, prxbIndicateArray, index); bPktInBuf = false; } - if (bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { - RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); + if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) { + RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): SET rx timeout timer\n", + __func__); pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; - mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime)); + mod_timer(&pTS->RxPktPendingTimer, jiffies + + MSECS(pHTInfo->RxReorderPendingTime)); } spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb *rxb,u8* src,u8* dst) +u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb *rxb, u8 *src, u8 *dst) { - struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr* )skb->data; + struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); - u16 LLCOffset= sizeof(struct rtllib_hdr_3addr); + u16 LLCOffset = sizeof(struct rtllib_hdr_3addr); u16 ChkLength; bool bIsAggregateFrame = false; u16 nSubframe_Length; u8 nPadding_Length = 0; - u16 SeqNum=0; + u16 SeqNum = 0; struct sk_buff *sub_skb; - u8 *data_ptr; + u8 *data_ptr; /* just for debug purpose */ SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl)); - if ((RTLLIB_QOS_HAS_SEQ(fc))&&\ - (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) { + if ((RTLLIB_QOS_HAS_SEQ(fc)) && + (((union frameqos *)(skb->data + RTLLIB_3ADDR_LEN))->field.reserved)) bIsAggregateFrame = true; - } - if (RTLLIB_QOS_HAS_SEQ(fc)) { + if (RTLLIB_QOS_HAS_SEQ(fc)) LLCOffset += 2; - } - if (rx_stats->bContainHTC) { + if (rx_stats->bContainHTC) LLCOffset += sHTCLng; - } - ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/ + ChkLength = LLCOffset; - if ( skb->len <= ChkLength ) { + if (skb->len <= ChkLength) return 0; - } skb_pull(skb, LLCOffset); ieee->bIsAggregateFrame = bIsAggregateFrame; @@ -787,25 +781,31 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, rxb->subframes[0] = sub_skb; - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); + memcpy(rxb->src, src, ETH_ALEN); + memcpy(rxb->dst, dst, ETH_ALEN); rxb->subframes[0]->dev = ieee->dev; return 1; } else { rxb->nr_subframes = 0; - memcpy(rxb->src,src,ETH_ALEN); - memcpy(rxb->dst,dst,ETH_ALEN); - while(skb->len > ETHERNET_HEADER_SIZE) { + memcpy(rxb->src, src, ETH_ALEN); + memcpy(rxb->dst, dst, ETH_ALEN); + while (skb->len > ETHERNET_HEADER_SIZE) { /* Offset 12 denote 2 mac address */ - nSubframe_Length = *((u16*)(skb->data + 12)); - nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8); + nSubframe_Length = *((u16 *)(skb->data + 12)); + nSubframe_Length = (nSubframe_Length >> 8) + + (nSubframe_Length << 8); - if (skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) { - printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\ - __func__,rxb->nr_subframes); - printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__func__, nSubframe_Length); - printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length); - printk("The Packet SeqNum is %d\n",SeqNum); + if (skb->len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { + printk(KERN_INFO "%s: A-MSDU parse error!! " + "pRfd->nTotalSubframe : %d\n",\ + __func__, rxb->nr_subframes); + printk(KERN_INFO "%s: A-MSDU parse error!! " + "Subframe Length: %d\n", __func__, + nSubframe_Length); + printk(KERN_INFO "nRemain_Length is %d and " + "nSubframe_Length is : %d\n", skb->len, + nSubframe_Length); + printk(KERN_INFO "The Packet SeqNum is %d\n", SeqNum); return 0; } @@ -824,27 +824,27 @@ u8 parse_subframe(struct rtllib_device* ieee,struct sk_buff *skb, sub_skb = dev_alloc_skb(nSubframe_Length + 12); skb_reserve(sub_skb, 12); data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); - memcpy(data_ptr,skb->data,nSubframe_Length); + memcpy(data_ptr, skb->data, nSubframe_Length); sub_skb->dev = ieee->dev; rxb->subframes[rxb->nr_subframes++] = sub_skb; if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) { - RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n"); + RTLLIB_DEBUG_RX("ParseSubframe(): Too many " + "Subframes! Packets dropped!\n"); break; } - skb_pull(skb,nSubframe_Length); + skb_pull(skb, nSubframe_Length); if (skb->len != 0) { - nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4); - if (nPadding_Length == 4) { + nPadding_Length = 4 - ((nSubframe_Length + + ETHERNET_HEADER_SIZE) % 4); + if (nPadding_Length == 4) nPadding_Length = 0; - } - if (skb->len < nPadding_Length) { + if (skb->len < nPadding_Length) return 0; - } - skb_pull(skb,nPadding_Length); + skb_pull(skb, nPadding_Length); } } @@ -863,7 +863,7 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, hdrlen = rtllib_get_hdrlen(fc); if (HTCCheck(ieee, skb->data)) { if (net_ratelimit()) - printk("%s: find HTCControl!\n", __func__); + printk(KERN_INFO "%s: find HTCControl!\n", __func__); hdrlen += 4; rx_stats->bContainHTC = 1; } @@ -874,7 +874,8 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, return hdrlen; } -int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u8 multicast) +int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, + u8 multicast) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc, sc; @@ -886,19 +887,18 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - if ( (ieee->pHTInfo->bCurRxReorderEnable == false) || + if ((ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active || !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)) { - if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))){ - if (is_duplicate_packet(ieee, hdr)){ + if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))) { + if (is_duplicate_packet(ieee, hdr)) return -1; - } } } else { struct rx_ts_record *pRxTS = NULL; if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2, - (u8)Frame_QoSTID((u8*)(skb->data)), RX_DIR, true)) { + (u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) { if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)) { return -1; @@ -907,41 +907,47 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, u pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc); } } else { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n",__func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip" + " the check!!\n", __func__); return -1; } } return 0; } -void rtllib_rx_extract_addr(struct rtllib_device *ieee, struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, u8 *bssid) + +void rtllib_rx_extract_addr(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, + u8 *bssid) { u16 fc = le16_to_cpu(hdr->frame_ctl); switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) { - case RTLLIB_FCTL_FROMDS: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr3, ETH_ALEN); - memcpy(bssid, hdr->addr2, ETH_ALEN); - break; - case RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr1, ETH_ALEN); - break; - case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: - memcpy(dst, hdr->addr3, ETH_ALEN); - memcpy(src, hdr->addr4, ETH_ALEN); - memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); - break; - case 0: - memcpy(dst, hdr->addr1, ETH_ALEN); - memcpy(src, hdr->addr2, ETH_ALEN); - memcpy(bssid, hdr->addr3, ETH_ALEN); - break; + case RTLLIB_FCTL_FROMDS: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr3, ETH_ALEN); + memcpy(bssid, hdr->addr2, ETH_ALEN); + break; + case RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr1, ETH_ALEN); + break; + case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS: + memcpy(dst, hdr->addr3, ETH_ALEN); + memcpy(src, hdr->addr4, ETH_ALEN); + memcpy(bssid, ieee->current_network.bssid, ETH_ALEN); + break; + case 0: + memcpy(dst, hdr->addr1, ETH_ALEN); + memcpy(src, hdr->addr2, ETH_ALEN); + memcpy(bssid, hdr->addr3, ETH_ALEN); + break; } } -int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, u8 *bssid, u8 *addr2) + +int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, + u8 *bssid, u8 *addr2) { u8 zero_addr[ETH_ALEN] = {0}; u8 type, stype; @@ -951,14 +957,14 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* Filter frames from different BSS */ if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) - && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) - && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { + && (compare_ether_addr(ieee->current_network.bssid, bssid) != 0) + && memcmp(ieee->current_network.bssid, zero_addr, ETH_ALEN)) { return -1; } /* Filter packets sent by an STA that will be forwarded by AP */ - if ( ieee->IntelPromiscuousModeInfo.bPromiscuousOn && - ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame ) { + if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn && + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame) { if ((fc & RTLLIB_FCTL_TODS) && !(fc & RTLLIB_FCTL_FROMDS) && (compare_ether_addr(dst, ieee->current_network.bssid) != 0) && (compare_ether_addr(bssid, ieee->current_network.bssid) == 0)) { @@ -968,13 +974,12 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* Nullfunc frames may have PS-bit set, so they must be passed to * hostap_handle_sta_rx() before being dropped here. */ - if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn){ + if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn) { if (stype != RTLLIB_STYPE_DATA && stype != RTLLIB_STYPE_DATA_CFACK && stype != RTLLIB_STYPE_DATA_CFPOLL && - stype != RTLLIB_STYPE_DATA_CFACKPOLL&& - stype != RTLLIB_STYPE_QOS_DATA - ) { + stype != RTLLIB_STYPE_DATA_CFACKPOLL && + stype != RTLLIB_STYPE_QOS_DATA) { if (stype != RTLLIB_STYPE_NULLFUNC) RTLLIB_DEBUG_DROP( "RX: dropped data frame " @@ -992,18 +997,15 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, /* {broad,multi}cast packets to our BSS go through */ if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) { - if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) { + if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN)) return -1; - } } } return 0; } -int rtllib_rx_get_crypt( - struct rtllib_device *ieee, - struct sk_buff *skb, - struct rtllib_crypt_data **crypt, - size_t hdrlen) + +int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_crypt_data **crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -1035,12 +1037,10 @@ int rtllib_rx_get_crypt( return 0; } -int rtllib_rx_decrypt( - struct rtllib_device *ieee, - struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_crypt_data *crypt, - size_t hdrlen) + +int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_crypt_data *crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr; int keyidx = 0; @@ -1052,15 +1052,14 @@ int rtllib_rx_decrypt( sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); - if ((!rx_stats->Decrypted)){ + if ((!rx_stats->Decrypted)) ieee->need_sw_enc = 1; - }else{ + else ieee->need_sw_enc = 0; - } - if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - ((keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt)) < 0)) { - printk("%s: decrypt frame error\n", __func__); + keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt); + if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && (keyidx < 0)) { + printk(KERN_INFO "%s: decrypt frame error\n", __func__); return -1; } @@ -1120,9 +1119,8 @@ int rtllib_rx_decrypt( /* skb: hdr + (possible reassembled) full MSDU payload; possibly still * encrypted/authenticated */ if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && - rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) - { - printk("%s: ==>decrypt msdu error\n", __func__); + rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) { + printk(KERN_INFO "%s: ==>decrypt msdu error\n", __func__); return -1; } @@ -1164,21 +1162,20 @@ int rtllib_rx_decrypt( return -1; } - if (rtllib_is_eapol_frame(ieee, skb, hdrlen)) { + if (rtllib_is_eapol_frame(ieee, skb, hdrlen)) printk(KERN_WARNING "RX: IEEE802.1X EAPOL frame!\n"); - } return 0; } + void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { - if (unicast){ + if (unicast) { - if ((ieee->state == RTLLIB_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) - { - if ( ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) || - (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) ) - { + if ((ieee->state == RTLLIB_LINKED)) { + if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod + + ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) { if (ieee->LeisurePSLeave) ieee->LeisurePSLeave(ieee->dev); } @@ -1186,10 +1183,10 @@ void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_sub } ieee->last_rx_ps_time = jiffies; } -void rtllib_rx_indicate_pkt_legacy( - struct rtllib_device *ieee, + +void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb* rxb, + struct rtllib_rxb *rxb, u8 *dst, u8 *src) { @@ -1197,21 +1194,21 @@ void rtllib_rx_indicate_pkt_legacy( u16 ethertype; int i = 0; - if (rxb == NULL){ - printk("%s: rxb is NULL!!\n", __func__); + if (rxb == NULL) { + printk(KERN_INFO "%s: rxb is NULL!!\n", __func__); return ; } - for (i = 0; inr_subframes; i++) { + for (i = 0; i < rxb->nr_subframes; i++) { struct sk_buff *sub_skb = rxb->subframes[i]; if (sub_skb) { /* convert hdr + possible LLC headers into Ethernet header */ ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && - ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || - memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { + ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 && + ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) || + memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) { /* remove RFC1042 or Bridge-Tunnel encapsulation and * replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); @@ -1229,9 +1226,8 @@ void rtllib_rx_indicate_pkt_legacy( ieee->stats.rx_packets++; ieee->stats.rx_bytes += sub_skb->len; - if (is_multicast_ether_addr(dst)) { + if (is_multicast_ether_addr(dst)) ieee->stats.multicast++; - } /* Indicat the packets to upper layer */ memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); @@ -1246,13 +1242,14 @@ void rtllib_rx_indicate_pkt_legacy( kfree(rxb); rxb = NULL; } + int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; struct rtllib_crypt_data *crypt = NULL; - struct rtllib_rxb* rxb = NULL; + struct rtllib_rxb *rxb = NULL; struct rx_ts_record *pTS = NULL; u16 fc, sc, SeqNum = 0; u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0; @@ -1279,8 +1276,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /*Filter pkt has too small length */ hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats); - if (skb->len < hdrlen){ - printk("%s():ERR!!! skb->len is smaller than hdrlen\n",__func__); + if (skb->len < hdrlen) { + printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); goto rx_dropped; } @@ -1290,9 +1287,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, goto rx_dropped; /* Filter CTRL Frame */ - if (type == RTLLIB_FTYPE_CTL) { + if (type == RTLLIB_FTYPE_CTL) goto rx_dropped; - } /* Filter MGNT Frame */ if (type == RTLLIB_FTYPE_MGMT) { @@ -1307,7 +1303,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /* Filter WAPI DATA Frame */ /* Update statstics for AP roaming */ - if (!bToOtherSTA){ + if (!bToOtherSTA) { ieee->LinkDetectInfo.NumRecvDataInPeriod++; ieee->LinkDetectInfo.NumRxOkInPeriod++; } @@ -1321,9 +1317,8 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, if (ret < 0) goto rx_dropped; - if (skb->len == hdrlen){ + if (skb->len == hdrlen) goto rx_dropped; - } /* Send pspoll based on moredata */ if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP) @@ -1352,32 +1347,29 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, hdr = (struct rtllib_hdr_4addr *) skb->data; if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data) && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1) - && (!bToOtherSTA)) - { + && (!bToOtherSTA)) { TID = Frame_QoSTID(skb->data); SeqNum = WLAN_GET_SEQ_SEQ(sc); - GetTs(ieee,(struct ts_common_info **) &pTS,hdr->addr2,TID,RX_DIR,true); - if (TID !=0 && TID !=3){ + GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, RX_DIR, true); + if (TID != 0 && TID != 3) ieee->bis_any_nonbepkts = true; - } } /* Parse rx data frame (For AMSDU) */ /* skb: hdr + (possible reassembled) full plaintext payload */ payload = skb->data + hdrlen; - rxb = (struct rtllib_rxb*)kmalloc(sizeof(struct rtllib_rxb),GFP_ATOMIC); - if (rxb == NULL) - { - RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): kmalloc rxb error\n",__func__); + rxb = kmalloc(sizeof(struct rtllib_rxb), GFP_ATOMIC); + if (rxb == NULL) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, + "%s(): kmalloc rxb error\n", __func__); goto rx_dropped; } /* to parse amsdu packets */ /* qos data packets & reserved bit is 1 */ - if (parse_subframe(ieee,skb,rx_stats,rxb,src,dst) == 0) { + if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) { /* only to free rxb, and not submit the packets to upper layer */ - for (i =0; i < rxb->nr_subframes; i++) { + for (i = 0; i < rxb->nr_subframes; i++) dev_kfree_skb(rxb->subframes[i]); - } kfree(rxb); rxb = NULL; goto rx_dropped; @@ -1386,7 +1378,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, /* Update WAPI PN */ /* Check if leave LPS */ - if (!bToOtherSTA){ + if (!bToOtherSTA) { if (ieee->bIsAggregateFrame) nr_subframes = rxb->nr_subframes; else @@ -1397,11 +1389,10 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, } /* Indicate packets to upper layer or Rx Reorder */ - if (ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL || bToOtherSTA){ + if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || bToOtherSTA) rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src); - }else{ + else RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); - } dev_kfree_skb(skb); @@ -1409,8 +1400,7 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, return 1; rx_dropped: - if (rxb != NULL) - { + if (rxb != NULL) { kfree(rxb); rxb = NULL; } @@ -1427,6 +1417,7 @@ int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, { return 0; } + int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { @@ -1434,14 +1425,14 @@ int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, u16 fc = le16_to_cpu(hdr->frame_ctl); size_t hdrlen = rtllib_get_hdrlen(fc); - if (skb->len < hdrlen){ - printk("%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); + if (skb->len < hdrlen) { + printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__); return 0; } if (HTCCheck(ieee, skb->data)) { if (net_ratelimit()) - printk("%s: Find HTCControl!\n", __func__); + printk(KERN_INFO "%s: Find HTCControl!\n", __func__); hdrlen += 4; } @@ -1466,12 +1457,12 @@ int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, { int ret = 0; - if ((NULL==ieee) || (NULL==skb) || (NULL==rx_stats)){ + if ((NULL == ieee) || (NULL == skb) || (NULL == rx_stats)) { printk(KERN_INFO "%s: Input parameters NULL!\n", __func__); goto rx_dropped; } if (skb->len < 10) { - printk(KERN_INFO "%s: SKB length < 10 \n", __func__); + printk(KERN_INFO "%s: SKB length < 10\n", __func__); goto rx_dropped; } @@ -1509,19 +1500,19 @@ static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; * the right values */ static int rtllib_verify_qos_info(struct rtllib_qos_information_element - *info_element, int sub_type) + *info_element, int sub_type) { - if (info_element->qui_subtype != sub_type) - return -1; - if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) - return -1; - if (info_element->qui_type != QOS_OUI_TYPE) - return -1; - if (info_element->version != QOS_VERSION_1) - return -1; + if (info_element->qui_subtype != sub_type) + return -1; + if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) + return -1; + if (info_element->qui_type != QOS_OUI_TYPE) + return -1; + if (info_element->version != QOS_VERSION_1) + return -1; - return 0; + return 0; } @@ -1529,56 +1520,56 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element * Parse a QoS parameter element */ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info - *element_param, struct rtllib_info_element - *info_element) + *element_param, struct rtllib_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; + int ret = 0; + u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; - if ((info_element == NULL) || (element_param == NULL)) - return -1; + if ((info_element == NULL) || (element_param == NULL)) + return -1; - if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { - memcpy(element_param->info_element.qui, info_element->data, - info_element->len); - element_param->info_element.elementID = info_element->id; - element_param->info_element.length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(&element_param->info_element, - QOS_OUI_PARAM_SUB_TYPE); - return ret; + if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { + memcpy(element_param->info_element.qui, info_element->data, + info_element->len); + element_param->info_element.elementID = info_element->id; + element_param->info_element.length = info_element->len; + } else + ret = -1; + if (ret == 0) + ret = rtllib_verify_qos_info(&element_param->info_element, + QOS_OUI_PARAM_SUB_TYPE); + return ret; } /* * Parse a QoS information element */ static int rtllib_read_qos_info_element(struct - rtllib_qos_information_element - *element_info, struct rtllib_info_element - *info_element) + rtllib_qos_information_element + *element_info, struct rtllib_info_element + *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_information_element) - 2; + int ret = 0; + u16 size = sizeof(struct rtllib_qos_information_element) - 2; - if (element_info == NULL) - return -1; - if (info_element == NULL) - return -1; + if (element_info == NULL) + return -1; + if (info_element == NULL) + return -1; - if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { - memcpy(element_info->qui, info_element->data, - info_element->len); - element_info->elementID = info_element->id; - element_info->length = info_element->len; - } else - ret = -1; + if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { + memcpy(element_info->qui, info_element->data, + info_element->len); + element_info->elementID = info_element->id; + element_info->length = info_element->len; + } else + ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); - return ret; + if (ret == 0) + ret = rtllib_verify_qos_info(element_info, + QOS_OUI_INFO_SUB_TYPE); + return ret; } @@ -1588,16 +1579,16 @@ static int rtllib_read_qos_info_element(struct static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm, struct rtllib_qos_data *qos_data) { - struct rtllib_qos_ac_parameter *ac_params; + struct rtllib_qos_ac_parameter *ac_params; struct rtllib_qos_parameters *qos_param = &(qos_data->parameters); - int rc = 0; - int i; + int rc = 0; + int i; u8 aci; u8 acm; qos_data->wmm_acm = 0; - for (i = 0; i < QOS_QUEUE_NUM; i++) { - ac_params = &(param_elm->ac_params_record[i]); + for (i = 0; i < QOS_QUEUE_NUM; i++) { + ac_params = &(param_elm->ac_params_record[i]); aci = (ac_params->aci_aifsn & 0x60) >> 5; acm = (ac_params->aci_aifsn & 0x10) >> 4; @@ -1605,43 +1596,43 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info if (aci >= QOS_QUEUE_NUM) continue; switch (aci) { - case 1: - /* BIT(0) | BIT(3) */ - if (acm) - qos_data->wmm_acm |= (0x01<<0)|(0x01<<3); - break; - case 2: - /* BIT(4) | BIT(5) */ - if (acm) - qos_data->wmm_acm |= (0x01<<4)|(0x01<<5); - break; - case 3: - /* BIT(6) | BIT(7) */ - if (acm) - qos_data->wmm_acm |= (0x01<<6)|(0x01<<7); - break; - case 0: - default: - /* BIT(1) | BIT(2) */ - if (acm) - qos_data->wmm_acm |= (0x01<<1)|(0x01<<2); - break; + case 1: + /* BIT(0) | BIT(3) */ + if (acm) + qos_data->wmm_acm |= (0x01<<0)|(0x01<<3); + break; + case 2: + /* BIT(4) | BIT(5) */ + if (acm) + qos_data->wmm_acm |= (0x01<<4)|(0x01<<5); + break; + case 3: + /* BIT(6) | BIT(7) */ + if (acm) + qos_data->wmm_acm |= (0x01<<6)|(0x01<<7); + break; + case 0: + default: + /* BIT(1) | BIT(2) */ + if (acm) + qos_data->wmm_acm |= (0x01<<1)|(0x01<<2); + break; } - qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; + qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f; /* WMM spec P.11: The minimum value for AIFSN shall be 2 */ - qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci]; + qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci]; - qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; + qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F; - qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; + qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4; - qos_param->flag[aci] = - (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; - qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); - } - return rc; + qos_param->flag[aci] = + (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; + qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); + } + return rc; } /* @@ -1650,96 +1641,94 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info * which type to read */ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element - *info_element, - struct rtllib_network *network) + *info_element, + struct rtllib_network *network) { - int rc = 0; - struct rtllib_qos_information_element qos_info_element; + int rc = 0; + struct rtllib_qos_information_element qos_info_element; - rc = rtllib_read_qos_info_element(&qos_info_element, info_element); + rc = rtllib_read_qos_info_element(&qos_info_element, info_element); - if (rc == 0) { - network->qos_data.param_count = qos_info_element.ac_info & 0x0F; - network->flags |= NETWORK_HAS_QOS_INFORMATION; - } else { - struct rtllib_qos_parameter_info param_element; + if (rc == 0) { + network->qos_data.param_count = qos_info_element.ac_info & 0x0F; + network->flags |= NETWORK_HAS_QOS_INFORMATION; + } else { + struct rtllib_qos_parameter_info param_element; - rc = rtllib_read_qos_param_element(¶m_element, - info_element); - if (rc == 0) { - rtllib_qos_convert_ac_to_parameters(¶m_element, - &(network->qos_data)); - network->flags |= NETWORK_HAS_QOS_PARAMETERS; - network->qos_data.param_count = - param_element.info_element.ac_info & 0x0F; - } - } + rc = rtllib_read_qos_param_element(¶m_element, + info_element); + if (rc == 0) { + rtllib_qos_convert_ac_to_parameters(¶m_element, + &(network->qos_data)); + network->flags |= NETWORK_HAS_QOS_PARAMETERS; + network->qos_data.param_count = + param_element.info_element.ac_info & 0x0F; + } + } - if (rc == 0) { - RTLLIB_DEBUG_QOS("QoS is supported\n"); - network->qos_data.supported = 1; - } - return rc; + if (rc == 0) { + RTLLIB_DEBUG_QOS("QoS is supported\n"); + network->qos_data.supported = 1; + } + return rc; } #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x static const char *get_info_element_string(u16 id) { - switch (id) { - MFIE_STRING(SSID); - MFIE_STRING(RATES); - MFIE_STRING(FH_SET); - MFIE_STRING(DS_SET); - MFIE_STRING(CF_SET); - MFIE_STRING(TIM); - MFIE_STRING(IBSS_SET); - MFIE_STRING(COUNTRY); - MFIE_STRING(HOP_PARAMS); - MFIE_STRING(HOP_TABLE); - MFIE_STRING(REQUEST); - MFIE_STRING(CHALLENGE); - MFIE_STRING(POWER_CONSTRAINT); - MFIE_STRING(POWER_CAPABILITY); - MFIE_STRING(TPC_REQUEST); - MFIE_STRING(TPC_REPORT); - MFIE_STRING(SUPP_CHANNELS); - MFIE_STRING(CSA); - MFIE_STRING(MEASURE_REQUEST); - MFIE_STRING(MEASURE_REPORT); - MFIE_STRING(QUIET); - MFIE_STRING(IBSS_DFS); - MFIE_STRING(RSN); - MFIE_STRING(RATES_EX); - MFIE_STRING(GENERIC); - MFIE_STRING(QOS_PARAMETER); - default: - return "UNKNOWN"; - } + switch (id) { + MFIE_STRING(SSID); + MFIE_STRING(RATES); + MFIE_STRING(FH_SET); + MFIE_STRING(DS_SET); + MFIE_STRING(CF_SET); + MFIE_STRING(TIM); + MFIE_STRING(IBSS_SET); + MFIE_STRING(COUNTRY); + MFIE_STRING(HOP_PARAMS); + MFIE_STRING(HOP_TABLE); + MFIE_STRING(REQUEST); + MFIE_STRING(CHALLENGE); + MFIE_STRING(POWER_CONSTRAINT); + MFIE_STRING(POWER_CAPABILITY); + MFIE_STRING(TPC_REQUEST); + MFIE_STRING(TPC_REPORT); + MFIE_STRING(SUPP_CHANNELS); + MFIE_STRING(CSA); + MFIE_STRING(MEASURE_REQUEST); + MFIE_STRING(MEASURE_REPORT); + MFIE_STRING(QUIET); + MFIE_STRING(IBSS_DFS); + MFIE_STRING(RSN); + MFIE_STRING(RATES_EX); + MFIE_STRING(GENERIC); + MFIE_STRING(QOS_PARAMETER); + default: + return "UNKNOWN"; + } } static inline void rtllib_extract_country_ie( struct rtllib_device *ieee, struct rtllib_info_element *info_element, struct rtllib_network *network, - u8 * addr2) + u8 *addr2) { if (IS_DOT11D_ENABLE(ieee)) { - if (info_element->len!= 0) { + if (info_element->len != 0) { memcpy(network->CountryIeBuf, info_element->data, info_element->len); network->CountryIeLen = info_element->len; - if (!IS_COUNTRY_IE_VALID(ieee)) - { - if ((rtllib_act_scanning(ieee,false) == true) && (ieee->FirstIe_InScan == 1)) - printk("Received beacon ContryIE, SSID: <%s>\n",network->ssid); + if (!IS_COUNTRY_IE_VALID(ieee)) { + if ((rtllib_act_scanning(ieee, false) == true) && (ieee->FirstIe_InScan == 1)) + printk(KERN_INFO "Received beacon ContryIE, SSID: <%s>\n", network->ssid); Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data); } } - if (IS_EQUAL_CIE_SRC(ieee, addr2)) { + if (IS_EQUAL_CIE_SRC(ieee, addr2)) UPDATE_CIE_WATCHDOG(ieee); - } } } @@ -1752,9 +1741,9 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, { u8 i; short offset; - u16 tmp_htcap_len=0; - u16 tmp_htinfo_len=0; - u16 ht_realtek_agg_len=0; + u16 tmp_htcap_len = 0; + u16 tmp_htinfo_len = 0; + u16 ht_realtek_agg_len = 0; u8 ht_realtek_agg_buf[MAX_IE_LEN]; char rates_str[64]; char *p; @@ -1864,28 +1853,28 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->tim.tim_count = info_element->data[0]; network->tim.tim_period = info_element->data[1]; - network->dtim_period = info_element->data[1]; - if (ieee->state != RTLLIB_LINKED) - break; + network->dtim_period = info_element->data[1]; + if (ieee->state != RTLLIB_LINKED) + break; network->last_dtim_sta_time = jiffies; - network->dtim_data = RTLLIB_DTIM_VALID; + network->dtim_data = RTLLIB_DTIM_VALID; - if (info_element->data[2] & 1) - network->dtim_data |= RTLLIB_DTIM_MBCAST; + if (info_element->data[2] & 1) + network->dtim_data |= RTLLIB_DTIM_MBCAST; - offset = (info_element->data[2] >> 1)*2; + offset = (info_element->data[2] >> 1)*2; - if (ieee->assoc_id < 8*offset || - ieee->assoc_id > 8*(offset + info_element->len -3)) + if (ieee->assoc_id < 8*offset || + ieee->assoc_id > 8*(offset + info_element->len - 3)) + break; - break; - - offset = (ieee->assoc_id / 8) - offset; - if (info_element->data[3+offset] & (1<<(ieee->assoc_id%8))) - network->dtim_data |= RTLLIB_DTIM_UCAST; + offset = (ieee->assoc_id / 8) - offset; + if (info_element->data[3 + offset] & + (1 << (ieee->assoc_id % 8))) + network->dtim_data |= RTLLIB_DTIM_UCAST; network->listen_interval = network->dtim_period; break; @@ -1923,13 +1912,13 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, network->wpa_ie_len); break; } - if (info_element->len == 7 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x01 && - info_element->data[4] == 0x02) - network->Turbo_Enable = 1; + if (info_element->len == 7 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x01 && + info_element->data[4] == 0x02) + network->Turbo_Enable = 1; if (tmp_htcap_len == 0) { if (info_element->len >= 4 && @@ -1938,193 +1927,160 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, info_element->data[2] == 0x4c && info_element->data[3] == 0x033) { - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htcap_len != 0){ + tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htcap_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? + sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf, info_element->data, network->bssht.bdHTCapLen); } } - if (tmp_htcap_len != 0){ + if (tmp_htcap_len != 0) { network->bssht.bdSupportHT = true; network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); - }else{ + } else { network->bssht.bdSupportHT = false; network->bssht.bdHT1R = false; } } - if (tmp_htinfo_len == 0){ + if (tmp_htinfo_len == 0) { if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x90 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x034){ - - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htinfo_len != 0){ - network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - if (tmp_htinfo_len){ - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); - } - + info_element->data[0] == 0x00 && + info_element->data[1] == 0x90 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x034) { + tmp_htinfo_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htinfo_len != 0) { + network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; + if (tmp_htinfo_len) { + network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf) ? + sizeof(network->bssht.bdHTInfoBuf) : tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf, info_element->data, network->bssht.bdHTInfoLen); } + } + } } - if (ieee->aggregation){ - if (network->bssht.bdSupportHT){ + if (ieee->aggregation) { + if (network->bssht.bdSupportHT) { if (info_element->len >= 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0xe0 && - info_element->data[2] == 0x4c && - info_element->data[3] == 0x02){ - - ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN); - memcpy(ht_realtek_agg_buf,info_element->data,info_element->len); - + info_element->data[0] == 0x00 && + info_element->data[1] == 0xe0 && + info_element->data[2] == 0x4c && + info_element->data[3] == 0x02) { + ht_realtek_agg_len = min(info_element->len, (u8)MAX_IE_LEN); + memcpy(ht_realtek_agg_buf, info_element->data, info_element->len); } - if (ht_realtek_agg_len >= 5){ + if (ht_realtek_agg_len >= 5) { network->realtek_cap_exit = true; network->bssht.bdRT2RTAggregation = true; if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02)) - network->bssht.bdRT2RTLongSlotTime = true; + network->bssht.bdRT2RTLongSlotTime = true; - if ((ht_realtek_agg_buf[4]==1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) - { + if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE)) network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; - } } } - if (ht_realtek_agg_len >= 5){ + if (ht_realtek_agg_len >= 5) { if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP)) network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP; } } - { - if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x05 && - info_element->data[2] == 0xb5) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf7) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x10 && - info_element->data[2] == 0x18)){ - - network->broadcom_cap_exist = true; - - } + if ((info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x05 && + info_element->data[2] == 0xb5) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf7) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x10 && + info_element->data[2] == 0x18)) { + network->broadcom_cap_exist = true; } if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0c && - info_element->data[2] == 0x43) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0c && + info_element->data[2] == 0x43) network->ralink_cap_exist = true; - } if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x03 && - info_element->data[2] == 0x7f) || - (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x13 && - info_element->data[2] == 0x74)) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x03 && + info_element->data[2] == 0x7f) || + (info_element->len >= 3 && + info_element->data[0] == 0x00 && + info_element->data[1] == 0x13 && + info_element->data[2] == 0x74)) network->atheros_cap_exist = true; - } if ((info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0x43) ) - { - network->marvell_cap_exist = true; - } + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0x43)) + network->marvell_cap_exist = true; if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96) network->cisco_cap_exist = true; - } if (info_element->len >= 3 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x0a && - info_element->data[2] == 0xf5) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x0a && + info_element->data[2] == 0xf5) network->airgo_cap_exist = true; - } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x01) - { - if (info_element->len == 6) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x01) { + if (info_element->len == 6) { memcpy(network->CcxRmState, &info_element[4], 2); if (network->CcxRmState[0] != 0) - { network->bCcxRmEnable = true; - } else network->bCcxRmEnable = false; network->MBssidMask = network->CcxRmState[1] & 0x07; - if (network->MBssidMask != 0) - { + if (network->MBssidMask != 0) { network->bMBssidValid = true; network->MBssidMask = 0xff << (network->MBssidMask); memcpy(network->MBssid, network->bssid, ETH_ALEN); network->MBssid[5] &= network->MBssidMask; - } - else - { + } else { network->bMBssidValid = false; } - } - else - { + } else { network->bCcxRmEnable = false; } } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x40 && - info_element->data[2] == 0x96 && - info_element->data[3] == 0x03) - { - if (info_element->len == 5) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x40 && + info_element->data[2] == 0x96 && + info_element->data[3] == 0x03) { + if (info_element->len == 5) { network->bWithCcxVerNum = true; network->BssCcxVerNumber = info_element->data[4]; - } - else - { + } else { network->bWithCcxVerNum = false; network->BssCcxVerNumber = 0; } } if (info_element->len > 4 && - info_element->data[0] == 0x00 && - info_element->data[1] == 0x50 && - info_element->data[2] == 0xf2 && - info_element->data[3] == 0x04) - { + info_element->data[0] == 0x00 && + info_element->data[1] == 0x50 && + info_element->data[2] == 0xf2 && + info_element->data[3] == 0x04) { RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n", info_element->len); network->wzc_ie_len = min(info_element->len+2, @@ -2146,22 +2102,26 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_CAP: RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n", info_element->len); - tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htcap_len != 0){ + tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htcap_len != 0) { network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC; - network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\ - sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len; - memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen); + network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ? + sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len; + memcpy(network->bssht.bdHTCapBuf, + info_element->data, + network->bssht.bdHTCapLen); network->bssht.bdSupportHT = true; - network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0); + network->bssht.bdHT1R = ((((struct ht_capab_ele *) + network->bssht.bdHTCapBuf))->MCS[1]) == 0; - network->bssht.bdBandWidth = (enum ht_channel_width)(((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->ChlWidth); - } - else{ + network->bssht.bdBandWidth = (enum ht_channel_width) + (((struct ht_capab_ele *) + (network->bssht.bdHTCapBuf))->ChlWidth); + } else { network->bssht.bdSupportHT = false; network->bssht.bdHT1R = false; - network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20 ; + network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20; } break; @@ -2169,34 +2129,33 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_HT_INFO: RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n", info_element->len); - tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN); - if (tmp_htinfo_len){ + tmp_htinfo_len = min(info_element->len, (u8)MAX_IE_LEN); + if (tmp_htinfo_len) { network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE; - network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\ - sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len; - memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen); + network->bssht.bdHTInfoLen = tmp_htinfo_len > + sizeof(network->bssht.bdHTInfoBuf) ? + sizeof(network->bssht.bdHTInfoBuf) : + tmp_htinfo_len; + memcpy(network->bssht.bdHTInfoBuf, + info_element->data, + network->bssht.bdHTInfoLen); } break; case MFIE_TYPE_AIRONET: RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n", info_element->len); - if (info_element->len >IE_CISCO_FLAG_POSITION) - { + if (info_element->len > IE_CISCO_FLAG_POSITION) { network->bWithAironetIE = true; - if ( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) || - (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) ) - { + if ((info_element->data[IE_CISCO_FLAG_POSITION] + & SUPPORT_CKIP_MIC) || + (info_element->data[IE_CISCO_FLAG_POSITION] + & SUPPORT_CKIP_PK)) network->bCkipSupported = true; - } else - { network->bCkipSupported = false; - } - } - else - { + } else { network->bWithAironetIE = false; network->bCkipSupported = false; } @@ -2209,7 +2168,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, case MFIE_TYPE_COUNTRY: RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", info_element->len); - rtllib_extract_country_ie(ieee, info_element, network, network->bssid); + rtllib_extract_country_ie(ieee, info_element, network, + network->bssid); break; /* TODO */ default: @@ -2227,70 +2187,43 @@ int rtllib_parse_info_param(struct rtllib_device *ieee, } if (!network->atheros_cap_exist && !network->broadcom_cap_exist && - !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation) - { + !network->cisco_cap_exist && !network->ralink_cap_exist && + !network->bssht.bdRT2RTAggregation) network->unknown_cap_exist = true; - } else - { network->unknown_cap_exist = false; - } return 0; } -static inline u8 rtllib_SignalStrengthTranslate( - u8 CurrSS - ) +static inline u8 rtllib_SignalStrengthTranslate(u8 CurrSS) { u8 RetSS; if (CurrSS >= 71 && CurrSS <= 100) - { RetSS = 90 + ((CurrSS - 70) / 3); - } else if (CurrSS >= 41 && CurrSS <= 70) - { RetSS = 78 + ((CurrSS - 40) / 3); - } else if (CurrSS >= 31 && CurrSS <= 40) - { RetSS = 66 + (CurrSS - 30); - } else if (CurrSS >= 21 && CurrSS <= 30) - { RetSS = 54 + (CurrSS - 20); - } else if (CurrSS >= 5 && CurrSS <= 20) - { RetSS = 42 + (((CurrSS - 5) * 2) / 3); - } else if (CurrSS == 4) - { RetSS = 36; - } else if (CurrSS == 3) - { RetSS = 27; - } else if (CurrSS == 2) - { RetSS = 18; - } else if (CurrSS == 1) - { RetSS = 9; - } else - { RetSS = CurrSS; - } - - return RetSS; } -long rtllib_translate_todbm(u8 signal_strength_index ) +long rtllib_translate_todbm(u8 signal_strength_index) { long signal_power; @@ -2308,10 +2241,10 @@ static inline int rtllib_network_init( { /* - network->qos_data.active = 0; - network->qos_data.supported = 0; - network->qos_data.param_count = 0; - network->qos_data.old_param_count = 0; + network->qos_data.active = 0; + network->qos_data.supported = 0; + network->qos_data.param_count = 0; + network->qos_data.old_param_count = 0; */ memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data)); @@ -2332,9 +2265,9 @@ static inline int rtllib_network_init( network->flags = 0; network->atim_window = 0; network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ? - 0x3 : 0x0; + 0x3 : 0x0; network->berp_info_valid = false; - network->broadcom_cap_exist = false; + network->broadcom_cap_exist = false; network->ralink_cap_exist = false; network->atheros_cap_exist = false; network->cisco_cap_exist = false; @@ -2358,12 +2291,12 @@ static inline int rtllib_network_init( network->rsn_ie_len = 0; network->wzc_ie_len = 0; - if (rtllib_parse_info_param(ieee, + if (rtllib_parse_info_param(ieee, beacon->info_element, (stats->len - sizeof(*beacon)), network, stats)) - return 1; + return 1; network->mode = 0; if (stats->freq == RTLLIB_52GHZ_BAND) @@ -2384,7 +2317,7 @@ static inline int rtllib_network_init( return 1; } - if (network->bssht.bdSupportHT){ + if (network->bssht.bdSupportHT) { if (network->mode == IEEE_A) network->mode = IEEE_N_5G; else if (network->mode & (IEEE_G | IEEE_B)) @@ -2393,7 +2326,7 @@ static inline int rtllib_network_init( if (rtllib_is_empty_essid(network->ssid, network->ssid_len)) network->flags |= NETWORK_EMPTY_ESSID; stats->signal = 30 + (stats->SignalStrength * 70) / 100; - stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) -25; + stats->noise = rtllib_translate_todbm((u8)(100-stats->signal)) - 25; memcpy(&network->stats, stats, sizeof(network->stats)); @@ -2407,11 +2340,11 @@ static inline int is_same_network(struct rtllib_network *src, * and the capability field (in particular IBSS and BSS) all match. * We treat all with the same BSSID and channel * as one network */ - return - (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) && + return (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) && (src->channel == dst->channel) && !memcmp(src->bssid, dst->bssid, ETH_ALEN) && - (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (!ssidbroad)) && + (!memcmp(src->ssid, dst->ssid, src->ssid_len) || + (!ssidbroad)) && ((src->capability & WLAN_CAPABILITY_IBSS) == (dst->capability & WLAN_CAPABILITY_IBSS)) && ((src->capability & WLAN_CAPABILITY_ESS) == @@ -2438,14 +2371,12 @@ static inline void update_network(struct rtllib_network *dst, dst->rates_len = src->rates_len; memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len); dst->rates_ex_len = src->rates_ex_len; - if (src->ssid_len > 0) - { - if (dst->ssid_len == 0) - { + if (src->ssid_len > 0) { + if (dst->ssid_len == 0) { memset(dst->hidden_ssid, 0, sizeof(dst->hidden_ssid)); dst->hidden_ssid_len = src->ssid_len; memcpy(dst->hidden_ssid, src->ssid, src->ssid_len); - }else{ + } else { memset(dst->ssid, 0, dst->ssid_len); dst->ssid_len = src->ssid_len; memcpy(dst->ssid, src->ssid, src->ssid_len); @@ -2455,8 +2386,7 @@ static inline void update_network(struct rtllib_network *dst, dst->flags = src->flags; dst->time_stamp[0] = src->time_stamp[0]; dst->time_stamp[1] = src->time_stamp[1]; - if (src->flags & NETWORK_HAS_ERP_VALUE) - { + if (src->flags & NETWORK_HAS_ERP_VALUE) { dst->erp_value = src->erp_value; dst->berp_info_valid = src->berp_info_valid = true; } @@ -2468,12 +2398,14 @@ static inline void update_network(struct rtllib_network *dst, dst->last_dtim_sta_time = src->last_dtim_sta_time; memcpy(&dst->tim, &src->tim, sizeof(struct rtllib_tim_parameters)); - dst->bssht.bdSupportHT = src->bssht.bdSupportHT; + dst->bssht.bdSupportHT = src->bssht.bdSupportHT; dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation; - dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen; - memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen); - dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen; - memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen); + dst->bssht.bdHTCapLen = src->bssht.bdHTCapLen; + memcpy(dst->bssht.bdHTCapBuf, src->bssht.bdHTCapBuf, + src->bssht.bdHTCapLen); + dst->bssht.bdHTInfoLen = src->bssht.bdHTInfoLen; + memcpy(dst->bssht.bdHTInfoBuf, src->bssht.bdHTInfoBuf, + src->bssht.bdHTInfoLen); dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer; dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime; dst->broadcom_cap_exist = src->broadcom_cap_exist; @@ -2497,7 +2429,8 @@ static inline void update_network(struct rtllib_network *dst, old_param = dst->qos_data.param_count; dst->qos_data.supported = src->qos_data.supported; if (dst->flags & NETWORK_HAS_QOS_PARAMETERS) - memcpy(&dst->qos_data, &src->qos_data, sizeof(struct rtllib_qos_data)); + memcpy(&dst->qos_data, &src->qos_data, + sizeof(struct rtllib_qos_data)); if (dst->qos_data.supported == 1) { if (dst->ssid_len) RTLLIB_DEBUG_QOS @@ -2512,12 +2445,11 @@ static inline void update_network(struct rtllib_network *dst, /* dst->last_associate is not overwritten */ dst->wmm_info = src->wmm_info; - if (src->wmm_param[0].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn|| \ - src->wmm_param[2].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn) { - memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); - } + if (src->wmm_param[0].ac_aci_acm_aifsn || + src->wmm_param[1].ac_aci_acm_aifsn || + src->wmm_param[2].ac_aci_acm_aifsn || + src->wmm_param[1].ac_aci_acm_aifsn) + memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); dst->SignalStrength = src->SignalStrength; dst->RSSI = src->RSSI; @@ -2528,24 +2460,24 @@ static inline void update_network(struct rtllib_network *dst, dst->bWithAironetIE = src->bWithAironetIE; dst->bCkipSupported = src->bCkipSupported; - memcpy(dst->CcxRmState,src->CcxRmState,2); + memcpy(dst->CcxRmState, src->CcxRmState, 2); dst->bCcxRmEnable = src->bCcxRmEnable; dst->MBssidMask = src->MBssidMask; dst->bMBssidValid = src->bMBssidValid; - memcpy(dst->MBssid,src->MBssid,6); + memcpy(dst->MBssid, src->MBssid, 6); dst->bWithCcxVerNum = src->bWithCcxVerNum; dst->BssCcxVerNumber = src->BssCcxVerNumber; - } + static inline int is_beacon(__le16 fc) { return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON); } -static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) +static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel) { if (MAX_CHANNEL_NUMBER < channel) { - printk("%s(): Invalid Channel\n", __func__); + printk(KERN_INFO "%s(): Invalid Channel\n", __func__); return 0; } @@ -2555,10 +2487,10 @@ static int IsPassiveChannel( struct rtllib_device *rtllib, u8 channel) return 0; } -int IsLegalChannel( struct rtllib_device *rtllib, u8 channel) +int IsLegalChannel(struct rtllib_device *rtllib, u8 channel) { if (MAX_CHANNEL_NUMBER < channel) { - printk("%s(): Invalid Channel\n", __func__); + printk(KERN_INFO "%s(): Invalid Channel\n", __func__); return 0; } if (rtllib->active_channel_map[channel] > 0) @@ -2567,7 +2499,6 @@ int IsLegalChannel( struct rtllib_device *rtllib, u8 channel) return 0; } - static inline void rtllib_process_probe_response( struct rtllib_device *ieee, struct rtllib_probe_response *beacon, @@ -2578,7 +2509,8 @@ static inline void rtllib_process_probe_response( struct rtllib_info_element *info_element = &beacon->info_element[0]; unsigned long flags; short renew; - struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), + GFP_ATOMIC); if (!network) return; @@ -2606,12 +2538,12 @@ static inline void rtllib_process_probe_response( if (rtllib_network_init(ieee, beacon, network, stats)) { RTLLIB_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", - escape_essid(info_element->data, - info_element->len), - MAC_ARG(beacon->header.addr3), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(info_element->data, + info_element->len), + MAC_ARG(beacon->header.addr3), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); goto free_network; } @@ -2619,10 +2551,12 @@ static inline void rtllib_process_probe_response( if (!IsLegalChannel(ieee, network->channel)) goto free_network; - if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP) { + if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP) { if (IsPassiveChannel(ieee, network->channel)) { - printk("GetScanInfo(): For Global Domain, " - "filter probe response at channel(%d).\n", network->channel); + printk(KERN_INFO "GetScanInfo(): For Global Domain, " + "filter probe response at channel(%d).\n", + network->channel); goto free_network; } } @@ -2631,32 +2565,32 @@ static inline void rtllib_process_probe_response( * to see if we can find it in our list. * * NOTE: This search is definitely not optimized. Once its doing - * the "right thing" we'll optimize it for efficiency if - * necessary */ + * the "right thing" we'll optimize it for efficiency if + * necessary */ /* Search for this entry in the list and update it if it is * already there. */ spin_lock_irqsave(&ieee->lock, flags); - { - if (is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))) { - update_network(&ieee->current_network, network); - if ((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G) - && ieee->current_network.berp_info_valid){ - if (ieee->current_network.erp_value& ERP_UseProtection) + if (is_same_network(&ieee->current_network, network, + (network->ssid_len ? 1 : 0))) { + update_network(&ieee->current_network, network); + if ((ieee->current_network.mode == IEEE_N_24G || + ieee->current_network.mode == IEEE_G) + && ieee->current_network.berp_info_valid) { + if (ieee->current_network.erp_value & ERP_UseProtection) ieee->current_network.buseprotection = true; - else - ieee->current_network.buseprotection = false; + else + ieee->current_network.buseprotection = false; } - if (is_beacon(beacon->header.frame_ctl)) - { - if (ieee->state >= RTLLIB_LINKED) - ieee->LinkDetectInfo.NumRecvBcnInPeriod++; - } + if (is_beacon(beacon->header.frame_ctl)) { + if (ieee->state >= RTLLIB_LINKED) + ieee->LinkDetectInfo.NumRecvBcnInPeriod++; } } list_for_each_entry(target, &ieee->network_list, list) { - if (is_same_network(target, network,(target->ssid_len?1:0))) + if (is_same_network(target, network, + (target->ssid_len ? 1 : 0))) break; if ((oldest == NULL) || (target->last_scanned < oldest->last_scanned)) @@ -2684,49 +2618,51 @@ static inline void rtllib_process_probe_response( RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", - escape_essid(network->ssid, - network->ssid_len), - MAC_ARG(network->bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(network->ssid, + network->ssid_len), + MAC_ARG(network->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); memcpy(target, network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { RTLLIB_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", - escape_essid(target->ssid, - target->ssid_len), - MAC_ARG(target->bssid), - WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == - RTLLIB_STYPE_PROBE_RESP ? - "PROBE RESPONSE" : "BEACON"); + escape_essid(target->ssid, + target->ssid_len), + MAC_ARG(target->bssid), + WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == + RTLLIB_STYPE_PROBE_RESP ? + "PROBE RESPONSE" : "BEACON"); - /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new - * net and call the new_net handler + /* we have an entry and we are going to update it. But this + * entry may be already expired. In this case we do the same + * as we found a new net and call the new_net handler */ - renew = !time_after(target->last_scanned + ieee->scan_age, jiffies); + renew = !time_after(target->last_scanned + ieee->scan_age, + jiffies); if ((!target->ssid_len) && - (((network->ssid_len > 0) && (target->hidden_ssid_len == 0)) - || ((ieee->current_network.ssid_len == network->ssid_len) && - (strncmp(ieee->current_network.ssid, network->ssid, network->ssid_len) == 0) && - (ieee->state == RTLLIB_NOLINK))) - ) { + (((network->ssid_len > 0) && (target->hidden_ssid_len == 0)) + || ((ieee->current_network.ssid_len == network->ssid_len) && + (strncmp(ieee->current_network.ssid, network->ssid, + network->ssid_len) == 0) && + (ieee->state == RTLLIB_NOLINK)))) renew = 1; - } update_network(target, network); if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) rtllib_softmac_new_net(ieee, network); } spin_unlock_irqrestore(&ieee->lock, flags); - if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, network, (network->ssid_len?1:0))&&\ - (ieee->state == RTLLIB_LINKED)) { - if (ieee->handle_beacon != NULL) { - ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); - } + if (is_beacon(beacon->header.frame_ctl) && + is_same_network(&ieee->current_network, network, + (network->ssid_len ? 1 : 0)) && + (ieee->state == RTLLIB_LINKED)) { + if (ieee->handle_beacon != NULL) + ieee->handle_beacon(ieee->dev, beacon, + &ieee->current_network); } free_network: kfree(network); @@ -2734,48 +2670,48 @@ free_network: } void rtllib_rx_mgt(struct rtllib_device *ieee, - struct sk_buff *skb, + struct sk_buff *skb, struct rtllib_rx_stats *stats) { - struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; - if (WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_PROBE_RESP && - WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_BEACON) - ieee->last_rx_ps_time = jiffies; + struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data ; - switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { + if (WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_PROBE_RESP && + WLAN_FC_GET_STYPE(header->frame_ctl) != RTLLIB_STYPE_BEACON) + ieee->last_rx_ps_time = jiffies; - case RTLLIB_STYPE_BEACON: - RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Beacon\n"); - rtllib_process_probe_response( - ieee, (struct rtllib_probe_response *)header, stats); + switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED && - ieee->iw_mode == IW_MODE_INFRA && - ieee->state == RTLLIB_LINKED)) - tasklet_schedule(&ieee->ps_task); + case RTLLIB_STYPE_BEACON: + RTLLIB_DEBUG_MGMT("received BEACON (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Beacon\n"); + rtllib_process_probe_response( + ieee, (struct rtllib_probe_response *)header, + stats); - break; + if (ieee->sta_sleep || (ieee->ps != RTLLIB_PS_DISABLED && + ieee->iw_mode == IW_MODE_INFRA && + ieee->state == RTLLIB_LINKED)) + tasklet_schedule(&ieee->ps_task); - case RTLLIB_STYPE_PROBE_RESP: - RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Probe response\n"); - rtllib_process_probe_response( - ieee, (struct rtllib_probe_response *)header, stats); - break; - case RTLLIB_STYPE_PROBE_REQ: - RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); - RTLLIB_DEBUG_SCAN("Probe request\n"); - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && - ((ieee->iw_mode == IW_MODE_ADHOC || - ieee->iw_mode == IW_MODE_MASTER) && - ieee->state == RTLLIB_LINKED)){ - rtllib_rx_probe_rq(ieee, skb); - } - break; - } + break; + case RTLLIB_STYPE_PROBE_RESP: + RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe response\n"); + rtllib_process_probe_response(ieee, + (struct rtllib_probe_response *)header, stats); + break; + case RTLLIB_STYPE_PROBE_REQ: + RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n", + WLAN_FC_GET_STYPE(header->frame_ctl)); + RTLLIB_DEBUG_SCAN("Probe request\n"); + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && + ((ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) && + ieee->state == RTLLIB_LINKED)) + rtllib_rx_probe_rq(ieee, skb); + break; + } } From 3927ee360059eb692507c413868a83471620e466 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 9 Aug 2011 13:19:58 -0500 Subject: [PATCH 16/25] staging: rtl8192e: Cleanup checkpatch -f errors - Part XIV With this patch, all of the checkpatch errors are fixed; however, only some of the lines that are too long were fixed. To complete the fixing of these warnings, the file rtllib_softmac.c will need refactoring. In addition, some of the variables may need renaming. Those changes can be deferred. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac.c | 1978 ++++++++++----------- 1 file changed, 961 insertions(+), 1017 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 29277d18f021..fa0e2afd1ed1 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -20,27 +20,26 @@ #include #include #include -#include +#include #include "dot11d.h" -extern void _setup_timer( struct timer_list*, void*, unsigned long ); u8 rsn_authen_cipher_suite[16][4] = { - {0x00,0x0F,0xAC,0x00}, - {0x00,0x0F,0xAC,0x01}, - {0x00,0x0F,0xAC,0x02}, - {0x00,0x0F,0xAC,0x03}, - {0x00,0x0F,0xAC,0x04}, - {0x00,0x0F,0xAC,0x05}, + {0x00, 0x0F, 0xAC, 0x00}, + {0x00, 0x0F, 0xAC, 0x01}, + {0x00, 0x0F, 0xAC, 0x02}, + {0x00, 0x0F, 0xAC, 0x03}, + {0x00, 0x0F, 0xAC, 0x04}, + {0x00, 0x0F, 0xAC, 0x05}, }; short rtllib_is_54g(struct rtllib_network *net) { - return ((net->rates_ex_len > 0) || (net->rates_len > 4)); + return (net->rates_ex_len > 0) || (net->rates_len > 4); } short rtllib_is_shortslot(struct rtllib_network net) { - return (net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME); + return net.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME; } /* returns the total length needed for pleacing the RATE MFIE @@ -69,7 +68,7 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & RTLLIB_CCK_MODULATION){ + if (ieee->modulation & RTLLIB_CCK_MODULATION) { *tag++ = MFIE_TYPE_RATES; *tag++ = 4; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; @@ -78,7 +77,8 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; } - /* We may add an option for custom rates that specific HW might support */ + /* We may add an option for custom rates that specific HW + * might support */ *tag_p = tag; } @@ -86,8 +86,7 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & RTLLIB_OFDM_MODULATION){ - + if (ieee->modulation & RTLLIB_OFDM_MODULATION) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; @@ -98,14 +97,14 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB; - } - - /* We may add an option for custom rates that specific HW might support */ + /* We may add an option for custom rates that specific HW might + * support */ *tag_p = tag; } -void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { +void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) +{ u8 *tag = *tag_p; *tag++ = MFIE_TYPE_GENERIC; @@ -120,17 +119,18 @@ void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { *tag_p = tag; } -void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { +void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) +{ u8 *tag = *tag_p; - *tag++ = MFIE_TYPE_GENERIC; - *tag++ = 7; - *tag++ = 0x00; - *tag++ = 0xe0; - *tag++ = 0x4c; - *tag++ = 0x01; - *tag++ = 0x02; - *tag++ = 0x11; + *tag++ = MFIE_TYPE_GENERIC; + *tag++ = 7; + *tag++ = 0x00; + *tag++ = 0xe0; + *tag++ = 0x4c; + *tag++ = 0x01; + *tag++ = 0x02; + *tag++ = 0x11; *tag++ = 0x00; *tag_p = tag; @@ -140,7 +140,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) { void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) { int nh; - nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; + nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; /* * if the queue is full but we have newer frames then @@ -183,29 +183,21 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee) u8 BasicRate; - for ( i = 0; i < ieee->current_network.rates_len; i++) - { + for (i = 0; i < ieee->current_network.rates_len; i++) { BasicRate = ieee->current_network.rates[i]&0x7F; - if (!rtllib_is_cck_rate(BasicRate)) - { - if (QueryRate == 0) - { + if (!rtllib_is_cck_rate(BasicRate)) { + if (QueryRate == 0) { QueryRate = BasicRate; - } - else - { + } else { if (BasicRate < QueryRate) - { QueryRate = BasicRate; - } } } } - if (QueryRate == 0) - { + if (QueryRate == 0) { QueryRate = 12; - printk("No BasicRate found!!\n"); + printk(KERN_INFO "No BasicRate found!!\n"); } return QueryRate; } @@ -220,10 +212,10 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) else rate = ieee->basic_rate & 0x7f; - if (rate == 0){ - if (ieee->mode == IEEE_A|| - ieee->mode== IEEE_N_5G|| - (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK)) + if (rate == 0) { + if (ieee->mode == IEEE_A || + ieee->mode == IEEE_N_5G || + (ieee->mode == IEEE_N_24G && !pHTInfo->bCurSuppCCK)) rate = 0x0c; else rate = 0x02; @@ -232,21 +224,18 @@ u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee) return rate; } - -void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); - inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct rtllib_hdr_3addr *header= + struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ - rtllib_sta_wakeup(ieee,0); + rtllib_sta_wakeup(ieee, 0); if (header->frame_ctl == RTLLIB_STYPE_BEACON) tcb_desc->queue_index = BEACON_QUEUE; @@ -261,9 +250,9 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) tcb_desc->bTxDisableRateFallBack = 1; tcb_desc->bTxUseDriverAssingedRate = 1; if (single) { - if (ieee->queue_stop){ - enqueue_mgmt(ieee,skb); - }else{ + if (ieee->queue_stop) { + enqueue_mgmt(ieee, skb); + } else { header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -272,11 +261,12 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) ieee->seq_ctrl[0]++; /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } spin_unlock_irqrestore(&ieee->lock, flags); - }else{ + } else { spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); @@ -288,17 +278,19 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee) ieee->seq_ctrl[0]++; /* check wether the managed packet queued greater than 5 */ - if (!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\ - (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\ - (ieee->queue_stop) ) { + if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) || + (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) || + (ieee->queue_stop)) { /* insert the skb packet to the management queue */ /* as for the completion function, it does not need * to check it any more. * */ - printk("%s():insert to waitqueue, queue_index:%d!\n",__func__,tcb_desc->queue_index); - skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); + printk(KERN_INFO "%s():insert to waitqueue, queue_index" + ":%d!\n", __func__, tcb_desc->queue_index); + skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], + skb); } else { - ieee->softmac_hard_start_xmit(skb,ieee->dev); + ieee->softmac_hard_start_xmit(skb, ieee->dev); } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } @@ -310,7 +302,7 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; - u16 fc,type,stype; + u16 fc, type, stype; struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8); fc = header->frame_ctl; @@ -342,7 +334,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, } /* avoid watchdog triggers */ - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } else { if (type != RTLLIB_FTYPE_CTL) { @@ -353,14 +346,14 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, else ieee->seq_ctrl[0]++; } - ieee->softmac_hard_start_xmit(skb,ieee->dev); + ieee->softmac_hard_start_xmit(skb, ieee->dev); } } inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) { - unsigned int len,rate_len; + unsigned int len, rate_len; u8 *tag; struct sk_buff *skb; struct rtllib_probe_request *req; @@ -377,7 +370,8 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) skb_reserve(skb, ieee->tx_headroom); - req = (struct rtllib_probe_request *) skb_put(skb,sizeof(struct rtllib_probe_request)); + req = (struct rtllib_probe_request *) skb_put(skb, + sizeof(struct rtllib_probe_request)); req->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_PROBE_REQ); req->header.duration_id = 0; @@ -385,15 +379,15 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - tag = (u8 *) skb_put(skb,len+2+rate_len); + tag = (u8 *) skb_put(skb, len + 2 + rate_len); *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - rtllib_MFIE_Brate(ieee,&tag); - rtllib_MFIE_Grate(ieee,&tag); + rtllib_MFIE_Brate(ieee, &tag); + rtllib_MFIE_Grate(ieee, &tag); return skb; } @@ -407,14 +401,14 @@ void rtllib_send_beacon(struct rtllib_device *ieee) return; skb = rtllib_get_beacon_(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_beacons++; } - if (ieee->beacon_txing && ieee->ieee_up){ - mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5))); - } + if (ieee->beacon_txing && ieee->ieee_up) + mod_timer(&ieee->beacon_timer, jiffies + + (MSECS(ieee->current_network.beacon_interval - 5))); } @@ -431,83 +425,86 @@ void rtllib_send_beacon_cb(unsigned long _ieee) /* * Description: - * Enable network monitor mode, all rx packets will be received. + * Enable network monitor mode, all rx packets will be received. */ -void rtllib_EnableNetMonitorMode(struct net_device* dev, - bool bInitState) +void rtllib_EnableNetMonitorMode(struct net_device *dev, + bool bInitState) { - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Enter Monitor Mode\n"); + printk(KERN_INFO "========>Enter Monitor Mode\n"); - ieee->AllowAllDestAddrHandler(dev, true, !bInitState); + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); } /* * Description: - * Disable network network monitor mode, only packets destinated to - * us will be received. + * Disable network network monitor mode, only packets destinated to + * us will be received. */ -void rtllib_DisableNetMonitorMode(struct net_device* dev, - bool bInitState) +void rtllib_DisableNetMonitorMode(struct net_device *dev, + bool bInitState) { - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Exit Monitor Mode\n"); + printk(KERN_INFO "========>Exit Monitor Mode\n"); - ieee->AllowAllDestAddrHandler(dev, false, !bInitState); + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); } /* * Description: - * This enables the specialized promiscuous mode required by Intel. - * In this mode, Intel intends to hear traffics from/to other STAs in the same BSS. - * Therefore we don't have to disable checking BSSID and we only need to allow all dest. - * BUT: if we enable checking BSSID then we can't recv packets from other STA. + * This enables the specialized promiscuous mode required by Intel. + * In this mode, Intel intends to hear traffics from/to other STAs in the + * same BSS. Therefore we don't have to disable checking BSSID and we only need + * to allow all dest. BUT: if we enable checking BSSID then we can't recv + * packets from other STA. */ -void rtllib_EnableIntelPromiscuousMode(struct net_device* dev, - bool bInitState) +void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, + bool bInitState) { - bool bFilterOutNonAssociatedBSSID = false; + bool bFilterOutNonAssociatedBSSID = false; - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Enter Intel Promiscuous Mode\n"); + printk(KERN_INFO "========>Enter Intel Promiscuous Mode\n"); - ieee->AllowAllDestAddrHandler(dev, true, !bInitState); - ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + ieee->AllowAllDestAddrHandler(dev, true, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, + (u8 *)&bFilterOutNonAssociatedBSSID); - ieee->bNetPromiscuousMode = true; + ieee->bNetPromiscuousMode = true; } /* * Description: - * This disables the specialized promiscuous mode required by Intel. - * See MgntEnableIntelPromiscuousMode for detail. + * This disables the specialized promiscuous mode required by Intel. + * See MgntEnableIntelPromiscuousMode for detail. */ -void rtllib_DisableIntelPromiscuousMode(struct net_device* dev, - bool bInitState) +void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, + bool bInitState) { - bool bFilterOutNonAssociatedBSSID = true; + bool bFilterOutNonAssociatedBSSID = true; - struct rtllib_device* ieee = netdev_priv_rsl(dev); + struct rtllib_device *ieee = netdev_priv_rsl(dev); - printk("========>Exit Intel Promiscuous Mode\n"); + printk(KERN_INFO "========>Exit Intel Promiscuous Mode\n"); - ieee->AllowAllDestAddrHandler(dev, false, !bInitState); - ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, (u8*)&bFilterOutNonAssociatedBSSID); + ieee->AllowAllDestAddrHandler(dev, false, !bInitState); + ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID, + (u8 *)&bFilterOutNonAssociatedBSSID); - ieee->bNetPromiscuousMode = false; + ieee->bNetPromiscuousMode = false; } void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) { struct sk_buff *skb; skb = rtllib_probe_req(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_probe_rq++; } @@ -529,7 +526,8 @@ void rtllib_softmac_hint11d_wq(void *data) void rtllib_update_active_chan_map(struct rtllib_device *ieee) { - memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); + memcpy(ieee->active_channel_map, GET_DOT11D_INFO(ieee)->channel_map, + MAX_CHANNEL_NUMBER+1); } /* this performs syncro scan blocking the caller until all channels @@ -537,6 +535,7 @@ void rtllib_update_active_chan_map(struct rtllib_device *ieee) */ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { + union iwreq_data wrqu; short ch = 0; rtllib_update_active_chan_map(ieee); @@ -545,14 +544,12 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) down(&ieee->scan_sem); - while(1) - { - + while (1) { do { ch++; if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - } while(!ieee->active_channel_map[ch]); + } while (!ieee->active_channel_map[ch]); /* this fuction can be called in two situations * 1- We have switched to ad-hoc mode and we are @@ -575,14 +572,14 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) if (ieee->state == RTLLIB_LINKED) goto out; - if (ieee->sync_scan_hurryup){ - printk("============>sync_scan_hurryup out\n"); + if (ieee->sync_scan_hurryup) { + printk(KERN_INFO "============>sync_scan_hurryup out\n"); goto out; } ieee->set_chan(ieee->dev, ch); if (ieee->active_channel_map[ch] == 1) - rtllib_send_probe_requests(ieee, 0); + rtllib_send_probe_requests(ieee, 0); /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. @@ -593,7 +590,7 @@ out: ieee->actscanning = false; ieee->sync_scan_hurryup = 0; - if (ieee->state >= RTLLIB_LINKED){ + if (ieee->state >= RTLLIB_LINKED) { if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); } @@ -601,53 +598,52 @@ out: ieee->be_scan_inprogress = false; - { - union iwreq_data wrqu; memset(&wrqu, 0, sizeof(wrqu)); - wireless_send_event(ieee->dev,SIOCGIWSCAN,&wrqu,NULL); - } + wireless_send_event(ieee->dev, SIOCGIWSCAN, &wrqu, NULL); } void rtllib_softmac_scan_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, softmac_scan_wq); u8 last_channel = ieee->current_network.channel; rtllib_update_active_chan_map(ieee); if (!ieee->ieee_up) return; - if (rtllib_act_scanning(ieee,true) == true) + if (rtllib_act_scanning(ieee, true) == true) return; down(&ieee->scan_sem); - if (ieee->eRFPowerState == eRfOff) - { - printk("======>%s():rf state is eRfOff, return\n",__func__); + if (ieee->eRFPowerState == eRfOff) { + printk(KERN_INFO "======>%s():rf state is eRfOff, return\n", + __func__); goto out1; } - do{ + do { ieee->current_network.channel = - (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; - if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) - { + (ieee->current_network.channel + 1) % + MAX_CHANNEL_NUMBER; + if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) { if (!ieee->active_channel_map[ieee->current_network.channel]) ieee->current_network.channel = 6; goto out; /* no good chans */ } - } while(!ieee->active_channel_map[ieee->current_network.channel]); + } while (!ieee->active_channel_map[ieee->current_network.channel]); - if (ieee->scanning_continue == 0 ) + if (ieee->scanning_continue == 0) goto out; ieee->set_chan(ieee->dev, ieee->current_network.channel); if (ieee->active_channel_map[ieee->current_network.channel] == 1) - rtllib_send_probe_requests(ieee, 0); + rtllib_send_probe_requests(ieee, 0); - queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); + queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, + MSECS(RTLLIB_SOFTMAC_SCAN_TIME)); up(&ieee->scan_sem); return; @@ -669,24 +665,24 @@ out1: void rtllib_beacons_start(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 1; rtllib_send_beacon(ieee); - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } void rtllib_beacons_stop(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 0; del_timer_sync(&ieee->beacon_timer); - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } @@ -725,9 +721,9 @@ void rtllib_softmac_stop_scan(struct rtllib_device *ieee) void rtllib_stop_scan(struct rtllib_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { rtllib_softmac_stop_scan(ieee); - }else{ + } else { if (ieee->rtllib_stop_hw_scan) ieee->rtllib_stop_hw_scan(ieee->dev); } @@ -735,9 +731,9 @@ void rtllib_stop_scan(struct rtllib_device *ieee) void rtllib_stop_scan_syncro(struct rtllib_device *ieee) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { ieee->sync_scan_hurryup = 1; - }else{ + } else { if (ieee->rtllib_stop_hw_scan) ieee->rtllib_stop_hw_scan(ieee->dev); } @@ -745,13 +741,12 @@ void rtllib_stop_scan_syncro(struct rtllib_device *ieee) bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) { - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ - if (sync_scan){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { + if (sync_scan) return ieee->be_scan_inprogress; - }else{ - return (ieee->actscanning ||ieee->be_scan_inprogress); - } - }else{ + else + return ieee->actscanning || ieee->be_scan_inprogress; + } else { return test_bit(STATUS_SCANNING, &ieee->status); } } @@ -759,61 +754,55 @@ bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) /* called with ieee->lock held */ void rtllib_start_scan(struct rtllib_device *ieee) { - RT_TRACE(COMP_DBG, "===>%s()\n",__func__); + RT_TRACE(COMP_DBG, "===>%s()\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) - ieee->rtllib_ips_leave_wq(ieee->dev); + ieee->rtllib_ips_leave_wq(ieee->dev); - - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { if (ieee->scanning_continue == 0) { ieee->actscanning = true; ieee->scanning_continue = 1; - queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq, 0); + queue_delayed_work_rsl(ieee->wq, + &ieee->softmac_scan_wq, 0); } } else { if (ieee->rtllib_start_hw_scan) ieee->rtllib_start_hw_scan(ieee->dev); } - } /* called with wx_sem held */ void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) { - if (IS_DOT11D_ENABLE(ieee) ) - { + if (IS_DOT11D_ENABLE(ieee)) { if (IS_COUNTRY_IE_VALID(ieee)) - { RESET_CIE_WATCHDOG(ieee); - } } ieee->sync_scan_hurryup = 0; - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { rtllib_softmac_scan_syncro(ieee, is_mesh); - }else{ + } else { if (ieee->rtllib_start_hw_scan) ieee->rtllib_start_hw_scan(ieee->dev); } - } inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, - struct rtllib_device *ieee, int challengelen,u8 * daddr) + struct rtllib_device *ieee, int challengelen, u8 *daddr) { struct sk_buff *skb; struct rtllib_authentication *auth; int len = 0; - len = sizeof(struct rtllib_authentication) + challengelen + ieee->tx_headroom + 4; + len = sizeof(struct rtllib_authentication) + challengelen + + ieee->tx_headroom + 4; skb = dev_alloc_skb(len); - if (!skb) return NULL; + if (!skb) + return NULL; skb_reserve(skb, ieee->tx_headroom); @@ -821,10 +810,11 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, skb_put(skb, sizeof(struct rtllib_authentication)); auth->header.frame_ctl = RTLLIB_STYPE_AUTH; - if (challengelen) auth->header.frame_ctl |= RTLLIB_FCTL_WEP; + if (challengelen) + auth->header.frame_ctl |= RTLLIB_FCTL_WEP; auth->header.duration_id = 0x013a; - memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); + memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN); if (ieee->auth_mode == 0) @@ -839,22 +829,18 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); return skb; - } -void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) +void constructWMMIE(u8 *wmmie, u8 *wmm_len, u8 oui_subtype) { - u8 szQoSOUI[] ={221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; + u8 szQoSOUI[] = {221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; - if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) - { + if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) { szQoSOUI[0] = 46; szQoSOUI[1] = *wmm_len; - memcpy(wmmie,szQoSOUI,3); + memcpy(wmmie, szQoSOUI, 3); *wmm_len = 3; - } - else - { + } else { szQoSOUI[1] = *wmm_len + 6; szQoSOUI[6] = oui_subtype; memcpy(wmmie, szQoSOUI, 8); @@ -863,15 +849,15 @@ void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype) } } -static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) +static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) { u8 *tag; int beacon_size; struct rtllib_probe_response *beacon_buf; struct sk_buff *skb = NULL; int encrypt; - int atim_len,erp_len; - struct rtllib_crypt_data* crypt; + int atim_len, erp_len; + struct rtllib_crypt_data *crypt; char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; @@ -880,82 +866,83 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) int wpa_ie_len = ieee->wpa_ie_len; u8 erpinfo_content = 0; - u8* tmp_ht_cap_buf = NULL; + u8 *tmp_ht_cap_buf = NULL; u8 tmp_ht_cap_len = 0; - u8* tmp_ht_info_buf = NULL; + u8 *tmp_ht_info_buf = NULL; u8 tmp_ht_info_len = 0; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8* tmp_generic_ie_buf = NULL; + u8 *tmp_generic_ie_buf = NULL; u8 tmp_generic_ie_len = 0; if (rate_ex_len > 0) - rate_ex_len+=2; + rate_ex_len += 2; if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - if ((ieee->current_network.mode == IEEE_G) - ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) { + if ((ieee->current_network.mode == IEEE_G) || + (ieee->current_network.mode == IEEE_N_24G && + ieee->pHTInfo->bCurSuppCCK)) { erp_len = 3; erpinfo_content = 0; if (ieee->current_network.buseprotection) erpinfo_content |= ERP_UseProtection; - } - else + } else erp_len = 0; crypt = ieee->crypt[ieee->tx_keyidx]; encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len)); - if (ieee->pHTInfo->bCurrentHTSupport){ - tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap); + if (ieee->pHTInfo->bCurrentHTSupport) { + tmp_ht_cap_buf = (u8 *) &(ieee->pHTInfo->SelfHTCap); tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo); + tmp_ht_info_buf = (u8 *) &(ieee->pHTInfo->SelfHTInfo); tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo); - HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt, false); - HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt); + HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, + &tmp_ht_cap_len, encrypt, false); + HTConstructInfoElement(ieee, tmp_ht_info_buf, &tmp_ht_info_len, + encrypt); - - if (pHTInfo->bRegRT2RTAggregation) - { + if (pHTInfo->bRegRT2RTAggregation) { tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len); + tmp_generic_ie_len = + sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, + &tmp_generic_ie_len); } } beacon_size = sizeof(struct rtllib_probe_response)+2+ - ssid_len - +3 - +rate_len - +rate_ex_len - +atim_len - +erp_len - +wpa_ie_len - +ieee->tx_headroom; + ssid_len + 3 + rate_len + rate_ex_len + atim_len + erp_len + + wpa_ie_len + ieee->tx_headroom; skb = dev_alloc_skb(beacon_size); if (!skb) return NULL; skb_reserve(skb, ieee->tx_headroom); - beacon_buf = (struct rtllib_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom)); - memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); - memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); + beacon_buf = (struct rtllib_probe_response *) skb_put(skb, + (beacon_size - ieee->tx_headroom)); + memcpy(beacon_buf->header.addr1, dest, ETH_ALEN); + memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); beacon_buf->header.duration_id = 0; beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); beacon_buf->capability = - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); + cpu_to_le16(ieee->current_network.capability & + WLAN_CAPABILITY_IBSS); beacon_buf->capability |= - cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); + cpu_to_le16(ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_PREAMBLE); - if (ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT_TIME)); + if (ieee->short_slot && (ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_SLOT_TIME)) + cpu_to_le16((beacon_buf->capability |= + WLAN_CAPABILITY_SHORT_SLOT_TIME)); crypt = ieee->crypt[ieee->tx_keyidx]; if (encrypt) @@ -966,7 +953,7 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) beacon_buf->info_element[0].id = MFIE_TYPE_SSID; beacon_buf->info_element[0].len = ssid_len; - tag = (u8*) beacon_buf->info_element[0].data; + tag = (u8 *) beacon_buf->info_element[0].data; memcpy(tag, ssid, ssid_len); @@ -974,58 +961,55 @@ static struct sk_buff* rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) *(tag++) = MFIE_TYPE_RATES; *(tag++) = rate_len-2; - memcpy(tag,ieee->current_network.rates,rate_len-2); - tag+=rate_len-2; + memcpy(tag, ieee->current_network.rates, rate_len-2); + tag += rate_len-2; *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - if (atim_len){ - u16 val16; + if (atim_len) { + u16 val16; *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; val16 = cpu_to_le16(ieee->current_network.atim_window); memcpy((u8 *)tag, (u8 *)&val16, 2); - tag+=2; + tag += 2; } - if (erp_len){ + if (erp_len) { *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; *(tag++) = erpinfo_content; } - if (rate_ex_len){ + if (rate_ex_len) { *(tag++) = MFIE_TYPE_RATES_EX; *(tag++) = rate_ex_len-2; - memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); - tag+=rate_ex_len-2; + memcpy(tag, ieee->current_network.rates_ex, rate_ex_len-2); + tag += rate_ex_len-2; } - if (wpa_ie_len) - { + if (wpa_ie_len) { if (ieee->iw_mode == IW_MODE_ADHOC) - { memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); - } memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); tag += ieee->wpa_ie_len; } - return skb; } -struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) +struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *skb; - u8* tag; + u8 *tag; - struct rtllib_crypt_data* crypt; + struct rtllib_crypt_data *crypt; struct rtllib_assoc_response_frame *assoc; short encrypt; unsigned int rate_len = rtllib_MFIE_rate_len(ieee); - int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + ieee->tx_headroom; + int len = sizeof(struct rtllib_assoc_response_frame) + rate_len + + ieee->tx_headroom; skb = dev_alloc_skb(len); @@ -1035,10 +1019,10 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) skb_reserve(skb, ieee->tx_headroom); assoc = (struct rtllib_assoc_response_frame *) - skb_put(skb,sizeof(struct rtllib_assoc_response_frame)); + skb_put(skb, sizeof(struct rtllib_assoc_response_frame)); assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP); - memcpy(assoc->header.addr1, dest,ETH_ALEN); + memcpy(assoc->header.addr1, dest, ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? @@ -1046,14 +1030,15 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) if (ieee->short_slot) - assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); + assoc->capability |= + cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; else crypt = NULL; - encrypt = ( crypt && crypt->ops); + encrypt = (crypt && crypt->ops); if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); @@ -1061,22 +1046,23 @@ struct sk_buff* rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); if (ieee->assoc_id == 0x2007) - ieee->assoc_id=0; + ieee->assoc_id = 0; else ieee->assoc_id++; - tag = (u8*) skb_put(skb, rate_len); + tag = (u8 *) skb_put(skb, rate_len); rtllib_MFIE_Brate(ieee, &tag); rtllib_MFIE_Grate(ieee, &tag); return skb; } -struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest) +struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, + u8 *dest) { struct sk_buff *skb = NULL; struct rtllib_authentication *auth; - int len = ieee->tx_headroom + sizeof(struct rtllib_authentication)+1; + int len = ieee->tx_headroom + sizeof(struct rtllib_authentication) + 1; skb = dev_alloc_skb(len); if (!skb) return NULL; @@ -1101,10 +1087,10 @@ struct sk_buff* rtllib_auth_resp(struct rtllib_device *ieee,int status, u8 *dest } -struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) +struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) { struct sk_buff *skb; - struct rtllib_hdr_3addr* hdr; + struct rtllib_hdr_3addr *hdr; skb = dev_alloc_skb(sizeof(struct rtllib_hdr_3addr)+ieee->tx_headroom); if (!skb) @@ -1112,7 +1098,8 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) skb_reserve(skb, ieee->tx_headroom); - hdr = (struct rtllib_hdr_3addr*)skb_put(skb,sizeof(struct rtllib_hdr_3addr)); + hdr = (struct rtllib_hdr_3addr *)skb_put(skb, + sizeof(struct rtllib_hdr_3addr)); memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -1120,17 +1107,17 @@ struct sk_buff* rtllib_null_func(struct rtllib_device *ieee,short pwr) hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA | RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS | - (pwr ? RTLLIB_FCTL_PM:0)); + (pwr ? RTLLIB_FCTL_PM : 0)); return skb; } -struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) +struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) { struct sk_buff *skb; - struct rtllib_pspoll_hdr* hdr; + struct rtllib_pspoll_hdr *hdr; skb = dev_alloc_skb(sizeof(struct rtllib_pspoll_hdr)+ieee->tx_headroom); if (!skb) @@ -1138,19 +1125,21 @@ struct sk_buff* rtllib_pspoll_func(struct rtllib_device *ieee) skb_reserve(skb, ieee->tx_headroom); - hdr = (struct rtllib_pspoll_hdr*)skb_put(skb,sizeof(struct rtllib_pspoll_hdr)); + hdr = (struct rtllib_pspoll_hdr *)skb_put(skb, + sizeof(struct rtllib_pspoll_hdr)); memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN); hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000); - hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL |RTLLIB_STYPE_PSPOLL | RTLLIB_FCTL_PM); + hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL | RTLLIB_STYPE_PSPOLL | + RTLLIB_FCTL_PM); return skb; } -void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) +void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); @@ -1159,7 +1148,7 @@ void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8* dest) } -void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8* dest) +void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) { struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); @@ -1181,110 +1170,98 @@ inline int SecIsInPMKIDList(struct rtllib_device *ieee, u8 *bssid) { int i = 0; - do - { - if ((ieee->PMKIDList[i].bUsed) && (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) - { + do { + if ((ieee->PMKIDList[i].bUsed) && + (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) break; - } else - { i++; - } } while (i < NUM_PMKID_CACHE); if (i == NUM_PMKID_CACHE) - { i = -1; - } - else - { - } - - return (i); - + return i; } - -inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,struct rtllib_device *ieee) +inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon, + struct rtllib_device *ieee) { struct sk_buff *skb; - struct rtllib_assoc_request_frame *hdr; u8 *tag, *ies; int i; - u8* ht_cap_buf = NULL; - u8 ht_cap_len=0; - u8* realtek_ie_buf=NULL; - u8 realtek_ie_len=0; - int wpa_ie_len= ieee->wpa_ie_len; + u8 *ht_cap_buf = NULL; + u8 ht_cap_len = 0; + u8 *realtek_ie_buf = NULL; + u8 realtek_ie_len = 0; + int wpa_ie_len = ieee->wpa_ie_len; int wps_ie_len = ieee->wps_ie_len; - unsigned int ckip_ie_len=0; - unsigned int ccxrm_ie_len=0; - unsigned int cxvernum_ie_len=0; - struct rtllib_crypt_data* crypt; + unsigned int ckip_ie_len = 0; + unsigned int ccxrm_ie_len = 0; + unsigned int cxvernum_ie_len = 0; + struct rtllib_crypt_data *crypt; int encrypt; int PMKCacheIdx; - unsigned int rate_len = (beacon->rates_len?(beacon->rates_len+2):0) + (beacon->rates_ex_len?(beacon->rates_ex_len)+2:0); + unsigned int rate_len = (beacon->rates_len ? + (beacon->rates_len + 2) : 0) + + (beacon->rates_ex_len ? (beacon->rates_ex_len) + + 2 : 0); - unsigned int wmm_info_len = beacon->qos_data.supported?9:0; - unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; + unsigned int wmm_info_len = beacon->qos_data.supported ? 9 : 0; + unsigned int turbo_info_len = beacon->Turbo_Enable ? 9 : 0; int len = 0; crypt = ieee->crypt[ieee->tx_keyidx]; - if (crypt != NULL) { - encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len)); - } else { + if (crypt != NULL) + encrypt = ieee->host_encrypt && crypt && crypt->ops && + ((0 == strcmp(crypt->ops->name, "WEP") || + wpa_ie_len)); + else encrypt = 0; - } - if ((ieee->rtllib_ap_sec_type && (ieee->rtllib_ap_sec_type(ieee)&SEC_ALG_TKIP)) ||(ieee->bForcedBgMode == true)) - { + if ((ieee->rtllib_ap_sec_type && + (ieee->rtllib_ap_sec_type(ieee) & SEC_ALG_TKIP)) || + (ieee->bForcedBgMode == true)) { ieee->pHTInfo->bEnableHT = 0; ieee->mode = WIRELESS_MODE_G; } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap); + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap); ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap); - HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt, true); + HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, + encrypt, true); if (ieee->pHTInfo->bCurrentRT2RTAggregation) { realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer; - realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer); - HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len); - + realtek_ie_len = + sizeof(ieee->pHTInfo->szRT2RTAggBuffer); + HTConstructRT2RTAggElement(ieee, realtek_ie_buf, + &realtek_ie_len); } } if (beacon->bCkipSupported) - { ckip_ie_len = 30+2; - } if (beacon->bCcxRmEnable) - { ccxrm_ie_len = 6+2; - } - if ( beacon->BssCcxVerNumber >= 2 ) - { + if (beacon->BssCcxVerNumber >= 2) cxvernum_ie_len = 5+2; - } PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid); - if (PMKCacheIdx >= 0) - { + if (PMKCacheIdx >= 0) { wpa_ie_len += 18; - printk("[PMK cache]: WPA2 IE length: %x\n", wpa_ie_len); + printk(KERN_INFO "[PMK cache]: WPA2 IE length: %x\n", + wpa_ie_len); } - len = sizeof(struct rtllib_assoc_request_frame)+ 2 + len = sizeof(struct rtllib_assoc_request_frame) + 2 + beacon->ssid_len + rate_len + wpa_ie_len + wps_ie_len + wmm_info_len + turbo_info_len - + ht_cap_len + + ht_cap_len + realtek_ie_len + ckip_ie_len + ccxrm_ie_len @@ -1299,11 +1276,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru skb_reserve(skb, ieee->tx_headroom); hdr = (struct rtllib_assoc_request_frame *) - skb_put(skb, sizeof(struct rtllib_assoc_request_frame)+2); + skb_put(skb, sizeof(struct rtllib_assoc_request_frame) + 2); hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ; - hdr->header.duration_id= 37; + hdr->header.duration_id = 37; memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); @@ -1311,13 +1288,14 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN); hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); - if (ieee->short_slot && (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) + if (ieee->short_slot && + (beacon->capability&WLAN_CAPABILITY_SHORT_SLOT_TIME)) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME); @@ -1331,94 +1309,89 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru tag = skb_put(skb, rate_len); - if (beacon->rates_len){ + if (beacon->rates_len) { *tag++ = MFIE_TYPE_RATES; *tag++ = beacon->rates_len; - for (i=0;irates_len;i++){ + for (i = 0; i < beacon->rates_len; i++) *tag++ = beacon->rates[i]; - } } - if (beacon->rates_ex_len){ + if (beacon->rates_ex_len) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = beacon->rates_ex_len; - for (i=0;irates_ex_len;i++){ + for (i = 0; i < beacon->rates_ex_len; i++) *tag++ = beacon->rates_ex[i]; - } } - if ( beacon->bCkipSupported ) - { + if (beacon->bCkipSupported) { static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; u8 CcxAironetBuf[30]; struct octet_string osCcxAironetIE; - memset(CcxAironetBuf, 0,30); + memset(CcxAironetBuf, 0, 30); osCcxAironetIE.Octet = CcxAironetBuf; osCcxAironetIE.Length = sizeof(CcxAironetBuf); - memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui)); + memcpy(osCcxAironetIE.Octet, AironetIeOui, + sizeof(AironetIeOui)); - osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ; + osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= + (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC); tag = skb_put(skb, ckip_ie_len); *tag++ = MFIE_TYPE_AIRONET; *tag++ = osCcxAironetIE.Length; - memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length); + memcpy(tag, osCcxAironetIE.Octet, osCcxAironetIE.Length); tag += osCcxAironetIE.Length; } - if (beacon->bCcxRmEnable) - { + if (beacon->bCcxRmEnable) { static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00}; struct octet_string osCcxRmCap; osCcxRmCap.Octet = CcxRmCapBuf; osCcxRmCap.Length = sizeof(CcxRmCapBuf); - tag = skb_put(skb,ccxrm_ie_len); + tag = skb_put(skb, ccxrm_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = osCcxRmCap.Length; - memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length); + memcpy(tag, osCcxRmCap.Octet, osCcxRmCap.Length); tag += osCcxRmCap.Length; } - if ( beacon->BssCcxVerNumber >= 2 ) - { - u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; + if (beacon->BssCcxVerNumber >= 2) { + u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00}; struct octet_string osCcxVerNum; CcxVerNumBuf[4] = beacon->BssCcxVerNumber; osCcxVerNum.Octet = CcxVerNumBuf; osCcxVerNum.Length = sizeof(CcxVerNumBuf); - tag = skb_put(skb,cxvernum_ie_len); + tag = skb_put(skb, cxvernum_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = osCcxVerNum.Length; - memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length); + memcpy(tag, osCcxVerNum.Octet, osCcxVerNum.Length); tag += osCcxVerNum.Length; } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_HT_CAP; *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len -2); - tag += ht_cap_len -2; + memcpy(tag, ht_cap_buf, ht_cap_len - 2); + tag += ht_cap_len - 2; } } - - if (wpa_ie_len){ + if (wpa_ie_len) { tag = skb_put(skb, ieee->wpa_ie_len); memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); - if (PMKCacheIdx >= 0) - { + if (PMKCacheIdx >= 0) { tag = skb_put(skb, 18); *tag = 1; *(tag + 1) = 0; - memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, 16); + memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, + 16); } } if (wmm_info_len) { - tag = skb_put(skb,wmm_info_len); + tag = skb_put(skb, wmm_info_len); rtllib_WMM_Info(ieee, &tag); } @@ -1427,42 +1400,39 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,stru memcpy(tag, ieee->wps_ie, wps_ie_len); } - tag = skb_put(skb,turbo_info_len); - if (turbo_info_len) - rtllib_TURBO_Info(ieee, &tag); + tag = skb_put(skb, turbo_info_len); + if (turbo_info_len) + rtllib_TURBO_Info(ieee, &tag); - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){ - if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) - { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + if (ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC) { tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len - 2); - tag += ht_cap_len -2; + memcpy(tag, ht_cap_buf, ht_cap_len - 2); + tag += ht_cap_len - 2; } - if (ieee->pHTInfo->bCurrentRT2RTAggregation){ + if (ieee->pHTInfo->bCurrentRT2RTAggregation) { tag = skb_put(skb, realtek_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = realtek_ie_len - 2; - memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); + memcpy(tag, realtek_ie_buf, realtek_ie_len - 2); } } - if (ieee->assocreq_ies){ - kfree(ieee->assocreq_ies); - ieee->assocreq_ies = NULL; - } + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; ies = &(hdr->info_element[0].id); ieee->assocreq_ies_len = (skb->data + skb->len) - ies; ieee->assocreq_ies = kmalloc(ieee->assocreq_ies_len, GFP_ATOMIC); if (ieee->assocreq_ies) memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len); - else{ - printk("%s()Warning: can't alloc memory for assocreq_ies\n", __func__); + else { + printk(KERN_INFO "%s()Warning: can't alloc memory for assocreq" + "_ies\n", __func__); ieee->assocreq_ies_len = 0; } - return skb; } @@ -1480,18 +1450,18 @@ void rtllib_associate_abort(struct rtllib_device *ieee) * Here we will check if there are good nets to associate * with, so we retry or just get back to NO_LINK and scanning */ - if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING){ + if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING) { RTLLIB_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; - }else{ + } else { RTLLIB_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } ieee->state = RTLLIB_ASSOCIATING_RETRY; - queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, \ - RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); + queue_delayed_work_rsl(ieee->wq, &ieee->associate_retry_wq, + RTLLIB_SOFTMAC_ASSOC_RETRY_TIME); spin_unlock_irqrestore(&ieee->lock, flags); } @@ -1501,7 +1471,7 @@ void rtllib_associate_abort_cb(unsigned long dev) rtllib_associate_abort((struct rtllib_device *) dev); } -void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) +void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) { struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -1510,15 +1480,15 @@ void rtllib_associate_step1(struct rtllib_device *ieee,u8 * daddr) ieee->softmac_stats.tx_auth_rq++; - skb=rtllib_authentication_req(beacon, ieee, 0,daddr); + skb = rtllib_authentication_req(beacon, ieee, 0, daddr); if (!skb) rtllib_associate_abort(ieee); - else{ + else { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING ; RTLLIB_DEBUG_MGMT("Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); - if (!timer_pending(&ieee->associate_timer)){ + if (!timer_pending(&ieee->associate_timer)) { ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } @@ -1534,19 +1504,21 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; - skb = rtllib_authentication_req(beacon, ieee, chlen+2,beacon->bssid); + skb = rtllib_authentication_req(beacon, ieee, chlen + 2, beacon->bssid); if (!skb) rtllib_associate_abort(ieee); - else{ + else { c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; memcpy(c, challenge, chlen); - RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n"); + RTLLIB_DEBUG_MGMT("Sending authentication challenge " + "response\n"); - rtllib_encrypt_fragment(ieee, skb, sizeof(struct rtllib_hdr_3addr )); + rtllib_encrypt_fragment(ieee, skb, + sizeof(struct rtllib_hdr_3addr)); softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); @@ -1556,7 +1528,7 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) void rtllib_associate_step2(struct rtllib_device *ieee) { - struct sk_buff* skb; + struct sk_buff *skb; struct rtllib_network *beacon = &ieee->current_network; del_timer_sync(&ieee->associate_timer); @@ -1564,10 +1536,10 @@ void rtllib_associate_step2(struct rtllib_device *ieee) RTLLIB_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=rtllib_association_req(beacon, ieee); + skb = rtllib_association_req(beacon, ieee); if (!skb) rtllib_associate_abort(ieee); - else{ + else { softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); } @@ -1576,48 +1548,54 @@ void rtllib_associate_step2(struct rtllib_device *ieee) #define CANCELLED 2 void rtllib_associate_complete_wq(void *data) { - struct rtllib_device *ieee = (struct rtllib_device *)container_of_work_rsl(data, struct rtllib_device, associate_complete_wq); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); + struct rtllib_device *ieee = (struct rtllib_device *) + container_of_work_rsl(data, + struct rtllib_device, + associate_complete_wq); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(ieee->PowerSaveControl)); printk(KERN_INFO "Associated successfully\n"); - if (ieee->is_silent_reset == 0){ - printk("normal associate\n"); - notify_wx_assoc_event(ieee); - } + if (ieee->is_silent_reset == 0) { + printk(KERN_INFO "normal associate\n"); + notify_wx_assoc_event(ieee); + } netif_carrier_on(ieee->dev); ieee->is_roaming = false; if (rtllib_is_54g(&ieee->current_network) && - (ieee->modulation & RTLLIB_OFDM_MODULATION)){ - + (ieee->modulation & RTLLIB_OFDM_MODULATION)) { ieee->rate = 108; printk(KERN_INFO"Using G rates:%d\n", ieee->rate); - }else{ + } else { ieee->rate = 22; ieee->SetWirelessMode(ieee->dev, IEEE_B); printk(KERN_INFO"Using B rates:%d\n", ieee->rate); } - if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT) - { - printk("Successfully associated, ht enabled\n"); + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) { + printk(KERN_INFO "Successfully associated, ht enabled\n"); HTOnAssocRsp(ieee); } else { - printk("Successfully associated, ht not enabled(%d, %d)\n", - ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT); + printk(KERN_INFO "Successfully associated, ht not " + "enabled(%d, %d)\n", + ieee->pHTInfo->bCurrentHTSupport, + ieee->pHTInfo->bEnableHT); memset(ieee->dot11HTOperationalRateSet, 0, 16); } - ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500); - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) - { + ieee->LinkDetectInfo.SlotNum = 2 * (1 + + ieee->current_network.beacon_interval / + 500); + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || + ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } pPSC->LpsIdleCount = 0; ieee->link_change(ieee->dev); - if (ieee->is_silent_reset == 1) { - printk("silent reset associate\n"); + if (ieee->is_silent_reset == 1) { + printk(KERN_INFO "silent reset associate\n"); ieee->is_silent_reset = 0; - } + } if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -1626,49 +1604,6 @@ void rtllib_associate_complete_wq(void *data) static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) { - char *buf; - size_t len; - int i; - union iwreq_data wrqu; - - return; - - - buf = kmalloc(50 + 2 * (ieee->assocreq_ies_len + ieee->assocresp_ies_len), GFP_ATOMIC); - if (!buf) - return; - - len = sprintf(buf, "ASSOCINFO("); - if (ieee->assocreq_ies) { - len += sprintf(buf + len, "ReqIEs="); - for (i = 0; i < ieee->assocreq_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocreq_ies[i]); - } - } - if (ieee->assocresp_ies) { - if (ieee->assocreq_ies) - len += sprintf(buf + len, " "); - len += sprintf(buf + len, "RespIEs="); - for (i = 0; i < ieee->assocresp_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); - } - } - len += sprintf(buf + len, ")"); - - if (len > IW_CUSTOM_MAX) { - len = sprintf(buf, "ASSOCRESPIE="); - for (i = 0; i < ieee->assocresp_ies_len; i++) { - len += sprintf(buf + len, "%02x", ieee->assocresp_ies[i]); - } - } - - if (len <= IW_CUSTOM_MAX) { - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = len; - wireless_send_event(ieee->dev, IWEVCUSTOM, &wrqu, buf); - } - - kfree(buf); } void rtllib_associate_complete(struct rtllib_device *ieee) @@ -1683,7 +1618,9 @@ void rtllib_associate_complete(struct rtllib_device *ieee) void rtllib_associate_procedure_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_procedure_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, + associate_procedure_wq); rtllib_stop_scan_syncro(ieee); if (ieee->rtllib_ips_leave != NULL) ieee->rtllib_ips_leave(ieee->dev); @@ -1693,11 +1630,12 @@ void rtllib_associate_procedure_wq(void *data) ieee->data_hard_stop(ieee->dev); rtllib_stop_scan(ieee); - RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, ieee->current_network.channel); + RT_TRACE(COMP_DBG, "===>%s(), chan:%d\n", __func__, + ieee->current_network.channel); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - if (ieee->eRFPowerState == eRfOff) - { - RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n",__func__); + if (ieee->eRFPowerState == eRfOff) { + RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff," + " schedule ipsleave wq again,return\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) ieee->rtllib_ips_leave_wq(ieee->dev); up(&ieee->wx_sem); @@ -1710,12 +1648,13 @@ void rtllib_associate_procedure_wq(void *data) up(&ieee->wx_sem); } -inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net) +inline void rtllib_softmac_new_net(struct rtllib_device *ieee, + struct rtllib_network *net) { - u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; + u8 tmp_ssid[IW_ESSID_MAX_SIZE + 1]; int tmp_ssid_len = 0; - short apset,ssidset,ssidbroad,apmatch,ssidmatch; + short apset, ssidset, ssidbroad, apmatch, ssidmatch; /* we are interested in new new only if we are not associated * and we are not associating / authenticating @@ -1723,103 +1662,124 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_net if (ieee->state != RTLLIB_NOLINK) return; - if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_ESS)) + if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & + WLAN_CAPABILITY_ESS)) return; - if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) + if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & + WLAN_CAPABILITY_IBSS)) return; - if ((ieee->iw_mode == IW_MODE_ADHOC) && (net->channel > ieee->ibss_maxjoin_chal)) { + if ((ieee->iw_mode == IW_MODE_ADHOC) && + (net->channel > ieee->ibss_maxjoin_chal)) return; - } - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) - { + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not * broadcast it, it can be put manually. */ apset = ieee->wap_set; ssidset = ieee->ssid_set; - ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); - apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); - if (!ssidbroad){ - ssidmatch = (ieee->current_network.ssid_len == net->hidden_ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->hidden_ssid, net->hidden_ssid_len)); - if (net->hidden_ssid_len > 0) - { - strncpy(net->ssid, net->hidden_ssid, net->hidden_ssid_len); - net->ssid_len = net->hidden_ssid_len; - ssidbroad = 1; - } - } - else - ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\ - (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); + ssidbroad = !(net->ssid_len == 0 || net->ssid[0] == '\0'); + apmatch = (memcmp(ieee->current_network.bssid, net->bssid, + ETH_ALEN) == 0); + if (!ssidbroad) { + ssidmatch = (ieee->current_network.ssid_len == + net->hidden_ssid_len) && + (!strncmp(ieee->current_network.ssid, + net->hidden_ssid, net->hidden_ssid_len)); + if (net->hidden_ssid_len > 0) { + strncpy(net->ssid, net->hidden_ssid, + net->hidden_ssid_len); + net->ssid_len = net->hidden_ssid_len; + ssidbroad = 1; + } + } else + ssidmatch = + (ieee->current_network.ssid_len == net->ssid_len) && + (!strncmp(ieee->current_network.ssid, net->ssid, + net->ssid_len)); - if ( /* if the user set the AP check if match. - * if the network does not broadcast essid we check the user supplyed ANY essid - * if the network does broadcast and the user does not set essid it is OK - * if the network does broadcast and the user did set essid chech if essid match - */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) - /* if the ap is not set, check that the user set the bssid - * and the network does bradcast and that those two bssid matches - */ - || (!apset && ssidset && ssidbroad && ssidmatch) || (ieee->is_roaming && ssidset && ssidbroad && ssidmatch) - ){ - /* if the essid is hidden replace it with the - * essid provided by the user. - */ - if (!ssidbroad){ - strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); - tmp_ssid_len = ieee->current_network.ssid_len; - } - memcpy(&ieee->current_network, net, sizeof(struct rtllib_network)); - if (!ssidbroad){ - strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = tmp_ssid_len; - } - printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x cur_net.flags:0x%x\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT, ieee->current_network.mode, ieee->current_network.flags); + /* if the user set the AP check if match. + * if the network does not broadcast essid we check the + * user supplyed ANY essid + * if the network does broadcast and the user does not set + * essid it is OK + * if the network does broadcast and the user did set essid + * check if essid match + * if the ap is not set, check that the user set the bssid + * and the network does bradcast and that those two bssid match + */ + if ((apset && apmatch && + ((ssidset && ssidbroad && ssidmatch) || + (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || + (!apset && ssidset && ssidbroad && ssidmatch) || + (ieee->is_roaming && ssidset && ssidbroad && ssidmatch)) { + /* if the essid is hidden replace it with the + * essid provided by the user. + */ + if (!ssidbroad) { + strncpy(tmp_ssid, ieee->current_network.ssid, + IW_ESSID_MAX_SIZE); + tmp_ssid_len = ieee->current_network.ssid_len; + } + memcpy(&ieee->current_network, net, + sizeof(struct rtllib_network)); + if (!ssidbroad) { + strncpy(ieee->current_network.ssid, tmp_ssid, + IW_ESSID_MAX_SIZE); + ieee->current_network.ssid_len = tmp_ssid_len; + } + printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, " + "myHT:%d, networkHT:%d, mode:%x cur_net.flags" + ":0x%x\n", ieee->current_network.ssid, + ieee->current_network.channel, + ieee->current_network.qos_data.supported, + ieee->pHTInfo->bEnableHT, + ieee->current_network.bssht.bdSupportHT, + ieee->current_network.mode, + ieee->current_network.flags); - if ((rtllib_act_scanning(ieee, false)) && !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ - rtllib_stop_scan_syncro(ieee); - } + if ((rtllib_act_scanning(ieee, false)) && + !(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) + rtllib_stop_scan_syncro(ieee); - ieee->hwscan_ch_bk = ieee->current_network.channel; - HTResetIOTSetting(ieee->pHTInfo); - ieee->wmm_acm = 0; - if (ieee->iw_mode == IW_MODE_INFRA) { - /* Join the network for the first time */ - ieee->AsocRetryCount = 0; - if ((ieee->current_network.qos_data.supported == 1) && - ieee->current_network.bssht.bdSupportHT) - HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network)); - else - ieee->pHTInfo->bCurrentHTSupport = false; + ieee->hwscan_ch_bk = ieee->current_network.channel; + HTResetIOTSetting(ieee->pHTInfo); + ieee->wmm_acm = 0; + if (ieee->iw_mode == IW_MODE_INFRA) { + /* Join the network for the first time */ + ieee->AsocRetryCount = 0; + if ((ieee->current_network.qos_data.supported == 1) && + ieee->current_network.bssht.bdSupportHT) + HTResetSelfAndSavePeerSetting(ieee, + &(ieee->current_network)); + else + ieee->pHTInfo->bCurrentHTSupport = + false; - ieee->state = RTLLIB_ASSOCIATING; - if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); + ieee->state = RTLLIB_ASSOCIATING; + if (ieee->LedControlHandler != NULL) + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + } else { + if (rtllib_is_54g(&ieee->current_network) && + (ieee->modulation & RTLLIB_OFDM_MODULATION)) { + ieee->rate = 108; + ieee->SetWirelessMode(ieee->dev, IEEE_G); + printk(KERN_INFO"Using G rates\n"); } else { - if (rtllib_is_54g(&ieee->current_network) && - (ieee->modulation & RTLLIB_OFDM_MODULATION)){ - ieee->rate = 108; - ieee->SetWirelessMode(ieee->dev, IEEE_G); - printk(KERN_INFO"Using G rates\n"); - }else{ - ieee->rate = 22; - ieee->SetWirelessMode(ieee->dev, IEEE_B); - printk(KERN_INFO"Using B rates\n"); - } - memset(ieee->dot11HTOperationalRateSet, 0, 16); - ieee->state = RTLLIB_LINKED; + ieee->rate = 22; + ieee->SetWirelessMode(ieee->dev, IEEE_B); + printk(KERN_INFO"Using B rates\n"); } - + memset(ieee->dot11HTOperationalRateSet, 0, 16); + ieee->state = RTLLIB_LINKED; + } } } - } void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) @@ -1838,51 +1798,49 @@ void rtllib_softmac_check_all_nets(struct rtllib_device *ieee) if (ieee->state != RTLLIB_NOLINK) break; - if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) - rtllib_softmac_new_net(ieee, target); + if (ieee->scan_age == 0 || time_after(target->last_scanned + + ieee->scan_age, jiffies)) + rtllib_softmac_new_net(ieee, target); } - spin_unlock_irqrestore(&ieee->lock, flags); - } - static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) { struct rtllib_authentication *a; u8 *t; - if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ - RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); + if (skb->len < (sizeof(struct rtllib_authentication) - + sizeof(struct rtllib_info_element))) { + RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } *challenge = NULL; - a = (struct rtllib_authentication*) skb->data; - if (skb->len > (sizeof(struct rtllib_authentication) +3)){ + a = (struct rtllib_authentication *) skb->data; + if (skb->len > (sizeof(struct rtllib_authentication) + 3)) { t = skb->data + sizeof(struct rtllib_authentication); - if (*(t++) == MFIE_TYPE_CHALLENGE){ + if (*(t++) == MFIE_TYPE_CHALLENGE) { *chlen = *(t++); - *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC); - memcpy(*challenge, t, *chlen); + *challenge = kmalloc(*chlen, GFP_ATOMIC); + memcpy(*challenge, t, *chlen); /*TODO - check here*/ } } - return cpu_to_le16(a->status); - } - -int auth_rq_parse(struct sk_buff *skb,u8* dest) +int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_authentication *a; - if (skb->len < (sizeof(struct rtllib_authentication)-sizeof(struct rtllib_info_element))){ - RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + if (skb->len < (sizeof(struct rtllib_authentication) - + sizeof(struct rtllib_info_element))) { + RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n", + skb->len); return -1; } - a = (struct rtllib_authentication*) skb->data; + a = (struct rtllib_authentication *) skb->data; - memcpy(dest,a->header.addr2, ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; @@ -1890,38 +1848,36 @@ int auth_rq_parse(struct sk_buff *skb,u8* dest) return WLAN_STATUS_SUCCESS; } -static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 *src) +static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, + u8 *src) { u8 *tag; u8 *skbend; - u8 *ssid=NULL; + u8 *ssid = NULL; u8 ssidlen = 0; - struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; + bool bssid_match; - if (skb->len < sizeof (struct rtllib_hdr_3addr )) + if (skb->len < sizeof(struct rtllib_hdr_3addr)) return -1; /* corrupted */ - if ((memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) != 0)&& - (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) != 0)) { - return -1; - } - if (memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) == 0) { - } + bssid_match = + (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) && + (memcmp(header->addr3, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0); + if (bssid_match) + return -1; - if (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) == 0) { - } - memcpy(src,header->addr2, ETH_ALEN); + memcpy(src, header->addr2, ETH_ALEN); - skbend = (u8*)skb->data + skb->len; + skbend = (u8 *)skb->data + skb->len; - tag = skb->data + sizeof (struct rtllib_hdr_3addr ); + tag = skb->data + sizeof(struct rtllib_hdr_3addr); - while (tag+1 < skbend){ - if (*tag == 0){ - ssid = tag+2; - ssidlen = *(tag+1); + while (tag + 1 < skbend) { + if (*tag == 0) { + ssid = tag + 2; + ssidlen = *(tag + 1); break; } tag++; /* point to the len field */ @@ -1929,53 +1885,56 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, u8 tag++; /* point to the next tag */ } - if (ssidlen == 0) return 1; + if (ssidlen == 0) + return 1; - if (!ssid) return 1; /* ssid not found in tagged param */ - return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); + if (!ssid) + return 1; /* ssid not found in tagged param */ + return !strncmp(ssid, ieee->current_network.ssid, ssidlen); } -int assoc_rq_parse(struct sk_buff *skb,u8* dest) +int assoc_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_assoc_request_frame *a; if (skb->len < (sizeof(struct rtllib_assoc_request_frame) - sizeof(struct rtllib_info_element))) { - RTLLIB_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); + RTLLIB_DEBUG_MGMT("invalid len in auth request:%d\n", skb->len); return -1; } - a = (struct rtllib_assoc_request_frame*) skb->data; + a = (struct rtllib_assoc_request_frame *) skb->data; - memcpy(dest,a->header.addr2,ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); return 0; } -static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, int *aid) +static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, + int *aid) { struct rtllib_assoc_response_frame *response_head; u16 status_code; - if (skb->len < sizeof(struct rtllib_assoc_response_frame)){ + if (skb->len < sizeof(struct rtllib_assoc_response_frame)) { RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - response_head = (struct rtllib_assoc_response_frame*) skb->data; + response_head = (struct rtllib_assoc_response_frame *) skb->data; *aid = le16_to_cpu(response_head->aid) & 0x3fff; status_code = le16_to_cpu(response_head->status); - if ((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \ - status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&& + if ((status_code == WLAN_STATUS_ASSOC_DENIED_RATES || + status_code == WLAN_STATUS_CAPS_UNSUPPORTED) && ((ieee->mode == IEEE_G) && - (ieee->current_network.mode == IEEE_N_24G) && - (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { - ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; - }else { - ieee->AsocRetryCount = 0; + (ieee->current_network.mode == IEEE_N_24G) && + (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) { + ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE; + } else { + ieee->AsocRetryCount = 0; } return le16_to_cpu(response_head->status); @@ -1985,38 +1944,37 @@ void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; ieee->softmac_stats.rx_probe_rq++; - if (probe_rq_parse(ieee, skb, dest) > 0){ + if (probe_rq_parse(ieee, skb, dest) > 0) { ieee->softmac_stats.tx_probe_rs++; rtllib_resp_to_probe(ieee, dest); } } -static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, struct sk_buff *skb) +static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee, + struct sk_buff *skb) { u8 dest[ETH_ALEN]; int status; ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ + status = auth_rq_parse(skb, dest); + if (status != -1) rtllib_resp_to_auth(ieee, status, dest); - } - } -static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, struct sk_buff *skb) +static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, + struct sk_buff *skb) { u8 dest[ETH_ALEN]; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ + if (assoc_rq_parse(skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); - } printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); } - void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) { @@ -2024,34 +1982,25 @@ void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee) { - struct sk_buff *buf = rtllib_pspoll_func(ieee); if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) { int timeout = ieee->ps_timeout; u8 dtim; - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(ieee->PowerSaveControl)); - /*if (ieee->ps == RTLLIB_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != RTLLIB_LINKED) + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(ieee->PowerSaveControl)); - return 0; - */ - - if (ieee->LPSDelayCnt) - { - ieee->LPSDelayCnt --; + if (ieee->LPSDelayCnt) { + ieee->LPSDelayCnt--; return 0; } @@ -2060,21 +2009,20 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) return 0; timeout = ieee->current_network.beacon_interval; ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID; - /* there's no need to nofity AP that I find you buffered with broadcast packet */ + /* there's no need to nofity AP that I find you buffered + * with broadcast packet */ if (dtim & (RTLLIB_DTIM_UCAST & ieee->ps)) return 2; - if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))){ + if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - } - if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))){ + if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - } - if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && - (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) + if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) && + (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if (time){ + if (time) { if (ieee->bAwakePktSent == true) { pPSC->LPSAwakeIntvl = 1; } else { @@ -2088,27 +2036,37 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) MaxPeriod = ieee->current_network.dtim_period; else MaxPeriod = pPSC->RegMaxLPSAwakeIntvl; - pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (pPSC->LPSAwakeIntvl + 1); + pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= + MaxPeriod) ? MaxPeriod : + (pPSC->LPSAwakeIntvl + 1); } { u8 LPSAwakeIntvl_tmp = 0; u8 period = ieee->current_network.dtim_period; u8 count = ieee->current_network.tim.tim_count; - if (count == 0 ) { + if (count == 0) { if (pPSC->LPSAwakeIntvl > period) - LPSAwakeIntvl_tmp = period + (pPSC->LPSAwakeIntvl - period) -((pPSC->LPSAwakeIntvl-period)%period); + LPSAwakeIntvl_tmp = period + + (pPSC->LPSAwakeIntvl - + period) - + ((pPSC->LPSAwakeIntvl-period) % + period); else LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } else { - if (pPSC->LPSAwakeIntvl > ieee->current_network.tim.tim_count) - LPSAwakeIntvl_tmp = count + (pPSC->LPSAwakeIntvl - count) -((pPSC->LPSAwakeIntvl-count)%period); + if (pPSC->LPSAwakeIntvl > + ieee->current_network.tim.tim_count) + LPSAwakeIntvl_tmp = count + + (pPSC->LPSAwakeIntvl - count) - + ((pPSC->LPSAwakeIntvl-count)%period); else LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl; } *time = ieee->current_network.last_dtim_sta_time - + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp); + + MSECS(ieee->current_network.beacon_interval * + LPSAwakeIntvl_tmp); } } @@ -2119,45 +2077,38 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) inline void rtllib_sta_ps(struct rtllib_device *ieee) { - u64 time; short sleep; - - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); if ((ieee->ps == RTLLIB_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != RTLLIB_LINKED)){ - - RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! ieee->ps is %d,ieee->iw_mode is %d,ieee->state is %d\n", - __func__,ieee->ps,ieee->iw_mode,ieee->state); + ieee->iw_mode != IW_MODE_INFRA || + ieee->state != RTLLIB_LINKED)) { + RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! " + "ieee->ps is %d, ieee->iw_mode is %d, ieee->state" + " is %d\n", __func__, ieee->ps, ieee->iw_mode, + ieee->state); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - rtllib_sta_wakeup(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = rtllib_sta_ps_sleep(ieee, &time); /* 2 wake, 1 sleep, 0 do nothing */ if (sleep == 0) - { goto out; - } - if (sleep == 1){ - if (ieee->sta_sleep == LPS_IS_SLEEP){ + if (sleep == 1) { + if (ieee->sta_sleep == LPS_IS_SLEEP) { ieee->enter_sleep_state(ieee->dev, time); - } - - else if (ieee->sta_sleep == LPS_IS_WAKE){ + } else if (ieee->sta_sleep == LPS_IS_WAKE) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->ps_is_queue_empty(ieee->dev)){ + if (ieee->ps_is_queue_empty(ieee->dev)) { ieee->sta_sleep = LPS_WAIT_NULL_DATA_SEND; ieee->ack_tx_to_ieee = 1; - rtllib_sta_ps_send_null_frame(ieee,1); + rtllib_sta_ps_send_null_frame(ieee, 1); ieee->ps_time = time; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -2166,10 +2117,10 @@ inline void rtllib_sta_ps(struct rtllib_device *ieee) ieee->bAwakePktSent = false; - }else if (sleep == 2){ + } else if (sleep == 2) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - rtllib_sta_wakeup(ieee,1); + rtllib_sta_wakeup(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } @@ -2181,15 +2132,13 @@ out: void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) { - if (ieee->sta_sleep == LPS_IS_WAKE){ - if (nl){ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (ieee->sta_sleep == LPS_IS_WAKE) { + if (nl) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); - } - else - { + } else { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_pspoll_frame(ieee); } @@ -2200,19 +2149,12 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) if (ieee->sta_sleep == LPS_IS_SLEEP) ieee->sta_wake_up(ieee->dev); - if (nl){ - /* - ieee->ack_tx_to_ieee = 1; - printk("%s(3): notify AP we are awaked ++++++++++ SendNullFunctionData\n", __func__); - rtllib_sta_ps_send_null_frame(ieee, 0); - */ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (nl) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) { ieee->ack_tx_to_ieee = 1; rtllib_sta_ps_send_null_frame(ieee, 0); - } - else - { + } else { ieee->ack_tx_to_ieee = 1; ieee->polling = true; rtllib_sta_ps_send_pspoll_frame(ieee); @@ -2226,13 +2168,13 @@ void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl) void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) { - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); - if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND){ + if (ieee->sta_sleep == LPS_WAIT_NULL_DATA_SEND) { /* Null frame with PS bit set */ - if (success){ + if (success) { ieee->sta_sleep = LPS_IS_SLEEP; ieee->enter_sleep_state(ieee->dev, ieee->ps_time); } @@ -2241,199 +2183,208 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) */ } else {/* 21112005 - tx again null without PS bit if lost */ - if ((ieee->sta_sleep == LPS_IS_WAKE) && !success){ + if ((ieee->sta_sleep == LPS_IS_WAKE) && !success) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING) - { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_NULL_DATA_POWER_SAVING) rtllib_sta_ps_send_null_frame(ieee, 0); - } else - { rtllib_sta_ps_send_pspoll_frame(ieee); - } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } } spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_process_action(struct rtllib_device* ieee, struct sk_buff* skb) +void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; - u8* act = rtllib_get_payload((struct rtllib_hdr *)header); + u8 *act = rtllib_get_payload((struct rtllib_hdr *)header); u8 category = 0; if (act == NULL) { - RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of action frame\n"); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of " + "action frame\n"); return; } category = *act; - act ++; + act++; switch (category) { - case ACT_CAT_BA: - switch (*act) { - case ACT_ADDBAREQ: - rtllib_rx_ADDBAReq(ieee, skb); - break; - case ACT_ADDBARSP: - rtllib_rx_ADDBARsp(ieee, skb); - break; - case ACT_DELBA: - rtllib_rx_DELBA(ieee, skb); - break; - } + case ACT_CAT_BA: + switch (*act) { + case ACT_ADDBAREQ: + rtllib_rx_ADDBAReq(ieee, skb); break; - default: + case ACT_ADDBARSP: + rtllib_rx_ADDBARsp(ieee, skb); break; + case ACT_DELBA: + rtllib_rx_DELBA(ieee, skb); + break; + } + break; + default: + break; } return; } -inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { u16 errcode; int aid; - u8* ies; + u8 *ies; struct rtllib_assoc_response_frame *assoc_resp; struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", - WLAN_FC_GET_STYPE(header->frame_ctl)); + WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && - (ieee->iw_mode == IW_MODE_INFRA)) - { - if (0 == (errcode=assoc_parse(ieee,skb, &aid))){ - struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network), GFP_ATOMIC); + ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED && + (ieee->iw_mode == IW_MODE_INFRA)) { + errcode = assoc_parse(ieee, skb, &aid); + if (0 == errcode) { + struct rtllib_network *network = + kzalloc(sizeof(struct rtllib_network), + GFP_ATOMIC); if (!network) return 1; - memset(network,0,sizeof(*network)); - ieee->state=RTLLIB_LINKED; + memset(network, 0, sizeof(*network)); + ieee->state = RTLLIB_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; /* station support qos */ - /* Let the register setting defaultly with Legacy station */ - assoc_resp = (struct rtllib_assoc_response_frame*)skb->data; + /* Let the register setting default with Legacy station */ + assoc_resp = (struct rtllib_assoc_response_frame *)skb->data; if (ieee->current_network.qos_data.supported == 1) { - if (rtllib_parse_info_param(ieee,assoc_resp->info_element,\ - rx_stats->len - sizeof(*assoc_resp),\ - network,rx_stats)){ + if (rtllib_parse_info_param(ieee, assoc_resp->info_element, + rx_stats->len - sizeof(*assoc_resp), + network, rx_stats)) { kfree(network); return 1; - } - else - { - memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); - memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); + } else { + memcpy(ieee->pHTInfo->PeerHTCapBuf, + network->bssht.bdHTCapBuf, + network->bssht.bdHTCapLen); + memcpy(ieee->pHTInfo->PeerHTInfoBuf, + network->bssht.bdHTInfoBuf, + network->bssht.bdHTInfoLen); } if (ieee->handle_assoc_response != NULL) - ieee->handle_assoc_response(ieee->dev, (struct rtllib_assoc_response_frame*)header, network); + ieee->handle_assoc_response(ieee->dev, + (struct rtllib_assoc_response_frame *)header, + network); kfree(network); } - if (ieee->assocresp_ies){ - kfree(ieee->assocresp_ies); - ieee->assocresp_ies = NULL; - } + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; ies = &(assoc_resp->info_element[0].id); ieee->assocresp_ies_len = (skb->data + skb->len) - ies; - ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, GFP_ATOMIC); + ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, + GFP_ATOMIC); if (ieee->assocresp_ies) - memcpy(ieee->assocresp_ies, ies, ieee->assocresp_ies_len); - else{ - printk("%s()Warning: can't alloc memory for assocresp_ies\n", __func__); + memcpy(ieee->assocresp_ies, ies, + ieee->assocresp_ies_len); + else { + printk(KERN_INFO "%s()Warning: can't alloc " + "memory for assocresp_ies\n", __func__); ieee->assocresp_ies_len = 0; } rtllib_associate_complete(ieee); } else { /* aid could not been allocated */ ieee->softmac_stats.rx_ass_err++; - printk( - "Association response status code 0x%x\n", + printk(KERN_INFO "Association response status code 0x%x\n", errcode); RTLLIB_DEBUG_MGMT( "Association response status code 0x%x\n", errcode); - if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) { - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 0); - } else { + if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 0); + else rtllib_associate_abort(ieee); - } } } - return 0; } -inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) +inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { u16 errcode; - u8* challenge; - int chlen=0; + u8 *challenge; + int chlen = 0; bool bSupportNmode = true, bHalfSupportNmode = false; - if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING && (ieee->iw_mode == IW_MODE_INFRA)) { RTLLIB_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))) { - if (ieee->open_wep || !challenge){ + errcode = auth_parse(skb, &challenge, &chlen); + if (0 == errcode) { + if (ieee->open_wep || !challenge) { ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; - if (!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE)) - { - if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) - { - if (IsHTHalfNmodeAPs(ieee)) - { + if (!(ieee->pHTInfo->IOTAction & + HT_IOT_ACT_PURE_N_MODE)) { + if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { + if (IsHTHalfNmodeAPs(ieee)) { bSupportNmode = true; bHalfSupportNmode = true; - } - else - { + } else { bSupportNmode = false; bHalfSupportNmode = false; } } } - /* Dummy wirless mode setting to avoid encryption issue */ + /* Dummy wirless mode setting to avoid + * encryption issue */ if (bSupportNmode) { - ieee->SetWirelessMode(ieee->dev, \ - ieee->current_network.mode); - }else{ + ieee->SetWirelessMode(ieee->dev, + ieee->current_network.mode); + } else { /*TODO*/ - ieee->SetWirelessMode(ieee->dev, IEEE_G); + ieee->SetWirelessMode(ieee->dev, + IEEE_G); } - if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true) - { - printk("===============>entern half N mode\n"); - ieee->bHalfWirelessN24GMode = true; - } - else - ieee->bHalfWirelessN24GMode = false; + if (ieee->current_network.mode == + IEEE_N_24G && + bHalfSupportNmode == true) { + printk(KERN_INFO "======>enter " + "half N mode\n"); + ieee->bHalfWirelessN24GMode = + true; + } else + ieee->bHalfWirelessN24GMode = + false; rtllib_associate_step2(ieee); - }else{ - rtllib_auth_challenge(ieee, challenge, chlen); + } else { + rtllib_auth_challenge(ieee, challenge, + chlen); } - }else{ + } else { ieee->softmac_stats.rx_auth_rs_err++; - RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",errcode); + RTLLIB_DEBUG_MGMT("Authentication respose" + " status code 0x%x", errcode); - printk("Authentication respose status code 0x%x",errcode); + printk(KERN_INFO "Authentication respose " + "status code 0x%x", errcode); rtllib_associate_abort(ieee); } - }else if (ieee->iw_mode == IW_MODE_MASTER){ + } else if (ieee->iw_mode == IW_MODE_MASTER) { rtllib_rx_auth_rq(ieee, skb); } } - return 0; } @@ -2453,7 +2404,7 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) printk(KERN_INFO "==========>received disassoc/deauth(%x) " "frame, reason code:%x\n", WLAN_FC_GET_STYPE(header->frame_ctl), - ((struct rtllib_disassoc*)skb->data)->reason); + ((struct rtllib_disassoc *)skb->data)->reason); ieee->state = RTLLIB_ASSOCIATING; ieee->softmac_stats.reassoc++; ieee->is_roaming = true; @@ -2461,18 +2412,21 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) rtllib_disassociate(ieee); RemovePeerTS(ieee, header->addr2); if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); + ieee->LedControlHandler(ieee->dev, + LED_CTL_START_TO_LINK); - if (!(ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_CCMP|SEC_ALG_TKIP))) - queue_delayed_work_rsl(ieee->wq, &ieee->associate_procedure_wq, 5); + if (!(ieee->rtllib_ap_sec_type(ieee) & + (SEC_ALG_CCMP|SEC_ALG_TKIP))) + queue_delayed_work_rsl(ieee->wq, + &ieee->associate_procedure_wq, 5); } - return 0; } -inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, u16 type, - u16 stype) +inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, u16 type, + u16 stype) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; @@ -2480,44 +2434,31 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *s return 0; switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { - - case RTLLIB_STYPE_ASSOC_RESP: - case RTLLIB_STYPE_REASSOC_RESP: - - if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) - return 1; - - break; - - case RTLLIB_STYPE_ASSOC_REQ: - case RTLLIB_STYPE_REASSOC_REQ: - - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && - ieee->iw_mode == IW_MODE_MASTER) - - rtllib_rx_assoc_rq(ieee, skb); - break; - - case RTLLIB_STYPE_AUTH: - - rtllib_rx_auth(ieee, skb, rx_stats); - - break; - case RTLLIB_STYPE_DISASSOC: - case RTLLIB_STYPE_DEAUTH: - - rtllib_rx_deauth(ieee, skb); - - break; - - case RTLLIB_STYPE_MANAGE_ACT: - rtllib_process_action(ieee,skb); - break; - default: - return -1; - break; + case RTLLIB_STYPE_ASSOC_RESP: + case RTLLIB_STYPE_REASSOC_RESP: + if (rtllib_rx_assoc_resp(ieee, skb, rx_stats) == 1) + return 1; + break; + case RTLLIB_STYPE_ASSOC_REQ: + case RTLLIB_STYPE_REASSOC_REQ: + if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && + ieee->iw_mode == IW_MODE_MASTER) + rtllib_rx_assoc_rq(ieee, skb); + break; + case RTLLIB_STYPE_AUTH: + rtllib_rx_auth(ieee, skb, rx_stats); + break; + case RTLLIB_STYPE_DISASSOC: + case RTLLIB_STYPE_DEAUTH: + rtllib_rx_deauth(ieee, skb); + break; + case RTLLIB_STYPE_MANAGE_ACT: + rtllib_process_action(ieee, skb); + break; + default: + return -1; + break; } - return 0; } @@ -2548,43 +2489,43 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) struct cb_desc *tcb_desc = NULL; unsigned long queue_len = 0; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd parm 0, no tx mgmt lock required */ - rtllib_sta_wakeup(ieee,0); + rtllib_sta_wakeup(ieee, 0); /* update the tx status */ - tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); - if (tcb_desc->bMulticast) { + tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + + MAX_DEV_ADDR_SIZE); + if (tcb_desc->bMulticast) ieee->stats.multicast++; - } - /* if xmit available, just xmit it immediately, else just insert it to the wait queue */ + /* if xmit available, just xmit it immediately, else just insert it to + * the wait queue */ for (i = 0; i < txb->nr_frags; i++) { queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]); if ((queue_len != 0) ||\ - (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\ - (ieee->queue_stop)) { + (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) || + (ieee->queue_stop)) { /* insert the skb packet to the wait queue */ /* as for the completion function, it does not need * to check it any more. * */ if (queue_len < 200) - { - skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]); - }else{ + skb_queue_tail(&ieee->skb_waitQ[queue_index], + txb->fragments[i]); + else kfree_skb(txb->fragments[i]); - } - }else{ + } else { ieee->softmac_data_hard_start_xmit( txb->fragments[i], - ieee->dev,ieee->rate); + ieee->dev, ieee->rate); } } rtllib_txb_free(txb); - spin_unlock_irqrestore(&ieee->lock,flags); + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2592,16 +2533,17 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) void rtllib_resume_tx(struct rtllib_device *ieee) { int i; - for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { + for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; + i++) { - if (ieee->queue_stop){ + if (ieee->queue_stop) { ieee->tx_pending.frag = i; return; - }else{ + } else { ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], - ieee->dev,ieee->rate); + ieee->dev, ieee->rate); ieee->stats.tx_packets++; } } @@ -2615,14 +2557,14 @@ void rtllib_reset_queue(struct rtllib_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); init_mgmt_queue(ieee); - if (ieee->tx_pending.txb){ + if (ieee->tx_pending.txb) { rtllib_txb_free(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; - spin_unlock_irqrestore(&ieee->lock,flags); + spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2633,13 +2575,14 @@ void rtllib_wake_queue(struct rtllib_device *ieee) struct sk_buff *skb; struct rtllib_hdr_3addr *header; - spin_lock_irqsave(&ieee->lock,flags); - if (! ieee->queue_stop) goto exit; + spin_lock_irqsave(&ieee->lock, flags); + if (!ieee->queue_stop) + goto exit; ieee->queue_stop = 0; - if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ + if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { + while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))) { header = (struct rtllib_hdr_3addr *) skb->data; @@ -2650,26 +2593,27 @@ void rtllib_wake_queue(struct rtllib_device *ieee) else ieee->seq_ctrl[0]++; - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, + ieee->basic_rate); } } if (!ieee->queue_stop && ieee->tx_pending.txb) rtllib_resume_tx(ieee); - if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)) { ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } -exit : - spin_unlock_irqrestore(&ieee->lock,flags); +exit: + spin_unlock_irqrestore(&ieee->lock, flags); } void rtllib_stop_queue(struct rtllib_device *ieee) { - if (! netif_queue_stopped(ieee->dev)){ + if (!netif_queue_stopped(ieee->dev)) { netif_stop_queue(ieee->dev); ieee->softmac_stats.swtxstop++; } @@ -2680,8 +2624,8 @@ void rtllib_stop_queue(struct rtllib_device *ieee) void rtllib_stop_all_queues(struct rtllib_device *ieee) { unsigned int i; - for (i=0; i < ieee->dev->num_tx_queues; i++) - netdev_get_tx_queue(ieee->dev,i)->trans_start = jiffies; + for (i = 0; i < ieee->dev->num_tx_queues; i++) + netdev_get_tx_queue(ieee->dev, i)->trans_start = jiffies; netif_tx_stop_all_queues(ieee->dev); } @@ -2708,12 +2652,13 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) { ieee->assoc_id = 1; - if (ieee->current_network.ssid_len == 0){ + if (ieee->current_network.ssid_len == 0) { strncpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); + ieee->current_network.ssid_len = + strlen(RTLLIB_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } @@ -2733,7 +2678,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) void rtllib_start_monitor_mode(struct rtllib_device *ieee) { /* reset hardware status */ - if (ieee->raw_tx){ + if (ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -2743,7 +2688,8 @@ void rtllib_start_monitor_mode(struct rtllib_device *ieee) void rtllib_start_ibss_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, start_ibss_wq); /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET * operations because of the wx_sem hold. @@ -2751,14 +2697,14 @@ void rtllib_start_ibss_wq(void *data) * (abort) this wq (when syncro scanning) before sleeping * on the semaphore */ - if (!ieee->proto_started){ - printk("==========oh driver down return\n"); + if (!ieee->proto_started) { + printk(KERN_INFO "==========oh driver down return\n"); return; } down(&ieee->wx_sem); - if (ieee->current_network.ssid_len == 0){ - strcpy(ieee->current_network.ssid,RTLLIB_DEFAULT_TX_ESSID); + if (ieee->current_network.ssid_len == 0) { + strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } @@ -2787,47 +2733,50 @@ void rtllib_start_ibss_wq(void *data) rtllib_start_scan_syncro(ieee, 0); /* the network definitively is not here.. create a new cell */ - if (ieee->state == RTLLIB_NOLINK){ - printk("creating new IBSS cell\n"); + if (ieee->state == RTLLIB_NOLINK) { + printk(KERN_INFO "creating new IBSS cell\n"); ieee->current_network.channel = ieee->IbssStartChnl; if (!ieee->wap_set) rtllib_randomize_cell(ieee); - if (ieee->modulation & RTLLIB_CCK_MODULATION){ + if (ieee->modulation & RTLLIB_CCK_MODULATION) { ieee->current_network.rates_len = 4; - ieee->current_network.rates[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; - ieee->current_network.rates[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; - ieee->current_network.rates[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; - ieee->current_network.rates[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; + ieee->current_network.rates[0] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_1MB; + ieee->current_network.rates[1] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_2MB; + ieee->current_network.rates[2] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_5MB; + ieee->current_network.rates[3] = + RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB; - }else + } else ieee->current_network.rates_len = 0; - if (ieee->modulation & RTLLIB_OFDM_MODULATION){ + if (ieee->modulation & RTLLIB_OFDM_MODULATION) { ieee->current_network.rates_ex_len = 8; - /*ieee->current_network.rates_ex[0] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_6MB; - ieee->current_network.rates_ex[1] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_9MB; - ieee->current_network.rates_ex[2] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_12MB; - ieee->current_network.rates_ex[3] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_18MB; - ieee->current_network.rates_ex[4] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_24MB; - ieee->current_network.rates_ex[5] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_36MB; - ieee->current_network.rates_ex[6] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_48MB; - ieee->current_network.rates_ex[7] = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB;*/ - - ieee->current_network.rates_ex[0] = RTLLIB_OFDM_RATE_6MB; - ieee->current_network.rates_ex[1] = RTLLIB_OFDM_RATE_9MB; - ieee->current_network.rates_ex[2] = RTLLIB_OFDM_RATE_12MB; - ieee->current_network.rates_ex[3] = RTLLIB_OFDM_RATE_18MB; - ieee->current_network.rates_ex[4] = RTLLIB_OFDM_RATE_24MB; - ieee->current_network.rates_ex[5] = RTLLIB_OFDM_RATE_36MB; - ieee->current_network.rates_ex[6] = RTLLIB_OFDM_RATE_48MB; - ieee->current_network.rates_ex[7] = RTLLIB_OFDM_RATE_54MB; + ieee->current_network.rates_ex[0] = + RTLLIB_OFDM_RATE_6MB; + ieee->current_network.rates_ex[1] = + RTLLIB_OFDM_RATE_9MB; + ieee->current_network.rates_ex[2] = + RTLLIB_OFDM_RATE_12MB; + ieee->current_network.rates_ex[3] = + RTLLIB_OFDM_RATE_18MB; + ieee->current_network.rates_ex[4] = + RTLLIB_OFDM_RATE_24MB; + ieee->current_network.rates_ex[5] = + RTLLIB_OFDM_RATE_36MB; + ieee->current_network.rates_ex[6] = + RTLLIB_OFDM_RATE_48MB; + ieee->current_network.rates_ex[7] = + RTLLIB_OFDM_RATE_54MB; ieee->rate = 108; - }else{ + } else { ieee->current_network.rates_ex_len = 0; ieee->rate = 22; } @@ -2839,20 +2788,21 @@ void rtllib_start_ibss_wq(void *data) ieee->current_network.capability = WLAN_CAPABILITY_IBSS; } - printk("%s(): ieee->mode = %d\n", __func__, ieee->mode); + printk(KERN_INFO "%s(): ieee->mode = %d\n", __func__, ieee->mode); if ((ieee->mode == IEEE_N_24G) || (ieee->mode == IEEE_N_5G)) HTUseDefaultSetting(ieee); else ieee->pHTInfo->bCurrentHTSupport = false; - ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&ieee->state)); + ieee->SetHwRegHandler(ieee->dev, HW_VAR_MEDIA_STATUS, + (u8 *)(&ieee->state)); ieee->state = RTLLIB_LINKED; ieee->link_change(ieee->dev); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); if (ieee->LedControlHandler != NULL) - ieee->LedControlHandler(ieee->dev,LED_CTL_LINK); + ieee->LedControlHandler(ieee->dev, LED_CTL_LINK); rtllib_start_send_beacons(ieee); @@ -2875,12 +2825,9 @@ inline void rtllib_start_ibss(struct rtllib_device *ieee) void rtllib_start_bss(struct rtllib_device *ieee) { unsigned long flags; - if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) - { - if (! ieee->bGlobalDomain) - { + if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) { + if (!ieee->bGlobalDomain) return; - } } /* check if we have already found the net we * are interested in (if any). @@ -2898,15 +2845,15 @@ void rtllib_start_bss(struct rtllib_device *ieee) */ spin_lock_irqsave(&ieee->lock, flags); - if (ieee->state == RTLLIB_NOLINK) { + if (ieee->state == RTLLIB_NOLINK) rtllib_start_scan(ieee); - } spin_unlock_irqrestore(&ieee->lock, flags); } void rtllib_link_change_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, link_change_wq); ieee->link_change(ieee->dev); } /* called only in userspace context */ @@ -2931,7 +2878,8 @@ void rtllib_disassociate(struct rtllib_device *ieee) void rtllib_associate_retry_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, associate_retry_wq); unsigned long flags; down(&ieee->wx_sem); @@ -2962,9 +2910,7 @@ void rtllib_associate_retry_wq(void *data) spin_lock_irqsave(&ieee->lock, flags); if (ieee->state == RTLLIB_NOLINK) - { rtllib_start_scan(ieee); - } spin_unlock_irqrestore(&ieee->lock, flags); ieee->beinretry = false; @@ -2974,7 +2920,7 @@ exit: struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) { - u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sk_buff *skb; struct rtllib_probe_response *b; @@ -3010,11 +2956,12 @@ struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee) return skb; } -void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, u8 shutdown) +void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, u8 mesh_flag, + u8 shutdown) { rtllib_stop_scan_syncro(ieee); down(&ieee->wx_sem); - rtllib_stop_protocol(ieee,shutdown); + rtllib_stop_protocol(ieee, shutdown); up(&ieee->wx_sem); } @@ -3024,8 +2971,8 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) if (!ieee->proto_started) return; - if (shutdown){ - ieee->proto_started = 0; + if (shutdown) { + ieee->proto_started = 0; ieee->proto_stoppping = 1; if (ieee->rtllib_ips_leave != NULL) ieee->rtllib_ips_leave(ieee->dev); @@ -3041,26 +2988,22 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown) if (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED) ieee->state = RTLLIB_NOLINK; - if (ieee->state == RTLLIB_LINKED){ + if (ieee->state == RTLLIB_LINKED) { if (ieee->iw_mode == IW_MODE_INFRA) - SendDisassociation(ieee,1,deauth_lv_ss); + SendDisassociation(ieee, 1, deauth_lv_ss); rtllib_disassociate(ieee); } - if (shutdown){ + if (shutdown) { RemoveAllTS(ieee); ieee->proto_stoppping = 0; } - if (ieee->assocreq_ies) { - kfree(ieee->assocreq_ies); - ieee->assocreq_ies = NULL; - ieee->assocreq_ies_len = 0; - } - if (ieee->assocresp_ies) { - kfree(ieee->assocresp_ies); - ieee->assocresp_ies = NULL; - ieee->assocresp_ies_len = 0; - } + kfree(ieee->assocreq_ies); + ieee->assocreq_ies = NULL; + ieee->assocreq_ies_len = 0; + kfree(ieee->assocresp_ies); + ieee->assocresp_ies = NULL; + ieee->assocresp_ies_len = 0; } void rtllib_softmac_start_protocol(struct rtllib_device *ieee, u8 mesh_flag) @@ -3087,7 +3030,7 @@ void rtllib_start_protocol(struct rtllib_device *ieee) ch++; if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - } while(!ieee->active_channel_map[ch]); + } while (!ieee->active_channel_map[ch]); ieee->current_network.channel = ch; } @@ -3130,20 +3073,19 @@ void rtllib_softmac_init(struct rtllib_device *ieee) memset(&ieee->current_network, 0, sizeof(struct rtllib_network)); ieee->state = RTLLIB_NOLINK; - for (i = 0; i < 5; i++) { - ieee->seq_ctrl[i] = 0; - } + for (i = 0; i < 5; i++) + ieee->seq_ctrl[i] = 0; ieee->pDot11dInfo = kmalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC); if (!ieee->pDot11dInfo) RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n"); memset(ieee->pDot11dInfo, 0, sizeof(struct rt_dot11d_info)); ieee->LinkDetectInfo.SlotIndex = 0; ieee->LinkDetectInfo.SlotNum = 2; - ieee->LinkDetectInfo.NumRecvBcnInPeriod=0; - ieee->LinkDetectInfo.NumRecvDataInPeriod=0; - ieee->LinkDetectInfo.NumTxOkInPeriod =0; - ieee->LinkDetectInfo.NumRxOkInPeriod =0; - ieee->LinkDetectInfo.NumRxUnicastOkInPeriod=0; + ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; ieee->bIsAggregateFrame = false; ieee->assoc_id = 0; ieee->queue_stop = 0; @@ -3158,13 +3100,13 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->ps = RTLLIB_PS_DISABLED; ieee->sta_sleep = LPS_IS_WAKE; - ieee->Regdot11HTOperationalRateSet[0]= 0xff; - ieee->Regdot11HTOperationalRateSet[1]= 0xff; - ieee->Regdot11HTOperationalRateSet[4]= 0x01; + ieee->Regdot11HTOperationalRateSet[0] = 0xff; + ieee->Regdot11HTOperationalRateSet[1] = 0xff; + ieee->Regdot11HTOperationalRateSet[4] = 0x01; - ieee->Regdot11TxHTOperationalRateSet[0]= 0xff; - ieee->Regdot11TxHTOperationalRateSet[1]= 0xff; - ieee->Regdot11TxHTOperationalRateSet[4]= 0x01; + ieee->Regdot11TxHTOperationalRateSet[0] = 0xff; + ieee->Regdot11TxHTOperationalRateSet[1] = 0xff; + ieee->Regdot11TxHTOperationalRateSet[4] = 0x01; ieee->FirstIe_InScan = false; ieee->actscanning = false; @@ -3191,18 +3133,26 @@ void rtllib_softmac_init(struct rtllib_device *ieee) ieee->wq = create_workqueue(DRV_NAME); - INIT_DELAYED_WORK_RSL(&ieee->link_change_wq,(void*)rtllib_link_change_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq,(void*)rtllib_start_ibss_wq,ieee); - INIT_WORK_RSL(&ieee->associate_complete_wq, (void*)rtllib_associate_complete_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, (void*)rtllib_associate_procedure_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq,(void*)rtllib_softmac_scan_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq,(void*)rtllib_softmac_hint11d_wq,ieee); - INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, (void*)rtllib_associate_retry_wq,ieee); - INIT_WORK_RSL(&ieee->wx_sync_scan_wq,(void*)rtllib_wx_sync_scan_wq,ieee); + INIT_DELAYED_WORK_RSL(&ieee->link_change_wq, + (void *)rtllib_link_change_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->start_ibss_wq, + (void *)rtllib_start_ibss_wq, ieee); + INIT_WORK_RSL(&ieee->associate_complete_wq, + (void *)rtllib_associate_complete_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_procedure_wq, + (void *)rtllib_associate_procedure_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_scan_wq, + (void *)rtllib_softmac_scan_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->softmac_hint11d_wq, + (void *)rtllib_softmac_hint11d_wq, ieee); + INIT_DELAYED_WORK_RSL(&ieee->associate_retry_wq, + (void *)rtllib_associate_retry_wq, ieee); + INIT_WORK_RSL(&ieee->wx_sync_scan_wq, (void *)rtllib_wx_sync_scan_wq, + ieee); sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); - sema_init(&ieee->ips_sem,1); + sema_init(&ieee->ips_sem, 1); spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); @@ -3216,8 +3166,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) void rtllib_softmac_free(struct rtllib_device *ieee) { down(&ieee->wx_sem); - if (NULL != ieee->pDot11dInfo) - { + if (NULL != ieee->pDot11dInfo) { kfree(ieee->pDot11dInfo); ieee->pDot11dInfo = NULL; } @@ -3229,8 +3178,8 @@ void rtllib_softmac_free(struct rtllib_device *ieee) } /******************************************************** - * Start of WPA code. * - * this is stolen from the ipw2200 driver * + * Start of WPA code. * + * this is stolen from the ipw2200 driver * ********************************************************/ @@ -3238,14 +3187,15 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ - printk("%s WPA\n",value ? "enabling" : "disabling"); + printk(KERN_INFO "%s WPA\n", value ? "enabling" : "disabling"); ieee->wpa_enabled = value; memset(ieee->ap_mac_addr, 0, 6); return 0; } -void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, int wpa_ie_len) +void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, + int wpa_ie_len) { /* make sure WPA is enabled */ rtllib_wpa_enable(ieee, 1); @@ -3268,7 +3218,7 @@ static int rtllib_wpa_mlme(struct rtllib_device *ieee, int command, int reason) break; default: - printk("Unknown MLME request: %d\n", command); + printk(KERN_INFO "Unknown MLME request: %d\n", command); ret = -EOPNOTSUPP; } @@ -3319,12 +3269,11 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) sec.auth_mode = WLAN_AUTH_SHARED_KEY; ieee->open_wep = 0; ieee->auth_mode = 1; - } else if (value & AUTH_ALG_OPEN_SYSTEM){ + } else if (value & AUTH_ALG_OPEN_SYSTEM) { sec.auth_mode = WLAN_AUTH_OPEN; ieee->open_wep = 1; ieee->auth_mode = 0; - } - else if (value & AUTH_ALG_LEAP){ + } else if (value & AUTH_ALG_LEAP) { sec.auth_mode = WLAN_AUTH_LEAP >> 6; ieee->open_wep = 1; ieee->auth_mode = 2; @@ -3339,7 +3288,7 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) { - int ret=0; + int ret = 0; unsigned long flags; switch (name) { @@ -3348,11 +3297,11 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) break; case IEEE_PARAM_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures=value; + ieee->tkip_countermeasures = value; break; - case IEEE_PARAM_DROP_UNENCRYPTED: - { + case IEEE_PARAM_DROP_UNENCRYPTED: + { /* HACK: * * wpa_supplicant calls set_wpa_enabled when the driver @@ -3375,8 +3324,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) if (!value) { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_0; - } - else { + } else { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; } @@ -3386,7 +3334,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) } case IEEE_PARAM_PRIVACY_INVOKED: - ieee->privacy_invoked=value; + ieee->privacy_invoked = value; break; case IEEE_PARAM_AUTH_ALGS: @@ -3394,15 +3342,15 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) break; case IEEE_PARAM_IEEE_802_1X: - ieee->ieee802_1x=value; + ieee->ieee802_1x = value; break; case IEEE_PARAM_WPAX_SELECT: - spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); - spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); + spin_lock_irqsave(&ieee->wpax_suitlist_lock, flags); + spin_unlock_irqrestore(&ieee->wpax_suitlist_lock, flags); break; default: - printk("Unknown WPA param: %d\n",name); + printk(KERN_INFO "Unknown WPA param: %d\n", name); ret = -EOPNOTSUPP; } @@ -3411,7 +3359,8 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) /* implementation borrowed from hostap driver */ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, - struct ieee_param *param, int param_len, u8 is_mesh) + struct ieee_param *param, int param_len, + u8 is_mesh) { int ret = 0; struct rtllib_crypto_ops *ops; @@ -3427,7 +3376,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, if (param_len != (int) ((char *) param->u.crypt.key - (char *) param) + param->u.crypt.key_len) { - printk("Len mismatch %d, %d\n", param_len, + printk(KERN_INFO "Len mismatch %d, %d\n", param_len, param->u.crypt.key_len); return -EINVAL; } @@ -3470,7 +3419,8 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, ops = rtllib_get_crypto_ops(param->u.crypt.alg); } if (ops == NULL) { - printk("unknown crypto alg '%s'\n", param->u.crypt.alg); + printk(KERN_INFO "unknown crypto alg '%s'\n", + param->u.crypt.alg); param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; ret = -EINVAL; goto done; @@ -3506,7 +3456,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, (*crypt)->ops->set_key(param->u.crypt.key, param->u.crypt.key_len, param->u.crypt.seq, (*crypt)->priv) < 0) { - printk("key setting failed\n"); + printk(KERN_INFO "key setting failed\n"); param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED; ret = -EINVAL; goto done; @@ -3551,7 +3501,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, ieee->iw_mode != IW_MODE_INFRA && ieee->reset_port && ieee->reset_port(ieee->dev)) { - printk("reset_port failed\n"); + printk(KERN_INFO "reset_port failed\n"); param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED; return -EINVAL; } @@ -3559,7 +3509,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee, return ret; } -inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, +inline struct sk_buff *rtllib_disauth_skb(struct rtllib_network *beacon, struct rtllib_device *ieee, u16 asRsn) { struct sk_buff *skb; @@ -3567,13 +3517,13 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, int len = sizeof(struct rtllib_disauth) + ieee->tx_headroom; skb = dev_alloc_skb(len); - if (!skb) { + if (!skb) return NULL; - } skb_reserve(skb, ieee->tx_headroom); - disauth = (struct rtllib_disauth *) skb_put(skb,sizeof(struct rtllib_disauth)); + disauth = (struct rtllib_disauth *) skb_put(skb, + sizeof(struct rtllib_disauth)); disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH); disauth->header.duration_id = 0; @@ -3585,7 +3535,7 @@ inline struct sk_buff *rtllib_disauth_skb( struct rtllib_network *beacon, return skb; } -inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, +inline struct sk_buff *rtllib_disassociate_skb(struct rtllib_network *beacon, struct rtllib_device *ieee, u16 asRsn) { struct sk_buff *skb; @@ -3593,13 +3543,13 @@ inline struct sk_buff *rtllib_disassociate_skb( struct rtllib_network *beacon, int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom; skb = dev_alloc_skb(len); - if (!skb) { + if (!skb) return NULL; - } skb_reserve(skb, ieee->tx_headroom); - disass = (struct rtllib_disassoc *) skb_put(skb,sizeof(struct rtllib_disassoc)); + disass = (struct rtllib_disassoc *) skb_put(skb, + sizeof(struct rtllib_disassoc)); disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC); disass->header.duration_id = 0; @@ -3616,36 +3566,36 @@ void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn) struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; - if (deauth) { - skb = rtllib_disauth_skb(beacon,ieee,asRsn); - } else { - skb = rtllib_disassociate_skb(beacon,ieee,asRsn); - } + if (deauth) + skb = rtllib_disauth_skb(beacon, ieee, asRsn); + else + skb = rtllib_disassociate_skb(beacon, ieee, asRsn); - if (skb){ + if (skb) softmac_mgmt_xmit(skb, ieee); - } } u8 rtllib_ap_sec_type(struct rtllib_device *ieee) { - static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04}; + static u8 ccmp_ie[4] = {0x00, 0x50, 0xf2, 0x04}; static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04}; - int wpa_ie_len= ieee->wpa_ie_len; - struct rtllib_crypt_data* crypt; + int wpa_ie_len = ieee->wpa_ie_len; + struct rtllib_crypt_data *crypt; int encrypt; crypt = ieee->crypt[ieee->tx_keyidx]; - encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) ||\ - (ieee->host_encrypt && crypt && crypt->ops && \ - (0 == strcmp(crypt->ops->name,"WEP"))); + encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) + || (ieee->host_encrypt && crypt && crypt->ops && + (0 == strcmp(crypt->ops->name, "WEP"))); /* simply judge */ if (encrypt && (wpa_ie_len == 0)) { return SEC_ALG_WEP; } else if ((wpa_ie_len != 0)) { - if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || - ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4)))) + if (((ieee->wpa_ie[0] == 0xdd) && + (!memcmp(&(ieee->wpa_ie[14]), ccmp_ie, 4))) || + ((ieee->wpa_ie[0] == 0x30) && + (!memcmp(&ieee->wpa_ie[10], ccmp_rsn_ie, 4)))) return SEC_ALG_CCMP; else return SEC_ALG_TKIP; @@ -3654,20 +3604,21 @@ u8 rtllib_ap_sec_type(struct rtllib_device *ieee) } } -int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, u8 is_mesh) +int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, + u8 is_mesh) { struct ieee_param *param; - int ret=0; + int ret = 0; down(&ieee->wx_sem); - if (p->length < sizeof(struct ieee_param) || !p->pointer){ + if (p->length < sizeof(struct ieee_param) || !p->pointer) { ret = -EINVAL; goto out; } - param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL); - if (param == NULL){ + param = kmalloc(p->length, GFP_KERNEL); + if (param == NULL) { ret = -ENOMEM; goto out; } @@ -3678,7 +3629,6 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, } switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: ret = rtllib_wpa_set_param(ieee, param->u.wpa_param.name, param->u.wpa_param.value); @@ -3698,7 +3648,8 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, break; default: - printk("Unknown WPA supplicant request: %d\n",param->cmd); + printk(KERN_INFO "Unknown WPA supplicant request: %d\n", + param->cmd); ret = -EOPNOTSUPP; break; } @@ -3713,8 +3664,7 @@ out: return ret; } -void -rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib) +void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib) { u8 OpMode; u8 i; @@ -3722,26 +3672,25 @@ rtllib_MgntDisconnectIBSS(struct rtllib_device* rtllib) rtllib->state = RTLLIB_NOLINK; - for (i=0;i<6;i++) rtllib->current_network.bssid[i]= 0x55; + for (i = 0; i < 6; i++) + rtllib->current_network.bssid[i] = 0x55; rtllib->OpMode = RT_OP_MODE_NO_LINK; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, + rtllib->current_network.bssid); OpMode = RT_OP_MODE_NO_LINK; rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, &OpMode); rtllib_stop_send_beacons(rtllib); bFilterOutNonAssociatedBSSID = false; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, + (u8 *)(&bFilterOutNonAssociatedBSSID)); notify_wx_assoc_event(rtllib); } -void -rtllib_MlmeDisassociateRequest( - struct rtllib_device* rtllib, - u8* asSta, - u8 asRsn - ) +void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, + u8 asRsn) { u8 i; u8 OpMode; @@ -3749,17 +3698,19 @@ rtllib_MlmeDisassociateRequest( RemovePeerTS(rtllib, asSta); - if (memcpy(rtllib->current_network.bssid,asSta,6) == 0) - { + if (memcpy(rtllib->current_network.bssid, asSta, 6) == 0) { rtllib->state = RTLLIB_NOLINK; - for (i=0;i<6;i++) rtllib->current_network.bssid[i] = 0x22; + for (i = 0; i < 6; i++) + rtllib->current_network.bssid[i] = 0x22; OpMode = RT_OP_MODE_NO_LINK; rtllib->OpMode = RT_OP_MODE_NO_LINK; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, (u8 *)(&OpMode) ); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_MEDIA_STATUS, + (u8 *)(&OpMode)); rtllib_disassociate(rtllib); - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, rtllib->current_network.bssid); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_BSSID, + rtllib->current_network.bssid); } @@ -3767,40 +3718,31 @@ rtllib_MlmeDisassociateRequest( void rtllib_MgntDisconnectAP( - struct rtllib_device* rtllib, + struct rtllib_device *rtllib, u8 asRsn ) { bool bFilterOutNonAssociatedBSSID = false; bFilterOutNonAssociatedBSSID = false; - rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8*)(&bFilterOutNonAssociatedBSSID)); - rtllib_MlmeDisassociateRequest( rtllib, rtllib->current_network.bssid, asRsn ); + rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, + (u8 *)(&bFilterOutNonAssociatedBSSID)); + rtllib_MlmeDisassociateRequest(rtllib, rtllib->current_network.bssid, + asRsn); rtllib->state = RTLLIB_NOLINK; } -bool -rtllib_MgntDisconnect( - struct rtllib_device* rtllib, - u8 asRsn -) +bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn) { if (rtllib->ps != RTLLIB_PS_DISABLED) - { - rtllib->sta_wake_up(rtllib->dev); - } + rtllib->sta_wake_up(rtllib->dev); - if ( rtllib->state == RTLLIB_LINKED ) - { - if ( rtllib->iw_mode == IW_MODE_ADHOC ) - { + if (rtllib->state == RTLLIB_LINKED) { + if (rtllib->iw_mode == IW_MODE_ADHOC) rtllib_MgntDisconnectIBSS(rtllib); - } - if ( rtllib->iw_mode == IW_MODE_INFRA ) - { + if (rtllib->iw_mode == IW_MODE_INFRA) rtllib_MgntDisconnectAP(rtllib, asRsn); - } } @@ -3816,10 +3758,12 @@ void notify_wx_assoc_event(struct rtllib_device *ieee) wrqu.ap_addr.sa_family = ARPHRD_ETHER; if (ieee->state == RTLLIB_LINKED) - memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN); - else{ + memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, + ETH_ALEN); + else { - printk("%s(): Tell user space disconnected\n",__func__); + printk(KERN_INFO "%s(): Tell user space disconnected\n", + __func__); memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); } wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL); From 755f3a84cfa5e366094c33fbede39f18a4f4f08a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 9 Aug 2011 14:42:16 -0500 Subject: [PATCH 17/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XV This patch removes all the errors and warnings generated by checkpatch -f for rtllib_softmac_wx.c.. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 177 ++++++++++--------- 1 file changed, 90 insertions(+), 87 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index e6702a141652..22988fbd444b 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -31,11 +31,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int ret; - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; down(&ieee->wx_sem); - if (ieee->iw_mode == IW_MODE_INFRA){ + if (ieee->iw_mode == IW_MODE_INFRA) { ret = 0; goto out; } @@ -56,11 +56,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, } } - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1) { ret = -EOPNOTSUPP; goto out; - }else { /* Set the channel */ + } else { /* Set the channel */ if (ieee->active_channel_map[fwrq->m] != 1) { ret = -EINVAL; @@ -69,11 +69,11 @@ int rtllib_wx_set_freq(struct rtllib_device *ieee, struct iw_request_info *a, ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - if (ieee->state == RTLLIB_LINKED){ - - rtllib_stop_send_beacons(ieee); - rtllib_start_send_beacons(ieee); + if (ieee->iw_mode == IW_MODE_ADHOC || + ieee->iw_mode == IW_MODE_MASTER) + if (ieee->state == RTLLIB_LINKED) { + rtllib_stop_send_beacons(ieee); + rtllib_start_send_beacons(ieee); } } @@ -88,11 +88,12 @@ int rtllib_wx_get_freq(struct rtllib_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; if (ieee->current_network.channel == 0) return -1; - fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel-1] * 100000; + fwrq->m = rtllib_wlan_frequencies[ieee->current_network.channel-1] * + 100000; fwrq->e = 1; return 0; } @@ -133,7 +134,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, { int ret = 0; - u8 zero[] = {0,0,0,0,0,0}; + u8 zero[] = {0, 0, 0, 0, 0, 0}; unsigned long flags; short ifup = ieee->proto_started; @@ -143,28 +144,28 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, down(&ieee->wx_sem); /* use ifconfig hw ether */ - if (ieee->iw_mode == IW_MODE_MASTER){ + if (ieee->iw_mode == IW_MODE_MASTER) { ret = -1; goto out; } - if (temp->sa_family != ARPHRD_ETHER){ + if (temp->sa_family != ARPHRD_ETHER) { ret = -EINVAL; goto out; } - if (memcmp(temp->sa_data, zero,ETH_ALEN) == 0){ - spin_lock_irqsave(&ieee->lock, flags); - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); - ieee->wap_set = 0; - spin_unlock_irqrestore(&ieee->lock, flags); - ret = -1; - goto out; - } + if (memcmp(temp->sa_data, zero, ETH_ALEN) == 0) { + spin_lock_irqsave(&ieee->lock, flags); + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); + ieee->wap_set = 0; + spin_unlock_irqrestore(&ieee->lock, flags); + ret = -1; + goto out; + } if (ifup) - rtllib_stop_protocol(ieee,true); + rtllib_stop_protocol(ieee, true); /* just to avoid to give inconsistent infos in the * get wx method. not really needed otherwise @@ -173,7 +174,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee, ieee->cannot_notify = false; memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN); - ieee->wap_set = (memcmp(temp->sa_data, zero,ETH_ALEN)!=0); + ieee->wap_set = (memcmp(temp->sa_data, zero, ETH_ALEN) != 0); spin_unlock_irqrestore(&ieee->lock, flags); @@ -184,9 +185,10 @@ out: return ret; } - int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) +int rtllib_wx_get_essid(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) { - int len,ret = 0; + int len, ret = 0; unsigned long flags; if (ieee->iw_mode == IW_MODE_MONITOR) @@ -196,20 +198,20 @@ out: spin_lock_irqsave(&ieee->lock, flags); if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0) { ret = -1; goto out; } if (ieee->state != RTLLIB_LINKED && ieee->state != RTLLIB_LINKED_SCANNING && - ieee->ssid_set == 0){ + ieee->ssid_set == 0) { ret = -1; goto out; } len = ieee->current_network.ssid_len; wrqu->essid.length = len; - strncpy(b,ieee->current_network.ssid,len); + strncpy(b, ieee->current_network.ssid, len); wrqu->essid.flags = 1; out: @@ -235,7 +237,8 @@ int rtllib_wx_get_rate(struct rtllib_device *ieee, union iwreq_data *wrqu, char *extra) { u32 tmp_rate = 0; - tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); + tmp_rate = TxCountToDataRate(ieee, + ieee->softmac_stats.CurrentShowTxate); wrqu->bitrate.value = tmp_rate * 500000; return 0; @@ -248,8 +251,7 @@ int rtllib_wx_set_rts(struct rtllib_device *ieee, { if (wrqu->rts.disabled || !wrqu->rts.fixed) ieee->rts = DEFAULT_RTS_THRESHOLD; - else - { + else { if (wrqu->rts.value < MIN_RTS_THRESHOLD || wrqu->rts.value > MAX_RTS_THRESHOLD) return -EINVAL; @@ -293,17 +295,17 @@ int rtllib_wx_set_mode(struct rtllib_device *ieee, struct iw_request_info *a, if (wrqu->mode == IW_MODE_MONITOR) { ieee->dev->type = ARPHRD_IEEE80211; - rtllib_EnableNetMonitorMode(ieee->dev,false); + rtllib_EnableNetMonitorMode(ieee->dev, false); } else { ieee->dev->type = ARPHRD_ETHER; if (ieee->iw_mode == IW_MODE_MONITOR) - rtllib_DisableNetMonitorMode(ieee->dev,false); + rtllib_DisableNetMonitorMode(ieee->dev, false); } if (!ieee->proto_started) { ieee->iw_mode = wrqu->mode; } else { - rtllib_stop_protocol(ieee,true); + rtllib_stop_protocol(ieee, true); ieee->iw_mode = wrqu->mode; rtllib_start_protocol(ieee); } @@ -315,14 +317,15 @@ out: void rtllib_wx_sync_scan_wq(void *data) { - struct rtllib_device *ieee = container_of_work_rsl(data, struct rtllib_device, wx_sync_scan_wq); + struct rtllib_device *ieee = container_of_work_rsl(data, + struct rtllib_device, wx_sync_scan_wq); short chan; - enum ht_extchnl_offset chan_offset=0; - enum ht_channel_width bandwidth=0; + enum ht_extchnl_offset chan_offset = 0; + enum ht_channel_width bandwidth = 0; int b40M = 0; - static int count = 0; + static int count; - if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) { rtllib_start_scan_syncro(ieee, 0); goto out; } @@ -346,15 +349,18 @@ void rtllib_wx_sync_scan_wq(void *data) msleep(50); if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); + ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_BACKUP); - if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) { + if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && + ieee->pHTInfo->bCurBW40MHz) { b40M = 1; chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset; bandwidth = (enum ht_channel_width)ieee->pHTInfo->bCurBW40MHz; - RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth); - ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); - } + RT_TRACE(COMP_DBG, "Scan in 40M, force to 20M first:%d, %d\n", + chan_offset, bandwidth); + ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, + HT_EXTCHNL_OFFSET_NO_EXT); + } rtllib_start_scan_syncro(ieee, 0); @@ -372,7 +378,7 @@ void rtllib_wx_sync_scan_wq(void *data) } if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); + ieee->ScanOperationBackupHandler(ieee->dev, SCAN_OPT_RESTORE); ieee->state = RTLLIB_LINKED; ieee->link_change(ieee->dev); @@ -381,9 +387,9 @@ void rtllib_wx_sync_scan_wq(void *data) rtllib_sta_ps_send_null_frame(ieee, 0); if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || - ieee->LinkDetectInfo.NumRecvDataInPeriod == 0 ) { + ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } if (ieee->data_hard_resume) @@ -407,12 +413,12 @@ int rtllib_wx_set_scan(struct rtllib_device *ieee, struct iw_request_info *a, down(&ieee->wx_sem); - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){ + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)) { ret = -1; goto out; } - if ( ieee->state == RTLLIB_LINKED){ + if (ieee->state == RTLLIB_LINKED) { queue_work_rsl(ieee->wq, &ieee->wx_sync_scan_wq); /* intentionally forget to up sem */ return 0; @@ -424,11 +430,11 @@ out: } int rtllib_wx_set_essid(struct rtllib_device *ieee, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) { - int ret=0,len,i; + int ret = 0, len, i; short proto_started; unsigned long flags; @@ -437,27 +443,28 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee, proto_started = ieee->proto_started; - len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; + len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : + IW_ESSID_MAX_SIZE; - if (len > IW_ESSID_MAX_SIZE){ - ret= -E2BIG; + if (len > IW_ESSID_MAX_SIZE) { + ret = -E2BIG; goto out; } - if (ieee->iw_mode == IW_MODE_MONITOR){ - ret= -1; + if (ieee->iw_mode == IW_MODE_MONITOR) { + ret = -1; goto out; } - for (i=0; icurrent_network.ssid_len = len; ieee->cannot_notify = false; ieee->ssid_set = 1; - } - else{ + } else { ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; @@ -485,16 +491,16 @@ out: return ret; } - int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) +int rtllib_wx_get_mode(struct rtllib_device *ieee, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) { wrqu->mode = ieee->iw_mode; return 0; } - int rtllib_wx_set_rawtx(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +int rtllib_wx_set_rawtx(struct rtllib_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int *parms = (int *)extra; @@ -511,9 +517,8 @@ out: printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); - if (ieee->iw_mode == IW_MODE_MONITOR) - { - if (prev == 0 && ieee->raw_tx){ + if (ieee->iw_mode == IW_MODE_MONITOR) { + if (prev == 0 && ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -552,33 +557,30 @@ int rtllib_wx_set_power(struct rtllib_device *ieee, { int ret = 0; - if ( - (!ieee->sta_wake_up) || - (!ieee->enter_sleep_state) || - (!ieee->ps_is_queue_empty)){ - - RTLLIB_DEBUG(RTLLIB_DL_ERR,"%s(): PS mode is tryied to be use but driver missed a callback\n\n",__func__); - + if ((!ieee->sta_wake_up) || + (!ieee->enter_sleep_state) || + (!ieee->ps_is_queue_empty)) { + RTLLIB_DEBUG(RTLLIB_DL_ERR, "%s(): PS mode is tryied to be use " + "but driver missed a callback\n\n", __func__); return -1; } down(&ieee->wx_sem); - if (wrqu->power.disabled){ - RT_TRACE(COMP_DBG, "===>%s(): power disable\n",__func__); + if (wrqu->power.disabled) { + RT_TRACE(COMP_DBG, "===>%s(): power disable\n", __func__); ieee->ps = RTLLIB_PS_DISABLED; goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { ieee->ps_timeout = wrqu->power.value / 1000; - RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n",__func__,ieee->ps_timeout); + RT_TRACE(COMP_DBG, "===>%s():ps_timeout is %d\n", __func__, + ieee->ps_timeout); } - if (wrqu->power.flags & IW_POWER_PERIOD) { - + if (wrqu->power.flags & IW_POWER_PERIOD) ieee->ps_period = wrqu->power.value / 1000; - } switch (wrqu->power.flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: ieee->ps = RTLLIB_PS_UNICAST; @@ -609,7 +611,7 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret =0; + int ret = 0; down(&ieee->wx_sem); @@ -628,7 +630,8 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, wrqu->power.value = ieee->ps_period * 1000; } - if ((ieee->ps & (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) == (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) + if ((ieee->ps & (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) == + (RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST)) wrqu->power.flags |= IW_POWER_ALL_R; else if (ieee->ps & RTLLIB_PS_MBCAST) wrqu->power.flags |= IW_POWER_MULTICAST_R; From 94fa3e89b4527606b0fef70f2659f9f4ecb38cfc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 9 Aug 2011 20:15:22 -0500 Subject: [PATCH 18/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVI This patch removes all the errors and most of the warnings generated by checkpatch -f for rtllib_softmac_tx.c.. Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtllib_tx.c | 512 ++++++++++++++------------- 1 file changed, 262 insertions(+), 250 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 134e69f4ee5b..f038aa930830 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include "rtllib.h" @@ -67,21 +67,21 @@ bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x | |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------| desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep | - | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | + | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | | '-----------------------------------------------------------------------------------------' - /\ - | -802.11 Data Frame | - ,--------- 'ctrl' expands to >-----------' - | + /\ + | +802.11 Data Frame | + ,--------- 'ctrl' expands to >-----------' + | ,--'---,-------------------------------------------------------------. Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | |------|------|---------|---------|---------|------|---------|------| Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs | - | | tion | (BSSID) | | | ence | data | | - `--------------------------------------------------| |------' -Total: 28 non-data bytes `----.----' - | + | | tion | (BSSID) | | | ence | data | | + `--------------------------------------------------| |------' +Total: 28 non-data bytes `----.----' + | .- 'Frame data' expands to <---------------------------' | V @@ -89,11 +89,11 @@ Total: 28 non-data bytes `----.----' Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 | |------|------|---------|----------|------|---------| Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP | - | DSAP | SSAP | | | | Packet | - | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | - `-----------------------------------------| | -Total: 8 non-data bytes `----.----' - | + | DSAP | SSAP | | | | Packet | + | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | + `-----------------------------------------| | +Total: 8 non-data bytes `----.----' + | .- 'IP Packet' expands, if WEP enabled, to <--' | V @@ -112,7 +112,7 @@ Total: 8 non-data bytes Bytes | 6 | 6 | 2 | Variable | 4 | |-------|-------|------|-----------|------| Desc. | Dest. | Source| Type | IP Packet | fcs | - | MAC | MAC | | | | + | MAC | MAC | | | | `-----------------------------------------' Total: 18 non-data bytes @@ -130,19 +130,19 @@ payload of each frame is reduced to 492 bytes. * * ,- skb->data * | -* | ETHERNET HEADER ,-<-- PAYLOAD -* | | 14 bytes from skb->data +* | ETHERNET HEADER ,-<-- PAYLOAD +* | | 14 bytes from skb->data * | 2 bytes for Type --> ,T. | (sizeof ethhdr) -* | | | | +* | | | | * |,-Dest.--. ,--Src.---. | | | * | 6 bytes| | 6 bytes | | | | -* v | | | | | | -* 0 | v 1 | v | v 2 +* v | | | | | | +* 0 | v 1 | v | v 2 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 -* ^ | ^ | ^ | -* | | | | | | -* | | | | `T' <---- 2 bytes for Type -* | | | | +* ^ | ^ | ^ | +* | | | | | | +* | | | | `T' <---- 2 bytes for Type +* | | | | * | | '---SNAP--' <-------- 6 bytes for SNAP * | | * `-IV--' <-------------------- 4 bytes for IV (WEP) @@ -177,19 +177,16 @@ inline int rtllib_put_snap(u8 *data, u16 h_proto) return SNAP_SIZE + sizeof(u16); } -int rtllib_encrypt_fragment( - struct rtllib_device *ieee, - struct sk_buff *frag, - int hdr_len) +int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag, + int hdr_len) { - struct rtllib_crypt_data* crypt = NULL; + struct rtllib_crypt_data *crypt = NULL; int res; crypt = ieee->crypt[ieee->tx_keyidx]; - if (!(crypt && crypt->ops)) - { - printk("=========>%s(), crypt is null\n", __func__); + if (!(crypt && crypt->ops)) { + printk(KERN_INFO "=========>%s(), crypt is null\n", __func__); return -1; } /* To encrypt, frame format is: @@ -216,20 +213,20 @@ int rtllib_encrypt_fragment( } -void rtllib_txb_free(struct rtllib_txb *txb) { +void rtllib_txb_free(struct rtllib_txb *txb) +{ if (unlikely(!txb)) return; kfree(txb); } struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, - int gfp_mask) + int gfp_mask) { struct rtllib_txb *txb; int i; - txb = kmalloc( - sizeof(struct rtllib_txb) + (sizeof(u8*) * nr_frags), - gfp_mask); + txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags), + gfp_mask); if (!txb) return NULL; @@ -286,23 +283,25 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, struct cb_desc * tcb_desc) +void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, struct sk_buff *skb, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; - struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr*)skb->data; + struct rtllib_hdr_1addr* hdr = (struct rtllib_hdr_1addr *)skb->data; - if (rtllib_act_scanning(ieee,false)) + if (rtllib_act_scanning(ieee, false)) return; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; if (!IsQoSDataFrame(skb->data)) return; - if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1)) + if (is_multicast_ether_addr(hdr->addr1) || + is_broadcast_ether_addr(hdr->addr1)) return; - if (tcb_desc->bdhcp || ieee->CntAfterLink<2) + if (tcb_desc->bdhcp || ieee->CntAfterLink < 2) return; if (pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) @@ -310,22 +309,25 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, st if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) return; - if (pHTInfo->bCurrentAMPDUEnable){ - if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)){ - printk("%s: can't get TS\n", __func__); + if (pHTInfo->bCurrentAMPDUEnable) { + if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, + skb->priority, TX_DIR, true)) { + printk(KERN_INFO "%s: can't get TS\n", __func__); return; } - if (pTxTs->TxAdmittedBARecord.bValid == false){ - if (ieee->wpa_ie_len && (ieee->pairwise_key_type == KEY_TYPE_NA)) { + if (pTxTs->TxAdmittedBARecord.bValid == false) { + if (ieee->wpa_ie_len && (ieee->pairwise_key_type == + KEY_TYPE_NA)) { ; - } else if (tcb_desc->bdhcp == 1){ + } else if (tcb_desc->bdhcp == 1) { ; - } else if (!pTxTs->bDisable_AddBa){ + } else if (!pTxTs->bDisable_AddBa) { TsStartAddBaProcess(ieee, pTxTs); } goto FORCED_AGG_SETTING; } else if (pTxTs->bUsingBa == false) { - if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096)) + if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, + (pTxTs->TxCurSeq+1)%4096)) pTxTs->bUsingBa = true; else goto FORCED_AGG_SETTING; @@ -338,81 +340,80 @@ void rtllib_tx_query_agg_cap(struct rtllib_device* ieee, struct sk_buff* skb, st } FORCED_AGG_SETTING: switch (pHTInfo->ForcedAMPDUMode) { - case HT_AGG_AUTO: - break; + case HT_AGG_AUTO: + break; - case HT_AGG_FORCE_ENABLE: - tcb_desc->bAMPDUEnable = true; - tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; - tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; - break; + case HT_AGG_FORCE_ENABLE: + tcb_desc->bAMPDUEnable = true; + tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; + tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; + break; - case HT_AGG_FORCE_DISABLE: - tcb_desc->bAMPDUEnable = false; - tcb_desc->ampdu_density = 0; - tcb_desc->ampdu_factor = 0; - break; - - } - return; -} - -extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) -{ - tcb_desc->bUseShortPreamble = false; - if (tcb_desc->data_rate == 2) - { - return; - } - else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) - { - tcb_desc->bUseShortPreamble = true; + case HT_AGG_FORCE_DISABLE: + tcb_desc->bAMPDUEnable = false; + tcb_desc->ampdu_density = 0; + tcb_desc->ampdu_factor = 0; + break; } return; } -extern void -rtllib_query_HTCapShortGI(struct rtllib_device *ieee, struct cb_desc *tcb_desc) +extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) +{ + tcb_desc->bUseShortPreamble = false; + if (tcb_desc->data_rate == 2) + return; + else if (ieee->current_network.capability & + WLAN_CAPABILITY_SHORT_PREAMBLE) + tcb_desc->bUseShortPreamble = true; + return; +} + +extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bUseShortGI = false; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; - if (pHTInfo->bForcedShortGI) - { + if (pHTInfo->bForcedShortGI) { tcb_desc->bUseShortGI = true; return; } - if ((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz) + if ((pHTInfo->bCurBW40MHz == true) && pHTInfo->bCurShortGI40MHz) tcb_desc->bUseShortGI = true; - else if ((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz) + else if ((pHTInfo->bCurBW40MHz == false) && pHTInfo->bCurShortGI20MHz) tcb_desc->bUseShortGI = true; } -void rtllib_query_BandwidthMode(struct rtllib_device* ieee, struct cb_desc *tcb_desc) +void rtllib_query_BandwidthMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; tcb_desc->bPacketBW = false; - if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) + if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) return; if (tcb_desc->bMulticast || tcb_desc->bBroadcast) return; - if ((tcb_desc->data_rate & 0x80)==0) + if ((tcb_desc->data_rate & 0x80) == 0) return; - if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz) + if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && + !ieee->bandwidth_auto_switch.bforced_tx20Mhz) tcb_desc->bPacketBW = true; return; } -void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc, struct sk_buff* skb) +void rtllib_query_protectionmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc, struct sk_buff *skb) { tcb_desc->bRTSSTBC = false; tcb_desc->bRTSUseShortGI = false; @@ -426,77 +427,58 @@ void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tc if (is_broadcast_ether_addr(skb->data+16)) return; - if (ieee->mode < IEEE_N_24G) - { - if (skb->len > ieee->rts) - { + if (ieee->mode < IEEE_N_24G) { + if (skb->len > ieee->rts) { tcb_desc->bRTSEnable = true; tcb_desc->rts_rate = MGN_24M; - } - else if (ieee->current_network.buseprotection) - { + } else if (ieee->current_network.buseprotection) { tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; } return; - } - else - { + } else { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - while (true) - { - if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) - { + while (true) { + if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) { tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; - } - else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_PURE_N_MODE)) - { + } else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS | + HT_IOT_ACT_PURE_N_MODE)) { tcb_desc->bRTSEnable = true; tcb_desc->rts_rate = MGN_24M; break; } - if (ieee->current_network.buseprotection) - { + if (ieee->current_network.buseprotection) { tcb_desc->bRTSEnable = true; tcb_desc->bCTSEnable = true; tcb_desc->rts_rate = MGN_24M; break; } - if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) - { + if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) { u8 HTOpMode = pHTInfo->CurrentOpMode; - if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) || - (!pHTInfo->bCurBW40MHz && HTOpMode == 3) ) - { + if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || + HTOpMode == 3)) || + (!pHTInfo->bCurBW40MHz && HTOpMode == 3)) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } } - if (skb->len > ieee->rts) - { + if (skb->len > ieee->rts) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = true; break; } - if (tcb_desc->bAMPDUEnable) - { + if (tcb_desc->bAMPDUEnable) { tcb_desc->rts_rate = MGN_24M; tcb_desc->bRTSEnable = false; break; } goto NO_PROTECTION; } - } - if ( 0 ) - { - tcb_desc->bCTSEnable = true; - tcb_desc->rts_rate = MGN_24M; - tcb_desc->bRTSEnable = true; } if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) tcb_desc->bUseShortPreamble = true; @@ -506,39 +488,40 @@ void rtllib_query_protectionmode(struct rtllib_device* ieee, struct cb_desc * tc NO_PROTECTION: tcb_desc->bRTSEnable = false; tcb_desc->bCTSEnable = false; - tcb_desc->rts_rate = 0; + tcb_desc->rts_rate = 0; tcb_desc->RTSSC = 0; - tcb_desc->bRTSBW = false; + tcb_desc->bRTSBW = false; } -void rtllib_txrate_selectmode(struct rtllib_device* ieee, struct cb_desc * tcb_desc) +void rtllib_txrate_selectmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; if (ieee->bTxUseDriverAssingedRate) tcb_desc->bTxUseDriverAssingedRate = true; - if (!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate) - { - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) + if (!tcb_desc->bTxDisableRateFallBack || + !tcb_desc->bTxUseDriverAssingedRate) { + if (ieee->iw_mode == IW_MODE_INFRA || + ieee->iw_mode == IW_MODE_ADHOC) tcb_desc->RATRIndex = 0; } } -u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) +u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb, + u8 *dst) { u16 seqnum = 0; if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) return 0; - if (IsQoSDataFrame(skb->data)) - { + if (IsQoSDataFrame(skb->data)) { struct tx_ts_record *pTS = NULL; - if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, skb->priority, TX_DIR, true)) - { + if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, + skb->priority, TX_DIR, true)) return 0; - } seqnum = pTS->TxCurSeq; pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096; return seqnum; @@ -549,26 +532,27 @@ u16 rtllib_query_seqnum(struct rtllib_device*ieee, struct sk_buff* skb, u8* dst) static int wme_downgrade_ac(struct sk_buff *skb) { switch (skb->priority) { - case 6: - case 7: - skb->priority = 5; /* VO -> VI */ - return 0; - case 4: - case 5: - skb->priority = 3; /* VI -> BE */ - return 0; - case 0: - case 3: - skb->priority = 1; /* BE -> BK */ - return 0; - default: - return -1; + case 6: + case 7: + skb->priority = 5; /* VO -> VI */ + return 0; + case 4: + case 5: + skb->priority = 3; /* VI -> BE */ + return 0; + case 0: + case 3: + skb->priority = 1; /* BE -> BK */ + return 0; + default: + return -1; } } int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) { - struct rtllib_device *ieee = (struct rtllib_device *)netdev_priv_rsl(dev); + struct rtllib_device *ieee = (struct rtllib_device *) + netdev_priv_rsl(dev); struct rtllib_txb *txb = NULL; struct rtllib_hdr_3addrqos *frag_hdr; int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; @@ -584,25 +568,27 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) }; u8 dest[ETH_ALEN], src[ETH_ALEN]; int qos_actived = ieee->current_network.qos_data.active; - struct rtllib_crypt_data* crypt = NULL; + struct rtllib_crypt_data *crypt = NULL; struct cb_desc *tcb_desc; u8 bIsMulticast = false; u8 IsAmsdu = false; + bool bdhcp = false; - bool bdhcp =false; spin_lock_irqsave(&ieee->lock, flags); /* If there is no driver handler to take the TXB, dont' bother * creating it... */ - if ((!ieee->hard_start_xmit && !(ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE))|| - ((!ieee->softmac_data_hard_start_xmit && (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) { + if ((!ieee->hard_start_xmit && !(ieee->softmac_features & + IEEE_SOFTMAC_TX_QUEUE)) || + ((!ieee->softmac_data_hard_start_xmit && + (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) { printk(KERN_WARNING "%s: No xmit handler.\n", ieee->dev->name); goto success; } - if (likely(ieee->raw_tx == 0)){ + if (likely(ieee->raw_tx == 0)) { if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); @@ -615,39 +601,46 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) memset(skb->cb, 0, sizeof(skb->cb)); ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); - if (ieee->iw_mode == IW_MODE_MONITOR) - { + if (ieee->iw_mode == IW_MODE_MONITOR) { txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); if (unlikely(!txb)) { - printk(KERN_WARNING "%s: Could not allocate TXB\n", + printk(KERN_WARNING "%s: Could not allocate " + "TXB\n", ieee->dev->name); goto failed; } txb->encrypted = 0; txb->payload_size = skb->len; - memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + memcpy(skb_put(txb->fragments[0], skb->len), skb->data, + skb->len); goto success; } if (skb->len > 282) { if (ETH_P_IP == ether_type) { - const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14); + const struct iphdr *ip = (struct iphdr *) + ((u8 *)skb->data+14); if (IPPROTO_UDP == ip->protocol) { - struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2)); - if (((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) || - ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) { + struct udphdr *udp; + + udp = (struct udphdr *)((u8 *)ip + + (ip->ihl << 2)); + if (((((u8 *)udp)[1] == 68) && + (((u8 *)udp)[3] == 67)) || + ((((u8 *)udp)[1] == 67) && + (((u8 *)udp)[3] == 68))) { bdhcp = true; ieee->LPSDelayCnt = 200; } } - }else if (ETH_P_ARP == ether_type){ - printk("=================>DHCP Protocol start tx ARP pkt!!\n"); + } else if (ETH_P_ARP == ether_type) { + printk(KERN_INFO "=================>DHCP " + "Protocol start tx ARP pkt!!\n"); bdhcp = true; - ieee->LPSDelayCnt = ieee->current_network.tim.tim_count; - - + ieee->LPSDelayCnt = + ieee->current_network.tim.tim_count; } } @@ -656,13 +649,14 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && ieee->host_encrypt && crypt && crypt->ops; if (!encrypt && ieee->ieee802_1x && - ieee->drop_unencrypted && ether_type != ETH_P_PAE) { + ieee->drop_unencrypted && ether_type != ETH_P_PAE) { stats->tx_dropped++; goto success; } if (crypt && !encrypt && ether_type == ETH_P_PAE) { struct eapol *eap = (struct eapol *)(skb->data + - sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16)); + sizeof(struct ethhdr) - SNAP_SIZE - + sizeof(u16)); RTLLIB_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n", eap_get_type(eap->type)); } @@ -670,7 +664,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) /* Advance the SKB to the start of the payload */ skb_pull(skb, sizeof(struct ethhdr)); - /* Determine total amount of storage required for TXB packets */ + /* Determine total amount of storage required for TXB packets */ bytes = skb->len + SNAP_SIZE + sizeof(u16); if (encrypt) @@ -687,10 +681,12 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) fc |= RTLLIB_FCTL_TODS; /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */ - memcpy(&header.addr1, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr1, ieee->current_network.bssid, + ETH_ALEN); memcpy(&header.addr2, &src, ETH_ALEN); if (IsAmsdu) - memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr3, + ieee->current_network.bssid, ETH_ALEN); else memcpy(&header.addr3, &dest, ETH_ALEN); } else if (ieee->iw_mode == IW_MODE_ADHOC) { @@ -698,12 +694,14 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) Addr3 = BSSID */ memcpy(&header.addr1, dest, ETH_ALEN); memcpy(&header.addr2, src, ETH_ALEN); - memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(&header.addr3, ieee->current_network.bssid, + ETH_ALEN); } - bIsMulticast = is_broadcast_ether_addr(header.addr1) ||is_multicast_ether_addr(header.addr1); + bIsMulticast = is_broadcast_ether_addr(header.addr1) || + is_multicast_ether_addr(header.addr1); - header.frame_ctl = cpu_to_le16(fc); + header.frame_ctl = cpu_to_le16(fc); /* Determine fragmentation size based on destination (multicast * and broadcast are not fragmented) */ @@ -718,29 +716,30 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) if (qos_actived) { hdr_len = RTLLIB_3ADDR_LEN + 2; - /* in case we are a client verify acm is not set for this ac */ - while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { - printk("skb->priority = %x\n", skb->priority); - if (wme_downgrade_ac(skb)) { - break; - } - printk("converted skb->priority = %x\n", skb->priority); - } - qos_ctl |= skb->priority; - header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); + /* in case we are a client verify acm is not set for this ac */ + while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { + printk(KERN_INFO "skb->priority = %x\n", skb->priority); + if (wme_downgrade_ac(skb)) + break; + printk(KERN_INFO "converted skb->priority = %x\n", + skb->priority); + } + qos_ctl |= skb->priority; + header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); } else { hdr_len = RTLLIB_3ADDR_LEN; } /* Determine amount of payload per fragment. Regardless of if - * this stack is providing the full 802.11 header, one will - * eventually be affixed to this fragment -- so we must account for - * it when determining the amount of payload space. */ + * this stack is providing the full 802.11 header, one will + * eventually be affixed to this fragment -- so we must account + * for it when determining the amount of payload space. */ bytes_per_frag = frag_size - hdr_len; if (ieee->config & - (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) bytes_per_frag -= RTLLIB_FCS_LEN; - /* Each fragment may need to have room for encryptiong pre/postfix */ + /* Each fragment may need to have room for encryptiong + * pre/postfix */ if (encrypt) { bytes_per_frag -= crypt->ops->extra_prefix_len + crypt->ops->extra_postfix_len; @@ -754,10 +753,11 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) else bytes_last_frag = bytes_per_frag; - /* When we allocate the TXB we allocate enough space for the reserve - * and full fragment bytes (bytes_per_frag doesn't include prefix, - * postfix, header, FCS, etc.) */ - txb = rtllib_alloc_txb(nr_frags, frag_size + ieee->tx_headroom, GFP_ATOMIC); + /* When we allocate the TXB we allocate enough space for the + * reserve and full fragment bytes (bytes_per_frag doesn't + * include prefix, postfix, header, FCS, etc.) */ + txb = rtllib_alloc_txb(nr_frags, frag_size + + ieee->tx_headroom, GFP_ATOMIC); if (unlikely(!txb)) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); @@ -767,16 +767,15 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) txb->payload_size = bytes; if (qos_actived) - { txb->queue_index = UP2AC(skb->priority); - } else { - txb->queue_index = WME_AC_BE;; - } + else + txb->queue_index = WME_AC_BE; for (i = 0; i < nr_frags; i++) { skb_frag = txb->fragments[i]; - tcb_desc = (struct cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE); - if (qos_actived){ + tcb_desc = (struct cb_desc *)(skb_frag->cb + + MAX_DEV_ADDR_SIZE); + if (qos_actived) { skb_frag->priority = skb->priority; tcb_desc->queue_index = UP2AC(skb->priority); } else { @@ -785,41 +784,46 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } skb_reserve(skb_frag, ieee->tx_headroom); - if (encrypt){ + if (encrypt) { if (ieee->hwsec_active) tcb_desc->bHwSec = 1; else tcb_desc->bHwSec = 0; - skb_reserve(skb_frag, crypt->ops->extra_prefix_len); + skb_reserve(skb_frag, + crypt->ops->extra_prefix_len); } else { tcb_desc->bHwSec = 0; } - frag_hdr = (struct rtllib_hdr_3addrqos *)skb_put(skb_frag, hdr_len); + frag_hdr = (struct rtllib_hdr_3addrqos *) + skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); - /* If this is not the last fragment, then add the MOREFRAGS - * bit to the frame control */ + /* If this is not the last fragment, then add the + * MOREFRAGS bit to the frame control */ if (i != nr_frags - 1) { frag_hdr->frame_ctl = cpu_to_le16( fc | RTLLIB_FCTL_MOREFRAGS); bytes = bytes_per_frag; } else { - /* The last fragment takes the remaining length */ + /* The last fragment has the remaining length */ bytes = bytes_last_frag; } - if ((qos_actived) && (!bIsMulticast)) - { - frag_hdr->seq_ctl = rtllib_query_seqnum(ieee, skb_frag, header.addr1); - frag_hdr->seq_ctl = cpu_to_le16(frag_hdr->seq_ctl<<4 | i); + if ((qos_actived) && (!bIsMulticast)) { + frag_hdr->seq_ctl = + rtllib_query_seqnum(ieee, skb_frag, + header.addr1); + frag_hdr->seq_ctl = + cpu_to_le16(frag_hdr->seq_ctl<<4 | i); } else { - frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); + frag_hdr->seq_ctl = + cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); } /* Put a SNAP header on the first fragment */ if (i == 0) { rtllib_put_snap( - skb_put(skb_frag, SNAP_SIZE + sizeof(u16)), - ether_type); + skb_put(skb_frag, SNAP_SIZE + + sizeof(u16)), ether_type); bytes -= SNAP_SIZE + sizeof(u16); } @@ -828,27 +832,29 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) /* Advance the SKB... */ skb_pull(skb, bytes); - /* Encryption routine will move the header forward in order - * to insert the IV between the header and the payload */ + /* Encryption routine will move the header forward in + * order to insert the IV between the header and the + * payload */ if (encrypt) - rtllib_encrypt_fragment(ieee, skb_frag, hdr_len); + rtllib_encrypt_fragment(ieee, skb_frag, + hdr_len); if (ieee->config & - (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) + (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) skb_put(skb_frag, 4); } if ((qos_actived) && (!bIsMulticast)) { - if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) - ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; - else - ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; + if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) + ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; + else + ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; } else { - if (ieee->seq_ctrl[0] == 0xFFF) - ieee->seq_ctrl[0] = 0; - else - ieee->seq_ctrl[0]++; + if (ieee->seq_ctrl[0] == 0xFFF) + ieee->seq_ctrl[0] = 0; + else + ieee->seq_ctrl[0]++; } - }else{ + } else { if (unlikely(skb->len < sizeof(struct rtllib_hdr_3addr))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); @@ -856,7 +862,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); - if (!txb){ + if (!txb) { printk(KERN_WARNING "%s: Could not allocate TXB\n", ieee->dev->name); goto failed; @@ -864,22 +870,24 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) txb->encrypted = 0; txb->payload_size = skb->len; - memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len); + memcpy(skb_put(txb->fragments[0], skb->len), skb->data, + skb->len); } success: - if (txb) - { - struct cb_desc *tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); + if (txb) { + struct cb_desc *tcb_desc = (struct cb_desc *) + (txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); tcb_desc->bTxEnableFwCalcDur = 1; tcb_desc->priority = skb->priority; if (ether_type == ETH_P_PAE) { - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_WA_IOT_Broadcom) { + tcb_desc->data_rate = + MgntQuery_TxRateExcludeCCKRates(ieee); tcb_desc->bTxDisableRateFallBack = false; - }else{ + } else { tcb_desc->data_rate = ieee->basic_rate; tcb_desc->bTxDisableRateFallBack = 1; } @@ -893,17 +901,19 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) if (is_broadcast_ether_addr(header.addr1)) tcb_desc->bBroadcast = 1; rtllib_txrate_selectmode(ieee, tcb_desc); - if ( tcb_desc->bMulticast || tcb_desc->bBroadcast) + if (tcb_desc->bMulticast || tcb_desc->bBroadcast) tcb_desc->data_rate = ieee->basic_rate; else - tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate); + tcb_desc->data_rate = CURRENT_RATE(ieee->mode, + ieee->rate, ieee->HTCurrentOperaRate); - if (bdhcp == true){ - if (ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) - { - tcb_desc->data_rate = MgntQuery_TxRateExcludeCCKRates(ieee); + if (bdhcp == true) { + if (ieee->pHTInfo->IOTAction & + HT_IOT_ACT_WA_IOT_Broadcom) { + tcb_desc->data_rate = + MgntQuery_TxRateExcludeCCKRates(ieee); tcb_desc->bTxDisableRateFallBack = false; - }else{ + } else { tcb_desc->data_rate = MGN_1M; tcb_desc->bTxDisableRateFallBack = 1; } @@ -915,20 +925,22 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) } rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); - rtllib_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc); + rtllib_tx_query_agg_cap(ieee, txb->fragments[0], + tcb_desc); rtllib_query_HTCapShortGI(ieee, tcb_desc); rtllib_query_BandwidthMode(ieee, tcb_desc); - rtllib_query_protectionmode(ieee, tcb_desc, txb->fragments[0]); + rtllib_query_protectionmode(ieee, tcb_desc, + txb->fragments[0]); } } spin_unlock_irqrestore(&ieee->lock, flags); dev_kfree_skb_any(skb); if (txb) { - if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){ + if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) { dev->stats.tx_packets++; dev->stats.tx_bytes += txb->payload_size; rtllib_softmac_xmit(txb, ieee); - }else{ + } else { if ((*ieee->hard_start_xmit)(txb, dev) == 0) { stats->tx_packets++; stats->tx_bytes += txb->payload_size; From c73901c9fded7be7fbc328be6f55c9a1a59f6d2c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 11 Aug 2011 18:16:43 -0500 Subject: [PATCH 19/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_pci.c | 21 +- drivers/staging/rtl8192e/rtl_pci.h | 6 +- drivers/staging/rtl8192e/rtllib_wx.c | 452 ++++++++++++++------------- 3 files changed, 247 insertions(+), 232 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl_pci.c index 2416db132179..ddadcc3e4e7c 100644 --- a/drivers/staging/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl_pci.c @@ -25,7 +25,8 @@ #include "rtl_pci.h" #include "rtl_core.h" -static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_device *dev) +static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, + struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -37,10 +38,11 @@ static void rtl8192_parse_pci_configuration(struct pci_dev *pdev, struct net_dev pci_read_config_byte(priv->pdev, pos + PCI_EXP_LNKCTL, &LinkCtrlReg); priv->NdisAdapter.LinkCtrlReg = LinkCtrlReg; - RT_TRACE(COMP_INIT, "Link Control Register =%x\n", priv->NdisAdapter.LinkCtrlReg); + RT_TRACE(COMP_INIT, "Link Control Register =%x\n", + priv->NdisAdapter.LinkCtrlReg); pci_read_config_byte(pdev, 0x98, &tmp); - tmp |=BIT4; + tmp |= BIT4; pci_write_config_byte(pdev, 0x98, tmp); tmp = 0x17; @@ -65,24 +67,27 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev) if (DeviceID == 0x8172) { switch (RevisionID) { case HAL_HW_PCI_REVISION_ID_8192PCIE: - printk("Adapter(8192 PCI-E) is found - DeviceID=%x\n", DeviceID); + printk(KERN_INFO "Adapter(8192 PCI-E) is found - " + "DeviceID=%x\n", DeviceID); priv->card_8192 = NIC_8192E; break; case HAL_HW_PCI_REVISION_ID_8192SE: - printk("Adapter(8192SE) is found - DeviceID=%x\n", DeviceID); + printk(KERN_INFO "Adapter(8192SE) is found - " + "DeviceID=%x\n", DeviceID); priv->card_8192 = NIC_8192SE; break; default: - printk("UNKNOWN nic type(%4x:%4x)\n", pdev->vendor, pdev->device); + printk(KERN_INFO "UNKNOWN nic type(%4x:%4x)\n", + pdev->vendor, pdev->device); priv->card_8192 = NIC_UNKNOWN; return false; } } if (priv->ops->nic_type != priv->card_8192) { - printk("Detect info(%x) and hardware info(%x) not match!\n", + printk(KERN_INFO "Detect info(%x) and hardware info(%x) not match!\n", priv->ops->nic_type, priv->card_8192); - printk("Please select proper driver before install!!!!\n"); + printk(KERN_INFO "Please select proper driver before install!!!!\n"); return false; } diff --git a/drivers/staging/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl_pci.h index b4efc7c4db02..7ea5a47dfd2b 100644 --- a/drivers/staging/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl_pci.h @@ -69,11 +69,11 @@ struct mp_adapter { u16 PciBridgeDeviceId; u8 PciBridgePCIeHdrOffset; u8 PciBridgeLinkCtrlReg; -};//,*pmp_adapter; +}; struct rt_pci_capab_header { - unsigned char CapabilityID; - unsigned char Next; + unsigned char CapabilityID; + unsigned char Next; }; #define PCI_MAX_BRIDGE_NUMBER 255 diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 39c6644f11b5..c350f4e277da 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -40,19 +40,19 @@ struct modes_unit { int mode_size; }; static struct modes_unit rtllib_modes[] = { - {"a",1}, - {"b",1}, - {"g",1}, - {"?",1}, - {"N-24G",5}, - {"N-5G",4}, + {"a", 1}, + {"b", 1}, + {"g", 1}, + {"?", 1}, + {"N-24G", 5}, + {"N-5G", 4}, }; #define MAX_CUSTOM_LEN 64 static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, char *start, char *stop, struct rtllib_network *network, - struct iw_request_info *info) + struct iw_request_info *info) { char custom[MAX_CUSTOM_LEN]; char proto_name[IFNAMSIZ]; @@ -67,52 +67,60 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN); - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_ADDR_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_ADDR_LEN); /* Remaining entries will be displayed in the order we provide them */ /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - if (network->ssid_len > 0){ + if (network->ssid_len > 0) { iwe.u.data.length = min(network->ssid_len, (u8)32); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); - }else if (network->hidden_ssid_len == 0){ + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, + network->ssid); + } else if (network->hidden_ssid_len == 0) { iwe.u.data.length = sizeof(""); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, ""); - }else { + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, ""); + } else { iwe.u.data.length = min(network->hidden_ssid_len, (u8)32); - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->hidden_ssid); + start = iwe_stream_add_point_rsl(info, start, stop, &iwe, + network->hidden_ssid); } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - for (i=0; i<(sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) { + for (i = 0; i < (sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) { if (network->mode&(1<capability & + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_CHAR_LEN); + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + if (network->capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { if (network->capability & WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_MASTER; else iwe.u.mode = IW_MODE_ADHOC; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_UINT_LEN); - } + start = iwe_stream_add_event_rsl(info, start, stop, + &iwe, IW_EV_UINT_LEN); + } - /* Add frequency/channel */ + /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; /* iwe.u.freq.m = rtllib_frequency(network->channel, network->mode); iwe.u.freq.e = 3; */ iwe.u.freq.m = network->channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_FREQ_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, + IW_EV_FREQ_LEN); /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; @@ -121,12 +129,13 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, network->ssid); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, network->ssid); /* Add basic and extended rates */ max_rate = 0; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - for (i = 0, j = 0; i < network->rates_len; ) { + for (i = 0, j = 0; i < network->rates_len;) { if (j < network->rates_ex_len && ((network->rates_ex[j] & 0x7F) < (network->rates[i] & 0x7F))) @@ -146,22 +155,24 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, max_rate = rate; } - if (network->mode >= IEEE_N_24G) - { + if (network->mode >= IEEE_N_24G) { struct ht_capab_ele *ht_cap = NULL; bool is40M = false, isShortGI = false; u8 max_mcs = 0; if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4)) - ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[4]; + ht_cap = (struct ht_capab_ele *) + &network->bssht.bdHTCapBuf[4]; else - ht_cap = (struct ht_capab_ele *)&network->bssht.bdHTCapBuf[0]; - is40M = (ht_cap->ChlWidth)?1:0; - isShortGI = (ht_cap->ChlWidth)? - ((ht_cap->ShortGI40Mhz)?1:0): - ((ht_cap->ShortGI20Mhz)?1:0); + ht_cap = (struct ht_capab_ele *) + &network->bssht.bdHTCapBuf[0]; + is40M = (ht_cap->ChlWidth) ? 1 : 0; + isShortGI = (ht_cap->ChlWidth) ? + ((ht_cap->ShortGI40Mhz) ? 1 : 0) : + ((ht_cap->ShortGI20Mhz) ? 1 : 0); - max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, MCS_FILTER_ALL); - rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs&0x7f]; + max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, + MCS_FILTER_ALL); + rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs & 0x7f]; if (rate > max_rate) max_rate = rate; } @@ -173,7 +184,8 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); /* Add quality statistics */ /* TODO: Fix these values... */ iwe.cmd = IWEVQUAL; @@ -188,53 +200,54 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee, if (!(network->stats.mask & RTLLIB_STATMASK_SIGNAL)) iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID; iwe.u.qual.updated = 7; - start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN); + start = iwe_stream_add_event_rsl(info, start, stop, &iwe, + IW_EV_QUAL_LEN); iwe.cmd = IWEVCUSTOM; p = custom; iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); memset(&iwe, 0, sizeof(iwe)); - if (network->wpa_ie_len) - { + if (network->wpa_ie_len) { char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->wpa_ie, network->wpa_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->wpa_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } memset(&iwe, 0, sizeof(iwe)); - if (network->rsn_ie_len) - { + if (network->rsn_ie_len) { char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->rsn_ie, network->rsn_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->rsn_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } /* add info for WZC */ memset(&iwe, 0, sizeof(iwe)); - if (network->wzc_ie_len) - { + if (network->wzc_ie_len) { char buf[MAX_WZC_IE_LEN]; memcpy(buf, network->wzc_ie, network->wzc_ie_len); iwe.cmd = IWEVGENIE; iwe.u.data.length = network->wzc_ie_len; start = iwe_stream_add_point_rsl(info, start, stop, &iwe, buf); - } + } /* Add EXTRA: Age to display seconds since last beacon/probe response * for given network. */ iwe.cmd = IWEVCUSTOM; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), - " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); + " Last beacon: %lums ago", + (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) - start = iwe_stream_add_point_rsl(info, start, stop, &iwe, custom); + start = iwe_stream_add_point_rsl(info, start, stop, + &iwe, custom); return start; } @@ -256,17 +269,16 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, list_for_each_entry(network, &ieee->network_list, list) { i++; - if ((stop-ev)<200) - { + if ((stop - ev) < 200) { err = -E2BIG; break; - } + } if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) - ev = rtl819x_translate_scan(ieee, ev, stop, network, info); + ev = rtl819x_translate_scan(ieee, ev, stop, network, + info); else - RTLLIB_DEBUG_SCAN( - "Not showing network '%s (" + RTLLIB_DEBUG_SCAN("Not showing network '%s (" MAC_FMT ")' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), @@ -326,7 +338,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, if (ieee->crypt[i] != NULL) { if (key_provided) break; - rtllib_crypt_delayed_deinit(ieee, &ieee->crypt[i]); + rtllib_crypt_delayed_deinit(ieee, + &ieee->crypt[i]); } } @@ -406,7 +419,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, NULL, (*crypt)->priv); if (len == 0) { /* Set a default key of all 0 */ - printk("Setting key %d to all zero.\n", + printk(KERN_INFO "Setting key %d to all zero.\n", key); RTLLIB_DEBUG_WX("Setting key %d to all zero.\n", @@ -429,7 +442,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee, } done: ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED); - ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; + ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : + WLAN_AUTH_SHARED_KEY; sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; sec.flags |= SEC_AUTH_MODE; RTLLIB_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? @@ -501,27 +515,27 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee, } int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; struct net_device *dev = ieee->dev; - struct iw_point *encoding = &wrqu->encoding; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - int i, idx; - int group_key = 0; - const char *alg, *module; - struct rtllib_crypto_ops *ops; - struct rtllib_crypt_data **crypt; + struct iw_point *encoding = &wrqu->encoding; + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; + int i, idx; + int group_key = 0; + const char *alg, *module; + struct rtllib_crypto_ops *ops; + struct rtllib_crypt_data **crypt; - struct rtllib_security sec = { - .flags = 0, - }; - idx = encoding->flags & IW_ENCODE_INDEX; - if (idx) { - if (idx < 1 || idx > WEP_KEYS) - return -EINVAL; - idx--; + struct rtllib_security sec = { + .flags = 0, + }; + idx = encoding->flags & IW_ENCODE_INDEX; + if (idx) { + if (idx < 1 || idx > WEP_KEYS) + return -EINVAL; + idx--; } else{ idx = ieee->tx_keyidx; } @@ -531,7 +545,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, } else { /* some Cisco APs use idx>0 for unicast in dynamic WEP */ if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) - return -EINVAL; + return -EINVAL; if (ieee->iw_mode == IW_MODE_INFRA) crypt = &ieee->crypt[idx]; else @@ -540,7 +554,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, sec.flags |= SEC_ENABLED; if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) { + ext->alg == IW_ENCODE_ALG_NONE) { if (*crypt) rtllib_crypt_delayed_deinit(ieee, crypt); @@ -557,108 +571,108 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, } sec.enabled = 1; - switch (ext->alg) { - case IW_ENCODE_ALG_WEP: - alg = "WEP"; - module = "rtllib_crypt_wep"; - break; - case IW_ENCODE_ALG_TKIP: - alg = "TKIP"; - module = "rtllib_crypt_tkip"; - break; - case IW_ENCODE_ALG_CCMP: - alg = "CCMP"; - module = "rtllib_crypt_ccmp"; - break; - default: - RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); - ret = -EINVAL; - goto done; - } - printk("alg name:%s\n",alg); + switch (ext->alg) { + case IW_ENCODE_ALG_WEP: + alg = "WEP"; + module = "rtllib_crypt_wep"; + break; + case IW_ENCODE_ALG_TKIP: + alg = "TKIP"; + module = "rtllib_crypt_tkip"; + break; + case IW_ENCODE_ALG_CCMP: + alg = "CCMP"; + module = "rtllib_crypt_ccmp"; + break; + default: + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); + ret = -EINVAL; + goto done; + } + printk(KERN_INFO "alg name:%s\n", alg); ops = rtllib_get_crypto_ops(alg); - if (ops == NULL) { - char tempbuf[100]; + if (ops == NULL) { + char tempbuf[100]; - memset( tempbuf, 0x00, 100 ); - sprintf( tempbuf, "%s", module); - request_module("%s",tempbuf); - ops = rtllib_get_crypto_ops(alg); - } - if (ops == NULL) { - RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", - dev->name, ext->alg); - printk("========>unknown crypto alg %d\n", ext->alg); - ret = -EINVAL; - goto done; - } + memset(tempbuf, 0x00, 100); + sprintf(tempbuf, "%s", module); + request_module("%s", tempbuf); + ops = rtllib_get_crypto_ops(alg); + } + if (ops == NULL) { + RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n", + dev->name, ext->alg); + printk(KERN_INFO "========>unknown crypto alg %d\n", ext->alg); + ret = -EINVAL; + goto done; + } - if (*crypt == NULL || (*crypt)->ops != ops) { - struct rtllib_crypt_data *new_crypt; + if (*crypt == NULL || (*crypt)->ops != ops) { + struct rtllib_crypt_data *new_crypt; - rtllib_crypt_delayed_deinit(ieee, crypt); + rtllib_crypt_delayed_deinit(ieee, crypt); - new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); - if (new_crypt == NULL) { - ret = -ENOMEM; - goto done; - } - new_crypt->ops = ops; + new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL); + if (new_crypt == NULL) { + ret = -ENOMEM; + goto done; + } + new_crypt->ops = ops; if (new_crypt->ops) - new_crypt->priv = new_crypt->ops->init(idx); + new_crypt->priv = new_crypt->ops->init(idx); - if (new_crypt->priv == NULL) { - kfree(new_crypt); - ret = -EINVAL; - goto done; - } - *crypt = new_crypt; + if (new_crypt->priv == NULL) { + kfree(new_crypt); + ret = -EINVAL; + goto done; + } + *crypt = new_crypt; } - if (ext->key_len > 0 && (*crypt)->ops->set_key && - (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, - (*crypt)->priv) < 0) { - RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name); - printk("key setting failed\n"); - ret = -EINVAL; - goto done; - } - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { - ieee->tx_keyidx = idx; - sec.active_key = idx; - sec.flags |= SEC_ACTIVE_KEY; - } - if (ext->alg != IW_ENCODE_ALG_NONE) { - sec.key_sizes[idx] = ext->key_len; - sec.flags |= (1 << idx); - if (ext->alg == IW_ENCODE_ALG_WEP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_1; - } else if (ext->alg == IW_ENCODE_ALG_TKIP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_2; - } else if (ext->alg == IW_ENCODE_ALG_CCMP) { - sec.flags |= SEC_LEVEL; - sec.level = SEC_LEVEL_3; - } - /* Don't set sec level for group keys. */ - if (group_key) - sec.flags &= ~SEC_LEVEL; - } + if (ext->key_len > 0 && (*crypt)->ops->set_key && + (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, + (*crypt)->priv) < 0) { + RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name); + printk(KERN_INFO "key setting failed\n"); + ret = -EINVAL; + goto done; + } + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { + ieee->tx_keyidx = idx; + sec.active_key = idx; + sec.flags |= SEC_ACTIVE_KEY; + } + if (ext->alg != IW_ENCODE_ALG_NONE) { + sec.key_sizes[idx] = ext->key_len; + sec.flags |= (1 << idx); + if (ext->alg == IW_ENCODE_ALG_WEP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_1; + } else if (ext->alg == IW_ENCODE_ALG_TKIP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_2; + } else if (ext->alg == IW_ENCODE_ALG_CCMP) { + sec.flags |= SEC_LEVEL; + sec.level = SEC_LEVEL_3; + } + /* Don't set sec level for group keys. */ + if (group_key) + sec.flags &= ~SEC_LEVEL; + } done: - if (ieee->set_security) - ieee->set_security(ieee->dev, &sec); + if (ieee->set_security) + ieee->set_security(ieee->dev, &sec); if (ieee->reset_on_keychange && - ieee->iw_mode != IW_MODE_INFRA && - ieee->reset_port && ieee->reset_port(dev)) { - RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); - return -EINVAL; - } - return ret; + ieee->iw_mode != IW_MODE_INFRA && + ieee->reset_port && ieee->reset_port(dev)) { + RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name); + return -EINVAL; + } + return ret; } int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, @@ -692,12 +706,12 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, encoding->flags = idx + 1; memset(ext, 0, sizeof(*ext)); - if (crypt == NULL || crypt->ops == NULL ) { + if (crypt == NULL || crypt->ops == NULL) { ext->alg = IW_ENCODE_ALG_NONE; ext->key_len = 0; encoding->flags |= IW_ENCODE_DISABLED; } else { - if (strcmp(crypt->ops->name, "WEP") == 0 ) + if (strcmp(crypt->ops->name, "WEP") == 0) ext->alg = IW_ENCODE_ALG_WEP; else if (strcmp(crypt->ops->name, "TKIP")) ext->alg = IW_ENCODE_ALG_TKIP; @@ -705,7 +719,8 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, ext->alg = IW_ENCODE_ALG_CCMP; else return -EINVAL; - ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, NULL, crypt->priv); + ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, + NULL, crypt->priv); encoding->flags |= IW_ENCODE_ENABLED; if (ext->key_len && (ext->alg == IW_ENCODE_ALG_TKIP || @@ -718,8 +733,8 @@ int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, } int rtllib_wx_set_mlme(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { u8 i = 0; bool deauth = false; @@ -731,28 +746,28 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, down(&ieee->wx_sem); switch (mlme->cmd) { - case IW_MLME_DEAUTH: - deauth = true; - /* leave break out intentionly */ + case IW_MLME_DEAUTH: + deauth = true; + /* leave break out intentionly */ - case IW_MLME_DISASSOC: - if (deauth == true) - printk("disauth packet !\n"); - else - printk("dis associate packet!\n"); + case IW_MLME_DISASSOC: + if (deauth == true) + printk(KERN_INFO "disauth packet !\n"); + else + printk(KERN_INFO "dis associate packet!\n"); - ieee->cannot_notify = true; + ieee->cannot_notify = true; - SendDisassociation(ieee,deauth,mlme->reason_code); - rtllib_disassociate(ieee); + SendDisassociation(ieee, deauth, mlme->reason_code); + rtllib_disassociate(ieee); - ieee->wap_set = 0; - for (i = 0; i < 6; i++) - ieee->current_network.bssid[i]= 0x55; + ieee->wap_set = 0; + for (i = 0; i < 6; i++) + ieee->current_network.bssid[i] = 0x55; - ieee->ssid_set = 0; - ieee->current_network.ssid[0] = '\0'; - ieee->current_network.ssid_len = 0; + ieee->ssid_set = 0; + ieee->current_network.ssid[0] = '\0'; + ieee->current_network.ssid_len = 0; break; default: up(&ieee->wx_sem); @@ -765,56 +780,53 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, } int rtllib_wx_set_auth(struct rtllib_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra) + struct iw_request_info *info, + struct iw_param *data, char *extra) { switch (data->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: + case IW_AUTH_WPA_VERSION: break; - case IW_AUTH_CIPHER_PAIRWISE: - case IW_AUTH_CIPHER_GROUP: - case IW_AUTH_KEY_MGMT: + case IW_AUTH_CIPHER_PAIRWISE: + case IW_AUTH_CIPHER_GROUP: + case IW_AUTH_KEY_MGMT: /* * Host AP driver does not use these parameters and allows * wpa_supplicant to control them internally. */ - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures = data->value; - break; - case IW_AUTH_DROP_UNENCRYPTED: - ieee->drop_unencrypted = data->value; + break; + case IW_AUTH_TKIP_COUNTERMEASURES: + ieee->tkip_countermeasures = data->value; + break; + case IW_AUTH_DROP_UNENCRYPTED: + ieee->drop_unencrypted = data->value; break; case IW_AUTH_80211_AUTH_ALG: - if (data->value & IW_AUTH_ALG_SHARED_KEY){ + if (data->value & IW_AUTH_ALG_SHARED_KEY) { ieee->open_wep = 0; ieee->auth_mode = 1; - } - else if (data->value & IW_AUTH_ALG_OPEN_SYSTEM){ + } else if (data->value & IW_AUTH_ALG_OPEN_SYSTEM) { ieee->open_wep = 1; ieee->auth_mode = 0; - } - else if (data->value & IW_AUTH_ALG_LEAP){ + } else if (data->value & IW_AUTH_ALG_LEAP) { ieee->open_wep = 1; ieee->auth_mode = 2; - } - else + } else return -EINVAL; break; case IW_AUTH_WPA_ENABLED: - ieee->wpa_enabled = (data->value)?1:0; + ieee->wpa_enabled = (data->value) ? 1 : 0; break; case IW_AUTH_RX_UNENCRYPTED_EAPOL: - ieee->ieee802_1x = data->value; + ieee->ieee802_1x = data->value; break; case IW_AUTH_PRIVACY_INVOKED: ieee->privacy_invoked = data->value; break; default: - return -EOPNOTSUPP; + return -EOPNOTSUPP; } return 0; } @@ -822,17 +834,18 @@ int rtllib_wx_set_auth(struct rtllib_device *ieee, int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) { u8 *buf; - u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) { + if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) return -EINVAL; - } if (len) { eid = ie[0]; - if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], wps_oui, 4))) { + if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2], + wps_oui, 4))) { - ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len):(MAX_WZC_IE_LEN); + ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len) : + (MAX_WZC_IE_LEN); buf = kmalloc(ieee->wps_ie_len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; @@ -842,13 +855,11 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) } } ieee->wps_ie_len = 0; - if (ieee->wps_ie) - kfree(ieee->wps_ie); + kfree(ieee->wps_ie); ieee->wps_ie = NULL; if (len) { - if (len != ie[1]+2) { + if (len != ie[1]+2) return -EINVAL; - } buf = kmalloc(len, GFP_KERNEL); if (buf == NULL) return -ENOMEM; @@ -857,7 +868,6 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len) ieee->wpa_ie = buf; ieee->wpa_ie_len = len; } else { - if (ieee->wpa_ie) kfree(ieee->wpa_ie); ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; From 8bd890a41f66b4b3f8494a9c91bface5a0b8cbe3 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 11 Aug 2011 22:00:11 -0500 Subject: [PATCH 20/25] staging: rtl8192e: Cleanup checkpatch -f warnings and errors - Part XVIII Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_pm.c | 120 +++-- drivers/staging/rtl8192e/rtl_pm.h | 8 +- drivers/staging/rtl8192e/rtl_ps.c | 182 ++++---- drivers/staging/rtl8192e/rtl_ps.h | 2 +- drivers/staging/rtl8192e/rtl_wx.c | 748 ++++++++++++++---------------- drivers/staging/rtl8192e/rtl_wx.h | 2 +- 6 files changed, 506 insertions(+), 556 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl_pm.c index af1c8201e01d..92e2fde7f5f4 100644 --- a/drivers/staging/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl_pm.c @@ -23,42 +23,38 @@ #include "r8190P_rtl8256.h" #include "rtl_pm.h" -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state) +int rtl8192E_save_state(struct pci_dev *dev, pm_message_t state) { - printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); - return(-EAGAIN); + printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event); + return -EAGAIN; } -int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) +int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv = rtllib_priv(dev); u32 ulRegRead; - RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); - printk("============> r8192E suspend call.\n"); + printk(KERN_INFO "============> r8192E suspend call.\n"); del_timer_sync(&priv->gpio_polling_timer); cancel_delayed_work(&priv->gpio_change_rf_wq); priv->polling_timer_on = 0; - if (!netif_running(dev)){ - printk("RTL819XE:UI is open out of suspend function\n"); - goto out_pci_suspend; - } + if (!netif_running(dev)) { + printk(KERN_INFO "RTL819XE:UI is open out of suspend " + "function\n"); + goto out_pci_suspend; + } -#ifdef HAVE_NET_DEVICE_OPS if (dev->netdev_ops->ndo_stop) dev->netdev_ops->ndo_stop(dev); -#else - dev->stop(dev); -#endif netif_device_detach(dev); if (!priv->rtllib->bSupportRemoteWakeUp) { - MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT,true); + MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_INIT, true); ulRegRead = read_nic_dword(dev, CPU_GEN); - ulRegRead|=CPU_GEN_SYSTEM_RESET; + ulRegRead |= CPU_GEN_SYSTEM_RESET; write_nic_dword(dev, CPU_GEN, ulRegRead); } else { write_nic_dword(dev, WFCRC0, 0xffffffff); @@ -68,81 +64,73 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) write_nic_byte(dev, MacBlkCtrl, 0xa); } out_pci_suspend: - RT_TRACE(COMP_POWER, "r8192E support WOL call??????????????????????\n"); printk("r8192E support WOL call??????????????????????\n"); - if (priv->rtllib->bSupportRemoteWakeUp) { - RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n"); - } + if (priv->rtllib->bSupportRemoteWakeUp) + RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!" + "!!!!!!!!!!!.\n"); pci_save_state(pdev); pci_disable_device(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev,state),\ - priv->rtllib->bSupportRemoteWakeUp?1:0); - pci_set_power_state(pdev,pci_choose_state(pdev,state)); + pci_enable_wake(pdev, pci_choose_state(pdev, state), + priv->rtllib->bSupportRemoteWakeUp ? 1 : 0); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); - mdelay(20); + mdelay(20); return 0; } -int rtl8192E_resume (struct pci_dev *pdev) +int rtl8192E_resume(struct pci_dev *pdev) { - struct net_device *dev = pci_get_drvdata(pdev); - struct r8192_priv *priv = rtllib_priv(dev); - int err; - u32 val; + struct net_device *dev = pci_get_drvdata(pdev); + struct r8192_priv *priv = rtllib_priv(dev); + int err; + u32 val; - RT_TRACE(COMP_POWER, "================>r8192E resume call."); - printk("================>r8192E resume call.\n"); + printk(KERN_INFO "================>r8192E resume call.\n"); - pci_set_power_state(pdev, PCI_D0); + pci_set_power_state(pdev, PCI_D0); - err = pci_enable_device(pdev); - if (err) { - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", - dev->name); - return err; - } - pci_restore_state(pdev); + err = pci_enable_device(pdev); + if (err) { + printk(KERN_ERR "%s: pci_enable_device failed on resume\n", + dev->name); + return err; + } + pci_restore_state(pdev); - pci_read_config_dword(pdev, 0x40, &val); - if ((val & 0x0000ff00) != 0) { - pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - } + pci_read_config_dword(pdev, 0x40, &val); + if ((val & 0x0000ff00) != 0) + pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - pci_enable_wake(pdev, PCI_D0, 0); + pci_enable_wake(pdev, PCI_D0, 0); - if (priv->polling_timer_on == 0){ - check_rfctrl_gpio_timer((unsigned long)dev); - } + if (priv->polling_timer_on == 0) + check_rfctrl_gpio_timer((unsigned long)dev); - if (!netif_running(dev)){ - printk("RTL819XE:UI is open out of resume function\n"); - goto out; - } + if (!netif_running(dev)) { + printk(KERN_INFO "RTL819XE:UI is open out of resume " + "function\n"); + goto out; + } - netif_device_attach(dev); -#ifdef HAVE_NET_DEVICE_OPS - if (dev->netdev_ops->ndo_open) - dev->netdev_ops->ndo_open(dev); -#else - dev->open(dev); -#endif + netif_device_attach(dev); + if (dev->netdev_ops->ndo_open) + dev->netdev_ops->ndo_open(dev); - if (!priv->rtllib->bSupportRemoteWakeUp) { - MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT,true); - } + if (!priv->rtllib->bSupportRemoteWakeUp) + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_INIT, true); out: - RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); - return 0; + RT_TRACE(COMP_POWER, "<================r8192E resume call.\n"); + return 0; } -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable) +int rtl8192E_enable_wake(struct pci_dev *dev, pm_message_t state, int enable) { - printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", + printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n", state.event, enable); - return(-EAGAIN); + return -EAGAIN; } #endif diff --git a/drivers/staging/rtl8192e/rtl_pm.h b/drivers/staging/rtl8192e/rtl_pm.h index 22df29081817..4d7f4067cc78 100644 --- a/drivers/staging/rtl8192e/rtl_pm.h +++ b/drivers/staging/rtl8192e/rtl_pm.h @@ -25,10 +25,10 @@ #include #include -int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state); -int rtl8192E_suspend (struct pci_dev *dev, pm_message_t state); -int rtl8192E_resume (struct pci_dev *dev); -int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable); +int rtl8192E_save_state(struct pci_dev *dev, pm_message_t state); +int rtl8192E_suspend(struct pci_dev *dev, pm_message_t state); +int rtl8192E_resume(struct pci_dev *dev); +int rtl8192E_enable_wake(struct pci_dev *dev, pm_message_t state, int enable); #endif diff --git a/drivers/staging/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl_ps.c index ea9eac712530..f39f0d340e2d 100644 --- a/drivers/staging/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl_ps.c @@ -33,44 +33,49 @@ void rtl8192_hw_sleep_down(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); if (priv->RFChangeInProgress) { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in progress! \n"); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in " + "progress!\n"); return; } - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); RT_TRACE(COMP_DBG, "%s()============>come to sleep down\n", __func__); - MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS,false); + MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS, false); } void rtl8192_hw_sleep_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_sleep_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, hw_sleep_wq); struct net_device *dev = ieee->dev; - rtl8192_hw_sleep_down(dev); + rtl8192_hw_sleep_down(dev); } -void rtl8192_hw_wakeup(struct net_device* dev) +void rtl8192_hw_wakeup(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; - spin_lock_irqsave(&priv->rf_ps_lock,flags); + spin_lock_irqsave(&priv->rf_ps_lock, flags); if (priv->RFChangeInProgress) { - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); - RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in progress! \n"); - queue_delayed_work_rsl(priv->rtllib->wq,&priv->rtllib->hw_wakeup_wq,MSECS(10)); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); + RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in " + "progress!\n"); + queue_delayed_work_rsl(priv->rtllib->wq, + &priv->rtllib->hw_wakeup_wq, MSECS(10)); return; } - spin_unlock_irqrestore(&priv->rf_ps_lock,flags); + spin_unlock_irqrestore(&priv->rf_ps_lock, flags); RT_TRACE(COMP_PS, "%s()============>come to wake up\n", __func__); - MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS,false); + MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS, false); } void rtl8192_hw_wakeup_wq(void *data) { - struct rtllib_device *ieee = container_of_dwork_rsl(data,struct rtllib_device,hw_wakeup_wq); + struct rtllib_device *ieee = container_of_dwork_rsl(data, + struct rtllib_device, hw_wakeup_wq); struct net_device *dev = ieee->dev; rtl8192_hw_wakeup(dev); @@ -85,12 +90,12 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) u32 tmp; unsigned long flags; - spin_lock_irqsave(&priv->ps_lock,flags); + spin_lock_irqsave(&priv->ps_lock, flags); time -= MSECS(8+16+7); if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) { - spin_unlock_irqrestore(&priv->ps_lock,flags); + spin_unlock_irqrestore(&priv->ps_lock, flags); printk(KERN_INFO "too short to sleep::%lld < %ld\n", time - jiffies, MSECS(MIN_SLEEP_TIME)); return; @@ -99,48 +104,48 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time) if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) { printk(KERN_INFO "========>too long to sleep:%lld > %ld\n", time - jiffies, MSECS(MAX_SLEEP_TIME)); - spin_unlock_irqrestore(&priv->ps_lock,flags); + spin_unlock_irqrestore(&priv->ps_lock, flags); return; } tmp = time - jiffies; queue_delayed_work_rsl(priv->rtllib->wq, - &priv->rtllib->hw_wakeup_wq,tmp); + &priv->rtllib->hw_wakeup_wq, tmp); queue_delayed_work_rsl(priv->rtllib->wq, - (void *)&priv->rtllib->hw_sleep_wq,0); - spin_unlock_irqrestore(&priv->ps_lock,flags); + (void *)&priv->rtllib->hw_sleep_wq, 0); + spin_unlock_irqrestore(&priv->ps_lock, flags); } void InactivePsWorkItemCallback(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() ---------> \n"); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() --------->\n"); pPSC->bSwRfProcessing = true; - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", \ - pPSC->eInactivePowerState == eRfOff?"OFF":"ON"); - MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS,false); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback(): Set RF to %s.\n", + pPSC->eInactivePowerState == eRfOff ? "OFF" : "ON"); + MgntActSet_RF_State(dev, pPSC->eInactivePowerState, RF_CHANGE_BY_IPS, + false); pPSC->bSwRfProcessing = false; - RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <--------- \n"); + RT_TRACE(COMP_PS, "InactivePsWorkItemCallback() <---------\n"); } -void -IPSEnter(struct net_device *dev) +void IPSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); enum rt_rf_power_state rtState; - if (pPSC->bInactivePs) - { + if (pPSC->bInactivePs) { rtState = priv->rtllib->eRFPowerState; - if (rtState == eRfOn && !pPSC->bSwRfProcessing &&\ - (priv->rtllib->state != RTLLIB_LINKED)&&\ - (priv->rtllib->iw_mode != IW_MODE_MASTER)) - { - RT_TRACE(COMP_PS,"IPSEnter(): Turn off RF.\n"); + if (rtState == eRfOn && !pPSC->bSwRfProcessing && + (priv->rtllib->state != RTLLIB_LINKED) && + (priv->rtllib->iw_mode != IW_MODE_MASTER)) { + RT_TRACE(COMP_PS, "IPSEnter(): Turn off RF.\n"); pPSC->eInactivePowerState = eRfOff; priv->isRFOff = true; priv->bInPowerSaveMode = true; @@ -149,18 +154,17 @@ IPSEnter(struct net_device *dev) } } -void -IPSLeave(struct net_device *dev) +void IPSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); enum rt_rf_power_state rtState; - if (pPSC->bInactivePs) - { + if (pPSC->bInactivePs) { rtState = priv->rtllib->eRFPowerState; - if (rtState != eRfOn && !pPSC->bSwRfProcessing && priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) - { + if (rtState != eRfOn && !pPSC->bSwRfProcessing && + priv->rtllib->RfOffReason <= RF_CHANGE_BY_IPS) { RT_TRACE(COMP_PS, "IPSLeave(): Turn on RF.\n"); pPSC->eInactivePowerState = eRfOn; priv->bInPowerSaveMode = false; @@ -168,9 +172,11 @@ IPSLeave(struct net_device *dev) } } } + void IPSLeave_wq(void *data) { - struct rtllib_device *ieee = container_of_work_rsl(data,struct rtllib_device,ips_leave_wq); + struct rtllib_device *ieee = container_of_work_rsl(data, + struct rtllib_device, ips_leave_wq); struct net_device *dev = ieee->dev; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); down(&priv->rtllib->ips_sem); @@ -184,20 +190,22 @@ void rtllib_ips_leave_wq(struct net_device *dev) enum rt_rf_power_state rtState; rtState = priv->rtllib->eRFPowerState; - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); return; - } - else{ - printk("=========>%s(): IPSLeave\n",__func__); - queue_work_rsl(priv->rtllib->wq,&priv->rtllib->ips_leave_wq); + } else { + printk(KERN_INFO "=========>%s(): IPSLeave\n", + __func__); + queue_work_rsl(priv->rtllib->wq, + &priv->rtllib->ips_leave_wq); } } } } + void rtllib_ips_leave(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -213,38 +221,42 @@ bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) if (priv->rtllib->iw_mode == IW_MODE_ADHOC) return false; - RT_TRACE(COMP_LPS,"%s(): set ieee->ps = %x\n",__func__,rtPsMode); - if (!priv->ps_force) { + RT_TRACE(COMP_LPS, "%s(): set ieee->ps = %x\n", __func__, rtPsMode); + if (!priv->ps_force) priv->rtllib->ps = rtPsMode; - } - if (priv->rtllib->sta_sleep != LPS_IS_WAKE && rtPsMode == RTLLIB_PS_DISABLED) { - unsigned long flags; + if (priv->rtllib->sta_sleep != LPS_IS_WAKE && + rtPsMode == RTLLIB_PS_DISABLED) { + unsigned long flags; rtl8192_hw_wakeup(dev); priv->rtllib->sta_sleep = LPS_IS_WAKE; - spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); + spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags); RT_TRACE(COMP_DBG, "LPS leave: notify AP we are awaked" " ++++++++++ SendNullFunctionData\n"); rtllib_sta_ps_send_null_frame(priv->rtllib, 0); - spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); + spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags); } return true; } - void LeisurePSEnter(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); RT_TRACE(COMP_PS, "LeisurePSEnter()...\n"); - RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", - pPSC->bLeisurePs, priv->rtllib->ps,pPSC->LpsIdleCount,RT_CHECK_FOR_HANG_PERIOD); + RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdle" + "Count is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n", + pPSC->bLeisurePs, priv->rtllib->ps, pPSC->LpsIdleCount, + RT_CHECK_FOR_HANG_PERIOD); - if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && (priv->rtllib->state == RTLLIB_LINKED)) - || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || (priv->rtllib->iw_mode == IW_MODE_MASTER)) + if (!((priv->rtllib->iw_mode == IW_MODE_INFRA) && + (priv->rtllib->state == RTLLIB_LINKED)) + || (priv->rtllib->iw_mode == IW_MODE_ADHOC) || + (priv->rtllib->iw_mode == IW_MODE_MASTER)) return; if (pPSC->bLeisurePs) { @@ -252,44 +264,46 @@ void LeisurePSEnter(struct net_device *dev) if (priv->rtllib->ps == RTLLIB_PS_DISABLED) { - RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter 802.11 power save mode...\n"); + RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter " + "802.11 power save mode...\n"); if (!pPSC->bFwCtrlLPS) { if (priv->rtllib->SetFwCmdHandler) - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_ENTER); + priv->rtllib->SetFwCmdHandler( + dev, FW_CMD_LPS_ENTER); } - MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_MBCAST|RTLLIB_PS_UNICAST); + MgntActSet_802_11_PowerSaveMode(dev, + RTLLIB_PS_MBCAST | + RTLLIB_PS_UNICAST); } } else pPSC->LpsIdleCount++; } } - void LeisurePSLeave(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + &(priv->rtllib->PowerSaveControl); RT_TRACE(COMP_PS, "LeisurePSLeave()...\n"); RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d\n", pPSC->bLeisurePs, priv->rtllib->ps); - if (pPSC->bLeisurePs) - { - if (priv->rtllib->ps != RTLLIB_PS_DISABLED) - { - RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , Leave 802.11 power save..\n"); - MgntActSet_802_11_PowerSaveMode(dev, RTLLIB_PS_DISABLED); + if (pPSC->bLeisurePs) { + if (priv->rtllib->ps != RTLLIB_PS_DISABLED) { + RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , " + "Leave 802.11 power save..\n"); + MgntActSet_802_11_PowerSaveMode(dev, + RTLLIB_PS_DISABLED); - if (!pPSC->bFwCtrlLPS) - { + if (!pPSC->bFwCtrlLPS) { if (priv->rtllib->SetFwCmdHandler) - { - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_LPS_LEAVE); - } - } + priv->rtllib->SetFwCmdHandler(dev, + FW_CMD_LPS_LEAVE); + } } } } diff --git a/drivers/staging/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl_ps.h index 453df2cbb3d2..a9c2d799c08f 100644 --- a/drivers/staging/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl_ps.h @@ -36,7 +36,7 @@ void rtl8192_hw_wakeup(struct net_device *dev); void rtl8192_hw_to_sleep(struct net_device *dev, u64 time); void rtllib_ips_leave_wq(struct net_device *dev); void rtllib_ips_leave(struct net_device *dev); -void IPSLeave_wq (void *data); +void IPSLeave_wq(void *data); void IPSEnter(struct net_device *dev); void IPSLeave(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index bc096c096cf9..f869ce3dbec0 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -22,14 +22,14 @@ #include "dot11d.h" #define RATE_COUNT 12 -u32 rtl8192_rates[] = {1000000,2000000,5500000,11000000, - 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; - +u32 rtl8192_rates[] = { + 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, + 18000000, 24000000, 36000000, 48000000, 54000000 +}; #ifndef ENETDOWN #define ENETDOWN 1 #endif -extern int hwwep; static int r8192_wx_get_freq(struct net_device *dev, struct iw_request_info *a, @@ -37,16 +37,16 @@ static int r8192_wx_get_freq(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_freq(priv->rtllib,a,wrqu,b); + return rtllib_wx_get_freq(priv->rtllib, a, wrqu, b); } static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8192_priv *priv=rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_mode(priv->rtllib,a,wrqu,b); + return rtllib_wx_get_mode(priv->rtllib, a, wrqu, b); } static int r8192_wx_get_rate(struct net_device *dev, @@ -54,7 +54,7 @@ static int r8192_wx_get_rate(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_rate(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra); } @@ -71,7 +71,7 @@ static int r8192_wx_set_rate(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_rate(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_rate(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -91,7 +91,7 @@ static int r8192_wx_set_rts(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_rts(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_rts(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -103,7 +103,7 @@ static int r8192_wx_get_rts(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_rts(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra); } static int r8192_wx_set_power(struct net_device *dev, @@ -113,13 +113,14 @@ static int r8192_wx_set_power(struct net_device *dev, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bHwRadioOff == true){ - RT_TRACE(COMP_ERR,"%s():Hw is Radio Off, we can't set Power,return\n",__func__); + if (priv->bHwRadioOff == true) { + RT_TRACE(COMP_ERR, "%s():Hw is Radio Off, we can't set " + "Power,return\n", __func__); return 0; } down(&priv->wx_sem); - ret = rtllib_wx_set_power(priv->rtllib,info,wrqu,extra); + ret = rtllib_wx_set_power(priv->rtllib, info, wrqu, extra); up(&priv->wx_sem); @@ -131,12 +132,12 @@ static int r8192_wx_get_power(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_power(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra); } static int r8192_wx_set_rawtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -162,7 +163,8 @@ static int r8192_wx_force_reset(struct net_device *dev, down(&priv->wx_sem); - RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", __func__, *extra); + RT_TRACE(COMP_DBG, "%s(): force reset ! extra is %d\n", + __func__, *extra); priv->force_reset = *extra; up(&priv->wx_sem); return 0; @@ -174,11 +176,11 @@ static int r8192_wx_force_mic_error(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; down(&priv->wx_sem); - RT_TRACE(COMP_DBG, "%s(): force mic error ! \n", __func__); + RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__); ieee->force_mic_error = true; up(&priv->wx_sem); return 0; @@ -197,8 +199,8 @@ struct adhoc_peers_info { }; int r8192_wx_get_adhoc_peers(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -216,12 +218,14 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); - struct rtllib_device* ieee = priv->rtllib; + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); + struct rtllib_device *ieee = priv->rtllib; down(&priv->wx_sem); - RT_TRACE(COMP_POWER, "%s(): %s\n",__func__, (*extra == 6)?"DC power":"AC power"); + RT_TRACE(COMP_POWER, "%s(): %s\n", __func__, (*extra == 6) ? + "DC power" : "AC power"); if (*extra || priv->force_lps) { priv->ps_force = false; pPSC->bLeisurePs = true; @@ -240,40 +244,41 @@ static int r8192_wx_adapter_power_status(struct net_device *dev, } static int r8192se_wx_set_radio(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); - down(&priv->wx_sem); + down(&priv->wx_sem); - printk("%s(): set radio ! extra is %d\n",__func__, *extra); - if ((*extra != 0) && (*extra != 1)) - { - RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n",__func__); - return -1; - } - priv->sw_radio_on = *extra; - up(&priv->wx_sem); - return 0; + printk(KERN_INFO "%s(): set radio ! extra is %d\n", __func__, *extra); + if ((*extra != 0) && (*extra != 1)) { + RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio " + "off) or 1(radio on)\n", __func__); + return -1; + } + priv->sw_radio_on = *extra; + up(&priv->wx_sem); + return 0; } static int r8192se_wx_set_lps_awake_interval(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)(&(priv->rtllib->PowerSaveControl)); + struct r8192_priv *priv = rtllib_priv(dev); + struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) + (&(priv->rtllib->PowerSaveControl)); - down(&priv->wx_sem); + down(&priv->wx_sem); - printk("%s(): set lps awake interval ! extra is %d\n",__func__, *extra); - - pPSC->RegMaxLPSAwakeIntvl = *extra; - up(&priv->wx_sem); - return 0; + printk(KERN_INFO "%s(): set lps awake interval ! extra is %d\n", + __func__, *extra); + pPSC->RegMaxLPSAwakeIntvl = *extra; + up(&priv->wx_sem); + return 0; } static int r8192se_wx_set_force_lps(struct net_device *dev, @@ -284,7 +289,8 @@ static int r8192se_wx_set_force_lps(struct net_device *dev, down(&priv->wx_sem); - printk("%s(): force LPS ! extra is %d (1 is open 0 is close)\n",__func__, *extra); + printk(KERN_INFO "%s(): force LPS ! extra is %d (1 is open 0 is " + "close)\n", __func__, *extra); priv->force_lps = *extra; up(&priv->wx_sem); return 0; @@ -292,8 +298,8 @@ static int r8192se_wx_set_force_lps(struct net_device *dev, } static int r8192_wx_set_debugflag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); u8 c = *extra; @@ -301,12 +307,12 @@ static int r8192_wx_set_debugflag(struct net_device *dev, if (priv->bHwRadioOff == true) return 0; - printk("=====>%s(), *extra:%x, debugflag:%x\n", __func__, *extra, rt_global_debug_component); - if (c > 0) { + printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__, + *extra, rt_global_debug_component); + if (c > 0) rt_global_debug_component |= (1<rtllib->eRFPowerState; down(&priv->wx_sem); - if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR - || ieee->bNetPromiscuousMode ) - { - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) - { - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (wrqu->mode == IW_MODE_ADHOC || wrqu->mode == IW_MODE_MONITOR || + ieee->bNetPromiscuousMode) { + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > + RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n", + __func__); up(&priv->wx_sem); return -1; } else { - printk("=========>%s(): IPSLeave\n",__func__); + printk(KERN_INFO "=========>%s(): " + "IPSLeave\n", __func__); down(&priv->rtllib->ips_sem); IPSLeave(dev); up(&priv->rtllib->ips_sem); @@ -342,33 +349,32 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, } } } - ret = rtllib_wx_set_mode(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_mode(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); return ret; } -struct iw_range_with_scan_capa -{ - /* Informative stuff (to choose between different interface) */ - __u32 throughput; /* To give an idea... */ - /* In theory this value should be the maximum benchmarked - * TCP/IP throughput, because with most of these devices the - * bit rate is meaningless (overhead an co) to estimate how - * fast the connection will go and pick the fastest one. - * I suggest people to play with Netperf or any benchmark... - */ +struct iw_range_with_scan_capa { + /* Informative stuff (to choose between different interface) */ + __u32 throughput; /* To give an idea... */ + /* In theory this value should be the maximum benchmarked + * TCP/IP throughput, because with most of these devices the + * bit rate is meaningless (overhead an co) to estimate how + * fast the connection will go and pick the fastest one. + * I suggest people to play with Netperf or any benchmark... + */ - /* NWID (or domain id) */ - __u32 min_nwid; /* Minimal NWID we are able to set */ - __u32 max_nwid; /* Maximal NWID we are able to set */ + /* NWID (or domain id) */ + __u32 min_nwid; /* Minimal NWID we are able to set */ + __u32 max_nwid; /* Maximal NWID we are able to set */ - /* Old Frequency (backward compat - moved lower ) */ - __u16 old_num_channels; - __u8 old_num_frequency; + /* Old Frequency (backward compat - moved lower ) */ + __u16 old_num_channels; + __u8 old_num_frequency; - /* Scan capabilities */ - __u8 scan_capa; + /* Scan capabilities */ + __u8 scan_capa; }; static int rtl8192_wx_get_range(struct net_device *dev, @@ -386,8 +392,10 @@ static int rtl8192_wx_get_range(struct net_device *dev, /* ~130 Mb/s real (802.11n) */ range->throughput = 130 * 1000 * 1000; - if (priv->rf_set_sens != NULL) - range->sensitivity = priv->max_sens; /* signal level threshold range */ + if (priv->rf_set_sens != NULL) { + /* signal level threshold range */ + range->sensitivity = priv->max_sens; + } range->max_qual.qual = 100; range->max_qual.level = 0; @@ -401,9 +409,8 @@ static int rtl8192_wx_get_range(struct net_device *dev, range->num_bitrates = min(RATE_COUNT, IW_MAX_BITRATES); - for (i = 0; i < range->num_bitrates; i++) { + for (i = 0; i < range->num_bitrates; i++) range->bitrate[i] = rtl8192_rates[i]; - } range->max_rts = DEFAULT_RTS_THRESHOLD; range->min_frag = MIN_FRAG_THRESHOLD; @@ -421,15 +428,15 @@ static int rtl8192_wx_get_range(struct net_device *dev, for (i = 0, val = 0; i < 14; i++) { if ((priv->rtllib->active_channel_map)[i+1]) { - range->freq[val].i = i + 1; - range->freq[val].m = rtllib_wlan_frequencies[i] * 100000; + range->freq[val].i = i + 1; + range->freq[val].m = rtllib_wlan_frequencies[i] * + 100000; range->freq[val].e = 1; val++; - } else { } if (val == IW_MAX_FREQUENCIES) - break; + break; } range->num_frequency = val; range->num_channels = val; @@ -437,7 +444,7 @@ static int rtl8192_wx_get_range(struct net_device *dev, IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE; - /* Event capability (kernel + driver) */ + /* Event capability (kernel + driver) */ return 0; } @@ -446,35 +453,36 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; enum rt_rf_power_state rtState; int ret; - if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)){ - if ((ieee->state >= RTLLIB_ASSOCIATING) && (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)){ + if (!(ieee->softmac_features & IEEE_SOFTMAC_SCAN)) { + if ((ieee->state >= RTLLIB_ASSOCIATING) && + (ieee->state <= RTLLIB_ASSOCIATING_AUTHENTICATED)) return 0; - } - if ((priv->rtllib->state == RTLLIB_LINKED) && (priv->rtllib->CntAfterLink<2)){ + if ((priv->rtllib->state == RTLLIB_LINKED) && + (priv->rtllib->CntAfterLink < 2)) return 0; - } } - if (priv->bHwRadioOff == true){ - printk("================>%s(): hwradio off\n",__func__); + if (priv->bHwRadioOff == true) { + printk(KERN_INFO "================>%s(): hwradio off\n", + __func__); return 0; } rtState = priv->rtllib->eRFPowerState; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true) return -EAGAIN; - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) - { - struct iw_scan_req* req = (struct iw_scan_req*)b; - if (req->essid_len) - { + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { + struct iw_scan_req *req = (struct iw_scan_req *)b; + if (req->essid_len) { ieee->current_network.ssid_len = req->essid_len; - memcpy(ieee->current_network.ssid, req->essid, req->essid_len); + memcpy(ieee->current_network.ssid, req->essid, + req->essid_len); } } @@ -482,15 +490,18 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, priv->rtllib->FirstIe_InScan = true; - if (priv->rtllib->state != RTLLIB_LINKED){ - if (priv->rtllib->PowerSaveControl.bInactivePs){ - if (rtState == eRfOff){ - if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS){ - RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",__func__); + if (priv->rtllib->state != RTLLIB_LINKED) { + if (priv->rtllib->PowerSaveControl.bInactivePs) { + if (rtState == eRfOff) { + if (priv->rtllib->RfOffReason > + RF_CHANGE_BY_IPS) { + RT_TRACE(COMP_ERR, "%s(): RF is " + "OFF.\n", __func__); up(&priv->wx_sem); return -1; - }else{ - RT_TRACE(COMP_PS, "=========>%s(): IPSLeave\n",__func__); + } else { + RT_TRACE(COMP_PS, "=========>%s(): " + "IPSLeave\n", __func__); down(&priv->rtllib->ips_sem); IPSLeave(dev); up(&priv->rtllib->ips_sem); @@ -499,23 +510,26 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } rtllib_stop_scan(priv->rtllib); if (priv->rtllib->LedControlHandler) - priv->rtllib->LedControlHandler(dev, LED_CTL_SITE_SURVEY); + priv->rtllib->LedControlHandler(dev, + LED_CTL_SITE_SURVEY); - if (priv->rtllib->eRFPowerState != eRfOff){ + if (priv->rtllib->eRFPowerState != eRfOff) { priv->rtllib->actscanning = true; if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_BACKUP); + ieee->ScanOperationBackupHandler(ieee->dev, + SCAN_OPT_BACKUP); rtllib_start_scan_syncro(priv->rtllib, 0); if (ieee->ScanOperationBackupHandler) - ieee->ScanOperationBackupHandler(ieee->dev,SCAN_OPT_RESTORE); - } + ieee->ScanOperationBackupHandler(ieee->dev, + SCAN_OPT_RESTORE); + } ret = 0; } else { priv->rtllib->actscanning = true; - ret = rtllib_wx_set_scan(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_scan(priv->rtllib, a, wrqu, b); } up(&priv->wx_sem); @@ -530,7 +544,8 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, int ret; struct r8192_priv *priv = rtllib_priv(dev); - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; if (priv->bHwRadioOff == true) return 0; @@ -538,7 +553,7 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, down(&priv->wx_sem); - ret = rtllib_wx_get_scan(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_get_scan(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); @@ -552,15 +567,17 @@ static int r8192_wx_set_essid(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); int ret; - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { + ; /* TODO - get rid of if */ } - if (priv->bHwRadioOff == true){ - printk("=========>%s():hw radio off,or Rf state is eRfOff, return\n",__func__); + if (priv->bHwRadioOff == true) { + printk(KERN_INFO "=========>%s():hw radio off,or Rf state is " + "eRfOff, return\n", __func__); return 0; } down(&priv->wx_sem); - ret = rtllib_wx_set_essid(priv->rtllib,a,wrqu,b); + ret = rtllib_wx_set_essid(priv->rtllib, a, wrqu, b); up(&priv->wx_sem); @@ -682,12 +699,12 @@ static int r8192_wx_set_wap(struct net_device *dev, union iwreq_data *awrq, char *extra) { - int ret; struct r8192_priv *priv = rtllib_priv(dev); - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) { + ; /* TODO - get rid of if */ } if (priv->bHwRadioOff == true) @@ -695,7 +712,7 @@ static int r8192_wx_set_wap(struct net_device *dev, down(&priv->wx_sem); - ret = rtllib_wx_set_wap(priv->rtllib,info,awrq,extra); + ret = rtllib_wx_set_wap(priv->rtllib, info, awrq, extra); up(&priv->wx_sem); @@ -710,7 +727,7 @@ static int r8192_wx_get_wap(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); - return rtllib_wx_get_wap(priv->rtllib,info,wrqu,extra); + return rtllib_wx_get_wap(priv->rtllib, info, wrqu, extra); } @@ -731,87 +748,91 @@ static int r8192_wx_set_enc(struct net_device *dev, int ret; struct rtllib_device *ieee = priv->rtllib; - u32 hwkey[4]={0,0,0,0}; - u8 mask=0xff; - u32 key_idx=0; - u8 zero_addr[4][6] ={ {0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x01}, - {0x00,0x00,0x00,0x00,0x00,0x02}, - {0x00,0x00,0x00,0x00,0x00,0x03} }; + u32 hwkey[4] = {0, 0, 0, 0}; + u8 mask = 0xff; + u32 key_idx = 0; + u8 zero_addr[4][6] = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} }; int i; - if ((rtllib_act_scanning(priv->rtllib, false)) && !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)){ - ; - } + if ((rtllib_act_scanning(priv->rtllib, false)) && + !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) + ; /* TODO - get rid of if */ if (priv->bHwRadioOff == true) return 0; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; - priv->rtllib->wx_set_enc = 1; - down(&priv->rtllib->ips_sem); - IPSLeave(dev); - up(&priv->rtllib->ips_sem); + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); down(&priv->wx_sem); RT_TRACE(COMP_SEC, "Setting SW wep key"); - ret = rtllib_wx_set_encode(priv->rtllib,info,wrqu,key); + ret = rtllib_wx_set_encode(priv->rtllib, info, wrqu, key); up(&priv->wx_sem); if (wrqu->encoding.flags & IW_ENCODE_DISABLED) { ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, + sizeof(struct sw_cam_table) * 32); goto end_hw_sec; } - if (wrqu->encoding.length!=0){ + if (wrqu->encoding.length != 0) { - for (i=0 ; i<4 ; i++){ + for (i = 0; i < 4; i++) { hwkey[i] |= key[4*i+0]&mask; - if (i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00; - if (i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00; - hwkey[i] |= (key[4*i+1]&mask)<<8; - hwkey[i] |= (key[4*i+2]&mask)<<16; - hwkey[i] |= (key[4*i+3]&mask)<<24; + if (i == 1 && (4 * i + 1) == wrqu->encoding.length) + mask = 0x00; + if (i == 3 && (4 * i + 1) == wrqu->encoding.length) + mask = 0x00; + hwkey[i] |= (key[4 * i + 1] & mask) << 8; + hwkey[i] |= (key[4 * i + 2] & mask) << 16; + hwkey[i] |= (key[4 * i + 3] & mask) << 24; } #define CONF_WEP40 0x4 #define CONF_WEP104 0x14 - switch (wrqu->encoding.flags & IW_ENCODE_INDEX){ - case 0: key_idx = ieee->tx_keyidx; break; - case 1: key_idx = 0; break; - case 2: key_idx = 1; break; - case 3: key_idx = 2; break; - case 4: key_idx = 3; break; - default: break; + switch (wrqu->encoding.flags & IW_ENCODE_INDEX) { + case 0: + key_idx = ieee->tx_keyidx; + break; + case 1: + key_idx = 0; + break; + case 2: + key_idx = 1; + break; + case 3: + key_idx = 2; + break; + case 4: + key_idx = 3; + break; + default: + break; } - if (wrqu->encoding.length==0x5){ + if (wrqu->encoding.length == 0x5) { ieee->pairwise_key_type = KEY_TYPE_WEP40; EnableHWSecurityConfig8192(dev); } - else if (wrqu->encoding.length==0xd){ + else if (wrqu->encoding.length == 0xd) { ieee->pairwise_key_type = KEY_TYPE_WEP104; EnableHWSecurityConfig8192(dev); - setKey( dev, - key_idx, - key_idx, - KEY_TYPE_WEP104, - zero_addr[key_idx], - 0, - hwkey); - set_swcam( dev, - key_idx, - key_idx, - KEY_TYPE_WEP104, - zero_addr[key_idx], - 0, - hwkey, - 0); + setKey(dev, key_idx, key_idx, KEY_TYPE_WEP104, + zero_addr[key_idx], 0, hwkey); + set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104, + zero_addr[key_idx], 0, hwkey, 0); } else { - printk("wrong type in WEP, not WEP40 and WEP104\n"); + printk(KERN_INFO "wrong type in WEP, not WEP40 and WEP104\n"); } } @@ -820,13 +841,13 @@ end_hw_sec: return ret; } - -static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union - iwreq_data *wrqu, char *p){ - +static int r8192_wx_set_scan_type(struct net_device *dev, + struct iw_request_info *aa, + union iwreq_data *wrqu, char *p) +{ struct r8192_priv *priv = rtllib_priv(dev); - int *parms=(int*)p; - int mode=parms[0]; + int *parms = (int *)p; + int mode = parms[0]; if (priv->bHwRadioOff == true) return 0; @@ -852,38 +873,32 @@ static int r8192_wx_set_retry(struct net_device *dev, down(&priv->wx_sem); if (wrqu->retry.flags & IW_RETRY_LIFETIME || - wrqu->retry.disabled){ + wrqu->retry.disabled) { err = -EINVAL; goto exit; } - if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){ + if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) { err = -EINVAL; goto exit; } - if (wrqu->retry.value > R8192_MAX_RETRY){ - err= -EINVAL; + if (wrqu->retry.value > R8192_MAX_RETRY) { + err = -EINVAL; goto exit; } if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; - DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); + DMESG("Setting retry for RTS/CTS data to %d", + wrqu->retry.value); - }else { + } else { priv->retry_data = wrqu->retry.value; - DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); + DMESG("Setting retry for non RTS/CTS data to %d", + wrqu->retry.value); } rtl8192_commit(dev); - /* - if (priv->up){ - rtl8180_halt_adapter(dev); - rtl8180_rx_enable(dev); - rtl8180_tx_enable(dev); - - } - */ exit: up(&priv->wx_sem); @@ -910,14 +925,12 @@ static int r8192_wx_get_retry(struct net_device *dev, wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN; wrqu->retry.value = priv->retry_data; } - - return 0; } static int r8192_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->rf_set_sens == NULL) @@ -941,13 +954,13 @@ static int r8192_wx_set_sens(struct net_device *dev, down(&priv->wx_sem); if (priv->rf_set_sens == NULL) { - err= -1; /* we have not this support for this radio */ + err = -1; /* we have not this support for this radio */ goto exit; } if (priv->rf_set_sens(dev, wrqu->sens.value) == 0) priv->sens = wrqu->sens.value; else - err= -EINVAL; + err = -EINVAL; exit: up(&priv->wx_sem); @@ -956,130 +969,90 @@ exit: } static int r8192_wx_set_enc_ext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; if (priv->bHwRadioOff == true) return 0; down(&priv->wx_sem); - priv->rtllib->wx_set_enc = 1; - down(&priv->rtllib->ips_sem); - IPSLeave(dev); - up(&priv->rtllib->ips_sem); + priv->rtllib->wx_set_enc = 1; + down(&priv->rtllib->ips_sem); + IPSLeave(dev); + up(&priv->rtllib->ips_sem); ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra); - { - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 zero[6] = {0}; u32 key[4] = {0}; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_point *encoding = &wrqu->encoding; u8 idx = 0, alg = 0, group = 0; if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) - { - ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA; + ext->alg == IW_ENCODE_ALG_NONE) { + ieee->pairwise_key_type = ieee->group_key_type + = KEY_TYPE_NA; CamResetAllEntry(dev); - memset(priv->rtllib->swcamtable,0,sizeof(struct sw_cam_table)*32); + memset(priv->rtllib->swcamtable, 0, + sizeof(struct sw_cam_table) * 32); goto end_hw_sec; } - alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; + alg = (ext->alg == IW_ENCODE_ALG_CCMP) ? KEY_TYPE_CCMP : + ext->alg; idx = encoding->flags & IW_ENCODE_INDEX; if (idx) - idx --; + idx--; group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY; - if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) - { - if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) ) + if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || + (alg == KEY_TYPE_WEP40)) { + if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40)) alg = KEY_TYPE_WEP104; ieee->pairwise_key_type = alg; EnableHWSecurityConfig8192(dev); } - memcpy((u8*)key, ext->key, 16); + memcpy((u8 *)key, ext->key, 16); - if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) ) - { + if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) { if (ext->key_len == 13) ieee->pairwise_key_type = alg = KEY_TYPE_WEP104; - setKey( dev, - idx, - idx, - alg, - zero, - 0, - key); - set_swcam( dev, - idx, - idx, - alg, - zero, - 0, - key, - 0); - } - else if (group) - { + setKey(dev, idx, idx, alg, zero, 0, key); + set_swcam(dev, idx, idx, alg, zero, 0, key, 0); + } else if (group) { ieee->group_key_type = alg; - setKey( dev, - idx, - idx, - alg, - broadcast_addr, - 0, - key); - set_swcam( dev, - idx, - idx, - alg, - broadcast_addr, - 0, - key, - 0); - } - else - { - if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && ieee->pHTInfo->bCurrentHTSupport){ - write_nic_byte(dev, 0x173, 1); - } - setKey( dev, - 4, - idx, - alg, - (u8*)ieee->ap_mac_addr, - 0, - key); - set_swcam( dev, - 4, - idx, - alg, - (u8*)ieee->ap_mac_addr, - 0, - key, - 0); + setKey(dev, idx, idx, alg, broadcast_addr, 0, key); + set_swcam(dev, idx, idx, alg, broadcast_addr, 0, + key, 0); + } else { + if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) && + ieee->pHTInfo->bCurrentHTSupport) + write_nic_byte(dev, 0x173, 1); + setKey(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr, + 0, key); + set_swcam(dev, 4, idx, alg, (u8 *)ieee->ap_mac_addr, + 0, key, 0); } } end_hw_sec: - priv->rtllib->wx_set_enc = 0; + priv->rtllib->wx_set_enc = 0; up(&priv->wx_sem); return ret; } static int r8192_wx_set_auth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) + struct iw_request_info *info, + union iwreq_data *data, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); @@ -1093,11 +1066,11 @@ static int r8192_wx_set_auth(struct net_device *dev, } static int r8192_wx_set_mlme(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = rtllib_priv(dev); @@ -1111,71 +1084,69 @@ static int r8192_wx_set_mlme(struct net_device *dev, } static int r8192_wx_set_gen_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *data, char *extra) + struct iw_request_info *info, + union iwreq_data *data, char *extra) { int ret = 0; - struct r8192_priv *priv = rtllib_priv(dev); + struct r8192_priv *priv = rtllib_priv(dev); if (priv->bHwRadioOff == true) return 0; - down(&priv->wx_sem); - ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length); - up(&priv->wx_sem); - return ret; + down(&priv->wx_sem); + ret = rtllib_wx_set_gen_ie(priv->rtllib, extra, data->data.length); + up(&priv->wx_sem); + return ret; } static int r8192_wx_get_gen_ie(struct net_device *dev, - struct iw_request_info *info, + struct iw_request_info *info, union iwreq_data *data, char *extra) { int ret = 0; - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) { data->data.length = 0; return 0; } - if (data->data.length < ieee->wpa_ie_len) { + if (data->data.length < ieee->wpa_ie_len) return -E2BIG; - } data->data.length = ieee->wpa_ie_len; memcpy(extra, ieee->wpa_ie, ieee->wpa_ie_len); - return ret; + return ret; } #define OID_RT_INTEL_PROMISCUOUS_MODE 0xFF0101F6 static int r8192_wx_set_PromiscuousMode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - u32 *info_buf = (u32*)(wrqu->data.pointer); + u32 *info_buf = (u32 *)(wrqu->data.pointer); u32 oid = info_buf[0]; u32 bPromiscuousOn = info_buf[1]; u32 bFilterSourceStationFrame = info_buf[2]; - if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) - { + if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) { ieee->IntelPromiscuousModeInfo.bPromiscuousOn = - (bPromiscuousOn)? (true) : (false); + (bPromiscuousOn) ? (true) : (false); ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame = - (bFilterSourceStationFrame)? (true) : (false); + (bFilterSourceStationFrame) ? (true) : (false); + (bPromiscuousOn) ? + (rtllib_EnableIntelPromiscuousMode(dev, false)) : + (rtllib_DisableIntelPromiscuousMode(dev, false)); - (bPromiscuousOn) ? (rtllib_EnableIntelPromiscuousMode(dev, false)) : - (rtllib_DisableIntelPromiscuousMode(dev, false)); - - printk("=======>%s(), on = %d, filter src sta = %d\n", __func__, - bPromiscuousOn, bFilterSourceStationFrame); + printk(KERN_INFO "=======>%s(), on = %d, filter src sta = %d\n", + __func__, bPromiscuousOn, bFilterSourceStationFrame); } else { return -1; } @@ -1185,56 +1156,55 @@ static int r8192_wx_set_PromiscuousMode(struct net_device *dev, static int r8192_wx_get_PromiscuousMode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; + struct rtllib_device *ieee = priv->rtllib; - down(&priv->wx_sem); + down(&priv->wx_sem); - snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d",\ - ieee->IntelPromiscuousModeInfo.bPromiscuousOn,\ - ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame); - wrqu->data.length = strlen(extra) + 1; + snprintf(extra, 45, "PromiscuousMode:%d, FilterSrcSTAFrame:%d", + ieee->IntelPromiscuousModeInfo.bPromiscuousOn, + ieee->IntelPromiscuousModeInfo.bFilterSourceStationFrame); + wrqu->data.length = strlen(extra) + 1; - up(&priv->wx_sem); + up(&priv->wx_sem); return 0; } #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] -static iw_handler r8192_wx_handlers[] = -{ - IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name, - IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq, - IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq, - IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode, - IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode, - IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens, - IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens, - IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range, - IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap, - IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap, - IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan, - IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan, - IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid, - IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid, - IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick, +static iw_handler r8192_wx_handlers[] = { + IW_IOCTL(SIOCGIWNAME) = r8192_wx_get_name, + IW_IOCTL(SIOCSIWFREQ) = r8192_wx_set_freq, + IW_IOCTL(SIOCGIWFREQ) = r8192_wx_get_freq, + IW_IOCTL(SIOCSIWMODE) = r8192_wx_set_mode, + IW_IOCTL(SIOCGIWMODE) = r8192_wx_get_mode, + IW_IOCTL(SIOCSIWSENS) = r8192_wx_set_sens, + IW_IOCTL(SIOCGIWSENS) = r8192_wx_get_sens, + IW_IOCTL(SIOCGIWRANGE) = rtl8192_wx_get_range, + IW_IOCTL(SIOCSIWAP) = r8192_wx_set_wap, + IW_IOCTL(SIOCGIWAP) = r8192_wx_get_wap, + IW_IOCTL(SIOCSIWSCAN) = r8192_wx_set_scan, + IW_IOCTL(SIOCGIWSCAN) = r8192_wx_get_scan, + IW_IOCTL(SIOCSIWESSID) = r8192_wx_set_essid, + IW_IOCTL(SIOCGIWESSID) = r8192_wx_get_essid, + IW_IOCTL(SIOCSIWNICKN) = r8192_wx_set_nick, IW_IOCTL(SIOCGIWNICKN) = r8192_wx_get_nick, - IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate, - IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate, - IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts, - IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts, - IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag, - IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag, - IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry, - IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry, - IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc, - IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, - IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, - IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, + IW_IOCTL(SIOCSIWRATE) = r8192_wx_set_rate, + IW_IOCTL(SIOCGIWRATE) = r8192_wx_get_rate, + IW_IOCTL(SIOCSIWRTS) = r8192_wx_set_rts, + IW_IOCTL(SIOCGIWRTS) = r8192_wx_get_rts, + IW_IOCTL(SIOCSIWFRAG) = r8192_wx_set_frag, + IW_IOCTL(SIOCGIWFRAG) = r8192_wx_get_frag, + IW_IOCTL(SIOCSIWRETRY) = r8192_wx_set_retry, + IW_IOCTL(SIOCGIWRETRY) = r8192_wx_get_retry, + IW_IOCTL(SIOCSIWENCODE) = r8192_wx_set_enc, + IW_IOCTL(SIOCGIWENCODE) = r8192_wx_get_enc, + IW_IOCTL(SIOCSIWPOWER) = r8192_wx_set_power, + IW_IOCTL(SIOCGIWPOWER) = r8192_wx_get_power, IW_IOCTL(SIOCSIWGENIE) = r8192_wx_set_gen_ie, IW_IOCTL(SIOCGIWGENIE) = r8192_wx_get_gen_ie, IW_IOCTL(SIOCSIWMLME) = r8192_wx_set_mlme, @@ -1251,69 +1221,47 @@ static const struct iw_priv_args r8192_private_args[] = { { SIOCIWFIRSTPRIV + 0x0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_debugflag" - }, - { + }, { SIOCIWFIRSTPRIV + 0x1, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan" - }, - { + }, { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x3, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x5, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1, "firm_ver" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "set_power" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x9, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "radio" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xa, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "lps_interv" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xb, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE, "lps_force" - } - , - { + }, { SIOCIWFIRSTPRIV + 0xc, 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list" - } - , - { + }, { SIOCIWFIRSTPRIV + 0x16, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" - } - , - { + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc" + }, { SIOCIWFIRSTPRIV + 0x17, - 0,IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc" + 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 45, "getpromisc" } }; @@ -1347,14 +1295,13 @@ static iw_handler r8192_private_handler[] = { struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { - struct r8192_priv *priv = rtllib_priv(dev); - struct rtllib_device* ieee = priv->rtllib; - struct iw_statistics* wstats = &priv->wstats; + struct r8192_priv *priv = rtllib_priv(dev); + struct rtllib_device *ieee = priv->rtllib; + struct iw_statistics *wstats = &priv->wstats; int tmp_level = 0; int tmp_qual = 0; int tmp_noise = 0; - if (ieee->state < RTLLIB_LINKED) - { + if (ieee->state < RTLLIB_LINKED) { wstats->qual.qual = 10; wstats->qual.level = 0; wstats->qual.noise = -100; @@ -1362,7 +1309,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } - tmp_level = (&ieee->current_network)->stats.rssi; + tmp_level = (&ieee->current_network)->stats.rssi; tmp_qual = (&ieee->current_network)->stats.signal; tmp_noise = (&ieee->current_network)->stats.noise; @@ -1373,12 +1320,13 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } -struct iw_handler_def r8192_wx_handlers_def={ +struct iw_handler_def r8192_wx_handlers_def = { .standard = r8192_wx_handlers, .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler), .private = r8192_private_handler, .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), + .num_private_args = sizeof(r8192_private_args) / + sizeof(struct iw_priv_args), .get_wireless_stats = r8192_get_wireless_stats, .private_args = (struct iw_priv_args *)r8192_private_args, }; diff --git a/drivers/staging/rtl8192e/rtl_wx.h b/drivers/staging/rtl8192e/rtl_wx.h index 94d42a822116..6a51a25ec87d 100644 --- a/drivers/staging/rtl8192e/rtl_wx.h +++ b/drivers/staging/rtl8192e/rtl_wx.h @@ -26,6 +26,6 @@ struct iw_statistics; extern struct iw_handler_def r8192_wx_handlers_def; struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); -u16 rtl8192_11n_user_show_rates(struct net_device* dev); +u16 rtl8192_11n_user_show_rates(struct net_device *dev); #endif From 438812c3ecfd6976d05bf9320783b689ec884dff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 11 Aug 2011 22:31:50 -0500 Subject: [PATCH 21/25] staging: rtl8192e: Remove MAC_FMT and MAC_ARG for %pM Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 15 +++---- drivers/staging/rtl8192e/rtl819x_TSProc.c | 6 +-- drivers/staging/rtl8192e/rtl_cam.c | 4 +- drivers/staging/rtl8192e/rtl_dm.c | 4 +- drivers/staging/rtl8192e/rtllib.h | 4 -- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 13 +++--- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 21 +++++---- drivers/staging/rtl8192e/rtllib_rx.c | 46 ++++++++++---------- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- drivers/staging/rtl8192e/rtllib_wx.c | 4 +- 10 files changed, 55 insertions(+), 64 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 2e4085b88775..5bdb78cdeab0 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -83,8 +83,8 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, u16 tmp = 0; u16 len = ieee->tx_headroom + 9; RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)" - " sentd to:"MAC_FMT", ieee->dev:%p\n", __func__, - type, MAC_ARG(Dst), ieee->dev); + " sentd to: %pM, ieee->dev:%p\n", __func__, + type, Dst, ieee->dev); if (pBA == NULL || ieee == NULL) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA(%p) is NULL or ieee(%p) is " "NULL\n", pBA, ieee); @@ -150,8 +150,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, if (net_ratelimit()) RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), Reason" - "Code(%d) sentd to:"MAC_FMT"\n", __func__, - ReasonCode, MAC_ARG(dst)); + "Code(%d) sentd to: %pM\n", __func__, + ReasonCode, dst); memset(&DelbaParamSet, 0, 2); @@ -265,7 +265,7 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb) pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (union sequence_control *)(req + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst)); + RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from : %pM\n", dst); if (ieee->current_network.qos_data.active == 0 || (ieee->pHTInfo->bCurrentHTSupport == false) || (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) { @@ -347,7 +347,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb) pBaParamSet = (union ba_param_set *)(tag + 5); pBaTimeoutVal = (u16 *)(tag + 7); - RT_TRACE(COMP_DBG, "====>rx ADDBARSP from :"MAC_FMT"\n", MAC_ARG(dst)); + RT_TRACE(COMP_DBG, "====>rx ADDBARSP from : %pM\n", dst); if (ieee->current_network.qos_data.active == 0 || ieee->pHTInfo->bCurrentHTSupport == false || ieee->pHTInfo->bCurrentAMPDUEnable == false) { @@ -459,8 +459,7 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb) if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst, (u8)pDelBaParamSet->field.TID, RX_DIR, false)) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS for RXTS in " - "%s().dst:"MAC_FMT" TID:%d\n", __func__, - MAC_ARG(dst), + "%s().dst: %pM TID:%d\n", __func__, dst, (u8)pDelBaParamSet->field.TID); return -1; } diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 519349f0ce4b..6ebd20e8530c 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -389,9 +389,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, } RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS" - ", UP:%d, Dir:%d, addr:"MAC_FMT + ", UP:%d, Dir:%d, addr: %pM" " ppTs=%p\n", UP, Dir, - MAC_ARG(Addr), *ppTS); + Addr, *ppTS); pTSInfo->field.ucTrafficType = 0; pTSInfo->field.ucTSID = UP; pTSInfo->field.ucDirection = Dir; @@ -462,7 +462,7 @@ void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr) { struct ts_common_info *pTS, *pTmpTS; - printk(KERN_INFO "===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr)); + printk(KERN_INFO "===========>RemovePeerTS, %pM\n", Addr); list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) { if (memcmp(pTS->Addr, Addr, 6) == 0) { diff --git a/drivers/staging/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl_cam.c index a9991a0fa1c8..baf3b6342e44 100644 --- a/drivers/staging/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl_cam.c @@ -126,8 +126,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d," - "KeyType:%d, MacAddr"MAC_FMT"\n", dev, EntryNo, KeyIndex, - KeyType, MAC_ARG(MacAddr)); + "KeyType:%d, MacAddr %pM\n", dev, EntryNo, KeyIndex, + KeyType, MacAddr); if (DefaultKey) usConfig |= BIT15 | (KeyType<<2); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 291ec3e9d22c..6d201ec38276 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -2322,9 +2322,9 @@ static void dm_check_edca_turbo(struct net_device *dev) static int wb_tmp; if (wb_tmp == 0) { printk(KERN_INFO "%s():iot peer is %s, bssid:" - MAC_FMT"\n", __func__, + " %pM\n", __func__, peername[pHTInfo->IOTPeer], - MAC_ARG(priv->rtllib->current_network.bssid)); + priv->rtllib->current_network.bssid); wb_tmp = 1; } } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c7b3641f30b6..b33caccb43a8 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -700,10 +700,6 @@ do { \ } \ } while (0) -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \ - ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] - /* * To use the debug system; * diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 306d6ff707af..78059b9671fc 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -279,7 +279,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPFormatErrors++; return -2; @@ -292,9 +292,9 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!key->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT + printk(KERN_DEBUG "CCMP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -342,7 +342,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: decrypt failed: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " %pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPDecryptErrors++; return -5; @@ -418,11 +418,10 @@ static char *rtllib_ccmp_print_stats(char *p, void *priv) { struct rtllib_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " - "tx_pn=%02x%02x%02x%02x%02x%02x " - "rx_pn=%02x%02x%02x%02x%02x%02x " + "tx_pn=%pM rx_pn=%pM " "format_errors=%d replays=%d decrypt_errors=%d\n", ccmp->key_idx, ccmp->key_set, - MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn), + ccmp->tx_pn, ccmp->rx_pn, ccmp->dot11RSNAStatsCCMPFormatErrors, ccmp->dot11RSNAStatsCCMPReplays, ccmp->dot11RSNAStatsCCMPDecryptErrors); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index c4e490e57ad3..6a0c87886422 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -400,7 +400,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } return -2; } @@ -412,9 +412,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tkey->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT + printk(KERN_DEBUG "TKIP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -428,9 +428,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) tkey->initialized) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: replay detected: STA=" - MAC_FMT - " previous TSC %08x%04x received TSC " - "%08x%04x\n", MAC_ARG(hdr->addr2), + " %pM previous TSC %08x%04x received " + "TSC %08x%04x\n",hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; @@ -453,8 +452,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from " MAC_FMT "\n", - MAC_ARG(hdr->addr2)); + "received packet from %pM\n", + hdr->addr2); } return -7; } @@ -474,7 +473,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: ICV error detected: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " %pM\n", hdr->addr2); } tkey->dot11RSNAStatsTKIPICVErrors++; return -5; @@ -624,8 +623,8 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx, struct rtllib_hdr_4addr *hdr; hdr = (struct rtllib_hdr_4addr *) skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " - "MSDU from " MAC_FMT " keyidx=%d\n", - skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), + "MSDU from %pM keyidx=%d\n", + skb->dev ? skb->dev->name : "N/A", hdr->addr2, keyidx); printk(KERN_DEBUG "%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 205c57508497..35f70d6fe2eb 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -305,8 +305,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, atomic_dec(&crypt->refcnt); if (res < 0) { RTLLIB_DEBUG_DROP( - "decryption failed (SA=" MAC_FMT - ") res=%d\n", MAC_ARG(hdr->addr2), res); + "decryption failed (SA= %pM" + ") res=%d\n", hdr->addr2, res); if (res == -2) RTLLIB_DEBUG_DROP("Decryption failed ICV " "mismatch (key %d)\n", @@ -345,8 +345,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb, atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" - " (SA=" MAC_FMT " keyidx=%d)\n", - ieee->dev->name, MAC_ARG(hdr->addr2), keyidx); + " (SA= %pM keyidx=%d)\n", + ieee->dev->name, hdr->addr2, keyidx); return -1; } @@ -1028,8 +1028,8 @@ int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, * frames silently instead of filling system log with * these reports. */ RTLLIB_DEBUG_DROP("Decryption failed (not set)" - " (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + " (SA= %pM)\n", + hdr->addr2); ieee->ieee_stats.rx_discards_undecryptable++; return -1; } @@ -1138,8 +1138,8 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, } else { RTLLIB_DEBUG_DROP( "encryption configured, but RX " - "frame not encrypted (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + "frame not encrypted (SA= %pM)\n", + hdr->addr2); return -1; } } @@ -1156,9 +1156,9 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, !rtllib_is_eapol_frame(ieee, skb, hdrlen)) { RTLLIB_DEBUG_DROP( "dropped unencrypted RX data " - "frame from " MAC_FMT + "frame from %pM" " (drop_unencrypted=1)\n", - MAC_ARG(hdr->addr2)); + hdr->addr2); return -1; } @@ -2309,11 +2309,11 @@ static inline int rtllib_network_init( } if (network->mode == 0) { - RTLLIB_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' " + RTLLIB_DEBUG_SCAN("Filtered out '%s (%pM)' " "network.\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid)); + network->bssid); return 1; } @@ -2516,9 +2516,9 @@ static inline void rtllib_process_probe_response( return; RTLLIB_DEBUG_SCAN( - "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", + "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, (beacon->capability & (1<<0xf)) ? '1' : '0', (beacon->capability & (1<<0xe)) ? '1' : '0', (beacon->capability & (1<<0xd)) ? '1' : '0', @@ -2537,10 +2537,10 @@ static inline void rtllib_process_probe_response( (beacon->capability & (1<<0x0)) ? '1' : '0'); if (rtllib_network_init(ieee, beacon, network, stats)) { - RTLLIB_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -2604,11 +2604,11 @@ static inline void rtllib_process_probe_response( /* If there are no more slots, expire the oldest */ list_del(&oldest->list); target = oldest; - RTLLIB_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from " + RTLLIB_DEBUG_SCAN("Expired '%s' ( %pM) from " "network list.\n", escape_essid(target->ssid, target->ssid_len), - MAC_ARG(target->bssid)); + target->bssid); } else { /* Otherwise just pull from the free list */ target = list_entry(ieee->network_free_list.next, @@ -2617,10 +2617,9 @@ static inline void rtllib_process_probe_response( } - RTLLIB_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n", escape_essid(network->ssid, - network->ssid_len), - MAC_ARG(network->bssid), + network->ssid_len), network->bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -2629,10 +2628,9 @@ static inline void rtllib_process_probe_response( if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) rtllib_softmac_new_net(ieee, network); } else { - RTLLIB_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", + RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n", escape_essid(target->ssid, - target->ssid_len), - MAC_ARG(target->bssid), + target->ssid_len), target->bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == RTLLIB_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index fa0e2afd1ed1..dd4dec8c53af 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1972,7 +1972,7 @@ static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee, if (assoc_rq_parse(skb, dest) != -1) rtllib_resp_to_assoc_rq(ieee, dest); - printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); + printk(KERN_INFO"New client associated: %pM\n", dest); } void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr) diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index c350f4e277da..8cea4a60e1b3 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -279,10 +279,10 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee, info); else RTLLIB_DEBUG_SCAN("Not showing network '%s (" - MAC_FMT ")' due to age (%lums).\n", + " %pM)' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid), + network->bssid, (jiffies - network->last_scanned) / (HZ / 100)); } From 966aeb321cd797332243b270e74d9b08936a6dab Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 12 Aug 2011 07:31:47 -0500 Subject: [PATCH 22/25] staging: rtl8192e: Fix sparse (non-endian) messages - Part I Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 24 +-- drivers/staging/rtl8192e/rtl819x_HTProc.c | 169 ++----------------- drivers/staging/rtl8192e/rtl819x_TSProc.c | 35 ++-- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- drivers/staging/rtl8192e/rtllib_module.c | 9 +- drivers/staging/rtl8192e/rtllib_softmac.c | 111 +++++------- drivers/staging/rtl8192e/rtllib_tx.c | 29 ++-- 7 files changed, 104 insertions(+), 275 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 5bdb78cdeab0..48f9f71051e4 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -20,21 +20,21 @@ #include "rtl819x_BA.h" #include "rtl_core.h" -void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, - u16 Time) +static void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA, + u16 Time) { pBA->bValid = true; if (Time != 0) mod_timer(&pBA->Timer, jiffies + MSECS(Time)); } -void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) +static void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA) { pBA->bValid = false; del_timer_sync(&pBA->Timer); } -u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) +static u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) { struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord; struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord; @@ -52,7 +52,7 @@ u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs) return bSendDELBA; } -u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) +static u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs) { struct ba_record *pBa = &pRxTs->RxAdmittedBARecord; u8 bSendDELBA = false; @@ -193,8 +193,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, return skb; } -void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA) +static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); @@ -209,8 +209,8 @@ void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst, return; } -void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA, u16 StatusCode) +static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, u16 StatusCode) { struct sk_buff *skb = NULL; skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); @@ -222,9 +222,9 @@ void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst, return; } -void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, - struct ba_record *pBA, enum tr_select TxRxSelect, - u16 ReasonCode) +static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, + struct ba_record *pBA, enum tr_select TxRxSelect, + u16 ReasonCode) { struct sk_buff *skb = NULL; skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index f8da913c47be..b1c0c566882f 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -214,7 +214,7 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) return; } -bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) +static bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -233,7 +233,7 @@ bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee) return retValue; } -bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) +static bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz) { bool retValue = false; struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -336,7 +336,7 @@ bool IsHTHalfNmodeAPs(struct rtllib_device *ieee) return retValue; } -void HTIOTPeerDetermine(struct rtllib_device *ieee) +static void HTIOTPeerDetermine(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rtllib_network *net = &ieee->current_network; @@ -378,40 +378,31 @@ void HTIOTPeerDetermine(struct rtllib_device *ieee) pHTInfo->IOTPeer); } -u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) +static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr) { return 0; } -bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) +static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee) { bool retValue = false; return retValue; } -bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) +static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee) { return false; } -u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) +static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr) { return false; } - -bool HTIOTActIsEnableBETxOPLimit(struct rtllib_device *ieee) -{ - bool retValue = false; - - return retValue; -} - - -u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, - struct rtllib_network *network) +static u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, + struct rtllib_network *network) { u8 retValue = 0; @@ -422,60 +413,7 @@ u8 HTIOTActIsMgntUseCCK6M(struct rtllib_device *ieee, return retValue; } -u8 HTIOTActWAIOTBroadcom(struct rtllib_device *ieee) -{ - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - u8 retValue = false; - u8 boundary = 59; - - pHTInfo->bWAIotBroadcom = false; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { - if (ieee->current_network.bssht.bdBandWidth == - HT_CHANNEL_WIDTH_20_40) { - if (!(pHTInfo->bRegBW40MHz)) { - if (ieee->current_network.mode != - WIRELESS_MODE_B) { - pHTInfo->bWAIotBroadcom = true; - - if (ieee->b_customer_lenovo_id) - boundary = 30; - - if (ieee->current_network.RSSI >= - boundary) - retValue = true; - } - } - } - } - return retValue; -} - -u8 HTIOTActIsForcedCTS2Self(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - if (ieee->pHTInfo->IOTPeer == HT_IOT_PEER_MARVELL) - retValue = 1; - - return retValue; -} - -u8 HTIOTActIsForcedRTSCTS(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - return retValue; -} - -u8 HTIOTActIsForcedAMSDU8K(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) +static u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) { u8 retValue = 0; @@ -484,42 +422,7 @@ u8 HTIOTActIsCCDFsync(struct rtllib_device *ieee) return retValue; } -u8 HTIOCActRejcectADDBARequest(struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsEDCABiasRx(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActDisableShortGI(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; - - if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK) - retValue = 1; - - return retValue; -} - -u8 HTIOTActDisableHighPower(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) +static void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL; @@ -532,52 +435,6 @@ void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss) } - -u8 HTIOTActIsDisableTx40MHz(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsTxNoAggregation(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -u8 HTIOTActIsDisableTx2SS(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - u8 retValue = 0; - - return retValue; -} - -bool HTIOCActIsDisableCckRate(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - -bool HTIOCActAllowPeerAggOnePacket(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - -bool HTIOTActIsNullDataPowerSaving(struct rtllib_device *ieee, - struct rtllib_network *network) -{ - bool retValue = false; - return retValue; -} - void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo) { pHTInfo->IOTAction = 0; @@ -735,7 +592,7 @@ void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg, return; } -u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) +static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS) { u8 i; if (pOperateMCS == NULL) { @@ -1148,7 +1005,7 @@ u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame) return false; } -void HTSetConnectBwModeCallback(struct rtllib_device *ieee) +static void HTSetConnectBwModeCallback(struct rtllib_device *ieee) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 6ebd20e8530c..ccec382cea23 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -20,15 +20,15 @@ #include #include "rtl819x_TS.h" -void TsSetupTimeOut(unsigned long data) +static void TsSetupTimeOut(unsigned long data) { } -void TsInactTimeout(unsigned long data) +static void TsInactTimeout(unsigned long data) { } -void RxPktPendingTimeout(unsigned long data) +static void RxPktPendingTimeout(unsigned long data) { struct rx_ts_record *pRxTs = (struct rx_ts_record *)data; struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, @@ -97,7 +97,7 @@ void RxPktPendingTimeout(unsigned long data) spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -void TsAddBaProcess(unsigned long data) +static void TsAddBaProcess(unsigned long data) { struct tx_ts_record *pTxTs = (struct tx_ts_record *)data; u8 num = pTxTs->num; @@ -109,7 +109,7 @@ void TsAddBaProcess(unsigned long data) "started!!\n"); } -void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) +static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) { memset(pTsCommonInfo->Addr, 0, 6); memset(&pTsCommonInfo->TSpec, 0, sizeof(union tspec_body)); @@ -118,7 +118,7 @@ void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo) pTsCommonInfo->TClasNum = 0; } -void ResetTxTsEntry(struct tx_ts_record *pTS) +static void ResetTxTsEntry(struct tx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->TxCurSeq = 0; @@ -130,7 +130,7 @@ void ResetTxTsEntry(struct tx_ts_record *pTS) ResetBaEntry(&pTS->TxPendingBARecord); } -void ResetRxTsEntry(struct rx_ts_record *pTS) +static void ResetRxTsEntry(struct rx_ts_record *pTS) { ResetTsCommonInfo(&pTS->TsCommonInfo); pTS->RxIndicateSeq = 0xffff; @@ -215,8 +215,8 @@ void TSInitialize(struct rtllib_device *ieee) } -void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, - u32 InactTime) +static void AdmitTS(struct rtllib_device *ieee, + struct ts_common_info *pTsCommonInfo, u32 InactTime) { del_timer_sync(&pTsCommonInfo->SetupTimer); del_timer_sync(&pTsCommonInfo->InactTimer); @@ -226,11 +226,12 @@ void AdmitTS(struct rtllib_device *ieee, struct ts_common_info *pTsCommonInfo, MSECS(InactTime)); } -struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, - u8 TID, enum tr_select TxRxSelect) +static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, + u8 *Addr, u8 TID, + enum tr_select TxRxSelect) { u8 dir; - bool search_dir[4] = {0, 0, 0, 0}; + bool search_dir[4] = {0}; struct list_head *psearch_list; struct ts_common_info *pRet = NULL; if (ieee->iw_mode == IW_MODE_MASTER) { @@ -283,9 +284,9 @@ struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee, u8 *Addr, return NULL; } -void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, - union tspec_body *pTSPEC, union qos_tclas *pTCLAS, - u8 TCLAS_Num, u8 TCLAS_Proc) +static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr, + union tspec_body *pTSPEC, union qos_tclas *pTCLAS, + u8 TCLAS_Num, u8 TCLAS_Proc) { u8 count; @@ -418,8 +419,8 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, } } -void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, - enum tr_select TxRxSelect) +static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs, + enum tr_select TxRxSelect) { del_timer_sync(&pTs->SetupTimer); del_timer_sync(&pTs->InactTimer); diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 78059b9671fc..6196b9aa3a09 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -53,7 +53,7 @@ struct rtllib_ccmp_data { u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, +static void rtllib_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { crypto_cipher_encrypt_one((void *)tfm, ct, pt); diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index dd0d8db01bda..0fe67a54edd2 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -68,7 +68,7 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee) if (ieee->networks) return 0; - ieee->networks = kmalloc( + ieee->networks = kzalloc( MAX_NETWORK_COUNT * sizeof(struct rtllib_network), GFP_KERNEL); if (!ieee->networks) { @@ -77,9 +77,6 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee) return -ENOMEM; } - memset(ieee->networks, 0, - MAX_NETWORK_COUNT * sizeof(struct rtllib_network)); - return 0; } @@ -223,7 +220,7 @@ u32 rtllib_debug_level; static int debug = \ RTLLIB_DL_ERR ; -struct proc_dir_entry *rtllib_proc; +static struct proc_dir_entry *rtllib_proc; static int show_debug_level(char *page, char **start, off_t offset, int count, int *eof, void *data) @@ -231,7 +228,7 @@ static int show_debug_level(char *page, char **start, off_t offset, return snprintf(page, count, "0x%08X\n", rtllib_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level(struct file *file, const char __user *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index dd4dec8c53af..a420ed1a9479 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -23,15 +23,6 @@ #include #include "dot11d.h" -u8 rsn_authen_cipher_suite[16][4] = { - {0x00, 0x0F, 0xAC, 0x00}, - {0x00, 0x0F, 0xAC, 0x01}, - {0x00, 0x0F, 0xAC, 0x02}, - {0x00, 0x0F, 0xAC, 0x03}, - {0x00, 0x0F, 0xAC, 0x04}, - {0x00, 0x0F, 0xAC, 0x05}, -}; - short rtllib_is_54g(struct rtllib_network *net) { return (net->rates_ex_len > 0) || (net->rates_len > 4); @@ -46,7 +37,7 @@ short rtllib_is_shortslot(struct rtllib_network net) * tag and the EXTENDED RATE MFIE tag if needed. * It encludes two bytes per tag for the tag itself and its len */ -unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) +static unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) { unsigned int rate_len = 0; @@ -64,7 +55,7 @@ unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee) * Then it updates the pointer so that * it points after the new MFIE tag added. */ -void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -82,7 +73,7 @@ void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p) *tag_p = tag; } -void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -103,7 +94,7 @@ void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p) *tag_p = tag; } -void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) +static void rtllib_WMM_Info(struct rtllib_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; @@ -137,7 +128,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p) printk(KERN_ALERT "This is enable turbo mode IE process\n"); } -void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) +static void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) { int nh; nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; @@ -154,7 +145,7 @@ void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb) } -struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) +static struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) { struct sk_buff *ret; @@ -169,7 +160,7 @@ struct sk_buff *dequeue_mgmt(struct rtllib_device *ieee) return ret; } -void init_mgmt_queue(struct rtllib_device *ieee) +static void init_mgmt_queue(struct rtllib_device *ieee) { ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } @@ -394,7 +385,7 @@ inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee); -void rtllib_send_beacon(struct rtllib_device *ieee) +static void rtllib_send_beacon(struct rtllib_device *ieee) { struct sk_buff *skb; if (!ieee->ieee_up) @@ -412,7 +403,7 @@ void rtllib_send_beacon(struct rtllib_device *ieee) } -void rtllib_send_beacon_cb(unsigned long _ieee) +static void rtllib_send_beacon_cb(unsigned long _ieee) { struct rtllib_device *ieee = (struct rtllib_device *) _ieee; @@ -500,7 +491,7 @@ void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, ieee->bNetPromiscuousMode = false; } -void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) +static void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh) { struct sk_buff *skb; skb = rtllib_probe_req(ieee); @@ -520,7 +511,7 @@ void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh) } } -void rtllib_softmac_hint11d_wq(void *data) +static void rtllib_softmac_hint11d_wq(void *data) { } @@ -602,7 +593,7 @@ out: wireless_send_event(ieee->dev, SIOCGIWSCAN, &wrqu, NULL); } -void rtllib_softmac_scan_wq(void *data) +static void rtllib_softmac_scan_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); @@ -662,7 +653,7 @@ out1: -void rtllib_beacons_start(struct rtllib_device *ieee) +static void rtllib_beacons_start(struct rtllib_device *ieee) { unsigned long flags; spin_lock_irqsave(&ieee->beacon_lock, flags); @@ -673,7 +664,7 @@ void rtllib_beacons_start(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->beacon_lock, flags); } -void rtllib_beacons_stop(struct rtllib_device *ieee) +static void rtllib_beacons_stop(struct rtllib_device *ieee) { unsigned long flags; @@ -705,7 +696,7 @@ void rtllib_start_send_beacons(struct rtllib_device *ieee) } -void rtllib_softmac_stop_scan(struct rtllib_device *ieee) +static void rtllib_softmac_stop_scan(struct rtllib_device *ieee) { down(&ieee->scan_sem); ieee->scan_watch_dog = 0; @@ -752,7 +743,7 @@ bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan) } /* called with ieee->lock held */ -void rtllib_start_scan(struct rtllib_device *ieee) +static void rtllib_start_scan(struct rtllib_device *ieee) { RT_TRACE(COMP_DBG, "===>%s()\n", __func__); if (ieee->rtllib_ips_leave_wq != NULL) @@ -831,24 +822,6 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon, return skb; } -void constructWMMIE(u8 *wmmie, u8 *wmm_len, u8 oui_subtype) -{ - u8 szQoSOUI[] = {221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1}; - - if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI) { - szQoSOUI[0] = 46; - szQoSOUI[1] = *wmm_len; - memcpy(wmmie, szQoSOUI, 3); - *wmm_len = 3; - } else { - szQoSOUI[1] = *wmm_len + 6; - szQoSOUI[6] = oui_subtype; - memcpy(wmmie, szQoSOUI, 8); - *(wmmie+8) = 0; - *wmm_len = 9; - } -} - static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) { u8 *tag; @@ -998,7 +971,7 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest) return skb; } -struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) +static struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *skb; u8 *tag; @@ -1057,7 +1030,7 @@ struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest) return skb; } -struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, +static struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, u8 *dest) { struct sk_buff *skb = NULL; @@ -1087,7 +1060,7 @@ struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status, } -struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) +static struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) { struct sk_buff *skb; struct rtllib_hdr_3addr *hdr; @@ -1114,7 +1087,7 @@ struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr) } -struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) +static struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) { struct sk_buff *skb; struct rtllib_pspoll_hdr *hdr; @@ -1139,7 +1112,7 @@ struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee) } -void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) +static void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_assoc_resp(ieee, dest); @@ -1148,7 +1121,7 @@ void rtllib_resp_to_assoc_rq(struct rtllib_device *ieee, u8 *dest) } -void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) +static void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) { struct sk_buff *buf = rtllib_auth_resp(ieee, s, dest); @@ -1157,7 +1130,7 @@ void rtllib_resp_to_auth(struct rtllib_device *ieee, int s, u8 *dest) } -void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest) +static void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest) { struct sk_buff *buf = rtllib_probe_resp(ieee, dest); @@ -1466,12 +1439,12 @@ void rtllib_associate_abort(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_associate_abort_cb(unsigned long dev) +static void rtllib_associate_abort_cb(unsigned long dev) { rtllib_associate_abort((struct rtllib_device *) dev); } -void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) +static void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) { struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; @@ -1495,7 +1468,7 @@ void rtllib_associate_step1(struct rtllib_device *ieee, u8 * daddr) } } -void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) +static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) { u8 *c; struct sk_buff *skb; @@ -1526,7 +1499,7 @@ void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen) kfree(challenge); } -void rtllib_associate_step2(struct rtllib_device *ieee) +static void rtllib_associate_step2(struct rtllib_device *ieee) { struct sk_buff *skb; struct rtllib_network *beacon = &ieee->current_network; @@ -1546,7 +1519,7 @@ void rtllib_associate_step2(struct rtllib_device *ieee) } #define CANCELLED 2 -void rtllib_associate_complete_wq(void *data) +static void rtllib_associate_complete_wq(void *data) { struct rtllib_device *ieee = (struct rtllib_device *) container_of_work_rsl(data, @@ -1606,7 +1579,7 @@ static void rtllib_sta_send_associnfo(struct rtllib_device *ieee) { } -void rtllib_associate_complete(struct rtllib_device *ieee) +static void rtllib_associate_complete(struct rtllib_device *ieee) { del_timer_sync(&ieee->associate_timer); @@ -1616,7 +1589,7 @@ void rtllib_associate_complete(struct rtllib_device *ieee) queue_work_rsl(ieee->wq, &ieee->associate_complete_wq); } -void rtllib_associate_procedure_wq(void *data) +static void rtllib_associate_procedure_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, @@ -1828,7 +1801,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) return cpu_to_le16(a->status); } -int auth_rq_parse(struct sk_buff *skb, u8 *dest) +static int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_authentication *a; @@ -1894,7 +1867,7 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb, return !strncmp(ssid, ieee->current_network.ssid, ssidlen); } -int assoc_rq_parse(struct sk_buff *skb, u8 *dest) +static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) { struct rtllib_assoc_request_frame *a; @@ -2075,7 +2048,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) } -inline void rtllib_sta_ps(struct rtllib_device *ieee) +static inline void rtllib_sta_ps(struct rtllib_device *ieee) { u64 time; short sleep; @@ -2196,7 +2169,7 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) +static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb) { struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data; u8 *act = rtllib_get_payload((struct rtllib_hdr *)header); @@ -2530,7 +2503,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) } /* called with ieee->lock acquired */ -void rtllib_resume_tx(struct rtllib_device *ieee) +static void rtllib_resume_tx(struct rtllib_device *ieee) { int i; for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; @@ -2675,7 +2648,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee) netif_carrier_on(ieee->dev); } -void rtllib_start_monitor_mode(struct rtllib_device *ieee) +static void rtllib_start_monitor_mode(struct rtllib_device *ieee) { /* reset hardware status */ if (ieee->raw_tx) { @@ -2686,7 +2659,7 @@ void rtllib_start_monitor_mode(struct rtllib_device *ieee) } } -void rtllib_start_ibss_wq(void *data) +static void rtllib_start_ibss_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, start_ibss_wq); @@ -2850,7 +2823,7 @@ void rtllib_start_bss(struct rtllib_device *ieee) spin_unlock_irqrestore(&ieee->lock, flags); } -void rtllib_link_change_wq(void *data) +static void rtllib_link_change_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, link_change_wq); @@ -2876,7 +2849,7 @@ void rtllib_disassociate(struct rtllib_device *ieee) notify_wx_assoc_event(ieee); } -void rtllib_associate_retry_wq(void *data) +static void rtllib_associate_retry_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, associate_retry_wq); @@ -3194,8 +3167,8 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value) } -void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, - int wpa_ie_len) +static void rtllib_wpa_assoc_frame(struct rtllib_device *ieee, char *wpa_ie, + int wpa_ie_len) { /* make sure WPA is enabled */ rtllib_wpa_enable(ieee, 1); @@ -3698,7 +3671,7 @@ void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, RemovePeerTS(rtllib, asSta); - if (memcpy(rtllib->current_network.bssid, asSta, 6) == 0) { + if (memcpy(rtllib->current_network.bssid, asSta, 6) == NULL) { rtllib->state = RTLLIB_NOLINK; for (i = 0; i < 6; i++) diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index f038aa930830..44e8006bc1af 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -220,8 +220,8 @@ void rtllib_txb_free(struct rtllib_txb *txb) kfree(txb); } -struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, - int gfp_mask) +static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, + gfp_t gfp_mask) { struct rtllib_txb *txb; int i; @@ -251,8 +251,7 @@ struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, return txb; } -int -rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) +static int rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) { struct ethhdr *eth; struct iphdr *ip; @@ -283,8 +282,9 @@ rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) } } -void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, struct sk_buff *skb, - struct cb_desc *tcb_desc) +static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, + struct sk_buff *skb, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct tx_ts_record *pTxTs = NULL; @@ -358,7 +358,7 @@ FORCED_AGG_SETTING: return; } -extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, +static void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { tcb_desc->bUseShortPreamble = false; @@ -370,7 +370,7 @@ extern void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, return; } -extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, +static void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -391,8 +391,8 @@ extern void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, tcb_desc->bUseShortGI = true; } -void rtllib_query_BandwidthMode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc) +static void rtllib_query_BandwidthMode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; @@ -412,8 +412,9 @@ void rtllib_query_BandwidthMode(struct rtllib_device *ieee, return; } -void rtllib_query_protectionmode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc, struct sk_buff *skb) +static void rtllib_query_protectionmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc, + struct sk_buff *skb) { tcb_desc->bRTSSTBC = false; tcb_desc->bRTSUseShortGI = false; @@ -494,8 +495,8 @@ NO_PROTECTION: } -void rtllib_txrate_selectmode(struct rtllib_device *ieee, - struct cb_desc *tcb_desc) +static void rtllib_txrate_selectmode(struct rtllib_device *ieee, + struct cb_desc *tcb_desc) { if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; From fec90b64dbbe6edbd11d12af2b8bc045790356e8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 12 Aug 2011 12:55:23 -0500 Subject: [PATCH 23/25] staging: rtl8192e: Fix sparse (non-endian) warnings - Part II Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/r8192E_cmdpkt.c | 10 +- drivers/staging/rtl8192e/r8192E_dev.c | 43 ++-- drivers/staging/rtl8192e/r8192E_firmware.c | 45 +--- drivers/staging/rtl8192e/r8192E_phy.c | 38 ++-- drivers/staging/rtl8192e/rtl_core.c | 144 ++++--------- drivers/staging/rtl8192e/rtl_core.h | 1 - drivers/staging/rtl8192e/rtl_dm.c | 237 ++------------------- drivers/staging/rtl8192e/rtl_eeprom.c | 11 +- drivers/staging/rtl8192e/rtl_ps.c | 7 +- drivers/staging/rtl8192e/rtl_wx.c | 10 +- drivers/staging/rtl8192e/rtllib_rx.c | 61 +++--- 11 files changed, 152 insertions(+), 455 deletions(-) diff --git a/drivers/staging/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/r8192E_cmdpkt.c index 881eb1f96d2c..09978b6428f1 100644 --- a/drivers/staging/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/r8192E_cmdpkt.c @@ -34,7 +34,7 @@ } /*---------------------------Define functions---------------------------------*/ -extern bool cmpk_message_handle_tx( +bool cmpk_message_handle_tx( struct net_device *dev, u8 *code_virtual_address, u32 packettype, @@ -167,7 +167,7 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) } /* cmpk_Handle_Tx_Feedback */ -void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) +static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u16 tx_rate; @@ -339,10 +339,8 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) } -extern u32 -cmpk_message_handle_rx( - struct net_device *dev, - struct rtllib_rx_stats *pstats) +u32 cmpk_message_handle_rx(struct net_device *dev, + struct rtllib_rx_stats *pstats) { struct r8192_priv *priv = rtllib_priv(dev); int total_length; diff --git a/drivers/staging/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/r8192E_dev.c index 229d6df789fd..899e4e5e98f3 100644 --- a/drivers/staging/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/r8192E_dev.c @@ -57,7 +57,7 @@ void rtl8192e_start_beacon(struct net_device *dev) rtl8192_irq_enable(dev); } -void rtl8192e_update_msr(struct net_device *dev) +static void rtl8192e_update_msr(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 msr; @@ -952,7 +952,7 @@ end: return rtStatus; } -void rtl8192_net_update(struct net_device *dev) +static void rtl8192_net_update(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1127,7 +1127,7 @@ static u8 MRateToHwRate8190Pci(u8 rate) return ret; } -u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) +static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority) { u8 QueueSelect = 0x0; @@ -1301,7 +1301,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device *dev, entry->OWN = 1; } -u8 HwRateToMRate90(bool bIsHT, u8 rate) +static u8 HwRateToMRate90(bool bIsHT, u8 rate) { u8 ret_rate = 0x02; @@ -1414,7 +1414,7 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate) return ret_rate; } -long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) +static long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) { long retsig; @@ -1450,7 +1450,7 @@ long rtl8192_signal_scale_mapping(struct r8192_priv *priv, long currsig) _pdrvinfo->RxRate == DESC90_RATE11M) &&\ !_pdrvinfo->RxHT) -void rtl8192_query_rxphystatus( +static void rtl8192_query_rxphystatus( struct r8192_priv *priv, struct rtllib_rx_stats *pstats, struct rx_desc *pdesc, @@ -1664,9 +1664,9 @@ void rtl8192_query_rxphystatus( } } -void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, - struct rtllib_rx_stats *prev_st, - struct rtllib_rx_stats *curr_st) +static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, + struct rtllib_rx_stats *prev_st, + struct rtllib_rx_stats *curr_st) { bool bcheck = false; u8 rfpath; @@ -1839,10 +1839,11 @@ void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, } } -void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, - struct rtllib_rx_stats *pstats, - struct rx_desc *pdesc, - struct rx_fwinfo *pdrvinfo) +static void rtl8192_TranslateRxSignalStuff(struct net_device *dev, + struct sk_buff *skb, + struct rtllib_rx_stats *pstats, + struct rx_desc *pdesc, + struct rx_fwinfo *pdrvinfo) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); bool bpacket_match_bssid, bpacket_toself; @@ -1867,7 +1868,7 @@ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, (fc & RTLLIB_FCTL_TODS) ? hdr->addr1 : (fc & RTLLIB_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV)); - bpacket_toself = bpacket_match_bssid & + bpacket_toself = bpacket_match_bssid && /* check this */ (!compare_ether_addr(praddr, priv->rtllib->dev->dev_addr)); if (WLAN_FC_GET_FRAMETYPE(fc) == RTLLIB_STYPE_BEACON) @@ -1883,7 +1884,8 @@ void rtl8192_TranslateRxSignalStuff(struct net_device *dev, struct sk_buff *skb, rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); } -void rtl8192_UpdateReceivedRateHistogramStatistics(struct net_device *dev, +static void rtl8192_UpdateReceivedRateHistogramStatistics( + struct net_device *dev, struct rtllib_rx_stats *pstats) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2255,17 +2257,6 @@ void rtl8192_enable_tx(struct net_device *dev) } -void rtl8192_beacon_disable(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - u32 reg; - - reg = read_nic_dword(priv->rtllib->dev, INTA_MASK); - - reg &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); - write_nic_dword(priv->rtllib->dev, INTA_MASK, reg); -} - void rtl8192_interrupt_recognized(struct net_device *dev, u32 *p_inta, u32 *p_intb) { diff --git a/drivers/staging/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/r8192E_firmware.c index c2689993530f..37719859bdae 100644 --- a/drivers/staging/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/r8192E_firmware.c @@ -23,7 +23,7 @@ #include "r8192E_firmware.h" #include -extern void firmware_init_param(struct net_device *dev) +void firmware_init_param(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_firmware *pfirmware = priv->pFirmware; @@ -32,8 +32,8 @@ extern void firmware_init_param(struct net_device *dev) MAX_TRANSMIT_BUFFER_SIZE); } -bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, - u32 buffer_len) +static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, + u32 buffer_len) { struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; @@ -102,42 +102,7 @@ bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, return rt_status; } -bool fwSendNullPacket(struct net_device *dev, u32 Length) -{ - bool rtStatus = true; - struct r8192_priv *priv = rtllib_priv(dev); - struct sk_buff *skb; - struct cb_desc *tcb_desc; - unsigned char *ptr_buf; - bool bLastInitPacket = false; - - - skb = dev_alloc_skb(Length + 4); - memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); - tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tcb_desc->queue_index = TXCMD_QUEUE; - tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; - tcb_desc->bLastIniPkt = bLastInitPacket; - ptr_buf = skb_put(skb, Length); - memset(ptr_buf, 0, Length); - tcb_desc->txbuf_size = (u16)Length; - - if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) || - (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc-> - queue_index])) || (priv->rtllib->queue_stop)) { - RT_TRACE(COMP_FIRMWARE, "===================NULL packet========" - "========> tx full!\n"); - skb_queue_tail(&priv->rtllib->skb_waitQ[tcb_desc->queue_index], - skb); - } else { - priv->rtllib->softmac_hard_start_xmit(skb, dev); - } - - write_nic_byte(dev, TPPoll, TPPoll_CQ); - return rtStatus; -} - -bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) +static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) { bool rt_status = true; u32 CPU_status = 0; @@ -184,7 +149,7 @@ CPUCheckMainCodeOKAndTurnOnCPU_Fail: return rt_status; } -bool CPUcheck_firmware_ready(struct net_device *dev) +static bool CPUcheck_firmware_ready(struct net_device *dev) { bool rt_status = true; diff --git a/drivers/staging/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/r8192E_phy.c index 96ccbd5b25d1..83e00d72199a 100644 --- a/drivers/staging/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/r8192E_phy.c @@ -53,7 +53,8 @@ static u32 phy_FwRFSerialRead(struct net_device *dev, static void phy_FwRFSerialWrite(struct net_device *dev, enum rf90_radio_path eRFPath, u32 Offset, u32 Data); -u32 rtl8192_CalculateBitShift(u32 dwBitMask) + +static u32 rtl8192_CalculateBitShift(u32 dwBitMask) { u32 i; for (i = 0; i <= 31; i++) { @@ -105,8 +106,8 @@ u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask) return Ret; } -u32 rtl8192_phy_RFSerialRead(struct net_device *dev, - enum rf90_radio_path eRFPath, u32 Offset) +static u32 rtl8192_phy_RFSerialRead(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset) { struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; @@ -161,9 +162,9 @@ u32 rtl8192_phy_RFSerialRead(struct net_device *dev, } -void rtl8192_phy_RFSerialWrite(struct net_device *dev, - enum rf90_radio_path eRFPath, u32 Offset, - u32 Data) +static void rtl8192_phy_RFSerialWrite(struct net_device *dev, + enum rf90_radio_path eRFPath, u32 Offset, + u32 Data) { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; @@ -400,7 +401,7 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType) return; } -void rtl8192_InitBBRFRegDef(struct net_device *dev) +static void rtl8192_InitBBRFRegDef(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -549,7 +550,7 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev, return ret; } -bool rtl8192_BB_Config_ParaFile(struct net_device *dev) +static bool rtl8192_BB_Config_ParaFile(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); bool rtStatus = true; @@ -790,7 +791,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, return ret; } -void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) +static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); u8 powerlevel = priv->TxPowerLevelCCK[channel-1]; @@ -815,9 +816,10 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) return; } -u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, - u32 CmdTableSz, enum sw_chnl_cmd_id CmdID, - u32 Para1, u32 Para2, u32 msDelay) +static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, + u32 CmdTableIdx, u32 CmdTableSz, + enum sw_chnl_cmd_id CmdID, + u32 Para1, u32 Para2, u32 msDelay) { struct sw_chnl_cmd *pCmd; @@ -843,8 +845,8 @@ u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable, u32 CmdTableIdx, return true; } -u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, - u8 *step, u32 *delay) +static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, + u8 *stage, u8 *step, u32 *delay) { struct r8192_priv *priv = rtllib_priv(dev); struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; @@ -983,7 +985,7 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, return false; } -void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) +static void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); u32 delay = 0; @@ -1410,8 +1412,8 @@ void PHY_SetRtl8192eRfOff(struct net_device *dev) } -bool SetRFPowerState8190(struct net_device *dev, - enum rt_rf_power_state eRFPowerState) +static bool SetRFPowerState8190(struct net_device *dev, + enum rt_rf_power_state eRFPowerState) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -1608,7 +1610,7 @@ bool SetRFPowerState(struct net_device *dev, return bResult; } -extern void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) +void PHY_ScanOperationBackup8192(struct net_device *dev, u8 Operation) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 68a4e858ecbc..9bc20f0ba399 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -58,10 +58,10 @@ int hwwep = 1; static int channels = 0x3fff; -char *ifname = "wlan%d"; +static char *ifname = "wlan%d"; -struct rtl819x_ops rtl819xp_ops = { +static struct rtl819x_ops rtl819xp_ops = { .nic_type = NIC_8192E, .get_eeprom_size = rtl8192_get_eeprom_size, .init_adapter_variable = rtl8192_InitializeVariables, @@ -108,7 +108,7 @@ static struct pci_driver rtl8192_pci_driver = { /**************************************************************************** -----------------------------IO STUFF------------------------- *****************************************************************************/ -bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) +static bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask) { bool bReturn = false; @@ -276,36 +276,36 @@ u32 read_nic_io_dword(struct net_device *dev, int x) u8 read_nic_byte(struct net_device *dev, int x) { - return 0xff & readb((u8 *)dev->mem_start + x); + return 0xff & readb((u8 __iomem *)dev->mem_start + x); } u32 read_nic_dword(struct net_device *dev, int x) { - return readl((u8 *)dev->mem_start + x); + return readl((u8 __iomem *)dev->mem_start + x); } u16 read_nic_word(struct net_device *dev, int x) { - return readw((u8 *)dev->mem_start + x); + return readw((u8 __iomem *)dev->mem_start + x); } void write_nic_byte(struct net_device *dev, int x, u8 y) { - writeb(y, (u8 *)dev->mem_start + x); + writeb(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } void write_nic_dword(struct net_device *dev, int x, u32 y) { - writel(y, (u8 *)dev->mem_start + x); + writel(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } void write_nic_word(struct net_device *dev, int x, u16 y) { - writew(y, (u8 *)dev->mem_start + x); + writew(y, (u8 __iomem *)dev->mem_start + x); udelay(20); } @@ -452,7 +452,7 @@ bool MgntActSet_RF_State(struct net_device *dev, } -short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) +static short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; @@ -467,7 +467,7 @@ short rtl8192_get_nic_desc_num(struct net_device *dev, int prio) return skb_queue_len(&ring->queue); } -short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) +static short rtl8192_check_nic_enough_desc(struct net_device *dev, int prio) { struct r8192_priv *priv = rtllib_priv(dev); struct rtl8192_tx_ring *ring = &priv->tx_ring[prio]; @@ -502,14 +502,6 @@ void rtl8192_irq_disable(struct net_device *dev) priv->irq_enabled = 0; } -void rtl8192_irq_clear(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - - priv->ops->irq_clear(dev); -} - - void rtl8192_set_chan(struct net_device *dev, short ch) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -579,7 +571,7 @@ static struct rtllib_qos_parameters def_qos_parameters = { {0, 0, 0, 0} }; -void rtl8192_update_beacon(void *data) +static void rtl8192_update_beacon(void *data) { struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, update_beacon_wq.work); @@ -598,7 +590,7 @@ void rtl8192_update_beacon(void *data) #define MOVE_INTO_HANDLER int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; -void rtl8192_qos_activate(void *data) +static void rtl8192_qos_activate(void *data) { struct r8192_priv *priv = container_of_work_rsl(data, struct r8192_priv, qos_activate); @@ -758,7 +750,7 @@ static int rtl8192_handle_assoc_response(struct net_device *dev, return 0; } -void rtl8192_prepare_beacon(struct r8192_priv *priv) +static void rtl8192_prepare_beacon(struct r8192_priv *priv) { struct net_device *dev = priv->rtllib->dev; struct sk_buff *pskb = NULL, *pnewskb = NULL; @@ -791,7 +783,7 @@ void rtl8192_prepare_beacon(struct r8192_priv *priv) return; } -void rtl8192_stop_beacon(struct net_device *dev) +static void rtl8192_stop_beacon(struct net_device *dev) { } @@ -887,7 +879,7 @@ void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) } } -void rtl8192_refresh_supportrate(struct r8192_priv *priv) +static void rtl8192_refresh_supportrate(struct r8192_priv *priv) { struct rtllib_device *ieee = priv->rtllib; if (ieee->mode == WIRELESS_MODE_N_24G || @@ -903,7 +895,7 @@ void rtl8192_refresh_supportrate(struct r8192_priv *priv) return; } -u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) +static u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 ret = 0; @@ -973,7 +965,7 @@ void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) rtl8192_refresh_supportrate(priv); } -int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) +static int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -1016,7 +1008,7 @@ int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset) return 0; } -int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) +static int rtl8192_sta_down(struct net_device *dev, bool shutdownrf) { struct r8192_priv *priv = rtllib_priv(dev); unsigned long flags = 0; @@ -1243,9 +1235,10 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->card_type = PCI; priv->AcmControl = 0; - priv->pFirmware = vmalloc(sizeof(struct rt_firmware)); - if (priv->pFirmware) - memset(priv->pFirmware, 0, sizeof(struct rt_firmware)); + priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); + if (!priv->pFirmware) + printk(KERN_ERR "rtl8193e: Unable to allocate space " + "for firmware\n"); skb_queue_head_init(&priv->rx_queue); skb_queue_head_init(&priv->skb_queue); @@ -1302,7 +1295,7 @@ static void rtl8192_init_priv_task(struct net_device *dev) (unsigned long)priv); } -short rtl8192_get_channel_map(struct net_device *dev) +static short rtl8192_get_channel_map(struct net_device *dev) { int i; @@ -1330,7 +1323,7 @@ short rtl8192_get_channel_map(struct net_device *dev) return 0; } -short rtl8192_init(struct net_device *dev) +static short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1395,7 +1388,7 @@ short rtl8192_is_tx_queue_empty(struct net_device *dev) return 1; } -enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) +static enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 QueueID; @@ -1454,7 +1447,7 @@ enum reset_type rtl819x_TxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) +static enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1466,8 +1459,7 @@ enum reset_type rtl819x_RxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } -enum reset_type -rtl819x_ifcheck_resetornot(struct net_device *dev) +static enum reset_type rtl819x_ifcheck_resetornot(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); enum reset_type TxResetType = RESET_TYPE_NORESET; @@ -1500,11 +1492,11 @@ rtl819x_ifcheck_resetornot(struct net_device *dev) } -void rtl819x_silentreset_mesh_bk(struct net_device *dev, u8 IsPortal) +static void rtl819x_silentreset_mesh_bk(struct net_device *dev, u8 IsPortal) { } -void rtl819x_ifsilentreset(struct net_device *dev) +static void rtl819x_ifsilentreset(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u8 reset_times = 0; @@ -1643,8 +1635,8 @@ END: } } -void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, - u32 *TotalRxDataNum) +static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, + u32 *TotalRxDataNum) { u16 SlotIndex; u8 i; @@ -1975,7 +1967,7 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } -void rtl8192_tx_isr(struct net_device *dev, int prio) +static void rtl8192_tx_isr(struct net_device *dev, int prio) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); @@ -2103,7 +2095,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) return 0; } -short rtl8192_alloc_rx_desc_ring(struct net_device *dev) +static short rtl8192_alloc_rx_desc_ring(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rx_desc *entry = NULL; @@ -2341,7 +2333,7 @@ rtl8192_record_rxdesc_forlateruse( -void rtl8192_rx_normal(struct net_device *dev) +static void rtl8192_rx_normal(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_hdr_1addr *rtllib_hdr = NULL; @@ -2446,12 +2438,12 @@ done: } -void rtl8192_rx_cmd(struct net_device *dev) +static void rtl8192_rx_cmd(struct net_device *dev) { } -void rtl8192_tx_resume(struct net_device *dev) +static void rtl8192_tx_resume(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; @@ -2504,7 +2496,7 @@ int _rtl8192_up(struct net_device *dev, bool is_silent_reset) } -int rtl8192_open(struct net_device *dev) +static int rtl8192_open(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -2527,7 +2519,7 @@ int rtl8192_up(struct net_device *dev) } -int rtl8192_close(struct net_device *dev) +static int rtl8192_close(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); int ret; @@ -2591,7 +2583,7 @@ static void r8192_set_multicast(struct net_device *dev) } -int r8192_set_mac_adr(struct net_device *dev, void *mac) +static int r8192_set_mac_adr(struct net_device *dev, void *mac) { struct r8192_priv *priv = rtllib_priv(dev); struct sockaddr *addr = mac; @@ -2607,7 +2599,7 @@ int r8192_set_mac_adr(struct net_device *dev, void *mac) } /* based on ipw2200 driver */ -int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); struct iwreq *wrq = (struct iwreq *)rq; @@ -2731,56 +2723,6 @@ out: return ret; } -void FairBeacon(struct net_device *dev) -{ - struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); - struct rtllib_network *net = &priv->rtllib->current_network; - static u8 i = 100; - static u8 forceturn; - u16 beaconint = net->beacon_interval; - - if (priv->rtllib->iw_mode != IW_MODE_ADHOC) - return; - - if (priv->bIbssCoordinator) { - i--; - - if (forceturn == 2) { - forceturn = 0; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - i = 100; - } - - if (i <= 94) { - beaconint = beaconint+2; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - forceturn = 1; - } - } else { - i++; - - if (forceturn == 1) { - forceturn = 0; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - i = 100; - } - - if (i >= 106) { - beaconint = beaconint-2; - priv->rtllib->SetHwRegHandler(dev, - HW_VAR_BEACON_INTERVAL, - (u8 *)(&beaconint)); - forceturn = 2; - } - } -} - irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) { @@ -3077,7 +3019,7 @@ fail: if (dev) { if (priv->irq) { free_irq(dev->irq, dev); - dev->irq = 0; + priv->irq = 0; } free_rtllib(dev); } @@ -3127,7 +3069,7 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev) kfree(priv->scan_cmd); if (dev->mem_start != 0) { - iounmap((void *)dev->mem_start); + iounmap((void __iomem *)dev->mem_start); release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); } diff --git a/drivers/staging/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl_core.h index 03a86fe283c0..5b78530bf220 100644 --- a/drivers/staging/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl_core.h @@ -1110,7 +1110,6 @@ void rtl819x_process_cck_rxpathsel(struct r8192_priv *priv, u8 rtl819x_query_rxpwrpercentage(char antpower); void rtl8192_record_rxdesc_forlateruse(struct rtllib_rx_stats *psrc_stats, struct rtllib_rx_stats *ptarget_stats); - bool NicIFEnableNIC(struct net_device *dev); bool NicIFDisableNIC(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl_dm.c index 6d201ec38276..a7fa9aad6f2d 100644 --- a/drivers/staging/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl_dm.c @@ -134,8 +134,7 @@ static void dm_send_rssi_tofw(struct net_device *dev); static void dm_ctstoself(struct net_device *dev); /*---------------------------Define function prototype------------------------*/ -extern void -init_hal_dm(struct net_device *dev) +void init_hal_dm(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); priv->DM_Type = DM_Type_ByDriver; @@ -158,14 +157,14 @@ init_hal_dm(struct net_device *dev) INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev); } -extern void deinit_hal_dm(struct net_device *dev) +void deinit_hal_dm(struct net_device *dev) { dm_deInit_fsync(dev); } -extern void hal_dm_watchdog(struct net_device *dev) +void hal_dm_watchdog(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->being_init_adapter) @@ -191,7 +190,7 @@ extern void hal_dm_watchdog(struct net_device *dev) dm_ctstoself(dev); } -void dm_check_ac_dc_power(struct net_device *dev) +static void dm_check_ac_dc_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh"; @@ -215,7 +214,7 @@ void dm_check_ac_dc_power(struct net_device *dev) }; -extern void init_rate_adaptive(struct net_device *dev) +void init_rate_adaptive(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1528,10 +1527,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH } } -extern void dm_cck_txpower_adjust( - struct net_device *dev, - bool binch14 -) +void dm_cck_txpower_adjust(struct net_device *dev, bool binch14) { struct r8192_priv *priv = rtllib_priv(dev); if (priv->IC_Cut >= IC_VersionCut_D) @@ -1540,9 +1536,7 @@ extern void dm_cck_txpower_adjust( dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); } -static void dm_txpower_reset_recovery( - struct net_device *dev -) +static void dm_txpower_reset_recovery(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1570,7 +1564,7 @@ static void dm_txpower_reset_recovery( } -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev) +void dm_restore_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); u32 reg_ratr = priv->rate_adaptive.last_ratr; @@ -1624,7 +1618,7 @@ static void dm_bb_initialgain_restore(struct net_device *dev) } -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev) +void dm_backup_dynamic_mechanism_state(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -1659,8 +1653,8 @@ static void dm_bb_initialgain_backup(struct net_device *dev) } -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, u32 dm_value) +void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, u32 dm_value) { if (dm_type == DIG_TYPE_THRESH_HIGH) { dm_digtable.rssi_high_thresh = dm_value; @@ -1704,75 +1698,6 @@ extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, dm_digtable.rx_gain_range_max = (u8)dm_value; } } -extern void dm_change_fsync_setting(struct net_device *dev, - s32 DM_Type, - s32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv(dev); - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - priv->framesyncMonitor = (u8)DM_Value; - } -} - -extern void -dm_change_rxpath_selection_setting( - struct net_device *dev, - s32 DM_Type, - s32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv(dev); - struct rate_adaptive *pRA = (struct rate_adaptive *)&(priv->rate_adaptive); - - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.Enable = (u8)DM_Value; - } else if (DM_Type == 1) { - if (DM_Value > 1) - DM_Value = 1; - DM_RxPathSelTable.DbgMode = (u8)DM_Value; - } else if (DM_Type == 2) { - if (DM_Value > 40) - DM_Value = 40; - DM_RxPathSelTable.SS_TH_low = (u8)DM_Value; - } else if (DM_Type == 3) { - if (DM_Value > 25) - DM_Value = 25; - DM_RxPathSelTable.diff_TH = (u8)DM_Value; - } else if (DM_Type == 4) { - if (DM_Value >= CCK_Rx_Version_MAX) - DM_Value = CCK_Rx_Version_1; - DM_RxPathSelTable.cck_method = (u8)DM_Value; - } else if (DM_Type == 10) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value; - } else if (DM_Type == 11) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value; - } else if (DM_Type == 12) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value; - } else if (DM_Type == 13) { - if (DM_Value > 100) - DM_Value = 50; - DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value; - } else if (DM_Type == 20) { - if (DM_Value > 1) - DM_Value = 1; - pRA->ping_rssi_enable = (u8)DM_Value; - } else if (DM_Type == 21) { - if (DM_Value > 30) - DM_Value = 30; - pRA->ping_rssi_thresh_for_ra = DM_Value; - } -} static void dm_dig_init(struct net_device *dev) { @@ -1814,37 +1739,6 @@ static void dm_dig_init(struct net_device *dev) dm_digtable.BackoffVal_range_min = DM_DIG_BACKOFF_MIN; } -void dm_FalseAlarmCounterStatistics(struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u32 ret_value; - struct false_alarm_stats *FalseAlmCnt = &(priv->FalseAlmCnt); - - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter1, bMaskDWord); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); - - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter2, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); - FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); - ret_value = rtl8192_QueryBBReg(dev, rOFDM_PHYCounter3, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); - - FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail; - - ret_value = rtl8192_QueryBBReg(dev, 0xc64, bMaskDWord); - FalseAlmCnt->Cnt_Cck_fail = (ret_value&0xffff); - FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Parity_Fail + - FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + - FalseAlmCnt->Cnt_Mcs_fail + - FalseAlmCnt->Cnt_Cck_fail); - - RT_TRACE(COMP_DIG, "Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d, Cnt_all = %d\n", - FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_Cck_fail, - FalseAlmCnt->Cnt_all); -} - static void dm_ctrl_initgain_byrssi(struct net_device *dev) { @@ -2099,91 +1993,6 @@ static void dm_initial_gain(struct net_device *dev) } } -void dm_initial_gain_STABeforeConnect( - struct net_device *dev) -{ - struct r8192_priv *priv = rtllib_priv(dev); - u8 initial_gain = 0; - static u8 initialized, force_write; - - RT_TRACE(COMP_DIG, "PreSTAConnectState = %x, CurSTAConnectState = %x\n", - dm_digtable.PreSTAConnectState, dm_digtable.CurSTAConnectState); - - - if ((dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) || - (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT)) { - if (dm_digtable.CurSTAConnectState == DIG_STA_BEFORE_CONNECT) { - if (priv->rtllib->eRFPowerState != eRfOn) - return; - - if (dm_digtable.Backoff_Enable_Flag == true) { - if (priv->FalseAlmCnt.Cnt_all > dm_digtable.FAHighThresh) { - if ((dm_digtable.backoff_val - 6) < dm_digtable.BackoffVal_range_min) - dm_digtable.backoff_val = dm_digtable.BackoffVal_range_min; - else - dm_digtable.backoff_val -= 6; - } else if (priv->FalseAlmCnt.Cnt_all < dm_digtable.FALowThresh) { - if ((dm_digtable.backoff_val + 6) > dm_digtable.BackoffVal_range_max) - dm_digtable.backoff_val = dm_digtable.BackoffVal_range_max; - else - dm_digtable.backoff_val += 6; - } - } else - dm_digtable.backoff_val = DM_DIG_BACKOFF; - - if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min; - else - dm_digtable.cur_ig_value = dm_digtable.rssi_val + 10 - - dm_digtable.backoff_val; - - if (priv->FalseAlmCnt.Cnt_all > 10000) - dm_digtable.cur_ig_value = (dm_digtable.cur_ig_value > 0x33) ? - dm_digtable.cur_ig_value : 0x33; - - if (priv->FalseAlmCnt.Cnt_all > 16000) - dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max; - - } else { - return; - } - } else { - dm_digtable.Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX; - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_ENABLE); - - dm_digtable.backoff_val = DM_DIG_BACKOFF; - dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; - dm_digtable.pre_ig_value = 0; - return; - } - - if (dm_digtable.pre_ig_value != rtl8192_QueryBBReg(dev, - rOFDM0_XAAGCCore1, bMaskByte0)) - force_write = 1; - - if ((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value) || - !initialized || force_write) { - priv->rtllib->SetFwCmdHandler(dev, FW_CMD_DIG_DISABLE); - - initial_gain = (u8)dm_digtable.cur_ig_value; - - rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, - initial_gain); - rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, - initial_gain); - dm_digtable.pre_ig_value = dm_digtable.cur_ig_value; - initialized = 1; - force_write = 0; - } - - RT_TRACE(COMP_DIG, "CurIGValue = 0x%x, pre_ig_value = 0x%x, " - "backoff_val = %d\n", dm_digtable.cur_ig_value, - dm_digtable.pre_ig_value, dm_digtable.backoff_val); - -} - static void dm_pd_th(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2287,7 +2096,7 @@ static void dm_cs_ratio(struct net_device *dev) } } -extern void dm_init_edca_turbo(struct net_device *dev) +void dm_init_edca_turbo(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); @@ -2390,22 +2199,6 @@ dm_CheckEdcaTurbo_EXIT: lastRxOkCnt = priv->stats.rxbytesunicast; } -extern void DM_CTSToSelfSetting(struct net_device *dev, u32 DM_Type, - u32 DM_Value) -{ - struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); - - if (DM_Type == 0) { - if (DM_Value > 1) - DM_Value = 1; - priv->rtllib->bCTSToSelfEnable = (bool)DM_Value; - } else if (DM_Type == 1) { - if (DM_Value >= 50) - DM_Value = 50; - priv->rtllib->CTSToSelfTH = (u8)DM_Value; - } -} - static void dm_init_ctstoself(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv((struct net_device *)dev); @@ -2454,7 +2247,7 @@ static void dm_check_pbc_gpio(struct net_device *dev) { } -extern void dm_CheckRfCtrlGPIO(void *data) +void dm_CheckRfCtrlGPIO(void *data) { struct r8192_priv *priv = container_of_dwork_rsl(data, struct r8192_priv, gpio_change_rf_wq); @@ -2791,7 +2584,7 @@ static void dm_deInit_fsync(struct net_device *dev) del_timer_sync(&priv->fsync_timer); } -extern void dm_fsync_timer_callback(unsigned long data) +void dm_fsync_timer_callback(unsigned long data) { struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = rtllib_priv((struct net_device *)data); @@ -3091,7 +2884,7 @@ void dm_check_fsync(struct net_device *dev) } } -extern void dm_shadow_init(struct net_device *dev) +void dm_shadow_init(struct net_device *dev) { u8 page; u16 offset; diff --git a/drivers/staging/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl_eeprom.c index df72a6007d08..c1ccff4a8321 100644 --- a/drivers/staging/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl_eeprom.c @@ -25,7 +25,7 @@ #include "rtl_core.h" #include "rtl_eeprom.h" -void eprom_cs(struct net_device *dev, short bit) +static void eprom_cs(struct net_device *dev, short bit) { if (bit) write_nic_byte(dev, EPROM_CMD, @@ -39,7 +39,7 @@ void eprom_cs(struct net_device *dev, short bit) } -void eprom_ck_cycle(struct net_device *dev) +static void eprom_ck_cycle(struct net_device *dev) { write_nic_byte(dev, EPROM_CMD, (1<ps_lock, flags); } -void InactivePsWorkItemCallback(struct net_device *dev) +static void InactivePsWorkItemCallback(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *) @@ -214,7 +214,8 @@ void rtllib_ips_leave(struct net_device *dev) up(&priv->rtllib->ips_sem); } -bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, u8 rtPsMode) +static bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev, + u8 rtPsMode) { struct r8192_priv *priv = rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl_wx.c index f869ce3dbec0..77ea4bb8c7a1 100644 --- a/drivers/staging/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl_wx.c @@ -22,7 +22,7 @@ #include "dot11d.h" #define RATE_COUNT 12 -u32 rtl8192_rates[] = { +static u32 rtl8192_rates[] = { 1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000 }; @@ -198,9 +198,9 @@ struct adhoc_peers_info { unsigned char num; }; -int r8192_wx_get_adhoc_peers(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int r8192_wx_get_adhoc_peers(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -1293,7 +1293,7 @@ static iw_handler r8192_private_handler[] = { (iw_handler)r8192_wx_get_PromiscuousMode, }; -struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) +static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 35f70d6fe2eb..745ae0861dfa 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -442,15 +442,20 @@ drop: return 1; } -bool AddReorderEntry(struct rx_ts_record *pTS, struct rx_reorder_entry *pReorderEntry) +static bool AddReorderEntry(struct rx_ts_record *pTS, + struct rx_reorder_entry *pReorderEntry) { struct list_head *pList = &pTS->RxPendingPktList; while (pList->next != &pTS->RxPendingPktList) { - if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) + if (SN_LESS(pReorderEntry->SeqNum, ((struct rx_reorder_entry *) + list_entry(pList->next, struct rx_reorder_entry, + List))->SeqNum)) pList = pList->next; - else if (SN_EQUAL(pReorderEntry->SeqNum, ((struct rx_reorder_entry *)list_entry(pList->next, struct rx_reorder_entry, List))->SeqNum)) - return false; + else if (SN_EQUAL(pReorderEntry->SeqNum, + ((struct rx_reorder_entry *)list_entry(pList->next, + struct rx_reorder_entry, List))->SeqNum)) + return false; else break; } @@ -539,8 +544,9 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record pTS->RxIndicateSeq = 0xffff; } -void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb, - struct rx_ts_record *pTS, u16 SeqNum) +static void RxReorderIndicatePacket(struct rtllib_device *ieee, + struct rtllib_rxb *prxb, + struct rx_ts_record *pTS, u16 SeqNum) { struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; struct rx_reorder_entry *pReorderEntry = NULL; @@ -728,9 +734,9 @@ void RxReorderIndicatePacket(struct rtllib_device *ieee, struct rtllib_rxb *prxb spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); } -u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats, - struct rtllib_rxb *rxb, u8 *src, u8 *dst) +static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats, + struct rtllib_rxb *rxb, u8 *src, u8 *dst) { struct rtllib_hdr_3addr *hdr = (struct rtllib_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -853,8 +859,9 @@ u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, } -size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, - struct rtllib_rx_stats *rx_stats) +static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, + struct sk_buff *skb, + struct rtllib_rx_stats *rx_stats) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -874,8 +881,8 @@ size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee, struct sk_buff *skb, return hdrlen; } -int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, - u8 multicast) +static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, + struct sk_buff *skb, u8 multicast) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; u16 fc, sc; @@ -916,9 +923,9 @@ int rtllib_rx_check_duplicate(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -void rtllib_rx_extract_addr(struct rtllib_device *ieee, - struct rtllib_hdr_4addr *hdr, u8 *dst, u8 *src, - u8 *bssid) +static void rtllib_rx_extract_addr(struct rtllib_device *ieee, + struct rtllib_hdr_4addr *hdr, u8 *dst, + u8 *src, u8 *bssid) { u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -946,8 +953,8 @@ void rtllib_rx_extract_addr(struct rtllib_device *ieee, } } -int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, - u8 *bssid, u8 *addr2) +static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, + u8 *dst, u8 *src, u8 *bssid, u8 *addr2) { u8 zero_addr[ETH_ALEN] = {0}; u8 type, stype; @@ -1004,7 +1011,7 @@ int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc, u8 *dst, u8 *src, return 0; } -int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_crypt_data **crypt, size_t hdrlen) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; @@ -1038,7 +1045,7 @@ int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats, struct rtllib_crypt_data *crypt, size_t hdrlen) { @@ -1168,7 +1175,7 @@ int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) +static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes) { if (unicast) { @@ -1184,7 +1191,7 @@ void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_sub ieee->last_rx_ps_time = jiffies; } -void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, +static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, struct rtllib_rx_stats *rx_stats, struct rtllib_rxb *rxb, u8 *dst, @@ -1243,7 +1250,7 @@ void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee, rxb = NULL; } -int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; @@ -1412,13 +1419,13 @@ int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, return 0; } -int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Master(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { return 0; } -int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data; @@ -1443,7 +1450,7 @@ int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, return 1; } -int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, +static int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb, struct rtllib_rx_stats *rx_stats) { return 0; @@ -2223,7 +2230,7 @@ static inline u8 rtllib_SignalStrengthTranslate(u8 CurrSS) return RetSS; } -long rtllib_translate_todbm(u8 signal_strength_index) +static long rtllib_translate_todbm(u8 signal_strength_index) { long signal_power; From c73298e6c45a336d813d613dc535b56964e3f55f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 12 Aug 2011 15:42:43 -0500 Subject: [PATCH 24/25] staging: rtl8192e: Add endian checking switch to Makefile Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index fb007491c5fa..a66a9ad33686 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -38,3 +38,4 @@ r8192e_pci-objs := \ obj-$(CONFIG_RTL8192E) += r8192e_pci.o +ccflags-y += -D__CHECK_ENDIAN__ From faae60d232df564ee5e88237fd816a6d3719a8c0 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Thu, 25 Aug 2011 15:02:09 +1000 Subject: [PATCH 25/25] rtl8192e: update for ndo_set_multicast_list removal. After merging the staging tree, today's linux-next build (x86_64 allmodconfig) failed like this: drivers/staging/rtl8192e/rtl_core.c:2917:2: error: unknown field 'ndo_set_multicast_list' specified in initializer Caused by commit 94a799425eee ("From: wlanfae " - really "[PATCH 1/8] rtl8192e: Import new version of driver from realtek" Signed-off-by: Stephen Rothwell Signed-off-by: Larry Finger --- drivers/staging/rtl8192e/rtl_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl_core.c index 9bc20f0ba399..2d7bb511c3c1 100644 --- a/drivers/staging/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl_core.c @@ -2867,7 +2867,7 @@ static const struct net_device_ops rtl8192_netdev_ops = { .ndo_stop = rtl8192_close, .ndo_tx_timeout = rtl8192_tx_timeout, .ndo_do_ioctl = rtl8192_ioctl, - .ndo_set_multicast_list = r8192_set_multicast, + .ndo_set_rx_mode = r8192_set_multicast, .ndo_set_mac_address = r8192_set_mac_adr, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = eth_change_mtu,