wavelan_cs.p.h 30 KB

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