⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mlme.c

📁 ralink 2870 usb无线网卡 最新驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
				WpaStateMachineInit(pAd, &pAd->Mlme.WpaMachine, pAd->Mlme.WpaFunc);		ActionStateMachineInit(pAd, &pAd->Mlme.ActMachine, pAd->Mlme.ActFunc);		// Init mlme periodic timer		RTMPInitTimer(pAd, &pAd->Mlme.PeriodicTimer, GET_TIMER_FUNCTION(MlmePeriodicExec), pAd, TRUE);		// Set mlme periodic timer		RTMPSetTimer(&pAd->Mlme.PeriodicTimer, MLME_TASK_EXEC_INTV);		// software-based RX Antenna diversity		RTMPInitTimer(pAd, &pAd->Mlme.RxAntEvalTimer, GET_TIMER_FUNCTION(AsicRxAntEvalTimeout), pAd, FALSE);#ifdef CONFIG_STA_SUPPORT		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)		{			RTMPInitTimer(pAd, &pAd->Mlme.LinkDownTimer, GET_TIMER_FUNCTION(LinkDownExec), pAd, FALSE);#ifdef RTMP_MAC_USB			RTMPInitTimer(pAd, &pAd->Mlme.AutoWakeupTimer, GET_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout), pAd, FALSE);			pAd->Mlme.AutoWakeupTimerRunning = FALSE;#endif // RTMP_MAC_USB //		}#endif // CONFIG_STA_SUPPORT //	} while (FALSE);	DBGPRINT(RT_DEBUG_TRACE, ("<-- MLME Initialize\n"));	return Status;}/*	==========================================================================	Description:		main loop of the MLME	Pre:		Mlme has to be initialized, and there are something inside the queue	Note:		This function is invoked from MPSetInformation and MPReceive;		This task guarantee only one MlmeHandler will run. 	IRQL = DISPATCH_LEVEL		========================================================================== */VOID MlmeHandler(	IN PRTMP_ADAPTER pAd) {	MLME_QUEUE_ELEM 	   *Elem = NULL;#ifdef APCLI_SUPPORT	SHORT apcliIfIndex;#endif // APCLI_SUPPORT //	// Only accept MLME and Frame from peer side, no other (control/data) frame should	// get into this state machine	NdisAcquireSpinLock(&pAd->Mlme.TaskLock);	if(pAd->Mlme.bRunning) 	{		NdisReleaseSpinLock(&pAd->Mlme.TaskLock);		return;	} 	else 	{		pAd->Mlme.bRunning = TRUE;	}	NdisReleaseSpinLock(&pAd->Mlme.TaskLock);	while (!MlmeQueueEmpty(&pAd->Mlme.Queue)) 	{		if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_MLME_RESET_IN_PROGRESS) ||			RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS) ||			RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))		{			DBGPRINT(RT_DEBUG_TRACE, ("Device Halted or Removed or MlmeRest, exit MlmeHandler! (queue num = %ld)\n", pAd->Mlme.Queue.Num));			break;		}		#ifdef RALINK_ATE					if(ATE_ON(pAd))		{			DBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now in MlmeHandler\n"));			break;		}	#endif // RALINK_ATE //		//From message type, determine which state machine I should drive		if (MlmeDequeue(&pAd->Mlme.Queue, &Elem)) 		{#ifdef RTMP_MAC_USB			if (Elem->MsgType == MT2_RESET_CONF)			{				DBGPRINT_RAW(RT_DEBUG_TRACE, ("!!! reset MLME state machine !!!\n"));				MlmeRestartStateMachine(pAd);				Elem->Occupied = FALSE;				Elem->MsgLen = 0;				continue;			}#endif // RTMP_MAC_USB //			// if dequeue success			switch (Elem->Machine) 			{				// STA state machines#ifdef CONFIG_STA_SUPPORT				case ASSOC_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.AssocMachine, Elem);					break;				case AUTH_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.AuthMachine, Elem);					break;				case AUTH_RSP_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.AuthRspMachine, Elem);					break;				case SYNC_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.SyncMachine, Elem);					break;				case MLME_CNTL_STATE_MACHINE:					MlmeCntlMachinePerformAction(pAd, &pAd->Mlme.CntlMachine, Elem);					break;				case WPA_PSK_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.WpaPskMachine, Elem);					break;	#ifdef QOS_DLS_SUPPORT				case DLS_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.DlsMachine, Elem);					break;#endif // QOS_DLS_SUPPORT //#endif // CONFIG_STA_SUPPORT //										case ACTION_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.ActMachine, Elem);					break;					case WPA_STATE_MACHINE:					StateMachinePerformAction(pAd, &pAd->Mlme.WpaMachine, Elem);					break;				default:					DBGPRINT(RT_DEBUG_TRACE, ("ERROR: Illegal machine %ld in MlmeHandler()\n", Elem->Machine));					break;			} // end of switch			// free MLME element			Elem->Occupied = FALSE;			Elem->MsgLen = 0;		}		else {			DBGPRINT_ERR(("MlmeHandler: MlmeQueue empty\n"));		}	}	NdisAcquireSpinLock(&pAd->Mlme.TaskLock);	pAd->Mlme.bRunning = FALSE;	NdisReleaseSpinLock(&pAd->Mlme.TaskLock);}/*	==========================================================================	Description:		Destructor of MLME (Destroy queue, state machine, spin lock and timer)	Parameters:		Adapter - NIC Adapter pointer	Post:		The MLME task will no longer work properly	IRQL = PASSIVE_LEVEL	========================================================================== */VOID MlmeHalt(	IN PRTMP_ADAPTER pAd) {	BOOLEAN 	  Cancelled;	DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeHalt\n"));	if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))	{		// disable BEACON generation and other BEACON related hardware timers		AsicDisableSync(pAd);	}#ifdef CONFIG_STA_SUPPORT	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)	{#ifdef QOS_DLS_SUPPORT		UCHAR		i;#endif // QOS_DLS_SUPPORT //		// Cancel pending timers		RTMPCancelTimer(&pAd->MlmeAux.AssocTimer,		&Cancelled);		RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer,		&Cancelled);		RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer,	&Cancelled);		RTMPCancelTimer(&pAd->MlmeAux.AuthTimer,		&Cancelled);		RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer,		&Cancelled);		RTMPCancelTimer(&pAd->MlmeAux.ScanTimer,		&Cancelled);#ifdef QOS_DLS_SUPPORT		for (i=0; i<MAX_NUM_OF_DLS_ENTRY; i++)		{			RTMPCancelTimer(&pAd->StaCfg.DLSEntry[i].Timer, &Cancelled);		}#endif // QOS_DLS_SUPPORT //		RTMPCancelTimer(&pAd->Mlme.LinkDownTimer, &Cancelled);#ifdef RTMP_MAC_USB		RTMPCancelTimer(&pAd->Mlme.AutoWakeupTimer, &Cancelled);#endif // RTMP_MAC_USB //	}#endif // CONFIG_STA_SUPPORT //	RTMPCancelTimer(&pAd->Mlme.PeriodicTimer,		&Cancelled);	RTMPCancelTimer(&pAd->Mlme.RxAntEvalTimer,		&Cancelled);	if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))	{		RTMP_CHIP_OP *pChipOps = &pAd->chipOps;				// Set LED		RTMPSetLED(pAd, LED_HALT);		RTMPSetSignalLED(pAd, -100);	// Force signal strength Led to be turned off, firmware is not done it.#ifdef RTMP_MAC_USB		{			LED_CFG_STRUC LedCfg;			RTMP_IO_READ32(pAd, LED_CFG, &LedCfg.word);			LedCfg.field.LedPolar = 0;			LedCfg.field.RLedMode = 0;			LedCfg.field.GLedMode = 0;			LedCfg.field.YLedMode = 0;			RTMP_IO_WRITE32(pAd, LED_CFG, LedCfg.word);		}#endif // RTMP_MAC_USB //		if (pChipOps->AsicHaltAction)			pChipOps->AsicHaltAction(pAd);	}	RTMPusecDelay(5000);    //  5 msec to gurantee Ant Diversity timer canceled	MlmeQueueDestroy(&pAd->Mlme.Queue);	NdisFreeSpinLock(&pAd->Mlme.TaskLock);	DBGPRINT(RT_DEBUG_TRACE, ("<== MlmeHalt\n"));}VOID MlmeResetRalinkCounters(	IN  PRTMP_ADAPTER   pAd){	pAd->RalinkCounters.LastOneSecRxOkDataCnt = pAd->RalinkCounters.OneSecRxOkDataCnt;	// clear all OneSecxxx counters.	pAd->RalinkCounters.OneSecBeaconSentCnt = 0;	pAd->RalinkCounters.OneSecFalseCCACnt = 0;	pAd->RalinkCounters.OneSecRxFcsErrCnt = 0;	pAd->RalinkCounters.OneSecRxOkCnt = 0;	pAd->RalinkCounters.OneSecTxFailCount = 0;	pAd->RalinkCounters.OneSecTxNoRetryOkCount = 0;	pAd->RalinkCounters.OneSecTxRetryOkCount = 0;	pAd->RalinkCounters.OneSecRxOkDataCnt = 0;	pAd->RalinkCounters.OneSecReceivedByteCount = 0;	pAd->RalinkCounters.OneSecTransmittedByteCount = 0;	// TODO: for debug only. to be removed	pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] = 0;	pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] = 0;	pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] = 0;	pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] = 0;	pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BE] = 0;	pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_BK] = 0;	pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VI] = 0;	pAd->RalinkCounters.OneSecDmaDoneCount[QID_AC_VO] = 0;	pAd->RalinkCounters.OneSecTxDoneCount = 0;	pAd->RalinkCounters.OneSecRxCount = 0;	pAd->RalinkCounters.OneSecTxAggregationCount = 0;	pAd->RalinkCounters.OneSecRxAggregationCount = 0;	return;}/*	==========================================================================	Description:		This routine is executed periodically to -		1. Decide if it's a right time to turn on PwrMgmt bit of all 		   outgoiing frames		2. Calculate ChannelQuality based on statistics of the last		   period, so that TX rate won't toggling very frequently between a 		   successful TX and a failed TX.		3. If the calculated ChannelQuality indicated current connection not 		   healthy, then a ROAMing attempt is tried here.	IRQL = DISPATCH_LEVEL	========================================================================== */#define ADHOC_BEACON_LOST_TIME		(8*OS_HZ)  // 8 secVOID MlmePeriodicExec(	IN PVOID SystemSpecific1, 	IN PVOID FunctionContext, 	IN PVOID SystemSpecific2, 	IN PVOID SystemSpecific3) {	ULONG			TxTotalCnt;	PRTMP_ADAPTER	pAd = (RTMP_ADAPTER *)FunctionContext;#ifdef CONFIG_STA_SUPPORT#endif // CONFIG_STA_SUPPORT //	// Do nothing if the driver is starting halt state.	// This might happen when timer already been fired before cancel timer with mlmehalt	if ((RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_HALT_IN_PROGRESS |								fRTMP_ADAPTER_RADIO_OFF |								fRTMP_ADAPTER_RADIO_MEASUREMENT |								fRTMP_ADAPTER_RESET_IN_PROGRESS))))		return;		RTMP_MLME_PRE_SANITY_CHECK(pAd);#ifdef RALINK_ATE	/* Do not show RSSI until "Normal 1 second Mlme PeriodicExec". */	if (ATE_ON(pAd))	{		if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE != (MLME_TASK_EXEC_MULTIPLE - 1))	{			pAd->Mlme.PeriodicRound ++;			return;		}	}#endif // RALINK_ATE //#ifdef CONFIG_STA_SUPPORT	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)	{		// Do nothing if monitor mode is on		if (MONITOR_ON(pAd))			return;		if (pAd->Mlme.PeriodicRound & 0x1)		{			// This is the fix for wifi 11n extension channel overlapping test case.  for 2860D			if (((pAd->MACVersion & 0xffff) == 0x0101) && 				(STA_TGN_WIFI_ON(pAd)) &&				(pAd->CommonCfg.IOTestParm.bToggle == FALSE))				{					RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x24Bf);					pAd->CommonCfg.IOTestParm.bToggle = TRUE;				}				else if ((STA_TGN_WIFI_ON(pAd)) &&						((pAd->MACVersion & 0xffff) == 0x0101))				{					RTMP_IO_WRITE32(pAd, TXOP_CTRL_CFG, 0x243f);					pAd->CommonCfg.IOTestParm.bToggle = FALSE;				}		}	}#endif // CONFIG_STA_SUPPORT //	pAd->bUpdateBcnCntDone = FALSE;	//	RECBATimerTimeout(SystemSpecific1,FunctionContext,SystemSpecific2,SystemSpecific3);	pAd->Mlme.PeriodicRound ++;#ifdef RTMP_MAC_USB	// execute every 100ms, update the Tx FIFO Cnt for update Tx Rate.	NICUpdateFifoStaCounters(pAd);#endif // RTMP_MAC_USB //	// execute every 500ms 	if ((pAd->Mlme.PeriodicRound % 5 == 0) && RTMPAutoRateSwitchCheck(pAd)/*(OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED))*/)	{#ifdef CONFIG_STA_SUPPORT		// perform dynamic tx rate switching based on past TX history		IF_DEV_CONFIG_OPMODE_ON_STA(pAd)		{			if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)					)				&& (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)))				MlmeDynamicTxRateSwitching(pAd);		}#endif // CONFIG_STA_SUPPORT //	}	// Normal 1 second Mlme PeriodicExec.	if (pAd->Mlme.PeriodicRound %MLME_TASK_EXEC_MULTIPLE == 0)	{                pAd->Mlme.OneSecPeriodicRound ++;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -