2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
28 /***********************************************************************/
30 /* Program: rt_linux.c */
31 /* Created: 4/21/2006 1:17:38 PM */
32 /* Author: Wu Xi-Kun */
33 /* Comments: `description` */
35 /*---------------------------------------------------------------------*/
38 /* Revision 1.1 4/21/2006 1:17:38 PM xsikun */
39 /* Initial revision */
41 /***********************************************************************/
43 #include "rtmp_type.h"
44 #include <linux/module.h>
45 #include <linux/version.h>
46 #include <linux/kernel.h>
48 #include <linux/spinlock.h>
49 #include <linux/init.h>
50 #include <linux/string.h>
51 #include <linux/timer.h>
52 #include <linux/errno.h>
53 #include <linux/slab.h>
54 #include <linux/interrupt.h>
55 #include <linux/pci.h>
56 #include <linux/netdevice.h>
57 #include <linux/etherdevice.h>
58 #include <linux/skbuff.h>
59 #include <linux/ethtool.h>
60 #include <linux/wireless.h>
61 #include <linux/proc_fs.h>
62 #include <linux/delay.h>
63 #include <linux/if_arp.h>
64 #include <linux/ctype.h>
65 #include <linux/vmalloc.h>
68 #include <linux/wireless.h>
69 #include <net/iw_handler.h>
72 #define __KERNEL_SYSCALLS__
73 #include <linux/unistd.h>
74 #include <asm/uaccess.h>
77 #define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
83 //#define CONFIG_CKIP_SUPPORT
86 #define __inline static inline
88 typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
92 #ifdef CONFIG_STA_SUPPORT
95 #define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
96 #define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin"
97 #define STA_NIC_DEVICE_NAME "RT2870STA"
98 #define STA_DRIVER_VERSION "2.0.1.0"
99 #ifdef MULTIPLE_CARD_SUPPORT
100 #define CARD_INFO_PATH "/etc/Wireless/RT2870STA/RT2870STACard.dat"
101 #endif // MULTIPLE_CARD_SUPPORT //
104 #endif // CONFIG_STA_SUPPORT //
107 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
109 #define RTMP_TIME_AFTER(a,b) \
110 (typecheck(unsigned long, (unsigned long)a) && \
111 typecheck(unsigned long, (unsigned long)b) && \
112 ((long)(b) - (long)(a) < 0))
114 #define RTMP_TIME_AFTER_EQ(a,b) \
115 (typecheck(unsigned long, (unsigned long)a) && \
116 typecheck(unsigned long, (unsigned long)b) && \
117 ((long)(a) - (long)(b) >= 0))
118 #define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
120 #define RTMP_TIME_AFTER(a,b) time_after(a, b)
123 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
124 #define RT_MOD_INC_USE_COUNT() \
125 if (!try_module_get(THIS_MODULE)) \
127 DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __FUNCTION__)); \
131 #define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
133 #define RT_MOD_INC_USE_COUNT() MOD_INC_USE_COUNT;
134 #define RT_MOD_DEC_USE_COUNT() MOD_DEC_USE_COUNT;
139 #define ETH_LENGTH_OF_ADDRESS 6
144 #define NDIS_STATUS INT
145 #define NDIS_STATUS_SUCCESS 0x00
146 #define NDIS_STATUS_FAILURE 0x01
147 #define NDIS_STATUS_INVALID_DATA 0x02
148 #define NDIS_STATUS_RESOURCES 0x03
150 #define MIN_NET_DEVICE_FOR_AID 0x00 //0x00~0x3f
151 #define MIN_NET_DEVICE_FOR_MBSSID 0x00 //0x00,0x10,0x20,0x30
152 #define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70
153 #define MIN_NET_DEVICE_FOR_APCLI 0x20
154 #define MIN_NET_DEVICE_FOR_MESH 0x30
155 #ifdef CONFIG_STA_SUPPORT
156 #define MIN_NET_DEVICE_FOR_DLS 0x40
157 #endif // CONFIG_STA_SUPPORT //
160 #ifdef CONFIG_STA_SUPPORT
161 #define NDIS_PACKET_TYPE_DIRECTED 0
162 #define NDIS_PACKET_TYPE_MULTICAST 1
163 #define NDIS_PACKET_TYPE_BROADCAST 2
164 #define NDIS_PACKET_TYPE_ALL_MULTICAST 3
165 #endif // CONFIG_STA_SUPPORT //
176 struct usb_device *pUsb_Dev;
178 struct pid * MLMEThr_pid;
179 struct pid * RTUSBCmdThr_pid;
180 struct pid * TimerQThr_pid;
183 struct tasklet_struct rx_done_task;
184 struct tasklet_struct mgmt_dma_done_task;
185 struct tasklet_struct ac0_dma_done_task;
186 struct tasklet_struct ac1_dma_done_task;
187 struct tasklet_struct ac2_dma_done_task;
188 struct tasklet_struct ac3_dma_done_task;
189 struct tasklet_struct hcca_dma_done_task;
190 struct tasklet_struct tbtt_task;
192 struct tasklet_struct null_frame_complete_task;
193 struct tasklet_struct rts_frame_complete_task;
194 struct tasklet_struct pspoll_frame_complete_task;
198 unsigned long apd_pid; //802.1x daemon pid
203 typedef struct _VIRTUAL_ADAPTER
205 struct net_device *RtmpDev;
206 struct net_device *VirtualDev;
207 } VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
214 printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \
218 typedef struct os_cookie * POS_COOKIE;
219 typedef struct pci_dev * PPCI_DEV;
220 typedef struct net_device * PNET_DEV;
221 typedef void * PNDIS_PACKET;
222 typedef char NDIS_PACKET;
223 typedef PNDIS_PACKET * PPNDIS_PACKET;
224 typedef dma_addr_t NDIS_PHYSICAL_ADDRESS;
225 typedef dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
226 //typedef struct timer_list RALINK_TIMER_STRUCT;
227 //typedef struct timer_list * PRALINK_TIMER_STRUCT;
228 //typedef struct os_lock NDIS_SPIN_LOCK;
229 typedef spinlock_t NDIS_SPIN_LOCK;
230 typedef struct timer_list NDIS_MINIPORT_TIMER;
231 typedef void * NDIS_HANDLE;
232 typedef char * PNDIS_BUFFER;
236 void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
238 dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
239 void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);
242 ////////////////////////////////////////
244 /////////////////////////////////////////
245 #define PKTSRC_NDIS 0x7f
246 #define PKTSRC_DRIVER 0x0f
247 #define PRINT_MAC(addr) \
248 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
251 #define RT2860_PCI_DEVICE_ID 0x0601
254 #define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
256 #define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
260 #define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \
261 dma_cache_wback(_ptr, _size)
264 //////////////////////////////////////////
266 //////////////////////////////////////////
269 #define NdisMIndicateStatus(_w, _x, _y, _z)
272 typedef struct timer_list RTMP_OS_TIMER;
275 /* ----------------- Timer Related MARCO ---------------*/
276 // In RT2870, we have a lot of timer functions and will read/write register, it's
277 // not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
278 // to ctrl pipe). So we need a wrapper function to take care it.
280 typedef VOID (*RT2870_TIMER_HANDLE)(
281 IN PVOID SystemSpecific1,
282 IN PVOID FunctionContext,
283 IN PVOID SystemSpecific2,
284 IN PVOID SystemSpecific3);
288 typedef struct _RALINK_TIMER_STRUCT {
289 RTMP_OS_TIMER TimerObj; // Ndis Timer object
290 BOOLEAN Valid; // Set to True when call RTMPInitTimer
291 BOOLEAN State; // True if timer cancelled
292 BOOLEAN PeriodicType; // True if timer is periodic timer
293 BOOLEAN Repeat; // True if periodic timer
294 ULONG TimerValue; // Timer value in milliseconds
295 ULONG cookie; // os specific object
297 RT2870_TIMER_HANDLE handle;
300 } RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
305 typedef enum _RT2870_KERNEL_THREAD_STATUS_
307 RT2870_THREAD_UNKNOWN = 0,
308 RT2870_THREAD_INITED = 1,
309 RT2870_THREAD_RUNNING = 2,
310 RT2870_THREAD_STOPED = 4,
311 }RT2870_KERNEL_THREAD_STATUS;
313 #define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
315 typedef struct _RT2870_TIMER_ENTRY_
317 RALINK_TIMER_STRUCT *pRaTimer;
318 struct _RT2870_TIMER_ENTRY_ *pNext;
322 #define TIMER_QUEUE_SIZE_MAX 128
323 typedef struct _RT2870_TIMER_QUEUE_
326 //wait_queue_head_t timerWaitQ;
329 RT2870_TIMER_ENTRY *pQPollFreeList;
330 RT2870_TIMER_ENTRY *pQHead;
331 RT2870_TIMER_ENTRY *pQTail;
339 // MACRO for debugging information
343 extern ULONG RTDebugLevel;
345 #define DBGPRINT_RAW(Level, Fmt) \
347 if (Level <= RTDebugLevel) \
353 #define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
356 #define DBGPRINT_ERR(Fmt) \
358 printk("ERROR!!! "); \
362 #define DBGPRINT_S(Status, Fmt) \
369 #define DBGPRINT(Level, Fmt)
370 #define DBGPRINT_RAW(Level, Fmt)
371 #define DBGPRINT_S(Status, Fmt)
372 #define DBGPRINT_ERR(Fmt)
377 // spin_lock enhanced for Nested spin lock
379 #define NdisAllocateSpinLock(__lock) \
381 spin_lock_init((spinlock_t *)(__lock)); \
384 #define NdisFreeSpinLock(lock) \
389 #define RTMP_SEM_LOCK(__lock) \
391 spin_lock_bh((spinlock_t *)(__lock)); \
394 #define RTMP_SEM_UNLOCK(__lock) \
396 spin_unlock_bh((spinlock_t *)(__lock)); \
399 // sample, use semaphore lock to replace IRQ lock, 2007/11/15
400 #define RTMP_IRQ_LOCK(__lock, __irqflags) \
403 spin_lock_bh((spinlock_t *)(__lock)); \
404 pAd->irq_disabled |= 1; \
407 #define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
409 pAd->irq_disabled &= 0; \
410 spin_unlock_bh((spinlock_t *)(__lock)); \
413 #define RTMP_INT_LOCK(__lock, __irqflags) \
415 spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
418 #define RTMP_INT_UNLOCK(__lock, __irqflag) \
420 spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
424 #define RTMP_IO_READ32(_A, _R, _pV) \
425 RTUSBReadMACRegister(_A, _R, _pV)
427 #define RTMP_IO_READ8(_A, _R, _pV) \
431 #define RTMP_IO_WRITE32(_A, _R, _V) \
432 RTUSBWriteMACRegister(_A, _R, _V)
435 #define RTMP_IO_WRITE8(_A, _R, _V) \
438 RTUSBSingleWrite(_A, _R, _Val); \
442 #define RTMP_IO_WRITE16(_A, _R, _V) \
444 RTUSBSingleWrite(_A, _R, _V); \
448 #ifndef wait_event_interruptible_timeout
449 #define __wait_event_interruptible_timeout(wq, condition, ret) \
451 wait_queue_t __wait; \
452 init_waitqueue_entry(&__wait, current); \
453 add_wait_queue(&wq, &__wait); \
455 set_current_state(TASK_INTERRUPTIBLE); \
458 if (!signal_pending(current)) { \
459 ret = schedule_timeout(ret); \
464 ret = -ERESTARTSYS; \
467 current->state = TASK_RUNNING; \
468 remove_wait_queue(&wq, &__wait); \
471 #define wait_event_interruptible_timeout(wq, condition, timeout) \
473 long __ret = timeout; \
475 __wait_event_interruptible_timeout(wq, condition, __ret); \
480 #define OS_WAIT(_time) \
482 long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
483 wait_queue_head_t _wait; \
484 init_waitqueue_head(&_wait); \
485 for (_i=0; _i<(_loop); _i++) \
486 wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
489 /* Modified by Wu Xi-Kun 4/21/2006 */
490 typedef void (*TIMER_FUNCTION)(unsigned long);
492 #define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
494 #define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
495 #define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
499 #define BUILD_TIMER_FUNCTION(_func) \
500 void linux_##_func(unsigned long data) \
502 PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
503 RT2870_TIMER_ENTRY *_pQNode; \
504 RTMP_ADAPTER *_pAd; \
506 _pTimer->handle = _func; \
507 _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
508 _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \
509 if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \
510 RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \
515 #define DECLARE_TIMER_FUNCTION(_func) \
516 void linux_##_func(unsigned long data)
518 #define GET_TIMER_FUNCTION(_func) \
521 DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
522 DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
523 DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
524 DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
525 DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
527 DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
531 #ifdef CONFIG_STA_SUPPORT
532 DECLARE_TIMER_FUNCTION(BeaconTimeout);
533 DECLARE_TIMER_FUNCTION(ScanTimeout);
534 DECLARE_TIMER_FUNCTION(AuthTimeout);
535 DECLARE_TIMER_FUNCTION(AssocTimeout);
536 DECLARE_TIMER_FUNCTION(ReassocTimeout);
537 DECLARE_TIMER_FUNCTION(DisassocTimeout);
538 DECLARE_TIMER_FUNCTION(LinkDownExec);
540 DECLARE_TIMER_FUNCTION(LeapAuthTimeout);
542 DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
543 DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
544 DECLARE_TIMER_FUNCTION(PsPollWakeExec);
545 DECLARE_TIMER_FUNCTION(RadioOnExec);
547 #ifdef QOS_DLS_SUPPORT
548 DECLARE_TIMER_FUNCTION(DlsTimeoutAction);
549 #endif // QOS_DLS_SUPPORT //
550 #endif // CONFIG_STA_SUPPORT //
552 #undef AP_WSC_INCLUDED
553 #undef STA_WSC_INCLUDED
557 #ifdef CONFIG_STA_SUPPORT
558 #endif // CONFIG_STA_SUPPORT //
560 #if defined(AP_WSC_INCLUDED) || defined(STA_WSC_INCLUDED)
566 void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
571 * - convert internal rt packet to os packet or
572 * os packet to rt packet
574 #define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
575 #define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p))
577 #define GET_OS_PKT_DATAPTR(_pkt) \
578 (RTPKT_TO_OSPKT(_pkt)->data)
580 #define GET_OS_PKT_LEN(_pkt) \
581 (RTPKT_TO_OSPKT(_pkt)->len)
583 #define GET_OS_PKT_DATATAIL(_pkt) \
584 (RTPKT_TO_OSPKT(_pkt)->tail)
586 #define GET_OS_PKT_HEAD(_pkt) \
587 (RTPKT_TO_OSPKT(_pkt)->head)
589 #define GET_OS_PKT_END(_pkt) \
590 (RTPKT_TO_OSPKT(_pkt)->end)
592 #define GET_OS_PKT_NETDEV(_pkt) \
593 (RTPKT_TO_OSPKT(_pkt)->dev)
595 #define GET_OS_PKT_TYPE(_pkt) \
596 (RTPKT_TO_OSPKT(_pkt))
598 #define GET_OS_PKT_NEXT(_pkt) \
599 (RTPKT_TO_OSPKT(_pkt)->next)
602 #define OS_NTOHS(_Val) \
604 #define OS_HTONS(_Val) \
606 #define OS_NTOHL(_Val) \
608 #define OS_HTONL(_Val) \
611 /* statistics counter */
612 #define STATS_INC_RX_PACKETS(_pAd, _dev)
613 #define STATS_INC_TX_PACKETS(_pAd, _dev)
615 #define STATS_INC_RX_BYTESS(_pAd, _dev, len)
616 #define STATS_INC_TX_BYTESS(_pAd, _dev, len)
618 #define STATS_INC_RX_ERRORS(_pAd, _dev)
619 #define STATS_INC_TX_ERRORS(_pAd, _dev)
621 #define STATS_INC_RX_DROPPED(_pAd, _dev)
622 #define STATS_INC_TX_DROPPED(_pAd, _dev)
628 // check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without
629 // ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver
631 //#define RTMP_GET_PACKET_MR(_p) (RTPKT_TO_OSPKT(_p))
634 #define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
635 #define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
638 #define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
639 #define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
641 // 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.
642 //(this value also as MAC(on-chip WCID) table index)
643 // 0x80~0xff: TX to a WDS link. b0~6: WDS index
644 #define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
645 #define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
647 // 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
648 #define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
649 #define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
651 // RTS/CTS-to-self protection method
652 #define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
653 #define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
654 // see RTMP_S(G)ET_PACKET_EMACTAB
657 #define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
658 #define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
660 // From which Interface
661 #define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
662 #define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
663 #define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
664 #define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
665 #define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
666 #define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
667 #define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
668 #define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
670 #define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
671 #define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
673 //#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) (RTPKT_TO_OSPKT(_p)->cb[8] = _bss)
674 //#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) (RTPKT_TO_OSPKT(_p)->cb[8])
677 // Sepcific Pakcet Type definition
679 #define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
681 #define RTMP_PACKET_SPECIFIC_DHCP 0x01
682 #define RTMP_PACKET_SPECIFIC_EAPOL 0x02
683 #define RTMP_PACKET_SPECIFIC_IPV4 0x04
684 #define RTMP_PACKET_SPECIFIC_WAI 0x08
685 #define RTMP_PACKET_SPECIFIC_VLAN 0x10
686 #define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
689 #define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
692 #define RTMP_SET_PACKET_DHCP(_p, _flg) \
695 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
697 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \
699 #define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
702 #define RTMP_SET_PACKET_EAPOL(_p, _flg) \
705 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
707 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \
709 #define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
712 #define RTMP_SET_PACKET_WAI(_p, _flg) \
715 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
717 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \
719 #define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
721 #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))
724 #define RTMP_SET_PACKET_VLAN(_p, _flg) \
727 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
729 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \
731 #define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
734 #define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
737 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
739 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \
742 #define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
745 #define RTMP_SET_PACKET_IPV4(_p, _flg) \
748 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
750 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \
753 #define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
755 // If this flag is set, it indicates that this EAPoL frame MUST be clear.
756 #define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
757 #define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
759 #define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
760 #define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
764 /*Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate */
765 #define RTMP_SET_PACKET_NOBULKOUT(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23] = _morebit)
766 #define RTMP_GET_PACKET_NOBULKOUT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23])
767 #endif // INF_AMAZON_SE //
771 #ifdef CONFIG_5VT_ENHANCE
772 #define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c
776 #define NDIS_SET_PACKET_STATUS(_p, _status)
779 #define GET_SG_LIST_FROM_PACKET(_p, _sc) \
780 rt_get_sg_list_from_packet(_p, _sc)
782 #define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
783 #define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
784 #define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
785 #define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
786 #define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
789 #define RTMP_INC_REF(_A) 0
790 #define RTMP_DEC_REF(_A) 0
791 #define RTMP_GET_REF(_A) 0
797 * RTMP_GetPhysicalAddressLow(
798 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
800 #define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
804 * RTMP_GetPhysicalAddressHigh(
805 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
807 #define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
811 * RTMP_SetPhysicalAddressLow(
812 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
815 #define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
816 PhysicalAddress = Value;
820 * RTMP_SetPhysicalAddressHigh(
821 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
824 #define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
827 //CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
828 #define QUEUE_ENTRY_TO_PACKET(pEntry) \
829 (PNDIS_PACKET)(pEntry)
831 #define PACKET_TO_QUEUE_ENTRY(pPacket) \
832 (PQUEUE_ENTRY)(pPacket)
835 #ifndef CONTAINING_RECORD
836 #define CONTAINING_RECORD(address, type, field) \
837 ((type *)((PCHAR)(address) - offsetof(type, field)))
841 #define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
843 RTMPFreeNdisPacket(_pAd, _pPacket); \
847 #define SWITCH_PhyAB(_pAA, _pBB) \
849 ULONG AABasePaHigh; \
851 ULONG BBBasePaHigh; \
853 BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB); \
854 BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB); \
855 AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA); \
856 AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA); \
857 RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh); \
858 RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow); \
859 RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh); \
860 RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow); \
864 #define NdisWriteErrorLogEntry(_a, _b, _c, _d)
865 #define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e) NDIS_STATUS_SUCCESS
868 #define NdisAcquireSpinLock RTMP_SEM_LOCK
869 #define NdisReleaseSpinLock RTMP_SEM_UNLOCK
871 static inline void NdisGetSystemUpTime(ULONG *time)
876 //pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
877 #define QUEUE_ENTRY_TO_PKT(pEntry) \
878 ((PNDIS_PACKET) (pEntry))
880 int rt28xx_packet_xmit(struct sk_buff *skb);
884 void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);