📄 miscproc.c
字号:
ReturnCmdNode (Adapter,Adapter->CurCmd);
Adapter->CurCmd = NULL;
//// ExecuteNextCommand(Adapter);
GetCmdFromQueueToExecute (Adapter);
return;
}
/******************************************************************************
*
* Name: SetStationPowerState()
*
* Description: Set MrvDrv power state
*
* Conditions for Use: Called by power state set OID handler
*
* Arguments:
* PMRVDRV_ADAPTER Adapter
* NDIS_DEVICE_POWER_STATE NewPowerState
* IN NDIS_OID Oid
* IN PULONG BytesRead
* IN PULONG BytesNeeded
* IN PVOID InformationBuffer
*
* Return Value:
*
* Notes:
*
*****************************************************************************/
NDIS_STATUS
SetStationPowerState(
PMRVDRV_ADAPTER Adapter,
NDIS_DEVICE_POWER_STATE NewPowerState,
IN NDIS_OID Oid,
IN PULONG BytesRead,
IN PULONG BytesNeeded,
IN PVOID InformationBuffer
)
{
BOOLEAN bFwReloaded = FALSE;
IX_STATUS ixStatus = IX_STATUS_SUCCESS;
PCF_OBJECT pCf = (PCF_OBJECT)Adapter->hwIface;
//int i;
//CmdCtrlNode *TempCmdArray;
if( Adapter->CurPowerState == NewPowerState )
return NDIS_STATUS_SUCCESS;
#ifdef HOST_WAKEUP
if (Adapter->bHostWakeCfgSet == 1)
return NDIS_STATUS_SUCCESS;
#endif
switch( Adapter->CurPowerState )
{
case NdisDeviceStateD0: // D0->D3
DBGPRINT(DBG_LOAD | DBG_SP,("D0->D3\n"));
//RETAILMSG(1, (TEXT("D0->D3 >>> ")));
HexDump(DBG_ALLEN, "PreviousSSID:", Adapter->PreviousSSID.Ssid, Adapter->PreviousSSID.SsidLength);
HexDump(DBG_ALLEN, "CurrentSSID:", Adapter->CurrentSSID.Ssid, Adapter->CurrentSSID.SsidLength);
if (Adapter->MediaConnectStatus == NdisMediaStateConnected)
{
USHORT usCommand;
// Adapter is connected and there is a mode change
// Disconnect first
if ( Adapter->InfrastructureMode == Ndis802_11Infrastructure )
usCommand = HostCmd_CMD_802_11_DEAUTHENTICATE;
else
usCommand = HostCmd_CMD_802_11_AD_HOC_STOP;
//RETAILMSG(1, (TEXT("usCommand = %d \r\n "), usCommand));
// completely clean up
PrepareAndSendCommand(
Adapter,
usCommand,
0,
HostCmd_OPTION_USE_INT,
(NDIS_OID)0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
Adapter->CurrentBSSID);
NdisMSleep(10000);
}
NdisZeroMemory(&Adapter->PreviousSSID, sizeof(NDIS_802_11_SSID));
{
// Memorize the previous SSID and BSSID
NdisMoveMemory( &(Adapter->PreviousSSID),
&(Adapter->CurrentSSID),
sizeof(NDIS_802_11_SSID));
//RETAILMSG(1, (TEXT("indicate NDIS_STATUS_MEDIA_DISCONNECT 3\r\n")));
NdisMIndicateStatus( Adapter->MrvDrvAdapterHdl,
NDIS_STATUS_MEDIA_DISCONNECT,
(PVOID)NULL,
0);
NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
Adapter->MediaConnectStatus = NdisMediaStateDisconnected;
Adapter->ulCurrentBSSIDIndex =0;
Adapter->LinkSpeed = MRVDRV_LINK_SPEED_1mbps; //do not set to 0mbps
Adapter->ulLastMICErrorTime = 0;
if ( Adapter->EncryptionStatus == Ndis802_11Encryption2Enabled ) // wpa
{
// set to key absent
Adapter->EncryptionStatus = Ndis802_11Encryption2KeyAbsent;
}
else if ( Adapter->EncryptionStatus == Ndis802_11Encryption3Enabled ) // wpa2
{
// set to key absent
Adapter->EncryptionStatus = Ndis802_11Encryption3KeyAbsent;
}
else if ( Adapter->EncryptionStatus == Ndis802_11Encryption1Enabled ) // wep
{
// set to key absent
Adapter->EncryptionStatus = Ndis802_11Encryption1KeyAbsent;
}
if (Adapter->PSMode == Ndis802_11PowerModeMAX_PSP)
{
PSWakeup( Adapter);
}
DisableInterrupt(Adapter);
CleanUpSingleTxBuffer(Adapter);
Adapter->psState = PS_STATE_FULL_POWER;
}
break;
case NdisDeviceStateD1:
case NdisDeviceStateD2:
break;
case NdisDeviceStateD3: // D3->D0
DBGPRINT(DBG_LOAD| DBG_SP,("D3->D0\n"));
//RETAILMSG(1, (TEXT("D3->D0 >>> ")));
HexDump(DBG_ALLEN, "PreviousSSID:", Adapter->PreviousSSID.Ssid, Adapter->PreviousSSID.SsidLength);
HexDump(DBG_ALLEN, "CurrentSSID:", Adapter->CurrentSSID.Ssid, Adapter->CurrentSSID.SsidLength);
// see if this is the problem
// NdisFillMemory(Adapter->CurrentAddr, MRVDRV_ETH_ADDR_LEN, 0xff);
ixStatus = cf_IsFirmwareLoaded( Adapter->hwIface );
//RETAILMSG(1, (TEXT("ixStatus 0x%x >>> "), ixStatus));
DBGPRINT(DBG_LOAD| DBG_SP,("ixStatus = %d\n", ixStatus));
if ( ixStatus == IX_STATUS_FAILURE )
{
DBGPRINT(DBG_LOAD | DBG_SP,("Bootloader in invalid state!\n"));
// we could do a hardware reset here on the card to try to restart
// the boot loader.
return NDIS_STATUS_FAILURE;
}
else if ( ixStatus == IX_STATUS_HOST_BOOT_READY )
{
DBGPRINT(DBG_LOAD| DBG_SP,("Host Boot!\n"));
ixStatus = cf_DownloadHelperImage((PCF_OBJECT)Adapter->hwIface, Adapter);
if (ixStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(DBG_LOAD| DBG_SP, ("Download Helper Image failed!\n"));
return NDIS_STATUS_FAILURE;
}
ixStatus = cf_DownloadFWImageHelperMode((PCF_OBJECT)Adapter->hwIface, Adapter);
if (ixStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(DBG_LOAD| DBG_SP, ("Download Helper Image failed!\n"));
return NDIS_STATUS_FAILURE;
}
bFwReloaded = TRUE;
}
else if (ixStatus == IX_STATUS_BOOT_READY)
{
return NDIS_STATUS_FAILURE;
}
else
{
DBGPRINT(DBG_LOAD | DBG_SP,("Firmware aleady running!\n"));
}
Adapter->CurPowerState = NewPowerState;
// Enable INT
EnableInterrupt(Adapter);
// indicate to OS that the network is not connected
// NdisMSetTimer(&Adapter->MrvDrvIndicateConnectStatusTimer, 100);
// Adapter->DisconnectTimerSet = TRUE;
//----------------------------------------------------------------------------
// If the FW required reloading, then we have to kick start the receiver again.
//----------------------------------------------------------------------------
{
Adapter->RadioOn = TRUE;
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_802_11_RADIO_CONTROL,
HostCmd_ACT_GEN_SET,
HostCmd_OPTION_USE_INT,
(NDIS_OID)0, //OID_MRVL_ENABLE_RADIO,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL);
}
// completely clean up
//InitializeWirelessConfig(Adapter);
{
PVOID InfoBuffer = NULL;
DBGPRINT(DBG_LOAD ,("Init: Setting fragmentation threshold to %d\n", Adapter->FragThsd ));
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_802_11_SNMP_MIB,
0,
HostCmd_OPTION_USE_INT,
(NDIS_OID)OID_802_11_FRAGMENTATION_THRESHOLD,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL);
DBGPRINT(DBG_LOAD ,("Init: Setting RTS threshold to %d\n", Adapter->RTSThsd ));
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_802_11_SNMP_MIB,
0,
HostCmd_OPTION_USE_INT,
(NDIS_OID)OID_802_11_RTS_THRESHOLD,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL);
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_MAC_CONTROL,
Adapter->usMacControlRecord,
HostCmd_OPTION_USE_INT,
0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL);
// BT Co-existence
if ( Adapter->BTMode != 0 )
{
// only send command if BT mode is not 0
DBGPRINT(DBG_LOAD, ("Setting BT Mode parameters:\n"));
DBGPRINT(DBG_LOAD, ("BTMode=0x%x, Antenna Config = 0x%x, Freq Config = 0x%x\n",
Adapter->BTMode, Adapter->BTAntennaConfig, Adapter->BTFrequencyConfig));
DBGPRINT(DBG_LOAD, ("TX Lo = 0x%x, TX Hi = 0x%x, RX Lo = 0x%x, RX Hi = 0x%x\n",
Adapter->BTWLANTxPriorityLo, Adapter->BTWLANTxPriorityHi,
Adapter->BTWLANRxPriorityLo, Adapter->BTWLANRxPriorityHi));
PrepareAndSendCommand(
Adapter,
HostCmd_CMD_BCA_CONFIG,
HostCmd_ACT_GEN_SET,
HostCmd_OPTION_USE_INT,
0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
NULL );
NdisMSleep(10000);
}
}
//InfraBssReconnectStart ( Adapter, RECONNECT_D3_TO_D0);
break;
default :
DBGPRINT(DBG_POWER,("ERROR: Unknown power state\n"));
break;
}
Adapter->CurPowerState = NewPowerState;
//RETAILMSG(1, (TEXT("Adapter->CurPowerState = %d\n"), Adapter->CurPowerState));
return NDIS_STATUS_SUCCESS;
}
/*
===============================================================================
CODED PRIVATE PROCEDURES
===============================================================================
*/
VOID
ResetDisconnectStatus(
IN PMRVDRV_ADAPTER Adapter
)
{
// RETAILMSG(1, (TEXT("ResetDisconnectStatus() \r\n")));
DBGPRINT(DBG_CMDRESP, ("Connection reset!\n"));
HexDump(DBG_ALLEN, "PreviousSSID:", Adapter->PreviousSSID.Ssid, Adapter->PreviousSSID.SsidLength);
HexDump(DBG_ALLEN, "CurrentSSID:", Adapter->CurrentSSID.Ssid, Adapter->CurrentSSID.SsidLength);
#ifdef BG_SCAN
if ( Adapter->bBgScanEnabled==TRUE)
{
EnableBgScan( Adapter, FALSE);
}
#endif
if (Adapter->CurrentSSID.SsidLength != 0)
{
NdisMoveMemory(&Adapter->PreviousSSID, &Adapter->CurrentSSID,
sizeof(NDIS_802_11_SSID));
}
//NdisZeroMemory(&(Adapter->CurrentSSID), sizeof(NDIS_802_11_SSID));
//NdisZeroMemory(Adapter->CurrentBSSID, MRVDRV_ETH_ADDR_LEN);
//NdisZeroMemory(&(Adapter->CurrentBSSIDDesciptor), sizeof(NDIS_WLAN_BSSID_EX));
if ( (Adapter->PSMode == Ndis802_11PowerModeMAX_PSP) &&
(Adapter->MediaConnectStatus == NdisMediaStateConnected ))
{
//Adapter->psState = PS_STATE_FULL_POWER;
PSWakeup(Adapter);
}
Adapter->MediaConnectStatus = NdisMediaStateDisconnected;
Adapter->ulCurrentBSSIDIndex =0;
Adapter->LinkSpeed = MRVDRV_LINK_SPEED_1mbps; //do not set to 0mbps
if ((Adapter->bIsReconnectEnable == FALSE) &&
(Adapter->bIsBeaconLoseEvent == FALSE) &&
(Adapter->bIsDeauthenticaticationEvent == FALSE)
#ifdef ACTIVE_ROAMING
&& (Adapter->bIsActiveRoaming == FALSE)
#endif
)
{
// RETAILMSG(1, (TEXT("indicate NDIS_STATUS_MEDIA_DISCONNECT 4\r\n")));
NdisMIndicateStatus( Adapter->MrvDrvAdapterHdl,
NDIS_STATUS_MEDIA_DISCONNECT,
(PVOID)NULL,
0);
NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
}
Adapter->ulLastMICErrorTime = 0;
if ((Adapter->bIsReconnectEnable == FALSE) &&
(Adapter->bIsBeaconLoseEvent == FALSE) &&
(Adapter->bIsDeauthenticaticationEvent == FALSE)
#ifdef ACTIVE_ROAMING
&&(Adapter->bIsActiveRoaming == FALSE)
#endif
)
{
//RETAILMSG(1, (TEXT("change EncryptionStatus %d\r\n"), Adapter->EncryptionStatus));
//RETAILMSG(1, (TEXT("change ReEncryptionStatus %d\r\n"), Adapter->ReEncryptionStatus));
if ( Adapter->EncryptionStatus == Ndis802_11Encryption2Enabled ) // wpa
{
// set to key absent
Adapter->EncryptionStatus = Ndis802_11Encryption2KeyAbsent;
}
else if ( Adapter->EncryptionStatus == Ndis802_11Encryption3Enabled ) // wpa2
{
// set to key absent
Adapter->EncryptionStatus = Ndis802_11Encryption3KeyAbsent;
}
/*
else if ( Adapter->EncryptionStatus == Ndis802_11Encryption1Enabled ) // wep
{
// set to key absent
Adapter->EncryptionStatus = Ndis802_11Encryption1KeyAbsent;
}
*/
}
return;
}
VOID
ResetSingleTxDoneAck(
IN PMRVDRV_ADAPTER Adapter
)
{
}
/******************************************************************************
*
* Name: SetMacPacketFilter()
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -