orinoco.c 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037
  1. /* orinoco.c - (formerly known as dldwd_cs.c and orinoco_cs.c)
  2. *
  3. * A driver for Hermes or Prism 2 chipset based PCMCIA wireless
  4. * adaptors, with Lucent/Agere, Intersil or Symbol firmware.
  5. *
  6. * Current maintainers (as of 29 September 2003) are:
  7. * Pavel Roskin <proski AT gnu.org>
  8. * and David Gibson <hermes AT gibson.dropbear.id.au>
  9. *
  10. * (C) Copyright David Gibson, IBM Corporation 2001-2003.
  11. * Copyright (C) 2000 David Gibson, Linuxcare Australia.
  12. * With some help from :
  13. * Copyright (C) 2001 Jean Tourrilhes, HP Labs
  14. * Copyright (C) 2001 Benjamin Herrenschmidt
  15. *
  16. * Based on dummy_cs.c 1.27 2000/06/12 21:27:25
  17. *
  18. * Portions based on wvlan_cs.c 1.0.6, Copyright Andreas Neuhaus <andy
  19. * AT fasta.fh-dortmund.de>
  20. * http://www.stud.fh-dortmund.de/~andy/wvlan/
  21. *
  22. * The contents of this file are subject to the Mozilla Public License
  23. * Version 1.1 (the "License"); you may not use this file except in
  24. * compliance with the License. You may obtain a copy of the License
  25. * at http://www.mozilla.org/MPL/
  26. *
  27. * Software distributed under the License is distributed on an "AS IS"
  28. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  29. * the License for the specific language governing rights and
  30. * limitations under the License.
  31. *
  32. * The initial developer of the original code is David A. Hinds
  33. * <dahinds AT users.sourceforge.net>. Portions created by David
  34. * A. Hinds are Copyright (C) 1999 David A. Hinds. All Rights
  35. * Reserved.
  36. *
  37. * Alternatively, the contents of this file may be used under the
  38. * terms of the GNU General Public License version 2 (the "GPL"), in
  39. * which case the provisions of the GPL are applicable instead of the
  40. * above. If you wish to allow the use of your version of this file
  41. * only under the terms of the GPL and not to allow others to use your
  42. * version of this file under the MPL, indicate your decision by
  43. * deleting the provisions above and replace them with the notice and
  44. * other provisions required by the GPL. If you do not delete the
  45. * provisions above, a recipient may use your version of this file
  46. * under either the MPL or the GPL. */
  47. /*
  48. * v0.01 -> v0.02 - 21/3/2001 - Jean II
  49. * o Allow to use regular ethX device name instead of dldwdX
  50. * o Warning on IBSS with ESSID=any for firmware 6.06
  51. * o Put proper range.throughput values (optimistic)
  52. * o IWSPY support (IOCTL and stat gather in Rx path)
  53. * o Allow setting frequency in Ad-Hoc mode
  54. * o Disable WEP setting if !has_wep to work on old firmware
  55. * o Fix txpower range
  56. * o Start adding support for Samsung/Compaq firmware
  57. *
  58. * v0.02 -> v0.03 - 23/3/2001 - Jean II
  59. * o Start adding Symbol support - need to check all that
  60. * o Fix Prism2/Symbol WEP to accept 128 bits keys
  61. * o Add Symbol WEP (add authentication type)
  62. * o Add Prism2/Symbol rate
  63. * o Add PM timeout (holdover duration)
  64. * o Enable "iwconfig eth0 key off" and friends (toggle flags)
  65. * o Enable "iwconfig eth0 power unicast/all" (toggle flags)
  66. * o Try with an Intel card. It report firmware 1.01, behave like
  67. * an antiquated firmware, however on windows it says 2.00. Yuck !
  68. * o Workaround firmware bug in allocate buffer (Intel 1.01)
  69. * o Finish external renaming to orinoco...
  70. * o Testing with various Wavelan firmwares
  71. *
  72. * v0.03 -> v0.04 - 30/3/2001 - Jean II
  73. * o Update to Wireless 11 -> add retry limit/lifetime support
  74. * o Tested with a D-Link DWL 650 card, fill in firmware support
  75. * o Warning on Vcc mismatch (D-Link 3.3v card in Lucent 5v only slot)
  76. * o Fixed the Prism2 WEP bugs that I introduced in v0.03 :-(
  77. * It works on D-Link *only* after a tcpdump. Weird...
  78. * And still doesn't work on Intel card. Grrrr...
  79. * o Update the mode after a setport3
  80. * o Add preamble setting for Symbol cards (not yet enabled)
  81. * o Don't complain as much about Symbol cards...
  82. *
  83. * v0.04 -> v0.04b - 22/4/2001 - David Gibson
  84. * o Removed the 'eth' parameter - always use ethXX as the
  85. * interface name instead of dldwdXX. The other was racy
  86. * anyway.
  87. * o Clean up RID definitions in hermes.h, other cleanups
  88. *
  89. * v0.04b -> v0.04c - 24/4/2001 - Jean II
  90. * o Tim Hurley <timster AT seiki.bliztech.com> reported a D-Link card
  91. * with vendor 02 and firmware 0.08. Added in the capabilities...
  92. * o Tested Lucent firmware 7.28, everything works...
  93. *
  94. * v0.04c -> v0.05 - 3/5/2001 - Benjamin Herrenschmidt
  95. * o Spin-off Pcmcia code. This file is renamed orinoco.c,
  96. * and orinoco_cs.c now contains only the Pcmcia specific stuff
  97. * o Add Airport driver support on top of orinoco.c (see airport.c)
  98. *
  99. * v0.05 -> v0.05a - 4/5/2001 - Jean II
  100. * o Revert to old Pcmcia code to fix breakage of Ben's changes...
  101. *
  102. * v0.05a -> v0.05b - 4/5/2001 - Jean II
  103. * o add module parameter 'ignore_cis_vcc' for D-Link @ 5V
  104. * o D-Link firmware doesn't support multicast. We just print a few
  105. * error messages, but otherwise everything works...
  106. * o For David : set/getport3 works fine, just upgrade iwpriv...
  107. *
  108. * v0.05b -> v0.05c - 5/5/2001 - Benjamin Herrenschmidt
  109. * o Adapt airport.c to latest changes in orinoco.c
  110. * o Remove deferred power enabling code
  111. *
  112. * v0.05c -> v0.05d - 5/5/2001 - Jean II
  113. * o Workaround to SNAP decapsulate frame from Linksys AP
  114. * original patch from : Dong Liu <dliu AT research.bell-labs.com>
  115. * (note : the memcmp bug was mine - fixed)
  116. * o Remove set_retry stuff, no firmware support it (bloat--).
  117. *
  118. * v0.05d -> v0.06 - 25/5/2001 - Jean II
  119. * Original patch from "Hong Lin" <alin AT redhat.com>,
  120. * "Ian Kinner" <ikinner AT redhat.com>
  121. * and "David Smith" <dsmith AT redhat.com>
  122. * o Init of priv->tx_rate_ctrl in firmware specific section.
  123. * o Prism2/Symbol rate, upto should be 0xF and not 0x15. Doh !
  124. * o Spectrum card always need cor_reset (for every reset)
  125. * o Fix cor_reset to not lose bit 7 in the register
  126. * o flush_stale_links to remove zombie Pcmcia instances
  127. * o Ack previous hermes event before reset
  128. * Me (with my little hands)
  129. * o Allow orinoco.c to call cor_reset via priv->card_reset_handler
  130. * o Add priv->need_card_reset to toggle this feature
  131. * o Fix various buglets when setting WEP in Symbol firmware
  132. * Now, encryption is fully functional on Symbol cards. Youpi !
  133. *
  134. * v0.06 -> v0.06b - 25/5/2001 - Jean II
  135. * o IBSS on Symbol use port_mode = 4. Please don't ask...
  136. *
  137. * v0.06b -> v0.06c - 29/5/2001 - Jean II
  138. * o Show first spy address in /proc/net/wireless for IBSS mode as well
  139. *
  140. * v0.06c -> v0.06d - 6/7/2001 - David Gibson
  141. * o Change a bunch of KERN_INFO messages to KERN_DEBUG, as per Linus'
  142. * wishes to reduce the number of unnecessary messages.
  143. * o Removed bogus message on CRC error.
  144. * o Merged fixes for v0.08 Prism 2 firmware from William Waghorn
  145. * <willwaghorn AT yahoo.co.uk>
  146. * o Slight cleanup/re-arrangement of firmware detection code.
  147. *
  148. * v0.06d -> v0.06e - 1/8/2001 - David Gibson
  149. * o Removed some redundant global initializers (orinoco_cs.c).
  150. * o Added some module metadata
  151. *
  152. * v0.06e -> v0.06f - 14/8/2001 - David Gibson
  153. * o Wording fix to license
  154. * o Added a 'use_alternate_encaps' module parameter for APs which need an
  155. * oui of 00:00:00. We really need a better way of handling this, but
  156. * the module flag is better than nothing for now.
  157. *
  158. * v0.06f -> v0.07 - 20/8/2001 - David Gibson
  159. * o Removed BAP error retries from hermes_bap_seek(). For Tx we now
  160. * let the upper layers handle the retry, we retry explicitly in the
  161. * Rx path, but don't make as much noise about it.
  162. * o Firmware detection cleanups.
  163. *
  164. * v0.07 -> v0.07a - 1/10/3001 - Jean II
  165. * o Add code to read Symbol firmware revision, inspired by latest code
  166. * in Spectrum24 by Lee John Keyser-Allen - Thanks Lee !
  167. * o Thanks to Jared Valentine <hidden AT xmission.com> for "providing" me
  168. * a 3Com card with a recent firmware, fill out Symbol firmware
  169. * capabilities of latest rev (2.20), as well as older Symbol cards.
  170. * o Disable Power Management in newer Symbol firmware, the API
  171. * has changed (documentation needed).
  172. *
  173. * v0.07a -> v0.08 - 3/10/2001 - David Gibson
  174. * o Fixed a possible buffer overrun found by the Stanford checker (in
  175. * dldwd_ioctl_setiwencode()). Can only be called by root anyway, so not
  176. * a big problem.
  177. * o Turned has_big_wep on for Intersil cards. That's not true for all of
  178. * them but we should at least let the capable ones try.
  179. * o Wait for BUSY to clear at the beginning of hermes_bap_seek(). I
  180. * realized that my assumption that the driver's serialization
  181. * would prevent the BAP being busy on entry was possibly false, because
  182. * things other than seeks may make the BAP busy.
  183. * o Use "alternate" (oui 00:00:00) encapsulation by default.
  184. * Setting use_old_encaps will mimic the old behaviour, but I think we
  185. * will be able to eliminate this.
  186. * o Don't try to make __initdata const (the version string). This can't
  187. * work because of the way the __initdata sectioning works.
  188. * o Added MODULE_LICENSE tags.
  189. * o Support for PLX (transparent PCMCIA->PCI bridge) cards.
  190. * o Changed to using the new type-fascist min/max.
  191. *
  192. * v0.08 -> v0.08a - 9/10/2001 - David Gibson
  193. * o Inserted some missing acknowledgements/info into the Changelog.
  194. * o Fixed some bugs in the normalization of signal level reporting.
  195. * o Fixed bad bug in WEP key handling on Intersil and Symbol firmware,
  196. * which led to an instant crash on big-endian machines.
  197. *
  198. * v0.08a -> v0.08b - 20/11/2001 - David Gibson
  199. * o Lots of cleanup and bugfixes in orinoco_plx.c
  200. * o Cleanup to handling of Tx rate setting.
  201. * o Removed support for old encapsulation method.
  202. * o Removed old "dldwd" names.
  203. * o Split RID constants into a new file hermes_rid.h
  204. * o Renamed RID constants to match linux-wlan-ng and prism2.o
  205. * o Bugfixes in hermes.c
  206. * o Poke the PLX's INTCSR register, so it actually starts
  207. * generating interrupts. These cards might actually work now.
  208. * o Update to wireless extensions v12 (Jean II)
  209. * o Support for tallies and inquire command (Jean II)
  210. * o Airport updates for newer PPC kernels (BenH)
  211. *
  212. * v0.08b -> v0.09 - 21/12/2001 - David Gibson
  213. * o Some new PCI IDs for PLX cards.
  214. * o Removed broken attempt to do ALLMULTI reception. Just use
  215. * promiscuous mode instead
  216. * o Preliminary work for list-AP (Jean II)
  217. * o Airport updates from (BenH)
  218. * o Eliminated racy hw_ready stuff
  219. * o Fixed generation of fake events in irq handler. This should
  220. * finally kill the EIO problems (Jean II & dgibson)
  221. * o Fixed breakage of bitrate set/get on Agere firmware (Jean II)
  222. *
  223. * v0.09 -> v0.09a - 2/1/2002 - David Gibson
  224. * o Fixed stupid mistake in multicast list handling, triggering
  225. * a BUG()
  226. *
  227. * v0.09a -> v0.09b - 16/1/2002 - David Gibson
  228. * o Fixed even stupider mistake in new interrupt handling, which
  229. * seriously broke things on big-endian machines.
  230. * o Removed a bunch of redundant includes and exports.
  231. * o Removed a redundant MOD_{INC,DEC}_USE_COUNT pair in airport.c
  232. * o Don't attempt to do hardware level multicast reception on
  233. * Intersil firmware, just go promisc instead.
  234. * o Typo fixed in hermes_issue_cmd()
  235. * o Eliminated WIRELESS_SPY #ifdefs
  236. * o Status code reported on Tx exceptions
  237. * o Moved netif_wake_queue() from ALLOC interrupts to TX and TXEXC
  238. * interrupts, which should fix the timeouts we're seeing.
  239. *
  240. * v0.09b -> v0.10 - 25 Feb 2002 - David Gibson
  241. * o Removed nested structures used for header parsing, so the
  242. * driver should now work without hackery on ARM
  243. * o Fix for WEP handling on Intersil (Hawk Newton)
  244. * o Eliminated the /proc/hermes/ethXX/regs debugging file. It
  245. * was never very useful.
  246. * o Make Rx errors less noisy.
  247. *
  248. * v0.10 -> v0.11 - 5 Apr 2002 - David Gibson
  249. * o Laid the groundwork in hermes.[ch] for devices which map
  250. * into PCI memory space rather than IO space.
  251. * o Fixed bug in multicast handling (cleared multicast list when
  252. * leaving promiscuous mode).
  253. * o Relegated Tx error messages to debug.
  254. * o Cleaned up / corrected handling of allocation lengths.
  255. * o Set OWNSSID in IBSS mode for WinXP interoperability (jimc).
  256. * o Change to using alloc_etherdev() for structure allocations.
  257. * o Check for and drop undersized packets.
  258. * o Fixed a race in stopping/waking the queue. This should fix
  259. * the timeout problems (Pavel Roskin)
  260. * o Reverted to netif_wake_queue() on the ALLOC event.
  261. * o Fixes for recent Symbol firmwares which lack AP density
  262. * (Pavel Roskin).
  263. *
  264. * v0.11 -> v0.11a - 29 Apr 2002 - David Gibson
  265. * o Handle different register spacing, necessary for Prism 2.5
  266. * PCI adaptors (Steve Hill).
  267. * o Cleaned up initialization of card structures in orinoco_cs
  268. * and airport. Removed card->priv field.
  269. * o Make response structure optional for hermes_docmd_wait()
  270. * Pavel Roskin)
  271. * o Added PCI id for Nortel emobility to orinoco_plx.c.
  272. * o Cleanup to handling of Symbol's allocation bug. (Pavel Roskin)
  273. * o Cleanups to firmware capability detection.
  274. * o Arrange for orinoco_pci.c to override firmware detection.
  275. * We should be able to support the PCI Intersil cards now.
  276. * o Cleanup handling of reset_cor and hard_reset (Pavel Roskin).
  277. * o Remove erroneous use of USER_BAP in the TxExc handler (Jouni
  278. * Malinen).
  279. * o Makefile changes for better integration into David Hinds
  280. * pcmcia-cs package.
  281. *
  282. * v0.11a -> v0.11b - 1 May 2002 - David Gibson
  283. * o Better error reporting in orinoco_plx_init_one()
  284. * o Fixed multiple bad kfree() bugs introduced by the
  285. * alloc_orinocodev() changes.
  286. *
  287. * v0.11b -> v0.12 - 19 Jun 2002 - David Gibson
  288. * o Support changing the MAC address.
  289. * o Correct display of Intersil firmware revision numbers.
  290. * o Entirely revised locking scheme. Should be both simpler and
  291. * better.
  292. * o Merged some common code in orinoco_plx, orinoco_pci and
  293. * airport by creating orinoco_default_{open,stop,reset}()
  294. * which are used as the dev->open, dev->stop, priv->reset
  295. * callbacks if none are specified when alloc_orinocodev() is
  296. * called.
  297. * o Removed orinoco_plx_interrupt() and orinoco_pci_interrupt().
  298. * They didn't do anything.
  299. *
  300. * v0.12 -> v0.12a - 4 Jul 2002 - David Gibson
  301. * o Some rearrangement of code.
  302. * o Numerous fixups to locking and rest handling, particularly
  303. * for PCMCIA.
  304. * o This allows open and stop net_device methods to be in
  305. * orinoco.c now, rather than in the init modules.
  306. * o In orinoco_cs.c link->priv now points to the struct
  307. * net_device not to the struct orinoco_private.
  308. * o Added a check for undersized SNAP frames, which could cause
  309. * crashes.
  310. *
  311. * v0.12a -> v0.12b - 11 Jul 2002 - David Gibson
  312. * o Fix hw->num_init testing code, so num_init is actually
  313. * incremented.
  314. * o Fix very stupid bug in orinoco_cs which broke compile with
  315. * CONFIG_SMP.
  316. * o Squashed a warning.
  317. *
  318. * v0.12b -> v0.12c - 26 Jul 2002 - David Gibson
  319. * o Change to C9X style designated initializers.
  320. * o Add support for 3Com AirConnect PCI.
  321. * o No longer ignore the hard_reset argument to
  322. * alloc_orinocodev(). Oops.
  323. *
  324. * v0.12c -> v0.13beta1 - 13 Sep 2002 - David Gibson
  325. * o Revert the broken 0.12* locking scheme and go to a new yet
  326. * simpler scheme.
  327. * o Do firmware resets only in orinoco_init() and when waking
  328. * the card from hard sleep.
  329. *
  330. * v0.13beta1 -> v0.13 - 27 Sep 2002 - David Gibson
  331. * o Re-introduced full resets (via schedule_task()) on Tx
  332. * timeout.
  333. *
  334. * v0.13 -> v0.13a - 30 Sep 2002 - David Gibson
  335. * o Minor cleanups to info frame handling. Add basic support
  336. * for linkstatus info frames.
  337. * o Include required kernel headers in orinoco.h, to avoid
  338. * compile problems.
  339. *
  340. * v0.13a -> v0.13b - 10 Feb 2003 - David Gibson
  341. * o Implemented hard reset for Airport cards
  342. * o Experimental suspend/resume implementation for orinoco_pci
  343. * o Abolished /proc debugging support, replaced with a debugging
  344. * iwpriv. Now it's ugly and simple instead of ugly and complex.
  345. * o Bugfix in hermes.c if the firmware returned a record length
  346. * of 0, we could go clobbering memory.
  347. * o Bugfix in orinoco_stop() - it used to fail if hw_unavailable
  348. * was set, which was usually true on PCMCIA hot removes.
  349. * o Track LINKSTATUS messages, silently drop Tx packets before
  350. * we are connected (avoids confusing the firmware), and only
  351. * give LINKSTATUS printk()s if the status has changed.
  352. *
  353. * v0.13b -> v0.13c - 11 Mar 2003 - David Gibson
  354. * o Cleanup: use dev instead of priv in various places.
  355. * o Bug fix: Don't ReleaseConfiguration on RESET_PHYSICAL event
  356. * if we're in the middle of a (driver initiated) hard reset.
  357. * o Bug fix: ETH_ZLEN is supposed to include the header
  358. * (Dionysus Blazakis & Manish Karir)
  359. * o Convert to using workqueues instead of taskqueues (and
  360. * backwards compatibility macros for pre 2.5.41 kernels).
  361. * o Drop redundant (I think...) MOD_{INC,DEC}_USE_COUNT in
  362. * airport.c
  363. * o New orinoco_tmd.c init module from Joerg Dorchain for
  364. * TMD7160 based PCI to PCMCIA bridges (similar to
  365. * orinoco_plx.c).
  366. *
  367. * v0.13c -> v0.13d - 22 Apr 2003 - David Gibson
  368. * o Make hw_unavailable a counter, rather than just a flag, this
  369. * is necessary to avoid some races (such as a card being
  370. * removed in the middle of orinoco_reset().
  371. * o Restore Release/RequestConfiguration in the PCMCIA event handler
  372. * when dealing with a driver initiated hard reset. This is
  373. * necessary to prevent hangs due to a spurious interrupt while
  374. * the reset is in progress.
  375. * o Clear the 802.11 header when transmitting, even though we
  376. * don't use it. This fixes a long standing bug on some
  377. * firmwares, which seem to get confused if that isn't done.
  378. * o Be less eager to de-encapsulate SNAP frames, only do so if
  379. * the OUI is 00:00:00 or 00:00:f8, leave others alone. The old
  380. * behaviour broke CDP (Cisco Discovery Protocol).
  381. * o Use dev instead of priv for free_irq() as well as
  382. * request_irq() (oops).
  383. * o Attempt to reset rather than giving up if we get too many
  384. * IRQs.
  385. * o Changed semantics of __orinoco_down() so it can be called
  386. * safely with hw_unavailable set. It also now clears the
  387. * linkstatus (since we're going to have to reassociate).
  388. *
  389. * v0.13d -> v0.13e - 12 May 2003 - David Gibson
  390. * o Support for post-2.5.68 return values from irq handler.
  391. * o Fixed bug where underlength packets would be double counted
  392. * in the rx_dropped statistics.
  393. * o Provided a module parameter to suppress linkstatus messages.
  394. *
  395. * v0.13e -> v0.14alpha1 - 30 Sep 2003 - David Gibson
  396. * o Replaced priv->connected logic with netif_carrier_on/off()
  397. * calls.
  398. * o Remove has_ibss_any and never set the CREATEIBSS RID when
  399. * the ESSID is empty. Too many firmwares break if we do.
  400. * o 2.6 merges: Replace pdev->slot_name with pci_name(), remove
  401. * __devinitdata from PCI ID tables, use free_netdev().
  402. * o Enabled shared-key authentication for Agere firmware (from
  403. * Robert J. Moore <Robert.J.Moore AT allanbank.com>
  404. * o Move netif_wake_queue() (back) to the Tx completion from the
  405. * ALLOC event. This seems to prevent/mitigate the rolling
  406. * error -110 problems at least on some Intersil firmwares.
  407. * Theoretically reduces performance, but I can't measure it.
  408. * Patch from Andrew Tridgell <tridge AT samba.org>
  409. *
  410. * v0.14alpha1 -> v0.14alpha2 - 20 Oct 2003 - David Gibson
  411. * o Correctly turn off shared-key authentication when requested
  412. * (bugfix from Robert J. Moore).
  413. * o Correct airport sleep interfaces for current 2.6 kernels.
  414. * o Add code for key change without disabling/enabling the MAC
  415. * port. This is supposed to allow 802.1x to work sanely, but
  416. * doesn't seem to yet.
  417. *
  418. * TODO
  419. * o New wireless extensions API (patch from Moustafa
  420. * Youssef, updated by Jim Carter and Pavel Roskin).
  421. * o Handle de-encapsulation within network layer, provide 802.11
  422. * headers (patch from Thomas 'Dent' Mirlacher)
  423. * o RF monitor mode support
  424. * o Fix possible races in SPY handling.
  425. * o Disconnect wireless extensions from fundamental configuration.
  426. * o (maybe) Software WEP support (patch from Stano Meduna).
  427. * o (maybe) Use multiple Tx buffers - driver handling queue
  428. * rather than firmware.
  429. */
  430. /* Locking and synchronization:
  431. *
  432. * The basic principle is that everything is serialized through a
  433. * single spinlock, priv->lock. The lock is used in user, bh and irq
  434. * context, so when taken outside hardirq context it should always be
  435. * taken with interrupts disabled. The lock protects both the
  436. * hardware and the struct orinoco_private.
  437. *
  438. * Another flag, priv->hw_unavailable indicates that the hardware is
  439. * unavailable for an extended period of time (e.g. suspended, or in
  440. * the middle of a hard reset). This flag is protected by the
  441. * spinlock. All code which touches the hardware should check the
  442. * flag after taking the lock, and if it is set, give up on whatever
  443. * they are doing and drop the lock again. The orinoco_lock()
  444. * function handles this (it unlocks and returns -EBUSY if
  445. * hw_unavailable is non-zero).
  446. */
  447. #define DRIVER_NAME "orinoco"
  448. #include <linux/config.h>
  449. #include <linux/module.h>
  450. #include <linux/kernel.h>
  451. #include <linux/init.h>
  452. #include <linux/ptrace.h>
  453. #include <linux/slab.h>
  454. #include <linux/string.h>
  455. #include <linux/timer.h>
  456. #include <linux/ioport.h>
  457. #include <linux/netdevice.h>
  458. #include <linux/if_arp.h>
  459. #include <linux/etherdevice.h>
  460. #include <linux/wireless.h>
  461. #include <asm/uaccess.h>
  462. #include <asm/io.h>
  463. #include <asm/system.h>
  464. #include "hermes.h"
  465. #include "hermes_rid.h"
  466. #include "orinoco.h"
  467. #include "ieee802_11.h"
  468. /********************************************************************/
  469. /* Module information */
  470. /********************************************************************/
  471. MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> & David Gibson <hermes@gibson.dropbear.id.au>");
  472. MODULE_DESCRIPTION("Driver for Lucent Orinoco, Prism II based and similar wireless cards");
  473. MODULE_LICENSE("Dual MPL/GPL");
  474. /* Level of debugging. Used in the macros in orinoco.h */
  475. #ifdef ORINOCO_DEBUG
  476. int orinoco_debug = ORINOCO_DEBUG;
  477. module_param(orinoco_debug, int, 0644);
  478. MODULE_PARM_DESC(orinoco_debug, "Debug level");
  479. EXPORT_SYMBOL(orinoco_debug);
  480. #endif
  481. static int suppress_linkstatus; /* = 0 */
  482. module_param(suppress_linkstatus, bool, 0644);
  483. MODULE_PARM_DESC(suppress_linkstatus, "Don't log link status changes");
  484. static int ignore_disconnect; /* = 0 */
  485. module_param(ignore_disconnect, int, 0644);
  486. MODULE_PARM_DESC(ignore_disconnect, "Don't report lost link to the network layer");
  487. /********************************************************************/
  488. /* Compile time configuration and compatibility stuff */
  489. /********************************************************************/
  490. /* We do this this way to avoid ifdefs in the actual code */
  491. #ifdef WIRELESS_SPY
  492. #define SPY_NUMBER(priv) (priv->spy_number)
  493. #else
  494. #define SPY_NUMBER(priv) 0
  495. #endif /* WIRELESS_SPY */
  496. /********************************************************************/
  497. /* Internal constants */
  498. /********************************************************************/
  499. #define ORINOCO_MIN_MTU 256
  500. #define ORINOCO_MAX_MTU (IEEE802_11_DATA_LEN - ENCAPS_OVERHEAD)
  501. #define SYMBOL_MAX_VER_LEN (14)
  502. #define USER_BAP 0
  503. #define IRQ_BAP 1
  504. #define MAX_IRQLOOPS_PER_IRQ 10
  505. #define MAX_IRQLOOPS_PER_JIFFY (20000/HZ) /* Based on a guestimate of
  506. * how many events the
  507. * device could
  508. * legitimately generate */
  509. #define SMALL_KEY_SIZE 5
  510. #define LARGE_KEY_SIZE 13
  511. #define TX_NICBUF_SIZE_BUG 1585 /* Bug in Symbol firmware */
  512. #define DUMMY_FID 0xFFFF
  513. /*#define MAX_MULTICAST(priv) (priv->firmware_type == FIRMWARE_TYPE_AGERE ? \
  514. HERMES_MAX_MULTICAST : 0)*/
  515. #define MAX_MULTICAST(priv) (HERMES_MAX_MULTICAST)
  516. #define ORINOCO_INTEN (HERMES_EV_RX | HERMES_EV_ALLOC \
  517. | HERMES_EV_TX | HERMES_EV_TXEXC \
  518. | HERMES_EV_WTERR | HERMES_EV_INFO \
  519. | HERMES_EV_INFDROP )
  520. /********************************************************************/
  521. /* Data tables */
  522. /********************************************************************/
  523. /* The frequency of each channel in MHz */
  524. static const long channel_frequency[] = {
  525. 2412, 2417, 2422, 2427, 2432, 2437, 2442,
  526. 2447, 2452, 2457, 2462, 2467, 2472, 2484
  527. };
  528. #define NUM_CHANNELS ARRAY_SIZE(channel_frequency)
  529. /* This tables gives the actual meanings of the bitrate IDs returned
  530. * by the firmware. */
  531. static struct {
  532. int bitrate; /* in 100s of kilobits */
  533. int automatic;
  534. u16 agere_txratectrl;
  535. u16 intersil_txratectrl;
  536. } bitrate_table[] = {
  537. {110, 1, 3, 15}, /* Entry 0 is the default */
  538. {10, 0, 1, 1},
  539. {10, 1, 1, 1},
  540. {20, 0, 2, 2},
  541. {20, 1, 6, 3},
  542. {55, 0, 4, 4},
  543. {55, 1, 7, 7},
  544. {110, 0, 5, 8},
  545. };
  546. #define BITRATE_TABLE_SIZE ARRAY_SIZE(bitrate_table)
  547. /********************************************************************/
  548. /* Data types */
  549. /********************************************************************/
  550. struct header_struct {
  551. /* 802.3 */
  552. u8 dest[ETH_ALEN];
  553. u8 src[ETH_ALEN];
  554. u16 len;
  555. /* 802.2 */
  556. u8 dsap;
  557. u8 ssap;
  558. u8 ctrl;
  559. /* SNAP */
  560. u8 oui[3];
  561. u16 ethertype;
  562. } __attribute__ ((packed));
  563. /* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
  564. u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
  565. #define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
  566. struct hermes_rx_descriptor {
  567. u16 status;
  568. u32 time;
  569. u8 silence;
  570. u8 signal;
  571. u8 rate;
  572. u8 rxflow;
  573. u32 reserved;
  574. } __attribute__ ((packed));
  575. /********************************************************************/
  576. /* Function prototypes */
  577. /********************************************************************/
  578. static int orinoco_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  579. static int __orinoco_program_rids(struct net_device *dev);
  580. static void __orinoco_set_multicast_list(struct net_device *dev);
  581. /********************************************************************/
  582. /* Internal helper functions */
  583. /********************************************************************/
  584. static inline void set_port_type(struct orinoco_private *priv)
  585. {
  586. switch (priv->iw_mode) {
  587. case IW_MODE_INFRA:
  588. priv->port_type = 1;
  589. priv->createibss = 0;
  590. break;
  591. case IW_MODE_ADHOC:
  592. if (priv->prefer_port3) {
  593. priv->port_type = 3;
  594. priv->createibss = 0;
  595. } else {
  596. priv->port_type = priv->ibss_port;
  597. priv->createibss = 1;
  598. }
  599. break;
  600. default:
  601. printk(KERN_ERR "%s: Invalid priv->iw_mode in set_port_type()\n",
  602. priv->ndev->name);
  603. }
  604. }
  605. /********************************************************************/
  606. /* Device methods */
  607. /********************************************************************/
  608. static int orinoco_open(struct net_device *dev)
  609. {
  610. struct orinoco_private *priv = netdev_priv(dev);
  611. unsigned long flags;
  612. int err;
  613. if (orinoco_lock(priv, &flags) != 0)
  614. return -EBUSY;
  615. err = __orinoco_up(dev);
  616. if (! err)
  617. priv->open = 1;
  618. orinoco_unlock(priv, &flags);
  619. return err;
  620. }
  621. int orinoco_stop(struct net_device *dev)
  622. {
  623. struct orinoco_private *priv = netdev_priv(dev);
  624. int err = 0;
  625. /* We mustn't use orinoco_lock() here, because we need to be
  626. able to close the interface even if hw_unavailable is set
  627. (e.g. as we're released after a PC Card removal) */
  628. spin_lock_irq(&priv->lock);
  629. priv->open = 0;
  630. err = __orinoco_down(dev);
  631. spin_unlock_irq(&priv->lock);
  632. return err;
  633. }
  634. static struct net_device_stats *orinoco_get_stats(struct net_device *dev)
  635. {
  636. struct orinoco_private *priv = netdev_priv(dev);
  637. return &priv->stats;
  638. }
  639. static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
  640. {
  641. struct orinoco_private *priv = netdev_priv(dev);
  642. hermes_t *hw = &priv->hw;
  643. struct iw_statistics *wstats = &priv->wstats;
  644. int err;
  645. unsigned long flags;
  646. if (! netif_device_present(dev)) {
  647. printk(KERN_WARNING "%s: get_wireless_stats() called while device not present\n",
  648. dev->name);
  649. return NULL; /* FIXME: Can we do better than this? */
  650. }
  651. /* If busy, return the old stats. Returning NULL may cause
  652. * the interface to disappear from /proc/net/wireless */
  653. if (orinoco_lock(priv, &flags) != 0)
  654. return wstats;
  655. /* We can't really wait for the tallies inquiry command to
  656. * complete, so we just use the previous results and trigger
  657. * a new tallies inquiry command for next time - Jean II */
  658. /* FIXME: Really we should wait for the inquiry to come back -
  659. * as it is the stats we give don't make a whole lot of sense.
  660. * Unfortunately, it's not clear how to do that within the
  661. * wireless extensions framework: I think we're in user
  662. * context, but a lock seems to be held by the time we get in
  663. * here so we're not safe to sleep here. */
  664. hermes_inquire(hw, HERMES_INQ_TALLIES);
  665. if (priv->iw_mode == IW_MODE_ADHOC) {
  666. memset(&wstats->qual, 0, sizeof(wstats->qual));
  667. /* If a spy address is defined, we report stats of the
  668. * first spy address - Jean II */
  669. if (SPY_NUMBER(priv)) {
  670. wstats->qual.qual = priv->spy_stat[0].qual;
  671. wstats->qual.level = priv->spy_stat[0].level;
  672. wstats->qual.noise = priv->spy_stat[0].noise;
  673. wstats->qual.updated = priv->spy_stat[0].updated;
  674. }
  675. } else {
  676. struct {
  677. u16 qual, signal, noise;
  678. } __attribute__ ((packed)) cq;
  679. err = HERMES_READ_RECORD(hw, USER_BAP,
  680. HERMES_RID_COMMSQUALITY, &cq);
  681. if (!err) {
  682. wstats->qual.qual = (int)le16_to_cpu(cq.qual);
  683. wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95;
  684. wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95;
  685. wstats->qual.updated = 7;
  686. }
  687. }
  688. orinoco_unlock(priv, &flags);
  689. return wstats;
  690. }
  691. static void orinoco_set_multicast_list(struct net_device *dev)
  692. {
  693. struct orinoco_private *priv = netdev_priv(dev);
  694. unsigned long flags;
  695. if (orinoco_lock(priv, &flags) != 0) {
  696. printk(KERN_DEBUG "%s: orinoco_set_multicast_list() "
  697. "called when hw_unavailable\n", dev->name);
  698. return;
  699. }
  700. __orinoco_set_multicast_list(dev);
  701. orinoco_unlock(priv, &flags);
  702. }
  703. static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
  704. {
  705. struct orinoco_private *priv = netdev_priv(dev);
  706. if ( (new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU) )
  707. return -EINVAL;
  708. if ( (new_mtu + ENCAPS_OVERHEAD + IEEE802_11_HLEN) >
  709. (priv->nicbuf_size - ETH_HLEN) )
  710. return -EINVAL;
  711. dev->mtu = new_mtu;
  712. return 0;
  713. }
  714. /********************************************************************/
  715. /* Tx path */
  716. /********************************************************************/
  717. static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
  718. {
  719. struct orinoco_private *priv = netdev_priv(dev);
  720. struct net_device_stats *stats = &priv->stats;
  721. hermes_t *hw = &priv->hw;
  722. int err = 0;
  723. u16 txfid = priv->txfid;
  724. char *p;
  725. struct ethhdr *eh;
  726. int len, data_len, data_off;
  727. struct hermes_tx_descriptor desc;
  728. unsigned long flags;
  729. TRACE_ENTER(dev->name);
  730. if (! netif_running(dev)) {
  731. printk(KERN_ERR "%s: Tx on stopped device!\n",
  732. dev->name);
  733. TRACE_EXIT(dev->name);
  734. return 1;
  735. }
  736. if (netif_queue_stopped(dev)) {
  737. printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
  738. dev->name);
  739. TRACE_EXIT(dev->name);
  740. return 1;
  741. }
  742. if (orinoco_lock(priv, &flags) != 0) {
  743. printk(KERN_ERR "%s: orinoco_xmit() called while hw_unavailable\n",
  744. dev->name);
  745. TRACE_EXIT(dev->name);
  746. return 1;
  747. }
  748. if (! netif_carrier_ok(dev)) {
  749. /* Oops, the firmware hasn't established a connection,
  750. silently drop the packet (this seems to be the
  751. safest approach). */
  752. stats->tx_errors++;
  753. orinoco_unlock(priv, &flags);
  754. dev_kfree_skb(skb);
  755. TRACE_EXIT(dev->name);
  756. return 0;
  757. }
  758. /* Length of the packet body */
  759. /* FIXME: what if the skb is smaller than this? */
  760. len = max_t(int,skb->len - ETH_HLEN, ETH_ZLEN - ETH_HLEN);
  761. eh = (struct ethhdr *)skb->data;
  762. memset(&desc, 0, sizeof(desc));
  763. desc.tx_control = cpu_to_le16(HERMES_TXCTRL_TX_OK | HERMES_TXCTRL_TX_EX);
  764. err = hermes_bap_pwrite(hw, USER_BAP, &desc, sizeof(desc), txfid, 0);
  765. if (err) {
  766. if (net_ratelimit())
  767. printk(KERN_ERR "%s: Error %d writing Tx descriptor "
  768. "to BAP\n", dev->name, err);
  769. stats->tx_errors++;
  770. goto fail;
  771. }
  772. /* Clear the 802.11 header and data length fields - some
  773. * firmwares (e.g. Lucent/Agere 8.xx) appear to get confused
  774. * if this isn't done. */
  775. hermes_clear_words(hw, HERMES_DATA0,
  776. HERMES_802_3_OFFSET - HERMES_802_11_OFFSET);
  777. /* Encapsulate Ethernet-II frames */
  778. if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */
  779. struct header_struct hdr;
  780. data_len = len;
  781. data_off = HERMES_802_3_OFFSET + sizeof(hdr);
  782. p = skb->data + ETH_HLEN;
  783. /* 802.3 header */
  784. memcpy(hdr.dest, eh->h_dest, ETH_ALEN);
  785. memcpy(hdr.src, eh->h_source, ETH_ALEN);
  786. hdr.len = htons(data_len + ENCAPS_OVERHEAD);
  787. /* 802.2 header */
  788. memcpy(&hdr.dsap, &encaps_hdr, sizeof(encaps_hdr));
  789. hdr.ethertype = eh->h_proto;
  790. err = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr),
  791. txfid, HERMES_802_3_OFFSET);
  792. if (err) {
  793. if (net_ratelimit())
  794. printk(KERN_ERR "%s: Error %d writing packet "
  795. "header to BAP\n", dev->name, err);
  796. stats->tx_errors++;
  797. goto fail;
  798. }
  799. } else { /* IEEE 802.3 frame */
  800. data_len = len + ETH_HLEN;
  801. data_off = HERMES_802_3_OFFSET;
  802. p = skb->data;
  803. }
  804. /* Round up for odd length packets */
  805. err = hermes_bap_pwrite(hw, USER_BAP, p, ALIGN(data_len, 2),
  806. txfid, data_off);
  807. if (err) {
  808. printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
  809. dev->name, err);
  810. stats->tx_errors++;
  811. goto fail;
  812. }
  813. /* Finally, we actually initiate the send */
  814. netif_stop_queue(dev);
  815. err = hermes_docmd_wait(hw, HERMES_CMD_TX | HERMES_CMD_RECL,
  816. txfid, NULL);
  817. if (err) {
  818. netif_start_queue(dev);
  819. printk(KERN_ERR "%s: Error %d transmitting packet\n",
  820. dev->name, err);
  821. stats->tx_errors++;
  822. goto fail;
  823. }
  824. dev->trans_start = jiffies;
  825. stats->tx_bytes += data_off + data_len;
  826. orinoco_unlock(priv, &flags);
  827. dev_kfree_skb(skb);
  828. TRACE_EXIT(dev->name);
  829. return 0;
  830. fail:
  831. TRACE_EXIT(dev->name);
  832. orinoco_unlock(priv, &flags);
  833. return err;
  834. }
  835. static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)
  836. {
  837. struct orinoco_private *priv = netdev_priv(dev);
  838. u16 fid = hermes_read_regn(hw, ALLOCFID);
  839. if (fid != priv->txfid) {
  840. if (fid != DUMMY_FID)
  841. printk(KERN_WARNING "%s: Allocate event on unexpected fid (%04X)\n",
  842. dev->name, fid);
  843. return;
  844. }
  845. hermes_write_regn(hw, ALLOCFID, DUMMY_FID);
  846. }
  847. static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw)
  848. {
  849. struct orinoco_private *priv = netdev_priv(dev);
  850. struct net_device_stats *stats = &priv->stats;
  851. stats->tx_packets++;
  852. netif_wake_queue(dev);
  853. hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
  854. }
  855. static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
  856. {
  857. struct orinoco_private *priv = netdev_priv(dev);
  858. struct net_device_stats *stats = &priv->stats;
  859. u16 fid = hermes_read_regn(hw, TXCOMPLFID);
  860. struct hermes_tx_descriptor desc;
  861. int err = 0;
  862. if (fid == DUMMY_FID)
  863. return; /* Nothing's really happened */
  864. err = hermes_bap_pread(hw, IRQ_BAP, &desc, sizeof(desc), fid, 0);
  865. if (err) {
  866. printk(KERN_WARNING "%s: Unable to read descriptor on Tx error "
  867. "(FID=%04X error %d)\n",
  868. dev->name, fid, err);
  869. } else {
  870. DEBUG(1, "%s: Tx error, status %d\n",
  871. dev->name, le16_to_cpu(desc.status));
  872. }
  873. stats->tx_errors++;
  874. netif_wake_queue(dev);
  875. hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
  876. }
  877. static void orinoco_tx_timeout(struct net_device *dev)
  878. {
  879. struct orinoco_private *priv = netdev_priv(dev);
  880. struct net_device_stats *stats = &priv->stats;
  881. struct hermes *hw = &priv->hw;
  882. printk(KERN_WARNING "%s: Tx timeout! "
  883. "ALLOCFID=%04x, TXCOMPLFID=%04x, EVSTAT=%04x\n",
  884. dev->name, hermes_read_regn(hw, ALLOCFID),
  885. hermes_read_regn(hw, TXCOMPLFID), hermes_read_regn(hw, EVSTAT));
  886. stats->tx_errors++;
  887. schedule_work(&priv->reset_work);
  888. }
  889. /********************************************************************/
  890. /* Rx path (data frames) */
  891. /********************************************************************/
  892. /* Does the frame have a SNAP header indicating it should be
  893. * de-encapsulated to Ethernet-II? */
  894. static inline int is_ethersnap(void *_hdr)
  895. {
  896. u8 *hdr = _hdr;
  897. /* We de-encapsulate all packets which, a) have SNAP headers
  898. * (i.e. SSAP=DSAP=0xaa and CTRL=0x3 in the 802.2 LLC header
  899. * and where b) the OUI of the SNAP header is 00:00:00 or
  900. * 00:00:f8 - we need both because different APs appear to use
  901. * different OUIs for some reason */
  902. return (memcmp(hdr, &encaps_hdr, 5) == 0)
  903. && ( (hdr[5] == 0x00) || (hdr[5] == 0xf8) );
  904. }
  905. static inline void orinoco_spy_gather(struct net_device *dev, u_char *mac,
  906. int level, int noise)
  907. {
  908. struct orinoco_private *priv = netdev_priv(dev);
  909. int i;
  910. /* Gather wireless spy statistics: for each packet, compare the
  911. * source address with out list, and if match, get the stats... */
  912. for (i = 0; i < priv->spy_number; i++)
  913. if (!memcmp(mac, priv->spy_address[i], ETH_ALEN)) {
  914. priv->spy_stat[i].level = level - 0x95;
  915. priv->spy_stat[i].noise = noise - 0x95;
  916. priv->spy_stat[i].qual = (level > noise) ? (level - noise) : 0;
  917. priv->spy_stat[i].updated = 7;
  918. }
  919. }
  920. static void orinoco_stat_gather(struct net_device *dev,
  921. struct sk_buff *skb,
  922. struct hermes_rx_descriptor *desc)
  923. {
  924. struct orinoco_private *priv = netdev_priv(dev);
  925. /* Using spy support with lots of Rx packets, like in an
  926. * infrastructure (AP), will really slow down everything, because
  927. * the MAC address must be compared to each entry of the spy list.
  928. * If the user really asks for it (set some address in the
  929. * spy list), we do it, but he will pay the price.
  930. * Note that to get here, you need both WIRELESS_SPY
  931. * compiled in AND some addresses in the list !!!
  932. */
  933. /* Note : gcc will optimise the whole section away if
  934. * WIRELESS_SPY is not defined... - Jean II */
  935. if (SPY_NUMBER(priv)) {
  936. orinoco_spy_gather(dev, skb->mac.raw + ETH_ALEN,
  937. desc->signal, desc->silence);
  938. }
  939. }
  940. static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
  941. {
  942. struct orinoco_private *priv = netdev_priv(dev);
  943. struct net_device_stats *stats = &priv->stats;
  944. struct iw_statistics *wstats = &priv->wstats;
  945. struct sk_buff *skb = NULL;
  946. u16 rxfid, status;
  947. int length, data_len, data_off;
  948. char *p;
  949. struct hermes_rx_descriptor desc;
  950. struct header_struct hdr;
  951. struct ethhdr *eh;
  952. int err;
  953. rxfid = hermes_read_regn(hw, RXFID);
  954. err = hermes_bap_pread(hw, IRQ_BAP, &desc, sizeof(desc),
  955. rxfid, 0);
  956. if (err) {
  957. printk(KERN_ERR "%s: error %d reading Rx descriptor. "
  958. "Frame dropped.\n", dev->name, err);
  959. stats->rx_errors++;
  960. goto drop;
  961. }
  962. status = le16_to_cpu(desc.status);
  963. if (status & HERMES_RXSTAT_ERR) {
  964. if (status & HERMES_RXSTAT_UNDECRYPTABLE) {
  965. wstats->discard.code++;
  966. DEBUG(1, "%s: Undecryptable frame on Rx. Frame dropped.\n",
  967. dev->name);
  968. } else {
  969. stats->rx_crc_errors++;
  970. DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n", dev->name);
  971. }
  972. stats->rx_errors++;
  973. goto drop;
  974. }
  975. /* For now we ignore the 802.11 header completely, assuming
  976. that the card's firmware has handled anything vital */
  977. err = hermes_bap_pread(hw, IRQ_BAP, &hdr, sizeof(hdr),
  978. rxfid, HERMES_802_3_OFFSET);
  979. if (err) {
  980. printk(KERN_ERR "%s: error %d reading frame header. "
  981. "Frame dropped.\n", dev->name, err);
  982. stats->rx_errors++;
  983. goto drop;
  984. }
  985. length = ntohs(hdr.len);
  986. /* Sanity checks */
  987. if (length < 3) { /* No for even an 802.2 LLC header */
  988. /* At least on Symbol firmware with PCF we get quite a
  989. lot of these legitimately - Poll frames with no
  990. data. */
  991. stats->rx_dropped++;
  992. goto drop;
  993. }
  994. if (length > IEEE802_11_DATA_LEN) {
  995. printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n",
  996. dev->name, length);
  997. stats->rx_length_errors++;
  998. stats->rx_errors++;
  999. goto drop;
  1000. }
  1001. /* We need space for the packet data itself, plus an ethernet
  1002. header, plus 2 bytes so we can align the IP header on a
  1003. 32bit boundary, plus 1 byte so we can read in odd length
  1004. packets from the card, which has an IO granularity of 16
  1005. bits */
  1006. skb = dev_alloc_skb(length+ETH_HLEN+2+1);
  1007. if (!skb) {
  1008. printk(KERN_WARNING "%s: Can't allocate skb for Rx\n",
  1009. dev->name);
  1010. goto drop;
  1011. }
  1012. skb_reserve(skb, 2); /* This way the IP header is aligned */
  1013. /* Handle decapsulation
  1014. * In most cases, the firmware tell us about SNAP frames.
  1015. * For some reason, the SNAP frames sent by LinkSys APs
  1016. * are not properly recognised by most firmwares.
  1017. * So, check ourselves */
  1018. if (((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_1042) ||
  1019. ((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_TUNNEL) ||
  1020. is_ethersnap(&hdr)) {
  1021. /* These indicate a SNAP within 802.2 LLC within
  1022. 802.11 frame which we'll need to de-encapsulate to
  1023. the original EthernetII frame. */
  1024. if (length < ENCAPS_OVERHEAD) { /* No room for full LLC+SNAP */
  1025. stats->rx_length_errors++;
  1026. goto drop;
  1027. }
  1028. /* Remove SNAP header, reconstruct EthernetII frame */
  1029. data_len = length - ENCAPS_OVERHEAD;
  1030. data_off = HERMES_802_3_OFFSET + sizeof(hdr);
  1031. eh = (struct ethhdr *)skb_put(skb, ETH_HLEN);
  1032. memcpy(eh, &hdr, 2 * ETH_ALEN);
  1033. eh->h_proto = hdr.ethertype;
  1034. } else {
  1035. /* All other cases indicate a genuine 802.3 frame. No
  1036. decapsulation needed. We just throw the whole
  1037. thing in, and hope the protocol layer can deal with
  1038. it as 802.3 */
  1039. data_len = length;
  1040. data_off = HERMES_802_3_OFFSET;
  1041. /* FIXME: we re-read from the card data we already read here */
  1042. }
  1043. p = skb_put(skb, data_len);
  1044. err = hermes_bap_pread(hw, IRQ_BAP, p, ALIGN(data_len, 2),
  1045. rxfid, data_off);
  1046. if (err) {
  1047. printk(KERN_ERR "%s: error %d reading frame. "
  1048. "Frame dropped.\n", dev->name, err);
  1049. stats->rx_errors++;
  1050. goto drop;
  1051. }
  1052. dev->last_rx = jiffies;
  1053. skb->dev = dev;
  1054. skb->protocol = eth_type_trans(skb, dev);
  1055. skb->ip_summed = CHECKSUM_NONE;
  1056. /* Process the wireless stats if needed */
  1057. orinoco_stat_gather(dev, skb, &desc);
  1058. /* Pass the packet to the networking stack */
  1059. netif_rx(skb);
  1060. stats->rx_packets++;
  1061. stats->rx_bytes += length;
  1062. return;
  1063. drop:
  1064. stats->rx_dropped++;
  1065. if (skb)
  1066. dev_kfree_skb_irq(skb);
  1067. return;
  1068. }
  1069. /********************************************************************/
  1070. /* Rx path (info frames) */
  1071. /********************************************************************/
  1072. static void print_linkstatus(struct net_device *dev, u16 status)
  1073. {
  1074. char * s;
  1075. if (suppress_linkstatus)
  1076. return;
  1077. switch (status) {
  1078. case HERMES_LINKSTATUS_NOT_CONNECTED:
  1079. s = "Not Connected";
  1080. break;
  1081. case HERMES_LINKSTATUS_CONNECTED:
  1082. s = "Connected";
  1083. break;
  1084. case HERMES_LINKSTATUS_DISCONNECTED:
  1085. s = "Disconnected";
  1086. break;
  1087. case HERMES_LINKSTATUS_AP_CHANGE:
  1088. s = "AP Changed";
  1089. break;
  1090. case HERMES_LINKSTATUS_AP_OUT_OF_RANGE:
  1091. s = "AP Out of Range";
  1092. break;
  1093. case HERMES_LINKSTATUS_AP_IN_RANGE:
  1094. s = "AP In Range";
  1095. break;
  1096. case HERMES_LINKSTATUS_ASSOC_FAILED:
  1097. s = "Association Failed";
  1098. break;
  1099. default:
  1100. s = "UNKNOWN";
  1101. }
  1102. printk(KERN_INFO "%s: New link status: %s (%04x)\n",
  1103. dev->name, s, status);
  1104. }
  1105. static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
  1106. {
  1107. struct orinoco_private *priv = netdev_priv(dev);
  1108. u16 infofid;
  1109. struct {
  1110. u16 len;
  1111. u16 type;
  1112. } __attribute__ ((packed)) info;
  1113. int len, type;
  1114. int err;
  1115. /* This is an answer to an INQUIRE command that we did earlier,
  1116. * or an information "event" generated by the card
  1117. * The controller return to us a pseudo frame containing
  1118. * the information in question - Jean II */
  1119. infofid = hermes_read_regn(hw, INFOFID);
  1120. /* Read the info frame header - don't try too hard */
  1121. err = hermes_bap_pread(hw, IRQ_BAP, &info, sizeof(info),
  1122. infofid, 0);
  1123. if (err) {
  1124. printk(KERN_ERR "%s: error %d reading info frame. "
  1125. "Frame dropped.\n", dev->name, err);
  1126. return;
  1127. }
  1128. len = HERMES_RECLEN_TO_BYTES(le16_to_cpu(info.len));
  1129. type = le16_to_cpu(info.type);
  1130. switch (type) {
  1131. case HERMES_INQ_TALLIES: {
  1132. struct hermes_tallies_frame tallies;
  1133. struct iw_statistics *wstats = &priv->wstats;
  1134. if (len > sizeof(tallies)) {
  1135. printk(KERN_WARNING "%s: Tallies frame too long (%d bytes)\n",
  1136. dev->name, len);
  1137. len = sizeof(tallies);
  1138. }
  1139. /* Read directly the data (no seek) */
  1140. hermes_read_words(hw, HERMES_DATA1, (void *) &tallies,
  1141. len / 2); /* FIXME: blech! */
  1142. /* Increment our various counters */
  1143. /* wstats->discard.nwid - no wrong BSSID stuff */
  1144. wstats->discard.code +=
  1145. le16_to_cpu(tallies.RxWEPUndecryptable);
  1146. if (len == sizeof(tallies))
  1147. wstats->discard.code +=
  1148. le16_to_cpu(tallies.RxDiscards_WEPICVError) +
  1149. le16_to_cpu(tallies.RxDiscards_WEPExcluded);
  1150. wstats->discard.misc +=
  1151. le16_to_cpu(tallies.TxDiscardsWrongSA);
  1152. wstats->discard.fragment +=
  1153. le16_to_cpu(tallies.RxMsgInBadMsgFragments);
  1154. wstats->discard.retries +=
  1155. le16_to_cpu(tallies.TxRetryLimitExceeded);
  1156. /* wstats->miss.beacon - no match */
  1157. }
  1158. break;
  1159. case HERMES_INQ_LINKSTATUS: {
  1160. struct hermes_linkstatus linkstatus;
  1161. u16 newstatus;
  1162. int connected;
  1163. if (len != sizeof(linkstatus)) {
  1164. printk(KERN_WARNING "%s: Unexpected size for linkstatus frame (%d bytes)\n",
  1165. dev->name, len);
  1166. break;
  1167. }
  1168. hermes_read_words(hw, HERMES_DATA1, (void *) &linkstatus,
  1169. len / 2);
  1170. newstatus = le16_to_cpu(linkstatus.linkstatus);
  1171. connected = (newstatus == HERMES_LINKSTATUS_CONNECTED)
  1172. || (newstatus == HERMES_LINKSTATUS_AP_CHANGE)
  1173. || (newstatus == HERMES_LINKSTATUS_AP_IN_RANGE);
  1174. if (connected)
  1175. netif_carrier_on(dev);
  1176. else if (!ignore_disconnect)
  1177. netif_carrier_off(dev);
  1178. if (newstatus != priv->last_linkstatus)
  1179. print_linkstatus(dev, newstatus);
  1180. priv->last_linkstatus = newstatus;
  1181. }
  1182. break;
  1183. default:
  1184. printk(KERN_DEBUG "%s: Unknown information frame received: "
  1185. "type 0x%04x, length %d\n", dev->name, type, len);
  1186. /* We don't actually do anything about it */
  1187. break;
  1188. }
  1189. }
  1190. static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw)
  1191. {
  1192. if (net_ratelimit())
  1193. printk(KERN_DEBUG "%s: Information frame lost.\n", dev->name);
  1194. }
  1195. /********************************************************************/
  1196. /* Internal hardware control routines */
  1197. /********************************************************************/
  1198. int __orinoco_up(struct net_device *dev)
  1199. {
  1200. struct orinoco_private *priv = netdev_priv(dev);
  1201. struct hermes *hw = &priv->hw;
  1202. int err;
  1203. err = __orinoco_program_rids(dev);
  1204. if (err) {
  1205. printk(KERN_ERR "%s: Error %d configuring card\n",
  1206. dev->name, err);
  1207. return err;
  1208. }
  1209. /* Fire things up again */
  1210. hermes_set_irqmask(hw, ORINOCO_INTEN);
  1211. err = hermes_enable_port(hw, 0);
  1212. if (err) {
  1213. printk(KERN_ERR "%s: Error %d enabling MAC port\n",
  1214. dev->name, err);
  1215. return err;
  1216. }
  1217. netif_start_queue(dev);
  1218. return 0;
  1219. }
  1220. int __orinoco_down(struct net_device *dev)
  1221. {
  1222. struct orinoco_private *priv = netdev_priv(dev);
  1223. struct hermes *hw = &priv->hw;
  1224. int err;
  1225. netif_stop_queue(dev);
  1226. if (! priv->hw_unavailable) {
  1227. if (! priv->broken_disableport) {
  1228. err = hermes_disable_port(hw, 0);
  1229. if (err) {
  1230. /* Some firmwares (e.g. Intersil 1.3.x) seem
  1231. * to have problems disabling the port, oh
  1232. * well, too bad. */
  1233. printk(KERN_WARNING "%s: Error %d disabling MAC port\n",
  1234. dev->name, err);
  1235. priv->broken_disableport = 1;
  1236. }
  1237. }
  1238. hermes_set_irqmask(hw, 0);
  1239. hermes_write_regn(hw, EVACK, 0xffff);
  1240. }
  1241. /* firmware will have to reassociate */
  1242. netif_carrier_off(dev);
  1243. priv->last_linkstatus = 0xffff;
  1244. return 0;
  1245. }
  1246. int orinoco_reinit_firmware(struct net_device *dev)
  1247. {
  1248. struct orinoco_private *priv = netdev_priv(dev);
  1249. struct hermes *hw = &priv->hw;
  1250. int err;
  1251. err = hermes_init(hw);
  1252. if (err)
  1253. return err;
  1254. err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid);
  1255. if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) {
  1256. /* Try workaround for old Symbol firmware bug */
  1257. printk(KERN_WARNING "%s: firmware ALLOC bug detected "
  1258. "(old Symbol firmware?). Trying to work around... ",
  1259. dev->name);
  1260. priv->nicbuf_size = TX_NICBUF_SIZE_BUG;
  1261. err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid);
  1262. if (err)
  1263. printk("failed!\n");
  1264. else
  1265. printk("ok.\n");
  1266. }
  1267. return err;
  1268. }
  1269. static int __orinoco_hw_set_bitrate(struct orinoco_private *priv)
  1270. {
  1271. hermes_t *hw = &priv->hw;
  1272. int err = 0;
  1273. if (priv->bitratemode >= BITRATE_TABLE_SIZE) {
  1274. printk(KERN_ERR "%s: BUG: Invalid bitrate mode %d\n",
  1275. priv->ndev->name, priv->bitratemode);
  1276. return -EINVAL;
  1277. }
  1278. switch (priv->firmware_type) {
  1279. case FIRMWARE_TYPE_AGERE:
  1280. err = hermes_write_wordrec(hw, USER_BAP,
  1281. HERMES_RID_CNFTXRATECONTROL,
  1282. bitrate_table[priv->bitratemode].agere_txratectrl);
  1283. break;
  1284. case FIRMWARE_TYPE_INTERSIL:
  1285. case FIRMWARE_TYPE_SYMBOL:
  1286. err = hermes_write_wordrec(hw, USER_BAP,
  1287. HERMES_RID_CNFTXRATECONTROL,
  1288. bitrate_table[priv->bitratemode].intersil_txratectrl);
  1289. break;
  1290. default:
  1291. BUG();
  1292. }
  1293. return err;
  1294. }
  1295. /* Change the WEP keys and/or the current keys. Can be called
  1296. * either from __orinoco_hw_setup_wep() or directly from
  1297. * orinoco_ioctl_setiwencode(). In the later case the association
  1298. * with the AP is not broken (if the firmware can handle it),
  1299. * which is needed for 802.1x implementations. */
  1300. static int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv)
  1301. {
  1302. hermes_t *hw = &priv->hw;
  1303. int err = 0;
  1304. switch (priv->firmware_type) {
  1305. case FIRMWARE_TYPE_AGERE:
  1306. err = HERMES_WRITE_RECORD(hw, USER_BAP,
  1307. HERMES_RID_CNFWEPKEYS_AGERE,
  1308. &priv->keys);
  1309. if (err)
  1310. return err;
  1311. err = hermes_write_wordrec(hw, USER_BAP,
  1312. HERMES_RID_CNFTXKEY_AGERE,
  1313. priv->tx_key);
  1314. if (err)
  1315. return err;
  1316. break;
  1317. case FIRMWARE_TYPE_INTERSIL:
  1318. case FIRMWARE_TYPE_SYMBOL:
  1319. {
  1320. int keylen;
  1321. int i;
  1322. /* Force uniform key length to work around firmware bugs */
  1323. keylen = le16_to_cpu(priv->keys[priv->tx_key].len);
  1324. if (keylen > LARGE_KEY_SIZE) {
  1325. printk(KERN_ERR "%s: BUG: Key %d has oversize length %d.\n",
  1326. priv->ndev->name, priv->tx_key, keylen);
  1327. return -E2BIG;
  1328. }
  1329. /* Write all 4 keys */
  1330. for(i = 0; i < ORINOCO_MAX_KEYS; i++) {
  1331. err = hermes_write_ltv(hw, USER_BAP,
  1332. HERMES_RID_CNFDEFAULTKEY0 + i,
  1333. HERMES_BYTES_TO_RECLEN(keylen),
  1334. priv->keys[i].data);
  1335. if (err)
  1336. return err;
  1337. }
  1338. /* Write the index of the key used in transmission */
  1339. err = hermes_write_wordrec(hw, USER_BAP,
  1340. HERMES_RID_CNFWEPDEFAULTKEYID,
  1341. priv->tx_key);
  1342. if (err)
  1343. return err;
  1344. }
  1345. break;
  1346. }
  1347. return 0;
  1348. }
  1349. static int __orinoco_hw_setup_wep(struct orinoco_private *priv)
  1350. {
  1351. hermes_t *hw = &priv->hw;
  1352. int err = 0;
  1353. int master_wep_flag;
  1354. int auth_flag;
  1355. if (priv->wep_on)
  1356. __orinoco_hw_setup_wepkeys(priv);
  1357. if (priv->wep_restrict)
  1358. auth_flag = HERMES_AUTH_SHARED_KEY;
  1359. else
  1360. auth_flag = HERMES_AUTH_OPEN;
  1361. switch (priv->firmware_type) {
  1362. case FIRMWARE_TYPE_AGERE: /* Agere style WEP */
  1363. if (priv->wep_on) {
  1364. /* Enable the shared-key authentication. */
  1365. err = hermes_write_wordrec(hw, USER_BAP,
  1366. HERMES_RID_CNFAUTHENTICATION_AGERE,
  1367. auth_flag);
  1368. }
  1369. err = hermes_write_wordrec(hw, USER_BAP,
  1370. HERMES_RID_CNFWEPENABLED_AGERE,
  1371. priv->wep_on);
  1372. if (err)
  1373. return err;
  1374. break;
  1375. case FIRMWARE_TYPE_INTERSIL: /* Intersil style WEP */
  1376. case FIRMWARE_TYPE_SYMBOL: /* Symbol style WEP */
  1377. if (priv->wep_on) {
  1378. if (priv->wep_restrict ||
  1379. (priv->firmware_type == FIRMWARE_TYPE_SYMBOL))
  1380. master_wep_flag = HERMES_WEP_PRIVACY_INVOKED |
  1381. HERMES_WEP_EXCL_UNENCRYPTED;
  1382. else
  1383. master_wep_flag = HERMES_WEP_PRIVACY_INVOKED;
  1384. err = hermes_write_wordrec(hw, USER_BAP,
  1385. HERMES_RID_CNFAUTHENTICATION,
  1386. auth_flag);
  1387. if (err)
  1388. return err;
  1389. } else
  1390. master_wep_flag = 0;
  1391. if (priv->iw_mode == IW_MODE_MONITOR)
  1392. master_wep_flag |= HERMES_WEP_HOST_DECRYPT;
  1393. /* Master WEP setting : on/off */
  1394. err = hermes_write_wordrec(hw, USER_BAP,
  1395. HERMES_RID_CNFWEPFLAGS_INTERSIL,
  1396. master_wep_flag);
  1397. if (err)
  1398. return err;
  1399. break;
  1400. }
  1401. return 0;
  1402. }
  1403. static int __orinoco_program_rids(struct net_device *dev)
  1404. {
  1405. struct orinoco_private *priv = netdev_priv(dev);
  1406. hermes_t *hw = &priv->hw;
  1407. int err;
  1408. struct hermes_idstring idbuf;
  1409. /* Set the MAC address */
  1410. err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
  1411. HERMES_BYTES_TO_RECLEN(ETH_ALEN), dev->dev_addr);
  1412. if (err) {
  1413. printk(KERN_ERR "%s: Error %d setting MAC address\n",
  1414. dev->name, err);
  1415. return err;
  1416. }
  1417. /* Set up the link mode */
  1418. err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFPORTTYPE,
  1419. priv->port_type);
  1420. if (err) {
  1421. printk(KERN_ERR "%s: Error %d setting port type\n",
  1422. dev->name, err);
  1423. return err;
  1424. }
  1425. /* Set the channel/frequency */
  1426. if (priv->channel != 0 && priv->iw_mode != IW_MODE_INFRA) {
  1427. err = hermes_write_wordrec(hw, USER_BAP,
  1428. HERMES_RID_CNFOWNCHANNEL,
  1429. priv->channel);
  1430. if (err) {
  1431. printk(KERN_ERR "%s: Error %d setting channel %d\n",
  1432. dev->name, err, priv->channel);
  1433. return err;
  1434. }
  1435. }
  1436. if (priv->has_ibss) {
  1437. u16 createibss;
  1438. if ((strlen(priv->desired_essid) == 0) && (priv->createibss)) {
  1439. printk(KERN_WARNING "%s: This firmware requires an "
  1440. "ESSID in IBSS-Ad-Hoc mode.\n", dev->name);
  1441. /* With wvlan_cs, in this case, we would crash.
  1442. * hopefully, this driver will behave better...
  1443. * Jean II */
  1444. createibss = 0;
  1445. } else {
  1446. createibss = priv->createibss;
  1447. }
  1448. err = hermes_write_wordrec(hw, USER_BAP,
  1449. HERMES_RID_CNFCREATEIBSS,
  1450. createibss);
  1451. if (err) {
  1452. printk(KERN_ERR "%s: Error %d setting CREATEIBSS\n",
  1453. dev->name, err);
  1454. return err;
  1455. }
  1456. }
  1457. /* Set the desired ESSID */
  1458. idbuf.len = cpu_to_le16(strlen(priv->desired_essid));
  1459. memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val));
  1460. /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */
  1461. err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID,
  1462. HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2),
  1463. &idbuf);
  1464. if (err) {
  1465. printk(KERN_ERR "%s: Error %d setting OWNSSID\n",
  1466. dev->name, err);
  1467. return err;
  1468. }
  1469. err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID,
  1470. HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2),
  1471. &idbuf);
  1472. if (err) {
  1473. printk(KERN_ERR "%s: Error %d setting DESIREDSSID\n",
  1474. dev->name, err);
  1475. return err;
  1476. }
  1477. /* Set the station name */
  1478. idbuf.len = cpu_to_le16(strlen(priv->nick));
  1479. memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val));
  1480. err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
  1481. HERMES_BYTES_TO_RECLEN(strlen(priv->nick)+2),
  1482. &idbuf);
  1483. if (err) {
  1484. printk(KERN_ERR "%s: Error %d setting nickname\n",
  1485. dev->name, err);
  1486. return err;
  1487. }
  1488. /* Set AP density */
  1489. if (priv->has_sensitivity) {
  1490. err = hermes_write_wordrec(hw, USER_BAP,
  1491. HERMES_RID_CNFSYSTEMSCALE,
  1492. priv->ap_density);
  1493. if (err) {
  1494. printk(KERN_WARNING "%s: Error %d setting SYSTEMSCALE. "
  1495. "Disabling sensitivity control\n",
  1496. dev->name, err);
  1497. priv->has_sensitivity = 0;
  1498. }
  1499. }
  1500. /* Set RTS threshold */
  1501. err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD,
  1502. priv->rts_thresh);
  1503. if (err) {
  1504. printk(KERN_ERR "%s: Error %d setting RTS threshold\n",
  1505. dev->name, err);
  1506. return err;
  1507. }
  1508. /* Set fragmentation threshold or MWO robustness */
  1509. if (priv->has_mwo)
  1510. err = hermes_write_wordrec(hw, USER_BAP,
  1511. HERMES_RID_CNFMWOROBUST_AGERE,
  1512. priv->mwo_robust);
  1513. else
  1514. err = hermes_write_wordrec(hw, USER_BAP,
  1515. HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
  1516. priv->frag_thresh);
  1517. if (err) {
  1518. printk(KERN_ERR "%s: Error %d setting fragmentation\n",
  1519. dev->name, err);
  1520. return err;
  1521. }
  1522. /* Set bitrate */
  1523. err = __orinoco_hw_set_bitrate(priv);
  1524. if (err) {
  1525. printk(KERN_ERR "%s: Error %d setting bitrate\n",
  1526. dev->name, err);
  1527. return err;
  1528. }
  1529. /* Set power management */
  1530. if (priv->has_pm) {
  1531. err = hermes_write_wordrec(hw, USER_BAP,
  1532. HERMES_RID_CNFPMENABLED,
  1533. priv->pm_on);
  1534. if (err) {
  1535. printk(KERN_ERR "%s: Error %d setting up PM\n",
  1536. dev->name, err);
  1537. return err;
  1538. }
  1539. err = hermes_write_wordrec(hw, USER_BAP,
  1540. HERMES_RID_CNFMULTICASTRECEIVE,
  1541. priv->pm_mcast);
  1542. if (err) {
  1543. printk(KERN_ERR "%s: Error %d setting up PM\n",
  1544. dev->name, err);
  1545. return err;
  1546. }
  1547. err = hermes_write_wordrec(hw, USER_BAP,
  1548. HERMES_RID_CNFMAXSLEEPDURATION,
  1549. priv->pm_period);
  1550. if (err) {
  1551. printk(KERN_ERR "%s: Error %d setting up PM\n",
  1552. dev->name, err);
  1553. return err;
  1554. }
  1555. err = hermes_write_wordrec(hw, USER_BAP,
  1556. HERMES_RID_CNFPMHOLDOVERDURATION,
  1557. priv->pm_timeout);
  1558. if (err) {
  1559. printk(KERN_ERR "%s: Error %d setting up PM\n",
  1560. dev->name, err);
  1561. return err;
  1562. }
  1563. }
  1564. /* Set preamble - only for Symbol so far... */
  1565. if (priv->has_preamble) {
  1566. err = hermes_write_wordrec(hw, USER_BAP,
  1567. HERMES_RID_CNFPREAMBLE_SYMBOL,
  1568. priv->preamble);
  1569. if (err) {
  1570. printk(KERN_ERR "%s: Error %d setting preamble\n",
  1571. dev->name, err);
  1572. return err;
  1573. }
  1574. }
  1575. /* Set up encryption */
  1576. if (priv->has_wep) {
  1577. err = __orinoco_hw_setup_wep(priv);
  1578. if (err) {
  1579. printk(KERN_ERR "%s: Error %d activating WEP\n",
  1580. dev->name, err);
  1581. return err;
  1582. }
  1583. }
  1584. /* Set promiscuity / multicast*/
  1585. priv->promiscuous = 0;
  1586. priv->mc_count = 0;
  1587. __orinoco_set_multicast_list(dev); /* FIXME: what about the xmit_lock */
  1588. return 0;
  1589. }
  1590. /* FIXME: return int? */
  1591. static void
  1592. __orinoco_set_multicast_list(struct net_device *dev)
  1593. {
  1594. struct orinoco_private *priv = netdev_priv(dev);
  1595. hermes_t *hw = &priv->hw;
  1596. int err = 0;
  1597. int promisc, mc_count;
  1598. /* The Hermes doesn't seem to have an allmulti mode, so we go
  1599. * into promiscuous mode and let the upper levels deal. */
  1600. if ( (dev->flags & IFF_PROMISC) || (dev->flags & IFF_ALLMULTI) ||
  1601. (dev->mc_count > MAX_MULTICAST(priv)) ) {
  1602. promisc = 1;
  1603. mc_count = 0;
  1604. } else {
  1605. promisc = 0;
  1606. mc_count = dev->mc_count;
  1607. }
  1608. if (promisc != priv->promiscuous) {
  1609. err = hermes_write_wordrec(hw, USER_BAP,
  1610. HERMES_RID_CNFPROMISCUOUSMODE,
  1611. promisc);
  1612. if (err) {
  1613. printk(KERN_ERR "%s: Error %d setting PROMISCUOUSMODE to 1.\n",
  1614. dev->name, err);
  1615. } else
  1616. priv->promiscuous = promisc;
  1617. }
  1618. if (! promisc && (mc_count || priv->mc_count) ) {
  1619. struct dev_mc_list *p = dev->mc_list;
  1620. struct hermes_multicast mclist;
  1621. int i;
  1622. for (i = 0; i < mc_count; i++) {
  1623. /* paranoia: is list shorter than mc_count? */
  1624. BUG_ON(! p);
  1625. /* paranoia: bad address size in list? */
  1626. BUG_ON(p->dmi_addrlen != ETH_ALEN);
  1627. memcpy(mclist.addr[i], p->dmi_addr, ETH_ALEN);
  1628. p = p->next;
  1629. }
  1630. if (p)
  1631. printk(KERN_WARNING "%s: Multicast list is "
  1632. "longer than mc_count\n", dev->name);
  1633. err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFGROUPADDRESSES,
  1634. HERMES_BYTES_TO_RECLEN(priv->mc_count * ETH_ALEN),
  1635. &mclist);
  1636. if (err)
  1637. printk(KERN_ERR "%s: Error %d setting multicast list.\n",
  1638. dev->name, err);
  1639. else
  1640. priv->mc_count = mc_count;
  1641. }
  1642. /* Since we can set the promiscuous flag when it wasn't asked
  1643. for, make sure the net_device knows about it. */
  1644. if (priv->promiscuous)
  1645. dev->flags |= IFF_PROMISC;
  1646. else
  1647. dev->flags &= ~IFF_PROMISC;
  1648. }
  1649. static int orinoco_reconfigure(struct net_device *dev)
  1650. {
  1651. struct orinoco_private *priv = netdev_priv(dev);
  1652. struct hermes *hw = &priv->hw;
  1653. unsigned long flags;
  1654. int err = 0;
  1655. if (priv->broken_disableport) {
  1656. schedule_work(&priv->reset_work);
  1657. return 0;
  1658. }
  1659. if (orinoco_lock(priv, &flags) != 0)
  1660. return -EBUSY;
  1661. err = hermes_disable_port(hw, 0);
  1662. if (err) {
  1663. printk(KERN_WARNING "%s: Unable to disable port while reconfiguring card\n",
  1664. dev->name);
  1665. priv->broken_disableport = 1;
  1666. goto out;
  1667. }
  1668. err = __orinoco_program_rids(dev);
  1669. if (err) {
  1670. printk(KERN_WARNING "%s: Unable to reconfigure card\n",
  1671. dev->name);
  1672. goto out;
  1673. }
  1674. err = hermes_enable_port(hw, 0);
  1675. if (err) {
  1676. printk(KERN_WARNING "%s: Unable to enable port while reconfiguring card\n",
  1677. dev->name);
  1678. goto out;
  1679. }
  1680. out:
  1681. if (err) {
  1682. printk(KERN_WARNING "%s: Resetting instead...\n", dev->name);
  1683. schedule_work(&priv->reset_work);
  1684. err = 0;
  1685. }
  1686. orinoco_unlock(priv, &flags);
  1687. return err;
  1688. }
  1689. /* This must be called from user context, without locks held - use
  1690. * schedule_work() */
  1691. static void orinoco_reset(struct net_device *dev)
  1692. {
  1693. struct orinoco_private *priv = netdev_priv(dev);
  1694. struct hermes *hw = &priv->hw;
  1695. int err = 0;
  1696. unsigned long flags;
  1697. if (orinoco_lock(priv, &flags) != 0)
  1698. /* When the hardware becomes available again, whatever
  1699. * detects that is responsible for re-initializing
  1700. * it. So no need for anything further */
  1701. return;
  1702. netif_stop_queue(dev);
  1703. /* Shut off interrupts. Depending on what state the hardware
  1704. * is in, this might not work, but we'll try anyway */
  1705. hermes_set_irqmask(hw, 0);
  1706. hermes_write_regn(hw, EVACK, 0xffff);
  1707. priv->hw_unavailable++;
  1708. priv->last_linkstatus = 0xffff; /* firmware will have to reassociate */
  1709. netif_carrier_off(dev);
  1710. orinoco_unlock(priv, &flags);
  1711. if (priv->hard_reset)
  1712. err = (*priv->hard_reset)(priv);
  1713. if (err) {
  1714. printk(KERN_ERR "%s: orinoco_reset: Error %d "
  1715. "performing hard reset\n", dev->name, err);
  1716. /* FIXME: shutdown of some sort */
  1717. return;
  1718. }
  1719. err = orinoco_reinit_firmware(dev);
  1720. if (err) {
  1721. printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n",
  1722. dev->name, err);
  1723. return;
  1724. }
  1725. spin_lock_irq(&priv->lock); /* This has to be called from user context */
  1726. priv->hw_unavailable--;
  1727. /* priv->open or priv->hw_unavailable might have changed while
  1728. * we dropped the lock */
  1729. if (priv->open && (! priv->hw_unavailable)) {
  1730. err = __orinoco_up(dev);
  1731. if (err) {
  1732. printk(KERN_ERR "%s: orinoco_reset: Error %d reenabling card\n",
  1733. dev->name, err);
  1734. } else
  1735. dev->trans_start = jiffies;
  1736. }
  1737. spin_unlock_irq(&priv->lock);
  1738. return;
  1739. }
  1740. /********************************************************************/
  1741. /* Interrupt handler */
  1742. /********************************************************************/
  1743. static void __orinoco_ev_tick(struct net_device *dev, hermes_t *hw)
  1744. {
  1745. printk(KERN_DEBUG "%s: TICK\n", dev->name);
  1746. }
  1747. static void __orinoco_ev_wterr(struct net_device *dev, hermes_t *hw)
  1748. {
  1749. /* This seems to happen a fair bit under load, but ignoring it
  1750. seems to work fine...*/
  1751. printk(KERN_DEBUG "%s: MAC controller error (WTERR). Ignoring.\n",
  1752. dev->name);
  1753. }
  1754. irqreturn_t orinoco_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  1755. {
  1756. struct net_device *dev = (struct net_device *)dev_id;
  1757. struct orinoco_private *priv = netdev_priv(dev);
  1758. hermes_t *hw = &priv->hw;
  1759. int count = MAX_IRQLOOPS_PER_IRQ;
  1760. u16 evstat, events;
  1761. /* These are used to detect a runaway interrupt situation */
  1762. /* If we get more than MAX_IRQLOOPS_PER_JIFFY iterations in a jiffy,
  1763. * we panic and shut down the hardware */
  1764. static int last_irq_jiffy = 0; /* jiffies value the last time
  1765. * we were called */
  1766. static int loops_this_jiffy = 0;
  1767. unsigned long flags;
  1768. if (orinoco_lock(priv, &flags) != 0) {
  1769. /* If hw is unavailable - we don't know if the irq was
  1770. * for us or not */
  1771. return IRQ_HANDLED;
  1772. }
  1773. evstat = hermes_read_regn(hw, EVSTAT);
  1774. events = evstat & hw->inten;
  1775. if (! events) {
  1776. orinoco_unlock(priv, &flags);
  1777. return IRQ_NONE;
  1778. }
  1779. if (jiffies != last_irq_jiffy)
  1780. loops_this_jiffy = 0;
  1781. last_irq_jiffy = jiffies;
  1782. while (events && count--) {
  1783. if (++loops_this_jiffy > MAX_IRQLOOPS_PER_JIFFY) {
  1784. printk(KERN_WARNING "%s: IRQ handler is looping too "
  1785. "much! Resetting.\n", dev->name);
  1786. /* Disable interrupts for now */
  1787. hermes_set_irqmask(hw, 0);
  1788. schedule_work(&priv->reset_work);
  1789. break;
  1790. }
  1791. /* Check the card hasn't been removed */
  1792. if (! hermes_present(hw)) {
  1793. DEBUG(0, "orinoco_interrupt(): card removed\n");
  1794. break;
  1795. }
  1796. if (events & HERMES_EV_TICK)
  1797. __orinoco_ev_tick(dev, hw);
  1798. if (events & HERMES_EV_WTERR)
  1799. __orinoco_ev_wterr(dev, hw);
  1800. if (events & HERMES_EV_INFDROP)
  1801. __orinoco_ev_infdrop(dev, hw);
  1802. if (events & HERMES_EV_INFO)
  1803. __orinoco_ev_info(dev, hw);
  1804. if (events & HERMES_EV_RX)
  1805. __orinoco_ev_rx(dev, hw);
  1806. if (events & HERMES_EV_TXEXC)
  1807. __orinoco_ev_txexc(dev, hw);
  1808. if (events & HERMES_EV_TX)
  1809. __orinoco_ev_tx(dev, hw);
  1810. if (events & HERMES_EV_ALLOC)
  1811. __orinoco_ev_alloc(dev, hw);
  1812. hermes_write_regn(hw, EVACK, events);
  1813. evstat = hermes_read_regn(hw, EVSTAT);
  1814. events = evstat & hw->inten;
  1815. };
  1816. orinoco_unlock(priv, &flags);
  1817. return IRQ_HANDLED;
  1818. }
  1819. /********************************************************************/
  1820. /* Initialization */
  1821. /********************************************************************/
  1822. struct comp_id {
  1823. u16 id, variant, major, minor;
  1824. } __attribute__ ((packed));
  1825. static inline fwtype_t determine_firmware_type(struct comp_id *nic_id)
  1826. {
  1827. if (nic_id->id < 0x8000)
  1828. return FIRMWARE_TYPE_AGERE;
  1829. else if (nic_id->id == 0x8000 && nic_id->major == 0)
  1830. return FIRMWARE_TYPE_SYMBOL;
  1831. else
  1832. return FIRMWARE_TYPE_INTERSIL;
  1833. }
  1834. /* Set priv->firmware type, determine firmware properties */
  1835. static int determine_firmware(struct net_device *dev)
  1836. {
  1837. struct orinoco_private *priv = netdev_priv(dev);
  1838. hermes_t *hw = &priv->hw;
  1839. int err;
  1840. struct comp_id nic_id, sta_id;
  1841. unsigned int firmver;
  1842. char tmp[SYMBOL_MAX_VER_LEN+1];
  1843. /* Get the hardware version */
  1844. err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id);
  1845. if (err) {
  1846. printk(KERN_ERR "%s: Cannot read hardware identity: error %d\n",
  1847. dev->name, err);
  1848. return err;
  1849. }
  1850. le16_to_cpus(&nic_id.id);
  1851. le16_to_cpus(&nic_id.variant);
  1852. le16_to_cpus(&nic_id.major);
  1853. le16_to_cpus(&nic_id.minor);
  1854. printk(KERN_DEBUG "%s: Hardware identity %04x:%04x:%04x:%04x\n",
  1855. dev->name, nic_id.id, nic_id.variant,
  1856. nic_id.major, nic_id.minor);
  1857. priv->firmware_type = determine_firmware_type(&nic_id);
  1858. /* Get the firmware version */
  1859. err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_STAID, &sta_id);
  1860. if (err) {
  1861. printk(KERN_ERR "%s: Cannot read station identity: error %d\n",
  1862. dev->name, err);
  1863. return err;
  1864. }
  1865. le16_to_cpus(&sta_id.id);
  1866. le16_to_cpus(&sta_id.variant);
  1867. le16_to_cpus(&sta_id.major);
  1868. le16_to_cpus(&sta_id.minor);
  1869. printk(KERN_DEBUG "%s: Station identity %04x:%04x:%04x:%04x\n",
  1870. dev->name, sta_id.id, sta_id.variant,
  1871. sta_id.major, sta_id.minor);
  1872. switch (sta_id.id) {
  1873. case 0x15:
  1874. printk(KERN_ERR "%s: Primary firmware is active\n",
  1875. dev->name);
  1876. return -ENODEV;
  1877. case 0x14b:
  1878. printk(KERN_ERR "%s: Tertiary firmware is active\n",
  1879. dev->name);
  1880. return -ENODEV;
  1881. case 0x1f: /* Intersil, Agere, Symbol Spectrum24 */
  1882. case 0x21: /* Symbol Spectrum24 Trilogy */
  1883. break;
  1884. default:
  1885. printk(KERN_NOTICE "%s: Unknown station ID, please report\n",
  1886. dev->name);
  1887. break;
  1888. }
  1889. /* Default capabilities */
  1890. priv->has_sensitivity = 1;
  1891. priv->has_mwo = 0;
  1892. priv->has_preamble = 0;
  1893. priv->has_port3 = 1;
  1894. priv->has_ibss = 1;
  1895. priv->has_wep = 0;
  1896. priv->has_big_wep = 0;
  1897. /* Determine capabilities from the firmware version */
  1898. switch (priv->firmware_type) {
  1899. case FIRMWARE_TYPE_AGERE:
  1900. /* Lucent Wavelan IEEE, Lucent Orinoco, Cabletron RoamAbout,
  1901. ELSA, Melco, HP, IBM, Dell 1150, Compaq 110/210 */
  1902. snprintf(priv->fw_name, sizeof(priv->fw_name) - 1,
  1903. "Lucent/Agere %d.%02d", sta_id.major, sta_id.minor);
  1904. firmver = ((unsigned long)sta_id.major << 16) | sta_id.minor;
  1905. priv->has_ibss = (firmver >= 0x60006);
  1906. priv->has_wep = (firmver >= 0x40020);
  1907. priv->has_big_wep = 1; /* FIXME: this is wrong - how do we tell
  1908. Gold cards from the others? */
  1909. priv->has_mwo = (firmver >= 0x60000);
  1910. priv->has_pm = (firmver >= 0x40020); /* Don't work in 7.52 ? */
  1911. priv->ibss_port = 1;
  1912. /* Tested with Agere firmware :
  1913. * 1.16 ; 4.08 ; 4.52 ; 6.04 ; 6.16 ; 7.28 => Jean II
  1914. * Tested CableTron firmware : 4.32 => Anton */
  1915. break;
  1916. case FIRMWARE_TYPE_SYMBOL:
  1917. /* Symbol , 3Com AirConnect, Intel, Ericsson WLAN */
  1918. /* Intel MAC : 00:02:B3:* */
  1919. /* 3Com MAC : 00:50:DA:* */
  1920. memset(tmp, 0, sizeof(tmp));
  1921. /* Get the Symbol firmware version */
  1922. err = hermes_read_ltv(hw, USER_BAP,
  1923. HERMES_RID_SECONDARYVERSION_SYMBOL,
  1924. SYMBOL_MAX_VER_LEN, NULL, &tmp);
  1925. if (err) {
  1926. printk(KERN_WARNING
  1927. "%s: Error %d reading Symbol firmware info. Wildly guessing capabilities...\n",
  1928. dev->name, err);
  1929. firmver = 0;
  1930. tmp[0] = '\0';
  1931. } else {
  1932. /* The firmware revision is a string, the format is
  1933. * something like : "V2.20-01".
  1934. * Quick and dirty parsing... - Jean II
  1935. */
  1936. firmver = ((tmp[1] - '0') << 16) | ((tmp[3] - '0') << 12)
  1937. | ((tmp[4] - '0') << 8) | ((tmp[6] - '0') << 4)
  1938. | (tmp[7] - '0');
  1939. tmp[SYMBOL_MAX_VER_LEN] = '\0';
  1940. }
  1941. snprintf(priv->fw_name, sizeof(priv->fw_name) - 1,
  1942. "Symbol %s", tmp);
  1943. priv->has_ibss = (firmver >= 0x20000);
  1944. priv->has_wep = (firmver >= 0x15012);
  1945. priv->has_big_wep = (firmver >= 0x20000);
  1946. priv->has_pm = (firmver >= 0x20000 && firmver < 0x22000) ||
  1947. (firmver >= 0x29000 && firmver < 0x30000) ||
  1948. firmver >= 0x31000;
  1949. priv->has_preamble = (firmver >= 0x20000);
  1950. priv->ibss_port = 4;
  1951. /* Tested with Intel firmware : 0x20015 => Jean II */
  1952. /* Tested with 3Com firmware : 0x15012 & 0x22001 => Jean II */
  1953. break;
  1954. case FIRMWARE_TYPE_INTERSIL:
  1955. /* D-Link, Linksys, Adtron, ZoomAir, and many others...
  1956. * Samsung, Compaq 100/200 and Proxim are slightly
  1957. * different and less well tested */
  1958. /* D-Link MAC : 00:40:05:* */
  1959. /* Addtron MAC : 00:90:D1:* */
  1960. snprintf(priv->fw_name, sizeof(priv->fw_name) - 1,
  1961. "Intersil %d.%d.%d", sta_id.major, sta_id.minor,
  1962. sta_id.variant);
  1963. firmver = ((unsigned long)sta_id.major << 16) |
  1964. ((unsigned long)sta_id.minor << 8) | sta_id.variant;
  1965. priv->has_ibss = (firmver >= 0x000700); /* FIXME */
  1966. priv->has_big_wep = priv->has_wep = (firmver >= 0x000800);
  1967. priv->has_pm = (firmver >= 0x000700);
  1968. if (firmver >= 0x000800)
  1969. priv->ibss_port = 0;
  1970. else {
  1971. printk(KERN_NOTICE "%s: Intersil firmware earlier "
  1972. "than v0.8.x - several features not supported\n",
  1973. dev->name);
  1974. priv->ibss_port = 1;
  1975. }
  1976. break;
  1977. }
  1978. printk(KERN_DEBUG "%s: Firmware determined as %s\n", dev->name,
  1979. priv->fw_name);
  1980. return 0;
  1981. }
  1982. static int orinoco_init(struct net_device *dev)
  1983. {
  1984. struct orinoco_private *priv = netdev_priv(dev);
  1985. hermes_t *hw = &priv->hw;
  1986. int err = 0;
  1987. struct hermes_idstring nickbuf;
  1988. u16 reclen;
  1989. int len;
  1990. TRACE_ENTER(dev->name);
  1991. /* No need to lock, the hw_unavailable flag is already set in
  1992. * alloc_orinocodev() */
  1993. priv->nicbuf_size = IEEE802_11_FRAME_LEN + ETH_HLEN;
  1994. /* Initialize the firmware */
  1995. err = orinoco_reinit_firmware(dev);
  1996. if (err != 0) {
  1997. printk(KERN_ERR "%s: failed to initialize firmware (err = %d)\n",
  1998. dev->name, err);
  1999. goto out;
  2000. }
  2001. err = determine_firmware(dev);
  2002. if (err != 0) {
  2003. printk(KERN_ERR "%s: Incompatible firmware, aborting\n",
  2004. dev->name);
  2005. goto out;
  2006. }
  2007. if (priv->has_port3)
  2008. printk(KERN_DEBUG "%s: Ad-hoc demo mode supported\n", dev->name);
  2009. if (priv->has_ibss)
  2010. printk(KERN_DEBUG "%s: IEEE standard IBSS ad-hoc mode supported\n",
  2011. dev->name);
  2012. if (priv->has_wep) {
  2013. printk(KERN_DEBUG "%s: WEP supported, ", dev->name);
  2014. if (priv->has_big_wep)
  2015. printk("104-bit key\n");
  2016. else
  2017. printk("40-bit key\n");
  2018. }
  2019. /* Get the MAC address */
  2020. err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
  2021. ETH_ALEN, NULL, dev->dev_addr);
  2022. if (err) {
  2023. printk(KERN_WARNING "%s: failed to read MAC address!\n",
  2024. dev->name);
  2025. goto out;
  2026. }
  2027. printk(KERN_DEBUG "%s: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n",
  2028. dev->name, dev->dev_addr[0], dev->dev_addr[1],
  2029. dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4],
  2030. dev->dev_addr[5]);
  2031. /* Get the station name */
  2032. err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
  2033. sizeof(nickbuf), &reclen, &nickbuf);
  2034. if (err) {
  2035. printk(KERN_ERR "%s: failed to read station name\n",
  2036. dev->name);
  2037. goto out;
  2038. }
  2039. if (nickbuf.len)
  2040. len = min(IW_ESSID_MAX_SIZE, (int)le16_to_cpu(nickbuf.len));
  2041. else
  2042. len = min(IW_ESSID_MAX_SIZE, 2 * reclen);
  2043. memcpy(priv->nick, &nickbuf.val, len);
  2044. priv->nick[len] = '\0';
  2045. printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick);
  2046. /* Get allowed channels */
  2047. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST,
  2048. &priv->channel_mask);
  2049. if (err) {
  2050. printk(KERN_ERR "%s: failed to read channel list!\n",
  2051. dev->name);
  2052. goto out;
  2053. }
  2054. /* Get initial AP density */
  2055. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE,
  2056. &priv->ap_density);
  2057. if (err || priv->ap_density < 1 || priv->ap_density > 3) {
  2058. priv->has_sensitivity = 0;
  2059. }
  2060. /* Get initial RTS threshold */
  2061. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD,
  2062. &priv->rts_thresh);
  2063. if (err) {
  2064. printk(KERN_ERR "%s: failed to read RTS threshold!\n",
  2065. dev->name);
  2066. goto out;
  2067. }
  2068. /* Get initial fragmentation settings */
  2069. if (priv->has_mwo)
  2070. err = hermes_read_wordrec(hw, USER_BAP,
  2071. HERMES_RID_CNFMWOROBUST_AGERE,
  2072. &priv->mwo_robust);
  2073. else
  2074. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
  2075. &priv->frag_thresh);
  2076. if (err) {
  2077. printk(KERN_ERR "%s: failed to read fragmentation settings!\n",
  2078. dev->name);
  2079. goto out;
  2080. }
  2081. /* Power management setup */
  2082. if (priv->has_pm) {
  2083. priv->pm_on = 0;
  2084. priv->pm_mcast = 1;
  2085. err = hermes_read_wordrec(hw, USER_BAP,
  2086. HERMES_RID_CNFMAXSLEEPDURATION,
  2087. &priv->pm_period);
  2088. if (err) {
  2089. printk(KERN_ERR "%s: failed to read power management period!\n",
  2090. dev->name);
  2091. goto out;
  2092. }
  2093. err = hermes_read_wordrec(hw, USER_BAP,
  2094. HERMES_RID_CNFPMHOLDOVERDURATION,
  2095. &priv->pm_timeout);
  2096. if (err) {
  2097. printk(KERN_ERR "%s: failed to read power management timeout!\n",
  2098. dev->name);
  2099. goto out;
  2100. }
  2101. }
  2102. /* Preamble setup */
  2103. if (priv->has_preamble) {
  2104. err = hermes_read_wordrec(hw, USER_BAP,
  2105. HERMES_RID_CNFPREAMBLE_SYMBOL,
  2106. &priv->preamble);
  2107. if (err)
  2108. goto out;
  2109. }
  2110. /* Set up the default configuration */
  2111. priv->iw_mode = IW_MODE_INFRA;
  2112. /* By default use IEEE/IBSS ad-hoc mode if we have it */
  2113. priv->prefer_port3 = priv->has_port3 && (! priv->has_ibss);
  2114. set_port_type(priv);
  2115. priv->channel = 0; /* use firmware default */
  2116. priv->promiscuous = 0;
  2117. priv->wep_on = 0;
  2118. priv->tx_key = 0;
  2119. /* Make the hardware available, as long as it hasn't been
  2120. * removed elsewhere (e.g. by PCMCIA hot unplug) */
  2121. spin_lock_irq(&priv->lock);
  2122. priv->hw_unavailable--;
  2123. spin_unlock_irq(&priv->lock);
  2124. printk(KERN_DEBUG "%s: ready\n", dev->name);
  2125. out:
  2126. TRACE_EXIT(dev->name);
  2127. return err;
  2128. }
  2129. struct net_device *alloc_orinocodev(int sizeof_card,
  2130. int (*hard_reset)(struct orinoco_private *))
  2131. {
  2132. struct net_device *dev;
  2133. struct orinoco_private *priv;
  2134. dev = alloc_etherdev(sizeof(struct orinoco_private) + sizeof_card);
  2135. if (! dev)
  2136. return NULL;
  2137. priv = netdev_priv(dev);
  2138. priv->ndev = dev;
  2139. if (sizeof_card)
  2140. priv->card = (void *)((unsigned long)netdev_priv(dev)
  2141. + sizeof(struct orinoco_private));
  2142. else
  2143. priv->card = NULL;
  2144. /* Setup / override net_device fields */
  2145. dev->init = orinoco_init;
  2146. dev->hard_start_xmit = orinoco_xmit;
  2147. dev->tx_timeout = orinoco_tx_timeout;
  2148. dev->watchdog_timeo = HZ; /* 1 second timeout */
  2149. dev->get_stats = orinoco_get_stats;
  2150. dev->get_wireless_stats = orinoco_get_wireless_stats;
  2151. dev->do_ioctl = orinoco_ioctl;
  2152. dev->change_mtu = orinoco_change_mtu;
  2153. dev->set_multicast_list = orinoco_set_multicast_list;
  2154. /* we use the default eth_mac_addr for setting the MAC addr */
  2155. /* Set up default callbacks */
  2156. dev->open = orinoco_open;
  2157. dev->stop = orinoco_stop;
  2158. priv->hard_reset = hard_reset;
  2159. spin_lock_init(&priv->lock);
  2160. priv->open = 0;
  2161. priv->hw_unavailable = 1; /* orinoco_init() must clear this
  2162. * before anything else touches the
  2163. * hardware */
  2164. INIT_WORK(&priv->reset_work, (void (*)(void *))orinoco_reset, dev);
  2165. netif_carrier_off(dev);
  2166. priv->last_linkstatus = 0xffff;
  2167. return dev;
  2168. }
  2169. void free_orinocodev(struct net_device *dev)
  2170. {
  2171. free_netdev(dev);
  2172. }
  2173. /********************************************************************/
  2174. /* Wireless extensions */
  2175. /********************************************************************/
  2176. static int orinoco_hw_get_bssid(struct orinoco_private *priv,
  2177. char buf[ETH_ALEN])
  2178. {
  2179. hermes_t *hw = &priv->hw;
  2180. int err = 0;
  2181. unsigned long flags;
  2182. if (orinoco_lock(priv, &flags) != 0)
  2183. return -EBUSY;
  2184. err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
  2185. ETH_ALEN, NULL, buf);
  2186. orinoco_unlock(priv, &flags);
  2187. return err;
  2188. }
  2189. static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
  2190. char buf[IW_ESSID_MAX_SIZE+1])
  2191. {
  2192. hermes_t *hw = &priv->hw;
  2193. int err = 0;
  2194. struct hermes_idstring essidbuf;
  2195. char *p = (char *)(&essidbuf.val);
  2196. int len;
  2197. unsigned long flags;
  2198. if (orinoco_lock(priv, &flags) != 0)
  2199. return -EBUSY;
  2200. if (strlen(priv->desired_essid) > 0) {
  2201. /* We read the desired SSID from the hardware rather
  2202. than from priv->desired_essid, just in case the
  2203. firmware is allowed to change it on us. I'm not
  2204. sure about this */
  2205. /* My guess is that the OWNSSID should always be whatever
  2206. * we set to the card, whereas CURRENT_SSID is the one that
  2207. * may change... - Jean II */
  2208. u16 rid;
  2209. *active = 1;
  2210. rid = (priv->port_type == 3) ? HERMES_RID_CNFOWNSSID :
  2211. HERMES_RID_CNFDESIREDSSID;
  2212. err = hermes_read_ltv(hw, USER_BAP, rid, sizeof(essidbuf),
  2213. NULL, &essidbuf);
  2214. if (err)
  2215. goto fail_unlock;
  2216. } else {
  2217. *active = 0;
  2218. err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENTSSID,
  2219. sizeof(essidbuf), NULL, &essidbuf);
  2220. if (err)
  2221. goto fail_unlock;
  2222. }
  2223. len = le16_to_cpu(essidbuf.len);
  2224. memset(buf, 0, IW_ESSID_MAX_SIZE+1);
  2225. memcpy(buf, p, len);
  2226. buf[len] = '\0';
  2227. fail_unlock:
  2228. orinoco_unlock(priv, &flags);
  2229. return err;
  2230. }
  2231. static long orinoco_hw_get_freq(struct orinoco_private *priv)
  2232. {
  2233. hermes_t *hw = &priv->hw;
  2234. int err = 0;
  2235. u16 channel;
  2236. long freq = 0;
  2237. unsigned long flags;
  2238. if (orinoco_lock(priv, &flags) != 0)
  2239. return -EBUSY;
  2240. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CURRENTCHANNEL, &channel);
  2241. if (err)
  2242. goto out;
  2243. /* Intersil firmware 1.3.5 returns 0 when the interface is down */
  2244. if (channel == 0) {
  2245. err = -EBUSY;
  2246. goto out;
  2247. }
  2248. if ( (channel < 1) || (channel > NUM_CHANNELS) ) {
  2249. printk(KERN_WARNING "%s: Channel out of range (%d)!\n",
  2250. priv->ndev->name, channel);
  2251. err = -EBUSY;
  2252. goto out;
  2253. }
  2254. freq = channel_frequency[channel-1] * 100000;
  2255. out:
  2256. orinoco_unlock(priv, &flags);
  2257. if (err > 0)
  2258. err = -EBUSY;
  2259. return err ? err : freq;
  2260. }
  2261. static int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
  2262. int *numrates, s32 *rates, int max)
  2263. {
  2264. hermes_t *hw = &priv->hw;
  2265. struct hermes_idstring list;
  2266. unsigned char *p = (unsigned char *)&list.val;
  2267. int err = 0;
  2268. int num;
  2269. int i;
  2270. unsigned long flags;
  2271. if (orinoco_lock(priv, &flags) != 0)
  2272. return -EBUSY;
  2273. err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_SUPPORTEDDATARATES,
  2274. sizeof(list), NULL, &list);
  2275. orinoco_unlock(priv, &flags);
  2276. if (err)
  2277. return err;
  2278. num = le16_to_cpu(list.len);
  2279. *numrates = num;
  2280. num = min(num, max);
  2281. for (i = 0; i < num; i++) {
  2282. rates[i] = (p[i] & 0x7f) * 500000; /* convert to bps */
  2283. }
  2284. return 0;
  2285. }
  2286. static int orinoco_ioctl_getiwrange(struct net_device *dev, struct iw_point *rrq)
  2287. {
  2288. struct orinoco_private *priv = netdev_priv(dev);
  2289. int err = 0;
  2290. int mode;
  2291. struct iw_range range;
  2292. int numrates;
  2293. int i, k;
  2294. unsigned long flags;
  2295. TRACE_ENTER(dev->name);
  2296. if (!access_ok(VERIFY_WRITE, rrq->pointer, sizeof(range)))
  2297. return -EFAULT;
  2298. rrq->length = sizeof(range);
  2299. if (orinoco_lock(priv, &flags) != 0)
  2300. return -EBUSY;
  2301. mode = priv->iw_mode;
  2302. orinoco_unlock(priv, &flags);
  2303. memset(&range, 0, sizeof(range));
  2304. /* Much of this shamelessly taken from wvlan_cs.c. No idea
  2305. * what it all means -dgibson */
  2306. range.we_version_compiled = WIRELESS_EXT;
  2307. range.we_version_source = 11;
  2308. range.min_nwid = range.max_nwid = 0; /* We don't use nwids */
  2309. /* Set available channels/frequencies */
  2310. range.num_channels = NUM_CHANNELS;
  2311. k = 0;
  2312. for (i = 0; i < NUM_CHANNELS; i++) {
  2313. if (priv->channel_mask & (1 << i)) {
  2314. range.freq[k].i = i + 1;
  2315. range.freq[k].m = channel_frequency[i] * 100000;
  2316. range.freq[k].e = 1;
  2317. k++;
  2318. }
  2319. if (k >= IW_MAX_FREQUENCIES)
  2320. break;
  2321. }
  2322. range.num_frequency = k;
  2323. range.sensitivity = 3;
  2324. if ((mode == IW_MODE_ADHOC) && (priv->spy_number == 0)){
  2325. /* Quality stats meaningless in ad-hoc mode */
  2326. range.max_qual.qual = 0;
  2327. range.max_qual.level = 0;
  2328. range.max_qual.noise = 0;
  2329. range.avg_qual.qual = 0;
  2330. range.avg_qual.level = 0;
  2331. range.avg_qual.noise = 0;
  2332. } else {
  2333. range.max_qual.qual = 0x8b - 0x2f;
  2334. range.max_qual.level = 0x2f - 0x95 - 1;
  2335. range.max_qual.noise = 0x2f - 0x95 - 1;
  2336. /* Need to get better values */
  2337. range.avg_qual.qual = 0x24;
  2338. range.avg_qual.level = 0xC2;
  2339. range.avg_qual.noise = 0x9E;
  2340. }
  2341. err = orinoco_hw_get_bitratelist(priv, &numrates,
  2342. range.bitrate, IW_MAX_BITRATES);
  2343. if (err)
  2344. return err;
  2345. range.num_bitrates = numrates;
  2346. /* Set an indication of the max TCP throughput in bit/s that we can
  2347. * expect using this interface. May be use for QoS stuff...
  2348. * Jean II */
  2349. if(numrates > 2)
  2350. range.throughput = 5 * 1000 * 1000; /* ~5 Mb/s */
  2351. else
  2352. range.throughput = 1.5 * 1000 * 1000; /* ~1.5 Mb/s */
  2353. range.min_rts = 0;
  2354. range.max_rts = 2347;
  2355. range.min_frag = 256;
  2356. range.max_frag = 2346;
  2357. if (orinoco_lock(priv, &flags) != 0)
  2358. return -EBUSY;
  2359. if (priv->has_wep) {
  2360. range.max_encoding_tokens = ORINOCO_MAX_KEYS;
  2361. range.encoding_size[0] = SMALL_KEY_SIZE;
  2362. range.num_encoding_sizes = 1;
  2363. if (priv->has_big_wep) {
  2364. range.encoding_size[1] = LARGE_KEY_SIZE;
  2365. range.num_encoding_sizes = 2;
  2366. }
  2367. } else {
  2368. range.num_encoding_sizes = 0;
  2369. range.max_encoding_tokens = 0;
  2370. }
  2371. orinoco_unlock(priv, &flags);
  2372. range.min_pmp = 0;
  2373. range.max_pmp = 65535000;
  2374. range.min_pmt = 0;
  2375. range.max_pmt = 65535 * 1000; /* ??? */
  2376. range.pmp_flags = IW_POWER_PERIOD;
  2377. range.pmt_flags = IW_POWER_TIMEOUT;
  2378. range.pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
  2379. range.num_txpower = 1;
  2380. range.txpower[0] = 15; /* 15dBm */
  2381. range.txpower_capa = IW_TXPOW_DBM;
  2382. range.retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
  2383. range.retry_flags = IW_RETRY_LIMIT;
  2384. range.r_time_flags = IW_RETRY_LIFETIME;
  2385. range.min_retry = 0;
  2386. range.max_retry = 65535; /* ??? */
  2387. range.min_r_time = 0;
  2388. range.max_r_time = 65535 * 1000; /* ??? */
  2389. if (copy_to_user(rrq->pointer, &range, sizeof(range)))
  2390. return -EFAULT;
  2391. TRACE_EXIT(dev->name);
  2392. return 0;
  2393. }
  2394. static int orinoco_ioctl_setiwencode(struct net_device *dev, struct iw_point *erq)
  2395. {
  2396. struct orinoco_private *priv = netdev_priv(dev);
  2397. int index = (erq->flags & IW_ENCODE_INDEX) - 1;
  2398. int setindex = priv->tx_key;
  2399. int enable = priv->wep_on;
  2400. int restricted = priv->wep_restrict;
  2401. u16 xlen = 0;
  2402. int err = 0;
  2403. char keybuf[ORINOCO_MAX_KEY_SIZE];
  2404. unsigned long flags;
  2405. if (! priv->has_wep)
  2406. return -EOPNOTSUPP;
  2407. if (erq->pointer) {
  2408. /* We actually have a key to set - check its length */
  2409. if (erq->length > LARGE_KEY_SIZE)
  2410. return -E2BIG;
  2411. if ( (erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep )
  2412. return -E2BIG;
  2413. if (copy_from_user(keybuf, erq->pointer, erq->length))
  2414. return -EFAULT;
  2415. }
  2416. if (orinoco_lock(priv, &flags) != 0)
  2417. return -EBUSY;
  2418. if (erq->pointer) {
  2419. if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
  2420. index = priv->tx_key;
  2421. /* Adjust key length to a supported value */
  2422. if (erq->length > SMALL_KEY_SIZE) {
  2423. xlen = LARGE_KEY_SIZE;
  2424. } else if (erq->length > 0) {
  2425. xlen = SMALL_KEY_SIZE;
  2426. } else
  2427. xlen = 0;
  2428. /* Switch on WEP if off */
  2429. if ((!enable) && (xlen > 0)) {
  2430. setindex = index;
  2431. enable = 1;
  2432. }
  2433. } else {
  2434. /* Important note : if the user do "iwconfig eth0 enc off",
  2435. * we will arrive there with an index of -1. This is valid
  2436. * but need to be taken care off... Jean II */
  2437. if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) {
  2438. if((index != -1) || (erq->flags == 0)) {
  2439. err = -EINVAL;
  2440. goto out;
  2441. }
  2442. } else {
  2443. /* Set the index : Check that the key is valid */
  2444. if(priv->keys[index].len == 0) {
  2445. err = -EINVAL;
  2446. goto out;
  2447. }
  2448. setindex = index;
  2449. }
  2450. }
  2451. if (erq->flags & IW_ENCODE_DISABLED)
  2452. enable = 0;
  2453. if (erq->flags & IW_ENCODE_OPEN)
  2454. restricted = 0;
  2455. if (erq->flags & IW_ENCODE_RESTRICTED)
  2456. restricted = 1;
  2457. if (erq->pointer) {
  2458. priv->keys[index].len = cpu_to_le16(xlen);
  2459. memset(priv->keys[index].data, 0,
  2460. sizeof(priv->keys[index].data));
  2461. memcpy(priv->keys[index].data, keybuf, erq->length);
  2462. }
  2463. priv->tx_key = setindex;
  2464. /* Try fast key change if connected and only keys are changed */
  2465. if (priv->wep_on && enable && (priv->wep_restrict == restricted) &&
  2466. netif_carrier_ok(dev)) {
  2467. err = __orinoco_hw_setup_wepkeys(priv);
  2468. /* No need to commit if successful */
  2469. goto out;
  2470. }
  2471. priv->wep_on = enable;
  2472. priv->wep_restrict = restricted;
  2473. out:
  2474. orinoco_unlock(priv, &flags);
  2475. return err;
  2476. }
  2477. static int orinoco_ioctl_getiwencode(struct net_device *dev, struct iw_point *erq)
  2478. {
  2479. struct orinoco_private *priv = netdev_priv(dev);
  2480. int index = (erq->flags & IW_ENCODE_INDEX) - 1;
  2481. u16 xlen = 0;
  2482. char keybuf[ORINOCO_MAX_KEY_SIZE];
  2483. unsigned long flags;
  2484. if (! priv->has_wep)
  2485. return -EOPNOTSUPP;
  2486. if (orinoco_lock(priv, &flags) != 0)
  2487. return -EBUSY;
  2488. if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
  2489. index = priv->tx_key;
  2490. erq->flags = 0;
  2491. if (! priv->wep_on)
  2492. erq->flags |= IW_ENCODE_DISABLED;
  2493. erq->flags |= index + 1;
  2494. if (priv->wep_restrict)
  2495. erq->flags |= IW_ENCODE_RESTRICTED;
  2496. else
  2497. erq->flags |= IW_ENCODE_OPEN;
  2498. xlen = le16_to_cpu(priv->keys[index].len);
  2499. erq->length = xlen;
  2500. memcpy(keybuf, priv->keys[index].data, ORINOCO_MAX_KEY_SIZE);
  2501. orinoco_unlock(priv, &flags);
  2502. if (erq->pointer) {
  2503. if (copy_to_user(erq->pointer, keybuf, xlen))
  2504. return -EFAULT;
  2505. }
  2506. return 0;
  2507. }
  2508. static int orinoco_ioctl_setessid(struct net_device *dev, struct iw_point *erq)
  2509. {
  2510. struct orinoco_private *priv = netdev_priv(dev);
  2511. char essidbuf[IW_ESSID_MAX_SIZE+1];
  2512. unsigned long flags;
  2513. /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it
  2514. * anyway... - Jean II */
  2515. memset(&essidbuf, 0, sizeof(essidbuf));
  2516. if (erq->flags) {
  2517. if (erq->length > IW_ESSID_MAX_SIZE)
  2518. return -E2BIG;
  2519. if (copy_from_user(&essidbuf, erq->pointer, erq->length))
  2520. return -EFAULT;
  2521. essidbuf[erq->length] = '\0';
  2522. }
  2523. if (orinoco_lock(priv, &flags) != 0)
  2524. return -EBUSY;
  2525. memcpy(priv->desired_essid, essidbuf, sizeof(priv->desired_essid));
  2526. orinoco_unlock(priv, &flags);
  2527. return 0;
  2528. }
  2529. static int orinoco_ioctl_getessid(struct net_device *dev, struct iw_point *erq)
  2530. {
  2531. struct orinoco_private *priv = netdev_priv(dev);
  2532. char essidbuf[IW_ESSID_MAX_SIZE+1];
  2533. int active;
  2534. int err = 0;
  2535. unsigned long flags;
  2536. TRACE_ENTER(dev->name);
  2537. if (netif_running(dev)) {
  2538. err = orinoco_hw_get_essid(priv, &active, essidbuf);
  2539. if (err)
  2540. return err;
  2541. } else {
  2542. if (orinoco_lock(priv, &flags) != 0)
  2543. return -EBUSY;
  2544. memcpy(essidbuf, priv->desired_essid, sizeof(essidbuf));
  2545. orinoco_unlock(priv, &flags);
  2546. }
  2547. erq->flags = 1;
  2548. erq->length = strlen(essidbuf) + 1;
  2549. if (erq->pointer)
  2550. if (copy_to_user(erq->pointer, essidbuf, erq->length))
  2551. return -EFAULT;
  2552. TRACE_EXIT(dev->name);
  2553. return 0;
  2554. }
  2555. static int orinoco_ioctl_setnick(struct net_device *dev, struct iw_point *nrq)
  2556. {
  2557. struct orinoco_private *priv = netdev_priv(dev);
  2558. char nickbuf[IW_ESSID_MAX_SIZE+1];
  2559. unsigned long flags;
  2560. if (nrq->length > IW_ESSID_MAX_SIZE)
  2561. return -E2BIG;
  2562. memset(nickbuf, 0, sizeof(nickbuf));
  2563. if (copy_from_user(nickbuf, nrq->pointer, nrq->length))
  2564. return -EFAULT;
  2565. nickbuf[nrq->length] = '\0';
  2566. if (orinoco_lock(priv, &flags) != 0)
  2567. return -EBUSY;
  2568. memcpy(priv->nick, nickbuf, sizeof(priv->nick));
  2569. orinoco_unlock(priv, &flags);
  2570. return 0;
  2571. }
  2572. static int orinoco_ioctl_getnick(struct net_device *dev, struct iw_point *nrq)
  2573. {
  2574. struct orinoco_private *priv = netdev_priv(dev);
  2575. char nickbuf[IW_ESSID_MAX_SIZE+1];
  2576. unsigned long flags;
  2577. if (orinoco_lock(priv, &flags) != 0)
  2578. return -EBUSY;
  2579. memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1);
  2580. orinoco_unlock(priv, &flags);
  2581. nrq->length = strlen(nickbuf)+1;
  2582. if (copy_to_user(nrq->pointer, nickbuf, sizeof(nickbuf)))
  2583. return -EFAULT;
  2584. return 0;
  2585. }
  2586. static int orinoco_ioctl_setfreq(struct net_device *dev, struct iw_freq *frq)
  2587. {
  2588. struct orinoco_private *priv = netdev_priv(dev);
  2589. int chan = -1;
  2590. unsigned long flags;
  2591. /* We can only use this in Ad-Hoc demo mode to set the operating
  2592. * frequency, or in IBSS mode to set the frequency where the IBSS
  2593. * will be created - Jean II */
  2594. if (priv->iw_mode != IW_MODE_ADHOC)
  2595. return -EOPNOTSUPP;
  2596. if ( (frq->e == 0) && (frq->m <= 1000) ) {
  2597. /* Setting by channel number */
  2598. chan = frq->m;
  2599. } else {
  2600. /* Setting by frequency - search the table */
  2601. int mult = 1;
  2602. int i;
  2603. for (i = 0; i < (6 - frq->e); i++)
  2604. mult *= 10;
  2605. for (i = 0; i < NUM_CHANNELS; i++)
  2606. if (frq->m == (channel_frequency[i] * mult))
  2607. chan = i+1;
  2608. }
  2609. if ( (chan < 1) || (chan > NUM_CHANNELS) ||
  2610. ! (priv->channel_mask & (1 << (chan-1)) ) )
  2611. return -EINVAL;
  2612. if (orinoco_lock(priv, &flags) != 0)
  2613. return -EBUSY;
  2614. priv->channel = chan;
  2615. orinoco_unlock(priv, &flags);
  2616. return 0;
  2617. }
  2618. static int orinoco_ioctl_getsens(struct net_device *dev, struct iw_param *srq)
  2619. {
  2620. struct orinoco_private *priv = netdev_priv(dev);
  2621. hermes_t *hw = &priv->hw;
  2622. u16 val;
  2623. int err;
  2624. unsigned long flags;
  2625. if (!priv->has_sensitivity)
  2626. return -EOPNOTSUPP;
  2627. if (orinoco_lock(priv, &flags) != 0)
  2628. return -EBUSY;
  2629. err = hermes_read_wordrec(hw, USER_BAP,
  2630. HERMES_RID_CNFSYSTEMSCALE, &val);
  2631. orinoco_unlock(priv, &flags);
  2632. if (err)
  2633. return err;
  2634. srq->value = val;
  2635. srq->fixed = 0; /* auto */
  2636. return 0;
  2637. }
  2638. static int orinoco_ioctl_setsens(struct net_device *dev, struct iw_param *srq)
  2639. {
  2640. struct orinoco_private *priv = netdev_priv(dev);
  2641. int val = srq->value;
  2642. unsigned long flags;
  2643. if (!priv->has_sensitivity)
  2644. return -EOPNOTSUPP;
  2645. if ((val < 1) || (val > 3))
  2646. return -EINVAL;
  2647. if (orinoco_lock(priv, &flags) != 0)
  2648. return -EBUSY;
  2649. priv->ap_density = val;
  2650. orinoco_unlock(priv, &flags);
  2651. return 0;
  2652. }
  2653. static int orinoco_ioctl_setrts(struct net_device *dev, struct iw_param *rrq)
  2654. {
  2655. struct orinoco_private *priv = netdev_priv(dev);
  2656. int val = rrq->value;
  2657. unsigned long flags;
  2658. if (rrq->disabled)
  2659. val = 2347;
  2660. if ( (val < 0) || (val > 2347) )
  2661. return -EINVAL;
  2662. if (orinoco_lock(priv, &flags) != 0)
  2663. return -EBUSY;
  2664. priv->rts_thresh = val;
  2665. orinoco_unlock(priv, &flags);
  2666. return 0;
  2667. }
  2668. static int orinoco_ioctl_setfrag(struct net_device *dev, struct iw_param *frq)
  2669. {
  2670. struct orinoco_private *priv = netdev_priv(dev);
  2671. int err = 0;
  2672. unsigned long flags;
  2673. if (orinoco_lock(priv, &flags) != 0)
  2674. return -EBUSY;
  2675. if (priv->has_mwo) {
  2676. if (frq->disabled)
  2677. priv->mwo_robust = 0;
  2678. else {
  2679. if (frq->fixed)
  2680. printk(KERN_WARNING "%s: Fixed fragmentation is "
  2681. "not supported on this firmware. "
  2682. "Using MWO robust instead.\n", dev->name);
  2683. priv->mwo_robust = 1;
  2684. }
  2685. } else {
  2686. if (frq->disabled)
  2687. priv->frag_thresh = 2346;
  2688. else {
  2689. if ( (frq->value < 256) || (frq->value > 2346) )
  2690. err = -EINVAL;
  2691. else
  2692. priv->frag_thresh = frq->value & ~0x1; /* must be even */
  2693. }
  2694. }
  2695. orinoco_unlock(priv, &flags);
  2696. return err;
  2697. }
  2698. static int orinoco_ioctl_getfrag(struct net_device *dev, struct iw_param *frq)
  2699. {
  2700. struct orinoco_private *priv = netdev_priv(dev);
  2701. hermes_t *hw = &priv->hw;
  2702. int err = 0;
  2703. u16 val;
  2704. unsigned long flags;
  2705. if (orinoco_lock(priv, &flags) != 0)
  2706. return -EBUSY;
  2707. if (priv->has_mwo) {
  2708. err = hermes_read_wordrec(hw, USER_BAP,
  2709. HERMES_RID_CNFMWOROBUST_AGERE,
  2710. &val);
  2711. if (err)
  2712. val = 0;
  2713. frq->value = val ? 2347 : 0;
  2714. frq->disabled = ! val;
  2715. frq->fixed = 0;
  2716. } else {
  2717. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
  2718. &val);
  2719. if (err)
  2720. val = 0;
  2721. frq->value = val;
  2722. frq->disabled = (val >= 2346);
  2723. frq->fixed = 1;
  2724. }
  2725. orinoco_unlock(priv, &flags);
  2726. return err;
  2727. }
  2728. static int orinoco_ioctl_setrate(struct net_device *dev, struct iw_param *rrq)
  2729. {
  2730. struct orinoco_private *priv = netdev_priv(dev);
  2731. int err = 0;
  2732. int ratemode = -1;
  2733. int bitrate; /* 100s of kilobits */
  2734. int i;
  2735. unsigned long flags;
  2736. /* As the user space doesn't know our highest rate, it uses -1
  2737. * to ask us to set the highest rate. Test it using "iwconfig
  2738. * ethX rate auto" - Jean II */
  2739. if (rrq->value == -1)
  2740. bitrate = 110;
  2741. else {
  2742. if (rrq->value % 100000)
  2743. return -EINVAL;
  2744. bitrate = rrq->value / 100000;
  2745. }
  2746. if ( (bitrate != 10) && (bitrate != 20) &&
  2747. (bitrate != 55) && (bitrate != 110) )
  2748. return -EINVAL;
  2749. for (i = 0; i < BITRATE_TABLE_SIZE; i++)
  2750. if ( (bitrate_table[i].bitrate == bitrate) &&
  2751. (bitrate_table[i].automatic == ! rrq->fixed) ) {
  2752. ratemode = i;
  2753. break;
  2754. }
  2755. if (ratemode == -1)
  2756. return -EINVAL;
  2757. if (orinoco_lock(priv, &flags) != 0)
  2758. return -EBUSY;
  2759. priv->bitratemode = ratemode;
  2760. orinoco_unlock(priv, &flags);
  2761. return err;
  2762. }
  2763. static int orinoco_ioctl_getrate(struct net_device *dev, struct iw_param *rrq)
  2764. {
  2765. struct orinoco_private *priv = netdev_priv(dev);
  2766. hermes_t *hw = &priv->hw;
  2767. int err = 0;
  2768. int ratemode;
  2769. int i;
  2770. u16 val;
  2771. unsigned long flags;
  2772. if (orinoco_lock(priv, &flags) != 0)
  2773. return -EBUSY;
  2774. ratemode = priv->bitratemode;
  2775. BUG_ON((ratemode < 0) || (ratemode >= BITRATE_TABLE_SIZE));
  2776. rrq->value = bitrate_table[ratemode].bitrate * 100000;
  2777. rrq->fixed = ! bitrate_table[ratemode].automatic;
  2778. rrq->disabled = 0;
  2779. /* If the interface is running we try to find more about the
  2780. current mode */
  2781. if (netif_running(dev)) {
  2782. err = hermes_read_wordrec(hw, USER_BAP,
  2783. HERMES_RID_CURRENTTXRATE, &val);
  2784. if (err)
  2785. goto out;
  2786. switch (priv->firmware_type) {
  2787. case FIRMWARE_TYPE_AGERE: /* Lucent style rate */
  2788. /* Note : in Lucent firmware, the return value of
  2789. * HERMES_RID_CURRENTTXRATE is the bitrate in Mb/s,
  2790. * and therefore is totally different from the
  2791. * encoding of HERMES_RID_CNFTXRATECONTROL.
  2792. * Don't forget that 6Mb/s is really 5.5Mb/s */
  2793. if (val == 6)
  2794. rrq->value = 5500000;
  2795. else
  2796. rrq->value = val * 1000000;
  2797. break;
  2798. case FIRMWARE_TYPE_INTERSIL: /* Intersil style rate */
  2799. case FIRMWARE_TYPE_SYMBOL: /* Symbol style rate */
  2800. for (i = 0; i < BITRATE_TABLE_SIZE; i++)
  2801. if (bitrate_table[i].intersil_txratectrl == val) {
  2802. ratemode = i;
  2803. break;
  2804. }
  2805. if (i >= BITRATE_TABLE_SIZE)
  2806. printk(KERN_INFO "%s: Unable to determine current bitrate (0x%04hx)\n",
  2807. dev->name, val);
  2808. rrq->value = bitrate_table[ratemode].bitrate * 100000;
  2809. break;
  2810. default:
  2811. BUG();
  2812. }
  2813. }
  2814. out:
  2815. orinoco_unlock(priv, &flags);
  2816. return err;
  2817. }
  2818. static int orinoco_ioctl_setpower(struct net_device *dev, struct iw_param *prq)
  2819. {
  2820. struct orinoco_private *priv = netdev_priv(dev);
  2821. int err = 0;
  2822. unsigned long flags;
  2823. if (orinoco_lock(priv, &flags) != 0)
  2824. return -EBUSY;
  2825. if (prq->disabled) {
  2826. priv->pm_on = 0;
  2827. } else {
  2828. switch (prq->flags & IW_POWER_MODE) {
  2829. case IW_POWER_UNICAST_R:
  2830. priv->pm_mcast = 0;
  2831. priv->pm_on = 1;
  2832. break;
  2833. case IW_POWER_ALL_R:
  2834. priv->pm_mcast = 1;
  2835. priv->pm_on = 1;
  2836. break;
  2837. case IW_POWER_ON:
  2838. /* No flags : but we may have a value - Jean II */
  2839. break;
  2840. default:
  2841. err = -EINVAL;
  2842. }
  2843. if (err)
  2844. goto out;
  2845. if (prq->flags & IW_POWER_TIMEOUT) {
  2846. priv->pm_on = 1;
  2847. priv->pm_timeout = prq->value / 1000;
  2848. }
  2849. if (prq->flags & IW_POWER_PERIOD) {
  2850. priv->pm_on = 1;
  2851. priv->pm_period = prq->value / 1000;
  2852. }
  2853. /* It's valid to not have a value if we are just toggling
  2854. * the flags... Jean II */
  2855. if(!priv->pm_on) {
  2856. err = -EINVAL;
  2857. goto out;
  2858. }
  2859. }
  2860. out:
  2861. orinoco_unlock(priv, &flags);
  2862. return err;
  2863. }
  2864. static int orinoco_ioctl_getpower(struct net_device *dev, struct iw_param *prq)
  2865. {
  2866. struct orinoco_private *priv = netdev_priv(dev);
  2867. hermes_t *hw = &priv->hw;
  2868. int err = 0;
  2869. u16 enable, period, timeout, mcast;
  2870. unsigned long flags;
  2871. if (orinoco_lock(priv, &flags) != 0)
  2872. return -EBUSY;
  2873. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFPMENABLED, &enable);
  2874. if (err)
  2875. goto out;
  2876. err = hermes_read_wordrec(hw, USER_BAP,
  2877. HERMES_RID_CNFMAXSLEEPDURATION, &period);
  2878. if (err)
  2879. goto out;
  2880. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFPMHOLDOVERDURATION, &timeout);
  2881. if (err)
  2882. goto out;
  2883. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFMULTICASTRECEIVE, &mcast);
  2884. if (err)
  2885. goto out;
  2886. prq->disabled = !enable;
  2887. /* Note : by default, display the period */
  2888. if ((prq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
  2889. prq->flags = IW_POWER_TIMEOUT;
  2890. prq->value = timeout * 1000;
  2891. } else {
  2892. prq->flags = IW_POWER_PERIOD;
  2893. prq->value = period * 1000;
  2894. }
  2895. if (mcast)
  2896. prq->flags |= IW_POWER_ALL_R;
  2897. else
  2898. prq->flags |= IW_POWER_UNICAST_R;
  2899. out:
  2900. orinoco_unlock(priv, &flags);
  2901. return err;
  2902. }
  2903. static int orinoco_ioctl_getretry(struct net_device *dev, struct iw_param *rrq)
  2904. {
  2905. struct orinoco_private *priv = netdev_priv(dev);
  2906. hermes_t *hw = &priv->hw;
  2907. int err = 0;
  2908. u16 short_limit, long_limit, lifetime;
  2909. unsigned long flags;
  2910. if (orinoco_lock(priv, &flags) != 0)
  2911. return -EBUSY;
  2912. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_SHORTRETRYLIMIT,
  2913. &short_limit);
  2914. if (err)
  2915. goto out;
  2916. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_LONGRETRYLIMIT,
  2917. &long_limit);
  2918. if (err)
  2919. goto out;
  2920. err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_MAXTRANSMITLIFETIME,
  2921. &lifetime);
  2922. if (err)
  2923. goto out;
  2924. rrq->disabled = 0; /* Can't be disabled */
  2925. /* Note : by default, display the retry number */
  2926. if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
  2927. rrq->flags = IW_RETRY_LIFETIME;
  2928. rrq->value = lifetime * 1000; /* ??? */
  2929. } else {
  2930. /* By default, display the min number */
  2931. if ((rrq->flags & IW_RETRY_MAX)) {
  2932. rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
  2933. rrq->value = long_limit;
  2934. } else {
  2935. rrq->flags = IW_RETRY_LIMIT;
  2936. rrq->value = short_limit;
  2937. if(short_limit != long_limit)
  2938. rrq->flags |= IW_RETRY_MIN;
  2939. }
  2940. }
  2941. out:
  2942. orinoco_unlock(priv, &flags);
  2943. return err;
  2944. }
  2945. static int orinoco_ioctl_setibssport(struct net_device *dev, struct iwreq *wrq)
  2946. {
  2947. struct orinoco_private *priv = netdev_priv(dev);
  2948. int val = *( (int *) wrq->u.name );
  2949. unsigned long flags;
  2950. if (orinoco_lock(priv, &flags) != 0)
  2951. return -EBUSY;
  2952. priv->ibss_port = val ;
  2953. /* Actually update the mode we are using */
  2954. set_port_type(priv);
  2955. orinoco_unlock(priv, &flags);
  2956. return 0;
  2957. }
  2958. static int orinoco_ioctl_getibssport(struct net_device *dev, struct iwreq *wrq)
  2959. {
  2960. struct orinoco_private *priv = netdev_priv(dev);
  2961. int *val = (int *)wrq->u.name;
  2962. unsigned long flags;
  2963. if (orinoco_lock(priv, &flags) != 0)
  2964. return -EBUSY;
  2965. *val = priv->ibss_port;
  2966. orinoco_unlock(priv, &flags);
  2967. return 0;
  2968. }
  2969. static int orinoco_ioctl_setport3(struct net_device *dev, struct iwreq *wrq)
  2970. {
  2971. struct orinoco_private *priv = netdev_priv(dev);
  2972. int val = *( (int *) wrq->u.name );
  2973. int err = 0;
  2974. unsigned long flags;
  2975. if (orinoco_lock(priv, &flags) != 0)
  2976. return -EBUSY;
  2977. switch (val) {
  2978. case 0: /* Try to do IEEE ad-hoc mode */
  2979. if (! priv->has_ibss) {
  2980. err = -EINVAL;
  2981. break;
  2982. }
  2983. priv->prefer_port3 = 0;
  2984. break;
  2985. case 1: /* Try to do Lucent proprietary ad-hoc mode */
  2986. if (! priv->has_port3) {
  2987. err = -EINVAL;
  2988. break;
  2989. }
  2990. priv->prefer_port3 = 1;
  2991. break;
  2992. default:
  2993. err = -EINVAL;
  2994. }
  2995. if (! err)
  2996. /* Actually update the mode we are using */
  2997. set_port_type(priv);
  2998. orinoco_unlock(priv, &flags);
  2999. return err;
  3000. }
  3001. static int orinoco_ioctl_getport3(struct net_device *dev, struct iwreq *wrq)
  3002. {
  3003. struct orinoco_private *priv = netdev_priv(dev);
  3004. int *val = (int *)wrq->u.name;
  3005. unsigned long flags;
  3006. if (orinoco_lock(priv, &flags) != 0)
  3007. return -EBUSY;
  3008. *val = priv->prefer_port3;
  3009. orinoco_unlock(priv, &flags);
  3010. return 0;
  3011. }
  3012. /* Spy is used for link quality/strength measurements in Ad-Hoc mode
  3013. * Jean II */
  3014. static int orinoco_ioctl_setspy(struct net_device *dev, struct iw_point *srq)
  3015. {
  3016. struct orinoco_private *priv = netdev_priv(dev);
  3017. struct sockaddr address[IW_MAX_SPY];
  3018. int number = srq->length;
  3019. int i;
  3020. int err = 0;
  3021. unsigned long flags;
  3022. /* Check the number of addresses */
  3023. if (number > IW_MAX_SPY)
  3024. return -E2BIG;
  3025. /* Get the data in the driver */
  3026. if (srq->pointer) {
  3027. if (copy_from_user(address, srq->pointer,
  3028. sizeof(struct sockaddr) * number))
  3029. return -EFAULT;
  3030. }
  3031. /* Make sure nobody mess with the structure while we do */
  3032. if (orinoco_lock(priv, &flags) != 0)
  3033. return -EBUSY;
  3034. /* orinoco_lock() doesn't disable interrupts, so make sure the
  3035. * interrupt rx path don't get confused while we copy */
  3036. priv->spy_number = 0;
  3037. if (number > 0) {
  3038. /* Extract the addresses */
  3039. for (i = 0; i < number; i++)
  3040. memcpy(priv->spy_address[i], address[i].sa_data,
  3041. ETH_ALEN);
  3042. /* Reset stats */
  3043. memset(priv->spy_stat, 0,
  3044. sizeof(struct iw_quality) * IW_MAX_SPY);
  3045. /* Set number of addresses */
  3046. priv->spy_number = number;
  3047. }
  3048. /* Now, let the others play */
  3049. orinoco_unlock(priv, &flags);
  3050. return err;
  3051. }
  3052. static int orinoco_ioctl_getspy(struct net_device *dev, struct iw_point *srq)
  3053. {
  3054. struct orinoco_private *priv = netdev_priv(dev);
  3055. struct sockaddr address[IW_MAX_SPY];
  3056. struct iw_quality spy_stat[IW_MAX_SPY];
  3057. int number;
  3058. int i;
  3059. unsigned long flags;
  3060. if (orinoco_lock(priv, &flags) != 0)
  3061. return -EBUSY;
  3062. number = priv->spy_number;
  3063. if ((number > 0) && (srq->pointer)) {
  3064. /* Create address struct */
  3065. for (i = 0; i < number; i++) {
  3066. memcpy(address[i].sa_data, priv->spy_address[i],
  3067. ETH_ALEN);
  3068. address[i].sa_family = AF_UNIX;
  3069. }
  3070. /* Copy stats */
  3071. /* In theory, we should disable irqs while copying the stats
  3072. * because the rx path might update it in the middle...
  3073. * Bah, who care ? - Jean II */
  3074. memcpy(&spy_stat, priv->spy_stat,
  3075. sizeof(struct iw_quality) * IW_MAX_SPY);
  3076. for (i=0; i < number; i++)
  3077. priv->spy_stat[i].updated = 0;
  3078. }
  3079. orinoco_unlock(priv, &flags);
  3080. /* Push stuff to user space */
  3081. srq->length = number;
  3082. if(copy_to_user(srq->pointer, address,
  3083. sizeof(struct sockaddr) * number))
  3084. return -EFAULT;
  3085. if(copy_to_user(srq->pointer + (sizeof(struct sockaddr)*number),
  3086. &spy_stat, sizeof(struct iw_quality) * number))
  3087. return -EFAULT;
  3088. return 0;
  3089. }
  3090. static int
  3091. orinoco_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  3092. {
  3093. struct orinoco_private *priv = netdev_priv(dev);
  3094. struct iwreq *wrq = (struct iwreq *)rq;
  3095. int err = 0;
  3096. int tmp;
  3097. int changed = 0;
  3098. unsigned long flags;
  3099. TRACE_ENTER(dev->name);
  3100. /* In theory, we could allow most of the the SET stuff to be
  3101. * done. In practice, the lapse of time at startup when the
  3102. * card is not ready is very short, so why bother... Note
  3103. * that netif_device_present is different from up/down
  3104. * (ifconfig), when the device is not yet up, it is usually
  3105. * already ready... Jean II */
  3106. if (! netif_device_present(dev))
  3107. return -ENODEV;
  3108. switch (cmd) {
  3109. case SIOCGIWNAME:
  3110. strcpy(wrq->u.name, "IEEE 802.11-DS");
  3111. break;
  3112. case SIOCGIWAP:
  3113. wrq->u.ap_addr.sa_family = ARPHRD_ETHER;
  3114. err = orinoco_hw_get_bssid(priv, wrq->u.ap_addr.sa_data);
  3115. break;
  3116. case SIOCGIWRANGE:
  3117. err = orinoco_ioctl_getiwrange(dev, &wrq->u.data);
  3118. break;
  3119. case SIOCSIWMODE:
  3120. if (orinoco_lock(priv, &flags) != 0)
  3121. return -EBUSY;
  3122. switch (wrq->u.mode) {
  3123. case IW_MODE_ADHOC:
  3124. if (! (priv->has_ibss || priv->has_port3) )
  3125. err = -EINVAL;
  3126. else {
  3127. priv->iw_mode = IW_MODE_ADHOC;
  3128. changed = 1;
  3129. }
  3130. break;
  3131. case IW_MODE_INFRA:
  3132. priv->iw_mode = IW_MODE_INFRA;
  3133. changed = 1;
  3134. break;
  3135. default:
  3136. err = -EINVAL;
  3137. break;
  3138. }
  3139. set_port_type(priv);
  3140. orinoco_unlock(priv, &flags);
  3141. break;
  3142. case SIOCGIWMODE:
  3143. if (orinoco_lock(priv, &flags) != 0)
  3144. return -EBUSY;
  3145. wrq->u.mode = priv->iw_mode;
  3146. orinoco_unlock(priv, &flags);
  3147. break;
  3148. case SIOCSIWENCODE:
  3149. err = orinoco_ioctl_setiwencode(dev, &wrq->u.encoding);
  3150. if (! err)
  3151. changed = 1;
  3152. break;
  3153. case SIOCGIWENCODE:
  3154. if (! capable(CAP_NET_ADMIN)) {
  3155. err = -EPERM;
  3156. break;
  3157. }
  3158. err = orinoco_ioctl_getiwencode(dev, &wrq->u.encoding);
  3159. break;
  3160. case SIOCSIWESSID:
  3161. err = orinoco_ioctl_setessid(dev, &wrq->u.essid);
  3162. if (! err)
  3163. changed = 1;
  3164. break;
  3165. case SIOCGIWESSID:
  3166. err = orinoco_ioctl_getessid(dev, &wrq->u.essid);
  3167. break;
  3168. case SIOCSIWNICKN:
  3169. err = orinoco_ioctl_setnick(dev, &wrq->u.data);
  3170. if (! err)
  3171. changed = 1;
  3172. break;
  3173. case SIOCGIWNICKN:
  3174. err = orinoco_ioctl_getnick(dev, &wrq->u.data);
  3175. break;
  3176. case SIOCGIWFREQ:
  3177. tmp = orinoco_hw_get_freq(priv);
  3178. if (tmp < 0) {
  3179. err = tmp;
  3180. } else {
  3181. wrq->u.freq.m = tmp;
  3182. wrq->u.freq.e = 1;
  3183. }
  3184. break;
  3185. case SIOCSIWFREQ:
  3186. err = orinoco_ioctl_setfreq(dev, &wrq->u.freq);
  3187. if (! err)
  3188. changed = 1;
  3189. break;
  3190. case SIOCGIWSENS:
  3191. err = orinoco_ioctl_getsens(dev, &wrq->u.sens);
  3192. break;
  3193. case SIOCSIWSENS:
  3194. err = orinoco_ioctl_setsens(dev, &wrq->u.sens);
  3195. if (! err)
  3196. changed = 1;
  3197. break;
  3198. case SIOCGIWRTS:
  3199. wrq->u.rts.value = priv->rts_thresh;
  3200. wrq->u.rts.disabled = (wrq->u.rts.value == 2347);
  3201. wrq->u.rts.fixed = 1;
  3202. break;
  3203. case SIOCSIWRTS:
  3204. err = orinoco_ioctl_setrts(dev, &wrq->u.rts);
  3205. if (! err)
  3206. changed = 1;
  3207. break;
  3208. case SIOCSIWFRAG:
  3209. err = orinoco_ioctl_setfrag(dev, &wrq->u.frag);
  3210. if (! err)
  3211. changed = 1;
  3212. break;
  3213. case SIOCGIWFRAG:
  3214. err = orinoco_ioctl_getfrag(dev, &wrq->u.frag);
  3215. break;
  3216. case SIOCSIWRATE:
  3217. err = orinoco_ioctl_setrate(dev, &wrq->u.bitrate);
  3218. if (! err)
  3219. changed = 1;
  3220. break;
  3221. case SIOCGIWRATE:
  3222. err = orinoco_ioctl_getrate(dev, &wrq->u.bitrate);
  3223. break;
  3224. case SIOCSIWPOWER:
  3225. err = orinoco_ioctl_setpower(dev, &wrq->u.power);
  3226. if (! err)
  3227. changed = 1;
  3228. break;
  3229. case SIOCGIWPOWER:
  3230. err = orinoco_ioctl_getpower(dev, &wrq->u.power);
  3231. break;
  3232. case SIOCGIWTXPOW:
  3233. /* The card only supports one tx power, so this is easy */
  3234. wrq->u.txpower.value = 15; /* dBm */
  3235. wrq->u.txpower.fixed = 1;
  3236. wrq->u.txpower.disabled = 0;
  3237. wrq->u.txpower.flags = IW_TXPOW_DBM;
  3238. break;
  3239. case SIOCSIWRETRY:
  3240. err = -EOPNOTSUPP;
  3241. break;
  3242. case SIOCGIWRETRY:
  3243. err = orinoco_ioctl_getretry(dev, &wrq->u.retry);
  3244. break;
  3245. case SIOCSIWSPY:
  3246. err = orinoco_ioctl_setspy(dev, &wrq->u.data);
  3247. break;
  3248. case SIOCGIWSPY:
  3249. err = orinoco_ioctl_getspy(dev, &wrq->u.data);
  3250. break;
  3251. case SIOCGIWPRIV:
  3252. if (wrq->u.data.pointer) {
  3253. struct iw_priv_args privtab[] = {
  3254. { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" },
  3255. { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
  3256. { SIOCIWFIRSTPRIV + 0x2,
  3257. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  3258. 0, "set_port3" },
  3259. { SIOCIWFIRSTPRIV + 0x3, 0,
  3260. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  3261. "get_port3" },
  3262. { SIOCIWFIRSTPRIV + 0x4,
  3263. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  3264. 0, "set_preamble" },
  3265. { SIOCIWFIRSTPRIV + 0x5, 0,
  3266. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  3267. "get_preamble" },
  3268. { SIOCIWFIRSTPRIV + 0x6,
  3269. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  3270. 0, "set_ibssport" },
  3271. { SIOCIWFIRSTPRIV + 0x7, 0,
  3272. IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
  3273. "get_ibssport" },
  3274. };
  3275. wrq->u.data.length = sizeof(privtab) / sizeof(privtab[0]);
  3276. if (copy_to_user(wrq->u.data.pointer, privtab, sizeof(privtab)))
  3277. err = -EFAULT;
  3278. }
  3279. break;
  3280. case SIOCIWFIRSTPRIV + 0x0: /* force_reset */
  3281. case SIOCIWFIRSTPRIV + 0x1: /* card_reset */
  3282. if (! capable(CAP_NET_ADMIN)) {
  3283. err = -EPERM;
  3284. break;
  3285. }
  3286. printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
  3287. schedule_work(&priv->reset_work);
  3288. break;
  3289. case SIOCIWFIRSTPRIV + 0x2: /* set_port3 */
  3290. if (! capable(CAP_NET_ADMIN)) {
  3291. err = -EPERM;
  3292. break;
  3293. }
  3294. err = orinoco_ioctl_setport3(dev, wrq);
  3295. if (! err)
  3296. changed = 1;
  3297. break;
  3298. case SIOCIWFIRSTPRIV + 0x3: /* get_port3 */
  3299. err = orinoco_ioctl_getport3(dev, wrq);
  3300. break;
  3301. case SIOCIWFIRSTPRIV + 0x4: /* set_preamble */
  3302. if (! capable(CAP_NET_ADMIN)) {
  3303. err = -EPERM;
  3304. break;
  3305. }
  3306. /* 802.11b has recently defined some short preamble.
  3307. * Basically, the Phy header has been reduced in size.
  3308. * This increase performance, especially at high rates
  3309. * (the preamble is transmitted at 1Mb/s), unfortunately
  3310. * this give compatibility troubles... - Jean II */
  3311. if(priv->has_preamble) {
  3312. int val = *( (int *) wrq->u.name );
  3313. if (orinoco_lock(priv, &flags) != 0)
  3314. return -EBUSY;
  3315. if (val)
  3316. priv->preamble = 1;
  3317. else
  3318. priv->preamble = 0;
  3319. orinoco_unlock(priv, &flags);
  3320. changed = 1;
  3321. } else
  3322. err = -EOPNOTSUPP;
  3323. break;
  3324. case SIOCIWFIRSTPRIV + 0x5: /* get_preamble */
  3325. if(priv->has_preamble) {
  3326. int *val = (int *)wrq->u.name;
  3327. if (orinoco_lock(priv, &flags) != 0)
  3328. return -EBUSY;
  3329. *val = priv->preamble;
  3330. orinoco_unlock(priv, &flags);
  3331. } else
  3332. err = -EOPNOTSUPP;
  3333. break;
  3334. case SIOCIWFIRSTPRIV + 0x6: /* set_ibssport */
  3335. if (! capable(CAP_NET_ADMIN)) {
  3336. err = -EPERM;
  3337. break;
  3338. }
  3339. err = orinoco_ioctl_setibssport(dev, wrq);
  3340. if (! err)
  3341. changed = 1;
  3342. break;
  3343. case SIOCIWFIRSTPRIV + 0x7: /* get_ibssport */
  3344. err = orinoco_ioctl_getibssport(dev, wrq);
  3345. break;
  3346. default:
  3347. err = -EOPNOTSUPP;
  3348. }
  3349. if (! err && changed && netif_running(dev)) {
  3350. err = orinoco_reconfigure(dev);
  3351. }
  3352. TRACE_EXIT(dev->name);
  3353. return err;
  3354. }
  3355. /********************************************************************/
  3356. /* Debugging */
  3357. /********************************************************************/
  3358. #if 0
  3359. static void show_rx_frame(struct orinoco_rxframe_hdr *frame)
  3360. {
  3361. printk(KERN_DEBUG "RX descriptor:\n");
  3362. printk(KERN_DEBUG " status = 0x%04x\n", frame->desc.status);
  3363. printk(KERN_DEBUG " time = 0x%08x\n", frame->desc.time);
  3364. printk(KERN_DEBUG " silence = 0x%02x\n", frame->desc.silence);
  3365. printk(KERN_DEBUG " signal = 0x%02x\n", frame->desc.signal);
  3366. printk(KERN_DEBUG " rate = 0x%02x\n", frame->desc.rate);
  3367. printk(KERN_DEBUG " rxflow = 0x%02x\n", frame->desc.rxflow);
  3368. printk(KERN_DEBUG " reserved = 0x%08x\n", frame->desc.reserved);
  3369. printk(KERN_DEBUG "IEEE 802.11 header:\n");
  3370. printk(KERN_DEBUG " frame_ctl = 0x%04x\n",
  3371. frame->p80211.frame_ctl);
  3372. printk(KERN_DEBUG " duration_id = 0x%04x\n",
  3373. frame->p80211.duration_id);
  3374. printk(KERN_DEBUG " addr1 = %02x:%02x:%02x:%02x:%02x:%02x\n",
  3375. frame->p80211.addr1[0], frame->p80211.addr1[1],
  3376. frame->p80211.addr1[2], frame->p80211.addr1[3],
  3377. frame->p80211.addr1[4], frame->p80211.addr1[5]);
  3378. printk(KERN_DEBUG " addr2 = %02x:%02x:%02x:%02x:%02x:%02x\n",
  3379. frame->p80211.addr2[0], frame->p80211.addr2[1],
  3380. frame->p80211.addr2[2], frame->p80211.addr2[3],
  3381. frame->p80211.addr2[4], frame->p80211.addr2[5]);
  3382. printk(KERN_DEBUG " addr3 = %02x:%02x:%02x:%02x:%02x:%02x\n",
  3383. frame->p80211.addr3[0], frame->p80211.addr3[1],
  3384. frame->p80211.addr3[2], frame->p80211.addr3[3],
  3385. frame->p80211.addr3[4], frame->p80211.addr3[5]);
  3386. printk(KERN_DEBUG " seq_ctl = 0x%04x\n",
  3387. frame->p80211.seq_ctl);
  3388. printk(KERN_DEBUG " addr4 = %02x:%02x:%02x:%02x:%02x:%02x\n",
  3389. frame->p80211.addr4[0], frame->p80211.addr4[1],
  3390. frame->p80211.addr4[2], frame->p80211.addr4[3],
  3391. frame->p80211.addr4[4], frame->p80211.addr4[5]);
  3392. printk(KERN_DEBUG " data_len = 0x%04x\n",
  3393. frame->p80211.data_len);
  3394. printk(KERN_DEBUG "IEEE 802.3 header:\n");
  3395. printk(KERN_DEBUG " dest = %02x:%02x:%02x:%02x:%02x:%02x\n",
  3396. frame->p8023.h_dest[0], frame->p8023.h_dest[1],
  3397. frame->p8023.h_dest[2], frame->p8023.h_dest[3],
  3398. frame->p8023.h_dest[4], frame->p8023.h_dest[5]);
  3399. printk(KERN_DEBUG " src = %02x:%02x:%02x:%02x:%02x:%02x\n",
  3400. frame->p8023.h_source[0], frame->p8023.h_source[1],
  3401. frame->p8023.h_source[2], frame->p8023.h_source[3],
  3402. frame->p8023.h_source[4], frame->p8023.h_source[5]);
  3403. printk(KERN_DEBUG " len = 0x%04x\n", frame->p8023.h_proto);
  3404. printk(KERN_DEBUG "IEEE 802.2 LLC/SNAP header:\n");
  3405. printk(KERN_DEBUG " DSAP = 0x%02x\n", frame->p8022.dsap);
  3406. printk(KERN_DEBUG " SSAP = 0x%02x\n", frame->p8022.ssap);
  3407. printk(KERN_DEBUG " ctrl = 0x%02x\n", frame->p8022.ctrl);
  3408. printk(KERN_DEBUG " OUI = %02x:%02x:%02x\n",
  3409. frame->p8022.oui[0], frame->p8022.oui[1], frame->p8022.oui[2]);
  3410. printk(KERN_DEBUG " ethertype = 0x%04x\n", frame->ethertype);
  3411. }
  3412. #endif /* 0 */
  3413. /********************************************************************/
  3414. /* Module initialization */
  3415. /********************************************************************/
  3416. EXPORT_SYMBOL(alloc_orinocodev);
  3417. EXPORT_SYMBOL(free_orinocodev);
  3418. EXPORT_SYMBOL(__orinoco_up);
  3419. EXPORT_SYMBOL(__orinoco_down);
  3420. EXPORT_SYMBOL(orinoco_stop);
  3421. EXPORT_SYMBOL(orinoco_reinit_firmware);
  3422. EXPORT_SYMBOL(orinoco_interrupt);
  3423. /* Can't be declared "const" or the whole __initdata section will
  3424. * become const */
  3425. static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
  3426. " (David Gibson <hermes@gibson.dropbear.id.au>, "
  3427. "Pavel Roskin <proski@gnu.org>, et al)";
  3428. static int __init init_orinoco(void)
  3429. {
  3430. printk(KERN_DEBUG "%s\n", version);
  3431. return 0;
  3432. }
  3433. static void __exit exit_orinoco(void)
  3434. {
  3435. }
  3436. module_init(init_orinoco);
  3437. module_exit(exit_orinoco);