wavelan_cs.p.h 29 KB

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