wavelan.c 122 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444
  1. /*
  2. * WaveLAN ISA driver
  3. *
  4. * Jean II - HPLB '96
  5. *
  6. * Reorganisation and extension of the driver.
  7. * Original copyright follows (also see the end of this file).
  8. * See wavelan.p.h for details.
  9. *
  10. *
  11. *
  12. * AT&T GIS (nee NCR) WaveLAN card:
  13. * An Ethernet-like radio transceiver
  14. * controlled by an Intel 82586 coprocessor.
  15. */
  16. #include "wavelan.p.h" /* Private header */
  17. /************************* MISC SUBROUTINES **************************/
  18. /*
  19. * Subroutines which won't fit in one of the following category
  20. * (WaveLAN modem or i82586)
  21. */
  22. /*------------------------------------------------------------------*/
  23. /*
  24. * Translate irq number to PSA irq parameter
  25. */
  26. static u8 wv_irq_to_psa(int irq)
  27. {
  28. if (irq < 0 || irq >= NELS(irqvals))
  29. return 0;
  30. return irqvals[irq];
  31. }
  32. /*------------------------------------------------------------------*/
  33. /*
  34. * Translate PSA irq parameter to irq number
  35. */
  36. static int __init wv_psa_to_irq(u8 irqval)
  37. {
  38. int irq;
  39. for (irq = 0; irq < NELS(irqvals); irq++)
  40. if (irqvals[irq] == irqval)
  41. return irq;
  42. return -1;
  43. }
  44. #ifdef STRUCT_CHECK
  45. /*------------------------------------------------------------------*/
  46. /*
  47. * Sanity routine to verify the sizes of the various WaveLAN interface
  48. * structures.
  49. */
  50. static char *wv_struct_check(void)
  51. {
  52. #define SC(t,s,n) if (sizeof(t) != s) return(n);
  53. SC(psa_t, PSA_SIZE, "psa_t");
  54. SC(mmw_t, MMW_SIZE, "mmw_t");
  55. SC(mmr_t, MMR_SIZE, "mmr_t");
  56. SC(ha_t, HA_SIZE, "ha_t");
  57. #undef SC
  58. return ((char *) NULL);
  59. } /* wv_struct_check */
  60. #endif /* STRUCT_CHECK */
  61. /********************* HOST ADAPTER SUBROUTINES *********************/
  62. /*
  63. * Useful subroutines to manage the WaveLAN ISA interface
  64. *
  65. * One major difference with the PCMCIA hardware (except the port mapping)
  66. * is that we have to keep the state of the Host Control Register
  67. * because of the interrupt enable & bus size flags.
  68. */
  69. /*------------------------------------------------------------------*/
  70. /*
  71. * Read from card's Host Adaptor Status Register.
  72. */
  73. static inline u16 hasr_read(unsigned long ioaddr)
  74. {
  75. return (inw(HASR(ioaddr)));
  76. } /* hasr_read */
  77. /*------------------------------------------------------------------*/
  78. /*
  79. * Write to card's Host Adapter Command Register.
  80. */
  81. static inline void hacr_write(unsigned long ioaddr, u16 hacr)
  82. {
  83. outw(hacr, HACR(ioaddr));
  84. } /* hacr_write */
  85. /*------------------------------------------------------------------*/
  86. /*
  87. * Write to card's Host Adapter Command Register. Include a delay for
  88. * those times when it is needed.
  89. */
  90. static void hacr_write_slow(unsigned long ioaddr, u16 hacr)
  91. {
  92. hacr_write(ioaddr, hacr);
  93. /* delay might only be needed sometimes */
  94. mdelay(1);
  95. } /* hacr_write_slow */
  96. /*------------------------------------------------------------------*/
  97. /*
  98. * Set the channel attention bit.
  99. */
  100. static inline void set_chan_attn(unsigned long ioaddr, u16 hacr)
  101. {
  102. hacr_write(ioaddr, hacr | HACR_CA);
  103. } /* set_chan_attn */
  104. /*------------------------------------------------------------------*/
  105. /*
  106. * Reset, and then set host adaptor into default mode.
  107. */
  108. static inline void wv_hacr_reset(unsigned long ioaddr)
  109. {
  110. hacr_write_slow(ioaddr, HACR_RESET);
  111. hacr_write(ioaddr, HACR_DEFAULT);
  112. } /* wv_hacr_reset */
  113. /*------------------------------------------------------------------*/
  114. /*
  115. * Set the I/O transfer over the ISA bus to 8-bit mode
  116. */
  117. static inline void wv_16_off(unsigned long ioaddr, u16 hacr)
  118. {
  119. hacr &= ~HACR_16BITS;
  120. hacr_write(ioaddr, hacr);
  121. } /* wv_16_off */
  122. /*------------------------------------------------------------------*/
  123. /*
  124. * Set the I/O transfer over the ISA bus to 8-bit mode
  125. */
  126. static inline void wv_16_on(unsigned long ioaddr, u16 hacr)
  127. {
  128. hacr |= HACR_16BITS;
  129. hacr_write(ioaddr, hacr);
  130. } /* wv_16_on */
  131. /*------------------------------------------------------------------*/
  132. /*
  133. * Disable interrupts on the WaveLAN hardware.
  134. * (called by wv_82586_stop())
  135. */
  136. static inline void wv_ints_off(struct net_device * dev)
  137. {
  138. net_local *lp = (net_local *) dev->priv;
  139. unsigned long ioaddr = dev->base_addr;
  140. lp->hacr &= ~HACR_INTRON;
  141. hacr_write(ioaddr, lp->hacr);
  142. } /* wv_ints_off */
  143. /*------------------------------------------------------------------*/
  144. /*
  145. * Enable interrupts on the WaveLAN hardware.
  146. * (called by wv_hw_reset())
  147. */
  148. static inline void wv_ints_on(struct net_device * dev)
  149. {
  150. net_local *lp = (net_local *) dev->priv;
  151. unsigned long ioaddr = dev->base_addr;
  152. lp->hacr |= HACR_INTRON;
  153. hacr_write(ioaddr, lp->hacr);
  154. } /* wv_ints_on */
  155. /******************* MODEM MANAGEMENT SUBROUTINES *******************/
  156. /*
  157. * Useful subroutines to manage the modem of the WaveLAN
  158. */
  159. /*------------------------------------------------------------------*/
  160. /*
  161. * Read the Parameter Storage Area from the WaveLAN card's memory
  162. */
  163. /*
  164. * Read bytes from the PSA.
  165. */
  166. static void psa_read(unsigned long ioaddr, u16 hacr, int o, /* offset in PSA */
  167. u8 * b, /* buffer to fill */
  168. int n)
  169. { /* size to read */
  170. wv_16_off(ioaddr, hacr);
  171. while (n-- > 0) {
  172. outw(o, PIOR2(ioaddr));
  173. o++;
  174. *b++ = inb(PIOP2(ioaddr));
  175. }
  176. wv_16_on(ioaddr, hacr);
  177. } /* psa_read */
  178. /*------------------------------------------------------------------*/
  179. /*
  180. * Write the Parameter Storage Area to the WaveLAN card's memory.
  181. */
  182. static void psa_write(unsigned long ioaddr, u16 hacr, int o, /* Offset in PSA */
  183. u8 * b, /* Buffer in memory */
  184. int n)
  185. { /* Length of buffer */
  186. int count = 0;
  187. wv_16_off(ioaddr, hacr);
  188. while (n-- > 0) {
  189. outw(o, PIOR2(ioaddr));
  190. o++;
  191. outb(*b, PIOP2(ioaddr));
  192. b++;
  193. /* Wait for the memory to finish its write cycle */
  194. count = 0;
  195. while ((count++ < 100) &&
  196. (hasr_read(ioaddr) & HASR_PSA_BUSY)) mdelay(1);
  197. }
  198. wv_16_on(ioaddr, hacr);
  199. } /* psa_write */
  200. #ifdef SET_PSA_CRC
  201. /*------------------------------------------------------------------*/
  202. /*
  203. * Calculate the PSA CRC
  204. * Thanks to Valster, Nico <NVALSTER@wcnd.nl.lucent.com> for the code
  205. * NOTE: By specifying a length including the CRC position the
  206. * returned value should be zero. (i.e. a correct checksum in the PSA)
  207. *
  208. * The Windows drivers don't use the CRC, but the AP and the PtP tool
  209. * depend on it.
  210. */
  211. static u16 psa_crc(u8 * psa, /* The PSA */
  212. int size)
  213. { /* Number of short for CRC */
  214. int byte_cnt; /* Loop on the PSA */
  215. u16 crc_bytes = 0; /* Data in the PSA */
  216. int bit_cnt; /* Loop on the bits of the short */
  217. for (byte_cnt = 0; byte_cnt < size; byte_cnt++) {
  218. crc_bytes ^= psa[byte_cnt]; /* Its an xor */
  219. for (bit_cnt = 1; bit_cnt < 9; bit_cnt++) {
  220. if (crc_bytes & 0x0001)
  221. crc_bytes = (crc_bytes >> 1) ^ 0xA001;
  222. else
  223. crc_bytes >>= 1;
  224. }
  225. }
  226. return crc_bytes;
  227. } /* psa_crc */
  228. #endif /* SET_PSA_CRC */
  229. /*------------------------------------------------------------------*/
  230. /*
  231. * update the checksum field in the Wavelan's PSA
  232. */
  233. static void update_psa_checksum(struct net_device * dev, unsigned long ioaddr, u16 hacr)
  234. {
  235. #ifdef SET_PSA_CRC
  236. psa_t psa;
  237. u16 crc;
  238. /* read the parameter storage area */
  239. psa_read(ioaddr, hacr, 0, (unsigned char *) &psa, sizeof(psa));
  240. /* update the checksum */
  241. crc = psa_crc((unsigned char *) &psa,
  242. sizeof(psa) - sizeof(psa.psa_crc[0]) -
  243. sizeof(psa.psa_crc[1])
  244. - sizeof(psa.psa_crc_status));
  245. psa.psa_crc[0] = crc & 0xFF;
  246. psa.psa_crc[1] = (crc & 0xFF00) >> 8;
  247. /* Write it ! */
  248. psa_write(ioaddr, hacr, (char *) &psa.psa_crc - (char *) &psa,
  249. (unsigned char *) &psa.psa_crc, 2);
  250. #ifdef DEBUG_IOCTL_INFO
  251. printk(KERN_DEBUG "%s: update_psa_checksum(): crc = 0x%02x%02x\n",
  252. dev->name, psa.psa_crc[0], psa.psa_crc[1]);
  253. /* Check again (luxury !) */
  254. crc = psa_crc((unsigned char *) &psa,
  255. sizeof(psa) - sizeof(psa.psa_crc_status));
  256. if (crc != 0)
  257. printk(KERN_WARNING
  258. "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n",
  259. dev->name);
  260. #endif /* DEBUG_IOCTL_INFO */
  261. #endif /* SET_PSA_CRC */
  262. } /* update_psa_checksum */
  263. /*------------------------------------------------------------------*/
  264. /*
  265. * Write 1 byte to the MMC.
  266. */
  267. static void mmc_out(unsigned long ioaddr, u16 o, u8 d)
  268. {
  269. int count = 0;
  270. /* Wait for MMC to go idle */
  271. while ((count++ < 100) && (inw(HASR(ioaddr)) & HASR_MMC_BUSY))
  272. udelay(10);
  273. outw((u16) (((u16) d << 8) | (o << 1) | 1), MMCR(ioaddr));
  274. }
  275. /*------------------------------------------------------------------*/
  276. /*
  277. * Routine to write bytes to the Modem Management Controller.
  278. * We start at the end because it is the way it should be!
  279. */
  280. static void mmc_write(unsigned long ioaddr, u8 o, u8 * b, int n)
  281. {
  282. o += n;
  283. b += n;
  284. while (n-- > 0)
  285. mmc_out(ioaddr, --o, *(--b));
  286. } /* mmc_write */
  287. /*------------------------------------------------------------------*/
  288. /*
  289. * Read a byte from the MMC.
  290. * Optimised version for 1 byte, avoid using memory.
  291. */
  292. static u8 mmc_in(unsigned long ioaddr, u16 o)
  293. {
  294. int count = 0;
  295. while ((count++ < 100) && (inw(HASR(ioaddr)) & HASR_MMC_BUSY))
  296. udelay(10);
  297. outw(o << 1, MMCR(ioaddr));
  298. while ((count++ < 100) && (inw(HASR(ioaddr)) & HASR_MMC_BUSY))
  299. udelay(10);
  300. return (u8) (inw(MMCR(ioaddr)) >> 8);
  301. }
  302. /*------------------------------------------------------------------*/
  303. /*
  304. * Routine to read bytes from the Modem Management Controller.
  305. * The implementation is complicated by a lack of address lines,
  306. * which prevents decoding of the low-order bit.
  307. * (code has just been moved in the above function)
  308. * We start at the end because it is the way it should be!
  309. */
  310. static inline void mmc_read(unsigned long ioaddr, u8 o, u8 * b, int n)
  311. {
  312. o += n;
  313. b += n;
  314. while (n-- > 0)
  315. *(--b) = mmc_in(ioaddr, --o);
  316. } /* mmc_read */
  317. /*------------------------------------------------------------------*/
  318. /*
  319. * Get the type of encryption available.
  320. */
  321. static inline int mmc_encr(unsigned long ioaddr)
  322. { /* I/O port of the card */
  323. int temp;
  324. temp = mmc_in(ioaddr, mmroff(0, mmr_des_avail));
  325. if ((temp != MMR_DES_AVAIL_DES) && (temp != MMR_DES_AVAIL_AES))
  326. return 0;
  327. else
  328. return temp;
  329. }
  330. /*------------------------------------------------------------------*/
  331. /*
  332. * Wait for the frequency EEPROM to complete a command.
  333. * I hope this one will be optimally inlined.
  334. */
  335. static inline void fee_wait(unsigned long ioaddr, /* I/O port of the card */
  336. int delay, /* Base delay to wait for */
  337. int number)
  338. { /* Number of time to wait */
  339. int count = 0; /* Wait only a limited time */
  340. while ((count++ < number) &&
  341. (mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
  342. MMR_FEE_STATUS_BUSY)) udelay(delay);
  343. }
  344. /*------------------------------------------------------------------*/
  345. /*
  346. * Read bytes from the Frequency EEPROM (frequency select cards).
  347. */
  348. static void fee_read(unsigned long ioaddr, /* I/O port of the card */
  349. u16 o, /* destination offset */
  350. u16 * b, /* data buffer */
  351. int n)
  352. { /* number of registers */
  353. b += n; /* Position at the end of the area */
  354. /* Write the address */
  355. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), o + n - 1);
  356. /* Loop on all buffer */
  357. while (n-- > 0) {
  358. /* Write the read command */
  359. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
  360. MMW_FEE_CTRL_READ);
  361. /* Wait until EEPROM is ready (should be quick). */
  362. fee_wait(ioaddr, 10, 100);
  363. /* Read the value. */
  364. *--b = ((mmc_in(ioaddr, mmroff(0, mmr_fee_data_h)) << 8) |
  365. mmc_in(ioaddr, mmroff(0, mmr_fee_data_l)));
  366. }
  367. }
  368. /*------------------------------------------------------------------*/
  369. /*
  370. * Write bytes from the Frequency EEPROM (frequency select cards).
  371. * This is a bit complicated, because the frequency EEPROM has to
  372. * be unprotected and the write enabled.
  373. * Jean II
  374. */
  375. static void fee_write(unsigned long ioaddr, /* I/O port of the card */
  376. u16 o, /* destination offset */
  377. u16 * b, /* data buffer */
  378. int n)
  379. { /* number of registers */
  380. b += n; /* Position at the end of the area. */
  381. #ifdef EEPROM_IS_PROTECTED /* disabled */
  382. #ifdef DOESNT_SEEM_TO_WORK /* disabled */
  383. /* Ask to read the protected register */
  384. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRREAD);
  385. fee_wait(ioaddr, 10, 100);
  386. /* Read the protected register. */
  387. printk("Protected 2: %02X-%02X\n",
  388. mmc_in(ioaddr, mmroff(0, mmr_fee_data_h)),
  389. mmc_in(ioaddr, mmroff(0, mmr_fee_data_l)));
  390. #endif /* DOESNT_SEEM_TO_WORK */
  391. /* Enable protected register. */
  392. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_EN);
  393. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PREN);
  394. fee_wait(ioaddr, 10, 100);
  395. /* Unprotect area. */
  396. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), o + n);
  397. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRWRITE);
  398. #ifdef DOESNT_SEEM_TO_WORK /* disabled */
  399. /* or use: */
  400. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRCLEAR);
  401. #endif /* DOESNT_SEEM_TO_WORK */
  402. fee_wait(ioaddr, 10, 100);
  403. #endif /* EEPROM_IS_PROTECTED */
  404. /* Write enable. */
  405. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_EN);
  406. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WREN);
  407. fee_wait(ioaddr, 10, 100);
  408. /* Write the EEPROM address. */
  409. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), o + n - 1);
  410. /* Loop on all buffer */
  411. while (n-- > 0) {
  412. /* Write the value. */
  413. mmc_out(ioaddr, mmwoff(0, mmw_fee_data_h), (*--b) >> 8);
  414. mmc_out(ioaddr, mmwoff(0, mmw_fee_data_l), *b & 0xFF);
  415. /* Write the write command. */
  416. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
  417. MMW_FEE_CTRL_WRITE);
  418. /* WaveLAN documentation says to wait at least 10 ms for EEBUSY = 0 */
  419. mdelay(10);
  420. fee_wait(ioaddr, 10, 100);
  421. }
  422. /* Write disable. */
  423. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), MMW_FEE_ADDR_DS);
  424. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WDS);
  425. fee_wait(ioaddr, 10, 100);
  426. #ifdef EEPROM_IS_PROTECTED /* disabled */
  427. /* Reprotect EEPROM. */
  428. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), 0x00);
  429. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_PRWRITE);
  430. fee_wait(ioaddr, 10, 100);
  431. #endif /* EEPROM_IS_PROTECTED */
  432. }
  433. /************************ I82586 SUBROUTINES *************************/
  434. /*
  435. * Useful subroutines to manage the Ethernet controller
  436. */
  437. /*------------------------------------------------------------------*/
  438. /*
  439. * Read bytes from the on-board RAM.
  440. * Why does inlining this function make it fail?
  441. */
  442. static /*inline */ void obram_read(unsigned long ioaddr,
  443. u16 o, u8 * b, int n)
  444. {
  445. outw(o, PIOR1(ioaddr));
  446. insw(PIOP1(ioaddr), (unsigned short *) b, (n + 1) >> 1);
  447. }
  448. /*------------------------------------------------------------------*/
  449. /*
  450. * Write bytes to the on-board RAM.
  451. */
  452. static inline void obram_write(unsigned long ioaddr, u16 o, u8 * b, int n)
  453. {
  454. outw(o, PIOR1(ioaddr));
  455. outsw(PIOP1(ioaddr), (unsigned short *) b, (n + 1) >> 1);
  456. }
  457. /*------------------------------------------------------------------*/
  458. /*
  459. * Acknowledge the reading of the status issued by the i82586.
  460. */
  461. static void wv_ack(struct net_device * dev)
  462. {
  463. net_local *lp = (net_local *) dev->priv;
  464. unsigned long ioaddr = dev->base_addr;
  465. u16 scb_cs;
  466. int i;
  467. obram_read(ioaddr, scboff(OFFSET_SCB, scb_status),
  468. (unsigned char *) &scb_cs, sizeof(scb_cs));
  469. scb_cs &= SCB_ST_INT;
  470. if (scb_cs == 0)
  471. return;
  472. obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
  473. (unsigned char *) &scb_cs, sizeof(scb_cs));
  474. set_chan_attn(ioaddr, lp->hacr);
  475. for (i = 1000; i > 0; i--) {
  476. obram_read(ioaddr, scboff(OFFSET_SCB, scb_command),
  477. (unsigned char *) &scb_cs, sizeof(scb_cs));
  478. if (scb_cs == 0)
  479. break;
  480. udelay(10);
  481. }
  482. udelay(100);
  483. #ifdef DEBUG_CONFIG_ERROR
  484. if (i <= 0)
  485. printk(KERN_INFO
  486. "%s: wv_ack(): board not accepting command.\n",
  487. dev->name);
  488. #endif
  489. }
  490. /*------------------------------------------------------------------*/
  491. /*
  492. * Set channel attention bit and busy wait until command has
  493. * completed, then acknowledge completion of the command.
  494. */
  495. static int wv_synchronous_cmd(struct net_device * dev, const char *str)
  496. {
  497. net_local *lp = (net_local *) dev->priv;
  498. unsigned long ioaddr = dev->base_addr;
  499. u16 scb_cmd;
  500. ach_t cb;
  501. int i;
  502. scb_cmd = SCB_CMD_CUC & SCB_CMD_CUC_GO;
  503. obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
  504. (unsigned char *) &scb_cmd, sizeof(scb_cmd));
  505. set_chan_attn(ioaddr, lp->hacr);
  506. for (i = 1000; i > 0; i--) {
  507. obram_read(ioaddr, OFFSET_CU, (unsigned char *) &cb,
  508. sizeof(cb));
  509. if (cb.ac_status & AC_SFLD_C)
  510. break;
  511. udelay(10);
  512. }
  513. udelay(100);
  514. if (i <= 0 || !(cb.ac_status & AC_SFLD_OK)) {
  515. #ifdef DEBUG_CONFIG_ERROR
  516. printk(KERN_INFO "%s: %s failed; status = 0x%x\n",
  517. dev->name, str, cb.ac_status);
  518. #endif
  519. #ifdef DEBUG_I82586_SHOW
  520. wv_scb_show(ioaddr);
  521. #endif
  522. return -1;
  523. }
  524. /* Ack the status */
  525. wv_ack(dev);
  526. return 0;
  527. }
  528. /*------------------------------------------------------------------*/
  529. /*
  530. * Configuration commands completion interrupt.
  531. * Check if done, and if OK.
  532. */
  533. static int
  534. wv_config_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp)
  535. {
  536. unsigned short mcs_addr;
  537. unsigned short status;
  538. int ret;
  539. #ifdef DEBUG_INTERRUPT_TRACE
  540. printk(KERN_DEBUG "%s: ->wv_config_complete()\n", dev->name);
  541. #endif
  542. mcs_addr = lp->tx_first_in_use + sizeof(ac_tx_t) + sizeof(ac_nop_t)
  543. + sizeof(tbd_t) + sizeof(ac_cfg_t) + sizeof(ac_ias_t);
  544. /* Read the status of the last command (set mc list). */
  545. obram_read(ioaddr, acoff(mcs_addr, ac_status),
  546. (unsigned char *) &status, sizeof(status));
  547. /* If not completed -> exit */
  548. if ((status & AC_SFLD_C) == 0)
  549. ret = 0; /* Not ready to be scrapped */
  550. else {
  551. #ifdef DEBUG_CONFIG_ERROR
  552. unsigned short cfg_addr;
  553. unsigned short ias_addr;
  554. /* Check mc_config command */
  555. if ((status & AC_SFLD_OK) != AC_SFLD_OK)
  556. printk(KERN_INFO
  557. "%s: wv_config_complete(): set_multicast_address failed; status = 0x%x\n",
  558. dev->name, status);
  559. /* check ia-config command */
  560. ias_addr = mcs_addr - sizeof(ac_ias_t);
  561. obram_read(ioaddr, acoff(ias_addr, ac_status),
  562. (unsigned char *) &status, sizeof(status));
  563. if ((status & AC_SFLD_OK) != AC_SFLD_OK)
  564. printk(KERN_INFO
  565. "%s: wv_config_complete(): set_MAC_address failed; status = 0x%x\n",
  566. dev->name, status);
  567. /* Check config command. */
  568. cfg_addr = ias_addr - sizeof(ac_cfg_t);
  569. obram_read(ioaddr, acoff(cfg_addr, ac_status),
  570. (unsigned char *) &status, sizeof(status));
  571. if ((status & AC_SFLD_OK) != AC_SFLD_OK)
  572. printk(KERN_INFO
  573. "%s: wv_config_complete(): configure failed; status = 0x%x\n",
  574. dev->name, status);
  575. #endif /* DEBUG_CONFIG_ERROR */
  576. ret = 1; /* Ready to be scrapped */
  577. }
  578. #ifdef DEBUG_INTERRUPT_TRACE
  579. printk(KERN_DEBUG "%s: <-wv_config_complete() - %d\n", dev->name,
  580. ret);
  581. #endif
  582. return ret;
  583. }
  584. /*------------------------------------------------------------------*/
  585. /*
  586. * Command completion interrupt.
  587. * Reclaim as many freed tx buffers as we can.
  588. * (called in wavelan_interrupt()).
  589. * Note : the spinlock is already grabbed for us.
  590. */
  591. static int wv_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp)
  592. {
  593. int nreaped = 0;
  594. #ifdef DEBUG_INTERRUPT_TRACE
  595. printk(KERN_DEBUG "%s: ->wv_complete()\n", dev->name);
  596. #endif
  597. /* Loop on all the transmit buffers */
  598. while (lp->tx_first_in_use != I82586NULL) {
  599. unsigned short tx_status;
  600. /* Read the first transmit buffer */
  601. obram_read(ioaddr, acoff(lp->tx_first_in_use, ac_status),
  602. (unsigned char *) &tx_status,
  603. sizeof(tx_status));
  604. /* If not completed -> exit */
  605. if ((tx_status & AC_SFLD_C) == 0)
  606. break;
  607. /* Hack for reconfiguration */
  608. if (tx_status == 0xFFFF)
  609. if (!wv_config_complete(dev, ioaddr, lp))
  610. break; /* Not completed */
  611. /* We now remove this buffer */
  612. nreaped++;
  613. --lp->tx_n_in_use;
  614. /*
  615. if (lp->tx_n_in_use > 0)
  616. printk("%c", "0123456789abcdefghijk"[lp->tx_n_in_use]);
  617. */
  618. /* Was it the last one? */
  619. if (lp->tx_n_in_use <= 0)
  620. lp->tx_first_in_use = I82586NULL;
  621. else {
  622. /* Next one in the chain */
  623. lp->tx_first_in_use += TXBLOCKZ;
  624. if (lp->tx_first_in_use >=
  625. OFFSET_CU +
  626. NTXBLOCKS * TXBLOCKZ) lp->tx_first_in_use -=
  627. NTXBLOCKS * TXBLOCKZ;
  628. }
  629. /* Hack for reconfiguration */
  630. if (tx_status == 0xFFFF)
  631. continue;
  632. /* Now, check status of the finished command */
  633. if (tx_status & AC_SFLD_OK) {
  634. int ncollisions;
  635. lp->stats.tx_packets++;
  636. ncollisions = tx_status & AC_SFLD_MAXCOL;
  637. lp->stats.collisions += ncollisions;
  638. #ifdef DEBUG_TX_INFO
  639. if (ncollisions > 0)
  640. printk(KERN_DEBUG
  641. "%s: wv_complete(): tx completed after %d collisions.\n",
  642. dev->name, ncollisions);
  643. #endif
  644. } else {
  645. lp->stats.tx_errors++;
  646. if (tx_status & AC_SFLD_S10) {
  647. lp->stats.tx_carrier_errors++;
  648. #ifdef DEBUG_TX_FAIL
  649. printk(KERN_DEBUG
  650. "%s: wv_complete(): tx error: no CS.\n",
  651. dev->name);
  652. #endif
  653. }
  654. if (tx_status & AC_SFLD_S9) {
  655. lp->stats.tx_carrier_errors++;
  656. #ifdef DEBUG_TX_FAIL
  657. printk(KERN_DEBUG
  658. "%s: wv_complete(): tx error: lost CTS.\n",
  659. dev->name);
  660. #endif
  661. }
  662. if (tx_status & AC_SFLD_S8) {
  663. lp->stats.tx_fifo_errors++;
  664. #ifdef DEBUG_TX_FAIL
  665. printk(KERN_DEBUG
  666. "%s: wv_complete(): tx error: slow DMA.\n",
  667. dev->name);
  668. #endif
  669. }
  670. if (tx_status & AC_SFLD_S6) {
  671. lp->stats.tx_heartbeat_errors++;
  672. #ifdef DEBUG_TX_FAIL
  673. printk(KERN_DEBUG
  674. "%s: wv_complete(): tx error: heart beat.\n",
  675. dev->name);
  676. #endif
  677. }
  678. if (tx_status & AC_SFLD_S5) {
  679. lp->stats.tx_aborted_errors++;
  680. #ifdef DEBUG_TX_FAIL
  681. printk(KERN_DEBUG
  682. "%s: wv_complete(): tx error: too many collisions.\n",
  683. dev->name);
  684. #endif
  685. }
  686. }
  687. #ifdef DEBUG_TX_INFO
  688. printk(KERN_DEBUG
  689. "%s: wv_complete(): tx completed, tx_status 0x%04x\n",
  690. dev->name, tx_status);
  691. #endif
  692. }
  693. #ifdef DEBUG_INTERRUPT_INFO
  694. if (nreaped > 1)
  695. printk(KERN_DEBUG "%s: wv_complete(): reaped %d\n",
  696. dev->name, nreaped);
  697. #endif
  698. /*
  699. * Inform upper layers.
  700. */
  701. if (lp->tx_n_in_use < NTXBLOCKS - 1) {
  702. netif_wake_queue(dev);
  703. }
  704. #ifdef DEBUG_INTERRUPT_TRACE
  705. printk(KERN_DEBUG "%s: <-wv_complete()\n", dev->name);
  706. #endif
  707. return nreaped;
  708. }
  709. /*------------------------------------------------------------------*/
  710. /*
  711. * Reconfigure the i82586, or at least ask for it.
  712. * Because wv_82586_config uses a transmission buffer, we must do it
  713. * when we are sure that there is one left, so we do it now
  714. * or in wavelan_packet_xmit() (I can't find any better place,
  715. * wavelan_interrupt is not an option), so you may experience
  716. * delays sometimes.
  717. */
  718. static void wv_82586_reconfig(struct net_device * dev)
  719. {
  720. net_local *lp = (net_local *) dev->priv;
  721. unsigned long flags;
  722. /* Arm the flag, will be cleard in wv_82586_config() */
  723. lp->reconfig_82586 = 1;
  724. /* Check if we can do it now ! */
  725. if((netif_running(dev)) && !(netif_queue_stopped(dev))) {
  726. spin_lock_irqsave(&lp->spinlock, flags);
  727. /* May fail */
  728. wv_82586_config(dev);
  729. spin_unlock_irqrestore(&lp->spinlock, flags);
  730. }
  731. else {
  732. #ifdef DEBUG_CONFIG_INFO
  733. printk(KERN_DEBUG
  734. "%s: wv_82586_reconfig(): delayed (state = %lX)\n",
  735. dev->name, dev->state);
  736. #endif
  737. }
  738. }
  739. /********************* DEBUG & INFO SUBROUTINES *********************/
  740. /*
  741. * This routine is used in the code to show information for debugging.
  742. * Most of the time, it dumps the contents of hardware structures.
  743. */
  744. #ifdef DEBUG_PSA_SHOW
  745. /*------------------------------------------------------------------*/
  746. /*
  747. * Print the formatted contents of the Parameter Storage Area.
  748. */
  749. static void wv_psa_show(psa_t * p)
  750. {
  751. printk(KERN_DEBUG "##### WaveLAN PSA contents: #####\n");
  752. printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n",
  753. p->psa_io_base_addr_1,
  754. p->psa_io_base_addr_2,
  755. p->psa_io_base_addr_3, p->psa_io_base_addr_4);
  756. printk(KERN_DEBUG "psa_rem_boot_addr_1: 0x%02X %02X %02X\n",
  757. p->psa_rem_boot_addr_1,
  758. p->psa_rem_boot_addr_2, p->psa_rem_boot_addr_3);
  759. printk(KERN_DEBUG "psa_holi_params: 0x%02x, ", p->psa_holi_params);
  760. printk("psa_int_req_no: %d\n", p->psa_int_req_no);
  761. #ifdef DEBUG_SHOW_UNUSED
  762. printk(KERN_DEBUG
  763. "psa_unused0[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
  764. p->psa_unused0[0], p->psa_unused0[1], p->psa_unused0[2],
  765. p->psa_unused0[3], p->psa_unused0[4], p->psa_unused0[5],
  766. p->psa_unused0[6]);
  767. #endif /* DEBUG_SHOW_UNUSED */
  768. printk(KERN_DEBUG
  769. "psa_univ_mac_addr[]: %02x:%02x:%02x:%02x:%02x:%02x\n",
  770. p->psa_univ_mac_addr[0], p->psa_univ_mac_addr[1],
  771. p->psa_univ_mac_addr[2], p->psa_univ_mac_addr[3],
  772. p->psa_univ_mac_addr[4], p->psa_univ_mac_addr[5]);
  773. printk(KERN_DEBUG
  774. "psa_local_mac_addr[]: %02x:%02x:%02x:%02x:%02x:%02x\n",
  775. p->psa_local_mac_addr[0], p->psa_local_mac_addr[1],
  776. p->psa_local_mac_addr[2], p->psa_local_mac_addr[3],
  777. p->psa_local_mac_addr[4], p->psa_local_mac_addr[5]);
  778. printk(KERN_DEBUG "psa_univ_local_sel: %d, ",
  779. p->psa_univ_local_sel);
  780. printk("psa_comp_number: %d, ", p->psa_comp_number);
  781. printk("psa_thr_pre_set: 0x%02x\n", p->psa_thr_pre_set);
  782. printk(KERN_DEBUG "psa_feature_select/decay_prm: 0x%02x, ",
  783. p->psa_feature_select);
  784. printk("psa_subband/decay_update_prm: %d\n", p->psa_subband);
  785. printk(KERN_DEBUG "psa_quality_thr: 0x%02x, ", p->psa_quality_thr);
  786. printk("psa_mod_delay: 0x%02x\n", p->psa_mod_delay);
  787. printk(KERN_DEBUG "psa_nwid: 0x%02x%02x, ", p->psa_nwid[0],
  788. p->psa_nwid[1]);
  789. printk("psa_nwid_select: %d\n", p->psa_nwid_select);
  790. printk(KERN_DEBUG "psa_encryption_select: %d, ",
  791. p->psa_encryption_select);
  792. printk
  793. ("psa_encryption_key[]: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
  794. p->psa_encryption_key[0], p->psa_encryption_key[1],
  795. p->psa_encryption_key[2], p->psa_encryption_key[3],
  796. p->psa_encryption_key[4], p->psa_encryption_key[5],
  797. p->psa_encryption_key[6], p->psa_encryption_key[7]);
  798. printk(KERN_DEBUG "psa_databus_width: %d\n", p->psa_databus_width);
  799. printk(KERN_DEBUG "psa_call_code/auto_squelch: 0x%02x, ",
  800. p->psa_call_code[0]);
  801. printk
  802. ("psa_call_code[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
  803. p->psa_call_code[0], p->psa_call_code[1], p->psa_call_code[2],
  804. p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5],
  805. p->psa_call_code[6], p->psa_call_code[7]);
  806. #ifdef DEBUG_SHOW_UNUSED
  807. printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n",
  808. p->psa_reserved[0],
  809. p->psa_reserved[1], p->psa_reserved[2], p->psa_reserved[3]);
  810. #endif /* DEBUG_SHOW_UNUSED */
  811. printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status);
  812. printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]);
  813. printk("psa_crc_status: 0x%02x\n", p->psa_crc_status);
  814. } /* wv_psa_show */
  815. #endif /* DEBUG_PSA_SHOW */
  816. #ifdef DEBUG_MMC_SHOW
  817. /*------------------------------------------------------------------*/
  818. /*
  819. * Print the formatted status of the Modem Management Controller.
  820. * This function needs to be completed.
  821. */
  822. static void wv_mmc_show(struct net_device * dev)
  823. {
  824. unsigned long ioaddr = dev->base_addr;
  825. net_local *lp = (net_local *) dev->priv;
  826. mmr_t m;
  827. /* Basic check */
  828. if (hasr_read(ioaddr) & HASR_NO_CLK) {
  829. printk(KERN_WARNING
  830. "%s: wv_mmc_show: modem not connected\n",
  831. dev->name);
  832. return;
  833. }
  834. /* Read the mmc */
  835. mmc_out(ioaddr, mmwoff(0, mmw_freeze), 1);
  836. mmc_read(ioaddr, 0, (u8 *) & m, sizeof(m));
  837. mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0);
  838. /* Don't forget to update statistics */
  839. lp->wstats.discard.nwid +=
  840. (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
  841. printk(KERN_DEBUG "##### WaveLAN modem status registers: #####\n");
  842. #ifdef DEBUG_SHOW_UNUSED
  843. printk(KERN_DEBUG
  844. "mmc_unused0[]: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
  845. m.mmr_unused0[0], m.mmr_unused0[1], m.mmr_unused0[2],
  846. m.mmr_unused0[3], m.mmr_unused0[4], m.mmr_unused0[5],
  847. m.mmr_unused0[6], m.mmr_unused0[7]);
  848. #endif /* DEBUG_SHOW_UNUSED */
  849. printk(KERN_DEBUG "Encryption algorithm: %02X - Status: %02X\n",
  850. m.mmr_des_avail, m.mmr_des_status);
  851. #ifdef DEBUG_SHOW_UNUSED
  852. printk(KERN_DEBUG "mmc_unused1[]: %02X:%02X:%02X:%02X:%02X\n",
  853. m.mmr_unused1[0],
  854. m.mmr_unused1[1],
  855. m.mmr_unused1[2], m.mmr_unused1[3], m.mmr_unused1[4]);
  856. #endif /* DEBUG_SHOW_UNUSED */
  857. printk(KERN_DEBUG "dce_status: 0x%x [%s%s%s%s]\n",
  858. m.mmr_dce_status,
  859. (m.
  860. mmr_dce_status & MMR_DCE_STATUS_RX_BUSY) ?
  861. "energy detected," : "",
  862. (m.
  863. mmr_dce_status & MMR_DCE_STATUS_LOOPT_IND) ?
  864. "loop test indicated," : "",
  865. (m.
  866. mmr_dce_status & MMR_DCE_STATUS_TX_BUSY) ?
  867. "transmitter on," : "",
  868. (m.
  869. mmr_dce_status & MMR_DCE_STATUS_JBR_EXPIRED) ?
  870. "jabber timer expired," : "");
  871. printk(KERN_DEBUG "Dsp ID: %02X\n", m.mmr_dsp_id);
  872. #ifdef DEBUG_SHOW_UNUSED
  873. printk(KERN_DEBUG "mmc_unused2[]: %02X:%02X\n",
  874. m.mmr_unused2[0], m.mmr_unused2[1]);
  875. #endif /* DEBUG_SHOW_UNUSED */
  876. printk(KERN_DEBUG "# correct_nwid: %d, # wrong_nwid: %d\n",
  877. (m.mmr_correct_nwid_h << 8) | m.mmr_correct_nwid_l,
  878. (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l);
  879. printk(KERN_DEBUG "thr_pre_set: 0x%x [current signal %s]\n",
  880. m.mmr_thr_pre_set & MMR_THR_PRE_SET,
  881. (m.
  882. mmr_thr_pre_set & MMR_THR_PRE_SET_CUR) ? "above" :
  883. "below");
  884. printk(KERN_DEBUG "signal_lvl: %d [%s], ",
  885. m.mmr_signal_lvl & MMR_SIGNAL_LVL,
  886. (m.
  887. mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) ? "new msg" :
  888. "no new msg");
  889. printk("silence_lvl: %d [%s], ",
  890. m.mmr_silence_lvl & MMR_SILENCE_LVL,
  891. (m.
  892. mmr_silence_lvl & MMR_SILENCE_LVL_VALID) ? "update done" :
  893. "no new update");
  894. printk("sgnl_qual: 0x%x [%s]\n", m.mmr_sgnl_qual & MMR_SGNL_QUAL,
  895. (m.
  896. mmr_sgnl_qual & MMR_SGNL_QUAL_ANT) ? "Antenna 1" :
  897. "Antenna 0");
  898. #ifdef DEBUG_SHOW_UNUSED
  899. printk(KERN_DEBUG "netw_id_l: %x\n", m.mmr_netw_id_l);
  900. #endif /* DEBUG_SHOW_UNUSED */
  901. } /* wv_mmc_show */
  902. #endif /* DEBUG_MMC_SHOW */
  903. #ifdef DEBUG_I82586_SHOW
  904. /*------------------------------------------------------------------*/
  905. /*
  906. * Print the last block of the i82586 memory.
  907. */
  908. static void wv_scb_show(unsigned long ioaddr)
  909. {
  910. scb_t scb;
  911. obram_read(ioaddr, OFFSET_SCB, (unsigned char *) &scb,
  912. sizeof(scb));
  913. printk(KERN_DEBUG "##### WaveLAN system control block: #####\n");
  914. printk(KERN_DEBUG "status: ");
  915. printk("stat 0x%x[%s%s%s%s] ",
  916. (scb.
  917. scb_status & (SCB_ST_CX | SCB_ST_FR | SCB_ST_CNA |
  918. SCB_ST_RNR)) >> 12,
  919. (scb.
  920. scb_status & SCB_ST_CX) ? "command completion interrupt," :
  921. "", (scb.scb_status & SCB_ST_FR) ? "frame received," : "",
  922. (scb.
  923. scb_status & SCB_ST_CNA) ? "command unit not active," : "",
  924. (scb.
  925. scb_status & SCB_ST_RNR) ? "receiving unit not ready," :
  926. "");
  927. printk("cus 0x%x[%s%s%s] ", (scb.scb_status & SCB_ST_CUS) >> 8,
  928. ((scb.scb_status & SCB_ST_CUS) ==
  929. SCB_ST_CUS_IDLE) ? "idle" : "",
  930. ((scb.scb_status & SCB_ST_CUS) ==
  931. SCB_ST_CUS_SUSP) ? "suspended" : "",
  932. ((scb.scb_status & SCB_ST_CUS) ==
  933. SCB_ST_CUS_ACTV) ? "active" : "");
  934. printk("rus 0x%x[%s%s%s%s]\n", (scb.scb_status & SCB_ST_RUS) >> 4,
  935. ((scb.scb_status & SCB_ST_RUS) ==
  936. SCB_ST_RUS_IDLE) ? "idle" : "",
  937. ((scb.scb_status & SCB_ST_RUS) ==
  938. SCB_ST_RUS_SUSP) ? "suspended" : "",
  939. ((scb.scb_status & SCB_ST_RUS) ==
  940. SCB_ST_RUS_NRES) ? "no resources" : "",
  941. ((scb.scb_status & SCB_ST_RUS) ==
  942. SCB_ST_RUS_RDY) ? "ready" : "");
  943. printk(KERN_DEBUG "command: ");
  944. printk("ack 0x%x[%s%s%s%s] ",
  945. (scb.
  946. scb_command & (SCB_CMD_ACK_CX | SCB_CMD_ACK_FR |
  947. SCB_CMD_ACK_CNA | SCB_CMD_ACK_RNR)) >> 12,
  948. (scb.
  949. scb_command & SCB_CMD_ACK_CX) ? "ack cmd completion," : "",
  950. (scb.
  951. scb_command & SCB_CMD_ACK_FR) ? "ack frame received," : "",
  952. (scb.
  953. scb_command & SCB_CMD_ACK_CNA) ? "ack CU not active," : "",
  954. (scb.
  955. scb_command & SCB_CMD_ACK_RNR) ? "ack RU not ready," : "");
  956. printk("cuc 0x%x[%s%s%s%s%s] ",
  957. (scb.scb_command & SCB_CMD_CUC) >> 8,
  958. ((scb.scb_command & SCB_CMD_CUC) ==
  959. SCB_CMD_CUC_NOP) ? "nop" : "",
  960. ((scb.scb_command & SCB_CMD_CUC) ==
  961. SCB_CMD_CUC_GO) ? "start cbl_offset" : "",
  962. ((scb.scb_command & SCB_CMD_CUC) ==
  963. SCB_CMD_CUC_RES) ? "resume execution" : "",
  964. ((scb.scb_command & SCB_CMD_CUC) ==
  965. SCB_CMD_CUC_SUS) ? "suspend execution" : "",
  966. ((scb.scb_command & SCB_CMD_CUC) ==
  967. SCB_CMD_CUC_ABT) ? "abort execution" : "");
  968. printk("ruc 0x%x[%s%s%s%s%s]\n",
  969. (scb.scb_command & SCB_CMD_RUC) >> 4,
  970. ((scb.scb_command & SCB_CMD_RUC) ==
  971. SCB_CMD_RUC_NOP) ? "nop" : "",
  972. ((scb.scb_command & SCB_CMD_RUC) ==
  973. SCB_CMD_RUC_GO) ? "start rfa_offset" : "",
  974. ((scb.scb_command & SCB_CMD_RUC) ==
  975. SCB_CMD_RUC_RES) ? "resume reception" : "",
  976. ((scb.scb_command & SCB_CMD_RUC) ==
  977. SCB_CMD_RUC_SUS) ? "suspend reception" : "",
  978. ((scb.scb_command & SCB_CMD_RUC) ==
  979. SCB_CMD_RUC_ABT) ? "abort reception" : "");
  980. printk(KERN_DEBUG "cbl_offset 0x%x ", scb.scb_cbl_offset);
  981. printk("rfa_offset 0x%x\n", scb.scb_rfa_offset);
  982. printk(KERN_DEBUG "crcerrs %d ", scb.scb_crcerrs);
  983. printk("alnerrs %d ", scb.scb_alnerrs);
  984. printk("rscerrs %d ", scb.scb_rscerrs);
  985. printk("ovrnerrs %d\n", scb.scb_ovrnerrs);
  986. }
  987. /*------------------------------------------------------------------*/
  988. /*
  989. * Print the formatted status of the i82586's receive unit.
  990. */
  991. static void wv_ru_show(struct net_device * dev)
  992. {
  993. /* net_local *lp = (net_local *) dev->priv; */
  994. printk(KERN_DEBUG
  995. "##### WaveLAN i82586 receiver unit status: #####\n");
  996. printk(KERN_DEBUG "ru:");
  997. /*
  998. * Not implemented yet
  999. */
  1000. printk("\n");
  1001. } /* wv_ru_show */
  1002. /*------------------------------------------------------------------*/
  1003. /*
  1004. * Display info about one control block of the i82586 memory.
  1005. */
  1006. static void wv_cu_show_one(struct net_device * dev, net_local * lp, int i, u16 p)
  1007. {
  1008. unsigned long ioaddr;
  1009. ac_tx_t actx;
  1010. ioaddr = dev->base_addr;
  1011. printk("%d: 0x%x:", i, p);
  1012. obram_read(ioaddr, p, (unsigned char *) &actx, sizeof(actx));
  1013. printk(" status=0x%x,", actx.tx_h.ac_status);
  1014. printk(" command=0x%x,", actx.tx_h.ac_command);
  1015. /*
  1016. {
  1017. tbd_t tbd;
  1018. obram_read(ioaddr, actx.tx_tbd_offset, (unsigned char *)&tbd, sizeof(tbd));
  1019. printk(" tbd_status=0x%x,", tbd.tbd_status);
  1020. }
  1021. */
  1022. printk("|");
  1023. }
  1024. /*------------------------------------------------------------------*/
  1025. /*
  1026. * Print status of the command unit of the i82586.
  1027. */
  1028. static void wv_cu_show(struct net_device * dev)
  1029. {
  1030. net_local *lp = (net_local *) dev->priv;
  1031. unsigned int i;
  1032. u16 p;
  1033. printk(KERN_DEBUG
  1034. "##### WaveLAN i82586 command unit status: #####\n");
  1035. printk(KERN_DEBUG);
  1036. for (i = 0, p = lp->tx_first_in_use; i < NTXBLOCKS; i++) {
  1037. wv_cu_show_one(dev, lp, i, p);
  1038. p += TXBLOCKZ;
  1039. if (p >= OFFSET_CU + NTXBLOCKS * TXBLOCKZ)
  1040. p -= NTXBLOCKS * TXBLOCKZ;
  1041. }
  1042. printk("\n");
  1043. }
  1044. #endif /* DEBUG_I82586_SHOW */
  1045. #ifdef DEBUG_DEVICE_SHOW
  1046. /*------------------------------------------------------------------*/
  1047. /*
  1048. * Print the formatted status of the WaveLAN PCMCIA device driver.
  1049. */
  1050. static void wv_dev_show(struct net_device * dev)
  1051. {
  1052. printk(KERN_DEBUG "dev:");
  1053. printk(" state=%lX,", dev->state);
  1054. printk(" trans_start=%ld,", dev->trans_start);
  1055. printk(" flags=0x%x,", dev->flags);
  1056. printk("\n");
  1057. } /* wv_dev_show */
  1058. /*------------------------------------------------------------------*/
  1059. /*
  1060. * Print the formatted status of the WaveLAN PCMCIA device driver's
  1061. * private information.
  1062. */
  1063. static void wv_local_show(struct net_device * dev)
  1064. {
  1065. net_local *lp;
  1066. lp = (net_local *) dev->priv;
  1067. printk(KERN_DEBUG "local:");
  1068. printk(" tx_n_in_use=%d,", lp->tx_n_in_use);
  1069. printk(" hacr=0x%x,", lp->hacr);
  1070. printk(" rx_head=0x%x,", lp->rx_head);
  1071. printk(" rx_last=0x%x,", lp->rx_last);
  1072. printk(" tx_first_free=0x%x,", lp->tx_first_free);
  1073. printk(" tx_first_in_use=0x%x,", lp->tx_first_in_use);
  1074. printk("\n");
  1075. } /* wv_local_show */
  1076. #endif /* DEBUG_DEVICE_SHOW */
  1077. #if defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO)
  1078. /*------------------------------------------------------------------*/
  1079. /*
  1080. * Dump packet header (and content if necessary) on the screen
  1081. */
  1082. static inline void wv_packet_info(u8 * p, /* Packet to dump */
  1083. int length, /* Length of the packet */
  1084. char *msg1, /* Name of the device */
  1085. char *msg2)
  1086. { /* Name of the function */
  1087. int i;
  1088. int maxi;
  1089. printk(KERN_DEBUG
  1090. "%s: %s(): dest %02X:%02X:%02X:%02X:%02X:%02X, length %d\n",
  1091. msg1, msg2, p[0], p[1], p[2], p[3], p[4], p[5], length);
  1092. printk(KERN_DEBUG
  1093. "%s: %s(): src %02X:%02X:%02X:%02X:%02X:%02X, type 0x%02X%02X\n",
  1094. msg1, msg2, p[6], p[7], p[8], p[9], p[10], p[11], p[12],
  1095. p[13]);
  1096. #ifdef DEBUG_PACKET_DUMP
  1097. printk(KERN_DEBUG "data=\"");
  1098. if ((maxi = length) > DEBUG_PACKET_DUMP)
  1099. maxi = DEBUG_PACKET_DUMP;
  1100. for (i = 14; i < maxi; i++)
  1101. if (p[i] >= ' ' && p[i] <= '~')
  1102. printk(" %c", p[i]);
  1103. else
  1104. printk("%02X", p[i]);
  1105. if (maxi < length)
  1106. printk("..");
  1107. printk("\"\n");
  1108. printk(KERN_DEBUG "\n");
  1109. #endif /* DEBUG_PACKET_DUMP */
  1110. }
  1111. #endif /* defined(DEBUG_RX_INFO) || defined(DEBUG_TX_INFO) */
  1112. /*------------------------------------------------------------------*/
  1113. /*
  1114. * This is the information which is displayed by the driver at startup.
  1115. * There are lots of flags for configuring it to your liking.
  1116. */
  1117. static void wv_init_info(struct net_device * dev)
  1118. {
  1119. short ioaddr = dev->base_addr;
  1120. net_local *lp = (net_local *) dev->priv;
  1121. psa_t psa;
  1122. int i;
  1123. /* Read the parameter storage area */
  1124. psa_read(ioaddr, lp->hacr, 0, (unsigned char *) &psa, sizeof(psa));
  1125. #ifdef DEBUG_PSA_SHOW
  1126. wv_psa_show(&psa);
  1127. #endif
  1128. #ifdef DEBUG_MMC_SHOW
  1129. wv_mmc_show(dev);
  1130. #endif
  1131. #ifdef DEBUG_I82586_SHOW
  1132. wv_cu_show(dev);
  1133. #endif
  1134. #ifdef DEBUG_BASIC_SHOW
  1135. /* Now, let's go for the basic stuff. */
  1136. printk(KERN_NOTICE "%s: WaveLAN at %#x,", dev->name, ioaddr);
  1137. for (i = 0; i < WAVELAN_ADDR_SIZE; i++)
  1138. printk("%s%02X", (i == 0) ? " " : ":", dev->dev_addr[i]);
  1139. printk(", IRQ %d", dev->irq);
  1140. /* Print current network ID. */
  1141. if (psa.psa_nwid_select)
  1142. printk(", nwid 0x%02X-%02X", psa.psa_nwid[0],
  1143. psa.psa_nwid[1]);
  1144. else
  1145. printk(", nwid off");
  1146. /* If 2.00 card */
  1147. if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
  1148. (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
  1149. unsigned short freq;
  1150. /* Ask the EEPROM to read the frequency from the first area. */
  1151. fee_read(ioaddr, 0x00, &freq, 1);
  1152. /* Print frequency */
  1153. printk(", 2.00, %ld", (freq >> 6) + 2400L);
  1154. /* Hack! */
  1155. if (freq & 0x20)
  1156. printk(".5");
  1157. } else {
  1158. printk(", PC");
  1159. switch (psa.psa_comp_number) {
  1160. case PSA_COMP_PC_AT_915:
  1161. case PSA_COMP_PC_AT_2400:
  1162. printk("-AT");
  1163. break;
  1164. case PSA_COMP_PC_MC_915:
  1165. case PSA_COMP_PC_MC_2400:
  1166. printk("-MC");
  1167. break;
  1168. case PSA_COMP_PCMCIA_915:
  1169. printk("MCIA");
  1170. break;
  1171. default:
  1172. printk("?");
  1173. }
  1174. printk(", ");
  1175. switch (psa.psa_subband) {
  1176. case PSA_SUBBAND_915:
  1177. printk("915");
  1178. break;
  1179. case PSA_SUBBAND_2425:
  1180. printk("2425");
  1181. break;
  1182. case PSA_SUBBAND_2460:
  1183. printk("2460");
  1184. break;
  1185. case PSA_SUBBAND_2484:
  1186. printk("2484");
  1187. break;
  1188. case PSA_SUBBAND_2430_5:
  1189. printk("2430.5");
  1190. break;
  1191. default:
  1192. printk("?");
  1193. }
  1194. }
  1195. printk(" MHz\n");
  1196. #endif /* DEBUG_BASIC_SHOW */
  1197. #ifdef DEBUG_VERSION_SHOW
  1198. /* Print version information */
  1199. printk(KERN_NOTICE "%s", version);
  1200. #endif
  1201. } /* wv_init_info */
  1202. /********************* IOCTL, STATS & RECONFIG *********************/
  1203. /*
  1204. * We found here routines that are called by Linux on different
  1205. * occasions after the configuration and not for transmitting data
  1206. * These may be called when the user use ifconfig, /proc/net/dev
  1207. * or wireless extensions
  1208. */
  1209. /*------------------------------------------------------------------*/
  1210. /*
  1211. * Get the current Ethernet statistics. This may be called with the
  1212. * card open or closed.
  1213. * Used when the user read /proc/net/dev
  1214. */
  1215. static en_stats *wavelan_get_stats(struct net_device * dev)
  1216. {
  1217. #ifdef DEBUG_IOCTL_TRACE
  1218. printk(KERN_DEBUG "%s: <>wavelan_get_stats()\n", dev->name);
  1219. #endif
  1220. return (&((net_local *) dev->priv)->stats);
  1221. }
  1222. /*------------------------------------------------------------------*/
  1223. /*
  1224. * Set or clear the multicast filter for this adaptor.
  1225. * num_addrs == -1 Promiscuous mode, receive all packets
  1226. * num_addrs == 0 Normal mode, clear multicast list
  1227. * num_addrs > 0 Multicast mode, receive normal and MC packets,
  1228. * and do best-effort filtering.
  1229. */
  1230. static void wavelan_set_multicast_list(struct net_device * dev)
  1231. {
  1232. net_local *lp = (net_local *) dev->priv;
  1233. #ifdef DEBUG_IOCTL_TRACE
  1234. printk(KERN_DEBUG "%s: ->wavelan_set_multicast_list()\n",
  1235. dev->name);
  1236. #endif
  1237. #ifdef DEBUG_IOCTL_INFO
  1238. printk(KERN_DEBUG
  1239. "%s: wavelan_set_multicast_list(): setting Rx mode %02X to %d addresses.\n",
  1240. dev->name, dev->flags, dev->mc_count);
  1241. #endif
  1242. /* Are we asking for promiscuous mode,
  1243. * or all multicast addresses (we don't have that!)
  1244. * or too many multicast addresses for the hardware filter? */
  1245. if ((dev->flags & IFF_PROMISC) ||
  1246. (dev->flags & IFF_ALLMULTI) ||
  1247. (dev->mc_count > I82586_MAX_MULTICAST_ADDRESSES)) {
  1248. /*
  1249. * Enable promiscuous mode: receive all packets.
  1250. */
  1251. if (!lp->promiscuous) {
  1252. lp->promiscuous = 1;
  1253. lp->mc_count = 0;
  1254. wv_82586_reconfig(dev);
  1255. /* Tell the kernel that we are doing a really bad job. */
  1256. dev->flags |= IFF_PROMISC;
  1257. }
  1258. } else
  1259. /* Are there multicast addresses to send? */
  1260. if (dev->mc_list != (struct dev_mc_list *) NULL) {
  1261. /*
  1262. * Disable promiscuous mode, but receive all packets
  1263. * in multicast list
  1264. */
  1265. #ifdef MULTICAST_AVOID
  1266. if (lp->promiscuous || (dev->mc_count != lp->mc_count))
  1267. #endif
  1268. {
  1269. lp->promiscuous = 0;
  1270. lp->mc_count = dev->mc_count;
  1271. wv_82586_reconfig(dev);
  1272. }
  1273. } else {
  1274. /*
  1275. * Switch to normal mode: disable promiscuous mode and
  1276. * clear the multicast list.
  1277. */
  1278. if (lp->promiscuous || lp->mc_count == 0) {
  1279. lp->promiscuous = 0;
  1280. lp->mc_count = 0;
  1281. wv_82586_reconfig(dev);
  1282. }
  1283. }
  1284. #ifdef DEBUG_IOCTL_TRACE
  1285. printk(KERN_DEBUG "%s: <-wavelan_set_multicast_list()\n",
  1286. dev->name);
  1287. #endif
  1288. }
  1289. /*------------------------------------------------------------------*/
  1290. /*
  1291. * This function doesn't exist.
  1292. * (Note : it was a nice way to test the reconfigure stuff...)
  1293. */
  1294. #ifdef SET_MAC_ADDRESS
  1295. static int wavelan_set_mac_address(struct net_device * dev, void *addr)
  1296. {
  1297. struct sockaddr *mac = addr;
  1298. /* Copy the address. */
  1299. memcpy(dev->dev_addr, mac->sa_data, WAVELAN_ADDR_SIZE);
  1300. /* Reconfigure the beast. */
  1301. wv_82586_reconfig(dev);
  1302. return 0;
  1303. }
  1304. #endif /* SET_MAC_ADDRESS */
  1305. /*------------------------------------------------------------------*/
  1306. /*
  1307. * Frequency setting (for hardware capable of it)
  1308. * It's a bit complicated and you don't really want to look into it.
  1309. * (called in wavelan_ioctl)
  1310. */
  1311. static int wv_set_frequency(unsigned long ioaddr, /* I/O port of the card */
  1312. iw_freq * frequency)
  1313. {
  1314. const int BAND_NUM = 10; /* Number of bands */
  1315. long freq = 0L; /* offset to 2.4 GHz in .5 MHz */
  1316. #ifdef DEBUG_IOCTL_INFO
  1317. int i;
  1318. #endif
  1319. /* Setting by frequency */
  1320. /* Theoretically, you may set any frequency between
  1321. * the two limits with a 0.5 MHz precision. In practice,
  1322. * I don't want you to have trouble with local regulations.
  1323. */
  1324. if ((frequency->e == 1) &&
  1325. (frequency->m >= (int) 2.412e8)
  1326. && (frequency->m <= (int) 2.487e8)) {
  1327. freq = ((frequency->m / 10000) - 24000L) / 5;
  1328. }
  1329. /* Setting by channel (same as wfreqsel) */
  1330. /* Warning: each channel is 22 MHz wide, so some of the channels
  1331. * will interfere. */
  1332. if ((frequency->e == 0) && (frequency->m < BAND_NUM)) {
  1333. /* Get frequency offset. */
  1334. freq = channel_bands[frequency->m] >> 1;
  1335. }
  1336. /* Verify that the frequency is allowed. */
  1337. if (freq != 0L) {
  1338. u16 table[10]; /* Authorized frequency table */
  1339. /* Read the frequency table. */
  1340. fee_read(ioaddr, 0x71, table, 10);
  1341. #ifdef DEBUG_IOCTL_INFO
  1342. printk(KERN_DEBUG "Frequency table: ");
  1343. for (i = 0; i < 10; i++) {
  1344. printk(" %04X", table[i]);
  1345. }
  1346. printk("\n");
  1347. #endif
  1348. /* Look in the table to see whether the frequency is allowed. */
  1349. if (!(table[9 - ((freq - 24) / 16)] &
  1350. (1 << ((freq - 24) % 16)))) return -EINVAL; /* not allowed */
  1351. } else
  1352. return -EINVAL;
  1353. /* if we get a usable frequency */
  1354. if (freq != 0L) {
  1355. unsigned short area[16];
  1356. unsigned short dac[2];
  1357. unsigned short area_verify[16];
  1358. unsigned short dac_verify[2];
  1359. /* Corresponding gain (in the power adjust value table)
  1360. * See AT&T WaveLAN Data Manual, REF 407-024689/E, page 3-8
  1361. * and WCIN062D.DOC, page 6.2.9. */
  1362. unsigned short power_limit[] = { 40, 80, 120, 160, 0 };
  1363. int power_band = 0; /* Selected band */
  1364. unsigned short power_adjust; /* Correct value */
  1365. /* Search for the gain. */
  1366. power_band = 0;
  1367. while ((freq > power_limit[power_band]) &&
  1368. (power_limit[++power_band] != 0));
  1369. /* Read the first area. */
  1370. fee_read(ioaddr, 0x00, area, 16);
  1371. /* Read the DAC. */
  1372. fee_read(ioaddr, 0x60, dac, 2);
  1373. /* Read the new power adjust value. */
  1374. fee_read(ioaddr, 0x6B - (power_band >> 1), &power_adjust,
  1375. 1);
  1376. if (power_band & 0x1)
  1377. power_adjust >>= 8;
  1378. else
  1379. power_adjust &= 0xFF;
  1380. #ifdef DEBUG_IOCTL_INFO
  1381. printk(KERN_DEBUG "WaveLAN EEPROM Area 1: ");
  1382. for (i = 0; i < 16; i++) {
  1383. printk(" %04X", area[i]);
  1384. }
  1385. printk("\n");
  1386. printk(KERN_DEBUG "WaveLAN EEPROM DAC: %04X %04X\n",
  1387. dac[0], dac[1]);
  1388. #endif
  1389. /* Frequency offset (for info only) */
  1390. area[0] = ((freq << 5) & 0xFFE0) | (area[0] & 0x1F);
  1391. /* Receiver Principle main divider coefficient */
  1392. area[3] = (freq >> 1) + 2400L - 352L;
  1393. area[2] = ((freq & 0x1) << 4) | (area[2] & 0xFFEF);
  1394. /* Transmitter Main divider coefficient */
  1395. area[13] = (freq >> 1) + 2400L;
  1396. area[12] = ((freq & 0x1) << 4) | (area[2] & 0xFFEF);
  1397. /* Other parts of the area are flags, bit streams or unused. */
  1398. /* Set the value in the DAC. */
  1399. dac[1] = ((power_adjust >> 1) & 0x7F) | (dac[1] & 0xFF80);
  1400. dac[0] = ((power_adjust & 0x1) << 4) | (dac[0] & 0xFFEF);
  1401. /* Write the first area. */
  1402. fee_write(ioaddr, 0x00, area, 16);
  1403. /* Write the DAC. */
  1404. fee_write(ioaddr, 0x60, dac, 2);
  1405. /* We now should verify here that the writing of the EEPROM went OK. */
  1406. /* Reread the first area. */
  1407. fee_read(ioaddr, 0x00, area_verify, 16);
  1408. /* Reread the DAC. */
  1409. fee_read(ioaddr, 0x60, dac_verify, 2);
  1410. /* Compare. */
  1411. if (memcmp(area, area_verify, 16 * 2) ||
  1412. memcmp(dac, dac_verify, 2 * 2)) {
  1413. #ifdef DEBUG_IOCTL_ERROR
  1414. printk(KERN_INFO
  1415. "WaveLAN: wv_set_frequency: unable to write new frequency to EEPROM(?).\n");
  1416. #endif
  1417. return -EOPNOTSUPP;
  1418. }
  1419. /* We must download the frequency parameters to the
  1420. * synthesizers (from the EEPROM - area 1)
  1421. * Note: as the EEPROM is automatically decremented, we set the end
  1422. * if the area... */
  1423. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), 0x0F);
  1424. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
  1425. MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD);
  1426. /* Wait until the download is finished. */
  1427. fee_wait(ioaddr, 100, 100);
  1428. /* We must now download the power adjust value (gain) to
  1429. * the synthesizers (from the EEPROM - area 7 - DAC). */
  1430. mmc_out(ioaddr, mmwoff(0, mmw_fee_addr), 0x61);
  1431. mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl),
  1432. MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD);
  1433. /* Wait for the download to finish. */
  1434. fee_wait(ioaddr, 100, 100);
  1435. #ifdef DEBUG_IOCTL_INFO
  1436. /* Verification of what we have done */
  1437. printk(KERN_DEBUG "WaveLAN EEPROM Area 1: ");
  1438. for (i = 0; i < 16; i++) {
  1439. printk(" %04X", area_verify[i]);
  1440. }
  1441. printk("\n");
  1442. printk(KERN_DEBUG "WaveLAN EEPROM DAC: %04X %04X\n",
  1443. dac_verify[0], dac_verify[1]);
  1444. #endif
  1445. return 0;
  1446. } else
  1447. return -EINVAL; /* Bah, never get there... */
  1448. }
  1449. /*------------------------------------------------------------------*/
  1450. /*
  1451. * Give the list of available frequencies.
  1452. */
  1453. static int wv_frequency_list(unsigned long ioaddr, /* I/O port of the card */
  1454. iw_freq * list, /* List of frequencies to fill */
  1455. int max)
  1456. { /* Maximum number of frequencies */
  1457. u16 table[10]; /* Authorized frequency table */
  1458. long freq = 0L; /* offset to 2.4 GHz in .5 MHz + 12 MHz */
  1459. int i; /* index in the table */
  1460. int c = 0; /* Channel number */
  1461. /* Read the frequency table. */
  1462. fee_read(ioaddr, 0x71 /* frequency table */ , table, 10);
  1463. /* Check all frequencies. */
  1464. i = 0;
  1465. for (freq = 0; freq < 150; freq++)
  1466. /* Look in the table if the frequency is allowed */
  1467. if (table[9 - (freq / 16)] & (1 << (freq % 16))) {
  1468. /* Compute approximate channel number */
  1469. while ((((channel_bands[c] >> 1) - 24) < freq) &&
  1470. (c < NELS(channel_bands)))
  1471. c++;
  1472. list[i].i = c; /* Set the list index */
  1473. /* put in the list */
  1474. list[i].m = (((freq + 24) * 5) + 24000L) * 10000;
  1475. list[i++].e = 1;
  1476. /* Check number. */
  1477. if (i >= max)
  1478. return (i);
  1479. }
  1480. return (i);
  1481. }
  1482. #ifdef IW_WIRELESS_SPY
  1483. /*------------------------------------------------------------------*/
  1484. /*
  1485. * Gather wireless spy statistics: for each packet, compare the source
  1486. * address with our list, and if they match, get the statistics.
  1487. * Sorry, but this function really needs the wireless extensions.
  1488. */
  1489. static inline void wl_spy_gather(struct net_device * dev,
  1490. u8 * mac, /* MAC address */
  1491. u8 * stats) /* Statistics to gather */
  1492. {
  1493. struct iw_quality wstats;
  1494. wstats.qual = stats[2] & MMR_SGNL_QUAL;
  1495. wstats.level = stats[0] & MMR_SIGNAL_LVL;
  1496. wstats.noise = stats[1] & MMR_SILENCE_LVL;
  1497. wstats.updated = 0x7;
  1498. /* Update spy records */
  1499. wireless_spy_update(dev, mac, &wstats);
  1500. }
  1501. #endif /* IW_WIRELESS_SPY */
  1502. #ifdef HISTOGRAM
  1503. /*------------------------------------------------------------------*/
  1504. /*
  1505. * This function calculates a histogram of the signal level.
  1506. * As the noise is quite constant, it's like doing it on the SNR.
  1507. * We have defined a set of interval (lp->his_range), and each time
  1508. * the level goes in that interval, we increment the count (lp->his_sum).
  1509. * With this histogram you may detect if one WaveLAN is really weak,
  1510. * or you may also calculate the mean and standard deviation of the level.
  1511. */
  1512. static inline void wl_his_gather(struct net_device * dev, u8 * stats)
  1513. { /* Statistics to gather */
  1514. net_local *lp = (net_local *) dev->priv;
  1515. u8 level = stats[0] & MMR_SIGNAL_LVL;
  1516. int i;
  1517. /* Find the correct interval. */
  1518. i = 0;
  1519. while ((i < (lp->his_number - 1))
  1520. && (level >= lp->his_range[i++]));
  1521. /* Increment interval counter. */
  1522. (lp->his_sum[i])++;
  1523. }
  1524. #endif /* HISTOGRAM */
  1525. /*------------------------------------------------------------------*/
  1526. /*
  1527. * Wireless Handler : get protocol name
  1528. */
  1529. static int wavelan_get_name(struct net_device *dev,
  1530. struct iw_request_info *info,
  1531. union iwreq_data *wrqu,
  1532. char *extra)
  1533. {
  1534. strcpy(wrqu->name, "WaveLAN");
  1535. return 0;
  1536. }
  1537. /*------------------------------------------------------------------*/
  1538. /*
  1539. * Wireless Handler : set NWID
  1540. */
  1541. static int wavelan_set_nwid(struct net_device *dev,
  1542. struct iw_request_info *info,
  1543. union iwreq_data *wrqu,
  1544. char *extra)
  1545. {
  1546. unsigned long ioaddr = dev->base_addr;
  1547. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1548. psa_t psa;
  1549. mm_t m;
  1550. unsigned long flags;
  1551. int ret = 0;
  1552. /* Disable interrupts and save flags. */
  1553. spin_lock_irqsave(&lp->spinlock, flags);
  1554. /* Set NWID in WaveLAN. */
  1555. if (!wrqu->nwid.disabled) {
  1556. /* Set NWID in psa */
  1557. psa.psa_nwid[0] = (wrqu->nwid.value & 0xFF00) >> 8;
  1558. psa.psa_nwid[1] = wrqu->nwid.value & 0xFF;
  1559. psa.psa_nwid_select = 0x01;
  1560. psa_write(ioaddr, lp->hacr,
  1561. (char *) psa.psa_nwid - (char *) &psa,
  1562. (unsigned char *) psa.psa_nwid, 3);
  1563. /* Set NWID in mmc. */
  1564. m.w.mmw_netw_id_l = psa.psa_nwid[1];
  1565. m.w.mmw_netw_id_h = psa.psa_nwid[0];
  1566. mmc_write(ioaddr,
  1567. (char *) &m.w.mmw_netw_id_l -
  1568. (char *) &m,
  1569. (unsigned char *) &m.w.mmw_netw_id_l, 2);
  1570. mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel), 0x00);
  1571. } else {
  1572. /* Disable NWID in the psa. */
  1573. psa.psa_nwid_select = 0x00;
  1574. psa_write(ioaddr, lp->hacr,
  1575. (char *) &psa.psa_nwid_select -
  1576. (char *) &psa,
  1577. (unsigned char *) &psa.psa_nwid_select,
  1578. 1);
  1579. /* Disable NWID in the mmc (no filtering). */
  1580. mmc_out(ioaddr, mmwoff(0, mmw_loopt_sel),
  1581. MMW_LOOPT_SEL_DIS_NWID);
  1582. }
  1583. /* update the Wavelan checksum */
  1584. update_psa_checksum(dev, ioaddr, lp->hacr);
  1585. /* Enable interrupts and restore flags. */
  1586. spin_unlock_irqrestore(&lp->spinlock, flags);
  1587. return ret;
  1588. }
  1589. /*------------------------------------------------------------------*/
  1590. /*
  1591. * Wireless Handler : get NWID
  1592. */
  1593. static int wavelan_get_nwid(struct net_device *dev,
  1594. struct iw_request_info *info,
  1595. union iwreq_data *wrqu,
  1596. char *extra)
  1597. {
  1598. unsigned long ioaddr = dev->base_addr;
  1599. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1600. psa_t psa;
  1601. unsigned long flags;
  1602. int ret = 0;
  1603. /* Disable interrupts and save flags. */
  1604. spin_lock_irqsave(&lp->spinlock, flags);
  1605. /* Read the NWID. */
  1606. psa_read(ioaddr, lp->hacr,
  1607. (char *) psa.psa_nwid - (char *) &psa,
  1608. (unsigned char *) psa.psa_nwid, 3);
  1609. wrqu->nwid.value = (psa.psa_nwid[0] << 8) + psa.psa_nwid[1];
  1610. wrqu->nwid.disabled = !(psa.psa_nwid_select);
  1611. wrqu->nwid.fixed = 1; /* Superfluous */
  1612. /* Enable interrupts and restore flags. */
  1613. spin_unlock_irqrestore(&lp->spinlock, flags);
  1614. return ret;
  1615. }
  1616. /*------------------------------------------------------------------*/
  1617. /*
  1618. * Wireless Handler : set frequency
  1619. */
  1620. static int wavelan_set_freq(struct net_device *dev,
  1621. struct iw_request_info *info,
  1622. union iwreq_data *wrqu,
  1623. char *extra)
  1624. {
  1625. unsigned long ioaddr = dev->base_addr;
  1626. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1627. unsigned long flags;
  1628. int ret;
  1629. /* Disable interrupts and save flags. */
  1630. spin_lock_irqsave(&lp->spinlock, flags);
  1631. /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
  1632. if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
  1633. (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY)))
  1634. ret = wv_set_frequency(ioaddr, &(wrqu->freq));
  1635. else
  1636. ret = -EOPNOTSUPP;
  1637. /* Enable interrupts and restore flags. */
  1638. spin_unlock_irqrestore(&lp->spinlock, flags);
  1639. return ret;
  1640. }
  1641. /*------------------------------------------------------------------*/
  1642. /*
  1643. * Wireless Handler : get frequency
  1644. */
  1645. static int wavelan_get_freq(struct net_device *dev,
  1646. struct iw_request_info *info,
  1647. union iwreq_data *wrqu,
  1648. char *extra)
  1649. {
  1650. unsigned long ioaddr = dev->base_addr;
  1651. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1652. psa_t psa;
  1653. unsigned long flags;
  1654. int ret = 0;
  1655. /* Disable interrupts and save flags. */
  1656. spin_lock_irqsave(&lp->spinlock, flags);
  1657. /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable).
  1658. * Does it work for everybody, especially old cards? */
  1659. if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
  1660. (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
  1661. unsigned short freq;
  1662. /* Ask the EEPROM to read the frequency from the first area. */
  1663. fee_read(ioaddr, 0x00, &freq, 1);
  1664. wrqu->freq.m = ((freq >> 5) * 5 + 24000L) * 10000;
  1665. wrqu->freq.e = 1;
  1666. } else {
  1667. psa_read(ioaddr, lp->hacr,
  1668. (char *) &psa.psa_subband - (char *) &psa,
  1669. (unsigned char *) &psa.psa_subband, 1);
  1670. if (psa.psa_subband <= 4) {
  1671. wrqu->freq.m = fixed_bands[psa.psa_subband];
  1672. wrqu->freq.e = (psa.psa_subband != 0);
  1673. } else
  1674. ret = -EOPNOTSUPP;
  1675. }
  1676. /* Enable interrupts and restore flags. */
  1677. spin_unlock_irqrestore(&lp->spinlock, flags);
  1678. return ret;
  1679. }
  1680. /*------------------------------------------------------------------*/
  1681. /*
  1682. * Wireless Handler : set level threshold
  1683. */
  1684. static int wavelan_set_sens(struct net_device *dev,
  1685. struct iw_request_info *info,
  1686. union iwreq_data *wrqu,
  1687. char *extra)
  1688. {
  1689. unsigned long ioaddr = dev->base_addr;
  1690. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1691. psa_t psa;
  1692. unsigned long flags;
  1693. int ret = 0;
  1694. /* Disable interrupts and save flags. */
  1695. spin_lock_irqsave(&lp->spinlock, flags);
  1696. /* Set the level threshold. */
  1697. /* We should complain loudly if wrqu->sens.fixed = 0, because we
  1698. * can't set auto mode... */
  1699. psa.psa_thr_pre_set = wrqu->sens.value & 0x3F;
  1700. psa_write(ioaddr, lp->hacr,
  1701. (char *) &psa.psa_thr_pre_set - (char *) &psa,
  1702. (unsigned char *) &psa.psa_thr_pre_set, 1);
  1703. /* update the Wavelan checksum */
  1704. update_psa_checksum(dev, ioaddr, lp->hacr);
  1705. mmc_out(ioaddr, mmwoff(0, mmw_thr_pre_set),
  1706. psa.psa_thr_pre_set);
  1707. /* Enable interrupts and restore flags. */
  1708. spin_unlock_irqrestore(&lp->spinlock, flags);
  1709. return ret;
  1710. }
  1711. /*------------------------------------------------------------------*/
  1712. /*
  1713. * Wireless Handler : get level threshold
  1714. */
  1715. static int wavelan_get_sens(struct net_device *dev,
  1716. struct iw_request_info *info,
  1717. union iwreq_data *wrqu,
  1718. char *extra)
  1719. {
  1720. unsigned long ioaddr = dev->base_addr;
  1721. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1722. psa_t psa;
  1723. unsigned long flags;
  1724. int ret = 0;
  1725. /* Disable interrupts and save flags. */
  1726. spin_lock_irqsave(&lp->spinlock, flags);
  1727. /* Read the level threshold. */
  1728. psa_read(ioaddr, lp->hacr,
  1729. (char *) &psa.psa_thr_pre_set - (char *) &psa,
  1730. (unsigned char *) &psa.psa_thr_pre_set, 1);
  1731. wrqu->sens.value = psa.psa_thr_pre_set & 0x3F;
  1732. wrqu->sens.fixed = 1;
  1733. /* Enable interrupts and restore flags. */
  1734. spin_unlock_irqrestore(&lp->spinlock, flags);
  1735. return ret;
  1736. }
  1737. /*------------------------------------------------------------------*/
  1738. /*
  1739. * Wireless Handler : set encryption key
  1740. */
  1741. static int wavelan_set_encode(struct net_device *dev,
  1742. struct iw_request_info *info,
  1743. union iwreq_data *wrqu,
  1744. char *extra)
  1745. {
  1746. unsigned long ioaddr = dev->base_addr;
  1747. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1748. unsigned long flags;
  1749. psa_t psa;
  1750. int ret = 0;
  1751. /* Disable interrupts and save flags. */
  1752. spin_lock_irqsave(&lp->spinlock, flags);
  1753. /* Check if capable of encryption */
  1754. if (!mmc_encr(ioaddr)) {
  1755. ret = -EOPNOTSUPP;
  1756. }
  1757. /* Check the size of the key */
  1758. if((wrqu->encoding.length != 8) && (wrqu->encoding.length != 0)) {
  1759. ret = -EINVAL;
  1760. }
  1761. if(!ret) {
  1762. /* Basic checking... */
  1763. if (wrqu->encoding.length == 8) {
  1764. /* Copy the key in the driver */
  1765. memcpy(psa.psa_encryption_key, extra,
  1766. wrqu->encoding.length);
  1767. psa.psa_encryption_select = 1;
  1768. psa_write(ioaddr, lp->hacr,
  1769. (char *) &psa.psa_encryption_select -
  1770. (char *) &psa,
  1771. (unsigned char *) &psa.
  1772. psa_encryption_select, 8 + 1);
  1773. mmc_out(ioaddr, mmwoff(0, mmw_encr_enable),
  1774. MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE);
  1775. mmc_write(ioaddr, mmwoff(0, mmw_encr_key),
  1776. (unsigned char *) &psa.
  1777. psa_encryption_key, 8);
  1778. }
  1779. /* disable encryption */
  1780. if (wrqu->encoding.flags & IW_ENCODE_DISABLED) {
  1781. psa.psa_encryption_select = 0;
  1782. psa_write(ioaddr, lp->hacr,
  1783. (char *) &psa.psa_encryption_select -
  1784. (char *) &psa,
  1785. (unsigned char *) &psa.
  1786. psa_encryption_select, 1);
  1787. mmc_out(ioaddr, mmwoff(0, mmw_encr_enable), 0);
  1788. }
  1789. /* update the Wavelan checksum */
  1790. update_psa_checksum(dev, ioaddr, lp->hacr);
  1791. }
  1792. /* Enable interrupts and restore flags. */
  1793. spin_unlock_irqrestore(&lp->spinlock, flags);
  1794. return ret;
  1795. }
  1796. /*------------------------------------------------------------------*/
  1797. /*
  1798. * Wireless Handler : get encryption key
  1799. */
  1800. static int wavelan_get_encode(struct net_device *dev,
  1801. struct iw_request_info *info,
  1802. union iwreq_data *wrqu,
  1803. char *extra)
  1804. {
  1805. unsigned long ioaddr = dev->base_addr;
  1806. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1807. psa_t psa;
  1808. unsigned long flags;
  1809. int ret = 0;
  1810. /* Disable interrupts and save flags. */
  1811. spin_lock_irqsave(&lp->spinlock, flags);
  1812. /* Check if encryption is available */
  1813. if (!mmc_encr(ioaddr)) {
  1814. ret = -EOPNOTSUPP;
  1815. } else {
  1816. /* Read the encryption key */
  1817. psa_read(ioaddr, lp->hacr,
  1818. (char *) &psa.psa_encryption_select -
  1819. (char *) &psa,
  1820. (unsigned char *) &psa.
  1821. psa_encryption_select, 1 + 8);
  1822. /* encryption is enabled ? */
  1823. if (psa.psa_encryption_select)
  1824. wrqu->encoding.flags = IW_ENCODE_ENABLED;
  1825. else
  1826. wrqu->encoding.flags = IW_ENCODE_DISABLED;
  1827. wrqu->encoding.flags |= mmc_encr(ioaddr);
  1828. /* Copy the key to the user buffer */
  1829. wrqu->encoding.length = 8;
  1830. memcpy(extra, psa.psa_encryption_key, wrqu->encoding.length);
  1831. }
  1832. /* Enable interrupts and restore flags. */
  1833. spin_unlock_irqrestore(&lp->spinlock, flags);
  1834. return ret;
  1835. }
  1836. /*------------------------------------------------------------------*/
  1837. /*
  1838. * Wireless Handler : get range info
  1839. */
  1840. static int wavelan_get_range(struct net_device *dev,
  1841. struct iw_request_info *info,
  1842. union iwreq_data *wrqu,
  1843. char *extra)
  1844. {
  1845. unsigned long ioaddr = dev->base_addr;
  1846. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1847. struct iw_range *range = (struct iw_range *) extra;
  1848. unsigned long flags;
  1849. int ret = 0;
  1850. /* Set the length (very important for backward compatibility) */
  1851. wrqu->data.length = sizeof(struct iw_range);
  1852. /* Set all the info we don't care or don't know about to zero */
  1853. memset(range, 0, sizeof(struct iw_range));
  1854. /* Set the Wireless Extension versions */
  1855. range->we_version_compiled = WIRELESS_EXT;
  1856. range->we_version_source = 9;
  1857. /* Set information in the range struct. */
  1858. range->throughput = 1.6 * 1000 * 1000; /* don't argue on this ! */
  1859. range->min_nwid = 0x0000;
  1860. range->max_nwid = 0xFFFF;
  1861. range->sensitivity = 0x3F;
  1862. range->max_qual.qual = MMR_SGNL_QUAL;
  1863. range->max_qual.level = MMR_SIGNAL_LVL;
  1864. range->max_qual.noise = MMR_SILENCE_LVL;
  1865. range->avg_qual.qual = MMR_SGNL_QUAL; /* Always max */
  1866. /* Need to get better values for those two */
  1867. range->avg_qual.level = 30;
  1868. range->avg_qual.noise = 8;
  1869. range->num_bitrates = 1;
  1870. range->bitrate[0] = 2000000; /* 2 Mb/s */
  1871. /* Event capability (kernel + driver) */
  1872. range->event_capa[0] = (IW_EVENT_CAPA_MASK(0x8B02) |
  1873. IW_EVENT_CAPA_MASK(0x8B04));
  1874. range->event_capa[1] = IW_EVENT_CAPA_K_1;
  1875. /* Disable interrupts and save flags. */
  1876. spin_lock_irqsave(&lp->spinlock, flags);
  1877. /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable). */
  1878. if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
  1879. (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
  1880. range->num_channels = 10;
  1881. range->num_frequency = wv_frequency_list(ioaddr, range->freq,
  1882. IW_MAX_FREQUENCIES);
  1883. } else
  1884. range->num_channels = range->num_frequency = 0;
  1885. /* Encryption supported ? */
  1886. if (mmc_encr(ioaddr)) {
  1887. range->encoding_size[0] = 8; /* DES = 64 bits key */
  1888. range->num_encoding_sizes = 1;
  1889. range->max_encoding_tokens = 1; /* Only one key possible */
  1890. } else {
  1891. range->num_encoding_sizes = 0;
  1892. range->max_encoding_tokens = 0;
  1893. }
  1894. /* Enable interrupts and restore flags. */
  1895. spin_unlock_irqrestore(&lp->spinlock, flags);
  1896. return ret;
  1897. }
  1898. /*------------------------------------------------------------------*/
  1899. /*
  1900. * Wireless Private Handler : set quality threshold
  1901. */
  1902. static int wavelan_set_qthr(struct net_device *dev,
  1903. struct iw_request_info *info,
  1904. union iwreq_data *wrqu,
  1905. char *extra)
  1906. {
  1907. unsigned long ioaddr = dev->base_addr;
  1908. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1909. psa_t psa;
  1910. unsigned long flags;
  1911. /* Disable interrupts and save flags. */
  1912. spin_lock_irqsave(&lp->spinlock, flags);
  1913. psa.psa_quality_thr = *(extra) & 0x0F;
  1914. psa_write(ioaddr, lp->hacr,
  1915. (char *) &psa.psa_quality_thr - (char *) &psa,
  1916. (unsigned char *) &psa.psa_quality_thr, 1);
  1917. /* update the Wavelan checksum */
  1918. update_psa_checksum(dev, ioaddr, lp->hacr);
  1919. mmc_out(ioaddr, mmwoff(0, mmw_quality_thr),
  1920. psa.psa_quality_thr);
  1921. /* Enable interrupts and restore flags. */
  1922. spin_unlock_irqrestore(&lp->spinlock, flags);
  1923. return 0;
  1924. }
  1925. /*------------------------------------------------------------------*/
  1926. /*
  1927. * Wireless Private Handler : get quality threshold
  1928. */
  1929. static int wavelan_get_qthr(struct net_device *dev,
  1930. struct iw_request_info *info,
  1931. union iwreq_data *wrqu,
  1932. char *extra)
  1933. {
  1934. unsigned long ioaddr = dev->base_addr;
  1935. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1936. psa_t psa;
  1937. unsigned long flags;
  1938. /* Disable interrupts and save flags. */
  1939. spin_lock_irqsave(&lp->spinlock, flags);
  1940. psa_read(ioaddr, lp->hacr,
  1941. (char *) &psa.psa_quality_thr - (char *) &psa,
  1942. (unsigned char *) &psa.psa_quality_thr, 1);
  1943. *(extra) = psa.psa_quality_thr & 0x0F;
  1944. /* Enable interrupts and restore flags. */
  1945. spin_unlock_irqrestore(&lp->spinlock, flags);
  1946. return 0;
  1947. }
  1948. #ifdef HISTOGRAM
  1949. /*------------------------------------------------------------------*/
  1950. /*
  1951. * Wireless Private Handler : set histogram
  1952. */
  1953. static int wavelan_set_histo(struct net_device *dev,
  1954. struct iw_request_info *info,
  1955. union iwreq_data *wrqu,
  1956. char *extra)
  1957. {
  1958. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1959. /* Check the number of intervals. */
  1960. if (wrqu->data.length > 16) {
  1961. return(-E2BIG);
  1962. }
  1963. /* Disable histo while we copy the addresses.
  1964. * As we don't disable interrupts, we need to do this */
  1965. lp->his_number = 0;
  1966. /* Are there ranges to copy? */
  1967. if (wrqu->data.length > 0) {
  1968. /* Copy interval ranges to the driver */
  1969. memcpy(lp->his_range, extra, wrqu->data.length);
  1970. {
  1971. int i;
  1972. printk(KERN_DEBUG "Histo :");
  1973. for(i = 0; i < wrqu->data.length; i++)
  1974. printk(" %d", lp->his_range[i]);
  1975. printk("\n");
  1976. }
  1977. /* Reset result structure. */
  1978. memset(lp->his_sum, 0x00, sizeof(long) * 16);
  1979. }
  1980. /* Now we can set the number of ranges */
  1981. lp->his_number = wrqu->data.length;
  1982. return(0);
  1983. }
  1984. /*------------------------------------------------------------------*/
  1985. /*
  1986. * Wireless Private Handler : get histogram
  1987. */
  1988. static int wavelan_get_histo(struct net_device *dev,
  1989. struct iw_request_info *info,
  1990. union iwreq_data *wrqu,
  1991. char *extra)
  1992. {
  1993. net_local *lp = (net_local *) dev->priv; /* lp is not unused */
  1994. /* Set the number of intervals. */
  1995. wrqu->data.length = lp->his_number;
  1996. /* Give back the distribution statistics */
  1997. if(lp->his_number > 0)
  1998. memcpy(extra, lp->his_sum, sizeof(long) * lp->his_number);
  1999. return(0);
  2000. }
  2001. #endif /* HISTOGRAM */
  2002. /*------------------------------------------------------------------*/
  2003. /*
  2004. * Structures to export the Wireless Handlers
  2005. */
  2006. static const iw_handler wavelan_handler[] =
  2007. {
  2008. NULL, /* SIOCSIWNAME */
  2009. wavelan_get_name, /* SIOCGIWNAME */
  2010. wavelan_set_nwid, /* SIOCSIWNWID */
  2011. wavelan_get_nwid, /* SIOCGIWNWID */
  2012. wavelan_set_freq, /* SIOCSIWFREQ */
  2013. wavelan_get_freq, /* SIOCGIWFREQ */
  2014. NULL, /* SIOCSIWMODE */
  2015. NULL, /* SIOCGIWMODE */
  2016. wavelan_set_sens, /* SIOCSIWSENS */
  2017. wavelan_get_sens, /* SIOCGIWSENS */
  2018. NULL, /* SIOCSIWRANGE */
  2019. wavelan_get_range, /* SIOCGIWRANGE */
  2020. NULL, /* SIOCSIWPRIV */
  2021. NULL, /* SIOCGIWPRIV */
  2022. NULL, /* SIOCSIWSTATS */
  2023. NULL, /* SIOCGIWSTATS */
  2024. iw_handler_set_spy, /* SIOCSIWSPY */
  2025. iw_handler_get_spy, /* SIOCGIWSPY */
  2026. iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
  2027. iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
  2028. NULL, /* SIOCSIWAP */
  2029. NULL, /* SIOCGIWAP */
  2030. NULL, /* -- hole -- */
  2031. NULL, /* SIOCGIWAPLIST */
  2032. NULL, /* -- hole -- */
  2033. NULL, /* -- hole -- */
  2034. NULL, /* SIOCSIWESSID */
  2035. NULL, /* SIOCGIWESSID */
  2036. NULL, /* SIOCSIWNICKN */
  2037. NULL, /* SIOCGIWNICKN */
  2038. NULL, /* -- hole -- */
  2039. NULL, /* -- hole -- */
  2040. NULL, /* SIOCSIWRATE */
  2041. NULL, /* SIOCGIWRATE */
  2042. NULL, /* SIOCSIWRTS */
  2043. NULL, /* SIOCGIWRTS */
  2044. NULL, /* SIOCSIWFRAG */
  2045. NULL, /* SIOCGIWFRAG */
  2046. NULL, /* SIOCSIWTXPOW */
  2047. NULL, /* SIOCGIWTXPOW */
  2048. NULL, /* SIOCSIWRETRY */
  2049. NULL, /* SIOCGIWRETRY */
  2050. /* Bummer ! Why those are only at the end ??? */
  2051. wavelan_set_encode, /* SIOCSIWENCODE */
  2052. wavelan_get_encode, /* SIOCGIWENCODE */
  2053. };
  2054. static const iw_handler wavelan_private_handler[] =
  2055. {
  2056. wavelan_set_qthr, /* SIOCIWFIRSTPRIV */
  2057. wavelan_get_qthr, /* SIOCIWFIRSTPRIV + 1 */
  2058. #ifdef HISTOGRAM
  2059. wavelan_set_histo, /* SIOCIWFIRSTPRIV + 2 */
  2060. wavelan_get_histo, /* SIOCIWFIRSTPRIV + 3 */
  2061. #endif /* HISTOGRAM */
  2062. };
  2063. static const struct iw_priv_args wavelan_private_args[] = {
  2064. /*{ cmd, set_args, get_args, name } */
  2065. { SIOCSIPQTHR, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "setqualthr" },
  2066. { SIOCGIPQTHR, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "getqualthr" },
  2067. { SIOCSIPHISTO, IW_PRIV_TYPE_BYTE | 16, 0, "sethisto" },
  2068. { SIOCGIPHISTO, 0, IW_PRIV_TYPE_INT | 16, "gethisto" },
  2069. };
  2070. static const struct iw_handler_def wavelan_handler_def =
  2071. {
  2072. .num_standard = sizeof(wavelan_handler)/sizeof(iw_handler),
  2073. .num_private = sizeof(wavelan_private_handler)/sizeof(iw_handler),
  2074. .num_private_args = sizeof(wavelan_private_args)/sizeof(struct iw_priv_args),
  2075. .standard = wavelan_handler,
  2076. .private = wavelan_private_handler,
  2077. .private_args = wavelan_private_args,
  2078. .get_wireless_stats = wavelan_get_wireless_stats,
  2079. };
  2080. /*------------------------------------------------------------------*/
  2081. /*
  2082. * Get wireless statistics.
  2083. * Called by /proc/net/wireless
  2084. */
  2085. static iw_stats *wavelan_get_wireless_stats(struct net_device * dev)
  2086. {
  2087. unsigned long ioaddr = dev->base_addr;
  2088. net_local *lp = (net_local *) dev->priv;
  2089. mmr_t m;
  2090. iw_stats *wstats;
  2091. unsigned long flags;
  2092. #ifdef DEBUG_IOCTL_TRACE
  2093. printk(KERN_DEBUG "%s: ->wavelan_get_wireless_stats()\n",
  2094. dev->name);
  2095. #endif
  2096. /* Check */
  2097. if (lp == (net_local *) NULL)
  2098. return (iw_stats *) NULL;
  2099. /* Disable interrupts and save flags. */
  2100. spin_lock_irqsave(&lp->spinlock, flags);
  2101. wstats = &lp->wstats;
  2102. /* Get data from the mmc. */
  2103. mmc_out(ioaddr, mmwoff(0, mmw_freeze), 1);
  2104. mmc_read(ioaddr, mmroff(0, mmr_dce_status), &m.mmr_dce_status, 1);
  2105. mmc_read(ioaddr, mmroff(0, mmr_wrong_nwid_l), &m.mmr_wrong_nwid_l,
  2106. 2);
  2107. mmc_read(ioaddr, mmroff(0, mmr_thr_pre_set), &m.mmr_thr_pre_set,
  2108. 4);
  2109. mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0);
  2110. /* Copy data to wireless stuff. */
  2111. wstats->status = m.mmr_dce_status & MMR_DCE_STATUS;
  2112. wstats->qual.qual = m.mmr_sgnl_qual & MMR_SGNL_QUAL;
  2113. wstats->qual.level = m.mmr_signal_lvl & MMR_SIGNAL_LVL;
  2114. wstats->qual.noise = m.mmr_silence_lvl & MMR_SILENCE_LVL;
  2115. wstats->qual.updated = (((m. mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) >> 7)
  2116. | ((m.mmr_signal_lvl & MMR_SIGNAL_LVL_VALID) >> 6)
  2117. | ((m.mmr_silence_lvl & MMR_SILENCE_LVL_VALID) >> 5));
  2118. wstats->discard.nwid += (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
  2119. wstats->discard.code = 0L;
  2120. wstats->discard.misc = 0L;
  2121. /* Enable interrupts and restore flags. */
  2122. spin_unlock_irqrestore(&lp->spinlock, flags);
  2123. #ifdef DEBUG_IOCTL_TRACE
  2124. printk(KERN_DEBUG "%s: <-wavelan_get_wireless_stats()\n",
  2125. dev->name);
  2126. #endif
  2127. return &lp->wstats;
  2128. }
  2129. /************************* PACKET RECEPTION *************************/
  2130. /*
  2131. * This part deals with receiving the packets.
  2132. * The interrupt handler gets an interrupt when a packet has been
  2133. * successfully received and calls this part.
  2134. */
  2135. /*------------------------------------------------------------------*/
  2136. /*
  2137. * This routine does the actual copying of data (including the Ethernet
  2138. * header structure) from the WaveLAN card to an sk_buff chain that
  2139. * will be passed up to the network interface layer. NOTE: we
  2140. * currently don't handle trailer protocols (neither does the rest of
  2141. * the network interface), so if that is needed, it will (at least in
  2142. * part) be added here. The contents of the receive ring buffer are
  2143. * copied to a message chain that is then passed to the kernel.
  2144. *
  2145. * Note: if any errors occur, the packet is "dropped on the floor".
  2146. * (called by wv_packet_rcv())
  2147. */
  2148. static void
  2149. wv_packet_read(struct net_device * dev, u16 buf_off, int sksize)
  2150. {
  2151. net_local *lp = (net_local *) dev->priv;
  2152. unsigned long ioaddr = dev->base_addr;
  2153. struct sk_buff *skb;
  2154. #ifdef DEBUG_RX_TRACE
  2155. printk(KERN_DEBUG "%s: ->wv_packet_read(0x%X, %d)\n",
  2156. dev->name, buf_off, sksize);
  2157. #endif
  2158. /* Allocate buffer for the data */
  2159. if ((skb = dev_alloc_skb(sksize)) == (struct sk_buff *) NULL) {
  2160. #ifdef DEBUG_RX_ERROR
  2161. printk(KERN_INFO
  2162. "%s: wv_packet_read(): could not alloc_skb(%d, GFP_ATOMIC).\n",
  2163. dev->name, sksize);
  2164. #endif
  2165. lp->stats.rx_dropped++;
  2166. return;
  2167. }
  2168. skb->dev = dev;
  2169. /* Copy the packet to the buffer. */
  2170. obram_read(ioaddr, buf_off, skb_put(skb, sksize), sksize);
  2171. skb->protocol = eth_type_trans(skb, dev);
  2172. #ifdef DEBUG_RX_INFO
  2173. wv_packet_info(skb->mac.raw, sksize, dev->name, "wv_packet_read");
  2174. #endif /* DEBUG_RX_INFO */
  2175. /* Statistics-gathering and associated stuff.
  2176. * It seem a bit messy with all the define, but it's really
  2177. * simple... */
  2178. if (
  2179. #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
  2180. (lp->spy_data.spy_number > 0) ||
  2181. #endif /* IW_WIRELESS_SPY */
  2182. #ifdef HISTOGRAM
  2183. (lp->his_number > 0) ||
  2184. #endif /* HISTOGRAM */
  2185. 0) {
  2186. u8 stats[3]; /* signal level, noise level, signal quality */
  2187. /* Read signal level, silence level and signal quality bytes */
  2188. /* Note: in the PCMCIA hardware, these are part of the frame.
  2189. * It seems that for the ISA hardware, it's nowhere to be
  2190. * found in the frame, so I'm obliged to do this (it has a
  2191. * side effect on /proc/net/wireless).
  2192. * Any ideas?
  2193. */
  2194. mmc_out(ioaddr, mmwoff(0, mmw_freeze), 1);
  2195. mmc_read(ioaddr, mmroff(0, mmr_signal_lvl), stats, 3);
  2196. mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0);
  2197. #ifdef DEBUG_RX_INFO
  2198. printk(KERN_DEBUG
  2199. "%s: wv_packet_read(): Signal level %d/63, Silence level %d/63, signal quality %d/16\n",
  2200. dev->name, stats[0] & 0x3F, stats[1] & 0x3F,
  2201. stats[2] & 0x0F);
  2202. #endif
  2203. /* Spying stuff */
  2204. #ifdef IW_WIRELESS_SPY
  2205. wl_spy_gather(dev, skb->mac.raw + WAVELAN_ADDR_SIZE,
  2206. stats);
  2207. #endif /* IW_WIRELESS_SPY */
  2208. #ifdef HISTOGRAM
  2209. wl_his_gather(dev, stats);
  2210. #endif /* HISTOGRAM */
  2211. }
  2212. /*
  2213. * Hand the packet to the network module.
  2214. */
  2215. netif_rx(skb);
  2216. /* Keep statistics up to date */
  2217. dev->last_rx = jiffies;
  2218. lp->stats.rx_packets++;
  2219. lp->stats.rx_bytes += sksize;
  2220. #ifdef DEBUG_RX_TRACE
  2221. printk(KERN_DEBUG "%s: <-wv_packet_read()\n", dev->name);
  2222. #endif
  2223. }
  2224. /*------------------------------------------------------------------*/
  2225. /*
  2226. * Transfer as many packets as we can
  2227. * from the device RAM.
  2228. * (called in wavelan_interrupt()).
  2229. * Note : the spinlock is already grabbed for us.
  2230. */
  2231. static void wv_receive(struct net_device * dev)
  2232. {
  2233. unsigned long ioaddr = dev->base_addr;
  2234. net_local *lp = (net_local *) dev->priv;
  2235. fd_t fd;
  2236. rbd_t rbd;
  2237. int nreaped = 0;
  2238. #ifdef DEBUG_RX_TRACE
  2239. printk(KERN_DEBUG "%s: ->wv_receive()\n", dev->name);
  2240. #endif
  2241. /* Loop on each received packet. */
  2242. for (;;) {
  2243. obram_read(ioaddr, lp->rx_head, (unsigned char *) &fd,
  2244. sizeof(fd));
  2245. /* Note about the status :
  2246. * It start up to be 0 (the value we set). Then, when the RU
  2247. * grab the buffer to prepare for reception, it sets the
  2248. * FD_STATUS_B flag. When the RU has finished receiving the
  2249. * frame, it clears FD_STATUS_B, set FD_STATUS_C to indicate
  2250. * completion and set the other flags to indicate the eventual
  2251. * errors. FD_STATUS_OK indicates that the reception was OK.
  2252. */
  2253. /* If the current frame is not complete, we have reached the end. */
  2254. if ((fd.fd_status & FD_STATUS_C) != FD_STATUS_C)
  2255. break; /* This is how we exit the loop. */
  2256. nreaped++;
  2257. /* Check whether frame was correctly received. */
  2258. if ((fd.fd_status & FD_STATUS_OK) == FD_STATUS_OK) {
  2259. /* Does the frame contain a pointer to the data? Let's check. */
  2260. if (fd.fd_rbd_offset != I82586NULL) {
  2261. /* Read the receive buffer descriptor */
  2262. obram_read(ioaddr, fd.fd_rbd_offset,
  2263. (unsigned char *) &rbd,
  2264. sizeof(rbd));
  2265. #ifdef DEBUG_RX_ERROR
  2266. if ((rbd.rbd_status & RBD_STATUS_EOF) !=
  2267. RBD_STATUS_EOF) printk(KERN_INFO
  2268. "%s: wv_receive(): missing EOF flag.\n",
  2269. dev->name);
  2270. if ((rbd.rbd_status & RBD_STATUS_F) !=
  2271. RBD_STATUS_F) printk(KERN_INFO
  2272. "%s: wv_receive(): missing F flag.\n",
  2273. dev->name);
  2274. #endif /* DEBUG_RX_ERROR */
  2275. /* Read the packet and transmit to Linux */
  2276. wv_packet_read(dev, rbd.rbd_bufl,
  2277. rbd.
  2278. rbd_status &
  2279. RBD_STATUS_ACNT);
  2280. }
  2281. #ifdef DEBUG_RX_ERROR
  2282. else /* if frame has no data */
  2283. printk(KERN_INFO
  2284. "%s: wv_receive(): frame has no data.\n",
  2285. dev->name);
  2286. #endif
  2287. } else { /* If reception was no successful */
  2288. lp->stats.rx_errors++;
  2289. #ifdef DEBUG_RX_INFO
  2290. printk(KERN_DEBUG
  2291. "%s: wv_receive(): frame not received successfully (%X).\n",
  2292. dev->name, fd.fd_status);
  2293. #endif
  2294. #ifdef DEBUG_RX_ERROR
  2295. if ((fd.fd_status & FD_STATUS_S6) != 0)
  2296. printk(KERN_INFO
  2297. "%s: wv_receive(): no EOF flag.\n",
  2298. dev->name);
  2299. #endif
  2300. if ((fd.fd_status & FD_STATUS_S7) != 0) {
  2301. lp->stats.rx_length_errors++;
  2302. #ifdef DEBUG_RX_FAIL
  2303. printk(KERN_DEBUG
  2304. "%s: wv_receive(): frame too short.\n",
  2305. dev->name);
  2306. #endif
  2307. }
  2308. if ((fd.fd_status & FD_STATUS_S8) != 0) {
  2309. lp->stats.rx_over_errors++;
  2310. #ifdef DEBUG_RX_FAIL
  2311. printk(KERN_DEBUG
  2312. "%s: wv_receive(): rx DMA overrun.\n",
  2313. dev->name);
  2314. #endif
  2315. }
  2316. if ((fd.fd_status & FD_STATUS_S9) != 0) {
  2317. lp->stats.rx_fifo_errors++;
  2318. #ifdef DEBUG_RX_FAIL
  2319. printk(KERN_DEBUG
  2320. "%s: wv_receive(): ran out of resources.\n",
  2321. dev->name);
  2322. #endif
  2323. }
  2324. if ((fd.fd_status & FD_STATUS_S10) != 0) {
  2325. lp->stats.rx_frame_errors++;
  2326. #ifdef DEBUG_RX_FAIL
  2327. printk(KERN_DEBUG
  2328. "%s: wv_receive(): alignment error.\n",
  2329. dev->name);
  2330. #endif
  2331. }
  2332. if ((fd.fd_status & FD_STATUS_S11) != 0) {
  2333. lp->stats.rx_crc_errors++;
  2334. #ifdef DEBUG_RX_FAIL
  2335. printk(KERN_DEBUG
  2336. "%s: wv_receive(): CRC error.\n",
  2337. dev->name);
  2338. #endif
  2339. }
  2340. }
  2341. fd.fd_status = 0;
  2342. obram_write(ioaddr, fdoff(lp->rx_head, fd_status),
  2343. (unsigned char *) &fd.fd_status,
  2344. sizeof(fd.fd_status));
  2345. fd.fd_command = FD_COMMAND_EL;
  2346. obram_write(ioaddr, fdoff(lp->rx_head, fd_command),
  2347. (unsigned char *) &fd.fd_command,
  2348. sizeof(fd.fd_command));
  2349. fd.fd_command = 0;
  2350. obram_write(ioaddr, fdoff(lp->rx_last, fd_command),
  2351. (unsigned char *) &fd.fd_command,
  2352. sizeof(fd.fd_command));
  2353. lp->rx_last = lp->rx_head;
  2354. lp->rx_head = fd.fd_link_offset;
  2355. } /* for(;;) -> loop on all frames */
  2356. #ifdef DEBUG_RX_INFO
  2357. if (nreaped > 1)
  2358. printk(KERN_DEBUG "%s: wv_receive(): reaped %d\n",
  2359. dev->name, nreaped);
  2360. #endif
  2361. #ifdef DEBUG_RX_TRACE
  2362. printk(KERN_DEBUG "%s: <-wv_receive()\n", dev->name);
  2363. #endif
  2364. }
  2365. /*********************** PACKET TRANSMISSION ***********************/
  2366. /*
  2367. * This part deals with sending packets through the WaveLAN.
  2368. *
  2369. */
  2370. /*------------------------------------------------------------------*/
  2371. /*
  2372. * This routine fills in the appropriate registers and memory
  2373. * locations on the WaveLAN card and starts the card off on
  2374. * the transmit.
  2375. *
  2376. * The principle:
  2377. * Each block contains a transmit command, a NOP command,
  2378. * a transmit block descriptor and a buffer.
  2379. * The CU read the transmit block which point to the tbd,
  2380. * read the tbd and the content of the buffer.
  2381. * When it has finish with it, it goes to the next command
  2382. * which in our case is the NOP. The NOP points on itself,
  2383. * so the CU stop here.
  2384. * When we add the next block, we modify the previous nop
  2385. * to make it point on the new tx command.
  2386. * Simple, isn't it ?
  2387. *
  2388. * (called in wavelan_packet_xmit())
  2389. */
  2390. static int wv_packet_write(struct net_device * dev, void *buf, short length)
  2391. {
  2392. net_local *lp = (net_local *) dev->priv;
  2393. unsigned long ioaddr = dev->base_addr;
  2394. unsigned short txblock;
  2395. unsigned short txpred;
  2396. unsigned short tx_addr;
  2397. unsigned short nop_addr;
  2398. unsigned short tbd_addr;
  2399. unsigned short buf_addr;
  2400. ac_tx_t tx;
  2401. ac_nop_t nop;
  2402. tbd_t tbd;
  2403. int clen = length;
  2404. unsigned long flags;
  2405. #ifdef DEBUG_TX_TRACE
  2406. printk(KERN_DEBUG "%s: ->wv_packet_write(%d)\n", dev->name,
  2407. length);
  2408. #endif
  2409. spin_lock_irqsave(&lp->spinlock, flags);
  2410. /* Check nothing bad has happened */
  2411. if (lp->tx_n_in_use == (NTXBLOCKS - 1)) {
  2412. #ifdef DEBUG_TX_ERROR
  2413. printk(KERN_INFO "%s: wv_packet_write(): Tx queue full.\n",
  2414. dev->name);
  2415. #endif
  2416. spin_unlock_irqrestore(&lp->spinlock, flags);
  2417. return 1;
  2418. }
  2419. /* Calculate addresses of next block and previous block. */
  2420. txblock = lp->tx_first_free;
  2421. txpred = txblock - TXBLOCKZ;
  2422. if (txpred < OFFSET_CU)
  2423. txpred += NTXBLOCKS * TXBLOCKZ;
  2424. lp->tx_first_free += TXBLOCKZ;
  2425. if (lp->tx_first_free >= OFFSET_CU + NTXBLOCKS * TXBLOCKZ)
  2426. lp->tx_first_free -= NTXBLOCKS * TXBLOCKZ;
  2427. lp->tx_n_in_use++;
  2428. /* Calculate addresses of the different parts of the block. */
  2429. tx_addr = txblock;
  2430. nop_addr = tx_addr + sizeof(tx);
  2431. tbd_addr = nop_addr + sizeof(nop);
  2432. buf_addr = tbd_addr + sizeof(tbd);
  2433. /*
  2434. * Transmit command
  2435. */
  2436. tx.tx_h.ac_status = 0;
  2437. obram_write(ioaddr, toff(ac_tx_t, tx_addr, tx_h.ac_status),
  2438. (unsigned char *) &tx.tx_h.ac_status,
  2439. sizeof(tx.tx_h.ac_status));
  2440. /*
  2441. * NOP command
  2442. */
  2443. nop.nop_h.ac_status = 0;
  2444. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
  2445. (unsigned char *) &nop.nop_h.ac_status,
  2446. sizeof(nop.nop_h.ac_status));
  2447. nop.nop_h.ac_link = nop_addr;
  2448. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
  2449. (unsigned char *) &nop.nop_h.ac_link,
  2450. sizeof(nop.nop_h.ac_link));
  2451. /*
  2452. * Transmit buffer descriptor
  2453. */
  2454. tbd.tbd_status = TBD_STATUS_EOF | (TBD_STATUS_ACNT & clen);
  2455. tbd.tbd_next_bd_offset = I82586NULL;
  2456. tbd.tbd_bufl = buf_addr;
  2457. tbd.tbd_bufh = 0;
  2458. obram_write(ioaddr, tbd_addr, (unsigned char *) &tbd, sizeof(tbd));
  2459. /*
  2460. * Data
  2461. */
  2462. obram_write(ioaddr, buf_addr, buf, length);
  2463. /*
  2464. * Overwrite the predecessor NOP link
  2465. * so that it points to this txblock.
  2466. */
  2467. nop_addr = txpred + sizeof(tx);
  2468. nop.nop_h.ac_status = 0;
  2469. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
  2470. (unsigned char *) &nop.nop_h.ac_status,
  2471. sizeof(nop.nop_h.ac_status));
  2472. nop.nop_h.ac_link = txblock;
  2473. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
  2474. (unsigned char *) &nop.nop_h.ac_link,
  2475. sizeof(nop.nop_h.ac_link));
  2476. /* Make sure the watchdog will keep quiet for a while */
  2477. dev->trans_start = jiffies;
  2478. /* Keep stats up to date. */
  2479. lp->stats.tx_bytes += length;
  2480. if (lp->tx_first_in_use == I82586NULL)
  2481. lp->tx_first_in_use = txblock;
  2482. if (lp->tx_n_in_use < NTXBLOCKS - 1)
  2483. netif_wake_queue(dev);
  2484. spin_unlock_irqrestore(&lp->spinlock, flags);
  2485. #ifdef DEBUG_TX_INFO
  2486. wv_packet_info((u8 *) buf, length, dev->name,
  2487. "wv_packet_write");
  2488. #endif /* DEBUG_TX_INFO */
  2489. #ifdef DEBUG_TX_TRACE
  2490. printk(KERN_DEBUG "%s: <-wv_packet_write()\n", dev->name);
  2491. #endif
  2492. return 0;
  2493. }
  2494. /*------------------------------------------------------------------*/
  2495. /*
  2496. * This routine is called when we want to send a packet (NET3 callback)
  2497. * In this routine, we check if the harware is ready to accept
  2498. * the packet. We also prevent reentrance. Then we call the function
  2499. * to send the packet.
  2500. */
  2501. static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev)
  2502. {
  2503. net_local *lp = (net_local *) dev->priv;
  2504. unsigned long flags;
  2505. #ifdef DEBUG_TX_TRACE
  2506. printk(KERN_DEBUG "%s: ->wavelan_packet_xmit(0x%X)\n", dev->name,
  2507. (unsigned) skb);
  2508. #endif
  2509. /*
  2510. * Block a timer-based transmit from overlapping.
  2511. * In other words, prevent reentering this routine.
  2512. */
  2513. netif_stop_queue(dev);
  2514. /* If somebody has asked to reconfigure the controller,
  2515. * we can do it now.
  2516. */
  2517. if (lp->reconfig_82586) {
  2518. spin_lock_irqsave(&lp->spinlock, flags);
  2519. wv_82586_config(dev);
  2520. spin_unlock_irqrestore(&lp->spinlock, flags);
  2521. /* Check that we can continue */
  2522. if (lp->tx_n_in_use == (NTXBLOCKS - 1))
  2523. return 1;
  2524. }
  2525. #ifdef DEBUG_TX_ERROR
  2526. if (skb->next)
  2527. printk(KERN_INFO "skb has next\n");
  2528. #endif
  2529. /* Do we need some padding? */
  2530. /* Note : on wireless the propagation time is in the order of 1us,
  2531. * and we don't have the Ethernet specific requirement of beeing
  2532. * able to detect collisions, therefore in theory we don't really
  2533. * need to pad. Jean II */
  2534. if (skb->len < ETH_ZLEN) {
  2535. skb = skb_padto(skb, ETH_ZLEN);
  2536. if (skb == NULL)
  2537. return 0;
  2538. }
  2539. /* Write packet on the card */
  2540. if(wv_packet_write(dev, skb->data, skb->len))
  2541. return 1; /* We failed */
  2542. dev_kfree_skb(skb);
  2543. #ifdef DEBUG_TX_TRACE
  2544. printk(KERN_DEBUG "%s: <-wavelan_packet_xmit()\n", dev->name);
  2545. #endif
  2546. return 0;
  2547. }
  2548. /*********************** HARDWARE CONFIGURATION ***********************/
  2549. /*
  2550. * This part does the real job of starting and configuring the hardware.
  2551. */
  2552. /*--------------------------------------------------------------------*/
  2553. /*
  2554. * Routine to initialize the Modem Management Controller.
  2555. * (called by wv_hw_reset())
  2556. */
  2557. static int wv_mmc_init(struct net_device * dev)
  2558. {
  2559. unsigned long ioaddr = dev->base_addr;
  2560. net_local *lp = (net_local *) dev->priv;
  2561. psa_t psa;
  2562. mmw_t m;
  2563. int configured;
  2564. #ifdef DEBUG_CONFIG_TRACE
  2565. printk(KERN_DEBUG "%s: ->wv_mmc_init()\n", dev->name);
  2566. #endif
  2567. /* Read the parameter storage area. */
  2568. psa_read(ioaddr, lp->hacr, 0, (unsigned char *) &psa, sizeof(psa));
  2569. #ifdef USE_PSA_CONFIG
  2570. configured = psa.psa_conf_status & 1;
  2571. #else
  2572. configured = 0;
  2573. #endif
  2574. /* Is the PSA is not configured */
  2575. if (!configured) {
  2576. /* User will be able to configure NWID later (with iwconfig). */
  2577. psa.psa_nwid[0] = 0;
  2578. psa.psa_nwid[1] = 0;
  2579. /* no NWID checking since NWID is not set */
  2580. psa.psa_nwid_select = 0;
  2581. /* Disable encryption */
  2582. psa.psa_encryption_select = 0;
  2583. /* Set to standard values:
  2584. * 0x04 for AT,
  2585. * 0x01 for MCA,
  2586. * 0x04 for PCMCIA and 2.00 card (AT&T 407-024689/E document)
  2587. */
  2588. if (psa.psa_comp_number & 1)
  2589. psa.psa_thr_pre_set = 0x01;
  2590. else
  2591. psa.psa_thr_pre_set = 0x04;
  2592. psa.psa_quality_thr = 0x03;
  2593. /* It is configured */
  2594. psa.psa_conf_status |= 1;
  2595. #ifdef USE_PSA_CONFIG
  2596. /* Write the psa. */
  2597. psa_write(ioaddr, lp->hacr,
  2598. (char *) psa.psa_nwid - (char *) &psa,
  2599. (unsigned char *) psa.psa_nwid, 4);
  2600. psa_write(ioaddr, lp->hacr,
  2601. (char *) &psa.psa_thr_pre_set - (char *) &psa,
  2602. (unsigned char *) &psa.psa_thr_pre_set, 1);
  2603. psa_write(ioaddr, lp->hacr,
  2604. (char *) &psa.psa_quality_thr - (char *) &psa,
  2605. (unsigned char *) &psa.psa_quality_thr, 1);
  2606. psa_write(ioaddr, lp->hacr,
  2607. (char *) &psa.psa_conf_status - (char *) &psa,
  2608. (unsigned char *) &psa.psa_conf_status, 1);
  2609. /* update the Wavelan checksum */
  2610. update_psa_checksum(dev, ioaddr, lp->hacr);
  2611. #endif
  2612. }
  2613. /* Zero the mmc structure. */
  2614. memset(&m, 0x00, sizeof(m));
  2615. /* Copy PSA info to the mmc. */
  2616. m.mmw_netw_id_l = psa.psa_nwid[1];
  2617. m.mmw_netw_id_h = psa.psa_nwid[0];
  2618. if (psa.psa_nwid_select & 1)
  2619. m.mmw_loopt_sel = 0x00;
  2620. else
  2621. m.mmw_loopt_sel = MMW_LOOPT_SEL_DIS_NWID;
  2622. memcpy(&m.mmw_encr_key, &psa.psa_encryption_key,
  2623. sizeof(m.mmw_encr_key));
  2624. if (psa.psa_encryption_select)
  2625. m.mmw_encr_enable =
  2626. MMW_ENCR_ENABLE_EN | MMW_ENCR_ENABLE_MODE;
  2627. else
  2628. m.mmw_encr_enable = 0;
  2629. m.mmw_thr_pre_set = psa.psa_thr_pre_set & 0x3F;
  2630. m.mmw_quality_thr = psa.psa_quality_thr & 0x0F;
  2631. /*
  2632. * Set default modem control parameters.
  2633. * See NCR document 407-0024326 Rev. A.
  2634. */
  2635. m.mmw_jabber_enable = 0x01;
  2636. m.mmw_freeze = 0;
  2637. m.mmw_anten_sel = MMW_ANTEN_SEL_ALG_EN;
  2638. m.mmw_ifs = 0x20;
  2639. m.mmw_mod_delay = 0x04;
  2640. m.mmw_jam_time = 0x38;
  2641. m.mmw_des_io_invert = 0;
  2642. m.mmw_decay_prm = 0;
  2643. m.mmw_decay_updat_prm = 0;
  2644. /* Write all info to MMC. */
  2645. mmc_write(ioaddr, 0, (u8 *) & m, sizeof(m));
  2646. /* The following code starts the modem of the 2.00 frequency
  2647. * selectable cards at power on. It's not strictly needed for the
  2648. * following boots.
  2649. * The original patch was by Joe Finney for the PCMCIA driver, but
  2650. * I've cleaned it up a bit and added documentation.
  2651. * Thanks to Loeke Brederveld from Lucent for the info.
  2652. */
  2653. /* Attempt to recognise 2.00 cards (2.4 GHz frequency selectable)
  2654. * Does it work for everybody, especially old cards? */
  2655. /* Note: WFREQSEL verifies that it is able to read a sensible
  2656. * frequency from EEPROM (address 0x00) and that MMR_FEE_STATUS_ID
  2657. * is 0xA (Xilinx version) or 0xB (Ariadne version).
  2658. * My test is more crude but does work. */
  2659. if (!(mmc_in(ioaddr, mmroff(0, mmr_fee_status)) &
  2660. (MMR_FEE_STATUS_DWLD | MMR_FEE_STATUS_BUSY))) {
  2661. /* We must download the frequency parameters to the
  2662. * synthesizers (from the EEPROM - area 1)
  2663. * Note: as the EEPROM is automatically decremented, we set the end
  2664. * if the area... */
  2665. m.mmw_fee_addr = 0x0F;
  2666. m.mmw_fee_ctrl = MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD;
  2667. mmc_write(ioaddr, (char *) &m.mmw_fee_ctrl - (char *) &m,
  2668. (unsigned char *) &m.mmw_fee_ctrl, 2);
  2669. /* Wait until the download is finished. */
  2670. fee_wait(ioaddr, 100, 100);
  2671. #ifdef DEBUG_CONFIG_INFO
  2672. /* The frequency was in the last word downloaded. */
  2673. mmc_read(ioaddr, (char *) &m.mmw_fee_data_l - (char *) &m,
  2674. (unsigned char *) &m.mmw_fee_data_l, 2);
  2675. /* Print some info for the user. */
  2676. printk(KERN_DEBUG
  2677. "%s: WaveLAN 2.00 recognised (frequency select). Current frequency = %ld\n",
  2678. dev->name,
  2679. ((m.
  2680. mmw_fee_data_h << 4) | (m.mmw_fee_data_l >> 4)) *
  2681. 5 / 2 + 24000L);
  2682. #endif
  2683. /* We must now download the power adjust value (gain) to
  2684. * the synthesizers (from the EEPROM - area 7 - DAC). */
  2685. m.mmw_fee_addr = 0x61;
  2686. m.mmw_fee_ctrl = MMW_FEE_CTRL_READ | MMW_FEE_CTRL_DWLD;
  2687. mmc_write(ioaddr, (char *) &m.mmw_fee_ctrl - (char *) &m,
  2688. (unsigned char *) &m.mmw_fee_ctrl, 2);
  2689. /* Wait until the download is finished. */
  2690. }
  2691. /* if 2.00 card */
  2692. #ifdef DEBUG_CONFIG_TRACE
  2693. printk(KERN_DEBUG "%s: <-wv_mmc_init()\n", dev->name);
  2694. #endif
  2695. return 0;
  2696. }
  2697. /*------------------------------------------------------------------*/
  2698. /*
  2699. * Construct the fd and rbd structures.
  2700. * Start the receive unit.
  2701. * (called by wv_hw_reset())
  2702. */
  2703. static int wv_ru_start(struct net_device * dev)
  2704. {
  2705. net_local *lp = (net_local *) dev->priv;
  2706. unsigned long ioaddr = dev->base_addr;
  2707. u16 scb_cs;
  2708. fd_t fd;
  2709. rbd_t rbd;
  2710. u16 rx;
  2711. u16 rx_next;
  2712. int i;
  2713. #ifdef DEBUG_CONFIG_TRACE
  2714. printk(KERN_DEBUG "%s: ->wv_ru_start()\n", dev->name);
  2715. #endif
  2716. obram_read(ioaddr, scboff(OFFSET_SCB, scb_status),
  2717. (unsigned char *) &scb_cs, sizeof(scb_cs));
  2718. if ((scb_cs & SCB_ST_RUS) == SCB_ST_RUS_RDY)
  2719. return 0;
  2720. lp->rx_head = OFFSET_RU;
  2721. for (i = 0, rx = lp->rx_head; i < NRXBLOCKS; i++, rx = rx_next) {
  2722. rx_next =
  2723. (i == NRXBLOCKS - 1) ? lp->rx_head : rx + RXBLOCKZ;
  2724. fd.fd_status = 0;
  2725. fd.fd_command = (i == NRXBLOCKS - 1) ? FD_COMMAND_EL : 0;
  2726. fd.fd_link_offset = rx_next;
  2727. fd.fd_rbd_offset = rx + sizeof(fd);
  2728. obram_write(ioaddr, rx, (unsigned char *) &fd, sizeof(fd));
  2729. rbd.rbd_status = 0;
  2730. rbd.rbd_next_rbd_offset = I82586NULL;
  2731. rbd.rbd_bufl = rx + sizeof(fd) + sizeof(rbd);
  2732. rbd.rbd_bufh = 0;
  2733. rbd.rbd_el_size = RBD_EL | (RBD_SIZE & MAXDATAZ);
  2734. obram_write(ioaddr, rx + sizeof(fd),
  2735. (unsigned char *) &rbd, sizeof(rbd));
  2736. lp->rx_last = rx;
  2737. }
  2738. obram_write(ioaddr, scboff(OFFSET_SCB, scb_rfa_offset),
  2739. (unsigned char *) &lp->rx_head, sizeof(lp->rx_head));
  2740. scb_cs = SCB_CMD_RUC_GO;
  2741. obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
  2742. (unsigned char *) &scb_cs, sizeof(scb_cs));
  2743. set_chan_attn(ioaddr, lp->hacr);
  2744. for (i = 1000; i > 0; i--) {
  2745. obram_read(ioaddr, scboff(OFFSET_SCB, scb_command),
  2746. (unsigned char *) &scb_cs, sizeof(scb_cs));
  2747. if (scb_cs == 0)
  2748. break;
  2749. udelay(10);
  2750. }
  2751. if (i <= 0) {
  2752. #ifdef DEBUG_CONFIG_ERROR
  2753. printk(KERN_INFO
  2754. "%s: wavelan_ru_start(): board not accepting command.\n",
  2755. dev->name);
  2756. #endif
  2757. return -1;
  2758. }
  2759. #ifdef DEBUG_CONFIG_TRACE
  2760. printk(KERN_DEBUG "%s: <-wv_ru_start()\n", dev->name);
  2761. #endif
  2762. return 0;
  2763. }
  2764. /*------------------------------------------------------------------*/
  2765. /*
  2766. * Initialise the transmit blocks.
  2767. * Start the command unit executing the NOP
  2768. * self-loop of the first transmit block.
  2769. *
  2770. * Here we create the list of send buffers used to transmit packets
  2771. * between the PC and the command unit. For each buffer, we create a
  2772. * buffer descriptor (pointing on the buffer), a transmit command
  2773. * (pointing to the buffer descriptor) and a NOP command.
  2774. * The transmit command is linked to the NOP, and the NOP to itself.
  2775. * When we will have finished executing the transmit command, we will
  2776. * then loop on the NOP. By releasing the NOP link to a new command,
  2777. * we may send another buffer.
  2778. *
  2779. * (called by wv_hw_reset())
  2780. */
  2781. static int wv_cu_start(struct net_device * dev)
  2782. {
  2783. net_local *lp = (net_local *) dev->priv;
  2784. unsigned long ioaddr = dev->base_addr;
  2785. int i;
  2786. u16 txblock;
  2787. u16 first_nop;
  2788. u16 scb_cs;
  2789. #ifdef DEBUG_CONFIG_TRACE
  2790. printk(KERN_DEBUG "%s: ->wv_cu_start()\n", dev->name);
  2791. #endif
  2792. lp->tx_first_free = OFFSET_CU;
  2793. lp->tx_first_in_use = I82586NULL;
  2794. for (i = 0, txblock = OFFSET_CU;
  2795. i < NTXBLOCKS; i++, txblock += TXBLOCKZ) {
  2796. ac_tx_t tx;
  2797. ac_nop_t nop;
  2798. tbd_t tbd;
  2799. unsigned short tx_addr;
  2800. unsigned short nop_addr;
  2801. unsigned short tbd_addr;
  2802. unsigned short buf_addr;
  2803. tx_addr = txblock;
  2804. nop_addr = tx_addr + sizeof(tx);
  2805. tbd_addr = nop_addr + sizeof(nop);
  2806. buf_addr = tbd_addr + sizeof(tbd);
  2807. tx.tx_h.ac_status = 0;
  2808. tx.tx_h.ac_command = acmd_transmit | AC_CFLD_I;
  2809. tx.tx_h.ac_link = nop_addr;
  2810. tx.tx_tbd_offset = tbd_addr;
  2811. obram_write(ioaddr, tx_addr, (unsigned char *) &tx,
  2812. sizeof(tx));
  2813. nop.nop_h.ac_status = 0;
  2814. nop.nop_h.ac_command = acmd_nop;
  2815. nop.nop_h.ac_link = nop_addr;
  2816. obram_write(ioaddr, nop_addr, (unsigned char *) &nop,
  2817. sizeof(nop));
  2818. tbd.tbd_status = TBD_STATUS_EOF;
  2819. tbd.tbd_next_bd_offset = I82586NULL;
  2820. tbd.tbd_bufl = buf_addr;
  2821. tbd.tbd_bufh = 0;
  2822. obram_write(ioaddr, tbd_addr, (unsigned char *) &tbd,
  2823. sizeof(tbd));
  2824. }
  2825. first_nop =
  2826. OFFSET_CU + (NTXBLOCKS - 1) * TXBLOCKZ + sizeof(ac_tx_t);
  2827. obram_write(ioaddr, scboff(OFFSET_SCB, scb_cbl_offset),
  2828. (unsigned char *) &first_nop, sizeof(first_nop));
  2829. scb_cs = SCB_CMD_CUC_GO;
  2830. obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
  2831. (unsigned char *) &scb_cs, sizeof(scb_cs));
  2832. set_chan_attn(ioaddr, lp->hacr);
  2833. for (i = 1000; i > 0; i--) {
  2834. obram_read(ioaddr, scboff(OFFSET_SCB, scb_command),
  2835. (unsigned char *) &scb_cs, sizeof(scb_cs));
  2836. if (scb_cs == 0)
  2837. break;
  2838. udelay(10);
  2839. }
  2840. if (i <= 0) {
  2841. #ifdef DEBUG_CONFIG_ERROR
  2842. printk(KERN_INFO
  2843. "%s: wavelan_cu_start(): board not accepting command.\n",
  2844. dev->name);
  2845. #endif
  2846. return -1;
  2847. }
  2848. lp->tx_n_in_use = 0;
  2849. netif_start_queue(dev);
  2850. #ifdef DEBUG_CONFIG_TRACE
  2851. printk(KERN_DEBUG "%s: <-wv_cu_start()\n", dev->name);
  2852. #endif
  2853. return 0;
  2854. }
  2855. /*------------------------------------------------------------------*/
  2856. /*
  2857. * This routine does a standard configuration of the WaveLAN
  2858. * controller (i82586).
  2859. *
  2860. * It initialises the scp, iscp and scb structure
  2861. * The first two are just pointers to the next.
  2862. * The last one is used for basic configuration and for basic
  2863. * communication (interrupt status).
  2864. *
  2865. * (called by wv_hw_reset())
  2866. */
  2867. static int wv_82586_start(struct net_device * dev)
  2868. {
  2869. net_local *lp = (net_local *) dev->priv;
  2870. unsigned long ioaddr = dev->base_addr;
  2871. scp_t scp; /* system configuration pointer */
  2872. iscp_t iscp; /* intermediate scp */
  2873. scb_t scb; /* system control block */
  2874. ach_t cb; /* Action command header */
  2875. u8 zeroes[512];
  2876. int i;
  2877. #ifdef DEBUG_CONFIG_TRACE
  2878. printk(KERN_DEBUG "%s: ->wv_82586_start()\n", dev->name);
  2879. #endif
  2880. /*
  2881. * Clear the onboard RAM.
  2882. */
  2883. memset(&zeroes[0], 0x00, sizeof(zeroes));
  2884. for (i = 0; i < I82586_MEMZ; i += sizeof(zeroes))
  2885. obram_write(ioaddr, i, &zeroes[0], sizeof(zeroes));
  2886. /*
  2887. * Construct the command unit structures:
  2888. * scp, iscp, scb, cb.
  2889. */
  2890. memset(&scp, 0x00, sizeof(scp));
  2891. scp.scp_sysbus = SCP_SY_16BBUS;
  2892. scp.scp_iscpl = OFFSET_ISCP;
  2893. obram_write(ioaddr, OFFSET_SCP, (unsigned char *) &scp,
  2894. sizeof(scp));
  2895. memset(&iscp, 0x00, sizeof(iscp));
  2896. iscp.iscp_busy = 1;
  2897. iscp.iscp_offset = OFFSET_SCB;
  2898. obram_write(ioaddr, OFFSET_ISCP, (unsigned char *) &iscp,
  2899. sizeof(iscp));
  2900. /* Our first command is to reset the i82586. */
  2901. memset(&scb, 0x00, sizeof(scb));
  2902. scb.scb_command = SCB_CMD_RESET;
  2903. scb.scb_cbl_offset = OFFSET_CU;
  2904. scb.scb_rfa_offset = OFFSET_RU;
  2905. obram_write(ioaddr, OFFSET_SCB, (unsigned char *) &scb,
  2906. sizeof(scb));
  2907. set_chan_attn(ioaddr, lp->hacr);
  2908. /* Wait for command to finish. */
  2909. for (i = 1000; i > 0; i--) {
  2910. obram_read(ioaddr, OFFSET_ISCP, (unsigned char *) &iscp,
  2911. sizeof(iscp));
  2912. if (iscp.iscp_busy == (unsigned short) 0)
  2913. break;
  2914. udelay(10);
  2915. }
  2916. if (i <= 0) {
  2917. #ifdef DEBUG_CONFIG_ERROR
  2918. printk(KERN_INFO
  2919. "%s: wv_82586_start(): iscp_busy timeout.\n",
  2920. dev->name);
  2921. #endif
  2922. return -1;
  2923. }
  2924. /* Check command completion. */
  2925. for (i = 15; i > 0; i--) {
  2926. obram_read(ioaddr, OFFSET_SCB, (unsigned char *) &scb,
  2927. sizeof(scb));
  2928. if (scb.scb_status == (SCB_ST_CX | SCB_ST_CNA))
  2929. break;
  2930. udelay(10);
  2931. }
  2932. if (i <= 0) {
  2933. #ifdef DEBUG_CONFIG_ERROR
  2934. printk(KERN_INFO
  2935. "%s: wv_82586_start(): status: expected 0x%02x, got 0x%02x.\n",
  2936. dev->name, SCB_ST_CX | SCB_ST_CNA, scb.scb_status);
  2937. #endif
  2938. return -1;
  2939. }
  2940. wv_ack(dev);
  2941. /* Set the action command header. */
  2942. memset(&cb, 0x00, sizeof(cb));
  2943. cb.ac_command = AC_CFLD_EL | (AC_CFLD_CMD & acmd_diagnose);
  2944. cb.ac_link = OFFSET_CU;
  2945. obram_write(ioaddr, OFFSET_CU, (unsigned char *) &cb, sizeof(cb));
  2946. if (wv_synchronous_cmd(dev, "diag()") == -1)
  2947. return -1;
  2948. obram_read(ioaddr, OFFSET_CU, (unsigned char *) &cb, sizeof(cb));
  2949. if (cb.ac_status & AC_SFLD_FAIL) {
  2950. #ifdef DEBUG_CONFIG_ERROR
  2951. printk(KERN_INFO
  2952. "%s: wv_82586_start(): i82586 Self Test failed.\n",
  2953. dev->name);
  2954. #endif
  2955. return -1;
  2956. }
  2957. #ifdef DEBUG_I82586_SHOW
  2958. wv_scb_show(ioaddr);
  2959. #endif
  2960. #ifdef DEBUG_CONFIG_TRACE
  2961. printk(KERN_DEBUG "%s: <-wv_82586_start()\n", dev->name);
  2962. #endif
  2963. return 0;
  2964. }
  2965. /*------------------------------------------------------------------*/
  2966. /*
  2967. * This routine does a standard configuration of the WaveLAN
  2968. * controller (i82586).
  2969. *
  2970. * This routine is a violent hack. We use the first free transmit block
  2971. * to make our configuration. In the buffer area, we create the three
  2972. * configuration commands (linked). We make the previous NOP point to
  2973. * the beginning of the buffer instead of the tx command. After, we go
  2974. * as usual to the NOP command.
  2975. * Note that only the last command (mc_set) will generate an interrupt.
  2976. *
  2977. * (called by wv_hw_reset(), wv_82586_reconfig(), wavelan_packet_xmit())
  2978. */
  2979. static void wv_82586_config(struct net_device * dev)
  2980. {
  2981. net_local *lp = (net_local *) dev->priv;
  2982. unsigned long ioaddr = dev->base_addr;
  2983. unsigned short txblock;
  2984. unsigned short txpred;
  2985. unsigned short tx_addr;
  2986. unsigned short nop_addr;
  2987. unsigned short tbd_addr;
  2988. unsigned short cfg_addr;
  2989. unsigned short ias_addr;
  2990. unsigned short mcs_addr;
  2991. ac_tx_t tx;
  2992. ac_nop_t nop;
  2993. ac_cfg_t cfg; /* Configure action */
  2994. ac_ias_t ias; /* IA-setup action */
  2995. ac_mcs_t mcs; /* Multicast setup */
  2996. struct dev_mc_list *dmi;
  2997. #ifdef DEBUG_CONFIG_TRACE
  2998. printk(KERN_DEBUG "%s: ->wv_82586_config()\n", dev->name);
  2999. #endif
  3000. /* Check nothing bad has happened */
  3001. if (lp->tx_n_in_use == (NTXBLOCKS - 1)) {
  3002. #ifdef DEBUG_CONFIG_ERROR
  3003. printk(KERN_INFO "%s: wv_82586_config(): Tx queue full.\n",
  3004. dev->name);
  3005. #endif
  3006. return;
  3007. }
  3008. /* Calculate addresses of next block and previous block. */
  3009. txblock = lp->tx_first_free;
  3010. txpred = txblock - TXBLOCKZ;
  3011. if (txpred < OFFSET_CU)
  3012. txpred += NTXBLOCKS * TXBLOCKZ;
  3013. lp->tx_first_free += TXBLOCKZ;
  3014. if (lp->tx_first_free >= OFFSET_CU + NTXBLOCKS * TXBLOCKZ)
  3015. lp->tx_first_free -= NTXBLOCKS * TXBLOCKZ;
  3016. lp->tx_n_in_use++;
  3017. /* Calculate addresses of the different parts of the block. */
  3018. tx_addr = txblock;
  3019. nop_addr = tx_addr + sizeof(tx);
  3020. tbd_addr = nop_addr + sizeof(nop);
  3021. cfg_addr = tbd_addr + sizeof(tbd_t); /* beginning of the buffer */
  3022. ias_addr = cfg_addr + sizeof(cfg);
  3023. mcs_addr = ias_addr + sizeof(ias);
  3024. /*
  3025. * Transmit command
  3026. */
  3027. tx.tx_h.ac_status = 0xFFFF; /* Fake completion value */
  3028. obram_write(ioaddr, toff(ac_tx_t, tx_addr, tx_h.ac_status),
  3029. (unsigned char *) &tx.tx_h.ac_status,
  3030. sizeof(tx.tx_h.ac_status));
  3031. /*
  3032. * NOP command
  3033. */
  3034. nop.nop_h.ac_status = 0;
  3035. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
  3036. (unsigned char *) &nop.nop_h.ac_status,
  3037. sizeof(nop.nop_h.ac_status));
  3038. nop.nop_h.ac_link = nop_addr;
  3039. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
  3040. (unsigned char *) &nop.nop_h.ac_link,
  3041. sizeof(nop.nop_h.ac_link));
  3042. /* Create a configure action. */
  3043. memset(&cfg, 0x00, sizeof(cfg));
  3044. /*
  3045. * For Linux we invert AC_CFG_ALOC() so as to conform
  3046. * to the way that net packets reach us from above.
  3047. * (See also ac_tx_t.)
  3048. *
  3049. * Updated from Wavelan Manual WCIN085B
  3050. */
  3051. cfg.cfg_byte_cnt =
  3052. AC_CFG_BYTE_CNT(sizeof(ac_cfg_t) - sizeof(ach_t));
  3053. cfg.cfg_fifolim = AC_CFG_FIFOLIM(4);
  3054. cfg.cfg_byte8 = AC_CFG_SAV_BF(1) | AC_CFG_SRDY(0);
  3055. cfg.cfg_byte9 = AC_CFG_ELPBCK(0) |
  3056. AC_CFG_ILPBCK(0) |
  3057. AC_CFG_PRELEN(AC_CFG_PLEN_2) |
  3058. AC_CFG_ALOC(1) | AC_CFG_ADDRLEN(WAVELAN_ADDR_SIZE);
  3059. cfg.cfg_byte10 = AC_CFG_BOFMET(1) |
  3060. AC_CFG_ACR(6) | AC_CFG_LINPRIO(0);
  3061. cfg.cfg_ifs = 0x20;
  3062. cfg.cfg_slotl = 0x0C;
  3063. cfg.cfg_byte13 = AC_CFG_RETRYNUM(15) | AC_CFG_SLTTMHI(0);
  3064. cfg.cfg_byte14 = AC_CFG_FLGPAD(0) |
  3065. AC_CFG_BTSTF(0) |
  3066. AC_CFG_CRC16(0) |
  3067. AC_CFG_NCRC(0) |
  3068. AC_CFG_TNCRS(1) |
  3069. AC_CFG_MANCH(0) |
  3070. AC_CFG_BCDIS(0) | AC_CFG_PRM(lp->promiscuous);
  3071. cfg.cfg_byte15 = AC_CFG_ICDS(0) |
  3072. AC_CFG_CDTF(0) | AC_CFG_ICSS(0) | AC_CFG_CSTF(0);
  3073. /*
  3074. cfg.cfg_min_frm_len = AC_CFG_MNFRM(64);
  3075. */
  3076. cfg.cfg_min_frm_len = AC_CFG_MNFRM(8);
  3077. cfg.cfg_h.ac_command = (AC_CFLD_CMD & acmd_configure);
  3078. cfg.cfg_h.ac_link = ias_addr;
  3079. obram_write(ioaddr, cfg_addr, (unsigned char *) &cfg, sizeof(cfg));
  3080. /* Set up the MAC address */
  3081. memset(&ias, 0x00, sizeof(ias));
  3082. ias.ias_h.ac_command = (AC_CFLD_CMD & acmd_ia_setup);
  3083. ias.ias_h.ac_link = mcs_addr;
  3084. memcpy(&ias.ias_addr[0], (unsigned char *) &dev->dev_addr[0],
  3085. sizeof(ias.ias_addr));
  3086. obram_write(ioaddr, ias_addr, (unsigned char *) &ias, sizeof(ias));
  3087. /* Initialize adapter's Ethernet multicast addresses */
  3088. memset(&mcs, 0x00, sizeof(mcs));
  3089. mcs.mcs_h.ac_command = AC_CFLD_I | (AC_CFLD_CMD & acmd_mc_setup);
  3090. mcs.mcs_h.ac_link = nop_addr;
  3091. mcs.mcs_cnt = WAVELAN_ADDR_SIZE * lp->mc_count;
  3092. obram_write(ioaddr, mcs_addr, (unsigned char *) &mcs, sizeof(mcs));
  3093. /* Any address to set? */
  3094. if (lp->mc_count) {
  3095. for (dmi = dev->mc_list; dmi; dmi = dmi->next)
  3096. outsw(PIOP1(ioaddr), (u16 *) dmi->dmi_addr,
  3097. WAVELAN_ADDR_SIZE >> 1);
  3098. #ifdef DEBUG_CONFIG_INFO
  3099. printk(KERN_DEBUG
  3100. "%s: wv_82586_config(): set %d multicast addresses:\n",
  3101. dev->name, lp->mc_count);
  3102. for (dmi = dev->mc_list; dmi; dmi = dmi->next)
  3103. printk(KERN_DEBUG
  3104. " %02x:%02x:%02x:%02x:%02x:%02x\n",
  3105. dmi->dmi_addr[0], dmi->dmi_addr[1],
  3106. dmi->dmi_addr[2], dmi->dmi_addr[3],
  3107. dmi->dmi_addr[4], dmi->dmi_addr[5]);
  3108. #endif
  3109. }
  3110. /*
  3111. * Overwrite the predecessor NOP link
  3112. * so that it points to the configure action.
  3113. */
  3114. nop_addr = txpred + sizeof(tx);
  3115. nop.nop_h.ac_status = 0;
  3116. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_status),
  3117. (unsigned char *) &nop.nop_h.ac_status,
  3118. sizeof(nop.nop_h.ac_status));
  3119. nop.nop_h.ac_link = cfg_addr;
  3120. obram_write(ioaddr, toff(ac_nop_t, nop_addr, nop_h.ac_link),
  3121. (unsigned char *) &nop.nop_h.ac_link,
  3122. sizeof(nop.nop_h.ac_link));
  3123. /* Job done, clear the flag */
  3124. lp->reconfig_82586 = 0;
  3125. if (lp->tx_first_in_use == I82586NULL)
  3126. lp->tx_first_in_use = txblock;
  3127. if (lp->tx_n_in_use == (NTXBLOCKS - 1))
  3128. netif_stop_queue(dev);
  3129. #ifdef DEBUG_CONFIG_TRACE
  3130. printk(KERN_DEBUG "%s: <-wv_82586_config()\n", dev->name);
  3131. #endif
  3132. }
  3133. /*------------------------------------------------------------------*/
  3134. /*
  3135. * This routine, called by wavelan_close(), gracefully stops the
  3136. * WaveLAN controller (i82586).
  3137. * (called by wavelan_close())
  3138. */
  3139. static void wv_82586_stop(struct net_device * dev)
  3140. {
  3141. net_local *lp = (net_local *) dev->priv;
  3142. unsigned long ioaddr = dev->base_addr;
  3143. u16 scb_cmd;
  3144. #ifdef DEBUG_CONFIG_TRACE
  3145. printk(KERN_DEBUG "%s: ->wv_82586_stop()\n", dev->name);
  3146. #endif
  3147. /* Suspend both command unit and receive unit. */
  3148. scb_cmd =
  3149. (SCB_CMD_CUC & SCB_CMD_CUC_SUS) | (SCB_CMD_RUC &
  3150. SCB_CMD_RUC_SUS);
  3151. obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
  3152. (unsigned char *) &scb_cmd, sizeof(scb_cmd));
  3153. set_chan_attn(ioaddr, lp->hacr);
  3154. /* No more interrupts */
  3155. wv_ints_off(dev);
  3156. #ifdef DEBUG_CONFIG_TRACE
  3157. printk(KERN_DEBUG "%s: <-wv_82586_stop()\n", dev->name);
  3158. #endif
  3159. }
  3160. /*------------------------------------------------------------------*/
  3161. /*
  3162. * Totally reset the WaveLAN and restart it.
  3163. * Performs the following actions:
  3164. * 1. A power reset (reset DMA)
  3165. * 2. Initialize the radio modem (using wv_mmc_init)
  3166. * 3. Reset & Configure LAN controller (using wv_82586_start)
  3167. * 4. Start the LAN controller's command unit
  3168. * 5. Start the LAN controller's receive unit
  3169. * (called by wavelan_interrupt(), wavelan_watchdog() & wavelan_open())
  3170. */
  3171. static int wv_hw_reset(struct net_device * dev)
  3172. {
  3173. net_local *lp = (net_local *) dev->priv;
  3174. unsigned long ioaddr = dev->base_addr;
  3175. #ifdef DEBUG_CONFIG_TRACE
  3176. printk(KERN_DEBUG "%s: ->wv_hw_reset(dev=0x%x)\n", dev->name,
  3177. (unsigned int) dev);
  3178. #endif
  3179. /* Increase the number of resets done. */
  3180. lp->nresets++;
  3181. wv_hacr_reset(ioaddr);
  3182. lp->hacr = HACR_DEFAULT;
  3183. if ((wv_mmc_init(dev) < 0) || (wv_82586_start(dev) < 0))
  3184. return -1;
  3185. /* Enable the card to send interrupts. */
  3186. wv_ints_on(dev);
  3187. /* Start card functions */
  3188. if (wv_cu_start(dev) < 0)
  3189. return -1;
  3190. /* Setup the controller and parameters */
  3191. wv_82586_config(dev);
  3192. /* Finish configuration with the receive unit */
  3193. if (wv_ru_start(dev) < 0)
  3194. return -1;
  3195. #ifdef DEBUG_CONFIG_TRACE
  3196. printk(KERN_DEBUG "%s: <-wv_hw_reset()\n", dev->name);
  3197. #endif
  3198. return 0;
  3199. }
  3200. /*------------------------------------------------------------------*/
  3201. /*
  3202. * Check if there is a WaveLAN at the specific base address.
  3203. * As a side effect, this reads the MAC address.
  3204. * (called in wavelan_probe() and init_module())
  3205. */
  3206. static int wv_check_ioaddr(unsigned long ioaddr, u8 * mac)
  3207. {
  3208. int i; /* Loop counter */
  3209. /* Check if the base address if available. */
  3210. if (!request_region(ioaddr, sizeof(ha_t), "wavelan probe"))
  3211. return -EBUSY; /* ioaddr already used */
  3212. /* Reset host interface */
  3213. wv_hacr_reset(ioaddr);
  3214. /* Read the MAC address from the parameter storage area. */
  3215. psa_read(ioaddr, HACR_DEFAULT, psaoff(0, psa_univ_mac_addr),
  3216. mac, 6);
  3217. release_region(ioaddr, sizeof(ha_t));
  3218. /*
  3219. * Check the first three octets of the address for the manufacturer's code.
  3220. * Note: if this can't find your WaveLAN card, you've got a
  3221. * non-NCR/AT&T/Lucent ISA card. See wavelan.p.h for detail on
  3222. * how to configure your card.
  3223. */
  3224. for (i = 0; i < (sizeof(MAC_ADDRESSES) / sizeof(char) / 3); i++)
  3225. if ((mac[0] == MAC_ADDRESSES[i][0]) &&
  3226. (mac[1] == MAC_ADDRESSES[i][1]) &&
  3227. (mac[2] == MAC_ADDRESSES[i][2]))
  3228. return 0;
  3229. #ifdef DEBUG_CONFIG_INFO
  3230. printk(KERN_WARNING
  3231. "WaveLAN (0x%3X): your MAC address might be %02X:%02X:%02X.\n",
  3232. ioaddr, mac[0], mac[1], mac[2]);
  3233. #endif
  3234. return -ENODEV;
  3235. }
  3236. /************************ INTERRUPT HANDLING ************************/
  3237. /*
  3238. * This function is the interrupt handler for the WaveLAN card. This
  3239. * routine will be called whenever:
  3240. */
  3241. static irqreturn_t wavelan_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  3242. {
  3243. struct net_device *dev;
  3244. unsigned long ioaddr;
  3245. net_local *lp;
  3246. u16 hasr;
  3247. u16 status;
  3248. u16 ack_cmd;
  3249. dev = dev_id;
  3250. #ifdef DEBUG_INTERRUPT_TRACE
  3251. printk(KERN_DEBUG "%s: ->wavelan_interrupt()\n", dev->name);
  3252. #endif
  3253. lp = (net_local *) dev->priv;
  3254. ioaddr = dev->base_addr;
  3255. #ifdef DEBUG_INTERRUPT_INFO
  3256. /* Check state of our spinlock */
  3257. if(spin_is_locked(&lp->spinlock))
  3258. printk(KERN_DEBUG
  3259. "%s: wavelan_interrupt(): spinlock is already locked !!!\n",
  3260. dev->name);
  3261. #endif
  3262. /* Prevent reentrancy. We need to do that because we may have
  3263. * multiple interrupt handler running concurrently.
  3264. * It is safe because interrupts are disabled before acquiring
  3265. * the spinlock. */
  3266. spin_lock(&lp->spinlock);
  3267. /* We always had spurious interrupts at startup, but lately I
  3268. * saw them comming *between* the request_irq() and the
  3269. * spin_lock_irqsave() in wavelan_open(), so the spinlock
  3270. * protection is no enough.
  3271. * So, we also check lp->hacr that will tell us is we enabled
  3272. * irqs or not (see wv_ints_on()).
  3273. * We can't use netif_running(dev) because we depend on the
  3274. * proper processing of the irq generated during the config. */
  3275. /* Which interrupt it is ? */
  3276. hasr = hasr_read(ioaddr);
  3277. #ifdef DEBUG_INTERRUPT_INFO
  3278. printk(KERN_INFO
  3279. "%s: wavelan_interrupt(): hasr 0x%04x; hacr 0x%04x.\n",
  3280. dev->name, hasr, lp->hacr);
  3281. #endif
  3282. /* Check modem interrupt */
  3283. if ((hasr & HASR_MMC_INTR) && (lp->hacr & HACR_MMC_INT_ENABLE)) {
  3284. u8 dce_status;
  3285. /*
  3286. * Interrupt from the modem management controller.
  3287. * This will clear it -- ignored for now.
  3288. */
  3289. mmc_read(ioaddr, mmroff(0, mmr_dce_status), &dce_status,
  3290. sizeof(dce_status));
  3291. #ifdef DEBUG_INTERRUPT_ERROR
  3292. printk(KERN_INFO
  3293. "%s: wavelan_interrupt(): unexpected mmc interrupt: status 0x%04x.\n",
  3294. dev->name, dce_status);
  3295. #endif
  3296. }
  3297. /* Check if not controller interrupt */
  3298. if (((hasr & HASR_82586_INTR) == 0) ||
  3299. ((lp->hacr & HACR_82586_INT_ENABLE) == 0)) {
  3300. #ifdef DEBUG_INTERRUPT_ERROR
  3301. printk(KERN_INFO
  3302. "%s: wavelan_interrupt(): interrupt not coming from i82586 - hasr 0x%04x.\n",
  3303. dev->name, hasr);
  3304. #endif
  3305. spin_unlock (&lp->spinlock);
  3306. return IRQ_NONE;
  3307. }
  3308. /* Read interrupt data. */
  3309. obram_read(ioaddr, scboff(OFFSET_SCB, scb_status),
  3310. (unsigned char *) &status, sizeof(status));
  3311. /*
  3312. * Acknowledge the interrupt(s).
  3313. */
  3314. ack_cmd = status & SCB_ST_INT;
  3315. obram_write(ioaddr, scboff(OFFSET_SCB, scb_command),
  3316. (unsigned char *) &ack_cmd, sizeof(ack_cmd));
  3317. set_chan_attn(ioaddr, lp->hacr);
  3318. #ifdef DEBUG_INTERRUPT_INFO
  3319. printk(KERN_DEBUG "%s: wavelan_interrupt(): status 0x%04x.\n",
  3320. dev->name, status);
  3321. #endif
  3322. /* Command completed. */
  3323. if ((status & SCB_ST_CX) == SCB_ST_CX) {
  3324. #ifdef DEBUG_INTERRUPT_INFO
  3325. printk(KERN_DEBUG
  3326. "%s: wavelan_interrupt(): command completed.\n",
  3327. dev->name);
  3328. #endif
  3329. wv_complete(dev, ioaddr, lp);
  3330. }
  3331. /* Frame received. */
  3332. if ((status & SCB_ST_FR) == SCB_ST_FR) {
  3333. #ifdef DEBUG_INTERRUPT_INFO
  3334. printk(KERN_DEBUG
  3335. "%s: wavelan_interrupt(): received packet.\n",
  3336. dev->name);
  3337. #endif
  3338. wv_receive(dev);
  3339. }
  3340. /* Check the state of the command unit. */
  3341. if (((status & SCB_ST_CNA) == SCB_ST_CNA) ||
  3342. (((status & SCB_ST_CUS) != SCB_ST_CUS_ACTV) &&
  3343. (netif_running(dev)))) {
  3344. #ifdef DEBUG_INTERRUPT_ERROR
  3345. printk(KERN_INFO
  3346. "%s: wavelan_interrupt(): CU inactive -- restarting\n",
  3347. dev->name);
  3348. #endif
  3349. wv_hw_reset(dev);
  3350. }
  3351. /* Check the state of the command unit. */
  3352. if (((status & SCB_ST_RNR) == SCB_ST_RNR) ||
  3353. (((status & SCB_ST_RUS) != SCB_ST_RUS_RDY) &&
  3354. (netif_running(dev)))) {
  3355. #ifdef DEBUG_INTERRUPT_ERROR
  3356. printk(KERN_INFO
  3357. "%s: wavelan_interrupt(): RU not ready -- restarting\n",
  3358. dev->name);
  3359. #endif
  3360. wv_hw_reset(dev);
  3361. }
  3362. /* Release spinlock */
  3363. spin_unlock (&lp->spinlock);
  3364. #ifdef DEBUG_INTERRUPT_TRACE
  3365. printk(KERN_DEBUG "%s: <-wavelan_interrupt()\n", dev->name);
  3366. #endif
  3367. return IRQ_HANDLED;
  3368. }
  3369. /*------------------------------------------------------------------*/
  3370. /*
  3371. * Watchdog: when we start a transmission, a timer is set for us in the
  3372. * kernel. If the transmission completes, this timer is disabled. If
  3373. * the timer expires, we are called and we try to unlock the hardware.
  3374. */
  3375. static void wavelan_watchdog(struct net_device * dev)
  3376. {
  3377. net_local * lp = (net_local *)dev->priv;
  3378. u_long ioaddr = dev->base_addr;
  3379. unsigned long flags;
  3380. unsigned int nreaped;
  3381. #ifdef DEBUG_INTERRUPT_TRACE
  3382. printk(KERN_DEBUG "%s: ->wavelan_watchdog()\n", dev->name);
  3383. #endif
  3384. #ifdef DEBUG_INTERRUPT_ERROR
  3385. printk(KERN_INFO "%s: wavelan_watchdog: watchdog timer expired\n",
  3386. dev->name);
  3387. #endif
  3388. /* Check that we came here for something */
  3389. if (lp->tx_n_in_use <= 0) {
  3390. return;
  3391. }
  3392. spin_lock_irqsave(&lp->spinlock, flags);
  3393. /* Try to see if some buffers are not free (in case we missed
  3394. * an interrupt */
  3395. nreaped = wv_complete(dev, ioaddr, lp);
  3396. #ifdef DEBUG_INTERRUPT_INFO
  3397. printk(KERN_DEBUG
  3398. "%s: wavelan_watchdog(): %d reaped, %d remain.\n",
  3399. dev->name, nreaped, lp->tx_n_in_use);
  3400. #endif
  3401. #ifdef DEBUG_PSA_SHOW
  3402. {
  3403. psa_t psa;
  3404. psa_read(dev, 0, (unsigned char *) &psa, sizeof(psa));
  3405. wv_psa_show(&psa);
  3406. }
  3407. #endif
  3408. #ifdef DEBUG_MMC_SHOW
  3409. wv_mmc_show(dev);
  3410. #endif
  3411. #ifdef DEBUG_I82586_SHOW
  3412. wv_cu_show(dev);
  3413. #endif
  3414. /* If no buffer has been freed */
  3415. if (nreaped == 0) {
  3416. #ifdef DEBUG_INTERRUPT_ERROR
  3417. printk(KERN_INFO
  3418. "%s: wavelan_watchdog(): cleanup failed, trying reset\n",
  3419. dev->name);
  3420. #endif
  3421. wv_hw_reset(dev);
  3422. }
  3423. /* At this point, we should have some free Tx buffer ;-) */
  3424. if (lp->tx_n_in_use < NTXBLOCKS - 1)
  3425. netif_wake_queue(dev);
  3426. spin_unlock_irqrestore(&lp->spinlock, flags);
  3427. #ifdef DEBUG_INTERRUPT_TRACE
  3428. printk(KERN_DEBUG "%s: <-wavelan_watchdog()\n", dev->name);
  3429. #endif
  3430. }
  3431. /********************* CONFIGURATION CALLBACKS *********************/
  3432. /*
  3433. * Here are the functions called by the Linux networking code (NET3)
  3434. * for initialization, configuration and deinstallations of the
  3435. * WaveLAN ISA hardware.
  3436. */
  3437. /*------------------------------------------------------------------*/
  3438. /*
  3439. * Configure and start up the WaveLAN PCMCIA adaptor.
  3440. * Called by NET3 when it "opens" the device.
  3441. */
  3442. static int wavelan_open(struct net_device * dev)
  3443. {
  3444. net_local * lp = (net_local *)dev->priv;
  3445. unsigned long flags;
  3446. #ifdef DEBUG_CALLBACK_TRACE
  3447. printk(KERN_DEBUG "%s: ->wavelan_open(dev=0x%x)\n", dev->name,
  3448. (unsigned int) dev);
  3449. #endif
  3450. /* Check irq */
  3451. if (dev->irq == 0) {
  3452. #ifdef DEBUG_CONFIG_ERROR
  3453. printk(KERN_WARNING "%s: wavelan_open(): no IRQ\n",
  3454. dev->name);
  3455. #endif
  3456. return -ENXIO;
  3457. }
  3458. if (request_irq(dev->irq, &wavelan_interrupt, 0, "WaveLAN", dev) != 0)
  3459. {
  3460. #ifdef DEBUG_CONFIG_ERROR
  3461. printk(KERN_WARNING "%s: wavelan_open(): invalid IRQ\n",
  3462. dev->name);
  3463. #endif
  3464. return -EAGAIN;
  3465. }
  3466. spin_lock_irqsave(&lp->spinlock, flags);
  3467. if (wv_hw_reset(dev) != -1) {
  3468. netif_start_queue(dev);
  3469. } else {
  3470. free_irq(dev->irq, dev);
  3471. #ifdef DEBUG_CONFIG_ERROR
  3472. printk(KERN_INFO
  3473. "%s: wavelan_open(): impossible to start the card\n",
  3474. dev->name);
  3475. #endif
  3476. spin_unlock_irqrestore(&lp->spinlock, flags);
  3477. return -EAGAIN;
  3478. }
  3479. spin_unlock_irqrestore(&lp->spinlock, flags);
  3480. #ifdef DEBUG_CALLBACK_TRACE
  3481. printk(KERN_DEBUG "%s: <-wavelan_open()\n", dev->name);
  3482. #endif
  3483. return 0;
  3484. }
  3485. /*------------------------------------------------------------------*/
  3486. /*
  3487. * Shut down the WaveLAN ISA card.
  3488. * Called by NET3 when it "closes" the device.
  3489. */
  3490. static int wavelan_close(struct net_device * dev)
  3491. {
  3492. net_local *lp = (net_local *) dev->priv;
  3493. unsigned long flags;
  3494. #ifdef DEBUG_CALLBACK_TRACE
  3495. printk(KERN_DEBUG "%s: ->wavelan_close(dev=0x%x)\n", dev->name,
  3496. (unsigned int) dev);
  3497. #endif
  3498. netif_stop_queue(dev);
  3499. /*
  3500. * Flush the Tx and disable Rx.
  3501. */
  3502. spin_lock_irqsave(&lp->spinlock, flags);
  3503. wv_82586_stop(dev);
  3504. spin_unlock_irqrestore(&lp->spinlock, flags);
  3505. free_irq(dev->irq, dev);
  3506. #ifdef DEBUG_CALLBACK_TRACE
  3507. printk(KERN_DEBUG "%s: <-wavelan_close()\n", dev->name);
  3508. #endif
  3509. return 0;
  3510. }
  3511. /*------------------------------------------------------------------*/
  3512. /*
  3513. * Probe an I/O address, and if the WaveLAN is there configure the
  3514. * device structure
  3515. * (called by wavelan_probe() and via init_module()).
  3516. */
  3517. static int __init wavelan_config(struct net_device *dev, unsigned short ioaddr)
  3518. {
  3519. u8 irq_mask;
  3520. int irq;
  3521. net_local *lp;
  3522. mac_addr mac;
  3523. int err;
  3524. if (!request_region(ioaddr, sizeof(ha_t), "wavelan"))
  3525. return -EADDRINUSE;
  3526. err = wv_check_ioaddr(ioaddr, mac);
  3527. if (err)
  3528. goto out;
  3529. memcpy(dev->dev_addr, mac, 6);
  3530. dev->base_addr = ioaddr;
  3531. #ifdef DEBUG_CALLBACK_TRACE
  3532. printk(KERN_DEBUG "%s: ->wavelan_config(dev=0x%x, ioaddr=0x%lx)\n",
  3533. dev->name, (unsigned int) dev, ioaddr);
  3534. #endif
  3535. /* Check IRQ argument on command line. */
  3536. if (dev->irq != 0) {
  3537. irq_mask = wv_irq_to_psa(dev->irq);
  3538. if (irq_mask == 0) {
  3539. #ifdef DEBUG_CONFIG_ERROR
  3540. printk(KERN_WARNING
  3541. "%s: wavelan_config(): invalid IRQ %d ignored.\n",
  3542. dev->name, dev->irq);
  3543. #endif
  3544. dev->irq = 0;
  3545. } else {
  3546. #ifdef DEBUG_CONFIG_INFO
  3547. printk(KERN_DEBUG
  3548. "%s: wavelan_config(): changing IRQ to %d\n",
  3549. dev->name, dev->irq);
  3550. #endif
  3551. psa_write(ioaddr, HACR_DEFAULT,
  3552. psaoff(0, psa_int_req_no), &irq_mask, 1);
  3553. /* update the Wavelan checksum */
  3554. update_psa_checksum(dev, ioaddr, HACR_DEFAULT);
  3555. wv_hacr_reset(ioaddr);
  3556. }
  3557. }
  3558. psa_read(ioaddr, HACR_DEFAULT, psaoff(0, psa_int_req_no),
  3559. &irq_mask, 1);
  3560. if ((irq = wv_psa_to_irq(irq_mask)) == -1) {
  3561. #ifdef DEBUG_CONFIG_ERROR
  3562. printk(KERN_INFO
  3563. "%s: wavelan_config(): could not wavelan_map_irq(%d).\n",
  3564. dev->name, irq_mask);
  3565. #endif
  3566. err = -EAGAIN;
  3567. goto out;
  3568. }
  3569. dev->irq = irq;
  3570. dev->mem_start = 0x0000;
  3571. dev->mem_end = 0x0000;
  3572. dev->if_port = 0;
  3573. /* Initialize device structures */
  3574. memset(dev->priv, 0, sizeof(net_local));
  3575. lp = (net_local *) dev->priv;
  3576. /* Back link to the device structure. */
  3577. lp->dev = dev;
  3578. /* Add the device at the beginning of the linked list. */
  3579. lp->next = wavelan_list;
  3580. wavelan_list = lp;
  3581. lp->hacr = HACR_DEFAULT;
  3582. /* Multicast stuff */
  3583. lp->promiscuous = 0;
  3584. lp->mc_count = 0;
  3585. /* Init spinlock */
  3586. spin_lock_init(&lp->spinlock);
  3587. SET_MODULE_OWNER(dev);
  3588. dev->open = wavelan_open;
  3589. dev->stop = wavelan_close;
  3590. dev->hard_start_xmit = wavelan_packet_xmit;
  3591. dev->get_stats = wavelan_get_stats;
  3592. dev->set_multicast_list = &wavelan_set_multicast_list;
  3593. dev->tx_timeout = &wavelan_watchdog;
  3594. dev->watchdog_timeo = WATCHDOG_JIFFIES;
  3595. #ifdef SET_MAC_ADDRESS
  3596. dev->set_mac_address = &wavelan_set_mac_address;
  3597. #endif /* SET_MAC_ADDRESS */
  3598. dev->wireless_handlers = &wavelan_handler_def;
  3599. lp->wireless_data.spy_data = &lp->spy_data;
  3600. dev->wireless_data = &lp->wireless_data;
  3601. dev->mtu = WAVELAN_MTU;
  3602. /* Display nice information. */
  3603. wv_init_info(dev);
  3604. #ifdef DEBUG_CALLBACK_TRACE
  3605. printk(KERN_DEBUG "%s: <-wavelan_config()\n", dev->name);
  3606. #endif
  3607. return 0;
  3608. out:
  3609. release_region(ioaddr, sizeof(ha_t));
  3610. return err;
  3611. }
  3612. /*------------------------------------------------------------------*/
  3613. /*
  3614. * Check for a network adaptor of this type. Return '0' iff one
  3615. * exists. There seem to be different interpretations of
  3616. * the initial value of dev->base_addr.
  3617. * We follow the example in drivers/net/ne.c.
  3618. * (called in "Space.c")
  3619. */
  3620. struct net_device * __init wavelan_probe(int unit)
  3621. {
  3622. struct net_device *dev;
  3623. short base_addr;
  3624. int def_irq;
  3625. int i;
  3626. int r = 0;
  3627. #ifdef STRUCT_CHECK
  3628. if (wv_struct_check() != (char *) NULL) {
  3629. printk(KERN_WARNING
  3630. "%s: wavelan_probe(): structure/compiler botch: \"%s\"\n",
  3631. dev->name, wv_struct_check());
  3632. return -ENODEV;
  3633. }
  3634. #endif /* STRUCT_CHECK */
  3635. dev = alloc_etherdev(sizeof(net_local));
  3636. if (!dev)
  3637. return ERR_PTR(-ENOMEM);
  3638. sprintf(dev->name, "eth%d", unit);
  3639. netdev_boot_setup_check(dev);
  3640. base_addr = dev->base_addr;
  3641. def_irq = dev->irq;
  3642. #ifdef DEBUG_CALLBACK_TRACE
  3643. printk(KERN_DEBUG
  3644. "%s: ->wavelan_probe(dev=%p (base_addr=0x%x))\n",
  3645. dev->name, dev, (unsigned int) dev->base_addr);
  3646. #endif
  3647. /* Don't probe at all. */
  3648. if (base_addr < 0) {
  3649. #ifdef DEBUG_CONFIG_ERROR
  3650. printk(KERN_WARNING
  3651. "%s: wavelan_probe(): invalid base address\n",
  3652. dev->name);
  3653. #endif
  3654. r = -ENXIO;
  3655. } else if (base_addr > 0x100) { /* Check a single specified location. */
  3656. r = wavelan_config(dev, base_addr);
  3657. #ifdef DEBUG_CONFIG_INFO
  3658. if (r != 0)
  3659. printk(KERN_DEBUG
  3660. "%s: wavelan_probe(): no device at specified base address (0x%X) or address already in use\n",
  3661. dev->name, base_addr);
  3662. #endif
  3663. #ifdef DEBUG_CALLBACK_TRACE
  3664. printk(KERN_DEBUG "%s: <-wavelan_probe()\n", dev->name);
  3665. #endif
  3666. } else { /* Scan all possible addresses of the WaveLAN hardware. */
  3667. for (i = 0; i < NELS(iobase); i++) {
  3668. dev->irq = def_irq;
  3669. if (wavelan_config(dev, iobase[i]) == 0) {
  3670. #ifdef DEBUG_CALLBACK_TRACE
  3671. printk(KERN_DEBUG
  3672. "%s: <-wavelan_probe()\n",
  3673. dev->name);
  3674. #endif
  3675. break;
  3676. }
  3677. }
  3678. if (i == NELS(iobase))
  3679. r = -ENODEV;
  3680. }
  3681. if (r)
  3682. goto out;
  3683. r = register_netdev(dev);
  3684. if (r)
  3685. goto out1;
  3686. return dev;
  3687. out1:
  3688. release_region(dev->base_addr, sizeof(ha_t));
  3689. wavelan_list = wavelan_list->next;
  3690. out:
  3691. free_netdev(dev);
  3692. return ERR_PTR(r);
  3693. }
  3694. /****************************** MODULE ******************************/
  3695. /*
  3696. * Module entry point: insertion and removal
  3697. */
  3698. #ifdef MODULE
  3699. /*------------------------------------------------------------------*/
  3700. /*
  3701. * Insertion of the module
  3702. * I'm now quite proud of the multi-device support.
  3703. */
  3704. int init_module(void)
  3705. {
  3706. int ret = -EIO; /* Return error if no cards found */
  3707. int i;
  3708. #ifdef DEBUG_MODULE_TRACE
  3709. printk(KERN_DEBUG "-> init_module()\n");
  3710. #endif
  3711. /* If probing is asked */
  3712. if (io[0] == 0) {
  3713. #ifdef DEBUG_CONFIG_ERROR
  3714. printk(KERN_WARNING
  3715. "WaveLAN init_module(): doing device probing (bad !)\n");
  3716. printk(KERN_WARNING
  3717. "Specify base addresses while loading module to correct the problem\n");
  3718. #endif
  3719. /* Copy the basic set of address to be probed. */
  3720. for (i = 0; i < NELS(iobase); i++)
  3721. io[i] = iobase[i];
  3722. }
  3723. /* Loop on all possible base addresses. */
  3724. i = -1;
  3725. while ((io[++i] != 0) && (i < NELS(io))) {
  3726. struct net_device *dev = alloc_etherdev(sizeof(net_local));
  3727. if (!dev)
  3728. break;
  3729. if (name[i])
  3730. strcpy(dev->name, name[i]); /* Copy name */
  3731. dev->base_addr = io[i];
  3732. dev->irq = irq[i];
  3733. /* Check if there is something at this base address. */
  3734. if (wavelan_config(dev, io[i]) == 0) {
  3735. if (register_netdev(dev) != 0) {
  3736. release_region(dev->base_addr, sizeof(ha_t));
  3737. wavelan_list = wavelan_list->next;
  3738. } else {
  3739. ret = 0;
  3740. continue;
  3741. }
  3742. }
  3743. free_netdev(dev);
  3744. }
  3745. #ifdef DEBUG_CONFIG_ERROR
  3746. if (!wavelan_list)
  3747. printk(KERN_WARNING
  3748. "WaveLAN init_module(): no device found\n");
  3749. #endif
  3750. #ifdef DEBUG_MODULE_TRACE
  3751. printk(KERN_DEBUG "<- init_module()\n");
  3752. #endif
  3753. return ret;
  3754. }
  3755. /*------------------------------------------------------------------*/
  3756. /*
  3757. * Removal of the module
  3758. */
  3759. void cleanup_module(void)
  3760. {
  3761. #ifdef DEBUG_MODULE_TRACE
  3762. printk(KERN_DEBUG "-> cleanup_module()\n");
  3763. #endif
  3764. /* Loop on all devices and release them. */
  3765. while (wavelan_list) {
  3766. struct net_device *dev = wavelan_list->dev;
  3767. #ifdef DEBUG_CONFIG_INFO
  3768. printk(KERN_DEBUG
  3769. "%s: cleanup_module(): removing device at 0x%x\n",
  3770. dev->name, (unsigned int) dev);
  3771. #endif
  3772. unregister_netdev(dev);
  3773. release_region(dev->base_addr, sizeof(ha_t));
  3774. wavelan_list = wavelan_list->next;
  3775. free_netdev(dev);
  3776. }
  3777. #ifdef DEBUG_MODULE_TRACE
  3778. printk(KERN_DEBUG "<- cleanup_module()\n");
  3779. #endif
  3780. }
  3781. #endif /* MODULE */
  3782. MODULE_LICENSE("GPL");
  3783. /*
  3784. * This software may only be used and distributed
  3785. * according to the terms of the GNU General Public License.
  3786. *
  3787. * This software was developed as a component of the
  3788. * Linux operating system.
  3789. * It is based on other device drivers and information
  3790. * either written or supplied by:
  3791. * Ajay Bakre (bakre@paul.rutgers.edu),
  3792. * Donald Becker (becker@scyld.com),
  3793. * Loeke Brederveld (Loeke.Brederveld@Utrecht.NCR.com),
  3794. * Anders Klemets (klemets@it.kth.se),
  3795. * Vladimir V. Kolpakov (w@stier.koenig.ru),
  3796. * Marc Meertens (Marc.Meertens@Utrecht.NCR.com),
  3797. * Pauline Middelink (middelin@polyware.iaf.nl),
  3798. * Robert Morris (rtm@das.harvard.edu),
  3799. * Jean Tourrilhes (jt@hplb.hpl.hp.com),
  3800. * Girish Welling (welling@paul.rutgers.edu),
  3801. *
  3802. * Thanks go also to:
  3803. * James Ashton (jaa101@syseng.anu.edu.au),
  3804. * Alan Cox (alan@redhat.com),
  3805. * Allan Creighton (allanc@cs.usyd.edu.au),
  3806. * Matthew Geier (matthew@cs.usyd.edu.au),
  3807. * Remo di Giovanni (remo@cs.usyd.edu.au),
  3808. * Eckhard Grah (grah@wrcs1.urz.uni-wuppertal.de),
  3809. * Vipul Gupta (vgupta@cs.binghamton.edu),
  3810. * Mark Hagan (mhagan@wtcpost.daytonoh.NCR.COM),
  3811. * Tim Nicholson (tim@cs.usyd.edu.au),
  3812. * Ian Parkin (ian@cs.usyd.edu.au),
  3813. * John Rosenberg (johnr@cs.usyd.edu.au),
  3814. * George Rossi (george@phm.gov.au),
  3815. * Arthur Scott (arthur@cs.usyd.edu.au),
  3816. * Peter Storey,
  3817. * for their assistance and advice.
  3818. *
  3819. * Please send bug reports, updates, comments to:
  3820. *
  3821. * Bruce Janson Email: bruce@cs.usyd.edu.au
  3822. * Basser Department of Computer Science Phone: +61-2-9351-3423
  3823. * University of Sydney, N.S.W., 2006, AUSTRALIA Fax: +61-2-9351-3838
  3824. */