Commit | Line | Data |
---|---|---|
91980990 GKH |
1 | /* |
2 | ************************************************************************* | |
3 | * Ralink Tech Inc. | |
4 | * 5F., No.36, Taiyuan St., Jhubei City, | |
5 | * Hsinchu County 302, | |
6 | * Taiwan, R.O.C. | |
7 | * | |
8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. | |
9 | * | |
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 | ************************************************************************* | |
26 | */ | |
27 | ||
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 | /***********************************************************************/ | |
42 | ||
43 | #include "rtmp_type.h" | |
44 | #include <linux/module.h> | |
91980990 GKH |
45 | #include <linux/kernel.h> |
46 | ||
47 | #include <linux/spinlock.h> | |
48 | #include <linux/init.h> | |
49 | #include <linux/string.h> | |
50 | #include <linux/timer.h> | |
51 | #include <linux/errno.h> | |
52 | #include <linux/slab.h> | |
53 | #include <linux/interrupt.h> | |
54 | #include <linux/pci.h> | |
55 | #include <linux/netdevice.h> | |
56 | #include <linux/etherdevice.h> | |
57 | #include <linux/skbuff.h> | |
58 | #include <linux/ethtool.h> | |
59 | #include <linux/wireless.h> | |
60 | #include <linux/proc_fs.h> | |
61 | #include <linux/delay.h> | |
62 | #include <linux/if_arp.h> | |
63 | #include <linux/ctype.h> | |
64 | #include <linux/vmalloc.h> | |
65 | ||
91980990 GKH |
66 | #include <net/iw_handler.h> |
67 | ||
68 | // load firmware | |
69 | #define __KERNEL_SYSCALLS__ | |
70 | #include <linux/unistd.h> | |
71 | #include <asm/uaccess.h> | |
72 | ||
73 | ||
74 | #define MEM_ALLOC_FLAG (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC) | |
75 | ||
76 | #ifndef IFNAMSIZ | |
77 | #define IFNAMSIZ 16 | |
78 | #endif | |
79 | ||
80 | //#define CONFIG_CKIP_SUPPORT | |
81 | ||
82 | #undef __inline | |
83 | #define __inline static inline | |
84 | ||
85 | typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev); | |
86 | ||
87 | // add by kathy | |
88 | ||
b8bc58c5 MS |
89 | /* order of "if defined()" is important, because for 3070 driver |
90 | both RT2870 and RT3070 are defined */ | |
91 | #if defined(RT2860) | |
92 | #define STA_PROFILE_PATH "/etc/Wireless/RT2860STA/RT2860STA.dat" | |
93 | #define STA_RTMP_FIRMWARE_FILE_NAME "/etc/Wireless/RT2860STA/RT2860STA.bin" | |
94 | #define STA_NIC_DEVICE_NAME "RT2860STA" | |
95 | #define STA_DRIVER_VERSION "1.8.1.1" | |
96 | #elif defined(RT3070) | |
97 | #define STA_PROFILE_PATH "/etc/Wireless/RT3070STA/RT3070STA.dat" | |
98 | #define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT3070STA/rt2870.bin" | |
99 | #define STA_NIC_DEVICE_NAME "RT3070STA" | |
100 | #define STA_DRIVER_VERSION "2.0.1.0" | |
101 | #elif defined(RT2870) | |
102 | #define STA_PROFILE_PATH "/etc/Wireless/RT2870STA/RT2870STA.dat" | |
103 | #define STA_RT2870_IMAGE_FILE_NAME "/etc/Wireless/RT2870STA/rt2870.bin" | |
104 | #define STA_NIC_DEVICE_NAME "RT2870STA" | |
105 | #define STA_DRIVER_VERSION "1.4.0.0" | |
3a32ed12 | 106 | #endif |
91980990 | 107 | |
3a32ed12 | 108 | #ifdef RT2860 |
91980990 GKH |
109 | #ifndef PCI_DEVICE |
110 | #define PCI_DEVICE(vend,dev) \ | |
111 | .vendor = (vend), .device = (dev), \ | |
112 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID | |
113 | #endif // PCI_DEVICE // | |
3a32ed12 | 114 | #endif |
91980990 | 115 | |
91980990 GKH |
116 | #define RTMP_TIME_AFTER(a,b) \ |
117 | (typecheck(unsigned long, (unsigned long)a) && \ | |
118 | typecheck(unsigned long, (unsigned long)b) && \ | |
119 | ((long)(b) - (long)(a) < 0)) | |
120 | ||
121 | #define RTMP_TIME_AFTER_EQ(a,b) \ | |
122 | (typecheck(unsigned long, (unsigned long)a) && \ | |
123 | typecheck(unsigned long, (unsigned long)b) && \ | |
124 | ((long)(a) - (long)(b) >= 0)) | |
125 | #define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a) | |
91980990 | 126 | |
91980990 GKH |
127 | #define RT_MOD_INC_USE_COUNT() \ |
128 | if (!try_module_get(THIS_MODULE)) \ | |
129 | { \ | |
d599edca | 130 | DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \ |
91980990 GKH |
131 | return -1; \ |
132 | } | |
133 | ||
134 | #define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE); | |
91980990 GKH |
135 | |
136 | #define OS_HZ HZ | |
137 | ||
138 | #define ETH_LENGTH_OF_ADDRESS 6 | |
139 | ||
140 | #define IN | |
141 | #define OUT | |
142 | ||
143 | #define NDIS_STATUS INT | |
144 | #define NDIS_STATUS_SUCCESS 0x00 | |
145 | #define NDIS_STATUS_FAILURE 0x01 | |
146 | #define NDIS_STATUS_INVALID_DATA 0x02 | |
147 | #define NDIS_STATUS_RESOURCES 0x03 | |
148 | ||
149 | #define MIN_NET_DEVICE_FOR_AID 0x00 //0x00~0x3f | |
150 | #define MIN_NET_DEVICE_FOR_MBSSID 0x00 //0x00,0x10,0x20,0x30 | |
151 | #define MIN_NET_DEVICE_FOR_WDS 0x10 //0x40,0x50,0x60,0x70 | |
152 | #define MIN_NET_DEVICE_FOR_APCLI 0x20 | |
153 | #define MIN_NET_DEVICE_FOR_MESH 0x30 | |
91980990 | 154 | #define MIN_NET_DEVICE_FOR_DLS 0x40 |
91980990 | 155 | |
91980990 GKH |
156 | #define NDIS_PACKET_TYPE_DIRECTED 0 |
157 | #define NDIS_PACKET_TYPE_MULTICAST 1 | |
158 | #define NDIS_PACKET_TYPE_BROADCAST 2 | |
159 | #define NDIS_PACKET_TYPE_ALL_MULTICAST 3 | |
91980990 | 160 | |
3a32ed12 | 161 | #ifndef RT30xx |
91980990 GKH |
162 | typedef struct pid * THREAD_PID; |
163 | #define THREAD_PID_INIT_VALUE NULL | |
164 | #define GET_PID(_v) find_get_pid(_v) | |
165 | #define GET_PID_NUMBER(_v) pid_nr(_v) | |
166 | #define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0) | |
167 | #define KILL_THREAD_PID(_A, _B, _C) kill_pid(_A, _B, _C) | |
3a32ed12 | 168 | #endif |
91980990 GKH |
169 | |
170 | struct os_lock { | |
171 | spinlock_t lock; | |
172 | unsigned long flags; | |
173 | }; | |
174 | ||
175 | ||
176 | struct os_cookie { | |
3a32ed12 | 177 | #ifdef RT2860 |
91980990 GKH |
178 | struct pci_dev *pci_dev; |
179 | struct pci_dev *parent_pci_dev; | |
180 | dma_addr_t pAd_pa; | |
3a32ed12 BZ |
181 | #endif |
182 | #ifdef RT2870 | |
2c63abf9 | 183 | struct usb_device *pUsb_Dev; |
91980990 | 184 | |
3a32ed12 | 185 | #ifndef RT30xx |
2c63abf9 MG |
186 | THREAD_PID MLMEThr_pid; |
187 | THREAD_PID RTUSBCmdThr_pid; | |
188 | THREAD_PID TimerQThr_pid; | |
3a32ed12 BZ |
189 | #endif |
190 | #ifdef RT30xx | |
191 | struct pid *MLMEThr_pid; | |
192 | struct pid *RTUSBCmdThr_pid; | |
193 | struct pid *TimerQThr_pid; | |
194 | #endif | |
195 | #endif // RT2870 // | |
91980990 GKH |
196 | |
197 | struct tasklet_struct rx_done_task; | |
198 | struct tasklet_struct mgmt_dma_done_task; | |
199 | struct tasklet_struct ac0_dma_done_task; | |
200 | struct tasklet_struct ac1_dma_done_task; | |
201 | struct tasklet_struct ac2_dma_done_task; | |
202 | struct tasklet_struct ac3_dma_done_task; | |
203 | struct tasklet_struct hcca_dma_done_task; | |
204 | struct tasklet_struct tbtt_task; | |
3a32ed12 | 205 | #ifdef RT2860 |
91980990 | 206 | struct tasklet_struct fifo_statistic_full_task; |
3a32ed12 BZ |
207 | #endif |
208 | #ifdef RT2870 | |
209 | struct tasklet_struct null_frame_complete_task; | |
210 | struct tasklet_struct rts_frame_complete_task; | |
211 | struct tasklet_struct pspoll_frame_complete_task; | |
212 | #endif // RT2870 // | |
91980990 GKH |
213 | |
214 | unsigned long apd_pid; //802.1x daemon pid | |
215 | INT ioctl_if_type; | |
216 | INT ioctl_if; | |
217 | }; | |
218 | ||
219 | typedef struct _VIRTUAL_ADAPTER | |
220 | { | |
221 | struct net_device *RtmpDev; | |
222 | struct net_device *VirtualDev; | |
223 | } VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER; | |
224 | ||
225 | #undef ASSERT | |
9411329d | 226 | #define ASSERT(x) |
91980990 GKH |
227 | |
228 | typedef struct os_cookie * POS_COOKIE; | |
229 | typedef struct pci_dev * PPCI_DEV; | |
230 | typedef struct net_device * PNET_DEV; | |
231 | typedef void * PNDIS_PACKET; | |
232 | typedef char NDIS_PACKET; | |
233 | typedef PNDIS_PACKET * PPNDIS_PACKET; | |
234 | typedef dma_addr_t NDIS_PHYSICAL_ADDRESS; | |
235 | typedef dma_addr_t * PNDIS_PHYSICAL_ADDRESS; | |
236 | typedef spinlock_t NDIS_SPIN_LOCK; | |
237 | typedef struct timer_list NDIS_MINIPORT_TIMER; | |
238 | typedef void * NDIS_HANDLE; | |
239 | typedef char * PNDIS_BUFFER; | |
240 | ||
241 | ||
242 | ||
243 | void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen); | |
244 | ||
245 | dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction); | |
246 | void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction); | |
247 | ||
248 | ||
249 | //////////////////////////////////////// | |
250 | // MOVE TO rtmp.h ? | |
251 | ///////////////////////////////////////// | |
252 | #define PKTSRC_NDIS 0x7f | |
253 | #define PKTSRC_DRIVER 0x0f | |
254 | #define PRINT_MAC(addr) \ | |
255 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] | |
256 | ||
257 | ||
258 | #define RT2860_PCI_DEVICE_ID 0x0601 | |
259 | ||
3a32ed12 | 260 | #ifdef RT2860 |
91980990 GKH |
261 | #define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \ |
262 | linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir) | |
263 | ||
264 | #define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) \ | |
265 | linux_pci_unmap_single(_handle, _ptr, _size, _dir) | |
266 | ||
267 | #define PCI_ALLOC_CONSISTENT(_pci_dev, _size, _ptr) \ | |
268 | pci_alloc_consistent(_pci_dev, _size, _ptr) | |
269 | ||
270 | #define PCI_FREE_CONSISTENT(_pci_dev, _size, _virtual_addr, _physical_addr) \ | |
271 | pci_free_consistent(_pci_dev, _size, _virtual_addr, _physical_addr) | |
272 | ||
273 | #define DEV_ALLOC_SKB(_length) \ | |
274 | dev_alloc_skb(_length) | |
3a32ed12 BZ |
275 | #endif |
276 | #ifdef RT2870 | |
277 | #define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0 | |
91980990 | 278 | |
3a32ed12 BZ |
279 | #define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) |
280 | #endif // RT2870 // | |
91980990 GKH |
281 | |
282 | ||
283 | #define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size) \ | |
284 | dma_cache_wback(_ptr, _size) | |
285 | ||
286 | ||
287 | ////////////////////////////////////////// | |
288 | // | |
289 | ////////////////////////////////////////// | |
290 | ||
291 | ||
292 | #define NdisMIndicateStatus(_w, _x, _y, _z) | |
293 | ||
91980990 GKH |
294 | typedef struct timer_list RTMP_OS_TIMER; |
295 | ||
3a32ed12 BZ |
296 | #ifdef RT2870 |
297 | /* ----------------- Timer Related MARCO ---------------*/ | |
298 | // In RT2870, we have a lot of timer functions and will read/write register, it's | |
299 | // not allowed in Linux USB sub-system to do it ( because of sleep issue when submit | |
300 | // to ctrl pipe). So we need a wrapper function to take care it. | |
301 | ||
302 | typedef VOID (*RT2870_TIMER_HANDLE)( | |
303 | IN PVOID SystemSpecific1, | |
304 | IN PVOID FunctionContext, | |
305 | IN PVOID SystemSpecific2, | |
306 | IN PVOID SystemSpecific3); | |
307 | #endif // RT2870 // | |
91980990 GKH |
308 | |
309 | ||
310 | typedef struct _RALINK_TIMER_STRUCT { | |
311 | RTMP_OS_TIMER TimerObj; // Ndis Timer object | |
312 | BOOLEAN Valid; // Set to True when call RTMPInitTimer | |
313 | BOOLEAN State; // True if timer cancelled | |
314 | BOOLEAN PeriodicType; // True if timer is periodic timer | |
315 | BOOLEAN Repeat; // True if periodic timer | |
316 | ULONG TimerValue; // Timer value in milliseconds | |
317 | ULONG cookie; // os specific object | |
3a32ed12 BZ |
318 | #ifdef RT2870 |
319 | RT2870_TIMER_HANDLE handle; | |
320 | void *pAd; | |
321 | #endif // RT2870 // | |
91980990 GKH |
322 | } RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT; |
323 | ||
324 | ||
3a32ed12 BZ |
325 | #ifdef RT2870 |
326 | ||
327 | typedef enum _RT2870_KERNEL_THREAD_STATUS_ | |
328 | { | |
329 | RT2870_THREAD_UNKNOWN = 0, | |
330 | RT2870_THREAD_INITED = 1, | |
331 | RT2870_THREAD_RUNNING = 2, | |
332 | RT2870_THREAD_STOPED = 4, | |
333 | }RT2870_KERNEL_THREAD_STATUS; | |
334 | ||
335 | #define RT2870_THREAD_CAN_DO_INSERT (RT2870_THREAD_INITED |RT2870_THREAD_RUNNING) | |
336 | ||
337 | typedef struct _RT2870_TIMER_ENTRY_ | |
338 | { | |
339 | RALINK_TIMER_STRUCT *pRaTimer; | |
340 | struct _RT2870_TIMER_ENTRY_ *pNext; | |
341 | }RT2870_TIMER_ENTRY; | |
342 | ||
343 | ||
344 | #define TIMER_QUEUE_SIZE_MAX 128 | |
345 | typedef struct _RT2870_TIMER_QUEUE_ | |
346 | { | |
347 | unsigned int status; | |
348 | UCHAR *pTimerQPoll; | |
349 | RT2870_TIMER_ENTRY *pQPollFreeList; | |
350 | RT2870_TIMER_ENTRY *pQHead; | |
351 | RT2870_TIMER_ENTRY *pQTail; | |
352 | }RT2870_TIMER_QUEUE; | |
353 | #endif // RT2870 // | |
91980990 GKH |
354 | |
355 | ||
356 | //#define DBG 1 | |
357 | ||
358 | // | |
359 | // MACRO for debugging information | |
360 | // | |
361 | ||
362 | #ifdef DBG | |
363 | extern ULONG RTDebugLevel; | |
364 | ||
365 | #define DBGPRINT_RAW(Level, Fmt) \ | |
366 | { \ | |
367 | if (Level <= RTDebugLevel) \ | |
368 | { \ | |
369 | printk Fmt; \ | |
370 | } \ | |
371 | } | |
372 | ||
373 | #define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt) | |
374 | ||
375 | ||
376 | #define DBGPRINT_ERR(Fmt) \ | |
377 | { \ | |
378 | printk("ERROR!!! "); \ | |
379 | printk Fmt; \ | |
380 | } | |
381 | ||
382 | #define DBGPRINT_S(Status, Fmt) \ | |
383 | { \ | |
384 | printk Fmt; \ | |
385 | } | |
386 | ||
387 | ||
388 | #else | |
389 | #define DBGPRINT(Level, Fmt) | |
390 | #define DBGPRINT_RAW(Level, Fmt) | |
391 | #define DBGPRINT_S(Status, Fmt) | |
392 | #define DBGPRINT_ERR(Fmt) | |
393 | #endif | |
394 | ||
395 | ||
396 | // | |
397 | // spin_lock enhanced for Nested spin lock | |
398 | // | |
399 | #define NdisAllocateSpinLock(__lock) \ | |
400 | { \ | |
401 | spin_lock_init((spinlock_t *)(__lock)); \ | |
402 | } | |
403 | ||
404 | #define NdisFreeSpinLock(lock) \ | |
405 | { \ | |
406 | } | |
407 | ||
408 | ||
409 | #define RTMP_SEM_LOCK(__lock) \ | |
410 | { \ | |
411 | spin_lock_bh((spinlock_t *)(__lock)); \ | |
412 | } | |
413 | ||
414 | #define RTMP_SEM_UNLOCK(__lock) \ | |
415 | { \ | |
416 | spin_unlock_bh((spinlock_t *)(__lock)); \ | |
417 | } | |
418 | ||
419 | // sample, use semaphore lock to replace IRQ lock, 2007/11/15 | |
420 | #define RTMP_IRQ_LOCK(__lock, __irqflags) \ | |
421 | { \ | |
422 | __irqflags = 0; \ | |
423 | spin_lock_bh((spinlock_t *)(__lock)); \ | |
424 | pAd->irq_disabled |= 1; \ | |
425 | } | |
426 | ||
427 | #define RTMP_IRQ_UNLOCK(__lock, __irqflag) \ | |
428 | { \ | |
429 | pAd->irq_disabled &= 0; \ | |
430 | spin_unlock_bh((spinlock_t *)(__lock)); \ | |
431 | } | |
432 | ||
433 | #define RTMP_INT_LOCK(__lock, __irqflags) \ | |
434 | { \ | |
435 | spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \ | |
436 | } | |
437 | ||
438 | #define RTMP_INT_UNLOCK(__lock, __irqflag) \ | |
439 | { \ | |
440 | spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \ | |
441 | } | |
442 | ||
3a32ed12 | 443 | #ifdef RT2860 |
91980990 GKH |
444 | #if defined(INF_TWINPASS) || defined(INF_DANUBE) || defined(IKANOS_VX_1X0) |
445 | //Patch for ASIC turst read/write bug, needs to remove after metel fix | |
446 | #define RTMP_IO_READ32(_A, _R, _pV) \ | |
447 | { \ | |
448 | if ((_A)->bPCIclkOff == FALSE) \ | |
449 | { \ | |
450 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ | |
451 | (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \ | |
452 | (*_pV = SWAP32(*((UINT32 *)(_pV)))); \ | |
453 | } \ | |
454 | } | |
ed291e80 AM |
455 | #define RTMP_IO_FORCE_READ32(_A, _R, _pV) \ |
456 | { \ | |
457 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ | |
458 | (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \ | |
459 | (*_pV = SWAP32(*((UINT32 *)(_pV)))); \ | |
460 | } | |
91980990 GKH |
461 | #define RTMP_IO_READ8(_A, _R, _pV) \ |
462 | { \ | |
463 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ | |
464 | (*_pV = readb((void *)((_A)->CSRBaseAddress + (_R)))); \ | |
465 | } | |
466 | #define RTMP_IO_WRITE32(_A, _R, _V) \ | |
467 | { \ | |
468 | if ((_A)->bPCIclkOff == FALSE) \ | |
469 | { \ | |
470 | UINT32 _Val; \ | |
471 | _Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ | |
472 | _Val = SWAP32(_V); \ | |
473 | writel(_Val, (void *)((_A)->CSRBaseAddress + (_R))); \ | |
474 | } \ | |
475 | } | |
476 | #define RTMP_IO_WRITE8(_A, _R, _V) \ | |
477 | { \ | |
478 | UINT Val; \ | |
479 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ | |
480 | writeb((_V), (PUCHAR)((_A)->CSRBaseAddress + (_R))); \ | |
481 | } | |
482 | #define RTMP_IO_WRITE16(_A, _R, _V) \ | |
483 | { \ | |
484 | UINT Val; \ | |
485 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ | |
486 | writew(SWAP16((_V)), (PUSHORT)((_A)->CSRBaseAddress + (_R))); \ | |
487 | } | |
488 | #else | |
489 | //Patch for ASIC turst read/write bug, needs to remove after metel fix | |
490 | #define RTMP_IO_READ32(_A, _R, _pV) \ | |
491 | { \ | |
492 | if ((_A)->bPCIclkOff == FALSE) \ | |
493 | { \ | |
494 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ | |
495 | (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \ | |
496 | } \ | |
497 | else \ | |
498 | *_pV = 0; \ | |
499 | } | |
ed291e80 AM |
500 | #define RTMP_IO_FORCE_READ32(_A, _R, _pV) \ |
501 | { \ | |
502 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ | |
503 | (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \ | |
504 | } | |
91980990 GKH |
505 | #define RTMP_IO_READ8(_A, _R, _pV) \ |
506 | { \ | |
507 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ | |
508 | (*_pV = readb((void *)((_A)->CSRBaseAddress + (_R)))); \ | |
509 | } | |
510 | #define RTMP_IO_WRITE32(_A, _R, _V) \ | |
511 | { \ | |
512 | if ((_A)->bPCIclkOff == FALSE) \ | |
513 | { \ | |
514 | UINT Val; \ | |
515 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ | |
516 | writel(_V, (void *)((_A)->CSRBaseAddress + (_R))); \ | |
517 | } \ | |
518 | } | |
519 | #if defined(BRCM_6358) | |
520 | #define RTMP_IO_WRITE8(_A, _R, _V) \ | |
521 | { \ | |
522 | ULONG Val; \ | |
523 | UCHAR _i; \ | |
524 | _i = (_R & 0x3); \ | |
525 | Val = readl((void *)((_A)->CSRBaseAddress + (_R - _i))); \ | |
526 | Val = Val & (~(0x000000ff << ((_i)*8))); \ | |
527 | Val = Val | ((ULONG)_V << ((_i)*8)); \ | |
528 | writel((Val), (void *)((_A)->CSRBaseAddress + (_R - _i))); \ | |
529 | } | |
530 | #else | |
531 | #define RTMP_IO_WRITE8(_A, _R, _V) \ | |
532 | { \ | |
533 | UINT Val; \ | |
534 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ | |
535 | writeb((_V), (PUCHAR)((_A)->CSRBaseAddress + (_R))); \ | |
536 | } | |
537 | #endif | |
538 | #define RTMP_IO_WRITE16(_A, _R, _V) \ | |
539 | { \ | |
540 | UINT Val; \ | |
541 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ | |
542 | writew((_V), (PUSHORT)((_A)->CSRBaseAddress + (_R))); \ | |
543 | } | |
544 | #endif | |
3a32ed12 BZ |
545 | #endif /* RT2860 */ |
546 | #ifdef RT2870 | |
547 | //Patch for ASIC turst read/write bug, needs to remove after metel fix | |
548 | #define RTMP_IO_READ32(_A, _R, _pV) \ | |
549 | RTUSBReadMACRegister(_A, _R, _pV) | |
550 | ||
551 | #define RTMP_IO_READ8(_A, _R, _pV) \ | |
552 | { \ | |
553 | } | |
91980990 | 554 | |
3a32ed12 BZ |
555 | #define RTMP_IO_WRITE32(_A, _R, _V) \ |
556 | RTUSBWriteMACRegister(_A, _R, _V) | |
557 | ||
558 | ||
559 | #define RTMP_IO_WRITE8(_A, _R, _V) \ | |
560 | { \ | |
561 | USHORT _Val = _V; \ | |
562 | RTUSBSingleWrite(_A, _R, _Val); \ | |
563 | } | |
564 | ||
565 | ||
566 | #define RTMP_IO_WRITE16(_A, _R, _V) \ | |
567 | { \ | |
568 | RTUSBSingleWrite(_A, _R, _V); \ | |
569 | } | |
570 | #endif // RT2870 // | |
91980990 GKH |
571 | |
572 | #ifndef wait_event_interruptible_timeout | |
573 | #define __wait_event_interruptible_timeout(wq, condition, ret) \ | |
574 | do { \ | |
575 | wait_queue_t __wait; \ | |
576 | init_waitqueue_entry(&__wait, current); \ | |
577 | add_wait_queue(&wq, &__wait); \ | |
578 | for (;;) { \ | |
579 | set_current_state(TASK_INTERRUPTIBLE); \ | |
580 | if (condition) \ | |
581 | break; \ | |
582 | if (!signal_pending(current)) { \ | |
583 | ret = schedule_timeout(ret); \ | |
584 | if (!ret) \ | |
585 | break; \ | |
586 | continue; \ | |
587 | } \ | |
588 | ret = -ERESTARTSYS; \ | |
589 | break; \ | |
590 | } \ | |
591 | current->state = TASK_RUNNING; \ | |
592 | remove_wait_queue(&wq, &__wait); \ | |
593 | } while (0) | |
594 | ||
595 | #define wait_event_interruptible_timeout(wq, condition, timeout) \ | |
596 | ({ \ | |
597 | long __ret = timeout; \ | |
598 | if (!(condition)) \ | |
599 | __wait_event_interruptible_timeout(wq, condition, __ret); \ | |
600 | __ret; \ | |
601 | }) | |
602 | #endif | |
603 | #define ONE_TICK 1 | |
604 | #define OS_WAIT(_time) \ | |
605 | { int _i; \ | |
606 | long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\ | |
607 | wait_queue_head_t _wait; \ | |
608 | init_waitqueue_head(&_wait); \ | |
609 | for (_i=0; _i<(_loop); _i++) \ | |
610 | wait_event_interruptible_timeout(_wait, 0, ONE_TICK); } | |
611 | ||
612 | ||
91980990 GKH |
613 | typedef void (*TIMER_FUNCTION)(unsigned long); |
614 | ||
615 | #define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN) | |
616 | ||
617 | #define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE) | |
618 | #define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA) | |
619 | ||
3a32ed12 | 620 | #ifdef RT2860 |
91980990 GKH |
621 | #define BUILD_TIMER_FUNCTION(_func) \ |
622 | void linux_##_func(unsigned long data) \ | |
623 | { \ | |
624 | PRALINK_TIMER_STRUCT pTimer = (PRALINK_TIMER_STRUCT) data; \ | |
625 | \ | |
626 | _func(NULL, (PVOID) pTimer->cookie, NULL, pTimer); \ | |
627 | if (pTimer->Repeat) \ | |
628 | RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue); \ | |
629 | } | |
3a32ed12 BZ |
630 | #endif |
631 | #ifdef RT2870 | |
632 | #define BUILD_TIMER_FUNCTION(_func) \ | |
633 | void linux_##_func(unsigned long data) \ | |
634 | { \ | |
635 | PRALINK_TIMER_STRUCT _pTimer = (PRALINK_TIMER_STRUCT)data; \ | |
636 | RT2870_TIMER_ENTRY *_pQNode; \ | |
637 | RTMP_ADAPTER *_pAd; \ | |
638 | \ | |
639 | _pTimer->handle = _func; \ | |
640 | _pAd = (RTMP_ADAPTER *)_pTimer->pAd; \ | |
641 | _pQNode = RT2870_TimerQ_Insert(_pAd, _pTimer); \ | |
642 | if ((_pQNode == NULL) && (_pAd->TimerQ.status & RT2870_THREAD_CAN_DO_INSERT)) \ | |
643 | RTMP_OS_Add_Timer(&_pTimer->TimerObj, HZ); \ | |
644 | } | |
645 | #endif // RT2870 // | |
91980990 GKH |
646 | |
647 | ||
648 | #define DECLARE_TIMER_FUNCTION(_func) \ | |
649 | void linux_##_func(unsigned long data) | |
650 | ||
651 | #define GET_TIMER_FUNCTION(_func) \ | |
652 | linux_##_func | |
653 | ||
654 | DECLARE_TIMER_FUNCTION(MlmePeriodicExec); | |
655 | DECLARE_TIMER_FUNCTION(MlmeRssiReportExec); | |
656 | DECLARE_TIMER_FUNCTION(AsicRxAntEvalTimeout); | |
657 | DECLARE_TIMER_FUNCTION(APSDPeriodicExec); | |
658 | DECLARE_TIMER_FUNCTION(AsicRfTuningExec); | |
3a32ed12 BZ |
659 | #ifdef RT2870 |
660 | DECLARE_TIMER_FUNCTION(BeaconUpdateExec); | |
661 | #endif // RT2870 // | |
91980990 | 662 | |
91980990 GKH |
663 | DECLARE_TIMER_FUNCTION(BeaconTimeout); |
664 | DECLARE_TIMER_FUNCTION(ScanTimeout); | |
665 | DECLARE_TIMER_FUNCTION(AuthTimeout); | |
666 | DECLARE_TIMER_FUNCTION(AssocTimeout); | |
667 | DECLARE_TIMER_FUNCTION(ReassocTimeout); | |
668 | DECLARE_TIMER_FUNCTION(DisassocTimeout); | |
669 | DECLARE_TIMER_FUNCTION(LinkDownExec); | |
91980990 GKH |
670 | DECLARE_TIMER_FUNCTION(StaQuickResponeForRateUpExec); |
671 | DECLARE_TIMER_FUNCTION(WpaDisassocApAndBlockAssoc); | |
672 | DECLARE_TIMER_FUNCTION(PsPollWakeExec); | |
673 | DECLARE_TIMER_FUNCTION(RadioOnExec); | |
91980990 GKH |
674 | |
675 | void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time); | |
676 | ||
677 | ||
678 | /* | |
679 | * packet helper | |
680 | * - convert internal rt packet to os packet or | |
681 | * os packet to rt packet | |
682 | */ | |
683 | #define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p)) | |
684 | #define OSPKT_TO_RTPKT(_p) ((PNDIS_PACKET)(_p)) | |
685 | ||
686 | #define GET_OS_PKT_DATAPTR(_pkt) \ | |
687 | (RTPKT_TO_OSPKT(_pkt)->data) | |
688 | ||
689 | #define GET_OS_PKT_LEN(_pkt) \ | |
690 | (RTPKT_TO_OSPKT(_pkt)->len) | |
691 | ||
692 | #define GET_OS_PKT_DATATAIL(_pkt) \ | |
693 | (RTPKT_TO_OSPKT(_pkt)->tail) | |
694 | ||
695 | #define GET_OS_PKT_HEAD(_pkt) \ | |
696 | (RTPKT_TO_OSPKT(_pkt)->head) | |
697 | ||
698 | #define GET_OS_PKT_END(_pkt) \ | |
699 | (RTPKT_TO_OSPKT(_pkt)->end) | |
700 | ||
701 | #define GET_OS_PKT_NETDEV(_pkt) \ | |
702 | (RTPKT_TO_OSPKT(_pkt)->dev) | |
703 | ||
704 | #define GET_OS_PKT_TYPE(_pkt) \ | |
705 | (RTPKT_TO_OSPKT(_pkt)) | |
706 | ||
707 | #define GET_OS_PKT_NEXT(_pkt) \ | |
708 | (RTPKT_TO_OSPKT(_pkt)->next) | |
709 | ||
710 | ||
711 | #define OS_NTOHS(_Val) \ | |
712 | (ntohs(_Val)) | |
713 | #define OS_HTONS(_Val) \ | |
714 | (htons(_Val)) | |
715 | #define OS_NTOHL(_Val) \ | |
716 | (ntohl(_Val)) | |
717 | #define OS_HTONL(_Val) \ | |
718 | (htonl(_Val)) | |
719 | ||
720 | /* statistics counter */ | |
721 | #define STATS_INC_RX_PACKETS(_pAd, _dev) | |
722 | #define STATS_INC_TX_PACKETS(_pAd, _dev) | |
723 | ||
724 | #define STATS_INC_RX_BYTESS(_pAd, _dev, len) | |
725 | #define STATS_INC_TX_BYTESS(_pAd, _dev, len) | |
726 | ||
727 | #define STATS_INC_RX_ERRORS(_pAd, _dev) | |
728 | #define STATS_INC_TX_ERRORS(_pAd, _dev) | |
729 | ||
730 | #define STATS_INC_RX_DROPPED(_pAd, _dev) | |
731 | #define STATS_INC_TX_DROPPED(_pAd, _dev) | |
732 | ||
733 | ||
734 | #define CB_OFF 10 | |
735 | ||
736 | ||
737 | // check DDK NDIS_PACKET data structure and find out only MiniportReservedEx[0..7] can be used by our driver without | |
738 | // ambiguity. Fields after pPacket->MiniportReservedEx[8] may be used by other wrapper layer thus crashes the driver | |
739 | // | |
740 | ||
741 | // User Priority | |
742 | #define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio) | |
743 | #define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0]) | |
744 | ||
745 | // Fragment # | |
746 | #define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num) | |
747 | #define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1]) | |
748 | ||
749 | // 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. | |
750 | //(this value also as MAC(on-chip WCID) table index) | |
751 | // 0x80~0xff: TX to a WDS link. b0~6: WDS index | |
752 | #define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx) | |
753 | #define RTMP_GET_PACKET_WCID(_p) ((UCHAR)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2])) | |
754 | ||
755 | // 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet | |
756 | #define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc) | |
757 | #define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3]) | |
758 | ||
759 | // RTS/CTS-to-self protection method | |
760 | #define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num) | |
761 | #define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4]) | |
762 | // see RTMP_S(G)ET_PACKET_EMACTAB | |
763 | ||
764 | // TX rate index | |
765 | #define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate) | |
766 | #define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5]) | |
767 | ||
768 | // From which Interface | |
769 | #define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx) | |
770 | #define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6]) | |
771 | #define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss)) | |
772 | #define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS)) | |
773 | #define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI)) | |
774 | #define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH)) | |
775 | #define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p)) | |
776 | #define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p)) | |
777 | ||
778 | #define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit) | |
779 | #define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7]) | |
780 | ||
781 | ||
91980990 GKH |
782 | // |
783 | // Sepcific Pakcet Type definition | |
784 | // | |
785 | #define RTMP_PACKET_SPECIFIC_CB_OFFSET 11 | |
786 | ||
787 | #define RTMP_PACKET_SPECIFIC_DHCP 0x01 | |
788 | #define RTMP_PACKET_SPECIFIC_EAPOL 0x02 | |
789 | #define RTMP_PACKET_SPECIFIC_IPV4 0x04 | |
790 | #define RTMP_PACKET_SPECIFIC_WAI 0x08 | |
791 | #define RTMP_PACKET_SPECIFIC_VLAN 0x10 | |
792 | #define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20 | |
793 | ||
794 | //Specific | |
795 | #define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg) | |
796 | ||
797 | //DHCP | |
798 | #define RTMP_SET_PACKET_DHCP(_p, _flg) \ | |
799 | do{ \ | |
800 | if (_flg) \ | |
801 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \ | |
802 | else \ | |
803 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \ | |
804 | }while(0) | |
805 | #define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP) | |
806 | ||
807 | //EAPOL | |
808 | #define RTMP_SET_PACKET_EAPOL(_p, _flg) \ | |
809 | do{ \ | |
810 | if (_flg) \ | |
811 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \ | |
812 | else \ | |
813 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \ | |
814 | }while(0) | |
815 | #define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL) | |
816 | ||
817 | //WAI | |
818 | #define RTMP_SET_PACKET_WAI(_p, _flg) \ | |
819 | do{ \ | |
820 | if (_flg) \ | |
821 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \ | |
822 | else \ | |
823 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \ | |
824 | }while(0) | |
825 | #define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI) | |
826 | ||
827 | #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)) | |
828 | ||
829 | //VLAN | |
830 | #define RTMP_SET_PACKET_VLAN(_p, _flg) \ | |
831 | do{ \ | |
832 | if (_flg) \ | |
833 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \ | |
834 | else \ | |
835 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \ | |
836 | }while(0) | |
837 | #define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN) | |
838 | ||
839 | //LLC/SNAP | |
840 | #define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \ | |
841 | do{ \ | |
842 | if (_flg) \ | |
843 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \ | |
844 | else \ | |
845 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \ | |
846 | }while(0) | |
847 | ||
848 | #define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP) | |
849 | ||
850 | // IP | |
851 | #define RTMP_SET_PACKET_IPV4(_p, _flg) \ | |
852 | do{ \ | |
853 | if (_flg) \ | |
854 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \ | |
855 | else \ | |
856 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \ | |
857 | }while(0) | |
858 | ||
859 | #define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4) | |
860 | ||
91980990 GKH |
861 | |
862 | // If this flag is set, it indicates that this EAPoL frame MUST be clear. | |
863 | #define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg) | |
864 | #define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12]) | |
865 | ||
866 | #define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg) | |
867 | #define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22]) | |
868 | ||
869 | #ifdef CONFIG_5VT_ENHANCE | |
870 | #define BRIDGE_TAG 0x35564252 // depends on 5VT define in br_input.c | |
871 | #endif | |
872 | ||
873 | ||
874 | #define NDIS_SET_PACKET_STATUS(_p, _status) | |
875 | ||
876 | ||
877 | #define GET_SG_LIST_FROM_PACKET(_p, _sc) \ | |
878 | rt_get_sg_list_from_packet(_p, _sc) | |
879 | ||
880 | #define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length) | |
881 | #define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length) | |
882 | #define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length) | |
883 | #define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length)) | |
884 | #define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length)) | |
885 | ||
886 | ||
887 | #define RTMP_INC_REF(_A) 0 | |
888 | #define RTMP_DEC_REF(_A) 0 | |
889 | #define RTMP_GET_REF(_A) 0 | |
890 | ||
891 | ||
892 | ||
893 | /* | |
894 | * ULONG | |
895 | * RTMP_GetPhysicalAddressLow( | |
896 | * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); | |
897 | */ | |
898 | #define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress) | |
899 | ||
900 | /* | |
901 | * ULONG | |
902 | * RTMP_GetPhysicalAddressHigh( | |
903 | * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); | |
904 | */ | |
905 | #define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0) | |
906 | ||
907 | /* | |
908 | * VOID | |
909 | * RTMP_SetPhysicalAddressLow( | |
910 | * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, | |
911 | * IN ULONG Value); | |
912 | */ | |
913 | #define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \ | |
914 | PhysicalAddress = Value; | |
915 | ||
916 | /* | |
917 | * VOID | |
918 | * RTMP_SetPhysicalAddressHigh( | |
919 | * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, | |
920 | * IN ULONG Value); | |
921 | */ | |
922 | #define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value) | |
923 | ||
924 | ||
925 | //CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx); | |
926 | #define QUEUE_ENTRY_TO_PACKET(pEntry) \ | |
927 | (PNDIS_PACKET)(pEntry) | |
928 | ||
929 | #define PACKET_TO_QUEUE_ENTRY(pPacket) \ | |
930 | (PQUEUE_ENTRY)(pPacket) | |
931 | ||
932 | ||
933 | #ifndef CONTAINING_RECORD | |
934 | #define CONTAINING_RECORD(address, type, field) \ | |
935 | ((type *)((PCHAR)(address) - offsetof(type, field))) | |
936 | #endif | |
937 | ||
938 | ||
939 | #define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \ | |
940 | { \ | |
941 | RTMPFreeNdisPacket(_pAd, _pPacket); \ | |
942 | } | |
943 | ||
944 | ||
945 | #define SWITCH_PhyAB(_pAA, _pBB) \ | |
946 | { \ | |
947 | ULONG AABasePaHigh; \ | |
948 | ULONG AABasePaLow; \ | |
949 | ULONG BBBasePaHigh; \ | |
950 | ULONG BBBasePaLow; \ | |
951 | BBBasePaHigh = RTMP_GetPhysicalAddressHigh(_pBB); \ | |
952 | BBBasePaLow = RTMP_GetPhysicalAddressLow(_pBB); \ | |
953 | AABasePaHigh = RTMP_GetPhysicalAddressHigh(_pAA); \ | |
954 | AABasePaLow = RTMP_GetPhysicalAddressLow(_pAA); \ | |
955 | RTMP_SetPhysicalAddressHigh(_pAA, BBBasePaHigh); \ | |
956 | RTMP_SetPhysicalAddressLow(_pAA, BBBasePaLow); \ | |
957 | RTMP_SetPhysicalAddressHigh(_pBB, AABasePaHigh); \ | |
958 | RTMP_SetPhysicalAddressLow(_pBB, AABasePaLow); \ | |
959 | } | |
960 | ||
961 | ||
962 | #define NdisWriteErrorLogEntry(_a, _b, _c, _d) | |
963 | #define NdisMAllocateMapRegisters(_a, _b, _c, _d, _e) NDIS_STATUS_SUCCESS | |
964 | ||
965 | ||
966 | #define NdisAcquireSpinLock RTMP_SEM_LOCK | |
967 | #define NdisReleaseSpinLock RTMP_SEM_UNLOCK | |
968 | ||
969 | static inline void NdisGetSystemUpTime(ULONG *time) | |
970 | { | |
971 | *time = jiffies; | |
972 | } | |
973 | ||
974 | //pPacket = CONTAINING_RECORD(pEntry, NDIS_PACKET, MiniportReservedEx); | |
975 | #define QUEUE_ENTRY_TO_PKT(pEntry) \ | |
976 | ((PNDIS_PACKET) (pEntry)) | |
977 | ||
978 | int rt28xx_packet_xmit(struct sk_buff *skb); | |
979 | ||
980 | ||
981 | ||
982 | void rtmp_os_thread_init(PUCHAR pThreadName, PVOID pNotify); | |
983 | ||
3a32ed12 | 984 | #ifdef RT2860 |
91980990 GKH |
985 | #if !defined(PCI_CAP_ID_EXP) |
986 | #define PCI_CAP_ID_EXP 0x10 | |
987 | #endif | |
988 | ||
989 | #if !defined(PCI_EXP_LNKCTL) | |
990 | #define PCI_EXP_LNKCTL 0x10 | |
991 | #endif | |
992 | ||
993 | #if !defined(PCI_CLASS_BRIDGE_PCI) | |
994 | #define PCI_CLASS_BRIDGE_PCI 0x0604 | |
995 | #endif | |
996 | ||
997 | #define PCIBUS_INTEL_VENDOR 0x8086 | |
3a32ed12 | 998 | #endif |
91980990 | 999 |