mac80211.h 226 KB

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