wavelan.p.h 25 KB

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