📄 wlan_pmufsm.c
字号:
else
{
DEBUGMSG(1,(L"PMU Trace:" L"Register KEYBAD message proc funtion sucessfully!"));
}
#ifdef WLAN_PMU_DEBUG
DEBUGMSG(1,(L"PMU INFO:" L"ARP dst mac addr is 0x%x", &pCB->stARPBuffer.dst_mac[0]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP src mac addr is 0x%x", &pCB->stARPBuffer.src_mac[0]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP type addr is 0x%x", &pCB->stARPBuffer.type));
DEBUGMSG(1,(L"PMU INFO:" L"ARP hw_type addr is 0x%x", &pCB->stARPBuffer.hw_type));
DEBUGMSG(1,(L"PMU INFO:" L"ARP protocol_type addr is 0x%x", &pCB->stARPBuffer.protocol_type));
DEBUGMSG(1,(L"PMU INFO:" L"ARP hw_size addr is 0x%x", &pCB->stARPBuffer.hw_size));
DEBUGMSG(1,(L"PMU INFO:" L"ARP protocol_size addr is 0x%x",&pCB->stARPBuffer.protocol_size));
DEBUGMSG(1,(L"PMU INFO:" L"ARP code addr is 0x%x", &pCB->stARPBuffer.code));
DEBUGMSG(1,(L"PMU INFO:" L"ARP sender mac addr is 0x%x", &pCB->stARPBuffer.sender_mac[0]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP sender ip addr is 0x%x", &pCB->stARPBuffer.sender_ip[0]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP target mac addr is 0x%x", &pCB->stARPBuffer.target_mac[0]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP target ip addr is 0x%x", &pCB->stARPBuffer.target_ip[0]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP dst mac is %2x:%2x:%2x:%2x:%2x:%2x", pCB->stARPBuffer.dst_mac[0],
pCB->stARPBuffer.dst_mac[1],
pCB->stARPBuffer.dst_mac[2],
pCB->stARPBuffer.dst_mac[3],
pCB->stARPBuffer.dst_mac[4],
pCB->stARPBuffer.dst_mac[5]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP src mac is %2x:%2x:%2x:%2x:%2x:%2x", pCB->stARPBuffer.src_mac[0],
pCB->stARPBuffer.src_mac[1],
pCB->stARPBuffer.src_mac[2],
pCB->stARPBuffer.src_mac[3],
pCB->stARPBuffer.src_mac[4],
pCB->stARPBuffer.src_mac[5]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP type is 0x%x", pCB->stARPBuffer.type));
DEBUGMSG(1,(L"PMU INFO:" L"ARP hw_type is 0x%x", pCB->stARPBuffer.hw_type));
DEBUGMSG(1,(L"PMU INFO:" L"ARP protocol_type is 0x%x", pCB->stARPBuffer.protocol_type));
DEBUGMSG(1,(L"PMU INFO:" L"ARP hw_size is 0x%x", pCB->stARPBuffer.hw_size));
DEBUGMSG(1,(L"PMU INFO:" L"ARP protocol_size is 0x%x", pCB->stARPBuffer.protocol_size));
DEBUGMSG(1,(L"PMU INFO:" L"ARP code is 0x%x", pCB->stARPBuffer.code));
DEBUGMSG(1,(L"PMU INFO:" L"ARP sender mac is %2x:%2x:%2x:%2x:%2x:%2x", pCB->stARPBuffer.sender_mac[0],
pCB->stARPBuffer.sender_mac[1],
pCB->stARPBuffer.sender_mac[2],
pCB->stARPBuffer.sender_mac[3],
pCB->stARPBuffer.sender_mac[4],
pCB->stARPBuffer.sender_mac[5]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP sender ip is %2x:%2x:%2x:%2x:%2x:%2x", pCB->stARPBuffer.sender_ip[0],
pCB->stARPBuffer.sender_ip[1],
pCB->stARPBuffer.sender_ip[2],
pCB->stARPBuffer.sender_ip[3]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP target mac is %2x:%2x:%2x:%2x:%2x:%2x", pCB->stARPBuffer.target_mac[0],
pCB->stARPBuffer.target_mac[1],
pCB->stARPBuffer.target_mac[2],
pCB->stARPBuffer.target_mac[3],
pCB->stARPBuffer.target_mac[4],
pCB->stARPBuffer.target_mac[5]));
DEBUGMSG(1,(L"PMU INFO:" L"ARP target ip is %2x:%2x:%2x:%2x:%2x:%2x", pCB->stARPBuffer.target_ip[0],
pCB->stARPBuffer.target_ip[1],
pCB->stARPBuffer.target_ip[2],
pCB->stARPBuffer.target_ip[3]));
#endif
// Sleep(100);
pCB->iInitCompleted = 1;
}
/*.......................................................................
* Func Name: wlan_PMUCheckWlanAppState
* Description: 检查应用状态
* Input: 无
* Output: 无
*/
int wlan_PMUCheckWlanAppState ()
{
int ret = FALSE;
WlanPmuCB *pCB = &g_stWlanPmuCB;
EnterCriticalSection(&pCB->IntCriticalSection);
if((pCB->iWlanAppStatusActive & WLAN_PMU_VOIP_BUSY) ||
(pCB->iWlanAppStatusActive & WLAN_PMU_IPAPP_BUSY))
ret = TRUE;
else
ret = FALSE;
LeaveCriticalSection(&pCB->IntCriticalSection);
return ret;
}
int wlan_PmuGetCmdQueLen(void)
{
int ret;
WlanPmuCB *pCB = &g_stWlanPmuCB;
EnterCriticalSection(&pCB->IntCriticalSection);
ret = pCB->iCurrentCmdCount;
LeaveCriticalSection(&pCB->IntCriticalSection);
return ret;
}
/*.......................................................................
* Func Name: wlan_PMUStartTxCmdTimer
* Description: Start Tx cmd timer, timeout reboot wlan
* Input: 无
* Output: 无
*/
void wlan_PMUStartTxCmdTimer ()
{
BOOLEAN timerStatus;
NdisMCancelTimer(&g_stWlanPmuCB.stTxCmdTimer, &timerStatus);
NdisMSetTimer(&g_stWlanPmuCB.stTxCmdTimer, WLAN_PMU_CMD_TIMEOUT);
}
/*.......................................................................
* Func Name: wlan_PMUReStartSleepModeCPURunTimer
* Description: Start Tx cmd timer, timeout reboot wlan
* Input: 无
* Output: 无
*/
#ifndef _WIN32_WCE
void wlan_PMUReStartSleepModeCPURunTimer ()
{
BOOLEAN timerStatus;
NdisMCancelTimer(&g_stWlanPmuCB.stSleepModeCPURunTimer, &timerStatus);
NdisMSetTimer(&g_stWlanPmuCB.stSleepModeCPURunTimer, WLAN_PMU_SLEEP_MODE_CPU_RUN_TIMEOUT);
}
#endif
#ifndef _WIN32_WCE
/*.......................................................................
* Func Name: wlan_PMUSetIfNetPrep
* Description: Set interface net Prepory.
* Input: 无
* Output: 无
*/
void wlan_PMUSetIfNetPrep (BYTE * data)
{
#ifdef WLAN_PMU_DEBUG
#ifndef _WIN32_WCE
int i;
#endif
#endif
WlanPmuCB *pCB = &g_stWlanPmuCB;
if(pCB->iGotIfNetPrep == 1)
{
DEBUGMSG(1,(L"PMU TRACE:" L"KERNEL: Net report have been set."));
return;
}
EnterCriticalSection(&pCB->IntCriticalSection);
#ifndef _WIN32_WCE
copy_from_user(&pCB->stIfNetPrep,(u8*)data,sizeof(NetReport));
#endif
pCB->iGotIfNetPrep = 1;
LeaveCriticalSection(&pCB->IntCriticalSection);
#ifdef WLAN_PMU_DEBUG
#ifndef _WIN32_WCE
for( i = 0; i < pCB->stIfNetPrep.RPNumber; i ++ )
{
DEBUGMSG(1,(L"PMU INFO:" L "Net report: %s : %x", pCB->stIfNetPrep.RPUnit[i].RPName, pCB->stIfNetPrep.RPUnit[i].RPValue ));
}
#endif
#endif
return;
}
#endif
/*.......................................................................
* Func Name: wlan_ManualRoamingBusy
* Description: Manual roaming is processing, wakeup card and wait response.
* Input: 无
* Output: 无
*/
void wlan_ManualRoamingBusy ()
{
WlanPmuCB *pCB = &g_stWlanPmuCB;
DEBUGMSG(1,(L"PMU TRACE:" L"Manual roaming busy"));
if(pCB->iState == WLAN_PMU_FSM_STATUS_POWER_OFF)
return;
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->iGotIfNetPrep = 0;
#ifdef CONFIG_WLAN_PMU_ARP_RESPONSE
pCB->iARPFieldGot = 0;
pCB->iARPRespCount = 0;
pCB->iGetIPNetTableTimerSetted = 0;
#endif
pCB->iWlanAppStatusActive |= WLAN_PMU_ROAMING_BUSY;
pCB->iWlanAppStatusActive |= WLAN_PMU_DHCP_BUSY;
LeaveCriticalSection(&pCB->IntCriticalSection);
wlan_PMUWlanAppsWakeup();
wlan_WaitExitFromSleepMode(3*1000);
return;
}
/*.....................................
/*.......................................................................
* Func Name: wlan_PMUProfileChanged
* Description: User change the profile in GUI, or roaming change the profile.
* Input: 无
* Output: 无
*/
void wlan_PMUProfileChanged ()
{
WlanPmuCB *pCB = &g_stWlanPmuCB;
DEBUGMSG(1,(L"PMU TRACE:" L"Profile changed"));
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->iGotIfNetPrep = 0;
#ifdef CONFIG_WLAN_PMU_ARP_RESPONSE
pCB->iARPFieldGot = 0;
pCB->iARPRespCount = 0;
pCB->iGetIPNetTableTimerSetted = 0;
#endif
// pCB->iWlanAppStatusActive |= WLAN_PMU_DHCP_BUSY;
LeaveCriticalSection(&pCB->IntCriticalSection);
// wlan_PMUWlanAppsWakeup();
// wlan_WaitExitFromSleepMode(3*1000);
return;
}
/*.......................................................................
* Func Name: wlan_PMUStartExitSleepCmdTimer
* Description: Start exit sleep cmd timer
* Input: 无
* Output: 无
*/
void wlan_PMUStartExitSleepCmdTimer ()
{
BOOLEAN timerStatus;
NdisMCancelTimer(&g_stWlanPmuCB.stExitSleepCmdTimer, &timerStatus);
NdisMSetTimer(&g_stWlanPmuCB.stExitSleepCmdTimer, WLAN_PMU_EXIT_SLEEP_TIMEOUT_VALUE);
}
/*.......................................................................
* Func Name: wlan_PMUCheckFsmState
* Description: Check if upper layer can operate the card.(Set information, OidProc)
* Input: 无
* Output: 1 WLAN Ready, 0 Not Ready
*/
int wlan_PMUCardReady ()
{
WlanPmuCB *pCB = &g_stWlanPmuCB;
int ret = 1;
DEBUGMSG(1,((L"PMU TRACE:" L"Check if upper layer can operate the card")));
EnterCriticalSection(&pCB->IntCriticalSection);
if(pCB->iState == WLAN_PMU_FSM_STATUS_POWER_OFF)
ret = 0;
else if(pCB->iState == WLAN_PMU_FSM_STATUS_DISCONNECTED)
ret = 1;
else if(pCB->iState == WLAN_PMU_FSM_STATUS_CONNECTED)
ret = 1;
else if(pCB->iState == WLAN_PMU_FSM_STATUS_SLEEP)
ret = 0;
else if(pCB->iState == WLAN_PMU_FSM_STATUS_DEEP_SLEEP)
ret = 0;
else {}
LeaveCriticalSection(&pCB->IntCriticalSection);
return ret;
}
/*.......................................................................
* Func Name: wlan_PMUGotRelatedAPs
* Description: After scan, we got the related APs
* Input: 无
* Output: 无
*/
void wlan_PMUGotRelatedAPs (BOOLEAN iGotAP )
{
WlanPmuCB *pCB = &g_stWlanPmuCB;
DEBUGMSG(1,((L"PMU TRACE:" L"GotRelated APs T/F: [%d]"), pCB->iGotRelatedAPs));
EnterCriticalSection(&pCB->IntCriticalSection);
pCB->iGotRelatedAPsOldStatus = pCB->iGotRelatedAPs;
if(iGotAP)
{
pCB->iGotRelatedAPs = 1;
}
else
{
pCB->iGotRelatedAPs = 0;
}
LeaveCriticalSection(&pCB->IntCriticalSection);
return;
}
/*.......................................................................
* Func Name: wlan_PMUCancelTxCmdTimer
* Description: Cancel Tx cmd timer
* Input: 无
* Output: 无
*/
void wlan_PMUCancelTxCmdTimer ()
{
BOOLEAN timerStatus;
NdisMCancelTimer(&g_stWlanPmuCB.stTxCmdTimer, &timerStatus);
}
/*.......................................................................
* Func Name: wlan_PMUTxCmdTimeout
* Description: Tx command timeout, reboot wlan
* Input: 无
* Output: 无
*/
VOID wlan_PMUTxCmdTimeout(
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_TX_CMD_TIMEOUT;
pmu_AppendCmdNode(cmd);
}
else
{
DEBUGMSG(1,(L"PMU ERROR:" L"No enough memory!"));
}
}
/*.......................................................................
* Func Name: wlan_PMUTxPacketTimeout
* Description: Tx packet timeout, reboot wlan
* Input: 无
* Output: 无
*/
void wlan_PMUTxPacketTimeout ()
{
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_TX_PACKET_TIMEOUT;
pmu_AppendCmdNode(cmd);
}
else
{
DEBUGMSG(1,(L"PMU ERROR:" L"No enough memory!"));
}
}
/*.......................................................................
* Func Name: wlan_PMUTurnoffDeepSleepTimer
* Description: Turn on/off the deep sleep retry timer.
* Input: 1 on /0 off
* Output: 无
*/
void wlan_PMUTurnoffDeepSleepTimer (int iIsOn)
{
PMRVDRV_ADAPTER adapter = g_stWlanPmuCB.adapter;
WlanPmuCB *pCB = &g_stWlanPmuCB;
BOOLEAN timerStatus;
DEBUGMSG(1,(L"PMU TRACE:" L"(on 1-off 0) value is %d", iIsOn));
if(!adapter) {
return;
}
if(pCB->iState == WLAN_PMU_FSM_STATUS_POWER_OFF)
{
return;
}
EnterCriticalSection(&pCB->IntCriticalSection);
if(adapter->IsDeepSleep)
{
if(iIsOn)
{
pCB->iSDBusAppStatus = 0;
pCB->iDeepSleepRestartInterval = WLAN_PMU_DEEP_SLEEP_RESET_DEF_INTERVAL;
NdisMCancelTimer(&pCB->stExitDSAssociateTimer, &timerStatus);
NdisMSetTimer(&pCB->stExitDSAssociateTimer, 10000);
}
else
{
pCB->iSDBusAppStatus = 1;
pCB->iDeepSleepRestartInterval = 5*WLAN_PMU_DEEP_SLEEP_RESET_DEF_INTERVAL;
NdisMCancelTimer(&pCB->stExitDSAssociateTimer, &timerStatus);
NdisMSetTimer(&pCB->stExitDSAssociateTimer, pCB->iDeepSleepRestartInterval);
}
}
LeaveCriticalSection(&pCB->IntCriticalSection);
return;
}
/*...................................................
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -