Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 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 | ************************************************************************* |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 26 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 27 | Module Name: |
| 28 | rt_linux.h |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 29 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 30 | Abstract: |
| 31 | |
| 32 | Revision History: |
| 33 | Who When What |
| 34 | --------- ---------- ---------------------------------------------- |
| 35 | */ |
| 36 | |
| 37 | #ifndef __RT_LINUX_H__ |
| 38 | #define __RT_LINUX_H__ |
| 39 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 40 | #include <linux/module.h> |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 41 | #include <linux/kernel.h> |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 42 | #include <linux/spinlock.h> |
| 43 | #include <linux/init.h> |
| 44 | #include <linux/string.h> |
| 45 | #include <linux/timer.h> |
| 46 | #include <linux/errno.h> |
| 47 | #include <linux/slab.h> |
| 48 | #include <linux/interrupt.h> |
| 49 | #include <linux/pci.h> |
| 50 | #include <linux/netdevice.h> |
| 51 | #include <linux/etherdevice.h> |
| 52 | #include <linux/skbuff.h> |
| 53 | #include <linux/ethtool.h> |
| 54 | #include <linux/wireless.h> |
| 55 | #include <linux/proc_fs.h> |
| 56 | #include <linux/delay.h> |
| 57 | #include <linux/if_arp.h> |
| 58 | #include <linux/ctype.h> |
| 59 | #include <linux/vmalloc.h> |
| 60 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 61 | #include <net/iw_handler.h> |
| 62 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 63 | /* load firmware */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 64 | #define __KERNEL_SYSCALLS__ |
| 65 | #include <linux/unistd.h> |
| 66 | #include <asm/uaccess.h> |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 67 | #include <asm/types.h> |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 68 | #include <asm/unaligned.h> /* for get_unaligned() */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 69 | |
| 70 | #define KTHREAD_SUPPORT 1 |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 71 | /* RT2870 2.1.0.0 has it disabled */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 72 | |
| 73 | #ifdef KTHREAD_SUPPORT |
| 74 | #include <linux/err.h> |
| 75 | #include <linux/kthread.h> |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 76 | #endif /* KTHREAD_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 77 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 78 | /*********************************************************************************** |
| 79 | * Profile related sections |
| 80 | ***********************************************************************************/ |
| 81 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 82 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 83 | #define STA_DRIVER_VERSION "2.1.0.0" |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 84 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 85 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 86 | #define STA_DRIVER_VERSION "2.1.0.0" |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 87 | /* RT3070 version: 2.1.1.0 */ |
| 88 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 89 | |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 90 | extern const struct iw_handler_def rt28xx_iw_handler_def; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 91 | |
| 92 | /*********************************************************************************** |
| 93 | * Compiler related definitions |
| 94 | ***********************************************************************************/ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 95 | #undef __inline |
| 96 | #define __inline static inline |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 97 | #define IN |
| 98 | #define OUT |
| 99 | #define INOUT |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 100 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 101 | /*********************************************************************************** |
| 102 | * OS Specific definitions and data structures |
| 103 | ***********************************************************************************/ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 104 | typedef int (*HARD_START_XMIT_FUNC) (struct sk_buff * skb, |
| 105 | struct net_device * net_dev); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 106 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 107 | #ifdef RTMP_MAC_PCI |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 108 | #ifndef PCI_DEVICE |
| 109 | #define PCI_DEVICE(vend,dev) \ |
| 110 | .vendor = (vend), .device = (dev), \ |
| 111 | .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 112 | #endif /* PCI_DEVICE // */ |
| 113 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 114 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 115 | #define RT_MOD_INC_USE_COUNT() \ |
| 116 | if (!try_module_get(THIS_MODULE)) \ |
| 117 | { \ |
Harvey Harrison | d599edc | 2009-01-07 14:31:57 -0800 | [diff] [blame] | 118 | DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 119 | return -1; \ |
| 120 | } |
| 121 | |
| 122 | #define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 123 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 124 | #define RTMP_INC_REF(_A) 0 |
| 125 | #define RTMP_DEC_REF(_A) 0 |
| 126 | #define RTMP_GET_REF(_A) 0 |
| 127 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 128 | /* This function will be called when query /proc */ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 129 | struct iw_statistics *rt28xx_get_wireless_stats(IN struct net_device *net_dev); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 130 | |
| 131 | /*********************************************************************************** |
| 132 | * Network related constant definitions |
| 133 | ***********************************************************************************/ |
| 134 | #ifndef IFNAMSIZ |
| 135 | #define IFNAMSIZ 16 |
| 136 | #endif |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 137 | |
| 138 | #define ETH_LENGTH_OF_ADDRESS 6 |
| 139 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 140 | #define NDIS_STATUS_SUCCESS 0x00 |
| 141 | #define NDIS_STATUS_FAILURE 0x01 |
| 142 | #define NDIS_STATUS_INVALID_DATA 0x02 |
| 143 | #define NDIS_STATUS_RESOURCES 0x03 |
| 144 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 145 | #define NDIS_SET_PACKET_STATUS(_p, _status) do{} while(0) |
| 146 | #define NdisWriteErrorLogEntry(_a, _b, _c, _d) do{} while(0) |
| 147 | |
| 148 | /* statistics counter */ |
| 149 | #define STATS_INC_RX_PACKETS(_pAd, _dev) |
| 150 | #define STATS_INC_TX_PACKETS(_pAd, _dev) |
| 151 | |
| 152 | #define STATS_INC_RX_BYTESS(_pAd, _dev, len) |
| 153 | #define STATS_INC_TX_BYTESS(_pAd, _dev, len) |
| 154 | |
| 155 | #define STATS_INC_RX_ERRORS(_pAd, _dev) |
| 156 | #define STATS_INC_TX_ERRORS(_pAd, _dev) |
| 157 | |
| 158 | #define STATS_INC_RX_DROPPED(_pAd, _dev) |
| 159 | #define STATS_INC_TX_DROPPED(_pAd, _dev) |
| 160 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 161 | /*********************************************************************************** |
| 162 | * Ralink Specific network related constant definitions |
| 163 | ***********************************************************************************/ |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 164 | #define MIN_NET_DEVICE_FOR_AID 0x00 /*0x00~0x3f */ |
| 165 | #define MIN_NET_DEVICE_FOR_MBSSID 0x00 /*0x00,0x10,0x20,0x30 */ |
| 166 | #define MIN_NET_DEVICE_FOR_WDS 0x10 /*0x40,0x50,0x60,0x70 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 167 | #define MIN_NET_DEVICE_FOR_APCLI 0x20 |
| 168 | #define MIN_NET_DEVICE_FOR_MESH 0x30 |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 169 | #define MIN_NET_DEVICE_FOR_DLS 0x40 |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 170 | #define NET_DEVICE_REAL_IDX_MASK 0x0f /* for each operation mode, we maximum support 15 entities. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 171 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 172 | #define NDIS_PACKET_TYPE_DIRECTED 0 |
| 173 | #define NDIS_PACKET_TYPE_MULTICAST 1 |
| 174 | #define NDIS_PACKET_TYPE_BROADCAST 2 |
| 175 | #define NDIS_PACKET_TYPE_ALL_MULTICAST 3 |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 176 | #define NDIS_PACKET_TYPE_PROMISCUOUS 4 |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 177 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 178 | /*********************************************************************************** |
| 179 | * OS signaling related constant definitions |
| 180 | ***********************************************************************************/ |
| 181 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 182 | /*********************************************************************************** |
| 183 | * OS file operation related data structure definitions |
| 184 | ***********************************************************************************/ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 185 | struct rt_rtmp_os_fs_info { |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 186 | int fsuid; |
| 187 | int fsgid; |
| 188 | mm_segment_t fs; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 189 | }; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 190 | |
| 191 | #define IS_FILE_OPEN_ERR(_fd) IS_ERR((_fd)) |
| 192 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 193 | /*********************************************************************************** |
| 194 | * OS semaphore related data structure and definitions |
| 195 | ***********************************************************************************/ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 196 | struct os_lock { |
| 197 | spinlock_t lock; |
| 198 | unsigned long flags; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 199 | }; |
| 200 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 201 | /* */ |
| 202 | /* spin_lock enhanced for Nested spin lock */ |
| 203 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 204 | #define NdisAllocateSpinLock(__lock) \ |
| 205 | { \ |
| 206 | spin_lock_init((spinlock_t *)(__lock)); \ |
| 207 | } |
| 208 | |
| 209 | #define NdisFreeSpinLock(lock) \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 210 | do{}while(0) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 211 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 212 | #define RTMP_SEM_LOCK(__lock) \ |
| 213 | { \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 214 | spin_lock_bh((spinlock_t *)(__lock)); \ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | #define RTMP_SEM_UNLOCK(__lock) \ |
| 218 | { \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 219 | spin_unlock_bh((spinlock_t *)(__lock)); \ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 222 | /* sample, use semaphore lock to replace IRQ lock, 2007/11/15 */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 223 | #define RTMP_IRQ_LOCK(__lock, __irqflags) \ |
| 224 | { \ |
| 225 | __irqflags = 0; \ |
| 226 | spin_lock_bh((spinlock_t *)(__lock)); \ |
| 227 | pAd->irq_disabled |= 1; \ |
| 228 | } |
| 229 | |
| 230 | #define RTMP_IRQ_UNLOCK(__lock, __irqflag) \ |
| 231 | { \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 232 | pAd->irq_disabled &= 0; \ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 233 | spin_unlock_bh((spinlock_t *)(__lock)); \ |
| 234 | } |
| 235 | |
| 236 | #define RTMP_INT_LOCK(__lock, __irqflags) \ |
| 237 | { \ |
| 238 | spin_lock_irqsave((spinlock_t *)__lock, __irqflags); \ |
| 239 | } |
| 240 | |
| 241 | #define RTMP_INT_UNLOCK(__lock, __irqflag) \ |
| 242 | { \ |
| 243 | spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag)); \ |
| 244 | } |
| 245 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 246 | #define NdisAcquireSpinLock RTMP_SEM_LOCK |
| 247 | #define NdisReleaseSpinLock RTMP_SEM_UNLOCK |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 248 | |
| 249 | #ifndef wait_event_interruptible_timeout |
| 250 | #define __wait_event_interruptible_timeout(wq, condition, ret) \ |
| 251 | do { \ |
| 252 | wait_queue_t __wait; \ |
| 253 | init_waitqueue_entry(&__wait, current); \ |
| 254 | add_wait_queue(&wq, &__wait); \ |
| 255 | for (;;) { \ |
| 256 | set_current_state(TASK_INTERRUPTIBLE); \ |
| 257 | if (condition) \ |
| 258 | break; \ |
| 259 | if (!signal_pending(current)) { \ |
| 260 | ret = schedule_timeout(ret); \ |
| 261 | if (!ret) \ |
| 262 | break; \ |
| 263 | continue; \ |
| 264 | } \ |
| 265 | ret = -ERESTARTSYS; \ |
| 266 | break; \ |
| 267 | } \ |
| 268 | current->state = TASK_RUNNING; \ |
| 269 | remove_wait_queue(&wq, &__wait); \ |
| 270 | } while (0) |
| 271 | |
| 272 | #define wait_event_interruptible_timeout(wq, condition, timeout) \ |
| 273 | ({ \ |
| 274 | long __ret = timeout; \ |
| 275 | if (!(condition)) \ |
| 276 | __wait_event_interruptible_timeout(wq, condition, __ret); \ |
| 277 | __ret; \ |
| 278 | }) |
| 279 | #endif |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 280 | |
| 281 | #define RTMP_SEM_EVENT_INIT_LOCKED(_pSema) sema_init((_pSema), 0) |
| 282 | #define RTMP_SEM_EVENT_INIT(_pSema) sema_init((_pSema), 1) |
| 283 | #define RTMP_SEM_EVENT_WAIT(_pSema, _status) ((_status) = down_interruptible((_pSema))) |
| 284 | #define RTMP_SEM_EVENT_UP(_pSema) up(_pSema) |
| 285 | |
| 286 | #ifdef KTHREAD_SUPPORT |
| 287 | #define RTMP_WAIT_EVENT_INTERRUPTIBLE(_pAd, _pTask) \ |
| 288 | { \ |
| 289 | wait_event_interruptible(_pTask->kthread_q, \ |
| 290 | _pTask->kthread_running || kthread_should_stop()); \ |
| 291 | _pTask->kthread_running = FALSE; \ |
| 292 | if (kthread_should_stop()) \ |
| 293 | { \ |
| 294 | RTMP_SET_FLAG(_pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); \ |
| 295 | break; \ |
| 296 | } \ |
| 297 | } |
| 298 | #endif |
| 299 | |
| 300 | #ifdef KTHREAD_SUPPORT |
| 301 | #define WAKE_UP(_pTask) \ |
| 302 | do{ \ |
| 303 | if ((_pTask)->kthread_task) \ |
| 304 | { \ |
| 305 | (_pTask)->kthread_running = TRUE; \ |
| 306 | wake_up(&(_pTask)->kthread_q); \ |
| 307 | } \ |
| 308 | }while(0) |
| 309 | #endif |
| 310 | |
| 311 | /*********************************************************************************** |
| 312 | * OS Memory Access related data structure and definitions |
| 313 | ***********************************************************************************/ |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 314 | #define MEM_ALLOC_FLAG (GFP_ATOMIC) /*(GFP_DMA | GFP_ATOMIC) */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 315 | |
| 316 | #define NdisMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length) |
| 317 | #define NdisCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length) |
| 318 | #define NdisZeroMemory(Destination, Length) memset(Destination, 0, Length) |
| 319 | #define NdisFillMemory(Destination, Length, Fill) memset(Destination, Fill, Length) |
| 320 | #define NdisCmpMemory(Destination, Source, Length) memcmp(Destination, Source, Length) |
| 321 | #define NdisEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length)) |
| 322 | #define RTMPEqualMemory(Source1, Source2, Length) (!memcmp(Source1, Source2, Length)) |
| 323 | |
| 324 | #define MlmeAllocateMemory(_pAd, _ppVA) os_alloc_mem(_pAd, _ppVA, MGMT_DMA_BUFFER_SIZE) |
| 325 | #define MlmeFreeMemory(_pAd, _pVA) os_free_mem(_pAd, _pVA) |
| 326 | |
| 327 | #define COPY_MAC_ADDR(Addr1, Addr2) memcpy((Addr1), (Addr2), MAC_ADDR_LEN) |
| 328 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 329 | /*********************************************************************************** |
| 330 | * OS task related data structure and definitions |
| 331 | ***********************************************************************************/ |
| 332 | #define RTMP_OS_MGMT_TASK_FLAGS CLONE_VM |
| 333 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 334 | #define THREAD_PID_INIT_VALUE NULL |
| 335 | #define GET_PID(_v) find_get_pid((_v)) |
| 336 | #define GET_PID_NUMBER(_v) pid_nr((_v)) |
| 337 | #define CHECK_PID_LEGALITY(_pid) if (pid_nr((_pid)) > 0) |
| 338 | #define KILL_THREAD_PID(_A, _B, _C) kill_pid((_A), (_B), (_C)) |
| 339 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 340 | /*********************************************************************************** |
| 341 | * Timer related definitions and data structures. |
| 342 | **********************************************************************************/ |
| 343 | #define OS_HZ HZ |
| 344 | |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 345 | typedef void (*TIMER_FUNCTION) (unsigned long); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 346 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 347 | #define OS_WAIT(_time) \ |
| 348 | { int _i; \ |
| 349 | long _loop = ((_time)/(1000/OS_HZ)) > 0 ? ((_time)/(1000/OS_HZ)) : 1;\ |
| 350 | wait_queue_head_t _wait; \ |
| 351 | init_waitqueue_head(&_wait); \ |
| 352 | for (_i=0; _i<(_loop); _i++) \ |
| 353 | wait_event_interruptible_timeout(_wait, 0, ONE_TICK); } |
| 354 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 355 | #define RTMP_TIME_AFTER(a,b) \ |
| 356 | (typecheck(unsigned long, (unsigned long)a) && \ |
| 357 | typecheck(unsigned long, (unsigned long)b) && \ |
| 358 | ((long)(b) - (long)(a) < 0)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 359 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 360 | #define RTMP_TIME_AFTER_EQ(a,b) \ |
| 361 | (typecheck(unsigned long, (unsigned long)a) && \ |
| 362 | typecheck(unsigned long, (unsigned long)b) && \ |
| 363 | ((long)(a) - (long)(b) >= 0)) |
| 364 | #define RTMP_TIME_BEFORE(a,b) RTMP_TIME_AFTER_EQ(b,a) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 365 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 366 | #define ONE_TICK 1 |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 367 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 368 | static inline void NdisGetSystemUpTime(unsigned long * time) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 369 | { |
| 370 | *time = jiffies; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 371 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 372 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 373 | /*********************************************************************************** |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 374 | * OS specific cookie data structure binding to struct rt_rtmp_adapter |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 375 | ***********************************************************************************/ |
| 376 | |
| 377 | struct os_cookie { |
| 378 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 379 | struct pci_dev *pci_dev; |
| 380 | struct pci_dev *parent_pci_dev; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 381 | u16 DeviceID; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 382 | dma_addr_t pAd_pa; |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 383 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 384 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 385 | struct usb_device *pUsb_Dev; |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 386 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 387 | |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 388 | struct tasklet_struct rx_done_task; |
| 389 | struct tasklet_struct mgmt_dma_done_task; |
| 390 | struct tasklet_struct ac0_dma_done_task; |
| 391 | struct tasklet_struct ac1_dma_done_task; |
| 392 | struct tasklet_struct ac2_dma_done_task; |
| 393 | struct tasklet_struct ac3_dma_done_task; |
| 394 | struct tasklet_struct tbtt_task; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 395 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 396 | struct tasklet_struct fifo_statistic_full_task; |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 397 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 398 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 399 | struct tasklet_struct null_frame_complete_task; |
| 400 | struct tasklet_struct rts_frame_complete_task; |
| 401 | struct tasklet_struct pspoll_frame_complete_task; |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 402 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 403 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 404 | unsigned long apd_pid; /*802.1x daemon pid */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 405 | int ioctl_if_type; |
| 406 | int ioctl_if; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 407 | }; |
| 408 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 409 | /*********************************************************************************** |
| 410 | * OS debugging and printing related definitions and data structure |
| 411 | ***********************************************************************************/ |
| 412 | #define PRINT_MAC(addr) \ |
| 413 | addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] |
| 414 | |
| 415 | #ifdef DBG |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 416 | extern unsigned long RTDebugLevel; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 417 | |
| 418 | #define DBGPRINT_RAW(Level, Fmt) \ |
| 419 | do{ \ |
| 420 | if (Level <= RTDebugLevel) \ |
| 421 | { \ |
| 422 | printk Fmt; \ |
| 423 | } \ |
| 424 | }while(0) |
| 425 | |
| 426 | #define DBGPRINT(Level, Fmt) DBGPRINT_RAW(Level, Fmt) |
| 427 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 428 | #define DBGPRINT_ERR(Fmt) \ |
| 429 | { \ |
| 430 | printk("ERROR!!! "); \ |
| 431 | printk Fmt; \ |
| 432 | } |
| 433 | |
| 434 | #define DBGPRINT_S(Status, Fmt) \ |
| 435 | { \ |
| 436 | printk Fmt; \ |
| 437 | } |
| 438 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 439 | #else |
| 440 | #define DBGPRINT(Level, Fmt) |
| 441 | #define DBGPRINT_RAW(Level, Fmt) |
| 442 | #define DBGPRINT_S(Status, Fmt) |
| 443 | #define DBGPRINT_ERR(Fmt) |
Bartlomiej Zolnierkiewicz | 3a32ed1 | 2009-04-26 16:06:25 +0200 | [diff] [blame] | 444 | #endif |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 445 | |
| 446 | #define ASSERT(x) |
| 447 | |
| 448 | void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen); |
| 449 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 450 | /********************************************************************************************************* |
| 451 | The following code are not revised, temporary put it here. |
| 452 | *********************************************************************************************************/ |
| 453 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 454 | /*********************************************************************************** |
| 455 | * Device DMA Access related definitions and data structures. |
| 456 | **********************************************************************************/ |
| 457 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 458 | dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, |
| 459 | int sd_idx, int direction); |
| 460 | void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, |
| 461 | int direction); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 462 | |
| 463 | #define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \ |
| 464 | linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir) |
| 465 | |
| 466 | #define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) \ |
| 467 | linux_pci_unmap_single(_handle, _ptr, _size, _dir) |
| 468 | |
| 469 | #define PCI_ALLOC_CONSISTENT(_pci_dev, _size, _ptr) \ |
| 470 | pci_alloc_consistent(_pci_dev, _size, _ptr) |
| 471 | |
| 472 | #define PCI_FREE_CONSISTENT(_pci_dev, _size, _virtual_addr, _physical_addr) \ |
| 473 | pci_free_consistent(_pci_dev, _size, _virtual_addr, _physical_addr) |
| 474 | |
| 475 | #define DEV_ALLOC_SKB(_length) \ |
| 476 | dev_alloc_skb(_length) |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 477 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 478 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 479 | #define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (unsigned long)0 |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 480 | |
| 481 | #define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 482 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 483 | |
| 484 | /* |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 485 | * unsigned long |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 486 | * RTMP_GetPhysicalAddressLow( |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 487 | * dma_addr_t PhysicalAddress); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 488 | */ |
| 489 | #define RTMP_GetPhysicalAddressLow(PhysicalAddress) (PhysicalAddress) |
| 490 | |
| 491 | /* |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 492 | * unsigned long |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 493 | * RTMP_GetPhysicalAddressHigh( |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 494 | * dma_addr_t PhysicalAddress); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 495 | */ |
| 496 | #define RTMP_GetPhysicalAddressHigh(PhysicalAddress) (0) |
| 497 | |
| 498 | /* |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 499 | * void |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 500 | * RTMP_SetPhysicalAddressLow( |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 501 | * dma_addr_t PhysicalAddress, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 502 | * unsigned long Value); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 503 | */ |
| 504 | #define RTMP_SetPhysicalAddressLow(PhysicalAddress, Value) \ |
| 505 | PhysicalAddress = Value; |
| 506 | |
| 507 | /* |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 508 | * void |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 509 | * RTMP_SetPhysicalAddressHigh( |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 510 | * dma_addr_t PhysicalAddress, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 511 | * unsigned long Value); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 512 | */ |
| 513 | #define RTMP_SetPhysicalAddressHigh(PhysicalAddress, Value) |
| 514 | |
| 515 | #define NdisMIndicateStatus(_w, _x, _y, _z) |
| 516 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 517 | /*********************************************************************************** |
| 518 | * Device Register I/O Access related definitions and data structures. |
| 519 | **********************************************************************************/ |
| 520 | #ifdef RTMP_MAC_PCI |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 521 | /*Patch for ASIC turst read/write bug, needs to remove after metel fix */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 522 | #define RTMP_IO_READ32(_A, _R, _pV) \ |
| 523 | { \ |
| 524 | if ((_A)->bPCIclkOff == FALSE) \ |
| 525 | { \ |
| 526 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ |
| 527 | (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \ |
| 528 | } \ |
| 529 | else \ |
| 530 | *_pV = 0; \ |
Bartlomiej Zolnierkiewicz | 3a32ed1 | 2009-04-26 16:06:25 +0200 | [diff] [blame] | 531 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 532 | |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 533 | #define RTMP_IO_FORCE_READ32(_A, _R, _pV) \ |
| 534 | { \ |
| 535 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ |
| 536 | (*_pV = readl((void *)((_A)->CSRBaseAddress + (_R)))); \ |
| 537 | } |
| 538 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 539 | #define RTMP_IO_READ8(_A, _R, _pV) \ |
| 540 | { \ |
| 541 | (*_pV = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0))); \ |
| 542 | (*_pV = readb((void *)((_A)->CSRBaseAddress + (_R)))); \ |
| 543 | } |
| 544 | #define RTMP_IO_WRITE32(_A, _R, _V) \ |
| 545 | { \ |
| 546 | if ((_A)->bPCIclkOff == FALSE) \ |
| 547 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 548 | u32 Val; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 549 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ |
| 550 | writel((_V), (void *)((_A)->CSRBaseAddress + (_R))); \ |
| 551 | } \ |
| 552 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 553 | |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 554 | #define RTMP_IO_FORCE_WRITE32(_A, _R, _V) \ |
| 555 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 556 | u32 Val; \ |
Bartlomiej Zolnierkiewicz | e44fd1c | 2009-09-22 20:44:24 +0200 | [diff] [blame] | 557 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ |
| 558 | writel(_V, (void *)((_A)->CSRBaseAddress + (_R))); \ |
| 559 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 560 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 561 | #if defined(RALINK_2880) || defined(RALINK_3052) |
| 562 | #define RTMP_IO_WRITE8(_A, _R, _V) \ |
| 563 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 564 | unsigned long Val; \ |
| 565 | u8 _i; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 566 | _i = ((_R) & 0x3); \ |
| 567 | Val = readl((void *)((_A)->CSRBaseAddress + ((_R) - _i))); \ |
| 568 | Val = Val & (~(0x000000ff << ((_i)*8))); \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 569 | Val = Val | ((unsigned long)(_V) << ((_i)*8)); \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 570 | writel((Val), (void *)((_A)->CSRBaseAddress + ((_R) - _i))); \ |
| 571 | } |
| 572 | #else |
| 573 | #define RTMP_IO_WRITE8(_A, _R, _V) \ |
| 574 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 575 | u32 Val; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 576 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 577 | writeb((_V), (u8 *)((_A)->CSRBaseAddress + (_R))); \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 578 | } |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 579 | #endif /* #if defined(BRCM_6358) || defined(RALINK_2880) // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 580 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 581 | #define RTMP_IO_WRITE16(_A, _R, _V) \ |
| 582 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 583 | u32 Val; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 584 | Val = readl((void *)((_A)->CSRBaseAddress + MAC_CSR0)); \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 585 | writew((_V), (u16 *)((_A)->CSRBaseAddress + (_R))); \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 586 | } |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 587 | #endif /* RTMP_MAC_PCI // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 588 | #ifdef RTMP_MAC_USB |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 589 | /*Patch for ASIC turst read/write bug, needs to remove after metel fix */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 590 | #define RTMP_IO_READ32(_A, _R, _pV) \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 591 | RTUSBReadMACRegister((_A), (_R), (u32 *)(_pV)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 592 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 593 | #define RTMP_IO_READ8(_A, _R, _pV) \ |
| 594 | { \ |
| 595 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 596 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 597 | #define RTMP_IO_WRITE32(_A, _R, _V) \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 598 | RTUSBWriteMACRegister((_A), (_R), (u32)(_V)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 599 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 600 | #define RTMP_IO_WRITE8(_A, _R, _V) \ |
| 601 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 602 | u16 _Val = _V; \ |
| 603 | RTUSBSingleWrite((_A), (_R), (u16)(_Val)); \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | #define RTMP_IO_WRITE16(_A, _R, _V) \ |
| 607 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 608 | RTUSBSingleWrite((_A), (_R), (u16)(_V)); \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 609 | } |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 610 | #endif /* RTMP_MAC_USB // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 611 | |
| 612 | /*********************************************************************************** |
| 613 | * Network Related data structure and marco definitions |
| 614 | ***********************************************************************************/ |
| 615 | #define PKTSRC_NDIS 0x7f |
| 616 | #define PKTSRC_DRIVER 0x0f |
| 617 | |
| 618 | #define RTMP_OS_NETDEV_SET_PRIV(_pNetDev, _pPriv) ((_pNetDev)->ml_priv = (_pPriv)) |
| 619 | #define RTMP_OS_NETDEV_GET_PRIV(_pNetDev) ((_pNetDev)->ml_priv) |
| 620 | #define RTMP_OS_NETDEV_GET_DEVNAME(_pNetDev) ((_pNetDev)->name) |
| 621 | #define RTMP_OS_NETDEV_GET_PHYADDR(_PNETDEV) ((_PNETDEV)->dev_addr) |
| 622 | |
| 623 | #define RTMP_OS_NETDEV_START_QUEUE(_pNetDev) netif_start_queue((_pNetDev)) |
| 624 | #define RTMP_OS_NETDEV_STOP_QUEUE(_pNetDev) netif_stop_queue((_pNetDev)) |
| 625 | #define RTMP_OS_NETDEV_WAKE_QUEUE(_pNetDev) netif_wake_queue((_pNetDev)) |
| 626 | #define RTMP_OS_NETDEV_CARRIER_OFF(_pNetDev) netif_carrier_off((_pNetDev)) |
| 627 | |
| 628 | #define QUEUE_ENTRY_TO_PACKET(pEntry) \ |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 629 | (void *)(pEntry) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 630 | |
| 631 | #define PACKET_TO_QUEUE_ENTRY(pPacket) \ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 632 | (struct rt_queue_entry *)(pPacket) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 633 | |
| 634 | #define GET_SG_LIST_FROM_PACKET(_p, _sc) \ |
| 635 | rt_get_sg_list_from_packet(_p, _sc) |
| 636 | |
| 637 | #define RELEASE_NDIS_PACKET(_pAd, _pPacket, _Status) \ |
| 638 | { \ |
| 639 | RTMPFreeNdisPacket(_pAd, _pPacket); \ |
| 640 | } |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 641 | |
| 642 | /* |
| 643 | * packet helper |
| 644 | * - convert internal rt packet to os packet or |
| 645 | * os packet to rt packet |
| 646 | */ |
| 647 | #define RTPKT_TO_OSPKT(_p) ((struct sk_buff *)(_p)) |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 648 | #define OSPKT_TO_RTPKT(_p) ((void *)(_p)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 649 | |
| 650 | #define GET_OS_PKT_DATAPTR(_pkt) \ |
| 651 | (RTPKT_TO_OSPKT(_pkt)->data) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 652 | #define SET_OS_PKT_DATAPTR(_pkt, _dataPtr) \ |
| 653 | (RTPKT_TO_OSPKT(_pkt)->data) = (_dataPtr) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 654 | |
| 655 | #define GET_OS_PKT_LEN(_pkt) \ |
| 656 | (RTPKT_TO_OSPKT(_pkt)->len) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 657 | #define SET_OS_PKT_LEN(_pkt, _len) \ |
| 658 | (RTPKT_TO_OSPKT(_pkt)->len) = (_len) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 659 | |
| 660 | #define GET_OS_PKT_DATATAIL(_pkt) \ |
| 661 | (RTPKT_TO_OSPKT(_pkt)->tail) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 662 | #define SET_OS_PKT_DATATAIL(_pkt, _start, _len) \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 663 | ((RTPKT_TO_OSPKT(_pkt))->tail) = (u8 *)((_start) + (_len)) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 664 | |
| 665 | #define GET_OS_PKT_HEAD(_pkt) \ |
| 666 | (RTPKT_TO_OSPKT(_pkt)->head) |
| 667 | |
| 668 | #define GET_OS_PKT_END(_pkt) \ |
| 669 | (RTPKT_TO_OSPKT(_pkt)->end) |
| 670 | |
| 671 | #define GET_OS_PKT_NETDEV(_pkt) \ |
| 672 | (RTPKT_TO_OSPKT(_pkt)->dev) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 673 | #define SET_OS_PKT_NETDEV(_pkt, _pNetDev) \ |
| 674 | (RTPKT_TO_OSPKT(_pkt)->dev) = (_pNetDev) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 675 | |
| 676 | #define GET_OS_PKT_TYPE(_pkt) \ |
| 677 | (RTPKT_TO_OSPKT(_pkt)) |
| 678 | |
| 679 | #define GET_OS_PKT_NEXT(_pkt) \ |
| 680 | (RTPKT_TO_OSPKT(_pkt)->next) |
| 681 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 682 | #define OS_PKT_CLONED(_pkt) skb_cloned(RTPKT_TO_OSPKT(_pkt)) |
| 683 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 684 | #define OS_NTOHS(_Val) \ |
| 685 | (ntohs(_Val)) |
| 686 | #define OS_HTONS(_Val) \ |
| 687 | (htons(_Val)) |
| 688 | #define OS_NTOHL(_Val) \ |
| 689 | (ntohl(_Val)) |
| 690 | #define OS_HTONL(_Val) \ |
| 691 | (htonl(_Val)) |
| 692 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 693 | #define CB_OFF 10 |
| 694 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 695 | /* User Priority */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 696 | #define RTMP_SET_PACKET_UP(_p, _prio) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0] = _prio) |
| 697 | #define RTMP_GET_PACKET_UP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+0]) |
| 698 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 699 | /* Fragment # */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 700 | #define RTMP_SET_PACKET_FRAGMENTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1] = _num) |
| 701 | #define RTMP_GET_PACKET_FRAGMENTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+1]) |
| 702 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 703 | /* 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. */ |
| 704 | /*(this value also as MAC(on-chip WCID) table index) */ |
| 705 | /* 0x80~0xff: TX to a WDS link. b0~6: WDS index */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 706 | #define RTMP_SET_PACKET_WCID(_p, _wdsidx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2] = _wdsidx) |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 707 | #define RTMP_GET_PACKET_WCID(_p) ((u8)(RTPKT_TO_OSPKT(_p)->cb[CB_OFF+2])) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 708 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 709 | /* 0xff: PKTSRC_NDIS, others: local TX buffer index. This value affects how to a packet */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 710 | #define RTMP_SET_PACKET_SOURCE(_p, _pktsrc) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3] = _pktsrc) |
| 711 | #define RTMP_GET_PACKET_SOURCE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+3]) |
| 712 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 713 | /* RTS/CTS-to-self protection method */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 714 | #define RTMP_SET_PACKET_RTS(_p, _num) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4] = _num) |
| 715 | #define RTMP_GET_PACKET_RTS(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+4]) |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 716 | /* see RTMP_S(G)ET_PACKET_EMACTAB */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 717 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 718 | /* TX rate index */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 719 | #define RTMP_SET_PACKET_TXRATE(_p, _rate) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5] = _rate) |
| 720 | #define RTMP_GET_PACKET_TXRATE(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+5]) |
| 721 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 722 | /* From which Interface */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 723 | #define RTMP_SET_PACKET_IF(_p, _ifdx) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6] = _ifdx) |
| 724 | #define RTMP_GET_PACKET_IF(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+6]) |
| 725 | #define RTMP_SET_PACKET_NET_DEVICE_MBSSID(_p, _bss) RTMP_SET_PACKET_IF((_p), (_bss)) |
| 726 | #define RTMP_SET_PACKET_NET_DEVICE_WDS(_p, _bss) RTMP_SET_PACKET_IF((_p), ((_bss) + MIN_NET_DEVICE_FOR_WDS)) |
| 727 | #define RTMP_SET_PACKET_NET_DEVICE_APCLI(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_APCLI)) |
| 728 | #define RTMP_SET_PACKET_NET_DEVICE_MESH(_p, _idx) RTMP_SET_PACKET_IF((_p), ((_idx) + MIN_NET_DEVICE_FOR_MESH)) |
| 729 | #define RTMP_GET_PACKET_NET_DEVICE_MBSSID(_p) RTMP_GET_PACKET_IF((_p)) |
| 730 | #define RTMP_GET_PACKET_NET_DEVICE(_p) RTMP_GET_PACKET_IF((_p)) |
| 731 | |
| 732 | #define RTMP_SET_PACKET_MOREDATA(_p, _morebit) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7] = _morebit) |
| 733 | #define RTMP_GET_PACKET_MOREDATA(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+7]) |
| 734 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 735 | /* */ |
| 736 | /* Sepcific Pakcet Type definition */ |
| 737 | /* */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 738 | #define RTMP_PACKET_SPECIFIC_CB_OFFSET 11 |
| 739 | |
| 740 | #define RTMP_PACKET_SPECIFIC_DHCP 0x01 |
| 741 | #define RTMP_PACKET_SPECIFIC_EAPOL 0x02 |
| 742 | #define RTMP_PACKET_SPECIFIC_IPV4 0x04 |
| 743 | #define RTMP_PACKET_SPECIFIC_WAI 0x08 |
| 744 | #define RTMP_PACKET_SPECIFIC_VLAN 0x10 |
| 745 | #define RTMP_PACKET_SPECIFIC_LLCSNAP 0x20 |
| 746 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 747 | /*Specific */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 748 | #define RTMP_SET_PACKET_SPECIFIC(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] = _flg) |
| 749 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 750 | /*DHCP */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 751 | #define RTMP_SET_PACKET_DHCP(_p, _flg) \ |
| 752 | do{ \ |
| 753 | if (_flg) \ |
| 754 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_DHCP); \ |
| 755 | else \ |
| 756 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_DHCP); \ |
| 757 | }while(0) |
| 758 | #define RTMP_GET_PACKET_DHCP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_DHCP) |
| 759 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 760 | /*EAPOL */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 761 | #define RTMP_SET_PACKET_EAPOL(_p, _flg) \ |
| 762 | do{ \ |
| 763 | if (_flg) \ |
| 764 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_EAPOL); \ |
| 765 | else \ |
| 766 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_EAPOL); \ |
| 767 | }while(0) |
| 768 | #define RTMP_GET_PACKET_EAPOL(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_EAPOL) |
| 769 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 770 | /*WAI */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 771 | #define RTMP_SET_PACKET_WAI(_p, _flg) \ |
| 772 | do{ \ |
| 773 | if (_flg) \ |
| 774 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_WAI); \ |
| 775 | else \ |
| 776 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_WAI); \ |
| 777 | }while(0) |
| 778 | #define RTMP_GET_PACKET_WAI(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_WAI) |
| 779 | |
| 780 | #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)) |
| 781 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 782 | /*VLAN */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 783 | #define RTMP_SET_PACKET_VLAN(_p, _flg) \ |
| 784 | do{ \ |
| 785 | if (_flg) \ |
| 786 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_VLAN); \ |
| 787 | else \ |
| 788 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_VLAN); \ |
| 789 | }while(0) |
| 790 | #define RTMP_GET_PACKET_VLAN(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_VLAN) |
| 791 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 792 | /*LLC/SNAP */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 793 | #define RTMP_SET_PACKET_LLCSNAP(_p, _flg) \ |
| 794 | do{ \ |
| 795 | if (_flg) \ |
| 796 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_LLCSNAP); \ |
| 797 | else \ |
| 798 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_LLCSNAP); \ |
| 799 | }while(0) |
| 800 | |
| 801 | #define RTMP_GET_PACKET_LLCSNAP(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_LLCSNAP) |
| 802 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 803 | /* IP */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 804 | #define RTMP_SET_PACKET_IPV4(_p, _flg) \ |
| 805 | do{ \ |
| 806 | if (_flg) \ |
| 807 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) |= (RTMP_PACKET_SPECIFIC_IPV4); \ |
| 808 | else \ |
| 809 | (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11]) &= (!RTMP_PACKET_SPECIFIC_IPV4); \ |
| 810 | }while(0) |
| 811 | |
| 812 | #define RTMP_GET_PACKET_IPV4(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+11] & RTMP_PACKET_SPECIFIC_IPV4) |
| 813 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 814 | /* If this flag is set, it indicates that this EAPoL frame MUST be clear. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 815 | #define RTMP_SET_PACKET_CLEAR_EAP_FRAME(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12] = _flg) |
| 816 | #define RTMP_GET_PACKET_CLEAR_EAP_FRAME(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+12]) |
| 817 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 818 | /* use bit3 of cb[CB_OFF+16] */ |
| 819 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 820 | #define RTMP_SET_PACKET_5VT(_p, _flg) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22] = _flg) |
| 821 | #define RTMP_GET_PACKET_5VT(_p) (RTPKT_TO_OSPKT(_p)->cb[CB_OFF+22]) |
| 822 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 823 | /* Max skb->cb = 48B = [CB_OFF+38] */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 824 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 825 | /*********************************************************************************** |
| 826 | * Other function prototypes definitions |
| 827 | ***********************************************************************************/ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 828 | void RTMP_GetCurrentSystemTime(LARGE_INTEGER * time); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 829 | int rt28xx_packet_xmit(struct sk_buff *skb); |
| 830 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 831 | #ifdef RTMP_MAC_PCI |
| 832 | /* function declarations */ |
| 833 | #define IRQ_HANDLE_TYPE irqreturn_t |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 834 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 835 | IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance); |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 836 | #endif /* RTMP_MAC_PCI // */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 837 | |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 838 | int rt28xx_sta_ioctl(struct net_device *net_dev, IN OUT struct ifreq *rq, int cmd); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 839 | |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 840 | extern int ra_mtd_write(int num, loff_t to, size_t len, const u_char * buf); |
| 841 | extern int ra_mtd_read(int num, loff_t from, size_t len, u_char * buf); |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 842 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 843 | #define GET_PAD_FROM_NET_DEV(_pAd, _net_dev) (_pAd) = (struct rt_rtmp_adapter *)(_net_dev)->ml_priv; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 844 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 845 | #endif /* __RT_LINUX_H__ // */ |