Staging: rtl8192su: refactored EnableHWSecurityConfig8192 and setKey
refactored EnableHWSecurityConfig8192 and setKey a bit by replacing if...else if... else with switch...case plus cosmetics Signed-off-by: Florian Schilhabel <florian.c.schilhabel@googlemail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
33f84a8f21
commit
8dbe821edf
@@ -7612,96 +7612,113 @@ void rtl8192_try_wake_queue(struct net_device *dev, int pri)
|
|||||||
|
|
||||||
void EnableHWSecurityConfig8192(struct net_device *dev)
|
void EnableHWSecurityConfig8192(struct net_device *dev)
|
||||||
{
|
{
|
||||||
u8 SECR_value = 0x0;
|
u8 SECR_value = 0x0;
|
||||||
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
|
||||||
struct ieee80211_device* ieee = priv->ieee80211;
|
struct ieee80211_device *ieee = priv->ieee80211;
|
||||||
|
|
||||||
SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
|
SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
|
||||||
#if 1
|
switch (ieee->pairwise_key_type) {
|
||||||
if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2))
|
case KEY_TYPE_WEP40:
|
||||||
{
|
case KEY_TYPE_WEP104:
|
||||||
SECR_value |= SCR_RxUseDK;
|
if (priv->ieee80211->auth_mode != 2) {
|
||||||
SECR_value |= SCR_TxUseDK;
|
SECR_value |= SCR_RxUseDK;
|
||||||
|
SECR_value |= SCR_TxUseDK;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KEY_TYPE_TKIP:
|
||||||
|
case KEY_TYPE_CCMP:
|
||||||
|
if (ieee->iw_mode == IW_MODE_ADHOC) {
|
||||||
|
SECR_value |= SCR_RxUseDK;
|
||||||
|
SECR_value |= SCR_TxUseDK;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//add HWSec active enable here.
|
|
||||||
//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* add HWSec active enable here.
|
||||||
|
* default using hwsec.
|
||||||
|
* when peer AP is in N mode only and pairwise_key_type is none_aes
|
||||||
|
* (which HT_IOT_ACT_PURE_N_MODE indicates it),
|
||||||
|
* use software security.
|
||||||
|
* when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes
|
||||||
|
* use g mode hw security.
|
||||||
|
*/
|
||||||
ieee->hwsec_active = 1;
|
ieee->hwsec_active = 1;
|
||||||
|
|
||||||
if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off
|
/* add hwsec_support flag to totol control hw_sec on/off */
|
||||||
{
|
if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) {
|
||||||
ieee->hwsec_active = 0;
|
ieee->hwsec_active = 0;
|
||||||
SECR_value &= ~SCR_RxDecEnable;
|
SECR_value &= ~SCR_RxDecEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, \
|
RT_TRACE(COMP_SEC, "%s(): hwsec: %d, pairwise_key: %d, "
|
||||||
ieee->hwsec_active, ieee->pairwise_key_type, SECR_value);
|
"SECR_value: %x",
|
||||||
{
|
__func__, ieee->hwsec_active,
|
||||||
write_nic_byte(dev, SECR, SECR_value);//SECR_value | SCR_UseDK );
|
ieee->pairwise_key_type, SECR_value);
|
||||||
}
|
|
||||||
|
write_nic_byte(dev, SECR, SECR_value); /* SECR_value | SCR_UseDK ); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setKey( struct net_device *dev,
|
void setKey(struct net_device *dev,
|
||||||
u8 EntryNo,
|
u8 EntryNo,
|
||||||
u8 KeyIndex,
|
u8 KeyIndex,
|
||||||
u16 KeyType,
|
u16 KeyType,
|
||||||
u8 *MacAddr,
|
u8 *MacAddr,
|
||||||
u8 DefaultKey,
|
u8 DefaultKey,
|
||||||
u32 *KeyContent )
|
u32 *KeyContent)
|
||||||
{
|
{
|
||||||
u32 TargetCommand = 0;
|
u32 TargetCommand = 0;
|
||||||
u32 TargetContent = 0;
|
u32 TargetContent = 0;
|
||||||
u16 usConfig = 0;
|
u16 usConfig = 0;
|
||||||
u8 i;
|
u8 i;
|
||||||
if (EntryNo >= TOTAL_CAM_ENTRY)
|
|
||||||
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%pM\n", dev,EntryNo, KeyIndex, KeyType, MacAddr);
|
if (EntryNo >= TOTAL_CAM_ENTRY)
|
||||||
|
RT_TRACE(COMP_ERR, "%s(): cam entry exceeds TOTAL_CAM_ENTRY",
|
||||||
|
__func__);
|
||||||
|
|
||||||
|
RT_TRACE(COMP_SEC, "%s(): dev: %p, EntryNo: %d, "
|
||||||
|
"KeyIndex: %d, KeyType: %d, MacAddr: %pM",
|
||||||
|
__func__, dev, EntryNo,
|
||||||
|
KeyIndex, KeyType, MacAddr);
|
||||||
|
|
||||||
if (DefaultKey)
|
if (DefaultKey)
|
||||||
usConfig |= BIT15 | (KeyType<<2);
|
usConfig |= BIT15 | (KeyType << 2);
|
||||||
else
|
else
|
||||||
usConfig |= BIT15 | (KeyType<<2) | KeyIndex;
|
usConfig |= BIT15 | (KeyType << 2) | KeyIndex;
|
||||||
// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex;
|
|
||||||
|
|
||||||
|
for (i = 0 ; i < CAM_CONTENT_COUNT; i++) {
|
||||||
for(i=0 ; i<CAM_CONTENT_COUNT; i++){
|
TargetCommand = i + CAM_CONTENT_COUNT * EntryNo;
|
||||||
TargetCommand = i+CAM_CONTENT_COUNT*EntryNo;
|
|
||||||
TargetCommand |= BIT31|BIT16;
|
TargetCommand |= BIT31|BIT16;
|
||||||
|
switch (i) {
|
||||||
if(i==0){//MAC|Config
|
case 0: /* MAC|Config */
|
||||||
TargetContent = (u32)(*(MacAddr+0)) << 16|
|
TargetContent = (u32)(*(MacAddr + 0)) << 16|
|
||||||
(u32)(*(MacAddr+1)) << 24|
|
(u32)(*(MacAddr + 1)) << 24|
|
||||||
(u32)usConfig;
|
(u32)usConfig;
|
||||||
|
|
||||||
write_nic_dword(dev, WCAMI, TargetContent);
|
write_nic_dword(dev, WCAMI, TargetContent);
|
||||||
write_nic_dword(dev, RWCAM, TargetCommand);
|
write_nic_dword(dev, RWCAM, TargetCommand);
|
||||||
// printk("setkey cam =%8x\n", read_cam(dev, i+6*EntryNo));
|
continue;
|
||||||
}
|
case 1: /* MAC */
|
||||||
else if(i==1){//MAC
|
TargetContent = (u32)(*(MacAddr + 2))|
|
||||||
TargetContent = (u32)(*(MacAddr+2)) |
|
(u32)(*(MacAddr + 3)) << 8|
|
||||||
(u32)(*(MacAddr+3)) << 8|
|
(u32)(*(MacAddr + 4)) << 16|
|
||||||
(u32)(*(MacAddr+4)) << 16|
|
(u32)(*(MacAddr + 5)) << 24;
|
||||||
(u32)(*(MacAddr+5)) << 24;
|
|
||||||
write_nic_dword(dev, WCAMI, TargetContent);
|
write_nic_dword(dev, WCAMI, TargetContent);
|
||||||
write_nic_dword(dev, RWCAM, TargetCommand);
|
write_nic_dword(dev, RWCAM, TargetCommand);
|
||||||
}
|
continue;
|
||||||
else {
|
default: /* Key Material */
|
||||||
//Key Material
|
if (KeyContent != NULL) {
|
||||||
if(KeyContent !=NULL){
|
write_nic_dword(dev, WCAMI,
|
||||||
write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) );
|
(u32)(*(KeyContent+i-2)));
|
||||||
write_nic_dword(dev, RWCAM, TargetCommand);
|
write_nic_dword(dev, RWCAM,
|
||||||
|
TargetCommand);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
Reference in New Issue
Block a user