📄 cmdproc.c
字号:
else if (PsSubCommand == 0)
AddToQueue = 0;
break;
}
switch(AddToQueue)
{
case 0:
InsertQNodeAtTail(&(Adapter->CmdPendQ),(PQ_NODE)pTempCmd);
break;
case 1:
InsertQNodeFromHead(&(Adapter->CmdPendQ),(PQ_NODE)pTempCmd);
break;
default:
ReturnCmdNode(Adapter, pTempCmd);
break;
}
}
VOID
GetCmdFromQueueToExecute(
IN PMRVDRV_ADAPTER Adapter
)
{
CmdCtrlNode *pTempNode=NULL;
CmdCtrlNode *pPsEnterCmd;
CmdCtrlNode *pPsExitCmd;
USHORT PsSubCommand;
USHORT Command;
USHORT IsDownloadCmdToFW;
NDIS_STATUS status;
//USHORT whichQ;
DBGPRINT(DBG_NEWCMD, ("GetCmdFromQueueToExecute() \n"));
//dralee_20051128
//if (Adapter->CurCmd || Adapter-> SentPacket)
//dralee_20060515. In case Adapter-> SentPacket is one of cases to return, the driver will lost
//a added on command to let FW enter PS again when Queue is empty. (see below)
if(Adapter->CurCmd || Adapter-> SentPacket)
{
DBGPRINT(DBG_NEWCMD, ("GetCmdFromQueueToExecute: return 1 =>Adapter->CurCmd\n"));
//RETAILMSG(1,(TEXT("GetCmdFromQueueToExecute: return 1 =>Adapter->CurCmd \r\n")));
return;
}
if ( Adapter->psState == PS_STATE_SLEEP && Adapter->bPSConfirm==TRUE )
{
DBGPRINT(DBG_NEWCMD, ("GetCmdFromQueueToExecute: return =>Adapter->psState == PS_STATE_SLEEP PS_STATE_SLEEP_PENDING \n"));
//RETAILMSG(1, (TEXT("GetCmdFromQueueToExecute: return 1 =>Sleep confirmed \n\r")));
return;
}
//dralee 072705
if( TryEnterCriticalSection(&Adapter->CmdQueueExeSection) == 0 )
return;
//dralee 08092005
EnterCriticalSection(&Adapter->TxCriticalSection);
IsDownloadCmdToFW = 0;
if (!IsQEmpty(&Adapter->CmdPendQ))
{
pTempNode = (CmdCtrlNode *)PopFirstQNode(&Adapter->CmdPendQ);
if(pTempNode != NULL)
{
Command = ((PHostCmd_DS_GEN)(pTempNode->BufVirtualAddr))->Command;
if ((Command == HostCmd_CMD_802_11_PS_MODE))
PsSubCommand = ((PHostCmd_DS_802_11_PS_MODE)pTempNode->BufVirtualAddr)->SubCommand;
else
PsSubCommand = 0;
switch(Adapter->psState)
{
case PS_STATE_FULL_POWER:
IsDownloadCmdToFW = 1;
break;
case PS_STATE_WAKEUP:
IsDownloadCmdToFW = 1;
#if 0 //dralee_20051119
if(PsSubCommand != HostCmd_SubCmd_Exit_PS)
#else
if(PsSubCommand != HostCmd_SubCmd_Exit_PS &&
Command != HostCmd_CMD_802_11_HOST_SLEEP_AWAKE_CONFIRM &&
Command != HostCmd_CMD_802_11_RSSI )
#endif
{
pPsExitCmd = GetFreeCmdCtrlNode(Adapter);
MakePsCmd (Adapter, pPsExitCmd, HostCmd_SubCmd_Exit_PS);
InsertQNodeFromHead(&(Adapter->CmdPendQ),(PQ_NODE)pTempNode);
pTempNode = pPsExitCmd;
}
break;
case PS_STATE_SLEEP:
if(PsSubCommand == HostCmd_SubCmd_Sleep_Confirmed)
IsDownloadCmdToFW = 1;
else
{
InsertQNodeFromHead(&(Adapter->CmdPendQ),(PQ_NODE)pTempNode);
}
break;
}
} // (pTempNode != NULL) end
}
else // Queue is empty
{
if((Adapter->MediaConnectStatus == NdisMediaStateConnected)&&
(Adapter->PSMode != Ndis802_11PowerModeCAM) &&
(Adapter->psState == PS_STATE_FULL_POWER) &&
(EncryptionStateCheck(Adapter)) // pluschen
)
{
pPsEnterCmd = GetFreeCmdCtrlNode(Adapter);
MakePsCmd (Adapter, pPsEnterCmd, HostCmd_SubCmd_Enter_PS);
pTempNode = pPsEnterCmd;
IsDownloadCmdToFW = 1;
}
}
if(IsDownloadCmdToFW)
{
// for debug
// Command = ((PHostCmd_DS_GEN)(pTempNode->BufVirtualAddr))->Command;
// if ((Command == HostCmd_CMD_802_11_PS_MODE))
// PsSubCommand = ((PHostCmd_DS_802_11_PS_MODE)pTempNode->BufVirtualAddr)->SubCommand;
// if(PsSubCommand != HostCmd_SubCmd_Sleep_Confirmed)
// DraleeMsg((L"GetCmdFromQueueToExecute: Cmd %x PsSubCmd %x PSSTATE %x \n", Command, PsSubCommand, Adapter->psState));
status = DownloadCommand(Adapter, pTempNode);
if ( status != NDIS_STATUS_SUCCESS)
{
InsertQNodeFromHead(&(Adapter->CmdPendQ),(PQ_NODE)pTempNode);
}
}
LeaveCriticalSection(&Adapter->TxCriticalSection);
LeaveCriticalSection(&Adapter->CmdQueueExeSection);
//sd_ReleaseCmdDownloadPath(Adapter);
}
// plus --
NDIS_STATUS
DownloadCommand(
IN PMRVDRV_ADAPTER Adapter,
IN CmdCtrlNode *pTempNode
)
{
//USHORT *pusPtr; // word pointer to current command.
PHostCmd_DS_GEN pCmdPtr;
ULONG ulTemp =0;
BOOLEAN bQueueCMD = FALSE;
//ULONG timeout;
USHORT Command = 0;
USHORT PsSubCommand = 0;
#if defined(IF_SDIO) || defined(IF_GSPI)
SD_API_STATUS status; // intermediate status
SDIO_TX_PKT cmdDownload;
#endif
#ifdef DEEP_SLEEP
///BOOLEAN timerStatus;
#endif
DBGPRINT(DBG_NEWCMD, ("DownloadCommand() \n"));
// Check device removal status
if( Adapter->SurpriseRemoved == TRUE ){
return NDIS_STATUS_ADAPTER_REMOVED;
}
DBGPRINT(DBG_NEWCMD,("**** Download command 2 0x%x ****\n",
((PHostCmd_DS_GEN)pTempNode->BufVirtualAddr)->Command));
Adapter->CurCmd = pTempNode;
pCmdPtr = (PHostCmd_DS_GEN)pTempNode->BufVirtualAddr;
/// set command timer
Command = ((PHostCmd_DS_GEN)Adapter->CurCmd->BufVirtualAddr)->Command;
DBGPRINT(DBG_NEWCMD,("Download command 3 0x%x ****\n",
((PHostCmd_DS_GEN)Adapter->CurCmd->BufVirtualAddr)->Command));
#if defined(IF_SDIO)||defined(IF_GSPI)
// prepare command download packet
cmdDownload.Len = ADD_SDIO_PKT_HDR_LENGTH(pCmdPtr->Size);
cmdDownload.Type = IF_CMD_PKT;
NdisMoveMemory(cmdDownload.Buf.CmdBuf, pCmdPtr, pCmdPtr->Size);
if ( Command != 0x21 )
V5DbgMsg( (L" # dwn: 0x%x\n", Command) );
Adapter->CommandTimerSet = TRUE;
Adapter->isCommandTimerExpired = FALSE;
NdisMSetTimer(&Adapter->MrvDrvCommandTimer, MRVDRV_DEFAULT_LONG_COMMAND_TIME_OUT);
status = If_DownloadPkt(Adapter, &cmdDownload);
if (!SD_API_SUCCESS(status))
{
if ( Adapter->CurCmd != NULL )
{
DBGPRINT(DBG_CMDRESP | DBG_ERROR,
("CMD 0x%x download failed!\n",
((PHostCmd_DS_GEN)Adapter->CurCmd->BufVirtualAddr)->Command));
// there is a race condition for suspend/resume, so need
// to check if suspend occured
if ( Adapter->ShutDown == TRUE ) //Adapter->ShutDown = TRUE when: SDCardEjected
{
// card eject event occured, the commands are cleaned up!
DBGPRINT(DBG_UNLOAD,
("Detected shutdown in DownloadCommand procedure, exit!\n"));
return NDIS_STATUS_FAILURE;
}
DBGPRINT(DBG_ALL, ("Call CleanupCmdCtrlNode\n"));
//Clean up the command control node
CleanUpCmdCtrlNode(Adapter->CurCmd);
DBGPRINT(DBG_ALL, ("Call InsertQ to CmdFreeQ\n"));
//Put current command back to CmdFreeQ
InsertQNodeAtTail(&Adapter->CmdFreeQ, (PQ_NODE)Adapter->CurCmd);
DBGPRINT(DBG_ALL, ("Set CurCmd to NULL\n"));
Adapter->CurCmd = NULL;
}
else
{
DBGPRINT(DBG_ERROR, ("Current command already removed, possibly due to"
" card removal?\n"));
}
return NDIS_STATUS_FAILURE;
}
#endif //IF_SDIO
switch(Command)
{
#ifdef DEEP_SLEEP
case HostCmd_CMD_802_11_DEEP_SLEEP:
//RETAILMSG(1,(TEXT("Deep Sleep : DEEP_SLEEP_CMD Sent Down\n")));
Adapter->IsDeepSleep = TRUE;
ResetCmdBuffer(Adapter);
NdisMIndicateStatus(
Adapter->MrvDrvAdapterHdl,
NDIS_STATUS_MEDIA_DISCONNECT,
(PVOID)NULL,
0);
NdisMIndicateStatusComplete(Adapter->MrvDrvAdapterHdl);
break;
#endif
case HostCmd_CMD_802_11_PS_MODE:
PsSubCommand = ((PHostCmd_DS_802_11_PS_MODE)pTempNode->BufVirtualAddr)->SubCommand;
if(PsSubCommand == HostCmd_SubCmd_Sleep_Confirmed)
{
Adapter->bPSConfirm=TRUE;
UpdatePowerSaveState( Adapter, Adapter->CurCmd, 0);
Adapter->CurCmd = NULL;
ReturnCmdNode(Adapter, pTempNode);
DBGPRINT(DBG_ALLEN,("[Maevell]DownloadCommand :HostCmd_SubCmd_Sleep_Confirmed 0x34\n"));
} //dralee_1108
else
NdisMSleep(100);
//Ling++ 102805, avoid SetTimer twice
//else
// NdisMSetTimer(&Adapter->MrvDrvCommandTimer, MRVDRV_DEFAULT_LONG_COMMAND_TIME_OUT);
//Ling-- 102805
break;
#ifdef HOST_SLEEP_PS
case HostCmd_CMD_802_11_HOST_SLEEP_CFG:
Adapter->HostPowerState = HTWK_STATE_PRESLEEP;
break;
#endif
default:
/* tt v5 firmware
NdisMSetTimer(&Adapter->MrvDrvCommandTimer, MRVDRV_DEFAULT_LONG_COMMAND_TIME_OUT);
*/
break;
}
return NDIS_STATUS_SUCCESS;
}
VOID
UpdatePowerSaveState(
IN PMRVDRV_ADAPTER Adapter,
IN CmdCtrlNode *pTempNode,
IN ULONG PsEvent
)
{
USHORT Command;
USHORT PsSubCommand;
//CmdCtrlNode *pPsComfirm;
DBGPRINT(DBG_NEWPS,("++ UpdatePowerSaveState\n"));
DBGPRINT(DBG_NEWPS,("Current State : %d\n",Adapter->psState));
if (PsEvent) // the input is a event
{
DBGPRINT(DBG_NEWPS,("Event Enter 0x%08x\n", PsEvent));
switch(Adapter->psState)
{
case PS_STATE_WAKEUP:
DBGPRINT(DBG_NEWPS,("Current State : PS_STATE_WAKEUP\n"));
if (PsEvent == MACREG_INT_CODE_PS_SLEEP)
{
DBGPRINT(DBG_NEWPS,("Receive Event : MACREG_INT_CODE_PS_SLEEP\n"));
// insert a PS_COMFIRM command to pQ
if( Adapter->HostPowerState == HTWK_STATE_FULL_POWER ||
Adapter->HostPowerState == HTWK_STATE_SLEEP )
{
//dralee_0126, to prevent MrvDrvSend() sendout a packet at this time
EnterCriticalSection(&Adapter->TxCriticalSection);
//++dralee_20060327
//if PPS is active, we only check CurCmd == NULL, otherwise, in IEEE PS, 4 conditions below must match
#ifdef PROPRIETARY_PERIODIC_PS
if( Adapter->CurCmd == NULL &&
(Adapter->sleepperiod != 0 ||
(Adapter->SentPacket == NULL && Adapter->TxPacketCount == 0 && IsQEmpty(&Adapter->CmdPendQ) ) ) )
#else
if( Adapter->SentPacket == NULL &&
Adapter->TxPacketCount == 0 && //dralee_1101, flush all pkts before sleep confirmed
IsQEmpty(&Adapter->CmdPendQ) && // plus
Adapter->CurCmd == NULL )
#endif
{
Adapter->psState = PS_STATE_SLEEP;
LeaveCriticalSection(&Adapter->TxCriticalSection);
PSConfirmSleep(Adapter);
}
else
#ifdef WMM_UAPSD // tt 060508
{
if ( Adapter->SentPacket == NULL && Adapter->CurCmd == NULL )
{
Adapter->psState = PS_STATE_SLEEP;
LeaveCriticalSection(&Adapter->TxCriticalSection);
PSConfirmSleep(Adapter);
}
else
LeaveCriticalSection(&Adapter->TxCriticalSection);
}
#else
{
LeaveCriticalSection(&Adapter->TxCriticalSection);
}
#endif // WMM_UAPSD
}
}
break;
case PS_STATE_SLEEP:
DBGPRINT(DBG_NEWPS,("Current State : PS_STATE_SLEEP\n"));
if (PsEvent == MACREG_INT_CODE_PS_AWAKE)
{
DBGPRINT(DBG_NEWPS,("Receive Event : MACREG_INT_CODE_PS_AWAKE\n"));
Adapter->psState = PS_STATE_WAKEUP;
}
break;
}
}
else // the input is a command
{
if (pTempNode==NULL)
return;
Command = ((PHostCmd_DS_GEN)(pTempNode->BufVirtualAddr))->Command;
DBGPRINT(DBG_NEWPS,("Command 0x%04x Enter\n", Command));
if ((Command == HostCmd_CMD_802_11_PS_MODE) ||
(Command == HostCmd_RET_802_11_PS_MODE))
{
PsSubCommand = ((PHostCmd_DS_802_11_PS_MODE)pTempNode->BufVirtualAddr)->SubCommand;
DBGPRINT(DBG_NEWPS,("PS Command : subcommand = %d\n",PsSubCommand));
switch(Adapter->psState)
{
case PS_STATE_FULL_POWER:
DBGPRINT(DBG_NEWPS,("Current State : PS_STATE_FULL_POWER\n"));
if (PsSubCommand == HostCmd_SubCmd_Enter_PS)
{
DBGPRINT(DBG_NEWPS,("Receive PS SubCommand : HostCmd_SubCmd_Enter_PS\n"));
Adapter->psState = PS_STATE_WAKEUP;
}
break;
case PS_STATE_WAKEUP:
DBGPRINT(DBG_NEWPS,("Current State : PS_STATE_WAKEUP\n"));
if (PsSubCommand == HostCmd_SubCmd_Exit_PS)
{
DBGPRINT(DBG_NEWPS,("Receive PS SubCommand : HostCmd_SubCmd_Exit_PS\n"));
Adapter->psState = PS_STATE_FULL_POWER;
}
if (PsSubCommand == HostCmd_SubCmd_Sleep_Confirmed)
{
DBGPRINT(DBG_NEWPS,("Receive PS SubCommand : HostCmd_SubCmd_Sleep_Confirmed\n"));
Adapter->psState = PS_STATE_SLEEP;
}
break;
case PS_STATE_SLEEP:
DBGPRINT(DBG_NEWPS,("Current State : PS_STATE_SLEEP_PENDING\n"));
if (PsSubCommand == HostCmd_SubCmd_Exit_PS)
{
DBGPRINT(DBG_NEWPS,("Receive PS SubCommand : HostCmd_SubCmd_Exit_PS\n"));
Adapter->psState = PS_STATE_FULL_POWER;
}
break;
}
}
}
DBGPRINT(DBG_ALLEN,("[Marvell]UpdatePowerSaveState Adapter->psState=%d\n",Adapter->psState));
DBGPRINT(DBG_NEWPS,("-- UpdatePowerSaveState\n"));
return;
}
// pluschen
UINT8 EncryptionStateCheck(IN PMRVDRV_ADAPTER Adapter)
{
UINT8 IsAllowPS;
DBGPRINT(DBG_ALL,("ESCheck %x \n", Adapter->EncryptionStatus));
switch(Adapter->EncryptionStatus)
{
case Ndis802_11Encryption1Enabled:
case Ndis802_11EncryptionDisabled:
case Ndis802_11Encryption2Enabled:
case Ndis802_11Encryption3Enabled:
IsAllowPS = 1;
break;
default:
IsAllowPS = 0;
break;
}
return IsAllowPS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -