3 Copyright (C) 2001-2012 Neil Cafferkey
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26 #include <exec/types.h>
27 #include <exec/devices.h>
28 #include <exec/interrupts.h>
29 #include <exec/semaphores.h>
30 #include <devices/sana2.h>
31 #include <devices/sana2specialstats.h>
32 #include <devices/sana2wireless.h>
33 #include <devices/timer.h>
34 #include <dos/dosextens.h>
39 #define DEVICE_NAME "atheros5000.device"
42 #define DATE "1.8.2012"
44 #define UTILITY_VERSION 39
45 #define PROMETHEUS_VERSION 2
46 #define EXPANSION_VERSION 50
47 #define OPENPCI_VERSION 1
48 #define DOS_VERSION 36
61 #if defined(__mc68000) && !defined(__AROS__)
62 #define _REG(A, B) B __asm(#A)
63 #define REG(A, B) _REG(A, B)
70 #define STR(A) _STR(A)
81 struct ExecBase
*sys_base
;
82 struct UtilityBase
*utility_base
;
83 struct Library
*prometheus_base
;
84 struct Library
*openpci_base
;
85 struct DosLibrary
*dos_base
;
86 struct MinList pci_units
;
87 struct timerequest timer_request
;
89 struct Library
*expansion_base
;
90 struct ExecIFace
*i_exec
;
91 struct UtilityIFace
*i_utility
;
92 struct PCIIFace
*i_pci
;
93 struct DOSIFace
*i_dos
;
94 struct TimerIFace
*i_timer
;
96 VOID (*wrapper_int_code
)();
116 #define ETH_ADDRESSSIZE 6
117 #define ETH_HEADERSIZE 14
119 #define ETH_MAXPACKETSIZE (ETH_HEADERSIZE + ETH_MTU)
121 #define ETH_PACKET_DEST 0
122 #define ETH_PACKET_SOURCE 6
123 #define ETH_PACKET_TYPE 12
124 #define ETH_PACKET_IEEELEN 12
125 #define ETH_PACKET_DATA 14
127 #define SNAP_HEADERSIZE 8
129 #define SNAP_FRM_TYPE 6
140 #define FRAME_BUFFER_COUNT 10
141 #define TX_SLOT_COUNT /* 200 */ 10
142 #define MGMT_SLOT_COUNT 10
143 #define RX_SLOT_COUNT /* 200 */ 10
197 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
198 struct DevBase
*device
;
201 BOOL (*insertion_function
)(APTR
, struct DevBase
*);
202 VOID (*removal_function
)(APTR
, struct DevBase
*);
203 APTR (*AllocDMAMem
)(APTR
, UPINT
, UWORD
);
204 VOID (*FreeDMAMem
)(APTR
, APTR
);
206 UBYTE
*tx_buffers
[TX_SLOT_COUNT
];
207 ULONG tx_buffers_p
[TX_SLOT_COUNT
];
208 UBYTE
*mgmt_buffers
[MGMT_SLOT_COUNT
];
209 ULONG mgmt_buffers_p
[MGMT_SLOT_COUNT
];
211 UBYTE
*rx_buffers
[RX_SLOT_COUNT
];
212 ULONG rx_buffers_p
[RX_SLOT_COUNT
];
214 LONG rx_fragment_nos
[FRAME_BUFFER_COUNT
];
215 ULONG card_removed_signal
;
216 ULONG card_inserted_signal
;
220 UBYTE address
[ETH_ADDRESSSIZE
];
221 UBYTE default_address
[ETH_ADDRESSSIZE
];
222 UBYTE bssid
[ETH_ADDRESSSIZE
+ 2];
223 struct MinList openers
;
224 struct MinList type_trackers
;
225 struct MinList multicast_ranges
;
226 struct Interrupt status_int
;
227 struct Interrupt rx_int
;
228 struct Interrupt tx_int
;
229 struct Interrupt tx_end_int
;
230 struct Interrupt mgmt_int
;
231 struct Interrupt mgmt_end_int
;
232 struct Interrupt reset_handler
;
233 struct Sana2DeviceStats stats
;
234 ULONG special_stats
[STAT_COUNT
];
235 struct ath_desc
*tx_descs
;
237 struct ath_desc
*mgmt_descs
;
239 struct ath_desc
*rx_descs
;
241 struct IOSana2Req
**tx_requests
;
242 struct IOSana2Req
**mgmt_requests
;
244 struct Sana2SignalQuality signal_quality
;
245 struct SignalSemaphore access_lock
;
261 const VOID
*rate_table
;
262 const ULONG
*tx_rates
;
264 UWORD tx_rate_codes
[4];
265 UWORD mgmt_rate_code
;
267 struct KeyUnion keys
[WIFI_KEYCOUNT
];
268 UWORD iv_sizes
[ENC_COUNT
];
269 VOID (*fragment_encrypt_functions
[ENC_COUNT
])(struct DevUnit
*, UBYTE
*,
270 UBYTE
*, UWORD
*, UBYTE
*, struct DevBase
*);
271 BOOL (*fragment_decrypt_functions
[ENC_COUNT
])(struct DevUnit
*, UBYTE
*,
272 UBYTE
*, UWORD
*, UBYTE
*, struct DevBase
*);
279 struct MsgPort read_port
;
280 struct MsgPort mgmt_port
;
281 BOOL (*rx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
282 BOOL (*tx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
283 UBYTE
*(*dma_tx_function
)(REG(a0
, APTR
));
284 struct Hook
*filter_hook
;
285 struct MinList initial_stats
;
286 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
287 const VOID
*real_rx_function
;
288 const VOID
*real_tx_function
;
289 const VOID
*real_dma_tx_function
;
298 struct Sana2PacketTypeStats stats
;
306 struct Sana2PacketTypeStats stats
;
315 ULONG lower_bound_left
;
316 ULONG upper_bound_left
;
317 UWORD lower_bound_right
;
318 UWORD upper_bound_right
;
324 #define UNITF_SHARED (1 << 0)
325 #define UNITF_ONLINE (1 << 1)
326 #define UNITF_HAVEADAPTER (1 << 2)
327 #define UNITF_CONFIGURED (1 << 3)
328 #define UNITF_PROM (1 << 4)
329 #define UNITF_WASONLINE (1 << 5) /* card was online at time of removal */
330 #define UNITF_HARDWEP (1 << 6)
331 #define UNITF_HARDTKIP (1 << 7)
332 #define UNITF_HARDMIC (1 << 8)
333 //#define UNITF_SPLITMIC (1 << 9)
334 #define UNITF_HARDAESOCB (1 << 9)
335 #define UNITF_ALLMCAST (1 << 10)
336 #define UNITF_HASADHOC (1 << 11)
337 #define UNITF_HARDCCMP (1 << 12)
338 #define UNITF_SPLITMIC (1 << 13)
339 #define UNITF_INTADDED (1 << 14)
340 #define UNITF_RESETADDED (1 << 15)
341 #define UNITF_SHORTPREAMBLE (1 << 16)
342 #define UNITF_SLOWRETRIES (1 << 17)
345 /* Endianness macros */
347 #define FlipWord(A) \
349 UWORD _FlipWord_A = (A); \
350 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
353 #define FlipLong(A) \
355 ULONG _FlipLong_A = (A); \
357 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
360 #ifndef __i386__ /* Big endian */
390 #define MakeBEWord(A) \
393 #define MakeBELong(A) \
396 #define MakeLEWord(A) \
399 #define MakeLELong(A) \
403 /* Library and device bases */
405 #define SysBase (base->sys_base)
406 #define UtilityBase (base->utility_base)
407 #define ExpansionBase (base->expansion_base)
408 #define OpenPciBase (base->openpci_base)
409 #define PrometheusBase (base->prometheus_base)
410 #define DOSBase (base->dos_base)
411 #define TimerBase (base->timer_request.tr_node.io_Device)
414 #define IExec (base->i_exec)
415 #define IUtility (base->i_utility)
416 #define IDOS (base->i_dos)
417 #define ITimer (base->i_timer)
424 extern struct DevBase
*hal_dev_base
;