Report S2EVENT_CONNECT when a new SSID is selected.
[AROS.git] / workbench / devs / networks / atheros5000 / device.h
blob0fbcc18fc1d6753a54c9ab01f8aeb5d2d7c5f53f
1 /*
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,
18 MA 02111-1307, USA.
22 #ifndef DEVICE_H
23 #define DEVICE_H
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>
36 #include "wireless.h"
37 #include "io.h"
39 #define DEVICE_NAME "atheros5000.device"
40 #define VERSION 1
41 #define REVISION 3
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
50 #ifndef UPINT
51 #ifdef __AROS__
52 typedef IPTR UPINT;
53 typedef SIPTR PINT;
54 #else
55 typedef ULONG UPINT;
56 typedef LONG PINT;
57 #endif
58 #endif
60 #ifndef REG
61 #if defined(__mc68000) && !defined(__AROS__)
62 #define _REG(A, B) B __asm(#A)
63 #define REG(A, B) _REG(A, B)
64 #else
65 #define REG(A, B) B
66 #endif
67 #endif
69 #define _STR(A) #A
70 #define STR(A) _STR(A)
72 #ifndef __AROS__
73 #define USE_HACKS
74 #endif
77 struct DevBase
79 struct Device device;
80 APTR seg_list;
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;
88 #ifdef __amigaos4__
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;
95 #endif
96 VOID (*wrapper_int_code)();
100 enum
102 WRITE_QUEUE,
103 MGMT_QUEUE,
104 ADOPT_QUEUE,
105 EVENT_QUEUE,
106 SCAN_QUEUE,
107 GENERAL_QUEUE,
108 REQUEST_QUEUE_COUNT
111 enum
113 PCI_BUS,
116 #define ETH_ADDRESSSIZE 6
117 #define ETH_HEADERSIZE 14
118 #define ETH_MTU 1500
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
131 #define IV_SIZE 4
132 #define EIV_SIZE 8
133 #define ICV_SIZE 4
134 #define MIC_SIZE 8
135 #define FCS_SIZE 4
137 #define STAT_COUNT 3
138 #define ENC_COUNT 4
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
146 struct KeyUnion
148 UWORD type;
149 union
151 struct WEPKey
153 UWORD length;
154 UBYTE key[13];
155 ULONG tx_iv;
157 wep;
158 struct TKIPKey
160 UWORD key[8];
161 ULONG tx_mic_key[2];
162 ULONG rx_mic_key[2];
163 UWORD tx_iv_low;
164 ULONG tx_iv_high;
165 UWORD rx_iv_low;
166 ULONG rx_iv_high;
167 UWORD tx_ttak[5];
168 BOOL tx_ttak_set;
169 UWORD rx_ttak[5];
170 BOOL rx_ttak_set;
172 tkip;
173 struct CCMPKey
175 UBYTE key[16];
176 BOOL stream_set;
177 ULONG stream[44];
178 UWORD tx_iv_low;
179 ULONG tx_iv_high;
180 UWORD rx_iv_low;
181 ULONG rx_iv_high;
183 ccmp;
189 struct DevUnit
191 struct MinNode node;
192 ULONG index;
193 ULONG open_count;
194 ULONG flags;
195 UWORD bus;
196 struct Task *task;
197 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
198 struct DevBase *device;
199 APTR card;
200 struct ath_hal *hal;
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);
205 UBYTE *tx_buffer;
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];
210 UBYTE *rx_buffer;
211 UBYTE *rx_buffers[RX_SLOT_COUNT];
212 ULONG rx_buffers_p[RX_SLOT_COUNT];
213 UBYTE *rx_frames;
214 LONG rx_fragment_nos[FRAME_BUFFER_COUNT];
215 ULONG card_removed_signal;
216 ULONG card_inserted_signal;
217 ULONG range_count;
218 ULONG filter_mask;
219 ULONG antenna;
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;
236 ULONG tx_descs_p;
237 struct ath_desc *mgmt_descs;
238 ULONG mgmt_descs_p;
239 struct ath_desc *rx_descs;
240 ULONG rx_descs_p;
241 struct IOSana2Req **tx_requests;
242 struct IOSana2Req **mgmt_requests;
243 ULONG speed;
244 struct Sana2SignalQuality signal_quality;
245 struct SignalSemaphore access_lock;
246 UWORD tx_queue_no;
247 UWORD mgmt_queue_no;
248 UWORD tx_in_slot;
249 UWORD tx_out_slot;
250 UWORD mgmt_in_slot;
251 UWORD mgmt_out_slot;
252 UWORD rx_slot;
253 UWORD mode;
254 UWORD band;
255 APTR channels;
256 UWORD channel_count;
257 UWORD channel;
258 UWORD assoc_id;
259 UWORD capabilities;
260 ULONG band_mask;
261 const VOID *rate_table;
262 const ULONG *tx_rates;
263 ULONG mgmt_rate;
264 UWORD tx_rate_codes[4];
265 UWORD mgmt_rate_code;
266 UWORD tx_key_no;
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 *);
276 struct Opener
278 struct MinNode node;
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;
290 #endif
294 struct TypeStats
296 struct MinNode node;
297 ULONG packet_type;
298 struct Sana2PacketTypeStats stats;
302 struct TypeTracker
304 struct MinNode node;
305 ULONG packet_type;
306 struct Sana2PacketTypeStats stats;
307 ULONG user_count;
311 struct AddressRange
313 struct MinNode node;
314 ULONG add_count;
315 ULONG lower_bound_left;
316 ULONG upper_bound_left;
317 UWORD lower_bound_right;
318 UWORD upper_bound_right;
322 /* Unit flags */
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) \
348 ({ \
349 UWORD _FlipWord_A = (A); \
350 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
353 #define FlipLong(A) \
354 ({ \
355 ULONG _FlipLong_A = (A); \
356 _FlipLong_A = \
357 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
360 #ifndef __i386__ /* Big endian */
362 #define BEWord(A) \
365 #define BELong(A) \
368 #define LEWord(A) \
369 FlipWord(A)
371 #define LELong(A) \
372 FlipLong(A)
374 #else
376 #define BEWord(A) \
377 FlipWord(A)
379 #define BELong(A) \
380 FlipLong(A)
382 #define LEWord(A) \
385 #define LELong(A) \
388 #endif
390 #define MakeBEWord(A) \
391 BEWord(A)
393 #define MakeBELong(A) \
394 BELong(A)
396 #define MakeLEWord(A) \
397 LEWord(A)
399 #define MakeLELong(A) \
400 LELong(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)
413 #ifdef __amigaos4__
414 #define IExec (base->i_exec)
415 #define IUtility (base->i_utility)
416 #define IDOS (base->i_dos)
417 #define ITimer (base->i_timer)
418 #endif
420 #ifndef BASE_REG
421 #define BASE_REG a6
422 #endif
424 extern struct DevBase *hal_dev_base;
427 #endif