wavelan.c 121 KB

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