3 Copyright (C) 2001-2017 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>
38 #define DEVICE_NAME "realtek8180.device"
41 #define DATE "7.7.2017"
43 #define UTILITY_VERSION 39
44 #define POSEIDON_VERSION 0
57 #if defined(__mc68000) && !defined(__AROS__)
58 #define _REG(A, B) B __asm(#A)
59 #define REG(A, B) _REG(A, B)
66 #define STR(A) _STR(A)
69 #include <aros/debug.h>
70 #define DebugPrintF kprintf
82 struct ExecBase
*sys_base
;
83 struct UtilityBase
*utility_base
;
84 struct Library
*poseidon_base
;
85 struct MinList usb_units
;
86 struct timerequest timer_request
;
88 struct Library
*expansion_base
;
89 struct ExecIFace
*i_exec
;
90 struct UtilityIFace
*i_utility
;
91 struct PCIIFace
*i_pci
;
92 struct TimerIFace
*i_timer
;
94 VOID (*wrapper_int_code
)();
130 #define ETH_ADDRESSSIZE 6
131 #define ETH_HEADERSIZE 14
133 #define ETH_MAXPACKETSIZE (ETH_HEADERSIZE + ETH_MTU)
135 #define ETH_PACKET_DEST 0
136 #define ETH_PACKET_SOURCE 6
137 #define ETH_PACKET_TYPE 12
138 #define ETH_PACKET_IEEELEN 12
139 #define ETH_PACKET_DATA 14
141 #define SNAP_HEADERSIZE 8
143 #define SNAP_FRM_TYPE 6
145 #define CHANNEL_COUNT 14
155 #define FRAME_BUFFER_SIZE (WIFI_FRM_DATA + SNAP_HEADERSIZE \
156 + ETH_MTU + EIV_SIZE + ICV_SIZE + MIC_SIZE)
157 #define FRAME_BUFFER_COUNT 10
158 #define TX_SLOT_COUNT 30
159 #define RX_SLOT_COUNT 30
213 UWORD eeprom_addr_size
;
216 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
217 struct DevBase
*device
;
219 BOOL (*insertion_function
)(APTR
, struct DevBase
*);
220 VOID (*removal_function
)(APTR
, struct DevBase
*);
221 ULONG (*ByteIn
)(APTR
, ULONG
);
222 VOID (*ByteOut
)(APTR
, ULONG
, UBYTE
);
223 UWORD (*LEWordIn
)(APTR
, ULONG
);
224 ULONG (*LELongIn
)(APTR
, ULONG
);
225 VOID (*LEWordOut
)(APTR
, ULONG
, UWORD
);
226 VOID (*LELongOut
)(APTR
, ULONG
, ULONG
);
227 VOID (*SendFrame
)(APTR
, APTR
, ULONG
);
228 VOID (*ReceiveFrame
)(APTR
, APTR
, ULONG
);
229 APTR (*AllocDMAMem
)(APTR
, UPINT
, UWORD
);
230 VOID (*FreeDMAMem
)(APTR
, APTR
);
232 UBYTE
*tx_buffers
[TX_SLOT_COUNT
];
234 UBYTE
*rx_buffers
[RX_SLOT_COUNT
];
236 LONG rx_fragment_nos
[FRAME_BUFFER_COUNT
];
237 ULONG card_removed_signal
;
238 ULONG card_inserted_signal
;
240 UBYTE address
[ETH_ADDRESSSIZE
];
241 UBYTE default_address
[ETH_ADDRESSSIZE
];
242 UBYTE bssid
[ETH_ADDRESSSIZE
+ 2];
243 struct MinList openers
;
244 struct MinList type_trackers
;
245 struct MinList multicast_ranges
;
246 struct Interrupt rx_int
;
247 struct Interrupt tx_int
;
248 struct Interrupt mgmt_int
;
249 struct Sana2DeviceStats stats
;
250 ULONG special_stats
[STAT_COUNT
];
251 UBYTE
*tx_descs
[TX_SLOT_COUNT
];
252 UBYTE
*rx_descs
[RX_SLOT_COUNT
];
253 struct IOSana2Req
**tx_requests
;
255 struct Sana2SignalQuality signal_quality
;
256 struct SignalSemaphore access_lock
;
263 UBYTE base_cck_power
;
264 UBYTE base_ofdm_power
;
265 UBYTE cck_power
[CHANNEL_COUNT
+ 1];
266 UBYTE ofdm_power
[CHANNEL_COUNT
+ 1];
272 UWORD mgmt_rate_code
;
275 struct KeyUnion keys
[WIFI_KEYCOUNT
];
276 UWORD iv_sizes
[ENC_COUNT
];
277 VOID (*fragment_encrypt_functions
[ENC_COUNT
])(struct DevUnit
*, UBYTE
*,
278 UBYTE
*, UWORD
*, UBYTE
*, struct DevBase
*);
279 BOOL (*fragment_decrypt_functions
[ENC_COUNT
])(struct DevUnit
*, UBYTE
*,
280 UBYTE
*, UWORD
*, UBYTE
*, struct DevBase
*);
281 UWORD retries_offset
;
290 struct MsgPort read_port
;
291 struct MsgPort mgmt_port
;
292 BOOL (*rx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
293 BOOL (*tx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
294 UBYTE
*(*dma_tx_function
)(REG(a0
, APTR
));
295 struct Hook
*filter_hook
;
296 struct MinList initial_stats
;
297 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
298 const VOID
*real_rx_function
;
299 const VOID
*real_tx_function
;
300 const VOID
*real_dma_tx_function
;
309 struct Sana2PacketTypeStats stats
;
317 struct Sana2PacketTypeStats stats
;
326 ULONG lower_bound_left
;
327 ULONG upper_bound_left
;
328 UWORD lower_bound_right
;
329 UWORD upper_bound_right
;
335 #define UNITF_SHARED (1 << 0)
336 #define UNITF_ONLINE (1 << 1)
337 #define UNITF_HAVEADAPTER (1 << 2)
338 #define UNITF_CONFIGURED (1 << 3)
339 #define UNITF_PROM (1 << 4)
340 #define UNITF_WASONLINE (1 << 5) /* card was online at time of removal */
341 #define UNITF_HARDWEP (1 << 6)
342 #define UNITF_HARDTKIP (1 << 7)
343 #define UNITF_HARDCCMP (1 << 8)
344 #define UNITF_ALLMCAST (1 << 9)
345 #define UNITF_HASADHOC (1 << 10)
346 #define UNITF_SHORTPREAMBLE (1 << 11)
347 #define UNITF_INTADDED (1 << 12)
348 #define UNITF_RESETADDED (1 << 13)
349 #define UNITF_TASKADDED (1 << 14)
352 /* Endianness macros */
354 #define FlipWord(A) \
356 UWORD _FlipWord_A = (A); \
357 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
360 #define FlipLong(A) \
362 ULONG _FlipLong_A = (A); \
364 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
367 #define FlipQuad(A) \
369 UQUAD _FlipQuad_A = (A); \
371 (FlipLong(_FlipQuad_A) << 32) | FlipLong(_FlipQuad_A >> 32); \
374 #ifndef __i386__ /* Big endian */
410 #define MakeBEWord(A) \
413 #define MakeBELong(A) \
416 #define MakeLEWord(A) \
419 #define MakeLELong(A) \
423 /* Library and device bases */
425 #define SysBase (base->sys_base)
426 #define UtilityBase (base->utility_base)
427 #define PsdBase (base->poseidon_base)
428 #define TimerBase (base->timer_request.tr_node.io_Device)
431 #define IExec (base->i_exec)
432 #define IUtility (base->i_utility)
433 #define ITimer (base->i_timer)