wavelan_cs.p.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  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. * writting 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/config.h>
  404. #include <linux/module.h>
  405. #include <linux/kernel.h>
  406. #include <linux/init.h>
  407. #include <linux/sched.h>
  408. #include <linux/ptrace.h>
  409. #include <linux/slab.h>
  410. #include <linux/string.h>
  411. #include <linux/timer.h>
  412. #include <linux/interrupt.h>
  413. #include <linux/spinlock.h>
  414. #include <linux/in.h>
  415. #include <linux/delay.h>
  416. #include <linux/bitops.h>
  417. #include <asm/uaccess.h>
  418. #include <asm/io.h>
  419. #include <asm/system.h>
  420. #include <linux/netdevice.h>
  421. #include <linux/etherdevice.h>
  422. #include <linux/skbuff.h>
  423. #include <linux/if_arp.h>
  424. #include <linux/ioport.h>
  425. #include <linux/fcntl.h>
  426. #include <linux/ethtool.h>
  427. #include <linux/wireless.h> /* Wireless extensions */
  428. #include <net/iw_handler.h> /* New driver API */
  429. /* Pcmcia headers that we need */
  430. #include <pcmcia/cs_types.h>
  431. #include <pcmcia/cs.h>
  432. #include <pcmcia/cistpl.h>
  433. #include <pcmcia/cisreg.h>
  434. #include <pcmcia/ds.h>
  435. /* Wavelan declarations */
  436. #include "i82593.h" /* Definitions for the Intel chip */
  437. #include "wavelan_cs.h" /* Others bits of the hardware */
  438. /************************** DRIVER OPTIONS **************************/
  439. /*
  440. * `#define' or `#undef' the following constant to change the behaviour
  441. * of the driver...
  442. */
  443. #define WAVELAN_ROAMING /* Include experimental roaming code */
  444. #undef WAVELAN_ROAMING_EXT /* Enable roaming wireless extensions */
  445. #undef SET_PSA_CRC /* Set the CRC in PSA (slower) */
  446. #define USE_PSA_CONFIG /* Use info from the PSA */
  447. #undef STRUCT_CHECK /* Verify padding of structures */
  448. #undef EEPROM_IS_PROTECTED /* Doesn't seem to be necessary */
  449. #define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical) */
  450. #undef SET_MAC_ADDRESS /* Experimental */
  451. /* Warning : these stuff will slow down the driver... */
  452. #define WIRELESS_SPY /* Enable spying addresses */
  453. #undef HISTOGRAM /* Enable histogram of sig level... */
  454. /****************************** DEBUG ******************************/
  455. #undef DEBUG_MODULE_TRACE /* Module insertion/removal */
  456. #undef DEBUG_CALLBACK_TRACE /* Calls made by Linux */
  457. #undef DEBUG_INTERRUPT_TRACE /* Calls to handler */
  458. #undef DEBUG_INTERRUPT_INFO /* type of interrupt & so on */
  459. #define DEBUG_INTERRUPT_ERROR /* problems */
  460. #undef DEBUG_CONFIG_TRACE /* Trace the config functions */
  461. #undef DEBUG_CONFIG_INFO /* What's going on... */
  462. #define DEBUG_CONFIG_ERRORS /* Errors on configuration */
  463. #undef DEBUG_TX_TRACE /* Transmission calls */
  464. #undef DEBUG_TX_INFO /* Header of the transmitted packet */
  465. #undef DEBUG_TX_FAIL /* Normal failure conditions */
  466. #define DEBUG_TX_ERROR /* Unexpected conditions */
  467. #undef DEBUG_RX_TRACE /* Transmission calls */
  468. #undef DEBUG_RX_INFO /* Header of the transmitted packet */
  469. #undef DEBUG_RX_FAIL /* Normal failure conditions */
  470. #define DEBUG_RX_ERROR /* Unexpected conditions */
  471. #undef DEBUG_PACKET_DUMP /* Dump packet on the screen */
  472. #undef DEBUG_IOCTL_TRACE /* Misc call by Linux */
  473. #undef DEBUG_IOCTL_INFO /* Various debug info */
  474. #define DEBUG_IOCTL_ERROR /* What's going wrong */
  475. #define DEBUG_BASIC_SHOW /* Show basic startup info */
  476. #undef DEBUG_VERSION_SHOW /* Print version info */
  477. #undef DEBUG_PSA_SHOW /* Dump psa to screen */
  478. #undef DEBUG_MMC_SHOW /* Dump mmc to screen */
  479. #undef DEBUG_SHOW_UNUSED /* Show also unused fields */
  480. #undef DEBUG_I82593_SHOW /* Show i82593 status */
  481. #undef DEBUG_DEVICE_SHOW /* Show device parameters */
  482. /************************ CONSTANTS & MACROS ************************/
  483. #ifdef DEBUG_VERSION_SHOW
  484. static const char *version = "wavelan_cs.c : v24 (SMP + wireless extensions) 11/1/02\n";
  485. #endif
  486. /* Watchdog temporisation */
  487. #define WATCHDOG_JIFFIES (256*HZ/100)
  488. /* Fix a bug in some old wireless extension definitions */
  489. #ifndef IW_ESSID_MAX_SIZE
  490. #define IW_ESSID_MAX_SIZE 32
  491. #endif
  492. /* ------------------------ PRIVATE IOCTL ------------------------ */
  493. #define SIOCSIPQTHR SIOCIWFIRSTPRIV /* Set quality threshold */
  494. #define SIOCGIPQTHR SIOCIWFIRSTPRIV + 1 /* Get quality threshold */
  495. #define SIOCSIPROAM SIOCIWFIRSTPRIV + 2 /* Set roaming state */
  496. #define SIOCGIPROAM SIOCIWFIRSTPRIV + 3 /* Get roaming state */
  497. #define SIOCSIPHISTO SIOCIWFIRSTPRIV + 4 /* Set histogram ranges */
  498. #define SIOCGIPHISTO SIOCIWFIRSTPRIV + 5 /* Get histogram values */
  499. /*************************** WaveLAN Roaming **************************/
  500. #ifdef WAVELAN_ROAMING /* Conditional compile, see above in options */
  501. #define WAVELAN_ROAMING_DEBUG 0 /* 1 = Trace of handover decisions */
  502. /* 2 = Info on each beacon rcvd... */
  503. #define MAX_WAVEPOINTS 7 /* Max visible at one time */
  504. #define WAVEPOINT_HISTORY 5 /* SNR sample history slow search */
  505. #define WAVEPOINT_FAST_HISTORY 2 /* SNR sample history fast search */
  506. #define SEARCH_THRESH_LOW 10 /* SNR to enter cell search */
  507. #define SEARCH_THRESH_HIGH 13 /* SNR to leave cell search */
  508. #define WAVELAN_ROAMING_DELTA 1 /* Hysteresis value (+/- SNR) */
  509. #define CELL_TIMEOUT 2*HZ /* in jiffies */
  510. #define FAST_CELL_SEARCH 1 /* Boolean values... */
  511. #define NWID_PROMISC 1 /* for code clarity. */
  512. typedef struct wavepoint_beacon
  513. {
  514. unsigned char dsap, /* Unused */
  515. ssap, /* Unused */
  516. ctrl, /* Unused */
  517. O,U,I, /* Unused */
  518. spec_id1, /* Unused */
  519. spec_id2, /* Unused */
  520. pdu_type, /* Unused */
  521. seq; /* WavePoint beacon sequence number */
  522. unsigned short domain_id, /* WavePoint Domain ID */
  523. nwid; /* WavePoint NWID */
  524. } wavepoint_beacon;
  525. typedef struct wavepoint_history
  526. {
  527. unsigned short nwid; /* WavePoint's NWID */
  528. int average_slow; /* SNR running average */
  529. int average_fast; /* SNR running average */
  530. unsigned char sigqual[WAVEPOINT_HISTORY]; /* Ringbuffer of recent SNR's */
  531. unsigned char qualptr; /* Index into ringbuffer */
  532. unsigned char last_seq; /* Last seq. no seen for WavePoint */
  533. struct wavepoint_history *next; /* Next WavePoint in table */
  534. struct wavepoint_history *prev; /* Previous WavePoint in table */
  535. unsigned long last_seen; /* Time of last beacon recvd, jiffies */
  536. } wavepoint_history;
  537. struct wavepoint_table
  538. {
  539. wavepoint_history *head; /* Start of ringbuffer */
  540. int num_wavepoints; /* No. of WavePoints visible */
  541. unsigned char locked; /* Table lock */
  542. };
  543. #endif /* WAVELAN_ROAMING */
  544. /****************************** TYPES ******************************/
  545. /* Shortcuts */
  546. typedef struct net_device_stats en_stats;
  547. typedef struct iw_statistics iw_stats;
  548. typedef struct iw_quality iw_qual;
  549. typedef struct iw_freq iw_freq;
  550. typedef struct net_local net_local;
  551. typedef struct timer_list timer_list;
  552. /* Basic types */
  553. typedef u_char mac_addr[WAVELAN_ADDR_SIZE]; /* Hardware address */
  554. /*
  555. * Static specific data for the interface.
  556. *
  557. * For each network interface, Linux keep data in two structure. "device"
  558. * keep the generic data (same format for everybody) and "net_local" keep
  559. * the additional specific data.
  560. * Note that some of this specific data is in fact generic (en_stats, for
  561. * example).
  562. */
  563. struct net_local
  564. {
  565. dev_node_t node; /* ???? What is this stuff ???? */
  566. struct net_device * dev; /* Reverse link... */
  567. spinlock_t spinlock; /* Serialize access to the hardware (SMP) */
  568. struct pcmcia_device * link; /* pcmcia structure */
  569. en_stats stats; /* Ethernet interface statistics */
  570. int nresets; /* Number of hw resets */
  571. u_char configured; /* If it is configured */
  572. u_char reconfig_82593; /* Need to reconfigure the controller */
  573. u_char promiscuous; /* Promiscuous mode */
  574. u_char allmulticast; /* All Multicast mode */
  575. int mc_count; /* Number of multicast addresses */
  576. int stop; /* Current i82593 Stop Hit Register */
  577. int rfp; /* Last DMA machine receive pointer */
  578. int overrunning; /* Receiver overrun flag */
  579. iw_stats wstats; /* Wireless specific stats */
  580. struct iw_spy_data spy_data;
  581. struct iw_public_data wireless_data;
  582. #ifdef HISTOGRAM
  583. int his_number; /* Number of intervals */
  584. u_char his_range[16]; /* Boundaries of interval ]n-1; n] */
  585. u_long his_sum[16]; /* Sum in interval */
  586. #endif /* HISTOGRAM */
  587. #ifdef WAVELAN_ROAMING
  588. u_long domain_id; /* Domain ID we lock on for roaming */
  589. int filter_domains; /* Check Domain ID of beacon found */
  590. struct wavepoint_table wavepoint_table; /* Table of visible WavePoints*/
  591. wavepoint_history * curr_point; /* Current wavepoint */
  592. int cell_search; /* Searching for new cell? */
  593. struct timer_list cell_timer; /* Garbage collection */
  594. #endif /* WAVELAN_ROAMING */
  595. void __iomem *mem;
  596. };
  597. /* ----------------- MODEM MANAGEMENT SUBROUTINES ----------------- */
  598. static inline u_char /* data */
  599. hasr_read(u_long); /* Read the host interface : base address */
  600. static inline void
  601. hacr_write(u_long, /* Write to host interface : base address */
  602. u_char), /* data */
  603. hacr_write_slow(u_long,
  604. u_char);
  605. static void
  606. psa_read(struct net_device *, /* Read the Parameter Storage Area */
  607. int, /* offset in PSA */
  608. u_char *, /* buffer to fill */
  609. int), /* size to read */
  610. psa_write(struct net_device *, /* Write to the PSA */
  611. int, /* Offset in psa */
  612. u_char *, /* Buffer in memory */
  613. int); /* Length of buffer */
  614. static inline void
  615. mmc_out(u_long, /* Write 1 byte to the Modem Manag Control */
  616. u_short,
  617. u_char),
  618. mmc_write(u_long, /* Write n bytes to the MMC */
  619. u_char,
  620. u_char *,
  621. int);
  622. static inline u_char /* Read 1 byte from the MMC */
  623. mmc_in(u_long,
  624. u_short);
  625. static inline void
  626. mmc_read(u_long, /* Read n bytes from the MMC */
  627. u_char,
  628. u_char *,
  629. int),
  630. fee_wait(u_long, /* Wait for frequency EEprom : base address */
  631. int, /* Base delay to wait for */
  632. int); /* Number of time to wait */
  633. static void
  634. fee_read(u_long, /* Read the frequency EEprom : base address */
  635. u_short, /* destination offset */
  636. u_short *, /* data buffer */
  637. int); /* number of registers */
  638. /* ---------------------- I82593 SUBROUTINES ----------------------- */
  639. static int
  640. wv_82593_cmd(struct net_device *, /* synchronously send a command to i82593 */
  641. char *,
  642. int,
  643. int);
  644. static inline int
  645. wv_diag(struct net_device *); /* Diagnostique the i82593 */
  646. static int
  647. read_ringbuf(struct net_device *, /* Read a receive buffer */
  648. int,
  649. char *,
  650. int);
  651. static inline void
  652. wv_82593_reconfig(struct net_device *); /* Reconfigure the controller */
  653. /* ------------------- DEBUG & INFO SUBROUTINES ------------------- */
  654. static inline void
  655. wv_init_info(struct net_device *); /* display startup info */
  656. /* ------------------- IOCTL, STATS & RECONFIG ------------------- */
  657. static en_stats *
  658. wavelan_get_stats(struct net_device *); /* Give stats /proc/net/dev */
  659. static iw_stats *
  660. wavelan_get_wireless_stats(struct net_device *);
  661. /* ----------------------- PACKET RECEPTION ----------------------- */
  662. static inline int
  663. wv_start_of_frame(struct net_device *, /* Seek beggining of current frame */
  664. int, /* end of frame */
  665. int); /* start of buffer */
  666. static inline void
  667. wv_packet_read(struct net_device *, /* Read a packet from a frame */
  668. int,
  669. int),
  670. wv_packet_rcv(struct net_device *); /* Read all packets waiting */
  671. /* --------------------- PACKET TRANSMISSION --------------------- */
  672. static inline void
  673. wv_packet_write(struct net_device *, /* Write a packet to the Tx buffer */
  674. void *,
  675. short);
  676. static int
  677. wavelan_packet_xmit(struct sk_buff *, /* Send a packet */
  678. struct net_device *);
  679. /* -------------------- HARDWARE CONFIGURATION -------------------- */
  680. static inline int
  681. wv_mmc_init(struct net_device *); /* Initialize the modem */
  682. static int
  683. wv_ru_stop(struct net_device *), /* Stop the i82593 receiver unit */
  684. wv_ru_start(struct net_device *); /* Start the i82593 receiver unit */
  685. static int
  686. wv_82593_config(struct net_device *); /* Configure the i82593 */
  687. static inline int
  688. wv_pcmcia_reset(struct net_device *); /* Reset the pcmcia interface */
  689. static int
  690. wv_hw_config(struct net_device *); /* Reset & configure the whole hardware */
  691. static inline void
  692. wv_hw_reset(struct net_device *); /* Same, + start receiver unit */
  693. static inline int
  694. wv_pcmcia_config(struct pcmcia_device *); /* Configure the pcmcia interface */
  695. static void
  696. wv_pcmcia_release(struct pcmcia_device *);/* Remove a device */
  697. /* ---------------------- INTERRUPT HANDLING ---------------------- */
  698. static irqreturn_t
  699. wavelan_interrupt(int, /* Interrupt handler */
  700. void *,
  701. struct pt_regs *);
  702. static void
  703. wavelan_watchdog(struct net_device *); /* Transmission watchdog */
  704. /* ------------------- CONFIGURATION CALLBACKS ------------------- */
  705. static int
  706. wavelan_open(struct net_device *), /* Open the device */
  707. wavelan_close(struct net_device *); /* Close the device */
  708. static void
  709. wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */
  710. /**************************** VARIABLES ****************************/
  711. /*
  712. * Parameters that can be set with 'insmod'
  713. * The exact syntax is 'insmod wavelan_cs.o <var>=<value>'
  714. */
  715. /* Shared memory speed, in ns */
  716. static int mem_speed = 0;
  717. /* New module interface */
  718. module_param(mem_speed, int, 0);
  719. #ifdef WAVELAN_ROAMING /* Conditional compile, see above in options */
  720. /* Enable roaming mode ? No ! Please keep this to 0 */
  721. static int do_roaming = 0;
  722. module_param(do_roaming, bool, 0);
  723. #endif /* WAVELAN_ROAMING */
  724. MODULE_LICENSE("GPL");
  725. #endif /* WAVELAN_CS_P_H */