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

📄 rt_main_dev.c

📁 ralink 2870 usb无线网卡 最新驱动
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ************************************************************************* * Ralink Tech Inc. * 5F., No.36, Taiyuan St., Jhubei City, * Hsinchu County 302, * Taiwan, R.O.C. * * (c) Copyright 2002-2007, Ralink Technology, Inc. * * This program is free software; you can redistribute it and/or modify  *  * it under the terms of the GNU General Public License as published by  *  * the Free Software Foundation; either version 2 of the License, or     *  * (at your option) any later version.                                   *  *                                                                       *  * This program is distributed in the hope that it will be useful,       *  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *  * GNU General Public License for more details.                          *  *                                                                       *  * You should have received a copy of the GNU General Public License     *  * along with this program; if not, write to the                         *  * Free Software Foundation, Inc.,                                       *  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *  *                                                                       *  *************************************************************************    Module Name:    rt_main_dev.c    Abstract:    Create and register network interface.    Revision History:    Who         When            What    --------    ----------      ----------------------------------------------*/#include "rt_config.h"#ifdef CONFIG_APSTA_MIXED_SUPPORTUINT32 CW_MAX_IN_BITS;#endif // CONFIG_APSTA_MIXED_SUPPORT ///*---------------------------------------------------------------------*//* Private Variables Used                                              *//*---------------------------------------------------------------------*/PSTRING mac = "";		   // default 00:00:00:00:00:00PSTRING hostname = "";		   // default CMPC#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12)MODULE_PARM (mac, "s");#elsemodule_param (mac, charp, 0);#endifMODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");/*---------------------------------------------------------------------*//* Prototypes of Functions Used                                        *//*---------------------------------------------------------------------*/// public function prototypeint rt28xx_close(IN struct net_device *net_dev);int rt28xx_open(struct net_device *net_dev);// private function prototypestatic INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);static struct net_device_stats *RT28xx_get_ether_stats(    IN  struct net_device *net_dev);/*========================================================================Routine Description:    Close raxx interface.Arguments:	*net_dev			the raxx interface pointerReturn Value:    0					Open OK	otherwise			Open FailNote:	1. if open fail, kernel will not call the close function.	2. Free memory for		(1) Mlme Memory Handler:		MlmeHalt()		(2) TX & RX:					RTMPFreeTxRxRingMemory()		(3) BA Reordering: 				ba_reordering_resource_release()========================================================================*/int MainVirtualIF_close(IN struct net_device *net_dev){    RTMP_ADAPTER *pAd = net_dev->priv;	// Sanity check for pAd	if (pAd == NULL)		return 0; // close ok	netif_carrier_off(pAd->net_dev);	netif_stop_queue(pAd->net_dev);	VIRTUAL_IF_DOWN(pAd);	RT_MOD_DEC_USE_COUNT();	return 0; // close ok}/*========================================================================Routine Description:    Open raxx interface.Arguments:	*net_dev			the raxx interface pointerReturn Value:    0					Open OK	otherwise			Open FailNote:	1. if open fail, kernel will not call the close function.	2. Free memory for		(1) Mlme Memory Handler:		MlmeHalt()		(2) TX & RX:					RTMPFreeTxRxRingMemory()		(3) BA Reordering: 				ba_reordering_resource_release()========================================================================*/int MainVirtualIF_open(IN struct net_device *net_dev){    RTMP_ADAPTER *pAd = net_dev->priv;	// Sanity check for pAd	if (pAd == NULL)		return 0; // close ok	if (VIRTUAL_IF_UP(pAd) != 0)		return -1;	// increase MODULE use count	RT_MOD_INC_USE_COUNT();	netif_start_queue(net_dev);	netif_carrier_on(net_dev);	netif_wake_queue(net_dev);	return 0;}/*========================================================================Routine Description:    Close raxx interface.Arguments:	*net_dev			the raxx interface pointerReturn Value:    0					Open OK	otherwise			Open FailNote:	1. if open fail, kernel will not call the close function.	2. Free memory for		(1) Mlme Memory Handler:		MlmeHalt()		(2) TX & RX:					RTMPFreeTxRxRingMemory()		(3) BA Reordering: 				ba_reordering_resource_release()========================================================================*/int rt28xx_close(IN PNET_DEV dev){	struct net_device * net_dev = (struct net_device *)dev;    RTMP_ADAPTER	*pAd = net_dev->priv;	BOOLEAN 		Cancelled;	UINT32			i = 0;#ifdef RTMP_MAC_USB	DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup); 	DECLARE_WAITQUEUE(wait, current);	//RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);#endif // RTMP_MAC_USB //	DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));	Cancelled = FALSE;	// Sanity check for pAd	if (pAd == NULL)		return 0; // close ok#ifdef WDS_SUPPORT	WdsDown(pAd);#endif // WDS_SUPPORT //#ifdef CONFIG_STA_SUPPORT	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)	{		// If dirver doesn't wake up firmware here,		// NICLoadFirmware will hang forever when interface is up again.		if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))        {      		    AsicForceWakeup(pAd, TRUE);        }#ifdef QOS_DLS_SUPPORT		// send DLS-TEAR_DOWN message, 		if (pAd->CommonCfg.bDLSCapable)		{			UCHAR i;			// tear down local dls table entry			for (i=0; i<MAX_NUM_OF_INIT_DLS_ENTRY; i++)			{				if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))				{					RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);					pAd->StaCfg.DLSEntry[i].Status	= DLS_NONE;					pAd->StaCfg.DLSEntry[i].Valid	= FALSE;				}			}			// tear down peer dls table entry			for (i=MAX_NUM_OF_INIT_DLS_ENTRY; i<MAX_NUM_OF_DLS_ENTRY; i++)			{				if (pAd->StaCfg.DLSEntry[i].Valid && (pAd->StaCfg.DLSEntry[i].Status == DLS_FINISH))				{					RTMPSendDLSTearDownFrame(pAd, pAd->StaCfg.DLSEntry[i].MacAddr);					pAd->StaCfg.DLSEntry[i].Status = DLS_NONE;					pAd->StaCfg.DLSEntry[i].Valid	= FALSE;				}			}			RTMP_MLME_HANDLER(pAd);		}#endif // QOS_DLS_SUPPORT //		if (INFRA_ON(pAd) &&			(!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))		{			MLME_DISASSOC_REQ_STRUCT	DisReq;			MLME_QUEUE_ELEM *MsgElem = (MLME_QUEUE_ELEM *) kmalloc(sizeof(MLME_QUEUE_ELEM), MEM_ALLOC_FLAG);    			if (MsgElem)			{			COPY_MAC_ADDR(DisReq.Addr, pAd->CommonCfg.Bssid);			DisReq.Reason =  REASON_DEAUTH_STA_LEAVING;			MsgElem->Machine = ASSOC_STATE_MACHINE;			MsgElem->MsgType = MT2_MLME_DISASSOC_REQ;			MsgElem->MsgLen = sizeof(MLME_DISASSOC_REQ_STRUCT);			NdisMoveMemory(MsgElem->Msg, &DisReq, sizeof(MLME_DISASSOC_REQ_STRUCT));			// Prevent to connect AP again in STAMlmePeriodicExec			pAd->MlmeAux.AutoReconnectSsidLen= 32;			NdisZeroMemory(pAd->MlmeAux.AutoReconnectSsid, pAd->MlmeAux.AutoReconnectSsidLen);			pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_OID_DISASSOC;			MlmeDisassocReqAction(pAd, MsgElem);			kfree(MsgElem);			}						RTMPusecDelay(1000);		}#ifdef RTMP_MAC_USB	RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_REMOVE_IN_PROGRESS);#endif // RTMP_MAC_USB //		RTMPCancelTimer(&pAd->StaCfg.StaQuickResponeForRateUpTimer, &Cancelled);		RTMPCancelTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, &Cancelled);#ifdef WPA_SUPPLICANT_SUPPORT#ifndef NATIVE_WPA_SUPPLICANT_SUPPORT		// send wireless event to wpa_supplicant for infroming interface down.		RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, RT_INTERFACE_DOWN, NULL, NULL, 0);#endif // NATIVE_WPA_SUPPLICANT_SUPPORT //#endif // WPA_SUPPLICANT_SUPPORT //		MlmeRadioOff(pAd);	}#endif // CONFIG_STA_SUPPORT //	RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);	for (i = 0 ; i < NUM_OF_TX_RING; i++)	{		while (pAd->DeQueueRunning[i] == TRUE)		{			DBGPRINT(RT_DEBUG_TRACE, ("Waiting for TxQueue[%d] done..........\n", i));			RTMPusecDelay(1000);		}	}	#ifdef RTMP_MAC_USB	// ensure there are no more active urbs.	add_wait_queue (&unlink_wakeup, &wait);	pAd->wait = &unlink_wakeup;	// maybe wait for deletions to finish.	i = 0;	//while((i < 25) && atomic_read(&pAd->PendingRx) > 0) 	while(i < 25)	{		unsigned long IrqFlags;		RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags);		if (pAd->PendingRx == 0)		{			RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);			break;		}		RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags);		#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)		msleep(UNLINK_TIMEOUT_MS);	//Time in millisecond#else		RTMPusecDelay(UNLINK_TIMEOUT_MS*1000);	//Time in microsecond#endif		i++;	}	pAd->wait = NULL;	remove_wait_queue (&unlink_wakeup, &wait); #endif // RTMP_MAC_USB //	// Stop Mlme state machine	MlmeHalt(pAd);		// Close net tasklets	RtmpNetTaskExit(pAd);#ifdef CONFIG_STA_SUPPORT	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)	{		MacTableReset(pAd);	}#endif // CONFIG_STA_SUPPORT //	MeasureReqTabExit(pAd);	TpcReqTabExit(pAd);	// Close kernel threads	RtmpMgmtTaskExit(pAd);	// Free IRQ	if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE))	{		RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE);	}	// Free Ring or USB buffers	RTMPFreeTxRxRingMemory(pAd);	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);#ifdef DOT11_N_SUPPORT	// Free BA reorder resource	ba_reordering_resource_release(pAd);#endif // DOT11_N_SUPPORT //	#ifdef CONFIG_STA_SUPPORT#endif // CONFIG_STA_SUPPORT //	RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_START_UP);/*+++Modify by woody to solve the bulk fail+++*/#ifdef CONFIG_STA_SUPPORT	IF_DEV_CONFIG_OPMODE_ON_STA(pAd)	{	}#endif // CONFIG_STA_SUPPORT //	DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n"));	return 0; // close ok} /* End of rt28xx_close *//*========================================================================Routine Description:    Open raxx interface.Arguments:	*net_dev			the raxx interface pointerReturn Value:    0					Open OK	otherwise			Open FailNote:========================================================================*/int rt28xx_open(IN PNET_DEV dev){				 	struct net_device * net_dev = (struct net_device *)dev;	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)net_dev->priv;	int retval = 0; 	//POS_COOKIE pObj;	// Sanity check for pAd	if (pAd == NULL)	{		/* if 1st open fail, pAd will be free;		   So the net_dev->priv will be NULL in 2rd open */		return -1;	}#ifdef CONFIG_APSTA_MIXED_SUPPORT	if (pAd->OpMode == OPMODE_AP)	{		CW_MAX_IN_BITS = 6;	}	else if (pAd->OpMode == OPMODE_STA)	{

⌨️ 快捷键说明

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