summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/mt7601udrv/include/os
diff options
context:
space:
mode:
authorFisher Cheng2013-05-24 16:54:08 +0800
committerJulien Lacour2013-10-01 12:12:48 +0200
commit8c1eb022607c0aba81d93b961abbfb47a2dcc325 (patch)
tree13b1cd55172e93b3d1e5baa7141ba259fd71b0af /cleopatre/devkit/mt7601udrv/include/os
parent9e4d9d72dcac9686f1b4720e46e3bb88f6375a1e (diff)
cleo/devkit: add MTK MT7601U drv source code, refs #4011
- Enable Wireless LAN and Wireless extension in linux26.config
Diffstat (limited to 'cleopatre/devkit/mt7601udrv/include/os')
-rw-r--r--cleopatre/devkit/mt7601udrv/include/os/rt_drv.h1061
-rw-r--r--cleopatre/devkit/mt7601udrv/include/os/rt_linux.h1575
-rw-r--r--cleopatre/devkit/mt7601udrv/include/os/rt_linux_cmm.h412
-rw-r--r--cleopatre/devkit/mt7601udrv/include/os/rt_os.h83
4 files changed, 3131 insertions, 0 deletions
diff --git a/cleopatre/devkit/mt7601udrv/include/os/rt_drv.h b/cleopatre/devkit/mt7601udrv/include/os/rt_drv.h
new file mode 100644
index 0000000000..290e68a0fe
--- /dev/null
+++ b/cleopatre/devkit/mt7601udrv/include/os/rt_drv.h
@@ -0,0 +1,1061 @@
+/****************************************************************************
+ * Ralink Tech Inc.
+ * 4F, No. 2 Technology 5th Rd.
+ * Science-based Industrial Park
+ * Hsin-chu, Taiwan, R.O.C.
+ * (c) Copyright 2002, Ralink Technology, Inc.
+ *
+ * All rights reserved. Ralink's source code is an unpublished work and the
+ * use of a copyright notice does not imply otherwise. This source code
+ * contains confidential trade secret material of Ralink Tech. Any attemp
+ * or participation in deciphering, decoding, reverse engineering or in any
+ * way altering the source code is stricitly prohibited, unless the prior
+ * written consent of Ralink Technology, Inc. is obtained.
+ ****************************************************************************
+
+ Module Name:
+ rt_drv.h
+
+ Abstract:
+ Put all virtual OS related definition/structure/MACRO here except
+ standard ANSI C function.
+
+ Note:
+ No any OS related definition/MACRO is defined here.
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+*/
+
+/* same as rt_linux.h to warn users the two files can not be used simultaneously */
+#ifndef __RT_LINUX_H__
+#define __RT_LINUX_H__
+
+#include "os/rt_linux_cmm.h"
+#include <linux/string.h>
+#include <linux/ctype.h>
+
+#undef AP_WSC_INCLUDED
+#undef STA_WSC_INCLUDED
+#undef WSC_INCLUDED
+
+#ifdef CONFIG_AP_SUPPORT
+#ifdef WSC_AP_SUPPORT
+#define AP_WSC_INCLUDED
+#endif /* WSC_AP_SUPPORT */
+#endif /* CONFIG_AP_SUPPORT */
+
+
+#if defined(WSC_AP_SUPPORT) || defined(WSC_STA_SUPPORT)
+#define WSC_INCLUDED
+#endif
+
+/*#ifdef RTMP_USB_SUPPORT */
+typedef VOID *PUSB_DEV;
+typedef VOID *purbb_t;
+typedef VOID pregs;
+/*typedef struct usb_ctrlrequest devctrlrequest; */
+/*#endif */
+
+/***********************************************************************************
+ * Profile related sections
+ ***********************************************************************************/
+#ifdef CONFIG_AP_SUPPORT
+#ifdef RTMP_MAC_USB
+#ifdef INF_AMAZON_SE
+#define AP_PROFILE_PATH "/ramdisk/etc/Wireless/RT2870AP/RT2870AP.dat"
+#define AP_RTMP_FIRMWARE_FILE_NAME "/ramdisk/etc/Wireless/RT2870AP/RT2870AP.bin"
+#else
+#define AP_PROFILE_PATH "/etc/Wireless/RT2870AP/RT2870AP.dat"
+#define AP_RTMP_FIRMWARE_FILE_NAME "/etc/Wireless/RT2870AP/RT2870AP.bin"
+#endif
+#define AP_NIC_DEVICE_NAME "RT2870AP"
+#define AP_DRIVER_VERSION "3.0.0.1"
+#ifdef MULTIPLE_CARD_SUPPORT
+#define CARD_INFO_PATH "/etc/Wireless/RT2870AP/RT2870APCard.dat"
+#endif /* MULTIPLE_CARD_SUPPORT */
+#endif /* RTMP_MAC_USB */
+
+#endif /* CONFIG_AP_SUPPORT */
+
+
+
+#ifdef SINGLE_SKU_V2
+#define SINGLE_SKU_TABLE_FILE_NAME "/etc/Wireless/RT2870STA/SingleSKU.dat"
+#endif /* SINGLE_SKU_V2 */
+
+/***********************************************************************************
+ * 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 void * PPCI_DEV;
+typedef void * PNET_DEV;
+typedef void * PNDIS_PACKET;
+typedef char NDIS_PACKET;
+typedef PNDIS_PACKET * PPNDIS_PACKET;
+typedef ra_dma_addr_t NDIS_PHYSICAL_ADDRESS;
+typedef ra_dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
+typedef void * NDIS_HANDLE;
+typedef char * PNDIS_BUFFER;
+
+#undef KERN_ERR
+#define KERN_ERR
+
+
+/***********************************************************************************
+ * 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_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
+
+#define NET_DEVICE_REAL_IDX_MASK 0x0f /* for each operation mode, we maximum support 15 entities. */
+
+
+
+
+/***********************************************************************************
+ * OS signaling related constant definitions
+ ***********************************************************************************/
+
+/***********************************************************************************
+ * OS file operation related data structure definitions
+ ***********************************************************************************/
+typedef VOID * RTMP_OS_FD;
+
+#define IS_FILE_OPEN_ERR(_fd) RtmpOsFileIsErr((_fd))
+
+#ifndef O_RDONLY
+#define O_RDONLY RTMP_FILE_RDONLY
+#endif /* O_RDONLY */
+
+#ifndef O_WRONLY
+#define O_WRONLY RTMP_FILE_WRONLY
+#endif /* O_WRONLY */
+
+#ifndef O_CREAT
+#define O_CREAT RTMP_FILE_CREAT
+#endif /* O_CREAT */
+
+#ifndef O_TRUNC
+#define O_TRUNC RTMP_FILE_TRUNC
+#endif /* O_TRUNC */
+
+
+/***********************************************************************************
+ * OS semaphore related data structure and definitions
+ ***********************************************************************************/
+#define RTCMDUp RtmpOsCmdUp
+
+
+/***********************************************************************************
+ * OS Memory Access related data structure and definitions
+ ***********************************************************************************/
+#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_PID ULONG /* value or pointer */
+
+#define RTMP_GET_OS_PID(_a, _b) RtmpOsGetPid(&_a, _b);
+#define CHECK_TASK_LEGALITY(_task) RtmpOsCheckTaskLegality(_task)
+#define ATE_KILL_THREAD_PID RtmpThreadPidKill
+
+typedef INT (*RTMP_OS_TASK_CALLBACK)(ULONG);
+
+
+/***********************************************************************************
+ * IOCTL related definitions and data structures.
+ **********************************************************************************/
+#define NET_IOCTL VOID
+#define PNET_IOCTL VOID *
+
+/* undef them to avoid compile errors in rt_symb.c */
+#undef EINVAL
+#undef EOPNOTSUPP
+#undef EFAULT
+#undef ENETDOWN
+#undef E2BIG
+#undef ENOMEM
+#undef EAGAIN
+#undef ENOTCONN
+
+#define EINVAL (-RTMP_IO_EINVAL)
+#define EOPNOTSUPP (-RTMP_IO_EOPNOTSUPP)
+#define EFAULT (-RTMP_IO_EFAULT)
+#define ENETDOWN (-RTMP_IO_ENETDOWN)
+#define E2BIG (-RTMP_IO_E2BIG)
+#define ENOMEM (-RTMP_IO_ENOMEM)
+#define EAGAIN (-RTMP_IO_EAGAIN)
+#define ENOTCONN (-RTMP_IO_ENOTCONN)
+
+
+/***********************************************************************************
+ * Timer related definitions and data structures.
+ **********************************************************************************/
+#define OS_HZ RtmpOsTickUnitGet()
+
+typedef void (*TIMER_FUNCTION)(ULONG);
+
+#define OS_WAIT RtmpOsWait
+
+#define RTMP_TIME_AFTER RtmpOsTimerAfter
+#define RTMP_TIME_BEFORE RtmpOsTimerBefore
+
+#define ONE_TICK 1
+
+#define NdisGetSystemUpTime RtmpOsGetSystemUpTime
+
+
+/***********************************************************************************
+ * OS specific cookie data structure binding to RTMP_ADAPTER
+ ***********************************************************************************/
+
+/* do not have compile option in the structure for UTIL module */
+struct os_cookie {
+
+#ifdef RTMP_MAC_USB
+ VOID *pUsb_Dev;
+
+#endif /* RTMP_MAC_USB */
+
+#ifdef WORKQUEUE_BH
+ UINT32 pAd_va;
+#endif /* WORKQUEUE_BH */
+
+ RTMP_NET_TASK_STRUCT rx_done_task;
+ RTMP_NET_TASK_STRUCT cmd_rsp_event_task;
+ RTMP_NET_TASK_STRUCT mgmt_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac0_dma_done_task;
+#ifdef RALINK_ATE
+ RTMP_NET_TASK_STRUCT ate_ac0_dma_done_task;
+#endif /* RALINK_ATE */
+ RTMP_NET_TASK_STRUCT ac1_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac2_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac3_dma_done_task;
+ RTMP_NET_TASK_STRUCT hcca_dma_done_task;
+ RTMP_NET_TASK_STRUCT tbtt_task;
+
+
+#ifdef UAPSD_SUPPORT
+ RTMP_NET_TASK_STRUCT uapsd_eosp_sent_task;
+#endif /* UAPSD_SUPPORT */
+
+#ifdef CONFIG_AP_SUPPORT
+#ifdef DFS_SUPPORT
+#ifdef DFS_SOFTWARE_SUPPORT
+ RTMP_NET_TASK_STRUCT pulse_radar_detect_task;
+ RTMP_NET_TASK_STRUCT width_radar_detect_task;
+#endif /* DFS_SOFTWARE_SUPPORT */
+#endif /* DFS_SUPPORT */
+
+#ifdef CARRIER_DETECTION_SUPPORT
+ RTMP_NET_TASK_STRUCT carrier_sense_task;
+#endif /* CARRIER_DETECTION_SUPPORT */
+
+#ifdef DFS_SUPPORT
+ RTMP_NET_TASK_STRUCT dfs_task;
+#endif /* DFS_SUPPORT */
+
+#endif /* CONFIG_AP_SUPPORT */
+
+#ifdef RTMP_MAC_USB
+ RTMP_NET_TASK_STRUCT null_frame_complete_task;
+ RTMP_NET_TASK_STRUCT pspoll_frame_complete_task;
+#endif /* RTMP_MAC_USB */
+
+#ifdef CONFIG_MULTI_CHANNEL
+ RTMP_NET_TASK_STRUCT hcca_null_frame_complete_task;
+#endif /* CONFIG_MULTI_CHANNEL */
+
+ RTMP_OS_PID apd_pid; /*802.1x daemon pid */
+ unsigned long apd_pid_nr;
+#ifdef CONFIG_AP_SUPPORT
+#ifdef IAPP_SUPPORT
+/* RT_SIGNAL_STRUC RTSignal; */
+ RTMP_OS_PID IappPid; /*IAPP daemon pid */
+ unsigned long IappPid_nr;
+#endif /* IAPP_SUPPORT */
+#endif /* CONFIG_AP_SUPPORT */
+#ifdef WAPI_SUPPORT
+ RTMP_OS_PID wapi_pid; /*wapi daemon pid */
+ unsigned long wapi_pid_nr;
+#endif /* WAPI_SUPPORT */
+ INT ioctl_if_type;
+ INT ioctl_if;
+};
+
+typedef struct os_cookie * POS_COOKIE;
+
+
+/***********************************************************************************
+ * OS debugging and printing related definitions and data structure
+ ***********************************************************************************/
+#define PRINT_MAC(addr) \
+ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
+
+#ifdef DBG
+extern ULONG RTDebugLevel;
+extern ULONG RTDebugFunc;
+
+#define DBGPRINT_RAW(Level, Fmt) \
+do{ \
+ ULONG __gLevel = (Level) & 0xff;\
+ ULONG __fLevel = ((Level)>>8) & 0xffffff;\
+ if (__gLevel <= RTDebugLevel) \
+ { \
+ if ((RTDebugFunc == 0) || \
+ ((RTDebugFunc != 0) && (((__fLevel & RTDebugFunc)!= 0) || (__gLevel <= RT_DEBUG_ERROR))))\
+ printk Fmt; \
+ } \
+}while(0)
+
+#define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
+
+
+#define DBGPRINT_ERR(Fmt) \
+{ \
+ printk("ERROR!!! "); \
+ printk Fmt; \
+}
+
+#define DBGPRINT_S(Status, Fmt) \
+{ \
+ printk Fmt; \
+}
+#else
+#define DBGPRINT(Level, Fmt)
+#define DBGPRINT_RAW(Level, Fmt)
+#define DBGPRINT_S(Status, Fmt)
+#define DBGPRINT_ERR(Fmt)
+#endif
+
+#undef ASSERT
+#ifdef DBG
+#define ASSERT(x) \
+{ \
+ if (!(x)) \
+ { \
+ printk(__FILE__ ":%d assert " #x "failed\n", __LINE__); \
+ } \
+}
+#else
+#define ASSERT(x)
+#endif /* DBG */
+
+void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
+
+
+/*********************************************************************************************************
+ The following code are not revised, temporary put it here.
+ *********************************************************************************************************/
+
+
+/***********************************************************************************
+ * Device DMA Access related definitions and data structures.
+ **********************************************************************************/
+/*#ifdef RTMP_MAC_PCI*/
+#define size_t ULONG
+
+ra_dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
+void linux_pci_unmap_single(void *handle, ra_dma_addr_t dma_addr, size_t size, int direction);
+
+#define pci_enable_msi RtmpOsPciMsiEnable
+#define pci_disable_msi RtmpOsPciMsiDisable
+
+#define PCI_MAP_SINGLE_DEV(_handle, _ptr, _size, _sd_idx, _dir) \
+ linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir)
+
+#define PCI_UNMAP_SINGLE(_pAd, _ptr, _size, _dir) \
+ linux_pci_unmap_single(((POS_COOKIE)(_pAd->OS_Cookie))->pci_dev, _ptr, _size, _dir)
+
+#define PCI_ALLOC_CONSISTENT(_pci_dev, _size, _ptr) \
+ pci_alloc_consistent(_pci_dev, _size, _ptr)
+
+#define PCI_FREE_CONSISTENT(_pci_dev, _size, _virtual_addr, _physical_addr) \
+ pci_free_consistent(_pci_dev, _size, _virtual_addr, _physical_addr)
+/*#endif RTMP_MAC_PCI*/
+
+#define DEV_ALLOC_SKB(_pAd, _Pkt, _length) \
+ _Pkt = RtmpOSNetPktAlloc(_pAd, _length);
+
+/*#ifdef RTMP_MAC_USB */
+/*#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0 */
+/*#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) */
+/*#endif RTMP_MAC_USB */
+
+
+/*
+ * ULONG
+ * RTMP_GetPhysicalAddressLow(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
+ */
+#define RTMP_GetPhysicalAddressLow(phy_addr) (phy_addr)
+
+/*
+ * ULONG
+ * RTMP_GetPhysicalAddressHigh(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
+ */
+#define RTMP_GetPhysicalAddressHigh(phy_addr) (0)
+
+/*
+ * VOID
+ * RTMP_SetPhysicalAddressLow(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
+ * IN ULONG Value);
+ */
+#define RTMP_SetPhysicalAddressLow(phy_addr, Value) \
+ phy_addr = Value;
+
+/*
+ * VOID
+ * RTMP_SetPhysicalAddressHigh(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
+ * IN ULONG Value);
+ */
+#define RTMP_SetPhysicalAddressHigh(phy_addr, Value)
+
+#define NdisMIndicateStatus(_w, _x, _y, _z)
+
+
+
+/***********************************************************************************
+ * Device Register I/O Access related definitions and data structures.
+ **********************************************************************************/
+#define readl RTMP_PCI_Readl
+#define readw RTMP_PCI_Readw
+#define readb RTMP_PCI_Readb
+#define writel RTMP_PCI_Writel
+#define writew RTMP_PCI_Writew
+#define writeb RTMP_PCI_Writeb
+
+/* TODO: We can merge two readl to a function to speed up or one real/writel */
+
+
+#ifdef RTMP_MAC_USB
+#define RTMP_IO_FORCE_READ32(_A, _R, _pV) \
+ RTUSBReadMACRegister((_A), (_R), (PUINT32) (_pV))
+
+#define RTMP_IO_FORCE_WRITE32(_A, _R, _V) \
+ do{\
+ /* if ((_R) != 0x404)*/ /* TODO:shiang-6590, depends on sw porting guide, don't acccess it now */\
+ RTUSBWriteMACRegister((_A), (_R), (UINT32) (_V), FALSE); \
+ }while(0)
+
+#define RTMP_IO_READ32(_A, _R, _pV) \
+ RTUSBReadMACRegister((_A), (_R), (PUINT32) (_pV))
+
+#define RTMP_IO_READ8(_A, _R, _pV) \
+{ \
+}
+
+#define RTMP_IO_WRITE32(_A, _R, _V) \
+ RTUSBWriteMACRegister((_A), (_R), (UINT32) (_V), FALSE)
+
+#define RTMP_IO_WRITE8(_A, _R, _V) \
+{ \
+ USHORT _Val = _V; \
+ RTUSBSingleWrite((_A), (_R), (USHORT) (_Val), FALSE); \
+}
+
+
+#define RTMP_IO_WRITE16(_A, _R, _V) \
+{ \
+ RTUSBSingleWrite((_A), (_R), (USHORT) (_V), FALSE); \
+}
+
+#define RTMP_SYS_IO_READ32
+#define RTMP_SYS_IO_WRITE32
+#endif /* RTMP_MAC_USB */
+
+#define pci_read_config_word RtmpOsPciConfigReadWord
+#define pci_write_config_word RtmpOsPciConfigWriteWord
+#define pci_read_config_dword RtmpOsPciConfigReadDWord
+#define pci_write_config_dword RtmpOsPciConfigWriteDWord
+#define pci_find_capability RtmpOsPciFindCapability
+
+#define RTMP_USB_URB_DATA_GET RtmpOsUsbUrbDataGet
+#define RTMP_USB_URB_STATUS_GET RtmpOsUsbUrbStatusGet
+#define RTMP_USB_URB_LEN_GET RtmpOsUsbUrbLenGet
+
+#define IW_SCAN_MAX_DATA RTMP_OS_MAX_SCAN_DATA_GET()
+
+/***********************************************************************************
+ * Network Related data structure and marco definitions
+ ***********************************************************************************/
+#define PKTSRC_NDIS 0x7f
+#define PKTSRC_DRIVER 0x0f
+
+#define RTMP_OS_NETDEV_GET_PHYADDR RtmpOsNetDevGetPhyAddr
+#define SET_OS_PKT_NETDEV RtmpOsSetPktNetDev
+#define RTMP_OS_NETDEV_GET_DEVNAME RtmpOsGetNetDevName
+#define RTMP_OS_NETDEV_SET_TYPE RtmpOsSetNetDevType
+#define RTMP_OS_NETDEV_SET_TYPE_MONITOR RtmpOsSetNetDevTypeMonitor
+
+#define QUEUE_ENTRY_TO_PACKET(pEntry) \
+ (PNDIS_PACKET)(pEntry)
+
+#define PACKET_TO_QUEUE_ENTRY(pPacket) \
+ (PQUEUE_ENTRY)(pPacket)
+
+#define RTMP_OS_NETDEV_STATE_RUNNING(_pNetDev) (RtmpOSNetDevIsUp(_pNetDev) == TRUE)
+
+#define RELEASE_NDIS_PACKET(_pReserved, _pPacket, _Status) \
+{ \
+ RTMPFreeNdisPacket(_pReserved, _pPacket); \
+}
+
+/*
+ * packet helper
+ * - convert internal rt packet to os packet or
+ * os packet to rt packet
+ */
+extern ULONG RTPktOffsetData, RTPktOffsetLen, RTPktOffsetCB;
+
+#define RTPKT_TO_OSPKT(_p) (_p)
+#define OSPKT_TO_RTPKT(_p) (_p)
+
+#define GET_OS_PKT_DATAPTR(_pkt) \
+ ((UCHAR *)(*(ULONG *)((UCHAR *)_pkt + RTPktOffsetData)))
+
+#define SET_OS_PKT_DATAPTR \
+ RtmpOsPktDataPtrAssign
+
+#define GET_OS_PKT_LEN(_pkt) \
+ (*(UINT32 *)((UCHAR *)_pkt + RTPktOffsetLen))
+
+#define SET_OS_PKT_LEN \
+ RtmpOsPktLenAssign
+
+#define GET_OS_PKT_CB(_pkt) \
+ ((UCHAR *)((UCHAR *)_pkt + RTPktOffsetCB))
+
+#define GET_OS_PKT_NETDEV(_pkt) RtmpOsPktNetDevGet
+
+#define OS_PKT_CLONED \
+ RtmpOsIsPktCloned
+
+#define OS_PKT_COPY \
+ RtmpOsPktCopy
+
+#define OS_PKT_TAIL_ADJUST \
+ RtmpOsPktTailAdjust
+
+#define OS_PKT_HEAD_BUF_EXTEND \
+ RtmpOsPktHeadBufExtend
+
+#define OS_PKT_TAIL_BUF_EXTEND \
+ RtmpOsPktTailBufExtend
+
+#define OS_PKT_RESERVE \
+ RtmpOsPktReserve
+
+#define OS_PKT_CLONE(_pAd, _pkt, _src, _flag) \
+ _src = RtmpOsPktClone((_pkt));
+
+#define RTMP_OS_PKT_INIT RtmpOsPktInit
+
+extern UINT32 RtmpOsGetUnaligned32(
+ IN UINT32 *pWord);
+
+extern ULONG RtmpOsGetUnalignedlong(
+ IN ULONG *pWord);
+
+#define get_unaligned RtmpOsGetUnaligned
+#define get_unaligned32 RtmpOsGetUnaligned32
+#define get_unalignedlong RtmpOsGetUnalignedlong
+
+#define OS_NTOHS RtmpOsNtohs
+#define OS_HTONS RtmpOsHtons
+#define OS_NTOHL RtmpOsNtohl
+#define OS_HTONL RtmpOsHtonl
+
+#ifndef ntohs
+#define ntohs OS_NTOHS
+#endif /* ntohs */
+#ifndef htons
+#define htons OS_HTONS
+#endif /* htons */
+#ifndef ntohl
+#define ntohl OS_NTOHL
+#endif /* ntohl */
+#ifndef htonl
+#define htonl OS_HTONL
+#endif /* htonl */
+
+#define RTMP_OS_NETDEV_START_QUEUE RtmpOsNetQueueStart
+#define RTMP_OS_NETDEV_STOP_QUEUE RtmpOsNetQueueStop
+#define RTMP_OS_NETDEV_WAKE_QUEUE RtmpOsNetQueueWake
+
+
+#define CB_OFF 10
+
+#define PACKET_CB_ASSIGN(_p, _offset) \
+ (*((UINT8 *)_p + RTPktOffsetCB + _offset))
+
+#define PACKET_CB(_p, _offset) \
+ (*((UINT8 *)_p + RTPktOffsetCB + CB_OFF + _offset))
+
+/* User Priority */
+#define RTMP_SET_PACKET_UP(_p, _prio) (PACKET_CB(_p, 0) = _prio)
+#define RTMP_GET_PACKET_UP(_p) (PACKET_CB(_p, 0))
+
+/* Fragment # */
+#define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (PACKET_CB(_p, 1) = _num)
+#define RTMP_GET_PACKET_FRAGMENTS(_p) (PACKET_CB(_p, 1))
+
+/* 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too. */
+/*(this value also as MAC(on-chip WCID) table index) */
+/* 0x80~0xff: TX to a WDS link. b0~6: WDS index */
+#define RTMP_SET_PACKET_WCID(_p, _wdsidx) (PACKET_CB(_p, 2) = _wdsidx)
+#define RTMP_GET_PACKET_WCID(_p) (PACKET_CB(_p, 2))
+
+/* 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet */
+#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (PACKET_CB(_p, 3) = _pktsrc)
+#define RTMP_GET_PACKET_SOURCE(_p) (PACKET_CB(_p, 3))
+
+/* RTS/CTS-to-self protection method */
+#define RTMP_SET_PACKET_RTS(_p, _num) (PACKET_CB(_p, 4) = _num)
+#define RTMP_GET_PACKET_RTS(_p) (PACKET_CB(_p, 4))
+/* see RTMP_S(G)ET_PACKET_EMACTAB */
+
+/* TX rate index */
+#define RTMP_SET_PACKET_TXRATE(_p, _rate) (PACKET_CB(_p, 5) = _rate)
+#define RTMP_GET_PACKET_TXRATE(_p) (PACKET_CB(_p, 5))
+
+/* From which Interface */
+#define RTMP_SET_PACKET_IF(_p, _ifdx) (PACKET_CB(_p, 6) = _ifdx)
+#define RTMP_GET_PACKET_IF(_p) (PACKET_CB(_p, 6))
+#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
+#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
+#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
+#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
+#define RTMP_SET_PACKET_NET_DEVICE_P2P(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_P2P_GO))
+#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
+#define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
+
+#define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (PACKET_CB(_p, 7) = _morebit)
+#define RTMP_GET_PACKET_MOREDATA(_p) (PACKET_CB(_p, 7))
+
+
+
+#ifdef UAPSD_SUPPORT
+/* if we queue a U-APSD packet to any software queue, we will set the U-APSD
+ flag and its physical queue ID for it */
+#define RTMP_SET_PACKET_UAPSD(_p, _flg_uapsd, _que_id) \
+ (PACKET_CB(_p, 9) = ((_flg_uapsd<<7) | _que_id))
+
+#define RTMP_SET_PACKET_QOS_NULL(_p) (PACKET_CB(_p, 9) = 0xff)
+#define RTMP_GET_PACKET_QOS_NULL(_p) (PACKET_CB(_p, 9))
+#define RTMP_SET_PACKET_NON_QOS_NULL(_p) (PACKET_CB(_p, 9) = 0x00)
+#define RTMP_GET_PACKET_UAPSD_Flag(_p) ((PACKET_CB(_p, 9) & 0x80) >> 7)
+#define RTMP_GET_PACKET_UAPSD_QUE_ID(_p) (PACKET_CB(_p, 9) & 0x7f)
+
+#define RTMP_SET_PACKET_EOSP(_p, _flg) (PACKET_CB(_p, 10) = _flg)
+#define RTMP_GET_PACKET_EOSP(_p) (PACKET_CB(_p, 10))
+#endif /* UAPSD_SUPPORT */
+
+
+/* */
+/* Sepcific Pakcet Type definition */
+/* */
+#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
+
+#define RTMP_PACKET_SPECIFIC_DHCP 0x01
+#define RTMP_PACKET_SPECIFIC_EAPOL 0x02
+#define RTMP_PACKET_SPECIFIC_IPV4 0x04
+#define RTMP_PACKET_SPECIFIC_WAI 0x08
+#define RTMP_PACKET_SPECIFIC_VLAN 0x10
+#define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
+#define RTMP_PACKET_SPECIFIC_TDLS 0x40
+
+/*Specific */
+#define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (PACKET_CB(_p, 11) = _flg)
+
+/*DHCP */
+#define RTMP_SET_PACKET_DHCP(_p, _flg) \
+ do{ \
+ if (_flg) \
+ PACKET_CB(_p, 11) |= (RTMP_PACKET_SPECIFIC_DHCP); \
+ else \
+ PACKET_CB(_p, 11) &= (~RTMP_PACKET_SPECIFIC_DHCP); \
+ }while(0)
+#define RTMP_GET_PACKET_DHCP(_p) (PACKET_CB(_p, 11) & RTMP_PACKET_SPECIFIC_DHCP)
+
+/*EAPOL */
+#define RTMP_SET_PACKET_EAPOL(_p, _flg) \
+ do{ \
+ if (_flg) \
+ PACKET_CB(_p, 11) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
+ else \
+ PACKET_CB(_p, 11) &= (~RTMP_PACKET_SPECIFIC_EAPOL); \
+ }while(0)
+#define RTMP_GET_PACKET_EAPOL(_p) (PACKET_CB(_p, 11) & RTMP_PACKET_SPECIFIC_EAPOL)
+
+/*WAI */
+#define RTMP_SET_PACKET_WAI(_p, _flg) \
+ do{ \
+ if (_flg) \
+ PACKET_CB(_p, 11) |= (RTMP_PACKET_SPECIFIC_WAI); \
+ else \
+ PACKET_CB(_p, 11) &= (~RTMP_PACKET_SPECIFIC_WAI); \
+ }while(0)
+#define RTMP_GET_PACKET_WAI(_p) (PACKET_CB(_p, 11) & RTMP_PACKET_SPECIFIC_WAI)
+
+#define RTMP_GET_PACKET_LOWRATE(_p) (PACKET_CB(_p, 11) & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
+
+/*VLAN */
+#define RTMP_SET_PACKET_VLAN(_p, _flg) \
+ do{ \
+ if (_flg) \
+ PACKET_CB(_p, 11) |= (RTMP_PACKET_SPECIFIC_VLAN); \
+ else \
+ PACKET_CB(_p, 11) &= (~RTMP_PACKET_SPECIFIC_VLAN); \
+ }while(0)
+#define RTMP_GET_PACKET_VLAN(_p) (PACKET_CB(_p, 11) & RTMP_PACKET_SPECIFIC_VLAN)
+
+/*LLC/SNAP */
+#define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
+ do{ \
+ if (_flg) \
+ PACKET_CB(_p, 11) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
+ else \
+ PACKET_CB(_p, 11) &= (~RTMP_PACKET_SPECIFIC_LLCSNAP); \
+ }while(0)
+
+#define RTMP_GET_PACKET_LLCSNAP(_p) (PACKET_CB(_p, 11) & RTMP_PACKET_SPECIFIC_LLCSNAP)
+
+/* IP */
+#define RTMP_SET_PACKET_IPV4(_p, _flg) \
+ do{ \
+ if (_flg) \
+ PACKET_CB(_p, 11) |= (RTMP_PACKET_SPECIFIC_IPV4); \
+ else \
+ PACKET_CB(_p, 11) &= (~RTMP_PACKET_SPECIFIC_IPV4); \
+ }while(0)
+
+#define RTMP_GET_PACKET_IPV4(_p) (PACKET_CB(_p, 11) & RTMP_PACKET_SPECIFIC_IPV4)
+
+/* TDLS */
+#define RTMP_SET_PACKET_TDLS(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_TDLS); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_TDLS); \
+ }while(0)
+
+#define RTMP_GET_PACKET_TDLS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_TDLS)
+
+/* If this flag is set, it indicates that this EAPoL frame MUST be clear. */
+#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (PACKET_CB(_p, 12) = _flg)
+#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (PACKET_CB(_p, 12))
+
+
+#ifdef DOT11_VHT_AC
+#define MAX_PACKETS_IN_QUEUE 1024 /*(512)*/
+#else
+#define MAX_PACKETS_IN_QUEUE (512)
+#endif /* DOT11_VHT_AC */
+
+
+/* use bit3 of cb[CB_OFF+16] */
+#define RTMP_SET_PACKET_MGMT_PKT(_p, _flg) \
+ PACKET_CB(_p, 16) = (PACKET_CB(_p, 16) & 0xF7) | ((_flg & 0x01) << 3);
+#define RTMP_GET_PACKET_MGMT_PKT(_p) \
+ ((PACKET_CB(_p, 16) & 0x08) >> 3)
+
+/* use bit0 of cb[CB_OFF+20] */
+#define RTMP_SET_PACKET_MGMT_PKT_DATA_QUE(_p, _flg) \
+ PACKET_CB(_p, 20) = (PACKET_CB(_p, 20) & 0xFE) | (_flg & 0x01);
+#define RTMP_GET_PACKET_MGMT_PKT_DATA_QUE(_p) \
+ (PACKET_CB(_p, 20) & 0x01)
+
+#define RTMP_SET_PACKET_5VT(_p, _flg) (PACKET_CB(_p, 22) = _flg)
+#define RTMP_GET_PACKET_5VT(_p) (PACKET_CB(_p, 22))
+
+#define RTMP_SET_PACKET_PROTOCOL(_p, _protocol) {\
+ (PACKET_CB(_p, 23) = (UINT8)((_protocol) & 0x00ff)); \
+ (PACKET_CB(_p, 24) = (UINT8)(((_protocol) & 0xff00) >> 8)); \
+}
+
+#define RTMP_GET_PACKET_PROTOCOL(_p) \
+ ((((UINT16)PACKET_CB(_p, 23)) << 8) \
+ | ((UINT16)PACKET_CB(_p, 24)))
+
+#ifdef INF_AMAZON_SE
+/* [CB_OFF+28], 1B, Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate */
+#define RTMP_SET_PACKET_NOBULKOUT(_p, _morebit) (PACKET_CB(_p, 28) = _morebit)
+#define RTMP_GET_PACKET_NOBULKOUT(_p) (PACKET_CB(_p, 28))
+#endif /* INF_AMAZON_SE */
+/* Max skb->cb = 48B = [CB_OFF+38] */
+
+
+
+
+#if defined(CONFIG_CSO_SUPPORT) || defined(CONFIG_RX_CSO_SUPPORT)
+#define RTMP_SET_TCP_CHKSUM_FAIL(_p, _flg) (PACKET_CB(_p, 30) = _flg);
+#define RTMP_GET_TCP_CHKSUM_FAIL(_p) (PACKET_CB(_p, 30))
+#endif /* defined(CONFIG_CSO_SUPPORT) || defined(CONFIG_RX_CSO_SUPPORT) */
+
+
+
+/***********************************************************************************
+ * Other function prototypes definitions
+ ***********************************************************************************/
+void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
+
+
+
+
+#ifdef RTMP_USB_SUPPORT
+/******************************************************************************
+
+ USB related definitions
+
+******************************************************************************/
+
+#define RTMP_USB_PKT_COPY RtmpOsPktBodyCopy
+
+/*typedef struct usb_device_id USB_DEVICE_ID; */
+
+#ifdef INF_AMAZON_SE
+#define BULKAGGRE_SIZE 30
+#else
+#define BULKAGGRE_SIZE 60
+#endif /* INF_AMAZON_SE */
+
+/*#define RT28XX_PUT_DEVICE rausb_put_dev */
+#define RTUSB_ALLOC_URB rausb_alloc_urb
+#define RTUSB_SUBMIT_URB rausb_submit_urb
+#define RTUSB_URB_ALLOC_BUFFER rausb_buffer_alloc
+#define RTUSB_URB_FREE_BUFFER rausb_buffer_free
+#define RTUSB_FREE_URB rausb_free_urb
+#define RTUSB_UNLINK_URB rausb_kill_urb
+#define USB_CONTROL_MSG rausb_control_msg
+#define usb_sndctrlpipe rausb_sndctrlpipe
+#define usb_rcvctrlpipe rausb_rcvctrlpipe
+#define RTUSB_AUTOPM_PUT_INTERFACE rausb_autopm_put_interface
+#define RTUSB_AUTOPM_GET_INTERFACE rausb_autopm_get_interface
+
+
+
+#define RTUSB_CONTROL_MSG(pUsb_Dev, uEndpointAddress, Request, RequestType, Value,Index, tmpBuf, TransferBufferLength, timeout, ret) \
+ do{ \
+ if (RequestType == DEVICE_VENDOR_REQUEST_OUT) \
+ ret = USB_CONTROL_MSG(pUsb_Dev, usb_sndctrlpipe(pUsb_Dev, uEndpointAddress), Request, RequestType, Value, Index, tmpBuf, TransferBufferLength, timeout); \
+ else if (RequestType == DEVICE_VENDOR_REQUEST_IN) \
+ ret = USB_CONTROL_MSG(pUsb_Dev, usb_rcvctrlpipe(pUsb_Dev, uEndpointAddress), Request, RequestType, Value, Index, tmpBuf, TransferBufferLength, timeout); \
+ else \
+ { \
+ DBGPRINT(RT_DEBUG_ERROR, ("vendor request direction is failed\n")); \
+ ret = -1; \
+ } \
+ }while(0)
+
+
+extern VOID dump_urb(VOID *purb);
+
+typedef VOID USBHST_STATUS;
+typedef INT32 URBCompleteStatus;
+#define RTMP_OS_WAIT_QUEUE_HEAD VOID
+typedef VOID (*usb_complete_t)(VOID *);
+
+#define RtmpUsbBulkOutDataPacketComplete pRtmpDrvNetOps->RtmpNetUsbBulkOutDataPacketComplete
+#define RtmpUsbBulkOutMLMEPacketComplete pRtmpDrvNetOps->RtmpNetUsbBulkOutMLMEPacketComplete
+#define RtmpUsbBulkOutNullFrameComplete pRtmpDrvNetOps->RtmpNetUsbBulkOutNullFrameComplete
+#ifdef CONFIG_MULTI_CHANNEL
+#define RtmpUsbBulkOutHCCANullFrameComplete pRtmpDrvNetOps->RtmpNetUsbBulkOutHCCANullFrameComplete
+#endif /* CONFIG_MULTI_CHANNEL */
+
+#define RtmpUsbBulkOutRTSFrameComplete pRtmpDrvNetOps->RtmpNetUsbBulkOutRTSFrameComplete
+#define RtmpUsbBulkOutPsPollComplete pRtmpDrvNetOps->RtmpNetUsbBulkOutPsPollComplete
+#define RtmpUsbBulkRxComplete pRtmpDrvNetOps->RtmpNetUsbBulkRxComplete
+#define RtmpUsbBulkCmdRspEventComplete pRtmpDrvNetOps->RtmpNetUsbBulkCmdRspEventComplete
+
+#define RTUSBBulkOutDataPacketComplete(Status, pURB, pt_regs) RTUSBBulkOutDataPacketComplete(pURB)
+#define RTUSBBulkOutMLMEPacketComplete(Status, pURB, pt_regs) RTUSBBulkOutMLMEPacketComplete(pURB)
+#define RTUSBBulkOutNullFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutNullFrameComplete(pURB)
+#define RTUSBBulkOutRTSFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutRTSFrameComplete(pURB)
+#define RTUSBBulkOutPsPollComplete(Status, pURB, pt_regs) RTUSBBulkOutPsPollComplete(pURB)
+#define RTUSBBulkRxComplete(Status, pURB, pt_regs) RTUSBBulkRxComplete(pURB)
+#define RTUSBBulkCmdRspEventComplete(Status, pURB, pt_regs) RTUSBBulkCmdRspEventComplete(pURB)
+#define USBUploadFWComplete(Status, pURB, pt_regs) USBUploadFWComplete(pURB)
+#define USBKickOutCmdComplete(Status, pURB, pt_regs) USBKickOutCmdComplete(pURB)
+#ifdef CONFIG_MULTI_CHANNEL
+#define RTUSBBulkOutHCCANullFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutHCCANullFrameComplete(pURB)
+#endif /* CONFIG_MULTI_CHANNEL */
+
+
+USBHST_STATUS RTUSBBulkOutDataPacketComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkOutMLMEPacketComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkOutNullFrameComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkOutRTSFrameComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkOutPsPollComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkRxComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkCmdRspEventComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+#ifdef CONFIG_MULTI_CHANNEL
+USBHST_STATUS RTUSBBulkOutHCCANullFrameComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+#endif /* CONFIG_MULTI_CHANNEL */
+
+#define rtusb_urb_context context
+#define rtusb_urb_status status
+
+#define RTMP_OS_USB_CONTEXT_GET RtmpOsUsbContextGet
+#define RTMP_OS_USB_STATUS_GET RtmpOsUsbStatusGet
+
+#define RTUSB_URB_DMA_MAPPING RtmpOsUsbDmaMapping
+
+#define RTUSB_FILL_TX_BULK_URB RtmpOsUsbInitHTTxDesc
+#define RTUSB_FILL_HTTX_BULK_URB RtmpOsUsbInitHTTxDesc
+#define RTUSB_FILL_RX_BULK_URB RtmpOsUsbInitRxDesc
+
+#undef in_interrupt
+#define in_interrupt RtmpOsIsInInterrupt
+
+extern VOID *rausb_alloc_urb(INT32 iso_packets);
+extern VOID rausb_free_urb(VOID *urb);
+extern INT32 rausb_submit_urb(VOID *urb);
+extern VOID *rausb_buffer_alloc(VOID *dev,
+ size_t size,
+ ra_dma_addr_t *dma);
+extern VOID rausb_buffer_free(VOID *dev,
+ size_t size,
+ VOID *addr,
+ ra_dma_addr_t dma);
+extern VOID rausb_kill_urb(VOID *urb);
+
+extern int rausb_control_msg(VOID *dev,
+ unsigned int pipe,
+ __u8 request,
+ __u8 requesttype,
+ __u16 value,
+ __u16 index,
+ void *data,
+ __u16 size,
+ int timeout);
+
+#endif /* RTMP_USB_SUPPORT */
+
+
+#ifdef RALINK_ATE
+/******************************************************************************
+
+ ATE related definitions
+
+******************************************************************************/
+#define ate_print printk
+#define ATEDBGPRINT DBGPRINT
+
+#ifdef RTMP_MAC_USB
+#ifdef CONFIG_AP_SUPPORT
+#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2870AP/e2p.bin"
+#endif /* CONFIG_AP_SUPPORT */
+#endif /* RTMP_MAC_USB */
+
+#endif /* RALINK_ATE */
+
+
+/* OS definition re-declaration */
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef ETH_P_IPV6
+#define ETH_P_IPV6 0x86DD
+#endif
+
+#ifndef ETH_P_IP
+#define ETH_P_IP 0x0800 /* Internet Protocol packet */
+#endif
+
+#ifndef ETH_ALEN
+#define ETH_ALEN 6
+#endif
+
+#undef KERN_EMERG
+#define KERN_EMERG
+#undef KERN_WARNING
+#define KERN_WARNING
+
+#undef copy_from_user
+#undef copy_to_user
+
+#define RTMP_OS_MAX_SCAN_DATA_GET RtmpOsMaxScanDataGet
+#define vmalloc RtmpOsVmalloc
+#define vfree RtmpOsVfree
+#define copy_from_user RtmpOsCopyFromUser
+#define copy_to_user RtmpOsCopyToUser
+#define simple_strtol RtmpOsSimpleStrtol
+
+#undef atomic_read
+#undef atomic_dec
+#undef InterlockedExchange
+#define atomic_read RtmpOsAtomicRead
+#define atomic_dec RtmpOsAtomicDec
+#define InterlockedExchange RtmpOsAtomicInterlockedExchange
+
+extern int sprintf(char * buf, const char * fmt, ...);
+extern int sscanf(const char *, const char *, ...);
+
+#define printk pRaOsOps->ra_printk
+#define snprintf pRaOsOps->ra_snprintf
+
+#endif /* __RT_LINUX_H__ */
diff --git a/cleopatre/devkit/mt7601udrv/include/os/rt_linux.h b/cleopatre/devkit/mt7601udrv/include/os/rt_linux.h
new file mode 100644
index 0000000000..af57cd58b5
--- /dev/null
+++ b/cleopatre/devkit/mt7601udrv/include/os/rt_linux.h
@@ -0,0 +1,1575 @@
+/****************************************************************************
+
+ Module Name:
+ rt_linux.h
+
+ Abstract:
+ Any OS related definition/MACRO is defined here.
+
+ 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>
+#ifdef RTMP_USB_SUPPORT
+#include <linux/usb.h>
+#endif /* RTMP_USB_SUPPORT */
+#include <linux/wireless.h>
+#include <net/iw_handler.h>
+
+#ifdef INF_PPA_SUPPORT
+#include <net/ifx_ppa_api.h>
+#include <net/ifx_ppa_hook.h>
+#endif /* INF_PPA_SUPPORT */
+
+/* load firmware */
+#define __KERNEL_SYSCALLS__
+#include <linux/unistd.h>
+#include <asm/uaccess.h>
+#include <asm/types.h>
+#include <asm/unaligned.h> /* for get_unaligned() */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+#include <linux/pid.h>
+#endif
+
+#ifdef RT_CFG80211_SUPPORT
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
+#include <net/mac80211.h>
+#define EXT_BUILD_CHANNEL_LIST /* must define with CRDA */
+#else /* LINUX_VERSION_CODE */
+#undef RT_CFG80211_SUPPORT
+#endif /* LINUX_VERSION_CODE */
+#endif /* RT_CFG80211_SUPPORT */
+
+#ifdef MAT_SUPPORT
+#include <linux/if_ether.h>
+#include <linux/if_arp.h>
+#include <linux/ip.h>
+#endif /* MAT_SUPPORT */
+
+/* must put the definition before include "os/rt_linux_cmm.h" */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+#define KTHREAD_SUPPORT 1
+#endif /* LINUX_VERSION_CODE */
+
+#ifdef KTHREAD_SUPPORT
+#include <linux/err.h>
+#include <linux/kthread.h>
+#endif /* KTHREAD_SUPPORT */
+
+
+#include "os/rt_linux_cmm.h"
+
+#ifdef RT_CFG80211_SUPPORT
+#include "cfg80211.h"
+#endif /* RT_CFG80211_SUPPORT */
+
+#undef AP_WSC_INCLUDED
+#undef STA_WSC_INCLUDED
+#undef WSC_INCLUDED
+
+#ifdef CONFIG_AP_SUPPORT
+#ifdef WSC_AP_SUPPORT
+#define AP_WSC_INCLUDED
+#endif /* WSC_AP_SUPPORT */
+#endif /* CONFIG_AP_SUPPORT */
+
+
+#if defined(WSC_AP_SUPPORT) || defined(WSC_STA_SUPPORT)
+#define WSC_INCLUDED
+#endif
+
+#ifdef KTHREAD_SUPPORT
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
+#error "This kerne version doesn't support kthread!!"
+#endif
+#endif /* KTHREAD_SUPPORT */
+
+/*#ifdef RTMP_USB_SUPPORT // os abl move */
+typedef struct usb_device *PUSB_DEV;
+typedef struct urb *purbb_t;
+typedef struct usb_ctrlrequest devctrlrequest;
+/*#endif */
+
+/***********************************************************************************
+ * Profile related sections
+ ***********************************************************************************/
+#ifdef CONFIG_AP_SUPPORT
+#ifdef RTMP_MAC_USB
+#ifdef INF_AMAZON_SE
+#define AP_PROFILE_PATH "/ramdisk/etc/Wireless/RT2870AP/RT2870AP.dat"
+#define AP_RTMP_FIRMWARE_FILE_NAME "/ramdisk/etc/Wireless/RT2870AP/RT2870AP.bin"
+#else
+#define AP_PROFILE_PATH "/etc/Wireless/RT2870AP/RT2870AP.dat"
+#define AP_RTMP_FIRMWARE_FILE_NAME "/etc/Wireless/RT2870AP/RT2870AP.bin"
+#endif
+#define AP_NIC_DEVICE_NAME "RT2870AP"
+#define AP_DRIVER_VERSION "3.0.0.1"
+#ifdef MULTIPLE_CARD_SUPPORT
+#define CARD_INFO_PATH "/etc/Wireless/RT2870AP/RT2870APCard.dat"
+#endif /* MULTIPLE_CARD_SUPPORT */
+#endif /* RTMP_MAC_USB */
+
+
+#ifdef SINGLE_SKU_V2
+#define SINGLE_SKU_TABLE_FILE_NAME "/etc/Wireless/RT2860STA/SingleSKU.dat"
+#endif /* SINGLE_SKU_V2 */
+
+#endif /* CONFIG_AP_SUPPORT */
+
+
+
+#ifdef CONFIG_APSTA_MIXED_SUPPORT
+extern 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 net_device_stats NET_DEV_STATS;
+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 ra_dma_addr_t NDIS_PHYSICAL_ADDRESS;
+typedef ra_dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
+typedef void * NDIS_HANDLE;
+typedef char * PNDIS_BUFFER;
+
+typedef struct ifreq NET_IOCTL;
+typedef struct ifreq * PNET_IOCTL;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+typedef struct pid * RTMP_OS_PID;
+#else
+typedef pid_t RTMP_OS_PID;
+#endif
+
+typedef struct semaphore 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 /proc */
+struct 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_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
+
+#define NET_DEVICE_REAL_IDX_MASK 0x0f /* for each operation mode, we maximum support 15 entities. */
+
+
+
+
+/***********************************************************************************
+ * OS signaling related constant definitions
+ ***********************************************************************************/
+
+
+/***********************************************************************************
+ * OS file operation related data structure definitions
+ ***********************************************************************************/
+typedef struct file* RTMP_OS_FD;
+
+typedef struct _OS_FS_INFO_
+{
+ int fsuid;
+ int fsgid;
+ mm_segment_t fs;
+} OS_FS_INFO;
+
+#define IS_FILE_OPEN_ERR(_fd) ((_fd == NULL) || IS_ERR((_fd)))
+
+
+/***********************************************************************************
+ * OS semaphore related data structure and definitions
+ ***********************************************************************************/
+struct os_lock {
+ spinlock_t lock;
+ unsigned long flags;
+};
+
+typedef spinlock_t OS_NDIS_SPIN_LOCK;
+
+/* */
+/* spin_lock enhanced for Nested spin lock */
+/* */
+#define OS_NdisAllocateSpinLock(__lock) \
+{ \
+ spin_lock_init((spinlock_t *)(__lock)); \
+}
+
+#define OS_NdisFreeSpinLock(lock) \
+ do{}while(0)
+
+
+#define OS_SEM_LOCK(__lock) \
+{ \
+ spin_lock_bh((spinlock_t *)(__lock)); \
+}
+
+#define OS_SEM_UNLOCK(__lock) \
+{ \
+ spin_unlock_bh((spinlock_t *)(__lock)); \
+}
+
+
+/* sample, use semaphore lock to replace IRQ lock, 2007/11/15 */
+#ifdef MULTI_CORE_SUPPORT
+
+#define OS_IRQ_LOCK(__lock, __irqflags) \
+{ \
+ __irqflags = 0; \
+ spin_lock_irqsave((spinlock_t *)(__lock), __irqflags); \
+}
+
+#define OS_IRQ_UNLOCK(__lock, __irqflag) \
+{ \
+ spin_unlock_irqrestore((spinlock_t *)(__lock), __irqflag); \
+}
+#else
+#define OS_IRQ_LOCK(__lock, __irqflags) \
+{ \
+ __irqflags = 0; \
+ spin_lock_bh((spinlock_t *)(__lock)); \
+}
+
+#define OS_IRQ_UNLOCK(__lock, __irqflag) \
+{ \
+ spin_unlock_bh((spinlock_t *)(__lock)); \
+}
+#endif // MULTI_CORE_SUPPORT //
+#define OS_INT_LOCK(__lock, __irqflags) \
+{ \
+ spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
+}
+
+#define OS_INT_UNLOCK(__lock, __irqflag) \
+{ \
+ spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
+}
+
+#define OS_NdisAcquireSpinLock OS_SEM_LOCK
+#define OS_NdisReleaseSpinLock OS_SEM_UNLOCK
+
+/*
+ Following lock/unlock definition used for BBP/RF register read/write.
+ Currently we don't use it to protect MAC register access.
+
+ For USB:
+ we use binary semaphore to do the protection because all register
+ access done in kernel thread and should allow task go sleep when
+ in protected status.
+
+ For PCI/PCI-E/RBUS:
+ We use interrupt to do the protection because the register may accessed
+ in thread/tasklet/timer/inteerupt, so we use interrupt_disable to protect
+ the access.
+*/
+#define RTMP_MCU_RW_LOCK(_pAd, _irqflags) \
+ do{ \
+ if (_pAd->infType == RTMP_DEV_INF_USB) \
+ {\
+ RTMP_SEM_EVENT_WAIT(&_pAd->McuCmdSem, _irqflags);\
+ }\
+ else\
+ {\
+ RTMP_SEM_LOCK(&_pAd->McuCmdLock, _irqflags);\
+ }\
+ }while(0)
+
+#define RTMP_MCU_RW_UNLOCK(_pAd, _irqflags) \
+ do{ \
+ if(_pAd->infType == RTMP_DEV_INF_USB)\
+ { \
+ RTMP_SEM_EVENT_UP(&_pAd->McuCmdSem);\
+ } \
+ else\
+ {\
+ RTMP_SEM_UNLOCK(&_pAd->McuCmdLock, _irqflags);\
+ }\
+ }while(0)
+
+
+#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 OS_SEM_EVENT_INIT_LOCKED(_pSema) sema_init((_pSema), 0)
+#define OS_SEM_EVENT_INIT(_pSema) sema_init((_pSema), 1)
+#define OS_SEM_EVENT_DESTORY(_pSema) do{}while(0)
+#define OS_SEM_EVENT_WAIT(_pSema, _status) ((_status) = down_interruptible((_pSema)))
+#define OS_SEM_EVENT_UP(_pSema) up(_pSema)
+
+#define RTCMDUp OS_RTCMDUp
+
+#ifdef KTHREAD_SUPPORT
+#define RTMP_WAIT_EVENT_INTERRUPTIBLE(_Status, _pTask) \
+do { \
+ wait_event_interruptible(_pTask->kthread_q, \
+ _pTask->kthread_running || kthread_should_stop()); \
+ _pTask->kthread_running = FALSE; \
+ if (kthread_should_stop()) \
+ { \
+ (_Status) = -1; \
+ break; \
+ } \
+ else (_Status) = 0; \
+} while(0)
+#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; // no use */
+#define THREAD_PID_INIT_VALUE NULL
+/* TODO: Use this IOCTL carefully when linux kernel version larger than 2.6.27, because the PID only correct when the user space task do this ioctl itself. */
+/*#define RTMP_GET_OS_PID(_x, _y) _x = get_task_pid(current, PIDTYPE_PID); */
+#define RT_GET_OS_PID(_x, _y) do{rcu_read_lock(); _x=(ULONG)current->pids[PIDTYPE_PID].pid; rcu_read_unlock();}while(0)
+#ifdef OS_ABL_FUNC_SUPPORT
+#define RTMP_GET_OS_PID(_a, _b) RtmpOsGetPid(&_a, _b)
+#else
+#define RTMP_GET_OS_PID(_a, _b) RT_GET_OS_PID(_a, _b)
+#endif
+#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))
+#else
+/*typedef pid_t THREAD_PID; // no use */
+#define THREAD_PID_INIT_VALUE -1
+#define RT_GET_OS_PID(_x, _pid) _x = _pid
+#define RTMP_GET_OS_PID(_x, _pid) _x = _pid
+#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))
+#endif
+
+#define ATE_KILL_THREAD_PID(PID) KILL_THREAD_PID(PID, SIGTERM, 1)
+
+typedef int (*cast_fn)(void *);
+typedef INT (*RTMP_OS_TASK_CALLBACK)(ULONG);
+
+#ifdef WORKQUEUE_BH
+typedef struct work_struct OS_NET_TASK_STRUCT;
+typedef struct work_struct *POS_NET_TASK_STRUCT;
+#else
+typedef struct tasklet_struct OS_NET_TASK_STRUCT;
+typedef struct tasklet_struct *POS_NET_TASK_STRUCT;
+#endif /* WORKQUEUE_BH */
+
+/***********************************************************************************
+ * Timer related definitions and data structures.
+ **********************************************************************************/
+#define OS_HZ HZ
+
+typedef struct timer_list OS_NDIS_MINIPORT_TIMER;
+typedef struct timer_list OS_TIMER;
+
+typedef void (*TIMER_FUNCTION)(unsigned long);
+
+
+#define OS_WAIT(_time) \
+{ \
+ if (in_interrupt()) \
+ {\
+ RTMPusecDelay(_time * 1000);\
+ }else \
+ {\
+ 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; \
+})
+#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)
+#define RTMP_TIME_AFTER(a,b) time_after(a, b)
+#endif
+
+#define ONE_TICK 1
+
+static inline void NdisGetSystemUpTime(ULONG *time)
+{
+ *time = jiffies;
+}
+
+
+/***********************************************************************************
+ * OS specific cookie data structure binding to RTMP_ADAPTER
+ ***********************************************************************************/
+
+struct os_cookie {
+
+#ifdef RTMP_MAC_USB
+ struct usb_device *pUsb_Dev;
+#endif /* RTMP_MAC_USB */
+
+#ifdef WORKQUEUE_BH
+ UINT32 pAd_va;
+#endif /* WORKQUEUE_BH */
+
+ RTMP_NET_TASK_STRUCT rx_done_task;
+ RTMP_NET_TASK_STRUCT cmd_rsp_event_task;
+ RTMP_NET_TASK_STRUCT mgmt_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac0_dma_done_task;
+#ifdef RALINK_ATE
+ RTMP_NET_TASK_STRUCT ate_ac0_dma_done_task;
+#endif /* RALINK_ATE */
+ RTMP_NET_TASK_STRUCT ac1_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac2_dma_done_task;
+ RTMP_NET_TASK_STRUCT ac3_dma_done_task;
+ RTMP_NET_TASK_STRUCT hcca_dma_done_task;
+ RTMP_NET_TASK_STRUCT tbtt_task;
+
+
+#ifdef UAPSD_SUPPORT
+ RTMP_NET_TASK_STRUCT uapsd_eosp_sent_task;
+#endif /* UAPSD_SUPPORT */
+
+#ifdef CONFIG_AP_SUPPORT
+#ifdef DFS_SUPPORT
+#ifdef DFS_SOFTWARE_SUPPORT
+ RTMP_NET_TASK_STRUCT pulse_radar_detect_task;
+ RTMP_NET_TASK_STRUCT width_radar_detect_task;
+#endif /* DFS_SOFTWARE_SUPPORT */
+#endif /* DFS_SUPPORT */
+
+#ifdef CARRIER_DETECTION_SUPPORT
+ RTMP_NET_TASK_STRUCT carrier_sense_task;
+#endif /* CARRIER_DETECTION_SUPPORT */
+
+#ifdef DFS_SUPPORT
+ struct tasklet_struct dfs_task;
+#endif /* DFS_SUPPORT */
+
+#endif /* CONFIG_AP_SUPPORT */
+
+#ifdef RTMP_MAC_USB
+ RTMP_NET_TASK_STRUCT null_frame_complete_task;
+ RTMP_NET_TASK_STRUCT pspoll_frame_complete_task;
+#endif /* RTMP_MAC_USB */
+
+#ifdef CONFIG_MULTI_CHANNEL
+ RTMP_NET_TASK_STRUCT hcca_null_frame_complete_task;
+#endif /* CONFIG_MULTI_CHANNEL */
+
+ RTMP_OS_PID apd_pid; /*802.1x daemon pid */
+ unsigned long apd_pid_nr;
+#ifdef CONFIG_AP_SUPPORT
+#ifdef IAPP_SUPPORT
+/* RT_SIGNAL_STRUC RTSignal; */
+ RTMP_OS_PID IappPid; /*IAPP daemon pid */
+ unsigned long IappPid_nr;
+#endif /* IAPP_SUPPORT */
+#endif /* CONFIG_AP_SUPPORT */
+#ifdef WAPI_SUPPORT
+ RTMP_OS_PID wapi_pid; /*wapi daemon pid */
+ unsigned long wapi_pid_nr;
+#endif /* WAPI_SUPPORT */
+ INT ioctl_if_type;
+ INT ioctl_if;
+};
+
+typedef struct os_cookie * POS_COOKIE;
+
+
+
+/***********************************************************************************
+ * OS debugging and printing related definitions and data structure
+ ***********************************************************************************/
+#define PRINT_MAC(addr) \
+ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
+
+#ifdef DBG
+extern ULONG RTDebugLevel;
+extern ULONG RTDebugFunc;
+
+#define DBGPRINT_RAW(Level, Fmt) \
+do{ \
+ ULONG __gLevel = (Level) & 0xff;\
+ ULONG __fLevel = ((Level)>>8) & 0xffffff;\
+ if (__gLevel <= RTDebugLevel) \
+ { \
+ if ((RTDebugFunc == 0) || \
+ ((RTDebugFunc != 0) && (((__fLevel & RTDebugFunc)!= 0) || (__gLevel <= RT_DEBUG_ERROR))))\
+ printk Fmt; \
+ } \
+}while(0)
+
+#define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
+
+
+#define DBGPRINT_ERR(Fmt) \
+{ \
+ printk("ERROR!!! "); \
+ printk Fmt; \
+}
+
+#define DBGPRINT_S(Status, Fmt) \
+{ \
+ printk Fmt; \
+}
+#else
+#define DBGPRINT(Level, Fmt)
+#define DBGPRINT_RAW(Level, Fmt)
+#define DBGPRINT_S(Status, Fmt)
+#define DBGPRINT_ERR(Fmt)
+#endif
+
+#undef ASSERT
+#ifdef DBG
+#define ASSERT(x) \
+{ \
+ if (!(x)) \
+ { \
+ printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \
+ } \
+}
+#else
+#define ASSERT(x)
+#endif /* DBG */
+
+void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
+
+
+/*********************************************************************************************************
+ The following code are not revised, temporary put it here.
+ *********************************************************************************************************/
+
+
+/***********************************************************************************
+ * Device DMA Access related definitions and data structures.
+ **********************************************************************************/
+ra_dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
+void linux_pci_unmap_single(void *handle, ra_dma_addr_t dma_addr, size_t size, int direction);
+
+#define PCI_MAP_SINGLE_DEV(_handle, _ptr, _size, _sd_idx, _dir) \
+ linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir)
+
+#define PCI_UNMAP_SINGLE(_pAd, _ptr, _size, _dir) \
+ linux_pci_unmap_single(((POS_COOKIE)(_pAd->OS_Cookie))->pci_dev, _ptr, _size, _dir)
+
+#define PCI_ALLOC_CONSISTENT(_pci_dev, _size, _ptr) \
+ pci_alloc_consistent(_pci_dev, _size, _ptr)
+
+#define PCI_FREE_CONSISTENT(_pci_dev, _size, _virtual_addr, _physical_addr) \
+ pci_free_consistent(_pci_dev, _size, _virtual_addr, _physical_addr)
+
+#ifdef VENDOR_FEATURE2_SUPPORT
+#define DEV_ALLOC_SKB(_pAd, _Pkt, _length) \
+ _Pkt = dev_alloc_skb(_length); \
+ if (_Pkt != NULL) {MEM_DBG_PKT_ALLOC_INC(_Pkt);};
+#else
+
+#define DEV_ALLOC_SKB(_pAd, _Pkt, _length) \
+ _Pkt = dev_alloc_skb(_length);
+#endif /* VENDOR_FEATURE2_SUPPORT */
+
+/*#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0 */
+/*#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) */
+
+
+/*
+ * ULONG
+ * RTMP_GetPhysicalAddressLow(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
+ */
+#define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
+
+/*
+ * ULONG
+ * RTMP_GetPhysicalAddressHigh(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
+ */
+#define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
+
+/*
+ * VOID
+ * RTMP_SetPhysicalAddressLow(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
+ * IN ULONG Value);
+ */
+#define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
+ PhysicalAddress = Value;
+
+/*
+ * VOID
+ * RTMP_SetPhysicalAddressHigh(
+ * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
+ * IN ULONG Value);
+ */
+#define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
+
+#define NdisMIndicateStatus(_w, _x, _y, _z)
+
+
+
+/***********************************************************************************
+ * Device Register I/O Access related definitions and data structures.
+ **********************************************************************************/
+
+#ifdef RTMP_MAC_USB
+#define RTMP_IO_FORCE_READ32(_A, _R, _pV) \
+ RTUSBReadMACRegister((_A), (_R), (PUINT32) (_pV))
+
+#define RTMP_IO_READ32(_A, _R, _pV) \
+ RTUSBReadMACRegister((_A), (_R), (PUINT32) (_pV))
+
+#define RTMP_IO_FORCE_WRITE32(_A, _R, _V) \
+ do{\
+ /*if ((_R) != 0x404)*/ /* TODO:shiang-6590, depends on sw porting guide, don't acccess it now */\
+ RTUSBWriteMACRegister((_A), (_R), (UINT32) (_V), FALSE); \
+ }while(0)
+
+#define RTMP_IO_READ8(_A, _R, _pV) \
+{ \
+}
+
+#define RTMP_IO_WRITE32(_A, _R, _V) \
+ RTUSBWriteMACRegister((_A), (_R), (UINT32) (_V), FALSE)
+
+#define RTMP_IO_WRITE8(_A, _R, _V) \
+{ \
+ USHORT _Val = _V; \
+ RTUSBSingleWrite((_A), (_R), (USHORT) (_Val), FALSE); \
+}
+
+
+#define RTMP_IO_WRITE16(_A, _R, _V) \
+{ \
+ RTUSBSingleWrite((_A), (_R), (USHORT) (_V), FALSE); \
+}
+
+#define RTMP_SYS_IO_READ32
+#define RTMP_SYS_IO_WRITE32
+#endif /* RTMP_MAC_USB */
+
+#define RTMP_USB_URB_DATA_GET(__pUrb) ((purbb_t)__pUrb)->context
+#define RTMP_USB_URB_STATUS_GET(__pUrb) ((purbb_t)__pUrb)->status
+#define RTMP_USB_URB_LEN_GET(__pUrb) ((purbb_t)__pUrb)->actual_length
+
+/***********************************************************************************
+ * Network Related data structure and marco definitions
+ ***********************************************************************************/
+#define PKTSRC_NDIS 0x7f
+#define PKTSRC_DRIVER 0x0f
+
+#define RTMP_OS_NETDEV_STATE_RUNNING(_pNetDev) ((_pNetDev)->flags & IFF_UP)
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+#define _RTMP_OS_NETDEV_GET_PRIV(_pNetDev) ((_pNetDev)->ml_priv)
+#define _RTMP_OS_NETDEV_SET_PRIV(_pNetDev, _pPriv) ((_pNetDev)->ml_priv = (_pPriv))
+#else
+#define _RTMP_OS_NETDEV_GET_PRIV(_pNetDev) ((_pNetDev)->priv)
+#define _RTMP_OS_NETDEV_SET_PRIV(_pNetDev, _pPriv) ((_pNetDev)->priv = (_pPriv))
+#endif
+
+#define RTMP_OS_NETDEV_GET_DEVNAME(_pNetDev) ((_pNetDev)->name)
+#define RTMP_OS_NETDEV_GET_PHYADDR(_pNetDev) ((_pNetDev)->dev_addr)
+
+/* Get & Set NETDEV interface hardware type */
+#define RTMP_OS_NETDEV_GET_TYPE(_pNetDev) ((_pNetDev)->type)
+#define RTMP_OS_NETDEV_SET_TYPE(_pNetDev, _type) ((_pNetDev)->type = (_type))
+#define RTMP_OS_NETDEV_SET_TYPE_MONITOR(_pNetDev) RTMP_OS_NETDEV_SET_TYPE(_pNetDev, ARPHRD_IEEE80211_PRISM)
+
+#define RTMP_OS_NETDEV_START_QUEUE(_pNetDev) netif_start_queue((_pNetDev))
+#define RTMP_OS_NETDEV_STOP_QUEUE(_pNetDev) netif_stop_queue((_pNetDev))
+#define RTMP_OS_NETDEV_WAKE_QUEUE(_pNetDev) netif_wake_queue((_pNetDev))
+#define RTMP_OS_NETDEV_CARRIER_OFF(_pNetDev) netif_carrier_off((_pNetDev))
+
+#define QUEUE_ENTRY_TO_PACKET(pEntry) \
+ (PNDIS_PACKET)(pEntry)
+
+#define PACKET_TO_QUEUE_ENTRY(pPacket) \
+ (PQUEUE_ENTRY)(pPacket)
+
+#ifdef CONFIG_5VT_ENHANCE
+#define BRIDGE_TAG 0x35564252 /* depends on 5VT define in br_input.c */
+#endif
+
+#define GET_SG_LIST_FROM_PACKET(_p, _sc) \
+ rt_get_sg_list_from_packet(_p, _sc)
+
+#define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
+{ \
+ RTMPFreeNdisPacket(_pAd, _pPacket); \
+}
+
+
+/*
+ * packet helper
+ * - convert internal rt packet to os packet or
+ * os packet to rt packet
+ */
+#define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
+#define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p))
+
+#define GET_OS_PKT_DATAPTR(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->data)
+#define SET_OS_PKT_DATAPTR(_pkt, _dataPtr) \
+ (RTPKT_TO_OSPKT(_pkt)->data) = (_dataPtr)
+
+#define GET_OS_PKT_LEN(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->len)
+#define SET_OS_PKT_LEN(_pkt, _len) \
+ (RTPKT_TO_OSPKT(_pkt)->len) = (_len)
+
+#define GET_OS_PKT_DATATAIL(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->tail)
+#define SET_OS_PKT_DATATAIL(_pkt, _start, _len) \
+ ((RTPKT_TO_OSPKT(_pkt))->tail) = (PUCHAR)((_start) + (_len))
+
+#define GET_OS_PKT_HEAD(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->head)
+
+#define GET_OS_PKT_END(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->end)
+
+#define GET_OS_PKT_NETDEV(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->dev)
+#define SET_OS_PKT_NETDEV(_pkt, _pNetDev) \
+ (RTPKT_TO_OSPKT(_pkt)->dev) = (_pNetDev)
+
+#define GET_OS_PKT_TYPE(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt))
+
+#define GET_OS_PKT_NEXT(_pkt) \
+ (RTPKT_TO_OSPKT(_pkt)->next)
+
+
+#define OS_PKT_CLONED(_pkt) skb_cloned(RTPKT_TO_OSPKT(_pkt))
+#define OS_PKT_COPY(_pkt) skb_copy(RTPKT_TO_OSPKT(_pkt), GFP_ATOMIC)
+
+#define OS_PKT_TAIL_ADJUST(_pkt, _removedTagLen) \
+ SET_OS_PKT_DATATAIL(_pkt, GET_OS_PKT_DATATAIL(_pkt), (-_removedTagLen)); \
+ GET_OS_PKT_LEN(_pkt) -= _removedTagLen;
+
+#define OS_PKT_HEAD_BUF_EXTEND(_pkt, _offset) \
+ skb_push(RTPKT_TO_OSPKT(_pkt), _offset)
+
+#define OS_PKT_TAIL_BUF_EXTEND(_pkt, _Len) \
+ skb_put(RTPKT_TO_OSPKT(_pkt), _Len)
+
+#define OS_PKT_RESERVE(_pkt, _Len) \
+ skb_reserve(RTPKT_TO_OSPKT(_pkt), _Len)
+
+#define RTMP_OS_PKT_INIT(__pRxPacket, __pNetDev, __pData, __DataSize) \
+{ \
+ PNDIS_PACKET __pRxPkt; \
+ __pRxPkt = RTPKT_TO_OSPKT(__pRxPacket); \
+ SET_OS_PKT_NETDEV(__pRxPkt, __pNetDev); \
+ SET_OS_PKT_DATAPTR(__pRxPkt, __pData); \
+ SET_OS_PKT_LEN(__pRxPkt, __DataSize); \
+ SET_OS_PKT_DATATAIL(__pRxPkt, __pData, __DataSize); \
+}
+
+#ifdef VENDOR_FEATURE2_SUPPORT
+#define OS_PKT_CLONE(_pAd, _pkt, _src, _flag) \
+ _src = skb_clone(RTPKT_TO_OSPKT(_pkt), _flag); \
+ if (_src != NULL) OS_NumOfPktAlloc ++;
+#else
+
+#define OS_PKT_CLONE(_pAd, _pkt, _src, _flag) \
+ _src = skb_clone(RTPKT_TO_OSPKT(_pkt), _flag);
+#endif /* VENDOR_FEATURE2_SUPPORT */
+
+#define get_unaligned32 get_unaligned
+#define get_unalignedlong get_unaligned
+
+#define OS_NTOHS(_Val) \
+ (ntohs((_Val)))
+#define OS_HTONS(_Val) \
+ (htons((_Val)))
+#define OS_NTOHL(_Val) \
+ (ntohl((_Val)))
+#define OS_HTONL(_Val) \
+ (htonl((_Val)))
+
+#define CB_OFF 10
+
+#define GET_OS_PKT_CB(_p) (RTPKT_TO_OSPKT(_p)->cb)
+
+/* User Priority */
+#define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
+#define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
+
+/* Fragment # */
+#define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
+#define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
+
+/* 0x0 ~0x7f: TX to AP's own BSS which has the specified AID. if AID>127, set bit 7 in RTMP_SET_PACKET_EMACTAB too. */
+/*(this value also as MAC(on-chip WCID) table index) */
+/* 0x80~0xff: TX to a WDS link. b0~6: WDS index */
+#define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
+#define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
+
+/* 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet */
+#define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
+#define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
+
+/* RTS/CTS-to-self protection method */
+#define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
+#define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
+/* see RTMP_S(G)ET_PACKET_EMACTAB */
+
+/* TX rate index */
+#define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
+#define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
+
+/* From which Interface */
+#define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
+#define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
+#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
+#define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
+#define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
+#define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
+#define RTMP_SET_PACKET_NET_DEVICE_P2P(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_P2P_GO))
+#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
+#define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
+
+#define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
+#define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
+
+
+
+#ifdef UAPSD_SUPPORT
+/* if we queue a U-APSD packet to any software queue, we will set the U-APSD
+ flag and its physical queue ID for it */
+#define RTMP_SET_PACKET_UAPSD(_p, _flg_uapsd, _que_id) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+9] = ((_flg_uapsd<<7) | _que_id))
+
+#define RTMP_SET_PACKET_QOS_NULL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+9] = 0xff)
+#define RTMP_GET_PACKET_QOS_NULL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+9])
+#define RTMP_SET_PACKET_NON_QOS_NULL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+9] = 0x00)
+#define RTMP_GET_PACKET_UAPSD_Flag(_p) (((RTPKT_TO_OSPKT(_p)->cb[CB_OFF+9]) & 0x80) >> 7)
+#define RTMP_GET_PACKET_UAPSD_QUE_ID(_p) ((RTPKT_TO_OSPKT(_p)->cb[CB_OFF+9]) & 0x7f)
+
+#define RTMP_SET_PACKET_EOSP(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+10] = _flg)
+#define RTMP_GET_PACKET_EOSP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+10])
+#endif /* UAPSD_SUPPORT */
+
+/* */
+/* Sepcific Pakcet Type definition */
+/* */
+#define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
+
+#define RTMP_PACKET_SPECIFIC_DHCP 0x01
+#define RTMP_PACKET_SPECIFIC_EAPOL 0x02
+#define RTMP_PACKET_SPECIFIC_IPV4 0x04
+#define RTMP_PACKET_SPECIFIC_WAI 0x08
+#define RTMP_PACKET_SPECIFIC_VLAN 0x10
+#define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
+#define RTMP_PACKET_SPECIFIC_TDLS 0x40
+
+/*Specific */
+#define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
+
+/*DHCP */
+#define RTMP_SET_PACKET_DHCP(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_DHCP); \
+ }while(0)
+#define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
+
+/*EAPOL */
+#define RTMP_SET_PACKET_EAPOL(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_EAPOL); \
+ }while(0)
+#define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
+
+/*WAI */
+#define RTMP_SET_PACKET_WAI(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_WAI); \
+ }while(0)
+#define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
+
+#define RTMP_GET_PACKET_LOWRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & (RTMP_PACKET_SPECIFIC_EAPOL | RTMP_PACKET_SPECIFIC_DHCP | RTMP_PACKET_SPECIFIC_WAI))
+
+/*VLAN */
+#define RTMP_SET_PACKET_VLAN(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_VLAN); \
+ }while(0)
+#define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
+
+/*LLC/SNAP */
+#define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_LLCSNAP); \
+ }while(0)
+
+#define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
+
+/* IP */
+#define RTMP_SET_PACKET_IPV4(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_IPV4); \
+ }while(0)
+
+#define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
+
+// TDLS
+#define RTMP_SET_PACKET_TDLS(_p, _flg) \
+ do{ \
+ if (_flg) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_TDLS); \
+ else \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (~RTMP_PACKET_SPECIFIC_TDLS); \
+ }while(0)
+
+#define RTMP_GET_PACKET_TDLS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_TDLS)
+
+/* If this flag is set, it indicates that this EAPoL frame MUST be clear. */
+#define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
+#define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
+
+
+#ifdef DOT11_VHT_AC
+#define MAX_PACKETS_IN_QUEUE 1024 /*(512)*/
+#else
+#define MAX_PACKETS_IN_QUEUE (512)
+#endif /* DOT11_VHT_AC */
+
+
+/* use bit3 of cb[CB_OFF+16] */
+#define RTMP_SET_PACKET_MGMT_PKT(_p, _flg) \
+ RTPKT_TO_OSPKT(_p)->cb[CB_OFF+16] = (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+16] & 0xF7) | ((_flg & 0x01) << 3);
+#define RTMP_GET_PACKET_MGMT_PKT(_p) \
+ ((RTPKT_TO_OSPKT(_p)->cb[CB_OFF+16] & 0x08) >> 3)
+
+/* use bit0 of cb[CB_OFF+20] */
+#define RTMP_SET_PACKET_MGMT_PKT_DATA_QUE(_p, _flg) \
+ RTPKT_TO_OSPKT(_p)->cb[CB_OFF+20] = (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+20] & 0xFE) | (_flg & 0x01);
+#define RTMP_GET_PACKET_MGMT_PKT_DATA_QUE(_p) \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+20] & 0x01)
+
+#define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
+#define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
+
+#define RTMP_SET_PACKET_PROTOCOL(_p, _protocol) {\
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23] = (UINT8)((_protocol) & 0x00ff)); \
+ (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+24] = (UINT8)(((_protocol) & 0xff00) >> 8)); \
+}
+
+#define RTMP_GET_PACKET_PROTOCOL(_p) \
+ ((((UINT16)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+24]) & 0x00ff) << 8) \
+ | ((UINT16)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23]) & 0x00ff))
+
+#ifdef INF_AMAZON_SE
+/* [CB_OFF+28], 1B, Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate */
+#define RTMP_SET_PACKET_NOBULKOUT(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+28] = _morebit)
+#define RTMP_GET_PACKET_NOBULKOUT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+28])
+#endif /* INF_AMAZON_SE */
+
+
+
+#if defined(CONFIG_CSO_SUPPORT) || defined(CONFIG_RX_CSO_SUPPORT)
+#define RTMP_SET_TCP_CHKSUM_FAIL(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+30] = _flg);
+#define RTMP_GET_TCP_CHKSUM_FAIL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+30])
+#endif /* defined(CONFIG_CSO_SUPPORT) || defined(CONFIG_RX_CSO_SUPPORT) */
+
+
+/* Max skb->cb = 48B = [CB_OFF+38] */
+
+
+
+/***********************************************************************************
+ * Other function prototypes definitions
+ ***********************************************************************************/
+void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
+int rt28xx_packet_xmit(VOID *skb);
+
+
+#if LINUX_VERSION_CODE <= 0x20402 /* Red Hat 7.1 */
+struct net_device *alloc_netdev(int sizeof_priv, const char *mask, void (*setup)(struct net_device *));
+#endif /* LINUX_VERSION_CODE */
+
+
+
+INT rt28xx_ioctl(
+ IN PNET_DEV net_dev,
+ IN OUT struct ifreq *rq,
+ IN INT cmd);
+
+extern int ra_mtd_write(int num, loff_t to, size_t len, const u_char *buf);
+extern int ra_mtd_read(int num, loff_t from, size_t len, u_char *buf);
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+#define _GET_PAD_FROM_NET_DEV(_pAd, _net_dev) (_pAd) = (_net_dev)->ml_priv;
+#else
+#define _GET_PAD_FROM_NET_DEV(_pAd, _net_dev) (_pAd) = (_net_dev)->priv;
+#endif
+
+#define GET_PAD_FROM_NET_DEV(_pAd, _net_dev) \
+ _pAd = RTMP_OS_NETDEV_GET_PRIV(_net_dev);
+
+/*#ifdef RTMP_USB_SUPPORT */
+/******************************************************************************
+
+ USB related definitions
+
+******************************************************************************/
+
+#define RTMP_USB_PKT_COPY(__pNetDev, __pNetPkt, __Len, __pData) \
+{ \
+ memcpy(skb_put(__pNetPkt, __Len), __pData, __Len); \
+ GET_OS_PKT_NETDEV(__pNetPkt) = __pNetDev; \
+ RTMP_SET_PACKET_SOURCE(OSPKT_TO_RTPKT(__pNetPkt), PKTSRC_NDIS); \
+}
+
+typedef struct usb_device_id USB_DEVICE_ID;
+
+#ifdef INF_AMAZON_SE
+#define BULKAGGRE_SIZE 30
+#else
+#define BULKAGGRE_SIZE 60 /* 100 */
+#endif /* INF_AMAZON_SE */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+
+#ifndef OS_ABL_SUPPORT
+/*#define RT28XX_PUT_DEVICE usb_put_dev */
+#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC)
+#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, GFP_ATOMIC)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#define RTUSB_URB_ALLOC_BUFFER(_dev, _size, _dma) usb_alloc_coherent(_dev, _size, GFP_ATOMIC, _dma)
+#define RTUSB_URB_FREE_BUFFER(_dev, _size, _addr, _dma) usb_free_coherent(_dev, _size, _addr, _dma)
+#else
+#define RTUSB_URB_ALLOC_BUFFER(_dev, _size, _dma) usb_buffer_alloc(_dev, _size, GFP_ATOMIC, _dma)
+#define RTUSB_URB_FREE_BUFFER(_dev, _size, _addr, _dma) usb_buffer_free(_dev, _size, _addr, _dma)
+#endif
+#else
+#define RTUSB_URB_ALLOC_BUFFER(_dev, _size, _dma) kmalloc(_size, GFP_ATOMIC)
+#define RTUSB_URB_FREE_BUFFER(_dev, _size, _addr, _dma) kfree(_addr)
+#endif
+
+#else
+
+/*#define RT28XX_PUT_DEVICE rausb_put_dev */
+#define RTUSB_ALLOC_URB(iso) rausb_alloc_urb(iso)
+#define RTUSB_SUBMIT_URB(pUrb) rausb_submit_urb(pUrb)
+#define RTUSB_URB_ALLOC_BUFFER rausb_buffer_alloc
+#define RTUSB_URB_FREE_BUFFER rausb_buffer_free
+#endif /* OS_ABL_SUPPORT */
+
+#else
+
+#define RT28XX_PUT_DEVICE(dev_p)
+
+#ifndef OS_ABL_SUPPORT
+#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso)
+#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb)
+#else
+#define RTUSB_ALLOC_URB(iso) rausb_alloc_urb(iso)
+#define RTUSB_SUBMIT_URB(pUrb) rausb_submit_urb(pUrb)
+#endif /* OS_ABL_SUPPORT */
+
+#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) kmalloc(BufSize, GFP_ATOMIC)
+#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) kfree(pTransferBuf)
+#endif
+
+#ifndef OS_ABL_SUPPORT
+#define RTUSB_FREE_URB(pUrb) usb_free_urb(pUrb)
+#else
+#define RTUSB_FREE_URB(pUrb) rausb_free_urb(pUrb)
+#endif /* OS_ABL_SUPPORT */
+
+/* unlink urb */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+
+#ifndef OS_ABL_SUPPORT
+#define RTUSB_UNLINK_URB(pUrb) usb_kill_urb(pUrb)
+#else
+#define RTUSB_UNLINK_URB(pUrb) rausb_kill_urb(pUrb)
+#endif /* OS_ABL_SUPPORT */
+
+#else
+#define RTUSB_UNLINK_URB(pUrb) usb_unlink_urb(pUrb)
+#endif /* LINUX_VERSION_CODE */
+
+/* Prototypes of completion funuc. */
+#define RtmpUsbBulkOutDataPacketComplete RTUSBBulkOutDataPacketComplete
+#define RtmpUsbBulkOutMLMEPacketComplete RTUSBBulkOutMLMEPacketComplete
+#define RtmpUsbBulkOutNullFrameComplete RTUSBBulkOutNullFrameComplete
+#ifdef CONFIG_MULTI_CHANNEL
+#define RtmpUsbBulkOutHCCANullFrameComplete RTUSBBulkOutHCCANullFrameComplete
+#endif /* CONFIG_MULTI_CHANNEL */
+#define RtmpUsbBulkOutRTSFrameComplete RTUSBBulkOutRTSFrameComplete
+#define RtmpUsbBulkOutPsPollComplete RTUSBBulkOutPsPollComplete
+#define RtmpUsbBulkRxComplete RTUSBBulkRxComplete
+#define RTUSBBulkCmdRspEventComplete(Status, pURB, pt_regs) RTUSBBulkCmdRspEventComplete(pURB)
+
+#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 51)) || (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)))
+#define RTUSBBulkOutDataPacketComplete(Status, pURB, pt_regs) RTUSBBulkOutDataPacketComplete(pURB)
+#define RTUSBBulkOutMLMEPacketComplete(Status, pURB, pt_regs) RTUSBBulkOutMLMEPacketComplete(pURB)
+#define RTUSBBulkOutNullFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutNullFrameComplete(pURB)
+#ifdef CONFIG_MULTI_CHANNEL
+#define RTUSBBulkOutHCCANullFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutHCCANullFrameComplete(pURB)
+#endif /* CONFIG_MULTI_CHANNEL */
+#define RTUSBBulkOutRTSFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutRTSFrameComplete(pURB)
+#define RTUSBBulkOutPsPollComplete(Status, pURB, pt_regs) RTUSBBulkOutPsPollComplete(pURB)
+#define RTUSBBulkRxComplete(Status, pURB, pt_regs) RTUSBBulkRxComplete(pURB)
+#define RTUSBBulkCmdRspEventComplete(Status, pURB, pt_regs) RTUSBBulkCmdRspEventComplete(pURB)
+#define USBUploadFWComplete(Status, pURB, pt_regs) USBUploadFWComplete(pURB)
+#define USBKickOutCmdComplete(Status, pURB, pt_regs) USBKickOutCmdComplete(pURB)
+#else
+#define RTUSBBulkOutDataPacketComplete(Status, pURB, pt_regs) RTUSBBulkOutDataPacketComplete(pURB, pt_regs)
+#define RTUSBBulkOutMLMEPacketComplete(Status, pURB, pt_regs) RTUSBBulkOutMLMEPacketComplete(pURB, pt_regs)
+#define RTUSBBulkOutNullFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutNullFrameComplete(pURB, pt_regs)
+#ifdef CONFIG_MULTI_CHANNEL
+#define RTUSBBulkOutHCCANullFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutHCCANullFrameComplete(pURB, pt_regs)
+#endif /* CONFIG_MULTI_CHANNEL */
+#define RTUSBBulkOutRTSFrameComplete(Status, pURB, pt_regs) RTUSBBulkOutRTSFrameComplete(pURB, pt_regs)
+#define RTUSBBulkOutPsPollComplete(Status, pURB, pt_regs) RTUSBBulkOutPsPollComplete(pURB, pt_regs)
+#define RTUSBBulkRxComplete(Status, pURB, pt_regs) RTUSBBulkRxComplete(pURB, pt_regs)
+#define RTUSBBulkCmdRspEventComplete(Status, pURB, pt_regs) RTUSBBulkCmdRspEventComplete(pURB, pt_regs)
+#define USBUploadFWComplete(Status, pURB, pt_regs) USBUploadFWComplete(pURB, pt_regs)
+#define USBKickOutCmdComplete(Status, pURB, pt_regs) USBKickOutCmdComplete(pURB, pt_regs)
+#endif /* */
+
+/*extern void dump_urb(struct urb *purb); */
+
+#define InterlockedIncrement atomic_inc
+#define NdisInterlockedIncrement atomic_inc
+#define InterlockedDecrement atomic_dec
+#define NdisInterlockedDecrement atomic_dec
+#define InterlockedExchange atomic_set
+
+typedef void USBHST_STATUS;
+typedef INT32 URBCompleteStatus;
+typedef struct pt_regs pregs;
+
+USBHST_STATUS RTUSBBulkOutDataPacketComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkOutMLMEPacketComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkOutNullFrameComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+#ifdef CONFIG_MULTI_CHANNEL
+USBHST_STATUS RTUSBBulkOutHCCANullFrameComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+#endif /* CONFIG_MULTI_CHANNEL */
+USBHST_STATUS RTUSBBulkOutRTSFrameComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkOutPsPollComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkRxComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS RTUSBBulkCmdRspEventComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS USBUploadFWComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+USBHST_STATUS USBKickOutCmdComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+
+
+/* Fill Bulk URB Macro */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define RTUSB_FILL_TX_BULK_URB(pUrb, \
+ pUsb_Dev, \
+ uEndpointAddress, \
+ pTransferBuf, \
+ BufSize, \
+ Complete, \
+ pContext, \
+ TransferDma) \
+ do{ \
+ usb_fill_bulk_urb(pUrb, pUsb_Dev, usb_sndbulkpipe(pUsb_Dev, uEndpointAddress), \
+ pTransferBuf, BufSize, Complete, pContext); \
+ pUrb->transfer_dma = TransferDma; \
+ pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; \
+ }while(0)
+#else
+#define RTUSB_FILL_TX_BULK_URB(pUrb, \
+ pUsb_Dev, \
+ uEndpointAddress, \
+ pTransferBuf, \
+ BufSize, \
+ Complete, \
+ pContext, \
+ TransferDma) \
+ do{ \
+ FILL_BULK_URB(pUrb, pUsb_Dev, usb_sndbulkpipe(pUsb_Dev, uEndpointAddress), \
+ pTransferBuf, BufSize, Complete, pContext); \
+ }while(0)
+
+#endif
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define RTUSB_FILL_HTTX_BULK_URB(pUrb, \
+ pUsb_Dev, \
+ uEndpointAddress, \
+ pTransferBuf, \
+ BufSize, \
+ Complete, \
+ pContext, \
+ TransferDma) \
+ do{ \
+ usb_fill_bulk_urb(pUrb, pUsb_Dev, usb_sndbulkpipe(pUsb_Dev, uEndpointAddress), \
+ pTransferBuf, BufSize, Complete, pContext); \
+ pUrb->transfer_dma = TransferDma; \
+ pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; \
+ }while(0)
+#else
+#define RTUSB_FILL_HTTX_BULK_URB(pUrb, \
+ pUsb_Dev, \
+ uEndpointAddress, \
+ pTransferBuf, \
+ BufSize, \
+ Complete, \
+ pContext, \
+ TransferDma) \
+ do{ \
+ FILL_BULK_URB(pUrb, pUsb_Dev, usb_sndbulkpipe(pUsb_Dev, uEndpointAddress), \
+ pTransferBuf, BufSize, Complete, pContext); \
+ }while(0)
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define RTUSB_FILL_RX_BULK_URB(pUrb, \
+ pUsb_Dev, \
+ uEndpointAddress, \
+ pTransferBuf, \
+ BufSize, \
+ Complete, \
+ pContext, \
+ TransferDma) \
+ do{ \
+ usb_fill_bulk_urb(pUrb, pUsb_Dev, usb_rcvbulkpipe(pUsb_Dev, uEndpointAddress), \
+ pTransferBuf, BufSize, Complete, pContext); \
+ pUrb->transfer_dma = TransferDma; \
+ pUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; \
+ }while(0)
+/* pRxContext->data_dma + pAd->NextRxBulkInPosition; */
+#else
+#define RTUSB_FILL_RX_BULK_URB(pUrb, \
+ pUsb_Dev, \
+ uEndpointAddress, \
+ pTransferBuf, \
+ BufSize, \
+ Complete, \
+ pContext, \
+ TransferDma) \
+ do{ \
+ FILL_BULK_URB(pUrb, pUsb_Dev, usb_rcvbulkpipe(pUsb_Dev, uEndpointAddress), \
+ pTransferBuf, BufSize, Complete, pContext); \
+ }while(0)
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define RTUSB_URB_DMA_MAPPING(pUrb) \
+ { \
+ pUrb->transfer_dma = 0; \
+ pUrb->transfer_flags &= (~URB_NO_TRANSFER_DMA_MAP); \
+ }
+#else
+#define RTUSB_URB_DMA_MAPPING(pUrb)
+#endif
+
+#define RTUSB_CONTROL_MSG(pUsb_Dev, uEndpointAddress, Request, RequestType, Value,Index, tmpBuf, TransferBufferLength, timeout, ret) \
+ do{ \
+ if (RequestType == DEVICE_VENDOR_REQUEST_OUT) \
+ ret = USB_CONTROL_MSG(pUsb_Dev, usb_sndctrlpipe(pUsb_Dev, uEndpointAddress), Request, RequestType, Value, Index, tmpBuf, TransferBufferLength, timeout); \
+ else if (RequestType == DEVICE_VENDOR_REQUEST_IN) \
+ ret = USB_CONTROL_MSG(pUsb_Dev, usb_rcvctrlpipe(pUsb_Dev, uEndpointAddress), Request, RequestType, Value, Index, tmpBuf, TransferBufferLength, timeout); \
+ else \
+ { \
+ DBGPRINT(RT_DEBUG_ERROR, ("vendor request direction is failed\n")); \
+ ret = -1; \
+ } \
+ }while(0)
+
+#define rtusb_urb_context context
+#define rtusb_urb_status status
+
+#define RTMP_OS_USB_CONTEXT_GET(__pURB) __pURB->rtusb_urb_context
+#define RTMP_OS_USB_STATUS_GET(__pURB) __pURB->rtusb_urb_status
+
+#ifndef OS_ABL_SUPPORT
+#define USB_CONTROL_MSG usb_control_msg
+
+#else
+
+#define USB_CONTROL_MSG rausb_control_msg
+
+/*extern int rausb_register(struct usb_driver * new_driver); */
+/*extern void rausb_deregister(struct usb_driver * driver); */
+
+extern struct urb *rausb_alloc_urb(int iso_packets);
+extern void rausb_free_urb(VOID *urb);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+extern void rausb_put_dev(VOID *dev);
+extern struct usb_device *rausb_get_dev(VOID *dev);
+#endif /* LINUX_VERSION_CODE */
+
+extern int rausb_submit_urb(VOID *urb);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#ifndef gfp_t
+#define gfp_t INT32
+#endif /* gfp_t */
+
+extern void *rausb_buffer_alloc(VOID *dev,
+ size_t size,
+ ra_dma_addr_t *dma);
+extern void rausb_buffer_free(VOID *dev,
+ size_t size,
+ void *addr,
+ ra_dma_addr_t dma);
+#endif /* LINUX_VERSION_CODE */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
+extern void rausb_kill_urb(VOID *urb);
+#endif /* LINUX_VERSION_CODE */
+
+extern int rausb_control_msg(VOID *dev,
+ unsigned int pipe,
+ __u8 request,
+ __u8 requesttype,
+ __u16 value,
+ __u16 index,
+ void *data,
+ __u16 size,
+ int timeout);
+
+#endif /* OS_ABL_SUPPORT */
+
+/*#endif // RTMP_USB_SUPPORT */
+
+#ifdef RALINK_ATE
+/******************************************************************************
+
+ ATE related definitions
+
+******************************************************************************/
+#define ate_print printk
+#define ATEDBGPRINT DBGPRINT
+
+#ifdef RTMP_MAC_USB
+#ifdef CONFIG_AP_SUPPORT
+#define EEPROM_BIN_FILE_NAME "/etc/Wireless/RT2870AP/e2p.bin"
+#endif /* CONFIG_AP_SUPPORT */
+#endif /* RTMP_MAC_USB */
+
+#ifdef RTMP_USB_SUPPORT
+
+#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 51)) || (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)))
+/* Prototypes of completion funuc. */
+#define ATE_RTUSBBulkOutDataPacketComplete(Status, pURB, pt_regs) ATE_RTUSBBulkOutDataPacketComplete(pURB)
+#else
+#define ATE_RTUSBBulkOutDataPacketComplete(Status, pURB, pt_regs) ATE_RTUSBBulkOutDataPacketComplete(pURB, pt_regs)
+#endif /* LINUX_VERSION_CODE */
+
+USBHST_STATUS ATE_RTUSBBulkOutDataPacketComplete(URBCompleteStatus Status, purbb_t pURB, pregs *pt_regs);
+
+#endif /* RTMP_USB_SUPPORT */
+
+#endif /* RALINK_ATE */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
+INT RtmpOSNetDevOpsAlloc(
+ IN PVOID *pNetDevOps);
+#endif
+
+#define RTMP_OS_MAX_SCAN_DATA_GET() IW_SCAN_MAX_DATA
+
+#include "os/rt_os.h"
+
+#endif /* __RT_LINUX_H__ */
diff --git a/cleopatre/devkit/mt7601udrv/include/os/rt_linux_cmm.h b/cleopatre/devkit/mt7601udrv/include/os/rt_linux_cmm.h
new file mode 100644
index 0000000000..6d0d0cc38b
--- /dev/null
+++ b/cleopatre/devkit/mt7601udrv/include/os/rt_linux_cmm.h
@@ -0,0 +1,412 @@
+/****************************************************************************
+ * Ralink Tech Inc.
+ * 4F, No. 2 Technology 5th Rd.
+ * Science-based Industrial Park
+ * Hsin-chu, Taiwan, R.O.C.
+ * (c) Copyright 2002, Ralink Technology, Inc.
+ *
+ * All rights reserved. Ralink's source code is an unpublished work and the
+ * use of a copyright notice does not imply otherwise. This source code
+ * contains confidential trade secret material of Ralink Tech. Any attemp
+ * or participation in deciphering, decoding, reverse engineering or in any
+ * way altering the source code is stricitly prohibited, unless the prior
+ * written consent of Ralink Technology, Inc. is obtained.
+ ****************************************************************************
+
+ Module Name:
+ rt_linux_cmm.h
+
+ Abstract:
+ Common OS structure/definition in LINUX whatever OS ABL.
+
+ Revision History:
+ Who When What
+ --------- ---------- ----------------------------------------------
+ */
+
+
+#ifndef __RT_LINUX_CMM_H__
+#define __RT_LINUX_CMM_H__
+
+
+typedef struct _OS_RSTRUC {
+ UCHAR *pContent; /* pointer to real structure content */
+} OS_RSTRUC;
+
+
+/* declare new chipset function here */
+#ifdef OS_ABL_FUNC_SUPPORT
+
+#define RTMP_DECLARE_DRV_OPS_FUNCTION(_func) \
+ void Rtmp_Drv_Ops_##_func(VOID *__pDrvOps, VOID *__pNetOps, \
+ VOID *__pPciConfig, VOID *__pUsbConfig)
+
+#define RTMP_BUILD_DRV_OPS_FUNCTION(_func) \
+void Rtmp_Drv_Ops_##_func(VOID *__pDrvOps, VOID *__pNetOps, \
+ VOID *__pPciConfig, VOID *__pUsbConfig) \
+{ \
+ RtmpDrvOpsInit(__pDrvOps, __pNetOps, __pPciConfig, __pUsbConfig);\
+}
+
+#define RTMP_GET_DRV_OPS_FUNCTION(_func) \
+ (PVOID)Rtmp_Drv_Ops_##_func
+
+#define RTMP_DRV_OPS_FUNCTION_BODY(_func) \
+ Rtmp_Drv_Ops_##_func
+
+
+#define xdef_to_str(s) def_to_str(s)
+#define def_to_str(s) #s
+
+
+#ifdef RTMP_MAC_USB
+#define RTMP_DRV_NAME "rtusb" xdef_to_str(RT28xx_MODE)
+RTMP_DECLARE_DRV_OPS_FUNCTION(usb);
+#define RTMP_DRV_OPS_FUNCTION RTMP_DRV_OPS_FUNCTION_BODY(usb)
+#define RTMP_BUILD_DRV_OPS_FUNCTION_BODY RTMP_BUILD_DRV_OPS_FUNCTION(usb)
+#endif /* RTMP_MAC_USB */
+
+#else
+
+#ifdef RTMP_MAC_USB
+#define RTMP_DRV_NAME "rt2870"
+#else
+#define RTMP_DRV_NAME "rt2860"
+#endif /* RTMP_MAC_USB */
+
+#endif /* OS_ABL_FUNC_SUPPORT */
+
+
+/*****************************************************************************
+ * OS task related data structure and definitions
+ ******************************************************************************/
+#define RTMP_OS_TASK_INIT(__pTask, __pTaskName, __pAd) \
+ RtmpOSTaskInit(__pTask, __pTaskName, __pAd, &(__pAd)->RscTaskMemList, &(__pAd)->RscSemMemList);
+
+#ifndef OS_ABL_FUNC_SUPPORT
+
+/* rt_linux.h */
+#define RTMP_OS_TASK OS_TASK
+
+#define RTMP_OS_TASK_GET(__pTask) \
+ (__pTask)
+
+#define RTMP_OS_TASK_DATA_GET(__pTask) \
+ ((__pTask)->priv)
+
+#define RTMP_OS_TASK_IS_KILLED(__pTask) \
+ ((__pTask)->task_killed)
+
+#ifdef KTHREAD_SUPPORT
+#define RTMP_OS_TASK_WAKE_UP(__pTask) \
+ WAKE_UP(pTask);
+#else
+#define RTMP_OS_TASK_WAKE_UP(__pTask) \
+ RTMP_SEM_EVENT_UP(&(pTask)->taskSema);
+#endif /* KTHREAD_SUPPORT */
+
+#ifdef KTHREAD_SUPPORT
+#define RTMP_OS_TASK_LEGALITY(__pTask) \
+ if ((__pTask)->kthread_task != NULL)
+#else
+#define RTMP_OS_TASK_LEGALITY(__pTask) \
+ CHECK_PID_LEGALITY((__pTask)->taskPID)
+#endif /* KTHREAD_SUPPORT */
+
+#else
+
+/* rt_linux_cmm.h */
+#define RTMP_OS_TASK OS_RSTRUC
+
+#define RTMP_OS_TASK_GET(__pTask) \
+ ((OS_TASK *)((__pTask)->pContent))
+
+#define RTMP_OS_TASK_DATA_GET(__pTask) \
+ RtmpOsTaskDataGet(__pTask)
+
+#define RTMP_OS_TASK_IS_KILLED(__pTask) \
+ RtmpOsTaskIsKilled(__pTask)
+
+#define RTMP_OS_TASK_WAKE_UP(__pTask) \
+ RtmpOsTaskWakeUp(pTask)
+
+#define RTMP_OS_TASK_LEGALITY(__pTask) \
+ if (RtmpOsCheckTaskLegality(__pTask))
+
+#endif /* OS_ABL_FUNC_SUPPORT */
+
+
+/*****************************************************************************
+ * Timer related definitions and data structures.
+ ******************************************************************************/
+#ifndef OS_ABL_FUNC_SUPPORT
+
+/* rt_linux.h */
+#define NDIS_MINIPORT_TIMER OS_NDIS_MINIPORT_TIMER
+#define RTMP_OS_TIMER OS_TIMER
+
+#define RTMP_OS_FREE_TIMER(__pAd)
+#define RTMP_OS_FREE_LOCK(__pAd)
+#define RTMP_OS_FREE_TASKLET(__pAd)
+#define RTMP_OS_FREE_TASK(__pAd)
+#define RTMP_OS_FREE_SEM(__pAd)
+#define RTMP_OS_FREE_ATOMIC(__pAd)
+
+#else
+
+/* rt_linux_cmm.h */
+#define NDIS_MINIPORT_TIMER OS_RSTRUC
+#define RTMP_OS_TIMER OS_RSTRUC
+
+#define RTMP_OS_FREE_TIMER(__pAd)
+#define RTMP_OS_FREE_LOCK(__pAd)
+#define RTMP_OS_FREE_TASKLET(__pAd)
+#define RTMP_OS_FREE_TASK(__pAd)
+#define RTMP_OS_FREE_SEM(__pAd)
+#define RTMP_OS_FREE_ATOMIC(__pAd)
+
+#endif /* OS_ABL_FUNC_SUPPORT */
+
+
+/*****************************************************************************
+ * OS file operation related data structure definitions
+ ******************************************************************************/
+/* if you add any new type, please also modify RtmpOSFileOpen() */
+#define RTMP_FILE_RDONLY 0x0F01
+#define RTMP_FILE_WRONLY 0x0F02
+#define RTMP_FILE_CREAT 0x0F03
+#define RTMP_FILE_TRUNC 0x0F04
+
+#ifndef OS_ABL_FUNC_SUPPORT
+
+/* rt_linux.h */
+#define RTMP_OS_FS_INFO OS_FS_INFO
+
+#else
+
+/* rt_linux_cmm.h */
+#define RTMP_OS_FS_INFO OS_RSTRUC
+
+#endif /* OS_ABL_FUNC_SUPPORT */
+
+
+/*****************************************************************************
+ * OS semaphore related data structure and definitions
+ ******************************************************************************/
+
+#ifndef OS_ABL_FUNC_SUPPORT
+
+#define NDIS_SPIN_LOCK OS_NDIS_SPIN_LOCK
+#define NdisAllocateSpinLock(__pReserved, __pLock) OS_NdisAllocateSpinLock(__pLock)
+#define NdisFreeSpinLock OS_NdisFreeSpinLock
+#define RTMP_SEM_LOCK OS_SEM_LOCK
+#define RTMP_SEM_UNLOCK OS_SEM_UNLOCK
+#define RTMP_IRQ_LOCK OS_IRQ_LOCK
+#define RTMP_IRQ_UNLOCK OS_IRQ_UNLOCK
+#define RTMP_INT_LOCK OS_INT_LOCK
+#define RTMP_INT_UNLOCK OS_INT_UNLOCK
+#define RTMP_OS_SEM OS_SEM
+#define RTMP_OS_ATOMIC atomic_t
+
+#define NdisAcquireSpinLock RTMP_SEM_LOCK
+#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
+
+#define RTMP_SEM_EVENT_INIT_LOCKED(__pSema, __pSemaList) OS_SEM_EVENT_INIT_LOCKED(__pSema)
+#define RTMP_SEM_EVENT_INIT(__pSema, __pSemaList) OS_SEM_EVENT_INIT(__pSema)
+#define RTMP_SEM_EVENT_DESTORY OS_SEM_EVENT_DESTORY
+#define RTMP_SEM_EVENT_WAIT OS_SEM_EVENT_WAIT
+#define RTMP_SEM_EVENT_UP OS_SEM_EVENT_UP
+
+#define RTUSBMlmeUp OS_RTUSBMlmeUp
+
+#define RTMP_OS_ATMOIC_INIT(__pAtomic, __pAtomicList)
+#define RTMP_OS_ATMOIC_DESTROY(__pAtomic)
+#define RTMP_THREAD_PID_KILL(__PID) KILL_THREAD_PID(__PID, SIGTERM, 1)
+
+#else
+
+#define NDIS_SPIN_LOCK OS_RSTRUC
+#define RTMP_OS_SEM OS_RSTRUC
+#define RTMP_OS_ATOMIC OS_RSTRUC
+
+#define RTMP_SEM_EVENT_INIT_LOCKED RtmpOsSemaInitLocked
+#define RTMP_SEM_EVENT_INIT RtmpOsSemaInit
+#define RTMP_SEM_EVENT_DESTORY RtmpOsSemaDestory
+#define RTMP_SEM_EVENT_WAIT(_pSema, _status) ((_status) = RtmpOsSemaWaitInterruptible((_pSema)))
+#define RTMP_SEM_EVENT_UP RtmpOsSemaWakeUp
+
+#define RTUSBMlmeUp RtmpOsMlmeUp
+
+#define RTMP_OS_ATMOIC_INIT RtmpOsAtomicInit
+#define RTMP_OS_ATMOIC_DESTROY RtmpOsAtomicDestroy
+#define RTMP_THREAD_PID_KILL RtmpThreadPidKill
+
+/* */
+/* spin_lock enhanced for Nested spin lock */
+/* */
+#define NdisAllocateSpinLock(__pAd, __pLock) RtmpOsAllocateLock(__pLock, &(__pAd)->RscLockMemList)
+#define NdisFreeSpinLock RtmpOsFreeSpinLock
+
+#define RTMP_SEM_LOCK(__lock) \
+{ \
+ RtmpOsSpinLockBh(__lock); \
+}
+
+#define RTMP_SEM_UNLOCK(__lock) \
+{ \
+ RtmpOsSpinUnLockBh(__lock); \
+}
+
+/* sample, use semaphore lock to replace IRQ lock, 2007/11/15 */
+#ifdef MULTI_CORE_SUPPORT
+
+#define RTMP_IRQ_LOCK(__lock, __irqflags) \
+{ \
+ __irqflags = 0; \
+ spin_lock_irqsave((spinlock_t *)(__lock), __irqflags); \
+}
+
+#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
+{ \
+ spin_unlock_irqrestore((spinlock_t *)(__lock), __irqflag); \
+}
+#else
+#define RTMP_IRQ_LOCK(__lock, __irqflags) \
+{ \
+ __irqflags = 0; \
+ RtmpOsSpinLockBh(__lock); \
+}
+
+#define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
+{ \
+ RtmpOsSpinUnLockBh(__lock); \
+}
+#endif // MULTI_CORE_SUPPORT //
+#define RTMP_INT_LOCK(__Lock, __Flag) RtmpOsIntLock(__Lock, &__Flag)
+#define RTMP_INT_UNLOCK RtmpOsIntUnLock
+
+#define NdisAcquireSpinLock RTMP_SEM_LOCK
+#define NdisReleaseSpinLock RTMP_SEM_UNLOCK
+
+#endif /* OS_ABL_FUNC_SUPPORT */
+
+
+/*****************************************************************************
+ * OS task related data structure and definitions
+ ******************************************************************************/
+
+#ifndef OS_ABL_FUNC_SUPPORT
+
+/* rt_linux.h */
+#define RTMP_NET_TASK_STRUCT OS_NET_TASK_STRUCT
+#define PRTMP_NET_TASK_STRUCT POS_NET_TASK_STRUCT
+
+#ifdef WORKQUEUE_BH
+#define RTMP_OS_TASKLET_SCHE(__pTasklet) \
+ schedule_work(__pTasklet)
+#define RTMP_OS_TASKLET_INIT(__pAd, __pTasklet, __pFunc, __Data) \
+ INIT_WORK((struct work_struct *)__pTasklet, (work_func_t)__pFunc)
+#define RTMP_OS_TASKLET_KILL(__pTasklet)
+#else
+#define RTMP_OS_TASKLET_SCHE(__pTasklet) \
+ tasklet_hi_schedule(__pTasklet)
+#define RTMP_OS_TASKLET_INIT(__pAd, __pTasklet, __pFunc, __Data) \
+ tasklet_init(__pTasklet, __pFunc, __Data)
+#define RTMP_OS_TASKLET_KILL(__pTasklet) \
+ tasklet_kill(__pTasklet)
+#endif /* WORKQUEUE_BH */
+
+#define RTMP_NET_TASK_DATA_ASSIGN(__Tasklet, __Data) \
+ (__Tasklet)->data = (unsigned long)__Data
+
+#else
+
+/* rt_linux_cmm.h */
+typedef OS_RSTRUC RTMP_NET_TASK_STRUCT;
+typedef OS_RSTRUC *PRTMP_NET_TASK_STRUCT;
+
+#define RTMP_OS_TASKLET_SCHE(__pTasklet) \
+ RtmpOsTaskletSche(__pTasklet)
+
+#define RTMP_OS_TASKLET_INIT(__pAd, __pTasklet, __pFunc, __Data) \
+ RtmpOsTaskletInit(__pTasklet, __pFunc, __Data, &(__pAd)->RscTaskletMemList)
+
+#define RTMP_OS_TASKLET_KILL(__pTasklet) \
+ RtmpOsTaskletKill(__pTasklet)
+
+#define RTMP_NET_TASK_DATA_ASSIGN(__pTasklet, __Data) \
+ RtmpOsTaskletDataAssign(__pTasklet, __Data)
+
+#endif /* OS_ABL_FUNC_SUPPORT */
+
+
+
+
+/*****************************************************************************
+ * OS definition related data structure and definitions
+ ******************************************************************************/
+
+#ifdef OS_ABL_SUPPORT
+
+#define RTMP_USB_CONTROL_MSG_ENODEV -1
+#define RTMP_USB_CONTROL_MSG_FAIL -2
+
+typedef struct __RTMP_PCI_CONFIG {
+
+ UINT32 ConfigVendorID;
+} RTMP_PCI_CONFIG;
+
+typedef struct __RTMP_USB_CONFIG {
+
+ UINT32 Reserved;
+} RTMP_USB_CONFIG;
+
+extern RTMP_PCI_CONFIG *pRtmpPciConfig;
+extern RTMP_USB_CONFIG *pRtmpUsbConfig;
+
+#define RTMP_OS_PCI_VENDOR_ID pRtmpPciConfig->ConfigVendorID
+
+/*
+ Declare dma_addr_t here, can not define it in rt_drv.h
+
+ If you define it in include/os/rt_drv.h, then the size in DRIVER module
+ will be 64-bit, but in UTIL/NET modules, it maybe 32-bit.
+ This will cause size mismatch problem when OS_ABL = yes.
+*/
+/*
+ In big-endian & 32-bit DMA address platform, if you use long long to
+ record DMA address, when you call kernel function to set DMA address,
+ the address will be 0 because you need to do swap I think.
+ So if you sure your DMA address is 32-bit, do not use RTMP_DMA_ADDR_64.
+*/
+#define ra_dma_addr_t unsigned long long
+
+#else
+
+#ifdef RTMP_USB_SUPPORT
+#define RTMP_USB_CONTROL_MSG_ENODEV (-ENODEV)
+#define RTMP_USB_CONTROL_MSG_FAIL (-EFAULT)
+#endif /* RTMP_USB_SUPPORT */
+
+#define RTMP_OS_PCI_VENDOR_ID PCI_VENDOR_ID
+
+#define ra_dma_addr_t dma_addr_t
+
+#endif /* OS_ABL_SUPPORT */
+
+#define PCI_MAP_SINGLE RtmpDrvPciMapSingle
+
+
+/***********************************************************************************
+ * Others
+ ***********************************************************************************/
+#define APCLI_IF_UP_CHECK(pAd, ifidx) (RtmpOSNetDevIsUp((pAd)->ApCfg.ApCliTab[(ifidx)].dev) == TRUE)
+
+
+#define RTMP_OS_NETDEV_SET_PRIV RtmpOsSetNetDevPriv
+#define RTMP_OS_NETDEV_GET_PRIV RtmpOsGetNetDevPriv
+#define RT_DEV_PRIV_FLAGS_GET RtmpDevPrivFlagsGet
+#define RT_DEV_PRIV_FLAGS_SET RtmpDevPrivFlagsSet
+
+#endif /* __RT_LINUX_CMM_H__ */
+
diff --git a/cleopatre/devkit/mt7601udrv/include/os/rt_os.h b/cleopatre/devkit/mt7601udrv/include/os/rt_os.h
new file mode 100644
index 0000000000..3f3b8fc741
--- /dev/null
+++ b/cleopatre/devkit/mt7601udrv/include/os/rt_os.h
@@ -0,0 +1,83 @@
+/*
+ ***************************************************************************
+ * Ralink Tech Inc.
+ * 4F, No. 2 Technology 5th Rd.
+ * Science-based Industrial Park
+ * Hsin-chu, Taiwan, R.O.C.
+ *
+ * (c) Copyright 2002-2004, Ralink Technology, Inc.
+ *
+ * All rights reserved. Ralink's source code is an unpublished work and the
+ * use of a copyright notice does not imply otherwise. This source code
+ * contains confidential trade secret material of Ralink Tech. Any attemp
+ * or participation in deciphering, decoding, reverse engineering or in any
+ * way altering the source code is stricitly prohibited, unless the prior
+ * written consent of Ralink Technology, Inc. is obtained.
+ ***************************************************************************
+
+ Module Name:
+ rt_os.h
+
+ Abstract:
+ Put all OS related definition/structure/MACRO here.
+
+ Note:
+ Used in UTIL/NETIF module.
+
+ Revision History:
+ Who When What
+ -------- ---------- ----------------------------------------------
+ Name Date Modification logs
+*/
+
+#ifndef _RT_OS_H_
+#define _RT_OS_H_
+
+
+#ifdef LINUX
+#if WIRELESS_EXT <= 11
+#ifndef SIOCDEVPRIVATE
+#define SIOCDEVPRIVATE 0x8BE0
+#endif
+#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
+#endif
+#endif /* LINUX */
+
+
+
+#ifdef CONFIG_AP_SUPPORT
+/* Ralink defined OIDs */
+#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x01)
+#define RTPRIV_IOCTL_SET (SIOCIWFIRSTPRIV + 0x02)
+#define RT_PRIV_IOCTL_EXT (SIOCIWFIRSTPRIV + 0x0E) /* Sync. with RT61 (for wpa_supplicant) */
+#ifdef DBG
+#define RTPRIV_IOCTL_BBP (SIOCIWFIRSTPRIV + 0x03)
+#define RTPRIV_IOCTL_MAC (SIOCIWFIRSTPRIV + 0x05)
+
+#define RTPRIV_IOCTL_RF (SIOCIWFIRSTPRIV + 0x13)
+
+#endif /* DBG */
+#define RTPRIV_IOCTL_E2P (SIOCIWFIRSTPRIV + 0x07)
+
+#define RTPRIV_IOCTL_ATE (SIOCIWFIRSTPRIV + 0x08)
+
+#define RTPRIV_IOCTL_STATISTICS (SIOCIWFIRSTPRIV + 0x09)
+#define RTPRIV_IOCTL_ADD_PMKID_CACHE (SIOCIWFIRSTPRIV + 0x0A)
+#define RTPRIV_IOCTL_RADIUS_DATA (SIOCIWFIRSTPRIV + 0x0C)
+#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
+#define RTPRIV_IOCTL_ADD_WPA_KEY (SIOCIWFIRSTPRIV + 0x0E)
+#define RTPRIV_IOCTL_GET_MAC_TABLE (SIOCIWFIRSTPRIV + 0x0F)
+#define RTPRIV_IOCTL_GET_MAC_TABLE_STRUCT (SIOCIWFIRSTPRIV + 0x1F) /* modified by Red@Ralink, 2009/09/30 */
+#define RTPRIV_IOCTL_STATIC_WEP_COPY (SIOCIWFIRSTPRIV + 0x10)
+
+#define RTPRIV_IOCTL_SHOW (SIOCIWFIRSTPRIV + 0x11)
+#define RTPRIV_IOCTL_WSC_PROFILE (SIOCIWFIRSTPRIV + 0x12)
+#define RTPRIV_IOCTL_QUERY_BATABLE (SIOCIWFIRSTPRIV + 0x16)
+#ifdef INF_AR9
+#define RTPRIV_IOCTL_GET_AR9_SHOW (SIOCIWFIRSTPRIV + 0x17)
+#endif/* INF_AR9 */
+#define RTPRIV_IOCTL_SET_WSCOOB (SIOCIWFIRSTPRIV + 0x19)
+#define RTPRIV_IOCTL_WSC_CALLBACK (SIOCIWFIRSTPRIV + 0x1A)
+#endif /* CONFIG_AP_SUPPORT */
+
+#endif /* _RT_OS_H_ */