File: /usr/src/linux/drivers/net/pcmcia/wavelan_cs.h

1     /*
2      *	Wavelan Pcmcia driver
3      *
4      *		Jean II - HPLB '96
5      *
6      * Reorganisation and extension of the driver.
7      *
8      * This file contain all definition and declarations necessary for the
9      * wavelan pcmcia driver. This file is a private header, so it should
10      * be included only on wavelan_cs.c !!!
11      */
12     
13     #ifndef WAVELAN_CS_H
14     #define WAVELAN_CS_H
15     
16     /************************** DOCUMENTATION **************************/
17     /*
18      * This driver provide a Linux interface to the Wavelan Pcmcia 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      * Wavelan are also distributed by DEC (RoamAbout DS)...
22      *
23      * To know how to use this driver, read the PCMCIA HOWTO.
24      * If you want to exploit the many other fonctionalities, look comments
25      * in the code...
26      *
27      * This driver is the result of the effort of many peoples (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      * Debugging and options
38      * ---------------------
39      *	You will find below a set of '#define" allowing a very fine control
40      *	on the driver behaviour and the debug messages printed.
41      *	The main options are :
42      *	o WAVELAN_ROAMING, for the experimental roaming support.
43      *	o SET_PSA_CRC, to have your card correctly recognised by
44      *	  an access point and the Point-to-Point diagnostic tool.
45      *	o USE_PSA_CONFIG, to read configuration from the PSA (EEprom)
46      *	  (otherwise we always start afresh with some defaults)
47      *
48      * wavelan_cs.o is darn too big
49      * -------------------------
50      *	That's true ! There is a very simple way to reduce the driver
51      *	object by 33% (yes !). Comment out the following line :
52      *		#include <linux/wireless.h>
53      *	Other compile options can also reduce the size of it...
54      *
55      * MAC address and hardware detection :
56      * ----------------------------------
57      *	The detection code of the wavelan chech that the first 3
58      *	octets of the MAC address fit the company code. This type of
59      *	detection work well for AT&T cards (because the AT&T code is
60      *	hardcoded in wavelan.h), but of course will fail for other
61      *	manufacturer.
62      *
63      *	If you are sure that your card is derived from the wavelan,
64      *	here is the way to configure it :
65      *	1) Get your MAC address
66      *		a) With your card utilities (wfreqsel, instconf, ...)
67      *		b) With the driver :
68      *			o compile the kernel with DEBUG_CONFIG_INFO enabled
69      *			o Boot and look the card messages
70      *	2) Set your MAC code (3 octets) in MAC_ADDRESSES[][3] (wavelan.h)
71      *	3) Compile & verify
72      *	4) Send me the MAC code - I will include it in the next version...
73      *
74      */
75     
76     /* --------------------- WIRELESS EXTENSIONS --------------------- */
77     /*
78      * This driver is the first one to support "wireless extensions".
79      * This set of extensions provide you some way to control the wireless
80      * caracteristics of the hardware in a standard way and support for
81      * applications for taking advantage of it (like Mobile IP).
82      *
83      * You will need to enable the CONFIG_NET_RADIO define in the kernel
84      * configuration to enable the wireless extensions (this is the one
85      * giving access to the radio network device choice).
86      *
87      * It might also be a good idea as well to fetch the wireless tools to
88      * configure the device and play a bit.
89      */
90     
91     /* ---------------------------- FILES ---------------------------- */
92     /*
93      * wavelan_cs.c :	The actual code for the driver - C functions
94      *
95      * wavelan_cs.h :	Private header : local types / vars for the driver
96      *
97      * wavelan.h :		Description of the hardware interface & structs
98      *
99      * i82593.h :		Description if the Ethernet controller
100      */
101     
102     /* --------------------------- HISTORY --------------------------- */
103     /*
104      * The history of the Wavelan drivers is as complicated as history of
105      * the Wavelan itself (NCR -> AT&T -> Lucent).
106      *
107      * All started with Anders Klemets <klemets@paul.rutgers.edu>,
108      * writting a Wavelan ISA driver for the MACH microkernel. Girish
109      * Welling <welling@paul.rutgers.edu> had also worked on it.
110      * Keith Moore modify this for the Pcmcia hardware.
111      * 
112      * Robert Morris <rtm@das.harvard.edu> port these two drivers to BSDI
113      * and add specific Pcmcia support (there is currently no equivalent
114      * of the PCMCIA package under BSD...).
115      *
116      * Jim Binkley <jrb@cs.pdx.edu> port both BSDI drivers to FreeBSD.
117      *
118      * Bruce Janson <bruce@cs.usyd.edu.au> port the BSDI ISA driver to Linux.
119      *
120      * Anthony D. Joseph <adj@lcs.mit.edu> started modify Bruce driver
121      * (with help of the BSDI PCMCIA driver) for PCMCIA.
122      * Yunzhou Li <yunzhou@strat.iol.unh.edu> finished is work.
123      * Joe Finney <joe@comp.lancs.ac.uk> patched the driver to start
124      * correctly 2.00 cards (2.4 GHz with frequency selection).
125      * David Hinds <dhinds@pcmcia.sourceforge.org> integrated the whole in his
126      * Pcmcia package (+ bug corrections).
127      *
128      * I (Jean Tourrilhes - jt@hplb.hpl.hp.com) then started to make some
129      * patchs to the Pcmcia driver. After, I added code in the ISA driver
130      * for Wireless Extensions and full support of frequency selection
131      * cards. Now, I'm doing the same to the Pcmcia driver + some
132      * reorganisation.
133      * Loeke Brederveld <lbrederv@wavelan.com> from Lucent has given me
134      * much needed informations on the Wavelan hardware.
135      */
136     
137     /* By the way : for the copyright & legal stuff :
138      * Almost everybody wrote code under GNU or BSD license (or alike),
139      * and want that their original copyright remain somewhere in the
140      * code (for myself, I go with the GPL).
141      * Nobody want to take responsibility for anything, except the fame...
142      */
143     
144     /* --------------------------- CREDITS --------------------------- */
145     /*
146      * Credits:
147      *    Special thanks to Jan Hoogendoorn of AT&T GIS Utrecht and
148      *	Loeke Brederveld of Lucent for providing extremely useful
149      *	information about WaveLAN PCMCIA hardware
150      *
151      *    This driver is based upon several other drivers, in particular:
152      *	David Hinds' Linux driver for the PCMCIA 3c589 ethernet adapter
153      *	Bruce Janson's Linux driver for the AT-bus WaveLAN adapter
154      *	Anders Klemets' PCMCIA WaveLAN adapter driver
155      *	Robert Morris' BSDI driver for the PCMCIA WaveLAN adapter
156      *
157      * Additional Credits:
158      *
159      *    This software was originally developed under Linux 1.2.3
160      *	(Slackware 2.0 distribution).
161      *    And then under Linux 2.0.x (Debian 1.1 - pcmcia 2.8.18-23) with
162      *	HP OmniBook 4000 & 5500.
163      *
164      *    It is based on other device drivers and information either written
165      *    or supplied by:
166      *	James Ashton (jaa101@syseng.anu.edu.au),
167      *	Ajay Bakre (bakre@paul.rutgers.edu),
168      *	Donald Becker (becker@super.org),
169      *	Jim Binkley <jrb@cs.pdx.edu>,
170      *	Loeke Brederveld <lbrederv@wavelan.com>,
171      *	Allan Creighton (allanc@cs.su.oz.au),
172      *	Brent Elphick <belphick@uwaterloo.ca>,
173      *	Joe Finney <joe@comp.lancs.ac.uk>,
174      *	Matthew Geier (matthew@cs.su.oz.au),
175      *	Remo di Giovanni (remo@cs.su.oz.au),
176      *	Mark Hagan (mhagan@wtcpost.daytonoh.NCR.COM),
177      *	David Hinds <dhinds@pcmcia.sourceforge.org>,
178      *	Jan Hoogendoorn (c/o marteijn@lucent.com),
179      *      Bruce Janson <bruce@cs.usyd.edu.au>,
180      *	Anthony D. Joseph <adj@lcs.mit.edu>,
181      *	Anders Klemets (klemets@paul.rutgers.edu),
182      *	Yunzhou Li <yunzhou@strat.iol.unh.edu>,
183      *	Marc Meertens (mmeertens@lucent.com),
184      *	Keith Moore,
185      *	Robert Morris (rtm@das.harvard.edu),
186      *	Ian Parkin (ian@cs.su.oz.au),
187      *	John Rosenberg (johnr@cs.su.oz.au),
188      *	George Rossi (george@phm.gov.au),
189      *	Arthur Scott (arthur@cs.su.oz.au),
190      *	Stanislav Sinyagin <stas@isf.ru>
191      *	Peter Storey,
192      *	Jean Tourrilhes <jt@hpl.hp.com>,
193      *	Girish Welling (welling@paul.rutgers.edu)
194      *	Clark Woodworth <clark@hiway1.exit109.com>
195      *	Yongguang Zhang <ygz@isl.hrl.hac.com>...
196      */
197     
198     /* ------------------------- IMPROVEMENTS ------------------------- */
199     /*
200      * I proudly present :
201      *
202      * Changes made in 2.8.22 :
203      * ----------------------
204      *	- improved wv_set_multicast_list
205      *	- catch spurious interrupt
206      *	- correct release of the device
207      *
208      * Changes mades in release :
209      * ------------------------
210      *	- Reorganisation of the code, function name change
211      *	- Creation of private header (wavelan_cs.h)
212      *	- Reorganised debug messages
213      *	- More comments, history, ...
214      *	- Configure earlier (in "insert" instead of "open")
215      *        and do things only once
216      *	- mmc_init : configure the PSA if not done
217      *	- mmc_init : 2.00 detection better code for 2.00 init
218      *	- better info at startup
219      *	- Correct a HUGE bug (volatile & uncalibrated busy loop)
220      *	  in wv_82593_cmd => config speedup
221      *	- Stop receiving & power down on close (and power up on open)
222      *	  use "ifconfig down" & "ifconfig up ; route add -net ..."
223      *	- Send packets : add watchdog instead of pooling
224      *	- Receive : check frame wrap around & try to recover some frames
225      *	- wavelan_set_multicast_list : avoid reset
226      *	- add wireless extensions (ioctl & get_wireless_stats)
227      *	  get/set nwid/frequency on fly, info for /proc/net/wireless
228      *	- Suppress useless stuff from lp (net_local), but add link
229      *	- More inlines
230      *	- Lot of others minor details & cleanups
231      *
232      * Changes made in second release :
233      * ------------------------------
234      *	- Optimise wv_85893_reconfig stuff, fix potential problems
235      *	- Change error values for ioctl
236      *	- Non blocking wv_ru_stop() + call wv_reset() in case of problems
237      *	- Remove development printk from wavelan_watchdog()
238      *	- Remove of the watchdog to wavelan_close instead of wavelan_release
239      *	  fix potential problems...
240      *	- Start debugging suspend stuff (but it's still a bit weird)
241      *	- Debug & optimize dump header/packet in Rx & Tx (debug)
242      *	- Use "readb" and "writeb" to be kernel 2.1 compliant
243      *	- Better handling of bogus interrupts
244      *	- Wireless extension : SETSPY and GETSPY
245      *	- Remove old stuff (stats - for those needing it, just ask me...)
246      *	- Make wireless extensions optional
247      *
248      * Changes made in third release :
249      * -----------------------------
250      *	- cleanups & typos
251      *	- modif wireless ext (spy -> only one pointer)
252      *	- new private ioctl to set/get quality & level threshold
253      *	- Init : correct default value of level threshold for pcmcia
254      *	- kill watchdog in hw_reset
255      *	- more 2.1 support (copy_to/from_user instead of memcpy_to/fromfs)
256      *	- Add message level (debug stuff in /var/adm/debug & errors not
257      *	  displayed at console and still in /var/adm/messages)
258      *
259      * Changes made in fourth release :
260      * ------------------------------
261      *	- multicast support (yes !) thanks to Yongguang Zhang.
262      *
263      * Changes made in fifth release (2.9.0) :
264      * -------------------------------------
265      *	- Revisited multicast code (it was mostly wrong).
266      *	- protect code in wv_82593_reconfig with dev->tbusy (oups !)
267      *
268      * Changes made in sixth release (2.9.1a) :
269      * --------------------------------------
270      *	- Change the detection code for multi manufacturer code support
271      *	- Correct bug (hang kernel) in init when we were "rejecting" a card 
272      *
273      * Changes made in seventh release (2.9.1b) :
274      * ----------------------------------------
275      *	- Update to wireless extensions changes
276      *	- Silly bug in card initial configuration (psa_conf_status)
277      *
278      * Changes made in eigth release :
279      * -----------------------------
280      *	- Small bug in debug code (probably not the last one...)
281      *	- 1.2.13 support (thanks to Clark Woodworth)
282      *
283      * Changes made for release in 2.9.2b :
284      * ----------------------------------
285      *	- Level threshold is now a standard wireless extension (version 4 !)
286      *	- modules parameters types for kernel > 2.1.17
287      *	- updated man page
288      *	- Others cleanup from David Hinds
289      *
290      * Changes made for release in 2.9.5 :
291      * ---------------------------------
292      *	- byte count stats (courtesy of David Hinds)
293      *	- Remove dev_tint stuff (courtesy of David Hinds)
294      *	- Others cleanup from David Hinds
295      *	- Encryption setting from Brent Elphick (thanks a lot !)
296      *	- 'base' to 'u_long' for the Alpha (thanks to Stanislav Sinyagin)
297      *
298      * Changes made for release in 2.9.6 :
299      * ---------------------------------
300      *	- fix bug : no longuer disable watchdog in case of bogus interrupt
301      *	- increase timeout in config code for picky hardware
302      *	- mask unused bits in status (Wireless Extensions)
303      *
304      * Changes integrated by Justin Seger <jseger@MIT.EDU> & David Hinds :
305      * -----------------------------------------------------------------
306      *	- Roaming "hack" from Joe Finney <joe@comp.lancs.ac.uk>
307      *	- PSA CRC code from Bob Gray <rgray@bald.cs.dartmouth.edu>
308      *	- Better initialisation of the i82593 controller
309      *	  from Joseph K. O'Sullivan <josullvn+@cs.cmu.edu>
310      *
311      * Changes made for release in 3.0.10 :
312      * ----------------------------------
313      *	- Fix eject "hang" of the driver under 2.2.X :
314      *		o create wv_flush_stale_links()
315      *		o Rename wavelan_release to wv_pcmcia_release & move up
316      *		o move unregister_netdev to wavelan_detach()
317      *		o wavelan_release() no longer call wavelan_detach()
318      *		o Suppress "release" timer
319      *		o Other cleanups & fixes
320      *	- New MAC address in the probe
321      *	- Reorg PSA_CRC code (endian neutral & cleaner)
322      *	- Correct initialisation of the i82593 from Lucent manual
323      *	- Put back the watchdog, with larger timeout
324      *	- TRANSMIT_NO_CRC is a "normal" error, so recover from it
325      *	  from Derrick J Brashear <shadow@dementia.org>
326      *	- Better handling of TX and RX normal failure conditions
327      *	- #ifdef out all the roaming code
328      *	- Add ESSID & "AP current address" ioctl stubs
329      *	- General cleanup of the code
330      *
331      * Changes made for release in 3.0.13 :
332      * ----------------------------------
333      *	- Re-enable compilation of roaming code by default, but with
334      *	  do_roaming = 0
335      *	- Nuke `nwid=nwid^ntohs(beacon->domain_id)' in wl_roam_gather
336      *	  at the demand of John Carol Langford <jcl@gs176.sp.cs.cmu.edu>
337      *	- Introduced WAVELAN_ROAMING_EXT for incomplete ESSID stuff.
338      *
339      * Changes made for release in 3.0.15 :
340      * ----------------------------------
341      *	- Change e-mail and web page addresses
342      *	- Watchdog timer is now correctly expressed in HZ, not in jiffies
343      *	- Add channel number to the list of frequencies in range
344      *	- Add the (short) list of bit-rates in range
345      *	- Developp a new sensitivity... (sens.value & sens.fixed)
346      *
347      * Changes made for release in 3.1.2 :
348      * ---------------------------------
349      *	- Fix check for root permission (break instead of exit)
350      *	- New nwid & encoding setting (Wireless Extension 9)
351      *
352      * Wishes & dreams:
353      * ----------------
354      *	- Cleanup and integrate the roaming code
355      *	  (std debug, set DomainID, decay avg and co...)
356      */
357     
358     /***************************** INCLUDES *****************************/
359     
360     /* Linux headers that we need */
361     #include <linux/config.h>
362     #include <linux/module.h>
363     #include <linux/kernel.h>
364     #include <linux/init.h>
365     #include <linux/sched.h>
366     #include <linux/ptrace.h>
367     #include <linux/slab.h>
368     #include <linux/string.h>
369     #include <linux/timer.h>
370     #include <linux/interrupt.h>
371     #include <linux/in.h>
372     #include <linux/delay.h>
373     #include <asm/uaccess.h>
374     #include <asm/io.h>
375     #include <asm/system.h>
376     #include <asm/bitops.h>
377     
378     #include <linux/netdevice.h>
379     #include <linux/etherdevice.h>
380     #include <linux/skbuff.h>
381     #include <linux/if_arp.h>
382     #include <linux/ioport.h>
383     #include <linux/fcntl.h>
384     
385     #ifdef CONFIG_NET_PCMCIA_RADIO
386     #include <linux/wireless.h>		/* Wireless extensions */
387     #endif	/* CONFIG_NET_PCMCIA_RADIO */
388     
389     /* Pcmcia headers that we need */
390     #include <pcmcia/cs_types.h>
391     #include <pcmcia/cs.h>
392     #include <pcmcia/cistpl.h>
393     #include <pcmcia/cisreg.h>
394     #include <pcmcia/ds.h>
395     #include <pcmcia/version.h>
396     
397     /* Wavelan declarations */
398     #include "i82593.h"	/* Definitions for the Intel chip */
399     
400     #include "wavelan.h"	/* Others bits of the hardware */
401     
402     /************************** DRIVER OPTIONS **************************/
403     /*
404      * `#define' or `#undef' the following constant to change the behaviour
405      * of the driver...
406      */
407     #define WAVELAN_ROAMING		/* Include experimental roaming code */
408     #undef WAVELAN_ROAMING_EXT	/* Enable roaming wireless extensions */
409     #undef SET_PSA_CRC		/* Set the CRC in PSA (slower) */
410     #define USE_PSA_CONFIG		/* Use info from the PSA */
411     #undef STRUCT_CHECK		/* Verify padding of structures */
412     #undef EEPROM_IS_PROTECTED	/* Doesn't seem to be necessary */
413     #define MULTICAST_AVOID		/* Avoid extra multicast (I'm sceptical) */
414     #undef SET_MAC_ADDRESS		/* Experimental */
415     
416     #ifdef WIRELESS_EXT	/* If wireless extension exist in the kernel */
417     /* Warning : these stuff will slow down the driver... */
418     #define WIRELESS_SPY		/* Enable spying addresses */
419     #undef HISTOGRAM		/* Enable histogram of sig level... */
420     #endif
421     
422     /****************************** DEBUG ******************************/
423     
424     #undef DEBUG_MODULE_TRACE	/* Module insertion/removal */
425     #undef DEBUG_CALLBACK_TRACE	/* Calls made by Linux */
426     #undef DEBUG_INTERRUPT_TRACE	/* Calls to handler */
427     #undef DEBUG_INTERRUPT_INFO	/* type of interrupt & so on */
428     #define DEBUG_INTERRUPT_ERROR	/* problems */
429     #undef DEBUG_CONFIG_TRACE	/* Trace the config functions */
430     #undef DEBUG_CONFIG_INFO	/* What's going on... */
431     #define DEBUG_CONFIG_ERRORS	/* Errors on configuration */
432     #undef DEBUG_TX_TRACE		/* Transmission calls */
433     #undef DEBUG_TX_INFO		/* Header of the transmitted packet */
434     #undef DEBUG_TX_FAIL		/* Normal failure conditions */
435     #define DEBUG_TX_ERROR		/* Unexpected conditions */
436     #undef DEBUG_RX_TRACE		/* Transmission calls */
437     #undef DEBUG_RX_INFO		/* Header of the transmitted packet */
438     #undef DEBUG_RX_FAIL		/* Normal failure conditions */
439     #define DEBUG_RX_ERROR		/* Unexpected conditions */
440     #undef DEBUG_PACKET_DUMP	/* Dump packet on the screen */
441     #undef DEBUG_IOCTL_TRACE	/* Misc call by Linux */
442     #undef DEBUG_IOCTL_INFO		/* Various debug info */
443     #define DEBUG_IOCTL_ERROR	/* What's going wrong */
444     #define DEBUG_BASIC_SHOW	/* Show basic startup info */
445     #undef DEBUG_VERSION_SHOW	/* Print version info */
446     #undef DEBUG_PSA_SHOW		/* Dump psa to screen */
447     #undef DEBUG_MMC_SHOW		/* Dump mmc to screen */
448     #undef DEBUG_SHOW_UNUSED	/* Show also unused fields */
449     #undef DEBUG_I82593_SHOW	/* Show i82593 status */
450     #undef DEBUG_DEVICE_SHOW	/* Show device parameters */
451     
452     /************************ CONSTANTS & MACROS ************************/
453     
454     #ifdef DEBUG_VERSION_SHOW
455     static const char *version = "wavelan_cs.c : v21 (wireless extensions) 18/10/99\n";
456     #endif
457     
458     /* Watchdog temporisation */
459     #define	WATCHDOG_JIFFIES	(256*HZ/100)
460     
461     /* Fix a bug in some old wireless extension definitions */
462     #ifndef IW_ESSID_MAX_SIZE
463     #define IW_ESSID_MAX_SIZE	32
464     #endif
465     
466     /* ------------------------ PRIVATE IOCTL ------------------------ */
467     
468     #define SIOCSIPQTHR	SIOCDEVPRIVATE		/* Set quality threshold */
469     #define SIOCGIPQTHR	SIOCDEVPRIVATE + 1	/* Get quality threshold */
470     #define SIOCSIPROAM     SIOCDEVPRIVATE + 2      /* Set roaming state */
471     #define SIOCGIPROAM     SIOCDEVPRIVATE + 3      /* Get roaming state */
472     
473     #define SIOCSIPHISTO	SIOCDEVPRIVATE + 6	/* Set histogram ranges */
474     #define SIOCGIPHISTO	SIOCDEVPRIVATE + 7	/* Get histogram values */
475     
476     /*************************** WaveLAN Roaming  **************************/
477     #ifdef WAVELAN_ROAMING		/* Conditional compile, see above in options */
478     
479     #define WAVELAN_ROAMING_DEBUG	 0	/* 1 = Trace of handover decisions */
480     					/* 2 = Info on each beacon rcvd... */
481     #define MAX_WAVEPOINTS		7	/* Max visible at one time */
482     #define WAVEPOINT_HISTORY	5	/* SNR sample history slow search */
483     #define WAVEPOINT_FAST_HISTORY	2	/* SNR sample history fast search */
484     #define SEARCH_THRESH_LOW	10	/* SNR to enter cell search */
485     #define SEARCH_THRESH_HIGH	13	/* SNR to leave cell search */
486     #define WAVELAN_ROAMING_DELTA	1	/* Hysteresis value (+/- SNR) */
487     #define CELL_TIMEOUT		2*HZ	/* in jiffies */
488     
489     #define FAST_CELL_SEARCH	1	/* Boolean values... */
490     #define NWID_PROMISC		1	/* for code clarity. */
491     
492     typedef struct wavepoint_beacon
493     {
494       unsigned char		dsap,		/* Unused */
495     			ssap,		/* Unused */
496     			ctrl,		/* Unused */
497     			O,U,I,		/* Unused */
498     			spec_id1,	/* Unused */
499     			spec_id2,	/* Unused */
500     			pdu_type,	/* Unused */
501     			seq;		/* WavePoint beacon sequence number */
502       unsigned short	domain_id,	/* WavePoint Domain ID */
503     			nwid;		/* WavePoint NWID */
504     } wavepoint_beacon;
505     
506     typedef struct wavepoint_history
507     {
508       unsigned short	nwid;		/* WavePoint's NWID */
509       int			average_slow;	/* SNR running average */
510       int			average_fast;	/* SNR running average */
511       unsigned char	  sigqual[WAVEPOINT_HISTORY]; /* Ringbuffer of recent SNR's */
512       unsigned char		qualptr;	/* Index into ringbuffer */
513       unsigned char		last_seq;	/* Last seq. no seen for WavePoint */
514       struct wavepoint_history *next;	/* Next WavePoint in table */
515       struct wavepoint_history *prev;	/* Previous WavePoint in table */
516       unsigned long		last_seen;	/* Time of last beacon recvd, jiffies */
517     } wavepoint_history;
518     
519     struct wavepoint_table
520     {
521       wavepoint_history	*head;		/* Start of ringbuffer */
522       int			num_wavepoints;	/* No. of WavePoints visible */
523       unsigned char		locked;		/* Table lock */
524     };
525     
526     #endif	/* WAVELAN_ROAMING */
527     
528     /****************************** TYPES ******************************/
529     
530     /* Shortcuts */
531     typedef struct net_device	device;
532     typedef struct net_device_stats	en_stats;
533     typedef struct iw_statistics	iw_stats;
534     typedef struct iw_quality	iw_qual;
535     typedef struct iw_freq		iw_freq;
536     typedef struct net_local	net_local;
537     typedef struct timer_list	timer_list;
538     
539     /* Basic types */
540     typedef u_char		mac_addr[WAVELAN_ADDR_SIZE];	/* Hardware address */
541     
542     /*
543      * Static specific data for the interface.
544      *
545      * For each network interface, Linux keep data in two structure. "device"
546      * keep the generic data (same format for everybody) and "net_local" keep
547      * the additional specific data.
548      * Note that some of this specific data is in fact generic (en_stats, for
549      * example).
550      */
551     struct net_local
552     {
553       spinlock_t	lock;
554       dev_node_t 	node;		/* ???? What is this stuff ???? */
555       device *	dev;		/* Reverse link... */
556       dev_link_t *	link;		/* pcmcia structure */
557       en_stats	stats;		/* Ethernet interface statistics */
558       int		nresets;	/* Number of hw resets */
559       u_char	configured;	/* If it is configured */
560       u_char	reconfig_82593;	/* Need to reconfigure the controller */
561       u_char	promiscuous;	/* Promiscuous mode */
562       u_char	allmulticast;	/* All Multicast mode */
563       int		mc_count;	/* Number of multicast addresses */
564       timer_list	watchdog;	/* To avoid blocking state */
565     
566       u_char        status;		/* Current i82593 status */
567       int   	stop;		/* Current i82593 Stop Hit Register */
568       int   	rfp;		/* Last DMA machine receive pointer */
569       int		overrunning;	/* Receiver overrun flag */
570     
571     #ifdef WIRELESS_EXT
572       iw_stats	wstats;		/* Wireless specific stats */
573     #endif
574     
575     #ifdef WIRELESS_SPY
576       int		spy_number;		/* Number of addresses to spy */
577       mac_addr	spy_address[IW_MAX_SPY];	/* The addresses to spy */
578       iw_qual	spy_stat[IW_MAX_SPY];		/* Statistics gathered */
579     #endif	/* WIRELESS_SPY */
580     #ifdef HISTOGRAM
581       int		his_number;		/* Number of intervals */
582       u_char	his_range[16];		/* Boundaries of interval ]n-1; n] */
583       u_long	his_sum[16];		/* Sum in interval */
584     #endif	/* HISTOGRAM */
585     #ifdef WAVELAN_ROAMING
586       u_long	domain_id;	/* Domain ID we lock on for roaming */
587       int		filter_domains;	/* Check Domain ID of beacon found */
588      struct wavepoint_table	wavepoint_table;	/* Table of visible WavePoints*/
589       wavepoint_history *	curr_point;		/* Current wavepoint */
590       int			cell_search;		/* Searching for new cell? */
591       struct timer_list	cell_timer;		/* Garbage collection */
592     #endif	/* WAVELAN_ROAMING */
593     };
594     
595     /**************************** PROTOTYPES ****************************/
596     
597     #ifdef WAVELAN_ROAMING
598     /* ---------------------- ROAMING SUBROUTINES -----------------------*/
599     
600     wavepoint_history *wl_roam_check(unsigned short nwid, net_local *lp);
601     wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char seq, net_local *lp);
602     void wl_del_wavepoint(wavepoint_history *wavepoint, net_local *lp);
603     void wl_cell_expiry(unsigned long data);
604     wavepoint_history *wl_best_sigqual(int fast_search, net_local *lp);
605     void wl_update_history(wavepoint_history *wavepoint, unsigned char sigqual, unsigned char seq);
606     void wv_roam_handover(wavepoint_history *wavepoint, net_local *lp);
607     void wv_nwid_filter(unsigned char mode, net_local *lp);
608     void wv_roam_init(struct net_device *dev);
609     void wv_roam_cleanup(struct net_device *dev);
610     #endif	/* WAVELAN_ROAMING */
611     
612     /* ----------------------- MISC SUBROUTINES ------------------------ */
613     static void
614     	cs_error(client_handle_t, /* Report error to cardmgr */
615     		 int,
616     		 int);
617     /* ----------------- MODEM MANAGEMENT SUBROUTINES ----------------- */
618     static inline u_char		/* data */
619     	hasr_read(u_long);	/* Read the host interface : base address */
620     static inline void
621     	hacr_write(u_long,	/* Write to host interface : base address */
622     		   u_char),	/* data */
623     	hacr_write_slow(u_long,
624     		   u_char);
625     static void
626     	psa_read(device *,	/* Read the Parameter Storage Area */
627     		 int,		/* offset in PSA */
628     		 u_char *,	/* buffer to fill */
629     		 int),		/* size to read */
630     	psa_write(device *,	/* Write to the PSA */
631     		  int,		/* Offset in psa */
632     		  u_char *,	/* Buffer in memory */
633     		  int);		/* Length of buffer */
634     static inline void
635     	mmc_out(u_long,		/* Write 1 byte to the Modem Manag Control */
636     		u_short,
637     		u_char),
638     	mmc_write(u_long,	/* Write n bytes to the MMC */
639     		  u_char,
640     		  u_char *,
641     		  int);
642     static inline u_char		/* Read 1 byte from the MMC */
643     	mmc_in(u_long,
644     	       u_short);
645     static inline void
646     	mmc_read(u_long,	/* Read n bytes from the MMC */
647     		 u_char,
648     		 u_char *,
649     		 int),
650     	fee_wait(u_long,	/* Wait for frequency EEprom : base address */
651     		 int,		/* Base delay to wait for */
652     		 int);		/* Number of time to wait */
653     static void
654     	fee_read(u_long,	/* Read the frequency EEprom : base address */
655     		 u_short,	/* destination offset */
656     		 u_short *,	/* data buffer */
657     		 int);		/* number of registers */
658     /* ---------------------- I82593 SUBROUTINES ----------------------- */
659     static int
660     	wv_82593_cmd(device *,	/* synchronously send a command to i82593 */ 
661     		     char *,
662     		     int,
663     		     int);
664     static inline int
665     	wv_diag(device *);	/* Diagnostique the i82593 */
666     static int
667     	read_ringbuf(device *,	/* Read a receive buffer */
668     		     int,
669     		     char *,
670     		     int);
671     static inline void
672     	wv_82593_reconfig(device *);	/* Reconfigure the controller */
673     /* ------------------- DEBUG & INFO SUBROUTINES ------------------- */
674     static inline void
675     	wv_init_info(device *);	/* display startup info */
676     /* ------------------- IOCTL, STATS & RECONFIG ------------------- */
677     static en_stats	*
678     	wavelan_get_stats(device *);	/* Give stats /proc/net/dev */
679     /* ----------------------- PACKET RECEPTION ----------------------- */
680     static inline int
681     	wv_start_of_frame(device *,	/* Seek beggining of current frame */
682     			  int,	/* end of frame */
683     			  int);	/* start of buffer */
684     static inline void
685     	wv_packet_read(device *,	/* Read a packet from a frame */
686     		       int,
687     		       int),
688     	wv_packet_rcv(device *);	/* Read all packets waiting */
689     /* --------------------- PACKET TRANSMISSION --------------------- */
690     static inline void
691     	wv_packet_write(device *,	/* Write a packet to the Tx buffer */
692     			void *,
693     			short);
694     static int
695     	wavelan_packet_xmit(struct sk_buff *,	/* Send a packet */
696     			    device *);
697     /* -------------------- HARDWARE CONFIGURATION -------------------- */
698     static inline int
699     	wv_mmc_init(device *);	/* Initialize the modem */
700     static int
701     	wv_ru_stop(device *),	/* Stop the i82593 receiver unit */
702     	wv_ru_start(device *);	/* Start the i82593 receiver unit */
703     static int
704     	wv_82593_config(device *);	/* Configure the i82593 */
705     static inline int
706     	wv_pcmcia_reset(device *);	/* Reset the pcmcia interface */
707     static int
708     	wv_hw_config(device *);	/* Reset & configure the whole hardware */
709     static inline void
710     	wv_hw_reset(device *);	/* Same, + start receiver unit */
711     static inline int
712     	wv_pcmcia_config(dev_link_t *);	/* Configure the pcmcia interface */
713     static void
714     	wv_pcmcia_release(u_long),	/* Remove a device */
715     	wv_flush_stale_links(void);	/* "detach" all possible devices */
716     /* ---------------------- INTERRUPT HANDLING ---------------------- */
717     static void
718     wavelan_interrupt(int,	/* Interrupt handler */
719     		  void *,
720     		  struct pt_regs *);
721     static void
722     	wavelan_watchdog(u_long);	/* Transmission watchdog */
723     /* ------------------- CONFIGURATION CALLBACKS ------------------- */
724     static int
725     	wavelan_open(device *),		/* Open the device */
726     	wavelan_close(device *),	/* Close the device */
727     	wavelan_init(device *);		/* Do nothing */
728     static dev_link_t *
729     	wavelan_attach(void);		/* Create a new device */
730     static void
731     	wavelan_detach(dev_link_t *);	/* Destroy a removed device */
732     static int
733     	wavelan_event(event_t,		/* Manage pcmcia events */
734     		      int,
735     		      event_callback_args_t *);
736     
737     /**************************** VARIABLES ****************************/
738     
739     static dev_info_t dev_info = "wavelan_cs";
740     static dev_link_t *dev_list;		/* Linked list of devices */
741     
742     /* WARNING : the following variable MUST be volatile
743      * It is used by wv_82593_cmd to syncronise with wavelan_interrupt */ 
744     static volatile int	wv_wait_completed;
745     
746     /*
747      * Parameters that can be set with 'insmod'
748      * The exact syntax is 'insmod wavelan_cs.o <var>=<value>'
749      */
750     
751     /* Bit map of interrupts to choose from */
752     /* This means pick from 15, 14, 12, 11, 10, 9, 7, 5, 4 and 3 */
753     static int	irq_mask = 0xdeb8;
754     static int 	irq_list[4] = { -1 };
755     
756     /* Shared memory speed, in ns */
757     static int	mem_speed;
758     
759     /* New module interface */
760     MODULE_PARM(irq_mask, "i");
761     MODULE_PARM(irq_list, "1-4i");
762     MODULE_PARM(mem_speed, "i");
763     
764     #ifdef WAVELAN_ROAMING		/* Conditional compile, see above in options */
765     /* Enable roaming mode ? No ! Please keep this to 0 */
766     static int	do_roaming;
767     MODULE_PARM(do_roaming, "i");
768     #endif	/* WAVELAN_ROAMING */
769     
770     #endif	/* WAVELAN_CS_H */
771     
772