wavelan.c 122 KB

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