wavelan.c 123 KB

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