📄 wlan_pmufsm.c
字号:
{
pCB->iGetIPNetTableTimerSetted = 0;
NdisMCancelTimer(&pCB->stGetIPNetTableTimer, &timerStatus);
}
else
{
NdisMCancelTimer(&pCB->stGetIPNetTableTimer, &timerStatus);
NdisMSetTimer(&pCB->stGetIPNetTableTimer, WLAN_PMU_GET_IP_TABLE_TIMEOUT*2);
pCB->iGetIPNetTableTimerSetted = 1;
}
return;
}
#endif
/*.......................................................................
* Func Name: wlan_PMUAdapterCheckTimerFunc
* Description: Check the adapter info, if none or only GSPI8385, bind it.
* Input: CB point
* Output: 无
*/
VOID wlan_PMUAdapterCheckTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
WlanPmuCB *pCB = FunctionContext;
SetEvent(pCB->hAdapterCheckEvent);
return;
}
/*.......................................................................
* Func Name: wlan_PMUSystemBusyTimerFunc
* Description: System busy too long, timeout.
* Input: CB point
* Output: 无
*/
VOID wlan_PMUDHCPTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
WlanPmuCB *pCB = FunctionContext;
DEBUGMSG(1,(L"PMU TRACE:" L"DHCP timeout"));
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->iWlanAppStatusActive &= ~WLAN_PMU_DHCP_BUSY;
pCB->iDHCPTimerSetted = 0;
LeaveCriticalSection(&pCB->IntCriticalSection);
SetEvent(pCB->hWlanSleepStatusEvent);
return;
}
/*.......................................................................
* Func Name: wlan_PMURebootCardFunc
* Description: reboot wlan card
* Input: 无
* Output: 无
*/
VOID wlan_PMURebootCardFunc()
{
WlanPmuCmdListNode *cmd = NULL;
NDIS_STATUS Status;
DEBUGMSG(1,(L"PMU TRACE:" L"Reboot"));
Status = MRVDRV_ALLOC_MEM((PVOID *)(&cmd), sizeof(WlanPmuCmdListNode));
if( Status == NDIS_STATUS_SUCCESS )
{
cmd->cmd_type = WLAN_PMU_CMD_REBOOT_CARD;
pmu_AppendCmdNode(cmd);
}
else
{
DEBUGMSG(1,(L"PMU ERROR:" L"No enough memory!"));
}
}
/*.......................................................................
* Func Name: wlan_PMUHostSleepConfirmTimerFunc
* Description: Tx command timeout, reboot wlan
* Input: 无
* Output: 无
*/
VOID wlan_PMUHostSleepConfirmTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
WlanPmuCmdListNode *cmd = NULL;
NDIS_STATUS Status;
DEBUGMSG(1,(L"PMU TRACE:" L"Timeout"));
Status = MRVDRV_ALLOC_MEM((PVOID *)(&cmd), sizeof(WlanPmuCmdListNode));
if( Status == NDIS_STATUS_SUCCESS )
{
cmd->cmd_type = WLAN_PMU_CMD_HOST_SLEEP_CONFIRM_TIMEOUT;
pmu_AppendCmdNode(cmd);
}
else
{
DEBUGMSG(1,(L"PMU ERROR:" L"No enough memory!"));
}
}
/*.......................................................................
* Func Name: wlan_PMUReassociateTimerFunc
* Description: CPU do standby.
* Input: CB point
* Output: 无
*/
VOID wlan_PMUReassociateTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
BOOLEAN timerStatus;
NDIS_STATUS Status;
WlanPmuCmdListNode *cmd = NULL;
WlanPmuCB *pCB = FunctionContext;
DEBUGMSG(1,(L"PMU TRACE:" L"Timeout"));
NdisMCancelTimer(&pCB->stSleepCmdTimer, &timerStatus);
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->bSetReassociateTimer = FALSE;
LeaveCriticalSection(&pCB->IntCriticalSection);
Status = MRVDRV_ALLOC_MEM((PVOID *)(&cmd), sizeof(WlanPmuCmdListNode));
if( Status == NDIS_STATUS_SUCCESS )
{
cmd->cmd_type = WLAN_PMU_CMD_REASSO_TIMEOUT;
cmd->args = 0;
pmu_AppendCmdNode(cmd);
}
else
{
DEBUGMSG(1,(L"PMU ERROR:" L"No enough memory!"));
}
}
/*.......................................................................
* Func Name: wlan_PMUArpReqSendTimerFunc
* Description: Send ARP request to keep the ARP entry.
* Input: CB point
* Output: 无
*/
#ifdef CONFIG_WLAN_PMU_ARP_REQUEST
VOID wlan_PMUArpReqSendTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
unsigned long ipAddr;
unsigned long ipMask;
unsigned long Gateway;
unsigned long SipSvrIpAddr;
unsigned long len = MAX_ADAPTER_ADDRESS_LENGTH;
WlanPmuCB *pCB = FunctionContext;
BOOLEAN timerStatus;
if(pCB->adapter->MediaConnectStatus == NdisMediaStateDisconnected)
{
return;
}
if(pCB->iGotIfNetPrep == 1)
{
pmu_GetIpFromStr(pCB->IPAddr.IpAddress.String, &ipAddr);
pmu_GetIpFromStr(pCB->IPAddr.IpMask.String, &ipMask);
pmu_GetIpFromStr(pCB->Gateway.IpAddress.String, &Gateway);
}
else
{
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->iArpReqSendTimerSeted = 0;
LeaveCriticalSection(&pCB->IntCriticalSection);
return;
}
FlushIpNetTable(pCB->dwIfIndex);
if(SendARP(ntohl(Gateway), 0, pCB->abyGWMacAddr,&len) != NO_ERROR)
{
DEBUGMSG(1,(L"PMU ERROR:" L"Request gateway ARP failed."));
}
if(pCB->dwSIPSvrIpaddr != 0)
{
if((pCB->dwSIPSvrIpaddr&ipMask) == (Gateway&ipMask))
{
if(SendARP(ntohl(pCB->dwSIPSvrIpaddr), 0, pCB->abySIPMacAddr,&len) != NO_ERROR)
{
DEBUGMSG(1,(L"PMU ERROR:" L"Request local SIP server ARP failed."));
}
}
}
NdisMCancelTimer(&pCB->stArpReqSendTimer, &timerStatus);
NdisMSetTimer(&pCB->stArpReqSendTimer, WLAN_PMU_ARP_ENTRY_KEEPING_INTERVAL);
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->iArpReqSendTimerSeted = 1;
LeaveCriticalSection(&pCB->IntCriticalSection);
return;
}
#endif
/*.......................................................................
* Func Name: wlan_PMUTxPktStatTimerFunc
* Description: Statistic the Tx packet count, if data rate is little to sleep.
* Input: CB point
* Output: 无
*/
VOID wlan_PMUTxPktStatTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
NDIS_STATUS Status;
WlanPmuCmdListNode *cmd = NULL;
WlanPmuCB *pCB = FunctionContext;
int cmd_type = 0;
BOOLEAN timerStatus;
#ifdef CONFIG_WLAN_PMU
DEBUGMSG(1,(TEXT("PMU TRACE: Statistic the TX packet count ,")));
#endif
EnterCriticalSection(&pCB->IntCriticalSection);
if(pCB->dwTxPktCount > (30*(WLAN_PMU_TX_PKT_STAT_INTERVAL/60000)))
{
NdisMCancelTimer(&pCB->stTxPktStatTimer, &timerStatus);
NdisMSetTimer(&pCB->stTxPktStatTimer, WLAN_PMU_TX_PKT_STAT_INTERVAL);
pCB->dwTxPktCount = 0;
LeaveCriticalSection(&pCB->IntCriticalSection);
}
else
{
pCB->iTxPktStatTimerSeted = 0;
pCB->dwTxPktCount = 0;
LeaveCriticalSection(&pCB->IntCriticalSection);
Status = MRVDRV_ALLOC_MEM((PVOID *)(&cmd), sizeof(WlanPmuCmdListNode));
if( Status == NDIS_STATUS_SUCCESS )
{
cmd->cmd_type = WLAN_PMU_CMD_LOW_DATA_RATE;
cmd->args = 0;
pmu_AppendCmdNode(cmd);
}
else
{
DEBUGMSG(1,(L"PMU ERROR:" L"No enough memory!"));
}
}
return;
}
/*.......................................................................
* Func Name: wlan_PMUHostWakeUpTimerFunc
* Description: In sleep mode, Check if need wakeup card.
* Input: CB point
* Output: 无
*/
VOID wlan_PMUHostWakeUpTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
NDIS_STATUS Status;
WlanPmuCmdListNode *cmd = NULL;
WlanPmuCB *pCB = FunctionContext;
int interval = 0;
int now;
BOOLEAN timerStatus;
#ifdef CONFIG_WLAN_PMU
DEBUGMSG(1,(TEXT("PMU TRACE: Host wakeup card")));
#endif
if(pCB->adapter->MediaConnectStatus == NdisMediaStateDisconnected)
return;
EnterCriticalSection(&pCB->adapter->TxCriticalSection);
if(pCB->adapter->TxPacketCount == 0)
interval = 2000;
else if(pCB->adapter->TxPacketCount < 2)
interval = 1500;
else if(pCB->adapter->TxPacketCount < 3)
interval = 1000;
else
interval = 500;
LeaveCriticalSection(&pCB->adapter->TxCriticalSection);
EnterCriticalSection(&pCB->IntCriticalSection);
NdisMCancelTimer(&pCB->stHostWakeUpTimer, &timerStatus);
NdisMSetTimer(&pCB->stHostWakeUpTimer, (interval));
pCB->iHostWakeUpTimerSeted = 1;
LeaveCriticalSection(&pCB->IntCriticalSection);
now = GetTickCount();
if(interval == (2000) && ((now - pCB->dwLastHostWakeTime) < (WLAN_PMU_ARP_ENTRY_KEEPING_INTERVAL - 2000)))
return;
pCB->dwLastHostWakeTime = now;
Status = MRVDRV_ALLOC_MEM((PVOID *)(&cmd), sizeof(WlanPmuCmdListNode));
if( Status == NDIS_STATUS_SUCCESS )
{
cmd->cmd_type = WLAN_PMU_CMD_HOST_WAKEUP_CARD;
cmd->args = 0;
pmu_AppendCmdNode(cmd);
}
else
{
DEBUGMSG(1,(L"PMU ERROR:" L"No enough memory!"));
}
return;
}
/*.......................................................................
* Func Name: wlan_PMUTxPkt
* Description: Every packet transmit will invoke the funtion.
* Input: CB point
* Output: 无
*/
void wlan_PMUTxPkt()
{
WlanPmuCB *pCB = &g_stWlanPmuCB;
BOOLEAN timerStatus;
if(pCB->adapter->MediaConnectStatus == NdisMediaStateDisconnected)
{
return;
}
if(pCB->iState != WLAN_PMU_FSM_STATUS_SLEEP)
{
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->dwTxPktCount++;
LeaveCriticalSection(&pCB->IntCriticalSection);
return;
}
else
{
int count = 0;
EnterCriticalSection(&pCB->adapter->TxCriticalSection);
count = pCB->adapter->TxPacketCount;
LeaveCriticalSection(&pCB->adapter->TxCriticalSection);
if(count >= 2)
{
if(pCB->iHostWakeUpTimerSeted)
{
NdisMCancelTimer(&pCB->stHostWakeUpTimer, &timerStatus);
NdisMSetTimer(&pCB->stHostWakeUpTimer, 100);
}
}
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->dwTxPktCount = 0;
LeaveCriticalSection(&pCB->IntCriticalSection);
}
return;
}
/*.......................................................................
* Func Name: wlan_PMUSleepModeCPURunTimerFunc
* Description: Enter sleep command resend timeout.
* Input: CB point
* Output: 无
*/
#ifndef _WIN32_WCE
VOID wlan_PMUSleepModeCPURunTimerFunc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3
)
{
BOOLEAN timerStatus;
WlanPmuCB *pCB = FunctionContext;
DEBUGMSG(1,(L"PMU TRACE:" L"Timeout"));
NdisMCancelTimer(&pCB->stSleepCmdTimer, &timerStatus);
pmu_FsmSleepModeCPURunTimeout(pCB);
return;
}
#endif
/*.......................................................................
* Func Name: wlan_PMUSleepCmdTimerFunc
* Description: Enter sleep command resend timeout.
* Input: CB point
* Output: 无
*/
VOID wlan_PMUSleepCmdTimerFunc(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -