]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * WaveLAN ISA driver | |
3 | * | |
4 | * Jean II - HPLB '96 | |
5 | * | |
6 | * Reorganisation and extension of the driver. | |
7 | * | |
8 | * This file contains all definitions and declarations necessary for the | |
9 | * WaveLAN ISA driver. This file is a private header, so it should | |
10 | * be included only in wavelan.c! | |
11 | */ | |
12 | ||
13 | #ifndef WAVELAN_P_H | |
14 | #define WAVELAN_P_H | |
15 | ||
16 | /************************** DOCUMENTATION ***************************/ | |
17 | /* | |
18 | * This driver provides a Linux interface to the WaveLAN ISA hardware. | |
19 | * The WaveLAN is a product of Lucent (http://www.wavelan.com/). | |
20 | * This division was formerly part of NCR and then AT&T. | |
21 | * WaveLANs are also distributed by DEC (RoamAbout DS) and Digital Ocean. | |
22 | * | |
23 | * To learn how to use this driver, read the NET3 HOWTO. | |
24 | * If you want to exploit the many other functionalities, read the comments | |
25 | * in the code. | |
26 | * | |
27 | * This driver is the result of the effort of many people (see below). | |
28 | */ | |
29 | ||
30 | /* ------------------------ SPECIFIC NOTES ------------------------ */ | |
31 | /* | |
32 | * Web page | |
33 | * -------- | |
34 | * I try to maintain a web page with the Wireless LAN Howto at : | |
35 | * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Wavelan.html | |
36 | * | |
37 | * SMP | |
38 | * --- | |
39 | * We now are SMP compliant (I eventually fixed the remaining bugs). | |
40 | * The driver has been tested on a dual P6-150 and survived my usual | |
41 | * set of torture tests. | |
42 | * Anyway, I spent enough time chasing interrupt re-entrancy during | |
43 | * errors or reconfigure, and I designed the locked/unlocked sections | |
44 | * of the driver with great care, and with the recent addition of | |
45 | * the spinlock (thanks to the new API), we should be quite close to | |
46 | * the truth. | |
47 | * The SMP/IRQ locking is quite coarse and conservative (i.e. not fast), | |
48 | * but better safe than sorry (especially at 2 Mb/s ;-). | |
49 | * | |
50 | * I have also looked into disabling only our interrupt on the card | |
51 | * (via HACR) instead of all interrupts in the processor (via cli), | |
52 | * so that other driver are not impacted, and it look like it's | |
53 | * possible, but it's very tricky to do right (full of races). As | |
54 | * the gain would be mostly for SMP systems, it can wait... | |
55 | * | |
56 | * Debugging and options | |
57 | * --------------------- | |
58 | * You will find below a set of '#define" allowing a very fine control | |
59 | * on the driver behaviour and the debug messages printed. | |
60 | * The main options are : | |
61 | * o SET_PSA_CRC, to have your card correctly recognised by | |
62 | * an access point and the Point-to-Point diagnostic tool. | |
63 | * o USE_PSA_CONFIG, to read configuration from the PSA (EEprom) | |
64 | * (otherwise we always start afresh with some defaults) | |
65 | * | |
66 | * wavelan.o is too darned big | |
67 | * --------------------------- | |
68 | * That's true! There is a very simple way to reduce the driver | |
69 | * object by 33%! Comment out the following line: | |
70 | * #include <linux/wireless.h> | |
71 | * Other compile options can also reduce the size of it... | |
72 | * | |
73 | * MAC address and hardware detection: | |
74 | * ----------------------------------- | |
75 | * The detection code for the WaveLAN checks that the first three | |
76 | * octets of the MAC address fit the company code. This type of | |
77 | * detection works well for AT&T cards (because the AT&T code is | |
78 | * hardcoded in wavelan.h), but of course will fail for other | |
79 | * manufacturers. | |
80 | * | |
81 | * If you are sure that your card is derived from the WaveLAN, | |
82 | * here is the way to configure it: | |
83 | * 1) Get your MAC address | |
84 | * a) With your card utilities (wfreqsel, instconf, etc.) | |
85 | * b) With the driver: | |
86 | * o compile the kernel with DEBUG_CONFIG_INFO enabled | |
87 | * o Boot and look the card messages | |
88 | * 2) Set your MAC code (3 octets) in MAC_ADDRESSES[][3] (wavelan.h) | |
89 | * 3) Compile and verify | |
90 | * 4) Send me the MAC code. I will include it in the next version. | |
91 | * | |
92 | */ | |
93 | ||
94 | /* --------------------- WIRELESS EXTENSIONS --------------------- */ | |
95 | /* | |
96 | * This driver is the first to support "wireless extensions". | |
97 | * This set of extensions provides a standard way to control the wireless | |
98 | * characteristics of the hardware. Applications such as mobile IP may | |
99 | * take advantage of it. | |
100 | * | |
d86b5e0e | 101 | * It might be a good idea as well to fetch the wireless tools to |
1da177e4 LT |
102 | * configure the device and play a bit. |
103 | */ | |
104 | ||
105 | /* ---------------------------- FILES ---------------------------- */ | |
106 | /* | |
107 | * wavelan.c: actual code for the driver: C functions | |
108 | * | |
109 | * wavelan.p.h: private header: local types and variables for driver | |
110 | * | |
111 | * wavelan.h: description of the hardware interface and structs | |
112 | * | |
113 | * i82586.h: description of the Ethernet controller | |
114 | */ | |
115 | ||
116 | /* --------------------------- HISTORY --------------------------- */ | |
117 | /* | |
118 | * This is based on information in the drivers' headers. It may not be | |
119 | * accurate, and I guarantee only my best effort. | |
120 | * | |
121 | * The history of the WaveLAN drivers is as complicated as the history of | |
122 | * the WaveLAN itself (NCR -> AT&T -> Lucent). | |
123 | * | |
124 | * It all started with Anders Klemets <klemets@paul.rutgers.edu> | |
125 | * writing a WaveLAN ISA driver for the Mach microkernel. Girish | |
126 | * Welling <welling@paul.rutgers.edu> had also worked on it. | |
127 | * Keith Moore modified this for the PCMCIA hardware. | |
128 | * | |
129 | * Robert Morris <rtm@das.harvard.edu> ported these two drivers to BSDI | |
130 | * and added specific PCMCIA support (there is currently no equivalent | |
131 | * of the PCMCIA package under BSD). | |
132 | * | |
133 | * Jim Binkley <jrb@cs.pdx.edu> ported both BSDI drivers to FreeBSD. | |
134 | * | |
135 | * Bruce Janson <bruce@cs.usyd.edu.au> ported the BSDI ISA driver to Linux. | |
136 | * | |
137 | * Anthony D. Joseph <adj@lcs.mit.edu> started to modify Bruce's driver | |
138 | * (with help of the BSDI PCMCIA driver) for PCMCIA. | |
139 | * Yunzhou Li <yunzhou@strat.iol.unh.edu> finished this work. | |
140 | * Joe Finney <joe@comp.lancs.ac.uk> patched the driver to start | |
141 | * 2.00 cards correctly (2.4 GHz with frequency selection). | |
142 | * David Hinds <dahinds@users.sourceforge.net> integrated the whole in his | |
143 | * PCMCIA package (and bug corrections). | |
144 | * | |
145 | * I (Jean Tourrilhes - jt@hplb.hpl.hp.com) then started to make some | |
146 | * patches to the PCMCIA driver. Later, I added code in the ISA driver | |
147 | * for Wireless Extensions and full support of frequency selection | |
148 | * cards. Then, I did the same to the PCMCIA driver, and did some | |
149 | * reorganisation. Finally, I came back to the ISA driver to | |
150 | * upgrade it at the same level as the PCMCIA one and reorganise | |
151 | * the code. | |
152 | * Loeke Brederveld <lbrederv@wavelan.com> from Lucent has given me | |
153 | * much needed information on the WaveLAN hardware. | |
154 | */ | |
155 | ||
156 | /* The original copyrights and literature mention others' names and | |
157 | * credits. I don't know what their part in this development was. | |
158 | */ | |
159 | ||
160 | /* By the way, for the copyright and legal stuff: | |
161 | * almost everybody wrote code under the GNU or BSD license (or similar), | |
162 | * and want their original copyright to remain somewhere in the | |
163 | * code (for myself, I go with the GPL). | |
164 | * Nobody wants to take responsibility for anything, except the fame. | |
165 | */ | |
166 | ||
167 | /* --------------------------- CREDITS --------------------------- */ | |
168 | /* | |
169 | * This software was developed as a component of the | |
170 | * Linux operating system. | |
171 | * It is based on other device drivers and information | |
172 | * either written or supplied by: | |
173 | * Ajay Bakre <bakre@paul.rutgers.edu>, | |
174 | * Donald Becker <becker@cesdis.gsfc.nasa.gov>, | |
175 | * Loeke Brederveld <Loeke.Brederveld@Utrecht.NCR.com>, | |
176 | * Brent Elphick <belphick@uwaterloo.ca>, | |
177 | * Anders Klemets <klemets@it.kth.se>, | |
178 | * Vladimir V. Kolpakov <w@stier.koenig.ru>, | |
179 | * Marc Meertens <Marc.Meertens@Utrecht.NCR.com>, | |
180 | * Pauline Middelink <middelin@polyware.iaf.nl>, | |
181 | * Robert Morris <rtm@das.harvard.edu>, | |
182 | * Jean Tourrilhes <jt@hpl.hp.com>, | |
183 | * Girish Welling <welling@paul.rutgers.edu>, | |
184 | * Clark Woodworth <clark@hiway1.exit109.com> | |
185 | * Yongguang Zhang <ygz@isl.hrl.hac.com> | |
186 | * | |
187 | * Thanks go also to: | |
188 | * James Ashton <jaa101@syseng.anu.edu.au>, | |
189 | * Alan Cox <alan@redhat.com>, | |
190 | * Allan Creighton <allanc@cs.usyd.edu.au>, | |
191 | * Matthew Geier <matthew@cs.usyd.edu.au>, | |
192 | * Remo di Giovanni <remo@cs.usyd.edu.au>, | |
193 | * Eckhard Grah <grah@wrcs1.urz.uni-wuppertal.de>, | |
194 | * Vipul Gupta <vgupta@cs.binghamton.edu>, | |
195 | * Mark Hagan <mhagan@wtcpost.daytonoh.NCR.COM>, | |
196 | * Tim Nicholson <tim@cs.usyd.edu.au>, | |
197 | * Ian Parkin <ian@cs.usyd.edu.au>, | |
198 | * John Rosenberg <johnr@cs.usyd.edu.au>, | |
199 | * George Rossi <george@phm.gov.au>, | |
200 | * Arthur Scott <arthur@cs.usyd.edu.au>, | |
201 | * Stanislav Sinyagin <stas@isf.ru> | |
202 | * and Peter Storey for their assistance and advice. | |
203 | * | |
204 | * Additional Credits: | |
205 | * | |
206 | * My development has been done initially under Debian 1.1 (Linux 2.0.x) | |
207 | * and now under Debian 2.2, initially with an HP Vectra XP/60, and now | |
208 | * an HP Vectra XP/90. | |
209 | * | |
210 | */ | |
211 | ||
212 | /* ------------------------- IMPROVEMENTS ------------------------- */ | |
213 | /* | |
214 | * I proudly present: | |
215 | * | |
216 | * Changes made in first pre-release: | |
217 | * ---------------------------------- | |
218 | * - reorganisation of the code, function name change | |
219 | * - creation of private header (wavelan.p.h) | |
220 | * - reorganised debug messages | |
221 | * - more comments, history, etc. | |
222 | * - mmc_init: configure the PSA if not done | |
223 | * - mmc_init: correct default value of level threshold for PCMCIA | |
224 | * - mmc_init: 2.00 detection better code for 2.00 initialization | |
225 | * - better info at startup | |
226 | * - IRQ setting (note: this setting is permanent) | |
227 | * - watchdog: change strategy (and solve module removal problems) | |
228 | * - add wireless extensions (ioctl and get_wireless_stats) | |
229 | * get/set nwid/frequency on fly, info for /proc/net/wireless | |
230 | * - more wireless extensions: SETSPY and GETSPY | |
231 | * - make wireless extensions optional | |
232 | * - private ioctl to set/get quality and level threshold, histogram | |
233 | * - remove /proc/net/wavelan | |
234 | * - suppress useless stuff from lp (net_local) | |
235 | * - kernel 2.1 support (copy_to/from_user instead of memcpy_to/fromfs) | |
236 | * - add message level (debug stuff in /var/adm/debug and errors not | |
237 | * displayed at console and still in /var/adm/messages) | |
238 | * - multi device support | |
239 | * - start fixing the probe (init code) | |
240 | * - more inlines | |
241 | * - man page | |
242 | * - many other minor details and cleanups | |
243 | * | |
244 | * Changes made in second pre-release: | |
245 | * ----------------------------------- | |
246 | * - clean up init code (probe and module init) | |
247 | * - better multiple device support (module) | |
248 | * - name assignment (module) | |
249 | * | |
250 | * Changes made in third pre-release: | |
251 | * ---------------------------------- | |
252 | * - be more conservative on timers | |
253 | * - preliminary support for multicast (I still lack some details) | |
254 | * | |
255 | * Changes made in fourth pre-release: | |
256 | * ----------------------------------- | |
257 | * - multicast (revisited and finished) | |
258 | * - avoid reset in set_multicast_list (a really big hack) | |
259 | * if somebody could apply this code for other i82586 based drivers | |
260 | * - share onboard memory 75% RU and 25% CU (instead of 50/50) | |
261 | * | |
262 | * Changes made for release in 2.1.15: | |
263 | * ----------------------------------- | |
264 | * - change the detection code for multi manufacturer code support | |
265 | * | |
266 | * Changes made for release in 2.1.17: | |
267 | * ----------------------------------- | |
268 | * - update to wireless extensions changes | |
269 | * - silly bug in card initial configuration (psa_conf_status) | |
270 | * | |
271 | * Changes made for release in 2.1.27 & 2.0.30: | |
272 | * -------------------------------------------- | |
273 | * - small bug in debug code (probably not the last one...) | |
274 | * - remove extern keyword for wavelan_probe() | |
275 | * - level threshold is now a standard wireless extension (version 4 !) | |
276 | * - modules parameters types (new module interface) | |
277 | * | |
278 | * Changes made for release in 2.1.36: | |
279 | * ----------------------------------- | |
280 | * - byte count stats (courtesy of David Hinds) | |
281 | * - remove dev_tint stuff (courtesy of David Hinds) | |
282 | * - encryption setting from Brent Elphick (thanks a lot!) | |
283 | * - 'ioaddr' to 'u_long' for the Alpha (thanks to Stanislav Sinyagin) | |
284 | * | |
285 | * Other changes (not by me) : | |
286 | * ------------------------- | |
287 | * - Spelling and gramar "rectification". | |
288 | * | |
289 | * Changes made for release in 2.0.37 & 2.2.2 : | |
290 | * ------------------------------------------ | |
291 | * - Correct status in /proc/net/wireless | |
292 | * - Set PSA CRC to make PtP diagnostic tool happy (Bob Gray) | |
293 | * - Module init code don't fail if we found at least one card in | |
294 | * the address list (Karlis Peisenieks) | |
295 | * - Missing parenthesis (Christopher Peterson) | |
296 | * - Correct i82586 configuration parameters | |
297 | * - Encryption initialisation bug (Robert McCormack) | |
298 | * - New mac addresses detected in the probe | |
299 | * - Increase watchdog for busy environments | |
300 | * | |
301 | * Changes made for release in 2.0.38 & 2.2.7 : | |
302 | * ------------------------------------------ | |
303 | * - Correct the reception logic to better report errors and avoid | |
304 | * sending bogus packet up the stack | |
305 | * - Delay RU config to avoid corrupting first received packet | |
306 | * - Change config completion code (to actually check something) | |
307 | * - Avoid reading out of bound in skbuf to transmit | |
308 | * - Rectify a lot of (useless) debugging code | |
309 | * - Change the way to `#ifdef SET_PSA_CRC' | |
310 | * | |
311 | * Changes made for release in 2.2.11 & 2.3.13 : | |
312 | * ------------------------------------------- | |
313 | * - Change e-mail and web page addresses | |
314 | * - Watchdog timer is now correctly expressed in HZ, not in jiffies | |
315 | * - Add channel number to the list of frequencies in range | |
316 | * - Add the (short) list of bit-rates in range | |
317 | * - Developp a new sensitivity... (sens.value & sens.fixed) | |
318 | * | |
319 | * Changes made for release in 2.2.14 & 2.3.23 : | |
320 | * ------------------------------------------- | |
321 | * - Fix check for root permission (break instead of exit) | |
322 | * - New nwid & encoding setting (Wireless Extension 9) | |
323 | * | |
324 | * Changes made for release in 2.3.49 : | |
325 | * ---------------------------------- | |
326 | * - Indentation reformating (Alan) | |
327 | * - Update to new network API (softnet - 2.3.43) : | |
328 | * o replace dev->tbusy (Alan) | |
329 | * o replace dev->tstart (Alan) | |
330 | * o remove dev->interrupt (Alan) | |
331 | * o add SMP locking via spinlock in splxx (me) | |
332 | * o add spinlock in interrupt handler (me) | |
333 | * o use kernel watchdog instead of ours (me) | |
334 | * o increase watchdog timeout (kernel is more sensitive) (me) | |
335 | * o verify that all the changes make sense and work (me) | |
336 | * - Fixup a potential gotcha when reconfiguring and thighten a bit | |
337 | * the interactions with Tx queue. | |
338 | * | |
339 | * Changes made for release in 2.4.0 : | |
340 | * --------------------------------- | |
341 | * - Fix spinlock stupid bugs that I left in. The driver is now SMP | |
342 | * compliant and doesn't lockup at startup. | |
343 | * | |
344 | * Changes made for release in 2.5.2 : | |
345 | * --------------------------------- | |
346 | * - Use new driver API for Wireless Extensions : | |
347 | * o got rid of wavelan_ioctl() | |
348 | * o use a bunch of iw_handler instead | |
349 | * | |
350 | * Changes made for release in 2.5.35 : | |
351 | * ---------------------------------- | |
352 | * - Set dev->trans_start to avoid filling the logs | |
353 | * - Handle better spurious/bogus interrupt | |
354 | * - Avoid deadlocks in mmc_out()/mmc_in() | |
355 | * | |
356 | * Wishes & dreams: | |
357 | * ---------------- | |
358 | * - roaming (see Pcmcia driver) | |
359 | */ | |
360 | ||
361 | /***************************** INCLUDES *****************************/ | |
362 | ||
363 | #include <linux/module.h> | |
364 | ||
365 | #include <linux/kernel.h> | |
366 | #include <linux/sched.h> | |
367 | #include <linux/types.h> | |
368 | #include <linux/fcntl.h> | |
369 | #include <linux/interrupt.h> | |
370 | #include <linux/stat.h> | |
371 | #include <linux/ptrace.h> | |
372 | #include <linux/ioport.h> | |
373 | #include <linux/in.h> | |
374 | #include <linux/string.h> | |
375 | #include <linux/delay.h> | |
376 | #include <linux/bitops.h> | |
377 | #include <asm/system.h> | |
378 | #include <asm/io.h> | |
379 | #include <asm/dma.h> | |
380 | #include <asm/uaccess.h> | |
381 | #include <linux/errno.h> | |
382 | #include <linux/netdevice.h> | |
383 | #include <linux/etherdevice.h> | |
384 | #include <linux/skbuff.h> | |
385 | #include <linux/slab.h> | |
386 | #include <linux/timer.h> | |
387 | #include <linux/init.h> | |
388 | ||
389 | #include <linux/wireless.h> /* Wireless extensions */ | |
390 | #include <net/iw_handler.h> /* Wireless handlers */ | |
391 | ||
392 | /* WaveLAN declarations */ | |
393 | #include "i82586.h" | |
394 | #include "wavelan.h" | |
395 | ||
396 | /************************** DRIVER OPTIONS **************************/ | |
397 | /* | |
398 | * `#define' or `#undef' the following constant to change the behaviour | |
399 | * of the driver... | |
400 | */ | |
401 | #undef SET_PSA_CRC /* Calculate and set the CRC on PSA (slower) */ | |
402 | #define USE_PSA_CONFIG /* Use info from the PSA. */ | |
1da177e4 LT |
403 | #undef EEPROM_IS_PROTECTED /* doesn't seem to be necessary */ |
404 | #define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */ | |
405 | #undef SET_MAC_ADDRESS /* Experimental */ | |
406 | ||
1da177e4 LT |
407 | /* Warning: this stuff will slow down the driver. */ |
408 | #define WIRELESS_SPY /* Enable spying addresses. */ | |
409 | #undef HISTOGRAM /* Enable histogram of signal level. */ | |
1da177e4 LT |
410 | |
411 | /****************************** DEBUG ******************************/ | |
412 | ||
413 | #undef DEBUG_MODULE_TRACE /* module insertion/removal */ | |
414 | #undef DEBUG_CALLBACK_TRACE /* calls made by Linux */ | |
415 | #undef DEBUG_INTERRUPT_TRACE /* calls to handler */ | |
416 | #undef DEBUG_INTERRUPT_INFO /* type of interrupt and so on */ | |
417 | #define DEBUG_INTERRUPT_ERROR /* problems */ | |
418 | #undef DEBUG_CONFIG_TRACE /* Trace the config functions. */ | |
419 | #undef DEBUG_CONFIG_INFO /* what's going on */ | |
420 | #define DEBUG_CONFIG_ERROR /* errors on configuration */ | |
421 | #undef DEBUG_TX_TRACE /* transmission calls */ | |
422 | #undef DEBUG_TX_INFO /* header of the transmitted packet */ | |
423 | #undef DEBUG_TX_FAIL /* Normal failure conditions */ | |
424 | #define DEBUG_TX_ERROR /* Unexpected conditions */ | |
425 | #undef DEBUG_RX_TRACE /* transmission calls */ | |
426 | #undef DEBUG_RX_INFO /* header of the received packet */ | |
427 | #undef DEBUG_RX_FAIL /* Normal failure conditions */ | |
428 | #define DEBUG_RX_ERROR /* Unexpected conditions */ | |
429 | ||
430 | #undef DEBUG_PACKET_DUMP /* Dump packet on the screen if defined to 32. */ | |
431 | #undef DEBUG_IOCTL_TRACE /* misc. call by Linux */ | |
432 | #undef DEBUG_IOCTL_INFO /* various debugging info */ | |
433 | #define DEBUG_IOCTL_ERROR /* what's going wrong */ | |
434 | #define DEBUG_BASIC_SHOW /* Show basic startup info. */ | |
435 | #undef DEBUG_VERSION_SHOW /* Print version info. */ | |
436 | #undef DEBUG_PSA_SHOW /* Dump PSA to screen. */ | |
437 | #undef DEBUG_MMC_SHOW /* Dump mmc to screen. */ | |
438 | #undef DEBUG_SHOW_UNUSED /* Show unused fields too. */ | |
439 | #undef DEBUG_I82586_SHOW /* Show i82586 status. */ | |
440 | #undef DEBUG_DEVICE_SHOW /* Show device parameters. */ | |
441 | ||
442 | /************************ CONSTANTS & MACROS ************************/ | |
443 | ||
444 | #ifdef DEBUG_VERSION_SHOW | |
445 | static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12/01\n"; | |
446 | #endif | |
447 | ||
448 | /* Watchdog temporisation */ | |
449 | #define WATCHDOG_JIFFIES (512*HZ/100) | |
450 | ||
1da177e4 LT |
451 | /* ------------------------ PRIVATE IOCTL ------------------------ */ |
452 | ||
453 | #define SIOCSIPQTHR SIOCIWFIRSTPRIV /* Set quality threshold */ | |
454 | #define SIOCGIPQTHR SIOCIWFIRSTPRIV + 1 /* Get quality threshold */ | |
455 | ||
456 | #define SIOCSIPHISTO SIOCIWFIRSTPRIV + 2 /* Set histogram ranges */ | |
457 | #define SIOCGIPHISTO SIOCIWFIRSTPRIV + 3 /* Get histogram values */ | |
458 | ||
459 | /****************************** TYPES ******************************/ | |
460 | ||
461 | /* Shortcuts */ | |
462 | typedef struct net_device_stats en_stats; | |
463 | typedef struct iw_statistics iw_stats; | |
464 | typedef struct iw_quality iw_qual; | |
465 | typedef struct iw_freq iw_freq; | |
466 | typedef struct net_local net_local; | |
467 | typedef struct timer_list timer_list; | |
468 | ||
469 | /* Basic types */ | |
470 | typedef u_char mac_addr[WAVELAN_ADDR_SIZE]; /* Hardware address */ | |
471 | ||
472 | /* | |
473 | * Static specific data for the interface. | |
474 | * | |
475 | * For each network interface, Linux keeps data in two structures: "device" | |
476 | * keeps the generic data (same format for everybody) and "net_local" keeps | |
477 | * additional specific data. | |
478 | * Note that some of this specific data is in fact generic (en_stats, for | |
479 | * example). | |
480 | */ | |
481 | struct net_local | |
482 | { | |
483 | net_local * next; /* linked list of the devices */ | |
484 | struct net_device * dev; /* reverse link */ | |
485 | spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ | |
486 | en_stats stats; /* Ethernet interface statistics */ | |
487 | int nresets; /* number of hardware resets */ | |
488 | u_char reconfig_82586; /* We need to reconfigure the controller. */ | |
489 | u_char promiscuous; /* promiscuous mode */ | |
490 | int mc_count; /* number of multicast addresses */ | |
491 | u_short hacr; /* current host interface state */ | |
492 | ||
493 | int tx_n_in_use; | |
494 | u_short rx_head; | |
495 | u_short rx_last; | |
496 | u_short tx_first_free; | |
497 | u_short tx_first_in_use; | |
498 | ||
1da177e4 LT |
499 | iw_stats wstats; /* Wireless-specific statistics */ |
500 | ||
501 | struct iw_spy_data spy_data; | |
502 | struct iw_public_data wireless_data; | |
1da177e4 LT |
503 | |
504 | #ifdef HISTOGRAM | |
505 | int his_number; /* number of intervals */ | |
506 | u_char his_range[16]; /* boundaries of interval ]n-1; n] */ | |
507 | u_long his_sum[16]; /* sum in interval */ | |
508 | #endif /* HISTOGRAM */ | |
509 | }; | |
510 | ||
511 | /**************************** PROTOTYPES ****************************/ | |
512 | ||
513 | /* ----------------------- MISC. SUBROUTINES ------------------------ */ | |
514 | static u_char | |
515 | wv_irq_to_psa(int); | |
516 | static int | |
517 | wv_psa_to_irq(u_char); | |
518 | /* ------------------- HOST ADAPTER SUBROUTINES ------------------- */ | |
519 | static inline u_short /* data */ | |
520 | hasr_read(u_long); /* Read the host interface: base address */ | |
521 | static inline void | |
522 | hacr_write(u_long, /* Write to host interface: base address */ | |
523 | u_short), /* data */ | |
524 | hacr_write_slow(u_long, | |
525 | u_short), | |
526 | set_chan_attn(u_long, /* ioaddr */ | |
527 | u_short), /* hacr */ | |
528 | wv_hacr_reset(u_long), /* ioaddr */ | |
529 | wv_16_off(u_long, /* ioaddr */ | |
530 | u_short), /* hacr */ | |
531 | wv_16_on(u_long, /* ioaddr */ | |
532 | u_short), /* hacr */ | |
533 | wv_ints_off(struct net_device *), | |
534 | wv_ints_on(struct net_device *); | |
535 | /* ----------------- MODEM MANAGEMENT SUBROUTINES ----------------- */ | |
536 | static void | |
537 | psa_read(u_long, /* Read the Parameter Storage Area. */ | |
538 | u_short, /* hacr */ | |
539 | int, /* offset in PSA */ | |
540 | u_char *, /* buffer to fill */ | |
541 | int), /* size to read */ | |
542 | psa_write(u_long, /* Write to the PSA. */ | |
543 | u_short, /* hacr */ | |
544 | int, /* offset in PSA */ | |
545 | u_char *, /* buffer in memory */ | |
546 | int); /* length of buffer */ | |
547 | static inline void | |
548 | mmc_out(u_long, /* Write 1 byte to the Modem Manag Control. */ | |
549 | u_short, | |
550 | u_char), | |
551 | mmc_write(u_long, /* Write n bytes to the MMC. */ | |
552 | u_char, | |
553 | u_char *, | |
554 | int); | |
555 | static inline u_char /* Read 1 byte from the MMC. */ | |
556 | mmc_in(u_long, | |
557 | u_short); | |
558 | static inline void | |
559 | mmc_read(u_long, /* Read n bytes from the MMC. */ | |
560 | u_char, | |
561 | u_char *, | |
562 | int), | |
563 | fee_wait(u_long, /* Wait for frequency EEPROM: base address */ | |
564 | int, /* base delay to wait for */ | |
565 | int); /* time to wait */ | |
566 | static void | |
567 | fee_read(u_long, /* Read the frequency EEPROM: base address */ | |
568 | u_short, /* destination offset */ | |
569 | u_short *, /* data buffer */ | |
570 | int); /* number of registers */ | |
571 | /* ---------------------- I82586 SUBROUTINES ----------------------- */ | |
572 | static /*inline*/ void | |
573 | obram_read(u_long, /* ioaddr */ | |
574 | u_short, /* o */ | |
575 | u_char *, /* b */ | |
576 | int); /* n */ | |
577 | static inline void | |
578 | obram_write(u_long, /* ioaddr */ | |
579 | u_short, /* o */ | |
580 | u_char *, /* b */ | |
581 | int); /* n */ | |
582 | static void | |
583 | wv_ack(struct net_device *); | |
584 | static inline int | |
585 | wv_synchronous_cmd(struct net_device *, | |
586 | const char *), | |
587 | wv_config_complete(struct net_device *, | |
588 | u_long, | |
589 | net_local *); | |
590 | static int | |
591 | wv_complete(struct net_device *, | |
592 | u_long, | |
593 | net_local *); | |
594 | static inline void | |
595 | wv_82586_reconfig(struct net_device *); | |
596 | /* ------------------- DEBUG & INFO SUBROUTINES ------------------- */ | |
597 | #ifdef DEBUG_I82586_SHOW | |
598 | static void | |
599 | wv_scb_show(unsigned short); | |
600 | #endif | |
601 | static inline void | |
602 | wv_init_info(struct net_device *); /* display startup info */ | |
603 | /* ------------------- IOCTL, STATS & RECONFIG ------------------- */ | |
604 | static en_stats * | |
605 | wavelan_get_stats(struct net_device *); /* Give stats /proc/net/dev */ | |
606 | static iw_stats * | |
607 | wavelan_get_wireless_stats(struct net_device *); | |
608 | static void | |
609 | wavelan_set_multicast_list(struct net_device *); | |
610 | /* ----------------------- PACKET RECEPTION ----------------------- */ | |
611 | static inline void | |
612 | wv_packet_read(struct net_device *, /* Read a packet from a frame. */ | |
613 | u_short, | |
614 | int), | |
615 | wv_receive(struct net_device *); /* Read all packets waiting. */ | |
616 | /* --------------------- PACKET TRANSMISSION --------------------- */ | |
617 | static inline int | |
618 | wv_packet_write(struct net_device *, /* Write a packet to the Tx buffer. */ | |
619 | void *, | |
620 | short); | |
621 | static int | |
622 | wavelan_packet_xmit(struct sk_buff *, /* Send a packet. */ | |
623 | struct net_device *); | |
624 | /* -------------------- HARDWARE CONFIGURATION -------------------- */ | |
625 | static inline int | |
626 | wv_mmc_init(struct net_device *), /* Initialize the modem. */ | |
627 | wv_ru_start(struct net_device *), /* Start the i82586 receiver unit. */ | |
628 | wv_cu_start(struct net_device *), /* Start the i82586 command unit. */ | |
629 | wv_82586_start(struct net_device *); /* Start the i82586. */ | |
630 | static void | |
631 | wv_82586_config(struct net_device *); /* Configure the i82586. */ | |
632 | static inline void | |
633 | wv_82586_stop(struct net_device *); | |
634 | static int | |
635 | wv_hw_reset(struct net_device *), /* Reset the WaveLAN hardware. */ | |
636 | wv_check_ioaddr(u_long, /* ioaddr */ | |
637 | u_char *); /* mac address (read) */ | |
638 | /* ---------------------- INTERRUPT HANDLING ---------------------- */ | |
639 | static irqreturn_t | |
640 | wavelan_interrupt(int, /* interrupt handler */ | |
7d12e780 | 641 | void *); |
1da177e4 LT |
642 | static void |
643 | wavelan_watchdog(struct net_device *); /* transmission watchdog */ | |
644 | /* ------------------- CONFIGURATION CALLBACKS ------------------- */ | |
645 | static int | |
646 | wavelan_open(struct net_device *), /* Open the device. */ | |
647 | wavelan_close(struct net_device *), /* Close the device. */ | |
648 | wavelan_config(struct net_device *, unsigned short);/* Configure one device. */ | |
649 | extern struct net_device *wavelan_probe(int unit); /* See Space.c. */ | |
650 | ||
651 | /**************************** VARIABLES ****************************/ | |
652 | ||
653 | /* | |
654 | * This is the root of the linked list of WaveLAN drivers | |
655 | * It is use to verify that we don't reuse the same base address | |
656 | * for two different drivers and to clean up when removing the module. | |
657 | */ | |
658 | static net_local * wavelan_list = (net_local *) NULL; | |
659 | ||
660 | /* | |
661 | * This table is used to translate the PSA value to IRQ number | |
662 | * and vice versa. | |
663 | */ | |
664 | static u_char irqvals[] = | |
665 | { | |
666 | 0, 0, 0, 0x01, | |
667 | 0x02, 0x04, 0, 0x08, | |
668 | 0, 0, 0x10, 0x20, | |
669 | 0x40, 0, 0, 0x80, | |
670 | }; | |
671 | ||
672 | /* | |
673 | * Table of the available I/O addresses (base addresses) for WaveLAN | |
674 | */ | |
675 | static unsigned short iobase[] = | |
676 | { | |
677 | #if 0 | |
678 | /* Leave out 0x3C0 for now -- seems to clash with some video | |
679 | * controllers. | |
680 | * Leave out the others too -- we will always use 0x390 and leave | |
681 | * 0x300 for the Ethernet device. | |
682 | * Jean II: 0x3E0 is fine as well. | |
683 | */ | |
684 | 0x300, 0x390, 0x3E0, 0x3C0 | |
685 | #endif /* 0 */ | |
686 | 0x390, 0x3E0 | |
687 | }; | |
688 | ||
689 | #ifdef MODULE | |
690 | /* Parameters set by insmod */ | |
691 | static int io[4]; | |
692 | static int irq[4]; | |
693 | static char *name[4]; | |
694 | module_param_array(io, int, NULL, 0); | |
695 | module_param_array(irq, int, NULL, 0); | |
696 | module_param_array(name, charp, NULL, 0); | |
697 | ||
698 | MODULE_PARM_DESC(io, "WaveLAN I/O base address(es),required"); | |
699 | MODULE_PARM_DESC(irq, "WaveLAN IRQ number(s)"); | |
700 | MODULE_PARM_DESC(name, "WaveLAN interface neme(s)"); | |
701 | #endif /* MODULE */ | |
702 | ||
703 | #endif /* WAVELAN_P_H */ |