| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938 |
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/Kconfig linux-6.18.9/drivers/net/wireless/intersil/Kconfig
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/Kconfig 2026-02-06 16:57:45.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/Kconfig 2026-02-16 14:00:36.619256404 +0100
- @@ -12,6 +12,7 @@
-
- if WLAN_VENDOR_INTERSIL
-
- +source "drivers/net/wireless/intersil/orinoco/Kconfig"
- source "drivers/net/wireless/intersil/p54/Kconfig"
-
- endif # WLAN_VENDOR_INTERSIL
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/Makefile linux-6.18.9/drivers/net/wireless/intersil/Makefile
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/Makefile 2026-02-06 16:57:45.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/Makefile 2026-02-16 14:00:36.619256404 +0100
- @@ -1,2 +1,3 @@
- # SPDX-License-Identifier: GPL-2.0-only
- +obj-$(CONFIG_HERMES) += orinoco/
- obj-$(CONFIG_P54_COMMON) += p54/
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/airport.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/airport.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/airport.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/airport.c 2026-02-16 14:00:36.619256404 +0100
- @@ -0,0 +1,268 @@
- +/* airport.c
- + *
- + * A driver for "Hermes" chipset based Apple Airport wireless
- + * card.
- + *
- + * Copyright notice & release notes in file main.c
- + *
- + * Note specific to airport stub:
- + *
- + * 0.05 : first version of the new split driver
- + * 0.06 : fix possible hang on powerup, add sleep support
- + */
- +
- +#define DRIVER_NAME "airport"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/init.h>
- +#include <linux/delay.h>
- +#include <linux/mod_devicetable.h>
- +#include <asm/pmac_feature.h>
- +
- +#include "orinoco.h"
- +
- +#define AIRPORT_IO_LEN (0x1000) /* one page */
- +
- +struct airport {
- + struct macio_dev *mdev;
- + void __iomem *vaddr;
- + unsigned int irq;
- + int irq_requested;
- + int ndev_registered;
- +};
- +
- +static int
- +airport_suspend(struct macio_dev *mdev, pm_message_t state)
- +{
- + struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev);
- + struct net_device *dev = priv->ndev;
- + struct airport *card = priv->card;
- + unsigned long flags;
- + int err;
- +
- + printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
- +
- + err = orinoco_lock(priv, &flags);
- + if (err) {
- + printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
- + dev->name);
- + return 0;
- + }
- +
- + orinoco_down(priv);
- + orinoco_unlock(priv, &flags);
- +
- + disable_irq(card->irq);
- + pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
- + macio_get_of_node(mdev), 0, 0);
- +
- + return 0;
- +}
- +
- +static int
- +airport_resume(struct macio_dev *mdev)
- +{
- + struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev);
- + struct net_device *dev = priv->ndev;
- + struct airport *card = priv->card;
- + unsigned long flags;
- + int err;
- +
- + printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
- +
- + pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
- + macio_get_of_node(mdev), 0, 1);
- + msleep(200);
- +
- + enable_irq(card->irq);
- +
- + priv->hw.ops->lock_irqsave(&priv->lock, &flags);
- + err = orinoco_up(priv);
- + priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
- +
- + return err;
- +}
- +
- +static int
- +airport_detach(struct macio_dev *mdev)
- +{
- + struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev);
- + struct airport *card = priv->card;
- +
- + if (card->ndev_registered)
- + orinoco_if_del(priv);
- + card->ndev_registered = 0;
- +
- + if (card->irq_requested)
- + free_irq(card->irq, priv);
- + card->irq_requested = 0;
- +
- + if (card->vaddr)
- + iounmap(card->vaddr);
- + card->vaddr = NULL;
- +
- + macio_release_resource(mdev, 0);
- +
- + pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
- + macio_get_of_node(mdev), 0, 0);
- + ssleep(1);
- +
- + macio_set_drvdata(mdev, NULL);
- + free_orinocodev(priv);
- +
- + return 0;
- +}
- +
- +static int airport_hard_reset(struct orinoco_private *priv)
- +{
- + /* It would be nice to power cycle the Airport for a real hard
- + * reset, but for some reason although it appears to
- + * re-initialize properly, it falls in a screaming heap
- + * shortly afterwards. */
- +#if 0
- + struct airport *card = priv->card;
- +
- + /* Vitally important. If we don't do this it seems we get an
- + * interrupt somewhere during the power cycle, since
- + * hw_unavailable is already set it doesn't get ACKed, we get
- + * into an interrupt loop and the PMU decides to turn us
- + * off. */
- + disable_irq(card->irq);
- +
- + pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
- + macio_get_of_node(card->mdev), 0, 0);
- + ssleep(1);
- + pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
- + macio_get_of_node(card->mdev), 0, 1);
- + ssleep(1);
- +
- + enable_irq(card->irq);
- + ssleep(1);
- +#endif
- +
- + return 0;
- +}
- +
- +static int
- +airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
- +{
- + struct orinoco_private *priv;
- + struct airport *card;
- + unsigned long phys_addr;
- + struct hermes *hw;
- +
- + if (macio_resource_count(mdev) < 1 || macio_irq_count(mdev) < 1) {
- + printk(KERN_ERR PFX "Wrong interrupt/addresses in OF tree\n");
- + return -ENODEV;
- + }
- +
- + /* Allocate space for private device-specific data */
- + priv = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev,
- + airport_hard_reset, NULL);
- + if (!priv) {
- + printk(KERN_ERR PFX "Cannot allocate network device\n");
- + return -ENODEV;
- + }
- + card = priv->card;
- +
- + hw = &priv->hw;
- + card->mdev = mdev;
- +
- + if (macio_request_resource(mdev, 0, DRIVER_NAME)) {
- + printk(KERN_ERR PFX "can't request IO resource !\n");
- + free_orinocodev(priv);
- + return -EBUSY;
- + }
- +
- + macio_set_drvdata(mdev, priv);
- +
- + /* Setup interrupts & base address */
- + card->irq = macio_irq(mdev, 0);
- + phys_addr = macio_resource_start(mdev, 0); /* Physical address */
- + printk(KERN_DEBUG PFX "Physical address %lx\n", phys_addr);
- + card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN);
- + if (!card->vaddr) {
- + printk(KERN_ERR PFX "ioremap() failed\n");
- + goto failed;
- + }
- +
- + hermes_struct_init(hw, card->vaddr, HERMES_16BIT_REGSPACING);
- +
- + /* Power up card */
- + pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
- + macio_get_of_node(mdev), 0, 1);
- + ssleep(1);
- +
- + /* Reset it before we get the interrupt */
- + hw->ops->init(hw);
- +
- + if (request_irq(card->irq, orinoco_interrupt, 0, DRIVER_NAME, priv)) {
- + printk(KERN_ERR PFX "Couldn't get IRQ %d\n", card->irq);
- + goto failed;
- + }
- + card->irq_requested = 1;
- +
- + /* Initialise the main driver */
- + if (orinoco_init(priv) != 0) {
- + printk(KERN_ERR PFX "orinoco_init() failed\n");
- + goto failed;
- + }
- +
- + /* Register an interface with the stack */
- + if (orinoco_if_add(priv, phys_addr, card->irq, NULL) != 0) {
- + printk(KERN_ERR PFX "orinoco_if_add() failed\n");
- + goto failed;
- + }
- + card->ndev_registered = 1;
- + return 0;
- + failed:
- + airport_detach(mdev);
- + return -ENODEV;
- +} /* airport_attach */
- +
- +
- +static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
- + " (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
- +MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
- +MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +static const struct of_device_id airport_match[] = {
- + {
- + .name = "radio",
- + },
- + {},
- +};
- +
- +MODULE_DEVICE_TABLE(of, airport_match);
- +
- +static struct macio_driver airport_driver = {
- + .driver = {
- + .name = DRIVER_NAME,
- + .owner = THIS_MODULE,
- + .of_match_table = airport_match,
- + },
- + .probe = airport_attach,
- + .remove = airport_detach,
- + .suspend = airport_suspend,
- + .resume = airport_resume,
- +};
- +
- +static int __init
- +init_airport(void)
- +{
- + printk(KERN_DEBUG "%s\n", version);
- +
- + return macio_register_driver(&airport_driver);
- +}
- +
- +static void __exit
- +exit_airport(void)
- +{
- + macio_unregister_driver(&airport_driver);
- +}
- +
- +module_init(init_airport);
- +module_exit(exit_airport);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/cfg.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/cfg.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/cfg.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/cfg.c 2026-02-16 14:03:20.553871680 +0100
- @@ -0,0 +1,297 @@
- +/* cfg80211 support
- + *
- + * See copyright notice in main.c
- + */
- +#include <linux/ieee80211.h>
- +#include <net/cfg80211.h>
- +#include "hw.h"
- +#include "main.h"
- +#include "orinoco.h"
- +
- +#include "cfg.h"
- +
- +/* Supported bitrates. Must agree with hw.c */
- +static struct ieee80211_rate orinoco_rates[] = {
- + { .bitrate = 10 },
- + { .bitrate = 20 },
- + { .bitrate = 55 },
- + { .bitrate = 110 },
- +};
- +
- +static const void * const orinoco_wiphy_privid = &orinoco_wiphy_privid;
- +
- +/* Called after orinoco_private is allocated. */
- +void orinoco_wiphy_init(struct wiphy *wiphy)
- +{
- + struct orinoco_private *priv = wiphy_priv(wiphy);
- +
- + wiphy->privid = orinoco_wiphy_privid;
- +
- + set_wiphy_dev(wiphy, priv->dev);
- +}
- +
- +/* Called after firmware is initialised */
- +int orinoco_wiphy_register(struct wiphy *wiphy)
- +{
- + struct orinoco_private *priv = wiphy_priv(wiphy);
- + int i, channels = 0;
- +
- + if (priv->firmware_type == FIRMWARE_TYPE_AGERE)
- + wiphy->max_scan_ssids = 1;
- + else
- + wiphy->max_scan_ssids = 0;
- +
- + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
- +
- + /* TODO: should we set if we only have demo ad-hoc?
- + * (priv->has_port3)
- + */
- + if (priv->has_ibss)
- + wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC);
- +
- + if (!priv->broken_monitor || force_monitor)
- + wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
- +
- + priv->band.bitrates = orinoco_rates;
- + priv->band.n_bitrates = ARRAY_SIZE(orinoco_rates);
- +
- + /* Only support channels allowed by the card EEPROM */
- + for (i = 0; i < NUM_CHANNELS; i++) {
- + if (priv->channel_mask & (1 << i)) {
- + priv->channels[i].center_freq =
- + ieee80211_channel_to_frequency(i + 1,
- + NL80211_BAND_2GHZ);
- + channels++;
- + }
- + }
- + priv->band.channels = priv->channels;
- + priv->band.n_channels = channels;
- +
- + wiphy->bands[NL80211_BAND_2GHZ] = &priv->band;
- + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
- +
- + i = 0;
- + if (priv->has_wep) {
- + priv->cipher_suites[i] = WLAN_CIPHER_SUITE_WEP40;
- + i++;
- +
- + if (priv->has_big_wep) {
- + priv->cipher_suites[i] = WLAN_CIPHER_SUITE_WEP104;
- + i++;
- + }
- + }
- + if (priv->has_wpa) {
- + priv->cipher_suites[i] = WLAN_CIPHER_SUITE_TKIP;
- + i++;
- + }
- + wiphy->cipher_suites = priv->cipher_suites;
- + wiphy->n_cipher_suites = i;
- +
- + wiphy->rts_threshold = priv->rts_thresh;
- + if (!priv->has_mwo)
- + wiphy->frag_threshold = priv->frag_thresh + 1;
- + wiphy->retry_short = priv->short_retry_limit;
- + wiphy->retry_long = priv->long_retry_limit;
- +
- + return wiphy_register(wiphy);
- +}
- +
- +static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev,
- + enum nl80211_iftype type,
- + struct vif_params *params)
- +{
- + struct orinoco_private *priv = wiphy_priv(wiphy);
- + int err = 0;
- + unsigned long lock;
- +
- + if (orinoco_lock(priv, &lock) != 0)
- + return -EBUSY;
- +
- + switch (type) {
- + case NL80211_IFTYPE_ADHOC:
- + if (!priv->has_ibss && !priv->has_port3)
- + err = -EINVAL;
- + break;
- +
- + case NL80211_IFTYPE_STATION:
- + break;
- +
- + case NL80211_IFTYPE_MONITOR:
- + if (priv->broken_monitor && !force_monitor) {
- + wiphy_warn(wiphy,
- + "Monitor mode support is buggy in this firmware, not enabling\n");
- + err = -EINVAL;
- + }
- + break;
- +
- + default:
- + err = -EINVAL;
- + }
- +
- + if (!err) {
- + priv->iw_mode = type;
- + set_port_type(priv);
- + err = orinoco_commit(priv);
- + }
- +
- + orinoco_unlock(priv, &lock);
- +
- + return err;
- +}
- +
- +static int orinoco_scan(struct wiphy *wiphy,
- + struct cfg80211_scan_request *request)
- +{
- + struct orinoco_private *priv = wiphy_priv(wiphy);
- + int err;
- +
- + if (!request)
- + return -EINVAL;
- +
- + if (priv->scan_request && priv->scan_request != request)
- + return -EBUSY;
- +
- + priv->scan_request = request;
- +
- + err = orinoco_hw_trigger_scan(priv, request->ssids);
- + /* On error the we aren't processing the request */
- + if (err)
- + priv->scan_request = NULL;
- +
- + return err;
- +}
- +
- +static int orinoco_set_monitor_channel(struct wiphy *wiphy,
- + struct net_device *dev,
- + struct cfg80211_chan_def *chandef)
- +{
- + struct orinoco_private *priv = wiphy_priv(wiphy);
- + int err = 0;
- + unsigned long flags;
- + int channel;
- +
- + if (!chandef->chan)
- + return -EINVAL;
- +
- + if (cfg80211_get_chandef_type(chandef) != NL80211_CHAN_NO_HT)
- + return -EINVAL;
- +
- + if (chandef->chan->band != NL80211_BAND_2GHZ)
- + return -EINVAL;
- +
- + channel = ieee80211_frequency_to_channel(chandef->chan->center_freq);
- +
- + if ((channel < 1) || (channel > NUM_CHANNELS) ||
- + !(priv->channel_mask & (1 << (channel - 1))))
- + return -EINVAL;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + priv->channel = channel;
- + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
- + /* Fast channel change - no commit if successful */
- + struct hermes *hw = &priv->hw;
- + err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
- + HERMES_TEST_SET_CHANNEL,
- + channel, NULL);
- + }
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_set_wiphy_params(struct wiphy *wiphy,
- + int radio_idx,
- + u32 changed)
- +{
- + struct orinoco_private *priv = wiphy_priv(wiphy);
- + int frag_value = -1;
- + int rts_value = -1;
- + int err = 0;
- +
- + if (radio_idx != 0)
- + return -EINVAL;
- +
- + if (changed & WIPHY_PARAM_RETRY_SHORT) {
- + /* Setting short retry not supported */
- + err = -EINVAL;
- + }
- +
- + if (changed & WIPHY_PARAM_RETRY_LONG) {
- + /* Setting long retry not supported */
- + err = -EINVAL;
- + }
- +
- + if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
- + /* Set fragmentation */
- + if (priv->has_mwo) {
- + if (wiphy->frag_threshold == -1)
- + frag_value = 0;
- + else {
- + printk(KERN_WARNING "%s: Fixed fragmentation "
- + "is not supported on this firmware. "
- + "Using MWO robust instead.\n",
- + priv->ndev->name);
- + frag_value = 1;
- + }
- + } else {
- + if (wiphy->frag_threshold == -1)
- + frag_value = 2346;
- + else if ((wiphy->frag_threshold < 257) ||
- + (wiphy->frag_threshold > 2347))
- + err = -EINVAL;
- + else
- + /* cfg80211 value is 257-2347 (odd only)
- + * orinoco rid has range 256-2346 (even only) */
- + frag_value = wiphy->frag_threshold & ~0x1;
- + }
- + }
- +
- + if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
- + /* Set RTS.
- + *
- + * Prism documentation suggests default of 2432,
- + * and a range of 0-3000.
- + *
- + * Current implementation uses 2347 as the default and
- + * the upper limit.
- + */
- +
- + if (wiphy->rts_threshold == -1)
- + rts_value = 2347;
- + else if (wiphy->rts_threshold > 2347)
- + err = -EINVAL;
- + else
- + rts_value = wiphy->rts_threshold;
- + }
- +
- + if (!err) {
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + if (frag_value >= 0) {
- + if (priv->has_mwo)
- + priv->mwo_robust = frag_value;
- + else
- + priv->frag_thresh = frag_value;
- + }
- + if (rts_value >= 0)
- + priv->rts_thresh = rts_value;
- +
- + err = orinoco_commit(priv);
- +
- + orinoco_unlock(priv, &flags);
- + }
- +
- + return err;
- +}
- +
- +const struct cfg80211_ops orinoco_cfg_ops = {
- + .change_virtual_intf = orinoco_change_vif,
- + .set_monitor_channel = orinoco_set_monitor_channel,
- + .scan = orinoco_scan,
- + .set_wiphy_params = orinoco_set_wiphy_params,
- +};
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/cfg.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/cfg.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/cfg.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/cfg.h 2026-02-16 14:00:36.619256404 +0100
- @@ -0,0 +1,15 @@
- +/* cfg80211 support.
- + *
- + * See copyright notice in main.c
- + */
- +#ifndef ORINOCO_CFG_H
- +#define ORINOCO_CFG_H
- +
- +#include <net/cfg80211.h>
- +
- +extern const struct cfg80211_ops orinoco_cfg_ops;
- +
- +void orinoco_wiphy_init(struct wiphy *wiphy);
- +int orinoco_wiphy_register(struct wiphy *wiphy);
- +
- +#endif /* ORINOCO_CFG_H */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/fw.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/fw.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/fw.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/fw.c 2026-02-16 14:00:36.619256404 +0100
- @@ -0,0 +1,387 @@
- +/* Firmware file reading and download helpers
- + *
- + * See copyright notice in main.c
- + */
- +#include <linux/kernel.h>
- +#include <linux/slab.h>
- +#include <linux/firmware.h>
- +#include <linux/device.h>
- +#include <linux/module.h>
- +
- +#include "hermes.h"
- +#include "hermes_dld.h"
- +#include "orinoco.h"
- +
- +#include "fw.h"
- +
- +/* End markers (for Symbol firmware only) */
- +#define TEXT_END 0x1A /* End of text header */
- +
- +struct fw_info {
- + char *pri_fw;
- + char *sta_fw;
- + char *ap_fw;
- + u32 pda_addr;
- + u16 pda_size;
- +};
- +
- +static const struct fw_info orinoco_fw[] = {
- + { NULL, "agere_sta_fw.bin", "agere_ap_fw.bin", 0x00390000, 1000 },
- + { NULL, "prism_sta_fw.bin", "prism_ap_fw.bin", 0, 1024 },
- + { "symbol_sp24t_prim_fw", "symbol_sp24t_sec_fw", NULL, 0x00003100, 512 }
- +};
- +MODULE_FIRMWARE("agere_sta_fw.bin");
- +MODULE_FIRMWARE("agere_ap_fw.bin");
- +MODULE_FIRMWARE("prism_sta_fw.bin");
- +MODULE_FIRMWARE("prism_ap_fw.bin");
- +MODULE_FIRMWARE("symbol_sp24t_prim_fw");
- +MODULE_FIRMWARE("symbol_sp24t_sec_fw");
- +
- +/* Structure used to access fields in FW
- + * Make sure LE decoding macros are used
- + */
- +struct orinoco_fw_header {
- + char hdr_vers[6]; /* ASCII string for header version */
- + __le16 headersize; /* Total length of header */
- + __le32 entry_point; /* NIC entry point */
- + __le32 blocks; /* Number of blocks to program */
- + __le32 block_offset; /* Offset of block data from eof header */
- + __le32 pdr_offset; /* Offset to PDR data from eof header */
- + __le32 pri_offset; /* Offset to primary plug data */
- + __le32 compat_offset; /* Offset to compatibility data*/
- + char signature[]; /* FW signature length headersize-20 */
- +} __packed;
- +
- +/* Check the range of various header entries. Return a pointer to a
- + * description of the problem, or NULL if everything checks out. */
- +static const char *validate_fw(const struct orinoco_fw_header *hdr, size_t len)
- +{
- + u16 hdrsize;
- +
- + if (len < sizeof(*hdr))
- + return "image too small";
- + if (memcmp(hdr->hdr_vers, "HFW", 3) != 0)
- + return "format not recognised";
- +
- + hdrsize = le16_to_cpu(hdr->headersize);
- + if (hdrsize > len)
- + return "bad headersize";
- + if ((hdrsize + le32_to_cpu(hdr->block_offset)) > len)
- + return "bad block offset";
- + if ((hdrsize + le32_to_cpu(hdr->pdr_offset)) > len)
- + return "bad PDR offset";
- + if ((hdrsize + le32_to_cpu(hdr->pri_offset)) > len)
- + return "bad PRI offset";
- + if ((hdrsize + le32_to_cpu(hdr->compat_offset)) > len)
- + return "bad compat offset";
- +
- + /* TODO: consider adding a checksum or CRC to the firmware format */
- + return NULL;
- +}
- +
- +#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
- +static inline const struct firmware *
- +orinoco_cached_fw_get(struct orinoco_private *priv, bool primary)
- +{
- + if (primary)
- + return priv->cached_pri_fw;
- + else
- + return priv->cached_fw;
- +}
- +#else
- +#define orinoco_cached_fw_get(priv, primary) (NULL)
- +#endif
- +
- +/* Download either STA or AP firmware into the card. */
- +static int
- +orinoco_dl_firmware(struct orinoco_private *priv,
- + const struct fw_info *fw,
- + int ap)
- +{
- + /* Plug Data Area (PDA) */
- + __le16 *pda;
- +
- + struct hermes *hw = &priv->hw;
- + const struct firmware *fw_entry;
- + const struct orinoco_fw_header *hdr;
- + const unsigned char *first_block;
- + const void *end;
- + const char *firmware;
- + const char *fw_err;
- + struct device *dev = priv->dev;
- + int err = 0;
- +
- + pda = kzalloc(fw->pda_size, GFP_KERNEL);
- + if (!pda)
- + return -ENOMEM;
- +
- + if (ap)
- + firmware = fw->ap_fw;
- + else
- + firmware = fw->sta_fw;
- +
- + dev_dbg(dev, "Attempting to download firmware %s\n", firmware);
- +
- + /* Read current plug data */
- + err = hw->ops->read_pda(hw, pda, fw->pda_addr, fw->pda_size);
- + dev_dbg(dev, "Read PDA returned %d\n", err);
- + if (err)
- + goto free;
- +
- + if (!orinoco_cached_fw_get(priv, false)) {
- + err = request_firmware(&fw_entry, firmware, priv->dev);
- +
- + if (err) {
- + dev_err(dev, "Cannot find firmware %s\n", firmware);
- + err = -ENOENT;
- + goto free;
- + }
- + } else
- + fw_entry = orinoco_cached_fw_get(priv, false);
- +
- + hdr = (const struct orinoco_fw_header *) fw_entry->data;
- +
- + fw_err = validate_fw(hdr, fw_entry->size);
- + if (fw_err) {
- + dev_warn(dev, "Invalid firmware image detected (%s). "
- + "Aborting download\n", fw_err);
- + err = -EINVAL;
- + goto abort;
- + }
- +
- + /* Enable aux port to allow programming */
- + err = hw->ops->program_init(hw, le32_to_cpu(hdr->entry_point));
- + dev_dbg(dev, "Program init returned %d\n", err);
- + if (err != 0)
- + goto abort;
- +
- + /* Program data */
- + first_block = (fw_entry->data +
- + le16_to_cpu(hdr->headersize) +
- + le32_to_cpu(hdr->block_offset));
- + end = fw_entry->data + fw_entry->size;
- +
- + err = hermes_program(hw, first_block, end);
- + dev_dbg(dev, "Program returned %d\n", err);
- + if (err != 0)
- + goto abort;
- +
- + /* Update production data */
- + first_block = (fw_entry->data +
- + le16_to_cpu(hdr->headersize) +
- + le32_to_cpu(hdr->pdr_offset));
- +
- + err = hermes_apply_pda_with_defaults(hw, first_block, end, pda,
- + &pda[fw->pda_size / sizeof(*pda)]);
- + dev_dbg(dev, "Apply PDA returned %d\n", err);
- + if (err)
- + goto abort;
- +
- + /* Tell card we've finished */
- + err = hw->ops->program_end(hw);
- + dev_dbg(dev, "Program end returned %d\n", err);
- + if (err != 0)
- + goto abort;
- +
- + /* Check if we're running */
- + dev_dbg(dev, "hermes_present returned %d\n", hermes_present(hw));
- +
- +abort:
- + /* If we requested the firmware, release it. */
- + if (!orinoco_cached_fw_get(priv, false))
- + release_firmware(fw_entry);
- +
- +free:
- + kfree(pda);
- + return err;
- +}
- +
- +/*
- + * Process a firmware image - stop the card, load the firmware, reset
- + * the card and make sure it responds. For the secondary firmware take
- + * care of the PDA - read it and then write it on top of the firmware.
- + */
- +static int
- +symbol_dl_image(struct orinoco_private *priv, const struct fw_info *fw,
- + const unsigned char *image, const void *end,
- + int secondary)
- +{
- + struct hermes *hw = &priv->hw;
- + int ret = 0;
- + const unsigned char *ptr;
- + const unsigned char *first_block;
- +
- + /* Plug Data Area (PDA) */
- + __le16 *pda = NULL;
- +
- + /* Binary block begins after the 0x1A marker */
- + ptr = image;
- + while (*ptr++ != TEXT_END);
- + first_block = ptr;
- +
- + /* Read the PDA from EEPROM */
- + if (secondary) {
- + pda = kzalloc(fw->pda_size, GFP_KERNEL);
- + if (!pda)
- + return -ENOMEM;
- +
- + ret = hw->ops->read_pda(hw, pda, fw->pda_addr, fw->pda_size);
- + if (ret)
- + goto free;
- + }
- +
- + /* Stop the firmware, so that it can be safely rewritten */
- + if (priv->stop_fw) {
- + ret = priv->stop_fw(priv, 1);
- + if (ret)
- + goto free;
- + }
- +
- + /* Program the adapter with new firmware */
- + ret = hermes_program(hw, first_block, end);
- + if (ret)
- + goto free;
- +
- + /* Write the PDA to the adapter */
- + if (secondary) {
- + size_t len = hermes_blocks_length(first_block, end);
- + ptr = first_block + len;
- + ret = hermes_apply_pda(hw, ptr, end, pda,
- + &pda[fw->pda_size / sizeof(*pda)]);
- + kfree(pda);
- + if (ret)
- + return ret;
- + }
- +
- + /* Run the firmware */
- + if (priv->stop_fw) {
- + ret = priv->stop_fw(priv, 0);
- + if (ret)
- + return ret;
- + }
- +
- + /* Reset hermes chip and make sure it responds */
- + ret = hw->ops->init(hw);
- +
- + /* hermes_reset() should return 0 with the secondary firmware */
- + if (secondary && ret != 0)
- + return -ENODEV;
- +
- + /* And this should work with any firmware */
- + if (!hermes_present(hw))
- + return -ENODEV;
- +
- + return 0;
- +
- +free:
- + kfree(pda);
- + return ret;
- +}
- +
- +
- +/*
- + * Download the firmware into the card, this also does a PCMCIA soft
- + * reset on the card, to make sure it's in a sane state.
- + */
- +static int
- +symbol_dl_firmware(struct orinoco_private *priv,
- + const struct fw_info *fw)
- +{
- + struct device *dev = priv->dev;
- + int ret;
- + const struct firmware *fw_entry;
- +
- + if (!orinoco_cached_fw_get(priv, true)) {
- + if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) {
- + dev_err(dev, "Cannot find firmware: %s\n", fw->pri_fw);
- + return -ENOENT;
- + }
- + } else
- + fw_entry = orinoco_cached_fw_get(priv, true);
- +
- + /* Load primary firmware */
- + ret = symbol_dl_image(priv, fw, fw_entry->data,
- + fw_entry->data + fw_entry->size, 0);
- +
- + if (!orinoco_cached_fw_get(priv, true))
- + release_firmware(fw_entry);
- + if (ret) {
- + dev_err(dev, "Primary firmware download failed\n");
- + return ret;
- + }
- +
- + if (!orinoco_cached_fw_get(priv, false)) {
- + if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) {
- + dev_err(dev, "Cannot find firmware: %s\n", fw->sta_fw);
- + return -ENOENT;
- + }
- + } else
- + fw_entry = orinoco_cached_fw_get(priv, false);
- +
- + /* Load secondary firmware */
- + ret = symbol_dl_image(priv, fw, fw_entry->data,
- + fw_entry->data + fw_entry->size, 1);
- + if (!orinoco_cached_fw_get(priv, false))
- + release_firmware(fw_entry);
- + if (ret)
- + dev_err(dev, "Secondary firmware download failed\n");
- +
- + return ret;
- +}
- +
- +int orinoco_download(struct orinoco_private *priv)
- +{
- + int err = 0;
- + /* Reload firmware */
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE:
- + /* case FIRMWARE_TYPE_INTERSIL: */
- + err = orinoco_dl_firmware(priv,
- + &orinoco_fw[priv->firmware_type], 0);
- + break;
- +
- + case FIRMWARE_TYPE_SYMBOL:
- + err = symbol_dl_firmware(priv,
- + &orinoco_fw[priv->firmware_type]);
- + break;
- + case FIRMWARE_TYPE_INTERSIL:
- + break;
- + }
- + /* TODO: if we fail we probably need to reinitialise
- + * the driver */
- +
- + return err;
- +}
- +
- +#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
- +void orinoco_cache_fw(struct orinoco_private *priv, int ap)
- +{
- + const struct firmware *fw_entry = NULL;
- + const char *pri_fw;
- + const char *fw;
- +
- + pri_fw = orinoco_fw[priv->firmware_type].pri_fw;
- + if (ap)
- + fw = orinoco_fw[priv->firmware_type].ap_fw;
- + else
- + fw = orinoco_fw[priv->firmware_type].sta_fw;
- +
- + if (pri_fw) {
- + if (request_firmware(&fw_entry, pri_fw, priv->dev) == 0)
- + priv->cached_pri_fw = fw_entry;
- + }
- +
- + if (fw) {
- + if (request_firmware(&fw_entry, fw, priv->dev) == 0)
- + priv->cached_fw = fw_entry;
- + }
- +}
- +
- +void orinoco_uncache_fw(struct orinoco_private *priv)
- +{
- + release_firmware(priv->cached_pri_fw);
- + release_firmware(priv->cached_fw);
- + priv->cached_pri_fw = NULL;
- + priv->cached_fw = NULL;
- +}
- +#endif
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/fw.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/fw.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/fw.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/fw.h 2026-02-16 14:00:36.619256404 +0100
- @@ -0,0 +1,21 @@
- +/* Firmware file reading and download helpers
- + *
- + * See copyright notice in main.c
- + */
- +#ifndef _ORINOCO_FW_H_
- +#define _ORINOCO_FW_H_
- +
- +/* Forward declations */
- +struct orinoco_private;
- +
- +int orinoco_download(struct orinoco_private *priv);
- +
- +#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
- +void orinoco_cache_fw(struct orinoco_private *priv, int ap);
- +void orinoco_uncache_fw(struct orinoco_private *priv);
- +#else
- +#define orinoco_cache_fw(priv, ap) do { } while (0)
- +#define orinoco_uncache_fw(priv) do { } while (0)
- +#endif
- +
- +#endif /* _ORINOCO_FW_H_ */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes.c 2026-02-16 14:00:36.619256404 +0100
- @@ -0,0 +1,778 @@
- +/* hermes.c
- + *
- + * Driver core for the "Hermes" wireless MAC controller, as used in
- + * the Lucent Orinoco and Cabletron RoamAbout cards. It should also
- + * work on the hfa3841 and hfa3842 MAC controller chips used in the
- + * Prism II chipsets.
- + *
- + * This is not a complete driver, just low-level access routines for
- + * the MAC controller itself.
- + *
- + * Based on the prism2 driver from Absolute Value Systems' linux-wlan
- + * project, the Linux wvlan_cs driver, Lucent's HCF-Light
- + * (wvlan_hcf.c) library, and the NetBSD wireless driver (in no
- + * particular order).
- + *
- + * Copyright (C) 2000, David Gibson, Linuxcare Australia.
- + * (C) Copyright David Gibson, IBM Corp. 2001-2003.
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + */
- +
- +#include <linux/net.h>
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/delay.h>
- +
- +#include "hermes.h"
- +
- +/* These are maximum timeouts. Most often, card wil react much faster */
- +#define CMD_BUSY_TIMEOUT (100) /* In iterations of ~1us */
- +#define CMD_INIT_TIMEOUT (50000) /* in iterations of ~10us */
- +#define CMD_COMPL_TIMEOUT (20000) /* in iterations of ~10us */
- +#define ALLOC_COMPL_TIMEOUT (1000) /* in iterations of ~10us */
- +
- +/*
- + * AUX port access. To unlock the AUX port write the access keys to the
- + * PARAM0-2 registers, then write HERMES_AUX_ENABLE to the HERMES_CONTROL
- + * register. Then read it and make sure it's HERMES_AUX_ENABLED.
- + */
- +#define HERMES_AUX_ENABLE 0x8000 /* Enable auxiliary port access */
- +#define HERMES_AUX_DISABLE 0x4000 /* Disable to auxiliary port access */
- +#define HERMES_AUX_ENABLED 0xC000 /* Auxiliary port is open */
- +#define HERMES_AUX_DISABLED 0x0000 /* Auxiliary port is closed */
- +
- +#define HERMES_AUX_PW0 0xFE01
- +#define HERMES_AUX_PW1 0xDC23
- +#define HERMES_AUX_PW2 0xBA45
- +
- +/* HERMES_CMD_DOWNLD */
- +#define HERMES_PROGRAM_DISABLE (0x0000 | HERMES_CMD_DOWNLD)
- +#define HERMES_PROGRAM_ENABLE_VOLATILE (0x0100 | HERMES_CMD_DOWNLD)
- +#define HERMES_PROGRAM_ENABLE_NON_VOLATILE (0x0200 | HERMES_CMD_DOWNLD)
- +#define HERMES_PROGRAM_NON_VOLATILE (0x0300 | HERMES_CMD_DOWNLD)
- +
- +/*
- + * Debugging helpers
- + */
- +
- +#define DMSG(stuff...) do {printk(KERN_DEBUG "hermes @ %p: " , hw->iobase); \
- + printk(stuff); } while (0)
- +
- +#undef HERMES_DEBUG
- +#ifdef HERMES_DEBUG
- +
- +#define DEBUG(lvl, stuff...) if ((lvl) <= HERMES_DEBUG) DMSG(stuff)
- +
- +#else /* ! HERMES_DEBUG */
- +
- +#define DEBUG(lvl, stuff...) do { } while (0)
- +
- +#endif /* ! HERMES_DEBUG */
- +
- +static const struct hermes_ops hermes_ops_local;
- +
- +/*
- + * Internal functions
- + */
- +
- +/* Issue a command to the chip. Waiting for it to complete is the caller's
- + problem.
- +
- + Returns -EBUSY if the command register is busy, 0 on success.
- +
- + Callable from any context.
- +*/
- +static int hermes_issue_cmd(struct hermes *hw, u16 cmd, u16 param0,
- + u16 param1, u16 param2)
- +{
- + int k = CMD_BUSY_TIMEOUT;
- + u16 reg;
- +
- + /* First wait for the command register to unbusy */
- + reg = hermes_read_regn(hw, CMD);
- + while ((reg & HERMES_CMD_BUSY) && k) {
- + k--;
- + udelay(1);
- + reg = hermes_read_regn(hw, CMD);
- + }
- + if (reg & HERMES_CMD_BUSY)
- + return -EBUSY;
- +
- + hermes_write_regn(hw, PARAM2, param2);
- + hermes_write_regn(hw, PARAM1, param1);
- + hermes_write_regn(hw, PARAM0, param0);
- + hermes_write_regn(hw, CMD, cmd);
- +
- + return 0;
- +}
- +
- +/*
- + * Function definitions
- + */
- +
- +/* For doing cmds that wipe the magic constant in SWSUPPORT0 */
- +static int hermes_doicmd_wait(struct hermes *hw, u16 cmd,
- + u16 parm0, u16 parm1, u16 parm2,
- + struct hermes_response *resp)
- +{
- + int err = 0;
- + int k;
- + u16 status, reg;
- +
- + err = hermes_issue_cmd(hw, cmd, parm0, parm1, parm2);
- + if (err)
- + return err;
- +
- + reg = hermes_read_regn(hw, EVSTAT);
- + k = CMD_INIT_TIMEOUT;
- + while ((!(reg & HERMES_EV_CMD)) && k) {
- + k--;
- + udelay(10);
- + reg = hermes_read_regn(hw, EVSTAT);
- + }
- +
- + hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
- +
- + if (!hermes_present(hw)) {
- + DEBUG(0, "hermes @ 0x%x: Card removed during reset.\n",
- + hw->iobase);
- + err = -ENODEV;
- + goto out;
- + }
- +
- + if (!(reg & HERMES_EV_CMD)) {
- + printk(KERN_ERR "hermes @ %p: "
- + "Timeout waiting for card to reset (reg=0x%04x)!\n",
- + hw->iobase, reg);
- + err = -ETIMEDOUT;
- + goto out;
- + }
- +
- + status = hermes_read_regn(hw, STATUS);
- + if (resp) {
- + resp->status = status;
- + resp->resp0 = hermes_read_regn(hw, RESP0);
- + resp->resp1 = hermes_read_regn(hw, RESP1);
- + resp->resp2 = hermes_read_regn(hw, RESP2);
- + }
- +
- + hermes_write_regn(hw, EVACK, HERMES_EV_CMD);
- +
- + if (status & HERMES_STATUS_RESULT)
- + err = -EIO;
- +out:
- + return err;
- +}
- +
- +void hermes_struct_init(struct hermes *hw, void __iomem *address,
- + int reg_spacing)
- +{
- + hw->iobase = address;
- + hw->reg_spacing = reg_spacing;
- + hw->inten = 0x0;
- + hw->eeprom_pda = false;
- + hw->ops = &hermes_ops_local;
- +}
- +EXPORT_SYMBOL(hermes_struct_init);
- +
- +static int hermes_init(struct hermes *hw)
- +{
- + u16 reg;
- + int err = 0;
- + int k;
- +
- + /* We don't want to be interrupted while resetting the chipset */
- + hw->inten = 0x0;
- + hermes_write_regn(hw, INTEN, 0);
- + hermes_write_regn(hw, EVACK, 0xffff);
- +
- + /* Normally it's a "can't happen" for the command register to
- + be busy when we go to issue a command because we are
- + serializing all commands. However we want to have some
- + chance of resetting the card even if it gets into a stupid
- + state, so we actually wait to see if the command register
- + will unbusy itself here. */
- + k = CMD_BUSY_TIMEOUT;
- + reg = hermes_read_regn(hw, CMD);
- + while (k && (reg & HERMES_CMD_BUSY)) {
- + if (reg == 0xffff) /* Special case - the card has probably been
- + removed, so don't wait for the timeout */
- + return -ENODEV;
- +
- + k--;
- + udelay(1);
- + reg = hermes_read_regn(hw, CMD);
- + }
- +
- + /* No need to explicitly handle the timeout - if we've timed
- + out hermes_issue_cmd() will probably return -EBUSY below */
- +
- + /* According to the documentation, EVSTAT may contain
- + obsolete event occurrence information. We have to acknowledge
- + it by writing EVACK. */
- + reg = hermes_read_regn(hw, EVSTAT);
- + hermes_write_regn(hw, EVACK, reg);
- +
- + /* We don't use hermes_docmd_wait here, because the reset wipes
- + the magic constant in SWSUPPORT0 away, and it gets confused */
- + err = hermes_doicmd_wait(hw, HERMES_CMD_INIT, 0, 0, 0, NULL);
- +
- + return err;
- +}
- +
- +/* Issue a command to the chip, and (busy!) wait for it to
- + * complete.
- + *
- + * Returns:
- + * < 0 on internal error
- + * 0 on success
- + * > 0 on error returned by the firmware
- + *
- + * Callable from any context, but locking is your problem. */
- +static int hermes_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
- + struct hermes_response *resp)
- +{
- + int err;
- + int k;
- + u16 reg;
- + u16 status;
- +
- + err = hermes_issue_cmd(hw, cmd, parm0, 0, 0);
- + if (err) {
- + if (!hermes_present(hw)) {
- + if (net_ratelimit())
- + printk(KERN_WARNING "hermes @ %p: "
- + "Card removed while issuing command "
- + "0x%04x.\n", hw->iobase, cmd);
- + err = -ENODEV;
- + } else
- + if (net_ratelimit())
- + printk(KERN_ERR "hermes @ %p: "
- + "Error %d issuing command 0x%04x.\n",
- + hw->iobase, err, cmd);
- + goto out;
- + }
- +
- + reg = hermes_read_regn(hw, EVSTAT);
- + k = CMD_COMPL_TIMEOUT;
- + while ((!(reg & HERMES_EV_CMD)) && k) {
- + k--;
- + udelay(10);
- + reg = hermes_read_regn(hw, EVSTAT);
- + }
- +
- + if (!hermes_present(hw)) {
- + printk(KERN_WARNING "hermes @ %p: Card removed "
- + "while waiting for command 0x%04x completion.\n",
- + hw->iobase, cmd);
- + err = -ENODEV;
- + goto out;
- + }
- +
- + if (!(reg & HERMES_EV_CMD)) {
- + printk(KERN_ERR "hermes @ %p: Timeout waiting for "
- + "command 0x%04x completion.\n", hw->iobase, cmd);
- + err = -ETIMEDOUT;
- + goto out;
- + }
- +
- + status = hermes_read_regn(hw, STATUS);
- + if (resp) {
- + resp->status = status;
- + resp->resp0 = hermes_read_regn(hw, RESP0);
- + resp->resp1 = hermes_read_regn(hw, RESP1);
- + resp->resp2 = hermes_read_regn(hw, RESP2);
- + }
- +
- + hermes_write_regn(hw, EVACK, HERMES_EV_CMD);
- +
- + if (status & HERMES_STATUS_RESULT)
- + err = -EIO;
- +
- + out:
- + return err;
- +}
- +
- +static int hermes_allocate(struct hermes *hw, u16 size, u16 *fid)
- +{
- + int err = 0;
- + int k;
- + u16 reg;
- +
- + if ((size < HERMES_ALLOC_LEN_MIN) || (size > HERMES_ALLOC_LEN_MAX))
- + return -EINVAL;
- +
- + err = hermes_docmd_wait(hw, HERMES_CMD_ALLOC, size, NULL);
- + if (err)
- + return err;
- +
- + reg = hermes_read_regn(hw, EVSTAT);
- + k = ALLOC_COMPL_TIMEOUT;
- + while ((!(reg & HERMES_EV_ALLOC)) && k) {
- + k--;
- + udelay(10);
- + reg = hermes_read_regn(hw, EVSTAT);
- + }
- +
- + if (!hermes_present(hw)) {
- + printk(KERN_WARNING "hermes @ %p: "
- + "Card removed waiting for frame allocation.\n",
- + hw->iobase);
- + return -ENODEV;
- + }
- +
- + if (!(reg & HERMES_EV_ALLOC)) {
- + printk(KERN_ERR "hermes @ %p: "
- + "Timeout waiting for frame allocation\n",
- + hw->iobase);
- + return -ETIMEDOUT;
- + }
- +
- + *fid = hermes_read_regn(hw, ALLOCFID);
- + hermes_write_regn(hw, EVACK, HERMES_EV_ALLOC);
- +
- + return 0;
- +}
- +
- +/* Set up a BAP to read a particular chunk of data from card's internal buffer.
- + *
- + * Returns:
- + * < 0 on internal failure (errno)
- + * 0 on success
- + * > 0 on error
- + * from firmware
- + *
- + * Callable from any context */
- +static int hermes_bap_seek(struct hermes *hw, int bap, u16 id, u16 offset)
- +{
- + int sreg = bap ? HERMES_SELECT1 : HERMES_SELECT0;
- + int oreg = bap ? HERMES_OFFSET1 : HERMES_OFFSET0;
- + int k;
- + u16 reg;
- +
- + /* Paranoia.. */
- + if ((offset > HERMES_BAP_OFFSET_MAX) || (offset % 2))
- + return -EINVAL;
- +
- + k = HERMES_BAP_BUSY_TIMEOUT;
- + reg = hermes_read_reg(hw, oreg);
- + while ((reg & HERMES_OFFSET_BUSY) && k) {
- + k--;
- + udelay(1);
- + reg = hermes_read_reg(hw, oreg);
- + }
- +
- + if (reg & HERMES_OFFSET_BUSY)
- + return -ETIMEDOUT;
- +
- + /* Now we actually set up the transfer */
- + hermes_write_reg(hw, sreg, id);
- + hermes_write_reg(hw, oreg, offset);
- +
- + /* Wait for the BAP to be ready */
- + k = HERMES_BAP_BUSY_TIMEOUT;
- + reg = hermes_read_reg(hw, oreg);
- + while ((reg & (HERMES_OFFSET_BUSY | HERMES_OFFSET_ERR)) && k) {
- + k--;
- + udelay(1);
- + reg = hermes_read_reg(hw, oreg);
- + }
- +
- + if (reg != offset) {
- + printk(KERN_ERR "hermes @ %p: BAP%d offset %s: "
- + "reg=0x%x id=0x%x offset=0x%x\n", hw->iobase, bap,
- + (reg & HERMES_OFFSET_BUSY) ? "timeout" : "error",
- + reg, id, offset);
- +
- + if (reg & HERMES_OFFSET_BUSY)
- + return -ETIMEDOUT;
- +
- + return -EIO; /* error or wrong offset */
- + }
- +
- + return 0;
- +}
- +
- +/* Read a block of data from the chip's buffer, via the
- + * BAP. Synchronization/serialization is the caller's problem. len
- + * must be even.
- + *
- + * Returns:
- + * < 0 on internal failure (errno)
- + * 0 on success
- + * > 0 on error from firmware
- + */
- +static int hermes_bap_pread(struct hermes *hw, int bap, void *buf, int len,
- + u16 id, u16 offset)
- +{
- + int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
- + int err = 0;
- +
- + if ((len < 0) || (len % 2))
- + return -EINVAL;
- +
- + err = hermes_bap_seek(hw, bap, id, offset);
- + if (err)
- + goto out;
- +
- + /* Actually do the transfer */
- + hermes_read_words(hw, dreg, buf, len / 2);
- +
- + out:
- + return err;
- +}
- +
- +/* Write a block of data to the chip's buffer, via the
- + * BAP. Synchronization/serialization is the caller's problem.
- + *
- + * Returns:
- + * < 0 on internal failure (errno)
- + * 0 on success
- + * > 0 on error from firmware
- + */
- +static int hermes_bap_pwrite(struct hermes *hw, int bap, const void *buf,
- + int len, u16 id, u16 offset)
- +{
- + int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
- + int err = 0;
- +
- + if (len < 0)
- + return -EINVAL;
- +
- + err = hermes_bap_seek(hw, bap, id, offset);
- + if (err)
- + goto out;
- +
- + /* Actually do the transfer */
- + hermes_write_bytes(hw, dreg, buf, len);
- +
- + out:
- + return err;
- +}
- +
- +/* Read a Length-Type-Value record from the card.
- + *
- + * If length is NULL, we ignore the length read from the card, and
- + * read the entire buffer regardless. This is useful because some of
- + * the configuration records appear to have incorrect lengths in
- + * practice.
- + *
- + * Callable from user or bh context. */
- +static int hermes_read_ltv(struct hermes *hw, int bap, u16 rid,
- + unsigned bufsize, u16 *length, void *buf)
- +{
- + int err = 0;
- + int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
- + u16 rlength, rtype;
- + unsigned nwords;
- +
- + if (bufsize % 2)
- + return -EINVAL;
- +
- + err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS, rid, NULL);
- + if (err)
- + return err;
- +
- + err = hermes_bap_seek(hw, bap, rid, 0);
- + if (err)
- + return err;
- +
- + rlength = hermes_read_reg(hw, dreg);
- +
- + if (!rlength)
- + return -ENODATA;
- +
- + rtype = hermes_read_reg(hw, dreg);
- +
- + if (length)
- + *length = rlength;
- +
- + if (rtype != rid)
- + printk(KERN_WARNING "hermes @ %p: %s(): "
- + "rid (0x%04x) does not match type (0x%04x)\n",
- + hw->iobase, __func__, rid, rtype);
- + if (HERMES_RECLEN_TO_BYTES(rlength) > bufsize)
- + printk(KERN_WARNING "hermes @ %p: "
- + "Truncating LTV record from %d to %d bytes. "
- + "(rid=0x%04x, len=0x%04x)\n", hw->iobase,
- + HERMES_RECLEN_TO_BYTES(rlength), bufsize, rid, rlength);
- +
- + nwords = min((unsigned)rlength - 1, bufsize / 2);
- + hermes_read_words(hw, dreg, buf, nwords);
- +
- + return 0;
- +}
- +
- +static int hermes_write_ltv(struct hermes *hw, int bap, u16 rid,
- + u16 length, const void *value)
- +{
- + int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
- + int err = 0;
- + unsigned count;
- +
- + if (length == 0)
- + return -EINVAL;
- +
- + err = hermes_bap_seek(hw, bap, rid, 0);
- + if (err)
- + return err;
- +
- + hermes_write_reg(hw, dreg, length);
- + hermes_write_reg(hw, dreg, rid);
- +
- + count = length - 1;
- +
- + hermes_write_bytes(hw, dreg, value, count << 1);
- +
- + err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE,
- + rid, NULL);
- +
- + return err;
- +}
- +
- +/*** Hermes AUX control ***/
- +
- +static inline void
- +hermes_aux_setaddr(struct hermes *hw, u32 addr)
- +{
- + hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7));
- + hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F));
- +}
- +
- +static inline int
- +hermes_aux_control(struct hermes *hw, int enabled)
- +{
- + int desired_state = enabled ? HERMES_AUX_ENABLED : HERMES_AUX_DISABLED;
- + int action = enabled ? HERMES_AUX_ENABLE : HERMES_AUX_DISABLE;
- + int i;
- +
- + /* Already open? */
- + if (hermes_read_reg(hw, HERMES_CONTROL) == desired_state)
- + return 0;
- +
- + hermes_write_reg(hw, HERMES_PARAM0, HERMES_AUX_PW0);
- + hermes_write_reg(hw, HERMES_PARAM1, HERMES_AUX_PW1);
- + hermes_write_reg(hw, HERMES_PARAM2, HERMES_AUX_PW2);
- + hermes_write_reg(hw, HERMES_CONTROL, action);
- +
- + for (i = 0; i < 20; i++) {
- + udelay(10);
- + if (hermes_read_reg(hw, HERMES_CONTROL) ==
- + desired_state)
- + return 0;
- + }
- +
- + return -EBUSY;
- +}
- +
- +/*** Hermes programming ***/
- +
- +/* About to start programming data (Hermes I)
- + * offset is the entry point
- + *
- + * Spectrum_cs' Symbol fw does not require this
- + * wl_lkm Agere fw does
- + * Don't know about intersil
- + */
- +static int hermesi_program_init(struct hermes *hw, u32 offset)
- +{
- + int err;
- +
- + /* Disable interrupts?*/
- + /*hw->inten = 0x0;*/
- + /*hermes_write_regn(hw, INTEN, 0);*/
- + /*hermes_set_irqmask(hw, 0);*/
- +
- + /* Acknowledge any outstanding command */
- + hermes_write_regn(hw, EVACK, 0xFFFF);
- +
- + /* Using init_cmd_wait rather than cmd_wait */
- + err = hw->ops->init_cmd_wait(hw,
- + 0x0100 | HERMES_CMD_INIT,
- + 0, 0, 0, NULL);
- + if (err)
- + return err;
- +
- + err = hw->ops->init_cmd_wait(hw,
- + 0x0000 | HERMES_CMD_INIT,
- + 0, 0, 0, NULL);
- + if (err)
- + return err;
- +
- + err = hermes_aux_control(hw, 1);
- + pr_debug("AUX enable returned %d\n", err);
- +
- + if (err)
- + return err;
- +
- + pr_debug("Enabling volatile, EP 0x%08x\n", offset);
- + err = hw->ops->init_cmd_wait(hw,
- + HERMES_PROGRAM_ENABLE_VOLATILE,
- + offset & 0xFFFFu,
- + offset >> 16,
- + 0,
- + NULL);
- + pr_debug("PROGRAM_ENABLE returned %d\n", err);
- +
- + return err;
- +}
- +
- +/* Done programming data (Hermes I)
- + *
- + * Spectrum_cs' Symbol fw does not require this
- + * wl_lkm Agere fw does
- + * Don't know about intersil
- + */
- +static int hermesi_program_end(struct hermes *hw)
- +{
- + struct hermes_response resp;
- + int rc = 0;
- + int err;
- +
- + rc = hw->ops->cmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp);
- +
- + pr_debug("PROGRAM_DISABLE returned %d, "
- + "r0 0x%04x, r1 0x%04x, r2 0x%04x\n",
- + rc, resp.resp0, resp.resp1, resp.resp2);
- +
- + if ((rc == 0) &&
- + ((resp.status & HERMES_STATUS_CMDCODE) != HERMES_CMD_DOWNLD))
- + rc = -EIO;
- +
- + err = hermes_aux_control(hw, 0);
- + pr_debug("AUX disable returned %d\n", err);
- +
- + /* Acknowledge any outstanding command */
- + hermes_write_regn(hw, EVACK, 0xFFFF);
- +
- + /* Reinitialise, ignoring return */
- + (void) hw->ops->init_cmd_wait(hw, 0x0000 | HERMES_CMD_INIT,
- + 0, 0, 0, NULL);
- +
- + return rc ? rc : err;
- +}
- +
- +static int hermes_program_bytes(struct hermes *hw, const char *data,
- + u32 addr, u32 len)
- +{
- + /* wl lkm splits the programming into chunks of 2000 bytes.
- + * This restriction appears to come from USB. The PCMCIA
- + * adapters can program the whole lot in one go */
- + hermes_aux_setaddr(hw, addr);
- + hermes_write_bytes(hw, HERMES_AUXDATA, data, len);
- + return 0;
- +}
- +
- +/* Read PDA from the adapter */
- +static int hermes_read_pda(struct hermes *hw, __le16 *pda, u32 pda_addr,
- + u16 pda_len)
- +{
- + int ret;
- + u16 pda_size;
- + u16 data_len = pda_len;
- + __le16 *data = pda;
- +
- + if (hw->eeprom_pda) {
- + /* PDA of spectrum symbol is in eeprom */
- +
- + /* Issue command to read EEPROM */
- + ret = hw->ops->cmd_wait(hw, HERMES_CMD_READMIF, 0, NULL);
- + if (ret)
- + return ret;
- + } else {
- + /* wl_lkm does not include PDA size in the PDA area.
- + * We will pad the information into pda, so other routines
- + * don't have to be modified */
- + pda[0] = cpu_to_le16(pda_len - 2);
- + /* Includes CFG_PROD_DATA but not itself */
- + pda[1] = cpu_to_le16(0x0800); /* CFG_PROD_DATA */
- + data_len = pda_len - 4;
- + data = pda + 2;
- + }
- +
- + /* Open auxiliary port */
- + ret = hermes_aux_control(hw, 1);
- + pr_debug("AUX enable returned %d\n", ret);
- + if (ret)
- + return ret;
- +
- + /* Read PDA */
- + hermes_aux_setaddr(hw, pda_addr);
- + hermes_read_words(hw, HERMES_AUXDATA, data, data_len / 2);
- +
- + /* Close aux port */
- + ret = hermes_aux_control(hw, 0);
- + pr_debug("AUX disable returned %d\n", ret);
- +
- + /* Check PDA length */
- + pda_size = le16_to_cpu(pda[0]);
- + pr_debug("Actual PDA length %d, Max allowed %d\n",
- + pda_size, pda_len);
- + if (pda_size > pda_len)
- + return -EINVAL;
- +
- + return 0;
- +}
- +
- +static void hermes_lock_irqsave(spinlock_t *lock,
- + unsigned long *flags) __acquires(lock)
- +{
- + spin_lock_irqsave(lock, *flags);
- +}
- +
- +static void hermes_unlock_irqrestore(spinlock_t *lock,
- + unsigned long *flags) __releases(lock)
- +{
- + spin_unlock_irqrestore(lock, *flags);
- +}
- +
- +static void hermes_lock_irq(spinlock_t *lock) __acquires(lock)
- +{
- + spin_lock_irq(lock);
- +}
- +
- +static void hermes_unlock_irq(spinlock_t *lock) __releases(lock)
- +{
- + spin_unlock_irq(lock);
- +}
- +
- +/* Hermes operations for local buses */
- +static const struct hermes_ops hermes_ops_local = {
- + .init = hermes_init,
- + .cmd_wait = hermes_docmd_wait,
- + .init_cmd_wait = hermes_doicmd_wait,
- + .allocate = hermes_allocate,
- + .read_ltv = hermes_read_ltv,
- + .read_ltv_pr = hermes_read_ltv,
- + .write_ltv = hermes_write_ltv,
- + .bap_pread = hermes_bap_pread,
- + .bap_pwrite = hermes_bap_pwrite,
- + .read_pda = hermes_read_pda,
- + .program_init = hermesi_program_init,
- + .program_end = hermesi_program_end,
- + .program = hermes_program_bytes,
- + .lock_irqsave = hermes_lock_irqsave,
- + .unlock_irqrestore = hermes_unlock_irqrestore,
- + .lock_irq = hermes_lock_irq,
- + .unlock_irq = hermes_unlock_irq,
- +};
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes_dld.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes_dld.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes_dld.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes_dld.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,477 @@
- +/*
- + * Hermes download helper.
- + *
- + * This helper:
- + * - is capable of writing to the volatile area of the hermes device
- + * - is currently not capable of writing to non-volatile areas
- + * - provide helpers to identify and update plugin data
- + * - is not capable of interpreting a fw image directly. That is up to
- + * the main card driver.
- + * - deals with Hermes I devices. It can probably be modified to deal
- + * with Hermes II devices
- + *
- + * Copyright (C) 2007, David Kilroy
- + *
- + * Plug data code slightly modified from spectrum_cs driver
- + * Copyright (C) 2002-2005 Pavel Roskin <proski@gnu.org>
- + * Portions based on information in wl_lkm_718 Agere driver
- + * COPYRIGHT (C) 2001-2004 by Agere Systems Inc. All Rights Reserved
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + */
- +
- +#include <linux/module.h>
- +#include <linux/delay.h>
- +#include "hermes.h"
- +#include "hermes_dld.h"
- +
- +#define PFX "hermes_dld: "
- +
- +/* End markers used in dblocks */
- +#define PDI_END 0x00000000 /* End of PDA */
- +#define BLOCK_END 0xFFFFFFFF /* Last image block */
- +#define TEXT_END 0x1A /* End of text header */
- +
- +/*
- + * The following structures have little-endian fields denoted by
- + * the leading underscore. Don't access them directly - use inline
- + * functions defined below.
- + */
- +
- +/*
- + * The binary image to be downloaded consists of series of data blocks.
- + * Each block has the following structure.
- + */
- +struct dblock {
- + __le32 addr; /* adapter address where to write the block */
- + __le16 len; /* length of the data only, in bytes */
- + char data[]; /* data to be written */
- +} __packed;
- +
- +/*
- + * Plug Data References are located in the image after the last data
- + * block. They refer to areas in the adapter memory where the plug data
- + * items with matching ID should be written.
- + */
- +struct pdr {
- + __le32 id; /* record ID */
- + __le32 addr; /* adapter address where to write the data */
- + __le32 len; /* expected length of the data, in bytes */
- + char next[]; /* next PDR starts here */
- +} __packed;
- +
- +/*
- + * Plug Data Items are located in the EEPROM read from the adapter by
- + * primary firmware. They refer to the device-specific data that should
- + * be plugged into the secondary firmware.
- + */
- +struct pdi {
- + __le16 len; /* length of ID and data, in words */
- + __le16 id; /* record ID */
- + char data[]; /* plug data */
- +} __packed;
- +
- +/*** FW data block access functions ***/
- +
- +static inline u32
- +dblock_addr(const struct dblock *blk)
- +{
- + return le32_to_cpu(blk->addr);
- +}
- +
- +static inline u32
- +dblock_len(const struct dblock *blk)
- +{
- + return le16_to_cpu(blk->len);
- +}
- +
- +/*** PDR Access functions ***/
- +
- +static inline u32
- +pdr_id(const struct pdr *pdr)
- +{
- + return le32_to_cpu(pdr->id);
- +}
- +
- +static inline u32
- +pdr_addr(const struct pdr *pdr)
- +{
- + return le32_to_cpu(pdr->addr);
- +}
- +
- +static inline u32
- +pdr_len(const struct pdr *pdr)
- +{
- + return le32_to_cpu(pdr->len);
- +}
- +
- +/*** PDI Access functions ***/
- +
- +static inline u32
- +pdi_id(const struct pdi *pdi)
- +{
- + return le16_to_cpu(pdi->id);
- +}
- +
- +/* Return length of the data only, in bytes */
- +static inline u32
- +pdi_len(const struct pdi *pdi)
- +{
- + return 2 * (le16_to_cpu(pdi->len) - 1);
- +}
- +
- +/*** Plug Data Functions ***/
- +
- +/*
- + * Scan PDR for the record with the specified RECORD_ID.
- + * If it's not found, return NULL.
- + */
- +static const struct pdr *
- +hermes_find_pdr(const struct pdr *first_pdr, u32 record_id, const void *end)
- +{
- + const struct pdr *pdr = first_pdr;
- +
- + end -= sizeof(struct pdr);
- +
- + while (((void *) pdr <= end) &&
- + (pdr_id(pdr) != PDI_END)) {
- + /*
- + * PDR area is currently not terminated by PDI_END.
- + * It's followed by CRC records, which have the type
- + * field where PDR has length. The type can be 0 or 1.
- + */
- + if (pdr_len(pdr) < 2)
- + return NULL;
- +
- + /* If the record ID matches, we are done */
- + if (pdr_id(pdr) == record_id)
- + return pdr;
- +
- + pdr = (struct pdr *) pdr->next;
- + }
- + return NULL;
- +}
- +
- +/* Scan production data items for a particular entry */
- +static const struct pdi *
- +hermes_find_pdi(const struct pdi *first_pdi, u32 record_id, const void *end)
- +{
- + const struct pdi *pdi = first_pdi;
- +
- + end -= sizeof(struct pdi);
- +
- + while (((void *) pdi <= end) &&
- + (pdi_id(pdi) != PDI_END)) {
- +
- + /* If the record ID matches, we are done */
- + if (pdi_id(pdi) == record_id)
- + return pdi;
- +
- + pdi = (struct pdi *) &pdi->data[pdi_len(pdi)];
- + }
- + return NULL;
- +}
- +
- +/* Process one Plug Data Item - find corresponding PDR and plug it */
- +static int
- +hermes_plug_pdi(struct hermes *hw, const struct pdr *first_pdr,
- + const struct pdi *pdi, const void *pdr_end)
- +{
- + const struct pdr *pdr;
- +
- + /* Find the PDR corresponding to this PDI */
- + pdr = hermes_find_pdr(first_pdr, pdi_id(pdi), pdr_end);
- +
- + /* No match is found, safe to ignore */
- + if (!pdr)
- + return 0;
- +
- + /* Lengths of the data in PDI and PDR must match */
- + if (pdi_len(pdi) != pdr_len(pdr))
- + return -EINVAL;
- +
- + /* do the actual plugging */
- + hw->ops->program(hw, pdi->data, pdr_addr(pdr), pdi_len(pdi));
- +
- + return 0;
- +}
- +
- +/* Parse PDA and write the records into the adapter
- + *
- + * Attempt to write every records that is in the specified pda
- + * which also has a valid production data record for the firmware.
- + */
- +int hermes_apply_pda(struct hermes *hw,
- + const char *first_pdr,
- + const void *pdr_end,
- + const __le16 *pda,
- + const void *pda_end)
- +{
- + int ret;
- + const struct pdi *pdi;
- + const struct pdr *pdr;
- +
- + pdr = (const struct pdr *) first_pdr;
- + pda_end -= sizeof(struct pdi);
- +
- + /* Go through every PDI and plug them into the adapter */
- + pdi = (const struct pdi *) (pda + 2);
- + while (((void *) pdi <= pda_end) &&
- + (pdi_id(pdi) != PDI_END)) {
- + ret = hermes_plug_pdi(hw, pdr, pdi, pdr_end);
- + if (ret)
- + return ret;
- +
- + /* Increment to the next PDI */
- + pdi = (const struct pdi *) &pdi->data[pdi_len(pdi)];
- + }
- + return 0;
- +}
- +
- +/* Identify the total number of bytes in all blocks
- + * including the header data.
- + */
- +size_t
- +hermes_blocks_length(const char *first_block, const void *end)
- +{
- + const struct dblock *blk = (const struct dblock *) first_block;
- + int total_len = 0;
- + int len;
- +
- + end -= sizeof(*blk);
- +
- + /* Skip all blocks to locate Plug Data References
- + * (Spectrum CS) */
- + while (((void *) blk <= end) &&
- + (dblock_addr(blk) != BLOCK_END)) {
- + len = dblock_len(blk);
- + total_len += sizeof(*blk) + len;
- + blk = (struct dblock *) &blk->data[len];
- + }
- +
- + return total_len;
- +}
- +
- +/*** Hermes programming ***/
- +
- +/* Program the data blocks */
- +int hermes_program(struct hermes *hw, const char *first_block, const void *end)
- +{
- + const struct dblock *blk;
- + u32 blkaddr;
- + u32 blklen;
- + int err = 0;
- +
- + blk = (const struct dblock *) first_block;
- +
- + if ((void *) blk > (end - sizeof(*blk)))
- + return -EIO;
- +
- + blkaddr = dblock_addr(blk);
- + blklen = dblock_len(blk);
- +
- + while ((blkaddr != BLOCK_END) &&
- + (((void *) blk + blklen) <= end)) {
- + pr_debug(PFX "Programming block of length %d "
- + "to address 0x%08x\n", blklen, blkaddr);
- +
- + err = hw->ops->program(hw, blk->data, blkaddr, blklen);
- + if (err)
- + break;
- +
- + blk = (const struct dblock *) &blk->data[blklen];
- +
- + if ((void *) blk > (end - sizeof(*blk)))
- + return -EIO;
- +
- + blkaddr = dblock_addr(blk);
- + blklen = dblock_len(blk);
- + }
- + return err;
- +}
- +
- +/*** Default plugging data for Hermes I ***/
- +/* Values from wl_lkm_718/hcf/dhf.c */
- +
- +#define DEFINE_DEFAULT_PDR(pid, length, data) \
- +static const struct { \
- + __le16 len; \
- + __le16 id; \
- + u8 val[length]; \
- +} __packed default_pdr_data_##pid = { \
- + cpu_to_le16((sizeof(default_pdr_data_##pid)/ \
- + sizeof(__le16)) - 1), \
- + cpu_to_le16(pid), \
- + data \
- +}
- +
- +#define DEFAULT_PDR(pid) default_pdr_data_##pid
- +
- +/* HWIF Compatibility */
- +DEFINE_DEFAULT_PDR(0x0005, 10, "\x00\x00\x06\x00\x01\x00\x01\x00\x01\x00");
- +
- +/* PPPPSign */
- +DEFINE_DEFAULT_PDR(0x0108, 4, "\x00\x00\x00\x00");
- +
- +/* PPPPProf */
- +DEFINE_DEFAULT_PDR(0x0109, 10, "\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00");
- +
- +/* Antenna diversity */
- +DEFINE_DEFAULT_PDR(0x0150, 2, "\x00\x3F");
- +
- +/* Modem VCO band Set-up */
- +DEFINE_DEFAULT_PDR(0x0160, 28,
- + "\x00\x00\x00\x00\x00\x00\x00\x00"
- + "\x00\x00\x00\x00\x00\x00\x00\x00"
- + "\x00\x00\x00\x00\x00\x00\x00\x00"
- + "\x00\x00\x00\x00");
- +
- +/* Modem Rx Gain Table Values */
- +DEFINE_DEFAULT_PDR(0x0161, 256,
- + "\x3F\x01\x3F\01\x3F\x01\x3F\x01"
- + "\x3F\x01\x3F\01\x3F\x01\x3F\x01"
- + "\x3F\x01\x3F\01\x3F\x01\x3F\x01"
- + "\x3F\x01\x3F\01\x3F\x01\x3F\x01"
- + "\x3F\x01\x3E\01\x3E\x01\x3D\x01"
- + "\x3D\x01\x3C\01\x3C\x01\x3B\x01"
- + "\x3B\x01\x3A\01\x3A\x01\x39\x01"
- + "\x39\x01\x38\01\x38\x01\x37\x01"
- + "\x37\x01\x36\01\x36\x01\x35\x01"
- + "\x35\x01\x34\01\x34\x01\x33\x01"
- + "\x33\x01\x32\x01\x32\x01\x31\x01"
- + "\x31\x01\x30\x01\x30\x01\x7B\x01"
- + "\x7B\x01\x7A\x01\x7A\x01\x79\x01"
- + "\x79\x01\x78\x01\x78\x01\x77\x01"
- + "\x77\x01\x76\x01\x76\x01\x75\x01"
- + "\x75\x01\x74\x01\x74\x01\x73\x01"
- + "\x73\x01\x72\x01\x72\x01\x71\x01"
- + "\x71\x01\x70\x01\x70\x01\x68\x01"
- + "\x68\x01\x67\x01\x67\x01\x66\x01"
- + "\x66\x01\x65\x01\x65\x01\x57\x01"
- + "\x57\x01\x56\x01\x56\x01\x55\x01"
- + "\x55\x01\x54\x01\x54\x01\x53\x01"
- + "\x53\x01\x52\x01\x52\x01\x51\x01"
- + "\x51\x01\x50\x01\x50\x01\x48\x01"
- + "\x48\x01\x47\x01\x47\x01\x46\x01"
- + "\x46\x01\x45\x01\x45\x01\x44\x01"
- + "\x44\x01\x43\x01\x43\x01\x42\x01"
- + "\x42\x01\x41\x01\x41\x01\x40\x01"
- + "\x40\x01\x40\x01\x40\x01\x40\x01"
- + "\x40\x01\x40\x01\x40\x01\x40\x01"
- + "\x40\x01\x40\x01\x40\x01\x40\x01"
- + "\x40\x01\x40\x01\x40\x01\x40\x01");
- +
- +/* Write PDA according to certain rules.
- + *
- + * For every production data record, look for a previous setting in
- + * the pda, and use that.
- + *
- + * For certain records, use defaults if they are not found in pda.
- + */
- +int hermes_apply_pda_with_defaults(struct hermes *hw,
- + const char *first_pdr,
- + const void *pdr_end,
- + const __le16 *pda,
- + const void *pda_end)
- +{
- + const struct pdr *pdr = (const struct pdr *) first_pdr;
- + const struct pdi *first_pdi = (const struct pdi *) &pda[2];
- + const struct pdi *pdi;
- + const struct pdi *default_pdi = NULL;
- + const struct pdi *outdoor_pdi;
- + int record_id;
- +
- + pdr_end -= sizeof(struct pdr);
- +
- + while (((void *) pdr <= pdr_end) &&
- + (pdr_id(pdr) != PDI_END)) {
- + /*
- + * For spectrum_cs firmwares,
- + * PDR area is currently not terminated by PDI_END.
- + * It's followed by CRC records, which have the type
- + * field where PDR has length. The type can be 0 or 1.
- + */
- + if (pdr_len(pdr) < 2)
- + break;
- + record_id = pdr_id(pdr);
- +
- + pdi = hermes_find_pdi(first_pdi, record_id, pda_end);
- + if (pdi)
- + pr_debug(PFX "Found record 0x%04x at %p\n",
- + record_id, pdi);
- +
- + switch (record_id) {
- + case 0x110: /* Modem REFDAC values */
- + case 0x120: /* Modem VGDAC values */
- + outdoor_pdi = hermes_find_pdi(first_pdi, record_id + 1,
- + pda_end);
- + default_pdi = NULL;
- + if (outdoor_pdi) {
- + pdi = outdoor_pdi;
- + pr_debug(PFX
- + "Using outdoor record 0x%04x at %p\n",
- + record_id + 1, pdi);
- + }
- + break;
- + case 0x5: /* HWIF Compatibility */
- + default_pdi = (struct pdi *) &DEFAULT_PDR(0x0005);
- + break;
- + case 0x108: /* PPPPSign */
- + default_pdi = (struct pdi *) &DEFAULT_PDR(0x0108);
- + break;
- + case 0x109: /* PPPPProf */
- + default_pdi = (struct pdi *) &DEFAULT_PDR(0x0109);
- + break;
- + case 0x150: /* Antenna diversity */
- + default_pdi = (struct pdi *) &DEFAULT_PDR(0x0150);
- + break;
- + case 0x160: /* Modem VCO band Set-up */
- + default_pdi = (struct pdi *) &DEFAULT_PDR(0x0160);
- + break;
- + case 0x161: /* Modem Rx Gain Table Values */
- + default_pdi = (struct pdi *) &DEFAULT_PDR(0x0161);
- + break;
- + default:
- + default_pdi = NULL;
- + break;
- + }
- + if (!pdi && default_pdi) {
- + /* Use default */
- + pdi = default_pdi;
- + pr_debug(PFX "Using default record 0x%04x at %p\n",
- + record_id, pdi);
- + }
- +
- + if (pdi) {
- + /* Lengths of the data in PDI and PDR must match */
- + if ((pdi_len(pdi) == pdr_len(pdr)) &&
- + ((void *) pdi->data + pdi_len(pdi) < pda_end)) {
- + /* do the actual plugging */
- + hw->ops->program(hw, pdi->data, pdr_addr(pdr),
- + pdi_len(pdi));
- + }
- + }
- +
- + pdr++;
- + }
- + return 0;
- +}
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes_dld.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes_dld.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes_dld.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes_dld.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,52 @@
- +/*
- + * Copyright (C) 2007, David Kilroy
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + */
- +#ifndef _HERMES_DLD_H
- +#define _HERMES_DLD_H
- +
- +#include "hermes.h"
- +
- +int hermesi_program_init(struct hermes *hw, u32 offset);
- +int hermesi_program_end(struct hermes *hw);
- +int hermes_program(struct hermes *hw, const char *first_block, const void *end);
- +
- +int hermes_read_pda(struct hermes *hw,
- + __le16 *pda,
- + u32 pda_addr,
- + u16 pda_len,
- + int use_eeprom);
- +int hermes_apply_pda(struct hermes *hw,
- + const char *first_pdr,
- + const void *pdr_end,
- + const __le16 *pda,
- + const void *pda_end);
- +int hermes_apply_pda_with_defaults(struct hermes *hw,
- + const char *first_pdr,
- + const void *pdr_end,
- + const __le16 *pda,
- + const void *pda_end);
- +
- +size_t hermes_blocks_length(const char *first_block, const void *end);
- +
- +#endif /* _HERMES_DLD_H */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,534 @@
- +/* SPDX-License-Identifier: GPL-2.0-only */
- +/* hermes.h
- + *
- + * Driver core for the "Hermes" wireless MAC controller, as used in
- + * the Lucent Orinoco and Cabletron RoamAbout cards. It should also
- + * work on the hfa3841 and hfa3842 MAC controller chips used in the
- + * Prism I & II chipsets.
- + *
- + * This is not a complete driver, just low-level access routines for
- + * the MAC controller itself.
- + *
- + * Based on the prism2 driver from Absolute Value Systems' linux-wlan
- + * project, the Linux wvlan_cs driver, Lucent's HCF-Light
- + * (wvlan_hcf.c) library, and the NetBSD wireless driver.
- + *
- + * Copyright (C) 2000, David Gibson, Linuxcare Australia.
- + * (C) Copyright David Gibson, IBM Corp. 2001-2003.
- + *
- + * Portions taken from hfa384x.h.
- + * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
- + */
- +
- +#ifndef _HERMES_H
- +#define _HERMES_H
- +
- +/* Notes on locking:
- + *
- + * As a module of low level hardware access routines, there is no
- + * locking. Users of this module should ensure that they serialize
- + * access to the hermes structure, and to the hardware
- +*/
- +
- +#include <linux/if_ether.h>
- +#include <linux/io.h>
- +
- +/*
- + * Limits and constants
- + */
- +#define HERMES_ALLOC_LEN_MIN (4)
- +#define HERMES_ALLOC_LEN_MAX (2400)
- +#define HERMES_LTV_LEN_MAX (34)
- +#define HERMES_BAP_DATALEN_MAX (4096)
- +#define HERMES_BAP_OFFSET_MAX (4096)
- +#define HERMES_PORTID_MAX (7)
- +#define HERMES_NUMPORTS_MAX (HERMES_PORTID_MAX + 1)
- +#define HERMES_PDR_LEN_MAX (260) /* in bytes, from EK */
- +#define HERMES_PDA_RECS_MAX (200) /* a guess */
- +#define HERMES_PDA_LEN_MAX (1024) /* in bytes, from EK */
- +#define HERMES_SCANRESULT_MAX (35)
- +#define HERMES_CHINFORESULT_MAX (8)
- +#define HERMES_MAX_MULTICAST (16)
- +#define HERMES_MAGIC (0x7d1f)
- +
- +/*
- + * Hermes register offsets
- + */
- +#define HERMES_CMD (0x00)
- +#define HERMES_PARAM0 (0x02)
- +#define HERMES_PARAM1 (0x04)
- +#define HERMES_PARAM2 (0x06)
- +#define HERMES_STATUS (0x08)
- +#define HERMES_RESP0 (0x0A)
- +#define HERMES_RESP1 (0x0C)
- +#define HERMES_RESP2 (0x0E)
- +#define HERMES_INFOFID (0x10)
- +#define HERMES_RXFID (0x20)
- +#define HERMES_ALLOCFID (0x22)
- +#define HERMES_TXCOMPLFID (0x24)
- +#define HERMES_SELECT0 (0x18)
- +#define HERMES_OFFSET0 (0x1C)
- +#define HERMES_DATA0 (0x36)
- +#define HERMES_SELECT1 (0x1A)
- +#define HERMES_OFFSET1 (0x1E)
- +#define HERMES_DATA1 (0x38)
- +#define HERMES_EVSTAT (0x30)
- +#define HERMES_INTEN (0x32)
- +#define HERMES_EVACK (0x34)
- +#define HERMES_CONTROL (0x14)
- +#define HERMES_SWSUPPORT0 (0x28)
- +#define HERMES_SWSUPPORT1 (0x2A)
- +#define HERMES_SWSUPPORT2 (0x2C)
- +#define HERMES_AUXPAGE (0x3A)
- +#define HERMES_AUXOFFSET (0x3C)
- +#define HERMES_AUXDATA (0x3E)
- +
- +/*
- + * CMD register bitmasks
- + */
- +#define HERMES_CMD_BUSY (0x8000)
- +#define HERMES_CMD_AINFO (0x7f00)
- +#define HERMES_CMD_MACPORT (0x0700)
- +#define HERMES_CMD_RECL (0x0100)
- +#define HERMES_CMD_WRITE (0x0100)
- +#define HERMES_CMD_PROGMODE (0x0300)
- +#define HERMES_CMD_CMDCODE (0x003f)
- +
- +/*
- + * STATUS register bitmasks
- + */
- +#define HERMES_STATUS_RESULT (0x7f00)
- +#define HERMES_STATUS_CMDCODE (0x003f)
- +
- +/*
- + * OFFSET register bitmasks
- + */
- +#define HERMES_OFFSET_BUSY (0x8000)
- +#define HERMES_OFFSET_ERR (0x4000)
- +#define HERMES_OFFSET_DATAOFF (0x0ffe)
- +
- +/*
- + * Event register bitmasks (INTEN, EVSTAT, EVACK)
- + */
- +#define HERMES_EV_TICK (0x8000)
- +#define HERMES_EV_WTERR (0x4000)
- +#define HERMES_EV_INFDROP (0x2000)
- +#define HERMES_EV_INFO (0x0080)
- +#define HERMES_EV_DTIM (0x0020)
- +#define HERMES_EV_CMD (0x0010)
- +#define HERMES_EV_ALLOC (0x0008)
- +#define HERMES_EV_TXEXC (0x0004)
- +#define HERMES_EV_TX (0x0002)
- +#define HERMES_EV_RX (0x0001)
- +
- +/*
- + * Command codes
- + */
- +/*--- Controller Commands ----------------------------*/
- +#define HERMES_CMD_INIT (0x0000)
- +#define HERMES_CMD_ENABLE (0x0001)
- +#define HERMES_CMD_DISABLE (0x0002)
- +#define HERMES_CMD_DIAG (0x0003)
- +
- +/*--- Buffer Mgmt Commands ---------------------------*/
- +#define HERMES_CMD_ALLOC (0x000A)
- +#define HERMES_CMD_TX (0x000B)
- +
- +/*--- Regulate Commands ------------------------------*/
- +#define HERMES_CMD_NOTIFY (0x0010)
- +#define HERMES_CMD_INQUIRE (0x0011)
- +
- +/*--- Configure Commands -----------------------------*/
- +#define HERMES_CMD_ACCESS (0x0021)
- +#define HERMES_CMD_DOWNLD (0x0022)
- +
- +/*--- Serial I/O Commands ----------------------------*/
- +#define HERMES_CMD_READMIF (0x0030)
- +#define HERMES_CMD_WRITEMIF (0x0031)
- +
- +/*--- Debugging Commands -----------------------------*/
- +#define HERMES_CMD_TEST (0x0038)
- +
- +
- +/* Test command arguments */
- +#define HERMES_TEST_SET_CHANNEL 0x0800
- +#define HERMES_TEST_MONITOR 0x0b00
- +#define HERMES_TEST_STOP 0x0f00
- +
- +/* Authentication algorithms */
- +#define HERMES_AUTH_OPEN 1
- +#define HERMES_AUTH_SHARED_KEY 2
- +
- +/* WEP settings */
- +#define HERMES_WEP_PRIVACY_INVOKED 0x0001
- +#define HERMES_WEP_EXCL_UNENCRYPTED 0x0002
- +#define HERMES_WEP_HOST_ENCRYPT 0x0010
- +#define HERMES_WEP_HOST_DECRYPT 0x0080
- +
- +/* Symbol hostscan options */
- +#define HERMES_HOSTSCAN_SYMBOL_5SEC 0x0001
- +#define HERMES_HOSTSCAN_SYMBOL_ONCE 0x0002
- +#define HERMES_HOSTSCAN_SYMBOL_PASSIVE 0x0040
- +#define HERMES_HOSTSCAN_SYMBOL_BCAST 0x0080
- +
- +/*
- + * Frame structures and constants
- + */
- +
- +#define HERMES_DESCRIPTOR_OFFSET 0
- +#define HERMES_802_11_OFFSET (14)
- +#define HERMES_802_3_OFFSET (14 + 32)
- +#define HERMES_802_2_OFFSET (14 + 32 + 14)
- +#define HERMES_TXCNTL2_OFFSET (HERMES_802_3_OFFSET - 2)
- +
- +#define HERMES_RXSTAT_ERR (0x0003)
- +#define HERMES_RXSTAT_BADCRC (0x0001)
- +#define HERMES_RXSTAT_UNDECRYPTABLE (0x0002)
- +#define HERMES_RXSTAT_MIC (0x0010) /* Frame contains MIC */
- +#define HERMES_RXSTAT_MACPORT (0x0700)
- +#define HERMES_RXSTAT_PCF (0x1000) /* Frame was received in CF period */
- +#define HERMES_RXSTAT_MIC_KEY_ID (0x1800) /* MIC key used */
- +#define HERMES_RXSTAT_MSGTYPE (0xE000)
- +#define HERMES_RXSTAT_1042 (0x2000) /* RFC-1042 frame */
- +#define HERMES_RXSTAT_TUNNEL (0x4000) /* bridge-tunnel encoded frame */
- +#define HERMES_RXSTAT_WMP (0x6000) /* Wavelan-II Management Protocol frame */
- +
- +/* Shift amount for key ID in RXSTAT and TXCTRL */
- +#define HERMES_MIC_KEY_ID_SHIFT 11
- +
- +struct hermes_tx_descriptor {
- + __le16 status;
- + __le16 reserved1;
- + __le16 reserved2;
- + __le32 sw_support;
- + u8 retry_count;
- + u8 tx_rate;
- + __le16 tx_control;
- +} __packed;
- +
- +#define HERMES_TXSTAT_RETRYERR (0x0001)
- +#define HERMES_TXSTAT_AGEDERR (0x0002)
- +#define HERMES_TXSTAT_DISCON (0x0004)
- +#define HERMES_TXSTAT_FORMERR (0x0008)
- +
- +#define HERMES_TXCTRL_TX_OK (0x0002) /* ?? interrupt on Tx complete */
- +#define HERMES_TXCTRL_TX_EX (0x0004) /* ?? interrupt on Tx exception */
- +#define HERMES_TXCTRL_802_11 (0x0008) /* We supply 802.11 header */
- +#define HERMES_TXCTRL_MIC (0x0010) /* 802.3 + TKIP */
- +#define HERMES_TXCTRL_MIC_KEY_ID (0x1800) /* MIC Key ID mask */
- +#define HERMES_TXCTRL_ALT_RTRY (0x0020)
- +
- +/* Inquiry constants and data types */
- +
- +#define HERMES_INQ_TALLIES (0xF100)
- +#define HERMES_INQ_SCAN (0xF101)
- +#define HERMES_INQ_CHANNELINFO (0xF102)
- +#define HERMES_INQ_HOSTSCAN (0xF103)
- +#define HERMES_INQ_HOSTSCAN_SYMBOL (0xF104)
- +#define HERMES_INQ_LINKSTATUS (0xF200)
- +#define HERMES_INQ_SEC_STAT_AGERE (0xF202)
- +
- +struct hermes_tallies_frame {
- + __le16 TxUnicastFrames;
- + __le16 TxMulticastFrames;
- + __le16 TxFragments;
- + __le16 TxUnicastOctets;
- + __le16 TxMulticastOctets;
- + __le16 TxDeferredTransmissions;
- + __le16 TxSingleRetryFrames;
- + __le16 TxMultipleRetryFrames;
- + __le16 TxRetryLimitExceeded;
- + __le16 TxDiscards;
- + __le16 RxUnicastFrames;
- + __le16 RxMulticastFrames;
- + __le16 RxFragments;
- + __le16 RxUnicastOctets;
- + __le16 RxMulticastOctets;
- + __le16 RxFCSErrors;
- + __le16 RxDiscards_NoBuffer;
- + __le16 TxDiscardsWrongSA;
- + __le16 RxWEPUndecryptable;
- + __le16 RxMsgInMsgFragments;
- + __le16 RxMsgInBadMsgFragments;
- + /* Those last are probably not available in very old firmwares */
- + __le16 RxDiscards_WEPICVError;
- + __le16 RxDiscards_WEPExcluded;
- +} __packed;
- +
- +/* Grabbed from wlan-ng - Thanks Mark... - Jean II
- + * This is the result of a scan inquiry command */
- +/* Structure describing info about an Access Point */
- +struct prism2_scan_apinfo {
- + __le16 channel; /* Channel where the AP sits */
- + __le16 noise; /* Noise level */
- + __le16 level; /* Signal level */
- + u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
- + __le16 beacon_interv; /* Beacon interval */
- + __le16 capabilities; /* Capabilities */
- + __le16 essid_len; /* ESSID length */
- + u8 essid[32]; /* ESSID of the network */
- + u8 rates[10]; /* Bit rate supported */
- + __le16 proberesp_rate; /* Data rate of the response frame */
- + __le16 atim; /* ATIM window time, Kus (hostscan only) */
- +} __packed;
- +
- +/* Same stuff for the Lucent/Agere card.
- + * Thanks to h1kari <h1kari AT dachb0den.com> - Jean II */
- +struct agere_scan_apinfo {
- + __le16 channel; /* Channel where the AP sits */
- + __le16 noise; /* Noise level */
- + __le16 level; /* Signal level */
- + u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
- + __le16 beacon_interv; /* Beacon interval */
- + __le16 capabilities; /* Capabilities */
- + /* bits: 0-ess, 1-ibss, 4-privacy [wep] */
- + __le16 essid_len; /* ESSID length */
- + u8 essid[32]; /* ESSID of the network */
- +} __packed;
- +
- +/* Moustafa: Scan structure for Symbol cards */
- +struct symbol_scan_apinfo {
- + u8 channel; /* Channel where the AP sits */
- + u8 unknown1; /* 8 in 2.9x and 3.9x f/w, 0 otherwise */
- + __le16 noise; /* Noise level */
- + __le16 level; /* Signal level */
- + u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
- + __le16 beacon_interv; /* Beacon interval */
- + __le16 capabilities; /* Capabilities */
- + /* bits: 0-ess, 1-ibss, 4-privacy [wep] */
- + __le16 essid_len; /* ESSID length */
- + u8 essid[32]; /* ESSID of the network */
- + __le16 rates[5]; /* Bit rate supported */
- + __le16 basic_rates; /* Basic rates bitmask */
- + u8 unknown2[6]; /* Always FF:FF:FF:FF:00:00 */
- + u8 unknown3[8]; /* Always 0, appeared in f/w 3.91-68 */
- +} __packed;
- +
- +union hermes_scan_info {
- + struct agere_scan_apinfo a;
- + struct prism2_scan_apinfo p;
- + struct symbol_scan_apinfo s;
- +};
- +
- +/* Extended scan struct for HERMES_INQ_CHANNELINFO.
- + * wl_lkm calls this an ACS scan (Automatic Channel Select).
- + * Keep out of union hermes_scan_info because it is much bigger than
- + * the older scan structures. */
- +struct agere_ext_scan_info {
- + __le16 reserved0;
- +
- + u8 noise;
- + u8 level;
- + u8 rx_flow;
- + u8 rate;
- + __le16 reserved1[2];
- +
- + __le16 frame_control;
- + __le16 dur_id;
- + u8 addr1[ETH_ALEN];
- + u8 addr2[ETH_ALEN];
- + u8 bssid[ETH_ALEN];
- + __le16 sequence;
- + u8 addr4[ETH_ALEN];
- +
- + __le16 data_length;
- +
- + /* Next 3 fields do not get filled in. */
- + u8 daddr[ETH_ALEN];
- + u8 saddr[ETH_ALEN];
- + __le16 len_type;
- +
- + __le64 timestamp;
- + __le16 beacon_interval;
- + __le16 capabilities;
- + u8 data[];
- +} __packed;
- +
- +#define HERMES_LINKSTATUS_NOT_CONNECTED (0x0000)
- +#define HERMES_LINKSTATUS_CONNECTED (0x0001)
- +#define HERMES_LINKSTATUS_DISCONNECTED (0x0002)
- +#define HERMES_LINKSTATUS_AP_CHANGE (0x0003)
- +#define HERMES_LINKSTATUS_AP_OUT_OF_RANGE (0x0004)
- +#define HERMES_LINKSTATUS_AP_IN_RANGE (0x0005)
- +#define HERMES_LINKSTATUS_ASSOC_FAILED (0x0006)
- +
- +struct hermes_linkstatus {
- + __le16 linkstatus; /* Link status */
- +} __packed;
- +
- +struct hermes_response {
- + u16 status, resp0, resp1, resp2;
- +};
- +
- +/* "ID" structure - used for ESSID and station nickname */
- +struct hermes_idstring {
- + __le16 len;
- + __le16 val[16];
- +} __packed;
- +
- +struct hermes_multicast {
- + u8 addr[HERMES_MAX_MULTICAST][ETH_ALEN];
- +} __packed;
- +
- +/* Timeouts */
- +#define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us */
- +
- +struct hermes;
- +
- +/* Functions to access hardware */
- +struct hermes_ops {
- + int (*init)(struct hermes *hw);
- + int (*cmd_wait)(struct hermes *hw, u16 cmd, u16 parm0,
- + struct hermes_response *resp);
- + int (*init_cmd_wait)(struct hermes *hw, u16 cmd,
- + u16 parm0, u16 parm1, u16 parm2,
- + struct hermes_response *resp);
- + int (*allocate)(struct hermes *hw, u16 size, u16 *fid);
- + int (*read_ltv)(struct hermes *hw, int bap, u16 rid, unsigned buflen,
- + u16 *length, void *buf);
- + int (*read_ltv_pr)(struct hermes *hw, int bap, u16 rid,
- + unsigned buflen, u16 *length, void *buf);
- + int (*write_ltv)(struct hermes *hw, int bap, u16 rid,
- + u16 length, const void *value);
- + int (*bap_pread)(struct hermes *hw, int bap, void *buf, int len,
- + u16 id, u16 offset);
- + int (*bap_pwrite)(struct hermes *hw, int bap, const void *buf,
- + int len, u16 id, u16 offset);
- + int (*read_pda)(struct hermes *hw, __le16 *pda,
- + u32 pda_addr, u16 pda_len);
- + int (*program_init)(struct hermes *hw, u32 entry_point);
- + int (*program_end)(struct hermes *hw);
- + int (*program)(struct hermes *hw, const char *buf,
- + u32 addr, u32 len);
- + void (*lock_irqsave)(spinlock_t *lock, unsigned long *flags);
- + void (*unlock_irqrestore)(spinlock_t *lock, unsigned long *flags);
- + void (*lock_irq)(spinlock_t *lock);
- + void (*unlock_irq)(spinlock_t *lock);
- +};
- +
- +/* Basic control structure */
- +struct hermes {
- + void __iomem *iobase;
- + int reg_spacing;
- +#define HERMES_16BIT_REGSPACING 0
- +#define HERMES_32BIT_REGSPACING 1
- + u16 inten; /* Which interrupts should be enabled? */
- + bool eeprom_pda;
- + const struct hermes_ops *ops;
- + void *priv;
- +};
- +
- +/* Register access convenience macros */
- +#define hermes_read_reg(hw, off) \
- + (ioread16((hw)->iobase + ((off) << (hw)->reg_spacing)))
- +#define hermes_write_reg(hw, off, val) \
- + (iowrite16((val), (hw)->iobase + ((off) << (hw)->reg_spacing)))
- +#define hermes_read_regn(hw, name) hermes_read_reg((hw), HERMES_##name)
- +#define hermes_write_regn(hw, name, val) \
- + hermes_write_reg((hw), HERMES_##name, (val))
- +
- +/* Function prototypes */
- +void hermes_struct_init(struct hermes *hw, void __iomem *address,
- + int reg_spacing);
- +
- +/* Inline functions */
- +
- +static inline int hermes_present(struct hermes *hw)
- +{
- + return hermes_read_regn(hw, SWSUPPORT0) == HERMES_MAGIC;
- +}
- +
- +static inline void hermes_set_irqmask(struct hermes *hw, u16 events)
- +{
- + hw->inten = events;
- + hermes_write_regn(hw, INTEN, events);
- +}
- +
- +static inline int hermes_enable_port(struct hermes *hw, int port)
- +{
- + return hw->ops->cmd_wait(hw, HERMES_CMD_ENABLE | (port << 8),
- + 0, NULL);
- +}
- +
- +static inline int hermes_disable_port(struct hermes *hw, int port)
- +{
- + return hw->ops->cmd_wait(hw, HERMES_CMD_DISABLE | (port << 8),
- + 0, NULL);
- +}
- +
- +/* Initiate an INQUIRE command (tallies or scan). The result will come as an
- + * information frame in __orinoco_ev_info() */
- +static inline int hermes_inquire(struct hermes *hw, u16 rid)
- +{
- + return hw->ops->cmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL);
- +}
- +
- +#define HERMES_BYTES_TO_RECLEN(n) ((((n) + 1) / 2) + 1)
- +#define HERMES_RECLEN_TO_BYTES(n) (((n) - 1) * 2)
- +
- +/* Note that for the next two, the count is in 16-bit words, not bytes */
- +static inline void hermes_read_words(struct hermes *hw, int off,
- + void *buf, unsigned count)
- +{
- + off = off << hw->reg_spacing;
- + ioread16_rep(hw->iobase + off, buf, count);
- +}
- +
- +static inline void hermes_write_bytes(struct hermes *hw, int off,
- + const char *buf, unsigned count)
- +{
- + off = off << hw->reg_spacing;
- + iowrite16_rep(hw->iobase + off, buf, count >> 1);
- + if (unlikely(count & 1))
- + iowrite8(buf[count - 1], hw->iobase + off);
- +}
- +
- +static inline void hermes_clear_words(struct hermes *hw, int off,
- + unsigned count)
- +{
- + unsigned i;
- +
- + off = off << hw->reg_spacing;
- +
- + for (i = 0; i < count; i++)
- + iowrite16(0, hw->iobase + off);
- +}
- +
- +#define HERMES_READ_RECORD(hw, bap, rid, buf) \
- + (hw->ops->read_ltv((hw), (bap), (rid), sizeof(*buf), NULL, (buf)))
- +#define HERMES_READ_RECORD_PR(hw, bap, rid, buf) \
- + (hw->ops->read_ltv_pr((hw), (bap), (rid), sizeof(*buf), NULL, (buf)))
- +#define HERMES_WRITE_RECORD(hw, bap, rid, buf) \
- + (hw->ops->write_ltv((hw), (bap), (rid), \
- + HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf)))
- +
- +static inline int hermes_read_wordrec(struct hermes *hw, int bap, u16 rid,
- + u16 *word)
- +{
- + __le16 rec;
- + int err;
- +
- + err = HERMES_READ_RECORD(hw, bap, rid, &rec);
- + *word = le16_to_cpu(rec);
- + return err;
- +}
- +
- +static inline int hermes_read_wordrec_pr(struct hermes *hw, int bap, u16 rid,
- + u16 *word)
- +{
- + __le16 rec;
- + int err;
- +
- + err = HERMES_READ_RECORD_PR(hw, bap, rid, &rec);
- + *word = le16_to_cpu(rec);
- + return err;
- +}
- +
- +static inline int hermes_write_wordrec(struct hermes *hw, int bap, u16 rid,
- + u16 word)
- +{
- + __le16 rec = cpu_to_le16(word);
- + return HERMES_WRITE_RECORD(hw, bap, rid, &rec);
- +}
- +
- +#endif /* _HERMES_H */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes_rid.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes_rid.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hermes_rid.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/hermes_rid.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,165 @@
- +#ifndef _HERMES_RID_H
- +#define _HERMES_RID_H
- +
- +/*
- + * Configuration RIDs
- + */
- +#define HERMES_RID_CNFPORTTYPE 0xFC00
- +#define HERMES_RID_CNFOWNMACADDR 0xFC01
- +#define HERMES_RID_CNFDESIREDSSID 0xFC02
- +#define HERMES_RID_CNFOWNCHANNEL 0xFC03
- +#define HERMES_RID_CNFOWNSSID 0xFC04
- +#define HERMES_RID_CNFOWNATIMWINDOW 0xFC05
- +#define HERMES_RID_CNFSYSTEMSCALE 0xFC06
- +#define HERMES_RID_CNFMAXDATALEN 0xFC07
- +#define HERMES_RID_CNFWDSADDRESS 0xFC08
- +#define HERMES_RID_CNFPMENABLED 0xFC09
- +#define HERMES_RID_CNFPMEPS 0xFC0A
- +#define HERMES_RID_CNFMULTICASTRECEIVE 0xFC0B
- +#define HERMES_RID_CNFMAXSLEEPDURATION 0xFC0C
- +#define HERMES_RID_CNFPMHOLDOVERDURATION 0xFC0D
- +#define HERMES_RID_CNFOWNNAME 0xFC0E
- +#define HERMES_RID_CNFOWNDTIMPERIOD 0xFC10
- +#define HERMES_RID_CNFWDSADDRESS1 0xFC11
- +#define HERMES_RID_CNFWDSADDRESS2 0xFC12
- +#define HERMES_RID_CNFWDSADDRESS3 0xFC13
- +#define HERMES_RID_CNFWDSADDRESS4 0xFC14
- +#define HERMES_RID_CNFWDSADDRESS5 0xFC15
- +#define HERMES_RID_CNFWDSADDRESS6 0xFC16
- +#define HERMES_RID_CNFMULTICASTPMBUFFERING 0xFC17
- +#define HERMES_RID_CNFWEPENABLED_AGERE 0xFC20
- +#define HERMES_RID_CNFAUTHENTICATION_AGERE 0xFC21
- +#define HERMES_RID_CNFMANDATORYBSSID_SYMBOL 0xFC21
- +#define HERMES_RID_CNFDROPUNENCRYPTED 0xFC22
- +#define HERMES_RID_CNFWEPDEFAULTKEYID 0xFC23
- +#define HERMES_RID_CNFDEFAULTKEY0 0xFC24
- +#define HERMES_RID_CNFDEFAULTKEY1 0xFC25
- +#define HERMES_RID_CNFMWOROBUST_AGERE 0xFC25
- +#define HERMES_RID_CNFDEFAULTKEY2 0xFC26
- +#define HERMES_RID_CNFDEFAULTKEY3 0xFC27
- +#define HERMES_RID_CNFWEPFLAGS_INTERSIL 0xFC28
- +#define HERMES_RID_CNFWEPKEYMAPPINGTABLE 0xFC29
- +#define HERMES_RID_CNFAUTHENTICATION 0xFC2A
- +#define HERMES_RID_CNFMAXASSOCSTA 0xFC2B
- +#define HERMES_RID_CNFKEYLENGTH_SYMBOL 0xFC2B
- +#define HERMES_RID_CNFTXCONTROL 0xFC2C
- +#define HERMES_RID_CNFROAMINGMODE 0xFC2D
- +#define HERMES_RID_CNFHOSTAUTHENTICATION 0xFC2E
- +#define HERMES_RID_CNFRCVCRCERROR 0xFC30
- +#define HERMES_RID_CNFMMLIFE 0xFC31
- +#define HERMES_RID_CNFALTRETRYCOUNT 0xFC32
- +#define HERMES_RID_CNFBEACONINT 0xFC33
- +#define HERMES_RID_CNFAPPCFINFO 0xFC34
- +#define HERMES_RID_CNFSTAPCFINFO 0xFC35
- +#define HERMES_RID_CNFPRIORITYQUSAGE 0xFC37
- +#define HERMES_RID_CNFTIMCTRL 0xFC40
- +#define HERMES_RID_CNFTHIRTY2TALLY 0xFC42
- +#define HERMES_RID_CNFENHSECURITY 0xFC43
- +#define HERMES_RID_CNFGROUPADDRESSES 0xFC80
- +#define HERMES_RID_CNFCREATEIBSS 0xFC81
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD 0xFC82
- +#define HERMES_RID_CNFRTSTHRESHOLD 0xFC83
- +#define HERMES_RID_CNFTXRATECONTROL 0xFC84
- +#define HERMES_RID_CNFPROMISCUOUSMODE 0xFC85
- +#define HERMES_RID_CNFBASICRATES_SYMBOL 0xFC8A
- +#define HERMES_RID_CNFPREAMBLE_SYMBOL 0xFC8C
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD0 0xFC90
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD1 0xFC91
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD2 0xFC92
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD3 0xFC93
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD4 0xFC94
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD5 0xFC95
- +#define HERMES_RID_CNFFRAGMENTATIONTHRESHOLD6 0xFC96
- +#define HERMES_RID_CNFRTSTHRESHOLD0 0xFC97
- +#define HERMES_RID_CNFRTSTHRESHOLD1 0xFC98
- +#define HERMES_RID_CNFRTSTHRESHOLD2 0xFC99
- +#define HERMES_RID_CNFRTSTHRESHOLD3 0xFC9A
- +#define HERMES_RID_CNFRTSTHRESHOLD4 0xFC9B
- +#define HERMES_RID_CNFRTSTHRESHOLD5 0xFC9C
- +#define HERMES_RID_CNFRTSTHRESHOLD6 0xFC9D
- +#define HERMES_RID_CNFHOSTSCAN_SYMBOL 0xFCAB
- +#define HERMES_RID_CNFSHORTPREAMBLE 0xFCB0
- +#define HERMES_RID_CNFWEPKEYS_AGERE 0xFCB0
- +#define HERMES_RID_CNFEXCLUDELONGPREAMBLE 0xFCB1
- +#define HERMES_RID_CNFTXKEY_AGERE 0xFCB1
- +#define HERMES_RID_CNFAUTHENTICATIONRSPTO 0xFCB2
- +#define HERMES_RID_CNFSCANSSID_AGERE 0xFCB2
- +#define HERMES_RID_CNFBASICRATES 0xFCB3
- +#define HERMES_RID_CNFSUPPORTEDRATES 0xFCB4
- +#define HERMES_RID_CNFADDDEFAULTTKIPKEY_AGERE 0xFCB4
- +#define HERMES_RID_CNFSETWPAAUTHMGMTSUITE_AGERE 0xFCB5
- +#define HERMES_RID_CNFREMDEFAULTTKIPKEY_AGERE 0xFCB6
- +#define HERMES_RID_CNFADDMAPPEDTKIPKEY_AGERE 0xFCB7
- +#define HERMES_RID_CNFREMMAPPEDTKIPKEY_AGERE 0xFCB8
- +#define HERMES_RID_CNFSETWPACAPABILITIES_AGERE 0xFCB9
- +#define HERMES_RID_CNFCACHEDPMKADDRESS 0xFCBA
- +#define HERMES_RID_CNFREMOVEPMKADDRESS 0xFCBB
- +#define HERMES_RID_CNFSCANCHANNELS2GHZ 0xFCC2
- +#define HERMES_RID_CNFDISASSOCIATE 0xFCC8
- +#define HERMES_RID_CNFTICKTIME 0xFCE0
- +#define HERMES_RID_CNFSCANREQUEST 0xFCE1
- +#define HERMES_RID_CNFJOINREQUEST 0xFCE2
- +#define HERMES_RID_CNFAUTHENTICATESTATION 0xFCE3
- +#define HERMES_RID_CNFCHANNELINFOREQUEST 0xFCE4
- +#define HERMES_RID_CNFHOSTSCAN 0xFCE5
- +
- +/*
- + * Information RIDs
- + */
- +#define HERMES_RID_MAXLOADTIME 0xFD00
- +#define HERMES_RID_DOWNLOADBUFFER 0xFD01
- +#define HERMES_RID_PRIID 0xFD02
- +#define HERMES_RID_PRISUPRANGE 0xFD03
- +#define HERMES_RID_CFIACTRANGES 0xFD04
- +#define HERMES_RID_NICSERNUM 0xFD0A
- +#define HERMES_RID_NICID 0xFD0B
- +#define HERMES_RID_MFISUPRANGE 0xFD0C
- +#define HERMES_RID_CFISUPRANGE 0xFD0D
- +#define HERMES_RID_CHANNELLIST 0xFD10
- +#define HERMES_RID_REGULATORYDOMAINS 0xFD11
- +#define HERMES_RID_TEMPTYPE 0xFD12
- +#define HERMES_RID_CIS 0xFD13
- +#define HERMES_RID_STAID 0xFD20
- +#define HERMES_RID_STASUPRANGE 0xFD21
- +#define HERMES_RID_MFIACTRANGES 0xFD22
- +#define HERMES_RID_CFIACTRANGES2 0xFD23
- +#define HERMES_RID_SECONDARYVERSION_SYMBOL 0xFD24
- +#define HERMES_RID_PORTSTATUS 0xFD40
- +#define HERMES_RID_CURRENTSSID 0xFD41
- +#define HERMES_RID_CURRENTBSSID 0xFD42
- +#define HERMES_RID_COMMSQUALITY 0xFD43
- +#define HERMES_RID_CURRENTTXRATE 0xFD44
- +#define HERMES_RID_CURRENTBEACONINTERVAL 0xFD45
- +#define HERMES_RID_CURRENTSCALETHRESHOLDS 0xFD46
- +#define HERMES_RID_PROTOCOLRSPTIME 0xFD47
- +#define HERMES_RID_SHORTRETRYLIMIT 0xFD48
- +#define HERMES_RID_LONGRETRYLIMIT 0xFD49
- +#define HERMES_RID_MAXTRANSMITLIFETIME 0xFD4A
- +#define HERMES_RID_MAXRECEIVELIFETIME 0xFD4B
- +#define HERMES_RID_CFPOLLABLE 0xFD4C
- +#define HERMES_RID_AUTHENTICATIONALGORITHMS 0xFD4D
- +#define HERMES_RID_PRIVACYOPTIONIMPLEMENTED 0xFD4F
- +#define HERMES_RID_DBMCOMMSQUALITY_INTERSIL 0xFD51
- +#define HERMES_RID_CURRENTTXRATE1 0xFD80
- +#define HERMES_RID_CURRENTTXRATE2 0xFD81
- +#define HERMES_RID_CURRENTTXRATE3 0xFD82
- +#define HERMES_RID_CURRENTTXRATE4 0xFD83
- +#define HERMES_RID_CURRENTTXRATE5 0xFD84
- +#define HERMES_RID_CURRENTTXRATE6 0xFD85
- +#define HERMES_RID_OWNMACADDR 0xFD86
- +#define HERMES_RID_SCANRESULTSTABLE 0xFD88
- +#define HERMES_RID_CURRENT_COUNTRY_INFO 0xFD89
- +#define HERMES_RID_CURRENT_WPA_IE 0xFD8A
- +#define HERMES_RID_CURRENT_TKIP_IV 0xFD8B
- +#define HERMES_RID_CURRENT_ASSOC_REQ_INFO 0xFD8C
- +#define HERMES_RID_CURRENT_ASSOC_RESP_INFO 0xFD8D
- +#define HERMES_RID_TXQUEUEEMPTY 0xFD91
- +#define HERMES_RID_PHYTYPE 0xFDC0
- +#define HERMES_RID_CURRENTCHANNEL 0xFDC1
- +#define HERMES_RID_CURRENTPOWERSTATE 0xFDC2
- +#define HERMES_RID_CCAMODE 0xFDC3
- +#define HERMES_RID_SUPPORTEDDATARATES 0xFDC6
- +#define HERMES_RID_BUILDSEQ 0xFFFE
- +#define HERMES_RID_FWID 0xFFFF
- +
- +#endif
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hw.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/hw.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hw.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/hw.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,1362 @@
- +/* Encapsulate basic setting changes and retrieval on Hermes hardware
- + *
- + * See copyright notice in main.c
- + */
- +#include <linux/kernel.h>
- +#include <linux/device.h>
- +#include <linux/if_arp.h>
- +#include <linux/ieee80211.h>
- +#include <linux/wireless.h>
- +#include <net/cfg80211.h>
- +#include "hermes.h"
- +#include "hermes_rid.h"
- +#include "orinoco.h"
- +
- +#include "hw.h"
- +
- +#define SYMBOL_MAX_VER_LEN (14)
- +
- +/* Symbol firmware has a bug allocating buffers larger than this */
- +#define TX_NICBUF_SIZE_BUG 1585
- +
- +/********************************************************************/
- +/* Data tables */
- +/********************************************************************/
- +
- +/* This tables gives the actual meanings of the bitrate IDs returned
- + * by the firmware. */
- +static const struct {
- + int bitrate; /* in 100s of kilobits */
- + int automatic;
- + u16 agere_txratectrl;
- + u16 intersil_txratectrl;
- +} bitrate_table[] = {
- + {110, 1, 3, 15}, /* Entry 0 is the default */
- + {10, 0, 1, 1},
- + {10, 1, 1, 1},
- + {20, 0, 2, 2},
- + {20, 1, 6, 3},
- + {55, 0, 4, 4},
- + {55, 1, 7, 7},
- + {110, 0, 5, 8},
- +};
- +#define BITRATE_TABLE_SIZE ARRAY_SIZE(bitrate_table)
- +
- +/* Firmware version encoding */
- +struct comp_id {
- + u16 id, variant, major, minor;
- +} __packed;
- +
- +static inline enum fwtype determine_firmware_type(struct comp_id *nic_id)
- +{
- + if (nic_id->id < 0x8000)
- + return FIRMWARE_TYPE_AGERE;
- + else if (nic_id->id == 0x8000 && nic_id->major == 0)
- + return FIRMWARE_TYPE_SYMBOL;
- + else
- + return FIRMWARE_TYPE_INTERSIL;
- +}
- +
- +/* Set priv->firmware type, determine firmware properties
- + * This function can be called before we have registerred with netdev,
- + * so all errors go out with dev_* rather than printk
- + *
- + * If non-NULL stores a firmware description in fw_name.
- + * If non-NULL stores a HW version in hw_ver
- + *
- + * These are output via generic cfg80211 ethtool support.
- + */
- +int determine_fw_capabilities(struct orinoco_private *priv,
- + char *fw_name, size_t fw_name_len,
- + u32 *hw_ver)
- +{
- + struct device *dev = priv->dev;
- + struct hermes *hw = &priv->hw;
- + int err;
- + struct comp_id nic_id, sta_id;
- + unsigned int firmver;
- + char tmp[SYMBOL_MAX_VER_LEN + 1] __attribute__((aligned(2)));
- +
- + /* Get the hardware version */
- + err = HERMES_READ_RECORD_PR(hw, USER_BAP, HERMES_RID_NICID, &nic_id);
- + if (err) {
- + dev_err(dev, "Cannot read hardware identity: error %d\n",
- + err);
- + return err;
- + }
- +
- + le16_to_cpus(&nic_id.id);
- + le16_to_cpus(&nic_id.variant);
- + le16_to_cpus(&nic_id.major);
- + le16_to_cpus(&nic_id.minor);
- + dev_info(dev, "Hardware identity %04x:%04x:%04x:%04x\n",
- + nic_id.id, nic_id.variant, nic_id.major, nic_id.minor);
- +
- + if (hw_ver)
- + *hw_ver = (((nic_id.id & 0xff) << 24) |
- + ((nic_id.variant & 0xff) << 16) |
- + ((nic_id.major & 0xff) << 8) |
- + (nic_id.minor & 0xff));
- +
- + priv->firmware_type = determine_firmware_type(&nic_id);
- +
- + /* Get the firmware version */
- + err = HERMES_READ_RECORD_PR(hw, USER_BAP, HERMES_RID_STAID, &sta_id);
- + if (err) {
- + dev_err(dev, "Cannot read station identity: error %d\n",
- + err);
- + return err;
- + }
- +
- + le16_to_cpus(&sta_id.id);
- + le16_to_cpus(&sta_id.variant);
- + le16_to_cpus(&sta_id.major);
- + le16_to_cpus(&sta_id.minor);
- + dev_info(dev, "Station identity %04x:%04x:%04x:%04x\n",
- + sta_id.id, sta_id.variant, sta_id.major, sta_id.minor);
- +
- + switch (sta_id.id) {
- + case 0x15:
- + dev_err(dev, "Primary firmware is active\n");
- + return -ENODEV;
- + case 0x14b:
- + dev_err(dev, "Tertiary firmware is active\n");
- + return -ENODEV;
- + case 0x1f: /* Intersil, Agere, Symbol Spectrum24 */
- + case 0x21: /* Symbol Spectrum24 Trilogy */
- + break;
- + default:
- + dev_notice(dev, "Unknown station ID, please report\n");
- + break;
- + }
- +
- + /* Default capabilities */
- + priv->has_sensitivity = 1;
- + priv->has_mwo = 0;
- + priv->has_preamble = 0;
- + priv->has_port3 = 1;
- + priv->has_ibss = 1;
- + priv->has_wep = 0;
- + priv->has_big_wep = 0;
- + priv->has_alt_txcntl = 0;
- + priv->has_ext_scan = 0;
- + priv->has_wpa = 0;
- + priv->do_fw_download = 0;
- +
- + /* Determine capabilities from the firmware version */
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE:
- + /* Lucent Wavelan IEEE, Lucent Orinoco, Cabletron RoamAbout,
- + ELSA, Melco, HP, IBM, Dell 1150, Compaq 110/210 */
- + if (fw_name)
- + snprintf(fw_name, fw_name_len, "Lucent/Agere %d.%02d",
- + sta_id.major, sta_id.minor);
- +
- + firmver = ((unsigned long)sta_id.major << 16) | sta_id.minor;
- +
- + priv->has_ibss = (firmver >= 0x60006);
- + priv->has_wep = (firmver >= 0x40020);
- + priv->has_big_wep = 1; /* FIXME: this is wrong - how do we tell
- + Gold cards from the others? */
- + priv->has_mwo = (firmver >= 0x60000);
- + priv->has_pm = (firmver >= 0x40020); /* Don't work in 7.52 ? */
- + priv->ibss_port = 1;
- + priv->has_hostscan = (firmver >= 0x8000a);
- + priv->do_fw_download = 1;
- + priv->broken_monitor = (firmver >= 0x80000);
- + priv->has_alt_txcntl = (firmver >= 0x90000); /* All 9.x ? */
- + priv->has_ext_scan = (firmver >= 0x90000); /* All 9.x ? */
- + priv->has_wpa = (firmver >= 0x9002a);
- + /* Tested with Agere firmware :
- + * 1.16 ; 4.08 ; 4.52 ; 6.04 ; 6.16 ; 7.28 => Jean II
- + * Tested CableTron firmware : 4.32 => Anton */
- + break;
- + case FIRMWARE_TYPE_SYMBOL:
- + /* Symbol , 3Com AirConnect, Intel, Ericsson WLAN */
- + /* Intel MAC : 00:02:B3:* */
- + /* 3Com MAC : 00:50:DA:* */
- + memset(tmp, 0, sizeof(tmp));
- + /* Get the Symbol firmware version */
- + err = hw->ops->read_ltv_pr(hw, USER_BAP,
- + HERMES_RID_SECONDARYVERSION_SYMBOL,
- + SYMBOL_MAX_VER_LEN, NULL, &tmp);
- + if (err) {
- + dev_warn(dev, "Error %d reading Symbol firmware info. "
- + "Wildly guessing capabilities...\n", err);
- + firmver = 0;
- + tmp[0] = '\0';
- + } else {
- + /* The firmware revision is a string, the format is
- + * something like : "V2.20-01".
- + * Quick and dirty parsing... - Jean II
- + */
- + firmver = ((tmp[1] - '0') << 16)
- + | ((tmp[3] - '0') << 12)
- + | ((tmp[4] - '0') << 8)
- + | ((tmp[6] - '0') << 4)
- + | (tmp[7] - '0');
- +
- + tmp[SYMBOL_MAX_VER_LEN] = '\0';
- + }
- +
- + if (fw_name)
- + snprintf(fw_name, fw_name_len, "Symbol %s", tmp);
- +
- + priv->has_ibss = (firmver >= 0x20000);
- + priv->has_wep = (firmver >= 0x15012);
- + priv->has_big_wep = (firmver >= 0x20000);
- + priv->has_pm = (firmver >= 0x20000 && firmver < 0x22000) ||
- + (firmver >= 0x29000 && firmver < 0x30000) ||
- + firmver >= 0x31000;
- + priv->has_preamble = (firmver >= 0x20000);
- + priv->ibss_port = 4;
- +
- + /* Symbol firmware is found on various cards, but
- + * there has been no attempt to check firmware
- + * download on non-spectrum_cs based cards.
- + *
- + * Given that the Agere firmware download works
- + * differently, we should avoid doing a firmware
- + * download with the Symbol algorithm on non-spectrum
- + * cards.
- + *
- + * For now we can identify a spectrum_cs based card
- + * because it has a firmware reset function.
- + */
- + priv->do_fw_download = (priv->stop_fw != NULL);
- +
- + priv->broken_disableport = (firmver == 0x25013) ||
- + (firmver >= 0x30000 && firmver <= 0x31000);
- + priv->has_hostscan = (firmver >= 0x31001) ||
- + (firmver >= 0x29057 && firmver < 0x30000);
- + /* Tested with Intel firmware : 0x20015 => Jean II */
- + /* Tested with 3Com firmware : 0x15012 & 0x22001 => Jean II */
- + break;
- + case FIRMWARE_TYPE_INTERSIL:
- + /* D-Link, Linksys, Adtron, ZoomAir, and many others...
- + * Samsung, Compaq 100/200 and Proxim are slightly
- + * different and less well tested */
- + /* D-Link MAC : 00:40:05:* */
- + /* Addtron MAC : 00:90:D1:* */
- + if (fw_name)
- + snprintf(fw_name, fw_name_len, "Intersil %d.%d.%d",
- + sta_id.major, sta_id.minor, sta_id.variant);
- +
- + firmver = ((unsigned long)sta_id.major << 16) |
- + ((unsigned long)sta_id.minor << 8) | sta_id.variant;
- +
- + priv->has_ibss = (firmver >= 0x000700); /* FIXME */
- + priv->has_big_wep = priv->has_wep = (firmver >= 0x000800);
- + priv->has_pm = (firmver >= 0x000700);
- + priv->has_hostscan = (firmver >= 0x010301);
- +
- + if (firmver >= 0x000800)
- + priv->ibss_port = 0;
- + else {
- + dev_notice(dev, "Intersil firmware earlier than v0.8.x"
- + " - several features not supported\n");
- + priv->ibss_port = 1;
- + }
- + break;
- + }
- + if (fw_name)
- + dev_info(dev, "Firmware determined as %s\n", fw_name);
- +
- +#ifndef CONFIG_HERMES_PRISM
- + if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL) {
- + dev_err(dev, "Support for Prism chipset is not enabled\n");
- + return -ENODEV;
- + }
- +#endif
- +
- + return 0;
- +}
- +
- +/* Read settings from EEPROM into our private structure.
- + * MAC address gets dropped into callers buffer
- + * Can be called before netdev registration.
- + */
- +int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr)
- +{
- + struct device *dev = priv->dev;
- + struct hermes_idstring nickbuf;
- + struct hermes *hw = &priv->hw;
- + int len;
- + int err;
- + u16 reclen;
- +
- + /* Get the MAC address */
- + err = hw->ops->read_ltv_pr(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
- + ETH_ALEN, NULL, dev_addr);
- + if (err) {
- + dev_warn(dev, "Failed to read MAC address!\n");
- + goto out;
- + }
- +
- + dev_dbg(dev, "MAC address %pM\n", dev_addr);
- +
- + /* Get the station name */
- + err = hw->ops->read_ltv_pr(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
- + sizeof(nickbuf), &reclen, &nickbuf);
- + if (err) {
- + dev_err(dev, "failed to read station name\n");
- + goto out;
- + }
- + if (nickbuf.len)
- + len = min(IW_ESSID_MAX_SIZE, (int)le16_to_cpu(nickbuf.len));
- + else
- + len = min(IW_ESSID_MAX_SIZE, 2 * reclen);
- + memcpy(priv->nick, &nickbuf.val, len);
- + priv->nick[len] = '\0';
- +
- + dev_dbg(dev, "Station name \"%s\"\n", priv->nick);
- +
- + /* Get allowed channels */
- + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CHANNELLIST,
- + &priv->channel_mask);
- + if (err) {
- + dev_err(dev, "Failed to read channel list!\n");
- + goto out;
- + }
- +
- + /* Get initial AP density */
- + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE,
- + &priv->ap_density);
- + if (err || priv->ap_density < 1 || priv->ap_density > 3)
- + priv->has_sensitivity = 0;
- +
- + /* Get initial RTS threshold */
- + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD,
- + &priv->rts_thresh);
- + if (err) {
- + dev_err(dev, "Failed to read RTS threshold!\n");
- + goto out;
- + }
- +
- + /* Get initial fragmentation settings */
- + if (priv->has_mwo)
- + err = hermes_read_wordrec_pr(hw, USER_BAP,
- + HERMES_RID_CNFMWOROBUST_AGERE,
- + &priv->mwo_robust);
- + else
- + err = hermes_read_wordrec_pr(hw, USER_BAP,
- + HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
- + &priv->frag_thresh);
- + if (err) {
- + dev_err(dev, "Failed to read fragmentation settings!\n");
- + goto out;
- + }
- +
- + /* Power management setup */
- + if (priv->has_pm) {
- + priv->pm_on = 0;
- + priv->pm_mcast = 1;
- + err = hermes_read_wordrec_pr(hw, USER_BAP,
- + HERMES_RID_CNFMAXSLEEPDURATION,
- + &priv->pm_period);
- + if (err) {
- + dev_err(dev, "Failed to read power management "
- + "period!\n");
- + goto out;
- + }
- + err = hermes_read_wordrec_pr(hw, USER_BAP,
- + HERMES_RID_CNFPMHOLDOVERDURATION,
- + &priv->pm_timeout);
- + if (err) {
- + dev_err(dev, "Failed to read power management "
- + "timeout!\n");
- + goto out;
- + }
- + }
- +
- + /* Preamble setup */
- + if (priv->has_preamble) {
- + err = hermes_read_wordrec_pr(hw, USER_BAP,
- + HERMES_RID_CNFPREAMBLE_SYMBOL,
- + &priv->preamble);
- + if (err) {
- + dev_err(dev, "Failed to read preamble setup\n");
- + goto out;
- + }
- + }
- +
- + /* Retry settings */
- + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_SHORTRETRYLIMIT,
- + &priv->short_retry_limit);
- + if (err) {
- + dev_err(dev, "Failed to read short retry limit\n");
- + goto out;
- + }
- +
- + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_LONGRETRYLIMIT,
- + &priv->long_retry_limit);
- + if (err) {
- + dev_err(dev, "Failed to read long retry limit\n");
- + goto out;
- + }
- +
- + err = hermes_read_wordrec_pr(hw, USER_BAP, HERMES_RID_MAXTRANSMITLIFETIME,
- + &priv->retry_lifetime);
- + if (err) {
- + dev_err(dev, "Failed to read max retry lifetime\n");
- + goto out;
- + }
- +
- +out:
- + return err;
- +}
- +
- +/* Can be called before netdev registration */
- +int orinoco_hw_allocate_fid(struct orinoco_private *priv)
- +{
- + struct device *dev = priv->dev;
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + err = hw->ops->allocate(hw, priv->nicbuf_size, &priv->txfid);
- + if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) {
- + /* Try workaround for old Symbol firmware bug */
- + priv->nicbuf_size = TX_NICBUF_SIZE_BUG;
- + err = hw->ops->allocate(hw, priv->nicbuf_size, &priv->txfid);
- +
- + dev_warn(dev, "Firmware ALLOC bug detected "
- + "(old Symbol firmware?). Work around %s\n",
- + err ? "failed!" : "ok.");
- + }
- +
- + return err;
- +}
- +
- +int orinoco_get_bitratemode(int bitrate, int automatic)
- +{
- + int ratemode = -1;
- + int i;
- +
- + if ((bitrate != 10) && (bitrate != 20) &&
- + (bitrate != 55) && (bitrate != 110))
- + return ratemode;
- +
- + for (i = 0; i < BITRATE_TABLE_SIZE; i++) {
- + if ((bitrate_table[i].bitrate == bitrate) &&
- + (bitrate_table[i].automatic == automatic)) {
- + ratemode = i;
- + break;
- + }
- + }
- + return ratemode;
- +}
- +
- +void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic)
- +{
- + BUG_ON((ratemode < 0) || (ratemode >= BITRATE_TABLE_SIZE));
- +
- + *bitrate = bitrate_table[ratemode].bitrate * 100000;
- + *automatic = bitrate_table[ratemode].automatic;
- +}
- +
- +int orinoco_hw_program_rids(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + struct wireless_dev *wdev = netdev_priv(dev);
- + struct hermes *hw = &priv->hw;
- + int err;
- + struct hermes_idstring idbuf;
- +
- + /* Set the MAC address */
- + err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR,
- + HERMES_BYTES_TO_RECLEN(ETH_ALEN),
- + dev->dev_addr);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting MAC address\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Set up the link mode */
- + err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFPORTTYPE,
- + priv->port_type);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting port type\n",
- + dev->name, err);
- + return err;
- + }
- + /* Set the channel/frequency */
- + if (priv->channel != 0 && priv->iw_mode != NL80211_IFTYPE_STATION) {
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFOWNCHANNEL,
- + priv->channel);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting channel %d\n",
- + dev->name, err, priv->channel);
- + return err;
- + }
- + }
- +
- + if (priv->has_ibss) {
- + u16 createibss;
- +
- + if ((strlen(priv->desired_essid) == 0) && (priv->createibss)) {
- + printk(KERN_WARNING "%s: This firmware requires an "
- + "ESSID in IBSS-Ad-Hoc mode.\n", dev->name);
- + /* With wvlan_cs, in this case, we would crash.
- + * hopefully, this driver will behave better...
- + * Jean II */
- + createibss = 0;
- + } else {
- + createibss = priv->createibss;
- + }
- +
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFCREATEIBSS,
- + createibss);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting CREATEIBSS\n",
- + dev->name, err);
- + return err;
- + }
- + }
- +
- + /* Set the desired BSSID */
- + err = __orinoco_hw_set_wap(priv);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting AP address\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Set the desired ESSID */
- + idbuf.len = cpu_to_le16(strlen(priv->desired_essid));
- + memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val));
- + /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */
- + err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID,
- + HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid) + 2),
- + &idbuf);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting OWNSSID\n",
- + dev->name, err);
- + return err;
- + }
- + err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID,
- + HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid) + 2),
- + &idbuf);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting DESIREDSSID\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Set the station name */
- + idbuf.len = cpu_to_le16(strlen(priv->nick));
- + memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val));
- + err = hw->ops->write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME,
- + HERMES_BYTES_TO_RECLEN(strlen(priv->nick) + 2),
- + &idbuf);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting nickname\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Set AP density */
- + if (priv->has_sensitivity) {
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFSYSTEMSCALE,
- + priv->ap_density);
- + if (err) {
- + printk(KERN_WARNING "%s: Error %d setting SYSTEMSCALE. "
- + "Disabling sensitivity control\n",
- + dev->name, err);
- +
- + priv->has_sensitivity = 0;
- + }
- + }
- +
- + /* Set RTS threshold */
- + err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD,
- + priv->rts_thresh);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting RTS threshold\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Set fragmentation threshold or MWO robustness */
- + if (priv->has_mwo)
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFMWOROBUST_AGERE,
- + priv->mwo_robust);
- + else
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFFRAGMENTATIONTHRESHOLD,
- + priv->frag_thresh);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting fragmentation\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Set bitrate */
- + err = __orinoco_hw_set_bitrate(priv);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting bitrate\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Set power management */
- + if (priv->has_pm) {
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFPMENABLED,
- + priv->pm_on);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting up PM\n",
- + dev->name, err);
- + return err;
- + }
- +
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFMULTICASTRECEIVE,
- + priv->pm_mcast);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting up PM\n",
- + dev->name, err);
- + return err;
- + }
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFMAXSLEEPDURATION,
- + priv->pm_period);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting up PM\n",
- + dev->name, err);
- + return err;
- + }
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFPMHOLDOVERDURATION,
- + priv->pm_timeout);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting up PM\n",
- + dev->name, err);
- + return err;
- + }
- + }
- +
- + /* Set preamble - only for Symbol so far... */
- + if (priv->has_preamble) {
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFPREAMBLE_SYMBOL,
- + priv->preamble);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting preamble\n",
- + dev->name, err);
- + return err;
- + }
- + }
- +
- + /* Set up encryption */
- + if (priv->has_wep || priv->has_wpa) {
- + err = __orinoco_hw_setup_enc(priv);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d activating encryption\n",
- + dev->name, err);
- + return err;
- + }
- + }
- +
- + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
- + /* Enable monitor mode */
- + dev->type = ARPHRD_IEEE80211;
- + err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
- + HERMES_TEST_MONITOR, 0, NULL);
- + } else {
- + /* Disable monitor mode */
- + dev->type = ARPHRD_ETHER;
- + err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
- + HERMES_TEST_STOP, 0, NULL);
- + }
- + if (err)
- + return err;
- +
- + /* Reset promiscuity / multicast*/
- + priv->promiscuous = 0;
- + priv->mc_count = 0;
- +
- + /* Record mode change */
- + wdev->iftype = priv->iw_mode;
- +
- + return 0;
- +}
- +
- +/* Get tsc from the firmware */
- +int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc)
- +{
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- + u8 tsc_arr[4][ORINOCO_SEQ_LEN];
- +
- + if ((key < 0) || (key >= 4))
- + return -EINVAL;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_TKIP_IV,
- + sizeof(tsc_arr), NULL, &tsc_arr);
- + if (!err)
- + memcpy(tsc, &tsc_arr[key][0], sizeof(tsc_arr[0]));
- +
- + return err;
- +}
- +
- +int __orinoco_hw_set_bitrate(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + int ratemode = priv->bitratemode;
- + int err = 0;
- +
- + if (ratemode >= BITRATE_TABLE_SIZE) {
- + printk(KERN_ERR "%s: BUG: Invalid bitrate mode %d\n",
- + priv->ndev->name, ratemode);
- + return -EINVAL;
- + }
- +
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE:
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFTXRATECONTROL,
- + bitrate_table[ratemode].agere_txratectrl);
- + break;
- + case FIRMWARE_TYPE_INTERSIL:
- + case FIRMWARE_TYPE_SYMBOL:
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFTXRATECONTROL,
- + bitrate_table[ratemode].intersil_txratectrl);
- + break;
- + default:
- + BUG();
- + }
- +
- + return err;
- +}
- +
- +int orinoco_hw_get_act_bitrate(struct orinoco_private *priv, int *bitrate)
- +{
- + struct hermes *hw = &priv->hw;
- + int i;
- + int err = 0;
- + u16 val;
- +
- + err = hermes_read_wordrec(hw, USER_BAP,
- + HERMES_RID_CURRENTTXRATE, &val);
- + if (err)
- + return err;
- +
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE: /* Lucent style rate */
- + /* Note : in Lucent firmware, the return value of
- + * HERMES_RID_CURRENTTXRATE is the bitrate in Mb/s,
- + * and therefore is totally different from the
- + * encoding of HERMES_RID_CNFTXRATECONTROL.
- + * Don't forget that 6Mb/s is really 5.5Mb/s */
- + if (val == 6)
- + *bitrate = 5500000;
- + else
- + *bitrate = val * 1000000;
- + break;
- + case FIRMWARE_TYPE_INTERSIL: /* Intersil style rate */
- + case FIRMWARE_TYPE_SYMBOL: /* Symbol style rate */
- + for (i = 0; i < BITRATE_TABLE_SIZE; i++)
- + if (bitrate_table[i].intersil_txratectrl == val) {
- + *bitrate = bitrate_table[i].bitrate * 100000;
- + break;
- + }
- +
- + if (i >= BITRATE_TABLE_SIZE) {
- + printk(KERN_INFO "%s: Unable to determine current bitrate (0x%04hx)\n",
- + priv->ndev->name, val);
- + err = -EIO;
- + }
- +
- + break;
- + default:
- + BUG();
- + }
- +
- + return err;
- +}
- +
- +/* Set fixed AP address */
- +int __orinoco_hw_set_wap(struct orinoco_private *priv)
- +{
- + int roaming_flag;
- + int err = 0;
- + struct hermes *hw = &priv->hw;
- +
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE:
- + /* not supported */
- + break;
- + case FIRMWARE_TYPE_INTERSIL:
- + if (priv->bssid_fixed)
- + roaming_flag = 2;
- + else
- + roaming_flag = 1;
- +
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFROAMINGMODE,
- + roaming_flag);
- + break;
- + case FIRMWARE_TYPE_SYMBOL:
- + err = HERMES_WRITE_RECORD(hw, USER_BAP,
- + HERMES_RID_CNFMANDATORYBSSID_SYMBOL,
- + &priv->desired_bssid);
- + break;
- + }
- + return err;
- +}
- +
- +/* Change the WEP keys and/or the current keys. Can be called
- + * either from __orinoco_hw_setup_enc() or directly from
- + * orinoco_ioctl_setiwencode(). In the later case the association
- + * with the AP is not broken (if the firmware can handle it),
- + * which is needed for 802.1x implementations. */
- +int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- + int i;
- +
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE:
- + {
- + struct orinoco_key keys[ORINOCO_MAX_KEYS];
- +
- + memset(&keys, 0, sizeof(keys));
- + for (i = 0; i < ORINOCO_MAX_KEYS; i++) {
- + int len = min(priv->keys[i].key_len,
- + ORINOCO_MAX_KEY_SIZE);
- + memcpy(&keys[i].data, priv->keys[i].key, len);
- + if (len > SMALL_KEY_SIZE)
- + keys[i].len = cpu_to_le16(LARGE_KEY_SIZE);
- + else if (len > 0)
- + keys[i].len = cpu_to_le16(SMALL_KEY_SIZE);
- + else
- + keys[i].len = cpu_to_le16(0);
- + }
- +
- + err = HERMES_WRITE_RECORD(hw, USER_BAP,
- + HERMES_RID_CNFWEPKEYS_AGERE,
- + &keys);
- + if (err)
- + return err;
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFTXKEY_AGERE,
- + priv->tx_key);
- + if (err)
- + return err;
- + break;
- + }
- + case FIRMWARE_TYPE_INTERSIL:
- + case FIRMWARE_TYPE_SYMBOL:
- + {
- + int keylen;
- +
- + /* Force uniform key length to work around
- + * firmware bugs */
- + keylen = priv->keys[priv->tx_key].key_len;
- +
- + if (keylen > LARGE_KEY_SIZE) {
- + printk(KERN_ERR "%s: BUG: Key %d has oversize length %d.\n",
- + priv->ndev->name, priv->tx_key, keylen);
- + return -E2BIG;
- + } else if (keylen > SMALL_KEY_SIZE)
- + keylen = LARGE_KEY_SIZE;
- + else if (keylen > 0)
- + keylen = SMALL_KEY_SIZE;
- + else
- + keylen = 0;
- +
- + /* Write all 4 keys */
- + for (i = 0; i < ORINOCO_MAX_KEYS; i++) {
- + u8 key[LARGE_KEY_SIZE] = { 0 };
- +
- + memcpy(key, priv->keys[i].key,
- + priv->keys[i].key_len);
- +
- + err = hw->ops->write_ltv(hw, USER_BAP,
- + HERMES_RID_CNFDEFAULTKEY0 + i,
- + HERMES_BYTES_TO_RECLEN(keylen),
- + key);
- + if (err)
- + return err;
- + }
- +
- + /* Write the index of the key used in transmission */
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFWEPDEFAULTKEYID,
- + priv->tx_key);
- + if (err)
- + return err;
- + }
- + break;
- + }
- +
- + return 0;
- +}
- +
- +int __orinoco_hw_setup_enc(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- + int master_wep_flag;
- + int auth_flag;
- + int enc_flag;
- +
- + /* Setup WEP keys */
- + if (priv->encode_alg == ORINOCO_ALG_WEP)
- + __orinoco_hw_setup_wepkeys(priv);
- +
- + if (priv->wep_restrict)
- + auth_flag = HERMES_AUTH_SHARED_KEY;
- + else
- + auth_flag = HERMES_AUTH_OPEN;
- +
- + if (priv->wpa_enabled)
- + enc_flag = 2;
- + else if (priv->encode_alg == ORINOCO_ALG_WEP)
- + enc_flag = 1;
- + else
- + enc_flag = 0;
- +
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE: /* Agere style WEP */
- + if (priv->encode_alg == ORINOCO_ALG_WEP) {
- + /* Enable the shared-key authentication. */
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFAUTHENTICATION_AGERE,
- + auth_flag);
- + if (err)
- + return err;
- + }
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFWEPENABLED_AGERE,
- + enc_flag);
- + if (err)
- + return err;
- +
- + if (priv->has_wpa) {
- + /* Set WPA key management */
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFSETWPAAUTHMGMTSUITE_AGERE,
- + priv->key_mgmt);
- + if (err)
- + return err;
- + }
- +
- + break;
- +
- + case FIRMWARE_TYPE_INTERSIL: /* Intersil style WEP */
- + case FIRMWARE_TYPE_SYMBOL: /* Symbol style WEP */
- + if (priv->encode_alg == ORINOCO_ALG_WEP) {
- + if (priv->wep_restrict ||
- + (priv->firmware_type == FIRMWARE_TYPE_SYMBOL))
- + master_wep_flag = HERMES_WEP_PRIVACY_INVOKED |
- + HERMES_WEP_EXCL_UNENCRYPTED;
- + else
- + master_wep_flag = HERMES_WEP_PRIVACY_INVOKED;
- +
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFAUTHENTICATION,
- + auth_flag);
- + if (err)
- + return err;
- + } else
- + master_wep_flag = 0;
- +
- + if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
- + master_wep_flag |= HERMES_WEP_HOST_DECRYPT;
- +
- + /* Master WEP setting : on/off */
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFWEPFLAGS_INTERSIL,
- + master_wep_flag);
- + if (err)
- + return err;
- +
- + break;
- + }
- +
- + return 0;
- +}
- +
- +/* key must be 32 bytes, including the tx and rx MIC keys.
- + * rsc must be NULL or up to 8 bytes
- + * tsc must be NULL or up to 8 bytes
- + */
- +int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
- + int set_tx, const u8 *key, size_t key_len,
- + const u8 *rsc, size_t rsc_len,
- + const u8 *tsc, size_t tsc_len)
- +{
- + struct {
- + __le16 idx;
- + u8 rsc[ORINOCO_SEQ_LEN];
- + struct {
- + u8 key[TKIP_KEYLEN];
- + u8 tx_mic[MIC_KEYLEN];
- + u8 rx_mic[MIC_KEYLEN];
- + } tkip;
- + u8 tsc[ORINOCO_SEQ_LEN];
- + } __packed buf;
- + struct hermes *hw = &priv->hw;
- + int ret;
- + int err;
- + int k;
- + u16 xmitting;
- +
- + key_idx &= 0x3;
- +
- + if (set_tx)
- + key_idx |= 0x8000;
- +
- + buf.idx = cpu_to_le16(key_idx);
- + if (key_len != sizeof(buf.tkip))
- + return -EINVAL;
- + memcpy(&buf.tkip, key, sizeof(buf.tkip));
- +
- + if (rsc_len > sizeof(buf.rsc))
- + rsc_len = sizeof(buf.rsc);
- +
- + if (tsc_len > sizeof(buf.tsc))
- + tsc_len = sizeof(buf.tsc);
- +
- + memset(buf.rsc, 0, sizeof(buf.rsc));
- + memset(buf.tsc, 0, sizeof(buf.tsc));
- +
- + if (rsc != NULL)
- + memcpy(buf.rsc, rsc, rsc_len);
- +
- + if (tsc != NULL)
- + memcpy(buf.tsc, tsc, tsc_len);
- + else
- + buf.tsc[4] = 0x10;
- +
- + /* Wait up to 100ms for tx queue to empty */
- + for (k = 100; k > 0; k--) {
- + udelay(1000);
- + ret = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_TXQUEUEEMPTY,
- + &xmitting);
- + if (ret || !xmitting)
- + break;
- + }
- +
- + if (k == 0)
- + ret = -ETIMEDOUT;
- +
- + err = HERMES_WRITE_RECORD(hw, USER_BAP,
- + HERMES_RID_CNFADDDEFAULTTKIPKEY_AGERE,
- + &buf);
- +
- + return ret ? ret : err;
- +}
- +
- +int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx)
- +{
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFREMDEFAULTTKIPKEY_AGERE,
- + key_idx);
- + if (err)
- + printk(KERN_WARNING "%s: Error %d clearing TKIP key %d\n",
- + priv->ndev->name, err, key_idx);
- + return err;
- +}
- +
- +int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
- + struct net_device *dev,
- + int mc_count, int promisc)
- +{
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- +
- + if (promisc != priv->promiscuous) {
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFPROMISCUOUSMODE,
- + promisc);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d setting PROMISCUOUSMODE to 1.\n",
- + priv->ndev->name, err);
- + } else
- + priv->promiscuous = promisc;
- + }
- +
- + /* If we're not in promiscuous mode, then we need to set the
- + * group address if either we want to multicast, or if we were
- + * multicasting and want to stop */
- + if (!promisc && (mc_count || priv->mc_count)) {
- + struct netdev_hw_addr *ha;
- + struct hermes_multicast mclist;
- + int i = 0;
- +
- + netdev_for_each_mc_addr(ha, dev) {
- + if (i == mc_count)
- + break;
- + memcpy(mclist.addr[i++], ha->addr, ETH_ALEN);
- + }
- +
- + err = hw->ops->write_ltv(hw, USER_BAP,
- + HERMES_RID_CNFGROUPADDRESSES,
- + HERMES_BYTES_TO_RECLEN(mc_count * ETH_ALEN),
- + &mclist);
- + if (err)
- + printk(KERN_ERR "%s: Error %d setting multicast list.\n",
- + priv->ndev->name, err);
- + else
- + priv->mc_count = mc_count;
- + }
- + return err;
- +}
- +
- +/* Return : < 0 -> error code ; >= 0 -> length */
- +int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
- + char buf[IW_ESSID_MAX_SIZE + 1])
- +{
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- + struct hermes_idstring essidbuf;
- + char *p = (char *)(&essidbuf.val);
- + int len;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + if (strlen(priv->desired_essid) > 0) {
- + /* We read the desired SSID from the hardware rather
- + than from priv->desired_essid, just in case the
- + firmware is allowed to change it on us. I'm not
- + sure about this */
- + /* My guess is that the OWNSSID should always be whatever
- + * we set to the card, whereas CURRENT_SSID is the one that
- + * may change... - Jean II */
- + u16 rid;
- +
- + *active = 1;
- +
- + rid = (priv->port_type == 3) ? HERMES_RID_CNFOWNSSID :
- + HERMES_RID_CNFDESIREDSSID;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, rid, sizeof(essidbuf),
- + NULL, &essidbuf);
- + if (err)
- + goto fail_unlock;
- + } else {
- + *active = 0;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTSSID,
- + sizeof(essidbuf), NULL, &essidbuf);
- + if (err)
- + goto fail_unlock;
- + }
- +
- + len = le16_to_cpu(essidbuf.len);
- + BUG_ON(len > IW_ESSID_MAX_SIZE);
- +
- + memset(buf, 0, IW_ESSID_MAX_SIZE);
- + memcpy(buf, p, len);
- + err = len;
- +
- + fail_unlock:
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +int orinoco_hw_get_freq(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- + u16 channel;
- + int freq = 0;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CURRENTCHANNEL,
- + &channel);
- + if (err)
- + goto out;
- +
- + /* Intersil firmware 1.3.5 returns 0 when the interface is down */
- + if (channel == 0) {
- + err = -EBUSY;
- + goto out;
- + }
- +
- + if ((channel < 1) || (channel > NUM_CHANNELS)) {
- + printk(KERN_WARNING "%s: Channel out of range (%d)!\n",
- + priv->ndev->name, channel);
- + err = -EBUSY;
- + goto out;
- +
- + }
- + freq = ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ);
- +
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + if (err > 0)
- + err = -EBUSY;
- + return err ? err : freq;
- +}
- +
- +int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
- + int *numrates, s32 *rates, int max)
- +{
- + struct hermes *hw = &priv->hw;
- + struct hermes_idstring list;
- + unsigned char *p = (unsigned char *)&list.val;
- + int err = 0;
- + int num;
- + int i;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_SUPPORTEDDATARATES,
- + sizeof(list), NULL, &list);
- + orinoco_unlock(priv, &flags);
- +
- + if (err)
- + return err;
- +
- + num = le16_to_cpu(list.len);
- + *numrates = num;
- + num = min(num, max);
- +
- + for (i = 0; i < num; i++)
- + rates[i] = (p[i] & 0x7f) * 500000; /* convert to bps */
- +
- + return 0;
- +}
- +
- +int orinoco_hw_trigger_scan(struct orinoco_private *priv,
- + const struct cfg80211_ssid *ssid)
- +{
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + unsigned long flags;
- + int err = 0;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + /* Scanning with port 0 disabled would fail */
- + if (!netif_running(dev)) {
- + err = -ENETDOWN;
- + goto out;
- + }
- +
- + /* In monitor mode, the scan results are always empty.
- + * Probe responses are passed to the driver as received
- + * frames and could be processed in software. */
- + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
- + err = -EOPNOTSUPP;
- + goto out;
- + }
- +
- + if (priv->has_hostscan) {
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_SYMBOL:
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFHOSTSCAN_SYMBOL,
- + HERMES_HOSTSCAN_SYMBOL_ONCE |
- + HERMES_HOSTSCAN_SYMBOL_BCAST);
- + break;
- + case FIRMWARE_TYPE_INTERSIL: {
- + __le16 req[3];
- +
- + req[0] = cpu_to_le16(0x3fff); /* All channels */
- + req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */
- + req[2] = 0; /* Any ESSID */
- + err = HERMES_WRITE_RECORD(hw, USER_BAP,
- + HERMES_RID_CNFHOSTSCAN, &req);
- + break;
- + }
- + case FIRMWARE_TYPE_AGERE:
- + if (ssid->ssid_len > 0) {
- + struct hermes_idstring idbuf;
- + size_t len = ssid->ssid_len;
- +
- + idbuf.len = cpu_to_le16(len);
- + memcpy(idbuf.val, ssid->ssid, len);
- +
- + err = hw->ops->write_ltv(hw, USER_BAP,
- + HERMES_RID_CNFSCANSSID_AGERE,
- + HERMES_BYTES_TO_RECLEN(len + 2),
- + &idbuf);
- + } else
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFSCANSSID_AGERE,
- + 0); /* Any ESSID */
- + if (err)
- + break;
- +
- + if (priv->has_ext_scan) {
- + err = hermes_write_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFSCANCHANNELS2GHZ,
- + 0x7FFF);
- + if (err)
- + goto out;
- +
- + err = hermes_inquire(hw,
- + HERMES_INQ_CHANNELINFO);
- + } else
- + err = hermes_inquire(hw, HERMES_INQ_SCAN);
- +
- + break;
- + }
- + } else
- + err = hermes_inquire(hw, HERMES_INQ_SCAN);
- +
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +/* Disassociate from node with BSSID addr */
- +int orinoco_hw_disassociate(struct orinoco_private *priv,
- + u8 *addr, u16 reason_code)
- +{
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + struct {
- + u8 addr[ETH_ALEN];
- + __le16 reason_code;
- + } __packed buf;
- +
- + /* Currently only supported by WPA enabled Agere fw */
- + if (!priv->has_wpa)
- + return -EOPNOTSUPP;
- +
- + memcpy(buf.addr, addr, ETH_ALEN);
- + buf.reason_code = cpu_to_le16(reason_code);
- + err = HERMES_WRITE_RECORD(hw, USER_BAP,
- + HERMES_RID_CNFDISASSOCIATE,
- + &buf);
- + return err;
- +}
- +
- +int orinoco_hw_get_current_bssid(struct orinoco_private *priv,
- + u8 *addr)
- +{
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
- + ETH_ALEN, NULL, addr);
- +
- + return err;
- +}
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hw.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/hw.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/hw.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/hw.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,60 @@
- +/* Encapsulate basic setting changes on Hermes hardware
- + *
- + * See copyright notice in main.c
- + */
- +#ifndef _ORINOCO_HW_H_
- +#define _ORINOCO_HW_H_
- +
- +#include <linux/types.h>
- +#include <linux/wireless.h>
- +#include <net/cfg80211.h>
- +
- +/* Hardware BAPs */
- +#define USER_BAP 0
- +#define IRQ_BAP 1
- +
- +/* WEP key sizes */
- +#define SMALL_KEY_SIZE 5
- +#define LARGE_KEY_SIZE 13
- +
- +/* Number of supported channels */
- +#define NUM_CHANNELS 14
- +
- +/* Forward declarations */
- +struct orinoco_private;
- +
- +int determine_fw_capabilities(struct orinoco_private *priv, char *fw_name,
- + size_t fw_name_len, u32 *hw_ver);
- +int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr);
- +int orinoco_hw_allocate_fid(struct orinoco_private *priv);
- +int orinoco_get_bitratemode(int bitrate, int automatic);
- +void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic);
- +
- +int orinoco_hw_program_rids(struct orinoco_private *priv);
- +int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc);
- +int __orinoco_hw_set_bitrate(struct orinoco_private *priv);
- +int orinoco_hw_get_act_bitrate(struct orinoco_private *priv, int *bitrate);
- +int __orinoco_hw_set_wap(struct orinoco_private *priv);
- +int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv);
- +int __orinoco_hw_setup_enc(struct orinoco_private *priv);
- +int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
- + int set_tx, const u8 *key, size_t key_len,
- + const u8 *rsc, size_t rsc_len,
- + const u8 *tsc, size_t tsc_len);
- +int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx);
- +int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
- + struct net_device *dev,
- + int mc_count, int promisc);
- +int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
- + char buf[IW_ESSID_MAX_SIZE + 1]);
- +int orinoco_hw_get_freq(struct orinoco_private *priv);
- +int orinoco_hw_get_bitratelist(struct orinoco_private *priv,
- + int *numrates, s32 *rates, int max);
- +int orinoco_hw_trigger_scan(struct orinoco_private *priv,
- + const struct cfg80211_ssid *ssid);
- +int orinoco_hw_disassociate(struct orinoco_private *priv,
- + u8 *addr, u16 reason_code);
- +int orinoco_hw_get_current_bssid(struct orinoco_private *priv,
- + u8 *addr);
- +
- +#endif /* _ORINOCO_HW_H_ */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/Kconfig linux-6.18.9/drivers/net/wireless/intersil/orinoco/Kconfig
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/Kconfig 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/Kconfig 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,143 @@
- +# SPDX-License-Identifier: GPL-2.0-only
- +config HERMES
- + tristate "Hermes chipset 802.11b support (Orinoco/Prism2/Symbol)"
- + depends on (PPC_PMAC || PCI || PCMCIA)
- + depends on CFG80211
- + select CFG80211_WEXT_EXPORT
- + select WIRELESS_EXT
- + select WEXT_SPY
- + select WEXT_PRIV
- + select FW_LOADER
- + select CRYPTO
- + select CRYPTO_MICHAEL_MIC
- + help
- + A driver for 802.11b wireless cards based on the "Hermes" or
- + Intersil HFA384x (Prism 2) MAC controller. This includes the vast
- + majority of the PCMCIA 802.11b cards (which are nearly all rebadges)
- + - except for the Cisco/Aironet cards. Cards supported include the
- + Apple Airport (not a PCMCIA card), WavelanIEEE/Orinoco,
- + Cabletron/EnteraSys Roamabout, ELSA AirLancer, MELCO Buffalo, Avaya,
- + IBM High Rate Wireless, Farralon Syyline, Samsung MagicLAN, Netgear
- + MA401, LinkSys WPC-11, D-Link DWL-650, 3Com AirConnect, Intel
- + IPW2011, and Symbol Spectrum24 High Rate amongst others.
- +
- + This option includes the guts of the driver, but in order to
- + actually use a card you will also need to enable support for PCMCIA
- + Hermes cards, PLX9052 based PCI adaptors or the Apple Airport below.
- +
- + You will also very likely also need the Wireless Tools in order to
- + configure your card and that /etc/pcmcia/wireless.opts works :
- + <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>
- +
- +config HERMES_PRISM
- + bool "Support Prism 2/2.5 chipset"
- + depends on HERMES
- + help
- +
- + Say Y to enable support for Prism 2 and 2.5 chipsets. These
- + chipsets are better handled by the hostap driver. This driver
- + would not support WPA or firmware download for Prism chipset.
- +
- + If you are not sure, say N.
- +
- +config HERMES_CACHE_FW_ON_INIT
- + bool "Cache Hermes firmware on driver initialisation"
- + depends on HERMES
- + default y
- + help
- + Say Y to cache any firmware required by the Hermes drivers
- + on startup. The firmware will remain cached until the
- + driver is unloaded. The cache uses 64K of RAM.
- +
- + Otherwise load the firmware from userspace as required. In
- + this case the driver should be unloaded and restarted
- + whenever the firmware is changed.
- +
- + If you are not sure, say Y.
- +
- +config APPLE_AIRPORT
- + tristate "Apple Airport support (built-in)"
- + depends on PPC_PMAC && HERMES
- + help
- + Say Y here to support the Airport 802.11b wireless Ethernet hardware
- + built into the Macintosh iBook and other recent PowerPC-based
- + Macintosh machines. This is essentially a Lucent Orinoco card with
- + a non-standard interface.
- +
- + This driver does not support the Airport Extreme (802.11b/g). Use
- + the BCM43xx driver for Airport Extreme cards.
- +
- +config PLX_HERMES
- + tristate "Hermes in PLX9052 based PCI adaptor support (Netgear MA301 etc.)"
- + depends on PCI && HERMES
- + help
- + Enable support for PCMCIA cards supported by the "Hermes" (aka
- + orinoco) driver when used in PLX9052 based PCI adaptors. These
- + adaptors are not a full PCMCIA controller but act as a more limited
- + PCI <-> PCMCIA bridge. Several vendors sell such adaptors so that
- + 802.11b PCMCIA cards can be used in desktop machines. The Netgear
- + MA301 is such an adaptor.
- +
- +config TMD_HERMES
- + tristate "Hermes in TMD7160 based PCI adaptor support"
- + depends on PCI && HERMES
- + help
- + Enable support for PCMCIA cards supported by the "Hermes" (aka
- + orinoco) driver when used in TMD7160 based PCI adaptors. These
- + adaptors are not a full PCMCIA controller but act as a more limited
- + PCI <-> PCMCIA bridge. Several vendors sell such adaptors so that
- + 802.11b PCMCIA cards can be used in desktop machines.
- +
- +config NORTEL_HERMES
- + tristate "Nortel emobility PCI adaptor support"
- + depends on PCI && HERMES
- + help
- + Enable support for PCMCIA cards supported by the "Hermes" (aka
- + orinoco) driver when used in Nortel emobility PCI adaptors. These
- + adaptors are not full PCMCIA controllers, but act as a more limited
- + PCI <-> PCMCIA bridge.
- +
- +config PCI_HERMES
- + tristate "Prism 2.5 PCI 802.11b adaptor support"
- + depends on PCI && HERMES && HERMES_PRISM
- + help
- + Enable support for PCI and mini-PCI 802.11b wireless NICs based on
- + the Prism 2.5 chipset. These are true PCI cards, not the 802.11b
- + PCMCIA cards bundled with PCI<->PCMCIA adaptors which are also
- + common. Some of the built-in wireless adaptors in laptops are of
- + this variety.
- +
- +config PCMCIA_HERMES
- + tristate "Hermes PCMCIA card support"
- + depends on PCMCIA && HERMES && HAS_IOPORT_MAP
- + help
- + A driver for "Hermes" chipset based PCMCIA wireless adaptors, such
- + as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/
- + EnteraSys RoamAbout 802.11, ELSA Airlancer, Melco Buffalo and
- + others). It should also be usable on various Prism II based cards
- + such as the Linksys, D-Link and Farallon Skyline. It should also
- + work on Symbol cards such as the 3Com AirConnect and Ericsson WLAN.
- +
- + You will very likely need the Wireless Tools in order to
- + configure your card and that /etc/pcmcia/wireless.opts works:
- + <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
- +
- +config PCMCIA_SPECTRUM
- + tristate "Symbol Spectrum24 Trilogy PCMCIA card support"
- + depends on PCMCIA && HERMES && HAS_IOPORT_MAP
- + help
- +
- + This is a driver for 802.11b cards using RAM-loadable Symbol
- + firmware, such as Symbol Wireless Networker LA4100, CompactFlash
- + cards by Socket Communications and Intel PRO/Wireless 2011B.
- +
- + This driver requires firmware download on startup. Utilities
- + for downloading Symbol firmware are available at
- + <http://sourceforge.net/projects/orinoco/>
- +
- +config ORINOCO_USB
- + tristate "Agere Orinoco USB support"
- + depends on USB && HERMES
- + select FW_LOADER
- + help
- + This driver is for USB versions of the Agere Orinoco card.
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/main.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/main.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/main.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/main.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,2414 @@
- +/* main.c - (formerly known as dldwd_cs.c, orinoco_cs.c and orinoco.c)
- + *
- + * A driver for Hermes or Prism 2 chipset based PCMCIA wireless
- + * adaptors, with Lucent/Agere, Intersil or Symbol firmware.
- + *
- + * Current maintainers (as of 29 September 2003) are:
- + * Pavel Roskin <proski AT gnu.org>
- + * and David Gibson <hermes AT gibson.dropbear.id.au>
- + *
- + * (C) Copyright David Gibson, IBM Corporation 2001-2003.
- + * Copyright (C) 2000 David Gibson, Linuxcare Australia.
- + * With some help from :
- + * Copyright (C) 2001 Jean Tourrilhes, HP Labs
- + * Copyright (C) 2001 Benjamin Herrenschmidt
- + *
- + * Based on dummy_cs.c 1.27 2000/06/12 21:27:25
- + *
- + * Portions based on wvlan_cs.c 1.0.6, Copyright Andreas Neuhaus <andy
- + * AT fasta.fh-dortmund.de>
- + * http://www.stud.fh-dortmund.de/~andy/wvlan/
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * The initial developer of the original code is David A. Hinds
- + * <dahinds AT users.sourceforge.net>. Portions created by David
- + * A. Hinds are Copyright (C) 1999 David A. Hinds. All Rights
- + * Reserved.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL. */
- +
- +/*
- + * TODO
- + * o Handle de-encapsulation within network layer, provide 802.11
- + * headers (patch from Thomas 'Dent' Mirlacher)
- + * o Fix possible races in SPY handling.
- + * o Disconnect wireless extensions from fundamental configuration.
- + * o (maybe) Software WEP support (patch from Stano Meduna).
- + * o (maybe) Use multiple Tx buffers - driver handling queue
- + * rather than firmware.
- + */
- +
- +/* Locking and synchronization:
- + *
- + * The basic principle is that everything is serialized through a
- + * single spinlock, priv->lock. The lock is used in user, bh and irq
- + * context, so when taken outside hardirq context it should always be
- + * taken with interrupts disabled. The lock protects both the
- + * hardware and the struct orinoco_private.
- + *
- + * Another flag, priv->hw_unavailable indicates that the hardware is
- + * unavailable for an extended period of time (e.g. suspended, or in
- + * the middle of a hard reset). This flag is protected by the
- + * spinlock. All code which touches the hardware should check the
- + * flag after taking the lock, and if it is set, give up on whatever
- + * they are doing and drop the lock again. The orinoco_lock()
- + * function handles this (it unlocks and returns -EBUSY if
- + * hw_unavailable is non-zero).
- + */
- +
- +#define DRIVER_NAME "orinoco"
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/slab.h>
- +#include <linux/init.h>
- +#include <linux/delay.h>
- +#include <linux/device.h>
- +#include <linux/netdevice.h>
- +#include <linux/etherdevice.h>
- +#include <linux/suspend.h>
- +#include <linux/if_arp.h>
- +#include <linux/wireless.h>
- +#include <linux/ieee80211.h>
- +#include <net/iw_handler.h>
- +#include <net/cfg80211.h>
- +
- +#include "hermes_rid.h"
- +#include "hermes_dld.h"
- +#include "hw.h"
- +#include "scan.h"
- +#include "mic.h"
- +#include "fw.h"
- +#include "wext.h"
- +#include "cfg.h"
- +#include "main.h"
- +
- +#include "orinoco.h"
- +
- +/********************************************************************/
- +/* Module information */
- +/********************************************************************/
- +
- +MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> & "
- + "David Gibson <hermes@gibson.dropbear.id.au>");
- +MODULE_DESCRIPTION("Driver for Lucent Orinoco, Prism II based "
- + "and similar wireless cards");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +/* Level of debugging. Used in the macros in orinoco.h */
- +#ifdef ORINOCO_DEBUG
- +int orinoco_debug = ORINOCO_DEBUG;
- +EXPORT_SYMBOL(orinoco_debug);
- +module_param(orinoco_debug, int, 0644);
- +MODULE_PARM_DESC(orinoco_debug, "Debug level");
- +#endif
- +
- +static bool suppress_linkstatus; /* = 0 */
- +module_param(suppress_linkstatus, bool, 0644);
- +MODULE_PARM_DESC(suppress_linkstatus, "Don't log link status changes");
- +
- +static int ignore_disconnect; /* = 0 */
- +module_param(ignore_disconnect, int, 0644);
- +MODULE_PARM_DESC(ignore_disconnect,
- + "Don't report lost link to the network layer");
- +
- +int force_monitor; /* = 0 */
- +module_param(force_monitor, int, 0644);
- +MODULE_PARM_DESC(force_monitor, "Allow monitor mode for all firmware versions");
- +
- +/********************************************************************/
- +/* Internal constants */
- +/********************************************************************/
- +
- +/* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
- +static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
- +#define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
- +
- +#define ORINOCO_MIN_MTU 256
- +#define ORINOCO_MAX_MTU (IEEE80211_MAX_DATA_LEN - ENCAPS_OVERHEAD)
- +
- +#define MAX_IRQLOOPS_PER_IRQ 10
- +#define MAX_IRQLOOPS_PER_JIFFY (20000 / HZ) /* Based on a guestimate of
- + * how many events the
- + * device could
- + * legitimately generate */
- +
- +#define DUMMY_FID 0xFFFF
- +
- +/*#define MAX_MULTICAST(priv) (priv->firmware_type == FIRMWARE_TYPE_AGERE ? \
- + HERMES_MAX_MULTICAST : 0)*/
- +#define MAX_MULTICAST(priv) (HERMES_MAX_MULTICAST)
- +
- +#define ORINOCO_INTEN (HERMES_EV_RX | HERMES_EV_ALLOC \
- + | HERMES_EV_TX | HERMES_EV_TXEXC \
- + | HERMES_EV_WTERR | HERMES_EV_INFO \
- + | HERMES_EV_INFDROP)
- +
- +/********************************************************************/
- +/* Data types */
- +/********************************************************************/
- +
- +/* Beginning of the Tx descriptor, used in TxExc handling */
- +struct hermes_txexc_data {
- + struct hermes_tx_descriptor desc;
- + __le16 frame_ctl;
- + __le16 duration_id;
- + u8 addr1[ETH_ALEN];
- +} __packed;
- +
- +/* Rx frame header except compatibility 802.3 header */
- +struct hermes_rx_descriptor {
- + /* Control */
- + __le16 status;
- + __le32 time;
- + u8 silence;
- + u8 signal;
- + u8 rate;
- + u8 rxflow;
- + __le32 reserved;
- +
- + /* 802.11 header */
- + __le16 frame_ctl;
- + __le16 duration_id;
- + u8 addr1[ETH_ALEN];
- + u8 addr2[ETH_ALEN];
- + u8 addr3[ETH_ALEN];
- + __le16 seq_ctl;
- + u8 addr4[ETH_ALEN];
- +
- + /* Data length */
- + __le16 data_len;
- +} __packed;
- +
- +struct orinoco_rx_data {
- + struct hermes_rx_descriptor *desc;
- + struct sk_buff *skb;
- + struct list_head list;
- +};
- +
- +struct orinoco_scan_data {
- + void *buf;
- + size_t len;
- + int type;
- + struct list_head list;
- +};
- +
- +/********************************************************************/
- +/* Function prototypes */
- +/********************************************************************/
- +
- +static int __orinoco_set_multicast_list(struct net_device *dev);
- +static int __orinoco_up(struct orinoco_private *priv);
- +static int __orinoco_down(struct orinoco_private *priv);
- +static int __orinoco_commit(struct orinoco_private *priv);
- +
- +/********************************************************************/
- +/* Internal helper functions */
- +/********************************************************************/
- +
- +void set_port_type(struct orinoco_private *priv)
- +{
- + switch (priv->iw_mode) {
- + case NL80211_IFTYPE_STATION:
- + priv->port_type = 1;
- + priv->createibss = 0;
- + break;
- + case NL80211_IFTYPE_ADHOC:
- + if (priv->prefer_port3) {
- + priv->port_type = 3;
- + priv->createibss = 0;
- + } else {
- + priv->port_type = priv->ibss_port;
- + priv->createibss = 1;
- + }
- + break;
- + case NL80211_IFTYPE_MONITOR:
- + priv->port_type = 3;
- + priv->createibss = 0;
- + break;
- + default:
- + printk(KERN_ERR "%s: Invalid priv->iw_mode in set_port_type()\n",
- + priv->ndev->name);
- + }
- +}
- +
- +/********************************************************************/
- +/* Device methods */
- +/********************************************************************/
- +
- +int orinoco_open(struct net_device *dev)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + unsigned long flags;
- + int err;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + err = __orinoco_up(priv);
- +
- + if (!err)
- + priv->open = 1;
- +
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +EXPORT_SYMBOL(orinoco_open);
- +
- +int orinoco_stop(struct net_device *dev)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + int err = 0;
- +
- + /* We mustn't use orinoco_lock() here, because we need to be
- + able to close the interface even if hw_unavailable is set
- + (e.g. as we're released after a PC Card removal) */
- + orinoco_lock_irq(priv);
- +
- + priv->open = 0;
- +
- + err = __orinoco_down(priv);
- +
- + orinoco_unlock_irq(priv);
- +
- + return err;
- +}
- +EXPORT_SYMBOL(orinoco_stop);
- +
- +void orinoco_set_multicast_list(struct net_device *dev)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0) {
- + printk(KERN_DEBUG "%s: orinoco_set_multicast_list() "
- + "called when hw_unavailable\n", dev->name);
- + return;
- + }
- +
- + __orinoco_set_multicast_list(dev);
- + orinoco_unlock(priv, &flags);
- +}
- +EXPORT_SYMBOL(orinoco_set_multicast_list);
- +
- +int orinoco_change_mtu(struct net_device *dev, int new_mtu)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- +
- + /* MTU + encapsulation + header length */
- + if ((new_mtu + ENCAPS_OVERHEAD + sizeof(struct ieee80211_hdr)) >
- + (priv->nicbuf_size - ETH_HLEN))
- + return -EINVAL;
- +
- + dev->mtu = new_mtu;
- +
- + return 0;
- +}
- +EXPORT_SYMBOL(orinoco_change_mtu);
- +
- +/********************************************************************/
- +/* Tx path */
- +/********************************************************************/
- +
- +/* Add encapsulation and MIC to the existing SKB.
- + * The main xmit routine will then send the whole lot to the card.
- + * Need 8 bytes headroom
- + * Need 8 bytes tailroom
- + *
- + * With encapsulated ethernet II frame
- + * --------
- + * 803.3 header (14 bytes)
- + * dst[6]
- + * -------- src[6]
- + * 803.3 header (14 bytes) len[2]
- + * dst[6] 803.2 header (8 bytes)
- + * src[6] encaps[6]
- + * len[2] <- leave alone -> len[2]
- + * -------- -------- <-- 0
- + * Payload Payload
- + * ... ...
- + *
- + * -------- --------
- + * MIC (8 bytes)
- + * --------
- + *
- + * returns 0 on success, -ENOMEM on error.
- + */
- +int orinoco_process_xmit_skb(struct sk_buff *skb,
- + struct net_device *dev,
- + struct orinoco_private *priv,
- + int *tx_control,
- + u8 *mic_buf)
- +{
- + struct orinoco_tkip_key *key;
- + struct ethhdr *eh;
- + int do_mic;
- +
- + key = (struct orinoco_tkip_key *) priv->keys[priv->tx_key].key;
- +
- + do_mic = ((priv->encode_alg == ORINOCO_ALG_TKIP) &&
- + (key != NULL));
- +
- + if (do_mic)
- + *tx_control |= (priv->tx_key << HERMES_MIC_KEY_ID_SHIFT) |
- + HERMES_TXCTRL_MIC;
- +
- + eh = (struct ethhdr *)skb->data;
- +
- + /* Encapsulate Ethernet-II frames */
- + if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */
- + struct header_struct {
- + struct ethhdr eth; /* 802.3 header */
- + u8 encap[6]; /* 802.2 header */
- + } __packed hdr;
- + int len = skb->len + sizeof(encaps_hdr) - (2 * ETH_ALEN);
- +
- + if (skb_headroom(skb) < ENCAPS_OVERHEAD) {
- + if (net_ratelimit())
- + printk(KERN_ERR
- + "%s: Not enough headroom for 802.2 headers %d\n",
- + dev->name, skb_headroom(skb));
- + return -ENOMEM;
- + }
- +
- + /* Fill in new header */
- + memcpy(&hdr.eth, eh, 2 * ETH_ALEN);
- + hdr.eth.h_proto = htons(len);
- + memcpy(hdr.encap, encaps_hdr, sizeof(encaps_hdr));
- +
- + /* Make room for the new header, and copy it in */
- + eh = skb_push(skb, ENCAPS_OVERHEAD);
- + memcpy(eh, &hdr, sizeof(hdr));
- + }
- +
- + /* Calculate Michael MIC */
- + if (do_mic) {
- + size_t len = skb->len - ETH_HLEN;
- + u8 *mic = &mic_buf[0];
- +
- + /* Have to write to an even address, so copy the spare
- + * byte across */
- + if (skb->len % 2) {
- + *mic = skb->data[skb->len - 1];
- + mic++;
- + }
- +
- + orinoco_mic(priv->tx_tfm_mic, key->tx_mic,
- + eh->h_dest, eh->h_source, 0 /* priority */,
- + skb->data + ETH_HLEN,
- + len, mic);
- + }
- +
- + return 0;
- +}
- +EXPORT_SYMBOL(orinoco_process_xmit_skb);
- +
- +static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct net_device_stats *stats = &dev->stats;
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- + u16 txfid = priv->txfid;
- + int tx_control;
- + unsigned long flags;
- + u8 mic_buf[MICHAEL_MIC_LEN + 1];
- +
- + if (!netif_running(dev)) {
- + printk(KERN_ERR "%s: Tx on stopped device!\n",
- + dev->name);
- + return NETDEV_TX_BUSY;
- + }
- +
- + if (netif_queue_stopped(dev)) {
- + printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
- + dev->name);
- + return NETDEV_TX_BUSY;
- + }
- +
- + if (orinoco_lock(priv, &flags) != 0) {
- + printk(KERN_ERR "%s: orinoco_xmit() called while hw_unavailable\n",
- + dev->name);
- + return NETDEV_TX_BUSY;
- + }
- +
- + if (!netif_carrier_ok(dev) ||
- + (priv->iw_mode == NL80211_IFTYPE_MONITOR)) {
- + /* Oops, the firmware hasn't established a connection,
- + silently drop the packet (this seems to be the
- + safest approach). */
- + goto drop;
- + }
- +
- + /* Check packet length */
- + if (skb->len < ETH_HLEN)
- + goto drop;
- +
- + tx_control = HERMES_TXCTRL_TX_OK | HERMES_TXCTRL_TX_EX;
- +
- + err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control,
- + &mic_buf[0]);
- + if (err)
- + goto drop;
- +
- + if (priv->has_alt_txcntl) {
- + /* WPA enabled firmwares have tx_cntl at the end of
- + * the 802.11 header. So write zeroed descriptor and
- + * 802.11 header at the same time
- + */
- + char desc[HERMES_802_3_OFFSET];
- + __le16 *txcntl = (__le16 *) &desc[HERMES_TXCNTL2_OFFSET];
- +
- + memset(&desc, 0, sizeof(desc));
- +
- + *txcntl = cpu_to_le16(tx_control);
- + err = hw->ops->bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
- + txfid, 0);
- + if (err) {
- + if (net_ratelimit())
- + printk(KERN_ERR "%s: Error %d writing Tx "
- + "descriptor to BAP\n", dev->name, err);
- + goto busy;
- + }
- + } else {
- + struct hermes_tx_descriptor desc;
- +
- + memset(&desc, 0, sizeof(desc));
- +
- + desc.tx_control = cpu_to_le16(tx_control);
- + err = hw->ops->bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
- + txfid, 0);
- + if (err) {
- + if (net_ratelimit())
- + printk(KERN_ERR "%s: Error %d writing Tx "
- + "descriptor to BAP\n", dev->name, err);
- + goto busy;
- + }
- +
- + /* Clear the 802.11 header and data length fields - some
- + * firmwares (e.g. Lucent/Agere 8.xx) appear to get confused
- + * if this isn't done. */
- + hermes_clear_words(hw, HERMES_DATA0,
- + HERMES_802_3_OFFSET - HERMES_802_11_OFFSET);
- + }
- +
- + err = hw->ops->bap_pwrite(hw, USER_BAP, skb->data, skb->len,
- + txfid, HERMES_802_3_OFFSET);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
- + dev->name, err);
- + goto busy;
- + }
- +
- + if (tx_control & HERMES_TXCTRL_MIC) {
- + size_t offset = HERMES_802_3_OFFSET + skb->len;
- + size_t len = MICHAEL_MIC_LEN;
- +
- + if (offset % 2) {
- + offset--;
- + len++;
- + }
- + err = hw->ops->bap_pwrite(hw, USER_BAP, &mic_buf[0], len,
- + txfid, offset);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d writing MIC to BAP\n",
- + dev->name, err);
- + goto busy;
- + }
- + }
- +
- + /* Finally, we actually initiate the send */
- + netif_stop_queue(dev);
- +
- + err = hw->ops->cmd_wait(hw, HERMES_CMD_TX | HERMES_CMD_RECL,
- + txfid, NULL);
- + if (err) {
- + netif_start_queue(dev);
- + if (net_ratelimit())
- + printk(KERN_ERR "%s: Error %d transmitting packet\n",
- + dev->name, err);
- + goto busy;
- + }
- +
- + stats->tx_bytes += HERMES_802_3_OFFSET + skb->len;
- + goto ok;
- +
- + drop:
- + stats->tx_errors++;
- + stats->tx_dropped++;
- +
- + ok:
- + orinoco_unlock(priv, &flags);
- + dev_kfree_skb(skb);
- + return NETDEV_TX_OK;
- +
- + busy:
- + if (err == -EIO)
- + schedule_work(&priv->reset_work);
- + orinoco_unlock(priv, &flags);
- + return NETDEV_TX_BUSY;
- +}
- +
- +static void __orinoco_ev_alloc(struct net_device *dev, struct hermes *hw)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + u16 fid = hermes_read_regn(hw, ALLOCFID);
- +
- + if (fid != priv->txfid) {
- + if (fid != DUMMY_FID)
- + printk(KERN_WARNING "%s: Allocate event on unexpected fid (%04X)\n",
- + dev->name, fid);
- + return;
- + }
- +
- + hermes_write_regn(hw, ALLOCFID, DUMMY_FID);
- +}
- +
- +static void __orinoco_ev_tx(struct net_device *dev, struct hermes *hw)
- +{
- + dev->stats.tx_packets++;
- +
- + netif_wake_queue(dev);
- +
- + hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
- +}
- +
- +static void __orinoco_ev_txexc(struct net_device *dev, struct hermes *hw)
- +{
- + struct net_device_stats *stats = &dev->stats;
- + u16 fid = hermes_read_regn(hw, TXCOMPLFID);
- + u16 status;
- + struct hermes_txexc_data hdr;
- + int err = 0;
- +
- + if (fid == DUMMY_FID)
- + return; /* Nothing's really happened */
- +
- + /* Read part of the frame header - we need status and addr1 */
- + err = hw->ops->bap_pread(hw, IRQ_BAP, &hdr,
- + sizeof(struct hermes_txexc_data),
- + fid, 0);
- +
- + hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
- + stats->tx_errors++;
- +
- + if (err) {
- + printk(KERN_WARNING "%s: Unable to read descriptor on Tx error "
- + "(FID=%04X error %d)\n",
- + dev->name, fid, err);
- + return;
- + }
- +
- + DEBUG(1, "%s: Tx error, err %d (FID=%04X)\n", dev->name,
- + err, fid);
- +
- + /* We produce a TXDROP event only for retry or lifetime
- + * exceeded, because that's the only status that really mean
- + * that this particular node went away.
- + * Other errors means that *we* screwed up. - Jean II */
- + status = le16_to_cpu(hdr.desc.status);
- + if (status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) {
- + union iwreq_data wrqu;
- +
- + /* Copy 802.11 dest address.
- + * We use the 802.11 header because the frame may
- + * not be 802.3 or may be mangled...
- + * In Ad-Hoc mode, it will be the node address.
- + * In managed mode, it will be most likely the AP addr
- + * User space will figure out how to convert it to
- + * whatever it needs (IP address or else).
- + * - Jean II */
- + memcpy(wrqu.addr.sa_data, hdr.addr1, ETH_ALEN);
- + wrqu.addr.sa_family = ARPHRD_ETHER;
- +
- + /* Send event to user space */
- + wireless_send_event(dev, IWEVTXDROP, &wrqu, NULL);
- + }
- +
- + netif_wake_queue(dev);
- +}
- +
- +void orinoco_tx_timeout(struct net_device *dev, unsigned int txqueue)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct net_device_stats *stats = &dev->stats;
- + struct hermes *hw = &priv->hw;
- +
- + printk(KERN_WARNING "%s: Tx timeout! "
- + "ALLOCFID=%04x, TXCOMPLFID=%04x, EVSTAT=%04x\n",
- + dev->name, hermes_read_regn(hw, ALLOCFID),
- + hermes_read_regn(hw, TXCOMPLFID), hermes_read_regn(hw, EVSTAT));
- +
- + stats->tx_errors++;
- +
- + schedule_work(&priv->reset_work);
- +}
- +EXPORT_SYMBOL(orinoco_tx_timeout);
- +
- +/********************************************************************/
- +/* Rx path (data frames) */
- +/********************************************************************/
- +
- +/* Does the frame have a SNAP header indicating it should be
- + * de-encapsulated to Ethernet-II? */
- +static inline int is_ethersnap(void *_hdr)
- +{
- + u8 *hdr = _hdr;
- +
- + /* We de-encapsulate all packets which, a) have SNAP headers
- + * (i.e. SSAP=DSAP=0xaa and CTRL=0x3 in the 802.2 LLC header
- + * and where b) the OUI of the SNAP header is 00:00:00 or
- + * 00:00:f8 - we need both because different APs appear to use
- + * different OUIs for some reason */
- + return (memcmp(hdr, &encaps_hdr, 5) == 0)
- + && ((hdr[5] == 0x00) || (hdr[5] == 0xf8));
- +}
- +
- +static inline void orinoco_spy_gather(struct net_device *dev, u_char *mac,
- + int level, int noise)
- +{
- + struct iw_quality wstats;
- + wstats.level = level - 0x95;
- + wstats.noise = noise - 0x95;
- + wstats.qual = (level > noise) ? (level - noise) : 0;
- + wstats.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
- + /* Update spy records */
- + //wireless_spy_update(dev, mac, &wstats);
- +}
- +
- +static void orinoco_stat_gather(struct net_device *dev,
- + struct sk_buff *skb,
- + struct hermes_rx_descriptor *desc)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- +
- + /* Using spy support with lots of Rx packets, like in an
- + * infrastructure (AP), will really slow down everything, because
- + * the MAC address must be compared to each entry of the spy list.
- + * If the user really asks for it (set some address in the
- + * spy list), we do it, but he will pay the price.
- + * Note that to get here, you need both WIRELESS_SPY
- + * compiled in AND some addresses in the list !!!
- + */
- + /* Note : gcc will optimise the whole section away if
- + * WIRELESS_SPY is not defined... - Jean II */
- + if (SPY_NUMBER(priv)) {
- + orinoco_spy_gather(dev, skb_mac_header(skb) + ETH_ALEN,
- + desc->signal, desc->silence);
- + }
- +}
- +
- +/*
- + * orinoco_rx_monitor - handle received monitor frames.
- + *
- + * Arguments:
- + * dev network device
- + * rxfid received FID
- + * desc rx descriptor of the frame
- + *
- + * Call context: interrupt
- + */
- +static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
- + struct hermes_rx_descriptor *desc)
- +{
- + u32 hdrlen = 30; /* return full header by default */
- + u32 datalen = 0;
- + u16 fc;
- + int err;
- + int len;
- + struct sk_buff *skb;
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct net_device_stats *stats = &dev->stats;
- + struct hermes *hw = &priv->hw;
- +
- + len = le16_to_cpu(desc->data_len);
- +
- + /* Determine the size of the header and the data */
- + fc = le16_to_cpu(desc->frame_ctl);
- + switch (fc & IEEE80211_FCTL_FTYPE) {
- + case IEEE80211_FTYPE_DATA:
- + if ((fc & IEEE80211_FCTL_TODS)
- + && (fc & IEEE80211_FCTL_FROMDS))
- + hdrlen = 30;
- + else
- + hdrlen = 24;
- + datalen = len;
- + break;
- + case IEEE80211_FTYPE_MGMT:
- + hdrlen = 24;
- + datalen = len;
- + break;
- + case IEEE80211_FTYPE_CTL:
- + switch (fc & IEEE80211_FCTL_STYPE) {
- + case IEEE80211_STYPE_PSPOLL:
- + case IEEE80211_STYPE_RTS:
- + case IEEE80211_STYPE_CFEND:
- + case IEEE80211_STYPE_CFENDACK:
- + hdrlen = 16;
- + break;
- + case IEEE80211_STYPE_CTS:
- + case IEEE80211_STYPE_ACK:
- + hdrlen = 10;
- + break;
- + }
- + break;
- + default:
- + /* Unknown frame type */
- + break;
- + }
- +
- + /* sanity check the length */
- + if (datalen > IEEE80211_MAX_DATA_LEN + 12) {
- + printk(KERN_DEBUG "%s: oversized monitor frame, "
- + "data length = %d\n", dev->name, datalen);
- + stats->rx_length_errors++;
- + goto update_stats;
- + }
- +
- + skb = dev_alloc_skb(hdrlen + datalen);
- + if (!skb) {
- + printk(KERN_WARNING "%s: Cannot allocate skb for monitor frame\n",
- + dev->name);
- + goto update_stats;
- + }
- +
- + /* Copy the 802.11 header to the skb */
- + skb_put_data(skb, &(desc->frame_ctl), hdrlen);
- + skb_reset_mac_header(skb);
- +
- + /* If any, copy the data from the card to the skb */
- + if (datalen > 0) {
- + err = hw->ops->bap_pread(hw, IRQ_BAP, skb_put(skb, datalen),
- + ALIGN(datalen, 2), rxfid,
- + HERMES_802_2_OFFSET);
- + if (err) {
- + printk(KERN_ERR "%s: error %d reading monitor frame\n",
- + dev->name, err);
- + goto drop;
- + }
- + }
- +
- + skb->dev = dev;
- + skb->ip_summed = CHECKSUM_NONE;
- + skb->pkt_type = PACKET_OTHERHOST;
- + skb->protocol = cpu_to_be16(ETH_P_802_2);
- +
- + stats->rx_packets++;
- + stats->rx_bytes += skb->len;
- +
- + netif_rx(skb);
- + return;
- +
- + drop:
- + dev_kfree_skb_irq(skb);
- + update_stats:
- + stats->rx_errors++;
- + stats->rx_dropped++;
- +}
- +
- +void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct net_device_stats *stats = &dev->stats;
- + struct iw_statistics *wstats = &priv->wstats;
- + struct sk_buff *skb = NULL;
- + u16 rxfid, status;
- + int length;
- + struct hermes_rx_descriptor *desc;
- + struct orinoco_rx_data *rx_data;
- + int err;
- +
- + desc = kmalloc(sizeof(*desc), GFP_ATOMIC);
- + if (!desc)
- + goto update_stats;
- +
- + rxfid = hermes_read_regn(hw, RXFID);
- +
- + err = hw->ops->bap_pread(hw, IRQ_BAP, desc, sizeof(*desc),
- + rxfid, 0);
- + if (err) {
- + printk(KERN_ERR "%s: error %d reading Rx descriptor. "
- + "Frame dropped.\n", dev->name, err);
- + goto update_stats;
- + }
- +
- + status = le16_to_cpu(desc->status);
- +
- + if (status & HERMES_RXSTAT_BADCRC) {
- + DEBUG(1, "%s: Bad CRC on Rx. Frame dropped.\n",
- + dev->name);
- + stats->rx_crc_errors++;
- + goto update_stats;
- + }
- +
- + /* Handle frames in monitor mode */
- + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
- + orinoco_rx_monitor(dev, rxfid, desc);
- + goto out;
- + }
- +
- + if (status & HERMES_RXSTAT_UNDECRYPTABLE) {
- + DEBUG(1, "%s: Undecryptable frame on Rx. Frame dropped.\n",
- + dev->name);
- + wstats->discard.code++;
- + goto update_stats;
- + }
- +
- + length = le16_to_cpu(desc->data_len);
- +
- + /* Sanity checks */
- + if (length < 3) { /* No for even an 802.2 LLC header */
- + /* At least on Symbol firmware with PCF we get quite a
- + lot of these legitimately - Poll frames with no
- + data. */
- + goto out;
- + }
- + if (length > IEEE80211_MAX_DATA_LEN) {
- + printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n",
- + dev->name, length);
- + stats->rx_length_errors++;
- + goto update_stats;
- + }
- +
- + /* Payload size does not include Michael MIC. Increase payload
- + * size to read it together with the data. */
- + if (status & HERMES_RXSTAT_MIC)
- + length += MICHAEL_MIC_LEN;
- +
- + /* We need space for the packet data itself, plus an ethernet
- + header, plus 2 bytes so we can align the IP header on a
- + 32bit boundary, plus 1 byte so we can read in odd length
- + packets from the card, which has an IO granularity of 16
- + bits */
- + skb = dev_alloc_skb(length + ETH_HLEN + 2 + 1);
- + if (!skb) {
- + printk(KERN_WARNING "%s: Can't allocate skb for Rx\n",
- + dev->name);
- + goto update_stats;
- + }
- +
- + /* We'll prepend the header, so reserve space for it. The worst
- + case is no decapsulation, when 802.3 header is prepended and
- + nothing is removed. 2 is for aligning the IP header. */
- + skb_reserve(skb, ETH_HLEN + 2);
- +
- + err = hw->ops->bap_pread(hw, IRQ_BAP, skb_put(skb, length),
- + ALIGN(length, 2), rxfid,
- + HERMES_802_2_OFFSET);
- + if (err) {
- + printk(KERN_ERR "%s: error %d reading frame. "
- + "Frame dropped.\n", dev->name, err);
- + goto drop;
- + }
- +
- + /* Add desc and skb to rx queue */
- + rx_data = kzalloc(sizeof(*rx_data), GFP_ATOMIC);
- + if (!rx_data)
- + goto drop;
- +
- + rx_data->desc = desc;
- + rx_data->skb = skb;
- + list_add_tail(&rx_data->list, &priv->rx_list);
- + tasklet_schedule(&priv->rx_tasklet);
- +
- + return;
- +
- +drop:
- + dev_kfree_skb_irq(skb);
- +update_stats:
- + stats->rx_errors++;
- + stats->rx_dropped++;
- +out:
- + kfree(desc);
- +}
- +EXPORT_SYMBOL(__orinoco_ev_rx);
- +
- +static void orinoco_rx(struct net_device *dev,
- + struct hermes_rx_descriptor *desc,
- + struct sk_buff *skb)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct net_device_stats *stats = &dev->stats;
- + u16 status, fc;
- + int length;
- + struct ethhdr *hdr;
- +
- + status = le16_to_cpu(desc->status);
- + length = le16_to_cpu(desc->data_len);
- + fc = le16_to_cpu(desc->frame_ctl);
- +
- + /* Calculate and check MIC */
- + if (status & HERMES_RXSTAT_MIC) {
- + struct orinoco_tkip_key *key;
- + int key_id = ((status & HERMES_RXSTAT_MIC_KEY_ID) >>
- + HERMES_MIC_KEY_ID_SHIFT);
- + u8 mic[MICHAEL_MIC_LEN];
- + u8 *rxmic;
- + u8 *src = (fc & IEEE80211_FCTL_FROMDS) ?
- + desc->addr3 : desc->addr2;
- +
- + /* Extract Michael MIC from payload */
- + rxmic = skb->data + skb->len - MICHAEL_MIC_LEN;
- +
- + skb_trim(skb, skb->len - MICHAEL_MIC_LEN);
- + length -= MICHAEL_MIC_LEN;
- +
- + key = (struct orinoco_tkip_key *) priv->keys[key_id].key;
- +
- + if (!key) {
- + printk(KERN_WARNING "%s: Received encrypted frame from "
- + "%pM using key %i, but key is not installed\n",
- + dev->name, src, key_id);
- + goto drop;
- + }
- +
- + orinoco_mic(priv->rx_tfm_mic, key->rx_mic, desc->addr1, src,
- + 0, /* priority or QoS? */
- + skb->data, skb->len, &mic[0]);
- +
- + if (memcmp(mic, rxmic,
- + MICHAEL_MIC_LEN)) {
- + union iwreq_data wrqu;
- + struct iw_michaelmicfailure wxmic;
- +
- + printk(KERN_WARNING "%s: "
- + "Invalid Michael MIC in data frame from %pM, "
- + "using key %i\n",
- + dev->name, src, key_id);
- +
- + /* TODO: update stats */
- +
- + /* Notify userspace */
- + memset(&wxmic, 0, sizeof(wxmic));
- + wxmic.flags = key_id & IW_MICFAILURE_KEY_ID;
- + wxmic.flags |= (desc->addr1[0] & 1) ?
- + IW_MICFAILURE_GROUP : IW_MICFAILURE_PAIRWISE;
- + wxmic.src_addr.sa_family = ARPHRD_ETHER;
- + memcpy(wxmic.src_addr.sa_data, src, ETH_ALEN);
- +
- + (void) orinoco_hw_get_tkip_iv(priv, key_id,
- + &wxmic.tsc[0]);
- +
- + memset(&wrqu, 0, sizeof(wrqu));
- + wrqu.data.length = sizeof(wxmic);
- + wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu,
- + (char *) &wxmic);
- +
- + goto drop;
- + }
- + }
- +
- + /* Handle decapsulation
- + * In most cases, the firmware tell us about SNAP frames.
- + * For some reason, the SNAP frames sent by LinkSys APs
- + * are not properly recognised by most firmwares.
- + * So, check ourselves */
- + if (length >= ENCAPS_OVERHEAD &&
- + (((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_1042) ||
- + ((status & HERMES_RXSTAT_MSGTYPE) == HERMES_RXSTAT_TUNNEL) ||
- + is_ethersnap(skb->data))) {
- + /* These indicate a SNAP within 802.2 LLC within
- + 802.11 frame which we'll need to de-encapsulate to
- + the original EthernetII frame. */
- + hdr = skb_push(skb, ETH_HLEN - ENCAPS_OVERHEAD);
- + } else {
- + /* 802.3 frame - prepend 802.3 header as is */
- + hdr = skb_push(skb, ETH_HLEN);
- + hdr->h_proto = htons(length);
- + }
- + memcpy(hdr->h_dest, desc->addr1, ETH_ALEN);
- + if (fc & IEEE80211_FCTL_FROMDS)
- + memcpy(hdr->h_source, desc->addr3, ETH_ALEN);
- + else
- + memcpy(hdr->h_source, desc->addr2, ETH_ALEN);
- +
- + skb->protocol = eth_type_trans(skb, dev);
- + skb->ip_summed = CHECKSUM_NONE;
- + if (fc & IEEE80211_FCTL_TODS)
- + skb->pkt_type = PACKET_OTHERHOST;
- +
- + /* Process the wireless stats if needed */
- + orinoco_stat_gather(dev, skb, desc);
- +
- + /* Pass the packet to the networking stack */
- + netif_rx(skb);
- + stats->rx_packets++;
- + stats->rx_bytes += length;
- +
- + return;
- +
- + drop:
- + dev_kfree_skb(skb);
- + stats->rx_errors++;
- + stats->rx_dropped++;
- +}
- +
- +static void orinoco_rx_isr_tasklet(struct tasklet_struct *t)
- +{
- + struct orinoco_private *priv = from_tasklet(priv, t, rx_tasklet);
- + struct net_device *dev = priv->ndev;
- + struct orinoco_rx_data *rx_data, *temp;
- + struct hermes_rx_descriptor *desc;
- + struct sk_buff *skb;
- + unsigned long flags;
- +
- + /* orinoco_rx requires the driver lock, and we also need to
- + * protect priv->rx_list, so just hold the lock over the
- + * lot.
- + *
- + * If orinoco_lock fails, we've unplugged the card. In this
- + * case just abort. */
- + if (orinoco_lock(priv, &flags) != 0)
- + return;
- +
- + /* extract desc and skb from queue */
- + list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) {
- + desc = rx_data->desc;
- + skb = rx_data->skb;
- + list_del(&rx_data->list);
- + kfree(rx_data);
- +
- + orinoco_rx(dev, desc, skb);
- +
- + kfree(desc);
- + }
- +
- + orinoco_unlock(priv, &flags);
- +}
- +
- +/********************************************************************/
- +/* Rx path (info frames) */
- +/********************************************************************/
- +
- +static void print_linkstatus(struct net_device *dev, u16 status)
- +{
- + char *s;
- +
- + if (suppress_linkstatus)
- + return;
- +
- + switch (status) {
- + case HERMES_LINKSTATUS_NOT_CONNECTED:
- + s = "Not Connected";
- + break;
- + case HERMES_LINKSTATUS_CONNECTED:
- + s = "Connected";
- + break;
- + case HERMES_LINKSTATUS_DISCONNECTED:
- + s = "Disconnected";
- + break;
- + case HERMES_LINKSTATUS_AP_CHANGE:
- + s = "AP Changed";
- + break;
- + case HERMES_LINKSTATUS_AP_OUT_OF_RANGE:
- + s = "AP Out of Range";
- + break;
- + case HERMES_LINKSTATUS_AP_IN_RANGE:
- + s = "AP In Range";
- + break;
- + case HERMES_LINKSTATUS_ASSOC_FAILED:
- + s = "Association Failed";
- + break;
- + default:
- + s = "UNKNOWN";
- + }
- +
- + printk(KERN_DEBUG "%s: New link status: %s (%04x)\n",
- + dev->name, s, status);
- +}
- +
- +/* Search scan results for requested BSSID, join it if found */
- +static void orinoco_join_ap(struct work_struct *work)
- +{
- + struct orinoco_private *priv =
- + container_of(work, struct orinoco_private, join_work);
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + int err;
- + unsigned long flags;
- + struct join_req {
- + u8 bssid[ETH_ALEN];
- + __le16 channel;
- + } __packed req;
- + const int atom_len = offsetof(struct prism2_scan_apinfo, atim);
- + struct prism2_scan_apinfo *atom = NULL;
- + int offset = 4;
- + int found = 0;
- + u8 *buf;
- + u16 len;
- +
- + /* Allocate buffer for scan results */
- + buf = kmalloc(MAX_SCAN_LEN, GFP_KERNEL);
- + if (!buf)
- + return;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + goto fail_lock;
- +
- + /* Sanity checks in case user changed something in the meantime */
- + if (!priv->bssid_fixed)
- + goto out;
- +
- + if (strlen(priv->desired_essid) == 0)
- + goto out;
- +
- + /* Read scan results from the firmware */
- + err = hw->ops->read_ltv(hw, USER_BAP,
- + HERMES_RID_SCANRESULTSTABLE,
- + MAX_SCAN_LEN, &len, buf);
- + if (err) {
- + printk(KERN_ERR "%s: Cannot read scan results\n",
- + dev->name);
- + goto out;
- + }
- +
- + len = HERMES_RECLEN_TO_BYTES(len);
- +
- + /* Go through the scan results looking for the channel of the AP
- + * we were requested to join */
- + for (; offset + atom_len <= len; offset += atom_len) {
- + atom = (struct prism2_scan_apinfo *) (buf + offset);
- + if (memcmp(&atom->bssid, priv->desired_bssid, ETH_ALEN) == 0) {
- + found = 1;
- + break;
- + }
- + }
- +
- + if (!found) {
- + DEBUG(1, "%s: Requested AP not found in scan results\n",
- + dev->name);
- + goto out;
- + }
- +
- + memcpy(req.bssid, priv->desired_bssid, ETH_ALEN);
- + req.channel = atom->channel; /* both are little-endian */
- + err = HERMES_WRITE_RECORD(hw, USER_BAP, HERMES_RID_CNFJOINREQUEST,
- + &req);
- + if (err)
- + printk(KERN_ERR "%s: Error issuing join request\n", dev->name);
- +
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + fail_lock:
- + kfree(buf);
- +}
- +
- +/* Send new BSSID to userspace */
- +static void orinoco_send_bssid_wevent(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + union iwreq_data wrqu;
- + int err;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENTBSSID,
- + ETH_ALEN, NULL, wrqu.ap_addr.sa_data);
- + if (err != 0)
- + return;
- +
- + wrqu.ap_addr.sa_family = ARPHRD_ETHER;
- +
- + /* Send event to user space */
- + wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
- +}
- +
- +static void orinoco_send_assocreqie_wevent(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + union iwreq_data wrqu;
- + int err;
- + u8 buf[88];
- + u8 *ie;
- +
- + if (!priv->has_wpa)
- + return;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_ASSOC_REQ_INFO,
- + sizeof(buf), NULL, &buf);
- + if (err != 0)
- + return;
- +
- + ie = orinoco_get_wpa_ie(buf, sizeof(buf));
- + if (ie) {
- + int rem = sizeof(buf) - (ie - &buf[0]);
- + wrqu.data.length = ie[1] + 2;
- + if (wrqu.data.length > rem)
- + wrqu.data.length = rem;
- +
- + if (wrqu.data.length)
- + /* Send event to user space */
- + wireless_send_event(dev, IWEVASSOCREQIE, &wrqu, ie);
- + }
- +}
- +
- +static void orinoco_send_assocrespie_wevent(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + union iwreq_data wrqu;
- + int err;
- + u8 buf[88]; /* TODO: verify max size or IW_GENERIC_IE_MAX */
- + u8 *ie;
- +
- + if (!priv->has_wpa)
- + return;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP,
- + HERMES_RID_CURRENT_ASSOC_RESP_INFO,
- + sizeof(buf), NULL, &buf);
- + if (err != 0)
- + return;
- +
- + ie = orinoco_get_wpa_ie(buf, sizeof(buf));
- + if (ie) {
- + int rem = sizeof(buf) - (ie - &buf[0]);
- + wrqu.data.length = ie[1] + 2;
- + if (wrqu.data.length > rem)
- + wrqu.data.length = rem;
- +
- + if (wrqu.data.length)
- + /* Send event to user space */
- + wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, ie);
- + }
- +}
- +
- +static void orinoco_send_wevents(struct work_struct *work)
- +{
- + struct orinoco_private *priv =
- + container_of(work, struct orinoco_private, wevent_work);
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return;
- +
- + orinoco_send_assocreqie_wevent(priv);
- + orinoco_send_assocrespie_wevent(priv);
- + orinoco_send_bssid_wevent(priv);
- +
- + orinoco_unlock(priv, &flags);
- +}
- +
- +static void qbuf_scan(struct orinoco_private *priv, void *buf,
- + int len, int type)
- +{
- + struct orinoco_scan_data *sd;
- + unsigned long flags;
- +
- + sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
- + if (!sd)
- + return;
- +
- + sd->buf = buf;
- + sd->len = len;
- + sd->type = type;
- +
- + spin_lock_irqsave(&priv->scan_lock, flags);
- + list_add_tail(&sd->list, &priv->scan_list);
- + spin_unlock_irqrestore(&priv->scan_lock, flags);
- +
- + schedule_work(&priv->process_scan);
- +}
- +
- +static void qabort_scan(struct orinoco_private *priv)
- +{
- + struct orinoco_scan_data *sd;
- + unsigned long flags;
- +
- + sd = kmalloc(sizeof(*sd), GFP_ATOMIC);
- + if (!sd)
- + return;
- +
- + sd->len = -1; /* Abort */
- +
- + spin_lock_irqsave(&priv->scan_lock, flags);
- + list_add_tail(&sd->list, &priv->scan_list);
- + spin_unlock_irqrestore(&priv->scan_lock, flags);
- +
- + schedule_work(&priv->process_scan);
- +}
- +
- +static void orinoco_process_scan_results(struct work_struct *work)
- +{
- + struct orinoco_private *priv =
- + container_of(work, struct orinoco_private, process_scan);
- + struct orinoco_scan_data *sd, *temp;
- + unsigned long flags;
- + void *buf;
- + int len;
- + int type;
- +
- + spin_lock_irqsave(&priv->scan_lock, flags);
- + list_for_each_entry_safe(sd, temp, &priv->scan_list, list) {
- +
- + buf = sd->buf;
- + len = sd->len;
- + type = sd->type;
- +
- + list_del(&sd->list);
- + spin_unlock_irqrestore(&priv->scan_lock, flags);
- + kfree(sd);
- +
- + if (len > 0) {
- + if (type == HERMES_INQ_CHANNELINFO)
- + orinoco_add_extscan_result(priv, buf, len);
- + else
- + orinoco_add_hostscan_results(priv, buf, len);
- +
- + kfree(buf);
- + } else {
- + /* Either abort or complete the scan */
- + orinoco_scan_done(priv, (len < 0));
- + }
- +
- + spin_lock_irqsave(&priv->scan_lock, flags);
- + }
- + spin_unlock_irqrestore(&priv->scan_lock, flags);
- +}
- +
- +void __orinoco_ev_info(struct net_device *dev, struct hermes *hw)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + u16 infofid;
- + struct {
- + __le16 len;
- + __le16 type;
- + } __packed info;
- + int len, type;
- + int err;
- +
- + /* This is an answer to an INQUIRE command that we did earlier,
- + * or an information "event" generated by the card
- + * The controller return to us a pseudo frame containing
- + * the information in question - Jean II */
- + infofid = hermes_read_regn(hw, INFOFID);
- +
- + /* Read the info frame header - don't try too hard */
- + err = hw->ops->bap_pread(hw, IRQ_BAP, &info, sizeof(info),
- + infofid, 0);
- + if (err) {
- + printk(KERN_ERR "%s: error %d reading info frame. "
- + "Frame dropped.\n", dev->name, err);
- + return;
- + }
- +
- + len = HERMES_RECLEN_TO_BYTES(le16_to_cpu(info.len));
- + type = le16_to_cpu(info.type);
- +
- + switch (type) {
- + case HERMES_INQ_TALLIES: {
- + struct hermes_tallies_frame tallies;
- + struct iw_statistics *wstats = &priv->wstats;
- +
- + if (len > sizeof(tallies)) {
- + printk(KERN_WARNING "%s: Tallies frame too long (%d bytes)\n",
- + dev->name, len);
- + len = sizeof(tallies);
- + }
- +
- + err = hw->ops->bap_pread(hw, IRQ_BAP, &tallies, len,
- + infofid, sizeof(info));
- + if (err)
- + break;
- +
- + /* Increment our various counters */
- + /* wstats->discard.nwid - no wrong BSSID stuff */
- + wstats->discard.code +=
- + le16_to_cpu(tallies.RxWEPUndecryptable);
- + if (len == sizeof(tallies))
- + wstats->discard.code +=
- + le16_to_cpu(tallies.RxDiscards_WEPICVError) +
- + le16_to_cpu(tallies.RxDiscards_WEPExcluded);
- + wstats->discard.misc +=
- + le16_to_cpu(tallies.TxDiscardsWrongSA);
- + wstats->discard.fragment +=
- + le16_to_cpu(tallies.RxMsgInBadMsgFragments);
- + wstats->discard.retries +=
- + le16_to_cpu(tallies.TxRetryLimitExceeded);
- + /* wstats->miss.beacon - no match */
- + }
- + break;
- + case HERMES_INQ_LINKSTATUS: {
- + struct hermes_linkstatus linkstatus;
- + u16 newstatus;
- + int connected;
- +
- + if (priv->iw_mode == NL80211_IFTYPE_MONITOR)
- + break;
- +
- + if (len != sizeof(linkstatus)) {
- + printk(KERN_WARNING "%s: Unexpected size for linkstatus frame (%d bytes)\n",
- + dev->name, len);
- + break;
- + }
- +
- + err = hw->ops->bap_pread(hw, IRQ_BAP, &linkstatus, len,
- + infofid, sizeof(info));
- + if (err)
- + break;
- + newstatus = le16_to_cpu(linkstatus.linkstatus);
- +
- + /* Symbol firmware uses "out of range" to signal that
- + * the hostscan frame can be requested. */
- + if (newstatus == HERMES_LINKSTATUS_AP_OUT_OF_RANGE &&
- + priv->firmware_type == FIRMWARE_TYPE_SYMBOL &&
- + priv->has_hostscan && priv->scan_request) {
- + hermes_inquire(hw, HERMES_INQ_HOSTSCAN_SYMBOL);
- + break;
- + }
- +
- + connected = (newstatus == HERMES_LINKSTATUS_CONNECTED)
- + || (newstatus == HERMES_LINKSTATUS_AP_CHANGE)
- + || (newstatus == HERMES_LINKSTATUS_AP_IN_RANGE);
- +
- + if (connected)
- + netif_carrier_on(dev);
- + else if (!ignore_disconnect)
- + netif_carrier_off(dev);
- +
- + if (newstatus != priv->last_linkstatus) {
- + priv->last_linkstatus = newstatus;
- + print_linkstatus(dev, newstatus);
- + /* The info frame contains only one word which is the
- + * status (see hermes.h). The status is pretty boring
- + * in itself, that's why we export the new BSSID...
- + * Jean II */
- + schedule_work(&priv->wevent_work);
- + }
- + }
- + break;
- + case HERMES_INQ_SCAN:
- + if (!priv->scan_request && priv->bssid_fixed &&
- + priv->firmware_type == FIRMWARE_TYPE_INTERSIL) {
- + schedule_work(&priv->join_work);
- + break;
- + }
- + fallthrough;
- + case HERMES_INQ_HOSTSCAN:
- + case HERMES_INQ_HOSTSCAN_SYMBOL: {
- + /* Result of a scanning. Contains information about
- + * cells in the vicinity - Jean II */
- + unsigned char *buf;
- +
- + /* Sanity check */
- + if (len > 4096) {
- + printk(KERN_WARNING "%s: Scan results too large (%d bytes)\n",
- + dev->name, len);
- + qabort_scan(priv);
- + break;
- + }
- +
- + /* Allocate buffer for results */
- + buf = kmalloc(len, GFP_ATOMIC);
- + if (buf == NULL) {
- + /* No memory, so can't printk()... */
- + qabort_scan(priv);
- + break;
- + }
- +
- + /* Read scan data */
- + err = hw->ops->bap_pread(hw, IRQ_BAP, (void *) buf, len,
- + infofid, sizeof(info));
- + if (err) {
- + kfree(buf);
- + qabort_scan(priv);
- + break;
- + }
- +
- +#ifdef ORINOCO_DEBUG
- + {
- + int i;
- + printk(KERN_DEBUG "Scan result [%02X", buf[0]);
- + for (i = 1; i < (len * 2); i++)
- + printk(":%02X", buf[i]);
- + printk("]\n");
- + }
- +#endif /* ORINOCO_DEBUG */
- +
- + qbuf_scan(priv, buf, len, type);
- + }
- + break;
- + case HERMES_INQ_CHANNELINFO:
- + {
- + struct agere_ext_scan_info *bss;
- +
- + if (!priv->scan_request) {
- + printk(KERN_DEBUG "%s: Got chaninfo without scan, "
- + "len=%d\n", dev->name, len);
- + break;
- + }
- +
- + /* An empty result indicates that the scan is complete */
- + if (len == 0) {
- + qbuf_scan(priv, NULL, len, type);
- + break;
- + }
- +
- + /* Sanity check */
- + else if (len < (offsetof(struct agere_ext_scan_info,
- + data) + 2)) {
- + /* Drop this result now so we don't have to
- + * keep checking later */
- + printk(KERN_WARNING
- + "%s: Ext scan results too short (%d bytes)\n",
- + dev->name, len);
- + break;
- + }
- +
- + bss = kmalloc(len, GFP_ATOMIC);
- + if (bss == NULL)
- + break;
- +
- + /* Read scan data */
- + err = hw->ops->bap_pread(hw, IRQ_BAP, (void *) bss, len,
- + infofid, sizeof(info));
- + if (err)
- + kfree(bss);
- + else
- + qbuf_scan(priv, bss, len, type);
- +
- + break;
- + }
- + case HERMES_INQ_SEC_STAT_AGERE:
- + /* Security status (Agere specific) */
- + /* Ignore this frame for now */
- + if (priv->firmware_type == FIRMWARE_TYPE_AGERE)
- + break;
- + fallthrough;
- + default:
- + printk(KERN_DEBUG "%s: Unknown information frame received: "
- + "type 0x%04x, length %d\n", dev->name, type, len);
- + /* We don't actually do anything about it */
- + break;
- + }
- +}
- +EXPORT_SYMBOL(__orinoco_ev_info);
- +
- +static void __orinoco_ev_infdrop(struct net_device *dev, struct hermes *hw)
- +{
- + if (net_ratelimit())
- + printk(KERN_DEBUG "%s: Information frame lost.\n", dev->name);
- +}
- +
- +/********************************************************************/
- +/* Internal hardware control routines */
- +/********************************************************************/
- +
- +static int __orinoco_up(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + netif_carrier_off(dev); /* just to make sure */
- +
- + err = __orinoco_commit(priv);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d configuring card\n",
- + dev->name, err);
- + return err;
- + }
- +
- + /* Fire things up again */
- + hermes_set_irqmask(hw, ORINOCO_INTEN);
- + err = hermes_enable_port(hw, 0);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d enabling MAC port\n",
- + dev->name, err);
- + return err;
- + }
- +
- + netif_start_queue(dev);
- +
- + return 0;
- +}
- +
- +static int __orinoco_down(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + netif_stop_queue(dev);
- +
- + if (!priv->hw_unavailable) {
- + if (!priv->broken_disableport) {
- + err = hermes_disable_port(hw, 0);
- + if (err) {
- + /* Some firmwares (e.g. Intersil 1.3.x) seem
- + * to have problems disabling the port, oh
- + * well, too bad. */
- + printk(KERN_WARNING "%s: Error %d disabling MAC port\n",
- + dev->name, err);
- + priv->broken_disableport = 1;
- + }
- + }
- + hermes_set_irqmask(hw, 0);
- + hermes_write_regn(hw, EVACK, 0xffff);
- + }
- +
- + orinoco_scan_done(priv, true);
- +
- + /* firmware will have to reassociate */
- + netif_carrier_off(dev);
- + priv->last_linkstatus = 0xffff;
- +
- + return 0;
- +}
- +
- +static int orinoco_reinit_firmware(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + err = hw->ops->init(hw);
- + if (priv->do_fw_download && !err) {
- + err = orinoco_download(priv);
- + if (err)
- + priv->do_fw_download = 0;
- + }
- + if (!err)
- + err = orinoco_hw_allocate_fid(priv);
- +
- + return err;
- +}
- +
- +static int
- +__orinoco_set_multicast_list(struct net_device *dev)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + int err = 0;
- + int promisc, mc_count;
- +
- + /* The Hermes doesn't seem to have an allmulti mode, so we go
- + * into promiscuous mode and let the upper levels deal. */
- + if ((dev->flags & IFF_PROMISC) || (dev->flags & IFF_ALLMULTI) ||
- + (netdev_mc_count(dev) > MAX_MULTICAST(priv))) {
- + promisc = 1;
- + mc_count = 0;
- + } else {
- + promisc = 0;
- + mc_count = netdev_mc_count(dev);
- + }
- +
- + err = __orinoco_hw_set_multicast_list(priv, dev, mc_count, promisc);
- +
- + return err;
- +}
- +
- +/* This must be called from user context, without locks held - use
- + * schedule_work() */
- +void orinoco_reset(struct work_struct *work)
- +{
- + struct orinoco_private *priv =
- + container_of(work, struct orinoco_private, reset_work);
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + int err;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + /* When the hardware becomes available again, whatever
- + * detects that is responsible for re-initializing
- + * it. So no need for anything further */
- + return;
- +
- + netif_stop_queue(dev);
- +
- + /* Shut off interrupts. Depending on what state the hardware
- + * is in, this might not work, but we'll try anyway */
- + hermes_set_irqmask(hw, 0);
- + hermes_write_regn(hw, EVACK, 0xffff);
- +
- + priv->hw_unavailable++;
- + priv->last_linkstatus = 0xffff; /* firmware will have to reassociate */
- + netif_carrier_off(dev);
- +
- + orinoco_unlock(priv, &flags);
- +
- + /* Scanning support: Notify scan cancellation */
- + orinoco_scan_done(priv, true);
- +
- + if (priv->hard_reset) {
- + err = (*priv->hard_reset)(priv);
- + if (err) {
- + printk(KERN_ERR "%s: orinoco_reset: Error %d "
- + "performing hard reset\n", dev->name, err);
- + goto disable;
- + }
- + }
- +
- + err = orinoco_reinit_firmware(priv);
- + if (err) {
- + printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n",
- + dev->name, err);
- + goto disable;
- + }
- +
- + /* This has to be called from user context */
- + orinoco_lock_irq(priv);
- +
- + priv->hw_unavailable--;
- +
- + /* priv->open or priv->hw_unavailable might have changed while
- + * we dropped the lock */
- + if (priv->open && (!priv->hw_unavailable)) {
- + err = __orinoco_up(priv);
- + if (err) {
- + printk(KERN_ERR "%s: orinoco_reset: Error %d reenabling card\n",
- + dev->name, err);
- + } else
- + netif_trans_update(dev);
- + }
- +
- + orinoco_unlock_irq(priv);
- +
- + return;
- + disable:
- + hermes_set_irqmask(hw, 0);
- + netif_device_detach(dev);
- + printk(KERN_ERR "%s: Device has been disabled!\n", dev->name);
- +}
- +
- +static int __orinoco_commit(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + int err = 0;
- +
- + /* If we've called commit, we are reconfiguring or bringing the
- + * interface up. Maintaining countermeasures across this would
- + * be confusing, so note that we've disabled them. The port will
- + * be enabled later in orinoco_commit or __orinoco_up. */
- + priv->tkip_cm_active = 0;
- +
- + err = orinoco_hw_program_rids(priv);
- +
- + /* FIXME: what about netif_tx_lock */
- + (void) __orinoco_set_multicast_list(dev);
- +
- + return err;
- +}
- +
- +/* Ensures configuration changes are applied. May result in a reset.
- + * The caller should hold priv->lock
- + */
- +int orinoco_commit(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + int err;
- +
- + if (priv->broken_disableport) {
- + schedule_work(&priv->reset_work);
- + return 0;
- + }
- +
- + err = hermes_disable_port(hw, 0);
- + if (err) {
- + printk(KERN_WARNING "%s: Unable to disable port "
- + "while reconfiguring card\n", dev->name);
- + priv->broken_disableport = 1;
- + goto out;
- + }
- +
- + err = __orinoco_commit(priv);
- + if (err) {
- + printk(KERN_WARNING "%s: Unable to reconfigure card\n",
- + dev->name);
- + goto out;
- + }
- +
- + err = hermes_enable_port(hw, 0);
- + if (err) {
- + printk(KERN_WARNING "%s: Unable to enable port while reconfiguring card\n",
- + dev->name);
- + goto out;
- + }
- +
- + out:
- + if (err) {
- + printk(KERN_WARNING "%s: Resetting instead...\n", dev->name);
- + schedule_work(&priv->reset_work);
- + err = 0;
- + }
- + return err;
- +}
- +
- +/********************************************************************/
- +/* Interrupt handler */
- +/********************************************************************/
- +
- +static void __orinoco_ev_tick(struct net_device *dev, struct hermes *hw)
- +{
- + printk(KERN_DEBUG "%s: TICK\n", dev->name);
- +}
- +
- +static void __orinoco_ev_wterr(struct net_device *dev, struct hermes *hw)
- +{
- + /* This seems to happen a fair bit under load, but ignoring it
- + seems to work fine...*/
- + printk(KERN_DEBUG "%s: MAC controller error (WTERR). Ignoring.\n",
- + dev->name);
- +}
- +
- +irqreturn_t orinoco_interrupt(int irq, void *dev_id)
- +{
- + struct orinoco_private *priv = dev_id;
- + struct net_device *dev = priv->ndev;
- + struct hermes *hw = &priv->hw;
- + int count = MAX_IRQLOOPS_PER_IRQ;
- + u16 evstat, events;
- + /* These are used to detect a runaway interrupt situation.
- + *
- + * If we get more than MAX_IRQLOOPS_PER_JIFFY iterations in a jiffy,
- + * we panic and shut down the hardware
- + */
- + /* jiffies value the last time we were called */
- + static int last_irq_jiffy; /* = 0 */
- + static int loops_this_jiffy; /* = 0 */
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0) {
- + /* If hw is unavailable - we don't know if the irq was
- + * for us or not */
- + return IRQ_HANDLED;
- + }
- +
- + evstat = hermes_read_regn(hw, EVSTAT);
- + events = evstat & hw->inten;
- + if (!events) {
- + orinoco_unlock(priv, &flags);
- + return IRQ_NONE;
- + }
- +
- + if (jiffies != last_irq_jiffy)
- + loops_this_jiffy = 0;
- + last_irq_jiffy = jiffies;
- +
- + while (events && count--) {
- + if (++loops_this_jiffy > MAX_IRQLOOPS_PER_JIFFY) {
- + printk(KERN_WARNING "%s: IRQ handler is looping too "
- + "much! Resetting.\n", dev->name);
- + /* Disable interrupts for now */
- + hermes_set_irqmask(hw, 0);
- + schedule_work(&priv->reset_work);
- + break;
- + }
- +
- + /* Check the card hasn't been removed */
- + if (!hermes_present(hw)) {
- + DEBUG(0, "orinoco_interrupt(): card removed\n");
- + break;
- + }
- +
- + if (events & HERMES_EV_TICK)
- + __orinoco_ev_tick(dev, hw);
- + if (events & HERMES_EV_WTERR)
- + __orinoco_ev_wterr(dev, hw);
- + if (events & HERMES_EV_INFDROP)
- + __orinoco_ev_infdrop(dev, hw);
- + if (events & HERMES_EV_INFO)
- + __orinoco_ev_info(dev, hw);
- + if (events & HERMES_EV_RX)
- + __orinoco_ev_rx(dev, hw);
- + if (events & HERMES_EV_TXEXC)
- + __orinoco_ev_txexc(dev, hw);
- + if (events & HERMES_EV_TX)
- + __orinoco_ev_tx(dev, hw);
- + if (events & HERMES_EV_ALLOC)
- + __orinoco_ev_alloc(dev, hw);
- +
- + hermes_write_regn(hw, EVACK, evstat);
- +
- + evstat = hermes_read_regn(hw, EVSTAT);
- + events = evstat & hw->inten;
- + }
- +
- + orinoco_unlock(priv, &flags);
- + return IRQ_HANDLED;
- +}
- +EXPORT_SYMBOL(orinoco_interrupt);
- +
- +/********************************************************************/
- +/* Power management */
- +/********************************************************************/
- +#if defined(CONFIG_PM_SLEEP) && !defined(CONFIG_HERMES_CACHE_FW_ON_INIT)
- +static int orinoco_pm_notifier(struct notifier_block *notifier,
- + unsigned long pm_event,
- + void *unused)
- +{
- + struct orinoco_private *priv = container_of(notifier,
- + struct orinoco_private,
- + pm_notifier);
- +
- + /* All we need to do is cache the firmware before suspend, and
- + * release it when we come out.
- + *
- + * Only need to do this if we're downloading firmware. */
- + if (!priv->do_fw_download)
- + return NOTIFY_DONE;
- +
- + switch (pm_event) {
- + case PM_HIBERNATION_PREPARE:
- + case PM_SUSPEND_PREPARE:
- + orinoco_cache_fw(priv, 0);
- + break;
- +
- + case PM_POST_RESTORE:
- + /* Restore from hibernation failed. We need to clean
- + * up in exactly the same way, so fall through. */
- + case PM_POST_HIBERNATION:
- + case PM_POST_SUSPEND:
- + orinoco_uncache_fw(priv);
- + break;
- +
- + case PM_RESTORE_PREPARE:
- + default:
- + break;
- + }
- +
- + return NOTIFY_DONE;
- +}
- +
- +static void orinoco_register_pm_notifier(struct orinoco_private *priv)
- +{
- + priv->pm_notifier.notifier_call = orinoco_pm_notifier;
- + register_pm_notifier(&priv->pm_notifier);
- +}
- +
- +static void orinoco_unregister_pm_notifier(struct orinoco_private *priv)
- +{
- + unregister_pm_notifier(&priv->pm_notifier);
- +}
- +#else /* !PM_SLEEP || HERMES_CACHE_FW_ON_INIT */
- +#define orinoco_register_pm_notifier(priv) do { } while (0)
- +#define orinoco_unregister_pm_notifier(priv) do { } while (0)
- +#endif
- +
- +/********************************************************************/
- +/* Initialization */
- +/********************************************************************/
- +
- +int orinoco_init(struct orinoco_private *priv)
- +{
- + struct device *dev = priv->dev;
- + struct wiphy *wiphy = priv_to_wiphy(priv);
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- +
- + /* No need to lock, the hw_unavailable flag is already set in
- + * alloc_orinocodev() */
- + priv->nicbuf_size = IEEE80211_MAX_FRAME_LEN + ETH_HLEN;
- +
- + /* Initialize the firmware */
- + err = hw->ops->init(hw);
- + if (err != 0) {
- + dev_err(dev, "Failed to initialize firmware (err = %d)\n",
- + err);
- + goto out;
- + }
- +
- + err = determine_fw_capabilities(priv, wiphy->fw_version,
- + sizeof(wiphy->fw_version),
- + &wiphy->hw_version);
- + if (err != 0) {
- + dev_err(dev, "Incompatible firmware, aborting\n");
- + goto out;
- + }
- +
- + if (priv->do_fw_download) {
- +#ifdef CONFIG_HERMES_CACHE_FW_ON_INIT
- + orinoco_cache_fw(priv, 0);
- +#endif
- +
- + err = orinoco_download(priv);
- + if (err)
- + priv->do_fw_download = 0;
- +
- + /* Check firmware version again */
- + err = determine_fw_capabilities(priv, wiphy->fw_version,
- + sizeof(wiphy->fw_version),
- + &wiphy->hw_version);
- + if (err != 0) {
- + dev_err(dev, "Incompatible firmware, aborting\n");
- + goto out;
- + }
- + }
- +
- + if (priv->has_port3)
- + dev_info(dev, "Ad-hoc demo mode supported\n");
- + if (priv->has_ibss)
- + dev_info(dev, "IEEE standard IBSS ad-hoc mode supported\n");
- + if (priv->has_wep)
- + dev_info(dev, "WEP supported, %s-bit key\n",
- + priv->has_big_wep ? "104" : "40");
- + if (priv->has_wpa) {
- + dev_info(dev, "WPA-PSK supported\n");
- + if (orinoco_mic_init(priv)) {
- + dev_err(dev, "Failed to setup MIC crypto algorithm. "
- + "Disabling WPA support\n");
- + priv->has_wpa = 0;
- + }
- + }
- +
- + err = orinoco_hw_read_card_settings(priv, wiphy->perm_addr);
- + if (err)
- + goto out;
- +
- + err = orinoco_hw_allocate_fid(priv);
- + if (err) {
- + dev_err(dev, "Failed to allocate NIC buffer!\n");
- + goto out;
- + }
- +
- + /* Set up the default configuration */
- + priv->iw_mode = NL80211_IFTYPE_STATION;
- + /* By default use IEEE/IBSS ad-hoc mode if we have it */
- + priv->prefer_port3 = priv->has_port3 && (!priv->has_ibss);
- + set_port_type(priv);
- + priv->channel = 0; /* use firmware default */
- +
- + priv->promiscuous = 0;
- + priv->encode_alg = ORINOCO_ALG_NONE;
- + priv->tx_key = 0;
- + priv->wpa_enabled = 0;
- + priv->tkip_cm_active = 0;
- + priv->key_mgmt = 0;
- + priv->wpa_ie_len = 0;
- + priv->wpa_ie = NULL;
- +
- + if (orinoco_wiphy_register(wiphy)) {
- + err = -ENODEV;
- + goto out;
- + }
- +
- + /* Make the hardware available, as long as it hasn't been
- + * removed elsewhere (e.g. by PCMCIA hot unplug) */
- + orinoco_lock_irq(priv);
- + priv->hw_unavailable--;
- + orinoco_unlock_irq(priv);
- +
- + dev_dbg(dev, "Ready\n");
- +
- + out:
- + return err;
- +}
- +EXPORT_SYMBOL(orinoco_init);
- +
- +static const struct net_device_ops orinoco_netdev_ops = {
- + .ndo_open = orinoco_open,
- + .ndo_stop = orinoco_stop,
- + .ndo_start_xmit = orinoco_xmit,
- + .ndo_set_rx_mode = orinoco_set_multicast_list,
- + .ndo_change_mtu = orinoco_change_mtu,
- + .ndo_set_mac_address = eth_mac_addr,
- + .ndo_validate_addr = eth_validate_addr,
- + .ndo_tx_timeout = orinoco_tx_timeout,
- +};
- +
- +/* Allocate private data.
- + *
- + * This driver has a number of structures associated with it
- + * netdev - Net device structure for each network interface
- + * wiphy - structure associated with wireless phy
- + * wireless_dev (wdev) - structure for each wireless interface
- + * hw - structure for hermes chip info
- + * card - card specific structure for use by the card driver
- + * (airport, orinoco_cs)
- + * priv - orinoco private data
- + * device - generic linux device structure
- + *
- + * +---------+ +---------+
- + * | wiphy | | netdev |
- + * | +-------+ | +-------+
- + * | | priv | | | wdev |
- + * | | +-----+ +-+-------+
- + * | | | hw |
- + * | +-+-----+
- + * | | card |
- + * +-+-------+
- + *
- + * priv has a link to netdev and device
- + * wdev has a link to wiphy
- + */
- +struct orinoco_private
- +*alloc_orinocodev(int sizeof_card,
- + struct device *device,
- + int (*hard_reset)(struct orinoco_private *),
- + int (*stop_fw)(struct orinoco_private *, int))
- +{
- + struct orinoco_private *priv;
- + struct wiphy *wiphy;
- +
- + /* allocate wiphy
- + * NOTE: We only support a single virtual interface
- + * but this may change when monitor mode is added
- + */
- + wiphy = wiphy_new(&orinoco_cfg_ops,
- + sizeof(struct orinoco_private) + sizeof_card);
- + if (!wiphy)
- + return NULL;
- +
- + priv = wiphy_priv(wiphy);
- + priv->dev = device;
- +
- + if (sizeof_card)
- + priv->card = (void *)((unsigned long)priv
- + + sizeof(struct orinoco_private));
- + else
- + priv->card = NULL;
- +
- + orinoco_wiphy_init(wiphy);
- +
- +#ifdef WIRELESS_SPY
- + priv->wireless_data.spy_data = &priv->spy_data;
- +#endif
- +
- + /* Set up default callbacks */
- + priv->hard_reset = hard_reset;
- + priv->stop_fw = stop_fw;
- +
- + spin_lock_init(&priv->lock);
- + priv->open = 0;
- + priv->hw_unavailable = 1; /* orinoco_init() must clear this
- + * before anything else touches the
- + * hardware */
- + INIT_WORK(&priv->reset_work, orinoco_reset);
- + INIT_WORK(&priv->join_work, orinoco_join_ap);
- + INIT_WORK(&priv->wevent_work, orinoco_send_wevents);
- +
- + INIT_LIST_HEAD(&priv->rx_list);
- + tasklet_setup(&priv->rx_tasklet, orinoco_rx_isr_tasklet);
- +
- + spin_lock_init(&priv->scan_lock);
- + INIT_LIST_HEAD(&priv->scan_list);
- + INIT_WORK(&priv->process_scan, orinoco_process_scan_results);
- +
- + priv->last_linkstatus = 0xffff;
- +
- +#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
- + priv->cached_pri_fw = NULL;
- + priv->cached_fw = NULL;
- +#endif
- +
- + /* Register PM notifiers */
- + orinoco_register_pm_notifier(priv);
- +
- + return priv;
- +}
- +EXPORT_SYMBOL(alloc_orinocodev);
- +
- +/* We can only support a single interface. We provide a separate
- + * function to set it up to distinguish between hardware
- + * initialisation and interface setup.
- + *
- + * The base_addr and irq parameters are passed on to netdev for use
- + * with SIOCGIFMAP.
- + */
- +int orinoco_if_add(struct orinoco_private *priv,
- + unsigned long base_addr,
- + unsigned int irq,
- + const struct net_device_ops *ops)
- +{
- + struct wiphy *wiphy = priv_to_wiphy(priv);
- + struct wireless_dev *wdev;
- + struct net_device *dev;
- + int ret;
- +
- + dev = alloc_etherdev(sizeof(struct wireless_dev));
- +
- + if (!dev)
- + return -ENOMEM;
- +
- + /* Initialise wireless_dev */
- + wdev = netdev_priv(dev);
- + wdev->wiphy = wiphy;
- + wdev->iftype = NL80211_IFTYPE_STATION;
- +
- + /* Setup / override net_device fields */
- + dev->ieee80211_ptr = wdev;
- + dev->watchdog_timeo = HZ; /* 1 second timeout */
- + dev->wireless_handlers = &orinoco_handler_def;
- +#ifdef WIRELESS_SPY
- + dev->wireless_data = &priv->wireless_data;
- +#endif
- + /* Default to standard ops if not set */
- + if (ops)
- + dev->netdev_ops = ops;
- + else
- + dev->netdev_ops = &orinoco_netdev_ops;
- +
- + /* we use the default eth_mac_addr for setting the MAC addr */
- +
- + /* Reserve space in skb for the SNAP header */
- + dev->needed_headroom = ENCAPS_OVERHEAD;
- +
- + netif_carrier_off(dev);
- +
- + eth_hw_addr_set(dev, wiphy->perm_addr);
- +
- + dev->base_addr = base_addr;
- + dev->irq = irq;
- +
- + dev->min_mtu = ORINOCO_MIN_MTU;
- + dev->max_mtu = ORINOCO_MAX_MTU;
- +
- + SET_NETDEV_DEV(dev, priv->dev);
- + ret = register_netdev(dev);
- + if (ret)
- + goto fail;
- +
- + priv->ndev = dev;
- +
- + /* Report what we've done */
- + dev_dbg(priv->dev, "Registered interface %s.\n", dev->name);
- +
- + return 0;
- +
- + fail:
- + free_netdev(dev);
- + return ret;
- +}
- +EXPORT_SYMBOL(orinoco_if_add);
- +
- +void orinoco_if_del(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- +
- + unregister_netdev(dev);
- + free_netdev(dev);
- +}
- +EXPORT_SYMBOL(orinoco_if_del);
- +
- +void free_orinocodev(struct orinoco_private *priv)
- +{
- + struct wiphy *wiphy = priv_to_wiphy(priv);
- + struct orinoco_rx_data *rx_data, *temp;
- + struct orinoco_scan_data *sd, *sdtemp;
- +
- + /* If the tasklet is scheduled when we call tasklet_kill it
- + * will run one final time. However the tasklet will only
- + * drain priv->rx_list if the hw is still available. */
- + tasklet_kill(&priv->rx_tasklet);
- +
- + /* Explicitly drain priv->rx_list */
- + list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) {
- + list_del(&rx_data->list);
- +
- + dev_kfree_skb(rx_data->skb);
- + kfree(rx_data->desc);
- + kfree(rx_data);
- + }
- +
- + cancel_work_sync(&priv->process_scan);
- + /* Explicitly drain priv->scan_list */
- + list_for_each_entry_safe(sd, sdtemp, &priv->scan_list, list) {
- + list_del(&sd->list);
- +
- + if (sd->len > 0)
- + kfree(sd->buf);
- + kfree(sd);
- + }
- +
- + orinoco_unregister_pm_notifier(priv);
- + orinoco_uncache_fw(priv);
- +
- + priv->wpa_ie_len = 0;
- + kfree(priv->wpa_ie);
- + orinoco_mic_free(priv);
- + wiphy_free(wiphy);
- +}
- +EXPORT_SYMBOL(free_orinocodev);
- +
- +int orinoco_up(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + unsigned long flags;
- + int err;
- +
- + priv->hw.ops->lock_irqsave(&priv->lock, &flags);
- +
- + err = orinoco_reinit_firmware(priv);
- + if (err) {
- + printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
- + dev->name, err);
- + goto exit;
- + }
- +
- + netif_device_attach(dev);
- + priv->hw_unavailable--;
- +
- + if (priv->open && !priv->hw_unavailable) {
- + err = __orinoco_up(priv);
- + if (err)
- + printk(KERN_ERR "%s: Error %d restarting card\n",
- + dev->name, err);
- + }
- +
- +exit:
- + priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
- +
- + return 0;
- +}
- +EXPORT_SYMBOL(orinoco_up);
- +
- +void orinoco_down(struct orinoco_private *priv)
- +{
- + struct net_device *dev = priv->ndev;
- + unsigned long flags;
- + int err;
- +
- + priv->hw.ops->lock_irqsave(&priv->lock, &flags);
- + err = __orinoco_down(priv);
- + if (err)
- + printk(KERN_WARNING "%s: Error %d downing interface\n",
- + dev->name, err);
- +
- + netif_device_detach(dev);
- + priv->hw_unavailable++;
- + priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
- +}
- +EXPORT_SYMBOL(orinoco_down);
- +
- +/********************************************************************/
- +/* Module initialization */
- +/********************************************************************/
- +
- +/* Can't be declared "const" or the whole __initdata section will
- + * become const */
- +static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
- + " (David Gibson <hermes@gibson.dropbear.id.au>, "
- + "Pavel Roskin <proski@gnu.org>, et al)";
- +
- +static int __init init_orinoco(void)
- +{
- + printk(KERN_DEBUG "%s\n", version);
- + return 0;
- +}
- +
- +static void __exit exit_orinoco(void)
- +{
- +}
- +
- +module_init(init_orinoco);
- +module_exit(exit_orinoco);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/main.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/main.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/main.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/main.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,50 @@
- +/* Exports from main to helper modules
- + *
- + * See copyright notice in main.c
- + */
- +#ifndef _ORINOCO_MAIN_H_
- +#define _ORINOCO_MAIN_H_
- +
- +#include <linux/ieee80211.h>
- +#include "orinoco.h"
- +
- +/********************************************************************/
- +/* Compile time configuration and compatibility stuff */
- +/********************************************************************/
- +
- +/* We do this this way to avoid ifdefs in the actual code */
- +#ifdef WIRELESS_SPY
- +#define SPY_NUMBER(priv) (priv->spy_data.spy_number)
- +#else
- +#define SPY_NUMBER(priv) 0
- +#endif /* WIRELESS_SPY */
- +
- +/********************************************************************/
- +
- +/* Export module parameter */
- +extern int force_monitor;
- +
- +/* Forward declarations */
- +struct net_device;
- +struct work_struct;
- +
- +void set_port_type(struct orinoco_private *priv);
- +int orinoco_commit(struct orinoco_private *priv);
- +void orinoco_reset(struct work_struct *work);
- +
- +/* Information element helpers - find a home for these... */
- +#define WPA_OUI_TYPE "\x00\x50\xF2\x01"
- +#define WPA_SELECTOR_LEN 4
- +static inline u8 *orinoco_get_wpa_ie(u8 *data, size_t len)
- +{
- + u8 *p = data;
- + while ((p + 2 + WPA_SELECTOR_LEN) < (data + len)) {
- + if ((p[0] == WLAN_EID_VENDOR_SPECIFIC) &&
- + (memcmp(&p[2], WPA_OUI_TYPE, WPA_SELECTOR_LEN) == 0))
- + return p;
- + p += p[1] + 2;
- + }
- + return NULL;
- +}
- +
- +#endif /* _ORINOCO_MAIN_H_ */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/Makefile linux-6.18.9/drivers/net/wireless/intersil/orinoco/Makefile
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/Makefile 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/Makefile 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,15 @@
- +# SPDX-License-Identifier: GPL-2.0
- +#
- +# Makefile for the orinoco wireless device drivers.
- +#
- +orinoco-objs := main.o fw.o hw.o mic.o scan.o wext.o hermes_dld.o hermes.o cfg.o
- +
- +obj-$(CONFIG_HERMES) += orinoco.o
- +obj-$(CONFIG_PCMCIA_HERMES) += orinoco_cs.o
- +obj-$(CONFIG_APPLE_AIRPORT) += airport.o
- +obj-$(CONFIG_PLX_HERMES) += orinoco_plx.o
- +obj-$(CONFIG_PCI_HERMES) += orinoco_pci.o
- +obj-$(CONFIG_TMD_HERMES) += orinoco_tmd.o
- +obj-$(CONFIG_NORTEL_HERMES) += orinoco_nortel.o
- +obj-$(CONFIG_PCMCIA_SPECTRUM) += spectrum_cs.o
- +obj-$(CONFIG_ORINOCO_USB) += orinoco_usb.o
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/mic.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/mic.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/mic.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/mic.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,89 @@
- +/* Orinoco MIC helpers
- + *
- + * See copyright notice in main.c
- + */
- +#include <linux/kernel.h>
- +#include <linux/string.h>
- +#include <linux/if_ether.h>
- +#include <linux/scatterlist.h>
- +#include <crypto/hash.h>
- +
- +#include "orinoco.h"
- +#include "mic.h"
- +
- +/********************************************************************/
- +/* Michael MIC crypto setup */
- +/********************************************************************/
- +int orinoco_mic_init(struct orinoco_private *priv)
- +{
- + priv->tx_tfm_mic = crypto_alloc_shash("michael_mic", 0, 0);
- + if (IS_ERR(priv->tx_tfm_mic)) {
- + printk(KERN_DEBUG "%s: could not allocate "
- + "crypto API michael_mic\n", __func__);
- + priv->tx_tfm_mic = NULL;
- + return -ENOMEM;
- + }
- +
- + priv->rx_tfm_mic = crypto_alloc_shash("michael_mic", 0, 0);
- + if (IS_ERR(priv->rx_tfm_mic)) {
- + printk(KERN_DEBUG "%s: could not allocate "
- + "crypto API michael_mic\n", __func__);
- + priv->rx_tfm_mic = NULL;
- + return -ENOMEM;
- + }
- +
- + return 0;
- +}
- +
- +void orinoco_mic_free(struct orinoco_private *priv)
- +{
- + if (priv->tx_tfm_mic)
- + crypto_free_shash(priv->tx_tfm_mic);
- + if (priv->rx_tfm_mic)
- + crypto_free_shash(priv->rx_tfm_mic);
- +}
- +
- +int orinoco_mic(struct crypto_shash *tfm_michael, u8 *key,
- + u8 *da, u8 *sa, u8 priority,
- + u8 *data, size_t data_len, u8 *mic)
- +{
- + SHASH_DESC_ON_STACK(desc, tfm_michael);
- + u8 hdr[ETH_HLEN + 2]; /* size of header + padding */
- + int err;
- +
- + if (tfm_michael == NULL) {
- + printk(KERN_WARNING "%s: tfm_michael == NULL\n", __func__);
- + return -1;
- + }
- +
- + /* Copy header into buffer. We need the padding on the end zeroed */
- + memcpy(&hdr[0], da, ETH_ALEN);
- + memcpy(&hdr[ETH_ALEN], sa, ETH_ALEN);
- + hdr[ETH_ALEN * 2] = priority;
- + hdr[ETH_ALEN * 2 + 1] = 0;
- + hdr[ETH_ALEN * 2 + 2] = 0;
- + hdr[ETH_ALEN * 2 + 3] = 0;
- +
- + desc->tfm = tfm_michael;
- +
- + err = crypto_shash_setkey(tfm_michael, key, MIC_KEYLEN);
- + if (err)
- + return err;
- +
- + err = crypto_shash_init(desc);
- + if (err)
- + return err;
- +
- + err = crypto_shash_update(desc, hdr, sizeof(hdr));
- + if (err)
- + return err;
- +
- + err = crypto_shash_update(desc, data, data_len);
- + if (err)
- + return err;
- +
- + err = crypto_shash_final(desc, mic);
- + shash_desc_zero(desc);
- +
- + return err;
- +}
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/mic.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/mic.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/mic.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/mic.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,23 @@
- +/* Orinoco MIC helpers
- + *
- + * See copyright notice in main.c
- + */
- +#ifndef _ORINOCO_MIC_H_
- +#define _ORINOCO_MIC_H_
- +
- +#include <linux/types.h>
- +#include <crypto/hash.h>
- +
- +#define MICHAEL_MIC_LEN 8
- +
- +/* Forward declarations */
- +struct orinoco_private;
- +struct crypto_ahash;
- +
- +int orinoco_mic_init(struct orinoco_private *priv);
- +void orinoco_mic_free(struct orinoco_private *priv);
- +int orinoco_mic(struct crypto_shash *tfm_michael, u8 *key,
- + u8 *da, u8 *sa, u8 priority,
- + u8 *data, size_t data_len, u8 *mic);
- +
- +#endif /* ORINOCO_MIC_H */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_cs.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_cs.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_cs.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_cs.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,350 @@
- +/* orinoco_cs.c (formerly known as dldwd_cs.c)
- + *
- + * A driver for "Hermes" chipset based PCMCIA wireless adaptors, such
- + * as the Lucent WavelanIEEE/Orinoco cards and their OEM (Cabletron/
- + * EnteraSys RoamAbout 802.11, ELSA Airlancer, Melco Buffalo and others).
- + * It should also be usable on various Prism II based cards such as the
- + * Linksys, D-Link and Farallon Skyline. It should also work on Symbol
- + * cards such as the 3Com AirConnect and Ericsson WLAN.
- + *
- + * Copyright notice & release notes in file main.c
- + */
- +
- +#define DRIVER_NAME "orinoco_cs"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/delay.h>
- +#include <pcmcia/cistpl.h>
- +#include <pcmcia/cisreg.h>
- +#include <pcmcia/ds.h>
- +
- +#include "orinoco.h"
- +
- +/********************************************************************/
- +/* Module stuff */
- +/********************************************************************/
- +
- +MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>");
- +MODULE_DESCRIPTION("Driver for PCMCIA Lucent Orinoco,"
- + " Prism II based and similar wireless cards");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +/* Module parameters */
- +
- +/* Some D-Link cards have buggy CIS. They do work at 5v properly, but
- + * don't have any CIS entry for it. This workaround it... */
- +static int ignore_cis_vcc; /* = 0 */
- +module_param(ignore_cis_vcc, int, 0);
- +MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
- +
- +/********************************************************************/
- +/* Data structures */
- +/********************************************************************/
- +
- +/* PCMCIA specific device information (goes in the card field of
- + * struct orinoco_private */
- +struct orinoco_pccard {
- + struct pcmcia_device *p_dev;
- +
- + /* Used to handle hard reset */
- + /* yuck, we need this hack to work around the insanity of the
- + * PCMCIA layer */
- + unsigned long hard_reset_in_progress;
- +};
- +
- +
- +/********************************************************************/
- +/* Function prototypes */
- +/********************************************************************/
- +
- +static int orinoco_cs_config(struct pcmcia_device *link);
- +static void orinoco_cs_release(struct pcmcia_device *link);
- +static void orinoco_cs_detach(struct pcmcia_device *p_dev);
- +
- +/********************************************************************/
- +/* Device methods */
- +/********************************************************************/
- +
- +static int
- +orinoco_cs_hard_reset(struct orinoco_private *priv)
- +{
- + struct orinoco_pccard *card = priv->card;
- + struct pcmcia_device *link = card->p_dev;
- + int err;
- +
- + /* We need atomic ops here, because we're not holding the lock */
- + set_bit(0, &card->hard_reset_in_progress);
- +
- + err = pcmcia_reset_card(link->socket);
- + if (err)
- + return err;
- +
- + msleep(100);
- + clear_bit(0, &card->hard_reset_in_progress);
- +
- + return 0;
- +}
- +
- +/********************************************************************/
- +/* PCMCIA stuff */
- +/********************************************************************/
- +
- +static int
- +orinoco_cs_probe(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv;
- + struct orinoco_pccard *card;
- + int ret;
- +
- + priv = alloc_orinocodev(sizeof(*card), &link->dev,
- + orinoco_cs_hard_reset, NULL);
- + if (!priv)
- + return -ENOMEM;
- + card = priv->card;
- +
- + /* Link both structures together */
- + card->p_dev = link;
- + link->priv = priv;
- +
- + ret = orinoco_cs_config(link);
- + if (ret)
- + goto err_free_orinocodev;
- +
- + return 0;
- +
- +err_free_orinocodev:
- + free_orinocodev(priv);
- + return ret;
- +}
- +
- +static void orinoco_cs_detach(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- +
- + orinoco_if_del(priv);
- +
- + orinoco_cs_release(link);
- +
- + wiphy_unregister(priv_to_wiphy(priv));
- + free_orinocodev(priv);
- +} /* orinoco_cs_detach */
- +
- +static int orinoco_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
- +{
- + if (p_dev->config_index == 0)
- + return -EINVAL;
- +
- + return pcmcia_request_io(p_dev);
- +};
- +
- +static int
- +orinoco_cs_config(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- + struct hermes *hw = &priv->hw;
- + int ret;
- + void __iomem *mem;
- +
- + link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC |
- + CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
- + if (ignore_cis_vcc)
- + link->config_flags &= ~CONF_AUTO_CHECK_VCC;
- + ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL);
- + if (ret) {
- + if (!ignore_cis_vcc)
- + printk(KERN_ERR PFX "GetNextTuple(): No matching "
- + "CIS configuration. Maybe you need the "
- + "ignore_cis_vcc=1 parameter.\n");
- + goto failed;
- + }
- +
- + mem = ioport_map(link->resource[0]->start,
- + resource_size(link->resource[0]));
- + if (!mem)
- + goto failed;
- +
- + /* We initialize the hermes structure before completing PCMCIA
- + * configuration just in case the interrupt handler gets
- + * called. */
- + hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
- +
- + ret = pcmcia_request_irq(link, orinoco_interrupt);
- + if (ret)
- + goto failed;
- +
- + ret = pcmcia_enable_device(link);
- + if (ret)
- + goto failed;
- +
- + /* Initialise the main driver */
- + if (orinoco_init(priv) != 0) {
- + printk(KERN_ERR PFX "orinoco_init() failed\n");
- + goto failed;
- + }
- +
- + /* Register an interface with the stack */
- + if (orinoco_if_add(priv, link->resource[0]->start,
- + link->irq, NULL) != 0) {
- + printk(KERN_ERR PFX "orinoco_if_add() failed\n");
- + goto failed;
- + }
- +
- + return 0;
- +
- + failed:
- + orinoco_cs_release(link);
- + return -ENODEV;
- +} /* orinoco_cs_config */
- +
- +static void
- +orinoco_cs_release(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- + unsigned long flags;
- +
- + /* We're committed to taking the device away now, so mark the
- + * hardware as unavailable */
- + priv->hw.ops->lock_irqsave(&priv->lock, &flags);
- + priv->hw_unavailable++;
- + priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
- +
- + pcmcia_disable_device(link);
- + if (priv->hw.iobase)
- + ioport_unmap(priv->hw.iobase);
- +} /* orinoco_cs_release */
- +
- +static int orinoco_cs_suspend(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- + struct orinoco_pccard *card = priv->card;
- +
- + /* This is probably racy, but I can't think of
- + a better way, short of rewriting the PCMCIA
- + layer to not suck :-( */
- + if (!test_bit(0, &card->hard_reset_in_progress))
- + orinoco_down(priv);
- +
- + return 0;
- +}
- +
- +static int orinoco_cs_resume(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- + struct orinoco_pccard *card = priv->card;
- + int err = 0;
- +
- + if (!test_bit(0, &card->hard_reset_in_progress))
- + err = orinoco_up(priv);
- +
- + return err;
- +}
- +
- +
- +/********************************************************************/
- +/* Module initialization */
- +/********************************************************************/
- +
- +static const struct pcmcia_device_id orinoco_cs_ids[] = {
- + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), /* 3Com AirConnect PCI 777A */
- + PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), /* Ericsson WLAN Card C11 */
- + PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), /* Nortel Networks eMobility 802.11 Wireless Adapter */
- + PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */
- + PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */
- + PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0003), /* ARtem Onair Comcard 11 */
- + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */
- + PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), /* ASUS SpaceLink WL-100 */
- + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), /* SpeedStream SS1021 Wireless Adapter */
- + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x3021), /* SpeedStream Wireless Adapter */
- + PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), /* PLANEX RoadLannerWave GW-NS11H */
- + PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3),
- + PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f),
- + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e),
- + PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842),
- + PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169),
- + PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb),
- + PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90),
- + PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916),
- + PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3),
- + PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c),
- + PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077),
- + PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92),
- + PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a),
- + PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410),
- + PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3),
- + PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a),
- + PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767),
- + PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed),
- + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9),
- + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26),
- + PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b),
- + PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e),
- + PCMCIA_DEVICE_MANF_CARD_PROD_ID3(0x0156, 0x0002, "Version 01.01", 0xd27deb1a), /* Lucent Orinoco */
- +#ifdef CONFIG_HERMES_PRISM
- + /* Only entries that certainly identify Prism chipset */
- + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), /* SonicWALL Long Range Wireless Card */
- + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), /* Sohoware NCP110, Philips 802.11b */
- + PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), /* AnyPoint(TM) Wireless II PC Card */
- + PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), /* PROXIM RangeLAN-DS/LAN PC CARD */
- + PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), /* Compaq WL100 11 Mbps Wireless Adapter */
- + PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), /* Intermec MobileLAN 11Mbps 802.11b WLAN Card */
- + PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */
- + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */
- + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */
- + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), /* Compaq HNW-100 11 Mbps Wireless Adapter */
- + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), /* Linksys WCF12 Wireless CompactFlash Card */
- + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), /* Airvast WN-100 */
- + PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), /* Adaptec Ultra Wireless ANW-8030 */
- + PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), /* CONTEC FLEXSCAN/FX-DDS110-PCC */
- + PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), /* Conceptronic CON11Cpro, EMTAC A2424i */
- + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), /* Safeway 802.11b, ZCOMAX AirRunner/XI-300 */
- + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), /* D-Link DCF660, Sandisk Connect SDWCFB-000 */
- + PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0),
- + PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5),
- + PCMCIA_DEVICE_PROD_ID12("Addtron", "AWP-100 Wireless PCMCIA", 0xe6ec52ce, 0x08649af2),
- + PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18),
- + PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3),
- + PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b),
- + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584),
- + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9),
- + PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae),
- + PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146),
- + PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac),
- + PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab),
- + PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9),
- + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18),
- + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77),
- + PCMCIA_DEVICE_PROD_ID12("Intersil", "PRISM 2_5 PCMCIA ADAPTER", 0x4b801a17, 0x6345a0bf),
- + PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395),
- + PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01),
- + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1),
- + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1),
- + PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6),
- + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264),
- + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178),
- + PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2532W-B EliteConnect Wireless Adapter", 0xc4f8b18b, 0x196bd757),
- + PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2632W", 0xc4f8b18b, 0x474a1f2a),
- + PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee),
- + PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092),
- + PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2),
- + PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b),
- + PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39),
- +
- + /* This may be Agere or Intersil Firmware */
- + PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
- +#endif
- + PCMCIA_DEVICE_NULL,
- +};
- +MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids);
- +
- +static struct pcmcia_driver orinoco_driver = {
- + .owner = THIS_MODULE,
- + .name = DRIVER_NAME,
- + .probe = orinoco_cs_probe,
- + .remove = orinoco_cs_detach,
- + .id_table = orinoco_cs_ids,
- + .suspend = orinoco_cs_suspend,
- + .resume = orinoco_cs_resume,
- +};
- +module_pcmcia_driver(orinoco_driver);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,249 @@
- +/* orinoco.h
- + *
- + * Common definitions to all pieces of the various orinoco
- + * drivers
- + */
- +
- +#ifndef _ORINOCO_H
- +#define _ORINOCO_H
- +
- +#define DRIVER_VERSION "0.15"
- +
- +#include <linux/interrupt.h>
- +#include <linux/suspend.h>
- +#include <linux/netdevice.h>
- +#include <linux/wireless.h>
- +#include <net/iw_handler.h>
- +#include <net/cfg80211.h>
- +
- +#include "hermes.h"
- +
- +/* To enable debug messages */
- +/*#define ORINOCO_DEBUG 3*/
- +
- +#define MAX_SCAN_LEN 4096
- +
- +#define ORINOCO_SEQ_LEN 8
- +#define ORINOCO_MAX_KEY_SIZE 14
- +#define ORINOCO_MAX_KEYS 4
- +
- +struct orinoco_key {
- + __le16 len; /* always stored as little-endian */
- + char data[ORINOCO_MAX_KEY_SIZE];
- +} __packed;
- +
- +#define TKIP_KEYLEN 16
- +#define MIC_KEYLEN 8
- +
- +struct orinoco_tkip_key {
- + u8 tkip[TKIP_KEYLEN];
- + u8 tx_mic[MIC_KEYLEN];
- + u8 rx_mic[MIC_KEYLEN];
- +};
- +
- +enum orinoco_alg {
- + ORINOCO_ALG_NONE,
- + ORINOCO_ALG_WEP,
- + ORINOCO_ALG_TKIP
- +};
- +
- +enum fwtype {
- + FIRMWARE_TYPE_AGERE,
- + FIRMWARE_TYPE_INTERSIL,
- + FIRMWARE_TYPE_SYMBOL
- +};
- +
- +struct firmware;
- +
- +struct orinoco_private {
- + void *card; /* Pointer to card dependent structure */
- + struct device *dev;
- + int (*hard_reset)(struct orinoco_private *);
- + int (*stop_fw)(struct orinoco_private *, int);
- +
- + struct ieee80211_supported_band band;
- + struct ieee80211_channel channels[14];
- + u32 cipher_suites[3];
- +
- + /* Synchronisation stuff */
- + spinlock_t lock;
- + int hw_unavailable;
- + struct work_struct reset_work;
- +
- + /* Interrupt tasklets */
- + struct tasklet_struct rx_tasklet;
- + struct list_head rx_list;
- +
- + /* driver state */
- + int open;
- + u16 last_linkstatus;
- + struct work_struct join_work;
- + struct work_struct wevent_work;
- +
- + /* Net device stuff */
- + struct net_device *ndev;
- + struct iw_statistics wstats;
- +
- + /* Hardware control variables */
- + struct hermes hw;
- + u16 txfid;
- +
- + /* Capabilities of the hardware/firmware */
- + enum fwtype firmware_type;
- + int ibss_port;
- + int nicbuf_size;
- + u16 channel_mask;
- +
- + /* Boolean capabilities */
- + unsigned int has_ibss:1;
- + unsigned int has_port3:1;
- + unsigned int has_wep:1;
- + unsigned int has_big_wep:1;
- + unsigned int has_mwo:1;
- + unsigned int has_pm:1;
- + unsigned int has_preamble:1;
- + unsigned int has_sensitivity:1;
- + unsigned int has_hostscan:1;
- + unsigned int has_alt_txcntl:1;
- + unsigned int has_ext_scan:1;
- + unsigned int has_wpa:1;
- + unsigned int do_fw_download:1;
- + unsigned int broken_disableport:1;
- + unsigned int broken_monitor:1;
- + unsigned int prefer_port3:1;
- +
- + /* Configuration paramaters */
- + enum nl80211_iftype iw_mode;
- + enum orinoco_alg encode_alg;
- + u16 wep_restrict, tx_key;
- + struct key_params keys[ORINOCO_MAX_KEYS];
- +
- + int bitratemode;
- + char nick[IW_ESSID_MAX_SIZE + 1];
- + char desired_essid[IW_ESSID_MAX_SIZE + 1];
- + char desired_bssid[ETH_ALEN];
- + int bssid_fixed;
- + u16 frag_thresh, mwo_robust;
- + u16 channel;
- + u16 ap_density, rts_thresh;
- + u16 pm_on, pm_mcast, pm_period, pm_timeout;
- + u16 preamble;
- + u16 short_retry_limit, long_retry_limit;
- + u16 retry_lifetime;
- +#ifdef WIRELESS_SPY
- + struct iw_spy_data spy_data; /* iwspy support */
- + struct iw_public_data wireless_data;
- +#endif
- +
- + /* Configuration dependent variables */
- + int port_type, createibss;
- + int promiscuous, mc_count;
- +
- + /* Scanning support */
- + struct cfg80211_scan_request *scan_request;
- + struct work_struct process_scan;
- + struct list_head scan_list;
- + spinlock_t scan_lock; /* protects the scan list */
- +
- + /* WPA support */
- + u8 *wpa_ie;
- + int wpa_ie_len;
- +
- + struct crypto_shash *rx_tfm_mic;
- + struct crypto_shash *tx_tfm_mic;
- +
- + unsigned int wpa_enabled:1;
- + unsigned int tkip_cm_active:1;
- + unsigned int key_mgmt:3;
- +
- +#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
- + /* Cached in memory firmware to use during ->resume. */
- + const struct firmware *cached_pri_fw;
- + const struct firmware *cached_fw;
- +#endif
- +
- + struct notifier_block pm_notifier;
- +};
- +
- +#ifdef ORINOCO_DEBUG
- +extern int orinoco_debug;
- +#define DEBUG(n, args...) do { \
- + if (orinoco_debug > (n)) \
- + printk(KERN_DEBUG args); \
- +} while (0)
- +#else
- +#define DEBUG(n, args...) do { } while (0)
- +#endif /* ORINOCO_DEBUG */
- +
- +/********************************************************************/
- +/* Exported prototypes */
- +/********************************************************************/
- +
- +struct orinoco_private *alloc_orinocodev(int sizeof_card, struct device *device,
- + int (*hard_reset)(struct orinoco_private *),
- + int (*stop_fw)(struct orinoco_private *, int));
- +void free_orinocodev(struct orinoco_private *priv);
- +int orinoco_init(struct orinoco_private *priv);
- +int orinoco_if_add(struct orinoco_private *priv, unsigned long base_addr,
- + unsigned int irq, const struct net_device_ops *ops);
- +void orinoco_if_del(struct orinoco_private *priv);
- +int orinoco_up(struct orinoco_private *priv);
- +void orinoco_down(struct orinoco_private *priv);
- +irqreturn_t orinoco_interrupt(int irq, void *dev_id);
- +
- +void __orinoco_ev_info(struct net_device *dev, struct hermes *hw);
- +void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw);
- +
- +int orinoco_process_xmit_skb(struct sk_buff *skb,
- + struct net_device *dev,
- + struct orinoco_private *priv,
- + int *tx_control,
- + u8 *mic);
- +
- +/* Common ndo functions exported for reuse by orinoco_usb */
- +int orinoco_open(struct net_device *dev);
- +int orinoco_stop(struct net_device *dev);
- +void orinoco_set_multicast_list(struct net_device *dev);
- +int orinoco_change_mtu(struct net_device *dev, int new_mtu);
- +void orinoco_tx_timeout(struct net_device *dev, unsigned int txqueue);
- +
- +/********************************************************************/
- +/* Locking and synchronization functions */
- +/********************************************************************/
- +
- +static inline int orinoco_lock(struct orinoco_private *priv,
- + unsigned long *flags)
- +{
- + priv->hw.ops->lock_irqsave(&priv->lock, flags);
- + if (priv->hw_unavailable) {
- + DEBUG(1, "orinoco_lock() called with hw_unavailable (dev=%p)\n",
- + priv->ndev);
- + priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
- + return -EBUSY;
- + }
- + return 0;
- +}
- +
- +static inline void orinoco_unlock(struct orinoco_private *priv,
- + unsigned long *flags)
- +{
- + priv->hw.ops->unlock_irqrestore(&priv->lock, flags);
- +}
- +
- +static inline void orinoco_lock_irq(struct orinoco_private *priv)
- +{
- + priv->hw.ops->lock_irq(&priv->lock);
- +}
- +
- +static inline void orinoco_unlock_irq(struct orinoco_private *priv)
- +{
- + priv->hw.ops->unlock_irq(&priv->lock);
- +}
- +
- +/*** Navigate from net_device to orinoco_private ***/
- +static inline struct orinoco_private *ndev_priv(struct net_device *dev)
- +{
- + struct wireless_dev *wdev = netdev_priv(dev);
- + return wdev_priv(wdev);
- +}
- +#endif /* _ORINOCO_H */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_nortel.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_nortel.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_nortel.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_nortel.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,314 @@
- +/* orinoco_nortel.c
- + *
- + * Driver for Prism II devices which would usually be driven by orinoco_cs,
- + * but are connected to the PCI bus by a PCI-to-PCMCIA adapter used in
- + * Nortel emobility, Symbol LA-4113 and Symbol LA-4123.
- + *
- + * Copyright (C) 2002 Tobias Hoffmann
- + * (C) 2003 Christoph Jungegger <disdos@traum404.de>
- + *
- + * Some of this code is borrowed from orinoco_plx.c
- + * Copyright (C) 2001 Daniel Barlow
- + * Some of this code is borrowed from orinoco_pci.c
- + * Copyright (C) 2001 Jean Tourrilhes
- + * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing
- + * has been copied from it. linux-wlan-ng-0.1.10 is originally :
- + * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + */
- +
- +#define DRIVER_NAME "orinoco_nortel"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/init.h>
- +#include <linux/delay.h>
- +#include <linux/pci.h>
- +#include <pcmcia/cisreg.h>
- +
- +#include "orinoco.h"
- +#include "orinoco_pci.h"
- +
- +#define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */
- +#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
- +
- +
- +/*
- + * Do a soft reset of the card using the Configuration Option Register
- + * We need this to get going...
- + * This is the part of the code that is strongly inspired from wlan-ng
- + *
- + * Note bis : Don't try to access HERMES_CMD during the reset phase.
- + * It just won't work !
- + */
- +static int orinoco_nortel_cor_reset(struct orinoco_private *priv)
- +{
- + struct orinoco_pci_card *card = priv->card;
- +
- + /* Assert the reset until the card notices */
- + iowrite16(8, card->bridge_io + 2);
- + ioread16(card->attr_io + COR_OFFSET);
- + iowrite16(0x80, card->attr_io + COR_OFFSET);
- + mdelay(1);
- +
- + /* Give time for the card to recover from this hard effort */
- + iowrite16(0, card->attr_io + COR_OFFSET);
- + iowrite16(0, card->attr_io + COR_OFFSET);
- + mdelay(1);
- +
- + /* Set COR as usual */
- + iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
- + iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
- + mdelay(1);
- +
- + iowrite16(0x228, card->bridge_io + 2);
- +
- + return 0;
- +}
- +
- +static int orinoco_nortel_hw_init(struct orinoco_pci_card *card)
- +{
- + int i;
- + u32 reg;
- +
- + /* Setup bridge */
- + if (ioread16(card->bridge_io) & 1) {
- + printk(KERN_ERR PFX "brg1 answer1 wrong\n");
- + return -EBUSY;
- + }
- + iowrite16(0x118, card->bridge_io + 2);
- + iowrite16(0x108, card->bridge_io + 2);
- + mdelay(30);
- + iowrite16(0x8, card->bridge_io + 2);
- + for (i = 0; i < 30; i++) {
- + mdelay(30);
- + if (ioread16(card->bridge_io) & 0x10)
- + break;
- + }
- + if (i == 30) {
- + printk(KERN_ERR PFX "brg1 timed out\n");
- + return -EBUSY;
- + }
- + if (ioread16(card->attr_io + COR_OFFSET) & 1) {
- + printk(KERN_ERR PFX "brg2 answer1 wrong\n");
- + return -EBUSY;
- + }
- + if (ioread16(card->attr_io + COR_OFFSET + 2) & 1) {
- + printk(KERN_ERR PFX "brg2 answer2 wrong\n");
- + return -EBUSY;
- + }
- + if (ioread16(card->attr_io + COR_OFFSET + 4) & 1) {
- + printk(KERN_ERR PFX "brg2 answer3 wrong\n");
- + return -EBUSY;
- + }
- +
- + /* Set the PCMCIA COR register */
- + iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
- + mdelay(1);
- + reg = ioread16(card->attr_io + COR_OFFSET);
- + if (reg != COR_VALUE) {
- + printk(KERN_ERR PFX "Error setting COR value (reg=%x)\n",
- + reg);
- + return -EBUSY;
- + }
- +
- + /* Set LEDs */
- + iowrite16(1, card->bridge_io + 10);
- + return 0;
- +}
- +
- +static int orinoco_nortel_init_one(struct pci_dev *pdev,
- + const struct pci_device_id *ent)
- +{
- + int err;
- + struct orinoco_private *priv;
- + struct orinoco_pci_card *card;
- + void __iomem *hermes_io, *bridge_io, *attr_io;
- +
- + err = pci_enable_device(pdev);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot enable PCI device\n");
- + return err;
- + }
- +
- + err = pci_request_regions(pdev, DRIVER_NAME);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
- + goto fail_resources;
- + }
- +
- + bridge_io = pci_iomap(pdev, 0, 0);
- + if (!bridge_io) {
- + printk(KERN_ERR PFX "Cannot map bridge registers\n");
- + err = -EIO;
- + goto fail_map_bridge;
- + }
- +
- + attr_io = pci_iomap(pdev, 1, 0);
- + if (!attr_io) {
- + printk(KERN_ERR PFX "Cannot map PCMCIA attributes\n");
- + err = -EIO;
- + goto fail_map_attr;
- + }
- +
- + hermes_io = pci_iomap(pdev, 2, 0);
- + if (!hermes_io) {
- + printk(KERN_ERR PFX "Cannot map chipset registers\n");
- + err = -EIO;
- + goto fail_map_hermes;
- + }
- +
- + /* Allocate network device */
- + priv = alloc_orinocodev(sizeof(*card), &pdev->dev,
- + orinoco_nortel_cor_reset, NULL);
- + if (!priv) {
- + printk(KERN_ERR PFX "Cannot allocate network device\n");
- + err = -ENOMEM;
- + goto fail_alloc;
- + }
- +
- + card = priv->card;
- + card->bridge_io = bridge_io;
- + card->attr_io = attr_io;
- +
- + hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
- +
- + err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
- + DRIVER_NAME, priv);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
- + err = -EBUSY;
- + goto fail_irq;
- + }
- +
- + err = orinoco_nortel_hw_init(card);
- + if (err) {
- + printk(KERN_ERR PFX "Hardware initialization failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_nortel_cor_reset(priv);
- + if (err) {
- + printk(KERN_ERR PFX "Initial reset failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_init(priv);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_init() failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_if_add(priv, 0, 0, NULL);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_if_add() failed\n");
- + goto fail_wiphy;
- + }
- +
- + pci_set_drvdata(pdev, priv);
- +
- + return 0;
- +
- + fail_wiphy:
- + wiphy_unregister(priv_to_wiphy(priv));
- + fail:
- + free_irq(pdev->irq, priv);
- +
- + fail_irq:
- + free_orinocodev(priv);
- +
- + fail_alloc:
- + pci_iounmap(pdev, hermes_io);
- +
- + fail_map_hermes:
- + pci_iounmap(pdev, attr_io);
- +
- + fail_map_attr:
- + pci_iounmap(pdev, bridge_io);
- +
- + fail_map_bridge:
- + pci_release_regions(pdev);
- +
- + fail_resources:
- + pci_disable_device(pdev);
- +
- + return err;
- +}
- +
- +static void orinoco_nortel_remove_one(struct pci_dev *pdev)
- +{
- + struct orinoco_private *priv = pci_get_drvdata(pdev);
- + struct orinoco_pci_card *card = priv->card;
- +
- + /* Clear LEDs */
- + iowrite16(0, card->bridge_io + 10);
- +
- + orinoco_if_del(priv);
- + wiphy_unregister(priv_to_wiphy(priv));
- + free_irq(pdev->irq, priv);
- + free_orinocodev(priv);
- + pci_iounmap(pdev, priv->hw.iobase);
- + pci_iounmap(pdev, card->attr_io);
- + pci_iounmap(pdev, card->bridge_io);
- + pci_release_regions(pdev);
- + pci_disable_device(pdev);
- +}
- +
- +static const struct pci_device_id orinoco_nortel_id_table[] = {
- + /* Nortel emobility PCI */
- + {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,},
- + /* Symbol LA-4123 PCI */
- + {0x1562, 0x0001, PCI_ANY_ID, PCI_ANY_ID,},
- + {0,},
- +};
- +
- +MODULE_DEVICE_TABLE(pci, orinoco_nortel_id_table);
- +
- +static struct pci_driver orinoco_nortel_driver = {
- + .name = DRIVER_NAME,
- + .id_table = orinoco_nortel_id_table,
- + .probe = orinoco_nortel_init_one,
- + .remove = orinoco_nortel_remove_one,
- + .driver.pm = &orinoco_pci_pm_ops,
- +};
- +
- +static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
- + " (Tobias Hoffmann & Christoph Jungegger <disdos@traum404.de>)";
- +MODULE_AUTHOR("Christoph Jungegger <disdos@traum404.de>");
- +MODULE_DESCRIPTION("Driver for wireless LAN cards using the Nortel PCI bridge");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +static int __init orinoco_nortel_init(void)
- +{
- + printk(KERN_DEBUG "%s\n", version);
- + return pci_register_driver(&orinoco_nortel_driver);
- +}
- +
- +static void __exit orinoco_nortel_exit(void)
- +{
- + pci_unregister_driver(&orinoco_nortel_driver);
- +}
- +
- +module_init(orinoco_nortel_init);
- +module_exit(orinoco_nortel_exit);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_pci.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_pci.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_pci.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_pci.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,257 @@
- +/* orinoco_pci.c
- + *
- + * Driver for Prism 2.5/3 devices that have a direct PCI interface
- + * (i.e. these are not PCMCIA cards in a PCMCIA-to-PCI bridge).
- + * The card contains only one PCI region, which contains all the usual
- + * hermes registers, as well as the COR register.
- + *
- + * Current maintainers are:
- + * Pavel Roskin <proski AT gnu.org>
- + * and David Gibson <hermes AT gibson.dropbear.id.au>
- + *
- + * Some of this code is borrowed from orinoco_plx.c
- + * Copyright (C) 2001 Daniel Barlow <dan AT telent.net>
- + * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing
- + * has been copied from it. linux-wlan-ng-0.1.10 is originally :
- + * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
- + * This file originally written by:
- + * Copyright (C) 2001 Jean Tourrilhes <jt AT hpl.hp.com>
- + * And is now maintained by:
- + * (C) Copyright David Gibson, IBM Corp. 2002-2003.
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + */
- +
- +#define DRIVER_NAME "orinoco_pci"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/init.h>
- +#include <linux/delay.h>
- +#include <linux/pci.h>
- +
- +#include "orinoco.h"
- +#include "orinoco_pci.h"
- +
- +/* Offset of the COR register of the PCI card */
- +#define HERMES_PCI_COR (0x26)
- +
- +/* Bitmask to reset the card */
- +#define HERMES_PCI_COR_MASK (0x0080)
- +
- +/* Magic timeouts for doing the reset.
- + * Those times are straight from wlan-ng, and it is claimed that they
- + * are necessary. Alan will kill me. Take your time and grab a coffee. */
- +#define HERMES_PCI_COR_ONT (250) /* ms */
- +#define HERMES_PCI_COR_OFFT (500) /* ms */
- +#define HERMES_PCI_COR_BUSYT (500) /* ms */
- +
- +/*
- + * Do a soft reset of the card using the Configuration Option Register
- + * We need this to get going...
- + * This is the part of the code that is strongly inspired from wlan-ng
- + *
- + * Note : This code is done with irq enabled. This mean that many
- + * interrupts will occur while we are there. This is why we use the
- + * jiffies to regulate time instead of a straight mdelay(). Usually we
- + * need only around 245 iteration of the loop to do 250 ms delay.
- + *
- + * Note bis : Don't try to access HERMES_CMD during the reset phase.
- + * It just won't work !
- + */
- +static int orinoco_pci_cor_reset(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + unsigned long timeout;
- + u16 reg;
- +
- + /* Assert the reset until the card notices */
- + hermes_write_regn(hw, PCI_COR, HERMES_PCI_COR_MASK);
- + mdelay(HERMES_PCI_COR_ONT);
- +
- + /* Give time for the card to recover from this hard effort */
- + hermes_write_regn(hw, PCI_COR, 0x0000);
- + mdelay(HERMES_PCI_COR_OFFT);
- +
- + /* The card is ready when it's no longer busy */
- + timeout = jiffies + msecs_to_jiffies(HERMES_PCI_COR_BUSYT);
- + reg = hermes_read_regn(hw, CMD);
- + while (time_before(jiffies, timeout) && (reg & HERMES_CMD_BUSY)) {
- + mdelay(1);
- + reg = hermes_read_regn(hw, CMD);
- + }
- +
- + /* Still busy? */
- + if (reg & HERMES_CMD_BUSY) {
- + printk(KERN_ERR PFX "Busy timeout\n");
- + return -ETIMEDOUT;
- + }
- +
- + return 0;
- +}
- +
- +static int orinoco_pci_init_one(struct pci_dev *pdev,
- + const struct pci_device_id *ent)
- +{
- + int err;
- + struct orinoco_private *priv;
- + struct orinoco_pci_card *card;
- + void __iomem *hermes_io;
- +
- + err = pci_enable_device(pdev);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot enable PCI device\n");
- + return err;
- + }
- +
- + err = pci_request_regions(pdev, DRIVER_NAME);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
- + goto fail_resources;
- + }
- +
- + hermes_io = pci_iomap(pdev, 0, 0);
- + if (!hermes_io) {
- + printk(KERN_ERR PFX "Cannot remap chipset registers\n");
- + err = -EIO;
- + goto fail_map_hermes;
- + }
- +
- + /* Allocate network device */
- + priv = alloc_orinocodev(sizeof(*card), &pdev->dev,
- + orinoco_pci_cor_reset, NULL);
- + if (!priv) {
- + printk(KERN_ERR PFX "Cannot allocate network device\n");
- + err = -ENOMEM;
- + goto fail_alloc;
- + }
- +
- + card = priv->card;
- +
- + hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING);
- +
- + err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
- + DRIVER_NAME, priv);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
- + err = -EBUSY;
- + goto fail_irq;
- + }
- +
- + err = orinoco_pci_cor_reset(priv);
- + if (err) {
- + printk(KERN_ERR PFX "Initial reset failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_init(priv);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_init() failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_if_add(priv, 0, 0, NULL);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_if_add() failed\n");
- + goto fail_wiphy;
- + }
- +
- + pci_set_drvdata(pdev, priv);
- +
- + return 0;
- +
- + fail_wiphy:
- + wiphy_unregister(priv_to_wiphy(priv));
- + fail:
- + free_irq(pdev->irq, priv);
- +
- + fail_irq:
- + free_orinocodev(priv);
- +
- + fail_alloc:
- + pci_iounmap(pdev, hermes_io);
- +
- + fail_map_hermes:
- + pci_release_regions(pdev);
- +
- + fail_resources:
- + pci_disable_device(pdev);
- +
- + return err;
- +}
- +
- +static void orinoco_pci_remove_one(struct pci_dev *pdev)
- +{
- + struct orinoco_private *priv = pci_get_drvdata(pdev);
- +
- + orinoco_if_del(priv);
- + wiphy_unregister(priv_to_wiphy(priv));
- + free_irq(pdev->irq, priv);
- + free_orinocodev(priv);
- + pci_iounmap(pdev, priv->hw.iobase);
- + pci_release_regions(pdev);
- + pci_disable_device(pdev);
- +}
- +
- +static const struct pci_device_id orinoco_pci_id_table[] = {
- + /* Intersil Prism 3 */
- + {0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID,},
- + /* Intersil Prism 2.5 */
- + {0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID,},
- + /* Samsung MagicLAN SWL-2210P */
- + {0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID,},
- + {0,},
- +};
- +
- +MODULE_DEVICE_TABLE(pci, orinoco_pci_id_table);
- +
- +static struct pci_driver orinoco_pci_driver = {
- + .name = DRIVER_NAME,
- + .id_table = orinoco_pci_id_table,
- + .probe = orinoco_pci_init_one,
- + .remove = orinoco_pci_remove_one,
- + .driver.pm = &orinoco_pci_pm_ops,
- +};
- +
- +static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
- + " (Pavel Roskin <proski@gnu.org>,"
- + " David Gibson <hermes@gibson.dropbear.id.au> &"
- + " Jean Tourrilhes <jt@hpl.hp.com>)";
- +MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> &"
- + " David Gibson <hermes@gibson.dropbear.id.au>");
- +MODULE_DESCRIPTION("Driver for wireless LAN cards using direct PCI interface");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +static int __init orinoco_pci_init(void)
- +{
- + printk(KERN_DEBUG "%s\n", version);
- + return pci_register_driver(&orinoco_pci_driver);
- +}
- +
- +static void __exit orinoco_pci_exit(void)
- +{
- + pci_unregister_driver(&orinoco_pci_driver);
- +}
- +
- +module_init(orinoco_pci_init);
- +module_exit(orinoco_pci_exit);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_pci.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_pci.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_pci.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_pci.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,54 @@
- +/* orinoco_pci.h
- + *
- + * Common code for all Orinoco drivers for PCI devices, including
- + * both native PCI and PCMCIA-to-PCI bridges.
- + *
- + * Copyright (C) 2005, Pavel Roskin.
- + * See main.c for license.
- + */
- +
- +#ifndef _ORINOCO_PCI_H
- +#define _ORINOCO_PCI_H
- +
- +#include <linux/netdevice.h>
- +
- +/* Driver specific data */
- +struct orinoco_pci_card {
- + void __iomem *bridge_io;
- + void __iomem *attr_io;
- +};
- +
- +static int __maybe_unused orinoco_pci_suspend(struct device *dev_d)
- +{
- + struct pci_dev *pdev = to_pci_dev(dev_d);
- + struct orinoco_private *priv = pci_get_drvdata(pdev);
- +
- + orinoco_down(priv);
- + free_irq(pdev->irq, priv);
- +
- + return 0;
- +}
- +
- +static int __maybe_unused orinoco_pci_resume(struct device *dev_d)
- +{
- + struct pci_dev *pdev = to_pci_dev(dev_d);
- + struct orinoco_private *priv = pci_get_drvdata(pdev);
- + struct net_device *dev = priv->ndev;
- + int err;
- +
- + err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
- + dev->name, priv);
- + if (err) {
- + printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
- + dev->name);
- + return -EBUSY;
- + }
- +
- + return orinoco_up(priv);
- +}
- +
- +static SIMPLE_DEV_PM_OPS(orinoco_pci_pm_ops,
- + orinoco_pci_suspend,
- + orinoco_pci_resume);
- +
- +#endif /* _ORINOCO_PCI_H */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_plx.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_plx.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_plx.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_plx.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,362 @@
- +/* orinoco_plx.c
- + *
- + * Driver for Prism II devices which would usually be driven by orinoco_cs,
- + * but are connected to the PCI bus by a PLX9052.
- + *
- + * Current maintainers are:
- + * Pavel Roskin <proski AT gnu.org>
- + * and David Gibson <hermes AT gibson.dropbear.id.au>
- + *
- + * (C) Copyright David Gibson, IBM Corp. 2001-2003.
- + * Copyright (C) 2001 Daniel Barlow
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + *
- + * Here's the general details on how the PLX9052 adapter works:
- + *
- + * - Two PCI I/O address spaces, one 0x80 long which contains the
- + * PLX9052 registers, and one that's 0x40 long mapped to the PCMCIA
- + * slot I/O address space.
- + *
- + * - One PCI memory address space, mapped to the PCMCIA attribute space
- + * (containing the CIS).
- + *
- + * Using the later, you can read through the CIS data to make sure the
- + * card is compatible with the driver. Keep in mind that the PCMCIA
- + * spec specifies the CIS as the lower 8 bits of each word read from
- + * the CIS, so to read the bytes of the CIS, read every other byte
- + * (0,2,4,...). Passing that test, you need to enable the I/O address
- + * space on the PCMCIA card via the PCMCIA COR register. This is the
- + * first byte following the CIS. In my case (which may not have any
- + * relation to what's on the PRISM2 cards), COR was at offset 0x800
- + * within the PCI memory space. Write 0x41 to the COR register to
- + * enable I/O mode and to select level triggered interrupts. To
- + * confirm you actually succeeded, read the COR register back and make
- + * sure it actually got set to 0x41, in case you have an unexpected
- + * card inserted.
- + *
- + * Following that, you can treat the second PCI I/O address space (the
- + * one that's not 0x80 in length) as the PCMCIA I/O space.
- + *
- + * Note that in the Eumitcom's source for their drivers, they register
- + * the interrupt as edge triggered when registering it with the
- + * Windows kernel. I don't recall how to register edge triggered on
- + * Linux (if it can be done at all). But in some experimentation, I
- + * don't see much operational difference between using either
- + * interrupt mode. Don't mess with the interrupt mode in the COR
- + * register though, as the PLX9052 wants level triggers with the way
- + * the serial EEPROM configures it on the WL11000.
- + *
- + * There's some other little quirks related to timing that I bumped
- + * into, but I don't recall right now. Also, there's two variants of
- + * the WL11000 I've seen, revision A1 and T2. These seem to differ
- + * slightly in the timings configured in the wait-state generator in
- + * the PLX9052. There have also been some comments from Eumitcom that
- + * cards shouldn't be hot swapped, apparently due to risk of cooking
- + * the PLX9052. I'm unsure why they believe this, as I can't see
- + * anything in the design that would really cause a problem, except
- + * for crashing drivers not written to expect it. And having developed
- + * drivers for the WL11000, I'd say it's quite tricky to write code
- + * that will successfully deal with a hot unplug. Very odd things
- + * happen on the I/O side of things. But anyway, be warned. Despite
- + * that, I've hot-swapped a number of times during debugging and
- + * driver development for various reasons (stuck WAIT# line after the
- + * radio card's firmware locks up).
- + */
- +
- +#define DRIVER_NAME "orinoco_plx"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/init.h>
- +#include <linux/delay.h>
- +#include <linux/pci.h>
- +#include <pcmcia/cisreg.h>
- +
- +#include "orinoco.h"
- +#include "orinoco_pci.h"
- +
- +#define COR_OFFSET (0x3e0) /* COR attribute offset of Prism2 PC card */
- +#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
- +#define COR_RESET (0x80) /* reset bit in the COR register */
- +#define PLX_RESET_TIME (500) /* milliseconds */
- +
- +#define PLX_INTCSR 0x4c /* Interrupt Control & Status Register */
- +#define PLX_INTCSR_INTEN (1 << 6) /* Interrupt Enable bit */
- +
- +/*
- + * Do a soft reset of the card using the Configuration Option Register
- + */
- +static int orinoco_plx_cor_reset(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + struct orinoco_pci_card *card = priv->card;
- + unsigned long timeout;
- + u16 reg;
- +
- + iowrite8(COR_VALUE | COR_RESET, card->attr_io + COR_OFFSET);
- + mdelay(1);
- +
- + iowrite8(COR_VALUE, card->attr_io + COR_OFFSET);
- + mdelay(1);
- +
- + /* Just in case, wait more until the card is no longer busy */
- + timeout = jiffies + msecs_to_jiffies(PLX_RESET_TIME);
- + reg = hermes_read_regn(hw, CMD);
- + while (time_before(jiffies, timeout) && (reg & HERMES_CMD_BUSY)) {
- + mdelay(1);
- + reg = hermes_read_regn(hw, CMD);
- + }
- +
- + /* Still busy? */
- + if (reg & HERMES_CMD_BUSY) {
- + printk(KERN_ERR PFX "Busy timeout\n");
- + return -ETIMEDOUT;
- + }
- +
- + return 0;
- +}
- +
- +static int orinoco_plx_hw_init(struct orinoco_pci_card *card)
- +{
- + int i;
- + u32 csr_reg;
- + static const u8 cis_magic[] = {
- + 0x01, 0x03, 0x00, 0x00, 0xff, 0x17, 0x04, 0x67
- + };
- +
- + printk(KERN_DEBUG PFX "CIS: ");
- + for (i = 0; i < 16; i++)
- + printk("%02X:", ioread8(card->attr_io + (i << 1)));
- + printk("\n");
- +
- + /* Verify whether a supported PC card is present */
- + /* FIXME: we probably need to be smarted about this */
- + for (i = 0; i < sizeof(cis_magic); i++) {
- + if (cis_magic[i] != ioread8(card->attr_io + (i << 1))) {
- + printk(KERN_ERR PFX "The CIS value of Prism2 PC "
- + "card is unexpected\n");
- + return -ENODEV;
- + }
- + }
- +
- + /* bjoern: We need to tell the card to enable interrupts, in
- + case the serial eprom didn't do this already. See the
- + PLX9052 data book, p8-1 and 8-24 for reference. */
- + csr_reg = ioread32(card->bridge_io + PLX_INTCSR);
- + if (!(csr_reg & PLX_INTCSR_INTEN)) {
- + csr_reg |= PLX_INTCSR_INTEN;
- + iowrite32(csr_reg, card->bridge_io + PLX_INTCSR);
- + csr_reg = ioread32(card->bridge_io + PLX_INTCSR);
- + if (!(csr_reg & PLX_INTCSR_INTEN)) {
- + printk(KERN_ERR PFX "Cannot enable interrupts\n");
- + return -EIO;
- + }
- + }
- +
- + return 0;
- +}
- +
- +static int orinoco_plx_init_one(struct pci_dev *pdev,
- + const struct pci_device_id *ent)
- +{
- + int err;
- + struct orinoco_private *priv;
- + struct orinoco_pci_card *card;
- + void __iomem *hermes_io, *attr_io, *bridge_io;
- +
- + err = pci_enable_device(pdev);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot enable PCI device\n");
- + return err;
- + }
- +
- + err = pci_request_regions(pdev, DRIVER_NAME);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
- + goto fail_resources;
- + }
- +
- + bridge_io = pci_iomap(pdev, 1, 0);
- + if (!bridge_io) {
- + printk(KERN_ERR PFX "Cannot map bridge registers\n");
- + err = -EIO;
- + goto fail_map_bridge;
- + }
- +
- + attr_io = pci_iomap(pdev, 2, 0);
- + if (!attr_io) {
- + printk(KERN_ERR PFX "Cannot map PCMCIA attributes\n");
- + err = -EIO;
- + goto fail_map_attr;
- + }
- +
- + hermes_io = pci_iomap(pdev, 3, 0);
- + if (!hermes_io) {
- + printk(KERN_ERR PFX "Cannot map chipset registers\n");
- + err = -EIO;
- + goto fail_map_hermes;
- + }
- +
- + /* Allocate network device */
- + priv = alloc_orinocodev(sizeof(*card), &pdev->dev,
- + orinoco_plx_cor_reset, NULL);
- + if (!priv) {
- + printk(KERN_ERR PFX "Cannot allocate network device\n");
- + err = -ENOMEM;
- + goto fail_alloc;
- + }
- +
- + card = priv->card;
- + card->bridge_io = bridge_io;
- + card->attr_io = attr_io;
- +
- + hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
- +
- + err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
- + DRIVER_NAME, priv);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
- + err = -EBUSY;
- + goto fail_irq;
- + }
- +
- + err = orinoco_plx_hw_init(card);
- + if (err) {
- + printk(KERN_ERR PFX "Hardware initialization failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_plx_cor_reset(priv);
- + if (err) {
- + printk(KERN_ERR PFX "Initial reset failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_init(priv);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_init() failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_if_add(priv, 0, 0, NULL);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_if_add() failed\n");
- + goto fail_wiphy;
- + }
- +
- + pci_set_drvdata(pdev, priv);
- +
- + return 0;
- +
- + fail_wiphy:
- + wiphy_unregister(priv_to_wiphy(priv));
- + fail:
- + free_irq(pdev->irq, priv);
- +
- + fail_irq:
- + free_orinocodev(priv);
- +
- + fail_alloc:
- + pci_iounmap(pdev, hermes_io);
- +
- + fail_map_hermes:
- + pci_iounmap(pdev, attr_io);
- +
- + fail_map_attr:
- + pci_iounmap(pdev, bridge_io);
- +
- + fail_map_bridge:
- + pci_release_regions(pdev);
- +
- + fail_resources:
- + pci_disable_device(pdev);
- +
- + return err;
- +}
- +
- +static void orinoco_plx_remove_one(struct pci_dev *pdev)
- +{
- + struct orinoco_private *priv = pci_get_drvdata(pdev);
- + struct orinoco_pci_card *card = priv->card;
- +
- + orinoco_if_del(priv);
- + wiphy_unregister(priv_to_wiphy(priv));
- + free_irq(pdev->irq, priv);
- + free_orinocodev(priv);
- + pci_iounmap(pdev, priv->hw.iobase);
- + pci_iounmap(pdev, card->attr_io);
- + pci_iounmap(pdev, card->bridge_io);
- + pci_release_regions(pdev);
- + pci_disable_device(pdev);
- +}
- +
- +static const struct pci_device_id orinoco_plx_id_table[] = {
- + {0x111a, 0x1023, PCI_ANY_ID, PCI_ANY_ID,}, /* Siemens SpeedStream SS1023 */
- + {0x1385, 0x4100, PCI_ANY_ID, PCI_ANY_ID,}, /* Netgear MA301 */
- + {0x15e8, 0x0130, PCI_ANY_ID, PCI_ANY_ID,}, /* Correga - does this work? */
- + {0x1638, 0x1100, PCI_ANY_ID, PCI_ANY_ID,}, /* SMC EZConnect SMC2602W,
- + Eumitcom PCI WL11000,
- + Addtron AWA-100 */
- + {0x16ab, 0x1100, PCI_ANY_ID, PCI_ANY_ID,}, /* Global Sun Tech GL24110P */
- + {0x16ab, 0x1101, PCI_ANY_ID, PCI_ANY_ID,}, /* Reported working, but unknown */
- + {0x16ab, 0x1102, PCI_ANY_ID, PCI_ANY_ID,}, /* Linksys WDT11 */
- + {0x16ec, 0x3685, PCI_ANY_ID, PCI_ANY_ID,}, /* USR 2415 */
- + {0xec80, 0xec00, PCI_ANY_ID, PCI_ANY_ID,}, /* Belkin F5D6000 tested by
- + Brendan W. McAdams <rit AT jacked-in.org> */
- + {0x10b7, 0x7770, PCI_ANY_ID, PCI_ANY_ID,}, /* 3Com AirConnect PCI tested by
- + Damien Persohn <damien AT persohn.net> */
- + {0,},
- +};
- +
- +MODULE_DEVICE_TABLE(pci, orinoco_plx_id_table);
- +
- +static struct pci_driver orinoco_plx_driver = {
- + .name = DRIVER_NAME,
- + .id_table = orinoco_plx_id_table,
- + .probe = orinoco_plx_init_one,
- + .remove = orinoco_plx_remove_one,
- + .driver.pm = &orinoco_pci_pm_ops,
- +};
- +
- +static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
- + " (Pavel Roskin <proski@gnu.org>,"
- + " David Gibson <hermes@gibson.dropbear.id.au>,"
- + " Daniel Barlow <dan@telent.net>)";
- +MODULE_AUTHOR("Daniel Barlow <dan@telent.net>");
- +MODULE_DESCRIPTION("Driver for wireless LAN cards using the PLX9052 PCI bridge");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +static int __init orinoco_plx_init(void)
- +{
- + printk(KERN_DEBUG "%s\n", version);
- + return pci_register_driver(&orinoco_plx_driver);
- +}
- +
- +static void __exit orinoco_plx_exit(void)
- +{
- + pci_unregister_driver(&orinoco_plx_driver);
- +}
- +
- +module_init(orinoco_plx_init);
- +module_exit(orinoco_plx_exit);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_tmd.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_tmd.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_tmd.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_tmd.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,237 @@
- +/* orinoco_tmd.c
- + *
- + * Driver for Prism II devices which would usually be driven by orinoco_cs,
- + * but are connected to the PCI bus by a TMD7160.
- + *
- + * Copyright (C) 2003 Joerg Dorchain <joerg AT dorchain.net>
- + * based heavily upon orinoco_plx.c Copyright (C) 2001 Daniel Barlow
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + *
- + * The actual driving is done by main.c, this is just resource
- + * allocation stuff.
- + *
- + * This driver is modeled after the orinoco_plx driver. The main
- + * difference is that the TMD chip has only IO port ranges and doesn't
- + * provide access to the PCMCIA attribute space.
- + *
- + * Pheecom sells cards with the TMD chip as "ASIC version"
- + */
- +
- +#define DRIVER_NAME "orinoco_tmd"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/init.h>
- +#include <linux/delay.h>
- +#include <linux/pci.h>
- +#include <pcmcia/cisreg.h>
- +
- +#include "orinoco.h"
- +#include "orinoco_pci.h"
- +
- +#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
- +#define COR_RESET (0x80) /* reset bit in the COR register */
- +#define TMD_RESET_TIME (500) /* milliseconds */
- +
- +/*
- + * Do a soft reset of the card using the Configuration Option Register
- + */
- +static int orinoco_tmd_cor_reset(struct orinoco_private *priv)
- +{
- + struct hermes *hw = &priv->hw;
- + struct orinoco_pci_card *card = priv->card;
- + unsigned long timeout;
- + u16 reg;
- +
- + iowrite8(COR_VALUE | COR_RESET, card->bridge_io);
- + mdelay(1);
- +
- + iowrite8(COR_VALUE, card->bridge_io);
- + mdelay(1);
- +
- + /* Just in case, wait more until the card is no longer busy */
- + timeout = jiffies + msecs_to_jiffies(TMD_RESET_TIME);
- + reg = hermes_read_regn(hw, CMD);
- + while (time_before(jiffies, timeout) && (reg & HERMES_CMD_BUSY)) {
- + mdelay(1);
- + reg = hermes_read_regn(hw, CMD);
- + }
- +
- + /* Still busy? */
- + if (reg & HERMES_CMD_BUSY) {
- + printk(KERN_ERR PFX "Busy timeout\n");
- + return -ETIMEDOUT;
- + }
- +
- + return 0;
- +}
- +
- +
- +static int orinoco_tmd_init_one(struct pci_dev *pdev,
- + const struct pci_device_id *ent)
- +{
- + int err;
- + struct orinoco_private *priv;
- + struct orinoco_pci_card *card;
- + void __iomem *hermes_io, *bridge_io;
- +
- + err = pci_enable_device(pdev);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot enable PCI device\n");
- + return err;
- + }
- +
- + err = pci_request_regions(pdev, DRIVER_NAME);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
- + goto fail_resources;
- + }
- +
- + bridge_io = pci_iomap(pdev, 1, 0);
- + if (!bridge_io) {
- + printk(KERN_ERR PFX "Cannot map bridge registers\n");
- + err = -EIO;
- + goto fail_map_bridge;
- + }
- +
- + hermes_io = pci_iomap(pdev, 2, 0);
- + if (!hermes_io) {
- + printk(KERN_ERR PFX "Cannot map chipset registers\n");
- + err = -EIO;
- + goto fail_map_hermes;
- + }
- +
- + /* Allocate network device */
- + priv = alloc_orinocodev(sizeof(*card), &pdev->dev,
- + orinoco_tmd_cor_reset, NULL);
- + if (!priv) {
- + printk(KERN_ERR PFX "Cannot allocate network device\n");
- + err = -ENOMEM;
- + goto fail_alloc;
- + }
- +
- + card = priv->card;
- + card->bridge_io = bridge_io;
- +
- + hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
- +
- + err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
- + DRIVER_NAME, priv);
- + if (err) {
- + printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
- + err = -EBUSY;
- + goto fail_irq;
- + }
- +
- + err = orinoco_tmd_cor_reset(priv);
- + if (err) {
- + printk(KERN_ERR PFX "Initial reset failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_init(priv);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_init() failed\n");
- + goto fail;
- + }
- +
- + err = orinoco_if_add(priv, 0, 0, NULL);
- + if (err) {
- + printk(KERN_ERR PFX "orinoco_if_add() failed\n");
- + goto fail;
- + }
- +
- + pci_set_drvdata(pdev, priv);
- +
- + return 0;
- +
- + fail:
- + free_irq(pdev->irq, priv);
- +
- + fail_irq:
- + free_orinocodev(priv);
- +
- + fail_alloc:
- + pci_iounmap(pdev, hermes_io);
- +
- + fail_map_hermes:
- + pci_iounmap(pdev, bridge_io);
- +
- + fail_map_bridge:
- + pci_release_regions(pdev);
- +
- + fail_resources:
- + pci_disable_device(pdev);
- +
- + return err;
- +}
- +
- +static void orinoco_tmd_remove_one(struct pci_dev *pdev)
- +{
- + struct orinoco_private *priv = pci_get_drvdata(pdev);
- + struct orinoco_pci_card *card = priv->card;
- +
- + orinoco_if_del(priv);
- + free_irq(pdev->irq, priv);
- + free_orinocodev(priv);
- + pci_iounmap(pdev, priv->hw.iobase);
- + pci_iounmap(pdev, card->bridge_io);
- + pci_release_regions(pdev);
- + pci_disable_device(pdev);
- +}
- +
- +static const struct pci_device_id orinoco_tmd_id_table[] = {
- + {0x15e8, 0x0131, PCI_ANY_ID, PCI_ANY_ID,}, /* NDC and OEMs, e.g. pheecom */
- + {0,},
- +};
- +
- +MODULE_DEVICE_TABLE(pci, orinoco_tmd_id_table);
- +
- +static struct pci_driver orinoco_tmd_driver = {
- + .name = DRIVER_NAME,
- + .id_table = orinoco_tmd_id_table,
- + .probe = orinoco_tmd_init_one,
- + .remove = orinoco_tmd_remove_one,
- + .driver.pm = &orinoco_pci_pm_ops,
- +};
- +
- +static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
- + " (Joerg Dorchain <joerg@dorchain.net>)";
- +MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
- +MODULE_DESCRIPTION("Driver for wireless LAN cards using the TMD7160 PCI bridge");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +static int __init orinoco_tmd_init(void)
- +{
- + printk(KERN_DEBUG "%s\n", version);
- + return pci_register_driver(&orinoco_tmd_driver);
- +}
- +
- +static void __exit orinoco_tmd_exit(void)
- +{
- + pci_unregister_driver(&orinoco_tmd_driver);
- +}
- +
- +module_init(orinoco_tmd_init);
- +module_exit(orinoco_tmd_exit);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_usb.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_usb.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/orinoco_usb.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/orinoco_usb.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,1787 @@
- +/*
- + * USB Orinoco driver
- + *
- + * Copyright (c) 2003 Manuel Estrada Sainz
- + *
- + * The contents of this file are subject to the Mozilla Public License
- + * Version 1.1 (the "License"); you may not use this file except in
- + * compliance with the License. You may obtain a copy of the License
- + * at http://www.mozilla.org/MPL/
- + *
- + * Software distributed under the License is distributed on an "AS IS"
- + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- + * the License for the specific language governing rights and
- + * limitations under the License.
- + *
- + * Alternatively, the contents of this file may be used under the
- + * terms of the GNU General Public License version 2 (the "GPL"), in
- + * which case the provisions of the GPL are applicable instead of the
- + * above. If you wish to allow the use of your version of this file
- + * only under the terms of the GPL and not to allow others to use your
- + * version of this file under the MPL, indicate your decision by
- + * deleting the provisions above and replace them with the notice and
- + * other provisions required by the GPL. If you do not delete the
- + * provisions above, a recipient may use your version of this file
- + * under either the MPL or the GPL.
- + *
- + * Queueing code based on linux-wlan-ng 0.2.1-pre5
- + *
- + * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
- + *
- + * The license is the same as above.
- + *
- + * Initialy based on USB Skeleton driver - 0.7
- + *
- + * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
- + *
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License as
- + * published by the Free Software Foundation; either version 2 of
- + * the License, or (at your option) any later version.
- + *
- + * NOTE: The original USB Skeleton driver is GPL, but all that code is
- + * gone so MPL/GPL applies.
- + */
- +
- +#define DRIVER_NAME "orinoco_usb"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/sched.h>
- +#include <linux/signal.h>
- +#include <linux/errno.h>
- +#include <linux/poll.h>
- +#include <linux/slab.h>
- +#include <linux/fcntl.h>
- +#include <linux/spinlock.h>
- +#include <linux/list.h>
- +#include <linux/usb.h>
- +#include <linux/timer.h>
- +
- +#include <linux/netdevice.h>
- +#include <linux/if_arp.h>
- +#include <linux/etherdevice.h>
- +#include <linux/wireless.h>
- +#include <linux/firmware.h>
- +#include <linux/refcount.h>
- +
- +#include "mic.h"
- +#include "orinoco.h"
- +
- +#ifndef URB_ASYNC_UNLINK
- +#define URB_ASYNC_UNLINK 0
- +#endif
- +
- +struct header_struct {
- + /* 802.3 */
- + u8 dest[ETH_ALEN];
- + u8 src[ETH_ALEN];
- + __be16 len;
- + /* 802.2 */
- + u8 dsap;
- + u8 ssap;
- + u8 ctrl;
- + /* SNAP */
- + u8 oui[3];
- + __be16 ethertype;
- +} __packed;
- +
- +struct ez_usb_fw {
- + u16 size;
- + const u8 *code;
- +};
- +
- +static struct ez_usb_fw firmware = {
- + .size = 0,
- + .code = NULL,
- +};
- +
- +/* Debugging macros */
- +#undef err
- +#define err(format, arg...) \
- + do { printk(KERN_ERR PFX format "\n", ## arg); } while (0)
- +
- +MODULE_FIRMWARE("orinoco_ezusb_fw");
- +
- +/*
- + * Under some conditions, the card gets stuck and stops paying attention
- + * to the world (i.e. data communication stalls) until we do something to
- + * it. Sending an INQ_TALLIES command seems to be enough and should be
- + * harmless otherwise. This behaviour has been observed when using the
- + * driver on a systemimager client during installation. In the past a
- + * timer was used to send INQ_TALLIES commands when there was no other
- + * activity, but it was troublesome and was removed.
- + */
- +
- +#define USB_COMPAQ_VENDOR_ID 0x049f /* Compaq Computer Corp. */
- +#define USB_COMPAQ_WL215_ID 0x001f /* Compaq WL215 USB Adapter */
- +#define USB_COMPAQ_W200_ID 0x0076 /* Compaq W200 USB Adapter */
- +#define USB_HP_WL215_ID 0x0082 /* Compaq WL215 USB Adapter */
- +
- +#define USB_MELCO_VENDOR_ID 0x0411
- +#define USB_BUFFALO_L11_ID 0x0006 /* BUFFALO WLI-USB-L11 */
- +#define USB_BUFFALO_L11G_WR_ID 0x000B /* BUFFALO WLI-USB-L11G-WR */
- +#define USB_BUFFALO_L11G_ID 0x000D /* BUFFALO WLI-USB-L11G */
- +
- +#define USB_LUCENT_VENDOR_ID 0x047E /* Lucent Technologies */
- +#define USB_LUCENT_ORINOCO_ID 0x0300 /* Lucent/Agere Orinoco USB Client */
- +
- +#define USB_AVAYA8_VENDOR_ID 0x0D98
- +#define USB_AVAYAE_VENDOR_ID 0x0D9E
- +#define USB_AVAYA_WIRELESS_ID 0x0300 /* Avaya USB Wireless Card */
- +
- +#define USB_AGERE_VENDOR_ID 0x0D4E /* Agere Systems */
- +#define USB_AGERE_MODEL0801_ID 0x1000 /* USB Wireless Card Model 0801 */
- +#define USB_AGERE_MODEL0802_ID 0x1001 /* USB Wireless Card Model 0802 */
- +#define USB_AGERE_REBRANDED_ID 0x047A /* USB WLAN Card */
- +
- +#define USB_ELSA_VENDOR_ID 0x05CC
- +#define USB_ELSA_AIRLANCER_ID 0x3100 /* ELSA AirLancer USB-11 */
- +
- +#define USB_LEGEND_VENDOR_ID 0x0E7C
- +#define USB_LEGEND_JOYNET_ID 0x0300 /* Joynet USB WLAN Card */
- +
- +#define USB_SAMSUNG_VENDOR_ID 0x04E8
- +#define USB_SAMSUNG_SEW2001U1_ID 0x5002 /* Samsung SEW-2001u Card */
- +#define USB_SAMSUNG_SEW2001U2_ID 0x5B11 /* Samsung SEW-2001u Card */
- +#define USB_SAMSUNG_SEW2003U_ID 0x7011 /* Samsung SEW-2003U Card */
- +
- +#define USB_IGATE_VENDOR_ID 0x0681
- +#define USB_IGATE_IGATE_11M_ID 0x0012 /* I-GATE 11M USB Card */
- +
- +#define USB_FUJITSU_VENDOR_ID 0x0BF8
- +#define USB_FUJITSU_E1100_ID 0x1002 /* connect2AIR WLAN E-1100 USB */
- +
- +#define USB_2WIRE_VENDOR_ID 0x1630
- +#define USB_2WIRE_WIRELESS_ID 0xff81 /* 2Wire USB Wireless adapter */
- +
- +
- +#define EZUSB_REQUEST_FW_TRANS 0xA0
- +#define EZUSB_REQUEST_TRIGGER 0xAA
- +#define EZUSB_REQUEST_TRIG_AC 0xAC
- +#define EZUSB_CPUCS_REG 0x7F92
- +
- +#define EZUSB_RID_TX 0x0700
- +#define EZUSB_RID_RX 0x0701
- +#define EZUSB_RID_INIT1 0x0702
- +#define EZUSB_RID_ACK 0x0710
- +#define EZUSB_RID_READ_PDA 0x0800
- +#define EZUSB_RID_PROG_INIT 0x0852
- +#define EZUSB_RID_PROG_SET_ADDR 0x0853
- +#define EZUSB_RID_PROG_BYTES 0x0854
- +#define EZUSB_RID_PROG_END 0x0855
- +#define EZUSB_RID_DOCMD 0x0860
- +
- +/* Recognize info frames */
- +#define EZUSB_IS_INFO(id) ((id >= 0xF000) && (id <= 0xF2FF))
- +
- +#define EZUSB_MAGIC 0x0210
- +
- +#define EZUSB_FRAME_DATA 1
- +#define EZUSB_FRAME_CONTROL 2
- +
- +#define DEF_TIMEOUT (3 * HZ)
- +
- +#define BULK_BUF_SIZE 2048
- +
- +#define MAX_DL_SIZE (BULK_BUF_SIZE - sizeof(struct ezusb_packet))
- +
- +#define FW_BUF_SIZE 64
- +#define FW_VAR_OFFSET_PTR 0x359
- +#define FW_VAR_VALUE 0
- +#define FW_HOLE_START 0x100
- +#define FW_HOLE_END 0x300
- +
- +struct ezusb_packet {
- + __le16 magic; /* 0x0210 */
- + u8 req_reply_count;
- + u8 ans_reply_count;
- + __le16 frame_type; /* 0x01 for data frames, 0x02 otherwise */
- + __le16 size; /* transport size */
- + __le16 crc; /* CRC up to here */
- + __le16 hermes_len;
- + __le16 hermes_rid;
- + u8 data[];
- +} __packed;
- +
- +/* Table of devices that work or may work with this driver */
- +static const struct usb_device_id ezusb_table[] = {
- + {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_WL215_ID)},
- + {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_HP_WL215_ID)},
- + {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_W200_ID)},
- + {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11_ID)},
- + {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_WR_ID)},
- + {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_ID)},
- + {USB_DEVICE(USB_LUCENT_VENDOR_ID, USB_LUCENT_ORINOCO_ID)},
- + {USB_DEVICE(USB_AVAYA8_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
- + {USB_DEVICE(USB_AVAYAE_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
- + {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0801_ID)},
- + {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0802_ID)},
- + {USB_DEVICE(USB_ELSA_VENDOR_ID, USB_ELSA_AIRLANCER_ID)},
- + {USB_DEVICE(USB_LEGEND_VENDOR_ID, USB_LEGEND_JOYNET_ID)},
- + {USB_DEVICE_VER(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U1_ID,
- + 0, 0)},
- + {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U2_ID)},
- + {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2003U_ID)},
- + {USB_DEVICE(USB_IGATE_VENDOR_ID, USB_IGATE_IGATE_11M_ID)},
- + {USB_DEVICE(USB_FUJITSU_VENDOR_ID, USB_FUJITSU_E1100_ID)},
- + {USB_DEVICE(USB_2WIRE_VENDOR_ID, USB_2WIRE_WIRELESS_ID)},
- + {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_REBRANDED_ID)},
- + {} /* Terminating entry */
- +};
- +
- +MODULE_DEVICE_TABLE(usb, ezusb_table);
- +
- +/* Structure to hold all of our device specific stuff */
- +struct ezusb_priv {
- + struct usb_device *udev;
- + struct net_device *dev;
- + struct mutex mtx;
- + spinlock_t req_lock;
- + struct list_head req_pending;
- + struct list_head req_active;
- + spinlock_t reply_count_lock;
- + u16 hermes_reg_fake[0x40];
- + u8 *bap_buf;
- + struct urb *read_urb;
- + int read_pipe;
- + int write_pipe;
- + u8 reply_count;
- +};
- +
- +enum ezusb_state {
- + EZUSB_CTX_START,
- + EZUSB_CTX_QUEUED,
- + EZUSB_CTX_REQ_SUBMITTED,
- + EZUSB_CTX_REQ_COMPLETE,
- + EZUSB_CTX_RESP_RECEIVED,
- + EZUSB_CTX_REQ_TIMEOUT,
- + EZUSB_CTX_REQ_FAILED,
- + EZUSB_CTX_RESP_TIMEOUT,
- + EZUSB_CTX_REQSUBMIT_FAIL,
- + EZUSB_CTX_COMPLETE,
- +};
- +
- +struct request_context {
- + struct list_head list;
- + refcount_t refcount;
- + struct completion done; /* Signals that CTX is dead */
- + int killed;
- + struct urb *outurb; /* OUT for req pkt */
- + struct ezusb_priv *upriv;
- + struct ezusb_packet *buf;
- + int buf_length;
- + struct timer_list timer; /* Timeout handling */
- + enum ezusb_state state; /* Current state */
- + /* the RID that we will wait for */
- + u16 out_rid;
- + u16 in_rid;
- +};
- +
- +
- +/* Forward declarations */
- +static void ezusb_ctx_complete(struct request_context *ctx);
- +static void ezusb_req_queue_run(struct ezusb_priv *upriv);
- +static void ezusb_bulk_in_callback(struct urb *urb);
- +
- +static inline u8 ezusb_reply_inc(u8 count)
- +{
- + if (count < 0x7F)
- + return count + 1;
- + else
- + return 1;
- +}
- +
- +static void ezusb_request_context_put(struct request_context *ctx)
- +{
- + if (!refcount_dec_and_test(&ctx->refcount))
- + return;
- +
- + WARN_ON(!ctx->done.done);
- + BUG_ON(ctx->outurb->status == -EINPROGRESS);
- + BUG_ON(timer_pending(&ctx->timer));
- + usb_free_urb(ctx->outurb);
- + kfree(ctx->buf);
- + kfree(ctx);
- +}
- +
- +static inline void ezusb_mod_timer(struct ezusb_priv *upriv,
- + struct timer_list *timer,
- + unsigned long expire)
- +{
- + if (!upriv->udev)
- + return;
- + mod_timer(timer, expire);
- +}
- +
- +static void ezusb_request_timerfn(struct timer_list *t)
- +{
- + struct request_context *ctx = from_timer(ctx, t, timer);
- +
- + ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
- + if (usb_unlink_urb(ctx->outurb) == -EINPROGRESS) {
- + ctx->state = EZUSB_CTX_REQ_TIMEOUT;
- + } else {
- + ctx->state = EZUSB_CTX_RESP_TIMEOUT;
- + dev_dbg(&ctx->outurb->dev->dev, "couldn't unlink\n");
- + refcount_inc(&ctx->refcount);
- + ctx->killed = 1;
- + ezusb_ctx_complete(ctx);
- + ezusb_request_context_put(ctx);
- + }
- +};
- +
- +static struct request_context *ezusb_alloc_ctx(struct ezusb_priv *upriv,
- + u16 out_rid, u16 in_rid)
- +{
- + struct request_context *ctx;
- +
- + ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
- + if (!ctx)
- + return NULL;
- +
- + ctx->buf = kmalloc(BULK_BUF_SIZE, GFP_ATOMIC);
- + if (!ctx->buf) {
- + kfree(ctx);
- + return NULL;
- + }
- + ctx->outurb = usb_alloc_urb(0, GFP_ATOMIC);
- + if (!ctx->outurb) {
- + kfree(ctx->buf);
- + kfree(ctx);
- + return NULL;
- + }
- +
- + ctx->upriv = upriv;
- + ctx->state = EZUSB_CTX_START;
- + ctx->out_rid = out_rid;
- + ctx->in_rid = in_rid;
- +
- + refcount_set(&ctx->refcount, 1);
- + init_completion(&ctx->done);
- +
- + timer_setup(&ctx->timer, ezusb_request_timerfn, 0);
- + return ctx;
- +}
- +
- +static void ezusb_ctx_complete(struct request_context *ctx)
- +{
- + struct ezusb_priv *upriv = ctx->upriv;
- + unsigned long flags;
- +
- + spin_lock_irqsave(&upriv->req_lock, flags);
- +
- + list_del_init(&ctx->list);
- + if (upriv->udev) {
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + ezusb_req_queue_run(upriv);
- + spin_lock_irqsave(&upriv->req_lock, flags);
- + }
- +
- + switch (ctx->state) {
- + case EZUSB_CTX_COMPLETE:
- + case EZUSB_CTX_REQSUBMIT_FAIL:
- + case EZUSB_CTX_REQ_FAILED:
- + case EZUSB_CTX_REQ_TIMEOUT:
- + case EZUSB_CTX_RESP_TIMEOUT:
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + if ((ctx->out_rid == EZUSB_RID_TX) && upriv->dev) {
- + struct net_device *dev = upriv->dev;
- + struct net_device_stats *stats = &dev->stats;
- +
- + if (ctx->state != EZUSB_CTX_COMPLETE)
- + stats->tx_errors++;
- + else
- + stats->tx_packets++;
- +
- + netif_wake_queue(dev);
- + }
- + complete_all(&ctx->done);
- + ezusb_request_context_put(ctx);
- + break;
- +
- + default:
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + if (!upriv->udev) {
- + /* This is normal, as all request contexts get flushed
- + * when the device is disconnected */
- + err("Called, CTX not terminating, but device gone");
- + complete_all(&ctx->done);
- + ezusb_request_context_put(ctx);
- + break;
- + }
- +
- + err("Called, CTX not in terminating state.");
- + /* Things are really bad if this happens. Just leak
- + * the CTX because it may still be linked to the
- + * queue or the OUT urb may still be active.
- + * Just leaking at least prevents an Oops or Panic.
- + */
- + break;
- + }
- +}
- +
- +/*
- + * ezusb_req_queue_run:
- + * Description:
- + * Note: Only one active CTX at any one time, because there's no
- + * other (reliable) way to match the response URB to the correct
- + * CTX.
- + */
- +static void ezusb_req_queue_run(struct ezusb_priv *upriv)
- +{
- + unsigned long flags;
- + struct request_context *ctx;
- + int result;
- +
- + spin_lock_irqsave(&upriv->req_lock, flags);
- +
- + if (!list_empty(&upriv->req_active))
- + goto unlock;
- +
- + if (list_empty(&upriv->req_pending))
- + goto unlock;
- +
- + ctx =
- + list_entry(upriv->req_pending.next, struct request_context,
- + list);
- +
- + if (!ctx->upriv->udev)
- + goto unlock;
- +
- + /* We need to split this off to avoid a race condition */
- + list_move_tail(&ctx->list, &upriv->req_active);
- +
- + if (ctx->state == EZUSB_CTX_QUEUED) {
- + refcount_inc(&ctx->refcount);
- + result = usb_submit_urb(ctx->outurb, GFP_ATOMIC);
- + if (result) {
- + ctx->state = EZUSB_CTX_REQSUBMIT_FAIL;
- +
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + err("Fatal, failed to submit command urb."
- + " error=%d\n", result);
- +
- + ezusb_ctx_complete(ctx);
- + ezusb_request_context_put(ctx);
- + goto done;
- + }
- +
- + ctx->state = EZUSB_CTX_REQ_SUBMITTED;
- + ezusb_mod_timer(ctx->upriv, &ctx->timer,
- + jiffies + DEF_TIMEOUT);
- + }
- +
- + unlock:
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + done:
- + return;
- +}
- +
- +static void ezusb_req_enqueue_run(struct ezusb_priv *upriv,
- + struct request_context *ctx)
- +{
- + unsigned long flags;
- +
- + spin_lock_irqsave(&upriv->req_lock, flags);
- +
- + if (!ctx->upriv->udev) {
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + goto done;
- + }
- + refcount_inc(&ctx->refcount);
- + list_add_tail(&ctx->list, &upriv->req_pending);
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + ctx->state = EZUSB_CTX_QUEUED;
- + ezusb_req_queue_run(upriv);
- +
- + done:
- + return;
- +}
- +
- +static void ezusb_request_out_callback(struct urb *urb)
- +{
- + unsigned long flags;
- + enum ezusb_state state;
- + struct request_context *ctx = urb->context;
- + struct ezusb_priv *upriv = ctx->upriv;
- +
- + spin_lock_irqsave(&upriv->req_lock, flags);
- +
- + del_timer(&ctx->timer);
- +
- + if (ctx->killed) {
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + pr_warn("interrupt called with dead ctx\n");
- + goto out;
- + }
- +
- + state = ctx->state;
- +
- + if (urb->status == 0) {
- + switch (state) {
- + case EZUSB_CTX_REQ_SUBMITTED:
- + if (ctx->in_rid) {
- + ctx->state = EZUSB_CTX_REQ_COMPLETE;
- + /* reply URB still pending */
- + ezusb_mod_timer(upriv, &ctx->timer,
- + jiffies + DEF_TIMEOUT);
- + spin_unlock_irqrestore(&upriv->req_lock,
- + flags);
- + break;
- + }
- + fallthrough;
- + case EZUSB_CTX_RESP_RECEIVED:
- + /* IN already received before this OUT-ACK */
- + ctx->state = EZUSB_CTX_COMPLETE;
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + ezusb_ctx_complete(ctx);
- + break;
- +
- + default:
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + err("Unexpected state(0x%x, %d) in OUT URB",
- + state, urb->status);
- + break;
- + }
- + } else {
- + /* If someone cancels the OUT URB then its status
- + * should be either -ECONNRESET or -ENOENT.
- + */
- + switch (state) {
- + case EZUSB_CTX_REQ_SUBMITTED:
- + case EZUSB_CTX_RESP_RECEIVED:
- + ctx->state = EZUSB_CTX_REQ_FAILED;
- + fallthrough;
- +
- + case EZUSB_CTX_REQ_FAILED:
- + case EZUSB_CTX_REQ_TIMEOUT:
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + ezusb_ctx_complete(ctx);
- + break;
- +
- + default:
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + err("Unexpected state(0x%x, %d) in OUT URB",
- + state, urb->status);
- + break;
- + }
- + }
- + out:
- + ezusb_request_context_put(ctx);
- +}
- +
- +static void ezusb_request_in_callback(struct ezusb_priv *upriv,
- + struct urb *urb)
- +{
- + struct ezusb_packet *ans = urb->transfer_buffer;
- + struct request_context *ctx = NULL;
- + enum ezusb_state state;
- + unsigned long flags;
- +
- + /* Find the CTX on the active queue that requested this URB */
- + spin_lock_irqsave(&upriv->req_lock, flags);
- + if (upriv->udev) {
- + struct list_head *item;
- +
- + list_for_each(item, &upriv->req_active) {
- + struct request_context *c;
- + int reply_count;
- +
- + c = list_entry(item, struct request_context, list);
- + reply_count =
- + ezusb_reply_inc(c->buf->req_reply_count);
- + if ((ans->ans_reply_count == reply_count)
- + && (le16_to_cpu(ans->hermes_rid) == c->in_rid)) {
- + ctx = c;
- + break;
- + }
- + netdev_dbg(upriv->dev, "Skipped (0x%x/0x%x) (%d/%d)\n",
- + le16_to_cpu(ans->hermes_rid), c->in_rid,
- + ans->ans_reply_count, reply_count);
- + }
- + }
- +
- + if (ctx == NULL) {
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + err("%s: got unexpected RID: 0x%04X", __func__,
- + le16_to_cpu(ans->hermes_rid));
- + ezusb_req_queue_run(upriv);
- + return;
- + }
- +
- + /* The data we want is in the in buffer, exchange */
- + urb->transfer_buffer = ctx->buf;
- + ctx->buf = (void *) ans;
- + ctx->buf_length = urb->actual_length;
- +
- + state = ctx->state;
- + switch (state) {
- + case EZUSB_CTX_REQ_SUBMITTED:
- + /* We have received our response URB before
- + * our request has been acknowledged. Do NOT
- + * destroy our CTX yet, because our OUT URB
- + * is still alive ...
- + */
- + ctx->state = EZUSB_CTX_RESP_RECEIVED;
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + /* Let the machine continue running. */
- + break;
- +
- + case EZUSB_CTX_REQ_COMPLETE:
- + /* This is the usual path: our request
- + * has already been acknowledged, and
- + * we have now received the reply.
- + */
- + ctx->state = EZUSB_CTX_COMPLETE;
- +
- + /* Stop the intimer */
- + del_timer(&ctx->timer);
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + /* Call the completion handler */
- + ezusb_ctx_complete(ctx);
- + break;
- +
- + default:
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + pr_warn("Matched IN URB, unexpected context state(0x%x)\n",
- + state);
- + /* Throw this CTX away and try submitting another */
- + del_timer(&ctx->timer);
- + ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
- + usb_unlink_urb(ctx->outurb);
- + ezusb_req_queue_run(upriv);
- + break;
- + } /* switch */
- +}
- +
- +typedef void (*ezusb_ctx_wait)(struct ezusb_priv *, struct request_context *);
- +
- +static void ezusb_req_ctx_wait_compl(struct ezusb_priv *upriv,
- + struct request_context *ctx)
- +{
- + switch (ctx->state) {
- + case EZUSB_CTX_QUEUED:
- + case EZUSB_CTX_REQ_SUBMITTED:
- + case EZUSB_CTX_REQ_COMPLETE:
- + case EZUSB_CTX_RESP_RECEIVED:
- + wait_for_completion(&ctx->done);
- + break;
- + default:
- + /* Done or failed - nothing to wait for */
- + break;
- + }
- +}
- +
- +static void ezusb_req_ctx_wait_poll(struct ezusb_priv *upriv,
- + struct request_context *ctx)
- +{
- + int msecs;
- +
- + switch (ctx->state) {
- + case EZUSB_CTX_QUEUED:
- + case EZUSB_CTX_REQ_SUBMITTED:
- + case EZUSB_CTX_REQ_COMPLETE:
- + case EZUSB_CTX_RESP_RECEIVED:
- + /* If we get called from a timer or with our lock acquired, then
- + * we can't wait for the completion and have to poll. This won't
- + * happen if the USB controller completes the URB requests in
- + * BH.
- + */
- + msecs = DEF_TIMEOUT * (1000 / HZ);
- +
- + while (!try_wait_for_completion(&ctx->done) && msecs--)
- + udelay(1000);
- + break;
- + default:
- + /* Done or failed - nothing to wait for */
- + break;
- + }
- +}
- +
- +static void ezusb_req_ctx_wait_skip(struct ezusb_priv *upriv,
- + struct request_context *ctx)
- +{
- + WARN(1, "Shouldn't be invoked for in_rid\n");
- +}
- +
- +static inline u16 build_crc(struct ezusb_packet *data)
- +{
- + u16 crc = 0;
- + u8 *bytes = (u8 *)data;
- + int i;
- +
- + for (i = 0; i < 8; i++)
- + crc = (crc << 1) + bytes[i];
- +
- + return crc;
- +}
- +
- +/*
- + * ezusb_fill_req:
- + *
- + * if data == NULL and length > 0 the data is assumed to be already in
- + * the target buffer and only the header is filled.
- + *
- + */
- +static int ezusb_fill_req(struct ezusb_packet *req, u16 length, u16 rid,
- + const void *data, u16 frame_type, u8 reply_count)
- +{
- + int total_size = sizeof(*req) + length;
- +
- + BUG_ON(total_size > BULK_BUF_SIZE);
- +
- + req->magic = cpu_to_le16(EZUSB_MAGIC);
- + req->req_reply_count = reply_count;
- + req->ans_reply_count = 0;
- + req->frame_type = cpu_to_le16(frame_type);
- + req->size = cpu_to_le16(length + 4);
- + req->crc = cpu_to_le16(build_crc(req));
- + req->hermes_len = cpu_to_le16(HERMES_BYTES_TO_RECLEN(length));
- + req->hermes_rid = cpu_to_le16(rid);
- + if (data)
- + memcpy(req->data, data, length);
- + return total_size;
- +}
- +
- +static int ezusb_submit_in_urb(struct ezusb_priv *upriv)
- +{
- + int retval = 0;
- + void *cur_buf = upriv->read_urb->transfer_buffer;
- +
- + if (upriv->read_urb->status == -EINPROGRESS) {
- + netdev_dbg(upriv->dev, "urb busy, not resubmiting\n");
- + retval = -EBUSY;
- + goto exit;
- + }
- + usb_fill_bulk_urb(upriv->read_urb, upriv->udev, upriv->read_pipe,
- + cur_buf, BULK_BUF_SIZE,
- + ezusb_bulk_in_callback, upriv);
- + upriv->read_urb->transfer_flags = 0;
- + retval = usb_submit_urb(upriv->read_urb, GFP_ATOMIC);
- + if (retval)
- + err("%s submit failed %d", __func__, retval);
- +
- + exit:
- + return retval;
- +}
- +
- +static inline int ezusb_8051_cpucs(struct ezusb_priv *upriv, int reset)
- +{
- + int ret;
- + u8 *res_val = NULL;
- +
- + if (!upriv->udev) {
- + err("%s: !upriv->udev", __func__);
- + return -EFAULT;
- + }
- +
- + res_val = kmalloc(sizeof(*res_val), GFP_KERNEL);
- +
- + if (!res_val)
- + return -ENOMEM;
- +
- + *res_val = reset; /* avoid argument promotion */
- +
- + ret = usb_control_msg(upriv->udev,
- + usb_sndctrlpipe(upriv->udev, 0),
- + EZUSB_REQUEST_FW_TRANS,
- + USB_TYPE_VENDOR | USB_RECIP_DEVICE |
- + USB_DIR_OUT, EZUSB_CPUCS_REG, 0, res_val,
- + sizeof(*res_val), DEF_TIMEOUT);
- +
- + kfree(res_val);
- +
- + return ret;
- +}
- +
- +static int ezusb_firmware_download(struct ezusb_priv *upriv,
- + struct ez_usb_fw *fw)
- +{
- + u8 *fw_buffer;
- + int retval, addr;
- + int variant_offset;
- +
- + fw_buffer = kmalloc(FW_BUF_SIZE, GFP_KERNEL);
- + if (!fw_buffer) {
- + printk(KERN_ERR PFX "Out of memory for firmware buffer.\n");
- + return -ENOMEM;
- + }
- + /*
- + * This byte is 1 and should be replaced with 0. The offset is
- + * 0x10AD in version 0.0.6. The byte in question should follow
- + * the end of the code pointed to by the jump in the beginning
- + * of the firmware. Also, it is read by code located at 0x358.
- + */
- + variant_offset = be16_to_cpup((__be16 *) &fw->code[FW_VAR_OFFSET_PTR]);
- + if (variant_offset >= fw->size) {
- + printk(KERN_ERR PFX "Invalid firmware variant offset: "
- + "0x%04x\n", variant_offset);
- + retval = -EINVAL;
- + goto fail;
- + }
- +
- + retval = ezusb_8051_cpucs(upriv, 1);
- + if (retval < 0)
- + goto fail;
- + for (addr = 0; addr < fw->size; addr += FW_BUF_SIZE) {
- + /* 0x100-0x300 should be left alone, it contains card
- + * specific data, like USB enumeration information */
- + if ((addr >= FW_HOLE_START) && (addr < FW_HOLE_END))
- + continue;
- +
- + memcpy(fw_buffer, &fw->code[addr], FW_BUF_SIZE);
- + if (variant_offset >= addr &&
- + variant_offset < addr + FW_BUF_SIZE) {
- + netdev_dbg(upriv->dev,
- + "Patching card_variant byte at 0x%04X\n",
- + variant_offset);
- + fw_buffer[variant_offset - addr] = FW_VAR_VALUE;
- + }
- + retval = usb_control_msg(upriv->udev,
- + usb_sndctrlpipe(upriv->udev, 0),
- + EZUSB_REQUEST_FW_TRANS,
- + USB_TYPE_VENDOR | USB_RECIP_DEVICE
- + | USB_DIR_OUT,
- + addr, 0x0,
- + fw_buffer, FW_BUF_SIZE,
- + DEF_TIMEOUT);
- +
- + if (retval < 0)
- + goto fail;
- + }
- + retval = ezusb_8051_cpucs(upriv, 0);
- + if (retval < 0)
- + goto fail;
- +
- + goto exit;
- + fail:
- + printk(KERN_ERR PFX "Firmware download failed, error %d\n",
- + retval);
- + exit:
- + kfree(fw_buffer);
- + return retval;
- +}
- +
- +static int ezusb_access_ltv(struct ezusb_priv *upriv,
- + struct request_context *ctx,
- + u16 length, const void *data, u16 frame_type,
- + void *ans_buff, unsigned ans_size, u16 *ans_length,
- + ezusb_ctx_wait ezusb_ctx_wait_func)
- +{
- + int req_size;
- + int retval = 0;
- + enum ezusb_state state;
- +
- + if (!upriv->udev) {
- + retval = -ENODEV;
- + goto exit;
- + }
- +
- + if (upriv->read_urb->status != -EINPROGRESS)
- + err("%s: in urb not pending", __func__);
- +
- + /* protect upriv->reply_count, guarantee sequential numbers */
- + spin_lock_bh(&upriv->reply_count_lock);
- + req_size = ezusb_fill_req(ctx->buf, length, ctx->out_rid, data,
- + frame_type, upriv->reply_count);
- + usb_fill_bulk_urb(ctx->outurb, upriv->udev, upriv->write_pipe,
- + ctx->buf, req_size,
- + ezusb_request_out_callback, ctx);
- +
- + if (ctx->in_rid)
- + upriv->reply_count = ezusb_reply_inc(upriv->reply_count);
- +
- + ezusb_req_enqueue_run(upriv, ctx);
- +
- + spin_unlock_bh(&upriv->reply_count_lock);
- +
- + if (ctx->in_rid)
- + ezusb_ctx_wait_func(upriv, ctx);
- +
- + state = ctx->state;
- + switch (state) {
- + case EZUSB_CTX_COMPLETE:
- + retval = ctx->outurb->status;
- + break;
- +
- + case EZUSB_CTX_QUEUED:
- + case EZUSB_CTX_REQ_SUBMITTED:
- + if (!ctx->in_rid)
- + break;
- + fallthrough;
- + default:
- + err("%s: Unexpected context state %d", __func__,
- + state);
- + fallthrough;
- + case EZUSB_CTX_REQ_TIMEOUT:
- + case EZUSB_CTX_REQ_FAILED:
- + case EZUSB_CTX_RESP_TIMEOUT:
- + case EZUSB_CTX_REQSUBMIT_FAIL:
- + printk(KERN_ERR PFX "Access failed, resetting (state %d,"
- + " reply_count %d)\n", state, upriv->reply_count);
- + upriv->reply_count = 0;
- + if (state == EZUSB_CTX_REQ_TIMEOUT
- + || state == EZUSB_CTX_RESP_TIMEOUT) {
- + printk(KERN_ERR PFX "ctx timed out\n");
- + retval = -ETIMEDOUT;
- + } else {
- + printk(KERN_ERR PFX "ctx failed\n");
- + retval = -EFAULT;
- + }
- + goto exit;
- + }
- + if (ctx->in_rid) {
- + struct ezusb_packet *ans = ctx->buf;
- + unsigned exp_len;
- +
- + if (ans->hermes_len != 0)
- + exp_len = le16_to_cpu(ans->hermes_len) * 2 + 12;
- + else
- + exp_len = 14;
- +
- + if (exp_len != ctx->buf_length) {
- + err("%s: length mismatch for RID 0x%04x: "
- + "expected %d, got %d", __func__,
- + ctx->in_rid, exp_len, ctx->buf_length);
- + retval = -EIO;
- + goto exit;
- + }
- +
- + if (ans_buff)
- + memcpy(ans_buff, ans->data, min(exp_len, ans_size));
- + if (ans_length)
- + *ans_length = le16_to_cpu(ans->hermes_len);
- + }
- + exit:
- + ezusb_request_context_put(ctx);
- + return retval;
- +}
- +
- +static int __ezusb_write_ltv(struct hermes *hw, int bap, u16 rid,
- + u16 length, const void *data,
- + ezusb_ctx_wait ezusb_ctx_wait_func)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + u16 frame_type;
- + struct request_context *ctx;
- +
- + if (length == 0)
- + return -EINVAL;
- +
- + length = HERMES_RECLEN_TO_BYTES(length);
- +
- + /* On memory mapped devices HERMES_RID_CNFGROUPADDRESSES can be
- + * set to be empty, but the USB bridge doesn't like it */
- + if (length == 0)
- + return 0;
- +
- + ctx = ezusb_alloc_ctx(upriv, rid, EZUSB_RID_ACK);
- + if (!ctx)
- + return -ENOMEM;
- +
- + if (rid == EZUSB_RID_TX)
- + frame_type = EZUSB_FRAME_DATA;
- + else
- + frame_type = EZUSB_FRAME_CONTROL;
- +
- + return ezusb_access_ltv(upriv, ctx, length, data, frame_type,
- + NULL, 0, NULL, ezusb_ctx_wait_func);
- +}
- +
- +static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid,
- + u16 length, const void *data)
- +{
- + return __ezusb_write_ltv(hw, bap, rid, length, data,
- + ezusb_req_ctx_wait_poll);
- +}
- +
- +static int __ezusb_read_ltv(struct hermes *hw, int bap, u16 rid,
- + unsigned bufsize, u16 *length, void *buf,
- + ezusb_ctx_wait ezusb_ctx_wait_func)
- +
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + struct request_context *ctx;
- +
- + if (bufsize % 2)
- + return -EINVAL;
- +
- + ctx = ezusb_alloc_ctx(upriv, rid, rid);
- + if (!ctx)
- + return -ENOMEM;
- +
- + return ezusb_access_ltv(upriv, ctx, 0, NULL, EZUSB_FRAME_CONTROL,
- + buf, bufsize, length, ezusb_req_ctx_wait_poll);
- +}
- +
- +static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid,
- + unsigned bufsize, u16 *length, void *buf)
- +{
- + return __ezusb_read_ltv(hw, bap, rid, bufsize, length, buf,
- + ezusb_req_ctx_wait_poll);
- +}
- +
- +static int ezusb_read_ltv_preempt(struct hermes *hw, int bap, u16 rid,
- + unsigned bufsize, u16 *length, void *buf)
- +{
- + return __ezusb_read_ltv(hw, bap, rid, bufsize, length, buf,
- + ezusb_req_ctx_wait_compl);
- +}
- +
- +static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1,
- + u16 parm2, struct hermes_response *resp)
- +{
- + WARN_ON_ONCE(1);
- + return -EINVAL;
- +}
- +
- +static int __ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
- + struct hermes_response *resp,
- + ezusb_ctx_wait ezusb_ctx_wait_func)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + struct request_context *ctx;
- +
- + __le16 data[4] = {
- + cpu_to_le16(cmd),
- + cpu_to_le16(parm0),
- + 0,
- + 0,
- + };
- + netdev_dbg(upriv->dev, "0x%04X, parm0 0x%04X\n", cmd, parm0);
- + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK);
- + if (!ctx)
- + return -ENOMEM;
- +
- + return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
- + EZUSB_FRAME_CONTROL, NULL, 0, NULL,
- + ezusb_ctx_wait_func);
- +}
- +
- +static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
- + struct hermes_response *resp)
- +{
- + return __ezusb_docmd_wait(hw, cmd, parm0, resp, ezusb_req_ctx_wait_poll);
- +}
- +
- +static int ezusb_bap_pread(struct hermes *hw, int bap,
- + void *buf, int len, u16 id, u16 offset)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + struct ezusb_packet *ans = (void *) upriv->read_urb->transfer_buffer;
- + int actual_length = upriv->read_urb->actual_length;
- +
- + if (id == EZUSB_RID_RX) {
- + if ((sizeof(*ans) + offset + len) > actual_length) {
- + printk(KERN_ERR PFX "BAP read beyond buffer end "
- + "in rx frame\n");
- + return -EINVAL;
- + }
- + memcpy(buf, ans->data + offset, len);
- + return 0;
- + }
- +
- + if (EZUSB_IS_INFO(id)) {
- + /* Include 4 bytes for length/type */
- + if ((sizeof(*ans) + offset + len - 4) > actual_length) {
- + printk(KERN_ERR PFX "BAP read beyond buffer end "
- + "in info frame\n");
- + return -EFAULT;
- + }
- + memcpy(buf, ans->data + offset - 4, len);
- + } else {
- + printk(KERN_ERR PFX "Unexpected fid 0x%04x\n", id);
- + return -EINVAL;
- + }
- +
- + return 0;
- +}
- +
- +static int ezusb_read_pda(struct hermes *hw, __le16 *pda,
- + u32 pda_addr, u16 pda_len)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + struct request_context *ctx;
- + __le16 data[] = {
- + cpu_to_le16(pda_addr & 0xffff),
- + cpu_to_le16(pda_len - 4)
- + };
- + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_READ_PDA, EZUSB_RID_READ_PDA);
- + if (!ctx)
- + return -ENOMEM;
- +
- + /* wl_lkm does not include PDA size in the PDA area.
- + * We will pad the information into pda, so other routines
- + * don't have to be modified */
- + pda[0] = cpu_to_le16(pda_len - 2);
- + /* Includes CFG_PROD_DATA but not itself */
- + pda[1] = cpu_to_le16(0x0800); /* CFG_PROD_DATA */
- +
- + return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
- + EZUSB_FRAME_CONTROL, &pda[2], pda_len - 4,
- + NULL, ezusb_req_ctx_wait_compl);
- +}
- +
- +static int ezusb_program_init(struct hermes *hw, u32 entry_point)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + struct request_context *ctx;
- + __le32 data = cpu_to_le32(entry_point);
- +
- + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_INIT, EZUSB_RID_ACK);
- + if (!ctx)
- + return -ENOMEM;
- +
- + return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
- + EZUSB_FRAME_CONTROL, NULL, 0, NULL,
- + ezusb_req_ctx_wait_compl);
- +}
- +
- +static int ezusb_program_end(struct hermes *hw)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + struct request_context *ctx;
- +
- + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_END, EZUSB_RID_ACK);
- + if (!ctx)
- + return -ENOMEM;
- +
- + return ezusb_access_ltv(upriv, ctx, 0, NULL,
- + EZUSB_FRAME_CONTROL, NULL, 0, NULL,
- + ezusb_req_ctx_wait_compl);
- +}
- +
- +static int ezusb_program_bytes(struct hermes *hw, const char *buf,
- + u32 addr, u32 len)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + struct request_context *ctx;
- + __le32 data = cpu_to_le32(addr);
- + int err;
- +
- + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_SET_ADDR, EZUSB_RID_ACK);
- + if (!ctx)
- + return -ENOMEM;
- +
- + err = ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
- + EZUSB_FRAME_CONTROL, NULL, 0, NULL,
- + ezusb_req_ctx_wait_compl);
- + if (err)
- + return err;
- +
- + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_BYTES, EZUSB_RID_ACK);
- + if (!ctx)
- + return -ENOMEM;
- +
- + return ezusb_access_ltv(upriv, ctx, len, buf,
- + EZUSB_FRAME_CONTROL, NULL, 0, NULL,
- + ezusb_req_ctx_wait_compl);
- +}
- +
- +static int ezusb_program(struct hermes *hw, const char *buf,
- + u32 addr, u32 len)
- +{
- + u32 ch_addr;
- + u32 ch_len;
- + int err = 0;
- +
- + /* We can only send 2048 bytes out of the bulk xmit at a time,
- + * so we have to split any programming into chunks of <2048
- + * bytes. */
- +
- + ch_len = (len < MAX_DL_SIZE) ? len : MAX_DL_SIZE;
- + ch_addr = addr;
- +
- + while (ch_addr < (addr + len)) {
- + pr_debug("Programming subblock of length %d "
- + "to address 0x%08x. Data @ %p\n",
- + ch_len, ch_addr, &buf[ch_addr - addr]);
- +
- + err = ezusb_program_bytes(hw, &buf[ch_addr - addr],
- + ch_addr, ch_len);
- + if (err)
- + break;
- +
- + ch_addr += ch_len;
- + ch_len = ((addr + len - ch_addr) < MAX_DL_SIZE) ?
- + (addr + len - ch_addr) : MAX_DL_SIZE;
- + }
- +
- + return err;
- +}
- +
- +static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct net_device_stats *stats = &dev->stats;
- + struct ezusb_priv *upriv = priv->card;
- + u8 mic[MICHAEL_MIC_LEN + 1];
- + int err = 0;
- + int tx_control;
- + unsigned long flags;
- + struct request_context *ctx;
- + u8 *buf;
- + int tx_size;
- +
- + if (!netif_running(dev)) {
- + printk(KERN_ERR "%s: Tx on stopped device!\n",
- + dev->name);
- + return NETDEV_TX_BUSY;
- + }
- +
- + if (netif_queue_stopped(dev)) {
- + printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
- + dev->name);
- + return NETDEV_TX_BUSY;
- + }
- +
- + if (orinoco_lock(priv, &flags) != 0) {
- + printk(KERN_ERR
- + "%s: ezusb_xmit() called while hw_unavailable\n",
- + dev->name);
- + return NETDEV_TX_BUSY;
- + }
- +
- + if (!netif_carrier_ok(dev) ||
- + (priv->iw_mode == NL80211_IFTYPE_MONITOR)) {
- + /* Oops, the firmware hasn't established a connection,
- + silently drop the packet (this seems to be the
- + safest approach). */
- + goto drop;
- + }
- +
- + /* Check packet length */
- + if (skb->len < ETH_HLEN)
- + goto drop;
- +
- + tx_control = 0;
- +
- + err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control,
- + &mic[0]);
- + if (err)
- + goto drop;
- +
- + ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0);
- + if (!ctx)
- + goto drop;
- +
- + memset(ctx->buf, 0, BULK_BUF_SIZE);
- + buf = ctx->buf->data;
- +
- + {
- + __le16 *tx_cntl = (__le16 *)buf;
- + *tx_cntl = cpu_to_le16(tx_control);
- + buf += sizeof(*tx_cntl);
- + }
- +
- + memcpy(buf, skb->data, skb->len);
- + buf += skb->len;
- +
- + if (tx_control & HERMES_TXCTRL_MIC) {
- + u8 *m = mic;
- + /* Mic has been offset so it can be copied to an even
- + * address. We're copying eveything anyway, so we
- + * don't need to copy that first byte. */
- + if (skb->len % 2)
- + m++;
- + memcpy(buf, m, MICHAEL_MIC_LEN);
- + buf += MICHAEL_MIC_LEN;
- + }
- +
- + /* Finally, we actually initiate the send */
- + netif_stop_queue(dev);
- +
- + /* The card may behave better if we send evenly sized usb transfers */
- + tx_size = ALIGN(buf - ctx->buf->data, 2);
- +
- + err = ezusb_access_ltv(upriv, ctx, tx_size, NULL,
- + EZUSB_FRAME_DATA, NULL, 0, NULL,
- + ezusb_req_ctx_wait_skip);
- +
- + if (err) {
- + netif_start_queue(dev);
- + if (net_ratelimit())
- + printk(KERN_ERR "%s: Error %d transmitting packet\n",
- + dev->name, err);
- + goto busy;
- + }
- +
- + netif_trans_update(dev);
- + stats->tx_bytes += skb->len;
- + goto ok;
- +
- + drop:
- + stats->tx_errors++;
- + stats->tx_dropped++;
- +
- + ok:
- + orinoco_unlock(priv, &flags);
- + dev_kfree_skb(skb);
- + return NETDEV_TX_OK;
- +
- + busy:
- + orinoco_unlock(priv, &flags);
- + return NETDEV_TX_BUSY;
- +}
- +
- +static int ezusb_allocate(struct hermes *hw, u16 size, u16 *fid)
- +{
- + *fid = EZUSB_RID_TX;
- + return 0;
- +}
- +
- +
- +static int ezusb_hard_reset(struct orinoco_private *priv)
- +{
- + struct ezusb_priv *upriv = priv->card;
- + int retval = ezusb_8051_cpucs(upriv, 1);
- +
- + if (retval < 0) {
- + err("Failed to reset");
- + return retval;
- + }
- +
- + retval = ezusb_8051_cpucs(upriv, 0);
- + if (retval < 0) {
- + err("Failed to unreset");
- + return retval;
- + }
- +
- + netdev_dbg(upriv->dev, "sending control message\n");
- + retval = usb_control_msg(upriv->udev,
- + usb_sndctrlpipe(upriv->udev, 0),
- + EZUSB_REQUEST_TRIGGER,
- + USB_TYPE_VENDOR | USB_RECIP_DEVICE |
- + USB_DIR_OUT, 0x0, 0x0, NULL, 0,
- + DEF_TIMEOUT);
- + if (retval < 0) {
- + err("EZUSB_REQUEST_TRIGGER failed retval %d", retval);
- + return retval;
- + }
- +#if 0
- + dbg("Sending EZUSB_REQUEST_TRIG_AC");
- + retval = usb_control_msg(upriv->udev,
- + usb_sndctrlpipe(upriv->udev, 0),
- + EZUSB_REQUEST_TRIG_AC,
- + USB_TYPE_VENDOR | USB_RECIP_DEVICE |
- + USB_DIR_OUT, 0x00FA, 0x0, NULL, 0,
- + DEF_TIMEOUT);
- + if (retval < 0) {
- + err("EZUSB_REQUEST_TRIG_AC failed retval %d", retval);
- + return retval;
- + }
- +#endif
- +
- + return 0;
- +}
- +
- +
- +static int ezusb_init(struct hermes *hw)
- +{
- + struct ezusb_priv *upriv = hw->priv;
- + int retval;
- +
- + if (!upriv)
- + return -EINVAL;
- +
- + upriv->reply_count = 0;
- + /* Write the MAGIC number on the simulated registers to keep
- + * orinoco.c happy */
- + hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
- + hermes_write_regn(hw, RXFID, EZUSB_RID_RX);
- +
- + usb_kill_urb(upriv->read_urb);
- + ezusb_submit_in_urb(upriv);
- +
- + retval = __ezusb_write_ltv(hw, 0, EZUSB_RID_INIT1,
- + HERMES_BYTES_TO_RECLEN(2), "\x10\x00",
- + ezusb_req_ctx_wait_compl);
- + if (retval < 0) {
- + printk(KERN_ERR PFX "EZUSB_RID_INIT1 error %d\n", retval);
- + return retval;
- + }
- +
- + retval = __ezusb_docmd_wait(hw, HERMES_CMD_INIT, 0, NULL,
- + ezusb_req_ctx_wait_compl);
- + if (retval < 0) {
- + printk(KERN_ERR PFX "HERMES_CMD_INIT error %d\n", retval);
- + return retval;
- + }
- +
- + return 0;
- +}
- +
- +static void ezusb_bulk_in_callback(struct urb *urb)
- +{
- + struct ezusb_priv *upriv = (struct ezusb_priv *) urb->context;
- + struct ezusb_packet *ans = urb->transfer_buffer;
- + u16 crc;
- + u16 hermes_rid;
- +
- + if (upriv->udev == NULL)
- + return;
- +
- + if (urb->status == -ETIMEDOUT) {
- + /* When a device gets unplugged we get this every time
- + * we resubmit, flooding the logs. Since we don't use
- + * USB timeouts, it shouldn't happen any other time*/
- + pr_warn("%s: urb timed out, not resubmitting\n", __func__);
- + return;
- + }
- + if (urb->status == -ECONNABORTED) {
- + pr_warn("%s: connection abort, resubmitting urb\n",
- + __func__);
- + goto resubmit;
- + }
- + if ((urb->status == -EILSEQ)
- + || (urb->status == -ENOENT)
- + || (urb->status == -ECONNRESET)) {
- + netdev_dbg(upriv->dev, "status %d, not resubmiting\n",
- + urb->status);
- + return;
- + }
- + if (urb->status)
- + netdev_dbg(upriv->dev, "status: %d length: %d\n",
- + urb->status, urb->actual_length);
- + if (urb->actual_length < sizeof(*ans)) {
- + err("%s: short read, ignoring", __func__);
- + goto resubmit;
- + }
- + crc = build_crc(ans);
- + if (le16_to_cpu(ans->crc) != crc) {
- + err("CRC error, ignoring packet");
- + goto resubmit;
- + }
- +
- + hermes_rid = le16_to_cpu(ans->hermes_rid);
- + if ((hermes_rid != EZUSB_RID_RX) && !EZUSB_IS_INFO(hermes_rid)) {
- + ezusb_request_in_callback(upriv, urb);
- + } else if (upriv->dev) {
- + struct net_device *dev = upriv->dev;
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct hermes *hw = &priv->hw;
- +
- + if (hermes_rid == EZUSB_RID_RX) {
- + __orinoco_ev_rx(dev, hw);
- + } else {
- + hermes_write_regn(hw, INFOFID,
- + le16_to_cpu(ans->hermes_rid));
- + __orinoco_ev_info(dev, hw);
- + }
- + }
- +
- + resubmit:
- + if (upriv->udev)
- + ezusb_submit_in_urb(upriv);
- +}
- +
- +static inline void ezusb_delete(struct ezusb_priv *upriv)
- +{
- + struct list_head *item;
- + struct list_head *tmp_item;
- + unsigned long flags;
- +
- + BUG_ON(!upriv);
- +
- + mutex_lock(&upriv->mtx);
- +
- + upriv->udev = NULL; /* No timer will be rearmed from here */
- +
- + usb_kill_urb(upriv->read_urb);
- +
- + spin_lock_irqsave(&upriv->req_lock, flags);
- + list_for_each_safe(item, tmp_item, &upriv->req_active) {
- + struct request_context *ctx;
- + int err;
- +
- + ctx = list_entry(item, struct request_context, list);
- + refcount_inc(&ctx->refcount);
- +
- + ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
- + err = usb_unlink_urb(ctx->outurb);
- +
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- + if (err == -EINPROGRESS)
- + wait_for_completion(&ctx->done);
- +
- + del_timer_sync(&ctx->timer);
- + /* FIXME: there is an slight chance for the irq handler to
- + * be running */
- + if (!list_empty(&ctx->list))
- + ezusb_ctx_complete(ctx);
- +
- + ezusb_request_context_put(ctx);
- + spin_lock_irqsave(&upriv->req_lock, flags);
- + }
- + spin_unlock_irqrestore(&upriv->req_lock, flags);
- +
- + list_for_each_safe(item, tmp_item, &upriv->req_pending)
- + ezusb_ctx_complete(list_entry(item,
- + struct request_context, list));
- +
- + if (upriv->read_urb && upriv->read_urb->status == -EINPROGRESS)
- + printk(KERN_ERR PFX "Some URB in progress\n");
- +
- + mutex_unlock(&upriv->mtx);
- +
- + if (upriv->read_urb) {
- + kfree(upriv->read_urb->transfer_buffer);
- + usb_free_urb(upriv->read_urb);
- + }
- + kfree(upriv->bap_buf);
- + if (upriv->dev) {
- + struct orinoco_private *priv = ndev_priv(upriv->dev);
- + orinoco_if_del(priv);
- + wiphy_unregister(priv_to_wiphy(upriv));
- + free_orinocodev(priv);
- + }
- +}
- +
- +static void ezusb_lock_irqsave(spinlock_t *lock,
- + unsigned long *flags) __acquires(lock)
- +{
- + spin_lock_bh(lock);
- +}
- +
- +static void ezusb_unlock_irqrestore(spinlock_t *lock,
- + unsigned long *flags) __releases(lock)
- +{
- + spin_unlock_bh(lock);
- +}
- +
- +static void ezusb_lock_irq(spinlock_t *lock) __acquires(lock)
- +{
- + spin_lock_bh(lock);
- +}
- +
- +static void ezusb_unlock_irq(spinlock_t *lock) __releases(lock)
- +{
- + spin_unlock_bh(lock);
- +}
- +
- +static const struct hermes_ops ezusb_ops = {
- + .init = ezusb_init,
- + .cmd_wait = ezusb_docmd_wait,
- + .init_cmd_wait = ezusb_doicmd_wait,
- + .allocate = ezusb_allocate,
- + .read_ltv = ezusb_read_ltv,
- + .read_ltv_pr = ezusb_read_ltv_preempt,
- + .write_ltv = ezusb_write_ltv,
- + .bap_pread = ezusb_bap_pread,
- + .read_pda = ezusb_read_pda,
- + .program_init = ezusb_program_init,
- + .program_end = ezusb_program_end,
- + .program = ezusb_program,
- + .lock_irqsave = ezusb_lock_irqsave,
- + .unlock_irqrestore = ezusb_unlock_irqrestore,
- + .lock_irq = ezusb_lock_irq,
- + .unlock_irq = ezusb_unlock_irq,
- +};
- +
- +static const struct net_device_ops ezusb_netdev_ops = {
- + .ndo_open = orinoco_open,
- + .ndo_stop = orinoco_stop,
- + .ndo_start_xmit = ezusb_xmit,
- + .ndo_set_rx_mode = orinoco_set_multicast_list,
- + .ndo_change_mtu = orinoco_change_mtu,
- + .ndo_set_mac_address = eth_mac_addr,
- + .ndo_validate_addr = eth_validate_addr,
- + .ndo_tx_timeout = orinoco_tx_timeout,
- +};
- +
- +static int ezusb_probe(struct usb_interface *interface,
- + const struct usb_device_id *id)
- +{
- + struct usb_device *udev = interface_to_usbdev(interface);
- + struct orinoco_private *priv;
- + struct hermes *hw;
- + struct ezusb_priv *upriv = NULL;
- + struct usb_interface_descriptor *iface_desc;
- + struct usb_endpoint_descriptor *ep;
- + const struct firmware *fw_entry = NULL;
- + int retval = 0;
- + int i;
- +
- + priv = alloc_orinocodev(sizeof(*upriv), &udev->dev,
- + ezusb_hard_reset, NULL);
- + if (!priv) {
- + err("Couldn't allocate orinocodev");
- + retval = -ENOMEM;
- + goto exit;
- + }
- +
- + hw = &priv->hw;
- +
- + upriv = priv->card;
- +
- + mutex_init(&upriv->mtx);
- + spin_lock_init(&upriv->reply_count_lock);
- +
- + spin_lock_init(&upriv->req_lock);
- + INIT_LIST_HEAD(&upriv->req_pending);
- + INIT_LIST_HEAD(&upriv->req_active);
- +
- + upriv->udev = udev;
- +
- + hw->iobase = (void __force __iomem *) &upriv->hermes_reg_fake;
- + hw->reg_spacing = HERMES_16BIT_REGSPACING;
- + hw->priv = upriv;
- + hw->ops = &ezusb_ops;
- +
- + /* set up the endpoint information */
- + /* check out the endpoints */
- +
- + iface_desc = &interface->cur_altsetting->desc;
- + for (i = 0; i < iface_desc->bNumEndpoints; ++i) {
- + ep = &interface->cur_altsetting->endpoint[i].desc;
- +
- + if (usb_endpoint_is_bulk_in(ep)) {
- + /* we found a bulk in endpoint */
- + if (upriv->read_urb != NULL) {
- + pr_warn("Found a second bulk in ep, ignored\n");
- + continue;
- + }
- +
- + upriv->read_urb = usb_alloc_urb(0, GFP_KERNEL);
- + if (!upriv->read_urb)
- + goto error;
- + if (le16_to_cpu(ep->wMaxPacketSize) != 64)
- + pr_warn("bulk in: wMaxPacketSize!= 64\n");
- + if (ep->bEndpointAddress != (2 | USB_DIR_IN))
- + pr_warn("bulk in: bEndpointAddress: %d\n",
- + ep->bEndpointAddress);
- + upriv->read_pipe = usb_rcvbulkpipe(udev,
- + ep->
- + bEndpointAddress);
- + upriv->read_urb->transfer_buffer =
- + kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
- + if (!upriv->read_urb->transfer_buffer) {
- + err("Couldn't allocate IN buffer");
- + goto error;
- + }
- + }
- +
- + if (usb_endpoint_is_bulk_out(ep)) {
- + /* we found a bulk out endpoint */
- + if (upriv->bap_buf != NULL) {
- + pr_warn("Found a second bulk out ep, ignored\n");
- + continue;
- + }
- +
- + if (le16_to_cpu(ep->wMaxPacketSize) != 64)
- + pr_warn("bulk out: wMaxPacketSize != 64\n");
- + if (ep->bEndpointAddress != 2)
- + pr_warn("bulk out: bEndpointAddress: %d\n",
- + ep->bEndpointAddress);
- + upriv->write_pipe = usb_sndbulkpipe(udev,
- + ep->
- + bEndpointAddress);
- + upriv->bap_buf = kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
- + if (!upriv->bap_buf) {
- + err("Couldn't allocate bulk_out_buffer");
- + goto error;
- + }
- + }
- + }
- + if (!upriv->bap_buf || !upriv->read_urb) {
- + err("Didn't find the required bulk endpoints");
- + goto error;
- + }
- +
- + if (request_firmware(&fw_entry, "orinoco_ezusb_fw",
- + &interface->dev) == 0) {
- + firmware.size = fw_entry->size;
- + firmware.code = fw_entry->data;
- + }
- + if (firmware.size && firmware.code) {
- + if (ezusb_firmware_download(upriv, &firmware) < 0)
- + goto error;
- + } else {
- + err("No firmware to download");
- + goto error;
- + }
- +
- + if (ezusb_hard_reset(priv) < 0) {
- + err("Cannot reset the device");
- + goto error;
- + }
- +
- + /* If the firmware is already downloaded orinoco.c will call
- + * ezusb_init but if the firmware is not already there, that will make
- + * the kernel very unstable, so we try initializing here and quit in
- + * case of error */
- + if (ezusb_init(hw) < 0) {
- + err("Couldn't initialize the device");
- + err("Firmware may not be downloaded or may be wrong.");
- + goto error;
- + }
- +
- + /* Initialise the main driver */
- + if (orinoco_init(priv) != 0) {
- + err("orinoco_init() failed\n");
- + goto error;
- + }
- +
- + if (orinoco_if_add(priv, 0, 0, &ezusb_netdev_ops) != 0) {
- + upriv->dev = NULL;
- + err("%s: orinoco_if_add() failed", __func__);
- + wiphy_unregister(priv_to_wiphy(priv));
- + goto error;
- + }
- + upriv->dev = priv->ndev;
- +
- + goto exit;
- +
- + error:
- + ezusb_delete(upriv);
- + if (upriv->dev) {
- + /* upriv->dev was 0, so ezusb_delete() didn't free it */
- + free_orinocodev(priv);
- + }
- + upriv = NULL;
- + retval = -EFAULT;
- + exit:
- + if (fw_entry) {
- + firmware.code = NULL;
- + firmware.size = 0;
- + release_firmware(fw_entry);
- + }
- + usb_set_intfdata(interface, upriv);
- + return retval;
- +}
- +
- +
- +static void ezusb_disconnect(struct usb_interface *intf)
- +{
- + struct ezusb_priv *upriv = usb_get_intfdata(intf);
- + usb_set_intfdata(intf, NULL);
- + ezusb_delete(upriv);
- + printk(KERN_INFO PFX "Disconnected\n");
- +}
- +
- +
- +/* usb specific object needed to register this driver with the usb subsystem */
- +static struct usb_driver orinoco_driver = {
- + .name = DRIVER_NAME,
- + .probe = ezusb_probe,
- + .disconnect = ezusb_disconnect,
- + .id_table = ezusb_table,
- + .disable_hub_initiated_lpm = 1,
- +};
- +
- +module_usb_driver(orinoco_driver);
- +
- +MODULE_AUTHOR("Manuel Estrada Sainz");
- +MODULE_DESCRIPTION("Driver for Orinoco wireless LAN cards using EZUSB bridge");
- +MODULE_LICENSE("Dual MPL/GPL");
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/scan.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/scan.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/scan.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/scan.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,259 @@
- +/* Helpers for managing scan queues
- + *
- + * See copyright notice in main.c
- + */
- +
- +#include <linux/gfp.h>
- +#include <linux/kernel.h>
- +#include <linux/string.h>
- +#include <linux/ieee80211.h>
- +#include <net/cfg80211.h>
- +
- +#include "hermes.h"
- +#include "orinoco.h"
- +#include "main.h"
- +
- +#include "scan.h"
- +
- +#define ZERO_DBM_OFFSET 0x95
- +#define MAX_SIGNAL_LEVEL 0x8A
- +#define MIN_SIGNAL_LEVEL 0x2F
- +
- +#define SIGNAL_TO_DBM(x) \
- + (clamp_t(s32, (x), MIN_SIGNAL_LEVEL, MAX_SIGNAL_LEVEL) \
- + - ZERO_DBM_OFFSET)
- +#define SIGNAL_TO_MBM(x) (SIGNAL_TO_DBM(x) * 100)
- +
- +static int symbol_build_supp_rates(u8 *buf, const __le16 *rates)
- +{
- + int i;
- + u8 rate;
- +
- + buf[0] = WLAN_EID_SUPP_RATES;
- + for (i = 0; i < 5; i++) {
- + rate = le16_to_cpu(rates[i]);
- + /* NULL terminated */
- + if (rate == 0x0)
- + break;
- + buf[i + 2] = rate;
- + }
- + buf[1] = i;
- +
- + return i + 2;
- +}
- +
- +static int prism_build_supp_rates(u8 *buf, const u8 *rates)
- +{
- + int i;
- +
- + buf[0] = WLAN_EID_SUPP_RATES;
- + for (i = 0; i < 8; i++) {
- + /* NULL terminated */
- + if (rates[i] == 0x0)
- + break;
- + buf[i + 2] = rates[i];
- + }
- + buf[1] = i;
- +
- + /* We might still have another 2 rates, which need to go in
- + * extended supported rates */
- + if (i == 8 && rates[i] > 0) {
- + buf[10] = WLAN_EID_EXT_SUPP_RATES;
- + for (; i < 10; i++) {
- + /* NULL terminated */
- + if (rates[i] == 0x0)
- + break;
- + buf[i + 2] = rates[i];
- + }
- + buf[11] = i - 8;
- + }
- +
- + return (i < 8) ? i + 2 : i + 4;
- +}
- +
- +static void orinoco_add_hostscan_result(struct orinoco_private *priv,
- + const union hermes_scan_info *bss)
- +{
- + struct wiphy *wiphy = priv_to_wiphy(priv);
- + struct ieee80211_channel *channel;
- + struct cfg80211_bss *cbss;
- + u8 *ie;
- + u8 ie_buf[46];
- + u64 timestamp;
- + s32 signal;
- + u16 capability;
- + u16 beacon_interval;
- + int ie_len;
- + int freq;
- + int len;
- +
- + len = le16_to_cpu(bss->a.essid_len);
- +
- + /* Reconstruct SSID and bitrate IEs to pass up */
- + ie_buf[0] = WLAN_EID_SSID;
- + ie_buf[1] = len;
- + memcpy(&ie_buf[2], bss->a.essid, len);
- +
- + ie = ie_buf + len + 2;
- + ie_len = ie_buf[1] + 2;
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_SYMBOL:
- + ie_len += symbol_build_supp_rates(ie, bss->s.rates);
- + break;
- +
- + case FIRMWARE_TYPE_INTERSIL:
- + ie_len += prism_build_supp_rates(ie, bss->p.rates);
- + break;
- +
- + case FIRMWARE_TYPE_AGERE:
- + default:
- + break;
- + }
- +
- + freq = ieee80211_channel_to_frequency(
- + le16_to_cpu(bss->a.channel), NL80211_BAND_2GHZ);
- + channel = ieee80211_get_channel(wiphy, freq);
- + if (!channel) {
- + printk(KERN_DEBUG "Invalid channel designation %04X(%04X)",
- + bss->a.channel, freq);
- + return; /* Then ignore it for now */
- + }
- + timestamp = 0;
- + capability = le16_to_cpu(bss->a.capabilities);
- + beacon_interval = le16_to_cpu(bss->a.beacon_interv);
- + signal = SIGNAL_TO_MBM(le16_to_cpu(bss->a.level));
- +
- + cbss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN,
- + bss->a.bssid, timestamp, capability,
- + beacon_interval, ie_buf, ie_len, signal,
- + GFP_KERNEL);
- + cfg80211_put_bss(wiphy, cbss);
- +}
- +
- +void orinoco_add_extscan_result(struct orinoco_private *priv,
- + struct agere_ext_scan_info *bss,
- + size_t len)
- +{
- + struct wiphy *wiphy = priv_to_wiphy(priv);
- + struct ieee80211_channel *channel;
- + struct cfg80211_bss *cbss;
- + const u8 *ie;
- + u64 timestamp;
- + s32 signal;
- + u16 capability;
- + u16 beacon_interval;
- + size_t ie_len;
- + int chan, freq;
- +
- + ie_len = len - sizeof(*bss);
- + ie = cfg80211_find_ie(WLAN_EID_DS_PARAMS, bss->data, ie_len);
- + chan = ie ? ie[2] : 0;
- + freq = ieee80211_channel_to_frequency(chan, NL80211_BAND_2GHZ);
- + channel = ieee80211_get_channel(wiphy, freq);
- +
- + timestamp = le64_to_cpu(bss->timestamp);
- + capability = le16_to_cpu(bss->capabilities);
- + beacon_interval = le16_to_cpu(bss->beacon_interval);
- + ie = bss->data;
- + signal = SIGNAL_TO_MBM(bss->level);
- +
- + cbss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN,
- + bss->bssid, timestamp, capability,
- + beacon_interval, ie, ie_len, signal,
- + GFP_KERNEL);
- + cfg80211_put_bss(wiphy, cbss);
- +}
- +
- +void orinoco_add_hostscan_results(struct orinoco_private *priv,
- + unsigned char *buf,
- + size_t len)
- +{
- + int offset; /* In the scan data */
- + size_t atom_len;
- + bool abort = false;
- +
- + switch (priv->firmware_type) {
- + case FIRMWARE_TYPE_AGERE:
- + atom_len = sizeof(struct agere_scan_apinfo);
- + offset = 0;
- + break;
- +
- + case FIRMWARE_TYPE_SYMBOL:
- + /* Lack of documentation necessitates this hack.
- + * Different firmwares have 68 or 76 byte long atoms.
- + * We try modulo first. If the length divides by both,
- + * we check what would be the channel in the second
- + * frame for a 68-byte atom. 76-byte atoms have 0 there.
- + * Valid channel cannot be 0. */
- + if (len % 76)
- + atom_len = 68;
- + else if (len % 68)
- + atom_len = 76;
- + else if (len >= 1292 && buf[68] == 0)
- + atom_len = 76;
- + else
- + atom_len = 68;
- + offset = 0;
- + break;
- +
- + case FIRMWARE_TYPE_INTERSIL:
- + offset = 4;
- + if (priv->has_hostscan) {
- + atom_len = le16_to_cpup((__le16 *)buf);
- + /* Sanity check for atom_len */
- + if (atom_len < sizeof(struct prism2_scan_apinfo)) {
- + printk(KERN_ERR "%s: Invalid atom_len in scan "
- + "data: %zu\n", priv->ndev->name,
- + atom_len);
- + abort = true;
- + goto scan_abort;
- + }
- + } else
- + atom_len = offsetof(struct prism2_scan_apinfo, atim);
- + break;
- +
- + default:
- + abort = true;
- + goto scan_abort;
- + }
- +
- + /* Check that we got an whole number of atoms */
- + if ((len - offset) % atom_len) {
- + printk(KERN_ERR "%s: Unexpected scan data length %zu, "
- + "atom_len %zu, offset %d\n", priv->ndev->name, len,
- + atom_len, offset);
- + abort = true;
- + goto scan_abort;
- + }
- +
- + /* Process the entries one by one */
- + for (; offset + atom_len <= len; offset += atom_len) {
- + union hermes_scan_info *atom;
- +
- + atom = (union hermes_scan_info *) (buf + offset);
- +
- + orinoco_add_hostscan_result(priv, atom);
- + }
- +
- + scan_abort:
- + if (priv->scan_request) {
- + struct cfg80211_scan_info info = {
- + .aborted = abort,
- + };
- +
- + cfg80211_scan_done(priv->scan_request, &info);
- + priv->scan_request = NULL;
- + }
- +}
- +
- +void orinoco_scan_done(struct orinoco_private *priv, bool abort)
- +{
- + if (priv->scan_request) {
- + struct cfg80211_scan_info info = {
- + .aborted = abort,
- + };
- +
- + cfg80211_scan_done(priv->scan_request, &info);
- + priv->scan_request = NULL;
- + }
- +}
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/scan.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/scan.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/scan.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/scan.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,21 @@
- +/* Helpers for managing scan queues
- + *
- + * See copyright notice in main.c
- + */
- +#ifndef _ORINOCO_SCAN_H_
- +#define _ORINOCO_SCAN_H_
- +
- +/* Forward declarations */
- +struct orinoco_private;
- +struct agere_ext_scan_info;
- +
- +/* Add scan results */
- +void orinoco_add_extscan_result(struct orinoco_private *priv,
- + struct agere_ext_scan_info *atom,
- + size_t len);
- +void orinoco_add_hostscan_results(struct orinoco_private *dev,
- + unsigned char *buf,
- + size_t len);
- +void orinoco_scan_done(struct orinoco_private *priv, bool abort);
- +
- +#endif /* _ORINOCO_SCAN_H_ */
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/spectrum_cs.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/spectrum_cs.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/spectrum_cs.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/spectrum_cs.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,328 @@
- +/*
- + * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as
- + * Symbol Wireless Networker LA4137, CompactFlash cards by Socket
- + * Communications and Intel PRO/Wireless 2011B.
- + *
- + * The driver implements Symbol firmware download. The rest is handled
- + * in hermes.c and main.c.
- + *
- + * Utilities for downloading the Symbol firmware are available at
- + * http://sourceforge.net/projects/orinoco/
- + *
- + * Copyright (C) 2002-2005 Pavel Roskin <proski@gnu.org>
- + * Portions based on orinoco_cs.c:
- + * Copyright (C) David Gibson, Linuxcare Australia
- + * Portions based on Spectrum24tDnld.c from original spectrum24 driver:
- + * Copyright (C) Symbol Technologies.
- + *
- + * See copyright notice in file main.c.
- + */
- +
- +#define DRIVER_NAME "spectrum_cs"
- +#define PFX DRIVER_NAME ": "
- +
- +#include <linux/module.h>
- +#include <linux/kernel.h>
- +#include <linux/delay.h>
- +#include <pcmcia/cistpl.h>
- +#include <pcmcia/cisreg.h>
- +#include <pcmcia/ds.h>
- +
- +#include "orinoco.h"
- +
- +/********************************************************************/
- +/* Module stuff */
- +/********************************************************************/
- +
- +MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
- +MODULE_DESCRIPTION("Driver for Symbol Spectrum24 Trilogy cards with firmware downloader");
- +MODULE_LICENSE("Dual MPL/GPL");
- +
- +/* Module parameters */
- +
- +/* Some D-Link cards have buggy CIS. They do work at 5v properly, but
- + * don't have any CIS entry for it. This workaround it... */
- +static int ignore_cis_vcc; /* = 0 */
- +module_param(ignore_cis_vcc, int, 0);
- +MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
- +
- +/********************************************************************/
- +/* Data structures */
- +/********************************************************************/
- +
- +/* PCMCIA specific device information (goes in the card field of
- + * struct orinoco_private */
- +struct orinoco_pccard {
- + struct pcmcia_device *p_dev;
- +};
- +
- +/********************************************************************/
- +/* Function prototypes */
- +/********************************************************************/
- +
- +static int spectrum_cs_config(struct pcmcia_device *link);
- +static void spectrum_cs_release(struct pcmcia_device *link);
- +
- +/* Constants for the CISREG_CCSR register */
- +#define HCR_RUN 0x07 /* run firmware after reset */
- +#define HCR_IDLE 0x0E /* don't run firmware after reset */
- +#define HCR_MEM16 0x10 /* memory width bit, should be preserved */
- +
- +
- +/*
- + * Reset the card using configuration registers COR and CCSR.
- + * If IDLE is 1, stop the firmware, so that it can be safely rewritten.
- + */
- +static int
- +spectrum_reset(struct pcmcia_device *link, int idle)
- +{
- + int ret;
- + u8 save_cor;
- + u8 ccsr;
- +
- + /* Doing it if hardware is gone is guaranteed crash */
- + if (!pcmcia_dev_present(link))
- + return -ENODEV;
- +
- + /* Save original COR value */
- + ret = pcmcia_read_config_byte(link, CISREG_COR, &save_cor);
- + if (ret)
- + goto failed;
- +
- + /* Soft-Reset card */
- + ret = pcmcia_write_config_byte(link, CISREG_COR,
- + (save_cor | COR_SOFT_RESET));
- + if (ret)
- + goto failed;
- + udelay(1000);
- +
- + /* Read CCSR */
- + ret = pcmcia_read_config_byte(link, CISREG_CCSR, &ccsr);
- + if (ret)
- + goto failed;
- +
- + /*
- + * Start or stop the firmware. Memory width bit should be
- + * preserved from the value we've just read.
- + */
- + ccsr = (idle ? HCR_IDLE : HCR_RUN) | (ccsr & HCR_MEM16);
- + ret = pcmcia_write_config_byte(link, CISREG_CCSR, ccsr);
- + if (ret)
- + goto failed;
- + udelay(1000);
- +
- + /* Restore original COR configuration index */
- + ret = pcmcia_write_config_byte(link, CISREG_COR,
- + (save_cor & ~COR_SOFT_RESET));
- + if (ret)
- + goto failed;
- + udelay(1000);
- + return 0;
- +
- +failed:
- + return -ENODEV;
- +}
- +
- +/********************************************************************/
- +/* Device methods */
- +/********************************************************************/
- +
- +static int
- +spectrum_cs_hard_reset(struct orinoco_private *priv)
- +{
- + struct orinoco_pccard *card = priv->card;
- + struct pcmcia_device *link = card->p_dev;
- +
- + /* Soft reset using COR and HCR */
- + spectrum_reset(link, 0);
- +
- + return 0;
- +}
- +
- +static int
- +spectrum_cs_stop_firmware(struct orinoco_private *priv, int idle)
- +{
- + struct orinoco_pccard *card = priv->card;
- + struct pcmcia_device *link = card->p_dev;
- +
- + return spectrum_reset(link, idle);
- +}
- +
- +/********************************************************************/
- +/* PCMCIA stuff */
- +/********************************************************************/
- +
- +static int
- +spectrum_cs_probe(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv;
- + struct orinoco_pccard *card;
- + int ret;
- +
- + priv = alloc_orinocodev(sizeof(*card), &link->dev,
- + spectrum_cs_hard_reset,
- + spectrum_cs_stop_firmware);
- + if (!priv)
- + return -ENOMEM;
- + card = priv->card;
- +
- + /* Link both structures together */
- + card->p_dev = link;
- + link->priv = priv;
- +
- + ret = spectrum_cs_config(link);
- + if (ret)
- + goto err_free_orinocodev;
- +
- + return 0;
- +
- +err_free_orinocodev:
- + free_orinocodev(priv);
- + return ret;
- +}
- +
- +static void spectrum_cs_detach(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- +
- + orinoco_if_del(priv);
- +
- + spectrum_cs_release(link);
- +
- + free_orinocodev(priv);
- +} /* spectrum_cs_detach */
- +
- +static int spectrum_cs_config_check(struct pcmcia_device *p_dev,
- + void *priv_data)
- +{
- + if (p_dev->config_index == 0)
- + return -EINVAL;
- +
- + return pcmcia_request_io(p_dev);
- +};
- +
- +static int
- +spectrum_cs_config(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- + struct hermes *hw = &priv->hw;
- + int ret;
- + void __iomem *mem;
- +
- + link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC |
- + CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
- + if (ignore_cis_vcc)
- + link->config_flags &= ~CONF_AUTO_CHECK_VCC;
- + ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL);
- + if (ret) {
- + if (!ignore_cis_vcc)
- + printk(KERN_ERR PFX "GetNextTuple(): No matching "
- + "CIS configuration. Maybe you need the "
- + "ignore_cis_vcc=1 parameter.\n");
- + goto failed;
- + }
- +
- + mem = ioport_map(link->resource[0]->start,
- + resource_size(link->resource[0]));
- + if (!mem)
- + goto failed;
- +
- + /* We initialize the hermes structure before completing PCMCIA
- + * configuration just in case the interrupt handler gets
- + * called. */
- + hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
- + hw->eeprom_pda = true;
- +
- + ret = pcmcia_request_irq(link, orinoco_interrupt);
- + if (ret)
- + goto failed;
- +
- + ret = pcmcia_enable_device(link);
- + if (ret)
- + goto failed;
- +
- + /* Reset card */
- + if (spectrum_cs_hard_reset(priv) != 0)
- + goto failed;
- +
- + /* Initialise the main driver */
- + if (orinoco_init(priv) != 0) {
- + printk(KERN_ERR PFX "orinoco_init() failed\n");
- + goto failed;
- + }
- +
- + /* Register an interface with the stack */
- + if (orinoco_if_add(priv, link->resource[0]->start,
- + link->irq, NULL) != 0) {
- + printk(KERN_ERR PFX "orinoco_if_add() failed\n");
- + goto failed;
- + }
- +
- + return 0;
- +
- + failed:
- + spectrum_cs_release(link);
- + return -ENODEV;
- +} /* spectrum_cs_config */
- +
- +static void
- +spectrum_cs_release(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- + unsigned long flags;
- +
- + /* We're committed to taking the device away now, so mark the
- + * hardware as unavailable */
- + priv->hw.ops->lock_irqsave(&priv->lock, &flags);
- + priv->hw_unavailable++;
- + priv->hw.ops->unlock_irqrestore(&priv->lock, &flags);
- +
- + pcmcia_disable_device(link);
- + if (priv->hw.iobase)
- + ioport_unmap(priv->hw.iobase);
- +} /* spectrum_cs_release */
- +
- +
- +static int
- +spectrum_cs_suspend(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- +
- + /* Mark the device as stopped, to block IO until later */
- + orinoco_down(priv);
- +
- + return 0;
- +}
- +
- +static int
- +spectrum_cs_resume(struct pcmcia_device *link)
- +{
- + struct orinoco_private *priv = link->priv;
- + int err = orinoco_up(priv);
- +
- + return err;
- +}
- +
- +
- +/********************************************************************/
- +/* Module initialization */
- +/********************************************************************/
- +
- +static const struct pcmcia_device_id spectrum_cs_ids[] = {
- + PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */
- + PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
- + PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */
- + PCMCIA_DEVICE_NULL,
- +};
- +MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids);
- +
- +static struct pcmcia_driver orinoco_driver = {
- + .owner = THIS_MODULE,
- + .name = DRIVER_NAME,
- + .probe = spectrum_cs_probe,
- + .remove = spectrum_cs_detach,
- + .suspend = spectrum_cs_suspend,
- + .resume = spectrum_cs_resume,
- + .id_table = spectrum_cs_ids,
- +};
- +module_pcmcia_driver(orinoco_driver);
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/wext.c linux-6.18.9/drivers/net/wireless/intersil/orinoco/wext.c
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/wext.c 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/wext.c 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,1415 @@
- +/* Wireless extensions support.
- + *
- + * See copyright notice in main.c
- + */
- +#include <linux/slab.h>
- +#include <linux/kernel.h>
- +#include <linux/if_arp.h>
- +#include <linux/wireless.h>
- +#include <linux/ieee80211.h>
- +#include <linux/etherdevice.h>
- +#include <net/iw_handler.h>
- +#include <net/cfg80211.h>
- +#include <net/cfg80211-wext.h>
- +
- +#include "hermes.h"
- +#include "hermes_rid.h"
- +#include "orinoco.h"
- +
- +#include "hw.h"
- +#include "mic.h"
- +#include "scan.h"
- +#include "main.h"
- +
- +#include "wext.h"
- +
- +#define MAX_RID_LEN 1024
- +
- +/* Helper routine to record keys
- + * It is called under orinoco_lock so it may not sleep */
- +static int orinoco_set_key(struct orinoco_private *priv, int index,
- + enum orinoco_alg alg, const u8 *key, int key_len,
- + const u8 *seq, int seq_len)
- +{
- + kfree_sensitive(priv->keys[index].key);
- + kfree_sensitive(priv->keys[index].seq);
- +
- + if (key_len) {
- + priv->keys[index].key = kzalloc(key_len, GFP_ATOMIC);
- + if (!priv->keys[index].key)
- + goto nomem;
- + } else
- + priv->keys[index].key = NULL;
- +
- + if (seq_len) {
- + priv->keys[index].seq = kzalloc(seq_len, GFP_ATOMIC);
- + if (!priv->keys[index].seq)
- + goto free_key;
- + } else
- + priv->keys[index].seq = NULL;
- +
- + priv->keys[index].key_len = key_len;
- + priv->keys[index].seq_len = seq_len;
- +
- + if (key_len)
- + memcpy((void *)priv->keys[index].key, key, key_len);
- + if (seq_len)
- + memcpy((void *)priv->keys[index].seq, seq, seq_len);
- +
- + switch (alg) {
- + case ORINOCO_ALG_TKIP:
- + priv->keys[index].cipher = WLAN_CIPHER_SUITE_TKIP;
- + break;
- +
- + case ORINOCO_ALG_WEP:
- + priv->keys[index].cipher = (key_len > SMALL_KEY_SIZE) ?
- + WLAN_CIPHER_SUITE_WEP104 : WLAN_CIPHER_SUITE_WEP40;
- + break;
- +
- + case ORINOCO_ALG_NONE:
- + default:
- + priv->keys[index].cipher = 0;
- + break;
- + }
- +
- + return 0;
- +
- +free_key:
- + kfree(priv->keys[index].key);
- + priv->keys[index].key = NULL;
- +
- +nomem:
- + priv->keys[index].key_len = 0;
- + priv->keys[index].seq_len = 0;
- + priv->keys[index].cipher = 0;
- +
- + return -ENOMEM;
- +}
- +
- +static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct hermes *hw = &priv->hw;
- + struct iw_statistics *wstats = &priv->wstats;
- + int err;
- + unsigned long flags;
- +
- + if (!netif_device_present(dev)) {
- + printk(KERN_WARNING "%s: get_wireless_stats() called while device not present\n",
- + dev->name);
- + return NULL; /* FIXME: Can we do better than this? */
- + }
- +
- + /* If busy, return the old stats. Returning NULL may cause
- + * the interface to disappear from /proc/net/wireless */
- + if (orinoco_lock(priv, &flags) != 0)
- + return wstats;
- +
- + /* We can't really wait for the tallies inquiry command to
- + * complete, so we just use the previous results and trigger
- + * a new tallies inquiry command for next time - Jean II */
- + /* FIXME: Really we should wait for the inquiry to come back -
- + * as it is the stats we give don't make a whole lot of sense.
- + * Unfortunately, it's not clear how to do that within the
- + * wireless extensions framework: I think we're in user
- + * context, but a lock seems to be held by the time we get in
- + * here so we're not safe to sleep here. */
- + hermes_inquire(hw, HERMES_INQ_TALLIES);
- +
- + if (priv->iw_mode == NL80211_IFTYPE_ADHOC) {
- + memset(&wstats->qual, 0, sizeof(wstats->qual));
- + } else {
- + struct {
- + __le16 qual, signal, noise, unused;
- + } __packed cq;
- +
- + err = HERMES_READ_RECORD(hw, USER_BAP,
- + HERMES_RID_COMMSQUALITY, &cq);
- +
- + if (!err) {
- + wstats->qual.qual = (int)le16_to_cpu(cq.qual);
- + wstats->qual.level = (int)le16_to_cpu(cq.signal) - 0x95;
- + wstats->qual.noise = (int)le16_to_cpu(cq.noise) - 0x95;
- + wstats->qual.updated =
- + IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
- + }
- + }
- +
- + orinoco_unlock(priv, &flags);
- + return wstats;
- +}
- +
- +/********************************************************************/
- +/* Wireless extensions */
- +/********************************************************************/
- +
- +static int orinoco_ioctl_setwap(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct sockaddr *ap_addr = &wrqu->ap_addr;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int err = -EINPROGRESS; /* Call commit handler */
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + /* Enable automatic roaming - no sanity checks are needed */
- + if (is_zero_ether_addr(ap_addr->sa_data) ||
- + is_broadcast_ether_addr(ap_addr->sa_data)) {
- + priv->bssid_fixed = 0;
- + eth_zero_addr(priv->desired_bssid);
- +
- + /* "off" means keep existing connection */
- + if (ap_addr->sa_data[0] == 0) {
- + __orinoco_hw_set_wap(priv);
- + err = 0;
- + }
- + goto out;
- + }
- +
- + if (priv->firmware_type == FIRMWARE_TYPE_AGERE) {
- + printk(KERN_WARNING "%s: Lucent/Agere firmware doesn't "
- + "support manual roaming\n",
- + dev->name);
- + err = -EOPNOTSUPP;
- + goto out;
- + }
- +
- + if (priv->iw_mode != NL80211_IFTYPE_STATION) {
- + printk(KERN_WARNING "%s: Manual roaming supported only in "
- + "managed mode\n", dev->name);
- + err = -EOPNOTSUPP;
- + goto out;
- + }
- +
- + /* Intersil firmware hangs without Desired ESSID */
- + if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL &&
- + strlen(priv->desired_essid) == 0) {
- + printk(KERN_WARNING "%s: Desired ESSID must be set for "
- + "manual roaming\n", dev->name);
- + err = -EOPNOTSUPP;
- + goto out;
- + }
- +
- + /* Finally, enable manual roaming */
- + priv->bssid_fixed = 1;
- + memcpy(priv->desired_bssid, &ap_addr->sa_data, ETH_ALEN);
- +
- + out:
- + orinoco_unlock(priv, &flags);
- + return err;
- +}
- +
- +static int orinoco_ioctl_getwap(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct sockaddr *ap_addr = &wrqu->ap_addr;
- + struct orinoco_private *priv = ndev_priv(dev);
- +
- + int err = 0;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + ap_addr->sa_family = ARPHRD_ETHER;
- + err = orinoco_hw_get_current_bssid(priv, ap_addr->sa_data);
- +
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_setiwencode(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *keybuf)
- +{
- + struct iw_point *erq = &wrqu->encoding;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int index = (erq->flags & IW_ENCODE_INDEX) - 1;
- + int setindex = priv->tx_key;
- + enum orinoco_alg encode_alg = priv->encode_alg;
- + int restricted = priv->wep_restrict;
- + int err = -EINPROGRESS; /* Call commit handler */
- + unsigned long flags;
- +
- + if (!priv->has_wep)
- + return -EOPNOTSUPP;
- +
- + if (erq->pointer) {
- + /* We actually have a key to set - check its length */
- + if (erq->length > LARGE_KEY_SIZE)
- + return -E2BIG;
- +
- + if ((erq->length > SMALL_KEY_SIZE) && !priv->has_big_wep)
- + return -E2BIG;
- + }
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + /* Clear any TKIP key we have */
- + if ((priv->has_wpa) && (priv->encode_alg == ORINOCO_ALG_TKIP))
- + (void) orinoco_clear_tkip_key(priv, setindex);
- +
- + if (erq->length > 0) {
- + if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
- + index = priv->tx_key;
- +
- + /* Switch on WEP if off */
- + if (encode_alg != ORINOCO_ALG_WEP) {
- + setindex = index;
- + encode_alg = ORINOCO_ALG_WEP;
- + }
- + } else {
- + /* Important note : if the user do "iwconfig eth0 enc off",
- + * we will arrive there with an index of -1. This is valid
- + * but need to be taken care off... Jean II */
- + if ((index < 0) || (index >= ORINOCO_MAX_KEYS)) {
- + if ((index != -1) || (erq->flags == 0)) {
- + err = -EINVAL;
- + goto out;
- + }
- + } else {
- + /* Set the index : Check that the key is valid */
- + if (priv->keys[index].key_len == 0) {
- + err = -EINVAL;
- + goto out;
- + }
- + setindex = index;
- + }
- + }
- +
- + if (erq->flags & IW_ENCODE_DISABLED)
- + encode_alg = ORINOCO_ALG_NONE;
- + if (erq->flags & IW_ENCODE_OPEN)
- + restricted = 0;
- + if (erq->flags & IW_ENCODE_RESTRICTED)
- + restricted = 1;
- +
- + if (erq->pointer && erq->length > 0) {
- + err = orinoco_set_key(priv, index, ORINOCO_ALG_WEP, keybuf,
- + erq->length, NULL, 0);
- + }
- + priv->tx_key = setindex;
- +
- + /* Try fast key change if connected and only keys are changed */
- + if ((priv->encode_alg == encode_alg) &&
- + (priv->wep_restrict == restricted) &&
- + netif_carrier_ok(dev)) {
- + err = __orinoco_hw_setup_wepkeys(priv);
- + /* No need to commit if successful */
- + goto out;
- + }
- +
- + priv->encode_alg = encode_alg;
- + priv->wep_restrict = restricted;
- +
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_getiwencode(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *keybuf)
- +{
- + struct iw_point *erq = &wrqu->encoding;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int index = (erq->flags & IW_ENCODE_INDEX) - 1;
- + unsigned long flags;
- +
- + if (!priv->has_wep)
- + return -EOPNOTSUPP;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + if ((index < 0) || (index >= ORINOCO_MAX_KEYS))
- + index = priv->tx_key;
- +
- + erq->flags = 0;
- + if (!priv->encode_alg)
- + erq->flags |= IW_ENCODE_DISABLED;
- + erq->flags |= index + 1;
- +
- + if (priv->wep_restrict)
- + erq->flags |= IW_ENCODE_RESTRICTED;
- + else
- + erq->flags |= IW_ENCODE_OPEN;
- +
- + erq->length = priv->keys[index].key_len;
- +
- + memcpy(keybuf, priv->keys[index].key, erq->length);
- +
- + orinoco_unlock(priv, &flags);
- + return 0;
- +}
- +
- +static int orinoco_ioctl_setessid(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *essidbuf)
- +{
- + struct iw_point *erq = &wrqu->essid;
- + struct orinoco_private *priv = ndev_priv(dev);
- + unsigned long flags;
- +
- + /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it
- + * anyway... - Jean II */
- +
- + /* Hum... Should not use Wireless Extension constant (may change),
- + * should use our own... - Jean II */
- + if (erq->length > IW_ESSID_MAX_SIZE)
- + return -E2BIG;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + /* NULL the string (for NULL termination & ESSID = ANY) - Jean II */
- + memset(priv->desired_essid, 0, sizeof(priv->desired_essid));
- +
- + /* If not ANY, get the new ESSID */
- + if (erq->flags)
- + memcpy(priv->desired_essid, essidbuf, erq->length);
- +
- + orinoco_unlock(priv, &flags);
- +
- + return -EINPROGRESS; /* Call commit handler */
- +}
- +
- +static int orinoco_ioctl_getessid(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *essidbuf)
- +{
- + struct iw_point *erq = &wrqu->essid;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int active;
- + int err = 0;
- + unsigned long flags;
- +
- + if (netif_running(dev)) {
- + err = orinoco_hw_get_essid(priv, &active, essidbuf);
- + if (err < 0)
- + return err;
- + erq->length = err;
- + } else {
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- + memcpy(essidbuf, priv->desired_essid, IW_ESSID_MAX_SIZE);
- + erq->length = strlen(priv->desired_essid);
- + orinoco_unlock(priv, &flags);
- + }
- +
- + erq->flags = 1;
- +
- + return 0;
- +}
- +
- +static int orinoco_ioctl_setfreq(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_freq *frq = &wrqu->freq;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int chan = -1;
- + unsigned long flags;
- + int err = -EINPROGRESS; /* Call commit handler */
- +
- + /* In infrastructure mode the AP sets the channel */
- + if (priv->iw_mode == NL80211_IFTYPE_STATION)
- + return -EBUSY;
- +
- + if ((frq->e == 0) && (frq->m <= 1000)) {
- + /* Setting by channel number */
- + chan = frq->m;
- + } else {
- + /* Setting by frequency */
- + int denom = 1;
- + int i;
- +
- + /* Calculate denominator to rescale to MHz */
- + for (i = 0; i < (6 - frq->e); i++)
- + denom *= 10;
- +
- + chan = ieee80211_frequency_to_channel(frq->m / denom);
- + }
- +
- + if ((chan < 1) || (chan > NUM_CHANNELS) ||
- + !(priv->channel_mask & (1 << (chan - 1))))
- + return -EINVAL;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + priv->channel = chan;
- + if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
- + /* Fast channel change - no commit if successful */
- + struct hermes *hw = &priv->hw;
- + err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
- + HERMES_TEST_SET_CHANNEL,
- + chan, NULL);
- + }
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_getfreq(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_freq *frq = &wrqu->freq;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int tmp;
- +
- + /* Locking done in there */
- + tmp = orinoco_hw_get_freq(priv);
- + if (tmp < 0)
- + return tmp;
- +
- + frq->m = tmp * 100000;
- + frq->e = 1;
- +
- + return 0;
- +}
- +
- +static int orinoco_ioctl_getsens(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_param *srq = &wrqu->sens;
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct hermes *hw = &priv->hw;
- + u16 val;
- + int err;
- + unsigned long flags;
- +
- + if (!priv->has_sensitivity)
- + return -EOPNOTSUPP;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- + err = hermes_read_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFSYSTEMSCALE, &val);
- + orinoco_unlock(priv, &flags);
- +
- + if (err)
- + return err;
- +
- + srq->value = val;
- + srq->fixed = 0; /* auto */
- +
- + return 0;
- +}
- +
- +static int orinoco_ioctl_setsens(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_param *srq = &wrqu->sens;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int val = srq->value;
- + unsigned long flags;
- +
- + if (!priv->has_sensitivity)
- + return -EOPNOTSUPP;
- +
- + if ((val < 1) || (val > 3))
- + return -EINVAL;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- + priv->ap_density = val;
- + orinoco_unlock(priv, &flags);
- +
- + return -EINPROGRESS; /* Call commit handler */
- +}
- +
- +static int orinoco_ioctl_setrate(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_param *rrq = &wrqu->bitrate;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int ratemode;
- + int bitrate; /* 100s of kilobits */
- + unsigned long flags;
- +
- + /* As the user space doesn't know our highest rate, it uses -1
- + * to ask us to set the highest rate. Test it using "iwconfig
- + * ethX rate auto" - Jean II */
- + if (rrq->value == -1)
- + bitrate = 110;
- + else {
- + if (rrq->value % 100000)
- + return -EINVAL;
- + bitrate = rrq->value / 100000;
- + }
- +
- + ratemode = orinoco_get_bitratemode(bitrate, !rrq->fixed);
- +
- + if (ratemode == -1)
- + return -EINVAL;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- + priv->bitratemode = ratemode;
- + orinoco_unlock(priv, &flags);
- +
- + return -EINPROGRESS;
- +}
- +
- +static int orinoco_ioctl_getrate(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_param *rrq = &wrqu->bitrate;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int err = 0;
- + int bitrate, automatic;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + orinoco_get_ratemode_cfg(priv->bitratemode, &bitrate, &automatic);
- +
- + /* If the interface is running we try to find more about the
- + current mode */
- + if (netif_running(dev)) {
- + int act_bitrate;
- + int lerr;
- +
- + /* Ignore errors if we can't get the actual bitrate */
- + lerr = orinoco_hw_get_act_bitrate(priv, &act_bitrate);
- + if (!lerr)
- + bitrate = act_bitrate;
- + }
- +
- + orinoco_unlock(priv, &flags);
- +
- + rrq->value = bitrate;
- + rrq->fixed = !automatic;
- + rrq->disabled = 0;
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_setpower(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_param *prq = &wrqu->power;
- + struct orinoco_private *priv = ndev_priv(dev);
- + int err = -EINPROGRESS; /* Call commit handler */
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + if (prq->disabled) {
- + priv->pm_on = 0;
- + } else {
- + switch (prq->flags & IW_POWER_MODE) {
- + case IW_POWER_UNICAST_R:
- + priv->pm_mcast = 0;
- + priv->pm_on = 1;
- + break;
- + case IW_POWER_ALL_R:
- + priv->pm_mcast = 1;
- + priv->pm_on = 1;
- + break;
- + case IW_POWER_ON:
- + /* No flags : but we may have a value - Jean II */
- + break;
- + default:
- + err = -EINVAL;
- + goto out;
- + }
- +
- + if (prq->flags & IW_POWER_TIMEOUT) {
- + priv->pm_on = 1;
- + priv->pm_timeout = prq->value / 1000;
- + }
- + if (prq->flags & IW_POWER_PERIOD) {
- + priv->pm_on = 1;
- + priv->pm_period = prq->value / 1000;
- + }
- + /* It's valid to not have a value if we are just toggling
- + * the flags... Jean II */
- + if (!priv->pm_on) {
- + err = -EINVAL;
- + goto out;
- + }
- + }
- +
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_getpower(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_param *prq = &wrqu->power;
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct hermes *hw = &priv->hw;
- + int err = 0;
- + u16 enable, period, timeout, mcast;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + err = hermes_read_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFPMENABLED, &enable);
- + if (err)
- + goto out;
- +
- + err = hermes_read_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFMAXSLEEPDURATION, &period);
- + if (err)
- + goto out;
- +
- + err = hermes_read_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFPMHOLDOVERDURATION, &timeout);
- + if (err)
- + goto out;
- +
- + err = hermes_read_wordrec(hw, USER_BAP,
- + HERMES_RID_CNFMULTICASTRECEIVE, &mcast);
- + if (err)
- + goto out;
- +
- + prq->disabled = !enable;
- + /* Note : by default, display the period */
- + if ((prq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
- + prq->flags = IW_POWER_TIMEOUT;
- + prq->value = timeout * 1000;
- + } else {
- + prq->flags = IW_POWER_PERIOD;
- + prq->value = period * 1000;
- + }
- + if (mcast)
- + prq->flags |= IW_POWER_ALL_R;
- + else
- + prq->flags |= IW_POWER_UNICAST_R;
- +
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_set_encodeext(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct iw_point *encoding = &wrqu->encoding;
- + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- + int idx, alg = ext->alg, set_key = 1;
- + unsigned long flags;
- + int err = -EINVAL;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + /* Determine and validate the key index */
- + idx = encoding->flags & IW_ENCODE_INDEX;
- + if (idx) {
- + if ((idx < 1) || (idx > 4))
- + goto out;
- + idx--;
- + } else
- + idx = priv->tx_key;
- +
- + if (encoding->flags & IW_ENCODE_DISABLED)
- + alg = IW_ENCODE_ALG_NONE;
- +
- + if (priv->has_wpa && (alg != IW_ENCODE_ALG_TKIP)) {
- + /* Clear any TKIP TX key we had */
- + (void) orinoco_clear_tkip_key(priv, priv->tx_key);
- + }
- +
- + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
- + priv->tx_key = idx;
- + set_key = ((alg == IW_ENCODE_ALG_TKIP) ||
- + (ext->key_len > 0)) ? 1 : 0;
- + }
- +
- + if (set_key) {
- + /* Set the requested key first */
- + switch (alg) {
- + case IW_ENCODE_ALG_NONE:
- + priv->encode_alg = ORINOCO_ALG_NONE;
- + err = orinoco_set_key(priv, idx, ORINOCO_ALG_NONE,
- + NULL, 0, NULL, 0);
- + break;
- +
- + case IW_ENCODE_ALG_WEP:
- + if (ext->key_len <= 0)
- + goto out;
- +
- + priv->encode_alg = ORINOCO_ALG_WEP;
- + err = orinoco_set_key(priv, idx, ORINOCO_ALG_WEP,
- + ext->key, ext->key_len, NULL, 0);
- + break;
- +
- + case IW_ENCODE_ALG_TKIP:
- + {
- + u8 *tkip_iv = NULL;
- +
- + if (!priv->has_wpa ||
- + (ext->key_len > sizeof(struct orinoco_tkip_key)))
- + goto out;
- +
- + priv->encode_alg = ORINOCO_ALG_TKIP;
- +
- + if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
- + tkip_iv = &ext->rx_seq[0];
- +
- + err = orinoco_set_key(priv, idx, ORINOCO_ALG_TKIP,
- + ext->key, ext->key_len, tkip_iv,
- + ORINOCO_SEQ_LEN);
- +
- + err = __orinoco_hw_set_tkip_key(priv, idx,
- + ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
- + priv->keys[idx].key, priv->keys[idx].key_len,
- + tkip_iv, ORINOCO_SEQ_LEN, NULL, 0);
- + if (err)
- + printk(KERN_ERR "%s: Error %d setting TKIP key"
- + "\n", dev->name, err);
- +
- + goto out;
- + }
- + default:
- + goto out;
- + }
- + }
- + err = -EINPROGRESS;
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_get_encodeext(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct iw_point *encoding = &wrqu->encoding;
- + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- + int idx, max_key_len;
- + unsigned long flags;
- + int err;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + err = -EINVAL;
- + max_key_len = encoding->length - sizeof(*ext);
- + if (max_key_len < 0)
- + goto out;
- +
- + idx = encoding->flags & IW_ENCODE_INDEX;
- + if (idx) {
- + if ((idx < 1) || (idx > 4))
- + goto out;
- + idx--;
- + } else
- + idx = priv->tx_key;
- +
- + encoding->flags = idx + 1;
- + memset(ext, 0, sizeof(*ext));
- +
- + switch (priv->encode_alg) {
- + case ORINOCO_ALG_NONE:
- + ext->alg = IW_ENCODE_ALG_NONE;
- + ext->key_len = 0;
- + encoding->flags |= IW_ENCODE_DISABLED;
- + break;
- + case ORINOCO_ALG_WEP:
- + ext->alg = IW_ENCODE_ALG_WEP;
- + ext->key_len = min(priv->keys[idx].key_len, max_key_len);
- + memcpy(ext->key, priv->keys[idx].key, ext->key_len);
- + encoding->flags |= IW_ENCODE_ENABLED;
- + break;
- + case ORINOCO_ALG_TKIP:
- + ext->alg = IW_ENCODE_ALG_TKIP;
- + ext->key_len = min(priv->keys[idx].key_len, max_key_len);
- + memcpy(ext->key, priv->keys[idx].key, ext->key_len);
- + encoding->flags |= IW_ENCODE_ENABLED;
- + break;
- + }
- +
- + err = 0;
- + out:
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_set_auth(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu, char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct hermes *hw = &priv->hw;
- + struct iw_param *param = &wrqu->param;
- + unsigned long flags;
- + int ret = -EINPROGRESS;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + switch (param->flags & IW_AUTH_INDEX) {
- + case IW_AUTH_WPA_VERSION:
- + case IW_AUTH_CIPHER_PAIRWISE:
- + case IW_AUTH_CIPHER_GROUP:
- + case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- + case IW_AUTH_PRIVACY_INVOKED:
- + case IW_AUTH_DROP_UNENCRYPTED:
- + /*
- + * orinoco does not use these parameters
- + */
- + break;
- +
- + case IW_AUTH_MFP:
- + /* Management Frame Protection not supported.
- + * Only fail if set to required.
- + */
- + if (param->value == IW_AUTH_MFP_REQUIRED)
- + ret = -EINVAL;
- + break;
- +
- + case IW_AUTH_KEY_MGMT:
- + /* wl_lkm implies value 2 == PSK for Hermes I
- + * which ties in with WEXT
- + * no other hints tho :(
- + */
- + priv->key_mgmt = param->value;
- + break;
- +
- + case IW_AUTH_TKIP_COUNTERMEASURES:
- + /* When countermeasures are enabled, shut down the
- + * card; when disabled, re-enable the card. This must
- + * take effect immediately.
- + *
- + * TODO: Make sure that the EAPOL message is getting
- + * out before card disabled
- + */
- + if (param->value) {
- + priv->tkip_cm_active = 1;
- + ret = hermes_disable_port(hw, 0);
- + } else {
- + priv->tkip_cm_active = 0;
- + ret = hermes_enable_port(hw, 0);
- + }
- + break;
- +
- + case IW_AUTH_80211_AUTH_ALG:
- + if (param->value & IW_AUTH_ALG_SHARED_KEY)
- + priv->wep_restrict = 1;
- + else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM)
- + priv->wep_restrict = 0;
- + else
- + ret = -EINVAL;
- + break;
- +
- + case IW_AUTH_WPA_ENABLED:
- + if (priv->has_wpa) {
- + priv->wpa_enabled = param->value ? 1 : 0;
- + } else {
- + if (param->value)
- + ret = -EOPNOTSUPP;
- + /* else silently accept disable of WPA */
- + priv->wpa_enabled = 0;
- + }
- + break;
- +
- + default:
- + ret = -EOPNOTSUPP;
- + }
- +
- + orinoco_unlock(priv, &flags);
- + return ret;
- +}
- +
- +static int orinoco_ioctl_get_auth(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu, char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct iw_param *param = &wrqu->param;
- + unsigned long flags;
- + int ret = 0;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + switch (param->flags & IW_AUTH_INDEX) {
- + case IW_AUTH_KEY_MGMT:
- + param->value = priv->key_mgmt;
- + break;
- +
- + case IW_AUTH_TKIP_COUNTERMEASURES:
- + param->value = priv->tkip_cm_active;
- + break;
- +
- + case IW_AUTH_80211_AUTH_ALG:
- + if (priv->wep_restrict)
- + param->value = IW_AUTH_ALG_SHARED_KEY;
- + else
- + param->value = IW_AUTH_ALG_OPEN_SYSTEM;
- + break;
- +
- + case IW_AUTH_WPA_ENABLED:
- + param->value = priv->wpa_enabled;
- + break;
- +
- + default:
- + ret = -EOPNOTSUPP;
- + }
- +
- + orinoco_unlock(priv, &flags);
- + return ret;
- +}
- +
- +static int orinoco_ioctl_set_genie(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu, char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + u8 *buf;
- + unsigned long flags;
- +
- + /* cut off at IEEE80211_MAX_DATA_LEN */
- + if ((wrqu->data.length > IEEE80211_MAX_DATA_LEN) ||
- + (wrqu->data.length && (extra == NULL)))
- + return -EINVAL;
- +
- + if (wrqu->data.length) {
- + buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL);
- + if (buf == NULL)
- + return -ENOMEM;
- + } else
- + buf = NULL;
- +
- + if (orinoco_lock(priv, &flags) != 0) {
- + kfree(buf);
- + return -EBUSY;
- + }
- +
- + kfree(priv->wpa_ie);
- + priv->wpa_ie = buf;
- + priv->wpa_ie_len = wrqu->data.length;
- +
- + if (priv->wpa_ie) {
- + /* Looks like wl_lkm wants to check the auth alg, and
- + * somehow pass it to the firmware.
- + * Instead it just calls the key mgmt rid
- + * - we do this in set auth.
- + */
- + }
- +
- + orinoco_unlock(priv, &flags);
- + return 0;
- +}
- +
- +static int orinoco_ioctl_get_genie(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu, char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + unsigned long flags;
- + int err = 0;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + if ((priv->wpa_ie_len == 0) || (priv->wpa_ie == NULL)) {
- + wrqu->data.length = 0;
- + goto out;
- + }
- +
- + if (wrqu->data.length < priv->wpa_ie_len) {
- + err = -E2BIG;
- + goto out;
- + }
- +
- + wrqu->data.length = priv->wpa_ie_len;
- + memcpy(extra, priv->wpa_ie, priv->wpa_ie_len);
- +
- +out:
- + orinoco_unlock(priv, &flags);
- + return err;
- +}
- +
- +static int orinoco_ioctl_set_mlme(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu, char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct iw_mlme *mlme = (struct iw_mlme *)extra;
- + unsigned long flags;
- + int ret = 0;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + switch (mlme->cmd) {
- + case IW_MLME_DEAUTH:
- + /* silently ignore */
- + break;
- +
- + case IW_MLME_DISASSOC:
- +
- + ret = orinoco_hw_disassociate(priv, mlme->addr.sa_data,
- + mlme->reason_code);
- + break;
- +
- + default:
- + ret = -EOPNOTSUPP;
- + }
- +
- + orinoco_unlock(priv, &flags);
- + return ret;
- +}
- +
- +static int orinoco_ioctl_reset(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- +
- + if (!capable(CAP_NET_ADMIN))
- + return -EPERM;
- +
- + if (info->cmd == (SIOCIWFIRSTPRIV + 0x1)) {
- + printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
- +
- + /* Firmware reset */
- + orinoco_reset(&priv->reset_work);
- + } else {
- + printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
- +
- + schedule_work(&priv->reset_work);
- + }
- +
- + return 0;
- +}
- +
- +static int orinoco_ioctl_setibssport(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + int val = *((int *) extra);
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + priv->ibss_port = val;
- +
- + /* Actually update the mode we are using */
- + set_port_type(priv);
- +
- + orinoco_unlock(priv, &flags);
- + return -EINPROGRESS; /* Call commit handler */
- +}
- +
- +static int orinoco_ioctl_getibssport(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + int *val = (int *) extra;
- +
- + *val = priv->ibss_port;
- + return 0;
- +}
- +
- +static int orinoco_ioctl_setport3(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + int val = *((int *) extra);
- + int err = 0;
- + unsigned long flags;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + switch (val) {
- + case 0: /* Try to do IEEE ad-hoc mode */
- + if (!priv->has_ibss) {
- + err = -EINVAL;
- + break;
- + }
- + priv->prefer_port3 = 0;
- +
- + break;
- +
- + case 1: /* Try to do Lucent proprietary ad-hoc mode */
- + if (!priv->has_port3) {
- + err = -EINVAL;
- + break;
- + }
- + priv->prefer_port3 = 1;
- + break;
- +
- + default:
- + err = -EINVAL;
- + }
- +
- + if (!err) {
- + /* Actually update the mode we are using */
- + set_port_type(priv);
- + err = -EINPROGRESS;
- + }
- +
- + orinoco_unlock(priv, &flags);
- +
- + return err;
- +}
- +
- +static int orinoco_ioctl_getport3(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + int *val = (int *) extra;
- +
- + *val = priv->prefer_port3;
- + return 0;
- +}
- +
- +static int orinoco_ioctl_setpreamble(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + unsigned long flags;
- + int val;
- +
- + if (!priv->has_preamble)
- + return -EOPNOTSUPP;
- +
- + /* 802.11b has recently defined some short preamble.
- + * Basically, the Phy header has been reduced in size.
- + * This increase performance, especially at high rates
- + * (the preamble is transmitted at 1Mb/s), unfortunately
- + * this give compatibility troubles... - Jean II */
- + val = *((int *) extra);
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + if (val)
- + priv->preamble = 1;
- + else
- + priv->preamble = 0;
- +
- + orinoco_unlock(priv, &flags);
- +
- + return -EINPROGRESS; /* Call commit handler */
- +}
- +
- +static int orinoco_ioctl_getpreamble(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + int *val = (int *) extra;
- +
- + if (!priv->has_preamble)
- + return -EOPNOTSUPP;
- +
- + *val = priv->preamble;
- + return 0;
- +}
- +
- +/* ioctl interface to hermes_read_ltv()
- + * To use with iwpriv, pass the RID as the token argument, e.g.
- + * iwpriv get_rid [0xfc00]
- + * At least Wireless Tools 25 is required to use iwpriv.
- + * For Wireless Tools 25 and 26 append "dummy" are the end. */
- +static int orinoco_ioctl_getrid(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct iw_point *data = &wrqu->data;
- + struct orinoco_private *priv = ndev_priv(dev);
- + struct hermes *hw = &priv->hw;
- + int rid = data->flags;
- + u16 length;
- + int err;
- + unsigned long flags;
- +
- + /* It's a "get" function, but we don't want users to access the
- + * WEP key and other raw firmware data */
- + if (!capable(CAP_NET_ADMIN))
- + return -EPERM;
- +
- + if (rid < 0xfc00 || rid > 0xffff)
- + return -EINVAL;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return -EBUSY;
- +
- + err = hw->ops->read_ltv(hw, USER_BAP, rid, MAX_RID_LEN, &length,
- + extra);
- + if (err)
- + goto out;
- +
- + data->length = min_t(u16, HERMES_RECLEN_TO_BYTES(length),
- + MAX_RID_LEN);
- +
- + out:
- + orinoco_unlock(priv, &flags);
- + return err;
- +}
- +
- +
- +/* Commit handler, called after set operations */
- +static int orinoco_ioctl_commit(struct net_device *dev,
- + struct iw_request_info *info,
- + union iwreq_data *wrqu,
- + char *extra)
- +{
- + struct orinoco_private *priv = ndev_priv(dev);
- + unsigned long flags;
- + int err = 0;
- +
- + if (!priv->open)
- + return 0;
- +
- + if (orinoco_lock(priv, &flags) != 0)
- + return err;
- +
- + err = orinoco_commit(priv);
- +
- + orinoco_unlock(priv, &flags);
- + return err;
- +}
- +
- +static const struct iw_priv_args orinoco_privtab[] = {
- + { SIOCIWFIRSTPRIV + 0x0, 0, 0, "force_reset" },
- + { SIOCIWFIRSTPRIV + 0x1, 0, 0, "card_reset" },
- + { SIOCIWFIRSTPRIV + 0x2, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
- + 0, "set_port3" },
- + { SIOCIWFIRSTPRIV + 0x3, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
- + "get_port3" },
- + { SIOCIWFIRSTPRIV + 0x4, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
- + 0, "set_preamble" },
- + { SIOCIWFIRSTPRIV + 0x5, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
- + "get_preamble" },
- + { SIOCIWFIRSTPRIV + 0x6, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
- + 0, "set_ibssport" },
- + { SIOCIWFIRSTPRIV + 0x7, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
- + "get_ibssport" },
- + { SIOCIWFIRSTPRIV + 0x9, 0, IW_PRIV_TYPE_BYTE | MAX_RID_LEN,
- + "get_rid" },
- +};
- +
- +
- +/*
- + * Structures to export the Wireless Handlers
- + */
- +
- +static const iw_handler orinoco_handler[] = {
- + IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit),
- + IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname),
- + IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq),
- + IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq),
- + IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode),
- + IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode),
- + IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens),
- + IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens),
- + IW_HANDLER(SIOCGIWRANGE, cfg80211_wext_giwrange),
- + IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap),
- + IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap),
- + IW_HANDLER(SIOCSIWSCAN, cfg80211_wext_siwscan),
- + IW_HANDLER(SIOCGIWSCAN, cfg80211_wext_giwscan),
- + IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid),
- + IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid),
- + IW_HANDLER(SIOCSIWRATE, orinoco_ioctl_setrate),
- + IW_HANDLER(SIOCGIWRATE, orinoco_ioctl_getrate),
- + IW_HANDLER(SIOCSIWRTS, cfg80211_wext_siwrts),
- + IW_HANDLER(SIOCGIWRTS, cfg80211_wext_giwrts),
- + IW_HANDLER(SIOCSIWFRAG, cfg80211_wext_siwfrag),
- + IW_HANDLER(SIOCGIWFRAG, cfg80211_wext_giwfrag),
- + IW_HANDLER(SIOCGIWRETRY, cfg80211_wext_giwretry),
- + IW_HANDLER(SIOCSIWENCODE, orinoco_ioctl_setiwencode),
- + IW_HANDLER(SIOCGIWENCODE, orinoco_ioctl_getiwencode),
- + IW_HANDLER(SIOCSIWPOWER, orinoco_ioctl_setpower),
- + IW_HANDLER(SIOCGIWPOWER, orinoco_ioctl_getpower),
- + IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie),
- + IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie),
- + IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme),
- + IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth),
- + IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth),
- + IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext),
- + IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext),
- +};
- +
- +
- +/*
- + Added typecasting since we no longer use iwreq_data -- Moustafa
- + */
- +static const iw_handler orinoco_private_handler[] = {
- + [0] = orinoco_ioctl_reset,
- + [1] = orinoco_ioctl_reset,
- + [2] = orinoco_ioctl_setport3,
- + [3] = orinoco_ioctl_getport3,
- + [4] = orinoco_ioctl_setpreamble,
- + [5] = orinoco_ioctl_getpreamble,
- + [6] = orinoco_ioctl_setibssport,
- + [7] = orinoco_ioctl_getibssport,
- + [9] = orinoco_ioctl_getrid,
- +};
- +
- +const struct iw_handler_def orinoco_handler_def = {
- + .num_standard = ARRAY_SIZE(orinoco_handler),
- + .num_private = ARRAY_SIZE(orinoco_private_handler),
- + .num_private_args = ARRAY_SIZE(orinoco_privtab),
- + .standard = orinoco_handler,
- + .private = orinoco_private_handler,
- + .private_args = orinoco_privtab,
- + .get_wireless_stats = orinoco_get_wireless_stats,
- +};
- diff -Nur linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/wext.h linux-6.18.9/drivers/net/wireless/intersil/orinoco/wext.h
- --- linux-6.18.9.orig/drivers/net/wireless/intersil/orinoco/wext.h 1970-01-01 01:00:00.000000000 +0100
- +++ linux-6.18.9/drivers/net/wireless/intersil/orinoco/wext.h 2026-02-16 14:00:36.623256352 +0100
- @@ -0,0 +1,13 @@
- +/* Wireless extensions support.
- + *
- + * See copyright notice in main.c
- + */
- +#ifndef _ORINOCO_WEXT_H_
- +#define _ORINOCO_WEXT_H_
- +
- +#include <net/iw_handler.h>
- +
- +/* Structure defining all our WEXT handlers */
- +extern const struct iw_handler_def orinoco_handler_def;
- +
- +#endif /* _ORINOCO_WEXT_H_ */
|