mac80211.h 283 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * mac80211 <-> driver interface
  4. *
  5. * Copyright 2002-2005, Devicescape Software, Inc.
  6. * Copyright 2006-2007 Jiri Benc <[email protected]>
  7. * Copyright 2007-2010 Johannes Berg <[email protected]>
  8. * Copyright 2013-2014 Intel Mobile Communications GmbH
  9. * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
  10. * Copyright (C) 2018 - 2022 Intel Corporation
  11. */
  12. #ifndef MAC80211_H
  13. #define MAC80211_H
  14. #include <linux/bug.h>
  15. #include <linux/kernel.h>
  16. #include <linux/if_ether.h>
  17. #include <linux/skbuff.h>
  18. #include <linux/ieee80211.h>
  19. #include <linux/lockdep.h>
  20. #include <linux/android_kabi.h>
  21. #include <net/cfg80211.h>
  22. #include <net/codel.h>
  23. #include <net/ieee80211_radiotap.h>
  24. #include <asm/unaligned.h>
  25. /**
  26. * DOC: Introduction
  27. *
  28. * mac80211 is the Linux stack for 802.11 hardware that implements
  29. * only partial functionality in hard- or firmware. This document
  30. * defines the interface between mac80211 and low-level hardware
  31. * drivers.
  32. */
  33. /**
  34. * DOC: Calling mac80211 from interrupts
  35. *
  36. * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
  37. * called in hardware interrupt context. The low-level driver must not call any
  38. * other functions in hardware interrupt context. If there is a need for such
  39. * call, the low-level driver should first ACK the interrupt and perform the
  40. * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even
  41. * tasklet function.
  42. *
  43. * NOTE: If the driver opts to use the _irqsafe() functions, it may not also
  44. * use the non-IRQ-safe functions!
  45. */
  46. /**
  47. * DOC: Warning
  48. *
  49. * If you're reading this document and not the header file itself, it will
  50. * be incomplete because not all documentation has been converted yet.
  51. */
  52. /**
  53. * DOC: Frame format
  54. *
  55. * As a general rule, when frames are passed between mac80211 and the driver,
  56. * they start with the IEEE 802.11 header and include the same octets that are
  57. * sent over the air except for the FCS which should be calculated by the
  58. * hardware.
  59. *
  60. * There are, however, various exceptions to this rule for advanced features:
  61. *
  62. * The first exception is for hardware encryption and decryption offload
  63. * where the IV/ICV may or may not be generated in hardware.
  64. *
  65. * Secondly, when the hardware handles fragmentation, the frame handed to
  66. * the driver from mac80211 is the MSDU, not the MPDU.
  67. */
  68. /**
  69. * DOC: mac80211 workqueue
  70. *
  71. * mac80211 provides its own workqueue for drivers and internal mac80211 use.
  72. * The workqueue is a single threaded workqueue and can only be accessed by
  73. * helpers for sanity checking. Drivers must ensure all work added onto the
  74. * mac80211 workqueue should be cancelled on the driver stop() callback.
  75. *
  76. * mac80211 will flushed the workqueue upon interface removal and during
  77. * suspend.
  78. *
  79. * All work performed on the mac80211 workqueue must not acquire the RTNL lock.
  80. *
  81. */
  82. /**
  83. * DOC: mac80211 software tx queueing
  84. *
  85. * mac80211 provides an optional intermediate queueing implementation designed
  86. * to allow the driver to keep hardware queues short and provide some fairness
  87. * between different stations/interfaces.
  88. * In this model, the driver pulls data frames from the mac80211 queue instead
  89. * of letting mac80211 push them via drv_tx().
  90. * Other frames (e.g. control or management) are still pushed using drv_tx().
  91. *
  92. * Drivers indicate that they use this model by implementing the .wake_tx_queue
  93. * driver operation.
  94. *
  95. * Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with
  96. * another per-sta for non-data/non-mgmt and bufferable management frames, and
  97. * a single per-vif queue for multicast data frames.
  98. *
  99. * The driver is expected to initialize its private per-queue data for stations
  100. * and interfaces in the .add_interface and .sta_add ops.
  101. *
  102. * The driver can't access the queue directly. To dequeue a frame from a
  103. * txq, it calls ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a
  104. * queue, it calls the .wake_tx_queue driver op.
  105. *
  106. * Drivers can optionally delegate responsibility for scheduling queues to
  107. * mac80211, to take advantage of airtime fairness accounting. In this case, to
  108. * obtain the next queue to pull frames from, the driver calls
  109. * ieee80211_next_txq(). The driver is then expected to return the txq using
  110. * ieee80211_return_txq().
  111. *
  112. * For AP powersave TIM handling, the driver only needs to indicate if it has
  113. * buffered packets in the driver specific data structures by calling
  114. * ieee80211_sta_set_buffered(). For frames buffered in the ieee80211_txq
  115. * struct, mac80211 sets the appropriate TIM PVB bits and calls
  116. * .release_buffered_frames().
  117. * In that callback the driver is therefore expected to release its own
  118. * buffered frames and afterwards also frames from the ieee80211_txq (obtained
  119. * via the usual ieee80211_tx_dequeue).
  120. */
  121. /**
  122. * DOC: HW timestamping
  123. *
  124. * Timing Measurement and Fine Timing Measurement require accurate timestamps
  125. * of the action frames TX/RX and their respective acks.
  126. *
  127. * To report hardware timestamps for Timing Measurement or Fine Timing
  128. * Measurement frame RX, the low level driver should set the SKB's hwtstamp
  129. * field to the frame RX timestamp and report the ack TX timestamp in the
  130. * ieee80211_rx_status struct.
  131. *
  132. * Similarly, To report hardware timestamps for Timing Measurement or Fine
  133. * Timing Measurement frame TX, the driver should set the SKB's hwtstamp field
  134. * to the frame TX timestamp and report the ack RX timestamp in the
  135. * ieee80211_tx_status struct.
  136. */
  137. struct device;
  138. /**
  139. * enum ieee80211_max_queues - maximum number of queues
  140. *
  141. * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues.
  142. * @IEEE80211_MAX_QUEUE_MAP: bitmap with maximum queues set
  143. */
  144. enum ieee80211_max_queues {
  145. IEEE80211_MAX_QUEUES = 16,
  146. IEEE80211_MAX_QUEUE_MAP = BIT(IEEE80211_MAX_QUEUES) - 1,
  147. };
  148. #define IEEE80211_INVAL_HW_QUEUE 0xff
  149. /**
  150. * enum ieee80211_ac_numbers - AC numbers as used in mac80211
  151. * @IEEE80211_AC_VO: voice
  152. * @IEEE80211_AC_VI: video
  153. * @IEEE80211_AC_BE: best effort
  154. * @IEEE80211_AC_BK: background
  155. */
  156. enum ieee80211_ac_numbers {
  157. IEEE80211_AC_VO = 0,
  158. IEEE80211_AC_VI = 1,
  159. IEEE80211_AC_BE = 2,
  160. IEEE80211_AC_BK = 3,
  161. };
  162. /**
  163. * struct ieee80211_tx_queue_params - transmit queue configuration
  164. *
  165. * The information provided in this structure is required for QoS
  166. * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
  167. *
  168. * @aifs: arbitration interframe space [0..255]
  169. * @cw_min: minimum contention window [a value of the form
  170. * 2^n-1 in the range 1..32767]
  171. * @cw_max: maximum contention window [like @cw_min]
  172. * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
  173. * @acm: is mandatory admission control required for the access category
  174. * @uapsd: is U-APSD mode enabled for the queue
  175. * @mu_edca: is the MU EDCA configured
  176. * @mu_edca_param_rec: MU EDCA Parameter Record for HE
  177. */
  178. struct ieee80211_tx_queue_params {
  179. u16 txop;
  180. u16 cw_min;
  181. u16 cw_max;
  182. u8 aifs;
  183. bool acm;
  184. bool uapsd;
  185. bool mu_edca;
  186. struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec;
  187. };
  188. struct ieee80211_low_level_stats {
  189. unsigned int dot11ACKFailureCount;
  190. unsigned int dot11RTSFailureCount;
  191. unsigned int dot11FCSErrorCount;
  192. unsigned int dot11RTSSuccessCount;
  193. };
  194. /**
  195. * enum ieee80211_chanctx_change - change flag for channel context
  196. * @IEEE80211_CHANCTX_CHANGE_WIDTH: The channel width changed
  197. * @IEEE80211_CHANCTX_CHANGE_RX_CHAINS: The number of RX chains changed
  198. * @IEEE80211_CHANCTX_CHANGE_RADAR: radar detection flag changed
  199. * @IEEE80211_CHANCTX_CHANGE_CHANNEL: switched to another operating channel,
  200. * this is used only with channel switching with CSA
  201. * @IEEE80211_CHANCTX_CHANGE_MIN_WIDTH: The min required channel width changed
  202. */
  203. enum ieee80211_chanctx_change {
  204. IEEE80211_CHANCTX_CHANGE_WIDTH = BIT(0),
  205. IEEE80211_CHANCTX_CHANGE_RX_CHAINS = BIT(1),
  206. IEEE80211_CHANCTX_CHANGE_RADAR = BIT(2),
  207. IEEE80211_CHANCTX_CHANGE_CHANNEL = BIT(3),
  208. IEEE80211_CHANCTX_CHANGE_MIN_WIDTH = BIT(4),
  209. };
  210. /**
  211. * struct ieee80211_chanctx_conf - channel context that vifs may be tuned to
  212. *
  213. * This is the driver-visible part. The ieee80211_chanctx
  214. * that contains it is visible in mac80211 only.
  215. *
  216. * @def: the channel definition
  217. * @min_def: the minimum channel definition currently required.
  218. * @rx_chains_static: The number of RX chains that must always be
  219. * active on the channel to receive MIMO transmissions
  220. * @rx_chains_dynamic: The number of RX chains that must be enabled
  221. * after RTS/CTS handshake to receive SMPS MIMO transmissions;
  222. * this will always be >= @rx_chains_static.
  223. * @radar_enabled: whether radar detection is enabled on this channel.
  224. * @drv_priv: data area for driver use, will always be aligned to
  225. * sizeof(void *), size is determined in hw information.
  226. */
  227. struct ieee80211_chanctx_conf {
  228. struct cfg80211_chan_def def;
  229. struct cfg80211_chan_def min_def;
  230. u8 rx_chains_static, rx_chains_dynamic;
  231. bool radar_enabled;
  232. u8 drv_priv[] __aligned(sizeof(void *));
  233. };
  234. /**
  235. * enum ieee80211_chanctx_switch_mode - channel context switch mode
  236. * @CHANCTX_SWMODE_REASSIGN_VIF: Both old and new contexts already
  237. * exist (and will continue to exist), but the virtual interface
  238. * needs to be switched from one to the other.
  239. * @CHANCTX_SWMODE_SWAP_CONTEXTS: The old context exists but will stop
  240. * to exist with this call, the new context doesn't exist but
  241. * will be active after this call, the virtual interface switches
  242. * from the old to the new (note that the driver may of course
  243. * implement this as an on-the-fly chandef switch of the existing
  244. * hardware context, but the mac80211 pointer for the old context
  245. * will cease to exist and only the new one will later be used
  246. * for changes/removal.)
  247. */
  248. enum ieee80211_chanctx_switch_mode {
  249. CHANCTX_SWMODE_REASSIGN_VIF,
  250. CHANCTX_SWMODE_SWAP_CONTEXTS,
  251. };
  252. /**
  253. * struct ieee80211_vif_chanctx_switch - vif chanctx switch information
  254. *
  255. * This is structure is used to pass information about a vif that
  256. * needs to switch from one chanctx to another. The
  257. * &ieee80211_chanctx_switch_mode defines how the switch should be
  258. * done.
  259. *
  260. * @vif: the vif that should be switched from old_ctx to new_ctx
  261. * @link_conf: the link conf that's switching
  262. * @old_ctx: the old context to which the vif was assigned
  263. * @new_ctx: the new context to which the vif must be assigned
  264. */
  265. struct ieee80211_vif_chanctx_switch {
  266. struct ieee80211_vif *vif;
  267. struct ieee80211_bss_conf *link_conf;
  268. struct ieee80211_chanctx_conf *old_ctx;
  269. struct ieee80211_chanctx_conf *new_ctx;
  270. };
  271. /**
  272. * enum ieee80211_bss_change - BSS change notification flags
  273. *
  274. * These flags are used with the bss_info_changed(), link_info_changed()
  275. * and vif_cfg_changed() callbacks to indicate which parameter(s) changed.
  276. *
  277. * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
  278. * also implies a change in the AID.
  279. * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
  280. * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
  281. * @BSS_CHANGED_ERP_SLOT: slot timing changed
  282. * @BSS_CHANGED_HT: 802.11n parameters changed
  283. * @BSS_CHANGED_BASIC_RATES: Basic rateset changed
  284. * @BSS_CHANGED_BEACON_INT: Beacon interval changed
  285. * @BSS_CHANGED_BSSID: BSSID changed, for whatever
  286. * reason (IBSS and managed mode)
  287. * @BSS_CHANGED_BEACON: Beacon data changed, retrieve
  288. * new beacon (beaconing modes)
  289. * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be
  290. * enabled/disabled (beaconing modes)
  291. * @BSS_CHANGED_CQM: Connection quality monitor config changed
  292. * @BSS_CHANGED_IBSS: IBSS join status changed
  293. * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed.
  294. * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note
  295. * that it is only ever disabled for station mode.
  296. * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
  297. * @BSS_CHANGED_SSID: SSID changed for this BSS (AP and IBSS mode)
  298. * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
  299. * @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
  300. * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface
  301. * @BSS_CHANGED_P2P_PS: P2P powersave settings (CTWindow, opportunistic PS)
  302. * changed
  303. * @BSS_CHANGED_BEACON_INFO: Data from the AP's beacon became available:
  304. * currently dtim_period only is under consideration.
  305. * @BSS_CHANGED_BANDWIDTH: The bandwidth used by this interface changed,
  306. * note that this is only called when it changes after the channel
  307. * context had been assigned.
  308. * @BSS_CHANGED_OCB: OCB join status changed
  309. * @BSS_CHANGED_MU_GROUPS: VHT MU-MIMO group id or user position changed
  310. * @BSS_CHANGED_KEEP_ALIVE: keep alive options (idle period or protected
  311. * keep alive) changed.
  312. * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface
  313. * @BSS_CHANGED_FTM_RESPONDER: fine timing measurement request responder
  314. * functionality changed for this BSS (AP mode).
  315. * @BSS_CHANGED_TWT: TWT status changed
  316. * @BSS_CHANGED_HE_OBSS_PD: OBSS Packet Detection status changed.
  317. * @BSS_CHANGED_HE_BSS_COLOR: BSS Color has changed
  318. * @BSS_CHANGED_FILS_DISCOVERY: FILS discovery status changed.
  319. * @BSS_CHANGED_UNSOL_BCAST_PROBE_RESP: Unsolicited broadcast probe response
  320. * status changed.
  321. *
  322. */
  323. enum ieee80211_bss_change {
  324. BSS_CHANGED_ASSOC = 1<<0,
  325. BSS_CHANGED_ERP_CTS_PROT = 1<<1,
  326. BSS_CHANGED_ERP_PREAMBLE = 1<<2,
  327. BSS_CHANGED_ERP_SLOT = 1<<3,
  328. BSS_CHANGED_HT = 1<<4,
  329. BSS_CHANGED_BASIC_RATES = 1<<5,
  330. BSS_CHANGED_BEACON_INT = 1<<6,
  331. BSS_CHANGED_BSSID = 1<<7,
  332. BSS_CHANGED_BEACON = 1<<8,
  333. BSS_CHANGED_BEACON_ENABLED = 1<<9,
  334. BSS_CHANGED_CQM = 1<<10,
  335. BSS_CHANGED_IBSS = 1<<11,
  336. BSS_CHANGED_ARP_FILTER = 1<<12,
  337. BSS_CHANGED_QOS = 1<<13,
  338. BSS_CHANGED_IDLE = 1<<14,
  339. BSS_CHANGED_SSID = 1<<15,
  340. BSS_CHANGED_AP_PROBE_RESP = 1<<16,
  341. BSS_CHANGED_PS = 1<<17,
  342. BSS_CHANGED_TXPOWER = 1<<18,
  343. BSS_CHANGED_P2P_PS = 1<<19,
  344. BSS_CHANGED_BEACON_INFO = 1<<20,
  345. BSS_CHANGED_BANDWIDTH = 1<<21,
  346. BSS_CHANGED_OCB = 1<<22,
  347. BSS_CHANGED_MU_GROUPS = 1<<23,
  348. BSS_CHANGED_KEEP_ALIVE = 1<<24,
  349. BSS_CHANGED_MCAST_RATE = 1<<25,
  350. BSS_CHANGED_FTM_RESPONDER = 1<<26,
  351. BSS_CHANGED_TWT = 1<<27,
  352. BSS_CHANGED_HE_OBSS_PD = 1<<28,
  353. BSS_CHANGED_HE_BSS_COLOR = 1<<29,
  354. BSS_CHANGED_FILS_DISCOVERY = 1<<30,
  355. BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = 1<<31,
  356. /* when adding here, make sure to change ieee80211_reconfig */
  357. };
  358. /*
  359. * The maximum number of IPv4 addresses listed for ARP filtering. If the number
  360. * of addresses for an interface increase beyond this value, hardware ARP
  361. * filtering will be disabled.
  362. */
  363. #define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4
  364. /**
  365. * enum ieee80211_event_type - event to be notified to the low level driver
  366. * @RSSI_EVENT: AP's rssi crossed the a threshold set by the driver.
  367. * @MLME_EVENT: event related to MLME
  368. * @BAR_RX_EVENT: a BAR was received
  369. * @BA_FRAME_TIMEOUT: Frames were released from the reordering buffer because
  370. * they timed out. This won't be called for each frame released, but only
  371. * once each time the timeout triggers.
  372. */
  373. enum ieee80211_event_type {
  374. RSSI_EVENT,
  375. MLME_EVENT,
  376. BAR_RX_EVENT,
  377. BA_FRAME_TIMEOUT,
  378. };
  379. /**
  380. * enum ieee80211_rssi_event_data - relevant when event type is %RSSI_EVENT
  381. * @RSSI_EVENT_HIGH: AP's rssi went below the threshold set by the driver.
  382. * @RSSI_EVENT_LOW: AP's rssi went above the threshold set by the driver.
  383. */
  384. enum ieee80211_rssi_event_data {
  385. RSSI_EVENT_HIGH,
  386. RSSI_EVENT_LOW,
  387. };
  388. /**
  389. * struct ieee80211_rssi_event - data attached to an %RSSI_EVENT
  390. * @data: See &enum ieee80211_rssi_event_data
  391. */
  392. struct ieee80211_rssi_event {
  393. enum ieee80211_rssi_event_data data;
  394. };
  395. /**
  396. * enum ieee80211_mlme_event_data - relevant when event type is %MLME_EVENT
  397. * @AUTH_EVENT: the MLME operation is authentication
  398. * @ASSOC_EVENT: the MLME operation is association
  399. * @DEAUTH_RX_EVENT: deauth received..
  400. * @DEAUTH_TX_EVENT: deauth sent.
  401. */
  402. enum ieee80211_mlme_event_data {
  403. AUTH_EVENT,
  404. ASSOC_EVENT,
  405. DEAUTH_RX_EVENT,
  406. DEAUTH_TX_EVENT,
  407. };
  408. /**
  409. * enum ieee80211_mlme_event_status - relevant when event type is %MLME_EVENT
  410. * @MLME_SUCCESS: the MLME operation completed successfully.
  411. * @MLME_DENIED: the MLME operation was denied by the peer.
  412. * @MLME_TIMEOUT: the MLME operation timed out.
  413. */
  414. enum ieee80211_mlme_event_status {
  415. MLME_SUCCESS,
  416. MLME_DENIED,
  417. MLME_TIMEOUT,
  418. };
  419. /**
  420. * struct ieee80211_mlme_event - data attached to an %MLME_EVENT
  421. * @data: See &enum ieee80211_mlme_event_data
  422. * @status: See &enum ieee80211_mlme_event_status
  423. * @reason: the reason code if applicable
  424. */
  425. struct ieee80211_mlme_event {
  426. enum ieee80211_mlme_event_data data;
  427. enum ieee80211_mlme_event_status status;
  428. u16 reason;
  429. };
  430. /**
  431. * struct ieee80211_ba_event - data attached for BlockAck related events
  432. * @sta: pointer to the &ieee80211_sta to which this event relates
  433. * @tid: the tid
  434. * @ssn: the starting sequence number (for %BAR_RX_EVENT)
  435. */
  436. struct ieee80211_ba_event {
  437. struct ieee80211_sta *sta;
  438. u16 tid;
  439. u16 ssn;
  440. };
  441. /**
  442. * struct ieee80211_event - event to be sent to the driver
  443. * @type: The event itself. See &enum ieee80211_event_type.
  444. * @rssi: relevant if &type is %RSSI_EVENT
  445. * @mlme: relevant if &type is %AUTH_EVENT
  446. * @ba: relevant if &type is %BAR_RX_EVENT or %BA_FRAME_TIMEOUT
  447. * @u:union holding the fields above
  448. */
  449. struct ieee80211_event {
  450. enum ieee80211_event_type type;
  451. union {
  452. struct ieee80211_rssi_event rssi;
  453. struct ieee80211_mlme_event mlme;
  454. struct ieee80211_ba_event ba;
  455. } u;
  456. };
  457. /**
  458. * struct ieee80211_mu_group_data - STA's VHT MU-MIMO group data
  459. *
  460. * This structure describes the group id data of VHT MU-MIMO
  461. *
  462. * @membership: 64 bits array - a bit is set if station is member of the group
  463. * @position: 2 bits per group id indicating the position in the group
  464. */
  465. struct ieee80211_mu_group_data {
  466. u8 membership[WLAN_MEMBERSHIP_LEN];
  467. u8 position[WLAN_USER_POSITION_LEN];
  468. };
  469. /**
  470. * struct ieee80211_ftm_responder_params - FTM responder parameters
  471. *
  472. * @lci: LCI subelement content
  473. * @civicloc: CIVIC location subelement content
  474. * @lci_len: LCI data length
  475. * @civicloc_len: Civic data length
  476. */
  477. struct ieee80211_ftm_responder_params {
  478. const u8 *lci;
  479. const u8 *civicloc;
  480. size_t lci_len;
  481. size_t civicloc_len;
  482. };
  483. /**
  484. * struct ieee80211_fils_discovery - FILS discovery parameters from
  485. * IEEE Std 802.11ai-2016, Annex C.3 MIB detail.
  486. *
  487. * @min_interval: Minimum packet interval in TUs (0 - 10000)
  488. * @max_interval: Maximum packet interval in TUs (0 - 10000)
  489. */
  490. struct ieee80211_fils_discovery {
  491. u32 min_interval;
  492. u32 max_interval;
  493. };
  494. /**
  495. * struct ieee80211_bss_conf - holds the BSS's changing parameters
  496. *
  497. * This structure keeps information about a BSS (and an association
  498. * to that BSS) that can change during the lifetime of the BSS.
  499. *
  500. * @addr: (link) address used locally
  501. * @link_id: link ID, or 0 for non-MLO
  502. * @htc_trig_based_pkt_ext: default PE in 4us units, if BSS supports HE
  503. * @uora_exists: is the UORA element advertised by AP
  504. * @ack_enabled: indicates support to receive a multi-TID that solicits either
  505. * ACK, BACK or both
  506. * @uora_ocw_range: UORA element's OCW Range field
  507. * @frame_time_rts_th: HE duration RTS threshold, in units of 32us
  508. * @he_support: does this BSS support HE
  509. * @twt_requester: does this BSS support TWT requester (relevant for managed
  510. * mode only, set if the AP advertises TWT responder role)
  511. * @twt_responder: does this BSS support TWT requester (relevant for managed
  512. * mode only, set if the AP advertises TWT responder role)
  513. * @twt_protected: does this BSS support protected TWT frames
  514. * @twt_broadcast: does this BSS support broadcast TWT
  515. * @use_cts_prot: use CTS protection
  516. * @use_short_preamble: use 802.11b short preamble
  517. * @use_short_slot: use short slot time (only relevant for ERP)
  518. * @dtim_period: num of beacons before the next DTIM, for beaconing,
  519. * valid in station mode only if after the driver was notified
  520. * with the %BSS_CHANGED_BEACON_INFO flag, will be non-zero then.
  521. * @sync_tsf: last beacon's/probe response's TSF timestamp (could be old
  522. * as it may have been received during scanning long ago). If the
  523. * HW flag %IEEE80211_HW_TIMING_BEACON_ONLY is set, then this can
  524. * only come from a beacon, but might not become valid until after
  525. * association when a beacon is received (which is notified with the
  526. * %BSS_CHANGED_DTIM flag.). See also sync_dtim_count important notice.
  527. * @sync_device_ts: the device timestamp corresponding to the sync_tsf,
  528. * the driver/device can use this to calculate synchronisation
  529. * (see @sync_tsf). See also sync_dtim_count important notice.
  530. * @sync_dtim_count: Only valid when %IEEE80211_HW_TIMING_BEACON_ONLY
  531. * is requested, see @sync_tsf/@sync_device_ts.
  532. * IMPORTANT: These three sync_* parameters would possibly be out of sync
  533. * by the time the driver will use them. The synchronized view is currently
  534. * guaranteed only in certain callbacks.
  535. * Note also that this is not used with MLD associations, mac80211 doesn't
  536. * know how to track beacons for all of the links for this.
  537. * @beacon_int: beacon interval
  538. * @assoc_capability: capabilities taken from assoc resp
  539. * @basic_rates: bitmap of basic rates, each bit stands for an
  540. * index into the rate table configured by the driver in
  541. * the current band.
  542. * @beacon_rate: associated AP's beacon TX rate
  543. * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
  544. * @bssid: The BSSID for this BSS
  545. * @enable_beacon: whether beaconing should be enabled or not
  546. * @chandef: Channel definition for this BSS -- the hardware might be
  547. * configured a higher bandwidth than this BSS uses, for example.
  548. * @mu_group: VHT MU-MIMO group membership data
  549. * @ht_operation_mode: HT operation mode like in &struct ieee80211_ht_operation.
  550. * This field is only valid when the channel is a wide HT/VHT channel.
  551. * Note that with TDLS this can be the case (channel is HT, protection must
  552. * be used from this field) even when the BSS association isn't using HT.
  553. * @cqm_rssi_thold: Connection quality monitor RSSI threshold, a zero value
  554. * implies disabled. As with the cfg80211 callback, a change here should
  555. * cause an event to be sent indicating where the current value is in
  556. * relation to the newly configured threshold.
  557. * @cqm_rssi_low: Connection quality monitor RSSI lower threshold, a zero value
  558. * implies disabled. This is an alternative mechanism to the single
  559. * threshold event and can't be enabled simultaneously with it.
  560. * @cqm_rssi_high: Connection quality monitor RSSI upper threshold.
  561. * @cqm_rssi_hyst: Connection quality monitor RSSI hysteresis
  562. * @qos: This is a QoS-enabled BSS.
  563. * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
  564. * @txpower: TX power in dBm. INT_MIN means not configured.
  565. * @txpower_type: TX power adjustment used to control per packet Transmit
  566. * Power Control (TPC) in lower driver for the current vif. In particular
  567. * TPC is enabled if value passed in %txpower_type is
  568. * NL80211_TX_POWER_LIMITED (allow using less than specified from
  569. * userspace), whereas TPC is disabled if %txpower_type is set to
  570. * NL80211_TX_POWER_FIXED (use value configured from userspace)
  571. * @p2p_noa_attr: P2P NoA attribute for P2P powersave
  572. * @allow_p2p_go_ps: indication for AP or P2P GO interface, whether it's allowed
  573. * to use P2P PS mechanism or not. AP/P2P GO is not allowed to use P2P PS
  574. * if it has associated clients without P2P PS support.
  575. * @max_idle_period: the time period during which the station can refrain from
  576. * transmitting frames to its associated AP without being disassociated.
  577. * In units of 1000 TUs. Zero value indicates that the AP did not include
  578. * a (valid) BSS Max Idle Period Element.
  579. * @protected_keep_alive: if set, indicates that the station should send an RSN
  580. * protected frame to the AP to reset the idle timer at the AP for the
  581. * station.
  582. * @ftm_responder: whether to enable or disable fine timing measurement FTM
  583. * responder functionality.
  584. * @ftmr_params: configurable lci/civic parameter when enabling FTM responder.
  585. * @nontransmitted: this BSS is a nontransmitted BSS profile
  586. * @transmitter_bssid: the address of transmitter AP
  587. * @bssid_index: index inside the multiple BSSID set
  588. * @bssid_indicator: 2^bssid_indicator is the maximum number of APs in set
  589. * @ema_ap: AP supports enhancements of discovery and advertisement of
  590. * nontransmitted BSSIDs
  591. * @profile_periodicity: the least number of beacon frames need to be received
  592. * in order to discover all the nontransmitted BSSIDs in the set.
  593. * @he_oper: HE operation information of the BSS (AP/Mesh) or of the AP we are
  594. * connected to (STA)
  595. * @he_obss_pd: OBSS Packet Detection parameters.
  596. * @he_bss_color: BSS coloring settings, if BSS supports HE
  597. * @fils_discovery: FILS discovery configuration
  598. * @unsol_bcast_probe_resp_interval: Unsolicited broadcast probe response
  599. * interval.
  600. * @beacon_tx_rate: The configured beacon transmit rate that needs to be passed
  601. * to driver when rate control is offloaded to firmware.
  602. * @power_type: power type of BSS for 6 GHz
  603. * @tx_pwr_env: transmit power envelope array of BSS.
  604. * @tx_pwr_env_num: number of @tx_pwr_env.
  605. * @pwr_reduction: power constraint of BSS.
  606. * @eht_support: does this BSS support EHT
  607. * @csa_active: marks whether a channel switch is going on. Internally it is
  608. * write-protected by sdata_lock and local->mtx so holding either is fine
  609. * for read access.
  610. * @mu_mimo_owner: indicates interface owns MU-MIMO capability
  611. * @chanctx_conf: The channel context this interface is assigned to, or %NULL
  612. * when it is not assigned. This pointer is RCU-protected due to the TX
  613. * path needing to access it; even though the netdev carrier will always
  614. * be off when it is %NULL there can still be races and packets could be
  615. * processed after it switches back to %NULL.
  616. * @color_change_active: marks whether a color change is ongoing. Internally it is
  617. * write-protected by sdata_lock and local->mtx so holding either is fine
  618. * for read access.
  619. * @color_change_color: the bss color that will be used after the change.
  620. */
  621. struct ieee80211_bss_conf {
  622. const u8 *bssid;
  623. unsigned int link_id;
  624. u8 addr[ETH_ALEN] __aligned(2);
  625. u8 htc_trig_based_pkt_ext;
  626. bool uora_exists;
  627. u8 uora_ocw_range;
  628. u16 frame_time_rts_th;
  629. bool he_support;
  630. bool twt_requester;
  631. bool twt_responder;
  632. bool twt_protected;
  633. bool twt_broadcast;
  634. /* erp related data */
  635. bool use_cts_prot;
  636. bool use_short_preamble;
  637. bool use_short_slot;
  638. bool enable_beacon;
  639. u8 dtim_period;
  640. u16 beacon_int;
  641. u16 assoc_capability;
  642. u64 sync_tsf;
  643. u32 sync_device_ts;
  644. u8 sync_dtim_count;
  645. u32 basic_rates;
  646. struct ieee80211_rate *beacon_rate;
  647. int mcast_rate[NUM_NL80211_BANDS];
  648. u16 ht_operation_mode;
  649. s32 cqm_rssi_thold;
  650. u32 cqm_rssi_hyst;
  651. s32 cqm_rssi_low;
  652. s32 cqm_rssi_high;
  653. struct cfg80211_chan_def chandef;
  654. struct ieee80211_mu_group_data mu_group;
  655. bool qos;
  656. bool hidden_ssid;
  657. int txpower;
  658. enum nl80211_tx_power_setting txpower_type;
  659. struct ieee80211_p2p_noa_attr p2p_noa_attr;
  660. bool allow_p2p_go_ps;
  661. u16 max_idle_period;
  662. bool protected_keep_alive;
  663. bool ftm_responder;
  664. struct ieee80211_ftm_responder_params *ftmr_params;
  665. /* Multiple BSSID data */
  666. bool nontransmitted;
  667. u8 transmitter_bssid[ETH_ALEN];
  668. u8 bssid_index;
  669. u8 bssid_indicator;
  670. bool ema_ap;
  671. u8 profile_periodicity;
  672. struct {
  673. u32 params;
  674. u16 nss_set;
  675. } he_oper;
  676. struct ieee80211_he_obss_pd he_obss_pd;
  677. struct cfg80211_he_bss_color he_bss_color;
  678. struct ieee80211_fils_discovery fils_discovery;
  679. u32 unsol_bcast_probe_resp_interval;
  680. struct cfg80211_bitrate_mask beacon_tx_rate;
  681. enum ieee80211_ap_reg_power power_type;
  682. struct ieee80211_tx_pwr_env tx_pwr_env[IEEE80211_TPE_MAX_IE_COUNT];
  683. u8 tx_pwr_env_num;
  684. u8 pwr_reduction;
  685. bool eht_support;
  686. bool csa_active;
  687. bool mu_mimo_owner;
  688. struct ieee80211_chanctx_conf __rcu *chanctx_conf;
  689. bool color_change_active;
  690. u8 color_change_color;
  691. ANDROID_KABI_RESERVE(1);
  692. };
  693. /**
  694. * enum mac80211_tx_info_flags - flags to describe transmission information/status
  695. *
  696. * These flags are used with the @flags member of &ieee80211_tx_info.
  697. *
  698. * @IEEE80211_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame.
  699. * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence
  700. * number to this frame, taking care of not overwriting the fragment
  701. * number and increasing the sequence number only when the
  702. * IEEE80211_TX_CTL_FIRST_FRAGMENT flag is set. mac80211 will properly
  703. * assign sequence numbers to QoS-data frames but cannot do so correctly
  704. * for non-QoS-data and management frames because beacons need them from
  705. * that counter as well and mac80211 cannot guarantee proper sequencing.
  706. * If this flag is set, the driver should instruct the hardware to
  707. * assign a sequence number to the frame or assign one itself. Cf. IEEE
  708. * 802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for
  709. * beacons and always be clear for frames without a sequence number field.
  710. * @IEEE80211_TX_CTL_NO_ACK: tell the low level not to wait for an ack
  711. * @IEEE80211_TX_CTL_CLEAR_PS_FILT: clear powersave filter for destination
  712. * station
  713. * @IEEE80211_TX_CTL_FIRST_FRAGMENT: this is a first fragment of the frame
  714. * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
  715. * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU
  716. * @IEEE80211_TX_CTL_INJECTED: Frame was injected, internal to mac80211.
  717. * @IEEE80211_TX_STAT_TX_FILTERED: The frame was not transmitted
  718. * because the destination STA was in powersave mode. Note that to
  719. * avoid race conditions, the filter must be set by the hardware or
  720. * firmware upon receiving a frame that indicates that the station
  721. * went to sleep (must be done on device to filter frames already on
  722. * the queue) and may only be unset after mac80211 gives the OK for
  723. * that by setting the IEEE80211_TX_CTL_CLEAR_PS_FILT (see above),
  724. * since only then is it guaranteed that no more frames are in the
  725. * hardware queue.
  726. * @IEEE80211_TX_STAT_ACK: Frame was acknowledged
  727. * @IEEE80211_TX_STAT_AMPDU: The frame was aggregated, so status
  728. * is for the whole aggregation.
  729. * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned,
  730. * so consider using block ack request (BAR).
  731. * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be
  732. * set by rate control algorithms to indicate probe rate, will
  733. * be cleared for fragmented frames (except on the last fragment)
  734. * @IEEE80211_TX_INTFL_OFFCHAN_TX_OK: Internal to mac80211. Used to indicate
  735. * that a frame can be transmitted while the queues are stopped for
  736. * off-channel operation.
  737. * @IEEE80211_TX_CTL_HW_80211_ENCAP: This frame uses hardware encapsulation
  738. * (header conversion)
  739. * @IEEE80211_TX_INTFL_RETRIED: completely internal to mac80211,
  740. * used to indicate that a frame was already retried due to PS
  741. * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
  742. * used to indicate frame should not be encrypted
  743. * @IEEE80211_TX_CTL_NO_PS_BUFFER: This frame is a response to a poll
  744. * frame (PS-Poll or uAPSD) or a non-bufferable MMPDU and must
  745. * be sent although the station is in powersave mode.
  746. * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
  747. * transmit function after the current frame, this can be used
  748. * by drivers to kick the DMA queue only if unset or when the
  749. * queue gets full.
  750. * @IEEE80211_TX_INTFL_RETRANSMISSION: This frame is being retransmitted
  751. * after TX status because the destination was asleep, it must not
  752. * be modified again (no seqno assignment, crypto, etc.)
  753. * @IEEE80211_TX_INTFL_MLME_CONN_TX: This frame was transmitted by the MLME
  754. * code for connection establishment, this indicates that its status
  755. * should kick the MLME state machine.
  756. * @IEEE80211_TX_INTFL_NL80211_FRAME_TX: Frame was requested through nl80211
  757. * MLME command (internal to mac80211 to figure out whether to send TX
  758. * status to user space)
  759. * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame
  760. * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this
  761. * frame and selects the maximum number of streams that it can use.
  762. * @IEEE80211_TX_CTL_TX_OFFCHAN: Marks this packet to be transmitted on
  763. * the off-channel channel when a remain-on-channel offload is done
  764. * in hardware -- normal packets still flow and are expected to be
  765. * handled properly by the device.
  766. * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP
  767. * testing. It will be sent out with incorrect Michael MIC key to allow
  768. * TKIP countermeasures to be tested.
  769. * @IEEE80211_TX_CTL_NO_CCK_RATE: This frame will be sent at non CCK rate.
  770. * This flag is actually used for management frame especially for P2P
  771. * frames not being sent at CCK rate in 2GHz band.
  772. * @IEEE80211_TX_STATUS_EOSP: This packet marks the end of service period,
  773. * when its status is reported the service period ends. For frames in
  774. * an SP that mac80211 transmits, it is already set; for driver frames
  775. * the driver may set this flag. It is also used to do the same for
  776. * PS-Poll responses.
  777. * @IEEE80211_TX_CTL_USE_MINRATE: This frame will be sent at lowest rate.
  778. * This flag is used to send nullfunc frame at minimum rate when
  779. * the nullfunc is used for connection monitoring purpose.
  780. * @IEEE80211_TX_CTL_DONTFRAG: Don't fragment this packet even if it
  781. * would be fragmented by size (this is optional, only used for
  782. * monitor injection).
  783. * @IEEE80211_TX_STAT_NOACK_TRANSMITTED: A frame that was marked with
  784. * IEEE80211_TX_CTL_NO_ACK has been successfully transmitted without
  785. * any errors (like issues specific to the driver/HW).
  786. * This flag must not be set for frames that don't request no-ack
  787. * behaviour with IEEE80211_TX_CTL_NO_ACK.
  788. *
  789. * Note: If you have to add new flags to the enumeration, then don't
  790. * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
  791. */
  792. enum mac80211_tx_info_flags {
  793. IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0),
  794. IEEE80211_TX_CTL_ASSIGN_SEQ = BIT(1),
  795. IEEE80211_TX_CTL_NO_ACK = BIT(2),
  796. IEEE80211_TX_CTL_CLEAR_PS_FILT = BIT(3),
  797. IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(4),
  798. IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(5),
  799. IEEE80211_TX_CTL_AMPDU = BIT(6),
  800. IEEE80211_TX_CTL_INJECTED = BIT(7),
  801. IEEE80211_TX_STAT_TX_FILTERED = BIT(8),
  802. IEEE80211_TX_STAT_ACK = BIT(9),
  803. IEEE80211_TX_STAT_AMPDU = BIT(10),
  804. IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(11),
  805. IEEE80211_TX_CTL_RATE_CTRL_PROBE = BIT(12),
  806. IEEE80211_TX_INTFL_OFFCHAN_TX_OK = BIT(13),
  807. IEEE80211_TX_CTL_HW_80211_ENCAP = BIT(14),
  808. IEEE80211_TX_INTFL_RETRIED = BIT(15),
  809. IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16),
  810. IEEE80211_TX_CTL_NO_PS_BUFFER = BIT(17),
  811. IEEE80211_TX_CTL_MORE_FRAMES = BIT(18),
  812. IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19),
  813. IEEE80211_TX_INTFL_MLME_CONN_TX = BIT(20),
  814. IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21),
  815. IEEE80211_TX_CTL_LDPC = BIT(22),
  816. IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24),
  817. IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25),
  818. IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26),
  819. IEEE80211_TX_CTL_NO_CCK_RATE = BIT(27),
  820. IEEE80211_TX_STATUS_EOSP = BIT(28),
  821. IEEE80211_TX_CTL_USE_MINRATE = BIT(29),
  822. IEEE80211_TX_CTL_DONTFRAG = BIT(30),
  823. IEEE80211_TX_STAT_NOACK_TRANSMITTED = BIT(31),
  824. };
  825. #define IEEE80211_TX_CTL_STBC_SHIFT 23
  826. #define IEEE80211_TX_RC_S1G_MCS IEEE80211_TX_RC_VHT_MCS
  827. /**
  828. * enum mac80211_tx_control_flags - flags to describe transmit control
  829. *
  830. * @IEEE80211_TX_CTRL_PORT_CTRL_PROTO: this frame is a port control
  831. * protocol frame (e.g. EAP)
  832. * @IEEE80211_TX_CTRL_PS_RESPONSE: This frame is a response to a poll
  833. * frame (PS-Poll or uAPSD).
  834. * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
  835. * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame
  836. * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path
  837. * @IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP: This frame skips mesh path lookup
  838. * @IEEE80211_TX_INTCFL_NEED_TXPROCESSING: completely internal to mac80211,
  839. * used to indicate that a pending frame requires TX processing before
  840. * it can be sent out.
  841. * @IEEE80211_TX_CTRL_NO_SEQNO: Do not overwrite the sequence number that
  842. * has already been assigned to this frame.
  843. * @IEEE80211_TX_CTRL_DONT_REORDER: This frame should not be reordered
  844. * relative to other frames that have this flag set, independent
  845. * of their QoS TID or other priority field values.
  846. * @IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX: first MLO TX, used mostly internally
  847. * for sequence number assignment
  848. * @IEEE80211_TX_CTRL_MLO_LINK: If not @IEEE80211_LINK_UNSPECIFIED, this
  849. * frame should be transmitted on the specific link. This really is
  850. * only relevant for frames that do not have data present, and is
  851. * also not used for 802.3 format frames. Note that even if the frame
  852. * is on a specific link, address translation might still apply if
  853. * it's intended for an MLD.
  854. *
  855. * These flags are used in tx_info->control.flags.
  856. */
  857. enum mac80211_tx_control_flags {
  858. IEEE80211_TX_CTRL_PORT_CTRL_PROTO = BIT(0),
  859. IEEE80211_TX_CTRL_PS_RESPONSE = BIT(1),
  860. IEEE80211_TX_CTRL_RATE_INJECT = BIT(2),
  861. IEEE80211_TX_CTRL_AMSDU = BIT(3),
  862. IEEE80211_TX_CTRL_FAST_XMIT = BIT(4),
  863. IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP = BIT(5),
  864. IEEE80211_TX_INTCFL_NEED_TXPROCESSING = BIT(6),
  865. IEEE80211_TX_CTRL_NO_SEQNO = BIT(7),
  866. IEEE80211_TX_CTRL_DONT_REORDER = BIT(8),
  867. IEEE80211_TX_CTRL_MCAST_MLO_FIRST_TX = BIT(9),
  868. IEEE80211_TX_CTRL_MLO_LINK = 0xf0000000,
  869. };
  870. #define IEEE80211_LINK_UNSPECIFIED 0xf
  871. #define IEEE80211_TX_CTRL_MLO_LINK_UNSPEC \
  872. u32_encode_bits(IEEE80211_LINK_UNSPECIFIED, \
  873. IEEE80211_TX_CTRL_MLO_LINK)
  874. /**
  875. * enum mac80211_tx_status_flags - flags to describe transmit status
  876. *
  877. * @IEEE80211_TX_STATUS_ACK_SIGNAL_VALID: ACK signal is valid
  878. *
  879. * These flags are used in tx_info->status.flags.
  880. */
  881. enum mac80211_tx_status_flags {
  882. IEEE80211_TX_STATUS_ACK_SIGNAL_VALID = BIT(0),
  883. };
  884. /*
  885. * This definition is used as a mask to clear all temporary flags, which are
  886. * set by the tx handlers for each transmission attempt by the mac80211 stack.
  887. */
  888. #define IEEE80211_TX_TEMPORARY_FLAGS (IEEE80211_TX_CTL_NO_ACK | \
  889. IEEE80211_TX_CTL_CLEAR_PS_FILT | IEEE80211_TX_CTL_FIRST_FRAGMENT | \
  890. IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \
  891. IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \
  892. IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \
  893. IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_NO_PS_BUFFER | \
  894. IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \
  895. IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP)
  896. /**
  897. * enum mac80211_rate_control_flags - per-rate flags set by the
  898. * Rate Control algorithm.
  899. *
  900. * These flags are set by the Rate control algorithm for each rate during tx,
  901. * in the @flags member of struct ieee80211_tx_rate.
  902. *
  903. * @IEEE80211_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
  904. * @IEEE80211_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
  905. * This is set if the current BSS requires ERP protection.
  906. * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
  907. * @IEEE80211_TX_RC_MCS: HT rate.
  908. * @IEEE80211_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is split
  909. * into a higher 4 bits (Nss) and lower 4 bits (MCS number)
  910. * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in
  911. * Greenfield mode.
  912. * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz.
  913. * @IEEE80211_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission
  914. * @IEEE80211_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission
  915. * (80+80 isn't supported yet)
  916. * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the
  917. * adjacent 20 MHz channels, if the current channel type is
  918. * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
  919. * @IEEE80211_TX_RC_SHORT_GI: Short Guard interval should be used for this rate.
  920. */
  921. enum mac80211_rate_control_flags {
  922. IEEE80211_TX_RC_USE_RTS_CTS = BIT(0),
  923. IEEE80211_TX_RC_USE_CTS_PROTECT = BIT(1),
  924. IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
  925. /* rate index is an HT/VHT MCS instead of an index */
  926. IEEE80211_TX_RC_MCS = BIT(3),
  927. IEEE80211_TX_RC_GREEN_FIELD = BIT(4),
  928. IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(5),
  929. IEEE80211_TX_RC_DUP_DATA = BIT(6),
  930. IEEE80211_TX_RC_SHORT_GI = BIT(7),
  931. IEEE80211_TX_RC_VHT_MCS = BIT(8),
  932. IEEE80211_TX_RC_80_MHZ_WIDTH = BIT(9),
  933. IEEE80211_TX_RC_160_MHZ_WIDTH = BIT(10),
  934. };
  935. /* there are 40 bytes if you don't need the rateset to be kept */
  936. #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
  937. /* if you do need the rateset, then you have less space */
  938. #define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24
  939. /* maximum number of rate stages */
  940. #define IEEE80211_TX_MAX_RATES 4
  941. /* maximum number of rate table entries */
  942. #define IEEE80211_TX_RATE_TABLE_SIZE 4
  943. /**
  944. * struct ieee80211_tx_rate - rate selection/status
  945. *
  946. * @idx: rate index to attempt to send with
  947. * @flags: rate control flags (&enum mac80211_rate_control_flags)
  948. * @count: number of tries in this rate before going to the next rate
  949. *
  950. * A value of -1 for @idx indicates an invalid rate and, if used
  951. * in an array of retry rates, that no more rates should be tried.
  952. *
  953. * When used for transmit status reporting, the driver should
  954. * always report the rate along with the flags it used.
  955. *
  956. * &struct ieee80211_tx_info contains an array of these structs
  957. * in the control information, and it will be filled by the rate
  958. * control algorithm according to what should be sent. For example,
  959. * if this array contains, in the format { <idx>, <count> } the
  960. * information::
  961. *
  962. * { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 }
  963. *
  964. * then this means that the frame should be transmitted
  965. * up to twice at rate 3, up to twice at rate 2, and up to four
  966. * times at rate 1 if it doesn't get acknowledged. Say it gets
  967. * acknowledged by the peer after the fifth attempt, the status
  968. * information should then contain::
  969. *
  970. * { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ...
  971. *
  972. * since it was transmitted twice at rate 3, twice at rate 2
  973. * and once at rate 1 after which we received an acknowledgement.
  974. */
  975. struct ieee80211_tx_rate {
  976. s8 idx;
  977. u16 count:5,
  978. flags:11;
  979. } __packed;
  980. #define IEEE80211_MAX_TX_RETRY 31
  981. static inline void ieee80211_rate_set_vht(struct ieee80211_tx_rate *rate,
  982. u8 mcs, u8 nss)
  983. {
  984. WARN_ON(mcs & ~0xF);
  985. WARN_ON((nss - 1) & ~0x7);
  986. rate->idx = ((nss - 1) << 4) | mcs;
  987. }
  988. static inline u8
  989. ieee80211_rate_get_vht_mcs(const struct ieee80211_tx_rate *rate)
  990. {
  991. return rate->idx & 0xF;
  992. }
  993. static inline u8
  994. ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
  995. {
  996. return (rate->idx >> 4) + 1;
  997. }
  998. /**
  999. * struct ieee80211_tx_info - skb transmit information
  1000. *
  1001. * This structure is placed in skb->cb for three uses:
  1002. * (1) mac80211 TX control - mac80211 tells the driver what to do
  1003. * (2) driver internal use (if applicable)
  1004. * (3) TX status information - driver tells mac80211 what happened
  1005. *
  1006. * @flags: transmit info flags, defined above
  1007. * @band: the band to transmit on (use e.g. for checking for races),
  1008. * not valid if the interface is an MLD since we won't know which
  1009. * link the frame will be transmitted on
  1010. * @hw_queue: HW queue to put the frame on, skb_get_queue_mapping() gives the AC
  1011. * @ack_frame_id: internal frame ID for TX status, used internally
  1012. * @tx_time_est: TX time estimate in units of 4us, used internally
  1013. * @control: union part for control data
  1014. * @control.rates: TX rates array to try
  1015. * @control.rts_cts_rate_idx: rate for RTS or CTS
  1016. * @control.use_rts: use RTS
  1017. * @control.use_cts_prot: use RTS/CTS
  1018. * @control.short_preamble: use short preamble (CCK only)
  1019. * @control.skip_table: skip externally configured rate table
  1020. * @control.jiffies: timestamp for expiry on powersave clients
  1021. * @control.vif: virtual interface (may be NULL)
  1022. * @control.hw_key: key to encrypt with (may be NULL)
  1023. * @control.flags: control flags, see &enum mac80211_tx_control_flags
  1024. * @control.enqueue_time: enqueue time (for iTXQs)
  1025. * @driver_rates: alias to @control.rates to reserve space
  1026. * @pad: padding
  1027. * @rate_driver_data: driver use area if driver needs @control.rates
  1028. * @status: union part for status data
  1029. * @status.rates: attempted rates
  1030. * @status.ack_signal: ACK signal
  1031. * @status.ampdu_ack_len: AMPDU ack length
  1032. * @status.ampdu_len: AMPDU length
  1033. * @status.antenna: (legacy, kept only for iwlegacy)
  1034. * @status.tx_time: airtime consumed for transmission; note this is only
  1035. * used for WMM AC, not for airtime fairness
  1036. * @status.flags: status flags, see &enum mac80211_tx_status_flags
  1037. * @status.status_driver_data: driver use area
  1038. * @ack: union part for pure ACK data
  1039. * @ack.cookie: cookie for the ACK
  1040. * @driver_data: array of driver_data pointers
  1041. * @ampdu_ack_len: number of acked aggregated frames.
  1042. * relevant only if IEEE80211_TX_STAT_AMPDU was set.
  1043. * @ampdu_len: number of aggregated frames.
  1044. * relevant only if IEEE80211_TX_STAT_AMPDU was set.
  1045. * @ack_signal: signal strength of the ACK frame
  1046. */
  1047. struct ieee80211_tx_info {
  1048. /* common information */
  1049. u32 flags;
  1050. u32 band:3,
  1051. ack_frame_id:13,
  1052. hw_queue:4,
  1053. tx_time_est:10;
  1054. /* 2 free bits */
  1055. union {
  1056. struct {
  1057. union {
  1058. /* rate control */
  1059. struct {
  1060. struct ieee80211_tx_rate rates[
  1061. IEEE80211_TX_MAX_RATES];
  1062. s8 rts_cts_rate_idx;
  1063. u8 use_rts:1;
  1064. u8 use_cts_prot:1;
  1065. u8 short_preamble:1;
  1066. u8 skip_table:1;
  1067. /* 2 bytes free */
  1068. };
  1069. /* only needed before rate control */
  1070. unsigned long jiffies;
  1071. };
  1072. /* NB: vif can be NULL for injected frames */
  1073. struct ieee80211_vif *vif;
  1074. struct ieee80211_key_conf *hw_key;
  1075. u32 flags;
  1076. codel_time_t enqueue_time;
  1077. } control;
  1078. struct {
  1079. u64 cookie;
  1080. } ack;
  1081. struct {
  1082. struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
  1083. s32 ack_signal;
  1084. u8 ampdu_ack_len;
  1085. u8 ampdu_len;
  1086. u8 antenna;
  1087. u8 pad;
  1088. u16 tx_time;
  1089. u8 flags;
  1090. u8 pad2;
  1091. void *status_driver_data[16 / sizeof(void *)];
  1092. } status;
  1093. struct {
  1094. struct ieee80211_tx_rate driver_rates[
  1095. IEEE80211_TX_MAX_RATES];
  1096. u8 pad[4];
  1097. void *rate_driver_data[
  1098. IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
  1099. };
  1100. ANDROID_KABI_RESERVE(1);
  1101. void *driver_data[
  1102. IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
  1103. };
  1104. };
  1105. static inline u16
  1106. ieee80211_info_set_tx_time_est(struct ieee80211_tx_info *info, u16 tx_time_est)
  1107. {
  1108. /* We only have 10 bits in tx_time_est, so store airtime
  1109. * in increments of 4us and clamp the maximum to 2**12-1
  1110. */
  1111. info->tx_time_est = min_t(u16, tx_time_est, 4095) >> 2;
  1112. return info->tx_time_est << 2;
  1113. }
  1114. static inline u16
  1115. ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info)
  1116. {
  1117. return info->tx_time_est << 2;
  1118. }
  1119. /***
  1120. * struct ieee80211_rate_status - mrr stage for status path
  1121. *
  1122. * This struct is used in struct ieee80211_tx_status to provide drivers a
  1123. * dynamic way to report about used rates and power levels per packet.
  1124. *
  1125. * @rate_idx The actual used rate.
  1126. * @try_count How often the rate was tried.
  1127. * @tx_power_idx An idx into the ieee80211_hw->tx_power_levels list of the
  1128. * corresponding wifi hardware. The idx shall point to the power level
  1129. * that was used when sending the packet.
  1130. */
  1131. struct ieee80211_rate_status {
  1132. struct rate_info rate_idx;
  1133. u8 try_count;
  1134. u8 tx_power_idx;
  1135. };
  1136. /**
  1137. * struct ieee80211_tx_status - extended tx status info for rate control
  1138. *
  1139. * @sta: Station that the packet was transmitted for
  1140. * @info: Basic tx status information
  1141. * @skb: Packet skb (can be NULL if not provided by the driver)
  1142. * @rates: Mrr stages that were used when sending the packet
  1143. * @n_rates: Number of mrr stages (count of instances for @rates)
  1144. * @free_list: list where processed skbs are stored to be free'd by the driver
  1145. * @ack_hwtstamp: Hardware timestamp of the received ack in nanoseconds
  1146. * Only needed for Timing measurement and Fine timing measurement action
  1147. * frames. Only reported by devices that have timestamping enabled.
  1148. */
  1149. struct ieee80211_tx_status {
  1150. struct ieee80211_sta *sta;
  1151. struct ieee80211_tx_info *info;
  1152. struct sk_buff *skb;
  1153. struct ieee80211_rate_status *rates;
  1154. ktime_t ack_hwtstamp;
  1155. u8 n_rates;
  1156. struct list_head *free_list;
  1157. };
  1158. /**
  1159. * struct ieee80211_scan_ies - descriptors for different blocks of IEs
  1160. *
  1161. * This structure is used to point to different blocks of IEs in HW scan
  1162. * and scheduled scan. These blocks contain the IEs passed by userspace
  1163. * and the ones generated by mac80211.
  1164. *
  1165. * @ies: pointers to band specific IEs.
  1166. * @len: lengths of band_specific IEs.
  1167. * @common_ies: IEs for all bands (especially vendor specific ones)
  1168. * @common_ie_len: length of the common_ies
  1169. */
  1170. struct ieee80211_scan_ies {
  1171. const u8 *ies[NUM_NL80211_BANDS];
  1172. size_t len[NUM_NL80211_BANDS];
  1173. const u8 *common_ies;
  1174. size_t common_ie_len;
  1175. };
  1176. static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb)
  1177. {
  1178. return (struct ieee80211_tx_info *)skb->cb;
  1179. }
  1180. static inline struct ieee80211_rx_status *IEEE80211_SKB_RXCB(struct sk_buff *skb)
  1181. {
  1182. return (struct ieee80211_rx_status *)skb->cb;
  1183. }
  1184. /**
  1185. * ieee80211_tx_info_clear_status - clear TX status
  1186. *
  1187. * @info: The &struct ieee80211_tx_info to be cleared.
  1188. *
  1189. * When the driver passes an skb back to mac80211, it must report
  1190. * a number of things in TX status. This function clears everything
  1191. * in the TX status but the rate control information (it does clear
  1192. * the count since you need to fill that in anyway).
  1193. *
  1194. * NOTE: While the rates array is kept intact, this will wipe all of the
  1195. * driver_data fields in info, so it's up to the driver to restore
  1196. * any fields it needs after calling this helper.
  1197. */
  1198. static inline void
  1199. ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
  1200. {
  1201. int i;
  1202. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
  1203. offsetof(struct ieee80211_tx_info, control.rates));
  1204. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
  1205. offsetof(struct ieee80211_tx_info, driver_rates));
  1206. BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != 8);
  1207. /* clear the rate counts */
  1208. for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
  1209. info->status.rates[i].count = 0;
  1210. memset_after(&info->status, 0, rates);
  1211. }
  1212. /**
  1213. * enum mac80211_rx_flags - receive flags
  1214. *
  1215. * These flags are used with the @flag member of &struct ieee80211_rx_status.
  1216. * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
  1217. * Use together with %RX_FLAG_MMIC_STRIPPED.
  1218. * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
  1219. * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
  1220. * verification has been done by the hardware.
  1221. * @RX_FLAG_IV_STRIPPED: The IV and ICV are stripped from this frame.
  1222. * If this flag is set, the stack cannot do any replay detection
  1223. * hence the driver or hardware will have to do that.
  1224. * @RX_FLAG_PN_VALIDATED: Currently only valid for CCMP/GCMP frames, this
  1225. * flag indicates that the PN was verified for replay protection.
  1226. * Note that this flag is also currently only supported when a frame
  1227. * is also decrypted (ie. @RX_FLAG_DECRYPTED must be set)
  1228. * @RX_FLAG_DUP_VALIDATED: The driver should set this flag if it did
  1229. * de-duplication by itself.
  1230. * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
  1231. * the frame.
  1232. * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
  1233. * the frame.
  1234. * @RX_FLAG_MACTIME_START: The timestamp passed in the RX status (@mactime
  1235. * field) is valid and contains the time the first symbol of the MPDU
  1236. * was received. This is useful in monitor mode and for proper IBSS
  1237. * merging.
  1238. * @RX_FLAG_MACTIME_END: The timestamp passed in the RX status (@mactime
  1239. * field) is valid and contains the time the last symbol of the MPDU
  1240. * (including FCS) was received.
  1241. * @RX_FLAG_MACTIME_PLCP_START: The timestamp passed in the RX status (@mactime
  1242. * field) is valid and contains the time the SYNC preamble was received.
  1243. * @RX_FLAG_NO_SIGNAL_VAL: The signal strength value is not present.
  1244. * Valid only for data frames (mainly A-MPDU)
  1245. * @RX_FLAG_AMPDU_DETAILS: A-MPDU details are known, in particular the reference
  1246. * number (@ampdu_reference) must be populated and be a distinct number for
  1247. * each A-MPDU
  1248. * @RX_FLAG_AMPDU_LAST_KNOWN: last subframe is known, should be set on all
  1249. * subframes of a single A-MPDU
  1250. * @RX_FLAG_AMPDU_IS_LAST: this subframe is the last subframe of the A-MPDU
  1251. * @RX_FLAG_AMPDU_DELIM_CRC_ERROR: A delimiter CRC error has been detected
  1252. * on this subframe
  1253. * @RX_FLAG_AMPDU_DELIM_CRC_KNOWN: The delimiter CRC field is known (the CRC
  1254. * is stored in the @ampdu_delimiter_crc field)
  1255. * @RX_FLAG_MIC_STRIPPED: The mic was stripped of this packet. Decryption was
  1256. * done by the hardware
  1257. * @RX_FLAG_ONLY_MONITOR: Report frame only to monitor interfaces without
  1258. * processing it in any regular way.
  1259. * This is useful if drivers offload some frames but still want to report
  1260. * them for sniffing purposes.
  1261. * @RX_FLAG_SKIP_MONITOR: Process and report frame to all interfaces except
  1262. * monitor interfaces.
  1263. * This is useful if drivers offload some frames but still want to report
  1264. * them for sniffing purposes.
  1265. * @RX_FLAG_AMSDU_MORE: Some drivers may prefer to report separate A-MSDU
  1266. * subframes instead of a one huge frame for performance reasons.
  1267. * All, but the last MSDU from an A-MSDU should have this flag set. E.g.
  1268. * if an A-MSDU has 3 frames, the first 2 must have the flag set, while
  1269. * the 3rd (last) one must not have this flag set. The flag is used to
  1270. * deal with retransmission/duplication recovery properly since A-MSDU
  1271. * subframes share the same sequence number. Reported subframes can be
  1272. * either regular MSDU or singly A-MSDUs. Subframes must not be
  1273. * interleaved with other frames.
  1274. * @RX_FLAG_RADIOTAP_VENDOR_DATA: This frame contains vendor-specific
  1275. * radiotap data in the skb->data (before the frame) as described by
  1276. * the &struct ieee80211_vendor_radiotap.
  1277. * @RX_FLAG_ALLOW_SAME_PN: Allow the same PN as same packet before.
  1278. * This is used for AMSDU subframes which can have the same PN as
  1279. * the first subframe.
  1280. * @RX_FLAG_ICV_STRIPPED: The ICV is stripped from this frame. CRC checking must
  1281. * be done in the hardware.
  1282. * @RX_FLAG_AMPDU_EOF_BIT: Value of the EOF bit in the A-MPDU delimiter for this
  1283. * frame
  1284. * @RX_FLAG_AMPDU_EOF_BIT_KNOWN: The EOF value is known
  1285. * @RX_FLAG_RADIOTAP_HE: HE radiotap data is present
  1286. * (&struct ieee80211_radiotap_he, mac80211 will fill in
  1287. *
  1288. * - DATA3_DATA_MCS
  1289. * - DATA3_DATA_DCM
  1290. * - DATA3_CODING
  1291. * - DATA5_GI
  1292. * - DATA5_DATA_BW_RU_ALLOC
  1293. * - DATA6_NSTS
  1294. * - DATA3_STBC
  1295. *
  1296. * from the RX info data, so leave those zeroed when building this data)
  1297. * @RX_FLAG_RADIOTAP_HE_MU: HE MU radiotap data is present
  1298. * (&struct ieee80211_radiotap_he_mu)
  1299. * @RX_FLAG_RADIOTAP_LSIG: L-SIG radiotap data is present
  1300. * @RX_FLAG_NO_PSDU: use the frame only for radiotap reporting, with
  1301. * the "0-length PSDU" field included there. The value for it is
  1302. * in &struct ieee80211_rx_status. Note that if this value isn't
  1303. * known the frame shouldn't be reported.
  1304. * @RX_FLAG_8023: the frame has an 802.3 header (decap offload performed by
  1305. * hardware or driver)
  1306. */
  1307. enum mac80211_rx_flags {
  1308. RX_FLAG_MMIC_ERROR = BIT(0),
  1309. RX_FLAG_DECRYPTED = BIT(1),
  1310. RX_FLAG_MACTIME_PLCP_START = BIT(2),
  1311. RX_FLAG_MMIC_STRIPPED = BIT(3),
  1312. RX_FLAG_IV_STRIPPED = BIT(4),
  1313. RX_FLAG_FAILED_FCS_CRC = BIT(5),
  1314. RX_FLAG_FAILED_PLCP_CRC = BIT(6),
  1315. RX_FLAG_MACTIME_START = BIT(7),
  1316. RX_FLAG_NO_SIGNAL_VAL = BIT(8),
  1317. RX_FLAG_AMPDU_DETAILS = BIT(9),
  1318. RX_FLAG_PN_VALIDATED = BIT(10),
  1319. RX_FLAG_DUP_VALIDATED = BIT(11),
  1320. RX_FLAG_AMPDU_LAST_KNOWN = BIT(12),
  1321. RX_FLAG_AMPDU_IS_LAST = BIT(13),
  1322. RX_FLAG_AMPDU_DELIM_CRC_ERROR = BIT(14),
  1323. RX_FLAG_AMPDU_DELIM_CRC_KNOWN = BIT(15),
  1324. RX_FLAG_MACTIME_END = BIT(16),
  1325. RX_FLAG_ONLY_MONITOR = BIT(17),
  1326. RX_FLAG_SKIP_MONITOR = BIT(18),
  1327. RX_FLAG_AMSDU_MORE = BIT(19),
  1328. RX_FLAG_RADIOTAP_VENDOR_DATA = BIT(20),
  1329. RX_FLAG_MIC_STRIPPED = BIT(21),
  1330. RX_FLAG_ALLOW_SAME_PN = BIT(22),
  1331. RX_FLAG_ICV_STRIPPED = BIT(23),
  1332. RX_FLAG_AMPDU_EOF_BIT = BIT(24),
  1333. RX_FLAG_AMPDU_EOF_BIT_KNOWN = BIT(25),
  1334. RX_FLAG_RADIOTAP_HE = BIT(26),
  1335. RX_FLAG_RADIOTAP_HE_MU = BIT(27),
  1336. RX_FLAG_RADIOTAP_LSIG = BIT(28),
  1337. RX_FLAG_NO_PSDU = BIT(29),
  1338. RX_FLAG_8023 = BIT(30),
  1339. };
  1340. /**
  1341. * enum mac80211_rx_encoding_flags - MCS & bandwidth flags
  1342. *
  1343. * @RX_ENC_FLAG_SHORTPRE: Short preamble was used for this frame
  1344. * @RX_ENC_FLAG_SHORT_GI: Short guard interval was used
  1345. * @RX_ENC_FLAG_HT_GF: This frame was received in a HT-greenfield transmission,
  1346. * if the driver fills this value it should add
  1347. * %IEEE80211_RADIOTAP_MCS_HAVE_FMT
  1348. * to @hw.radiotap_mcs_details to advertise that fact.
  1349. * @RX_ENC_FLAG_LDPC: LDPC was used
  1350. * @RX_ENC_FLAG_STBC_MASK: STBC 2 bit bitmask. 1 - Nss=1, 2 - Nss=2, 3 - Nss=3
  1351. * @RX_ENC_FLAG_BF: packet was beamformed
  1352. */
  1353. enum mac80211_rx_encoding_flags {
  1354. RX_ENC_FLAG_SHORTPRE = BIT(0),
  1355. RX_ENC_FLAG_SHORT_GI = BIT(2),
  1356. RX_ENC_FLAG_HT_GF = BIT(3),
  1357. RX_ENC_FLAG_STBC_MASK = BIT(4) | BIT(5),
  1358. RX_ENC_FLAG_LDPC = BIT(6),
  1359. RX_ENC_FLAG_BF = BIT(7),
  1360. };
  1361. #define RX_ENC_FLAG_STBC_SHIFT 4
  1362. enum mac80211_rx_encoding {
  1363. RX_ENC_LEGACY = 0,
  1364. RX_ENC_HT,
  1365. RX_ENC_VHT,
  1366. RX_ENC_HE,
  1367. };
  1368. /**
  1369. * struct ieee80211_rx_status - receive status
  1370. *
  1371. * The low-level driver should provide this information (the subset
  1372. * supported by hardware) to the 802.11 code with each received
  1373. * frame, in the skb's control buffer (cb).
  1374. *
  1375. * @mactime: value in microseconds of the 64-bit Time Synchronization Function
  1376. * (TSF) timer when the first data symbol (MPDU) arrived at the hardware.
  1377. * @boottime_ns: CLOCK_BOOTTIME timestamp the frame was received at, this is
  1378. * needed only for beacons and probe responses that update the scan cache.
  1379. * @ack_tx_hwtstamp: Hardware timestamp for the ack TX in nanoseconds. Only
  1380. * needed for Timing measurement and Fine timing measurement action frames.
  1381. * Only reported by devices that have timestamping enabled.
  1382. * @device_timestamp: arbitrary timestamp for the device, mac80211 doesn't use
  1383. * it but can store it and pass it back to the driver for synchronisation
  1384. * @band: the active band when this frame was received
  1385. * @freq: frequency the radio was tuned to when receiving this frame, in MHz
  1386. * This field must be set for management frames, but isn't strictly needed
  1387. * for data (other) frames - for those it only affects radiotap reporting.
  1388. * @freq_offset: @freq has a positive offset of 500Khz.
  1389. * @signal: signal strength when receiving this frame, either in dBm, in dB or
  1390. * unspecified depending on the hardware capabilities flags
  1391. * @IEEE80211_HW_SIGNAL_*
  1392. * @chains: bitmask of receive chains for which separate signal strength
  1393. * values were filled.
  1394. * @chain_signal: per-chain signal strength, in dBm (unlike @signal, doesn't
  1395. * support dB or unspecified units)
  1396. * @antenna: antenna used
  1397. * @rate_idx: index of data rate into band's supported rates or MCS index if
  1398. * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
  1399. * @nss: number of streams (VHT and HE only)
  1400. * @flag: %RX_FLAG_\*
  1401. * @encoding: &enum mac80211_rx_encoding
  1402. * @bw: &enum rate_info_bw
  1403. * @enc_flags: uses bits from &enum mac80211_rx_encoding_flags
  1404. * @he_ru: HE RU, from &enum nl80211_he_ru_alloc
  1405. * @he_gi: HE GI, from &enum nl80211_he_gi
  1406. * @he_dcm: HE DCM value
  1407. * @rx_flags: internal RX flags for mac80211
  1408. * @ampdu_reference: A-MPDU reference number, must be a different value for
  1409. * each A-MPDU but the same for each subframe within one A-MPDU
  1410. * @ampdu_delimiter_crc: A-MPDU delimiter CRC
  1411. * @zero_length_psdu_type: radiotap type of the 0-length PSDU
  1412. * @link_valid: if the link which is identified by @link_id is valid. This flag
  1413. * is set only when connection is MLO.
  1414. * @link_id: id of the link used to receive the packet. This is used along with
  1415. * @link_valid.
  1416. */
  1417. struct ieee80211_rx_status {
  1418. u64 mactime;
  1419. union {
  1420. u64 boottime_ns;
  1421. ktime_t ack_tx_hwtstamp;
  1422. };
  1423. u32 device_timestamp;
  1424. u32 ampdu_reference;
  1425. u32 flag;
  1426. u16 freq: 13, freq_offset: 1;
  1427. u8 enc_flags;
  1428. u8 encoding:2, bw:3, he_ru:3;
  1429. u8 he_gi:2, he_dcm:1;
  1430. u8 rate_idx;
  1431. u8 nss;
  1432. u8 rx_flags;
  1433. u8 band;
  1434. u8 antenna;
  1435. s8 signal;
  1436. u8 chains;
  1437. s8 chain_signal[IEEE80211_MAX_CHAINS];
  1438. u8 ampdu_delimiter_crc;
  1439. u8 zero_length_psdu_type;
  1440. u8 link_valid:1, link_id:4;
  1441. };
  1442. static inline u32
  1443. ieee80211_rx_status_to_khz(struct ieee80211_rx_status *rx_status)
  1444. {
  1445. return MHZ_TO_KHZ(rx_status->freq) +
  1446. (rx_status->freq_offset ? 500 : 0);
  1447. }
  1448. /**
  1449. * struct ieee80211_vendor_radiotap - vendor radiotap data information
  1450. * @present: presence bitmap for this vendor namespace
  1451. * (this could be extended in the future if any vendor needs more
  1452. * bits, the radiotap spec does allow for that)
  1453. * @align: radiotap vendor namespace alignment. This defines the needed
  1454. * alignment for the @data field below, not for the vendor namespace
  1455. * description itself (which has a fixed 2-byte alignment)
  1456. * Must be a power of two, and be set to at least 1!
  1457. * @oui: radiotap vendor namespace OUI
  1458. * @subns: radiotap vendor sub namespace
  1459. * @len: radiotap vendor sub namespace skip length, if alignment is done
  1460. * then that's added to this, i.e. this is only the length of the
  1461. * @data field.
  1462. * @pad: number of bytes of padding after the @data, this exists so that
  1463. * the skb data alignment can be preserved even if the data has odd
  1464. * length
  1465. * @data: the actual vendor namespace data
  1466. *
  1467. * This struct, including the vendor data, goes into the skb->data before
  1468. * the 802.11 header. It's split up in mac80211 using the align/oui/subns
  1469. * data.
  1470. */
  1471. struct ieee80211_vendor_radiotap {
  1472. u32 present;
  1473. u8 align;
  1474. u8 oui[3];
  1475. u8 subns;
  1476. u8 pad;
  1477. u16 len;
  1478. u8 data[];
  1479. } __packed;
  1480. /**
  1481. * enum ieee80211_conf_flags - configuration flags
  1482. *
  1483. * Flags to define PHY configuration options
  1484. *
  1485. * @IEEE80211_CONF_MONITOR: there's a monitor interface present -- use this
  1486. * to determine for example whether to calculate timestamps for packets
  1487. * or not, do not use instead of filter flags!
  1488. * @IEEE80211_CONF_PS: Enable 802.11 power save mode (managed mode only).
  1489. * This is the power save mode defined by IEEE 802.11-2007 section 11.2,
  1490. * meaning that the hardware still wakes up for beacons, is able to
  1491. * transmit frames and receive the possible acknowledgment frames.
  1492. * Not to be confused with hardware specific wakeup/sleep states,
  1493. * driver is responsible for that. See the section "Powersave support"
  1494. * for more.
  1495. * @IEEE80211_CONF_IDLE: The device is running, but idle; if the flag is set
  1496. * the driver should be prepared to handle configuration requests but
  1497. * may turn the device off as much as possible. Typically, this flag will
  1498. * be set when an interface is set UP but not associated or scanning, but
  1499. * it can also be unset in that case when monitor interfaces are active.
  1500. * @IEEE80211_CONF_OFFCHANNEL: The device is currently not on its main
  1501. * operating channel.
  1502. */
  1503. enum ieee80211_conf_flags {
  1504. IEEE80211_CONF_MONITOR = (1<<0),
  1505. IEEE80211_CONF_PS = (1<<1),
  1506. IEEE80211_CONF_IDLE = (1<<2),
  1507. IEEE80211_CONF_OFFCHANNEL = (1<<3),
  1508. };
  1509. /**
  1510. * enum ieee80211_conf_changed - denotes which configuration changed
  1511. *
  1512. * @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed
  1513. * @IEEE80211_CONF_CHANGE_MONITOR: the monitor flag changed
  1514. * @IEEE80211_CONF_CHANGE_PS: the PS flag or dynamic PS timeout changed
  1515. * @IEEE80211_CONF_CHANGE_POWER: the TX power changed
  1516. * @IEEE80211_CONF_CHANGE_CHANNEL: the channel/channel_type changed
  1517. * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed
  1518. * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed
  1519. * @IEEE80211_CONF_CHANGE_SMPS: Spatial multiplexing powersave mode changed
  1520. * Note that this is only valid if channel contexts are not used,
  1521. * otherwise each channel context has the number of chains listed.
  1522. */
  1523. enum ieee80211_conf_changed {
  1524. IEEE80211_CONF_CHANGE_SMPS = BIT(1),
  1525. IEEE80211_CONF_CHANGE_LISTEN_INTERVAL = BIT(2),
  1526. IEEE80211_CONF_CHANGE_MONITOR = BIT(3),
  1527. IEEE80211_CONF_CHANGE_PS = BIT(4),
  1528. IEEE80211_CONF_CHANGE_POWER = BIT(5),
  1529. IEEE80211_CONF_CHANGE_CHANNEL = BIT(6),
  1530. IEEE80211_CONF_CHANGE_RETRY_LIMITS = BIT(7),
  1531. IEEE80211_CONF_CHANGE_IDLE = BIT(8),
  1532. };
  1533. /**
  1534. * enum ieee80211_smps_mode - spatial multiplexing power save mode
  1535. *
  1536. * @IEEE80211_SMPS_AUTOMATIC: automatic
  1537. * @IEEE80211_SMPS_OFF: off
  1538. * @IEEE80211_SMPS_STATIC: static
  1539. * @IEEE80211_SMPS_DYNAMIC: dynamic
  1540. * @IEEE80211_SMPS_NUM_MODES: internal, don't use
  1541. */
  1542. enum ieee80211_smps_mode {
  1543. IEEE80211_SMPS_AUTOMATIC,
  1544. IEEE80211_SMPS_OFF,
  1545. IEEE80211_SMPS_STATIC,
  1546. IEEE80211_SMPS_DYNAMIC,
  1547. /* keep last */
  1548. IEEE80211_SMPS_NUM_MODES,
  1549. };
  1550. /**
  1551. * struct ieee80211_conf - configuration of the device
  1552. *
  1553. * This struct indicates how the driver shall configure the hardware.
  1554. *
  1555. * @flags: configuration flags defined above
  1556. *
  1557. * @listen_interval: listen interval in units of beacon interval
  1558. * @ps_dtim_period: The DTIM period of the AP we're connected to, for use
  1559. * in power saving. Power saving will not be enabled until a beacon
  1560. * has been received and the DTIM period is known.
  1561. * @dynamic_ps_timeout: The dynamic powersave timeout (in ms), see the
  1562. * powersave documentation below. This variable is valid only when
  1563. * the CONF_PS flag is set.
  1564. *
  1565. * @power_level: requested transmit power (in dBm), backward compatibility
  1566. * value only that is set to the minimum of all interfaces
  1567. *
  1568. * @chandef: the channel definition to tune to
  1569. * @radar_enabled: whether radar detection is enabled
  1570. *
  1571. * @long_frame_max_tx_count: Maximum number of transmissions for a "long" frame
  1572. * (a frame not RTS protected), called "dot11LongRetryLimit" in 802.11,
  1573. * but actually means the number of transmissions not the number of retries
  1574. * @short_frame_max_tx_count: Maximum number of transmissions for a "short"
  1575. * frame, called "dot11ShortRetryLimit" in 802.11, but actually means the
  1576. * number of transmissions not the number of retries
  1577. *
  1578. * @smps_mode: spatial multiplexing powersave mode; note that
  1579. * %IEEE80211_SMPS_STATIC is used when the device is not
  1580. * configured for an HT channel.
  1581. * Note that this is only valid if channel contexts are not used,
  1582. * otherwise each channel context has the number of chains listed.
  1583. */
  1584. struct ieee80211_conf {
  1585. u32 flags;
  1586. int power_level, dynamic_ps_timeout;
  1587. u16 listen_interval;
  1588. u8 ps_dtim_period;
  1589. u8 long_frame_max_tx_count, short_frame_max_tx_count;
  1590. struct cfg80211_chan_def chandef;
  1591. bool radar_enabled;
  1592. enum ieee80211_smps_mode smps_mode;
  1593. ANDROID_KABI_RESERVE(1);
  1594. };
  1595. /**
  1596. * struct ieee80211_channel_switch - holds the channel switch data
  1597. *
  1598. * The information provided in this structure is required for channel switch
  1599. * operation.
  1600. *
  1601. * @timestamp: value in microseconds of the 64-bit Time Synchronization
  1602. * Function (TSF) timer when the frame containing the channel switch
  1603. * announcement was received. This is simply the rx.mactime parameter
  1604. * the driver passed into mac80211.
  1605. * @device_timestamp: arbitrary timestamp for the device, this is the
  1606. * rx.device_timestamp parameter the driver passed to mac80211.
  1607. * @block_tx: Indicates whether transmission must be blocked before the
  1608. * scheduled channel switch, as indicated by the AP.
  1609. * @chandef: the new channel to switch to
  1610. * @count: the number of TBTT's until the channel switch event
  1611. * @delay: maximum delay between the time the AP transmitted the last beacon in
  1612. * current channel and the expected time of the first beacon in the new
  1613. * channel, expressed in TU.
  1614. */
  1615. struct ieee80211_channel_switch {
  1616. u64 timestamp;
  1617. u32 device_timestamp;
  1618. bool block_tx;
  1619. struct cfg80211_chan_def chandef;
  1620. u8 count;
  1621. u32 delay;
  1622. };
  1623. /**
  1624. * enum ieee80211_vif_flags - virtual interface flags
  1625. *
  1626. * @IEEE80211_VIF_BEACON_FILTER: the device performs beacon filtering
  1627. * on this virtual interface to avoid unnecessary CPU wakeups
  1628. * @IEEE80211_VIF_SUPPORTS_CQM_RSSI: the device can do connection quality
  1629. * monitoring on this virtual interface -- i.e. it can monitor
  1630. * connection quality related parameters, such as the RSSI level and
  1631. * provide notifications if configured trigger levels are reached.
  1632. * @IEEE80211_VIF_SUPPORTS_UAPSD: The device can do U-APSD for this
  1633. * interface. This flag should be set during interface addition,
  1634. * but may be set/cleared as late as authentication to an AP. It is
  1635. * only valid for managed/station mode interfaces.
  1636. * @IEEE80211_VIF_GET_NOA_UPDATE: request to handle NOA attributes
  1637. * and send P2P_PS notification to the driver if NOA changed, even
  1638. * this is not pure P2P vif.
  1639. */
  1640. enum ieee80211_vif_flags {
  1641. IEEE80211_VIF_BEACON_FILTER = BIT(0),
  1642. IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1),
  1643. IEEE80211_VIF_SUPPORTS_UAPSD = BIT(2),
  1644. IEEE80211_VIF_GET_NOA_UPDATE = BIT(3),
  1645. };
  1646. /**
  1647. * enum ieee80211_offload_flags - virtual interface offload flags
  1648. *
  1649. * @IEEE80211_OFFLOAD_ENCAP_ENABLED: tx encapsulation offload is enabled
  1650. * The driver supports sending frames passed as 802.3 frames by mac80211.
  1651. * It must also support sending 802.11 packets for the same interface.
  1652. * @IEEE80211_OFFLOAD_ENCAP_4ADDR: support 4-address mode encapsulation offload
  1653. * @IEEE80211_OFFLOAD_DECAP_ENABLED: rx encapsulation offload is enabled
  1654. * The driver supports passing received 802.11 frames as 802.3 frames to
  1655. * mac80211.
  1656. */
  1657. enum ieee80211_offload_flags {
  1658. IEEE80211_OFFLOAD_ENCAP_ENABLED = BIT(0),
  1659. IEEE80211_OFFLOAD_ENCAP_4ADDR = BIT(1),
  1660. IEEE80211_OFFLOAD_DECAP_ENABLED = BIT(2),
  1661. };
  1662. /**
  1663. * struct ieee80211_vif_cfg - interface configuration
  1664. * @assoc: association status
  1665. * @ibss_joined: indicates whether this station is part of an IBSS or not
  1666. * @ibss_creator: indicates if a new IBSS network is being created
  1667. * @ps: power-save mode (STA only). This flag is NOT affected by
  1668. * offchannel/dynamic_ps operations.
  1669. * @aid: association ID number, valid only when @assoc is true
  1670. * @arp_addr_list: List of IPv4 addresses for hardware ARP filtering. The
  1671. * may filter ARP queries targeted for other addresses than listed here.
  1672. * The driver must allow ARP queries targeted for all address listed here
  1673. * to pass through. An empty list implies no ARP queries need to pass.
  1674. * @arp_addr_cnt: Number of addresses currently on the list. Note that this
  1675. * may be larger than %IEEE80211_BSS_ARP_ADDR_LIST_LEN (the arp_addr_list
  1676. * array size), it's up to the driver what to do in that case.
  1677. * @ssid: The SSID of the current vif. Valid in AP and IBSS mode.
  1678. * @ssid_len: Length of SSID given in @ssid.
  1679. * @s1g: BSS is S1G BSS (affects Association Request format).
  1680. * @idle: This interface is idle. There's also a global idle flag in the
  1681. * hardware config which may be more appropriate depending on what
  1682. * your driver/device needs to do.
  1683. * @ap_addr: AP MLD address, or BSSID for non-MLO connections
  1684. * (station mode only)
  1685. */
  1686. struct ieee80211_vif_cfg {
  1687. /* association related data */
  1688. bool assoc, ibss_joined;
  1689. bool ibss_creator;
  1690. bool ps;
  1691. u16 aid;
  1692. __be32 arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN];
  1693. int arp_addr_cnt;
  1694. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1695. size_t ssid_len;
  1696. bool s1g;
  1697. bool idle;
  1698. u8 ap_addr[ETH_ALEN] __aligned(2);
  1699. };
  1700. /**
  1701. * struct ieee80211_vif - per-interface data
  1702. *
  1703. * Data in this structure is continually present for driver
  1704. * use during the life of a virtual interface.
  1705. *
  1706. * @type: type of this virtual interface
  1707. * @cfg: vif configuration, see &struct ieee80211_vif_cfg
  1708. * @bss_conf: BSS configuration for this interface, either our own
  1709. * or the BSS we're associated to
  1710. * @link_conf: in case of MLD, the per-link BSS configuration,
  1711. * indexed by link ID
  1712. * @valid_links: bitmap of valid links, or 0 for non-MLO.
  1713. * @active_links: The bitmap of active links, or 0 for non-MLO.
  1714. * The driver shouldn't change this directly, but use the
  1715. * API calls meant for that purpose.
  1716. * @addr: address of this interface
  1717. * @p2p: indicates whether this AP or STA interface is a p2p
  1718. * interface, i.e. a GO or p2p-sta respectively
  1719. * @driver_flags: flags/capabilities the driver has for this interface,
  1720. * these need to be set (or cleared) when the interface is added
  1721. * or, if supported by the driver, the interface type is changed
  1722. * at runtime, mac80211 will never touch this field
  1723. * @offload_flags: hardware offload capabilities/flags for this interface.
  1724. * These are initialized by mac80211 before calling .add_interface,
  1725. * .change_interface or .update_vif_offload and updated by the driver
  1726. * within these ops, based on supported features or runtime change
  1727. * restrictions.
  1728. * @hw_queue: hardware queue for each AC
  1729. * @cab_queue: content-after-beacon (DTIM beacon really) queue, AP mode only
  1730. * @debugfs_dir: debugfs dentry, can be used by drivers to create own per
  1731. * interface debug files. Note that it will be NULL for the virtual
  1732. * monitor interface (if that is requested.)
  1733. * @probe_req_reg: probe requests should be reported to mac80211 for this
  1734. * interface.
  1735. * @rx_mcast_action_reg: multicast Action frames should be reported to mac80211
  1736. * for this interface.
  1737. * @drv_priv: data area for driver use, will always be aligned to
  1738. * sizeof(void \*).
  1739. * @txq: the multicast data TX queue (if driver uses the TXQ abstraction)
  1740. * @offload_flags: 802.3 -> 802.11 enapsulation offload flags, see
  1741. * &enum ieee80211_offload_flags.
  1742. * @mbssid_tx_vif: Pointer to the transmitting interface if MBSSID is enabled.
  1743. */
  1744. struct ieee80211_vif {
  1745. enum nl80211_iftype type;
  1746. struct ieee80211_vif_cfg cfg;
  1747. struct ieee80211_bss_conf bss_conf;
  1748. struct ieee80211_bss_conf __rcu *link_conf[IEEE80211_MLD_MAX_NUM_LINKS];
  1749. u16 valid_links, active_links;
  1750. u8 addr[ETH_ALEN] __aligned(2);
  1751. bool p2p;
  1752. u8 cab_queue;
  1753. u8 hw_queue[IEEE80211_NUM_ACS];
  1754. struct ieee80211_txq *txq;
  1755. u32 driver_flags;
  1756. u32 offload_flags;
  1757. #ifdef CONFIG_MAC80211_DEBUGFS
  1758. struct dentry *debugfs_dir;
  1759. #endif
  1760. bool probe_req_reg;
  1761. bool rx_mcast_action_reg;
  1762. struct ieee80211_vif *mbssid_tx_vif;
  1763. ANDROID_KABI_RESERVE(1);
  1764. /* must be last */
  1765. u8 drv_priv[] __aligned(sizeof(void *));
  1766. };
  1767. #define for_each_vif_active_link(vif, link, link_id) \
  1768. for (link_id = 0; link_id < ARRAY_SIZE((vif)->link_conf); link_id++) \
  1769. if ((!(vif)->active_links || \
  1770. (vif)->active_links & BIT(link_id)) && \
  1771. (link = rcu_dereference((vif)->link_conf[link_id])))
  1772. static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
  1773. {
  1774. #ifdef CONFIG_MAC80211_MESH
  1775. return vif->type == NL80211_IFTYPE_MESH_POINT;
  1776. #endif
  1777. return false;
  1778. }
  1779. /**
  1780. * wdev_to_ieee80211_vif - return a vif struct from a wdev
  1781. * @wdev: the wdev to get the vif for
  1782. *
  1783. * This can be used by mac80211 drivers with direct cfg80211 APIs
  1784. * (like the vendor commands) that get a wdev.
  1785. *
  1786. * Note that this function may return %NULL if the given wdev isn't
  1787. * associated with a vif that the driver knows about (e.g. monitor
  1788. * or AP_VLAN interfaces.)
  1789. */
  1790. struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
  1791. /**
  1792. * ieee80211_vif_to_wdev - return a wdev struct from a vif
  1793. * @vif: the vif to get the wdev for
  1794. *
  1795. * This can be used by mac80211 drivers with direct cfg80211 APIs
  1796. * (like the vendor commands) that needs to get the wdev for a vif.
  1797. * This can also be useful to get the netdev associated to a vif.
  1798. */
  1799. struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
  1800. /**
  1801. * lockdep_vif_mutex_held - for lockdep checks on link poiners
  1802. * @vif: the interface to check
  1803. */
  1804. static inline bool lockdep_vif_mutex_held(struct ieee80211_vif *vif)
  1805. {
  1806. return lockdep_is_held(&ieee80211_vif_to_wdev(vif)->mtx);
  1807. }
  1808. #define link_conf_dereference_protected(vif, link_id) \
  1809. rcu_dereference_protected((vif)->link_conf[link_id], \
  1810. lockdep_vif_mutex_held(vif))
  1811. /**
  1812. * enum ieee80211_key_flags - key flags
  1813. *
  1814. * These flags are used for communication about keys between the driver
  1815. * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
  1816. *
  1817. * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
  1818. * driver to indicate that it requires IV generation for this
  1819. * particular key. Setting this flag does not necessarily mean that SKBs
  1820. * will have sufficient tailroom for ICV or MIC.
  1821. * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
  1822. * the driver for a TKIP key if it requires Michael MIC
  1823. * generation in software.
  1824. * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates
  1825. * that the key is pairwise rather then a shared key.
  1826. * @IEEE80211_KEY_FLAG_SW_MGMT_TX: This flag should be set by the driver for a
  1827. * CCMP/GCMP key if it requires CCMP/GCMP encryption of management frames
  1828. * (MFP) to be done in software.
  1829. * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver
  1830. * if space should be prepared for the IV, but the IV
  1831. * itself should not be generated. Do not set together with
  1832. * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. Setting this flag does
  1833. * not necessarily mean that SKBs will have sufficient tailroom for ICV or
  1834. * MIC.
  1835. * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received
  1836. * management frames. The flag can help drivers that have a hardware
  1837. * crypto implementation that doesn't deal with management frames
  1838. * properly by allowing them to not upload the keys to hardware and
  1839. * fall back to software crypto. Note that this flag deals only with
  1840. * RX, if your crypto engine can't deal with TX you can also set the
  1841. * %IEEE80211_KEY_FLAG_SW_MGMT_TX flag to encrypt such frames in SW.
  1842. * @IEEE80211_KEY_FLAG_GENERATE_IV_MGMT: This flag should be set by the
  1843. * driver for a CCMP/GCMP key to indicate that is requires IV generation
  1844. * only for management frames (MFP).
  1845. * @IEEE80211_KEY_FLAG_RESERVE_TAILROOM: This flag should be set by the
  1846. * driver for a key to indicate that sufficient tailroom must always
  1847. * be reserved for ICV or MIC, even when HW encryption is enabled.
  1848. * @IEEE80211_KEY_FLAG_PUT_MIC_SPACE: This flag should be set by the driver for
  1849. * a TKIP key if it only requires MIC space. Do not set together with
  1850. * @IEEE80211_KEY_FLAG_GENERATE_MMIC on the same key.
  1851. * @IEEE80211_KEY_FLAG_NO_AUTO_TX: Key needs explicit Tx activation.
  1852. * @IEEE80211_KEY_FLAG_GENERATE_MMIE: This flag should be set by the driver
  1853. * for a AES_CMAC key to indicate that it requires sequence number
  1854. * generation only
  1855. */
  1856. enum ieee80211_key_flags {
  1857. IEEE80211_KEY_FLAG_GENERATE_IV_MGMT = BIT(0),
  1858. IEEE80211_KEY_FLAG_GENERATE_IV = BIT(1),
  1859. IEEE80211_KEY_FLAG_GENERATE_MMIC = BIT(2),
  1860. IEEE80211_KEY_FLAG_PAIRWISE = BIT(3),
  1861. IEEE80211_KEY_FLAG_SW_MGMT_TX = BIT(4),
  1862. IEEE80211_KEY_FLAG_PUT_IV_SPACE = BIT(5),
  1863. IEEE80211_KEY_FLAG_RX_MGMT = BIT(6),
  1864. IEEE80211_KEY_FLAG_RESERVE_TAILROOM = BIT(7),
  1865. IEEE80211_KEY_FLAG_PUT_MIC_SPACE = BIT(8),
  1866. IEEE80211_KEY_FLAG_NO_AUTO_TX = BIT(9),
  1867. IEEE80211_KEY_FLAG_GENERATE_MMIE = BIT(10),
  1868. };
  1869. /**
  1870. * struct ieee80211_key_conf - key information
  1871. *
  1872. * This key information is given by mac80211 to the driver by
  1873. * the set_key() callback in &struct ieee80211_ops.
  1874. *
  1875. * @hw_key_idx: To be set by the driver, this is the key index the driver
  1876. * wants to be given when a frame is transmitted and needs to be
  1877. * encrypted in hardware.
  1878. * @cipher: The key's cipher suite selector.
  1879. * @tx_pn: PN used for TX keys, may be used by the driver as well if it
  1880. * needs to do software PN assignment by itself (e.g. due to TSO)
  1881. * @flags: key flags, see &enum ieee80211_key_flags.
  1882. * @keyidx: the key index (0-3)
  1883. * @keylen: key material length
  1884. * @key: key material. For ALG_TKIP the key is encoded as a 256-bit (32 byte)
  1885. * data block:
  1886. * - Temporal Encryption Key (128 bits)
  1887. * - Temporal Authenticator Tx MIC Key (64 bits)
  1888. * - Temporal Authenticator Rx MIC Key (64 bits)
  1889. * @icv_len: The ICV length for this key type
  1890. * @iv_len: The IV length for this key type
  1891. * @link_id: the link ID for MLO, or -1 for non-MLO or pairwise keys
  1892. */
  1893. struct ieee80211_key_conf {
  1894. atomic64_t tx_pn;
  1895. u32 cipher;
  1896. u8 icv_len;
  1897. u8 iv_len;
  1898. u8 hw_key_idx;
  1899. s8 keyidx;
  1900. u16 flags;
  1901. s8 link_id;
  1902. u8 keylen;
  1903. u8 key[];
  1904. };
  1905. #define IEEE80211_MAX_PN_LEN 16
  1906. #define TKIP_PN_TO_IV16(pn) ((u16)(pn & 0xffff))
  1907. #define TKIP_PN_TO_IV32(pn) ((u32)((pn >> 16) & 0xffffffff))
  1908. /**
  1909. * struct ieee80211_key_seq - key sequence counter
  1910. *
  1911. * @tkip: TKIP data, containing IV32 and IV16 in host byte order
  1912. * @ccmp: PN data, most significant byte first (big endian,
  1913. * reverse order than in packet)
  1914. * @aes_cmac: PN data, most significant byte first (big endian,
  1915. * reverse order than in packet)
  1916. * @aes_gmac: PN data, most significant byte first (big endian,
  1917. * reverse order than in packet)
  1918. * @gcmp: PN data, most significant byte first (big endian,
  1919. * reverse order than in packet)
  1920. * @hw: data for HW-only (e.g. cipher scheme) keys
  1921. */
  1922. struct ieee80211_key_seq {
  1923. union {
  1924. struct {
  1925. u32 iv32;
  1926. u16 iv16;
  1927. } tkip;
  1928. struct {
  1929. u8 pn[6];
  1930. } ccmp;
  1931. struct {
  1932. u8 pn[6];
  1933. } aes_cmac;
  1934. struct {
  1935. u8 pn[6];
  1936. } aes_gmac;
  1937. struct {
  1938. u8 pn[6];
  1939. } gcmp;
  1940. struct {
  1941. u8 seq[IEEE80211_MAX_PN_LEN];
  1942. u8 seq_len;
  1943. } hw;
  1944. };
  1945. };
  1946. /**
  1947. * enum set_key_cmd - key command
  1948. *
  1949. * Used with the set_key() callback in &struct ieee80211_ops, this
  1950. * indicates whether a key is being removed or added.
  1951. *
  1952. * @SET_KEY: a key is set
  1953. * @DISABLE_KEY: a key must be disabled
  1954. */
  1955. enum set_key_cmd {
  1956. SET_KEY, DISABLE_KEY,
  1957. };
  1958. /**
  1959. * enum ieee80211_sta_state - station state
  1960. *
  1961. * @IEEE80211_STA_NOTEXIST: station doesn't exist at all,
  1962. * this is a special state for add/remove transitions
  1963. * @IEEE80211_STA_NONE: station exists without special state
  1964. * @IEEE80211_STA_AUTH: station is authenticated
  1965. * @IEEE80211_STA_ASSOC: station is associated
  1966. * @IEEE80211_STA_AUTHORIZED: station is authorized (802.1X)
  1967. */
  1968. enum ieee80211_sta_state {
  1969. /* NOTE: These need to be ordered correctly! */
  1970. IEEE80211_STA_NOTEXIST,
  1971. IEEE80211_STA_NONE,
  1972. IEEE80211_STA_AUTH,
  1973. IEEE80211_STA_ASSOC,
  1974. IEEE80211_STA_AUTHORIZED,
  1975. };
  1976. /**
  1977. * enum ieee80211_sta_rx_bandwidth - station RX bandwidth
  1978. * @IEEE80211_STA_RX_BW_20: station can only receive 20 MHz
  1979. * @IEEE80211_STA_RX_BW_40: station can receive up to 40 MHz
  1980. * @IEEE80211_STA_RX_BW_80: station can receive up to 80 MHz
  1981. * @IEEE80211_STA_RX_BW_160: station can receive up to 160 MHz
  1982. * (including 80+80 MHz)
  1983. * @IEEE80211_STA_RX_BW_320: station can receive up to 320 MHz
  1984. *
  1985. * Implementation note: 20 must be zero to be initialized
  1986. * correctly, the values must be sorted.
  1987. */
  1988. enum ieee80211_sta_rx_bandwidth {
  1989. IEEE80211_STA_RX_BW_20 = 0,
  1990. IEEE80211_STA_RX_BW_40,
  1991. IEEE80211_STA_RX_BW_80,
  1992. IEEE80211_STA_RX_BW_160,
  1993. IEEE80211_STA_RX_BW_320,
  1994. };
  1995. /**
  1996. * struct ieee80211_sta_rates - station rate selection table
  1997. *
  1998. * @rcu_head: RCU head used for freeing the table on update
  1999. * @rate: transmit rates/flags to be used by default.
  2000. * Overriding entries per-packet is possible by using cb tx control.
  2001. */
  2002. struct ieee80211_sta_rates {
  2003. struct rcu_head rcu_head;
  2004. struct {
  2005. s8 idx;
  2006. u8 count;
  2007. u8 count_cts;
  2008. u8 count_rts;
  2009. u16 flags;
  2010. } rate[IEEE80211_TX_RATE_TABLE_SIZE];
  2011. };
  2012. /**
  2013. * struct ieee80211_sta_txpwr - station txpower configuration
  2014. *
  2015. * Used to configure txpower for station.
  2016. *
  2017. * @power: indicates the tx power, in dBm, to be used when sending data frames
  2018. * to the STA.
  2019. * @type: In particular if TPC %type is NL80211_TX_POWER_LIMITED then tx power
  2020. * will be less than or equal to specified from userspace, whereas if TPC
  2021. * %type is NL80211_TX_POWER_AUTOMATIC then it indicates default tx power.
  2022. * NL80211_TX_POWER_FIXED is not a valid configuration option for
  2023. * per peer TPC.
  2024. */
  2025. struct ieee80211_sta_txpwr {
  2026. s16 power;
  2027. enum nl80211_tx_power_setting type;
  2028. };
  2029. /**
  2030. * struct ieee80211_sta_aggregates - info that is aggregated from active links
  2031. *
  2032. * Used for any per-link data that needs to be aggregated and updated in the
  2033. * main &struct ieee80211_sta when updated or the active links change.
  2034. *
  2035. * @max_amsdu_len: indicates the maximal length of an A-MSDU in bytes.
  2036. * This field is always valid for packets with a VHT preamble.
  2037. * For packets with a HT preamble, additional limits apply:
  2038. *
  2039. * * If the skb is transmitted as part of a BA agreement, the
  2040. * A-MSDU maximal size is min(max_amsdu_len, 4065) bytes.
  2041. * * If the skb is not part of a BA agreement, the A-MSDU maximal
  2042. * size is min(max_amsdu_len, 7935) bytes.
  2043. *
  2044. * Both additional HT limits must be enforced by the low level
  2045. * driver. This is defined by the spec (IEEE 802.11-2012 section
  2046. * 8.3.2.2 NOTE 2).
  2047. * @max_rc_amsdu_len: Maximum A-MSDU size in bytes recommended by rate control.
  2048. * @max_tid_amsdu_len: Maximum A-MSDU size in bytes for this TID
  2049. */
  2050. struct ieee80211_sta_aggregates {
  2051. u16 max_amsdu_len;
  2052. u16 max_rc_amsdu_len;
  2053. u16 max_tid_amsdu_len[IEEE80211_NUM_TIDS];
  2054. };
  2055. /**
  2056. * struct ieee80211_link_sta - station Link specific info
  2057. * All link specific info for a STA link for a non MLD STA(single)
  2058. * or a MLD STA(multiple entries) are stored here.
  2059. *
  2060. * @addr: MAC address of the Link STA. For non-MLO STA this is same as the addr
  2061. * in ieee80211_sta. For MLO Link STA this addr can be same or different
  2062. * from addr in ieee80211_sta (representing MLD STA addr)
  2063. * @link_id: the link ID for this link STA (0 for deflink)
  2064. * @smps_mode: current SMPS mode (off, static or dynamic)
  2065. * @supp_rates: Bitmap of supported rates
  2066. * @ht_cap: HT capabilities of this STA; restricted to our own capabilities
  2067. * @vht_cap: VHT capabilities of this STA; restricted to our own capabilities
  2068. * @he_cap: HE capabilities of this STA
  2069. * @he_6ghz_capa: on 6 GHz, holds the HE 6 GHz band capabilities
  2070. * @eht_cap: EHT capabilities of this STA
  2071. * @bandwidth: current bandwidth the station can receive with
  2072. * @rx_nss: in HT/VHT, the maximum number of spatial streams the
  2073. * station can receive at the moment, changed by operating mode
  2074. * notifications and capabilities. The value is only valid after
  2075. * the station moves to associated state.
  2076. * @txpwr: the station tx power configuration
  2077. *
  2078. */
  2079. struct ieee80211_link_sta {
  2080. u8 addr[ETH_ALEN];
  2081. u8 link_id;
  2082. enum ieee80211_smps_mode smps_mode;
  2083. u32 supp_rates[NUM_NL80211_BANDS];
  2084. struct ieee80211_sta_ht_cap ht_cap;
  2085. struct ieee80211_sta_vht_cap vht_cap;
  2086. struct ieee80211_sta_he_cap he_cap;
  2087. struct ieee80211_he_6ghz_capa he_6ghz_capa;
  2088. struct ieee80211_sta_eht_cap eht_cap;
  2089. struct ieee80211_sta_aggregates agg;
  2090. u8 rx_nss;
  2091. enum ieee80211_sta_rx_bandwidth bandwidth;
  2092. struct ieee80211_sta_txpwr txpwr;
  2093. };
  2094. /**
  2095. * struct ieee80211_sta - station table entry
  2096. *
  2097. * A station table entry represents a station we are possibly
  2098. * communicating with. Since stations are RCU-managed in
  2099. * mac80211, any ieee80211_sta pointer you get access to must
  2100. * either be protected by rcu_read_lock() explicitly or implicitly,
  2101. * or you must take good care to not use such a pointer after a
  2102. * call to your sta_remove callback that removed it.
  2103. * This also represents the MLD STA in case of MLO association
  2104. * and holds pointers to various link STA's
  2105. *
  2106. * @addr: MAC address
  2107. * @aid: AID we assigned to the station if we're an AP
  2108. * @max_rx_aggregation_subframes: maximal amount of frames in a single AMPDU
  2109. * that this station is allowed to transmit to us.
  2110. * Can be modified by driver.
  2111. * @wme: indicates whether the STA supports QoS/WME (if local devices does,
  2112. * otherwise always false)
  2113. * @drv_priv: data area for driver use, will always be aligned to
  2114. * sizeof(void \*), size is determined in hw information.
  2115. * @uapsd_queues: bitmap of queues configured for uapsd. Only valid
  2116. * if wme is supported. The bits order is like in
  2117. * IEEE80211_WMM_IE_STA_QOSINFO_AC_*.
  2118. * @max_sp: max Service Period. Only valid if wme is supported.
  2119. * @rates: rate control selection table
  2120. * @tdls: indicates whether the STA is a TDLS peer
  2121. * @tdls_initiator: indicates the STA is an initiator of the TDLS link. Only
  2122. * valid if the STA is a TDLS peer in the first place.
  2123. * @mfp: indicates whether the STA uses management frame protection or not.
  2124. * @mlo: indicates whether the STA is MLO station.
  2125. * @max_amsdu_subframes: indicates the maximal number of MSDUs in a single
  2126. * A-MSDU. Taken from the Extended Capabilities element. 0 means
  2127. * unlimited.
  2128. * @cur: currently valid data as aggregated from the active links
  2129. * For non MLO STA it will point to the deflink data. For MLO STA
  2130. * ieee80211_sta_recalc_aggregates() must be called to update it.
  2131. * @support_p2p_ps: indicates whether the STA supports P2P PS mechanism or not.
  2132. * @txq: per-TID data TX queues (if driver uses the TXQ abstraction); note that
  2133. * the last entry (%IEEE80211_NUM_TIDS) is used for non-data frames
  2134. * @deflink: This holds the default link STA information, for non MLO STA all link
  2135. * specific STA information is accessed through @deflink or through
  2136. * link[0] which points to address of @deflink. For MLO Link STA
  2137. * the first added link STA will point to deflink.
  2138. * @link: reference to Link Sta entries. For Non MLO STA, except 1st link,
  2139. * i.e link[0] all links would be assigned to NULL by default and
  2140. * would access link information via @deflink or link[0]. For MLO
  2141. * STA, first link STA being added will point its link pointer to
  2142. * @deflink address and remaining would be allocated and the address
  2143. * would be assigned to link[link_id] where link_id is the id assigned
  2144. * by the AP.
  2145. * @valid_links: bitmap of valid links, or 0 for non-MLO
  2146. */
  2147. struct ieee80211_sta {
  2148. u8 addr[ETH_ALEN];
  2149. u16 aid;
  2150. u16 max_rx_aggregation_subframes;
  2151. bool wme;
  2152. u8 uapsd_queues;
  2153. u8 max_sp;
  2154. struct ieee80211_sta_rates __rcu *rates;
  2155. bool tdls;
  2156. bool tdls_initiator;
  2157. bool mfp;
  2158. bool mlo;
  2159. u8 max_amsdu_subframes;
  2160. struct ieee80211_sta_aggregates *cur;
  2161. bool support_p2p_ps;
  2162. struct ieee80211_txq *txq[IEEE80211_NUM_TIDS + 1];
  2163. u16 valid_links;
  2164. struct ieee80211_link_sta deflink;
  2165. struct ieee80211_link_sta __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS];
  2166. ANDROID_KABI_RESERVE(1);
  2167. /* must be last */
  2168. u8 drv_priv[] __aligned(sizeof(void *));
  2169. };
  2170. #ifdef CONFIG_LOCKDEP
  2171. bool lockdep_sta_mutex_held(struct ieee80211_sta *pubsta);
  2172. #else
  2173. static inline bool lockdep_sta_mutex_held(struct ieee80211_sta *pubsta)
  2174. {
  2175. return true;
  2176. }
  2177. #endif
  2178. #define link_sta_dereference_protected(sta, link_id) \
  2179. rcu_dereference_protected((sta)->link[link_id], \
  2180. lockdep_sta_mutex_held(sta))
  2181. #define for_each_sta_active_link(vif, sta, link_sta, link_id) \
  2182. for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) \
  2183. if ((!(vif)->active_links || \
  2184. (vif)->active_links & BIT(link_id)) && \
  2185. ((link_sta) = link_sta_dereference_protected(sta, link_id)))
  2186. /**
  2187. * enum sta_notify_cmd - sta notify command
  2188. *
  2189. * Used with the sta_notify() callback in &struct ieee80211_ops, this
  2190. * indicates if an associated station made a power state transition.
  2191. *
  2192. * @STA_NOTIFY_SLEEP: a station is now sleeping
  2193. * @STA_NOTIFY_AWAKE: a sleeping station woke up
  2194. */
  2195. enum sta_notify_cmd {
  2196. STA_NOTIFY_SLEEP, STA_NOTIFY_AWAKE,
  2197. };
  2198. /**
  2199. * struct ieee80211_tx_control - TX control data
  2200. *
  2201. * @sta: station table entry, this sta pointer may be NULL and
  2202. * it is not allowed to copy the pointer, due to RCU.
  2203. */
  2204. struct ieee80211_tx_control {
  2205. struct ieee80211_sta *sta;
  2206. };
  2207. /**
  2208. * struct ieee80211_txq - Software intermediate tx queue
  2209. *
  2210. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  2211. * @sta: station table entry, %NULL for per-vif queue
  2212. * @tid: the TID for this queue (unused for per-vif queue),
  2213. * %IEEE80211_NUM_TIDS for non-data (if enabled)
  2214. * @ac: the AC for this queue
  2215. * @drv_priv: driver private area, sized by hw->txq_data_size
  2216. *
  2217. * The driver can obtain packets from this queue by calling
  2218. * ieee80211_tx_dequeue().
  2219. */
  2220. struct ieee80211_txq {
  2221. struct ieee80211_vif *vif;
  2222. struct ieee80211_sta *sta;
  2223. u8 tid;
  2224. u8 ac;
  2225. /* must be last */
  2226. u8 drv_priv[] __aligned(sizeof(void *));
  2227. };
  2228. /**
  2229. * enum ieee80211_hw_flags - hardware flags
  2230. *
  2231. * These flags are used to indicate hardware capabilities to
  2232. * the stack. Generally, flags here should have their meaning
  2233. * done in a way that the simplest hardware doesn't need setting
  2234. * any particular flags. There are some exceptions to this rule,
  2235. * however, so you are advised to review these flags carefully.
  2236. *
  2237. * @IEEE80211_HW_HAS_RATE_CONTROL:
  2238. * The hardware or firmware includes rate control, and cannot be
  2239. * controlled by the stack. As such, no rate control algorithm
  2240. * should be instantiated, and the TX rate reported to userspace
  2241. * will be taken from the TX status instead of the rate control
  2242. * algorithm.
  2243. * Note that this requires that the driver implement a number of
  2244. * callbacks so it has the correct information, it needs to have
  2245. * the @set_rts_threshold callback and must look at the BSS config
  2246. * @use_cts_prot for G/N protection, @use_short_slot for slot
  2247. * timing in 2.4 GHz and @use_short_preamble for preambles for
  2248. * CCK frames.
  2249. *
  2250. * @IEEE80211_HW_RX_INCLUDES_FCS:
  2251. * Indicates that received frames passed to the stack include
  2252. * the FCS at the end.
  2253. *
  2254. * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING:
  2255. * Some wireless LAN chipsets buffer broadcast/multicast frames
  2256. * for power saving stations in the hardware/firmware and others
  2257. * rely on the host system for such buffering. This option is used
  2258. * to configure the IEEE 802.11 upper layer to buffer broadcast and
  2259. * multicast frames when there are power saving stations so that
  2260. * the driver can fetch them with ieee80211_get_buffered_bc().
  2261. *
  2262. * @IEEE80211_HW_SIGNAL_UNSPEC:
  2263. * Hardware can provide signal values but we don't know its units. We
  2264. * expect values between 0 and @max_signal.
  2265. * If possible please provide dB or dBm instead.
  2266. *
  2267. * @IEEE80211_HW_SIGNAL_DBM:
  2268. * Hardware gives signal values in dBm, decibel difference from
  2269. * one milliwatt. This is the preferred method since it is standardized
  2270. * between different devices. @max_signal does not need to be set.
  2271. *
  2272. * @IEEE80211_HW_SPECTRUM_MGMT:
  2273. * Hardware supports spectrum management defined in 802.11h
  2274. * Measurement, Channel Switch, Quieting, TPC
  2275. *
  2276. * @IEEE80211_HW_AMPDU_AGGREGATION:
  2277. * Hardware supports 11n A-MPDU aggregation.
  2278. *
  2279. * @IEEE80211_HW_SUPPORTS_PS:
  2280. * Hardware has power save support (i.e. can go to sleep).
  2281. *
  2282. * @IEEE80211_HW_PS_NULLFUNC_STACK:
  2283. * Hardware requires nullfunc frame handling in stack, implies
  2284. * stack support for dynamic PS.
  2285. *
  2286. * @IEEE80211_HW_SUPPORTS_DYNAMIC_PS:
  2287. * Hardware has support for dynamic PS.
  2288. *
  2289. * @IEEE80211_HW_MFP_CAPABLE:
  2290. * Hardware supports management frame protection (MFP, IEEE 802.11w).
  2291. *
  2292. * @IEEE80211_HW_REPORTS_TX_ACK_STATUS:
  2293. * Hardware can provide ack status reports of Tx frames to
  2294. * the stack.
  2295. *
  2296. * @IEEE80211_HW_CONNECTION_MONITOR:
  2297. * The hardware performs its own connection monitoring, including
  2298. * periodic keep-alives to the AP and probing the AP on beacon loss.
  2299. *
  2300. * @IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC:
  2301. * This device needs to get data from beacon before association (i.e.
  2302. * dtim_period).
  2303. *
  2304. * @IEEE80211_HW_SUPPORTS_PER_STA_GTK: The device's crypto engine supports
  2305. * per-station GTKs as used by IBSS RSN or during fast transition. If
  2306. * the device doesn't support per-station GTKs, but can be asked not
  2307. * to decrypt group addressed frames, then IBSS RSN support is still
  2308. * possible but software crypto will be used. Advertise the wiphy flag
  2309. * only in that case.
  2310. *
  2311. * @IEEE80211_HW_AP_LINK_PS: When operating in AP mode the device
  2312. * autonomously manages the PS status of connected stations. When
  2313. * this flag is set mac80211 will not trigger PS mode for connected
  2314. * stations based on the PM bit of incoming frames.
  2315. * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure
  2316. * the PS mode of connected stations.
  2317. *
  2318. * @IEEE80211_HW_TX_AMPDU_SETUP_IN_HW: The device handles TX A-MPDU session
  2319. * setup strictly in HW. mac80211 should not attempt to do this in
  2320. * software.
  2321. *
  2322. * @IEEE80211_HW_WANT_MONITOR_VIF: The driver would like to be informed of
  2323. * a virtual monitor interface when monitor interfaces are the only
  2324. * active interfaces.
  2325. *
  2326. * @IEEE80211_HW_NO_AUTO_VIF: The driver would like for no wlanX to
  2327. * be created. It is expected user-space will create vifs as
  2328. * desired (and thus have them named as desired).
  2329. *
  2330. * @IEEE80211_HW_SW_CRYPTO_CONTROL: The driver wants to control which of the
  2331. * crypto algorithms can be done in software - so don't automatically
  2332. * try to fall back to it if hardware crypto fails, but do so only if
  2333. * the driver returns 1. This also forces the driver to advertise its
  2334. * supported cipher suites.
  2335. *
  2336. * @IEEE80211_HW_SUPPORT_FAST_XMIT: The driver/hardware supports fast-xmit,
  2337. * this currently requires only the ability to calculate the duration
  2338. * for frames.
  2339. *
  2340. * @IEEE80211_HW_QUEUE_CONTROL: The driver wants to control per-interface
  2341. * queue mapping in order to use different queues (not just one per AC)
  2342. * for different virtual interfaces. See the doc section on HW queue
  2343. * control for more details.
  2344. *
  2345. * @IEEE80211_HW_SUPPORTS_RC_TABLE: The driver supports using a rate
  2346. * selection table provided by the rate control algorithm.
  2347. *
  2348. * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
  2349. * P2P Interface. This will be honoured even if more than one interface
  2350. * is supported.
  2351. *
  2352. * @IEEE80211_HW_TIMING_BEACON_ONLY: Use sync timing from beacon frames
  2353. * only, to allow getting TBTT of a DTIM beacon.
  2354. *
  2355. * @IEEE80211_HW_SUPPORTS_HT_CCK_RATES: Hardware supports mixing HT/CCK rates
  2356. * and can cope with CCK rates in an aggregation session (e.g. by not
  2357. * using aggregation for such frames.)
  2358. *
  2359. * @IEEE80211_HW_CHANCTX_STA_CSA: Support 802.11h based channel-switch (CSA)
  2360. * for a single active channel while using channel contexts. When support
  2361. * is not enabled the default action is to disconnect when getting the
  2362. * CSA frame.
  2363. *
  2364. * @IEEE80211_HW_SUPPORTS_CLONED_SKBS: The driver will never modify the payload
  2365. * or tailroom of TX skbs without copying them first.
  2366. *
  2367. * @IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS: The HW supports scanning on all bands
  2368. * in one command, mac80211 doesn't have to run separate scans per band.
  2369. *
  2370. * @IEEE80211_HW_TDLS_WIDER_BW: The device/driver supports wider bandwidth
  2371. * than then BSS bandwidth for a TDLS link on the base channel.
  2372. *
  2373. * @IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU: The driver supports receiving A-MSDUs
  2374. * within A-MPDU.
  2375. *
  2376. * @IEEE80211_HW_BEACON_TX_STATUS: The device/driver provides TX status
  2377. * for sent beacons.
  2378. *
  2379. * @IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR: Hardware (or driver) requires that each
  2380. * station has a unique address, i.e. each station entry can be identified
  2381. * by just its MAC address; this prevents, for example, the same station
  2382. * from connecting to two virtual AP interfaces at the same time.
  2383. *
  2384. * @IEEE80211_HW_SUPPORTS_REORDERING_BUFFER: Hardware (or driver) manages the
  2385. * reordering buffer internally, guaranteeing mac80211 receives frames in
  2386. * order and does not need to manage its own reorder buffer or BA session
  2387. * timeout.
  2388. *
  2389. * @IEEE80211_HW_USES_RSS: The device uses RSS and thus requires parallel RX,
  2390. * which implies using per-CPU station statistics.
  2391. *
  2392. * @IEEE80211_HW_TX_AMSDU: Hardware (or driver) supports software aggregated
  2393. * A-MSDU frames. Requires software tx queueing and fast-xmit support.
  2394. * When not using minstrel/minstrel_ht rate control, the driver must
  2395. * limit the maximum A-MSDU size based on the current tx rate by setting
  2396. * max_rc_amsdu_len in struct ieee80211_sta.
  2397. *
  2398. * @IEEE80211_HW_TX_FRAG_LIST: Hardware (or driver) supports sending frag_list
  2399. * skbs, needed for zero-copy software A-MSDU.
  2400. *
  2401. * @IEEE80211_HW_REPORTS_LOW_ACK: The driver (or firmware) reports low ack event
  2402. * by ieee80211_report_low_ack() based on its own algorithm. For such
  2403. * drivers, mac80211 packet loss mechanism will not be triggered and driver
  2404. * is completely depending on firmware event for station kickout.
  2405. *
  2406. * @IEEE80211_HW_SUPPORTS_TX_FRAG: Hardware does fragmentation by itself.
  2407. * The stack will not do fragmentation.
  2408. * The callback for @set_frag_threshold should be set as well.
  2409. *
  2410. * @IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA: Hardware supports buffer STA on
  2411. * TDLS links.
  2412. *
  2413. * @IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP: The driver requires the
  2414. * mgd_prepare_tx() callback to be called before transmission of a
  2415. * deauthentication frame in case the association was completed but no
  2416. * beacon was heard. This is required in multi-channel scenarios, where the
  2417. * virtual interface might not be given air time for the transmission of
  2418. * the frame, as it is not synced with the AP/P2P GO yet, and thus the
  2419. * deauthentication frame might not be transmitted.
  2420. *
  2421. * @IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP: The driver (or firmware) doesn't
  2422. * support QoS NDP for AP probing - that's most likely a driver bug.
  2423. *
  2424. * @IEEE80211_HW_BUFF_MMPDU_TXQ: use the TXQ for bufferable MMPDUs, this of
  2425. * course requires the driver to use TXQs to start with.
  2426. *
  2427. * @IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW: (Hardware) rate control supports VHT
  2428. * extended NSS BW (dot11VHTExtendedNSSBWCapable). This flag will be set if
  2429. * the selected rate control algorithm sets %RATE_CTRL_CAPA_VHT_EXT_NSS_BW
  2430. * but if the rate control is built-in then it must be set by the driver.
  2431. * See also the documentation for that flag.
  2432. *
  2433. * @IEEE80211_HW_STA_MMPDU_TXQ: use the extra non-TID per-station TXQ for all
  2434. * MMPDUs on station interfaces. This of course requires the driver to use
  2435. * TXQs to start with.
  2436. *
  2437. * @IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN: Driver does not report accurate A-MPDU
  2438. * length in tx status information
  2439. *
  2440. * @IEEE80211_HW_SUPPORTS_MULTI_BSSID: Hardware supports multi BSSID
  2441. *
  2442. * @IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID: Hardware supports multi BSSID
  2443. * only for HE APs. Applies if @IEEE80211_HW_SUPPORTS_MULTI_BSSID is set.
  2444. *
  2445. * @IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT: The card and driver is only
  2446. * aggregating MPDUs with the same keyid, allowing mac80211 to keep Tx
  2447. * A-MPDU sessions active while rekeying with Extended Key ID.
  2448. *
  2449. * @IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD: Hardware supports tx encapsulation
  2450. * offload
  2451. *
  2452. * @IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD: Hardware supports rx decapsulation
  2453. * offload
  2454. *
  2455. * @IEEE80211_HW_SUPPORTS_CONC_MON_RX_DECAP: Hardware supports concurrent rx
  2456. * decapsulation offload and passing raw 802.11 frames for monitor iface.
  2457. * If this is supported, the driver must pass both 802.3 frames for real
  2458. * usage and 802.11 frames with %RX_FLAG_ONLY_MONITOR set for monitor to
  2459. * the stack.
  2460. *
  2461. * @IEEE80211_HW_DETECTS_COLOR_COLLISION: HW/driver has support for BSS color
  2462. * collision detection and doesn't need it in software.
  2463. *
  2464. * @IEEE80211_HW_MLO_MCAST_MULTI_LINK_TX: Hardware/driver handles transmitting
  2465. * multicast frames on all links, mac80211 should not do that.
  2466. *
  2467. * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  2468. */
  2469. enum ieee80211_hw_flags {
  2470. IEEE80211_HW_HAS_RATE_CONTROL,
  2471. IEEE80211_HW_RX_INCLUDES_FCS,
  2472. IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING,
  2473. IEEE80211_HW_SIGNAL_UNSPEC,
  2474. IEEE80211_HW_SIGNAL_DBM,
  2475. IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC,
  2476. IEEE80211_HW_SPECTRUM_MGMT,
  2477. IEEE80211_HW_AMPDU_AGGREGATION,
  2478. IEEE80211_HW_SUPPORTS_PS,
  2479. IEEE80211_HW_PS_NULLFUNC_STACK,
  2480. IEEE80211_HW_SUPPORTS_DYNAMIC_PS,
  2481. IEEE80211_HW_MFP_CAPABLE,
  2482. IEEE80211_HW_WANT_MONITOR_VIF,
  2483. IEEE80211_HW_NO_AUTO_VIF,
  2484. IEEE80211_HW_SW_CRYPTO_CONTROL,
  2485. IEEE80211_HW_SUPPORT_FAST_XMIT,
  2486. IEEE80211_HW_REPORTS_TX_ACK_STATUS,
  2487. IEEE80211_HW_CONNECTION_MONITOR,
  2488. IEEE80211_HW_QUEUE_CONTROL,
  2489. IEEE80211_HW_SUPPORTS_PER_STA_GTK,
  2490. IEEE80211_HW_AP_LINK_PS,
  2491. IEEE80211_HW_TX_AMPDU_SETUP_IN_HW,
  2492. IEEE80211_HW_SUPPORTS_RC_TABLE,
  2493. IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF,
  2494. IEEE80211_HW_TIMING_BEACON_ONLY,
  2495. IEEE80211_HW_SUPPORTS_HT_CCK_RATES,
  2496. IEEE80211_HW_CHANCTX_STA_CSA,
  2497. IEEE80211_HW_SUPPORTS_CLONED_SKBS,
  2498. IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS,
  2499. IEEE80211_HW_TDLS_WIDER_BW,
  2500. IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU,
  2501. IEEE80211_HW_BEACON_TX_STATUS,
  2502. IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
  2503. IEEE80211_HW_SUPPORTS_REORDERING_BUFFER,
  2504. IEEE80211_HW_USES_RSS,
  2505. IEEE80211_HW_TX_AMSDU,
  2506. IEEE80211_HW_TX_FRAG_LIST,
  2507. IEEE80211_HW_REPORTS_LOW_ACK,
  2508. IEEE80211_HW_SUPPORTS_TX_FRAG,
  2509. IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
  2510. IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
  2511. IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP,
  2512. IEEE80211_HW_BUFF_MMPDU_TXQ,
  2513. IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW,
  2514. IEEE80211_HW_STA_MMPDU_TXQ,
  2515. IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN,
  2516. IEEE80211_HW_SUPPORTS_MULTI_BSSID,
  2517. IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
  2518. IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT,
  2519. IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD,
  2520. IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD,
  2521. IEEE80211_HW_SUPPORTS_CONC_MON_RX_DECAP,
  2522. IEEE80211_HW_DETECTS_COLOR_COLLISION,
  2523. IEEE80211_HW_MLO_MCAST_MULTI_LINK_TX,
  2524. /* keep last, obviously */
  2525. NUM_IEEE80211_HW_FLAGS
  2526. };
  2527. /**
  2528. * struct ieee80211_hw - hardware information and state
  2529. *
  2530. * This structure contains the configuration and hardware
  2531. * information for an 802.11 PHY.
  2532. *
  2533. * @wiphy: This points to the &struct wiphy allocated for this
  2534. * 802.11 PHY. You must fill in the @perm_addr and @dev
  2535. * members of this structure using SET_IEEE80211_DEV()
  2536. * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
  2537. * bands (with channels, bitrates) are registered here.
  2538. *
  2539. * @conf: &struct ieee80211_conf, device configuration, don't use.
  2540. *
  2541. * @priv: pointer to private area that was allocated for driver use
  2542. * along with this structure.
  2543. *
  2544. * @flags: hardware flags, see &enum ieee80211_hw_flags.
  2545. *
  2546. * @extra_tx_headroom: headroom to reserve in each transmit skb
  2547. * for use by the driver (e.g. for transmit headers.)
  2548. *
  2549. * @extra_beacon_tailroom: tailroom to reserve in each beacon tx skb.
  2550. * Can be used by drivers to add extra IEs.
  2551. *
  2552. * @max_signal: Maximum value for signal (rssi) in RX information, used
  2553. * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB
  2554. *
  2555. * @max_listen_interval: max listen interval in units of beacon interval
  2556. * that HW supports
  2557. *
  2558. * @queues: number of available hardware transmit queues for
  2559. * data packets. WMM/QoS requires at least four, these
  2560. * queues need to have configurable access parameters.
  2561. *
  2562. * @rate_control_algorithm: rate control algorithm for this hardware.
  2563. * If unset (NULL), the default algorithm will be used. Must be
  2564. * set before calling ieee80211_register_hw().
  2565. *
  2566. * @vif_data_size: size (in bytes) of the drv_priv data area
  2567. * within &struct ieee80211_vif.
  2568. * @sta_data_size: size (in bytes) of the drv_priv data area
  2569. * within &struct ieee80211_sta.
  2570. * @chanctx_data_size: size (in bytes) of the drv_priv data area
  2571. * within &struct ieee80211_chanctx_conf.
  2572. * @txq_data_size: size (in bytes) of the drv_priv data area
  2573. * within @struct ieee80211_txq.
  2574. *
  2575. * @max_rates: maximum number of alternate rate retry stages the hw
  2576. * can handle.
  2577. * @max_report_rates: maximum number of alternate rate retry stages
  2578. * the hw can report back.
  2579. * @max_rate_tries: maximum number of tries for each stage
  2580. *
  2581. * @max_rx_aggregation_subframes: maximum buffer size (number of
  2582. * sub-frames) to be used for A-MPDU block ack receiver
  2583. * aggregation.
  2584. * This is only relevant if the device has restrictions on the
  2585. * number of subframes, if it relies on mac80211 to do reordering
  2586. * it shouldn't be set.
  2587. *
  2588. * @max_tx_aggregation_subframes: maximum number of subframes in an
  2589. * aggregate an HT/HE device will transmit. In HT AddBA we'll
  2590. * advertise a constant value of 64 as some older APs crash if
  2591. * the window size is smaller (an example is LinkSys WRT120N
  2592. * with FW v1.0.07 build 002 Jun 18 2012).
  2593. * For AddBA to HE capable peers this value will be used.
  2594. *
  2595. * @max_tx_fragments: maximum number of tx buffers per (A)-MSDU, sum
  2596. * of 1 + skb_shinfo(skb)->nr_frags for each skb in the frag_list.
  2597. *
  2598. * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX
  2599. * (if %IEEE80211_HW_QUEUE_CONTROL is set)
  2600. *
  2601. * @radiotap_mcs_details: lists which MCS information can the HW
  2602. * reports, by default it is set to _MCS, _GI and _BW but doesn't
  2603. * include _FMT. Use %IEEE80211_RADIOTAP_MCS_HAVE_\* values, only
  2604. * adding _BW is supported today.
  2605. *
  2606. * @radiotap_vht_details: lists which VHT MCS information the HW reports,
  2607. * the default is _GI | _BANDWIDTH.
  2608. * Use the %IEEE80211_RADIOTAP_VHT_KNOWN_\* values.
  2609. *
  2610. * @radiotap_he: HE radiotap validity flags
  2611. *
  2612. * @radiotap_timestamp: Information for the radiotap timestamp field; if the
  2613. * @units_pos member is set to a non-negative value then the timestamp
  2614. * field will be added and populated from the &struct ieee80211_rx_status
  2615. * device_timestamp.
  2616. * @radiotap_timestamp.units_pos: Must be set to a combination of a
  2617. * IEEE80211_RADIOTAP_TIMESTAMP_UNIT_* and a
  2618. * IEEE80211_RADIOTAP_TIMESTAMP_SPOS_* value.
  2619. * @radiotap_timestamp.accuracy: If non-negative, fills the accuracy in the
  2620. * radiotap field and the accuracy known flag will be set.
  2621. *
  2622. * @netdev_features: netdev features to be set in each netdev created
  2623. * from this HW. Note that not all features are usable with mac80211,
  2624. * other features will be rejected during HW registration.
  2625. *
  2626. * @uapsd_queues: This bitmap is included in (re)association frame to indicate
  2627. * for each access category if it is uAPSD trigger-enabled and delivery-
  2628. * enabled. Use IEEE80211_WMM_IE_STA_QOSINFO_AC_* to set this bitmap.
  2629. * Each bit corresponds to different AC. Value '1' in specific bit means
  2630. * that corresponding AC is both trigger- and delivery-enabled. '0' means
  2631. * neither enabled.
  2632. *
  2633. * @uapsd_max_sp_len: maximum number of total buffered frames the WMM AP may
  2634. * deliver to a WMM STA during any Service Period triggered by the WMM STA.
  2635. * Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct values.
  2636. *
  2637. * @max_nan_de_entries: maximum number of NAN DE functions supported by the
  2638. * device.
  2639. *
  2640. * @tx_sk_pacing_shift: Pacing shift to set on TCP sockets when frames from
  2641. * them are encountered. The default should typically not be changed,
  2642. * unless the driver has good reasons for needing more buffers.
  2643. *
  2644. * @weight_multiplier: Driver specific airtime weight multiplier used while
  2645. * refilling deficit of each TXQ.
  2646. *
  2647. * @max_mtu: the max mtu could be set.
  2648. *
  2649. * @tx_power_levels: a list of power levels supported by the wifi hardware.
  2650. * The power levels can be specified either as integer or fractions.
  2651. * The power level at idx 0 shall be the maximum positive power level.
  2652. *
  2653. * @max_txpwr_levels_idx: the maximum valid idx of 'tx_power_levels' list.
  2654. */
  2655. struct ieee80211_hw {
  2656. struct ieee80211_conf conf;
  2657. struct wiphy *wiphy;
  2658. const char *rate_control_algorithm;
  2659. void *priv;
  2660. unsigned long flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)];
  2661. unsigned int extra_tx_headroom;
  2662. unsigned int extra_beacon_tailroom;
  2663. int vif_data_size;
  2664. int sta_data_size;
  2665. int chanctx_data_size;
  2666. int txq_data_size;
  2667. u16 queues;
  2668. u16 max_listen_interval;
  2669. s8 max_signal;
  2670. u8 max_rates;
  2671. u8 max_report_rates;
  2672. u8 max_rate_tries;
  2673. u16 max_rx_aggregation_subframes;
  2674. u16 max_tx_aggregation_subframes;
  2675. u8 max_tx_fragments;
  2676. u8 offchannel_tx_hw_queue;
  2677. u8 radiotap_mcs_details;
  2678. u16 radiotap_vht_details;
  2679. struct {
  2680. int units_pos;
  2681. s16 accuracy;
  2682. } radiotap_timestamp;
  2683. netdev_features_t netdev_features;
  2684. u8 uapsd_queues;
  2685. u8 uapsd_max_sp_len;
  2686. u8 max_nan_de_entries;
  2687. u8 tx_sk_pacing_shift;
  2688. u8 weight_multiplier;
  2689. u32 max_mtu;
  2690. const s8 *tx_power_levels;
  2691. u8 max_txpwr_levels_idx;
  2692. ANDROID_KABI_RESERVE(1);
  2693. };
  2694. static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw,
  2695. enum ieee80211_hw_flags flg)
  2696. {
  2697. return test_bit(flg, hw->flags);
  2698. }
  2699. #define ieee80211_hw_check(hw, flg) _ieee80211_hw_check(hw, IEEE80211_HW_##flg)
  2700. static inline void _ieee80211_hw_set(struct ieee80211_hw *hw,
  2701. enum ieee80211_hw_flags flg)
  2702. {
  2703. return __set_bit(flg, hw->flags);
  2704. }
  2705. #define ieee80211_hw_set(hw, flg) _ieee80211_hw_set(hw, IEEE80211_HW_##flg)
  2706. /**
  2707. * struct ieee80211_scan_request - hw scan request
  2708. *
  2709. * @ies: pointers different parts of IEs (in req.ie)
  2710. * @req: cfg80211 request.
  2711. */
  2712. struct ieee80211_scan_request {
  2713. struct ieee80211_scan_ies ies;
  2714. /* Keep last */
  2715. struct cfg80211_scan_request req;
  2716. };
  2717. /**
  2718. * struct ieee80211_tdls_ch_sw_params - TDLS channel switch parameters
  2719. *
  2720. * @sta: peer this TDLS channel-switch request/response came from
  2721. * @chandef: channel referenced in a TDLS channel-switch request
  2722. * @action_code: see &enum ieee80211_tdls_actioncode
  2723. * @status: channel-switch response status
  2724. * @timestamp: time at which the frame was received
  2725. * @switch_time: switch-timing parameter received in the frame
  2726. * @switch_timeout: switch-timing parameter received in the frame
  2727. * @tmpl_skb: TDLS switch-channel response template
  2728. * @ch_sw_tm_ie: offset of the channel-switch timing IE inside @tmpl_skb
  2729. */
  2730. struct ieee80211_tdls_ch_sw_params {
  2731. struct ieee80211_sta *sta;
  2732. struct cfg80211_chan_def *chandef;
  2733. u8 action_code;
  2734. u32 status;
  2735. u32 timestamp;
  2736. u16 switch_time;
  2737. u16 switch_timeout;
  2738. struct sk_buff *tmpl_skb;
  2739. u32 ch_sw_tm_ie;
  2740. };
  2741. /**
  2742. * wiphy_to_ieee80211_hw - return a mac80211 driver hw struct from a wiphy
  2743. *
  2744. * @wiphy: the &struct wiphy which we want to query
  2745. *
  2746. * mac80211 drivers can use this to get to their respective
  2747. * &struct ieee80211_hw. Drivers wishing to get to their own private
  2748. * structure can then access it via hw->priv. Note that mac802111 drivers should
  2749. * not use wiphy_priv() to try to get their private driver structure as this
  2750. * is already used internally by mac80211.
  2751. *
  2752. * Return: The mac80211 driver hw struct of @wiphy.
  2753. */
  2754. struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy);
  2755. /**
  2756. * SET_IEEE80211_DEV - set device for 802.11 hardware
  2757. *
  2758. * @hw: the &struct ieee80211_hw to set the device for
  2759. * @dev: the &struct device of this 802.11 device
  2760. */
  2761. static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
  2762. {
  2763. set_wiphy_dev(hw->wiphy, dev);
  2764. }
  2765. /**
  2766. * SET_IEEE80211_PERM_ADDR - set the permanent MAC address for 802.11 hardware
  2767. *
  2768. * @hw: the &struct ieee80211_hw to set the MAC address for
  2769. * @addr: the address to set
  2770. */
  2771. static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 *addr)
  2772. {
  2773. memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
  2774. }
  2775. static inline struct ieee80211_rate *
  2776. ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
  2777. const struct ieee80211_tx_info *c)
  2778. {
  2779. if (WARN_ON_ONCE(c->control.rates[0].idx < 0))
  2780. return NULL;
  2781. return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
  2782. }
  2783. static inline struct ieee80211_rate *
  2784. ieee80211_get_rts_cts_rate(const struct ieee80211_hw *hw,
  2785. const struct ieee80211_tx_info *c)
  2786. {
  2787. if (c->control.rts_cts_rate_idx < 0)
  2788. return NULL;
  2789. return &hw->wiphy->bands[c->band]->bitrates[c->control.rts_cts_rate_idx];
  2790. }
  2791. static inline struct ieee80211_rate *
  2792. ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
  2793. const struct ieee80211_tx_info *c, int idx)
  2794. {
  2795. if (c->control.rates[idx + 1].idx < 0)
  2796. return NULL;
  2797. return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx];
  2798. }
  2799. /**
  2800. * ieee80211_free_txskb - free TX skb
  2801. * @hw: the hardware
  2802. * @skb: the skb
  2803. *
  2804. * Free a transmit skb. Use this function when some failure
  2805. * to transmit happened and thus status cannot be reported.
  2806. */
  2807. void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
  2808. /**
  2809. * DOC: Hardware crypto acceleration
  2810. *
  2811. * mac80211 is capable of taking advantage of many hardware
  2812. * acceleration designs for encryption and decryption operations.
  2813. *
  2814. * The set_key() callback in the &struct ieee80211_ops for a given
  2815. * device is called to enable hardware acceleration of encryption and
  2816. * decryption. The callback takes a @sta parameter that will be NULL
  2817. * for default keys or keys used for transmission only, or point to
  2818. * the station information for the peer for individual keys.
  2819. * Multiple transmission keys with the same key index may be used when
  2820. * VLANs are configured for an access point.
  2821. *
  2822. * When transmitting, the TX control data will use the @hw_key_idx
  2823. * selected by the driver by modifying the &struct ieee80211_key_conf
  2824. * pointed to by the @key parameter to the set_key() function.
  2825. *
  2826. * The set_key() call for the %SET_KEY command should return 0 if
  2827. * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be
  2828. * added; if you return 0 then hw_key_idx must be assigned to the
  2829. * hardware key index, you are free to use the full u8 range.
  2830. *
  2831. * Note that in the case that the @IEEE80211_HW_SW_CRYPTO_CONTROL flag is
  2832. * set, mac80211 will not automatically fall back to software crypto if
  2833. * enabling hardware crypto failed. The set_key() call may also return the
  2834. * value 1 to permit this specific key/algorithm to be done in software.
  2835. *
  2836. * When the cmd is %DISABLE_KEY then it must succeed.
  2837. *
  2838. * Note that it is permissible to not decrypt a frame even if a key
  2839. * for it has been uploaded to hardware, the stack will not make any
  2840. * decision based on whether a key has been uploaded or not but rather
  2841. * based on the receive flags.
  2842. *
  2843. * The &struct ieee80211_key_conf structure pointed to by the @key
  2844. * parameter is guaranteed to be valid until another call to set_key()
  2845. * removes it, but it can only be used as a cookie to differentiate
  2846. * keys.
  2847. *
  2848. * In TKIP some HW need to be provided a phase 1 key, for RX decryption
  2849. * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
  2850. * handler.
  2851. * The update_tkip_key() call updates the driver with the new phase 1 key.
  2852. * This happens every time the iv16 wraps around (every 65536 packets). The
  2853. * set_key() call will happen only once for each key (unless the AP did
  2854. * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
  2855. * provided by update_tkip_key only. The trigger that makes mac80211 call this
  2856. * handler is software decryption with wrap around of iv16.
  2857. *
  2858. * The set_default_unicast_key() call updates the default WEP key index
  2859. * configured to the hardware for WEP encryption type. This is required
  2860. * for devices that support offload of data packets (e.g. ARP responses).
  2861. *
  2862. * Mac80211 drivers should set the @NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 flag
  2863. * when they are able to replace in-use PTK keys according to the following
  2864. * requirements:
  2865. * 1) They do not hand over frames decrypted with the old key to mac80211
  2866. once the call to set_key() with command %DISABLE_KEY has been completed,
  2867. 2) either drop or continue to use the old key for any outgoing frames queued
  2868. at the time of the key deletion (including re-transmits),
  2869. 3) never send out a frame queued prior to the set_key() %SET_KEY command
  2870. encrypted with the new key when also needing
  2871. @IEEE80211_KEY_FLAG_GENERATE_IV and
  2872. 4) never send out a frame unencrypted when it should be encrypted.
  2873. Mac80211 will not queue any new frames for a deleted key to the driver.
  2874. */
  2875. /**
  2876. * DOC: Powersave support
  2877. *
  2878. * mac80211 has support for various powersave implementations.
  2879. *
  2880. * First, it can support hardware that handles all powersaving by itself,
  2881. * such hardware should simply set the %IEEE80211_HW_SUPPORTS_PS hardware
  2882. * flag. In that case, it will be told about the desired powersave mode
  2883. * with the %IEEE80211_CONF_PS flag depending on the association status.
  2884. * The hardware must take care of sending nullfunc frames when necessary,
  2885. * i.e. when entering and leaving powersave mode. The hardware is required
  2886. * to look at the AID in beacons and signal to the AP that it woke up when
  2887. * it finds traffic directed to it.
  2888. *
  2889. * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in
  2890. * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused
  2891. * with hardware wakeup and sleep states. Driver is responsible for waking
  2892. * up the hardware before issuing commands to the hardware and putting it
  2893. * back to sleep at appropriate times.
  2894. *
  2895. * When PS is enabled, hardware needs to wakeup for beacons and receive the
  2896. * buffered multicast/broadcast frames after the beacon. Also it must be
  2897. * possible to send frames and receive the acknowledment frame.
  2898. *
  2899. * Other hardware designs cannot send nullfunc frames by themselves and also
  2900. * need software support for parsing the TIM bitmap. This is also supported
  2901. * by mac80211 by combining the %IEEE80211_HW_SUPPORTS_PS and
  2902. * %IEEE80211_HW_PS_NULLFUNC_STACK flags. The hardware is of course still
  2903. * required to pass up beacons. The hardware is still required to handle
  2904. * waking up for multicast traffic; if it cannot the driver must handle that
  2905. * as best as it can, mac80211 is too slow to do that.
  2906. *
  2907. * Dynamic powersave is an extension to normal powersave in which the
  2908. * hardware stays awake for a user-specified period of time after sending a
  2909. * frame so that reply frames need not be buffered and therefore delayed to
  2910. * the next wakeup. It's compromise of getting good enough latency when
  2911. * there's data traffic and still saving significantly power in idle
  2912. * periods.
  2913. *
  2914. * Dynamic powersave is simply supported by mac80211 enabling and disabling
  2915. * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS
  2916. * flag and mac80211 will handle everything automatically. Additionally,
  2917. * hardware having support for the dynamic PS feature may set the
  2918. * %IEEE80211_HW_SUPPORTS_DYNAMIC_PS flag to indicate that it can support
  2919. * dynamic PS mode itself. The driver needs to look at the
  2920. * @dynamic_ps_timeout hardware configuration value and use it that value
  2921. * whenever %IEEE80211_CONF_PS is set. In this case mac80211 will disable
  2922. * dynamic PS feature in stack and will just keep %IEEE80211_CONF_PS
  2923. * enabled whenever user has enabled powersave.
  2924. *
  2925. * Driver informs U-APSD client support by enabling
  2926. * %IEEE80211_VIF_SUPPORTS_UAPSD flag. The mode is configured through the
  2927. * uapsd parameter in conf_tx() operation. Hardware needs to send the QoS
  2928. * Nullfunc frames and stay awake until the service period has ended. To
  2929. * utilize U-APSD, dynamic powersave is disabled for voip AC and all frames
  2930. * from that AC are transmitted with powersave enabled.
  2931. *
  2932. * Note: U-APSD client mode is not yet supported with
  2933. * %IEEE80211_HW_PS_NULLFUNC_STACK.
  2934. */
  2935. /**
  2936. * DOC: Beacon filter support
  2937. *
  2938. * Some hardware have beacon filter support to reduce host cpu wakeups
  2939. * which will reduce system power consumption. It usually works so that
  2940. * the firmware creates a checksum of the beacon but omits all constantly
  2941. * changing elements (TSF, TIM etc). Whenever the checksum changes the
  2942. * beacon is forwarded to the host, otherwise it will be just dropped. That
  2943. * way the host will only receive beacons where some relevant information
  2944. * (for example ERP protection or WMM settings) have changed.
  2945. *
  2946. * Beacon filter support is advertised with the %IEEE80211_VIF_BEACON_FILTER
  2947. * interface capability. The driver needs to enable beacon filter support
  2948. * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When
  2949. * power save is enabled, the stack will not check for beacon loss and the
  2950. * driver needs to notify about loss of beacons with ieee80211_beacon_loss().
  2951. *
  2952. * The time (or number of beacons missed) until the firmware notifies the
  2953. * driver of a beacon loss event (which in turn causes the driver to call
  2954. * ieee80211_beacon_loss()) should be configurable and will be controlled
  2955. * by mac80211 and the roaming algorithm in the future.
  2956. *
  2957. * Since there may be constantly changing information elements that nothing
  2958. * in the software stack cares about, we will, in the future, have mac80211
  2959. * tell the driver which information elements are interesting in the sense
  2960. * that we want to see changes in them. This will include
  2961. *
  2962. * - a list of information element IDs
  2963. * - a list of OUIs for the vendor information element
  2964. *
  2965. * Ideally, the hardware would filter out any beacons without changes in the
  2966. * requested elements, but if it cannot support that it may, at the expense
  2967. * of some efficiency, filter out only a subset. For example, if the device
  2968. * doesn't support checking for OUIs it should pass up all changes in all
  2969. * vendor information elements.
  2970. *
  2971. * Note that change, for the sake of simplification, also includes information
  2972. * elements appearing or disappearing from the beacon.
  2973. *
  2974. * Some hardware supports an "ignore list" instead, just make sure nothing
  2975. * that was requested is on the ignore list, and include commonly changing
  2976. * information element IDs in the ignore list, for example 11 (BSS load) and
  2977. * the various vendor-assigned IEs with unknown contents (128, 129, 133-136,
  2978. * 149, 150, 155, 156, 173, 176, 178, 179, 219); for forward compatibility
  2979. * it could also include some currently unused IDs.
  2980. *
  2981. *
  2982. * In addition to these capabilities, hardware should support notifying the
  2983. * host of changes in the beacon RSSI. This is relevant to implement roaming
  2984. * when no traffic is flowing (when traffic is flowing we see the RSSI of
  2985. * the received data packets). This can consist in notifying the host when
  2986. * the RSSI changes significantly or when it drops below or rises above
  2987. * configurable thresholds. In the future these thresholds will also be
  2988. * configured by mac80211 (which gets them from userspace) to implement
  2989. * them as the roaming algorithm requires.
  2990. *
  2991. * If the hardware cannot implement this, the driver should ask it to
  2992. * periodically pass beacon frames to the host so that software can do the
  2993. * signal strength threshold checking.
  2994. */
  2995. /**
  2996. * DOC: Spatial multiplexing power save
  2997. *
  2998. * SMPS (Spatial multiplexing power save) is a mechanism to conserve
  2999. * power in an 802.11n implementation. For details on the mechanism
  3000. * and rationale, please refer to 802.11 (as amended by 802.11n-2009)
  3001. * "11.2.3 SM power save".
  3002. *
  3003. * The mac80211 implementation is capable of sending action frames
  3004. * to update the AP about the station's SMPS mode, and will instruct
  3005. * the driver to enter the specific mode. It will also announce the
  3006. * requested SMPS mode during the association handshake. Hardware
  3007. * support for this feature is required, and can be indicated by
  3008. * hardware flags.
  3009. *
  3010. * The default mode will be "automatic", which nl80211/cfg80211
  3011. * defines to be dynamic SMPS in (regular) powersave, and SMPS
  3012. * turned off otherwise.
  3013. *
  3014. * To support this feature, the driver must set the appropriate
  3015. * hardware support flags, and handle the SMPS flag to the config()
  3016. * operation. It will then with this mechanism be instructed to
  3017. * enter the requested SMPS mode while associated to an HT AP.
  3018. */
  3019. /**
  3020. * DOC: Frame filtering
  3021. *
  3022. * mac80211 requires to see many management frames for proper
  3023. * operation, and users may want to see many more frames when
  3024. * in monitor mode. However, for best CPU usage and power consumption,
  3025. * having as few frames as possible percolate through the stack is
  3026. * desirable. Hence, the hardware should filter as much as possible.
  3027. *
  3028. * To achieve this, mac80211 uses filter flags (see below) to tell
  3029. * the driver's configure_filter() function which frames should be
  3030. * passed to mac80211 and which should be filtered out.
  3031. *
  3032. * Before configure_filter() is invoked, the prepare_multicast()
  3033. * callback is invoked with the parameters @mc_count and @mc_list
  3034. * for the combined multicast address list of all virtual interfaces.
  3035. * It's use is optional, and it returns a u64 that is passed to
  3036. * configure_filter(). Additionally, configure_filter() has the
  3037. * arguments @changed_flags telling which flags were changed and
  3038. * @total_flags with the new flag states.
  3039. *
  3040. * If your device has no multicast address filters your driver will
  3041. * need to check both the %FIF_ALLMULTI flag and the @mc_count
  3042. * parameter to see whether multicast frames should be accepted
  3043. * or dropped.
  3044. *
  3045. * All unsupported flags in @total_flags must be cleared.
  3046. * Hardware does not support a flag if it is incapable of _passing_
  3047. * the frame to the stack. Otherwise the driver must ignore
  3048. * the flag, but not clear it.
  3049. * You must _only_ clear the flag (announce no support for the
  3050. * flag to mac80211) if you are not able to pass the packet type
  3051. * to the stack (so the hardware always filters it).
  3052. * So for example, you should clear @FIF_CONTROL, if your hardware
  3053. * always filters control frames. If your hardware always passes
  3054. * control frames to the kernel and is incapable of filtering them,
  3055. * you do _not_ clear the @FIF_CONTROL flag.
  3056. * This rule applies to all other FIF flags as well.
  3057. */
  3058. /**
  3059. * DOC: AP support for powersaving clients
  3060. *
  3061. * In order to implement AP and P2P GO modes, mac80211 has support for
  3062. * client powersaving, both "legacy" PS (PS-Poll/null data) and uAPSD.
  3063. * There currently is no support for sAPSD.
  3064. *
  3065. * There is one assumption that mac80211 makes, namely that a client
  3066. * will not poll with PS-Poll and trigger with uAPSD at the same time.
  3067. * Both are supported, and both can be used by the same client, but
  3068. * they can't be used concurrently by the same client. This simplifies
  3069. * the driver code.
  3070. *
  3071. * The first thing to keep in mind is that there is a flag for complete
  3072. * driver implementation: %IEEE80211_HW_AP_LINK_PS. If this flag is set,
  3073. * mac80211 expects the driver to handle most of the state machine for
  3074. * powersaving clients and will ignore the PM bit in incoming frames.
  3075. * Drivers then use ieee80211_sta_ps_transition() to inform mac80211 of
  3076. * stations' powersave transitions. In this mode, mac80211 also doesn't
  3077. * handle PS-Poll/uAPSD.
  3078. *
  3079. * In the mode without %IEEE80211_HW_AP_LINK_PS, mac80211 will check the
  3080. * PM bit in incoming frames for client powersave transitions. When a
  3081. * station goes to sleep, we will stop transmitting to it. There is,
  3082. * however, a race condition: a station might go to sleep while there is
  3083. * data buffered on hardware queues. If the device has support for this
  3084. * it will reject frames, and the driver should give the frames back to
  3085. * mac80211 with the %IEEE80211_TX_STAT_TX_FILTERED flag set which will
  3086. * cause mac80211 to retry the frame when the station wakes up. The
  3087. * driver is also notified of powersave transitions by calling its
  3088. * @sta_notify callback.
  3089. *
  3090. * When the station is asleep, it has three choices: it can wake up,
  3091. * it can PS-Poll, or it can possibly start a uAPSD service period.
  3092. * Waking up is implemented by simply transmitting all buffered (and
  3093. * filtered) frames to the station. This is the easiest case. When
  3094. * the station sends a PS-Poll or a uAPSD trigger frame, mac80211
  3095. * will inform the driver of this with the @allow_buffered_frames
  3096. * callback; this callback is optional. mac80211 will then transmit
  3097. * the frames as usual and set the %IEEE80211_TX_CTL_NO_PS_BUFFER
  3098. * on each frame. The last frame in the service period (or the only
  3099. * response to a PS-Poll) also has %IEEE80211_TX_STATUS_EOSP set to
  3100. * indicate that it ends the service period; as this frame must have
  3101. * TX status report it also sets %IEEE80211_TX_CTL_REQ_TX_STATUS.
  3102. * When TX status is reported for this frame, the service period is
  3103. * marked has having ended and a new one can be started by the peer.
  3104. *
  3105. * Additionally, non-bufferable MMPDUs can also be transmitted by
  3106. * mac80211 with the %IEEE80211_TX_CTL_NO_PS_BUFFER set in them.
  3107. *
  3108. * Another race condition can happen on some devices like iwlwifi
  3109. * when there are frames queued for the station and it wakes up
  3110. * or polls; the frames that are already queued could end up being
  3111. * transmitted first instead, causing reordering and/or wrong
  3112. * processing of the EOSP. The cause is that allowing frames to be
  3113. * transmitted to a certain station is out-of-band communication to
  3114. * the device. To allow this problem to be solved, the driver can
  3115. * call ieee80211_sta_block_awake() if frames are buffered when it
  3116. * is notified that the station went to sleep. When all these frames
  3117. * have been filtered (see above), it must call the function again
  3118. * to indicate that the station is no longer blocked.
  3119. *
  3120. * If the driver buffers frames in the driver for aggregation in any
  3121. * way, it must use the ieee80211_sta_set_buffered() call when it is
  3122. * notified of the station going to sleep to inform mac80211 of any
  3123. * TIDs that have frames buffered. Note that when a station wakes up
  3124. * this information is reset (hence the requirement to call it when
  3125. * informed of the station going to sleep). Then, when a service
  3126. * period starts for any reason, @release_buffered_frames is called
  3127. * with the number of frames to be released and which TIDs they are
  3128. * to come from. In this case, the driver is responsible for setting
  3129. * the EOSP (for uAPSD) and MORE_DATA bits in the released frames,
  3130. * to help the @more_data parameter is passed to tell the driver if
  3131. * there is more data on other TIDs -- the TIDs to release frames
  3132. * from are ignored since mac80211 doesn't know how many frames the
  3133. * buffers for those TIDs contain.
  3134. *
  3135. * If the driver also implement GO mode, where absence periods may
  3136. * shorten service periods (or abort PS-Poll responses), it must
  3137. * filter those response frames except in the case of frames that
  3138. * are buffered in the driver -- those must remain buffered to avoid
  3139. * reordering. Because it is possible that no frames are released
  3140. * in this case, the driver must call ieee80211_sta_eosp()
  3141. * to indicate to mac80211 that the service period ended anyway.
  3142. *
  3143. * Finally, if frames from multiple TIDs are released from mac80211
  3144. * but the driver might reorder them, it must clear & set the flags
  3145. * appropriately (only the last frame may have %IEEE80211_TX_STATUS_EOSP)
  3146. * and also take care of the EOSP and MORE_DATA bits in the frame.
  3147. * The driver may also use ieee80211_sta_eosp() in this case.
  3148. *
  3149. * Note that if the driver ever buffers frames other than QoS-data
  3150. * frames, it must take care to never send a non-QoS-data frame as
  3151. * the last frame in a service period, adding a QoS-nulldata frame
  3152. * after a non-QoS-data frame if needed.
  3153. */
  3154. /**
  3155. * DOC: HW queue control
  3156. *
  3157. * Before HW queue control was introduced, mac80211 only had a single static
  3158. * assignment of per-interface AC software queues to hardware queues. This
  3159. * was problematic for a few reasons:
  3160. * 1) off-channel transmissions might get stuck behind other frames
  3161. * 2) multiple virtual interfaces couldn't be handled correctly
  3162. * 3) after-DTIM frames could get stuck behind other frames
  3163. *
  3164. * To solve this, hardware typically uses multiple different queues for all
  3165. * the different usages, and this needs to be propagated into mac80211 so it
  3166. * won't have the same problem with the software queues.
  3167. *
  3168. * Therefore, mac80211 now offers the %IEEE80211_HW_QUEUE_CONTROL capability
  3169. * flag that tells it that the driver implements its own queue control. To do
  3170. * so, the driver will set up the various queues in each &struct ieee80211_vif
  3171. * and the offchannel queue in &struct ieee80211_hw. In response, mac80211 will
  3172. * use those queue IDs in the hw_queue field of &struct ieee80211_tx_info and
  3173. * if necessary will queue the frame on the right software queue that mirrors
  3174. * the hardware queue.
  3175. * Additionally, the driver has to then use these HW queue IDs for the queue
  3176. * management functions (ieee80211_stop_queue() et al.)
  3177. *
  3178. * The driver is free to set up the queue mappings as needed, multiple virtual
  3179. * interfaces may map to the same hardware queues if needed. The setup has to
  3180. * happen during add_interface or change_interface callbacks. For example, a
  3181. * driver supporting station+station and station+AP modes might decide to have
  3182. * 10 hardware queues to handle different scenarios:
  3183. *
  3184. * 4 AC HW queues for 1st vif: 0, 1, 2, 3
  3185. * 4 AC HW queues for 2nd vif: 4, 5, 6, 7
  3186. * after-DTIM queue for AP: 8
  3187. * off-channel queue: 9
  3188. *
  3189. * It would then set up the hardware like this:
  3190. * hw.offchannel_tx_hw_queue = 9
  3191. *
  3192. * and the first virtual interface that is added as follows:
  3193. * vif.hw_queue[IEEE80211_AC_VO] = 0
  3194. * vif.hw_queue[IEEE80211_AC_VI] = 1
  3195. * vif.hw_queue[IEEE80211_AC_BE] = 2
  3196. * vif.hw_queue[IEEE80211_AC_BK] = 3
  3197. * vif.cab_queue = 8 // if AP mode, otherwise %IEEE80211_INVAL_HW_QUEUE
  3198. * and the second virtual interface with 4-7.
  3199. *
  3200. * If queue 6 gets full, for example, mac80211 would only stop the second
  3201. * virtual interface's BE queue since virtual interface queues are per AC.
  3202. *
  3203. * Note that the vif.cab_queue value should be set to %IEEE80211_INVAL_HW_QUEUE
  3204. * whenever the queue is not used (i.e. the interface is not in AP mode) if the
  3205. * queue could potentially be shared since mac80211 will look at cab_queue when
  3206. * a queue is stopped/woken even if the interface is not in AP mode.
  3207. */
  3208. /**
  3209. * enum ieee80211_filter_flags - hardware filter flags
  3210. *
  3211. * These flags determine what the filter in hardware should be
  3212. * programmed to let through and what should not be passed to the
  3213. * stack. It is always safe to pass more frames than requested,
  3214. * but this has negative impact on power consumption.
  3215. *
  3216. * @FIF_ALLMULTI: pass all multicast frames, this is used if requested
  3217. * by the user or if the hardware is not capable of filtering by
  3218. * multicast address.
  3219. *
  3220. * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the
  3221. * %RX_FLAG_FAILED_FCS_CRC for them)
  3222. *
  3223. * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set
  3224. * the %RX_FLAG_FAILED_PLCP_CRC for them
  3225. *
  3226. * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate
  3227. * to the hardware that it should not filter beacons or probe responses
  3228. * by BSSID. Filtering them can greatly reduce the amount of processing
  3229. * mac80211 needs to do and the amount of CPU wakeups, so you should
  3230. * honour this flag if possible.
  3231. *
  3232. * @FIF_CONTROL: pass control frames (except for PS Poll) addressed to this
  3233. * station
  3234. *
  3235. * @FIF_OTHER_BSS: pass frames destined to other BSSes
  3236. *
  3237. * @FIF_PSPOLL: pass PS Poll frames
  3238. *
  3239. * @FIF_PROBE_REQ: pass probe request frames
  3240. *
  3241. * @FIF_MCAST_ACTION: pass multicast Action frames
  3242. */
  3243. enum ieee80211_filter_flags {
  3244. FIF_ALLMULTI = 1<<1,
  3245. FIF_FCSFAIL = 1<<2,
  3246. FIF_PLCPFAIL = 1<<3,
  3247. FIF_BCN_PRBRESP_PROMISC = 1<<4,
  3248. FIF_CONTROL = 1<<5,
  3249. FIF_OTHER_BSS = 1<<6,
  3250. FIF_PSPOLL = 1<<7,
  3251. FIF_PROBE_REQ = 1<<8,
  3252. FIF_MCAST_ACTION = 1<<9,
  3253. };
  3254. /**
  3255. * enum ieee80211_ampdu_mlme_action - A-MPDU actions
  3256. *
  3257. * These flags are used with the ampdu_action() callback in
  3258. * &struct ieee80211_ops to indicate which action is needed.
  3259. *
  3260. * Note that drivers MUST be able to deal with a TX aggregation
  3261. * session being stopped even before they OK'ed starting it by
  3262. * calling ieee80211_start_tx_ba_cb_irqsafe, because the peer
  3263. * might receive the addBA frame and send a delBA right away!
  3264. *
  3265. * @IEEE80211_AMPDU_RX_START: start RX aggregation
  3266. * @IEEE80211_AMPDU_RX_STOP: stop RX aggregation
  3267. * @IEEE80211_AMPDU_TX_START: start TX aggregation, the driver must either
  3268. * call ieee80211_start_tx_ba_cb_irqsafe() or
  3269. * call ieee80211_start_tx_ba_cb_irqsafe() with status
  3270. * %IEEE80211_AMPDU_TX_START_DELAY_ADDBA to delay addba after
  3271. * ieee80211_start_tx_ba_cb_irqsafe is called, or just return the special
  3272. * status %IEEE80211_AMPDU_TX_START_IMMEDIATE.
  3273. * @IEEE80211_AMPDU_TX_OPERATIONAL: TX aggregation has become operational
  3274. * @IEEE80211_AMPDU_TX_STOP_CONT: stop TX aggregation but continue transmitting
  3275. * queued packets, now unaggregated. After all packets are transmitted the
  3276. * driver has to call ieee80211_stop_tx_ba_cb_irqsafe().
  3277. * @IEEE80211_AMPDU_TX_STOP_FLUSH: stop TX aggregation and flush all packets,
  3278. * called when the station is removed. There's no need or reason to call
  3279. * ieee80211_stop_tx_ba_cb_irqsafe() in this case as mac80211 assumes the
  3280. * session is gone and removes the station.
  3281. * @IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: called when TX aggregation is stopped
  3282. * but the driver hasn't called ieee80211_stop_tx_ba_cb_irqsafe() yet and
  3283. * now the connection is dropped and the station will be removed. Drivers
  3284. * should clean up and drop remaining packets when this is called.
  3285. */
  3286. enum ieee80211_ampdu_mlme_action {
  3287. IEEE80211_AMPDU_RX_START,
  3288. IEEE80211_AMPDU_RX_STOP,
  3289. IEEE80211_AMPDU_TX_START,
  3290. IEEE80211_AMPDU_TX_STOP_CONT,
  3291. IEEE80211_AMPDU_TX_STOP_FLUSH,
  3292. IEEE80211_AMPDU_TX_STOP_FLUSH_CONT,
  3293. IEEE80211_AMPDU_TX_OPERATIONAL,
  3294. };
  3295. #define IEEE80211_AMPDU_TX_START_IMMEDIATE 1
  3296. #define IEEE80211_AMPDU_TX_START_DELAY_ADDBA 2
  3297. /**
  3298. * struct ieee80211_ampdu_params - AMPDU action parameters
  3299. *
  3300. * @action: the ampdu action, value from %ieee80211_ampdu_mlme_action.
  3301. * @sta: peer of this AMPDU session
  3302. * @tid: tid of the BA session
  3303. * @ssn: start sequence number of the session. TX/RX_STOP can pass 0. When
  3304. * action is set to %IEEE80211_AMPDU_RX_START the driver passes back the
  3305. * actual ssn value used to start the session and writes the value here.
  3306. * @buf_size: reorder buffer size (number of subframes). Valid only when the
  3307. * action is set to %IEEE80211_AMPDU_RX_START or
  3308. * %IEEE80211_AMPDU_TX_OPERATIONAL
  3309. * @amsdu: indicates the peer's ability to receive A-MSDU within A-MPDU.
  3310. * valid when the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL
  3311. * @timeout: BA session timeout. Valid only when the action is set to
  3312. * %IEEE80211_AMPDU_RX_START
  3313. */
  3314. struct ieee80211_ampdu_params {
  3315. enum ieee80211_ampdu_mlme_action action;
  3316. struct ieee80211_sta *sta;
  3317. u16 tid;
  3318. u16 ssn;
  3319. u16 buf_size;
  3320. bool amsdu;
  3321. u16 timeout;
  3322. };
  3323. /**
  3324. * enum ieee80211_frame_release_type - frame release reason
  3325. * @IEEE80211_FRAME_RELEASE_PSPOLL: frame released for PS-Poll
  3326. * @IEEE80211_FRAME_RELEASE_UAPSD: frame(s) released due to
  3327. * frame received on trigger-enabled AC
  3328. */
  3329. enum ieee80211_frame_release_type {
  3330. IEEE80211_FRAME_RELEASE_PSPOLL,
  3331. IEEE80211_FRAME_RELEASE_UAPSD,
  3332. };
  3333. /**
  3334. * enum ieee80211_rate_control_changed - flags to indicate what changed
  3335. *
  3336. * @IEEE80211_RC_BW_CHANGED: The bandwidth that can be used to transmit
  3337. * to this station changed. The actual bandwidth is in the station
  3338. * information -- for HT20/40 the IEEE80211_HT_CAP_SUP_WIDTH_20_40
  3339. * flag changes, for HT and VHT the bandwidth field changes.
  3340. * @IEEE80211_RC_SMPS_CHANGED: The SMPS state of the station changed.
  3341. * @IEEE80211_RC_SUPP_RATES_CHANGED: The supported rate set of this peer
  3342. * changed (in IBSS mode) due to discovering more information about
  3343. * the peer.
  3344. * @IEEE80211_RC_NSS_CHANGED: N_SS (number of spatial streams) was changed
  3345. * by the peer
  3346. */
  3347. enum ieee80211_rate_control_changed {
  3348. IEEE80211_RC_BW_CHANGED = BIT(0),
  3349. IEEE80211_RC_SMPS_CHANGED = BIT(1),
  3350. IEEE80211_RC_SUPP_RATES_CHANGED = BIT(2),
  3351. IEEE80211_RC_NSS_CHANGED = BIT(3),
  3352. };
  3353. /**
  3354. * enum ieee80211_roc_type - remain on channel type
  3355. *
  3356. * With the support for multi channel contexts and multi channel operations,
  3357. * remain on channel operations might be limited/deferred/aborted by other
  3358. * flows/operations which have higher priority (and vice versa).
  3359. * Specifying the ROC type can be used by devices to prioritize the ROC
  3360. * operations compared to other operations/flows.
  3361. *
  3362. * @IEEE80211_ROC_TYPE_NORMAL: There are no special requirements for this ROC.
  3363. * @IEEE80211_ROC_TYPE_MGMT_TX: The remain on channel request is required
  3364. * for sending management frames offchannel.
  3365. */
  3366. enum ieee80211_roc_type {
  3367. IEEE80211_ROC_TYPE_NORMAL = 0,
  3368. IEEE80211_ROC_TYPE_MGMT_TX,
  3369. };
  3370. /**
  3371. * enum ieee80211_reconfig_type - reconfig type
  3372. *
  3373. * This enum is used by the reconfig_complete() callback to indicate what
  3374. * reconfiguration type was completed.
  3375. *
  3376. * @IEEE80211_RECONFIG_TYPE_RESTART: hw restart type
  3377. * (also due to resume() callback returning 1)
  3378. * @IEEE80211_RECONFIG_TYPE_SUSPEND: suspend type (regardless
  3379. * of wowlan configuration)
  3380. */
  3381. enum ieee80211_reconfig_type {
  3382. IEEE80211_RECONFIG_TYPE_RESTART,
  3383. IEEE80211_RECONFIG_TYPE_SUSPEND,
  3384. };
  3385. /**
  3386. * struct ieee80211_prep_tx_info - prepare TX information
  3387. * @duration: if non-zero, hint about the required duration,
  3388. * only used with the mgd_prepare_tx() method.
  3389. * @subtype: frame subtype (auth, (re)assoc, deauth, disassoc)
  3390. * @success: whether the frame exchange was successful, only
  3391. * used with the mgd_complete_tx() method, and then only
  3392. * valid for auth and (re)assoc.
  3393. */
  3394. struct ieee80211_prep_tx_info {
  3395. u16 duration;
  3396. u16 subtype;
  3397. u8 success:1;
  3398. };
  3399. /**
  3400. * struct ieee80211_ops - callbacks from mac80211 to the driver
  3401. *
  3402. * This structure contains various callbacks that the driver may
  3403. * handle or, in some cases, must handle, for example to configure
  3404. * the hardware to a new channel or to transmit a frame.
  3405. *
  3406. * @tx: Handler that 802.11 module calls for each transmitted frame.
  3407. * skb contains the buffer starting from the IEEE 802.11 header.
  3408. * The low-level driver should send the frame out based on
  3409. * configuration in the TX control data. This handler should,
  3410. * preferably, never fail and stop queues appropriately.
  3411. * Must be atomic.
  3412. *
  3413. * @start: Called before the first netdevice attached to the hardware
  3414. * is enabled. This should turn on the hardware and must turn on
  3415. * frame reception (for possibly enabled monitor interfaces.)
  3416. * Returns negative error codes, these may be seen in userspace,
  3417. * or zero.
  3418. * When the device is started it should not have a MAC address
  3419. * to avoid acknowledging frames before a non-monitor device
  3420. * is added.
  3421. * Must be implemented and can sleep.
  3422. *
  3423. * @stop: Called after last netdevice attached to the hardware
  3424. * is disabled. This should turn off the hardware (at least
  3425. * it must turn off frame reception.)
  3426. * May be called right after add_interface if that rejects
  3427. * an interface. If you added any work onto the mac80211 workqueue
  3428. * you should ensure to cancel it on this callback.
  3429. * Must be implemented and can sleep.
  3430. *
  3431. * @suspend: Suspend the device; mac80211 itself will quiesce before and
  3432. * stop transmitting and doing any other configuration, and then
  3433. * ask the device to suspend. This is only invoked when WoWLAN is
  3434. * configured, otherwise the device is deconfigured completely and
  3435. * reconfigured at resume time.
  3436. * The driver may also impose special conditions under which it
  3437. * wants to use the "normal" suspend (deconfigure), say if it only
  3438. * supports WoWLAN when the device is associated. In this case, it
  3439. * must return 1 from this function.
  3440. *
  3441. * @resume: If WoWLAN was configured, this indicates that mac80211 is
  3442. * now resuming its operation, after this the device must be fully
  3443. * functional again. If this returns an error, the only way out is
  3444. * to also unregister the device. If it returns 1, then mac80211
  3445. * will also go through the regular complete restart on resume.
  3446. *
  3447. * @set_wakeup: Enable or disable wakeup when WoWLAN configuration is
  3448. * modified. The reason is that device_set_wakeup_enable() is
  3449. * supposed to be called when the configuration changes, not only
  3450. * in suspend().
  3451. *
  3452. * @add_interface: Called when a netdevice attached to the hardware is
  3453. * enabled. Because it is not called for monitor mode devices, @start
  3454. * and @stop must be implemented.
  3455. * The driver should perform any initialization it needs before
  3456. * the device can be enabled. The initial configuration for the
  3457. * interface is given in the conf parameter.
  3458. * The callback may refuse to add an interface by returning a
  3459. * negative error code (which will be seen in userspace.)
  3460. * Must be implemented and can sleep.
  3461. *
  3462. * @change_interface: Called when a netdevice changes type. This callback
  3463. * is optional, but only if it is supported can interface types be
  3464. * switched while the interface is UP. The callback may sleep.
  3465. * Note that while an interface is being switched, it will not be
  3466. * found by the interface iteration callbacks.
  3467. *
  3468. * @remove_interface: Notifies a driver that an interface is going down.
  3469. * The @stop callback is called after this if it is the last interface
  3470. * and no monitor interfaces are present.
  3471. * When all interfaces are removed, the MAC address in the hardware
  3472. * must be cleared so the device no longer acknowledges packets,
  3473. * the mac_addr member of the conf structure is, however, set to the
  3474. * MAC address of the device going away.
  3475. * Hence, this callback must be implemented. It can sleep.
  3476. *
  3477. * @config: Handler for configuration requests. IEEE 802.11 code calls this
  3478. * function to change hardware configuration, e.g., channel.
  3479. * This function should never fail but returns a negative error code
  3480. * if it does. The callback can sleep.
  3481. *
  3482. * @bss_info_changed: Handler for configuration requests related to BSS
  3483. * parameters that may vary during BSS's lifespan, and may affect low
  3484. * level driver (e.g. assoc/disassoc status, erp parameters).
  3485. * This function should not be used if no BSS has been set, unless
  3486. * for association indication. The @changed parameter indicates which
  3487. * of the bss parameters has changed when a call is made. The callback
  3488. * can sleep.
  3489. * Note: this callback is called if @vif_cfg_changed or @link_info_changed
  3490. * are not implemented.
  3491. *
  3492. * @vif_cfg_changed: Handler for configuration requests related to interface
  3493. * (MLD) parameters from &struct ieee80211_vif_cfg that vary during the
  3494. * lifetime of the interface (e.g. assoc status, IP addresses, etc.)
  3495. * The @changed parameter indicates which value changed.
  3496. * The callback can sleep.
  3497. *
  3498. * @link_info_changed: Handler for configuration requests related to link
  3499. * parameters from &struct ieee80211_bss_conf that are related to an
  3500. * individual link. e.g. legacy/HT/VHT/... rate information.
  3501. * The @changed parameter indicates which value changed, and the @link_id
  3502. * parameter indicates the link ID. Note that the @link_id will be 0 for
  3503. * non-MLO connections.
  3504. * The callback can sleep.
  3505. *
  3506. * @prepare_multicast: Prepare for multicast filter configuration.
  3507. * This callback is optional, and its return value is passed
  3508. * to configure_filter(). This callback must be atomic.
  3509. *
  3510. * @configure_filter: Configure the device's RX filter.
  3511. * See the section "Frame filtering" for more information.
  3512. * This callback must be implemented and can sleep.
  3513. *
  3514. * @config_iface_filter: Configure the interface's RX filter.
  3515. * This callback is optional and is used to configure which frames
  3516. * should be passed to mac80211. The filter_flags is the combination
  3517. * of FIF_* flags. The changed_flags is a bit mask that indicates
  3518. * which flags are changed.
  3519. * This callback can sleep.
  3520. *
  3521. * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit
  3522. * must be set or cleared for a given STA. Must be atomic.
  3523. *
  3524. * @set_key: See the section "Hardware crypto acceleration"
  3525. * This callback is only called between add_interface and
  3526. * remove_interface calls, i.e. while the given virtual interface
  3527. * is enabled.
  3528. * Returns a negative error code if the key can't be added.
  3529. * The callback can sleep.
  3530. *
  3531. * @update_tkip_key: See the section "Hardware crypto acceleration"
  3532. * This callback will be called in the context of Rx. Called for drivers
  3533. * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
  3534. * The callback must be atomic.
  3535. *
  3536. * @set_rekey_data: If the device supports GTK rekeying, for example while the
  3537. * host is suspended, it can assign this callback to retrieve the data
  3538. * necessary to do GTK rekeying, this is the KEK, KCK and replay counter.
  3539. * After rekeying was done it should (for example during resume) notify
  3540. * userspace of the new replay counter using ieee80211_gtk_rekey_notify().
  3541. *
  3542. * @set_default_unicast_key: Set the default (unicast) key index, useful for
  3543. * WEP when the device sends data packets autonomously, e.g. for ARP
  3544. * offloading. The index can be 0-3, or -1 for unsetting it.
  3545. *
  3546. * @hw_scan: Ask the hardware to service the scan request, no need to start
  3547. * the scan state machine in stack. The scan must honour the channel
  3548. * configuration done by the regulatory agent in the wiphy's
  3549. * registered bands. The hardware (or the driver) needs to make sure
  3550. * that power save is disabled.
  3551. * The @req ie/ie_len members are rewritten by mac80211 to contain the
  3552. * entire IEs after the SSID, so that drivers need not look at these
  3553. * at all but just send them after the SSID -- mac80211 includes the
  3554. * (extended) supported rates and HT information (where applicable).
  3555. * When the scan finishes, ieee80211_scan_completed() must be called;
  3556. * note that it also must be called when the scan cannot finish due to
  3557. * any error unless this callback returned a negative error code.
  3558. * This callback is also allowed to return the special return value 1,
  3559. * this indicates that hardware scan isn't desirable right now and a
  3560. * software scan should be done instead. A driver wishing to use this
  3561. * capability must ensure its (hardware) scan capabilities aren't
  3562. * advertised as more capable than mac80211's software scan is.
  3563. * The callback can sleep.
  3564. *
  3565. * @cancel_hw_scan: Ask the low-level tp cancel the active hw scan.
  3566. * The driver should ask the hardware to cancel the scan (if possible),
  3567. * but the scan will be completed only after the driver will call
  3568. * ieee80211_scan_completed().
  3569. * This callback is needed for wowlan, to prevent enqueueing a new
  3570. * scan_work after the low-level driver was already suspended.
  3571. * The callback can sleep.
  3572. *
  3573. * @sched_scan_start: Ask the hardware to start scanning repeatedly at
  3574. * specific intervals. The driver must call the
  3575. * ieee80211_sched_scan_results() function whenever it finds results.
  3576. * This process will continue until sched_scan_stop is called.
  3577. *
  3578. * @sched_scan_stop: Tell the hardware to stop an ongoing scheduled scan.
  3579. * In this case, ieee80211_sched_scan_stopped() must not be called.
  3580. *
  3581. * @sw_scan_start: Notifier function that is called just before a software scan
  3582. * is started. Can be NULL, if the driver doesn't need this notification.
  3583. * The mac_addr parameter allows supporting NL80211_SCAN_FLAG_RANDOM_ADDR,
  3584. * the driver may set the NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR flag if it
  3585. * can use this parameter. The callback can sleep.
  3586. *
  3587. * @sw_scan_complete: Notifier function that is called just after a
  3588. * software scan finished. Can be NULL, if the driver doesn't need
  3589. * this notification.
  3590. * The callback can sleep.
  3591. *
  3592. * @get_stats: Return low-level statistics.
  3593. * Returns zero if statistics are available.
  3594. * The callback can sleep.
  3595. *
  3596. * @get_key_seq: If your device implements encryption in hardware and does
  3597. * IV/PN assignment then this callback should be provided to read the
  3598. * IV/PN for the given key from hardware.
  3599. * The callback must be atomic.
  3600. *
  3601. * @set_frag_threshold: Configuration of fragmentation threshold. Assign this
  3602. * if the device does fragmentation by itself. Note that to prevent the
  3603. * stack from doing fragmentation IEEE80211_HW_SUPPORTS_TX_FRAG
  3604. * should be set as well.
  3605. * The callback can sleep.
  3606. *
  3607. * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
  3608. * The callback can sleep.
  3609. *
  3610. * @sta_add: Notifies low level driver about addition of an associated station,
  3611. * AP, IBSS/WDS/mesh peer etc. This callback can sleep.
  3612. *
  3613. * @sta_remove: Notifies low level driver about removal of an associated
  3614. * station, AP, IBSS/WDS/mesh peer etc. Note that after the callback
  3615. * returns it isn't safe to use the pointer, not even RCU protected;
  3616. * no RCU grace period is guaranteed between returning here and freeing
  3617. * the station. See @sta_pre_rcu_remove if needed.
  3618. * This callback can sleep.
  3619. *
  3620. * @sta_add_debugfs: Drivers can use this callback to add debugfs files
  3621. * when a station is added to mac80211's station list. This callback
  3622. * should be within a CONFIG_MAC80211_DEBUGFS conditional. This
  3623. * callback can sleep.
  3624. *
  3625. * @sta_notify: Notifies low level driver about power state transition of an
  3626. * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating
  3627. * in AP mode, this callback will not be called when the flag
  3628. * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic.
  3629. *
  3630. * @sta_set_txpwr: Configure the station tx power. This callback set the tx
  3631. * power for the station.
  3632. * This callback can sleep.
  3633. *
  3634. * @sta_state: Notifies low level driver about state transition of a
  3635. * station (which can be the AP, a client, IBSS/WDS/mesh peer etc.)
  3636. * This callback is mutually exclusive with @sta_add/@sta_remove.
  3637. * It must not fail for down transitions but may fail for transitions
  3638. * up the list of states. Also note that after the callback returns it
  3639. * isn't safe to use the pointer, not even RCU protected - no RCU grace
  3640. * period is guaranteed between returning here and freeing the station.
  3641. * See @sta_pre_rcu_remove if needed.
  3642. * The callback can sleep.
  3643. *
  3644. * @sta_pre_rcu_remove: Notify driver about station removal before RCU
  3645. * synchronisation. This is useful if a driver needs to have station
  3646. * pointers protected using RCU, it can then use this call to clear
  3647. * the pointers instead of waiting for an RCU grace period to elapse
  3648. * in @sta_state.
  3649. * The callback can sleep.
  3650. *
  3651. * @sta_rc_update: Notifies the driver of changes to the bitrates that can be
  3652. * used to transmit to the station. The changes are advertised with bits
  3653. * from &enum ieee80211_rate_control_changed and the values are reflected
  3654. * in the station data. This callback should only be used when the driver
  3655. * uses hardware rate control (%IEEE80211_HW_HAS_RATE_CONTROL) since
  3656. * otherwise the rate control algorithm is notified directly.
  3657. * Must be atomic.
  3658. * @sta_rate_tbl_update: Notifies the driver that the rate table changed. This
  3659. * is only used if the configured rate control algorithm actually uses
  3660. * the new rate table API, and is therefore optional. Must be atomic.
  3661. *
  3662. * @sta_statistics: Get statistics for this station. For example with beacon
  3663. * filtering, the statistics kept by mac80211 might not be accurate, so
  3664. * let the driver pre-fill the statistics. The driver can fill most of
  3665. * the values (indicating which by setting the filled bitmap), but not
  3666. * all of them make sense - see the source for which ones are possible.
  3667. * Statistics that the driver doesn't fill will be filled by mac80211.
  3668. * The callback can sleep.
  3669. *
  3670. * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
  3671. * bursting) for a hardware TX queue.
  3672. * Returns a negative error code on failure.
  3673. * The callback can sleep.
  3674. *
  3675. * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently,
  3676. * this is only used for IBSS mode BSSID merging and debugging. Is not a
  3677. * required function.
  3678. * The callback can sleep.
  3679. *
  3680. * @set_tsf: Set the TSF timer to the specified value in the firmware/hardware.
  3681. * Currently, this is only used for IBSS mode debugging. Is not a
  3682. * required function.
  3683. * The callback can sleep.
  3684. *
  3685. * @offset_tsf: Offset the TSF timer by the specified value in the
  3686. * firmware/hardware. Preferred to set_tsf as it avoids delay between
  3687. * calling set_tsf() and hardware getting programmed, which will show up
  3688. * as TSF delay. Is not a required function.
  3689. * The callback can sleep.
  3690. *
  3691. * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize
  3692. * with other STAs in the IBSS. This is only used in IBSS mode. This
  3693. * function is optional if the firmware/hardware takes full care of
  3694. * TSF synchronization.
  3695. * The callback can sleep.
  3696. *
  3697. * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
  3698. * This is needed only for IBSS mode and the result of this function is
  3699. * used to determine whether to reply to Probe Requests.
  3700. * Returns non-zero if this device sent the last beacon.
  3701. * The callback can sleep.
  3702. *
  3703. * @get_survey: Return per-channel survey information
  3704. *
  3705. * @rfkill_poll: Poll rfkill hardware state. If you need this, you also
  3706. * need to set wiphy->rfkill_poll to %true before registration,
  3707. * and need to call wiphy_rfkill_set_hw_state() in the callback.
  3708. * The callback can sleep.
  3709. *
  3710. * @set_coverage_class: Set slot time for given coverage class as specified
  3711. * in IEEE 802.11-2007 section 17.3.8.6 and modify ACK timeout
  3712. * accordingly; coverage class equals to -1 to enable ACK timeout
  3713. * estimation algorithm (dynack). To disable dynack set valid value for
  3714. * coverage class. This callback is not required and may sleep.
  3715. *
  3716. * @testmode_cmd: Implement a cfg80211 test mode command. The passed @vif may
  3717. * be %NULL. The callback can sleep.
  3718. * @testmode_dump: Implement a cfg80211 test mode dump. The callback can sleep.
  3719. *
  3720. * @flush: Flush all pending frames from the hardware queue, making sure
  3721. * that the hardware queues are empty. The @queues parameter is a bitmap
  3722. * of queues to flush, which is useful if different virtual interfaces
  3723. * use different hardware queues; it may also indicate all queues.
  3724. * If the parameter @drop is set to %true, pending frames may be dropped.
  3725. * Note that vif can be NULL.
  3726. * The callback can sleep.
  3727. *
  3728. * @channel_switch: Drivers that need (or want) to offload the channel
  3729. * switch operation for CSAs received from the AP may implement this
  3730. * callback. They must then call ieee80211_chswitch_done() to indicate
  3731. * completion of the channel switch.
  3732. *
  3733. * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
  3734. * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
  3735. * reject TX/RX mask combinations they cannot support by returning -EINVAL
  3736. * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
  3737. *
  3738. * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
  3739. *
  3740. * @remain_on_channel: Starts an off-channel period on the given channel, must
  3741. * call back to ieee80211_ready_on_channel() when on that channel. Note
  3742. * that normal channel traffic is not stopped as this is intended for hw
  3743. * offload. Frames to transmit on the off-channel channel are transmitted
  3744. * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the
  3745. * duration (which will always be non-zero) expires, the driver must call
  3746. * ieee80211_remain_on_channel_expired().
  3747. * Note that this callback may be called while the device is in IDLE and
  3748. * must be accepted in this case.
  3749. * This callback may sleep.
  3750. * @cancel_remain_on_channel: Requests that an ongoing off-channel period is
  3751. * aborted before it expires. This callback may sleep.
  3752. *
  3753. * @set_ringparam: Set tx and rx ring sizes.
  3754. *
  3755. * @get_ringparam: Get tx and rx ring current and maximum sizes.
  3756. *
  3757. * @tx_frames_pending: Check if there is any pending frame in the hardware
  3758. * queues before entering power save.
  3759. *
  3760. * @set_bitrate_mask: Set a mask of rates to be used for rate control selection
  3761. * when transmitting a frame. Currently only legacy rates are handled.
  3762. * The callback can sleep.
  3763. * @event_callback: Notify driver about any event in mac80211. See
  3764. * &enum ieee80211_event_type for the different types.
  3765. * The callback must be atomic.
  3766. *
  3767. * @release_buffered_frames: Release buffered frames according to the given
  3768. * parameters. In the case where the driver buffers some frames for
  3769. * sleeping stations mac80211 will use this callback to tell the driver
  3770. * to release some frames, either for PS-poll or uAPSD.
  3771. * Note that if the @more_data parameter is %false the driver must check
  3772. * if there are more frames on the given TIDs, and if there are more than
  3773. * the frames being released then it must still set the more-data bit in
  3774. * the frame. If the @more_data parameter is %true, then of course the
  3775. * more-data bit must always be set.
  3776. * The @tids parameter tells the driver which TIDs to release frames
  3777. * from, for PS-poll it will always have only a single bit set.
  3778. * In the case this is used for a PS-poll initiated release, the
  3779. * @num_frames parameter will always be 1 so code can be shared. In
  3780. * this case the driver must also set %IEEE80211_TX_STATUS_EOSP flag
  3781. * on the TX status (and must report TX status) so that the PS-poll
  3782. * period is properly ended. This is used to avoid sending multiple
  3783. * responses for a retried PS-poll frame.
  3784. * In the case this is used for uAPSD, the @num_frames parameter may be
  3785. * bigger than one, but the driver may send fewer frames (it must send
  3786. * at least one, however). In this case it is also responsible for
  3787. * setting the EOSP flag in the QoS header of the frames. Also, when the
  3788. * service period ends, the driver must set %IEEE80211_TX_STATUS_EOSP
  3789. * on the last frame in the SP. Alternatively, it may call the function
  3790. * ieee80211_sta_eosp() to inform mac80211 of the end of the SP.
  3791. * This callback must be atomic.
  3792. * @allow_buffered_frames: Prepare device to allow the given number of frames
  3793. * to go out to the given station. The frames will be sent by mac80211
  3794. * via the usual TX path after this call. The TX information for frames
  3795. * released will also have the %IEEE80211_TX_CTL_NO_PS_BUFFER flag set
  3796. * and the last one will also have %IEEE80211_TX_STATUS_EOSP set. In case
  3797. * frames from multiple TIDs are released and the driver might reorder
  3798. * them between the TIDs, it must set the %IEEE80211_TX_STATUS_EOSP flag
  3799. * on the last frame and clear it on all others and also handle the EOSP
  3800. * bit in the QoS header correctly. Alternatively, it can also call the
  3801. * ieee80211_sta_eosp() function.
  3802. * The @tids parameter is a bitmap and tells the driver which TIDs the
  3803. * frames will be on; it will at most have two bits set.
  3804. * This callback must be atomic.
  3805. *
  3806. * @get_et_sset_count: Ethtool API to get string-set count.
  3807. *
  3808. * @get_et_stats: Ethtool API to get a set of u64 stats.
  3809. *
  3810. * @get_et_strings: Ethtool API to get a set of strings to describe stats
  3811. * and perhaps other supported types of ethtool data-sets.
  3812. *
  3813. * @mgd_prepare_tx: Prepare for transmitting a management frame for association
  3814. * before associated. In multi-channel scenarios, a virtual interface is
  3815. * bound to a channel before it is associated, but as it isn't associated
  3816. * yet it need not necessarily be given airtime, in particular since any
  3817. * transmission to a P2P GO needs to be synchronized against the GO's
  3818. * powersave state. mac80211 will call this function before transmitting a
  3819. * management frame prior to having successfully associated to allow the
  3820. * driver to give it channel time for the transmission, to get a response
  3821. * and to be able to synchronize with the GO.
  3822. * For drivers that set %IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP, mac80211
  3823. * would also call this function before transmitting a deauthentication
  3824. * frame in case that no beacon was heard from the AP/P2P GO.
  3825. * The callback will be called before each transmission and upon return
  3826. * mac80211 will transmit the frame right away.
  3827. * Additional information is passed in the &struct ieee80211_prep_tx_info
  3828. * data. If duration there is greater than zero, mac80211 hints to the
  3829. * driver the duration for which the operation is requested.
  3830. * The callback is optional and can (should!) sleep.
  3831. * @mgd_complete_tx: Notify the driver that the response frame for a previously
  3832. * transmitted frame announced with @mgd_prepare_tx was received, the data
  3833. * is filled similarly to @mgd_prepare_tx though the duration is not used.
  3834. *
  3835. * @mgd_protect_tdls_discover: Protect a TDLS discovery session. After sending
  3836. * a TDLS discovery-request, we expect a reply to arrive on the AP's
  3837. * channel. We must stay on the channel (no PSM, scan, etc.), since a TDLS
  3838. * setup-response is a direct packet not buffered by the AP.
  3839. * mac80211 will call this function just before the transmission of a TDLS
  3840. * discovery-request. The recommended period of protection is at least
  3841. * 2 * (DTIM period).
  3842. * The callback is optional and can sleep.
  3843. *
  3844. * @add_chanctx: Notifies device driver about new channel context creation.
  3845. * This callback may sleep.
  3846. * @remove_chanctx: Notifies device driver about channel context destruction.
  3847. * This callback may sleep.
  3848. * @change_chanctx: Notifies device driver about channel context changes that
  3849. * may happen when combining different virtual interfaces on the same
  3850. * channel context with different settings
  3851. * This callback may sleep.
  3852. * @assign_vif_chanctx: Notifies device driver about channel context being bound
  3853. * to vif. Possible use is for hw queue remapping.
  3854. * This callback may sleep.
  3855. * @unassign_vif_chanctx: Notifies device driver about channel context being
  3856. * unbound from vif.
  3857. * This callback may sleep.
  3858. * @switch_vif_chanctx: switch a number of vifs from one chanctx to
  3859. * another, as specified in the list of
  3860. * @ieee80211_vif_chanctx_switch passed to the driver, according
  3861. * to the mode defined in &ieee80211_chanctx_switch_mode.
  3862. * This callback may sleep.
  3863. *
  3864. * @start_ap: Start operation on the AP interface, this is called after all the
  3865. * information in bss_conf is set and beacon can be retrieved. A channel
  3866. * context is bound before this is called. Note that if the driver uses
  3867. * software scan or ROC, this (and @stop_ap) isn't called when the AP is
  3868. * just "paused" for scanning/ROC, which is indicated by the beacon being
  3869. * disabled/enabled via @bss_info_changed.
  3870. * @stop_ap: Stop operation on the AP interface.
  3871. *
  3872. * @reconfig_complete: Called after a call to ieee80211_restart_hw() and
  3873. * during resume, when the reconfiguration has completed.
  3874. * This can help the driver implement the reconfiguration step (and
  3875. * indicate mac80211 is ready to receive frames).
  3876. * This callback may sleep.
  3877. *
  3878. * @ipv6_addr_change: IPv6 address assignment on the given interface changed.
  3879. * Currently, this is only called for managed or P2P client interfaces.
  3880. * This callback is optional; it must not sleep.
  3881. *
  3882. * @channel_switch_beacon: Starts a channel switch to a new channel.
  3883. * Beacons are modified to include CSA or ECSA IEs before calling this
  3884. * function. The corresponding count fields in these IEs must be
  3885. * decremented, and when they reach 1 the driver must call
  3886. * ieee80211_csa_finish(). Drivers which use ieee80211_beacon_get()
  3887. * get the csa counter decremented by mac80211, but must check if it is
  3888. * 1 using ieee80211_beacon_counter_is_complete() after the beacon has been
  3889. * transmitted and then call ieee80211_csa_finish().
  3890. * If the CSA count starts as zero or 1, this function will not be called,
  3891. * since there won't be any time to beacon before the switch anyway.
  3892. * @pre_channel_switch: This is an optional callback that is called
  3893. * before a channel switch procedure is started (ie. when a STA
  3894. * gets a CSA or a userspace initiated channel-switch), allowing
  3895. * the driver to prepare for the channel switch.
  3896. * @post_channel_switch: This is an optional callback that is called
  3897. * after a channel switch procedure is completed, allowing the
  3898. * driver to go back to a normal configuration.
  3899. * @abort_channel_switch: This is an optional callback that is called
  3900. * when channel switch procedure was completed, allowing the
  3901. * driver to go back to a normal configuration.
  3902. * @channel_switch_rx_beacon: This is an optional callback that is called
  3903. * when channel switch procedure is in progress and additional beacon with
  3904. * CSA IE was received, allowing driver to track changes in count.
  3905. * @join_ibss: Join an IBSS (on an IBSS interface); this is called after all
  3906. * information in bss_conf is set up and the beacon can be retrieved. A
  3907. * channel context is bound before this is called.
  3908. * @leave_ibss: Leave the IBSS again.
  3909. *
  3910. * @get_expected_throughput: extract the expected throughput towards the
  3911. * specified station. The returned value is expressed in Kbps. It returns 0
  3912. * if the RC algorithm does not have proper data to provide.
  3913. *
  3914. * @get_txpower: get current maximum tx power (in dBm) based on configuration
  3915. * and hardware limits.
  3916. *
  3917. * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
  3918. * is responsible for continually initiating channel-switching operations
  3919. * and returning to the base channel for communication with the AP. The
  3920. * driver receives a channel-switch request template and the location of
  3921. * the switch-timing IE within the template as part of the invocation.
  3922. * The template is valid only within the call, and the driver can
  3923. * optionally copy the skb for further re-use.
  3924. * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
  3925. * peers must be on the base channel when the call completes.
  3926. * @tdls_recv_channel_switch: a TDLS channel-switch related frame (request or
  3927. * response) has been received from a remote peer. The driver gets
  3928. * parameters parsed from the incoming frame and may use them to continue
  3929. * an ongoing channel-switch operation. In addition, a channel-switch
  3930. * response template is provided, together with the location of the
  3931. * switch-timing IE within the template. The skb can only be used within
  3932. * the function call.
  3933. *
  3934. * @wake_tx_queue: Called when new packets have been added to the queue.
  3935. * @sync_rx_queues: Process all pending frames in RSS queues. This is a
  3936. * synchronization which is needed in case driver has in its RSS queues
  3937. * pending frames that were received prior to the control path action
  3938. * currently taken (e.g. disassociation) but are not processed yet.
  3939. *
  3940. * @start_nan: join an existing NAN cluster, or create a new one.
  3941. * @stop_nan: leave the NAN cluster.
  3942. * @nan_change_conf: change NAN configuration. The data in cfg80211_nan_conf
  3943. * contains full new configuration and changes specify which parameters
  3944. * are changed with respect to the last NAN config.
  3945. * The driver gets both full configuration and the changed parameters since
  3946. * some devices may need the full configuration while others need only the
  3947. * changed parameters.
  3948. * @add_nan_func: Add a NAN function. Returns 0 on success. The data in
  3949. * cfg80211_nan_func must not be referenced outside the scope of
  3950. * this call.
  3951. * @del_nan_func: Remove a NAN function. The driver must call
  3952. * ieee80211_nan_func_terminated() with
  3953. * NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST reason code upon removal.
  3954. * @can_aggregate_in_amsdu: Called in order to determine if HW supports
  3955. * aggregating two specific frames in the same A-MSDU. The relation
  3956. * between the skbs should be symmetric and transitive. Note that while
  3957. * skb is always a real frame, head may or may not be an A-MSDU.
  3958. * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
  3959. * Statistics should be cumulative, currently no way to reset is provided.
  3960. *
  3961. * @start_pmsr: start peer measurement (e.g. FTM) (this call can sleep)
  3962. * @abort_pmsr: abort peer measurement (this call can sleep)
  3963. * @set_tid_config: Apply TID specific configurations. This callback may sleep.
  3964. * @reset_tid_config: Reset TID specific configuration for the peer.
  3965. * This callback may sleep.
  3966. * @update_vif_offload: Update virtual interface offload flags
  3967. * This callback may sleep.
  3968. * @sta_set_4addr: Called to notify the driver when a station starts/stops using
  3969. * 4-address mode
  3970. * @set_sar_specs: Update the SAR (TX power) settings.
  3971. * @sta_set_decap_offload: Called to notify the driver when a station is allowed
  3972. * to use rx decapsulation offload
  3973. * @add_twt_setup: Update hw with TWT agreement parameters received from the peer.
  3974. * This callback allows the hw to check if requested parameters
  3975. * are supported and if there is enough room for a new agreement.
  3976. * The hw is expected to set agreement result in the req_type field of
  3977. * twt structure.
  3978. * @twt_teardown_request: Update the hw with TWT teardown request received
  3979. * from the peer.
  3980. * @set_radar_background: Configure dedicated offchannel chain available for
  3981. * radar/CAC detection on some hw. This chain can't be used to transmit
  3982. * or receive frames and it is bounded to a running wdev.
  3983. * Background radar/CAC detection allows to avoid the CAC downtime
  3984. * switching to a different channel during CAC detection on the selected
  3985. * radar channel.
  3986. * The caller is expected to set chandef pointer to NULL in order to
  3987. * disable background CAC/radar detection.
  3988. * @net_fill_forward_path: Called from .ndo_fill_forward_path in order to
  3989. * resolve a path for hardware flow offloading
  3990. * @change_vif_links: Change the valid links on an interface, note that while
  3991. * removing the old link information is still valid (link_conf pointer),
  3992. * but may immediately disappear after the function returns. The old or
  3993. * new links bitmaps may be 0 if going from/to a non-MLO situation.
  3994. * The @old array contains pointers to the old bss_conf structures
  3995. * that were already removed, in case they're needed.
  3996. * This callback can sleep.
  3997. * @change_sta_links: Change the valid links of a station, similar to
  3998. * @change_vif_links. This callback can sleep.
  3999. * Note that a sta can also be inserted or removed with valid links,
  4000. * i.e. passed to @sta_add/@sta_state with sta->valid_links not zero.
  4001. * In fact, cannot change from having valid_links and not having them.
  4002. */
  4003. struct ieee80211_ops {
  4004. void (*tx)(struct ieee80211_hw *hw,
  4005. struct ieee80211_tx_control *control,
  4006. struct sk_buff *skb);
  4007. int (*start)(struct ieee80211_hw *hw);
  4008. void (*stop)(struct ieee80211_hw *hw);
  4009. #ifdef CONFIG_PM
  4010. int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
  4011. int (*resume)(struct ieee80211_hw *hw);
  4012. void (*set_wakeup)(struct ieee80211_hw *hw, bool enabled);
  4013. #endif
  4014. int (*add_interface)(struct ieee80211_hw *hw,
  4015. struct ieee80211_vif *vif);
  4016. int (*change_interface)(struct ieee80211_hw *hw,
  4017. struct ieee80211_vif *vif,
  4018. enum nl80211_iftype new_type, bool p2p);
  4019. void (*remove_interface)(struct ieee80211_hw *hw,
  4020. struct ieee80211_vif *vif);
  4021. int (*config)(struct ieee80211_hw *hw, u32 changed);
  4022. void (*bss_info_changed)(struct ieee80211_hw *hw,
  4023. struct ieee80211_vif *vif,
  4024. struct ieee80211_bss_conf *info,
  4025. u64 changed);
  4026. void (*vif_cfg_changed)(struct ieee80211_hw *hw,
  4027. struct ieee80211_vif *vif,
  4028. u64 changed);
  4029. void (*link_info_changed)(struct ieee80211_hw *hw,
  4030. struct ieee80211_vif *vif,
  4031. struct ieee80211_bss_conf *info,
  4032. u64 changed);
  4033. int (*start_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4034. struct ieee80211_bss_conf *link_conf);
  4035. void (*stop_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4036. struct ieee80211_bss_conf *link_conf);
  4037. u64 (*prepare_multicast)(struct ieee80211_hw *hw,
  4038. struct netdev_hw_addr_list *mc_list);
  4039. void (*configure_filter)(struct ieee80211_hw *hw,
  4040. unsigned int changed_flags,
  4041. unsigned int *total_flags,
  4042. u64 multicast);
  4043. void (*config_iface_filter)(struct ieee80211_hw *hw,
  4044. struct ieee80211_vif *vif,
  4045. unsigned int filter_flags,
  4046. unsigned int changed_flags);
  4047. int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
  4048. bool set);
  4049. int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  4050. struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  4051. struct ieee80211_key_conf *key);
  4052. void (*update_tkip_key)(struct ieee80211_hw *hw,
  4053. struct ieee80211_vif *vif,
  4054. struct ieee80211_key_conf *conf,
  4055. struct ieee80211_sta *sta,
  4056. u32 iv32, u16 *phase1key);
  4057. void (*set_rekey_data)(struct ieee80211_hw *hw,
  4058. struct ieee80211_vif *vif,
  4059. struct cfg80211_gtk_rekey_data *data);
  4060. void (*set_default_unicast_key)(struct ieee80211_hw *hw,
  4061. struct ieee80211_vif *vif, int idx);
  4062. int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4063. struct ieee80211_scan_request *req);
  4064. void (*cancel_hw_scan)(struct ieee80211_hw *hw,
  4065. struct ieee80211_vif *vif);
  4066. int (*sched_scan_start)(struct ieee80211_hw *hw,
  4067. struct ieee80211_vif *vif,
  4068. struct cfg80211_sched_scan_request *req,
  4069. struct ieee80211_scan_ies *ies);
  4070. int (*sched_scan_stop)(struct ieee80211_hw *hw,
  4071. struct ieee80211_vif *vif);
  4072. void (*sw_scan_start)(struct ieee80211_hw *hw,
  4073. struct ieee80211_vif *vif,
  4074. const u8 *mac_addr);
  4075. void (*sw_scan_complete)(struct ieee80211_hw *hw,
  4076. struct ieee80211_vif *vif);
  4077. int (*get_stats)(struct ieee80211_hw *hw,
  4078. struct ieee80211_low_level_stats *stats);
  4079. void (*get_key_seq)(struct ieee80211_hw *hw,
  4080. struct ieee80211_key_conf *key,
  4081. struct ieee80211_key_seq *seq);
  4082. int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
  4083. int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
  4084. int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4085. struct ieee80211_sta *sta);
  4086. int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4087. struct ieee80211_sta *sta);
  4088. #ifdef CONFIG_MAC80211_DEBUGFS
  4089. void (*sta_add_debugfs)(struct ieee80211_hw *hw,
  4090. struct ieee80211_vif *vif,
  4091. struct ieee80211_sta *sta,
  4092. struct dentry *dir);
  4093. #endif
  4094. void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4095. enum sta_notify_cmd, struct ieee80211_sta *sta);
  4096. int (*sta_set_txpwr)(struct ieee80211_hw *hw,
  4097. struct ieee80211_vif *vif,
  4098. struct ieee80211_sta *sta);
  4099. int (*sta_state)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4100. struct ieee80211_sta *sta,
  4101. enum ieee80211_sta_state old_state,
  4102. enum ieee80211_sta_state new_state);
  4103. void (*sta_pre_rcu_remove)(struct ieee80211_hw *hw,
  4104. struct ieee80211_vif *vif,
  4105. struct ieee80211_sta *sta);
  4106. void (*sta_rc_update)(struct ieee80211_hw *hw,
  4107. struct ieee80211_vif *vif,
  4108. struct ieee80211_sta *sta,
  4109. u32 changed);
  4110. void (*sta_rate_tbl_update)(struct ieee80211_hw *hw,
  4111. struct ieee80211_vif *vif,
  4112. struct ieee80211_sta *sta);
  4113. void (*sta_statistics)(struct ieee80211_hw *hw,
  4114. struct ieee80211_vif *vif,
  4115. struct ieee80211_sta *sta,
  4116. struct station_info *sinfo);
  4117. int (*conf_tx)(struct ieee80211_hw *hw,
  4118. struct ieee80211_vif *vif,
  4119. unsigned int link_id, u16 ac,
  4120. const struct ieee80211_tx_queue_params *params);
  4121. u64 (*get_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  4122. void (*set_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4123. u64 tsf);
  4124. void (*offset_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4125. s64 offset);
  4126. void (*reset_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  4127. int (*tx_last_beacon)(struct ieee80211_hw *hw);
  4128. /**
  4129. * @ampdu_action:
  4130. * Perform a certain A-MPDU action.
  4131. * The RA/TID combination determines the destination and TID we want
  4132. * the ampdu action to be performed for. The action is defined through
  4133. * ieee80211_ampdu_mlme_action.
  4134. * When the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL the driver
  4135. * may neither send aggregates containing more subframes than @buf_size
  4136. * nor send aggregates in a way that lost frames would exceed the
  4137. * buffer size. If just limiting the aggregate size, this would be
  4138. * possible with a buf_size of 8:
  4139. *
  4140. * - ``TX: 1.....7``
  4141. * - ``RX: 2....7`` (lost frame #1)
  4142. * - ``TX: 8..1...``
  4143. *
  4144. * which is invalid since #1 was now re-transmitted well past the
  4145. * buffer size of 8. Correct ways to retransmit #1 would be:
  4146. *
  4147. * - ``TX: 1 or``
  4148. * - ``TX: 18 or``
  4149. * - ``TX: 81``
  4150. *
  4151. * Even ``189`` would be wrong since 1 could be lost again.
  4152. *
  4153. * Returns a negative error code on failure. The driver may return
  4154. * %IEEE80211_AMPDU_TX_START_IMMEDIATE for %IEEE80211_AMPDU_TX_START
  4155. * if the session can start immediately.
  4156. *
  4157. * The callback can sleep.
  4158. */
  4159. int (*ampdu_action)(struct ieee80211_hw *hw,
  4160. struct ieee80211_vif *vif,
  4161. struct ieee80211_ampdu_params *params);
  4162. int (*get_survey)(struct ieee80211_hw *hw, int idx,
  4163. struct survey_info *survey);
  4164. void (*rfkill_poll)(struct ieee80211_hw *hw);
  4165. void (*set_coverage_class)(struct ieee80211_hw *hw, s16 coverage_class);
  4166. #ifdef CONFIG_NL80211_TESTMODE
  4167. int (*testmode_cmd)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4168. void *data, int len);
  4169. int (*testmode_dump)(struct ieee80211_hw *hw, struct sk_buff *skb,
  4170. struct netlink_callback *cb,
  4171. void *data, int len);
  4172. #endif
  4173. void (*flush)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4174. u32 queues, bool drop);
  4175. void (*channel_switch)(struct ieee80211_hw *hw,
  4176. struct ieee80211_vif *vif,
  4177. struct ieee80211_channel_switch *ch_switch);
  4178. int (*set_antenna)(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant);
  4179. int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
  4180. int (*remain_on_channel)(struct ieee80211_hw *hw,
  4181. struct ieee80211_vif *vif,
  4182. struct ieee80211_channel *chan,
  4183. int duration,
  4184. enum ieee80211_roc_type type);
  4185. int (*cancel_remain_on_channel)(struct ieee80211_hw *hw,
  4186. struct ieee80211_vif *vif);
  4187. int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx);
  4188. void (*get_ringparam)(struct ieee80211_hw *hw,
  4189. u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
  4190. bool (*tx_frames_pending)(struct ieee80211_hw *hw);
  4191. int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4192. const struct cfg80211_bitrate_mask *mask);
  4193. void (*event_callback)(struct ieee80211_hw *hw,
  4194. struct ieee80211_vif *vif,
  4195. const struct ieee80211_event *event);
  4196. void (*allow_buffered_frames)(struct ieee80211_hw *hw,
  4197. struct ieee80211_sta *sta,
  4198. u16 tids, int num_frames,
  4199. enum ieee80211_frame_release_type reason,
  4200. bool more_data);
  4201. void (*release_buffered_frames)(struct ieee80211_hw *hw,
  4202. struct ieee80211_sta *sta,
  4203. u16 tids, int num_frames,
  4204. enum ieee80211_frame_release_type reason,
  4205. bool more_data);
  4206. int (*get_et_sset_count)(struct ieee80211_hw *hw,
  4207. struct ieee80211_vif *vif, int sset);
  4208. void (*get_et_stats)(struct ieee80211_hw *hw,
  4209. struct ieee80211_vif *vif,
  4210. struct ethtool_stats *stats, u64 *data);
  4211. void (*get_et_strings)(struct ieee80211_hw *hw,
  4212. struct ieee80211_vif *vif,
  4213. u32 sset, u8 *data);
  4214. void (*mgd_prepare_tx)(struct ieee80211_hw *hw,
  4215. struct ieee80211_vif *vif,
  4216. struct ieee80211_prep_tx_info *info);
  4217. void (*mgd_complete_tx)(struct ieee80211_hw *hw,
  4218. struct ieee80211_vif *vif,
  4219. struct ieee80211_prep_tx_info *info);
  4220. void (*mgd_protect_tdls_discover)(struct ieee80211_hw *hw,
  4221. struct ieee80211_vif *vif);
  4222. int (*add_chanctx)(struct ieee80211_hw *hw,
  4223. struct ieee80211_chanctx_conf *ctx);
  4224. void (*remove_chanctx)(struct ieee80211_hw *hw,
  4225. struct ieee80211_chanctx_conf *ctx);
  4226. void (*change_chanctx)(struct ieee80211_hw *hw,
  4227. struct ieee80211_chanctx_conf *ctx,
  4228. u32 changed);
  4229. int (*assign_vif_chanctx)(struct ieee80211_hw *hw,
  4230. struct ieee80211_vif *vif,
  4231. struct ieee80211_bss_conf *link_conf,
  4232. struct ieee80211_chanctx_conf *ctx);
  4233. void (*unassign_vif_chanctx)(struct ieee80211_hw *hw,
  4234. struct ieee80211_vif *vif,
  4235. struct ieee80211_bss_conf *link_conf,
  4236. struct ieee80211_chanctx_conf *ctx);
  4237. int (*switch_vif_chanctx)(struct ieee80211_hw *hw,
  4238. struct ieee80211_vif_chanctx_switch *vifs,
  4239. int n_vifs,
  4240. enum ieee80211_chanctx_switch_mode mode);
  4241. void (*reconfig_complete)(struct ieee80211_hw *hw,
  4242. enum ieee80211_reconfig_type reconfig_type);
  4243. #if IS_ENABLED(CONFIG_IPV6)
  4244. void (*ipv6_addr_change)(struct ieee80211_hw *hw,
  4245. struct ieee80211_vif *vif,
  4246. struct inet6_dev *idev);
  4247. #endif
  4248. void (*channel_switch_beacon)(struct ieee80211_hw *hw,
  4249. struct ieee80211_vif *vif,
  4250. struct cfg80211_chan_def *chandef);
  4251. int (*pre_channel_switch)(struct ieee80211_hw *hw,
  4252. struct ieee80211_vif *vif,
  4253. struct ieee80211_channel_switch *ch_switch);
  4254. int (*post_channel_switch)(struct ieee80211_hw *hw,
  4255. struct ieee80211_vif *vif);
  4256. void (*abort_channel_switch)(struct ieee80211_hw *hw,
  4257. struct ieee80211_vif *vif);
  4258. void (*channel_switch_rx_beacon)(struct ieee80211_hw *hw,
  4259. struct ieee80211_vif *vif,
  4260. struct ieee80211_channel_switch *ch_switch);
  4261. int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  4262. void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  4263. u32 (*get_expected_throughput)(struct ieee80211_hw *hw,
  4264. struct ieee80211_sta *sta);
  4265. int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4266. int *dbm);
  4267. int (*tdls_channel_switch)(struct ieee80211_hw *hw,
  4268. struct ieee80211_vif *vif,
  4269. struct ieee80211_sta *sta, u8 oper_class,
  4270. struct cfg80211_chan_def *chandef,
  4271. struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
  4272. void (*tdls_cancel_channel_switch)(struct ieee80211_hw *hw,
  4273. struct ieee80211_vif *vif,
  4274. struct ieee80211_sta *sta);
  4275. void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw,
  4276. struct ieee80211_vif *vif,
  4277. struct ieee80211_tdls_ch_sw_params *params);
  4278. void (*wake_tx_queue)(struct ieee80211_hw *hw,
  4279. struct ieee80211_txq *txq);
  4280. void (*sync_rx_queues)(struct ieee80211_hw *hw);
  4281. int (*start_nan)(struct ieee80211_hw *hw,
  4282. struct ieee80211_vif *vif,
  4283. struct cfg80211_nan_conf *conf);
  4284. int (*stop_nan)(struct ieee80211_hw *hw,
  4285. struct ieee80211_vif *vif);
  4286. int (*nan_change_conf)(struct ieee80211_hw *hw,
  4287. struct ieee80211_vif *vif,
  4288. struct cfg80211_nan_conf *conf, u32 changes);
  4289. int (*add_nan_func)(struct ieee80211_hw *hw,
  4290. struct ieee80211_vif *vif,
  4291. const struct cfg80211_nan_func *nan_func);
  4292. void (*del_nan_func)(struct ieee80211_hw *hw,
  4293. struct ieee80211_vif *vif,
  4294. u8 instance_id);
  4295. bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *hw,
  4296. struct sk_buff *head,
  4297. struct sk_buff *skb);
  4298. int (*get_ftm_responder_stats)(struct ieee80211_hw *hw,
  4299. struct ieee80211_vif *vif,
  4300. struct cfg80211_ftm_responder_stats *ftm_stats);
  4301. int (*start_pmsr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4302. struct cfg80211_pmsr_request *request);
  4303. void (*abort_pmsr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4304. struct cfg80211_pmsr_request *request);
  4305. int (*set_tid_config)(struct ieee80211_hw *hw,
  4306. struct ieee80211_vif *vif,
  4307. struct ieee80211_sta *sta,
  4308. struct cfg80211_tid_config *tid_conf);
  4309. int (*reset_tid_config)(struct ieee80211_hw *hw,
  4310. struct ieee80211_vif *vif,
  4311. struct ieee80211_sta *sta, u8 tids);
  4312. void (*update_vif_offload)(struct ieee80211_hw *hw,
  4313. struct ieee80211_vif *vif);
  4314. void (*sta_set_4addr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  4315. struct ieee80211_sta *sta, bool enabled);
  4316. int (*set_sar_specs)(struct ieee80211_hw *hw,
  4317. const struct cfg80211_sar_specs *sar);
  4318. void (*sta_set_decap_offload)(struct ieee80211_hw *hw,
  4319. struct ieee80211_vif *vif,
  4320. struct ieee80211_sta *sta, bool enabled);
  4321. void (*add_twt_setup)(struct ieee80211_hw *hw,
  4322. struct ieee80211_sta *sta,
  4323. struct ieee80211_twt_setup *twt);
  4324. void (*twt_teardown_request)(struct ieee80211_hw *hw,
  4325. struct ieee80211_sta *sta, u8 flowid);
  4326. int (*set_radar_background)(struct ieee80211_hw *hw,
  4327. struct cfg80211_chan_def *chandef);
  4328. int (*net_fill_forward_path)(struct ieee80211_hw *hw,
  4329. struct ieee80211_vif *vif,
  4330. struct ieee80211_sta *sta,
  4331. struct net_device_path_ctx *ctx,
  4332. struct net_device_path *path);
  4333. int (*change_vif_links)(struct ieee80211_hw *hw,
  4334. struct ieee80211_vif *vif,
  4335. u16 old_links, u16 new_links,
  4336. struct ieee80211_bss_conf *old[IEEE80211_MLD_MAX_NUM_LINKS]);
  4337. int (*change_sta_links)(struct ieee80211_hw *hw,
  4338. struct ieee80211_vif *vif,
  4339. struct ieee80211_sta *sta,
  4340. u16 old_links, u16 new_links);
  4341. ANDROID_KABI_RESERVE(1);
  4342. ANDROID_KABI_RESERVE(2);
  4343. ANDROID_KABI_RESERVE(3);
  4344. ANDROID_KABI_RESERVE(4);
  4345. };
  4346. /**
  4347. * ieee80211_alloc_hw_nm - Allocate a new hardware device
  4348. *
  4349. * This must be called once for each hardware device. The returned pointer
  4350. * must be used to refer to this device when calling other functions.
  4351. * mac80211 allocates a private data area for the driver pointed to by
  4352. * @priv in &struct ieee80211_hw, the size of this area is given as
  4353. * @priv_data_len.
  4354. *
  4355. * @priv_data_len: length of private data
  4356. * @ops: callbacks for this device
  4357. * @requested_name: Requested name for this device.
  4358. * NULL is valid value, and means use the default naming (phy%d)
  4359. *
  4360. * Return: A pointer to the new hardware device, or %NULL on error.
  4361. */
  4362. struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
  4363. const struct ieee80211_ops *ops,
  4364. const char *requested_name);
  4365. /**
  4366. * ieee80211_alloc_hw - Allocate a new hardware device
  4367. *
  4368. * This must be called once for each hardware device. The returned pointer
  4369. * must be used to refer to this device when calling other functions.
  4370. * mac80211 allocates a private data area for the driver pointed to by
  4371. * @priv in &struct ieee80211_hw, the size of this area is given as
  4372. * @priv_data_len.
  4373. *
  4374. * @priv_data_len: length of private data
  4375. * @ops: callbacks for this device
  4376. *
  4377. * Return: A pointer to the new hardware device, or %NULL on error.
  4378. */
  4379. static inline
  4380. struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
  4381. const struct ieee80211_ops *ops)
  4382. {
  4383. return ieee80211_alloc_hw_nm(priv_data_len, ops, NULL);
  4384. }
  4385. /**
  4386. * ieee80211_register_hw - Register hardware device
  4387. *
  4388. * You must call this function before any other functions in
  4389. * mac80211. Note that before a hardware can be registered, you
  4390. * need to fill the contained wiphy's information.
  4391. *
  4392. * @hw: the device to register as returned by ieee80211_alloc_hw()
  4393. *
  4394. * Return: 0 on success. An error code otherwise.
  4395. */
  4396. int ieee80211_register_hw(struct ieee80211_hw *hw);
  4397. /**
  4398. * struct ieee80211_tpt_blink - throughput blink description
  4399. * @throughput: throughput in Kbit/sec
  4400. * @blink_time: blink time in milliseconds
  4401. * (full cycle, ie. one off + one on period)
  4402. */
  4403. struct ieee80211_tpt_blink {
  4404. int throughput;
  4405. int blink_time;
  4406. };
  4407. /**
  4408. * enum ieee80211_tpt_led_trigger_flags - throughput trigger flags
  4409. * @IEEE80211_TPT_LEDTRIG_FL_RADIO: enable blinking with radio
  4410. * @IEEE80211_TPT_LEDTRIG_FL_WORK: enable blinking when working
  4411. * @IEEE80211_TPT_LEDTRIG_FL_CONNECTED: enable blinking when at least one
  4412. * interface is connected in some way, including being an AP
  4413. */
  4414. enum ieee80211_tpt_led_trigger_flags {
  4415. IEEE80211_TPT_LEDTRIG_FL_RADIO = BIT(0),
  4416. IEEE80211_TPT_LEDTRIG_FL_WORK = BIT(1),
  4417. IEEE80211_TPT_LEDTRIG_FL_CONNECTED = BIT(2),
  4418. };
  4419. #ifdef CONFIG_MAC80211_LEDS
  4420. const char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
  4421. const char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
  4422. const char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
  4423. const char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
  4424. const char *
  4425. __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
  4426. unsigned int flags,
  4427. const struct ieee80211_tpt_blink *blink_table,
  4428. unsigned int blink_table_len);
  4429. #endif
  4430. /**
  4431. * ieee80211_get_tx_led_name - get name of TX LED
  4432. *
  4433. * mac80211 creates a transmit LED trigger for each wireless hardware
  4434. * that can be used to drive LEDs if your driver registers a LED device.
  4435. * This function returns the name (or %NULL if not configured for LEDs)
  4436. * of the trigger so you can automatically link the LED device.
  4437. *
  4438. * @hw: the hardware to get the LED trigger name for
  4439. *
  4440. * Return: The name of the LED trigger. %NULL if not configured for LEDs.
  4441. */
  4442. static inline const char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
  4443. {
  4444. #ifdef CONFIG_MAC80211_LEDS
  4445. return __ieee80211_get_tx_led_name(hw);
  4446. #else
  4447. return NULL;
  4448. #endif
  4449. }
  4450. /**
  4451. * ieee80211_get_rx_led_name - get name of RX LED
  4452. *
  4453. * mac80211 creates a receive LED trigger for each wireless hardware
  4454. * that can be used to drive LEDs if your driver registers a LED device.
  4455. * This function returns the name (or %NULL if not configured for LEDs)
  4456. * of the trigger so you can automatically link the LED device.
  4457. *
  4458. * @hw: the hardware to get the LED trigger name for
  4459. *
  4460. * Return: The name of the LED trigger. %NULL if not configured for LEDs.
  4461. */
  4462. static inline const char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
  4463. {
  4464. #ifdef CONFIG_MAC80211_LEDS
  4465. return __ieee80211_get_rx_led_name(hw);
  4466. #else
  4467. return NULL;
  4468. #endif
  4469. }
  4470. /**
  4471. * ieee80211_get_assoc_led_name - get name of association LED
  4472. *
  4473. * mac80211 creates a association LED trigger for each wireless hardware
  4474. * that can be used to drive LEDs if your driver registers a LED device.
  4475. * This function returns the name (or %NULL if not configured for LEDs)
  4476. * of the trigger so you can automatically link the LED device.
  4477. *
  4478. * @hw: the hardware to get the LED trigger name for
  4479. *
  4480. * Return: The name of the LED trigger. %NULL if not configured for LEDs.
  4481. */
  4482. static inline const char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
  4483. {
  4484. #ifdef CONFIG_MAC80211_LEDS
  4485. return __ieee80211_get_assoc_led_name(hw);
  4486. #else
  4487. return NULL;
  4488. #endif
  4489. }
  4490. /**
  4491. * ieee80211_get_radio_led_name - get name of radio LED
  4492. *
  4493. * mac80211 creates a radio change LED trigger for each wireless hardware
  4494. * that can be used to drive LEDs if your driver registers a LED device.
  4495. * This function returns the name (or %NULL if not configured for LEDs)
  4496. * of the trigger so you can automatically link the LED device.
  4497. *
  4498. * @hw: the hardware to get the LED trigger name for
  4499. *
  4500. * Return: The name of the LED trigger. %NULL if not configured for LEDs.
  4501. */
  4502. static inline const char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
  4503. {
  4504. #ifdef CONFIG_MAC80211_LEDS
  4505. return __ieee80211_get_radio_led_name(hw);
  4506. #else
  4507. return NULL;
  4508. #endif
  4509. }
  4510. /**
  4511. * ieee80211_create_tpt_led_trigger - create throughput LED trigger
  4512. * @hw: the hardware to create the trigger for
  4513. * @flags: trigger flags, see &enum ieee80211_tpt_led_trigger_flags
  4514. * @blink_table: the blink table -- needs to be ordered by throughput
  4515. * @blink_table_len: size of the blink table
  4516. *
  4517. * Return: %NULL (in case of error, or if no LED triggers are
  4518. * configured) or the name of the new trigger.
  4519. *
  4520. * Note: This function must be called before ieee80211_register_hw().
  4521. */
  4522. static inline const char *
  4523. ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags,
  4524. const struct ieee80211_tpt_blink *blink_table,
  4525. unsigned int blink_table_len)
  4526. {
  4527. #ifdef CONFIG_MAC80211_LEDS
  4528. return __ieee80211_create_tpt_led_trigger(hw, flags, blink_table,
  4529. blink_table_len);
  4530. #else
  4531. return NULL;
  4532. #endif
  4533. }
  4534. /**
  4535. * ieee80211_unregister_hw - Unregister a hardware device
  4536. *
  4537. * This function instructs mac80211 to free allocated resources
  4538. * and unregister netdevices from the networking subsystem.
  4539. *
  4540. * @hw: the hardware to unregister
  4541. */
  4542. void ieee80211_unregister_hw(struct ieee80211_hw *hw);
  4543. /**
  4544. * ieee80211_free_hw - free hardware descriptor
  4545. *
  4546. * This function frees everything that was allocated, including the
  4547. * private data for the driver. You must call ieee80211_unregister_hw()
  4548. * before calling this function.
  4549. *
  4550. * @hw: the hardware to free
  4551. */
  4552. void ieee80211_free_hw(struct ieee80211_hw *hw);
  4553. /**
  4554. * ieee80211_restart_hw - restart hardware completely
  4555. *
  4556. * Call this function when the hardware was restarted for some reason
  4557. * (hardware error, ...) and the driver is unable to restore its state
  4558. * by itself. mac80211 assumes that at this point the driver/hardware
  4559. * is completely uninitialised and stopped, it starts the process by
  4560. * calling the ->start() operation. The driver will need to reset all
  4561. * internal state that it has prior to calling this function.
  4562. *
  4563. * @hw: the hardware to restart
  4564. */
  4565. void ieee80211_restart_hw(struct ieee80211_hw *hw);
  4566. /**
  4567. * ieee80211_rx_list - receive frame and store processed skbs in a list
  4568. *
  4569. * Use this function to hand received frames to mac80211. The receive
  4570. * buffer in @skb must start with an IEEE 802.11 header. In case of a
  4571. * paged @skb is used, the driver is recommended to put the ieee80211
  4572. * header of the frame on the linear part of the @skb to avoid memory
  4573. * allocation and/or memcpy by the stack.
  4574. *
  4575. * This function may not be called in IRQ context. Calls to this function
  4576. * for a single hardware must be synchronized against each other. Calls to
  4577. * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
  4578. * mixed for a single hardware. Must not run concurrently with
  4579. * ieee80211_tx_status() or ieee80211_tx_status_ni().
  4580. *
  4581. * This function must be called with BHs disabled and RCU read lock
  4582. *
  4583. * @hw: the hardware this frame came in on
  4584. * @sta: the station the frame was received from, or %NULL
  4585. * @skb: the buffer to receive, owned by mac80211 after this call
  4586. * @list: the destination list
  4587. */
  4588. void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
  4589. struct sk_buff *skb, struct list_head *list);
  4590. /**
  4591. * ieee80211_rx_napi - receive frame from NAPI context
  4592. *
  4593. * Use this function to hand received frames to mac80211. The receive
  4594. * buffer in @skb must start with an IEEE 802.11 header. In case of a
  4595. * paged @skb is used, the driver is recommended to put the ieee80211
  4596. * header of the frame on the linear part of the @skb to avoid memory
  4597. * allocation and/or memcpy by the stack.
  4598. *
  4599. * This function may not be called in IRQ context. Calls to this function
  4600. * for a single hardware must be synchronized against each other. Calls to
  4601. * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
  4602. * mixed for a single hardware. Must not run concurrently with
  4603. * ieee80211_tx_status() or ieee80211_tx_status_ni().
  4604. *
  4605. * This function must be called with BHs disabled.
  4606. *
  4607. * @hw: the hardware this frame came in on
  4608. * @sta: the station the frame was received from, or %NULL
  4609. * @skb: the buffer to receive, owned by mac80211 after this call
  4610. * @napi: the NAPI context
  4611. */
  4612. void ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
  4613. struct sk_buff *skb, struct napi_struct *napi);
  4614. /**
  4615. * ieee80211_rx - receive frame
  4616. *
  4617. * Use this function to hand received frames to mac80211. The receive
  4618. * buffer in @skb must start with an IEEE 802.11 header. In case of a
  4619. * paged @skb is used, the driver is recommended to put the ieee80211
  4620. * header of the frame on the linear part of the @skb to avoid memory
  4621. * allocation and/or memcpy by the stack.
  4622. *
  4623. * This function may not be called in IRQ context. Calls to this function
  4624. * for a single hardware must be synchronized against each other. Calls to
  4625. * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
  4626. * mixed for a single hardware. Must not run concurrently with
  4627. * ieee80211_tx_status() or ieee80211_tx_status_ni().
  4628. *
  4629. * In process context use instead ieee80211_rx_ni().
  4630. *
  4631. * @hw: the hardware this frame came in on
  4632. * @skb: the buffer to receive, owned by mac80211 after this call
  4633. */
  4634. static inline void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
  4635. {
  4636. ieee80211_rx_napi(hw, NULL, skb, NULL);
  4637. }
  4638. /**
  4639. * ieee80211_rx_irqsafe - receive frame
  4640. *
  4641. * Like ieee80211_rx() but can be called in IRQ context
  4642. * (internally defers to a tasklet.)
  4643. *
  4644. * Calls to this function, ieee80211_rx() or ieee80211_rx_ni() may not
  4645. * be mixed for a single hardware.Must not run concurrently with
  4646. * ieee80211_tx_status() or ieee80211_tx_status_ni().
  4647. *
  4648. * @hw: the hardware this frame came in on
  4649. * @skb: the buffer to receive, owned by mac80211 after this call
  4650. */
  4651. void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb);
  4652. /**
  4653. * ieee80211_rx_ni - receive frame (in process context)
  4654. *
  4655. * Like ieee80211_rx() but can be called in process context
  4656. * (internally disables bottom halves).
  4657. *
  4658. * Calls to this function, ieee80211_rx() and ieee80211_rx_irqsafe() may
  4659. * not be mixed for a single hardware. Must not run concurrently with
  4660. * ieee80211_tx_status() or ieee80211_tx_status_ni().
  4661. *
  4662. * @hw: the hardware this frame came in on
  4663. * @skb: the buffer to receive, owned by mac80211 after this call
  4664. */
  4665. static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
  4666. struct sk_buff *skb)
  4667. {
  4668. local_bh_disable();
  4669. ieee80211_rx(hw, skb);
  4670. local_bh_enable();
  4671. }
  4672. /**
  4673. * ieee80211_sta_ps_transition - PS transition for connected sta
  4674. *
  4675. * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS
  4676. * flag set, use this function to inform mac80211 about a connected station
  4677. * entering/leaving PS mode.
  4678. *
  4679. * This function may not be called in IRQ context or with softirqs enabled.
  4680. *
  4681. * Calls to this function for a single hardware must be synchronized against
  4682. * each other.
  4683. *
  4684. * @sta: currently connected sta
  4685. * @start: start or stop PS
  4686. *
  4687. * Return: 0 on success. -EINVAL when the requested PS mode is already set.
  4688. */
  4689. int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start);
  4690. /**
  4691. * ieee80211_sta_ps_transition_ni - PS transition for connected sta
  4692. * (in process context)
  4693. *
  4694. * Like ieee80211_sta_ps_transition() but can be called in process context
  4695. * (internally disables bottom halves). Concurrent call restriction still
  4696. * applies.
  4697. *
  4698. * @sta: currently connected sta
  4699. * @start: start or stop PS
  4700. *
  4701. * Return: Like ieee80211_sta_ps_transition().
  4702. */
  4703. static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta,
  4704. bool start)
  4705. {
  4706. int ret;
  4707. local_bh_disable();
  4708. ret = ieee80211_sta_ps_transition(sta, start);
  4709. local_bh_enable();
  4710. return ret;
  4711. }
  4712. /**
  4713. * ieee80211_sta_pspoll - PS-Poll frame received
  4714. * @sta: currently connected station
  4715. *
  4716. * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS flag set,
  4717. * use this function to inform mac80211 that a PS-Poll frame from a
  4718. * connected station was received.
  4719. * This must be used in conjunction with ieee80211_sta_ps_transition()
  4720. * and possibly ieee80211_sta_uapsd_trigger(); calls to all three must
  4721. * be serialized.
  4722. */
  4723. void ieee80211_sta_pspoll(struct ieee80211_sta *sta);
  4724. /**
  4725. * ieee80211_sta_uapsd_trigger - (potential) U-APSD trigger frame received
  4726. * @sta: currently connected station
  4727. * @tid: TID of the received (potential) trigger frame
  4728. *
  4729. * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS flag set,
  4730. * use this function to inform mac80211 that a (potential) trigger frame
  4731. * from a connected station was received.
  4732. * This must be used in conjunction with ieee80211_sta_ps_transition()
  4733. * and possibly ieee80211_sta_pspoll(); calls to all three must be
  4734. * serialized.
  4735. * %IEEE80211_NUM_TIDS can be passed as the tid if the tid is unknown.
  4736. * In this case, mac80211 will not check that this tid maps to an AC
  4737. * that is trigger enabled and assume that the caller did the proper
  4738. * checks.
  4739. */
  4740. void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, u8 tid);
  4741. /*
  4742. * The TX headroom reserved by mac80211 for its own tx_status functions.
  4743. * This is enough for the radiotap header.
  4744. */
  4745. #define IEEE80211_TX_STATUS_HEADROOM ALIGN(14, 4)
  4746. /**
  4747. * ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames
  4748. * @sta: &struct ieee80211_sta pointer for the sleeping station
  4749. * @tid: the TID that has buffered frames
  4750. * @buffered: indicates whether or not frames are buffered for this TID
  4751. *
  4752. * If a driver buffers frames for a powersave station instead of passing
  4753. * them back to mac80211 for retransmission, the station may still need
  4754. * to be told that there are buffered frames via the TIM bit.
  4755. *
  4756. * This function informs mac80211 whether or not there are frames that are
  4757. * buffered in the driver for a given TID; mac80211 can then use this data
  4758. * to set the TIM bit (NOTE: This may call back into the driver's set_tim
  4759. * call! Beware of the locking!)
  4760. *
  4761. * If all frames are released to the station (due to PS-poll or uAPSD)
  4762. * then the driver needs to inform mac80211 that there no longer are
  4763. * frames buffered. However, when the station wakes up mac80211 assumes
  4764. * that all buffered frames will be transmitted and clears this data,
  4765. * drivers need to make sure they inform mac80211 about all buffered
  4766. * frames on the sleep transition (sta_notify() with %STA_NOTIFY_SLEEP).
  4767. *
  4768. * Note that technically mac80211 only needs to know this per AC, not per
  4769. * TID, but since driver buffering will inevitably happen per TID (since
  4770. * it is related to aggregation) it is easier to make mac80211 map the
  4771. * TID to the AC as required instead of keeping track in all drivers that
  4772. * use this API.
  4773. */
  4774. void ieee80211_sta_set_buffered(struct ieee80211_sta *sta,
  4775. u8 tid, bool buffered);
  4776. /**
  4777. * ieee80211_get_tx_rates - get the selected transmit rates for a packet
  4778. *
  4779. * Call this function in a driver with per-packet rate selection support
  4780. * to combine the rate info in the packet tx info with the most recent
  4781. * rate selection table for the station entry.
  4782. *
  4783. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  4784. * @sta: the receiver station to which this packet is sent.
  4785. * @skb: the frame to be transmitted.
  4786. * @dest: buffer for extracted rate/retry information
  4787. * @max_rates: maximum number of rates to fetch
  4788. */
  4789. void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
  4790. struct ieee80211_sta *sta,
  4791. struct sk_buff *skb,
  4792. struct ieee80211_tx_rate *dest,
  4793. int max_rates);
  4794. /**
  4795. * ieee80211_sta_set_expected_throughput - set the expected tpt for a station
  4796. *
  4797. * Call this function to notify mac80211 about a change in expected throughput
  4798. * to a station. A driver for a device that does rate control in firmware can
  4799. * call this function when the expected throughput estimate towards a station
  4800. * changes. The information is used to tune the CoDel AQM applied to traffic
  4801. * going towards that station (which can otherwise be too aggressive and cause
  4802. * slow stations to starve).
  4803. *
  4804. * @pubsta: the station to set throughput for.
  4805. * @thr: the current expected throughput in kbps.
  4806. */
  4807. void ieee80211_sta_set_expected_throughput(struct ieee80211_sta *pubsta,
  4808. u32 thr);
  4809. /**
  4810. * ieee80211_tx_rate_update - transmit rate update callback
  4811. *
  4812. * Drivers should call this functions with a non-NULL pub sta
  4813. * This function can be used in drivers that does not have provision
  4814. * in updating the tx rate in data path.
  4815. *
  4816. * @hw: the hardware the frame was transmitted by
  4817. * @pubsta: the station to update the tx rate for.
  4818. * @info: tx status information
  4819. */
  4820. void ieee80211_tx_rate_update(struct ieee80211_hw *hw,
  4821. struct ieee80211_sta *pubsta,
  4822. struct ieee80211_tx_info *info);
  4823. /**
  4824. * ieee80211_tx_status - transmit status callback
  4825. *
  4826. * Call this function for all transmitted frames after they have been
  4827. * transmitted. It is permissible to not call this function for
  4828. * multicast frames but this can affect statistics.
  4829. *
  4830. * This function may not be called in IRQ context. Calls to this function
  4831. * for a single hardware must be synchronized against each other. Calls
  4832. * to this function, ieee80211_tx_status_ni() and ieee80211_tx_status_irqsafe()
  4833. * may not be mixed for a single hardware. Must not run concurrently with
  4834. * ieee80211_rx() or ieee80211_rx_ni().
  4835. *
  4836. * @hw: the hardware the frame was transmitted by
  4837. * @skb: the frame that was transmitted, owned by mac80211 after this call
  4838. */
  4839. void ieee80211_tx_status(struct ieee80211_hw *hw,
  4840. struct sk_buff *skb);
  4841. /**
  4842. * ieee80211_tx_status_ext - extended transmit status callback
  4843. *
  4844. * This function can be used as a replacement for ieee80211_tx_status
  4845. * in drivers that may want to provide extra information that does not
  4846. * fit into &struct ieee80211_tx_info.
  4847. *
  4848. * Calls to this function for a single hardware must be synchronized
  4849. * against each other. Calls to this function, ieee80211_tx_status_ni()
  4850. * and ieee80211_tx_status_irqsafe() may not be mixed for a single hardware.
  4851. *
  4852. * @hw: the hardware the frame was transmitted by
  4853. * @status: tx status information
  4854. */
  4855. void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
  4856. struct ieee80211_tx_status *status);
  4857. /**
  4858. * ieee80211_tx_status_noskb - transmit status callback without skb
  4859. *
  4860. * This function can be used as a replacement for ieee80211_tx_status
  4861. * in drivers that cannot reliably map tx status information back to
  4862. * specific skbs.
  4863. *
  4864. * Calls to this function for a single hardware must be synchronized
  4865. * against each other. Calls to this function, ieee80211_tx_status_ni()
  4866. * and ieee80211_tx_status_irqsafe() may not be mixed for a single hardware.
  4867. *
  4868. * @hw: the hardware the frame was transmitted by
  4869. * @sta: the receiver station to which this packet is sent
  4870. * (NULL for multicast packets)
  4871. * @info: tx status information
  4872. */
  4873. static inline void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
  4874. struct ieee80211_sta *sta,
  4875. struct ieee80211_tx_info *info)
  4876. {
  4877. struct ieee80211_tx_status status = {
  4878. .sta = sta,
  4879. .info = info,
  4880. };
  4881. ieee80211_tx_status_ext(hw, &status);
  4882. }
  4883. /**
  4884. * ieee80211_tx_status_ni - transmit status callback (in process context)
  4885. *
  4886. * Like ieee80211_tx_status() but can be called in process context.
  4887. *
  4888. * Calls to this function, ieee80211_tx_status() and
  4889. * ieee80211_tx_status_irqsafe() may not be mixed
  4890. * for a single hardware.
  4891. *
  4892. * @hw: the hardware the frame was transmitted by
  4893. * @skb: the frame that was transmitted, owned by mac80211 after this call
  4894. */
  4895. static inline void ieee80211_tx_status_ni(struct ieee80211_hw *hw,
  4896. struct sk_buff *skb)
  4897. {
  4898. local_bh_disable();
  4899. ieee80211_tx_status(hw, skb);
  4900. local_bh_enable();
  4901. }
  4902. /**
  4903. * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback
  4904. *
  4905. * Like ieee80211_tx_status() but can be called in IRQ context
  4906. * (internally defers to a tasklet.)
  4907. *
  4908. * Calls to this function, ieee80211_tx_status() and
  4909. * ieee80211_tx_status_ni() may not be mixed for a single hardware.
  4910. *
  4911. * @hw: the hardware the frame was transmitted by
  4912. * @skb: the frame that was transmitted, owned by mac80211 after this call
  4913. */
  4914. void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
  4915. struct sk_buff *skb);
  4916. /**
  4917. * ieee80211_tx_status_8023 - transmit status callback for 802.3 frame format
  4918. *
  4919. * Call this function for all transmitted data frames after their transmit
  4920. * completion. This callback should only be called for data frames which
  4921. * are using driver's (or hardware's) offload capability of encap/decap
  4922. * 802.11 frames.
  4923. *
  4924. * This function may not be called in IRQ context. Calls to this function
  4925. * for a single hardware must be synchronized against each other and all
  4926. * calls in the same tx status family.
  4927. *
  4928. * @hw: the hardware the frame was transmitted by
  4929. * @vif: the interface for which the frame was transmitted
  4930. * @skb: the frame that was transmitted, owned by mac80211 after this call
  4931. */
  4932. void ieee80211_tx_status_8023(struct ieee80211_hw *hw,
  4933. struct ieee80211_vif *vif,
  4934. struct sk_buff *skb);
  4935. /**
  4936. * ieee80211_report_low_ack - report non-responding station
  4937. *
  4938. * When operating in AP-mode, call this function to report a non-responding
  4939. * connected STA.
  4940. *
  4941. * @sta: the non-responding connected sta
  4942. * @num_packets: number of packets sent to @sta without a response
  4943. */
  4944. void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);
  4945. #define IEEE80211_MAX_CNTDWN_COUNTERS_NUM 2
  4946. /**
  4947. * struct ieee80211_mutable_offsets - mutable beacon offsets
  4948. * @tim_offset: position of TIM element
  4949. * @tim_length: size of TIM element
  4950. * @cntdwn_counter_offs: array of IEEE80211_MAX_CNTDWN_COUNTERS_NUM offsets
  4951. * to countdown counters. This array can contain zero values which
  4952. * should be ignored.
  4953. * @mbssid_off: position of the multiple bssid element
  4954. */
  4955. struct ieee80211_mutable_offsets {
  4956. u16 tim_offset;
  4957. u16 tim_length;
  4958. u16 cntdwn_counter_offs[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
  4959. u16 mbssid_off;
  4960. };
  4961. /**
  4962. * ieee80211_beacon_get_template - beacon template generation function
  4963. * @hw: pointer obtained from ieee80211_alloc_hw().
  4964. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  4965. * @offs: &struct ieee80211_mutable_offsets pointer to struct that will
  4966. * receive the offsets that may be updated by the driver.
  4967. * @link_id: the link id to which the beacon belongs (or 0 for a non-MLD AP)
  4968. *
  4969. * If the driver implements beaconing modes, it must use this function to
  4970. * obtain the beacon template.
  4971. *
  4972. * This function should be used if the beacon frames are generated by the
  4973. * device, and then the driver must use the returned beacon as the template
  4974. * The driver or the device are responsible to update the DTIM and, when
  4975. * applicable, the CSA count.
  4976. *
  4977. * The driver is responsible for freeing the returned skb.
  4978. *
  4979. * Return: The beacon template. %NULL on error.
  4980. */
  4981. struct sk_buff *
  4982. ieee80211_beacon_get_template(struct ieee80211_hw *hw,
  4983. struct ieee80211_vif *vif,
  4984. struct ieee80211_mutable_offsets *offs,
  4985. unsigned int link_id);
  4986. /**
  4987. * ieee80211_beacon_get_tim - beacon generation function
  4988. * @hw: pointer obtained from ieee80211_alloc_hw().
  4989. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  4990. * @tim_offset: pointer to variable that will receive the TIM IE offset.
  4991. * Set to 0 if invalid (in non-AP modes).
  4992. * @tim_length: pointer to variable that will receive the TIM IE length,
  4993. * (including the ID and length bytes!).
  4994. * Set to 0 if invalid (in non-AP modes).
  4995. * @link_id: the link id to which the beacon belongs (or 0 for a non-MLD AP)
  4996. *
  4997. * If the driver implements beaconing modes, it must use this function to
  4998. * obtain the beacon frame.
  4999. *
  5000. * If the beacon frames are generated by the host system (i.e., not in
  5001. * hardware/firmware), the driver uses this function to get each beacon
  5002. * frame from mac80211 -- it is responsible for calling this function exactly
  5003. * once before the beacon is needed (e.g. based on hardware interrupt).
  5004. *
  5005. * The driver is responsible for freeing the returned skb.
  5006. *
  5007. * Return: The beacon template. %NULL on error.
  5008. */
  5009. struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
  5010. struct ieee80211_vif *vif,
  5011. u16 *tim_offset, u16 *tim_length,
  5012. unsigned int link_id);
  5013. /**
  5014. * ieee80211_beacon_get - beacon generation function
  5015. * @hw: pointer obtained from ieee80211_alloc_hw().
  5016. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5017. * @link_id: the link id to which the beacon belongs (or 0 for a non-MLD AP)
  5018. *
  5019. * See ieee80211_beacon_get_tim().
  5020. *
  5021. * Return: See ieee80211_beacon_get_tim().
  5022. */
  5023. static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
  5024. struct ieee80211_vif *vif,
  5025. unsigned int link_id)
  5026. {
  5027. return ieee80211_beacon_get_tim(hw, vif, NULL, NULL, link_id);
  5028. }
  5029. /**
  5030. * ieee80211_beacon_update_cntdwn - request mac80211 to decrement the beacon countdown
  5031. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5032. *
  5033. * The beacon counter should be updated after each beacon transmission.
  5034. * This function is called implicitly when
  5035. * ieee80211_beacon_get/ieee80211_beacon_get_tim are called, however if the
  5036. * beacon frames are generated by the device, the driver should call this
  5037. * function after each beacon transmission to sync mac80211's beacon countdown.
  5038. *
  5039. * Return: new countdown value
  5040. */
  5041. u8 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif);
  5042. /**
  5043. * ieee80211_beacon_set_cntdwn - request mac80211 to set beacon countdown
  5044. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5045. * @counter: the new value for the counter
  5046. *
  5047. * The beacon countdown can be changed by the device, this API should be
  5048. * used by the device driver to update csa counter in mac80211.
  5049. *
  5050. * It should never be used together with ieee80211_beacon_update_cntdwn(),
  5051. * as it will cause a race condition around the counter value.
  5052. */
  5053. void ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter);
  5054. /**
  5055. * ieee80211_csa_finish - notify mac80211 about channel switch
  5056. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5057. *
  5058. * After a channel switch announcement was scheduled and the counter in this
  5059. * announcement hits 1, this function must be called by the driver to
  5060. * notify mac80211 that the channel can be changed.
  5061. */
  5062. void ieee80211_csa_finish(struct ieee80211_vif *vif);
  5063. /**
  5064. * ieee80211_beacon_cntdwn_is_complete - find out if countdown reached 1
  5065. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5066. *
  5067. * This function returns whether the countdown reached zero.
  5068. */
  5069. bool ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif);
  5070. /**
  5071. * ieee80211_color_change_finish - notify mac80211 about color change
  5072. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5073. *
  5074. * After a color change announcement was scheduled and the counter in this
  5075. * announcement hits 1, this function must be called by the driver to
  5076. * notify mac80211 that the color can be changed
  5077. */
  5078. void ieee80211_color_change_finish(struct ieee80211_vif *vif);
  5079. /**
  5080. * ieee80211_proberesp_get - retrieve a Probe Response template
  5081. * @hw: pointer obtained from ieee80211_alloc_hw().
  5082. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5083. *
  5084. * Creates a Probe Response template which can, for example, be uploaded to
  5085. * hardware. The destination address should be set by the caller.
  5086. *
  5087. * Can only be called in AP mode.
  5088. *
  5089. * Return: The Probe Response template. %NULL on error.
  5090. */
  5091. struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw,
  5092. struct ieee80211_vif *vif);
  5093. /**
  5094. * ieee80211_pspoll_get - retrieve a PS Poll template
  5095. * @hw: pointer obtained from ieee80211_alloc_hw().
  5096. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5097. *
  5098. * Creates a PS Poll a template which can, for example, uploaded to
  5099. * hardware. The template must be updated after association so that correct
  5100. * AID, BSSID and MAC address is used.
  5101. *
  5102. * Note: Caller (or hardware) is responsible for setting the
  5103. * &IEEE80211_FCTL_PM bit.
  5104. *
  5105. * Return: The PS Poll template. %NULL on error.
  5106. */
  5107. struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
  5108. struct ieee80211_vif *vif);
  5109. /**
  5110. * ieee80211_nullfunc_get - retrieve a nullfunc template
  5111. * @hw: pointer obtained from ieee80211_alloc_hw().
  5112. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5113. * @link_id: If the vif is an MLD, get a frame with the link addresses
  5114. * for the given link ID. For a link_id < 0 you get a frame with
  5115. * MLD addresses, however useful that might be.
  5116. * @qos_ok: QoS NDP is acceptable to the caller, this should be set
  5117. * if at all possible
  5118. *
  5119. * Creates a Nullfunc template which can, for example, uploaded to
  5120. * hardware. The template must be updated after association so that correct
  5121. * BSSID and address is used.
  5122. *
  5123. * If @qos_ndp is set and the association is to an AP with QoS/WMM, the
  5124. * returned packet will be QoS NDP.
  5125. *
  5126. * Note: Caller (or hardware) is responsible for setting the
  5127. * &IEEE80211_FCTL_PM bit as well as Duration and Sequence Control fields.
  5128. *
  5129. * Return: The nullfunc template. %NULL on error.
  5130. */
  5131. struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
  5132. struct ieee80211_vif *vif,
  5133. int link_id, bool qos_ok);
  5134. /**
  5135. * ieee80211_probereq_get - retrieve a Probe Request template
  5136. * @hw: pointer obtained from ieee80211_alloc_hw().
  5137. * @src_addr: source MAC address
  5138. * @ssid: SSID buffer
  5139. * @ssid_len: length of SSID
  5140. * @tailroom: tailroom to reserve at end of SKB for IEs
  5141. *
  5142. * Creates a Probe Request template which can, for example, be uploaded to
  5143. * hardware.
  5144. *
  5145. * Return: The Probe Request template. %NULL on error.
  5146. */
  5147. struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
  5148. const u8 *src_addr,
  5149. const u8 *ssid, size_t ssid_len,
  5150. size_t tailroom);
  5151. /**
  5152. * ieee80211_rts_get - RTS frame generation function
  5153. * @hw: pointer obtained from ieee80211_alloc_hw().
  5154. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5155. * @frame: pointer to the frame that is going to be protected by the RTS.
  5156. * @frame_len: the frame length (in octets).
  5157. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  5158. * @rts: The buffer where to store the RTS frame.
  5159. *
  5160. * If the RTS frames are generated by the host system (i.e., not in
  5161. * hardware/firmware), the low-level driver uses this function to receive
  5162. * the next RTS frame from the 802.11 code. The low-level is responsible
  5163. * for calling this function before and RTS frame is needed.
  5164. */
  5165. void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  5166. const void *frame, size_t frame_len,
  5167. const struct ieee80211_tx_info *frame_txctl,
  5168. struct ieee80211_rts *rts);
  5169. /**
  5170. * ieee80211_rts_duration - Get the duration field for an RTS frame
  5171. * @hw: pointer obtained from ieee80211_alloc_hw().
  5172. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5173. * @frame_len: the length of the frame that is going to be protected by the RTS.
  5174. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  5175. *
  5176. * If the RTS is generated in firmware, but the host system must provide
  5177. * the duration field, the low-level driver uses this function to receive
  5178. * the duration field value in little-endian byteorder.
  5179. *
  5180. * Return: The duration.
  5181. */
  5182. __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
  5183. struct ieee80211_vif *vif, size_t frame_len,
  5184. const struct ieee80211_tx_info *frame_txctl);
  5185. /**
  5186. * ieee80211_ctstoself_get - CTS-to-self frame generation function
  5187. * @hw: pointer obtained from ieee80211_alloc_hw().
  5188. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5189. * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
  5190. * @frame_len: the frame length (in octets).
  5191. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  5192. * @cts: The buffer where to store the CTS-to-self frame.
  5193. *
  5194. * If the CTS-to-self frames are generated by the host system (i.e., not in
  5195. * hardware/firmware), the low-level driver uses this function to receive
  5196. * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
  5197. * for calling this function before and CTS-to-self frame is needed.
  5198. */
  5199. void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
  5200. struct ieee80211_vif *vif,
  5201. const void *frame, size_t frame_len,
  5202. const struct ieee80211_tx_info *frame_txctl,
  5203. struct ieee80211_cts *cts);
  5204. /**
  5205. * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
  5206. * @hw: pointer obtained from ieee80211_alloc_hw().
  5207. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5208. * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
  5209. * @frame_txctl: &struct ieee80211_tx_info of the frame.
  5210. *
  5211. * If the CTS-to-self is generated in firmware, but the host system must provide
  5212. * the duration field, the low-level driver uses this function to receive
  5213. * the duration field value in little-endian byteorder.
  5214. *
  5215. * Return: The duration.
  5216. */
  5217. __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
  5218. struct ieee80211_vif *vif,
  5219. size_t frame_len,
  5220. const struct ieee80211_tx_info *frame_txctl);
  5221. /**
  5222. * ieee80211_generic_frame_duration - Calculate the duration field for a frame
  5223. * @hw: pointer obtained from ieee80211_alloc_hw().
  5224. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5225. * @band: the band to calculate the frame duration on
  5226. * @frame_len: the length of the frame.
  5227. * @rate: the rate at which the frame is going to be transmitted.
  5228. *
  5229. * Calculate the duration field of some generic frame, given its
  5230. * length and transmission rate (in 100kbps).
  5231. *
  5232. * Return: The duration.
  5233. */
  5234. __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
  5235. struct ieee80211_vif *vif,
  5236. enum nl80211_band band,
  5237. size_t frame_len,
  5238. struct ieee80211_rate *rate);
  5239. /**
  5240. * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
  5241. * @hw: pointer as obtained from ieee80211_alloc_hw().
  5242. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5243. *
  5244. * Function for accessing buffered broadcast and multicast frames. If
  5245. * hardware/firmware does not implement buffering of broadcast/multicast
  5246. * frames when power saving is used, 802.11 code buffers them in the host
  5247. * memory. The low-level driver uses this function to fetch next buffered
  5248. * frame. In most cases, this is used when generating beacon frame.
  5249. *
  5250. * Return: A pointer to the next buffered skb or NULL if no more buffered
  5251. * frames are available.
  5252. *
  5253. * Note: buffered frames are returned only after DTIM beacon frame was
  5254. * generated with ieee80211_beacon_get() and the low-level driver must thus
  5255. * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
  5256. * NULL if the previous generated beacon was not DTIM, so the low-level driver
  5257. * does not need to check for DTIM beacons separately and should be able to
  5258. * use common code for all beacons.
  5259. */
  5260. struct sk_buff *
  5261. ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
  5262. /**
  5263. * ieee80211_get_tkip_p1k_iv - get a TKIP phase 1 key for IV32
  5264. *
  5265. * This function returns the TKIP phase 1 key for the given IV32.
  5266. *
  5267. * @keyconf: the parameter passed with the set key
  5268. * @iv32: IV32 to get the P1K for
  5269. * @p1k: a buffer to which the key will be written, as 5 u16 values
  5270. */
  5271. void ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *keyconf,
  5272. u32 iv32, u16 *p1k);
  5273. /**
  5274. * ieee80211_get_tkip_p1k - get a TKIP phase 1 key
  5275. *
  5276. * This function returns the TKIP phase 1 key for the IV32 taken
  5277. * from the given packet.
  5278. *
  5279. * @keyconf: the parameter passed with the set key
  5280. * @skb: the packet to take the IV32 value from that will be encrypted
  5281. * with this P1K
  5282. * @p1k: a buffer to which the key will be written, as 5 u16 values
  5283. */
  5284. static inline void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
  5285. struct sk_buff *skb, u16 *p1k)
  5286. {
  5287. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  5288. const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
  5289. u32 iv32 = get_unaligned_le32(&data[4]);
  5290. ieee80211_get_tkip_p1k_iv(keyconf, iv32, p1k);
  5291. }
  5292. /**
  5293. * ieee80211_get_tkip_rx_p1k - get a TKIP phase 1 key for RX
  5294. *
  5295. * This function returns the TKIP phase 1 key for the given IV32
  5296. * and transmitter address.
  5297. *
  5298. * @keyconf: the parameter passed with the set key
  5299. * @ta: TA that will be used with the key
  5300. * @iv32: IV32 to get the P1K for
  5301. * @p1k: a buffer to which the key will be written, as 5 u16 values
  5302. */
  5303. void ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
  5304. const u8 *ta, u32 iv32, u16 *p1k);
  5305. /**
  5306. * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
  5307. *
  5308. * This function computes the TKIP RC4 key for the IV values
  5309. * in the packet.
  5310. *
  5311. * @keyconf: the parameter passed with the set key
  5312. * @skb: the packet to take the IV32/IV16 values from that will be
  5313. * encrypted with this key
  5314. * @p2k: a buffer to which the key will be written, 16 bytes
  5315. */
  5316. void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
  5317. struct sk_buff *skb, u8 *p2k);
  5318. /**
  5319. * ieee80211_tkip_add_iv - write TKIP IV and Ext. IV to pos
  5320. *
  5321. * @pos: start of crypto header
  5322. * @keyconf: the parameter passed with the set key
  5323. * @pn: PN to add
  5324. *
  5325. * Returns: pointer to the octet following IVs (i.e. beginning of
  5326. * the packet payload)
  5327. *
  5328. * This function writes the tkip IV value to pos (which should
  5329. * point to the crypto header)
  5330. */
  5331. u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key_conf *keyconf, u64 pn);
  5332. /**
  5333. * ieee80211_get_key_rx_seq - get key RX sequence counter
  5334. *
  5335. * @keyconf: the parameter passed with the set key
  5336. * @tid: The TID, or -1 for the management frame value (CCMP/GCMP only);
  5337. * the value on TID 0 is also used for non-QoS frames. For
  5338. * CMAC, only TID 0 is valid.
  5339. * @seq: buffer to receive the sequence data
  5340. *
  5341. * This function allows a driver to retrieve the current RX IV/PNs
  5342. * for the given key. It must not be called if IV checking is done
  5343. * by the device and not by mac80211.
  5344. *
  5345. * Note that this function may only be called when no RX processing
  5346. * can be done concurrently.
  5347. */
  5348. void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
  5349. int tid, struct ieee80211_key_seq *seq);
  5350. /**
  5351. * ieee80211_set_key_rx_seq - set key RX sequence counter
  5352. *
  5353. * @keyconf: the parameter passed with the set key
  5354. * @tid: The TID, or -1 for the management frame value (CCMP/GCMP only);
  5355. * the value on TID 0 is also used for non-QoS frames. For
  5356. * CMAC, only TID 0 is valid.
  5357. * @seq: new sequence data
  5358. *
  5359. * This function allows a driver to set the current RX IV/PNs for the
  5360. * given key. This is useful when resuming from WoWLAN sleep and GTK
  5361. * rekey may have been done while suspended. It should not be called
  5362. * if IV checking is done by the device and not by mac80211.
  5363. *
  5364. * Note that this function may only be called when no RX processing
  5365. * can be done concurrently.
  5366. */
  5367. void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf,
  5368. int tid, struct ieee80211_key_seq *seq);
  5369. /**
  5370. * ieee80211_remove_key - remove the given key
  5371. * @keyconf: the parameter passed with the set key
  5372. *
  5373. * Remove the given key. If the key was uploaded to the hardware at the
  5374. * time this function is called, it is not deleted in the hardware but
  5375. * instead assumed to have been removed already.
  5376. *
  5377. * Note that due to locking considerations this function can (currently)
  5378. * only be called during key iteration (ieee80211_iter_keys().)
  5379. */
  5380. void ieee80211_remove_key(struct ieee80211_key_conf *keyconf);
  5381. /**
  5382. * ieee80211_gtk_rekey_add - add a GTK key from rekeying during WoWLAN
  5383. * @vif: the virtual interface to add the key on
  5384. * @keyconf: new key data
  5385. *
  5386. * When GTK rekeying was done while the system was suspended, (a) new
  5387. * key(s) will be available. These will be needed by mac80211 for proper
  5388. * RX processing, so this function allows setting them.
  5389. *
  5390. * The function returns the newly allocated key structure, which will
  5391. * have similar contents to the passed key configuration but point to
  5392. * mac80211-owned memory. In case of errors, the function returns an
  5393. * ERR_PTR(), use IS_ERR() etc.
  5394. *
  5395. * Note that this function assumes the key isn't added to hardware
  5396. * acceleration, so no TX will be done with the key. Since it's a GTK
  5397. * on managed (station) networks, this is true anyway. If the driver
  5398. * calls this function from the resume callback and subsequently uses
  5399. * the return code 1 to reconfigure the device, this key will be part
  5400. * of the reconfiguration.
  5401. *
  5402. * Note that the driver should also call ieee80211_set_key_rx_seq()
  5403. * for the new key for each TID to set up sequence counters properly.
  5404. *
  5405. * IMPORTANT: If this replaces a key that is present in the hardware,
  5406. * then it will attempt to remove it during this call. In many cases
  5407. * this isn't what you want, so call ieee80211_remove_key() first for
  5408. * the key that's being replaced.
  5409. */
  5410. struct ieee80211_key_conf *
  5411. ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
  5412. struct ieee80211_key_conf *keyconf);
  5413. /**
  5414. * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying
  5415. * @vif: virtual interface the rekeying was done on
  5416. * @bssid: The BSSID of the AP, for checking association
  5417. * @replay_ctr: the new replay counter after GTK rekeying
  5418. * @gfp: allocation flags
  5419. */
  5420. void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid,
  5421. const u8 *replay_ctr, gfp_t gfp);
  5422. /**
  5423. * ieee80211_key_mic_failure - increment MIC failure counter for the key
  5424. *
  5425. * Note: this is really only safe if no other RX function is called
  5426. * at the same time.
  5427. *
  5428. * @keyconf: the key in question
  5429. */
  5430. void ieee80211_key_mic_failure(struct ieee80211_key_conf *keyconf);
  5431. /**
  5432. * ieee80211_key_replay - increment replay counter for the key
  5433. *
  5434. * Note: this is really only safe if no other RX function is called
  5435. * at the same time.
  5436. *
  5437. * @keyconf: the key in question
  5438. */
  5439. void ieee80211_key_replay(struct ieee80211_key_conf *keyconf);
  5440. /**
  5441. * ieee80211_wake_queue - wake specific queue
  5442. * @hw: pointer as obtained from ieee80211_alloc_hw().
  5443. * @queue: queue number (counted from zero).
  5444. *
  5445. * Drivers should use this function instead of netif_wake_queue.
  5446. */
  5447. void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
  5448. /**
  5449. * ieee80211_stop_queue - stop specific queue
  5450. * @hw: pointer as obtained from ieee80211_alloc_hw().
  5451. * @queue: queue number (counted from zero).
  5452. *
  5453. * Drivers should use this function instead of netif_stop_queue.
  5454. */
  5455. void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
  5456. /**
  5457. * ieee80211_queue_stopped - test status of the queue
  5458. * @hw: pointer as obtained from ieee80211_alloc_hw().
  5459. * @queue: queue number (counted from zero).
  5460. *
  5461. * Drivers should use this function instead of netif_stop_queue.
  5462. *
  5463. * Return: %true if the queue is stopped. %false otherwise.
  5464. */
  5465. int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue);
  5466. /**
  5467. * ieee80211_stop_queues - stop all queues
  5468. * @hw: pointer as obtained from ieee80211_alloc_hw().
  5469. *
  5470. * Drivers should use this function instead of netif_stop_queue.
  5471. */
  5472. void ieee80211_stop_queues(struct ieee80211_hw *hw);
  5473. /**
  5474. * ieee80211_wake_queues - wake all queues
  5475. * @hw: pointer as obtained from ieee80211_alloc_hw().
  5476. *
  5477. * Drivers should use this function instead of netif_wake_queue.
  5478. */
  5479. void ieee80211_wake_queues(struct ieee80211_hw *hw);
  5480. /**
  5481. * ieee80211_scan_completed - completed hardware scan
  5482. *
  5483. * When hardware scan offload is used (i.e. the hw_scan() callback is
  5484. * assigned) this function needs to be called by the driver to notify
  5485. * mac80211 that the scan finished. This function can be called from
  5486. * any context, including hardirq context.
  5487. *
  5488. * @hw: the hardware that finished the scan
  5489. * @info: information about the completed scan
  5490. */
  5491. void ieee80211_scan_completed(struct ieee80211_hw *hw,
  5492. struct cfg80211_scan_info *info);
  5493. /**
  5494. * ieee80211_sched_scan_results - got results from scheduled scan
  5495. *
  5496. * When a scheduled scan is running, this function needs to be called by the
  5497. * driver whenever there are new scan results available.
  5498. *
  5499. * @hw: the hardware that is performing scheduled scans
  5500. */
  5501. void ieee80211_sched_scan_results(struct ieee80211_hw *hw);
  5502. /**
  5503. * ieee80211_sched_scan_stopped - inform that the scheduled scan has stopped
  5504. *
  5505. * When a scheduled scan is running, this function can be called by
  5506. * the driver if it needs to stop the scan to perform another task.
  5507. * Usual scenarios are drivers that cannot continue the scheduled scan
  5508. * while associating, for instance.
  5509. *
  5510. * @hw: the hardware that is performing scheduled scans
  5511. */
  5512. void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw);
  5513. /**
  5514. * enum ieee80211_interface_iteration_flags - interface iteration flags
  5515. * @IEEE80211_IFACE_ITER_NORMAL: Iterate over all interfaces that have
  5516. * been added to the driver; However, note that during hardware
  5517. * reconfiguration (after restart_hw) it will iterate over a new
  5518. * interface and over all the existing interfaces even if they
  5519. * haven't been re-added to the driver yet.
  5520. * @IEEE80211_IFACE_ITER_RESUME_ALL: During resume, iterate over all
  5521. * interfaces, even if they haven't been re-added to the driver yet.
  5522. * @IEEE80211_IFACE_ITER_ACTIVE: Iterate only active interfaces (netdev is up).
  5523. * @IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER: Skip any interfaces where SDATA
  5524. * is not in the driver. This may fix crashes during firmware recovery
  5525. * for instance.
  5526. */
  5527. enum ieee80211_interface_iteration_flags {
  5528. IEEE80211_IFACE_ITER_NORMAL = 0,
  5529. IEEE80211_IFACE_ITER_RESUME_ALL = BIT(0),
  5530. IEEE80211_IFACE_ITER_ACTIVE = BIT(1),
  5531. IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER = BIT(2),
  5532. };
  5533. /**
  5534. * ieee80211_iterate_interfaces - iterate interfaces
  5535. *
  5536. * This function iterates over the interfaces associated with a given
  5537. * hardware and calls the callback for them. This includes active as well as
  5538. * inactive interfaces. This function allows the iterator function to sleep.
  5539. * Will iterate over a new interface during add_interface().
  5540. *
  5541. * @hw: the hardware struct of which the interfaces should be iterated over
  5542. * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
  5543. * @iterator: the iterator function to call
  5544. * @data: first argument of the iterator function
  5545. */
  5546. void ieee80211_iterate_interfaces(struct ieee80211_hw *hw, u32 iter_flags,
  5547. void (*iterator)(void *data, u8 *mac,
  5548. struct ieee80211_vif *vif),
  5549. void *data);
  5550. /**
  5551. * ieee80211_iterate_active_interfaces - iterate active interfaces
  5552. *
  5553. * This function iterates over the interfaces associated with a given
  5554. * hardware that are currently active and calls the callback for them.
  5555. * This function allows the iterator function to sleep, when the iterator
  5556. * function is atomic @ieee80211_iterate_active_interfaces_atomic can
  5557. * be used.
  5558. * Does not iterate over a new interface during add_interface().
  5559. *
  5560. * @hw: the hardware struct of which the interfaces should be iterated over
  5561. * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
  5562. * @iterator: the iterator function to call
  5563. * @data: first argument of the iterator function
  5564. */
  5565. static inline void
  5566. ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, u32 iter_flags,
  5567. void (*iterator)(void *data, u8 *mac,
  5568. struct ieee80211_vif *vif),
  5569. void *data)
  5570. {
  5571. ieee80211_iterate_interfaces(hw,
  5572. iter_flags | IEEE80211_IFACE_ITER_ACTIVE,
  5573. iterator, data);
  5574. }
  5575. /**
  5576. * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces
  5577. *
  5578. * This function iterates over the interfaces associated with a given
  5579. * hardware that are currently active and calls the callback for them.
  5580. * This function requires the iterator callback function to be atomic,
  5581. * if that is not desired, use @ieee80211_iterate_active_interfaces instead.
  5582. * Does not iterate over a new interface during add_interface().
  5583. *
  5584. * @hw: the hardware struct of which the interfaces should be iterated over
  5585. * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
  5586. * @iterator: the iterator function to call, cannot sleep
  5587. * @data: first argument of the iterator function
  5588. */
  5589. void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
  5590. u32 iter_flags,
  5591. void (*iterator)(void *data,
  5592. u8 *mac,
  5593. struct ieee80211_vif *vif),
  5594. void *data);
  5595. /**
  5596. * ieee80211_iterate_active_interfaces_mtx - iterate active interfaces
  5597. *
  5598. * This function iterates over the interfaces associated with a given
  5599. * hardware that are currently active and calls the callback for them.
  5600. * This version can only be used while holding the wiphy mutex.
  5601. * The driver must not call this with a lock held that it can also take in
  5602. * response to callbacks from mac80211, and it must not call this within
  5603. * callbacks made by mac80211 - both would result in deadlocks.
  5604. *
  5605. * @hw: the hardware struct of which the interfaces should be iterated over
  5606. * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
  5607. * @iterator: the iterator function to call, cannot sleep
  5608. * @data: first argument of the iterator function
  5609. */
  5610. void ieee80211_iterate_active_interfaces_mtx(struct ieee80211_hw *hw,
  5611. u32 iter_flags,
  5612. void (*iterator)(void *data,
  5613. u8 *mac,
  5614. struct ieee80211_vif *vif),
  5615. void *data);
  5616. /**
  5617. * ieee80211_iterate_stations - iterate stations
  5618. *
  5619. * This function iterates over all stations associated with a given
  5620. * hardware that are currently uploaded to the driver and calls the callback
  5621. * function for them.
  5622. * This function allows the iterator function to sleep, when the iterator
  5623. * function is atomic @ieee80211_iterate_stations_atomic can be used.
  5624. *
  5625. * @hw: the hardware struct of which the interfaces should be iterated over
  5626. * @iterator: the iterator function to call, cannot sleep
  5627. * @data: first argument of the iterator function
  5628. */
  5629. void ieee80211_iterate_stations(struct ieee80211_hw *hw,
  5630. void (*iterator)(void *data,
  5631. struct ieee80211_sta *sta),
  5632. void *data);
  5633. /**
  5634. * ieee80211_iterate_stations_atomic - iterate stations
  5635. *
  5636. * This function iterates over all stations associated with a given
  5637. * hardware that are currently uploaded to the driver and calls the callback
  5638. * function for them.
  5639. * This function requires the iterator callback function to be atomic,
  5640. *
  5641. * @hw: the hardware struct of which the interfaces should be iterated over
  5642. * @iterator: the iterator function to call, cannot sleep
  5643. * @data: first argument of the iterator function
  5644. */
  5645. void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
  5646. void (*iterator)(void *data,
  5647. struct ieee80211_sta *sta),
  5648. void *data);
  5649. /**
  5650. * ieee80211_queue_work - add work onto the mac80211 workqueue
  5651. *
  5652. * Drivers and mac80211 use this to add work onto the mac80211 workqueue.
  5653. * This helper ensures drivers are not queueing work when they should not be.
  5654. *
  5655. * @hw: the hardware struct for the interface we are adding work for
  5656. * @work: the work we want to add onto the mac80211 workqueue
  5657. */
  5658. void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work);
  5659. /**
  5660. * ieee80211_queue_delayed_work - add work onto the mac80211 workqueue
  5661. *
  5662. * Drivers and mac80211 use this to queue delayed work onto the mac80211
  5663. * workqueue.
  5664. *
  5665. * @hw: the hardware struct for the interface we are adding work for
  5666. * @dwork: delayable work to queue onto the mac80211 workqueue
  5667. * @delay: number of jiffies to wait before queueing
  5668. */
  5669. void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
  5670. struct delayed_work *dwork,
  5671. unsigned long delay);
  5672. /**
  5673. * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
  5674. * @sta: the station for which to start a BA session
  5675. * @tid: the TID to BA on.
  5676. * @timeout: session timeout value (in TUs)
  5677. *
  5678. * Return: success if addBA request was sent, failure otherwise
  5679. *
  5680. * Although mac80211/low level driver/user space application can estimate
  5681. * the need to start aggregation on a certain RA/TID, the session level
  5682. * will be managed by the mac80211.
  5683. */
  5684. int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid,
  5685. u16 timeout);
  5686. /**
  5687. * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
  5688. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  5689. * @ra: receiver address of the BA session recipient.
  5690. * @tid: the TID to BA on.
  5691. *
  5692. * This function must be called by low level driver once it has
  5693. * finished with preparations for the BA session. It can be called
  5694. * from any context.
  5695. */
  5696. void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
  5697. u16 tid);
  5698. /**
  5699. * ieee80211_stop_tx_ba_session - Stop a Block Ack session.
  5700. * @sta: the station whose BA session to stop
  5701. * @tid: the TID to stop BA.
  5702. *
  5703. * Return: negative error if the TID is invalid, or no aggregation active
  5704. *
  5705. * Although mac80211/low level driver/user space application can estimate
  5706. * the need to stop aggregation on a certain RA/TID, the session level
  5707. * will be managed by the mac80211.
  5708. */
  5709. int ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, u16 tid);
  5710. /**
  5711. * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate.
  5712. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  5713. * @ra: receiver address of the BA session recipient.
  5714. * @tid: the desired TID to BA on.
  5715. *
  5716. * This function must be called by low level driver once it has
  5717. * finished with preparations for the BA session tear down. It
  5718. * can be called from any context.
  5719. */
  5720. void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
  5721. u16 tid);
  5722. /**
  5723. * ieee80211_find_sta - find a station
  5724. *
  5725. * @vif: virtual interface to look for station on
  5726. * @addr: station's address
  5727. *
  5728. * Return: The station, if found. %NULL otherwise.
  5729. *
  5730. * Note: This function must be called under RCU lock and the
  5731. * resulting pointer is only valid under RCU lock as well.
  5732. */
  5733. struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif,
  5734. const u8 *addr);
  5735. /**
  5736. * ieee80211_find_sta_by_ifaddr - find a station on hardware
  5737. *
  5738. * @hw: pointer as obtained from ieee80211_alloc_hw()
  5739. * @addr: remote station's address
  5740. * @localaddr: local address (vif->sdata->vif.addr). Use NULL for 'any'.
  5741. *
  5742. * Return: The station, if found. %NULL otherwise.
  5743. *
  5744. * Note: This function must be called under RCU lock and the
  5745. * resulting pointer is only valid under RCU lock as well.
  5746. *
  5747. * NOTE: You may pass NULL for localaddr, but then you will just get
  5748. * the first STA that matches the remote address 'addr'.
  5749. * We can have multiple STA associated with multiple
  5750. * logical stations (e.g. consider a station connecting to another
  5751. * BSSID on the same AP hardware without disconnecting first).
  5752. * In this case, the result of this method with localaddr NULL
  5753. * is not reliable.
  5754. *
  5755. * DO NOT USE THIS FUNCTION with localaddr NULL if at all possible.
  5756. */
  5757. struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw,
  5758. const u8 *addr,
  5759. const u8 *localaddr);
  5760. /**
  5761. * ieee80211_find_sta_by_link_addrs - find STA by link addresses
  5762. * @hw: pointer as obtained from ieee80211_alloc_hw()
  5763. * @addr: remote station's link address
  5764. * @localaddr: local link address, use %NULL for any (but avoid that)
  5765. * @link_id: pointer to obtain the link ID if the STA is found,
  5766. * may be %NULL if the link ID is not needed
  5767. *
  5768. * Obtain the STA by link address, must use RCU protection.
  5769. */
  5770. struct ieee80211_sta *
  5771. ieee80211_find_sta_by_link_addrs(struct ieee80211_hw *hw,
  5772. const u8 *addr,
  5773. const u8 *localaddr,
  5774. unsigned int *link_id);
  5775. /**
  5776. * ieee80211_sta_block_awake - block station from waking up
  5777. * @hw: the hardware
  5778. * @pubsta: the station
  5779. * @block: whether to block or unblock
  5780. *
  5781. * Some devices require that all frames that are on the queues
  5782. * for a specific station that went to sleep are flushed before
  5783. * a poll response or frames after the station woke up can be
  5784. * delivered to that it. Note that such frames must be rejected
  5785. * by the driver as filtered, with the appropriate status flag.
  5786. *
  5787. * This function allows implementing this mode in a race-free
  5788. * manner.
  5789. *
  5790. * To do this, a driver must keep track of the number of frames
  5791. * still enqueued for a specific station. If this number is not
  5792. * zero when the station goes to sleep, the driver must call
  5793. * this function to force mac80211 to consider the station to
  5794. * be asleep regardless of the station's actual state. Once the
  5795. * number of outstanding frames reaches zero, the driver must
  5796. * call this function again to unblock the station. That will
  5797. * cause mac80211 to be able to send ps-poll responses, and if
  5798. * the station queried in the meantime then frames will also
  5799. * be sent out as a result of this. Additionally, the driver
  5800. * will be notified that the station woke up some time after
  5801. * it is unblocked, regardless of whether the station actually
  5802. * woke up while blocked or not.
  5803. */
  5804. void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
  5805. struct ieee80211_sta *pubsta, bool block);
  5806. /**
  5807. * ieee80211_sta_eosp - notify mac80211 about end of SP
  5808. * @pubsta: the station
  5809. *
  5810. * When a device transmits frames in a way that it can't tell
  5811. * mac80211 in the TX status about the EOSP, it must clear the
  5812. * %IEEE80211_TX_STATUS_EOSP bit and call this function instead.
  5813. * This applies for PS-Poll as well as uAPSD.
  5814. *
  5815. * Note that just like with _tx_status() and _rx() drivers must
  5816. * not mix calls to irqsafe/non-irqsafe versions, this function
  5817. * must not be mixed with those either. Use the all irqsafe, or
  5818. * all non-irqsafe, don't mix!
  5819. *
  5820. * NB: the _irqsafe version of this function doesn't exist, no
  5821. * driver needs it right now. Don't call this function if
  5822. * you'd need the _irqsafe version, look at the git history
  5823. * and restore the _irqsafe version!
  5824. */
  5825. void ieee80211_sta_eosp(struct ieee80211_sta *pubsta);
  5826. /**
  5827. * ieee80211_send_eosp_nullfunc - ask mac80211 to send NDP with EOSP
  5828. * @pubsta: the station
  5829. * @tid: the tid of the NDP
  5830. *
  5831. * Sometimes the device understands that it needs to close
  5832. * the Service Period unexpectedly. This can happen when
  5833. * sending frames that are filling holes in the BA window.
  5834. * In this case, the device can ask mac80211 to send a
  5835. * Nullfunc frame with EOSP set. When that happens, the
  5836. * driver must have called ieee80211_sta_set_buffered() to
  5837. * let mac80211 know that there are no buffered frames any
  5838. * more, otherwise mac80211 will get the more_data bit wrong.
  5839. * The low level driver must have made sure that the frame
  5840. * will be sent despite the station being in power-save.
  5841. * Mac80211 won't call allow_buffered_frames().
  5842. * Note that calling this function, doesn't exempt the driver
  5843. * from closing the EOSP properly, it will still have to call
  5844. * ieee80211_sta_eosp when the NDP is sent.
  5845. */
  5846. void ieee80211_send_eosp_nullfunc(struct ieee80211_sta *pubsta, int tid);
  5847. /**
  5848. * ieee80211_sta_recalc_aggregates - recalculate aggregate data after a change
  5849. * @pubsta: the station
  5850. *
  5851. * Call this function after changing a per-link aggregate data as referenced in
  5852. * &struct ieee80211_sta_aggregates by accessing the agg field of
  5853. * &struct ieee80211_link_sta.
  5854. *
  5855. * With non MLO the data in deflink will be referenced directly. In that case
  5856. * there is no need to call this function.
  5857. */
  5858. void ieee80211_sta_recalc_aggregates(struct ieee80211_sta *pubsta);
  5859. /**
  5860. * ieee80211_sta_register_airtime - register airtime usage for a sta/tid
  5861. *
  5862. * Register airtime usage for a given sta on a given tid. The driver must call
  5863. * this function to notify mac80211 that a station used a certain amount of
  5864. * airtime. This information will be used by the TXQ scheduler to schedule
  5865. * stations in a way that ensures airtime fairness.
  5866. *
  5867. * The reported airtime should as a minimum include all time that is spent
  5868. * transmitting to the remote station, including overhead and padding, but not
  5869. * including time spent waiting for a TXOP. If the time is not reported by the
  5870. * hardware it can in some cases be calculated from the rate and known frame
  5871. * composition. When possible, the time should include any failed transmission
  5872. * attempts.
  5873. *
  5874. * The driver can either call this function synchronously for every packet or
  5875. * aggregate, or asynchronously as airtime usage information becomes available.
  5876. * TX and RX airtime can be reported together, or separately by setting one of
  5877. * them to 0.
  5878. *
  5879. * @pubsta: the station
  5880. * @tid: the TID to register airtime for
  5881. * @tx_airtime: airtime used during TX (in usec)
  5882. * @rx_airtime: airtime used during RX (in usec)
  5883. */
  5884. void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid,
  5885. u32 tx_airtime, u32 rx_airtime);
  5886. /**
  5887. * ieee80211_txq_airtime_check - check if a txq can send frame to device
  5888. *
  5889. * @hw: pointer obtained from ieee80211_alloc_hw()
  5890. * @txq: pointer obtained from station or virtual interface
  5891. *
  5892. * Return true if the AQL's airtime limit has not been reached and the txq can
  5893. * continue to send more packets to the device. Otherwise return false.
  5894. */
  5895. bool
  5896. ieee80211_txq_airtime_check(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
  5897. /**
  5898. * ieee80211_iter_keys - iterate keys programmed into the device
  5899. * @hw: pointer obtained from ieee80211_alloc_hw()
  5900. * @vif: virtual interface to iterate, may be %NULL for all
  5901. * @iter: iterator function that will be called for each key
  5902. * @iter_data: custom data to pass to the iterator function
  5903. *
  5904. * This function can be used to iterate all the keys known to
  5905. * mac80211, even those that weren't previously programmed into
  5906. * the device. This is intended for use in WoWLAN if the device
  5907. * needs reprogramming of the keys during suspend. Note that due
  5908. * to locking reasons, it is also only safe to call this at few
  5909. * spots since it must hold the RTNL and be able to sleep.
  5910. *
  5911. * The order in which the keys are iterated matches the order
  5912. * in which they were originally installed and handed to the
  5913. * set_key callback.
  5914. */
  5915. void ieee80211_iter_keys(struct ieee80211_hw *hw,
  5916. struct ieee80211_vif *vif,
  5917. void (*iter)(struct ieee80211_hw *hw,
  5918. struct ieee80211_vif *vif,
  5919. struct ieee80211_sta *sta,
  5920. struct ieee80211_key_conf *key,
  5921. void *data),
  5922. void *iter_data);
  5923. /**
  5924. * ieee80211_iter_keys_rcu - iterate keys programmed into the device
  5925. * @hw: pointer obtained from ieee80211_alloc_hw()
  5926. * @vif: virtual interface to iterate, may be %NULL for all
  5927. * @iter: iterator function that will be called for each key
  5928. * @iter_data: custom data to pass to the iterator function
  5929. *
  5930. * This function can be used to iterate all the keys known to
  5931. * mac80211, even those that weren't previously programmed into
  5932. * the device. Note that due to locking reasons, keys of station
  5933. * in removal process will be skipped.
  5934. *
  5935. * This function requires being called in an RCU critical section,
  5936. * and thus iter must be atomic.
  5937. */
  5938. void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
  5939. struct ieee80211_vif *vif,
  5940. void (*iter)(struct ieee80211_hw *hw,
  5941. struct ieee80211_vif *vif,
  5942. struct ieee80211_sta *sta,
  5943. struct ieee80211_key_conf *key,
  5944. void *data),
  5945. void *iter_data);
  5946. /**
  5947. * ieee80211_iter_chan_contexts_atomic - iterate channel contexts
  5948. * @hw: pointer obtained from ieee80211_alloc_hw().
  5949. * @iter: iterator function
  5950. * @iter_data: data passed to iterator function
  5951. *
  5952. * Iterate all active channel contexts. This function is atomic and
  5953. * doesn't acquire any locks internally that might be held in other
  5954. * places while calling into the driver.
  5955. *
  5956. * The iterator will not find a context that's being added (during
  5957. * the driver callback to add it) but will find it while it's being
  5958. * removed.
  5959. *
  5960. * Note that during hardware restart, all contexts that existed
  5961. * before the restart are considered already present so will be
  5962. * found while iterating, whether they've been re-added already
  5963. * or not.
  5964. */
  5965. void ieee80211_iter_chan_contexts_atomic(
  5966. struct ieee80211_hw *hw,
  5967. void (*iter)(struct ieee80211_hw *hw,
  5968. struct ieee80211_chanctx_conf *chanctx_conf,
  5969. void *data),
  5970. void *iter_data);
  5971. /**
  5972. * ieee80211_ap_probereq_get - retrieve a Probe Request template
  5973. * @hw: pointer obtained from ieee80211_alloc_hw().
  5974. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5975. *
  5976. * Creates a Probe Request template which can, for example, be uploaded to
  5977. * hardware. The template is filled with bssid, ssid and supported rate
  5978. * information. This function must only be called from within the
  5979. * .bss_info_changed callback function and only in managed mode. The function
  5980. * is only useful when the interface is associated, otherwise it will return
  5981. * %NULL.
  5982. *
  5983. * Return: The Probe Request template. %NULL on error.
  5984. */
  5985. struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
  5986. struct ieee80211_vif *vif);
  5987. /**
  5988. * ieee80211_beacon_loss - inform hardware does not receive beacons
  5989. *
  5990. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  5991. *
  5992. * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER and
  5993. * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the
  5994. * hardware is not receiving beacons with this function.
  5995. */
  5996. void ieee80211_beacon_loss(struct ieee80211_vif *vif);
  5997. /**
  5998. * ieee80211_connection_loss - inform hardware has lost connection to the AP
  5999. *
  6000. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6001. *
  6002. * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER, and
  6003. * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver
  6004. * needs to inform if the connection to the AP has been lost.
  6005. * The function may also be called if the connection needs to be terminated
  6006. * for some other reason, even if %IEEE80211_HW_CONNECTION_MONITOR isn't set.
  6007. *
  6008. * This function will cause immediate change to disassociated state,
  6009. * without connection recovery attempts.
  6010. */
  6011. void ieee80211_connection_loss(struct ieee80211_vif *vif);
  6012. /**
  6013. * ieee80211_disconnect - request disconnection
  6014. *
  6015. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6016. * @reconnect: immediate reconnect is desired
  6017. *
  6018. * Request disconnection from the current network and, if enabled, send a
  6019. * hint to the higher layers that immediate reconnect is desired.
  6020. */
  6021. void ieee80211_disconnect(struct ieee80211_vif *vif, bool reconnect);
  6022. /**
  6023. * ieee80211_resume_disconnect - disconnect from AP after resume
  6024. *
  6025. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6026. *
  6027. * Instructs mac80211 to disconnect from the AP after resume.
  6028. * Drivers can use this after WoWLAN if they know that the
  6029. * connection cannot be kept up, for example because keys were
  6030. * used while the device was asleep but the replay counters or
  6031. * similar cannot be retrieved from the device during resume.
  6032. *
  6033. * Note that due to implementation issues, if the driver uses
  6034. * the reconfiguration functionality during resume the interface
  6035. * will still be added as associated first during resume and then
  6036. * disconnect normally later.
  6037. *
  6038. * This function can only be called from the resume callback and
  6039. * the driver must not be holding any of its own locks while it
  6040. * calls this function, or at least not any locks it needs in the
  6041. * key configuration paths (if it supports HW crypto).
  6042. */
  6043. void ieee80211_resume_disconnect(struct ieee80211_vif *vif);
  6044. /**
  6045. * ieee80211_hw_restart_disconnect - disconnect from AP after
  6046. * hardware restart
  6047. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6048. *
  6049. * Instructs mac80211 to disconnect from the AP after
  6050. * hardware restart.
  6051. */
  6052. void ieee80211_hw_restart_disconnect(struct ieee80211_vif *vif);
  6053. /**
  6054. * ieee80211_cqm_rssi_notify - inform a configured connection quality monitoring
  6055. * rssi threshold triggered
  6056. *
  6057. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6058. * @rssi_event: the RSSI trigger event type
  6059. * @rssi_level: new RSSI level value or 0 if not available
  6060. * @gfp: context flags
  6061. *
  6062. * When the %IEEE80211_VIF_SUPPORTS_CQM_RSSI is set, and a connection quality
  6063. * monitoring is configured with an rssi threshold, the driver will inform
  6064. * whenever the rssi level reaches the threshold.
  6065. */
  6066. void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
  6067. enum nl80211_cqm_rssi_threshold_event rssi_event,
  6068. s32 rssi_level,
  6069. gfp_t gfp);
  6070. /**
  6071. * ieee80211_cqm_beacon_loss_notify - inform CQM of beacon loss
  6072. *
  6073. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6074. * @gfp: context flags
  6075. */
  6076. void ieee80211_cqm_beacon_loss_notify(struct ieee80211_vif *vif, gfp_t gfp);
  6077. /**
  6078. * ieee80211_radar_detected - inform that a radar was detected
  6079. *
  6080. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6081. */
  6082. void ieee80211_radar_detected(struct ieee80211_hw *hw);
  6083. /**
  6084. * ieee80211_chswitch_done - Complete channel switch process
  6085. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6086. * @success: make the channel switch successful or not
  6087. *
  6088. * Complete the channel switch post-process: set the new operational channel
  6089. * and wake up the suspended queues.
  6090. */
  6091. void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
  6092. /**
  6093. * ieee80211_channel_switch_disconnect - disconnect due to channel switch error
  6094. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6095. * @block_tx: if %true, do not send deauth frame.
  6096. *
  6097. * Instruct mac80211 to disconnect due to a channel switch error. The channel
  6098. * switch can request to block the tx and so, we need to make sure we do not send
  6099. * a deauth frame in this case.
  6100. */
  6101. void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif,
  6102. bool block_tx);
  6103. /**
  6104. * ieee80211_request_smps - request SM PS transition
  6105. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6106. * @link_id: link ID for MLO, or 0
  6107. * @smps_mode: new SM PS mode
  6108. *
  6109. * This allows the driver to request an SM PS transition in managed
  6110. * mode. This is useful when the driver has more information than
  6111. * the stack about possible interference, for example by bluetooth.
  6112. */
  6113. void ieee80211_request_smps(struct ieee80211_vif *vif, unsigned int link_id,
  6114. enum ieee80211_smps_mode smps_mode);
  6115. /**
  6116. * ieee80211_ready_on_channel - notification of remain-on-channel start
  6117. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6118. */
  6119. void ieee80211_ready_on_channel(struct ieee80211_hw *hw);
  6120. /**
  6121. * ieee80211_remain_on_channel_expired - remain_on_channel duration expired
  6122. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6123. */
  6124. void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw);
  6125. /**
  6126. * ieee80211_stop_rx_ba_session - callback to stop existing BA sessions
  6127. *
  6128. * in order not to harm the system performance and user experience, the device
  6129. * may request not to allow any rx ba session and tear down existing rx ba
  6130. * sessions based on system constraints such as periodic BT activity that needs
  6131. * to limit wlan activity (eg.sco or a2dp)."
  6132. * in such cases, the intention is to limit the duration of the rx ppdu and
  6133. * therefore prevent the peer device to use a-mpdu aggregation.
  6134. *
  6135. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6136. * @ba_rx_bitmap: Bit map of open rx ba per tid
  6137. * @addr: & to bssid mac address
  6138. */
  6139. void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap,
  6140. const u8 *addr);
  6141. /**
  6142. * ieee80211_mark_rx_ba_filtered_frames - move RX BA window and mark filtered
  6143. * @pubsta: station struct
  6144. * @tid: the session's TID
  6145. * @ssn: starting sequence number of the bitmap, all frames before this are
  6146. * assumed to be out of the window after the call
  6147. * @filtered: bitmap of filtered frames, BIT(0) is the @ssn entry etc.
  6148. * @received_mpdus: number of received mpdus in firmware
  6149. *
  6150. * This function moves the BA window and releases all frames before @ssn, and
  6151. * marks frames marked in the bitmap as having been filtered. Afterwards, it
  6152. * checks if any frames in the window starting from @ssn can now be released
  6153. * (in case they were only waiting for frames that were filtered.)
  6154. * (Only work correctly if @max_rx_aggregation_subframes <= 64 frames)
  6155. */
  6156. void ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *pubsta, u8 tid,
  6157. u16 ssn, u64 filtered,
  6158. u16 received_mpdus);
  6159. /**
  6160. * ieee80211_send_bar - send a BlockAckReq frame
  6161. *
  6162. * can be used to flush pending frames from the peer's aggregation reorder
  6163. * buffer.
  6164. *
  6165. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6166. * @ra: the peer's destination address
  6167. * @tid: the TID of the aggregation session
  6168. * @ssn: the new starting sequence number for the receiver
  6169. */
  6170. void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn);
  6171. /**
  6172. * ieee80211_manage_rx_ba_offl - helper to queue an RX BA work
  6173. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  6174. * @addr: station mac address
  6175. * @tid: the rx tid
  6176. */
  6177. void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif, const u8 *addr,
  6178. unsigned int tid);
  6179. /**
  6180. * ieee80211_start_rx_ba_session_offl - start a Rx BA session
  6181. *
  6182. * Some device drivers may offload part of the Rx aggregation flow including
  6183. * AddBa/DelBa negotiation but may otherwise be incapable of full Rx
  6184. * reordering.
  6185. *
  6186. * Create structures responsible for reordering so device drivers may call here
  6187. * when they complete AddBa negotiation.
  6188. *
  6189. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  6190. * @addr: station mac address
  6191. * @tid: the rx tid
  6192. */
  6193. static inline void ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif,
  6194. const u8 *addr, u16 tid)
  6195. {
  6196. if (WARN_ON(tid >= IEEE80211_NUM_TIDS))
  6197. return;
  6198. ieee80211_manage_rx_ba_offl(vif, addr, tid);
  6199. }
  6200. /**
  6201. * ieee80211_stop_rx_ba_session_offl - stop a Rx BA session
  6202. *
  6203. * Some device drivers may offload part of the Rx aggregation flow including
  6204. * AddBa/DelBa negotiation but may otherwise be incapable of full Rx
  6205. * reordering.
  6206. *
  6207. * Destroy structures responsible for reordering so device drivers may call here
  6208. * when they complete DelBa negotiation.
  6209. *
  6210. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  6211. * @addr: station mac address
  6212. * @tid: the rx tid
  6213. */
  6214. static inline void ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif,
  6215. const u8 *addr, u16 tid)
  6216. {
  6217. if (WARN_ON(tid >= IEEE80211_NUM_TIDS))
  6218. return;
  6219. ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS);
  6220. }
  6221. /**
  6222. * ieee80211_rx_ba_timer_expired - stop a Rx BA session due to timeout
  6223. *
  6224. * Some device drivers do not offload AddBa/DelBa negotiation, but handle rx
  6225. * buffer reording internally, and therefore also handle the session timer.
  6226. *
  6227. * Trigger the timeout flow, which sends a DelBa.
  6228. *
  6229. * @vif: &struct ieee80211_vif pointer from the add_interface callback
  6230. * @addr: station mac address
  6231. * @tid: the rx tid
  6232. */
  6233. void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
  6234. const u8 *addr, unsigned int tid);
  6235. /* Rate control API */
  6236. /**
  6237. * struct ieee80211_tx_rate_control - rate control information for/from RC algo
  6238. *
  6239. * @hw: The hardware the algorithm is invoked for.
  6240. * @sband: The band this frame is being transmitted on.
  6241. * @bss_conf: the current BSS configuration
  6242. * @skb: the skb that will be transmitted, the control information in it needs
  6243. * to be filled in
  6244. * @reported_rate: The rate control algorithm can fill this in to indicate
  6245. * which rate should be reported to userspace as the current rate and
  6246. * used for rate calculations in the mesh network.
  6247. * @rts: whether RTS will be used for this frame because it is longer than the
  6248. * RTS threshold
  6249. * @short_preamble: whether mac80211 will request short-preamble transmission
  6250. * if the selected rate supports it
  6251. * @rate_idx_mask: user-requested (legacy) rate mask
  6252. * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
  6253. * @bss: whether this frame is sent out in AP or IBSS mode
  6254. */
  6255. struct ieee80211_tx_rate_control {
  6256. struct ieee80211_hw *hw;
  6257. struct ieee80211_supported_band *sband;
  6258. struct ieee80211_bss_conf *bss_conf;
  6259. struct sk_buff *skb;
  6260. struct ieee80211_tx_rate reported_rate;
  6261. bool rts, short_preamble;
  6262. u32 rate_idx_mask;
  6263. u8 *rate_idx_mcs_mask;
  6264. bool bss;
  6265. };
  6266. /**
  6267. * enum rate_control_capabilities - rate control capabilities
  6268. */
  6269. enum rate_control_capabilities {
  6270. /**
  6271. * @RATE_CTRL_CAPA_VHT_EXT_NSS_BW:
  6272. * Support for extended NSS BW support (dot11VHTExtendedNSSCapable)
  6273. * Note that this is only looked at if the minimum number of chains
  6274. * that the AP uses is < the number of TX chains the hardware has,
  6275. * otherwise the NSS difference doesn't bother us.
  6276. */
  6277. RATE_CTRL_CAPA_VHT_EXT_NSS_BW = BIT(0),
  6278. /**
  6279. * @RATE_CTRL_CAPA_AMPDU_TRIGGER:
  6280. * mac80211 should start A-MPDU sessions on tx
  6281. */
  6282. RATE_CTRL_CAPA_AMPDU_TRIGGER = BIT(1),
  6283. };
  6284. struct rate_control_ops {
  6285. unsigned long capa;
  6286. const char *name;
  6287. void *(*alloc)(struct ieee80211_hw *hw);
  6288. void (*add_debugfs)(struct ieee80211_hw *hw, void *priv,
  6289. struct dentry *debugfsdir);
  6290. void (*free)(void *priv);
  6291. void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp);
  6292. void (*rate_init)(void *priv, struct ieee80211_supported_band *sband,
  6293. struct cfg80211_chan_def *chandef,
  6294. struct ieee80211_sta *sta, void *priv_sta);
  6295. void (*rate_update)(void *priv, struct ieee80211_supported_band *sband,
  6296. struct cfg80211_chan_def *chandef,
  6297. struct ieee80211_sta *sta, void *priv_sta,
  6298. u32 changed);
  6299. void (*free_sta)(void *priv, struct ieee80211_sta *sta,
  6300. void *priv_sta);
  6301. void (*tx_status_ext)(void *priv,
  6302. struct ieee80211_supported_band *sband,
  6303. void *priv_sta, struct ieee80211_tx_status *st);
  6304. void (*tx_status)(void *priv, struct ieee80211_supported_band *sband,
  6305. struct ieee80211_sta *sta, void *priv_sta,
  6306. struct sk_buff *skb);
  6307. void (*get_rate)(void *priv, struct ieee80211_sta *sta, void *priv_sta,
  6308. struct ieee80211_tx_rate_control *txrc);
  6309. void (*add_sta_debugfs)(void *priv, void *priv_sta,
  6310. struct dentry *dir);
  6311. u32 (*get_expected_throughput)(void *priv_sta);
  6312. ANDROID_KABI_RESERVE(1);
  6313. ANDROID_KABI_RESERVE(2);
  6314. ANDROID_KABI_RESERVE(3);
  6315. ANDROID_KABI_RESERVE(4);
  6316. };
  6317. static inline int rate_supported(struct ieee80211_sta *sta,
  6318. enum nl80211_band band,
  6319. int index)
  6320. {
  6321. return (sta == NULL || sta->deflink.supp_rates[band] & BIT(index));
  6322. }
  6323. static inline s8
  6324. rate_lowest_index(struct ieee80211_supported_band *sband,
  6325. struct ieee80211_sta *sta)
  6326. {
  6327. int i;
  6328. for (i = 0; i < sband->n_bitrates; i++)
  6329. if (rate_supported(sta, sband->band, i))
  6330. return i;
  6331. /* warn when we cannot find a rate. */
  6332. WARN_ON_ONCE(1);
  6333. /* and return 0 (the lowest index) */
  6334. return 0;
  6335. }
  6336. static inline
  6337. bool rate_usable_index_exists(struct ieee80211_supported_band *sband,
  6338. struct ieee80211_sta *sta)
  6339. {
  6340. unsigned int i;
  6341. for (i = 0; i < sband->n_bitrates; i++)
  6342. if (rate_supported(sta, sband->band, i))
  6343. return true;
  6344. return false;
  6345. }
  6346. /**
  6347. * rate_control_set_rates - pass the sta rate selection to mac80211/driver
  6348. *
  6349. * When not doing a rate control probe to test rates, rate control should pass
  6350. * its rate selection to mac80211. If the driver supports receiving a station
  6351. * rate table, it will use it to ensure that frames are always sent based on
  6352. * the most recent rate control module decision.
  6353. *
  6354. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6355. * @pubsta: &struct ieee80211_sta pointer to the target destination.
  6356. * @rates: new tx rate set to be used for this station.
  6357. */
  6358. int rate_control_set_rates(struct ieee80211_hw *hw,
  6359. struct ieee80211_sta *pubsta,
  6360. struct ieee80211_sta_rates *rates);
  6361. int ieee80211_rate_control_register(const struct rate_control_ops *ops);
  6362. void ieee80211_rate_control_unregister(const struct rate_control_ops *ops);
  6363. static inline bool
  6364. conf_is_ht20(struct ieee80211_conf *conf)
  6365. {
  6366. return conf->chandef.width == NL80211_CHAN_WIDTH_20;
  6367. }
  6368. static inline bool
  6369. conf_is_ht40_minus(struct ieee80211_conf *conf)
  6370. {
  6371. return conf->chandef.width == NL80211_CHAN_WIDTH_40 &&
  6372. conf->chandef.center_freq1 < conf->chandef.chan->center_freq;
  6373. }
  6374. static inline bool
  6375. conf_is_ht40_plus(struct ieee80211_conf *conf)
  6376. {
  6377. return conf->chandef.width == NL80211_CHAN_WIDTH_40 &&
  6378. conf->chandef.center_freq1 > conf->chandef.chan->center_freq;
  6379. }
  6380. static inline bool
  6381. conf_is_ht40(struct ieee80211_conf *conf)
  6382. {
  6383. return conf->chandef.width == NL80211_CHAN_WIDTH_40;
  6384. }
  6385. static inline bool
  6386. conf_is_ht(struct ieee80211_conf *conf)
  6387. {
  6388. return (conf->chandef.width != NL80211_CHAN_WIDTH_5) &&
  6389. (conf->chandef.width != NL80211_CHAN_WIDTH_10) &&
  6390. (conf->chandef.width != NL80211_CHAN_WIDTH_20_NOHT);
  6391. }
  6392. static inline enum nl80211_iftype
  6393. ieee80211_iftype_p2p(enum nl80211_iftype type, bool p2p)
  6394. {
  6395. if (p2p) {
  6396. switch (type) {
  6397. case NL80211_IFTYPE_STATION:
  6398. return NL80211_IFTYPE_P2P_CLIENT;
  6399. case NL80211_IFTYPE_AP:
  6400. return NL80211_IFTYPE_P2P_GO;
  6401. default:
  6402. break;
  6403. }
  6404. }
  6405. return type;
  6406. }
  6407. static inline enum nl80211_iftype
  6408. ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
  6409. {
  6410. return ieee80211_iftype_p2p(vif->type, vif->p2p);
  6411. }
  6412. /**
  6413. * ieee80211_update_mu_groups - set the VHT MU-MIMO groud data
  6414. *
  6415. * @vif: the specified virtual interface
  6416. * @link_id: the link ID for MLO, otherwise 0
  6417. * @membership: 64 bits array - a bit is set if station is member of the group
  6418. * @position: 2 bits per group id indicating the position in the group
  6419. *
  6420. * Note: This function assumes that the given vif is valid and the position and
  6421. * membership data is of the correct size and are in the same byte order as the
  6422. * matching GroupId management frame.
  6423. * Calls to this function need to be serialized with RX path.
  6424. */
  6425. void ieee80211_update_mu_groups(struct ieee80211_vif *vif, unsigned int link_id,
  6426. const u8 *membership, const u8 *position);
  6427. void ieee80211_enable_rssi_reports(struct ieee80211_vif *vif,
  6428. int rssi_min_thold,
  6429. int rssi_max_thold);
  6430. void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif);
  6431. /**
  6432. * ieee80211_ave_rssi - report the average RSSI for the specified interface
  6433. *
  6434. * @vif: the specified virtual interface
  6435. *
  6436. * Note: This function assumes that the given vif is valid.
  6437. *
  6438. * Return: The average RSSI value for the requested interface, or 0 if not
  6439. * applicable.
  6440. */
  6441. int ieee80211_ave_rssi(struct ieee80211_vif *vif);
  6442. /**
  6443. * ieee80211_report_wowlan_wakeup - report WoWLAN wakeup
  6444. * @vif: virtual interface
  6445. * @wakeup: wakeup reason(s)
  6446. * @gfp: allocation flags
  6447. *
  6448. * See cfg80211_report_wowlan_wakeup().
  6449. */
  6450. void ieee80211_report_wowlan_wakeup(struct ieee80211_vif *vif,
  6451. struct cfg80211_wowlan_wakeup *wakeup,
  6452. gfp_t gfp);
  6453. /**
  6454. * ieee80211_tx_prepare_skb - prepare an 802.11 skb for transmission
  6455. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6456. * @vif: virtual interface
  6457. * @skb: frame to be sent from within the driver
  6458. * @band: the band to transmit on
  6459. * @sta: optional pointer to get the station to send the frame to
  6460. *
  6461. * Note: must be called under RCU lock
  6462. */
  6463. bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,
  6464. struct ieee80211_vif *vif, struct sk_buff *skb,
  6465. int band, struct ieee80211_sta **sta);
  6466. /**
  6467. * ieee80211_parse_tx_radiotap - Sanity-check and parse the radiotap header
  6468. * of injected frames.
  6469. *
  6470. * To accurately parse and take into account rate and retransmission fields,
  6471. * you must initialize the chandef field in the ieee80211_tx_info structure
  6472. * of the skb before calling this function.
  6473. *
  6474. * @skb: packet injected by userspace
  6475. * @dev: the &struct device of this 802.11 device
  6476. */
  6477. bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
  6478. struct net_device *dev);
  6479. /**
  6480. * struct ieee80211_noa_data - holds temporary data for tracking P2P NoA state
  6481. *
  6482. * @next_tsf: TSF timestamp of the next absent state change
  6483. * @has_next_tsf: next absent state change event pending
  6484. *
  6485. * @absent: descriptor bitmask, set if GO is currently absent
  6486. *
  6487. * private:
  6488. *
  6489. * @count: count fields from the NoA descriptors
  6490. * @desc: adjusted data from the NoA
  6491. */
  6492. struct ieee80211_noa_data {
  6493. u32 next_tsf;
  6494. bool has_next_tsf;
  6495. u8 absent;
  6496. u8 count[IEEE80211_P2P_NOA_DESC_MAX];
  6497. struct {
  6498. u32 start;
  6499. u32 duration;
  6500. u32 interval;
  6501. } desc[IEEE80211_P2P_NOA_DESC_MAX];
  6502. };
  6503. /**
  6504. * ieee80211_parse_p2p_noa - initialize NoA tracking data from P2P IE
  6505. *
  6506. * @attr: P2P NoA IE
  6507. * @data: NoA tracking data
  6508. * @tsf: current TSF timestamp
  6509. *
  6510. * Return: number of successfully parsed descriptors
  6511. */
  6512. int ieee80211_parse_p2p_noa(const struct ieee80211_p2p_noa_attr *attr,
  6513. struct ieee80211_noa_data *data, u32 tsf);
  6514. /**
  6515. * ieee80211_update_p2p_noa - get next pending P2P GO absent state change
  6516. *
  6517. * @data: NoA tracking data
  6518. * @tsf: current TSF timestamp
  6519. */
  6520. void ieee80211_update_p2p_noa(struct ieee80211_noa_data *data, u32 tsf);
  6521. /**
  6522. * ieee80211_tdls_oper_request - request userspace to perform a TDLS operation
  6523. * @vif: virtual interface
  6524. * @peer: the peer's destination address
  6525. * @oper: the requested TDLS operation
  6526. * @reason_code: reason code for the operation, valid for TDLS teardown
  6527. * @gfp: allocation flags
  6528. *
  6529. * See cfg80211_tdls_oper_request().
  6530. */
  6531. void ieee80211_tdls_oper_request(struct ieee80211_vif *vif, const u8 *peer,
  6532. enum nl80211_tdls_operation oper,
  6533. u16 reason_code, gfp_t gfp);
  6534. /**
  6535. * ieee80211_reserve_tid - request to reserve a specific TID
  6536. *
  6537. * There is sometimes a need (such as in TDLS) for blocking the driver from
  6538. * using a specific TID so that the FW can use it for certain operations such
  6539. * as sending PTI requests. To make sure that the driver doesn't use that TID,
  6540. * this function must be called as it flushes out packets on this TID and marks
  6541. * it as blocked, so that any transmit for the station on this TID will be
  6542. * redirected to the alternative TID in the same AC.
  6543. *
  6544. * Note that this function blocks and may call back into the driver, so it
  6545. * should be called without driver locks held. Also note this function should
  6546. * only be called from the driver's @sta_state callback.
  6547. *
  6548. * @sta: the station to reserve the TID for
  6549. * @tid: the TID to reserve
  6550. *
  6551. * Returns: 0 on success, else on failure
  6552. */
  6553. int ieee80211_reserve_tid(struct ieee80211_sta *sta, u8 tid);
  6554. /**
  6555. * ieee80211_unreserve_tid - request to unreserve a specific TID
  6556. *
  6557. * Once there is no longer any need for reserving a certain TID, this function
  6558. * should be called, and no longer will packets have their TID modified for
  6559. * preventing use of this TID in the driver.
  6560. *
  6561. * Note that this function blocks and acquires a lock, so it should be called
  6562. * without driver locks held. Also note this function should only be called
  6563. * from the driver's @sta_state callback.
  6564. *
  6565. * @sta: the station
  6566. * @tid: the TID to unreserve
  6567. */
  6568. void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
  6569. /**
  6570. * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
  6571. *
  6572. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6573. * @txq: pointer obtained from station or virtual interface, or from
  6574. * ieee80211_next_txq()
  6575. *
  6576. * Returns the skb if successful, %NULL if no frame was available.
  6577. *
  6578. * Note that this must be called in an rcu_read_lock() critical section,
  6579. * which can only be released after the SKB was handled. Some pointers in
  6580. * skb->cb, e.g. the key pointer, are protected by RCU and thus the
  6581. * critical section must persist not just for the duration of this call
  6582. * but for the duration of the frame handling.
  6583. * However, also note that while in the wake_tx_queue() method,
  6584. * rcu_read_lock() is already held.
  6585. *
  6586. * softirqs must also be disabled when this function is called.
  6587. * In process context, use ieee80211_tx_dequeue_ni() instead.
  6588. */
  6589. struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
  6590. struct ieee80211_txq *txq);
  6591. /**
  6592. * ieee80211_tx_dequeue_ni - dequeue a packet from a software tx queue
  6593. * (in process context)
  6594. *
  6595. * Like ieee80211_tx_dequeue() but can be called in process context
  6596. * (internally disables bottom halves).
  6597. *
  6598. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6599. * @txq: pointer obtained from station or virtual interface, or from
  6600. * ieee80211_next_txq()
  6601. */
  6602. static inline struct sk_buff *ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw,
  6603. struct ieee80211_txq *txq)
  6604. {
  6605. struct sk_buff *skb;
  6606. local_bh_disable();
  6607. skb = ieee80211_tx_dequeue(hw, txq);
  6608. local_bh_enable();
  6609. return skb;
  6610. }
  6611. /**
  6612. * ieee80211_next_txq - get next tx queue to pull packets from
  6613. *
  6614. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6615. * @ac: AC number to return packets from.
  6616. *
  6617. * Returns the next txq if successful, %NULL if no queue is eligible. If a txq
  6618. * is returned, it should be returned with ieee80211_return_txq() after the
  6619. * driver has finished scheduling it.
  6620. */
  6621. struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac);
  6622. /**
  6623. * ieee80211_txq_schedule_start - start new scheduling round for TXQs
  6624. *
  6625. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6626. * @ac: AC number to acquire locks for
  6627. *
  6628. * Should be called before ieee80211_next_txq() or ieee80211_return_txq().
  6629. * The driver must not call multiple TXQ scheduling rounds concurrently.
  6630. */
  6631. void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac);
  6632. /* (deprecated) */
  6633. static inline void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac)
  6634. {
  6635. }
  6636. void __ieee80211_schedule_txq(struct ieee80211_hw *hw,
  6637. struct ieee80211_txq *txq, bool force);
  6638. /**
  6639. * ieee80211_schedule_txq - schedule a TXQ for transmission
  6640. *
  6641. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6642. * @txq: pointer obtained from station or virtual interface
  6643. *
  6644. * Schedules a TXQ for transmission if it is not already scheduled,
  6645. * even if mac80211 does not have any packets buffered.
  6646. *
  6647. * The driver may call this function if it has buffered packets for
  6648. * this TXQ internally.
  6649. */
  6650. static inline void
  6651. ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
  6652. {
  6653. __ieee80211_schedule_txq(hw, txq, true);
  6654. }
  6655. /**
  6656. * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq()
  6657. *
  6658. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6659. * @txq: pointer obtained from station or virtual interface
  6660. * @force: schedule txq even if mac80211 does not have any buffered packets.
  6661. *
  6662. * The driver may set force=true if it has buffered packets for this TXQ
  6663. * internally.
  6664. */
  6665. static inline void
  6666. ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq,
  6667. bool force)
  6668. {
  6669. __ieee80211_schedule_txq(hw, txq, force);
  6670. }
  6671. /**
  6672. * ieee80211_txq_may_transmit - check whether TXQ is allowed to transmit
  6673. *
  6674. * This function is used to check whether given txq is allowed to transmit by
  6675. * the airtime scheduler, and can be used by drivers to access the airtime
  6676. * fairness accounting without going using the scheduling order enfored by
  6677. * next_txq().
  6678. *
  6679. * Returns %true if the airtime scheduler thinks the TXQ should be allowed to
  6680. * transmit, and %false if it should be throttled. This function can also have
  6681. * the side effect of rotating the TXQ in the scheduler rotation, which will
  6682. * eventually bring the deficit to positive and allow the station to transmit
  6683. * again.
  6684. *
  6685. * The API ieee80211_txq_may_transmit() also ensures that TXQ list will be
  6686. * aligned against driver's own round-robin scheduler list. i.e it rotates
  6687. * the TXQ list till it makes the requested node becomes the first entry
  6688. * in TXQ list. Thus both the TXQ list and driver's list are in sync. If this
  6689. * function returns %true, the driver is expected to schedule packets
  6690. * for transmission, and then return the TXQ through ieee80211_return_txq().
  6691. *
  6692. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6693. * @txq: pointer obtained from station or virtual interface
  6694. */
  6695. bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw,
  6696. struct ieee80211_txq *txq);
  6697. /**
  6698. * ieee80211_txq_get_depth - get pending frame/byte count of given txq
  6699. *
  6700. * The values are not guaranteed to be coherent with regard to each other, i.e.
  6701. * txq state can change half-way of this function and the caller may end up
  6702. * with "new" frame_cnt and "old" byte_cnt or vice-versa.
  6703. *
  6704. * @txq: pointer obtained from station or virtual interface
  6705. * @frame_cnt: pointer to store frame count
  6706. * @byte_cnt: pointer to store byte count
  6707. */
  6708. void ieee80211_txq_get_depth(struct ieee80211_txq *txq,
  6709. unsigned long *frame_cnt,
  6710. unsigned long *byte_cnt);
  6711. /**
  6712. * ieee80211_nan_func_terminated - notify about NAN function termination.
  6713. *
  6714. * This function is used to notify mac80211 about NAN function termination.
  6715. * Note that this function can't be called from hard irq.
  6716. *
  6717. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6718. * @inst_id: the local instance id
  6719. * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
  6720. * @gfp: allocation flags
  6721. */
  6722. void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
  6723. u8 inst_id,
  6724. enum nl80211_nan_func_term_reason reason,
  6725. gfp_t gfp);
  6726. /**
  6727. * ieee80211_nan_func_match - notify about NAN function match event.
  6728. *
  6729. * This function is used to notify mac80211 about NAN function match. The
  6730. * cookie inside the match struct will be assigned by mac80211.
  6731. * Note that this function can't be called from hard irq.
  6732. *
  6733. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6734. * @match: match event information
  6735. * @gfp: allocation flags
  6736. */
  6737. void ieee80211_nan_func_match(struct ieee80211_vif *vif,
  6738. struct cfg80211_nan_match_params *match,
  6739. gfp_t gfp);
  6740. /**
  6741. * ieee80211_calc_rx_airtime - calculate estimated transmission airtime for RX.
  6742. *
  6743. * This function calculates the estimated airtime usage of a frame based on the
  6744. * rate information in the RX status struct and the frame length.
  6745. *
  6746. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6747. * @status: &struct ieee80211_rx_status containing the transmission rate
  6748. * information.
  6749. * @len: frame length in bytes
  6750. */
  6751. u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
  6752. struct ieee80211_rx_status *status,
  6753. int len);
  6754. /**
  6755. * ieee80211_calc_tx_airtime - calculate estimated transmission airtime for TX.
  6756. *
  6757. * This function calculates the estimated airtime usage of a frame based on the
  6758. * rate information in the TX info struct and the frame length.
  6759. *
  6760. * @hw: pointer as obtained from ieee80211_alloc_hw()
  6761. * @info: &struct ieee80211_tx_info of the frame.
  6762. * @len: frame length in bytes
  6763. */
  6764. u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,
  6765. struct ieee80211_tx_info *info,
  6766. int len);
  6767. /**
  6768. * ieee80211_set_hw_80211_encap - enable hardware encapsulation offloading.
  6769. *
  6770. * This function is used to notify mac80211 that a vif can be passed raw 802.3
  6771. * frames. The driver needs to then handle the 802.11 encapsulation inside the
  6772. * hardware or firmware.
  6773. *
  6774. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6775. * @enable: indicate if the feature should be turned on or off
  6776. */
  6777. bool ieee80211_set_hw_80211_encap(struct ieee80211_vif *vif, bool enable);
  6778. /**
  6779. * ieee80211_get_fils_discovery_tmpl - Get FILS discovery template.
  6780. * @hw: pointer obtained from ieee80211_alloc_hw().
  6781. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6782. *
  6783. * The driver is responsible for freeing the returned skb.
  6784. *
  6785. * Return: FILS discovery template. %NULL on error.
  6786. */
  6787. struct sk_buff *ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
  6788. struct ieee80211_vif *vif);
  6789. /**
  6790. * ieee80211_get_unsol_bcast_probe_resp_tmpl - Get unsolicited broadcast
  6791. * probe response template.
  6792. * @hw: pointer obtained from ieee80211_alloc_hw().
  6793. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6794. *
  6795. * The driver is responsible for freeing the returned skb.
  6796. *
  6797. * Return: Unsolicited broadcast probe response template. %NULL on error.
  6798. */
  6799. struct sk_buff *
  6800. ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw,
  6801. struct ieee80211_vif *vif);
  6802. /**
  6803. * ieeee80211_obss_color_collision_notify - notify userland about a BSS color
  6804. * collision.
  6805. *
  6806. * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  6807. * @color_bitmap: a 64 bit bitmap representing the colors that the local BSS is
  6808. * aware of.
  6809. * @gfp: allocation flags
  6810. */
  6811. void
  6812. ieeee80211_obss_color_collision_notify(struct ieee80211_vif *vif,
  6813. u64 color_bitmap, gfp_t gfp);
  6814. /**
  6815. * ieee80211_is_tx_data - check if frame is a data frame
  6816. *
  6817. * The function is used to check if a frame is a data frame. Frames with
  6818. * hardware encapsulation enabled are data frames.
  6819. *
  6820. * @skb: the frame to be transmitted.
  6821. */
  6822. static inline bool ieee80211_is_tx_data(struct sk_buff *skb)
  6823. {
  6824. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  6825. struct ieee80211_hdr *hdr = (void *) skb->data;
  6826. return info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP ||
  6827. ieee80211_is_data(hdr->frame_control);
  6828. }
  6829. /**
  6830. * ieee80211_set_active_links - set active links in client mode
  6831. * @vif: interface to set active links on
  6832. * @active_links: the new active links bitmap
  6833. *
  6834. * This changes the active links on an interface. The interface
  6835. * must be in client mode (in AP mode, all links are always active),
  6836. * and @active_links must be a subset of the vif's valid_links.
  6837. *
  6838. * If a link is switched off and another is switched on at the same
  6839. * time (e.g. active_links going from 0x1 to 0x10) then you will get
  6840. * a sequence of calls like
  6841. * - change_vif_links(0x11)
  6842. * - unassign_vif_chanctx(link_id=0)
  6843. * - change_sta_links(0x11) for each affected STA (the AP)
  6844. * (TDLS connections on now inactive links should be torn down)
  6845. * - remove group keys on the old link (link_id 0)
  6846. * - add new group keys (GTK/IGTK/BIGTK) on the new link (link_id 4)
  6847. * - change_sta_links(0x10) for each affected STA (the AP)
  6848. * - assign_vif_chanctx(link_id=4)
  6849. * - change_vif_links(0x10)
  6850. *
  6851. * Note: This function acquires some mac80211 locks and must not
  6852. * be called with any driver locks held that could cause a
  6853. * lock dependency inversion. Best call it without locks.
  6854. */
  6855. int ieee80211_set_active_links(struct ieee80211_vif *vif, u16 active_links);
  6856. /**
  6857. * ieee80211_set_active_links_async - asynchronously set active links
  6858. * @vif: interface to set active links on
  6859. * @active_links: the new active links bitmap
  6860. *
  6861. * See ieee80211_set_active_links() for more information, the only
  6862. * difference here is that the link change is triggered async and
  6863. * can be called in any context, but the link switch will only be
  6864. * completed after it returns.
  6865. */
  6866. void ieee80211_set_active_links_async(struct ieee80211_vif *vif,
  6867. u16 active_links);
  6868. #endif /* MAC80211_H */