Staging: rt3070: remove dead *WSC_INCLUDED code
[firewire-audio.git] / drivers / staging / rt3070 / rt_linux.h
blobd1a2da1fe35aa984054c77360340d6ba445eac17
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
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. *
14 * *
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. *
19 * *
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. *
24 * *
25 *************************************************************************
28 /***********************************************************************/
29 /* */
30 /* Program: rt_linux.c */
31 /* Created: 4/21/2006 1:17:38 PM */
32 /* Author: Wu Xi-Kun */
33 /* Comments: `description` */
34 /* */
35 /*---------------------------------------------------------------------*/
36 /* */
37 /* History: */
38 /* Revision 1.1 4/21/2006 1:17:38 PM xsikun */
39 /* Initial revision */
40 /* */
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 <net/iw_handler.h>
70 // load firmware
71 #define __KERNEL_SYSCALLS__
72 #include <linux/unistd.h>
73 #include <asm/uaccess.h>
76 #define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)
78 #ifndef IFNAMSIZ
79 #define IFNAMSIZ 16
80 #endif
82 //#define CONFIG_CKIP_SUPPORT
84 #undef __inline
85 #define __inline static inline
87 typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);
89 // add by kathy
91 #ifdef CONFIG_STA_SUPPORT
93 #ifdef RT2870
94 #define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat"
95 #define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin"
96 #define STA_NIC_DEVICE_NAME "RT2870STA"
97 #define STA_DRIVER_VERSION "2.0.1.0"
98 #ifdef MULTIPLE_CARD_SUPPORT
99 #define CARD_INFO_PATH "/etc/Wireless/RT2870STA/RT2870STACard.dat"
100 #endif // MULTIPLE_CARD_SUPPORT //
101 #endif // RT2870 //
103 #endif // CONFIG_STA_SUPPORT //
106 #define RTMP_TIME_AFTER(a,b) \
107 (typecheck(unsigned long, (unsigned long)a) && \
108 typecheck(unsigned long, (unsigned long)b) && \
109 ((long)(b) - (long)(a) < 0))
111 #define RTMP_TIME_AFTER_EQ(a,b) \
112 (typecheck(unsigned long, (unsigned long)a) && \
113 typecheck(unsigned long, (unsigned long)b) && \
114 ((long)(a) - (long)(b) >= 0))
115 #define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a)
117 #define RT_MOD_INC_USE_COUNT() \
118 if (!try_module_get(THIS_MODULE)) \
120 DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
121 return -1; \
124 #define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);
126 #define OS_HZ HZ
128 #define ETH_LENGTH_OF_ADDRESS 6
130 #define IN
131 #define OUT
133 #define NDIS_STATUS INT
134 #define NDIS_STATUS_SUCCESS 0x00
135 #define NDIS_STATUS_FAILURE 0x01
136 #define NDIS_STATUS_INVALID_DATA 0x02
137 #define NDIS_STATUS_RESOURCES 0x03
139 #define MIN_NET_DEVICE_FOR_AID 0x00 //0x00~0x3f
140 #define MIN_NET_DEVICE_FOR_MBSSID 0x00 //0x00,0x10,0x20,0x30
141 #define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70
142 #define MIN_NET_DEVICE_FOR_APCLI 0x20
143 #define MIN_NET_DEVICE_FOR_MESH 0x30
144 #ifdef CONFIG_STA_SUPPORT
145 #define MIN_NET_DEVICE_FOR_DLS 0x40
146 #endif // CONFIG_STA_SUPPORT //
149 #ifdef CONFIG_STA_SUPPORT
150 #define NDIS_PACKET_TYPE_DIRECTED 0
151 #define NDIS_PACKET_TYPE_MULTICAST 1
152 #define NDIS_PACKET_TYPE_BROADCAST 2
153 #define NDIS_PACKET_TYPE_ALL_MULTICAST 3
154 #endif // CONFIG_STA_SUPPORT //
156 struct os_lock {
157 spinlock_t lock;
158 unsigned long flags;
162 struct os_cookie {
164 #ifdef RT2870
165 struct usb_device *pUsb_Dev;
167 struct pid * MLMEThr_pid;
168 struct pid * RTUSBCmdThr_pid;
169 struct pid * TimerQThr_pid;
170 #endif // RT2870 //
172 struct tasklet_struct rx_done_task;
173 struct tasklet_struct mgmt_dma_done_task;
174 struct tasklet_struct ac0_dma_done_task;
175 struct tasklet_struct ac1_dma_done_task;
176 struct tasklet_struct ac2_dma_done_task;
177 struct tasklet_struct ac3_dma_done_task;
178 struct tasklet_struct hcca_dma_done_task;
179 struct tasklet_struct tbtt_task;
180 #ifdef RT2870
181 struct tasklet_struct null_frame_complete_task;
182 struct tasklet_struct rts_frame_complete_task;
183 struct tasklet_struct pspoll_frame_complete_task;
184 #endif // RT2870 //
187 unsigned long apd_pid; //802.1x daemon pid
188 INT ioctl_if_type;
189 INT ioctl_if;
192 typedef struct _VIRTUAL_ADAPTER
194 struct net_device *RtmpDev;
195 struct net_device *VirtualDev;
196 } VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;
198 #undef ASSERT
199 #define ASSERT(x) \
201 if (!(x)) \
203 printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__); \
207 typedef struct os_cookie * POS_COOKIE;
208 typedef struct pci_dev * PPCI_DEV;
209 typedef struct net_device * PNET_DEV;
210 typedef void * PNDIS_PACKET;
211 typedef char NDIS_PACKET;
212 typedef PNDIS_PACKET * PPNDIS_PACKET;
213 typedef dma_addr_t NDIS_PHYSICAL_ADDRESS;
214 typedef dma_addr_t * PNDIS_PHYSICAL_ADDRESS;
215 //typedef struct timer_list RALINK_TIMER_STRUCT;
216 //typedef struct timer_list * PRALINK_TIMER_STRUCT;
217 //typedef struct os_lock NDIS_SPIN_LOCK;
218 typedef spinlock_t NDIS_SPIN_LOCK;
219 typedef struct timer_list NDIS_MINIPORT_TIMER;
220 typedef void * NDIS_HANDLE;
221 typedef char * PNDIS_BUFFER;
225 void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);
227 dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);
228 void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);
231 ////////////////////////////////////////
232 // MOVE TO rtmp.h ?
233 /////////////////////////////////////////
234 #define PKTSRC_NDIS 0x7f
235 #define PKTSRC_DRIVER 0x0f
236 #define PRINT_MAC(addr) \
237 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
240 #define RT2860_PCI_DEVICE_ID 0x0601
242 #ifdef RT2870
243 #define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0
245 #define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)
246 #endif // RT2870 //
249 #define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \
250 dma_cache_wback(_ptr, _size)
253 //////////////////////////////////////////
255 //////////////////////////////////////////
258 #define NdisMIndicateStatus(_w, _x, _y, _z)
261 typedef struct timer_list RTMP_OS_TIMER;
263 #ifdef RT2870
264 /* ----------------- Timer Related MARCO ---------------*/
265 // In RT2870, we have a lot of timer functions and will read/write register, it's
266 // not allowed in Linux USB sub-system to do it ( because of sleep issue when submit
267 // to ctrl pipe). So we need a wrapper function to take care it.
269 typedef VOID (*RT2870_TIMER_HANDLE)(
270 IN PVOID SystemSpecific1,
271 IN PVOID FunctionContext,
272 IN PVOID SystemSpecific2,
273 IN PVOID SystemSpecific3);
274 #endif // RT2870 //
277 typedef struct _RALINK_TIMER_STRUCT {
278 RTMP_OS_TIMER TimerObj; // Ndis Timer object
279 BOOLEAN Valid; // Set to True when call RTMPInitTimer
280 BOOLEAN State; // True if timer cancelled
281 BOOLEAN PeriodicType; // True if timer is periodic timer
282 BOOLEAN Repeat; // True if periodic timer
283 ULONG TimerValue; // Timer value in milliseconds
284 ULONG cookie; // os specific object
285 #ifdef RT2870
286 RT2870_TIMER_HANDLE handle;
287 void *pAd;
288 #endif // RT2870 //
289 } RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;
292 #ifdef RT2870
294 typedef enum _RT2870_KERNEL_THREAD_STATUS_
296 RT2870_THREAD_UNKNOWN = 0,
297 RT2870_THREAD_INITED = 1,
298 RT2870_THREAD_RUNNING = 2,
299 RT2870_THREAD_STOPED = 4,
300 }RT2870_KERNEL_THREAD_STATUS;
302 #define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)
304 typedef struct _RT2870_TIMER_ENTRY_
306 RALINK_TIMER_STRUCT *pRaTimer;
307 struct _RT2870_TIMER_ENTRY_ *pNext;
308 }RT2870_TIMER_ENTRY;
311 #define TIMER_QUEUE_SIZE_MAX 128
312 typedef struct _RT2870_TIMER_QUEUE_
314 unsigned int status;
315 //wait_queue_head_t timerWaitQ;
316 //atomic_t count;
317 UCHAR *pTimerQPoll;
318 RT2870_TIMER_ENTRY *pQPollFreeList;
319 RT2870_TIMER_ENTRY *pQHead;
320 RT2870_TIMER_ENTRY *pQTail;
321 }RT2870_TIMER_QUEUE;
322 #endif // RT2870 //
325 //#define DBG 1
328 // MACRO for debugging information
331 #ifdef DBG
332 extern ULONG RTDebugLevel;
334 #define DBGPRINT_RAW(Level, Fmt) \
336 if (Level <= RTDebugLevel) \
338 printk Fmt; \
342 #define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt)
345 #define DBGPRINT_ERR(Fmt) \
347 printk("ERROR!!! "); \
348 printk Fmt; \
351 #define DBGPRINT_S(Status, Fmt) \
353 printk Fmt; \
357 #else
358 #define DBGPRINT(Level, Fmt)
359 #define DBGPRINT_RAW(Level, Fmt)
360 #define DBGPRINT_S(Status, Fmt)
361 #define DBGPRINT_ERR(Fmt)
362 #endif
366 // spin_lock enhanced for Nested spin lock
368 #define NdisAllocateSpinLock(__lock) \
370 spin_lock_init((spinlock_t *)(__lock)); \
373 #define NdisFreeSpinLock(lock) \
378 #define RTMP_SEM_LOCK(__lock) \
380 spin_lock_bh((spinlock_t *)(__lock)); \
383 #define RTMP_SEM_UNLOCK(__lock) \
385 spin_unlock_bh((spinlock_t *)(__lock)); \
388 // sample, use semaphore lock to replace IRQ lock, 2007/11/15
389 #define RTMP_IRQ_LOCK(__lock, __irqflags) \
391 __irqflags = 0; \
392 spin_lock_bh((spinlock_t *)(__lock)); \
393 pAd->irq_disabled |= 1; \
396 #define RTMP_IRQ_UNLOCK(__lock, __irqflag) \
398 pAd->irq_disabled &= 0; \
399 spin_unlock_bh((spinlock_t *)(__lock)); \
402 #define RTMP_INT_LOCK(__lock, __irqflags) \
404 spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \
407 #define RTMP_INT_UNLOCK(__lock, __irqflag) \
409 spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \
412 #ifdef RT2870
413 #define RTMP_IO_READ32(_A, _R, _pV) \
414 RTUSBReadMACRegister(_A, _R, _pV)
416 #define RTMP_IO_READ8(_A, _R, _pV) \
420 #define RTMP_IO_WRITE32(_A, _R, _V) \
421 RTUSBWriteMACRegister(_A, _R, _V)
424 #define RTMP_IO_WRITE8(_A, _R, _V) \
426 USHORT _Val = _V; \
427 RTUSBSingleWrite(_A, _R, _Val); \
431 #define RTMP_IO_WRITE16(_A, _R, _V) \
433 RTUSBSingleWrite(_A, _R, _V); \
435 #endif // RT2870 //
437 #ifndef wait_event_interruptible_timeout
438 #define __wait_event_interruptible_timeout(wq, condition, ret) \
439 do { \
440 wait_queue_t __wait; \
441 init_waitqueue_entry(&__wait, current); \
442 add_wait_queue(&wq, &__wait); \
443 for (;;) { \
444 set_current_state(TASK_INTERRUPTIBLE); \
445 if (condition) \
446 break; \
447 if (!signal_pending(current)) { \
448 ret = schedule_timeout(ret); \
449 if (!ret) \
450 break; \
451 continue; \
453 ret = -ERESTARTSYS; \
454 break; \
456 current->state = TASK_RUNNING; \
457 remove_wait_queue(&wq, &__wait); \
458 } while (0)
460 #define wait_event_interruptible_timeout(wq, condition, timeout) \
461 ({ \
462 long __ret = timeout; \
463 if (!(condition)) \
464 __wait_event_interruptible_timeout(wq, condition, __ret); \
465 __ret; \
467 #endif
468 #define ONE_TICK 1
469 #define OS_WAIT(_time) \
470 { int _i; \
471 long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\
472 wait_queue_head_t _wait; \
473 init_waitqueue_head(&_wait); \
474 for (_i=0; _i<(_loop); _i++) \
475 wait_event_interruptible_timeout(_wait, 0, ONE_TICK); }
478 /* Modified by Wu Xi-Kun 4/21/2006 */
479 typedef void (*TIMER_FUNCTION)(unsigned long);
481 #define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN)
483 #define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE)
484 #define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA)
487 #ifdef RT2870
488 #define BUILD_TIMER_FUNCTION(_func) \
489 void linux_##_func(unsigned long data) \
491 PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \
492 RT2870_TIMER_ENTRY *_pQNode; \
493 RTMP_ADAPTER *_pAd; \
495 _pTimer->handle = _func; \
496 _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \
497 _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \
498 if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \
499 RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \
501 #endif // RT2870 //
504 #define DECLARE_TIMER_FUNCTION(_func) \
505 void linux_##_func(unsigned long data)
507 #define GET_TIMER_FUNCTION(_func) \
508 linux_##_func
510 DECLARE_TIMER_FUNCTION(MlmePeriodicExec);
511 DECLARE_TIMER_FUNCTION(MlmeRssiReportExec);
512 DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout);
513 DECLARE_TIMER_FUNCTION(APSDPeriodicExec);
514 DECLARE_TIMER_FUNCTION(AsicRfTuningExec);
515 #ifdef RT2870
516 DECLARE_TIMER_FUNCTION(BeaconUpdateExec);
517 #endif // RT2870 //
520 #ifdef CONFIG_STA_SUPPORT
521 DECLARE_TIMER_FUNCTION(BeaconTimeout);
522 DECLARE_TIMER_FUNCTION(ScanTimeout);
523 DECLARE_TIMER_FUNCTION(AuthTimeout);
524 DECLARE_TIMER_FUNCTION(AssocTimeout);
525 DECLARE_TIMER_FUNCTION(ReassocTimeout);
526 DECLARE_TIMER_FUNCTION(DisassocTimeout);
527 DECLARE_TIMER_FUNCTION(LinkDownExec);
528 #ifdef LEAP_SUPPORT
529 DECLARE_TIMER_FUNCTION(LeapAuthTimeout);
530 #endif
531 DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec);
532 DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc);
533 DECLARE_TIMER_FUNCTION(PsPollWakeExec);
534 DECLARE_TIMER_FUNCTION(RadioOnExec);
536 #ifdef QOS_DLS_SUPPORT
537 DECLARE_TIMER_FUNCTION(DlsTimeoutAction);
538 #endif // QOS_DLS_SUPPORT //
539 #endif // CONFIG_STA_SUPPORT //
541 void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time);
545 * packet helper
546 * - convert internal rt packet to os packet or
547 * os packet to rt packet
549 #define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p))
550 #define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p))
552 #define GET_OS_PKT_DATAPTR(_pkt) \
553 (RTPKT_TO_OSPKT(_pkt)->data)
555 #define GET_OS_PKT_LEN(_pkt) \
556 (RTPKT_TO_OSPKT(_pkt)->len)
558 #define GET_OS_PKT_DATATAIL(_pkt) \
559 (RTPKT_TO_OSPKT(_pkt)->tail)
561 #define GET_OS_PKT_HEAD(_pkt) \
562 (RTPKT_TO_OSPKT(_pkt)->head)
564 #define GET_OS_PKT_END(_pkt) \
565 (RTPKT_TO_OSPKT(_pkt)->end)
567 #define GET_OS_PKT_NETDEV(_pkt) \
568 (RTPKT_TO_OSPKT(_pkt)->dev)
570 #define GET_OS_PKT_TYPE(_pkt) \
571 (RTPKT_TO_OSPKT(_pkt))
573 #define GET_OS_PKT_NEXT(_pkt) \
574 (RTPKT_TO_OSPKT(_pkt)->next)
577 #define OS_NTOHS(_Val) \
578 (ntohs(_Val))
579 #define OS_HTONS(_Val) \
580 (htons(_Val))
581 #define OS_NTOHL(_Val) \
582 (ntohl(_Val))
583 #define OS_HTONL(_Val) \
584 (htonl(_Val))
586 /* statistics counter */
587 #define STATS_INC_RX_PACKETS(_pAd, _dev)
588 #define STATS_INC_TX_PACKETS(_pAd, _dev)
590 #define STATS_INC_RX_BYTESS(_pAd, _dev, len)
591 #define STATS_INC_TX_BYTESS(_pAd, _dev, len)
593 #define STATS_INC_RX_ERRORS(_pAd, _dev)
594 #define STATS_INC_TX_ERRORS(_pAd, _dev)
596 #define STATS_INC_RX_DROPPED(_pAd, _dev)
597 #define STATS_INC_TX_DROPPED(_pAd, _dev)
600 #define CB_OFF 10
603 // check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without
604 // ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver
606 //#define RTMP_GET_PACKET_MR(_p) (RTPKT_TO_OSPKT(_p))
608 // User Priority
609 #define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio)
610 #define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0])
612 // Fragment #
613 #define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num)
614 #define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1])
616 // 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.
617 //(this value also as MAC(on-chip WCID) table index)
618 // 0x80~0xff: TX to a WDS link. b0~6: WDS index
619 #define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx)
620 #define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2]))
622 // 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet
623 #define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc)
624 #define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3])
626 // RTS/CTS-to-self protection method
627 #define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num)
628 #define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4])
629 // see RTMP_S(G)ET_PACKET_EMACTAB
631 // TX rate index
632 #define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate)
633 #define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5])
635 // From which Interface
636 #define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx)
637 #define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6])
638 #define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss))
639 #define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS))
640 #define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI))
641 #define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH))
642 #define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p))
643 #define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p))
645 #define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit)
646 #define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7])
648 //#define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) (RTPKT_TO_OSPKT(_p)->cb[8] = _bss)
649 //#define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) (RTPKT_TO_OSPKT(_p)->cb[8])
652 // Sepcific Pakcet Type definition
654 #define RTMP_PACKET_SPECIFIC_CB_OFFSET 11
656 #define RTMP_PACKET_SPECIFIC_DHCP 0x01
657 #define RTMP_PACKET_SPECIFIC_EAPOL 0x02
658 #define RTMP_PACKET_SPECIFIC_IPV4 0x04
659 #define RTMP_PACKET_SPECIFIC_WAI 0x08
660 #define RTMP_PACKET_SPECIFIC_VLAN 0x10
661 #define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20
663 //Specific
664 #define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg)
666 //DHCP
667 #define RTMP_SET_PACKET_DHCP(_p, _flg) \
668 do{ \
669 if (_flg) \
670 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \
671 else \
672 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \
673 }while(0)
674 #define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP)
676 //EAPOL
677 #define RTMP_SET_PACKET_EAPOL(_p, _flg) \
678 do{ \
679 if (_flg) \
680 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \
681 else \
682 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \
683 }while(0)
684 #define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL)
686 //WAI
687 #define RTMP_SET_PACKET_WAI(_p, _flg) \
688 do{ \
689 if (_flg) \
690 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \
691 else \
692 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \
693 }while(0)
694 #define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI)
696 #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))
698 //VLAN
699 #define RTMP_SET_PACKET_VLAN(_p, _flg) \
700 do{ \
701 if (_flg) \
702 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \
703 else \
704 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \
705 }while(0)
706 #define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN)
708 //LLC/SNAP
709 #define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \
710 do{ \
711 if (_flg) \
712 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \
713 else \
714 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \
715 }while(0)
717 #define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP)
719 // IP
720 #define RTMP_SET_PACKET_IPV4(_p, _flg) \
721 do{ \
722 if (_flg) \
723 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \
724 else \
725 (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \
726 }while(0)
728 #define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4)
730 // If this flag is set, it indicates that this EAPoL frame MUST be clear.
731 #define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg)
732 #define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12])
734 #define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg)
735 #define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22])
738 #ifdef INF_AMAZON_SE
739 /*Iverson patch for WMM A5-T07 ,WirelessStaToWirelessSta do not bulk out aggregate */
740 #define RTMP_SET_PACKET_NOBULKOUT(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23] = _morebit)
741 #define RTMP_GET_PACKET_NOBULKOUT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+23])
742 #endif // INF_AMAZON_SE //
746 #ifdef CONFIG_5VT_ENHANCE
747 #define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c
748 #endif
751 #define NDIS_SET_PACKET_STATUS(_p, _status)
754 #define GET_SG_LIST_FROM_PACKET(_p, _sc) \
755 rt_get_sg_list_from_packet(_p, _sc)
757 #define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
758 #define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length)
759 #define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length)
760 #define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
761 #define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length))
764 #define RTMP_INC_REF(_A) 0
765 #define RTMP_DEC_REF(_A) 0
766 #define RTMP_GET_REF(_A) 0
771 * ULONG
772 * RTMP_GetPhysicalAddressLow(
773 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
775 #define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress)
778 * ULONG
779 * RTMP_GetPhysicalAddressHigh(
780 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
782 #define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0)
785 * VOID
786 * RTMP_SetPhysicalAddressLow(
787 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
788 * IN ULONG Value);
790 #define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \
791 PhysicalAddress = Value;
794 * VOID
795 * RTMP_SetPhysicalAddressHigh(
796 * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
797 * IN ULONG Value);
799 #define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value)
802 //CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
803 #define QUEUE_ENTRY_TO_PACKET(pEntry) \
804 (PNDIS_PACKET)(pEntry)
806 #define PACKET_TO_QUEUE_ENTRY(pPacket) \
807 (PQUEUE_ENTRY)(pPacket)
810 #ifndef CONTAINING_RECORD
811 #define CONTAINING_RECORD(address, type, field) \
812 ((type *)((PCHAR)(address) - offsetof(type, field)))
813 #endif
816 #define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \
818 RTMPFreeNdisPacket(_pAd, _pPacket); \
822 #define SWITCH_PhyAB(_pAA, _pBB) \
824 ULONG AABasePaHigh; \
825 ULONG AABasePaLow; \
826 ULONG BBBasePaHigh; \
827 ULONG BBBasePaLow; \
828 BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB); \
829 BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB); \
830 AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA); \
831 AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA); \
832 RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh); \
833 RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow); \
834 RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh); \
835 RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow); \
839 #define NdisWriteErrorLogEntry(_a, _b, _c, _d)
840 #define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e) NDIS_STATUS_SUCCESS
843 #define NdisAcquireSpinLock RTMP_SEM_LOCK
844 #define NdisReleaseSpinLock RTMP_SEM_UNLOCK
846 static inline void NdisGetSystemUpTime(ULONG *time)
848 *time = jiffies;
851 //pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx);
852 #define QUEUE_ENTRY_TO_PKT(pEntry) \
853 ((PNDIS_PACKET) (pEntry))
855 int rt28xx_packet_xmit(struct sk_buff *skb);
859 void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify);