mac80211.h 300 KB

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