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

📄 rtmp.h

📁 RT73_Linux_STA_Drv1.0.3.6 linux系统下
💻 H
📖 第 1 页 / 共 5 页
字号:
/*
 ***************************************************************************
 * Ralink Tech Inc.
 * 4F, No. 2 Technology 5th Rd.
 * Science-based Industrial Park
 * Hsin-chu, Taiwan, R.O.C.
 *
 * (c) Copyright 2002-2006, 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:
	rtmp.h

	Abstract:

	Revision History:
	Who			When		What
	--------	----------	----------------------------------------------
*/

#ifndef __RTMP_H__
#define __RTMP_H__

#include "mlme.h"
#include "oid.h"
#include "wpa.h"

//
// Extern
//
extern UCHAR BROADCAST_ADDR[MAC_ADDR_LEN];
extern UCHAR ZERO_MAC_ADDR[MAC_ADDR_LEN];
extern ULONG BIT32[32];
extern UCHAR BIT8[8];
extern char* CipherName[];

extern UCHAR SNAP_802_1H[6];
extern UCHAR SNAP_BRIDGE_TUNNEL[6];
extern UCHAR EAPOL_LLC_SNAP[8];
extern UCHAR EAPOL[2];
extern UCHAR IPX[2];
extern UCHAR APPLE_TALK[2];
extern UCHAR RateIdToPlcpSignal[12]; // see IEEE802.11a-1999 p.14
extern UCHAR OfdmSignalToRateId[16] ;
extern UCHAR default_cwmin[4];
extern UCHAR default_cwmax[4];
extern UCHAR default_sta_aifsn[4];
extern UCHAR MapUserPriorityToAccessCategory[8];

extern UCHAR  Phy11BNextRateDownward[];
extern UCHAR  Phy11BNextRateUpward[];
extern UCHAR  Phy11BGNextRateDownward[];
extern UCHAR  Phy11BGNextRateUpward[];
extern UCHAR  Phy11ANextRateDownward[];
extern UCHAR  Phy11ANextRateUpward[];
extern CHAR   RssiSafeLevelForTxRate[];
extern UCHAR  RateIdToMbps[];
extern USHORT RateIdTo500Kbps[];

extern UCHAR  CipherSuiteWpaNoneTkip[];
extern UCHAR  CipherSuiteWpaNoneTkipLen;

extern UCHAR  CipherSuiteWpaNoneAes[];
extern UCHAR  CipherSuiteWpaNoneAesLen;

extern UCHAR  SsidIe;
extern UCHAR  SupRateIe;
extern UCHAR  ExtRateIe;
extern UCHAR  ErpIe;
extern UCHAR  DsIe;
extern UCHAR  TimIe;
extern UCHAR  WpaIe;
extern UCHAR  Wpa2Ie;
extern UCHAR  IbssIe;

extern UCHAR  WPA_OUI[];
extern UCHAR  WME_INFO_ELEM[];
extern UCHAR  WME_PARM_ELEM[];
extern UCHAR  RALINK_OUI[];

extern struct usb_device_id rtusb_usb_id[];
extern INT const rtusb_usb_id_len;

//
// MACRO for linux usb
//
typedef struct urb *purbb_t;
typedef struct usb_ctrlrequest devctrlrequest;

// for vendor-specific control operations
#define CONTROL_TIMEOUT_MS		(1000)	 /* msec */  // lengthen timeout for loading firmware
#define CONTROL_TIMEOUT_JIFFIES ((CONTROL_TIMEOUT_MS * HZ)/1000)

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
#define RTUSB_UNLINK_URB(urb)	usb_kill_urb(urb)
#else
#define RTUSB_UNLINK_URB(urb)	usb_unlink_urb(urb)
#endif

/* map devrequest fields onto usb_ctrlrequest's */
#define DEVREQ_REQUEST(x)		((x)->bRequest)
#define DEVREQ_REQUESTTYPE(x)	((x)->bRequestType)
#define DEVREQ_VALUE(x) 		((x)->wValue)
#define DEVREQ_INDEX(x) 		((x)->wIndex)
#define DEVREQ_LENGTH(x)		((x)->wLength)

#define PURB		purbb_t
#define PIRP		PVOID
#define PMDL		PVOID
#define NDIS_OID	UINT	

#define STATUS_SUCCESS		0x00
#define STATUS_UNSUCCESSFUL 0x01

typedef LONG		NTSTATUS;
typedef NTSTATUS	*PNTSTATUS;


//
//	Queue structure and macros
//
typedef struct	_QUEUE_ENTRY	{
	struct _QUEUE_ENTRY 	*Next;
}	QUEUE_ENTRY, *PQUEUE_ENTRY;

// Queue structure
typedef struct	_QUEUE_HEADER	{
	PQUEUE_ENTRY	Head;
	PQUEUE_ENTRY	Tail;
	ULONG			Number;
}	QUEUE_HEADER, *PQUEUE_HEADER;

#define InitializeQueueHeader(QueueHeader)				\
{														\
	(QueueHeader)->Head = (QueueHeader)->Tail = NULL;	\
	(QueueHeader)->Number = 0;							\
}

#define RemoveHeadQueue(QueueHeader)				\
(QueueHeader)->Head;								\
{													\
	PQUEUE_ENTRY pNext; 							\
	if ((QueueHeader)->Head != NULL)				\
	{												\
		pNext = (QueueHeader)->Head->Next;			\
		(QueueHeader)->Head = pNext;				\
		if (pNext == NULL)							\
			(QueueHeader)->Tail = NULL; 			\
		(QueueHeader)->Number--;					\
	}												\
}

#define InsertHeadQueue(QueueHeader, QueueEntry)			\
{															\
	((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \
	(QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry);		\
	if ((QueueHeader)->Tail == NULL)						\
		(QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry);	\
	(QueueHeader)->Number++;								\
}

#define InsertTailQueue(QueueHeader, QueueEntry)				\
{																\
	((PQUEUE_ENTRY)QueueEntry)->Next = NULL;					\
	if ((QueueHeader)->Tail)									\
		(QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
	else														\
		(QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry);		\
	(QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry);			\
	(QueueHeader)->Number++;									\
}


//
//	Macro for debugging information
//
#ifdef DBG
extern ULONG	RTDebugLevel;

#define DBGPRINT(Level, fmt, args...)		\
{											\
	if (Level <= RTDebugLevel)				\
	{										\
		printk(NIC_DBG_STRING); 			\
		printk(KERN_DEBUG fmt, ## args);	\
	}										\
}

#define DBGPRINT_ERR(fmt, args...)			\
{											\
	printk("ERROR!!! ");					\
	printk(KERN_DEBUG fmt, ## args);		\
}

#define DBGPRINT_RAW(Level, fmt, args...)	\
{											\
	if (Level <= RTDebugLevel)				\
	{										\
		printk(" ");						\
		printk(KERN_DEBUG fmt, ## args);	\
	}										\
}
#else
#define DBGPRINT(Level, fmt, args...)
#define DBGPRINT_ERR(fmt, args...)
#define DBGPRINT_RAW(Level, fmt, args...)
#endif

#  define assert(expr)											\
		if(unlikely(!(expr))) {									\
		printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n",	\
		#expr,__FILE__,__FUNCTION__,__LINE__);					\
		}


//
//	spin_lock enhanced for Nested spin lock
//
#define	NdisAllocateSpinLock(lock)	\
{									\
	spin_lock_init(lock);			\
}
#if 0
#define NdisReleaseSpinLock(lock, flagg)    \
{											\
	if (in_interrupt())						\
		spin_unlock_irqrestore(lock, flagg);\
	else									\
		spin_unlock(lock);					\
}

#define NdisAcquireSpinLock(lock, flagg)    \
{											\
	if (in_interrupt())						\
		spin_lock_irqsave(lock, flagg);		\
	else									\
		spin_lock(lock);					\
}
#else
#define NdisReleaseSpinLock(lock, flagg)	\
{											\
	spin_unlock_irqrestore(lock, flagg);	\
}
#define NdisAcquireSpinLock(lock, flagg)	\
{											\
	spin_lock_irqsave(lock, flagg);			\
}
#endif

#define NdisFreeSpinLock(lock)			\
{										\
}

#define RTUSBFreeSkbBuffer(skb)				\
{											\
	dev_kfree_skb_any(skb);					\
}

#define RTUSBMlmeUp(pAd)	        \
{								    \
	if(pAd->MLMEThr_pid>0)		    \
        up(&(pAd->mlme_semaphore)); \
}

#define RTUSBCMDUp(pAd)	                \
{									    \
	if(pAd->RTUSBCmdThr_pid>0)		    \
	    up(&(pAd->RTUSBCmd_semaphore)); \
}

//Setup Packet used in Ctrl urb's filler....
#define FILL_REQUEST(a,aa,ab,ac,ad,ae)		\
  do {										\
	  (a)->devreq->request = aa;			\
	  (a)->devreq->requesttype = ab;		\
	  (a)->devreq->value = cpu_to_le16(ac); \
	  (a)->devreq->index = cpu_to_le16(ad); \
	  (a)->devreq->length = cpu_to_le16(ae);\
  }while(0);


// direction is specified in TransferFlags
#define URB_FUNCTION_RESERVED0						0x0016

//
// These are for sending vendor and class commands
// on the default pipe
//
// direction is specified in TransferFlags
#define URB_FUNCTION_VENDOR_DEVICE					 0x0017
#define URB_FUNCTION_VENDOR_INTERFACE				 0x0018
#define URB_FUNCTION_VENDOR_ENDPOINT				 0x0019
#define URB_FUNCTION_VENDOR_OTHER					 0x0020

#define URB_FUNCTION_CLASS_DEVICE					 0x001A
#define URB_FUNCTION_CLASS_INTERFACE				 0x001B
#define URB_FUNCTION_CLASS_ENDPOINT 				 0x001C
#define URB_FUNCTION_CLASS_OTHER					 0x001F

//
// Reserved function codes
//																										  
#define URB_FUNCTION_RESERVED						 0x001D

#define URB_FUNCTION_GET_CONFIGURATION				 0x0026
#define URB_FUNCTION_GET_INTERFACE					 0x0027
					
#define URB_FUNCTION_LAST							 0x0029


//
//	Assert MACRO to make sure program running
//
#undef	ASSERT
#define ASSERT(x)																\
{																				\
	if (!(x))																	\
	{																			\
		printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__);	\
	}																			\
}

//
//	Macros for flag and ref count operations
//
#define RTMP_SET_FLAG(_M, _F)		((_M)->Flags |= (_F))
#define RTMP_CLEAR_FLAG(_M, _F) 	((_M)->Flags &= ~(_F))
#define RTMP_CLEAR_FLAGS(_M)		((_M)->Flags = 0)
#define RTMP_TEST_FLAG(_M, _F)		(((_M)->Flags & (_F)) != 0)
#define RTMP_TEST_FLAGS(_M, _F) 	(((_M)->Flags & (_F)) == (_F))

// Flags control for RT2500 USB bulk out frame type
#define RTUSB_SET_BULK_FLAG(_M, _F)				((_M)->BulkFlags |= (_F))
#define RTUSB_CLEAR_BULK_FLAG(_M, _F)			((_M)->BulkFlags &= ~(_F))
#define RTUSB_TEST_BULK_FLAG(_M, _F)			(((_M)->BulkFlags & (_F)) != 0)

#define OPSTATUS_SET_FLAG(_pAd, _F) 	((_pAd)->PortCfg.OpStatusFlags |= (_F))
#define OPSTATUS_CLEAR_FLAG(_pAd, _F)	((_pAd)->PortCfg.OpStatusFlags &= ~(_F))
#define OPSTATUS_TEST_FLAG(_pAd, _F)	(((_pAd)->PortCfg.OpStatusFlags & (_F)) != 0)

#define CLIENT_STATUS_SET_FLAG(_pEntry,_F)		((_pEntry)->ClientStatusFlags |= (_F))
#define CLIENT_STATUS_CLEAR_FLAG(_pEntry,_F)	((_pEntry)->ClientStatusFlags &= ~(_F))
#define CLIENT_STATUS_TEST_FLAG(_pEntry,_F) 	(((_pEntry)->ClientStatusFlags & (_F)) != 0)


#define INC_RING_INDEX(_idx, _RingSize)    \
{										   \
	(_idx)++;							   \
	if ((_idx) >= (_RingSize)) _idx=0;	   \
}

// Increase TxTsc value for next transmission
// TODO: 
// When i==6, means TSC has done one full cycle, do re-keying stuff follow specs
// Should send a special event microsoft defined to request re-key
#define INC_TX_TSC(_tsc)								\
{														\
	int i=0;											\
	while (++_tsc[i] == 0x0)							\
	{													\
		i++;											\
		if (i == 6) 									\
			break;										\
	}													\
}


#undef	NdisMoveMemory
#undef	NdisZeroMemory
#undef	NdisFillMemory
#undef	NdisEqualMemory

#define NdisMoveMemory(Destination, Source, Length) RTMPMoveMemory(Destination, Source, Length)
#define NdisZeroMemory(Destination, Length) 		RTMPZeroMemory(Destination, Length)
#define NdisFillMemory(Destination, Length, Fill)	RTMPFillMemory(Destination, Length, Fill)
#define NdisEqualMemory(Source1, Source2, Length)	RTMPEqualMemory(Source1, Source2, Length)

#define MAC_ADDR_EQUAL(pAddr1,pAddr2)				RTMPEqualMemory((PVOID)(pAddr1), (PVOID)(pAddr2), MAC_ADDR_LEN)
#define COPY_MAC_ADDR(Addr1, Addr2) 				memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
#define SSID_EQUAL(ssid1, len1, ssid2, len2)		((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1)))

#define NdisMSleep                                  mdelay


#define 	MAP_CHANNEL_ID_TO_KHZ(ch, khz)	{				\
				switch (ch) 								\
				{											\
					case 1: 	khz = 2412000;	 break; 	\
					case 2: 	khz = 2417000;	 break; 	\
					case 3: 	khz = 2422000;	 break; 	\
					case 4: 	khz = 2427000;	 break; 	\
					case 5: 	khz = 2432000;	 break; 	\
					case 6: 	khz = 2437000;	 break; 	\
					case 7: 	khz = 2442000;	 break; 	\
					case 8: 	khz = 2447000;	 break; 	\
					case 9: 	khz = 2452000;	 break; 	\
					case 10:	khz = 2457000;	 break; 	\
					case 11:	khz = 2462000;	 break; 	\

⌨️ 快捷键说明

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