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

📄 rt_linux.h

📁 ralink 2870 usb无线网卡 最新驱动
💻 H
📖 第 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_linux.h    Abstract:    Revision History:    Who          When          What    ---------    ----------    ----------------------------------------------*/#ifndef __RT_LINUX_H__#define __RT_LINUX_H__#include <linux/module.h>#include <linux/version.h>#include <linux/kernel.h>#include <linux/spinlock.h>#include <linux/init.h>#include <linux/string.h>#include <linux/timer.h>#include <linux/errno.h>#include <linux/slab.h>#include <linux/interrupt.h>#include <linux/pci.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/skbuff.h>#include <linux/ethtool.h>#include <linux/wireless.h>#include <linux/proc_fs.h>#include <linux/delay.h>#include <linux/if_arp.h>#include <linux/ctype.h>#include <linux/vmalloc.h>#include <linux/wireless.h>#include <net/iw_handler.h>// load firmware#define __KERNEL_SYSCALLS__#include <linux/unistd.h>#include <asm/uaccess.h>#include <asm/types.h>#include <asm/unaligned.h>	// for get_unaligned()#ifdef KTHREAD_SUPPORT#include <linux/err.h>#include <linux/kthread.h>#endif // KTHREAD_SUPPORT //#undef AP_WSC_INCLUDED#undef STA_WSC_INCLUDED#undef WSC_INCLUDED#ifdef CONFIG_STA_SUPPORT#endif // CONFIG_STA_SUPPORT //#ifdef KTHREAD_SUPPORT#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)#error "This kerne version doesn't support kthread!!"#endif#endif // KTHREAD_SUPPORT ///*********************************************************************************** *	Profile related sections ***********************************************************************************/#ifdef CONFIG_STA_SUPPORT#ifdef RTMP_MAC_USB#define STA_PROFILE_PATH			"/etc/Wireless/RT2870STA/RT2870STA.dat"#define STA_DRIVER_VERSION			"2.1.0.0"#ifdef MULTIPLE_CARD_SUPPORT#define CARD_INFO_PATH			"/etc/Wireless/RT2870STA/RT2870STACard.dat"#endif // MULTIPLE_CARD_SUPPORT //#endif // RTMP_MAC_USB //extern	const struct iw_handler_def rt28xx_iw_handler_def;#endif // CONFIG_STA_SUPPORT //#ifdef CONFIG_APSTA_MIXED_SUPPORTextern	const struct iw_handler_def rt28xx_ap_iw_handler_def;#endif // CONFIG_APSTA_MIXED_SUPPORT ///*********************************************************************************** *	Compiler related definitions ***********************************************************************************/#undef __inline#define __inline		static inline#define IN#define OUT#define INOUT#define NDIS_STATUS		INT/*********************************************************************************** *	OS Specific definitions and data structures ***********************************************************************************/typedef struct pci_dev 		* PPCI_DEV;typedef struct net_device	* PNET_DEV;typedef void				* PNDIS_PACKET;typedef char				NDIS_PACKET;typedef PNDIS_PACKET		* PPNDIS_PACKET;typedef	dma_addr_t			NDIS_PHYSICAL_ADDRESS;typedef	dma_addr_t			* PNDIS_PHYSICAL_ADDRESS;typedef void				* NDIS_HANDLE;typedef char 				* PNDIS_BUFFER;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
typedef	struct pid *	RTMP_OS_PID;
#else
typedef pid_t 			RTMP_OS_PID;
#endiftypedef struct semaphore	RTMP_OS_SEM;typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)#define RT_MOD_INC_USE_COUNT() \	if (!try_module_get(THIS_MODULE)) \	{ \		DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __FUNCTION__)); \		return -1; \	}#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);#else#define RT_MOD_INC_USE_COUNT()	MOD_INC_USE_COUNT;#define RT_MOD_DEC_USE_COUNT() MOD_DEC_USE_COUNT;#endif#define RTMP_INC_REF(_A)		0#define RTMP_DEC_REF(_A)		0#define RTMP_GET_REF(_A)		0#if WIRELESS_EXT >= 12// This function will be called when query /procstruct iw_statistics *rt28xx_get_wireless_stats(    IN struct net_device *net_dev);#endif/*********************************************************************************** *	Network related constant definitions ***********************************************************************************/#ifndef IFNAMSIZ#define IFNAMSIZ 16#endif#define ETH_LENGTH_OF_ADDRESS	6#define NDIS_STATUS_SUCCESS                     0x00#define NDIS_STATUS_FAILURE                     0x01#define NDIS_STATUS_INVALID_DATA				0x02#define NDIS_STATUS_RESOURCES                   0x03#define NDIS_SET_PACKET_STATUS(_p, _status)			do{} while(0)#define NdisWriteErrorLogEntry(_a, _b, _c, _d)		do{} while(0)/* statistics counter */#define STATS_INC_RX_PACKETS(_pAd, _dev)#define STATS_INC_TX_PACKETS(_pAd, _dev)#define STATS_INC_RX_BYTESS(_pAd, _dev, len)#define STATS_INC_TX_BYTESS(_pAd, _dev, len)#define STATS_INC_RX_ERRORS(_pAd, _dev)#define STATS_INC_TX_ERRORS(_pAd, _dev)#define STATS_INC_RX_DROPPED(_pAd, _dev)#define STATS_INC_TX_DROPPED(_pAd, _dev)/*********************************************************************************** *	Ralink Specific network related constant definitions ***********************************************************************************/#define MIN_NET_DEVICE_FOR_AID			0x00		//0x00~0x3f#define MIN_NET_DEVICE_FOR_MBSSID		0x00		//0x00,0x10,0x20,0x30#define MIN_NET_DEVICE_FOR_WDS			0x10		//0x40,0x50,0x60,0x70#define MIN_NET_DEVICE_FOR_APCLI		0x20#define MIN_NET_DEVICE_FOR_MESH			0x30#ifdef CONFIG_STA_SUPPORT#define MIN_NET_DEVICE_FOR_DLS			0x40#endif // CONFIG_STA_SUPPORT //#define NET_DEVICE_REAL_IDX_MASK		0x0f		// for each operation mode, we maximum support 15 entities.#ifdef CONFIG_STA_SUPPORT#define NDIS_PACKET_TYPE_DIRECTED		0#define NDIS_PACKET_TYPE_MULTICAST		1#define NDIS_PACKET_TYPE_BROADCAST		2#define NDIS_PACKET_TYPE_ALL_MULTICAST	3#define NDIS_PACKET_TYPE_PROMISCUOUS	4#endif // CONFIG_STA_SUPPORT ///*********************************************************************************** *	OS signaling related constant definitions ***********************************************************************************//*********************************************************************************** *	OS file operation related data structure definitions ***********************************************************************************/typedef struct file* RTMP_OS_FD;typedef struct _RTMP_OS_FS_INFO_{	int				fsuid;	int				fsgid;	mm_segment_t	fs;}RTMP_OS_FS_INFO;#define IS_FILE_OPEN_ERR(_fd) 	IS_ERR((_fd))/*********************************************************************************** *	OS semaphore related data structure and definitions ***********************************************************************************/struct os_lock  {	spinlock_t		lock;	unsigned long  	flags;};typedef spinlock_t			NDIS_SPIN_LOCK;////  spin_lock enhanced for Nested spin lock//#define NdisAllocateSpinLock(__lock)      \{                                       \    spin_lock_init((spinlock_t *)(__lock));               \}#define NdisFreeSpinLock(lock)          \	do{}while(0)#define RTMP_SEM_LOCK(__lock)					\{												\	spin_lock_bh((spinlock_t *)(__lock));		\}#define RTMP_SEM_UNLOCK(__lock)					\{												\	spin_unlock_bh((spinlock_t *)(__lock));		\}// sample, use semaphore lock to replace IRQ lock, 2007/11/15#define RTMP_IRQ_LOCK(__lock, __irqflags)			\{													\	__irqflags = 0;									\	spin_lock_bh((spinlock_t *)(__lock));			\	pAd->irq_disabled |= 1; \}#define RTMP_IRQ_UNLOCK(__lock, __irqflag)			\{													\	pAd->irq_disabled &= 0; 						\	spin_unlock_bh((spinlock_t *)(__lock));			\}#define RTMP_INT_LOCK(__lock, __irqflags)			\{													\	spin_lock_irqsave((spinlock_t *)__lock, __irqflags);	\}#define RTMP_INT_UNLOCK(__lock, __irqflag)			\{													\	spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag));	\}#define NdisAcquireSpinLock		RTMP_SEM_LOCK#define NdisReleaseSpinLock		RTMP_SEM_UNLOCK#ifndef wait_event_interruptible_timeout#define __wait_event_interruptible_timeout(wq, condition, ret) \do { \        wait_queue_t __wait; \        init_waitqueue_entry(&__wait, current); \        add_wait_queue(&wq, &__wait); \        for (;;) { \                set_current_state(TASK_INTERRUPTIBLE); \                if (condition) \                        break; \                if (!signal_pending(current)) { \                        ret = schedule_timeout(ret); \                        if (!ret) \                                break; \                        continue; \                } \                ret = -ERESTARTSYS; \                break; \        } \        current->state = TASK_RUNNING; \        remove_wait_queue(&wq, &__wait); \} while (0)#define wait_event_interruptible_timeout(wq, condition, timeout) \({ \        long __ret = timeout; \        if (!(condition)) \                __wait_event_interruptible_timeout(wq, condition, __ret); \        __ret; \})#endif#define RTMP_SEM_EVENT_INIT_LOCKED(_pSema) 	sema_init((_pSema), 0)#define RTMP_SEM_EVENT_INIT(_pSema)			sema_init((_pSema), 1)#define RTMP_SEM_EVENT_WAIT(_pSema, _status)	((_status) = down_interruptible((_pSema)))#define RTMP_SEM_EVENT_UP(_pSema)			up(_pSema)#ifdef KTHREAD_SUPPORT#define RTMP_WAIT_EVENT_INTERRUPTIBLE(_pAd, _pTask) \{ \		wait_event_interruptible(_pTask->kthread_q, \								 _pTask->kthread_running || kthread_should_stop()); \		_pTask->kthread_running = FALSE; \		if (kthread_should_stop()) \		{ \			RTMP_SET_FLAG(_pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); \			break; \		} \}#endif#ifdef KTHREAD_SUPPORT#define WAKE_UP(_pTask) \	do{ \		if ((_pTask)->kthread_task) \        { \			(_pTask)->kthread_running = TRUE; \	        wake_up(&(_pTask)->kthread_q); \		} \	}while(0)#endif/*********************************************************************************** *	OS Memory Access related data structure and definitions ***********************************************************************************/#define MEM_ALLOC_FLAG      (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)#define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)#define NdisCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)#define NdisZeroMemory(Destination, Length)         memset(Destination, 0, Length)#define NdisFillMemory(Destination, Length, Fill)   memset(Destination, Fill, Length)#define NdisCmpMemory(Destination, Source, Length)  memcmp(Destination, Source, Length)#define NdisEqualMemory(Source1, Source2, Length)   (!memcmp(Source1, Source2, Length))#define RTMPEqualMemory(Source1, Source2, Length)	(!memcmp(Source1, Source2, Length))#define MlmeAllocateMemory(_pAd, _ppVA)		os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)#define MlmeFreeMemory(_pAd, _pVA)			os_free_mem(_pAd, _pVA)#define COPY_MAC_ADDR(Addr1, Addr2)             memcpy((Addr1), (Addr2), MAC_ADDR_LEN)/*********************************************************************************** *	OS task related data structure and definitions ***********************************************************************************/#define RTMP_OS_MGMT_TASK_FLAGS	CLONE_VM#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)typedef	struct pid *	THREAD_PID;#define	THREAD_PID_INIT_VALUE	NULL#define	GET_PID(_v)	find_get_pid((_v))#define	GET_PID_NUMBER(_v)	pid_nr((_v))#define CHECK_PID_LEGALITY(_pid)	if (pid_nr((_pid)) >= 0)#define KILL_THREAD_PID(_A, _B, _C)	kill_pid((_A), (_B), (_C))#elsetypedef	pid_t	THREAD_PID;#define	THREAD_PID_INIT_VALUE	-1#define	GET_PID(_v)	(_v)#define	GET_PID_NUMBER(_v)	(_v)#define CHECK_PID_LEGALITY(_pid)	if ((_pid) >= 0)#define KILL_THREAD_PID(_A, _B, _C)	kill_proc((_A), (_B), (_C))#endiftypedef struct tasklet_struct  RTMP_NET_TASK_STRUCT;typedef struct tasklet_struct  *PRTMP_NET_TASK_STRUCT;/*********************************************************************************** * Timer related definitions and data structures. **********************************************************************************/#define OS_HZ			HZtypedef struct timer_list	NDIS_MINIPORT_TIMER;typedef struct timer_list	RTMP_OS_TIMER;typedef void (*TIMER_FUNCTION)(unsigned long);#define OS_WAIT(_time) \{	int _i; \	long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\	wait_queue_head_t _wait; \	init_waitqueue_head(&_wait); \	for (_i=0; _i<(_loop); _i++) \		wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
#define RTMP_TIME_AFTER(a,b)		\
	(typecheck(unsigned long, (unsigned long)a) && \
	 typecheck(unsigned long, (unsigned long)b) && \
	 ((long)(b) - (long)(a) < 0))

#define RTMP_TIME_AFTER_EQ(a,b)	\
	(typecheck(unsigned long, (unsigned long)a) && \
	 typecheck(unsigned long, (unsigned long)b) && \
	 ((long)(a) - (long)(b) >= 0))
#define RTMP_TIME_BEFORE(a,b)	RTMP_TIME_AFTER_EQ(b,a)
#else
#define typecheck(type,x) \
({      type __dummy; \
        typeof(x) __dummy2; \
        (void)(&__dummy == &__dummy2); \
        1; \

⌨️ 快捷键说明

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