📄 zddebug.c
字号:
CamEncryType = WEP64;
tmpDynKeyMode=DYN_KEY_WEP64;
}
else
{//keylen=13, WEP 128
CamEncryType = WEP128;
tmpDynKeyMode=DYN_KEY_WEP128;
}
// For Dynamic WEP key (Non-WPA Radius), the key ID range: 0-3
// In WPA/RSN mode, the key ID range: 1-3, usually, a broadcast key.
// For WEP key setting: we set mDynKeyMode and mKeyFormat in following case:
// 1. For 802.1x dynamically generated WEP key method.
// 2. For WPA/RSN mode, but key id == 0. (But this is an impossible case)
// So, only check case 1.
if (macp->cardSetting.WPAIeLen==0)
{
mKeyFormat = CamEncryType;
mDynKeyMode = pSetting->DynKeyMode = tmpDynKeyMode;
mPrivacyInvoked=TRUE;
mCap |= CAP_PRIVACY;
macp->cardSetting.EncryOnOff=1;
}
}
/* DUMP key context */
#ifdef WPA_DEBUG
if (keylen > 0)
{
int ii;
printk("zddebug:Key Context:\n");
for(ii = 0; ii < keylen;) {
printk("0x%02x ", pkey[ii]);
if((++ii % 16) == 0)
printk("\n");
}
printk("\n");
}
#endif
zd_SetKeyInfo(zdparm->sta_addr, CamEncryType, keylen, idx, pkey);
break;
#if 0
WPADEBUG("zd1205_wpa_ioctl: ZD_CMD_SET_ENCRYPT_KEY\n");
/* DUMP the Key information set by the upper layer */
{
WPADEBUG("alg=%s key_idx=%d set_tx=%d key_len=%d\n",
zdparm->u.crypt.alg, zdparm->u.crypt.idx,
zdparm->u.crypt.flags, zdparm->u.crypt.key_len);
}
keylen = zdparm->u.crypt.key_len;
idx = zdparm->u.crypt.idx;
pkey = zdparm->u.crypt.key;
if (strcmp(zdparm->u.crypt.alg, "NONE") == 0) {
/* Reset those settings related to WPA */
mKeyFormat=0;
pSetting->EncryMode=0;
pSetting->DynKeyMode = 0;
return ret;
}
else if (strcmp(zdparm->u.crypt.alg, "TKIP") == 0) {
/* Try to change mDynKeyMode here. 4D06 */
pSetting->DynKeyMode = DYN_KEY_TKIP;
mDynKeyMode = DYN_KEY_TKIP;
mKeyFormat = TKIP;
}
else if (strcmp(zdparm->u.crypt.alg, "CCMP") == 0) {
/* Try to change mDynKeyMode here. 4D06 */
pSetting->DynKeyMode = DYN_KEY_AES;
mDynKeyMode = DYN_KEY_AES;
mKeyFormat = AES;
}
/* DUMP key context */
{
int ii;
WPADEBUG("Key Context: ");
for(ii = 0; ii < keylen;) {
WPADEBUG("0x%02x ", pkey[ii]);
if((++ii % 16) == 0)
WPADEBUG("\n");
}
WPADEBUG("\n");
}
/* If Key Index is 0, this is the unicast key */
if (idx == 0) {
/* Set unicast key installed information */
zd_SetKeyContext(&macp->BSSID[0], pSetting->DynKeyMode, keylen, idx, pkey);
}
else {
/* Set broadcast key installed information */
u8 bcaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
zd_SetKeyContext(bcaddr, pSetting->DynKeyMode, keylen, idx, pkey);
}
break;
#endif
case ZD_CMD_SET_MLME:
WPADEBUG("zd1205_wpa_ioctl: ZD_CMD_SET_MLME\n");
/* Translate STA's address */
sprintf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", zdparm->sta_addr[0], zdparm->sta_addr[1],
zdparm->sta_addr[2], zdparm->sta_addr[3], zdparm->sta_addr[4], zdparm->sta_addr[5]);
switch(zdparm->u.mlme.cmd) {
case MLME_STA_DEAUTH:
printk(" -------Call zd_CmdDeauth, reason:%d\n",zdparm->u.mlme.reason_code);
if(zd_CmdDeauth((MacAddr_t *) zdparm->sta_addr, zdparm->u.mlme.reason_code) == FALSE)
WPADEBUG("Can't deauthencate STA: %s\n", mac_addr);
else
WPADEBUG("Deauthenticate STA: %s with reason code: %d\n", mac_addr, zdparm->u.mlme.reason_code);
break;
case MLME_STA_DISASSOC:
if(zd_CmdDisasoc((MacAddr_t *) zdparm->sta_addr, zdparm->u.mlme.reason_code) == FALSE)
WPADEBUG("Can't disassociate STA: %s\n", mac_addr);
else
WPADEBUG("Disassociate STA: %s with reason code: %d\n", mac_addr, zdparm->u.mlme.reason_code);
break;
default:
WPADEBUG("MLME command: 0x%04x not support\n", zdparm->u.mlme.cmd);
break;
}
break;
case ZD_CMD_SCAN_REQ:
WPADEBUG("zd1205_wpa_ioctl: ZD_CMD_SCAN_REQ\n");
break;
case ZD_CMD_SET_GENERIC_ELEMENT:
WPADEBUG("zd1205_wpa_ioctl: ZD_CMD_SET_GENERIC_ELEMENT\n");
/* Copy the WPA IE */
pSetting->WPAIeLen = zdparm->u.generic_elem.len;
memcpy(&pSetting->WPAIe, zdparm->u.generic_elem.data, pSetting->WPAIeLen);
{
int ii;
WPADEBUG("pSetting->WPAIeLen: %d\n", pSetting->WPAIeLen);
/* DUMP WPA IE */
for(ii = 0; ii < pSetting->WPAIeLen;) {
WPADEBUG("0x%02x ", pSetting->WPAIe[ii]);
if((++ii % 16) == 0)
WPADEBUG("\n");
}
WPADEBUG("\n");
}
#if CODE4_AP
#ifdef HOSTAPD_SUPPORT
if (pSetting->BssType == AP_BSS)
{// Update Beacon FIFO in the next TBTT.
memcpy(&mWPAIe, pSetting->WPAIe, pSetting->WPAIeLen);
WPADEBUG("Copy WPA IE into mWPAIe\n");
}
#endif
#endif
break;
default:
WPADEBUG("zd1205_wpa_ioctl: default\n");
ret = -EINVAL;
break;
}
return ret;
}
int zd1205_cont_tx(struct zd1205_private *macp, u8 rate) {
void *reg = dot11Obj.reg;
static u8 LastCont_TX_Rate=0;
printk(KERN_ERR "ZDContinuousTx,Rate=%d\n",rate);
//if (le32_to_cpu(pZDRD->ZDRdLength) < sizeof(ZD_RD_STRUCT))
//{
// pZDRD->ZDRdLength = cpu_to_le32(sizeof(ZD_RD_STRUCT));
// *BytesNeeded = sizeof(ZD_RD_STRUCT);
// *BytesRead = 0;
// Status = NDIS_STATUS_BUFFER_TOO_SHORT;
// break;
//}
//macp->bContinueTxMode = le32_to_cpu(pZDRD->Buffer[0]);
//macp->bContinueTx = le32_to_cpu(pZDRD->Buffer[1]);
/* Use the Fixed Rate instead of LastSentTxRate */
//macp->LastZDContinuousTxRate = macp->cardSetting.LastSentTxRate;
//macp->LastZDContinuousTxRate = macp->cardSetting.FixedRate;
// Roger 2004-11-10 , Set for Dr.Wang request , set 0x0001c4 when CCK mode with AL2230
if (dot11Obj.rfMode == AL2230_RF) {
//if (macp->cardSetting.LastSentTxRate > 3) {
if (LastCont_TX_Rate > 3) {
HW_Set_IF_Synthesizer(&dot11Obj, 0x0005a4);
}
//else if (macp->cardSetting.LastSentTxRate <= 3) {
else if (LastCont_TX_Rate <= 3) {
HW_Set_IF_Synthesizer(&dot11Obj, 0x0001c4);
}
}
LastCont_TX_Rate = rate;
if(rate <= RATE_54M) { // Start
u8 tmpChr = 0;
u32 RateTmp= 0;
u32 tmpvalue;
u32 nLoop;
LockPhyReg(&dot11Obj);
dot11Obj.SetReg(reg, ZD1205_CR2, 0x3F);
dot11Obj.SetReg(reg, ZD1205_CR138, 0x28);
dot11Obj.SetReg(reg, ZD1205_CR33, 0x20);
// Query CR60 until change to 0x04
nLoop = 200;
while(nLoop--)
{
dot11Obj.DelayUs(10*1000); // sleep 10ms
tmpvalue = dot11Obj.GetReg(reg, ZD1205_CR60);
if(tmpvalue == 0x04)
break;
}
UnLockPhyReg(&dot11Obj);
printk(KERN_DEBUG "Start ContTx_Normal\n");
dot11Obj.bContinueTx = 1;
LockPhyReg(&dot11Obj);
/* In order to avoid the uninitial length problem,
force to set length to 0x20.
*/
dot11Obj.SetReg(reg, ZD1205_CR134, 0x20);
UnLockPhyReg(&dot11Obj);
switch (rate){
case RATE_6M: //6M
RateTmp = 0xB;
break;
case RATE_9M: //9M
RateTmp = 0xF;
break;
case RATE_12M: //12M
RateTmp = 0xA;
break;
case RATE_18M: //18M
RateTmp = 0xE;
break;
case RATE_24M: //24M
RateTmp = 0x9;
break;
case RATE_36M: //36M
RateTmp = 0xD;
break;
case RATE_48M: //48M
RateTmp = 0x8;
break;
case RATE_54M: //54M
RateTmp = 0xC;
break;
default:
RateTmp = 0;
break;
}
printk(KERN_DEBUG "RateTmp=0x%08x\n", RateTmp);
if (RateTmp){
LockPhyReg(&dot11Obj);
dot11Obj.SetReg(reg, ZD1205_CR132, RateTmp);
//AcquireCtrOfPhyReg(Adapter);
tmpvalue = dot11Obj.GetReg(reg, ZD1205_CR159);
tmpvalue &= ~(BIT_0 + BIT_1 );
tmpvalue |= BIT_2;
dot11Obj.SetReg(reg, ZD1205_CR159, tmpvalue);
dot11Obj.SetReg(reg, 0x644, 7);
tmpvalue = dot11Obj.GetReg(reg, 0x648);
tmpvalue &= ~BIT_0;
dot11Obj.SetReg(reg, 0x648, tmpvalue);
UnLockPhyReg(&dot11Obj);
}
tmpChr = LastCont_TX_Rate;
printk(KERN_DEBUG "tmpChr=0x%x\n", tmpChr);
#if 0
if (macp->preambleMode == 1)
macp->cardSetting.PreambleType = 0x00;
else if (macp->preambleMode == 2)
macp->cardSetting.PreambleType = 0x20;
#endif
if (macp->cardSetting.PreambleType == SHORT_PREAMBLE){
// short premable
tmpChr |= BIT_5;
}
else{
// long premable
tmpChr &= ~BIT_5;
}
if (macp->RegionCode == 0x10)
tmpChr &= ~BIT_6; //USA
if (macp->RegionCode == 0x40)
tmpChr |= BIT_6; //japan
LockPhyReg(&dot11Obj);
dot11Obj.SetReg(reg, ZD1205_CR5, tmpChr);
dot11Obj.SetReg(reg, 0x644, 3);
UnLockPhyReg(&dot11Obj);
}
else {
u32 tmpvalue;
// Roger 2004-11-10 , Set for Dr.Wang request , set 0x0001c4 when CCK mode with AL2230
if (dot11Obj.rfMode == AL2230_RF) {
HW_Set_IF_Synthesizer(&dot11Obj, 0x0005a4);
}
LockPhyReg(&dot11Obj);
dot11Obj.SetReg(reg, ZD1205_CR2, 0x26);
dot11Obj.SetReg(reg, ZD1205_CR138, 0xA8);
dot11Obj.SetReg(reg, ZD1205_CR33, 0x08);
UnLockPhyReg(&dot11Obj);
printk(KERN_DEBUG "Stop Normal Continuous Transmit\n");
dot11Obj.bContinueTx = 0;
LockPhyReg(&dot11Obj);
macp->PHYTestTimer = 30;
// ZD1205_WRITE_REGISTER(Adapter,CR122, 0x0);
UnLockPhyReg(&dot11Obj);
if (LastCont_TX_Rate >= 4){
LockPhyReg(&dot11Obj);
tmpvalue = dot11Obj.GetReg(reg, ZD1205_CR159);
tmpvalue &= ~(BIT_0 + BIT_1 + BIT_2 );
dot11Obj.SetReg(reg, ZD1205_CR159, tmpvalue);
dot11Obj.SetReg(reg, 0x644, 0);
tmpvalue = dot11Obj.GetReg(reg, 0x648);
tmpvalue |= BIT_0;
dot11Obj.SetReg(reg, 0x648, tmpvalue);
UnLockPhyReg(&dot11Obj);
}
else{
LockPhyReg(&dot11Obj);
dot11Obj.SetReg(reg, 0x644, 0);
tmpvalue = dot11Obj.GetReg(reg, 0x648);
tmpvalue |= BIT_0;
dot11Obj.SetReg(reg, 0x648, tmpvalue);
UnLockPhyReg(&dot11Obj);
}
//dot11Obj.SetReg(reg, ZD_PS_Ctrl, 0x1);
//Roger 2004-11-16 SoftwareReset here to solve RX fail after TxContinue problem
{
//zd1205_device_reset(macp);
//Card resetting , copying from driver of ZyNOS
//It's a little different from ours
u32 tmp_value;
/* Update the value of Beacon Interval and Pre TBTT */
update_beacon_interval(macp, 0x2);
zd_writel(0x01, Pre_TBTT);
LockPhyReg(&dot11Obj);
dot11Obj.SetReg(dot11Obj.reg, ZD1205_PHY_END, 0x8);
tmp_value = zd_readl(PS_Ctrl);
zd_writel(tmp_value | BIT_5, PS_Ctrl);
dot11Obj.SetReg(dot11Obj.reg, ZD1205_PHY_END, 0x0);
UnLockPhyReg(&dot11Obj);
dot11Obj.bDeviceInSleep = 1;
dot11Obj.DelayUs(5000);
}
}
return 0;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -