wavelan.p.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:26k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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