wavelan.c 121 KB

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