cfg80211.h 224 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349
  1. #ifndef __NET_CFG80211_H
  2. #define __NET_CFG80211_H
  3. /*
  4. * 802.11 device and configuration interface
  5. *
  6. * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
  7. * Copyright 2013-2014 Intel Mobile Communications GmbH
  8. * Copyright 2015-2017 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. #include <linux/netdevice.h>
  15. #include <linux/debugfs.h>
  16. #include <linux/list.h>
  17. #include <linux/bug.h>
  18. #include <linux/netlink.h>
  19. #include <linux/skbuff.h>
  20. #include <linux/nl80211.h>
  21. #include <linux/if_ether.h>
  22. #include <linux/ieee80211.h>
  23. #include <linux/net.h>
  24. #include <net/regulatory.h>
  25. /**
  26. * DOC: Introduction
  27. *
  28. * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges
  29. * userspace and drivers, and offers some utility functionality associated
  30. * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used
  31. * by all modern wireless drivers in Linux, so that they offer a consistent
  32. * API through nl80211. For backward compatibility, cfg80211 also offers
  33. * wireless extensions to userspace, but hides them from drivers completely.
  34. *
  35. * Additionally, cfg80211 contains code to help enforce regulatory spectrum
  36. * use restrictions.
  37. */
  38. /**
  39. * DOC: Device registration
  40. *
  41. * In order for a driver to use cfg80211, it must register the hardware device
  42. * with cfg80211. This happens through a number of hardware capability structs
  43. * described below.
  44. *
  45. * The fundamental structure for each device is the 'wiphy', of which each
  46. * instance describes a physical wireless device connected to the system. Each
  47. * such wiphy can have zero, one, or many virtual interfaces associated with
  48. * it, which need to be identified as such by pointing the network interface's
  49. * @ieee80211_ptr pointer to a &struct wireless_dev which further describes
  50. * the wireless part of the interface, normally this struct is embedded in the
  51. * network interface's private data area. Drivers can optionally allow creating
  52. * or destroying virtual interfaces on the fly, but without at least one or the
  53. * ability to create some the wireless device isn't useful.
  54. *
  55. * Each wiphy structure contains device capability information, and also has
  56. * a pointer to the various operations the driver offers. The definitions and
  57. * structures here describe these capabilities in detail.
  58. */
  59. struct wiphy;
  60. /*
  61. * wireless hardware capability structures
  62. */
  63. /**
  64. * enum ieee80211_channel_flags - channel flags
  65. *
  66. * Channel flags set by the regulatory control code.
  67. *
  68. * @IEEE80211_CHAN_DISABLED: This channel is disabled.
  69. * @IEEE80211_CHAN_NO_IR: do not initiate radiation, this includes
  70. * sending probe requests or beaconing.
  71. * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
  72. * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
  73. * is not permitted.
  74. * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel
  75. * is not permitted.
  76. * @IEEE80211_CHAN_NO_OFDM: OFDM is not allowed on this channel.
  77. * @IEEE80211_CHAN_NO_80MHZ: If the driver supports 80 MHz on the band,
  78. * this flag indicates that an 80 MHz channel cannot use this
  79. * channel as the control or any of the secondary channels.
  80. * This may be due to the driver or due to regulatory bandwidth
  81. * restrictions.
  82. * @IEEE80211_CHAN_NO_160MHZ: If the driver supports 160 MHz on the band,
  83. * this flag indicates that an 160 MHz channel cannot use this
  84. * channel as the control or any of the secondary channels.
  85. * This may be due to the driver or due to regulatory bandwidth
  86. * restrictions.
  87. * @IEEE80211_CHAN_INDOOR_ONLY: see %NL80211_FREQUENCY_ATTR_INDOOR_ONLY
  88. * @IEEE80211_CHAN_IR_CONCURRENT: see %NL80211_FREQUENCY_ATTR_IR_CONCURRENT
  89. * @IEEE80211_CHAN_NO_20MHZ: 20 MHz bandwidth is not permitted
  90. * on this channel.
  91. * @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
  92. * on this channel.
  93. *
  94. */
  95. enum ieee80211_channel_flags {
  96. IEEE80211_CHAN_DISABLED = 1<<0,
  97. IEEE80211_CHAN_NO_IR = 1<<1,
  98. /* hole at 1<<2 */
  99. IEEE80211_CHAN_RADAR = 1<<3,
  100. IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
  101. IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
  102. IEEE80211_CHAN_NO_OFDM = 1<<6,
  103. IEEE80211_CHAN_NO_80MHZ = 1<<7,
  104. IEEE80211_CHAN_NO_160MHZ = 1<<8,
  105. IEEE80211_CHAN_INDOOR_ONLY = 1<<9,
  106. IEEE80211_CHAN_IR_CONCURRENT = 1<<10,
  107. IEEE80211_CHAN_NO_20MHZ = 1<<11,
  108. IEEE80211_CHAN_NO_10MHZ = 1<<12,
  109. };
  110. #define IEEE80211_CHAN_NO_HT40 \
  111. (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
  112. #define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
  113. #define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
  114. /**
  115. * struct ieee80211_channel - channel definition
  116. *
  117. * This structure describes a single channel for use
  118. * with cfg80211.
  119. *
  120. * @center_freq: center frequency in MHz
  121. * @hw_value: hardware-specific value for the channel
  122. * @flags: channel flags from &enum ieee80211_channel_flags.
  123. * @orig_flags: channel flags at registration time, used by regulatory
  124. * code to support devices with additional restrictions
  125. * @band: band this channel belongs to.
  126. * @max_antenna_gain: maximum antenna gain in dBi
  127. * @max_power: maximum transmission power (in dBm)
  128. * @max_reg_power: maximum regulatory transmission power (in dBm)
  129. * @beacon_found: helper to regulatory code to indicate when a beacon
  130. * has been found on this channel. Use regulatory_hint_found_beacon()
  131. * to enable this, this is useful only on 5 GHz band.
  132. * @orig_mag: internal use
  133. * @orig_mpwr: internal use
  134. * @dfs_state: current state of this channel. Only relevant if radar is required
  135. * on this channel.
  136. * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
  137. * @dfs_cac_ms: DFS CAC time in milliseconds, this is valid for DFS channels.
  138. */
  139. struct ieee80211_channel {
  140. enum nl80211_band band;
  141. u16 center_freq;
  142. u16 hw_value;
  143. u32 flags;
  144. int max_antenna_gain;
  145. int max_power;
  146. int max_reg_power;
  147. bool beacon_found;
  148. u32 orig_flags;
  149. int orig_mag, orig_mpwr;
  150. enum nl80211_dfs_state dfs_state;
  151. unsigned long dfs_state_entered;
  152. unsigned int dfs_cac_ms;
  153. };
  154. /**
  155. * enum ieee80211_rate_flags - rate flags
  156. *
  157. * Hardware/specification flags for rates. These are structured
  158. * in a way that allows using the same bitrate structure for
  159. * different bands/PHY modes.
  160. *
  161. * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
  162. * preamble on this bitrate; only relevant in 2.4GHz band and
  163. * with CCK rates.
  164. * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
  165. * when used with 802.11a (on the 5 GHz band); filled by the
  166. * core code when registering the wiphy.
  167. * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
  168. * when used with 802.11b (on the 2.4 GHz band); filled by the
  169. * core code when registering the wiphy.
  170. * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
  171. * when used with 802.11g (on the 2.4 GHz band); filled by the
  172. * core code when registering the wiphy.
  173. * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
  174. * @IEEE80211_RATE_SUPPORTS_5MHZ: Rate can be used in 5 MHz mode
  175. * @IEEE80211_RATE_SUPPORTS_10MHZ: Rate can be used in 10 MHz mode
  176. */
  177. enum ieee80211_rate_flags {
  178. IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
  179. IEEE80211_RATE_MANDATORY_A = 1<<1,
  180. IEEE80211_RATE_MANDATORY_B = 1<<2,
  181. IEEE80211_RATE_MANDATORY_G = 1<<3,
  182. IEEE80211_RATE_ERP_G = 1<<4,
  183. IEEE80211_RATE_SUPPORTS_5MHZ = 1<<5,
  184. IEEE80211_RATE_SUPPORTS_10MHZ = 1<<6,
  185. };
  186. /**
  187. * enum ieee80211_bss_type - BSS type filter
  188. *
  189. * @IEEE80211_BSS_TYPE_ESS: Infrastructure BSS
  190. * @IEEE80211_BSS_TYPE_PBSS: Personal BSS
  191. * @IEEE80211_BSS_TYPE_IBSS: Independent BSS
  192. * @IEEE80211_BSS_TYPE_MBSS: Mesh BSS
  193. * @IEEE80211_BSS_TYPE_ANY: Wildcard value for matching any BSS type
  194. */
  195. enum ieee80211_bss_type {
  196. IEEE80211_BSS_TYPE_ESS,
  197. IEEE80211_BSS_TYPE_PBSS,
  198. IEEE80211_BSS_TYPE_IBSS,
  199. IEEE80211_BSS_TYPE_MBSS,
  200. IEEE80211_BSS_TYPE_ANY
  201. };
  202. /**
  203. * enum ieee80211_privacy - BSS privacy filter
  204. *
  205. * @IEEE80211_PRIVACY_ON: privacy bit set
  206. * @IEEE80211_PRIVACY_OFF: privacy bit clear
  207. * @IEEE80211_PRIVACY_ANY: Wildcard value for matching any privacy setting
  208. */
  209. enum ieee80211_privacy {
  210. IEEE80211_PRIVACY_ON,
  211. IEEE80211_PRIVACY_OFF,
  212. IEEE80211_PRIVACY_ANY
  213. };
  214. #define IEEE80211_PRIVACY(x) \
  215. ((x) ? IEEE80211_PRIVACY_ON : IEEE80211_PRIVACY_OFF)
  216. /**
  217. * struct ieee80211_rate - bitrate definition
  218. *
  219. * This structure describes a bitrate that an 802.11 PHY can
  220. * operate with. The two values @hw_value and @hw_value_short
  221. * are only for driver use when pointers to this structure are
  222. * passed around.
  223. *
  224. * @flags: rate-specific flags
  225. * @bitrate: bitrate in units of 100 Kbps
  226. * @hw_value: driver/hardware value for this rate
  227. * @hw_value_short: driver/hardware value for this rate when
  228. * short preamble is used
  229. */
  230. struct ieee80211_rate {
  231. u32 flags;
  232. u16 bitrate;
  233. u16 hw_value, hw_value_short;
  234. };
  235. /**
  236. * struct ieee80211_sta_ht_cap - STA's HT capabilities
  237. *
  238. * This structure describes most essential parameters needed
  239. * to describe 802.11n HT capabilities for an STA.
  240. *
  241. * @ht_supported: is HT supported by the STA
  242. * @cap: HT capabilities map as described in 802.11n spec
  243. * @ampdu_factor: Maximum A-MPDU length factor
  244. * @ampdu_density: Minimum A-MPDU spacing
  245. * @mcs: Supported MCS rates
  246. */
  247. struct ieee80211_sta_ht_cap {
  248. u16 cap; /* use IEEE80211_HT_CAP_ */
  249. bool ht_supported;
  250. u8 ampdu_factor;
  251. u8 ampdu_density;
  252. struct ieee80211_mcs_info mcs;
  253. };
  254. /**
  255. * struct ieee80211_sta_vht_cap - STA's VHT capabilities
  256. *
  257. * This structure describes most essential parameters needed
  258. * to describe 802.11ac VHT capabilities for an STA.
  259. *
  260. * @vht_supported: is VHT supported by the STA
  261. * @cap: VHT capabilities map as described in 802.11ac spec
  262. * @vht_mcs: Supported VHT MCS rates
  263. */
  264. struct ieee80211_sta_vht_cap {
  265. bool vht_supported;
  266. u32 cap; /* use IEEE80211_VHT_CAP_ */
  267. struct ieee80211_vht_mcs_info vht_mcs;
  268. };
  269. /**
  270. * struct ieee80211_supported_band - frequency band definition
  271. *
  272. * This structure describes a frequency band a wiphy
  273. * is able to operate in.
  274. *
  275. * @channels: Array of channels the hardware can operate in
  276. * in this band.
  277. * @band: the band this structure represents
  278. * @n_channels: Number of channels in @channels
  279. * @bitrates: Array of bitrates the hardware can operate with
  280. * in this band. Must be sorted to give a valid "supported
  281. * rates" IE, i.e. CCK rates first, then OFDM.
  282. * @n_bitrates: Number of bitrates in @bitrates
  283. * @ht_cap: HT capabilities in this band
  284. * @vht_cap: VHT capabilities in this band
  285. */
  286. struct ieee80211_supported_band {
  287. struct ieee80211_channel *channels;
  288. struct ieee80211_rate *bitrates;
  289. enum nl80211_band band;
  290. int n_channels;
  291. int n_bitrates;
  292. struct ieee80211_sta_ht_cap ht_cap;
  293. struct ieee80211_sta_vht_cap vht_cap;
  294. };
  295. /**
  296. * wiphy_read_of_freq_limits - read frequency limits from device tree
  297. *
  298. * @wiphy: the wireless device to get extra limits for
  299. *
  300. * Some devices may have extra limitations specified in DT. This may be useful
  301. * for chipsets that normally support more bands but are limited due to board
  302. * design (e.g. by antennas or external power amplifier).
  303. *
  304. * This function reads info from DT and uses it to *modify* channels (disable
  305. * unavailable ones). It's usually a *bad* idea to use it in drivers with
  306. * shared channel data as DT limitations are device specific. You should make
  307. * sure to call it only if channels in wiphy are copied and can be modified
  308. * without affecting other devices.
  309. *
  310. * As this function access device node it has to be called after set_wiphy_dev.
  311. * It also modifies channels so they have to be set first.
  312. * If using this helper, call it before wiphy_register().
  313. */
  314. #ifdef CONFIG_OF
  315. void wiphy_read_of_freq_limits(struct wiphy *wiphy);
  316. #else /* CONFIG_OF */
  317. static inline void wiphy_read_of_freq_limits(struct wiphy *wiphy)
  318. {
  319. }
  320. #endif /* !CONFIG_OF */
  321. /*
  322. * Wireless hardware/device configuration structures and methods
  323. */
  324. /**
  325. * DOC: Actions and configuration
  326. *
  327. * Each wireless device and each virtual interface offer a set of configuration
  328. * operations and other actions that are invoked by userspace. Each of these
  329. * actions is described in the operations structure, and the parameters these
  330. * operations use are described separately.
  331. *
  332. * Additionally, some operations are asynchronous and expect to get status
  333. * information via some functions that drivers need to call.
  334. *
  335. * Scanning and BSS list handling with its associated functionality is described
  336. * in a separate chapter.
  337. */
  338. #define VHT_MUMIMO_GROUPS_DATA_LEN (WLAN_MEMBERSHIP_LEN +\
  339. WLAN_USER_POSITION_LEN)
  340. /**
  341. * struct vif_params - describes virtual interface parameters
  342. * @flags: monitor interface flags, unchanged if 0, otherwise
  343. * %MONITOR_FLAG_CHANGED will be set
  344. * @use_4addr: use 4-address frames
  345. * @macaddr: address to use for this virtual interface.
  346. * If this parameter is set to zero address the driver may
  347. * determine the address as needed.
  348. * This feature is only fully supported by drivers that enable the
  349. * %NL80211_FEATURE_MAC_ON_CREATE flag. Others may support creating
  350. ** only p2p devices with specified MAC.
  351. * @vht_mumimo_groups: MU-MIMO groupID, used for monitoring MU-MIMO packets
  352. * belonging to that MU-MIMO groupID; %NULL if not changed
  353. * @vht_mumimo_follow_addr: MU-MIMO follow address, used for monitoring
  354. * MU-MIMO packets going to the specified station; %NULL if not changed
  355. */
  356. struct vif_params {
  357. u32 flags;
  358. int use_4addr;
  359. u8 macaddr[ETH_ALEN];
  360. const u8 *vht_mumimo_groups;
  361. const u8 *vht_mumimo_follow_addr;
  362. };
  363. /**
  364. * struct key_params - key information
  365. *
  366. * Information about a key
  367. *
  368. * @key: key material
  369. * @key_len: length of key material
  370. * @cipher: cipher suite selector
  371. * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
  372. * with the get_key() callback, must be in little endian,
  373. * length given by @seq_len.
  374. * @seq_len: length of @seq.
  375. */
  376. struct key_params {
  377. const u8 *key;
  378. const u8 *seq;
  379. int key_len;
  380. int seq_len;
  381. u32 cipher;
  382. };
  383. /**
  384. * struct cfg80211_chan_def - channel definition
  385. * @chan: the (control) channel
  386. * @width: channel width
  387. * @center_freq1: center frequency of first segment
  388. * @center_freq2: center frequency of second segment
  389. * (only with 80+80 MHz)
  390. */
  391. struct cfg80211_chan_def {
  392. struct ieee80211_channel *chan;
  393. enum nl80211_chan_width width;
  394. u32 center_freq1;
  395. u32 center_freq2;
  396. };
  397. /**
  398. * cfg80211_get_chandef_type - return old channel type from chandef
  399. * @chandef: the channel definition
  400. *
  401. * Return: The old channel type (NOHT, HT20, HT40+/-) from a given
  402. * chandef, which must have a bandwidth allowing this conversion.
  403. */
  404. static inline enum nl80211_channel_type
  405. cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef)
  406. {
  407. switch (chandef->width) {
  408. case NL80211_CHAN_WIDTH_20_NOHT:
  409. return NL80211_CHAN_NO_HT;
  410. case NL80211_CHAN_WIDTH_20:
  411. return NL80211_CHAN_HT20;
  412. case NL80211_CHAN_WIDTH_40:
  413. if (chandef->center_freq1 > chandef->chan->center_freq)
  414. return NL80211_CHAN_HT40PLUS;
  415. return NL80211_CHAN_HT40MINUS;
  416. default:
  417. WARN_ON(1);
  418. return NL80211_CHAN_NO_HT;
  419. }
  420. }
  421. /**
  422. * cfg80211_chandef_create - create channel definition using channel type
  423. * @chandef: the channel definition struct to fill
  424. * @channel: the control channel
  425. * @chantype: the channel type
  426. *
  427. * Given a channel type, create a channel definition.
  428. */
  429. void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
  430. struct ieee80211_channel *channel,
  431. enum nl80211_channel_type chantype);
  432. /**
  433. * cfg80211_chandef_identical - check if two channel definitions are identical
  434. * @chandef1: first channel definition
  435. * @chandef2: second channel definition
  436. *
  437. * Return: %true if the channels defined by the channel definitions are
  438. * identical, %false otherwise.
  439. */
  440. static inline bool
  441. cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
  442. const struct cfg80211_chan_def *chandef2)
  443. {
  444. return (chandef1->chan == chandef2->chan &&
  445. chandef1->width == chandef2->width &&
  446. chandef1->center_freq1 == chandef2->center_freq1 &&
  447. chandef1->center_freq2 == chandef2->center_freq2);
  448. }
  449. /**
  450. * cfg80211_chandef_compatible - check if two channel definitions are compatible
  451. * @chandef1: first channel definition
  452. * @chandef2: second channel definition
  453. *
  454. * Return: %NULL if the given channel definitions are incompatible,
  455. * chandef1 or chandef2 otherwise.
  456. */
  457. const struct cfg80211_chan_def *
  458. cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1,
  459. const struct cfg80211_chan_def *chandef2);
  460. /**
  461. * cfg80211_chandef_valid - check if a channel definition is valid
  462. * @chandef: the channel definition to check
  463. * Return: %true if the channel definition is valid. %false otherwise.
  464. */
  465. bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef);
  466. /**
  467. * cfg80211_chandef_usable - check if secondary channels can be used
  468. * @wiphy: the wiphy to validate against
  469. * @chandef: the channel definition to check
  470. * @prohibited_flags: the regulatory channel flags that must not be set
  471. * Return: %true if secondary channels are usable. %false otherwise.
  472. */
  473. bool cfg80211_chandef_usable(struct wiphy *wiphy,
  474. const struct cfg80211_chan_def *chandef,
  475. u32 prohibited_flags);
  476. /**
  477. * cfg80211_chandef_dfs_required - checks if radar detection is required
  478. * @wiphy: the wiphy to validate against
  479. * @chandef: the channel definition to check
  480. * @iftype: the interface type as specified in &enum nl80211_iftype
  481. * Returns:
  482. * 1 if radar detection is required, 0 if it is not, < 0 on error
  483. */
  484. int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
  485. const struct cfg80211_chan_def *chandef,
  486. enum nl80211_iftype iftype);
  487. /**
  488. * ieee80211_chandef_rate_flags - returns rate flags for a channel
  489. *
  490. * In some channel types, not all rates may be used - for example CCK
  491. * rates may not be used in 5/10 MHz channels.
  492. *
  493. * @chandef: channel definition for the channel
  494. *
  495. * Returns: rate flags which apply for this channel
  496. */
  497. static inline enum ieee80211_rate_flags
  498. ieee80211_chandef_rate_flags(struct cfg80211_chan_def *chandef)
  499. {
  500. switch (chandef->width) {
  501. case NL80211_CHAN_WIDTH_5:
  502. return IEEE80211_RATE_SUPPORTS_5MHZ;
  503. case NL80211_CHAN_WIDTH_10:
  504. return IEEE80211_RATE_SUPPORTS_10MHZ;
  505. default:
  506. break;
  507. }
  508. return 0;
  509. }
  510. /**
  511. * ieee80211_chandef_max_power - maximum transmission power for the chandef
  512. *
  513. * In some regulations, the transmit power may depend on the configured channel
  514. * bandwidth which may be defined as dBm/MHz. This function returns the actual
  515. * max_power for non-standard (20 MHz) channels.
  516. *
  517. * @chandef: channel definition for the channel
  518. *
  519. * Returns: maximum allowed transmission power in dBm for the chandef
  520. */
  521. static inline int
  522. ieee80211_chandef_max_power(struct cfg80211_chan_def *chandef)
  523. {
  524. switch (chandef->width) {
  525. case NL80211_CHAN_WIDTH_5:
  526. return min(chandef->chan->max_reg_power - 6,
  527. chandef->chan->max_power);
  528. case NL80211_CHAN_WIDTH_10:
  529. return min(chandef->chan->max_reg_power - 3,
  530. chandef->chan->max_power);
  531. default:
  532. break;
  533. }
  534. return chandef->chan->max_power;
  535. }
  536. /**
  537. * enum survey_info_flags - survey information flags
  538. *
  539. * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in
  540. * @SURVEY_INFO_IN_USE: channel is currently being used
  541. * @SURVEY_INFO_TIME: active time (in ms) was filled in
  542. * @SURVEY_INFO_TIME_BUSY: busy time was filled in
  543. * @SURVEY_INFO_TIME_EXT_BUSY: extension channel busy time was filled in
  544. * @SURVEY_INFO_TIME_RX: receive time was filled in
  545. * @SURVEY_INFO_TIME_TX: transmit time was filled in
  546. * @SURVEY_INFO_TIME_SCAN: scan time was filled in
  547. *
  548. * Used by the driver to indicate which info in &struct survey_info
  549. * it has filled in during the get_survey().
  550. */
  551. enum survey_info_flags {
  552. SURVEY_INFO_NOISE_DBM = BIT(0),
  553. SURVEY_INFO_IN_USE = BIT(1),
  554. SURVEY_INFO_TIME = BIT(2),
  555. SURVEY_INFO_TIME_BUSY = BIT(3),
  556. SURVEY_INFO_TIME_EXT_BUSY = BIT(4),
  557. SURVEY_INFO_TIME_RX = BIT(5),
  558. SURVEY_INFO_TIME_TX = BIT(6),
  559. SURVEY_INFO_TIME_SCAN = BIT(7),
  560. };
  561. /**
  562. * struct survey_info - channel survey response
  563. *
  564. * @channel: the channel this survey record reports, may be %NULL for a single
  565. * record to report global statistics
  566. * @filled: bitflag of flags from &enum survey_info_flags
  567. * @noise: channel noise in dBm. This and all following fields are
  568. * optional
  569. * @time: amount of time in ms the radio was turn on (on the channel)
  570. * @time_busy: amount of time the primary channel was sensed busy
  571. * @time_ext_busy: amount of time the extension channel was sensed busy
  572. * @time_rx: amount of time the radio spent receiving data
  573. * @time_tx: amount of time the radio spent transmitting data
  574. * @time_scan: amount of time the radio spent for scanning
  575. *
  576. * Used by dump_survey() to report back per-channel survey information.
  577. *
  578. * This structure can later be expanded with things like
  579. * channel duty cycle etc.
  580. */
  581. struct survey_info {
  582. struct ieee80211_channel *channel;
  583. u64 time;
  584. u64 time_busy;
  585. u64 time_ext_busy;
  586. u64 time_rx;
  587. u64 time_tx;
  588. u64 time_scan;
  589. u32 filled;
  590. s8 noise;
  591. };
  592. #define CFG80211_MAX_WEP_KEYS 4
  593. /**
  594. * struct cfg80211_crypto_settings - Crypto settings
  595. * @wpa_versions: indicates which, if any, WPA versions are enabled
  596. * (from enum nl80211_wpa_versions)
  597. * @cipher_group: group key cipher suite (or 0 if unset)
  598. * @n_ciphers_pairwise: number of AP supported unicast ciphers
  599. * @ciphers_pairwise: unicast key cipher suites
  600. * @n_akm_suites: number of AKM suites
  601. * @akm_suites: AKM suites
  602. * @control_port: Whether user space controls IEEE 802.1X port, i.e.,
  603. * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  604. * required to assume that the port is unauthorized until authorized by
  605. * user space. Otherwise, port is marked authorized by default.
  606. * @control_port_ethertype: the control port protocol that should be
  607. * allowed through even on unauthorized ports
  608. * @control_port_no_encrypt: TRUE to prevent encryption of control port
  609. * protocol frames.
  610. * @wep_keys: static WEP keys, if not NULL points to an array of
  611. * CFG80211_MAX_WEP_KEYS WEP keys
  612. * @wep_tx_key: key index (0..3) of the default TX static WEP key
  613. * @psk: PSK (for devices supporting 4-way-handshake offload)
  614. */
  615. struct cfg80211_crypto_settings {
  616. u32 wpa_versions;
  617. u32 cipher_group;
  618. int n_ciphers_pairwise;
  619. u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
  620. int n_akm_suites;
  621. u32 akm_suites[NL80211_MAX_NR_AKM_SUITES];
  622. bool control_port;
  623. __be16 control_port_ethertype;
  624. bool control_port_no_encrypt;
  625. struct key_params *wep_keys;
  626. int wep_tx_key;
  627. const u8 *psk;
  628. };
  629. /**
  630. * struct cfg80211_beacon_data - beacon data
  631. * @head: head portion of beacon (before TIM IE)
  632. * or %NULL if not changed
  633. * @tail: tail portion of beacon (after TIM IE)
  634. * or %NULL if not changed
  635. * @head_len: length of @head
  636. * @tail_len: length of @tail
  637. * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
  638. * @beacon_ies_len: length of beacon_ies in octets
  639. * @proberesp_ies: extra information element(s) to add into Probe Response
  640. * frames or %NULL
  641. * @proberesp_ies_len: length of proberesp_ies in octets
  642. * @assocresp_ies: extra information element(s) to add into (Re)Association
  643. * Response frames or %NULL
  644. * @assocresp_ies_len: length of assocresp_ies in octets
  645. * @probe_resp_len: length of probe response template (@probe_resp)
  646. * @probe_resp: probe response template (AP mode only)
  647. */
  648. struct cfg80211_beacon_data {
  649. const u8 *head, *tail;
  650. const u8 *beacon_ies;
  651. const u8 *proberesp_ies;
  652. const u8 *assocresp_ies;
  653. const u8 *probe_resp;
  654. size_t head_len, tail_len;
  655. size_t beacon_ies_len;
  656. size_t proberesp_ies_len;
  657. size_t assocresp_ies_len;
  658. size_t probe_resp_len;
  659. };
  660. struct mac_address {
  661. u8 addr[ETH_ALEN];
  662. };
  663. /**
  664. * struct cfg80211_acl_data - Access control list data
  665. *
  666. * @acl_policy: ACL policy to be applied on the station's
  667. * entry specified by mac_addr
  668. * @n_acl_entries: Number of MAC address entries passed
  669. * @mac_addrs: List of MAC addresses of stations to be used for ACL
  670. */
  671. struct cfg80211_acl_data {
  672. enum nl80211_acl_policy acl_policy;
  673. int n_acl_entries;
  674. /* Keep it last */
  675. struct mac_address mac_addrs[];
  676. };
  677. /*
  678. * cfg80211_bitrate_mask - masks for bitrate control
  679. */
  680. struct cfg80211_bitrate_mask {
  681. struct {
  682. u32 legacy;
  683. u8 ht_mcs[IEEE80211_HT_MCS_MASK_LEN];
  684. u16 vht_mcs[NL80211_VHT_NSS_MAX];
  685. enum nl80211_txrate_gi gi;
  686. } control[NUM_NL80211_BANDS];
  687. };
  688. /**
  689. * struct cfg80211_ap_settings - AP configuration
  690. *
  691. * Used to configure an AP interface.
  692. *
  693. * @chandef: defines the channel to use
  694. * @beacon: beacon data
  695. * @beacon_interval: beacon interval
  696. * @dtim_period: DTIM period
  697. * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
  698. * user space)
  699. * @ssid_len: length of @ssid
  700. * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames
  701. * @crypto: crypto settings
  702. * @privacy: the BSS uses privacy
  703. * @auth_type: Authentication type (algorithm)
  704. * @smps_mode: SMPS mode
  705. * @inactivity_timeout: time in seconds to determine station's inactivity.
  706. * @p2p_ctwindow: P2P CT Window
  707. * @p2p_opp_ps: P2P opportunistic PS
  708. * @acl: ACL configuration used by the drivers which has support for
  709. * MAC address based access control
  710. * @pbss: If set, start as a PCP instead of AP. Relevant for DMG
  711. * networks.
  712. * @beacon_rate: bitrate to be used for beacons
  713. * @ht_cap: HT capabilities (or %NULL if HT isn't enabled)
  714. * @vht_cap: VHT capabilities (or %NULL if VHT isn't enabled)
  715. * @ht_required: stations must support HT
  716. * @vht_required: stations must support VHT
  717. */
  718. struct cfg80211_ap_settings {
  719. struct cfg80211_chan_def chandef;
  720. struct cfg80211_beacon_data beacon;
  721. int beacon_interval, dtim_period;
  722. const u8 *ssid;
  723. size_t ssid_len;
  724. enum nl80211_hidden_ssid hidden_ssid;
  725. struct cfg80211_crypto_settings crypto;
  726. bool privacy;
  727. enum nl80211_auth_type auth_type;
  728. enum nl80211_smps_mode smps_mode;
  729. int inactivity_timeout;
  730. u8 p2p_ctwindow;
  731. bool p2p_opp_ps;
  732. const struct cfg80211_acl_data *acl;
  733. bool pbss;
  734. struct cfg80211_bitrate_mask beacon_rate;
  735. const struct ieee80211_ht_cap *ht_cap;
  736. const struct ieee80211_vht_cap *vht_cap;
  737. bool ht_required, vht_required;
  738. };
  739. /**
  740. * struct cfg80211_csa_settings - channel switch settings
  741. *
  742. * Used for channel switch
  743. *
  744. * @chandef: defines the channel to use after the switch
  745. * @beacon_csa: beacon data while performing the switch
  746. * @counter_offsets_beacon: offsets of the counters within the beacon (tail)
  747. * @counter_offsets_presp: offsets of the counters within the probe response
  748. * @n_counter_offsets_beacon: number of csa counters the beacon (tail)
  749. * @n_counter_offsets_presp: number of csa counters in the probe response
  750. * @beacon_after: beacon data to be used on the new channel
  751. * @radar_required: whether radar detection is required on the new channel
  752. * @block_tx: whether transmissions should be blocked while changing
  753. * @count: number of beacons until switch
  754. */
  755. struct cfg80211_csa_settings {
  756. struct cfg80211_chan_def chandef;
  757. struct cfg80211_beacon_data beacon_csa;
  758. const u16 *counter_offsets_beacon;
  759. const u16 *counter_offsets_presp;
  760. unsigned int n_counter_offsets_beacon;
  761. unsigned int n_counter_offsets_presp;
  762. struct cfg80211_beacon_data beacon_after;
  763. bool radar_required;
  764. bool block_tx;
  765. u8 count;
  766. };
  767. #define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10
  768. /**
  769. * struct iface_combination_params - input parameters for interface combinations
  770. *
  771. * Used to pass interface combination parameters
  772. *
  773. * @num_different_channels: the number of different channels we want
  774. * to use for verification
  775. * @radar_detect: a bitmap where each bit corresponds to a channel
  776. * width where radar detection is needed, as in the definition of
  777. * &struct ieee80211_iface_combination.@radar_detect_widths
  778. * @iftype_num: array with the number of interfaces of each interface
  779. * type. The index is the interface type as specified in &enum
  780. * nl80211_iftype.
  781. * @new_beacon_int: set this to the beacon interval of a new interface
  782. * that's not operating yet, if such is to be checked as part of
  783. * the verification
  784. */
  785. struct iface_combination_params {
  786. int num_different_channels;
  787. u8 radar_detect;
  788. int iftype_num[NUM_NL80211_IFTYPES];
  789. u32 new_beacon_int;
  790. };
  791. /**
  792. * enum station_parameters_apply_mask - station parameter values to apply
  793. * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp)
  794. * @STATION_PARAM_APPLY_CAPABILITY: apply new capability
  795. * @STATION_PARAM_APPLY_PLINK_STATE: apply new plink state
  796. *
  797. * Not all station parameters have in-band "no change" signalling,
  798. * for those that don't these flags will are used.
  799. */
  800. enum station_parameters_apply_mask {
  801. STATION_PARAM_APPLY_UAPSD = BIT(0),
  802. STATION_PARAM_APPLY_CAPABILITY = BIT(1),
  803. STATION_PARAM_APPLY_PLINK_STATE = BIT(2),
  804. };
  805. /**
  806. * struct station_parameters - station parameters
  807. *
  808. * Used to change and create a new station.
  809. *
  810. * @vlan: vlan interface station should belong to
  811. * @supported_rates: supported rates in IEEE 802.11 format
  812. * (or NULL for no change)
  813. * @supported_rates_len: number of supported rates
  814. * @sta_flags_mask: station flags that changed
  815. * (bitmask of BIT(%NL80211_STA_FLAG_...))
  816. * @sta_flags_set: station flags values
  817. * (bitmask of BIT(%NL80211_STA_FLAG_...))
  818. * @listen_interval: listen interval or -1 for no change
  819. * @aid: AID or zero for no change
  820. * @peer_aid: mesh peer AID or zero for no change
  821. * @plink_action: plink action to take
  822. * @plink_state: set the peer link state for a station
  823. * @ht_capa: HT capabilities of station
  824. * @vht_capa: VHT capabilities of station
  825. * @uapsd_queues: bitmap of queues configured for uapsd. same format
  826. * as the AC bitmap in the QoS info field
  827. * @max_sp: max Service Period. same format as the MAX_SP in the
  828. * QoS info field (but already shifted down)
  829. * @sta_modify_mask: bitmap indicating which parameters changed
  830. * (for those that don't have a natural "no change" value),
  831. * see &enum station_parameters_apply_mask
  832. * @local_pm: local link-specific mesh power save mode (no change when set
  833. * to unknown)
  834. * @capability: station capability
  835. * @ext_capab: extended capabilities of the station
  836. * @ext_capab_len: number of extended capabilities
  837. * @supported_channels: supported channels in IEEE 802.11 format
  838. * @supported_channels_len: number of supported channels
  839. * @supported_oper_classes: supported oper classes in IEEE 802.11 format
  840. * @supported_oper_classes_len: number of supported operating classes
  841. * @opmode_notif: operating mode field from Operating Mode Notification
  842. * @opmode_notif_used: information if operating mode field is used
  843. * @support_p2p_ps: information if station supports P2P PS mechanism
  844. */
  845. struct station_parameters {
  846. const u8 *supported_rates;
  847. struct net_device *vlan;
  848. u32 sta_flags_mask, sta_flags_set;
  849. u32 sta_modify_mask;
  850. int listen_interval;
  851. u16 aid;
  852. u16 peer_aid;
  853. u8 supported_rates_len;
  854. u8 plink_action;
  855. u8 plink_state;
  856. const struct ieee80211_ht_cap *ht_capa;
  857. const struct ieee80211_vht_cap *vht_capa;
  858. u8 uapsd_queues;
  859. u8 max_sp;
  860. enum nl80211_mesh_power_mode local_pm;
  861. u16 capability;
  862. const u8 *ext_capab;
  863. u8 ext_capab_len;
  864. const u8 *supported_channels;
  865. u8 supported_channels_len;
  866. const u8 *supported_oper_classes;
  867. u8 supported_oper_classes_len;
  868. u8 opmode_notif;
  869. bool opmode_notif_used;
  870. int support_p2p_ps;
  871. };
  872. /**
  873. * struct station_del_parameters - station deletion parameters
  874. *
  875. * Used to delete a station entry (or all stations).
  876. *
  877. * @mac: MAC address of the station to remove or NULL to remove all stations
  878. * @subtype: Management frame subtype to use for indicating removal
  879. * (10 = Disassociation, 12 = Deauthentication)
  880. * @reason_code: Reason code for the Disassociation/Deauthentication frame
  881. */
  882. struct station_del_parameters {
  883. const u8 *mac;
  884. u8 subtype;
  885. u16 reason_code;
  886. };
  887. /**
  888. * enum cfg80211_station_type - the type of station being modified
  889. * @CFG80211_STA_AP_CLIENT: client of an AP interface
  890. * @CFG80211_STA_AP_CLIENT_UNASSOC: client of an AP interface that is still
  891. * unassociated (update properties for this type of client is permitted)
  892. * @CFG80211_STA_AP_MLME_CLIENT: client of an AP interface that has
  893. * the AP MLME in the device
  894. * @CFG80211_STA_AP_STA: AP station on managed interface
  895. * @CFG80211_STA_IBSS: IBSS station
  896. * @CFG80211_STA_TDLS_PEER_SETUP: TDLS peer on managed interface (dummy entry
  897. * while TDLS setup is in progress, it moves out of this state when
  898. * being marked authorized; use this only if TDLS with external setup is
  899. * supported/used)
  900. * @CFG80211_STA_TDLS_PEER_ACTIVE: TDLS peer on managed interface (active
  901. * entry that is operating, has been marked authorized by userspace)
  902. * @CFG80211_STA_MESH_PEER_KERNEL: peer on mesh interface (kernel managed)
  903. * @CFG80211_STA_MESH_PEER_USER: peer on mesh interface (user managed)
  904. */
  905. enum cfg80211_station_type {
  906. CFG80211_STA_AP_CLIENT,
  907. CFG80211_STA_AP_CLIENT_UNASSOC,
  908. CFG80211_STA_AP_MLME_CLIENT,
  909. CFG80211_STA_AP_STA,
  910. CFG80211_STA_IBSS,
  911. CFG80211_STA_TDLS_PEER_SETUP,
  912. CFG80211_STA_TDLS_PEER_ACTIVE,
  913. CFG80211_STA_MESH_PEER_KERNEL,
  914. CFG80211_STA_MESH_PEER_USER,
  915. };
  916. /**
  917. * cfg80211_check_station_change - validate parameter changes
  918. * @wiphy: the wiphy this operates on
  919. * @params: the new parameters for a station
  920. * @statype: the type of station being modified
  921. *
  922. * Utility function for the @change_station driver method. Call this function
  923. * with the appropriate station type looking up the station (and checking that
  924. * it exists). It will verify whether the station change is acceptable, and if
  925. * not will return an error code. Note that it may modify the parameters for
  926. * backward compatibility reasons, so don't use them before calling this.
  927. */
  928. int cfg80211_check_station_change(struct wiphy *wiphy,
  929. struct station_parameters *params,
  930. enum cfg80211_station_type statype);
  931. /**
  932. * enum station_info_rate_flags - bitrate info flags
  933. *
  934. * Used by the driver to indicate the specific rate transmission
  935. * type for 802.11n transmissions.
  936. *
  937. * @RATE_INFO_FLAGS_MCS: mcs field filled with HT MCS
  938. * @RATE_INFO_FLAGS_VHT_MCS: mcs field filled with VHT MCS
  939. * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval
  940. * @RATE_INFO_FLAGS_60G: 60GHz MCS
  941. */
  942. enum rate_info_flags {
  943. RATE_INFO_FLAGS_MCS = BIT(0),
  944. RATE_INFO_FLAGS_VHT_MCS = BIT(1),
  945. RATE_INFO_FLAGS_SHORT_GI = BIT(2),
  946. RATE_INFO_FLAGS_60G = BIT(3),
  947. };
  948. /**
  949. * enum rate_info_bw - rate bandwidth information
  950. *
  951. * Used by the driver to indicate the rate bandwidth.
  952. *
  953. * @RATE_INFO_BW_5: 5 MHz bandwidth
  954. * @RATE_INFO_BW_10: 10 MHz bandwidth
  955. * @RATE_INFO_BW_20: 20 MHz bandwidth
  956. * @RATE_INFO_BW_40: 40 MHz bandwidth
  957. * @RATE_INFO_BW_80: 80 MHz bandwidth
  958. * @RATE_INFO_BW_160: 160 MHz bandwidth
  959. */
  960. enum rate_info_bw {
  961. RATE_INFO_BW_20 = 0,
  962. RATE_INFO_BW_5,
  963. RATE_INFO_BW_10,
  964. RATE_INFO_BW_40,
  965. RATE_INFO_BW_80,
  966. RATE_INFO_BW_160,
  967. };
  968. /**
  969. * struct rate_info - bitrate information
  970. *
  971. * Information about a receiving or transmitting bitrate
  972. *
  973. * @flags: bitflag of flags from &enum rate_info_flags
  974. * @mcs: mcs index if struct describes a 802.11n bitrate
  975. * @legacy: bitrate in 100kbit/s for 802.11abg
  976. * @nss: number of streams (VHT only)
  977. * @bw: bandwidth (from &enum rate_info_bw)
  978. */
  979. struct rate_info {
  980. u8 flags;
  981. u8 mcs;
  982. u16 legacy;
  983. u8 nss;
  984. u8 bw;
  985. };
  986. /**
  987. * enum station_info_rate_flags - bitrate info flags
  988. *
  989. * Used by the driver to indicate the specific rate transmission
  990. * type for 802.11n transmissions.
  991. *
  992. * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled
  993. * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled
  994. * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled
  995. */
  996. enum bss_param_flags {
  997. BSS_PARAM_FLAGS_CTS_PROT = 1<<0,
  998. BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1,
  999. BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2,
  1000. };
  1001. /**
  1002. * struct sta_bss_parameters - BSS parameters for the attached station
  1003. *
  1004. * Information about the currently associated BSS
  1005. *
  1006. * @flags: bitflag of flags from &enum bss_param_flags
  1007. * @dtim_period: DTIM period for the BSS
  1008. * @beacon_interval: beacon interval
  1009. */
  1010. struct sta_bss_parameters {
  1011. u8 flags;
  1012. u8 dtim_period;
  1013. u16 beacon_interval;
  1014. };
  1015. /**
  1016. * struct cfg80211_tid_stats - per-TID statistics
  1017. * @filled: bitmap of flags using the bits of &enum nl80211_tid_stats to
  1018. * indicate the relevant values in this struct are filled
  1019. * @rx_msdu: number of received MSDUs
  1020. * @tx_msdu: number of (attempted) transmitted MSDUs
  1021. * @tx_msdu_retries: number of retries (not counting the first) for
  1022. * transmitted MSDUs
  1023. * @tx_msdu_failed: number of failed transmitted MSDUs
  1024. */
  1025. struct cfg80211_tid_stats {
  1026. u32 filled;
  1027. u64 rx_msdu;
  1028. u64 tx_msdu;
  1029. u64 tx_msdu_retries;
  1030. u64 tx_msdu_failed;
  1031. };
  1032. #define IEEE80211_MAX_CHAINS 4
  1033. /**
  1034. * struct station_info - station information
  1035. *
  1036. * Station information filled by driver for get_station() and dump_station.
  1037. *
  1038. * @filled: bitflag of flags using the bits of &enum nl80211_sta_info to
  1039. * indicate the relevant values in this struct for them
  1040. * @connected_time: time(in secs) since a station is last connected
  1041. * @inactive_time: time since last station activity (tx/rx) in milliseconds
  1042. * @rx_bytes: bytes (size of MPDUs) received from this station
  1043. * @tx_bytes: bytes (size of MPDUs) transmitted to this station
  1044. * @llid: mesh local link id
  1045. * @plid: mesh peer link id
  1046. * @plink_state: mesh peer link state
  1047. * @signal: The signal strength, type depends on the wiphy's signal_type.
  1048. * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
  1049. * @signal_avg: Average signal strength, type depends on the wiphy's signal_type.
  1050. * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_.
  1051. * @chains: bitmask for filled values in @chain_signal, @chain_signal_avg
  1052. * @chain_signal: per-chain signal strength of last received packet in dBm
  1053. * @chain_signal_avg: per-chain signal strength average in dBm
  1054. * @txrate: current unicast bitrate from this station
  1055. * @rxrate: current unicast bitrate to this station
  1056. * @rx_packets: packets (MSDUs & MMPDUs) received from this station
  1057. * @tx_packets: packets (MSDUs & MMPDUs) transmitted to this station
  1058. * @tx_retries: cumulative retry counts (MPDUs)
  1059. * @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK)
  1060. * @rx_dropped_misc: Dropped for un-specified reason.
  1061. * @bss_param: current BSS parameters
  1062. * @generation: generation number for nl80211 dumps.
  1063. * This number should increase every time the list of stations
  1064. * changes, i.e. when a station is added or removed, so that
  1065. * userspace can tell whether it got a consistent snapshot.
  1066. * @assoc_req_ies: IEs from (Re)Association Request.
  1067. * This is used only when in AP mode with drivers that do not use
  1068. * user space MLME/SME implementation. The information is provided for
  1069. * the cfg80211_new_sta() calls to notify user space of the IEs.
  1070. * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets.
  1071. * @sta_flags: station flags mask & values
  1072. * @beacon_loss_count: Number of times beacon loss event has triggered.
  1073. * @t_offset: Time offset of the station relative to this host.
  1074. * @local_pm: local mesh STA power save mode
  1075. * @peer_pm: peer mesh STA power save mode
  1076. * @nonpeer_pm: non-peer mesh STA power save mode
  1077. * @expected_throughput: expected throughput in kbps (including 802.11 headers)
  1078. * towards this station.
  1079. * @rx_beacon: number of beacons received from this peer
  1080. * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
  1081. * from this peer
  1082. * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
  1083. * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
  1084. * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
  1085. * @ack_signal: signal strength (in dBm) of the last ACK frame.
  1086. */
  1087. struct station_info {
  1088. u64 filled;
  1089. u32 connected_time;
  1090. u32 inactive_time;
  1091. u64 rx_bytes;
  1092. u64 tx_bytes;
  1093. u16 llid;
  1094. u16 plid;
  1095. u8 plink_state;
  1096. s8 signal;
  1097. s8 signal_avg;
  1098. u8 chains;
  1099. s8 chain_signal[IEEE80211_MAX_CHAINS];
  1100. s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
  1101. struct rate_info txrate;
  1102. struct rate_info rxrate;
  1103. u32 rx_packets;
  1104. u32 tx_packets;
  1105. u32 tx_retries;
  1106. u32 tx_failed;
  1107. u32 rx_dropped_misc;
  1108. struct sta_bss_parameters bss_param;
  1109. struct nl80211_sta_flag_update sta_flags;
  1110. int generation;
  1111. const u8 *assoc_req_ies;
  1112. size_t assoc_req_ies_len;
  1113. u32 beacon_loss_count;
  1114. s64 t_offset;
  1115. enum nl80211_mesh_power_mode local_pm;
  1116. enum nl80211_mesh_power_mode peer_pm;
  1117. enum nl80211_mesh_power_mode nonpeer_pm;
  1118. u32 expected_throughput;
  1119. u64 rx_beacon;
  1120. u64 rx_duration;
  1121. u8 rx_beacon_signal_avg;
  1122. struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1];
  1123. s8 ack_signal;
  1124. };
  1125. #if IS_ENABLED(CONFIG_CFG80211)
  1126. /**
  1127. * cfg80211_get_station - retrieve information about a given station
  1128. * @dev: the device where the station is supposed to be connected to
  1129. * @mac_addr: the mac address of the station of interest
  1130. * @sinfo: pointer to the structure to fill with the information
  1131. *
  1132. * Returns 0 on success and sinfo is filled with the available information
  1133. * otherwise returns a negative error code and the content of sinfo has to be
  1134. * considered undefined.
  1135. */
  1136. int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
  1137. struct station_info *sinfo);
  1138. #else
  1139. static inline int cfg80211_get_station(struct net_device *dev,
  1140. const u8 *mac_addr,
  1141. struct station_info *sinfo)
  1142. {
  1143. return -ENOENT;
  1144. }
  1145. #endif
  1146. /**
  1147. * enum monitor_flags - monitor flags
  1148. *
  1149. * Monitor interface configuration flags. Note that these must be the bits
  1150. * according to the nl80211 flags.
  1151. *
  1152. * @MONITOR_FLAG_CHANGED: set if the flags were changed
  1153. * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
  1154. * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
  1155. * @MONITOR_FLAG_CONTROL: pass control frames
  1156. * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
  1157. * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
  1158. * @MONITOR_FLAG_ACTIVE: active monitor, ACKs frames on its MAC address
  1159. */
  1160. enum monitor_flags {
  1161. MONITOR_FLAG_CHANGED = 1<<__NL80211_MNTR_FLAG_INVALID,
  1162. MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
  1163. MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
  1164. MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
  1165. MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
  1166. MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
  1167. MONITOR_FLAG_ACTIVE = 1<<NL80211_MNTR_FLAG_ACTIVE,
  1168. };
  1169. /**
  1170. * enum mpath_info_flags - mesh path information flags
  1171. *
  1172. * Used by the driver to indicate which info in &struct mpath_info it has filled
  1173. * in during get_station() or dump_station().
  1174. *
  1175. * @MPATH_INFO_FRAME_QLEN: @frame_qlen filled
  1176. * @MPATH_INFO_SN: @sn filled
  1177. * @MPATH_INFO_METRIC: @metric filled
  1178. * @MPATH_INFO_EXPTIME: @exptime filled
  1179. * @MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
  1180. * @MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
  1181. * @MPATH_INFO_FLAGS: @flags filled
  1182. */
  1183. enum mpath_info_flags {
  1184. MPATH_INFO_FRAME_QLEN = BIT(0),
  1185. MPATH_INFO_SN = BIT(1),
  1186. MPATH_INFO_METRIC = BIT(2),
  1187. MPATH_INFO_EXPTIME = BIT(3),
  1188. MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
  1189. MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
  1190. MPATH_INFO_FLAGS = BIT(6),
  1191. };
  1192. /**
  1193. * struct mpath_info - mesh path information
  1194. *
  1195. * Mesh path information filled by driver for get_mpath() and dump_mpath().
  1196. *
  1197. * @filled: bitfield of flags from &enum mpath_info_flags
  1198. * @frame_qlen: number of queued frames for this destination
  1199. * @sn: target sequence number
  1200. * @metric: metric (cost) of this mesh path
  1201. * @exptime: expiration time for the mesh path from now, in msecs
  1202. * @flags: mesh path flags
  1203. * @discovery_timeout: total mesh path discovery timeout, in msecs
  1204. * @discovery_retries: mesh path discovery retries
  1205. * @generation: generation number for nl80211 dumps.
  1206. * This number should increase every time the list of mesh paths
  1207. * changes, i.e. when a station is added or removed, so that
  1208. * userspace can tell whether it got a consistent snapshot.
  1209. */
  1210. struct mpath_info {
  1211. u32 filled;
  1212. u32 frame_qlen;
  1213. u32 sn;
  1214. u32 metric;
  1215. u32 exptime;
  1216. u32 discovery_timeout;
  1217. u8 discovery_retries;
  1218. u8 flags;
  1219. int generation;
  1220. };
  1221. /**
  1222. * struct bss_parameters - BSS parameters
  1223. *
  1224. * Used to change BSS parameters (mainly for AP mode).
  1225. *
  1226. * @use_cts_prot: Whether to use CTS protection
  1227. * (0 = no, 1 = yes, -1 = do not change)
  1228. * @use_short_preamble: Whether the use of short preambles is allowed
  1229. * (0 = no, 1 = yes, -1 = do not change)
  1230. * @use_short_slot_time: Whether the use of short slot time is allowed
  1231. * (0 = no, 1 = yes, -1 = do not change)
  1232. * @basic_rates: basic rates in IEEE 802.11 format
  1233. * (or NULL for no change)
  1234. * @basic_rates_len: number of basic rates
  1235. * @ap_isolate: do not forward packets between connected stations
  1236. * @ht_opmode: HT Operation mode
  1237. * (u16 = opmode, -1 = do not change)
  1238. * @p2p_ctwindow: P2P CT Window (-1 = no change)
  1239. * @p2p_opp_ps: P2P opportunistic PS (-1 = no change)
  1240. */
  1241. struct bss_parameters {
  1242. int use_cts_prot;
  1243. int use_short_preamble;
  1244. int use_short_slot_time;
  1245. const u8 *basic_rates;
  1246. u8 basic_rates_len;
  1247. int ap_isolate;
  1248. int ht_opmode;
  1249. s8 p2p_ctwindow, p2p_opp_ps;
  1250. };
  1251. /**
  1252. * struct mesh_config - 802.11s mesh configuration
  1253. *
  1254. * These parameters can be changed while the mesh is active.
  1255. *
  1256. * @dot11MeshRetryTimeout: the initial retry timeout in millisecond units used
  1257. * by the Mesh Peering Open message
  1258. * @dot11MeshConfirmTimeout: the initial retry timeout in millisecond units
  1259. * used by the Mesh Peering Open message
  1260. * @dot11MeshHoldingTimeout: the confirm timeout in millisecond units used by
  1261. * the mesh peering management to close a mesh peering
  1262. * @dot11MeshMaxPeerLinks: the maximum number of peer links allowed on this
  1263. * mesh interface
  1264. * @dot11MeshMaxRetries: the maximum number of peer link open retries that can
  1265. * be sent to establish a new peer link instance in a mesh
  1266. * @dot11MeshTTL: the value of TTL field set at a source mesh STA
  1267. * @element_ttl: the value of TTL field set at a mesh STA for path selection
  1268. * elements
  1269. * @auto_open_plinks: whether we should automatically open peer links when we
  1270. * detect compatible mesh peers
  1271. * @dot11MeshNbrOffsetMaxNeighbor: the maximum number of neighbors to
  1272. * synchronize to for 11s default synchronization method
  1273. * @dot11MeshHWMPmaxPREQretries: the number of action frames containing a PREQ
  1274. * that an originator mesh STA can send to a particular path target
  1275. * @path_refresh_time: how frequently to refresh mesh paths in milliseconds
  1276. * @min_discovery_timeout: the minimum length of time to wait until giving up on
  1277. * a path discovery in milliseconds
  1278. * @dot11MeshHWMPactivePathTimeout: the time (in TUs) for which mesh STAs
  1279. * receiving a PREQ shall consider the forwarding information from the
  1280. * root to be valid. (TU = time unit)
  1281. * @dot11MeshHWMPpreqMinInterval: the minimum interval of time (in TUs) during
  1282. * which a mesh STA can send only one action frame containing a PREQ
  1283. * element
  1284. * @dot11MeshHWMPperrMinInterval: the minimum interval of time (in TUs) during
  1285. * which a mesh STA can send only one Action frame containing a PERR
  1286. * element
  1287. * @dot11MeshHWMPnetDiameterTraversalTime: the interval of time (in TUs) that
  1288. * it takes for an HWMP information element to propagate across the mesh
  1289. * @dot11MeshHWMPRootMode: the configuration of a mesh STA as root mesh STA
  1290. * @dot11MeshHWMPRannInterval: the interval of time (in TUs) between root
  1291. * announcements are transmitted
  1292. * @dot11MeshGateAnnouncementProtocol: whether to advertise that this mesh
  1293. * station has access to a broader network beyond the MBSS. (This is
  1294. * missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol set to true
  1295. * only means that the station will announce others it's a mesh gate, but
  1296. * not necessarily using the gate announcement protocol. Still keeping the
  1297. * same nomenclature to be in sync with the spec)
  1298. * @dot11MeshForwarding: whether the Mesh STA is forwarding or non-forwarding
  1299. * entity (default is TRUE - forwarding entity)
  1300. * @rssi_threshold: the threshold for average signal strength of candidate
  1301. * station to establish a peer link
  1302. * @ht_opmode: mesh HT protection mode
  1303. *
  1304. * @dot11MeshHWMPactivePathToRootTimeout: The time (in TUs) for which mesh STAs
  1305. * receiving a proactive PREQ shall consider the forwarding information to
  1306. * the root mesh STA to be valid.
  1307. *
  1308. * @dot11MeshHWMProotInterval: The interval of time (in TUs) between proactive
  1309. * PREQs are transmitted.
  1310. * @dot11MeshHWMPconfirmationInterval: The minimum interval of time (in TUs)
  1311. * during which a mesh STA can send only one Action frame containing
  1312. * a PREQ element for root path confirmation.
  1313. * @power_mode: The default mesh power save mode which will be the initial
  1314. * setting for new peer links.
  1315. * @dot11MeshAwakeWindowDuration: The duration in TUs the STA will remain awake
  1316. * after transmitting its beacon.
  1317. * @plink_timeout: If no tx activity is seen from a STA we've established
  1318. * peering with for longer than this time (in seconds), then remove it
  1319. * from the STA's list of peers. Default is 30 minutes.
  1320. */
  1321. struct mesh_config {
  1322. u16 dot11MeshRetryTimeout;
  1323. u16 dot11MeshConfirmTimeout;
  1324. u16 dot11MeshHoldingTimeout;
  1325. u16 dot11MeshMaxPeerLinks;
  1326. u8 dot11MeshMaxRetries;
  1327. u8 dot11MeshTTL;
  1328. u8 element_ttl;
  1329. bool auto_open_plinks;
  1330. u32 dot11MeshNbrOffsetMaxNeighbor;
  1331. u8 dot11MeshHWMPmaxPREQretries;
  1332. u32 path_refresh_time;
  1333. u16 min_discovery_timeout;
  1334. u32 dot11MeshHWMPactivePathTimeout;
  1335. u16 dot11MeshHWMPpreqMinInterval;
  1336. u16 dot11MeshHWMPperrMinInterval;
  1337. u16 dot11MeshHWMPnetDiameterTraversalTime;
  1338. u8 dot11MeshHWMPRootMode;
  1339. u16 dot11MeshHWMPRannInterval;
  1340. bool dot11MeshGateAnnouncementProtocol;
  1341. bool dot11MeshForwarding;
  1342. s32 rssi_threshold;
  1343. u16 ht_opmode;
  1344. u32 dot11MeshHWMPactivePathToRootTimeout;
  1345. u16 dot11MeshHWMProotInterval;
  1346. u16 dot11MeshHWMPconfirmationInterval;
  1347. enum nl80211_mesh_power_mode power_mode;
  1348. u16 dot11MeshAwakeWindowDuration;
  1349. u32 plink_timeout;
  1350. };
  1351. /**
  1352. * struct mesh_setup - 802.11s mesh setup configuration
  1353. * @chandef: defines the channel to use
  1354. * @mesh_id: the mesh ID
  1355. * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes
  1356. * @sync_method: which synchronization method to use
  1357. * @path_sel_proto: which path selection protocol to use
  1358. * @path_metric: which metric to use
  1359. * @auth_id: which authentication method this mesh is using
  1360. * @ie: vendor information elements (optional)
  1361. * @ie_len: length of vendor information elements
  1362. * @is_authenticated: this mesh requires authentication
  1363. * @is_secure: this mesh uses security
  1364. * @user_mpm: userspace handles all MPM functions
  1365. * @dtim_period: DTIM period to use
  1366. * @beacon_interval: beacon interval to use
  1367. * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a]
  1368. * @basic_rates: basic rates to use when creating the mesh
  1369. * @beacon_rate: bitrate to be used for beacons
  1370. * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  1371. * changes the channel when a radar is detected. This is required
  1372. * to operate on DFS channels.
  1373. *
  1374. * These parameters are fixed when the mesh is created.
  1375. */
  1376. struct mesh_setup {
  1377. struct cfg80211_chan_def chandef;
  1378. const u8 *mesh_id;
  1379. u8 mesh_id_len;
  1380. u8 sync_method;
  1381. u8 path_sel_proto;
  1382. u8 path_metric;
  1383. u8 auth_id;
  1384. const u8 *ie;
  1385. u8 ie_len;
  1386. bool is_authenticated;
  1387. bool is_secure;
  1388. bool user_mpm;
  1389. u8 dtim_period;
  1390. u16 beacon_interval;
  1391. int mcast_rate[NUM_NL80211_BANDS];
  1392. u32 basic_rates;
  1393. struct cfg80211_bitrate_mask beacon_rate;
  1394. bool userspace_handles_dfs;
  1395. };
  1396. /**
  1397. * struct ocb_setup - 802.11p OCB mode setup configuration
  1398. * @chandef: defines the channel to use
  1399. *
  1400. * These parameters are fixed when connecting to the network
  1401. */
  1402. struct ocb_setup {
  1403. struct cfg80211_chan_def chandef;
  1404. };
  1405. /**
  1406. * struct ieee80211_txq_params - TX queue parameters
  1407. * @ac: AC identifier
  1408. * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
  1409. * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
  1410. * 1..32767]
  1411. * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
  1412. * 1..32767]
  1413. * @aifs: Arbitration interframe space [0..255]
  1414. */
  1415. struct ieee80211_txq_params {
  1416. enum nl80211_ac ac;
  1417. u16 txop;
  1418. u16 cwmin;
  1419. u16 cwmax;
  1420. u8 aifs;
  1421. };
  1422. /**
  1423. * DOC: Scanning and BSS list handling
  1424. *
  1425. * The scanning process itself is fairly simple, but cfg80211 offers quite
  1426. * a bit of helper functionality. To start a scan, the scan operation will
  1427. * be invoked with a scan definition. This scan definition contains the
  1428. * channels to scan, and the SSIDs to send probe requests for (including the
  1429. * wildcard, if desired). A passive scan is indicated by having no SSIDs to
  1430. * probe. Additionally, a scan request may contain extra information elements
  1431. * that should be added to the probe request. The IEs are guaranteed to be
  1432. * well-formed, and will not exceed the maximum length the driver advertised
  1433. * in the wiphy structure.
  1434. *
  1435. * When scanning finds a BSS, cfg80211 needs to be notified of that, because
  1436. * it is responsible for maintaining the BSS list; the driver should not
  1437. * maintain a list itself. For this notification, various functions exist.
  1438. *
  1439. * Since drivers do not maintain a BSS list, there are also a number of
  1440. * functions to search for a BSS and obtain information about it from the
  1441. * BSS structure cfg80211 maintains. The BSS list is also made available
  1442. * to userspace.
  1443. */
  1444. /**
  1445. * struct cfg80211_ssid - SSID description
  1446. * @ssid: the SSID
  1447. * @ssid_len: length of the ssid
  1448. */
  1449. struct cfg80211_ssid {
  1450. u8 ssid[IEEE80211_MAX_SSID_LEN];
  1451. u8 ssid_len;
  1452. };
  1453. /**
  1454. * struct cfg80211_scan_info - information about completed scan
  1455. * @scan_start_tsf: scan start time in terms of the TSF of the BSS that the
  1456. * wireless device that requested the scan is connected to. If this
  1457. * information is not available, this field is left zero.
  1458. * @tsf_bssid: the BSSID according to which %scan_start_tsf is set.
  1459. * @aborted: set to true if the scan was aborted for any reason,
  1460. * userspace will be notified of that
  1461. */
  1462. struct cfg80211_scan_info {
  1463. u64 scan_start_tsf;
  1464. u8 tsf_bssid[ETH_ALEN] __aligned(2);
  1465. bool aborted;
  1466. };
  1467. /**
  1468. * struct cfg80211_scan_request - scan request description
  1469. *
  1470. * @ssids: SSIDs to scan for (active scan only)
  1471. * @n_ssids: number of SSIDs
  1472. * @channels: channels to scan on.
  1473. * @n_channels: total number of channels to scan
  1474. * @scan_width: channel width for scanning
  1475. * @ie: optional information element(s) to add into Probe Request or %NULL
  1476. * @ie_len: length of ie in octets
  1477. * @duration: how long to listen on each channel, in TUs. If
  1478. * %duration_mandatory is not set, this is the maximum dwell time and
  1479. * the actual dwell time may be shorter.
  1480. * @duration_mandatory: if set, the scan duration must be as specified by the
  1481. * %duration field.
  1482. * @flags: bit field of flags controlling operation
  1483. * @rates: bitmap of rates to advertise for each band
  1484. * @wiphy: the wiphy this was for
  1485. * @scan_start: time (in jiffies) when the scan started
  1486. * @wdev: the wireless device to scan for
  1487. * @info: (internal) information about completed scan
  1488. * @notified: (internal) scan request was notified as done or aborted
  1489. * @no_cck: used to send probe requests at non CCK rate in 2GHz band
  1490. * @mac_addr: MAC address used with randomisation
  1491. * @mac_addr_mask: MAC address mask used with randomisation, bits that
  1492. * are 0 in the mask should be randomised, bits that are 1 should
  1493. * be taken from the @mac_addr
  1494. * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
  1495. */
  1496. struct cfg80211_scan_request {
  1497. struct cfg80211_ssid *ssids;
  1498. int n_ssids;
  1499. u32 n_channels;
  1500. enum nl80211_bss_scan_width scan_width;
  1501. const u8 *ie;
  1502. size_t ie_len;
  1503. u16 duration;
  1504. bool duration_mandatory;
  1505. u32 flags;
  1506. u32 rates[NUM_NL80211_BANDS];
  1507. struct wireless_dev *wdev;
  1508. u8 mac_addr[ETH_ALEN] __aligned(2);
  1509. u8 mac_addr_mask[ETH_ALEN] __aligned(2);
  1510. u8 bssid[ETH_ALEN] __aligned(2);
  1511. /* internal */
  1512. struct wiphy *wiphy;
  1513. unsigned long scan_start;
  1514. struct cfg80211_scan_info info;
  1515. bool notified;
  1516. bool no_cck;
  1517. /* keep last */
  1518. struct ieee80211_channel *channels[0];
  1519. };
  1520. static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
  1521. {
  1522. int i;
  1523. get_random_bytes(buf, ETH_ALEN);
  1524. for (i = 0; i < ETH_ALEN; i++) {
  1525. buf[i] &= ~mask[i];
  1526. buf[i] |= addr[i] & mask[i];
  1527. }
  1528. }
  1529. /**
  1530. * struct cfg80211_match_set - sets of attributes to match
  1531. *
  1532. * @ssid: SSID to be matched; may be zero-length in case of BSSID match
  1533. * or no match (RSSI only)
  1534. * @bssid: BSSID to be matched; may be all-zero BSSID in case of SSID match
  1535. * or no match (RSSI only)
  1536. * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  1537. */
  1538. struct cfg80211_match_set {
  1539. struct cfg80211_ssid ssid;
  1540. u8 bssid[ETH_ALEN];
  1541. s32 rssi_thold;
  1542. };
  1543. /**
  1544. * struct cfg80211_sched_scan_plan - scan plan for scheduled scan
  1545. *
  1546. * @interval: interval between scheduled scan iterations. In seconds.
  1547. * @iterations: number of scan iterations in this scan plan. Zero means
  1548. * infinite loop.
  1549. * The last scan plan will always have this parameter set to zero,
  1550. * all other scan plans will have a finite number of iterations.
  1551. */
  1552. struct cfg80211_sched_scan_plan {
  1553. u32 interval;
  1554. u32 iterations;
  1555. };
  1556. /**
  1557. * struct cfg80211_bss_select_adjust - BSS selection with RSSI adjustment.
  1558. *
  1559. * @band: band of BSS which should match for RSSI level adjustment.
  1560. * @delta: value of RSSI level adjustment.
  1561. */
  1562. struct cfg80211_bss_select_adjust {
  1563. enum nl80211_band band;
  1564. s8 delta;
  1565. };
  1566. /**
  1567. * struct cfg80211_sched_scan_request - scheduled scan request description
  1568. *
  1569. * @reqid: identifies this request.
  1570. * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans)
  1571. * @n_ssids: number of SSIDs
  1572. * @n_channels: total number of channels to scan
  1573. * @scan_width: channel width for scanning
  1574. * @ie: optional information element(s) to add into Probe Request or %NULL
  1575. * @ie_len: length of ie in octets
  1576. * @flags: bit field of flags controlling operation
  1577. * @match_sets: sets of parameters to be matched for a scan result
  1578. * entry to be considered valid and to be passed to the host
  1579. * (others are filtered out).
  1580. * If ommited, all results are passed.
  1581. * @n_match_sets: number of match sets
  1582. * @report_results: indicates that results were reported for this request
  1583. * @wiphy: the wiphy this was for
  1584. * @dev: the interface
  1585. * @scan_start: start time of the scheduled scan
  1586. * @channels: channels to scan
  1587. * @min_rssi_thold: for drivers only supporting a single threshold, this
  1588. * contains the minimum over all matchsets
  1589. * @mac_addr: MAC address used with randomisation
  1590. * @mac_addr_mask: MAC address mask used with randomisation, bits that
  1591. * are 0 in the mask should be randomised, bits that are 1 should
  1592. * be taken from the @mac_addr
  1593. * @scan_plans: scan plans to be executed in this scheduled scan. Lowest
  1594. * index must be executed first.
  1595. * @n_scan_plans: number of scan plans, at least 1.
  1596. * @rcu_head: RCU callback used to free the struct
  1597. * @owner_nlportid: netlink portid of owner (if this should is a request
  1598. * owned by a particular socket)
  1599. * @nl_owner_dead: netlink owner socket was closed - this request be freed
  1600. * @list: for keeping list of requests.
  1601. * @delay: delay in seconds to use before starting the first scan
  1602. * cycle. The driver may ignore this parameter and start
  1603. * immediately (or at any other time), if this feature is not
  1604. * supported.
  1605. * @relative_rssi_set: Indicates whether @relative_rssi is set or not.
  1606. * @relative_rssi: Relative RSSI threshold in dB to restrict scan result
  1607. * reporting in connected state to cases where a matching BSS is determined
  1608. * to have better or slightly worse RSSI than the current connected BSS.
  1609. * The relative RSSI threshold values are ignored in disconnected state.
  1610. * @rssi_adjust: delta dB of RSSI preference to be given to the BSSs that belong
  1611. * to the specified band while deciding whether a better BSS is reported
  1612. * using @relative_rssi. If delta is a negative number, the BSSs that
  1613. * belong to the specified band will be penalized by delta dB in relative
  1614. * comparisions.
  1615. */
  1616. struct cfg80211_sched_scan_request {
  1617. u64 reqid;
  1618. struct cfg80211_ssid *ssids;
  1619. int n_ssids;
  1620. u32 n_channels;
  1621. enum nl80211_bss_scan_width scan_width;
  1622. const u8 *ie;
  1623. size_t ie_len;
  1624. u32 flags;
  1625. struct cfg80211_match_set *match_sets;
  1626. int n_match_sets;
  1627. s32 min_rssi_thold;
  1628. u32 delay;
  1629. struct cfg80211_sched_scan_plan *scan_plans;
  1630. int n_scan_plans;
  1631. u8 mac_addr[ETH_ALEN] __aligned(2);
  1632. u8 mac_addr_mask[ETH_ALEN] __aligned(2);
  1633. bool relative_rssi_set;
  1634. s8 relative_rssi;
  1635. struct cfg80211_bss_select_adjust rssi_adjust;
  1636. /* internal */
  1637. struct wiphy *wiphy;
  1638. struct net_device *dev;
  1639. unsigned long scan_start;
  1640. bool report_results;
  1641. struct rcu_head rcu_head;
  1642. u32 owner_nlportid;
  1643. bool nl_owner_dead;
  1644. struct list_head list;
  1645. /* keep last */
  1646. struct ieee80211_channel *channels[0];
  1647. };
  1648. /**
  1649. * enum cfg80211_signal_type - signal type
  1650. *
  1651. * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available
  1652. * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm)
  1653. * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100
  1654. */
  1655. enum cfg80211_signal_type {
  1656. CFG80211_SIGNAL_TYPE_NONE,
  1657. CFG80211_SIGNAL_TYPE_MBM,
  1658. CFG80211_SIGNAL_TYPE_UNSPEC,
  1659. };
  1660. /**
  1661. * struct cfg80211_inform_bss - BSS inform data
  1662. * @chan: channel the frame was received on
  1663. * @scan_width: scan width that was used
  1664. * @signal: signal strength value, according to the wiphy's
  1665. * signal type
  1666. * @boottime_ns: timestamp (CLOCK_BOOTTIME) when the information was
  1667. * received; should match the time when the frame was actually
  1668. * received by the device (not just by the host, in case it was
  1669. * buffered on the device) and be accurate to about 10ms.
  1670. * If the frame isn't buffered, just passing the return value of
  1671. * ktime_get_boot_ns() is likely appropriate.
  1672. * @parent_tsf: the time at the start of reception of the first octet of the
  1673. * timestamp field of the frame. The time is the TSF of the BSS specified
  1674. * by %parent_bssid.
  1675. * @parent_bssid: the BSS according to which %parent_tsf is set. This is set to
  1676. * the BSS that requested the scan in which the beacon/probe was received.
  1677. * @chains: bitmask for filled values in @chain_signal.
  1678. * @chain_signal: per-chain signal strength of last received BSS in dBm.
  1679. */
  1680. struct cfg80211_inform_bss {
  1681. struct ieee80211_channel *chan;
  1682. enum nl80211_bss_scan_width scan_width;
  1683. s32 signal;
  1684. u64 boottime_ns;
  1685. u64 parent_tsf;
  1686. u8 parent_bssid[ETH_ALEN] __aligned(2);
  1687. u8 chains;
  1688. s8 chain_signal[IEEE80211_MAX_CHAINS];
  1689. };
  1690. /**
  1691. * struct cfg80211_bss_ies - BSS entry IE data
  1692. * @tsf: TSF contained in the frame that carried these IEs
  1693. * @rcu_head: internal use, for freeing
  1694. * @len: length of the IEs
  1695. * @from_beacon: these IEs are known to come from a beacon
  1696. * @data: IE data
  1697. */
  1698. struct cfg80211_bss_ies {
  1699. u64 tsf;
  1700. struct rcu_head rcu_head;
  1701. int len;
  1702. bool from_beacon;
  1703. u8 data[];
  1704. };
  1705. /**
  1706. * struct cfg80211_bss - BSS description
  1707. *
  1708. * This structure describes a BSS (which may also be a mesh network)
  1709. * for use in scan results and similar.
  1710. *
  1711. * @channel: channel this BSS is on
  1712. * @scan_width: width of the control channel
  1713. * @bssid: BSSID of the BSS
  1714. * @beacon_interval: the beacon interval as from the frame
  1715. * @capability: the capability field in host byte order
  1716. * @ies: the information elements (Note that there is no guarantee that these
  1717. * are well-formed!); this is a pointer to either the beacon_ies or
  1718. * proberesp_ies depending on whether Probe Response frame has been
  1719. * received. It is always non-%NULL.
  1720. * @beacon_ies: the information elements from the last Beacon frame
  1721. * (implementation note: if @hidden_beacon_bss is set this struct doesn't
  1722. * own the beacon_ies, but they're just pointers to the ones from the
  1723. * @hidden_beacon_bss struct)
  1724. * @proberesp_ies: the information elements from the last Probe Response frame
  1725. * @hidden_beacon_bss: in case this BSS struct represents a probe response from
  1726. * a BSS that hides the SSID in its beacon, this points to the BSS struct
  1727. * that holds the beacon data. @beacon_ies is still valid, of course, and
  1728. * points to the same data as hidden_beacon_bss->beacon_ies in that case.
  1729. * @signal: signal strength value (type depends on the wiphy's signal_type)
  1730. * @chains: bitmask for filled values in @chain_signal.
  1731. * @chain_signal: per-chain signal strength of last received BSS in dBm.
  1732. * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes
  1733. */
  1734. struct cfg80211_bss {
  1735. struct ieee80211_channel *channel;
  1736. enum nl80211_bss_scan_width scan_width;
  1737. const struct cfg80211_bss_ies __rcu *ies;
  1738. const struct cfg80211_bss_ies __rcu *beacon_ies;
  1739. const struct cfg80211_bss_ies __rcu *proberesp_ies;
  1740. struct cfg80211_bss *hidden_beacon_bss;
  1741. s32 signal;
  1742. u16 beacon_interval;
  1743. u16 capability;
  1744. u8 bssid[ETH_ALEN];
  1745. u8 chains;
  1746. s8 chain_signal[IEEE80211_MAX_CHAINS];
  1747. u8 priv[0] __aligned(sizeof(void *));
  1748. };
  1749. /**
  1750. * ieee80211_bss_get_ie - find IE with given ID
  1751. * @bss: the bss to search
  1752. * @ie: the IE ID
  1753. *
  1754. * Note that the return value is an RCU-protected pointer, so
  1755. * rcu_read_lock() must be held when calling this function.
  1756. * Return: %NULL if not found.
  1757. */
  1758. const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie);
  1759. /**
  1760. * struct cfg80211_auth_request - Authentication request data
  1761. *
  1762. * This structure provides information needed to complete IEEE 802.11
  1763. * authentication.
  1764. *
  1765. * @bss: The BSS to authenticate with, the callee must obtain a reference
  1766. * to it if it needs to keep it.
  1767. * @auth_type: Authentication type (algorithm)
  1768. * @ie: Extra IEs to add to Authentication frame or %NULL
  1769. * @ie_len: Length of ie buffer in octets
  1770. * @key_len: length of WEP key for shared key authentication
  1771. * @key_idx: index of WEP key for shared key authentication
  1772. * @key: WEP key for shared key authentication
  1773. * @auth_data: Fields and elements in Authentication frames. This contains
  1774. * the authentication frame body (non-IE and IE data), excluding the
  1775. * Authentication algorithm number, i.e., starting at the Authentication
  1776. * transaction sequence number field.
  1777. * @auth_data_len: Length of auth_data buffer in octets
  1778. */
  1779. struct cfg80211_auth_request {
  1780. struct cfg80211_bss *bss;
  1781. const u8 *ie;
  1782. size_t ie_len;
  1783. enum nl80211_auth_type auth_type;
  1784. const u8 *key;
  1785. u8 key_len, key_idx;
  1786. const u8 *auth_data;
  1787. size_t auth_data_len;
  1788. };
  1789. /**
  1790. * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association.
  1791. *
  1792. * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n)
  1793. * @ASSOC_REQ_DISABLE_VHT: Disable VHT
  1794. * @ASSOC_REQ_USE_RRM: Declare RRM capability in this association
  1795. * @CONNECT_REQ_EXTERNAL_AUTH_SUPPORT: User space indicates external
  1796. * authentication capability. Drivers can offload authentication to
  1797. * userspace if this flag is set. Only applicable for cfg80211_connect()
  1798. * request (connect callback).
  1799. */
  1800. enum cfg80211_assoc_req_flags {
  1801. ASSOC_REQ_DISABLE_HT = BIT(0),
  1802. ASSOC_REQ_DISABLE_VHT = BIT(1),
  1803. ASSOC_REQ_USE_RRM = BIT(2),
  1804. CONNECT_REQ_EXTERNAL_AUTH_SUPPORT = BIT(3),
  1805. };
  1806. /**
  1807. * struct cfg80211_assoc_request - (Re)Association request data
  1808. *
  1809. * This structure provides information needed to complete IEEE 802.11
  1810. * (re)association.
  1811. * @bss: The BSS to associate with. If the call is successful the driver is
  1812. * given a reference that it must give back to cfg80211_send_rx_assoc()
  1813. * or to cfg80211_assoc_timeout(). To ensure proper refcounting, new
  1814. * association requests while already associating must be rejected.
  1815. * @ie: Extra IEs to add to (Re)Association Request frame or %NULL
  1816. * @ie_len: Length of ie buffer in octets
  1817. * @use_mfp: Use management frame protection (IEEE 802.11w) in this association
  1818. * @crypto: crypto settings
  1819. * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
  1820. * to indicate a request to reassociate within the ESS instead of a request
  1821. * do the initial association with the ESS. When included, this is set to
  1822. * the BSSID of the current association, i.e., to the value that is
  1823. * included in the Current AP address field of the Reassociation Request
  1824. * frame.
  1825. * @flags: See &enum cfg80211_assoc_req_flags
  1826. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  1827. * will be used in ht_capa. Un-supported values will be ignored.
  1828. * @ht_capa_mask: The bits of ht_capa which are to be used.
  1829. * @vht_capa: VHT capability override
  1830. * @vht_capa_mask: VHT capability mask indicating which fields to use
  1831. * @fils_kek: FILS KEK for protecting (Re)Association Request/Response frame or
  1832. * %NULL if FILS is not used.
  1833. * @fils_kek_len: Length of fils_kek in octets
  1834. * @fils_nonces: FILS nonces (part of AAD) for protecting (Re)Association
  1835. * Request/Response frame or %NULL if FILS is not used. This field starts
  1836. * with 16 octets of STA Nonce followed by 16 octets of AP Nonce.
  1837. */
  1838. struct cfg80211_assoc_request {
  1839. struct cfg80211_bss *bss;
  1840. const u8 *ie, *prev_bssid;
  1841. size_t ie_len;
  1842. struct cfg80211_crypto_settings crypto;
  1843. bool use_mfp;
  1844. u32 flags;
  1845. struct ieee80211_ht_cap ht_capa;
  1846. struct ieee80211_ht_cap ht_capa_mask;
  1847. struct ieee80211_vht_cap vht_capa, vht_capa_mask;
  1848. const u8 *fils_kek;
  1849. size_t fils_kek_len;
  1850. const u8 *fils_nonces;
  1851. };
  1852. /**
  1853. * struct cfg80211_deauth_request - Deauthentication request data
  1854. *
  1855. * This structure provides information needed to complete IEEE 802.11
  1856. * deauthentication.
  1857. *
  1858. * @bssid: the BSSID of the BSS to deauthenticate from
  1859. * @ie: Extra IEs to add to Deauthentication frame or %NULL
  1860. * @ie_len: Length of ie buffer in octets
  1861. * @reason_code: The reason code for the deauthentication
  1862. * @local_state_change: if set, change local state only and
  1863. * do not set a deauth frame
  1864. */
  1865. struct cfg80211_deauth_request {
  1866. const u8 *bssid;
  1867. const u8 *ie;
  1868. size_t ie_len;
  1869. u16 reason_code;
  1870. bool local_state_change;
  1871. };
  1872. /**
  1873. * struct cfg80211_disassoc_request - Disassociation request data
  1874. *
  1875. * This structure provides information needed to complete IEEE 802.11
  1876. * disassociation.
  1877. *
  1878. * @bss: the BSS to disassociate from
  1879. * @ie: Extra IEs to add to Disassociation frame or %NULL
  1880. * @ie_len: Length of ie buffer in octets
  1881. * @reason_code: The reason code for the disassociation
  1882. * @local_state_change: This is a request for a local state only, i.e., no
  1883. * Disassociation frame is to be transmitted.
  1884. */
  1885. struct cfg80211_disassoc_request {
  1886. struct cfg80211_bss *bss;
  1887. const u8 *ie;
  1888. size_t ie_len;
  1889. u16 reason_code;
  1890. bool local_state_change;
  1891. };
  1892. /**
  1893. * struct cfg80211_ibss_params - IBSS parameters
  1894. *
  1895. * This structure defines the IBSS parameters for the join_ibss()
  1896. * method.
  1897. *
  1898. * @ssid: The SSID, will always be non-null.
  1899. * @ssid_len: The length of the SSID, will always be non-zero.
  1900. * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not
  1901. * search for IBSSs with a different BSSID.
  1902. * @chandef: defines the channel to use if no other IBSS to join can be found
  1903. * @channel_fixed: The channel should be fixed -- do not search for
  1904. * IBSSs to join on other channels.
  1905. * @ie: information element(s) to include in the beacon
  1906. * @ie_len: length of that
  1907. * @beacon_interval: beacon interval to use
  1908. * @privacy: this is a protected network, keys will be configured
  1909. * after joining
  1910. * @control_port: whether user space controls IEEE 802.1X port, i.e.,
  1911. * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  1912. * required to assume that the port is unauthorized until authorized by
  1913. * user space. Otherwise, port is marked authorized by default.
  1914. * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  1915. * changes the channel when a radar is detected. This is required
  1916. * to operate on DFS channels.
  1917. * @basic_rates: bitmap of basic rates to use when creating the IBSS
  1918. * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
  1919. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  1920. * will be used in ht_capa. Un-supported values will be ignored.
  1921. * @ht_capa_mask: The bits of ht_capa which are to be used.
  1922. * @wep_keys: static WEP keys, if not NULL points to an array of
  1923. * CFG80211_MAX_WEP_KEYS WEP keys
  1924. * @wep_tx_key: key index (0..3) of the default TX static WEP key
  1925. */
  1926. struct cfg80211_ibss_params {
  1927. const u8 *ssid;
  1928. const u8 *bssid;
  1929. struct cfg80211_chan_def chandef;
  1930. const u8 *ie;
  1931. u8 ssid_len, ie_len;
  1932. u16 beacon_interval;
  1933. u32 basic_rates;
  1934. bool channel_fixed;
  1935. bool privacy;
  1936. bool control_port;
  1937. bool userspace_handles_dfs;
  1938. int mcast_rate[NUM_NL80211_BANDS];
  1939. struct ieee80211_ht_cap ht_capa;
  1940. struct ieee80211_ht_cap ht_capa_mask;
  1941. struct key_params *wep_keys;
  1942. int wep_tx_key;
  1943. };
  1944. /**
  1945. * struct cfg80211_bss_selection - connection parameters for BSS selection.
  1946. *
  1947. * @behaviour: requested BSS selection behaviour.
  1948. * @param: parameters for requestion behaviour.
  1949. * @band_pref: preferred band for %NL80211_BSS_SELECT_ATTR_BAND_PREF.
  1950. * @adjust: parameters for %NL80211_BSS_SELECT_ATTR_RSSI_ADJUST.
  1951. */
  1952. struct cfg80211_bss_selection {
  1953. enum nl80211_bss_select_attr behaviour;
  1954. union {
  1955. enum nl80211_band band_pref;
  1956. struct cfg80211_bss_select_adjust adjust;
  1957. } param;
  1958. };
  1959. /**
  1960. * struct cfg80211_connect_params - Connection parameters
  1961. *
  1962. * This structure provides information needed to complete IEEE 802.11
  1963. * authentication and association.
  1964. *
  1965. * @channel: The channel to use or %NULL if not specified (auto-select based
  1966. * on scan results)
  1967. * @channel_hint: The channel of the recommended BSS for initial connection or
  1968. * %NULL if not specified
  1969. * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan
  1970. * results)
  1971. * @bssid_hint: The recommended AP BSSID for initial connection to the BSS or
  1972. * %NULL if not specified. Unlike the @bssid parameter, the driver is
  1973. * allowed to ignore this @bssid_hint if it has knowledge of a better BSS
  1974. * to use.
  1975. * @ssid: SSID
  1976. * @ssid_len: Length of ssid in octets
  1977. * @auth_type: Authentication type (algorithm)
  1978. * @ie: IEs for association request
  1979. * @ie_len: Length of assoc_ie in octets
  1980. * @privacy: indicates whether privacy-enabled APs should be used
  1981. * @mfp: indicate whether management frame protection is used
  1982. * @crypto: crypto settings
  1983. * @key_len: length of WEP key for shared key authentication
  1984. * @key_idx: index of WEP key for shared key authentication
  1985. * @key: WEP key for shared key authentication
  1986. * @flags: See &enum cfg80211_assoc_req_flags
  1987. * @bg_scan_period: Background scan period in seconds
  1988. * or -1 to indicate that default value is to be used.
  1989. * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
  1990. * will be used in ht_capa. Un-supported values will be ignored.
  1991. * @ht_capa_mask: The bits of ht_capa which are to be used.
  1992. * @vht_capa: VHT Capability overrides
  1993. * @vht_capa_mask: The bits of vht_capa which are to be used.
  1994. * @pbss: if set, connect to a PCP instead of AP. Valid for DMG
  1995. * networks.
  1996. * @bss_select: criteria to be used for BSS selection.
  1997. * @prev_bssid: previous BSSID, if not %NULL use reassociate frame. This is used
  1998. * to indicate a request to reassociate within the ESS instead of a request
  1999. * do the initial association with the ESS. When included, this is set to
  2000. * the BSSID of the current association, i.e., to the value that is
  2001. * included in the Current AP address field of the Reassociation Request
  2002. * frame.
  2003. * @fils_erp_username: EAP re-authentication protocol (ERP) username part of the
  2004. * NAI or %NULL if not specified. This is used to construct FILS wrapped
  2005. * data IE.
  2006. * @fils_erp_username_len: Length of @fils_erp_username in octets.
  2007. * @fils_erp_realm: EAP re-authentication protocol (ERP) realm part of NAI or
  2008. * %NULL if not specified. This specifies the domain name of ER server and
  2009. * is used to construct FILS wrapped data IE.
  2010. * @fils_erp_realm_len: Length of @fils_erp_realm in octets.
  2011. * @fils_erp_next_seq_num: The next sequence number to use in the FILS ERP
  2012. * messages. This is also used to construct FILS wrapped data IE.
  2013. * @fils_erp_rrk: ERP re-authentication Root Key (rRK) used to derive additional
  2014. * keys in FILS or %NULL if not specified.
  2015. * @fils_erp_rrk_len: Length of @fils_erp_rrk in octets.
  2016. * @want_1x: indicates user-space supports and wants to use 802.1X driver
  2017. * offload of 4-way handshake.
  2018. */
  2019. struct cfg80211_connect_params {
  2020. struct ieee80211_channel *channel;
  2021. struct ieee80211_channel *channel_hint;
  2022. const u8 *bssid;
  2023. const u8 *bssid_hint;
  2024. const u8 *ssid;
  2025. size_t ssid_len;
  2026. enum nl80211_auth_type auth_type;
  2027. const u8 *ie;
  2028. size_t ie_len;
  2029. bool privacy;
  2030. enum nl80211_mfp mfp;
  2031. struct cfg80211_crypto_settings crypto;
  2032. const u8 *key;
  2033. u8 key_len, key_idx;
  2034. u32 flags;
  2035. int bg_scan_period;
  2036. struct ieee80211_ht_cap ht_capa;
  2037. struct ieee80211_ht_cap ht_capa_mask;
  2038. struct ieee80211_vht_cap vht_capa;
  2039. struct ieee80211_vht_cap vht_capa_mask;
  2040. bool pbss;
  2041. struct cfg80211_bss_selection bss_select;
  2042. const u8 *prev_bssid;
  2043. const u8 *fils_erp_username;
  2044. size_t fils_erp_username_len;
  2045. const u8 *fils_erp_realm;
  2046. size_t fils_erp_realm_len;
  2047. u16 fils_erp_next_seq_num;
  2048. const u8 *fils_erp_rrk;
  2049. size_t fils_erp_rrk_len;
  2050. bool want_1x;
  2051. };
  2052. /**
  2053. * enum cfg80211_connect_params_changed - Connection parameters being updated
  2054. *
  2055. * This enum provides information of all connect parameters that
  2056. * have to be updated as part of update_connect_params() call.
  2057. *
  2058. * @UPDATE_ASSOC_IES: Indicates whether association request IEs are updated
  2059. */
  2060. enum cfg80211_connect_params_changed {
  2061. UPDATE_ASSOC_IES = BIT(0),
  2062. };
  2063. /**
  2064. * enum wiphy_params_flags - set_wiphy_params bitfield values
  2065. * @WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed
  2066. * @WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed
  2067. * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed
  2068. * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
  2069. * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
  2070. * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
  2071. */
  2072. enum wiphy_params_flags {
  2073. WIPHY_PARAM_RETRY_SHORT = 1 << 0,
  2074. WIPHY_PARAM_RETRY_LONG = 1 << 1,
  2075. WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2,
  2076. WIPHY_PARAM_RTS_THRESHOLD = 1 << 3,
  2077. WIPHY_PARAM_COVERAGE_CLASS = 1 << 4,
  2078. WIPHY_PARAM_DYN_ACK = 1 << 5,
  2079. };
  2080. /**
  2081. * struct cfg80211_pmksa - PMK Security Association
  2082. *
  2083. * This structure is passed to the set/del_pmksa() method for PMKSA
  2084. * caching.
  2085. *
  2086. * @bssid: The AP's BSSID (may be %NULL).
  2087. * @pmkid: The identifier to refer a PMKSA.
  2088. * @pmk: The PMK for the PMKSA identified by @pmkid. This is used for key
  2089. * derivation by a FILS STA. Otherwise, %NULL.
  2090. * @pmk_len: Length of the @pmk. The length of @pmk can differ depending on
  2091. * the hash algorithm used to generate this.
  2092. * @ssid: SSID to specify the ESS within which a PMKSA is valid when using FILS
  2093. * cache identifier (may be %NULL).
  2094. * @ssid_len: Length of the @ssid in octets.
  2095. * @cache_id: 2-octet cache identifier advertized by a FILS AP identifying the
  2096. * scope of PMKSA. This is valid only if @ssid_len is non-zero (may be
  2097. * %NULL).
  2098. */
  2099. struct cfg80211_pmksa {
  2100. const u8 *bssid;
  2101. const u8 *pmkid;
  2102. const u8 *pmk;
  2103. size_t pmk_len;
  2104. const u8 *ssid;
  2105. size_t ssid_len;
  2106. const u8 *cache_id;
  2107. };
  2108. /**
  2109. * struct cfg80211_pkt_pattern - packet pattern
  2110. * @mask: bitmask where to match pattern and where to ignore bytes,
  2111. * one bit per byte, in same format as nl80211
  2112. * @pattern: bytes to match where bitmask is 1
  2113. * @pattern_len: length of pattern (in bytes)
  2114. * @pkt_offset: packet offset (in bytes)
  2115. *
  2116. * Internal note: @mask and @pattern are allocated in one chunk of
  2117. * memory, free @mask only!
  2118. */
  2119. struct cfg80211_pkt_pattern {
  2120. const u8 *mask, *pattern;
  2121. int pattern_len;
  2122. int pkt_offset;
  2123. };
  2124. /**
  2125. * struct cfg80211_wowlan_tcp - TCP connection parameters
  2126. *
  2127. * @sock: (internal) socket for source port allocation
  2128. * @src: source IP address
  2129. * @dst: destination IP address
  2130. * @dst_mac: destination MAC address
  2131. * @src_port: source port
  2132. * @dst_port: destination port
  2133. * @payload_len: data payload length
  2134. * @payload: data payload buffer
  2135. * @payload_seq: payload sequence stamping configuration
  2136. * @data_interval: interval at which to send data packets
  2137. * @wake_len: wakeup payload match length
  2138. * @wake_data: wakeup payload match data
  2139. * @wake_mask: wakeup payload match mask
  2140. * @tokens_size: length of the tokens buffer
  2141. * @payload_tok: payload token usage configuration
  2142. */
  2143. struct cfg80211_wowlan_tcp {
  2144. struct socket *sock;
  2145. __be32 src, dst;
  2146. u16 src_port, dst_port;
  2147. u8 dst_mac[ETH_ALEN];
  2148. int payload_len;
  2149. const u8 *payload;
  2150. struct nl80211_wowlan_tcp_data_seq payload_seq;
  2151. u32 data_interval;
  2152. u32 wake_len;
  2153. const u8 *wake_data, *wake_mask;
  2154. u32 tokens_size;
  2155. /* must be last, variable member */
  2156. struct nl80211_wowlan_tcp_data_token payload_tok;
  2157. };
  2158. /**
  2159. * struct cfg80211_wowlan - Wake on Wireless-LAN support info
  2160. *
  2161. * This structure defines the enabled WoWLAN triggers for the device.
  2162. * @any: wake up on any activity -- special trigger if device continues
  2163. * operating as normal during suspend
  2164. * @disconnect: wake up if getting disconnected
  2165. * @magic_pkt: wake up on receiving magic packet
  2166. * @patterns: wake up on receiving packet matching a pattern
  2167. * @n_patterns: number of patterns
  2168. * @gtk_rekey_failure: wake up on GTK rekey failure
  2169. * @eap_identity_req: wake up on EAP identity request packet
  2170. * @four_way_handshake: wake up on 4-way handshake
  2171. * @rfkill_release: wake up when rfkill is released
  2172. * @tcp: TCP connection establishment/wakeup parameters, see nl80211.h.
  2173. * NULL if not configured.
  2174. * @nd_config: configuration for the scan to be used for net detect wake.
  2175. */
  2176. struct cfg80211_wowlan {
  2177. bool any, disconnect, magic_pkt, gtk_rekey_failure,
  2178. eap_identity_req, four_way_handshake,
  2179. rfkill_release;
  2180. struct cfg80211_pkt_pattern *patterns;
  2181. struct cfg80211_wowlan_tcp *tcp;
  2182. int n_patterns;
  2183. struct cfg80211_sched_scan_request *nd_config;
  2184. };
  2185. /**
  2186. * struct cfg80211_coalesce_rules - Coalesce rule parameters
  2187. *
  2188. * This structure defines coalesce rule for the device.
  2189. * @delay: maximum coalescing delay in msecs.
  2190. * @condition: condition for packet coalescence.
  2191. * see &enum nl80211_coalesce_condition.
  2192. * @patterns: array of packet patterns
  2193. * @n_patterns: number of patterns
  2194. */
  2195. struct cfg80211_coalesce_rules {
  2196. int delay;
  2197. enum nl80211_coalesce_condition condition;
  2198. struct cfg80211_pkt_pattern *patterns;
  2199. int n_patterns;
  2200. };
  2201. /**
  2202. * struct cfg80211_coalesce - Packet coalescing settings
  2203. *
  2204. * This structure defines coalescing settings.
  2205. * @rules: array of coalesce rules
  2206. * @n_rules: number of rules
  2207. */
  2208. struct cfg80211_coalesce {
  2209. struct cfg80211_coalesce_rules *rules;
  2210. int n_rules;
  2211. };
  2212. /**
  2213. * struct cfg80211_wowlan_nd_match - information about the match
  2214. *
  2215. * @ssid: SSID of the match that triggered the wake up
  2216. * @n_channels: Number of channels where the match occurred. This
  2217. * value may be zero if the driver can't report the channels.
  2218. * @channels: center frequencies of the channels where a match
  2219. * occurred (in MHz)
  2220. */
  2221. struct cfg80211_wowlan_nd_match {
  2222. struct cfg80211_ssid ssid;
  2223. int n_channels;
  2224. u32 channels[];
  2225. };
  2226. /**
  2227. * struct cfg80211_wowlan_nd_info - net detect wake up information
  2228. *
  2229. * @n_matches: Number of match information instances provided in
  2230. * @matches. This value may be zero if the driver can't provide
  2231. * match information.
  2232. * @matches: Array of pointers to matches containing information about
  2233. * the matches that triggered the wake up.
  2234. */
  2235. struct cfg80211_wowlan_nd_info {
  2236. int n_matches;
  2237. struct cfg80211_wowlan_nd_match *matches[];
  2238. };
  2239. /**
  2240. * struct cfg80211_wowlan_wakeup - wakeup report
  2241. * @disconnect: woke up by getting disconnected
  2242. * @magic_pkt: woke up by receiving magic packet
  2243. * @gtk_rekey_failure: woke up by GTK rekey failure
  2244. * @eap_identity_req: woke up by EAP identity request packet
  2245. * @four_way_handshake: woke up by 4-way handshake
  2246. * @rfkill_release: woke up by rfkill being released
  2247. * @pattern_idx: pattern that caused wakeup, -1 if not due to pattern
  2248. * @packet_present_len: copied wakeup packet data
  2249. * @packet_len: original wakeup packet length
  2250. * @packet: The packet causing the wakeup, if any.
  2251. * @packet_80211: For pattern match, magic packet and other data
  2252. * frame triggers an 802.3 frame should be reported, for
  2253. * disconnect due to deauth 802.11 frame. This indicates which
  2254. * it is.
  2255. * @tcp_match: TCP wakeup packet received
  2256. * @tcp_connlost: TCP connection lost or failed to establish
  2257. * @tcp_nomoretokens: TCP data ran out of tokens
  2258. * @net_detect: if not %NULL, woke up because of net detect
  2259. */
  2260. struct cfg80211_wowlan_wakeup {
  2261. bool disconnect, magic_pkt, gtk_rekey_failure,
  2262. eap_identity_req, four_way_handshake,
  2263. rfkill_release, packet_80211,
  2264. tcp_match, tcp_connlost, tcp_nomoretokens;
  2265. s32 pattern_idx;
  2266. u32 packet_present_len, packet_len;
  2267. const void *packet;
  2268. struct cfg80211_wowlan_nd_info *net_detect;
  2269. };
  2270. /**
  2271. * struct cfg80211_gtk_rekey_data - rekey data
  2272. * @kek: key encryption key (NL80211_KEK_LEN bytes)
  2273. * @kck: key confirmation key (NL80211_KCK_LEN bytes)
  2274. * @replay_ctr: replay counter (NL80211_REPLAY_CTR_LEN bytes)
  2275. */
  2276. struct cfg80211_gtk_rekey_data {
  2277. const u8 *kek, *kck, *replay_ctr;
  2278. };
  2279. /**
  2280. * struct cfg80211_update_ft_ies_params - FT IE Information
  2281. *
  2282. * This structure provides information needed to update the fast transition IE
  2283. *
  2284. * @md: The Mobility Domain ID, 2 Octet value
  2285. * @ie: Fast Transition IEs
  2286. * @ie_len: Length of ft_ie in octets
  2287. */
  2288. struct cfg80211_update_ft_ies_params {
  2289. u16 md;
  2290. const u8 *ie;
  2291. size_t ie_len;
  2292. };
  2293. /**
  2294. * struct cfg80211_mgmt_tx_params - mgmt tx parameters
  2295. *
  2296. * This structure provides information needed to transmit a mgmt frame
  2297. *
  2298. * @chan: channel to use
  2299. * @offchan: indicates wether off channel operation is required
  2300. * @wait: duration for ROC
  2301. * @buf: buffer to transmit
  2302. * @len: buffer length
  2303. * @no_cck: don't use cck rates for this frame
  2304. * @dont_wait_for_ack: tells the low level not to wait for an ack
  2305. * @n_csa_offsets: length of csa_offsets array
  2306. * @csa_offsets: array of all the csa offsets in the frame
  2307. */
  2308. struct cfg80211_mgmt_tx_params {
  2309. struct ieee80211_channel *chan;
  2310. bool offchan;
  2311. unsigned int wait;
  2312. const u8 *buf;
  2313. size_t len;
  2314. bool no_cck;
  2315. bool dont_wait_for_ack;
  2316. int n_csa_offsets;
  2317. const u16 *csa_offsets;
  2318. };
  2319. /**
  2320. * struct cfg80211_dscp_exception - DSCP exception
  2321. *
  2322. * @dscp: DSCP value that does not adhere to the user priority range definition
  2323. * @up: user priority value to which the corresponding DSCP value belongs
  2324. */
  2325. struct cfg80211_dscp_exception {
  2326. u8 dscp;
  2327. u8 up;
  2328. };
  2329. /**
  2330. * struct cfg80211_dscp_range - DSCP range definition for user priority
  2331. *
  2332. * @low: lowest DSCP value of this user priority range, inclusive
  2333. * @high: highest DSCP value of this user priority range, inclusive
  2334. */
  2335. struct cfg80211_dscp_range {
  2336. u8 low;
  2337. u8 high;
  2338. };
  2339. /* QoS Map Set element length defined in IEEE Std 802.11-2012, 8.4.2.97 */
  2340. #define IEEE80211_QOS_MAP_MAX_EX 21
  2341. #define IEEE80211_QOS_MAP_LEN_MIN 16
  2342. #define IEEE80211_QOS_MAP_LEN_MAX \
  2343. (IEEE80211_QOS_MAP_LEN_MIN + 2 * IEEE80211_QOS_MAP_MAX_EX)
  2344. /**
  2345. * struct cfg80211_qos_map - QoS Map Information
  2346. *
  2347. * This struct defines the Interworking QoS map setting for DSCP values
  2348. *
  2349. * @num_des: number of DSCP exceptions (0..21)
  2350. * @dscp_exception: optionally up to maximum of 21 DSCP exceptions from
  2351. * the user priority DSCP range definition
  2352. * @up: DSCP range definition for a particular user priority
  2353. */
  2354. struct cfg80211_qos_map {
  2355. u8 num_des;
  2356. struct cfg80211_dscp_exception dscp_exception[IEEE80211_QOS_MAP_MAX_EX];
  2357. struct cfg80211_dscp_range up[8];
  2358. };
  2359. /**
  2360. * struct cfg80211_nan_conf - NAN configuration
  2361. *
  2362. * This struct defines NAN configuration parameters
  2363. *
  2364. * @master_pref: master preference (1 - 255)
  2365. * @bands: operating bands, a bitmap of &enum nl80211_band values.
  2366. * For instance, for NL80211_BAND_2GHZ, bit 0 would be set
  2367. * (i.e. BIT(NL80211_BAND_2GHZ)).
  2368. */
  2369. struct cfg80211_nan_conf {
  2370. u8 master_pref;
  2371. u8 bands;
  2372. };
  2373. /**
  2374. * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
  2375. * configuration
  2376. *
  2377. * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
  2378. * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
  2379. */
  2380. enum cfg80211_nan_conf_changes {
  2381. CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
  2382. CFG80211_NAN_CONF_CHANGED_BANDS = BIT(1),
  2383. };
  2384. /**
  2385. * struct cfg80211_nan_func_filter - a NAN function Rx / Tx filter
  2386. *
  2387. * @filter: the content of the filter
  2388. * @len: the length of the filter
  2389. */
  2390. struct cfg80211_nan_func_filter {
  2391. const u8 *filter;
  2392. u8 len;
  2393. };
  2394. /**
  2395. * struct cfg80211_nan_func - a NAN function
  2396. *
  2397. * @type: &enum nl80211_nan_function_type
  2398. * @service_id: the service ID of the function
  2399. * @publish_type: &nl80211_nan_publish_type
  2400. * @close_range: if true, the range should be limited. Threshold is
  2401. * implementation specific.
  2402. * @publish_bcast: if true, the solicited publish should be broadcasted
  2403. * @subscribe_active: if true, the subscribe is active
  2404. * @followup_id: the instance ID for follow up
  2405. * @followup_reqid: the requestor instance ID for follow up
  2406. * @followup_dest: MAC address of the recipient of the follow up
  2407. * @ttl: time to live counter in DW.
  2408. * @serv_spec_info: Service Specific Info
  2409. * @serv_spec_info_len: Service Specific Info length
  2410. * @srf_include: if true, SRF is inclusive
  2411. * @srf_bf: Bloom Filter
  2412. * @srf_bf_len: Bloom Filter length
  2413. * @srf_bf_idx: Bloom Filter index
  2414. * @srf_macs: SRF MAC addresses
  2415. * @srf_num_macs: number of MAC addresses in SRF
  2416. * @rx_filters: rx filters that are matched with corresponding peer's tx_filter
  2417. * @tx_filters: filters that should be transmitted in the SDF.
  2418. * @num_rx_filters: length of &rx_filters.
  2419. * @num_tx_filters: length of &tx_filters.
  2420. * @instance_id: driver allocated id of the function.
  2421. * @cookie: unique NAN function identifier.
  2422. */
  2423. struct cfg80211_nan_func {
  2424. enum nl80211_nan_function_type type;
  2425. u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
  2426. u8 publish_type;
  2427. bool close_range;
  2428. bool publish_bcast;
  2429. bool subscribe_active;
  2430. u8 followup_id;
  2431. u8 followup_reqid;
  2432. struct mac_address followup_dest;
  2433. u32 ttl;
  2434. const u8 *serv_spec_info;
  2435. u8 serv_spec_info_len;
  2436. bool srf_include;
  2437. const u8 *srf_bf;
  2438. u8 srf_bf_len;
  2439. u8 srf_bf_idx;
  2440. struct mac_address *srf_macs;
  2441. int srf_num_macs;
  2442. struct cfg80211_nan_func_filter *rx_filters;
  2443. struct cfg80211_nan_func_filter *tx_filters;
  2444. u8 num_tx_filters;
  2445. u8 num_rx_filters;
  2446. u8 instance_id;
  2447. u64 cookie;
  2448. };
  2449. /**
  2450. * struct cfg80211_pmk_conf - PMK configuration
  2451. *
  2452. * @aa: authenticator address
  2453. * @pmk_len: PMK length in bytes.
  2454. * @pmk: the PMK material
  2455. * @pmk_r0_name: PMK-R0 Name. NULL if not applicable (i.e., the PMK
  2456. * is not PMK-R0). When pmk_r0_name is not NULL, the pmk field
  2457. * holds PMK-R0.
  2458. */
  2459. struct cfg80211_pmk_conf {
  2460. const u8 *aa;
  2461. u8 pmk_len;
  2462. const u8 *pmk;
  2463. const u8 *pmk_r0_name;
  2464. };
  2465. /**
  2466. * struct cfg80211_external_auth_params - Trigger External authentication.
  2467. *
  2468. * Commonly used across the external auth request and event interfaces.
  2469. *
  2470. * @action: action type / trigger for external authentication. Only significant
  2471. * for the authentication request event interface (driver to user space).
  2472. * @bssid: BSSID of the peer with which the authentication has
  2473. * to happen. Used by both the authentication request event and
  2474. * authentication response command interface.
  2475. * @ssid: SSID of the AP. Used by both the authentication request event and
  2476. * authentication response command interface.
  2477. * @key_mgmt_suite: AKM suite of the respective authentication. Used by the
  2478. * authentication request event interface.
  2479. * @status: status code, %WLAN_STATUS_SUCCESS for successful authentication,
  2480. * use %WLAN_STATUS_UNSPECIFIED_FAILURE if user space cannot give you
  2481. * the real status code for failures. Used only for the authentication
  2482. * response command interface (user space to driver).
  2483. */
  2484. struct cfg80211_external_auth_params {
  2485. enum nl80211_external_auth_action action;
  2486. u8 bssid[ETH_ALEN] __aligned(2);
  2487. struct cfg80211_ssid ssid;
  2488. unsigned int key_mgmt_suite;
  2489. u16 status;
  2490. };
  2491. /**
  2492. * struct cfg80211_ops - backend description for wireless configuration
  2493. *
  2494. * This struct is registered by fullmac card drivers and/or wireless stacks
  2495. * in order to handle configuration requests on their interfaces.
  2496. *
  2497. * All callbacks except where otherwise noted should return 0
  2498. * on success or a negative error code.
  2499. *
  2500. * All operations are currently invoked under rtnl for consistency with the
  2501. * wireless extensions but this is subject to reevaluation as soon as this
  2502. * code is used more widely and we have a first user without wext.
  2503. *
  2504. * @suspend: wiphy device needs to be suspended. The variable @wow will
  2505. * be %NULL or contain the enabled Wake-on-Wireless triggers that are
  2506. * configured for the device.
  2507. * @resume: wiphy device needs to be resumed
  2508. * @set_wakeup: Called when WoWLAN is enabled/disabled, use this callback
  2509. * to call device_set_wakeup_enable() to enable/disable wakeup from
  2510. * the device.
  2511. *
  2512. * @add_virtual_intf: create a new virtual interface with the given name,
  2513. * must set the struct wireless_dev's iftype. Beware: You must create
  2514. * the new netdev in the wiphy's network namespace! Returns the struct
  2515. * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
  2516. * also set the address member in the wdev.
  2517. *
  2518. * @del_virtual_intf: remove the virtual interface
  2519. *
  2520. * @change_virtual_intf: change type/configuration of virtual interface,
  2521. * keep the struct wireless_dev's iftype updated.
  2522. *
  2523. * @add_key: add a key with the given parameters. @mac_addr will be %NULL
  2524. * when adding a group key.
  2525. *
  2526. * @get_key: get information about the key with the given parameters.
  2527. * @mac_addr will be %NULL when requesting information for a group
  2528. * key. All pointers given to the @callback function need not be valid
  2529. * after it returns. This function should return an error if it is
  2530. * not possible to retrieve the key, -ENOENT if it doesn't exist.
  2531. *
  2532. * @del_key: remove a key given the @mac_addr (%NULL for a group key)
  2533. * and @key_index, return -ENOENT if the key doesn't exist.
  2534. *
  2535. * @set_default_key: set the default key on an interface
  2536. *
  2537. * @set_default_mgmt_key: set the default management frame key on an interface
  2538. *
  2539. * @set_rekey_data: give the data necessary for GTK rekeying to the driver
  2540. *
  2541. * @start_ap: Start acting in AP mode defined by the parameters.
  2542. * @change_beacon: Change the beacon parameters for an access point mode
  2543. * interface. This should reject the call when AP mode wasn't started.
  2544. * @stop_ap: Stop being an AP, including stopping beaconing.
  2545. *
  2546. * @add_station: Add a new station.
  2547. * @del_station: Remove a station
  2548. * @change_station: Modify a given station. Note that flags changes are not much
  2549. * validated in cfg80211, in particular the auth/assoc/authorized flags
  2550. * might come to the driver in invalid combinations -- make sure to check
  2551. * them, also against the existing state! Drivers must call
  2552. * cfg80211_check_station_change() to validate the information.
  2553. * @get_station: get station information for the station identified by @mac
  2554. * @dump_station: dump station callback -- resume dump at index @idx
  2555. *
  2556. * @add_mpath: add a fixed mesh path
  2557. * @del_mpath: delete a given mesh path
  2558. * @change_mpath: change a given mesh path
  2559. * @get_mpath: get a mesh path for the given parameters
  2560. * @dump_mpath: dump mesh path callback -- resume dump at index @idx
  2561. * @get_mpp: get a mesh proxy path for the given parameters
  2562. * @dump_mpp: dump mesh proxy path callback -- resume dump at index @idx
  2563. * @join_mesh: join the mesh network with the specified parameters
  2564. * (invoked with the wireless_dev mutex held)
  2565. * @leave_mesh: leave the current mesh network
  2566. * (invoked with the wireless_dev mutex held)
  2567. *
  2568. * @get_mesh_config: Get the current mesh configuration
  2569. *
  2570. * @update_mesh_config: Update mesh parameters on a running mesh.
  2571. * The mask is a bitfield which tells us which parameters to
  2572. * set, and which to leave alone.
  2573. *
  2574. * @change_bss: Modify parameters for a given BSS.
  2575. *
  2576. * @set_txq_params: Set TX queue parameters
  2577. *
  2578. * @libertas_set_mesh_channel: Only for backward compatibility for libertas,
  2579. * as it doesn't implement join_mesh and needs to set the channel to
  2580. * join the mesh instead.
  2581. *
  2582. * @set_monitor_channel: Set the monitor mode channel for the device. If other
  2583. * interfaces are active this callback should reject the configuration.
  2584. * If no interfaces are active or the device is down, the channel should
  2585. * be stored for when a monitor interface becomes active.
  2586. *
  2587. * @scan: Request to do a scan. If returning zero, the scan request is given
  2588. * the driver, and will be valid until passed to cfg80211_scan_done().
  2589. * For scan results, call cfg80211_inform_bss(); you can call this outside
  2590. * the scan/scan_done bracket too.
  2591. * @abort_scan: Tell the driver to abort an ongoing scan. The driver shall
  2592. * indicate the status of the scan through cfg80211_scan_done().
  2593. *
  2594. * @auth: Request to authenticate with the specified peer
  2595. * (invoked with the wireless_dev mutex held)
  2596. * @assoc: Request to (re)associate with the specified peer
  2597. * (invoked with the wireless_dev mutex held)
  2598. * @deauth: Request to deauthenticate from the specified peer
  2599. * (invoked with the wireless_dev mutex held)
  2600. * @disassoc: Request to disassociate from the specified peer
  2601. * (invoked with the wireless_dev mutex held)
  2602. *
  2603. * @connect: Connect to the ESS with the specified parameters. When connected,
  2604. * call cfg80211_connect_result()/cfg80211_connect_bss() with status code
  2605. * %WLAN_STATUS_SUCCESS. If the connection fails for some reason, call
  2606. * cfg80211_connect_result()/cfg80211_connect_bss() with the status code
  2607. * from the AP or cfg80211_connect_timeout() if no frame with status code
  2608. * was received.
  2609. * The driver is allowed to roam to other BSSes within the ESS when the
  2610. * other BSS matches the connect parameters. When such roaming is initiated
  2611. * by the driver, the driver is expected to verify that the target matches
  2612. * the configured security parameters and to use Reassociation Request
  2613. * frame instead of Association Request frame.
  2614. * The connect function can also be used to request the driver to perform a
  2615. * specific roam when connected to an ESS. In that case, the prev_bssid
  2616. * parameter is set to the BSSID of the currently associated BSS as an
  2617. * indication of requesting reassociation.
  2618. * In both the driver-initiated and new connect() call initiated roaming
  2619. * cases, the result of roaming is indicated with a call to
  2620. * cfg80211_roamed(). (invoked with the wireless_dev mutex held)
  2621. * @update_connect_params: Update the connect parameters while connected to a
  2622. * BSS. The updated parameters can be used by driver/firmware for
  2623. * subsequent BSS selection (roaming) decisions and to form the
  2624. * Authentication/(Re)Association Request frames. This call does not
  2625. * request an immediate disassociation or reassociation with the current
  2626. * BSS, i.e., this impacts only subsequent (re)associations. The bits in
  2627. * changed are defined in &enum cfg80211_connect_params_changed.
  2628. * (invoked with the wireless_dev mutex held)
  2629. * @disconnect: Disconnect from the BSS/ESS or stop connection attempts if
  2630. * connection is in progress. Once done, call cfg80211_disconnected() in
  2631. * case connection was already established (invoked with the
  2632. * wireless_dev mutex held), otherwise call cfg80211_connect_timeout().
  2633. *
  2634. * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call
  2635. * cfg80211_ibss_joined(), also call that function when changing BSSID due
  2636. * to a merge.
  2637. * (invoked with the wireless_dev mutex held)
  2638. * @leave_ibss: Leave the IBSS.
  2639. * (invoked with the wireless_dev mutex held)
  2640. *
  2641. * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or
  2642. * MESH mode)
  2643. *
  2644. * @set_wiphy_params: Notify that wiphy parameters have changed;
  2645. * @changed bitfield (see &enum wiphy_params_flags) describes which values
  2646. * have changed. The actual parameter values are available in
  2647. * struct wiphy. If returning an error, no value should be changed.
  2648. *
  2649. * @set_tx_power: set the transmit power according to the parameters,
  2650. * the power passed is in mBm, to get dBm use MBM_TO_DBM(). The
  2651. * wdev may be %NULL if power was set for the wiphy, and will
  2652. * always be %NULL unless the driver supports per-vif TX power
  2653. * (as advertised by the nl80211 feature flag.)
  2654. * @get_tx_power: store the current TX power into the dbm variable;
  2655. * return 0 if successful
  2656. *
  2657. * @set_wds_peer: set the WDS peer for a WDS interface
  2658. *
  2659. * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
  2660. * functions to adjust rfkill hw state
  2661. *
  2662. * @dump_survey: get site survey information.
  2663. *
  2664. * @remain_on_channel: Request the driver to remain awake on the specified
  2665. * channel for the specified duration to complete an off-channel
  2666. * operation (e.g., public action frame exchange). When the driver is
  2667. * ready on the requested channel, it must indicate this with an event
  2668. * notification by calling cfg80211_ready_on_channel().
  2669. * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation.
  2670. * This allows the operation to be terminated prior to timeout based on
  2671. * the duration value.
  2672. * @mgmt_tx: Transmit a management frame.
  2673. * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management
  2674. * frame on another channel
  2675. *
  2676. * @testmode_cmd: run a test mode command; @wdev may be %NULL
  2677. * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be
  2678. * used by the function, but 0 and 1 must not be touched. Additionally,
  2679. * return error codes other than -ENOBUFS and -ENOENT will terminate the
  2680. * dump and return to userspace with an error, so be careful. If any data
  2681. * was passed in from userspace then the data/len arguments will be present
  2682. * and point to the data contained in %NL80211_ATTR_TESTDATA.
  2683. *
  2684. * @set_bitrate_mask: set the bitrate mask configuration
  2685. *
  2686. * @set_pmksa: Cache a PMKID for a BSSID. This is mostly useful for fullmac
  2687. * devices running firmwares capable of generating the (re) association
  2688. * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
  2689. * @del_pmksa: Delete a cached PMKID.
  2690. * @flush_pmksa: Flush all cached PMKIDs.
  2691. * @set_power_mgmt: Configure WLAN power management. A timeout value of -1
  2692. * allows the driver to adjust the dynamic ps timeout value.
  2693. * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold.
  2694. * After configuration, the driver should (soon) send an event indicating
  2695. * the current level is above/below the configured threshold; this may
  2696. * need some care when the configuration is changed (without first being
  2697. * disabled.)
  2698. * @set_cqm_rssi_range_config: Configure two RSSI thresholds in the
  2699. * connection quality monitor. An event is to be sent only when the
  2700. * signal level is found to be outside the two values. The driver should
  2701. * set %NL80211_EXT_FEATURE_CQM_RSSI_LIST if this method is implemented.
  2702. * If it is provided then there's no point providing @set_cqm_rssi_config.
  2703. * @set_cqm_txe_config: Configure connection quality monitor TX error
  2704. * thresholds.
  2705. * @sched_scan_start: Tell the driver to start a scheduled scan.
  2706. * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
  2707. * given request id. This call must stop the scheduled scan and be ready
  2708. * for starting a new one before it returns, i.e. @sched_scan_start may be
  2709. * called immediately after that again and should not fail in that case.
  2710. * The driver should not call cfg80211_sched_scan_stopped() for a requested
  2711. * stop (when this method returns 0).
  2712. *
  2713. * @mgmt_frame_register: Notify driver that a management frame type was
  2714. * registered. The callback is allowed to sleep.
  2715. *
  2716. * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
  2717. * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
  2718. * reject TX/RX mask combinations they cannot support by returning -EINVAL
  2719. * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
  2720. *
  2721. * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
  2722. *
  2723. * @tdls_mgmt: Transmit a TDLS management frame.
  2724. * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup).
  2725. *
  2726. * @probe_client: probe an associated client, must return a cookie that it
  2727. * later passes to cfg80211_probe_status().
  2728. *
  2729. * @set_noack_map: Set the NoAck Map for the TIDs.
  2730. *
  2731. * @get_channel: Get the current operating channel for the virtual interface.
  2732. * For monitor interfaces, it should return %NULL unless there's a single
  2733. * current monitoring channel.
  2734. *
  2735. * @start_p2p_device: Start the given P2P device.
  2736. * @stop_p2p_device: Stop the given P2P device.
  2737. *
  2738. * @set_mac_acl: Sets MAC address control list in AP and P2P GO mode.
  2739. * Parameters include ACL policy, an array of MAC address of stations
  2740. * and the number of MAC addresses. If there is already a list in driver
  2741. * this new list replaces the existing one. Driver has to clear its ACL
  2742. * when number of MAC addresses entries is passed as 0. Drivers which
  2743. * advertise the support for MAC based ACL have to implement this callback.
  2744. *
  2745. * @start_radar_detection: Start radar detection in the driver.
  2746. *
  2747. * @update_ft_ies: Provide updated Fast BSS Transition information to the
  2748. * driver. If the SME is in the driver/firmware, this information can be
  2749. * used in building Authentication and Reassociation Request frames.
  2750. *
  2751. * @crit_proto_start: Indicates a critical protocol needs more link reliability
  2752. * for a given duration (milliseconds). The protocol is provided so the
  2753. * driver can take the most appropriate actions.
  2754. * @crit_proto_stop: Indicates critical protocol no longer needs increased link
  2755. * reliability. This operation can not fail.
  2756. * @set_coalesce: Set coalesce parameters.
  2757. *
  2758. * @channel_switch: initiate channel-switch procedure (with CSA). Driver is
  2759. * responsible for veryfing if the switch is possible. Since this is
  2760. * inherently tricky driver may decide to disconnect an interface later
  2761. * with cfg80211_stop_iface(). This doesn't mean driver can accept
  2762. * everything. It should do it's best to verify requests and reject them
  2763. * as soon as possible.
  2764. *
  2765. * @set_qos_map: Set QoS mapping information to the driver
  2766. *
  2767. * @set_ap_chanwidth: Set the AP (including P2P GO) mode channel width for the
  2768. * given interface This is used e.g. for dynamic HT 20/40 MHz channel width
  2769. * changes during the lifetime of the BSS.
  2770. *
  2771. * @add_tx_ts: validate (if admitted_time is 0) or add a TX TS to the device
  2772. * with the given parameters; action frame exchange has been handled by
  2773. * userspace so this just has to modify the TX path to take the TS into
  2774. * account.
  2775. * If the admitted time is 0 just validate the parameters to make sure
  2776. * the session can be created at all; it is valid to just always return
  2777. * success for that but that may result in inefficient behaviour (handshake
  2778. * with the peer followed by immediate teardown when the addition is later
  2779. * rejected)
  2780. * @del_tx_ts: remove an existing TX TS
  2781. *
  2782. * @join_ocb: join the OCB network with the specified parameters
  2783. * (invoked with the wireless_dev mutex held)
  2784. * @leave_ocb: leave the current OCB network
  2785. * (invoked with the wireless_dev mutex held)
  2786. *
  2787. * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
  2788. * is responsible for continually initiating channel-switching operations
  2789. * and returning to the base channel for communication with the AP.
  2790. * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
  2791. * peers must be on the base channel when the call completes.
  2792. * @start_nan: Start the NAN interface.
  2793. * @stop_nan: Stop the NAN interface.
  2794. * @add_nan_func: Add a NAN function. Returns negative value on failure.
  2795. * On success @nan_func ownership is transferred to the driver and
  2796. * it may access it outside of the scope of this function. The driver
  2797. * should free the @nan_func when no longer needed by calling
  2798. * cfg80211_free_nan_func().
  2799. * On success the driver should assign an instance_id in the
  2800. * provided @nan_func.
  2801. * @del_nan_func: Delete a NAN function.
  2802. * @nan_change_conf: changes NAN configuration. The changed parameters must
  2803. * be specified in @changes (using &enum cfg80211_nan_conf_changes);
  2804. * All other parameters must be ignored.
  2805. *
  2806. * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
  2807. *
  2808. * @set_pmk: configure the PMK to be used for offloaded 802.1X 4-Way handshake.
  2809. * If not deleted through @del_pmk the PMK remains valid until disconnect
  2810. * upon which the driver should clear it.
  2811. * (invoked with the wireless_dev mutex held)
  2812. * @del_pmk: delete the previously configured PMK for the given authenticator.
  2813. * (invoked with the wireless_dev mutex held)
  2814. *
  2815. * @external_auth: indicates result of offloaded authentication processing from
  2816. * user space
  2817. */
  2818. struct cfg80211_ops {
  2819. int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
  2820. int (*resume)(struct wiphy *wiphy);
  2821. void (*set_wakeup)(struct wiphy *wiphy, bool enabled);
  2822. struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
  2823. const char *name,
  2824. unsigned char name_assign_type,
  2825. enum nl80211_iftype type,
  2826. struct vif_params *params);
  2827. int (*del_virtual_intf)(struct wiphy *wiphy,
  2828. struct wireless_dev *wdev);
  2829. int (*change_virtual_intf)(struct wiphy *wiphy,
  2830. struct net_device *dev,
  2831. enum nl80211_iftype type,
  2832. struct vif_params *params);
  2833. int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
  2834. u8 key_index, bool pairwise, const u8 *mac_addr,
  2835. struct key_params *params);
  2836. int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
  2837. u8 key_index, bool pairwise, const u8 *mac_addr,
  2838. void *cookie,
  2839. void (*callback)(void *cookie, struct key_params*));
  2840. int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
  2841. u8 key_index, bool pairwise, const u8 *mac_addr);
  2842. int (*set_default_key)(struct wiphy *wiphy,
  2843. struct net_device *netdev,
  2844. u8 key_index, bool unicast, bool multicast);
  2845. int (*set_default_mgmt_key)(struct wiphy *wiphy,
  2846. struct net_device *netdev,
  2847. u8 key_index);
  2848. int (*start_ap)(struct wiphy *wiphy, struct net_device *dev,
  2849. struct cfg80211_ap_settings *settings);
  2850. int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev,
  2851. struct cfg80211_beacon_data *info);
  2852. int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev);
  2853. int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
  2854. const u8 *mac,
  2855. struct station_parameters *params);
  2856. int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
  2857. struct station_del_parameters *params);
  2858. int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
  2859. const u8 *mac,
  2860. struct station_parameters *params);
  2861. int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
  2862. const u8 *mac, struct station_info *sinfo);
  2863. int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
  2864. int idx, u8 *mac, struct station_info *sinfo);
  2865. int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2866. const u8 *dst, const u8 *next_hop);
  2867. int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2868. const u8 *dst);
  2869. int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2870. const u8 *dst, const u8 *next_hop);
  2871. int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2872. u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
  2873. int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
  2874. int idx, u8 *dst, u8 *next_hop,
  2875. struct mpath_info *pinfo);
  2876. int (*get_mpp)(struct wiphy *wiphy, struct net_device *dev,
  2877. u8 *dst, u8 *mpp, struct mpath_info *pinfo);
  2878. int (*dump_mpp)(struct wiphy *wiphy, struct net_device *dev,
  2879. int idx, u8 *dst, u8 *mpp,
  2880. struct mpath_info *pinfo);
  2881. int (*get_mesh_config)(struct wiphy *wiphy,
  2882. struct net_device *dev,
  2883. struct mesh_config *conf);
  2884. int (*update_mesh_config)(struct wiphy *wiphy,
  2885. struct net_device *dev, u32 mask,
  2886. const struct mesh_config *nconf);
  2887. int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev,
  2888. const struct mesh_config *conf,
  2889. const struct mesh_setup *setup);
  2890. int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev);
  2891. int (*join_ocb)(struct wiphy *wiphy, struct net_device *dev,
  2892. struct ocb_setup *setup);
  2893. int (*leave_ocb)(struct wiphy *wiphy, struct net_device *dev);
  2894. int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
  2895. struct bss_parameters *params);
  2896. int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev,
  2897. struct ieee80211_txq_params *params);
  2898. int (*libertas_set_mesh_channel)(struct wiphy *wiphy,
  2899. struct net_device *dev,
  2900. struct ieee80211_channel *chan);
  2901. int (*set_monitor_channel)(struct wiphy *wiphy,
  2902. struct cfg80211_chan_def *chandef);
  2903. int (*scan)(struct wiphy *wiphy,
  2904. struct cfg80211_scan_request *request);
  2905. void (*abort_scan)(struct wiphy *wiphy, struct wireless_dev *wdev);
  2906. int (*auth)(struct wiphy *wiphy, struct net_device *dev,
  2907. struct cfg80211_auth_request *req);
  2908. int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
  2909. struct cfg80211_assoc_request *req);
  2910. int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
  2911. struct cfg80211_deauth_request *req);
  2912. int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
  2913. struct cfg80211_disassoc_request *req);
  2914. int (*connect)(struct wiphy *wiphy, struct net_device *dev,
  2915. struct cfg80211_connect_params *sme);
  2916. int (*update_connect_params)(struct wiphy *wiphy,
  2917. struct net_device *dev,
  2918. struct cfg80211_connect_params *sme,
  2919. u32 changed);
  2920. int (*disconnect)(struct wiphy *wiphy, struct net_device *dev,
  2921. u16 reason_code);
  2922. int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev,
  2923. struct cfg80211_ibss_params *params);
  2924. int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
  2925. int (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev,
  2926. int rate[NUM_NL80211_BANDS]);
  2927. int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed);
  2928. int (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2929. enum nl80211_tx_power_setting type, int mbm);
  2930. int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2931. int *dbm);
  2932. int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev,
  2933. const u8 *addr);
  2934. void (*rfkill_poll)(struct wiphy *wiphy);
  2935. #ifdef CONFIG_NL80211_TESTMODE
  2936. int (*testmode_cmd)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2937. void *data, int len);
  2938. int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb,
  2939. struct netlink_callback *cb,
  2940. void *data, int len);
  2941. #endif
  2942. int (*set_bitrate_mask)(struct wiphy *wiphy,
  2943. struct net_device *dev,
  2944. const u8 *peer,
  2945. const struct cfg80211_bitrate_mask *mask);
  2946. int (*dump_survey)(struct wiphy *wiphy, struct net_device *netdev,
  2947. int idx, struct survey_info *info);
  2948. int (*set_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
  2949. struct cfg80211_pmksa *pmksa);
  2950. int (*del_pmksa)(struct wiphy *wiphy, struct net_device *netdev,
  2951. struct cfg80211_pmksa *pmksa);
  2952. int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev);
  2953. int (*remain_on_channel)(struct wiphy *wiphy,
  2954. struct wireless_dev *wdev,
  2955. struct ieee80211_channel *chan,
  2956. unsigned int duration,
  2957. u64 *cookie);
  2958. int (*cancel_remain_on_channel)(struct wiphy *wiphy,
  2959. struct wireless_dev *wdev,
  2960. u64 cookie);
  2961. int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev,
  2962. struct cfg80211_mgmt_tx_params *params,
  2963. u64 *cookie);
  2964. int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy,
  2965. struct wireless_dev *wdev,
  2966. u64 cookie);
  2967. int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
  2968. bool enabled, int timeout);
  2969. int (*set_cqm_rssi_config)(struct wiphy *wiphy,
  2970. struct net_device *dev,
  2971. s32 rssi_thold, u32 rssi_hyst);
  2972. int (*set_cqm_rssi_range_config)(struct wiphy *wiphy,
  2973. struct net_device *dev,
  2974. s32 rssi_low, s32 rssi_high);
  2975. int (*set_cqm_txe_config)(struct wiphy *wiphy,
  2976. struct net_device *dev,
  2977. u32 rate, u32 pkts, u32 intvl);
  2978. void (*mgmt_frame_register)(struct wiphy *wiphy,
  2979. struct wireless_dev *wdev,
  2980. u16 frame_type, bool reg);
  2981. int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
  2982. int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
  2983. int (*sched_scan_start)(struct wiphy *wiphy,
  2984. struct net_device *dev,
  2985. struct cfg80211_sched_scan_request *request);
  2986. int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev,
  2987. u64 reqid);
  2988. int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev,
  2989. struct cfg80211_gtk_rekey_data *data);
  2990. int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev,
  2991. const u8 *peer, u8 action_code, u8 dialog_token,
  2992. u16 status_code, u32 peer_capability,
  2993. bool initiator, const u8 *buf, size_t len);
  2994. int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev,
  2995. const u8 *peer, enum nl80211_tdls_operation oper);
  2996. int (*probe_client)(struct wiphy *wiphy, struct net_device *dev,
  2997. const u8 *peer, u64 *cookie);
  2998. int (*set_noack_map)(struct wiphy *wiphy,
  2999. struct net_device *dev,
  3000. u16 noack_map);
  3001. int (*get_channel)(struct wiphy *wiphy,
  3002. struct wireless_dev *wdev,
  3003. struct cfg80211_chan_def *chandef);
  3004. int (*start_p2p_device)(struct wiphy *wiphy,
  3005. struct wireless_dev *wdev);
  3006. void (*stop_p2p_device)(struct wiphy *wiphy,
  3007. struct wireless_dev *wdev);
  3008. int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev,
  3009. const struct cfg80211_acl_data *params);
  3010. int (*start_radar_detection)(struct wiphy *wiphy,
  3011. struct net_device *dev,
  3012. struct cfg80211_chan_def *chandef,
  3013. u32 cac_time_ms);
  3014. int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
  3015. struct cfg80211_update_ft_ies_params *ftie);
  3016. int (*crit_proto_start)(struct wiphy *wiphy,
  3017. struct wireless_dev *wdev,
  3018. enum nl80211_crit_proto_id protocol,
  3019. u16 duration);
  3020. void (*crit_proto_stop)(struct wiphy *wiphy,
  3021. struct wireless_dev *wdev);
  3022. int (*set_coalesce)(struct wiphy *wiphy,
  3023. struct cfg80211_coalesce *coalesce);
  3024. int (*channel_switch)(struct wiphy *wiphy,
  3025. struct net_device *dev,
  3026. struct cfg80211_csa_settings *params);
  3027. int (*set_qos_map)(struct wiphy *wiphy,
  3028. struct net_device *dev,
  3029. struct cfg80211_qos_map *qos_map);
  3030. int (*set_ap_chanwidth)(struct wiphy *wiphy, struct net_device *dev,
  3031. struct cfg80211_chan_def *chandef);
  3032. int (*add_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
  3033. u8 tsid, const u8 *peer, u8 user_prio,
  3034. u16 admitted_time);
  3035. int (*del_tx_ts)(struct wiphy *wiphy, struct net_device *dev,
  3036. u8 tsid, const u8 *peer);
  3037. int (*tdls_channel_switch)(struct wiphy *wiphy,
  3038. struct net_device *dev,
  3039. const u8 *addr, u8 oper_class,
  3040. struct cfg80211_chan_def *chandef);
  3041. void (*tdls_cancel_channel_switch)(struct wiphy *wiphy,
  3042. struct net_device *dev,
  3043. const u8 *addr);
  3044. int (*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3045. struct cfg80211_nan_conf *conf);
  3046. void (*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
  3047. int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3048. struct cfg80211_nan_func *nan_func);
  3049. void (*del_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3050. u64 cookie);
  3051. int (*nan_change_conf)(struct wiphy *wiphy,
  3052. struct wireless_dev *wdev,
  3053. struct cfg80211_nan_conf *conf,
  3054. u32 changes);
  3055. int (*set_multicast_to_unicast)(struct wiphy *wiphy,
  3056. struct net_device *dev,
  3057. const bool enabled);
  3058. int (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
  3059. const struct cfg80211_pmk_conf *conf);
  3060. int (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
  3061. const u8 *aa);
  3062. int (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
  3063. struct cfg80211_external_auth_params *params);
  3064. };
  3065. /*
  3066. * wireless hardware and networking interfaces structures
  3067. * and registration/helper functions
  3068. */
  3069. /**
  3070. * enum wiphy_flags - wiphy capability flags
  3071. *
  3072. * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
  3073. * wiphy at all
  3074. * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
  3075. * by default -- this flag will be set depending on the kernel's default
  3076. * on wiphy_new(), but can be changed by the driver if it has a good
  3077. * reason to override the default
  3078. * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station
  3079. * on a VLAN interface)
  3080. * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station
  3081. * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the
  3082. * control port protocol ethertype. The device also honours the
  3083. * control_port_no_encrypt flag.
  3084. * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN.
  3085. * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing
  3086. * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH.
  3087. * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the
  3088. * firmware.
  3089. * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP.
  3090. * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation.
  3091. * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z)
  3092. * link setup/discovery operations internally. Setup, discovery and
  3093. * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT
  3094. * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be
  3095. * used for asking the driver/firmware to perform a TDLS operation.
  3096. * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME
  3097. * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes
  3098. * when there are virtual interfaces in AP mode by calling
  3099. * cfg80211_report_obss_beacon().
  3100. * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device
  3101. * responds to probe-requests in hardware.
  3102. * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
  3103. * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
  3104. * @WIPHY_FLAG_SUPPORTS_5_10_MHZ: Device supports 5 MHz and 10 MHz channels.
  3105. * @WIPHY_FLAG_HAS_CHANNEL_SWITCH: Device supports channel switch in
  3106. * beaconing mode (AP, IBSS, Mesh, ...).
  3107. * @WIPHY_FLAG_HAS_STATIC_WEP: The device supports static WEP key installation
  3108. * before connection.
  3109. */
  3110. enum wiphy_flags {
  3111. /* use hole at 0 */
  3112. /* use hole at 1 */
  3113. /* use hole at 2 */
  3114. WIPHY_FLAG_NETNS_OK = BIT(3),
  3115. WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
  3116. WIPHY_FLAG_4ADDR_AP = BIT(5),
  3117. WIPHY_FLAG_4ADDR_STATION = BIT(6),
  3118. WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7),
  3119. WIPHY_FLAG_IBSS_RSN = BIT(8),
  3120. WIPHY_FLAG_MESH_AUTH = BIT(10),
  3121. /* use hole at 11 */
  3122. /* use hole at 12 */
  3123. WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13),
  3124. WIPHY_FLAG_AP_UAPSD = BIT(14),
  3125. WIPHY_FLAG_SUPPORTS_TDLS = BIT(15),
  3126. WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16),
  3127. WIPHY_FLAG_HAVE_AP_SME = BIT(17),
  3128. WIPHY_FLAG_REPORTS_OBSS = BIT(18),
  3129. WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19),
  3130. WIPHY_FLAG_OFFCHAN_TX = BIT(20),
  3131. WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21),
  3132. WIPHY_FLAG_SUPPORTS_5_10_MHZ = BIT(22),
  3133. WIPHY_FLAG_HAS_CHANNEL_SWITCH = BIT(23),
  3134. WIPHY_FLAG_HAS_STATIC_WEP = BIT(24),
  3135. };
  3136. /**
  3137. * struct ieee80211_iface_limit - limit on certain interface types
  3138. * @max: maximum number of interfaces of these types
  3139. * @types: interface types (bits)
  3140. */
  3141. struct ieee80211_iface_limit {
  3142. u16 max;
  3143. u16 types;
  3144. };
  3145. /**
  3146. * struct ieee80211_iface_combination - possible interface combination
  3147. *
  3148. * With this structure the driver can describe which interface
  3149. * combinations it supports concurrently.
  3150. *
  3151. * Examples:
  3152. *
  3153. * 1. Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
  3154. *
  3155. * .. code-block:: c
  3156. *
  3157. * struct ieee80211_iface_limit limits1[] = {
  3158. * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
  3159. * { .max = 1, .types = BIT(NL80211_IFTYPE_AP}, },
  3160. * };
  3161. * struct ieee80211_iface_combination combination1 = {
  3162. * .limits = limits1,
  3163. * .n_limits = ARRAY_SIZE(limits1),
  3164. * .max_interfaces = 2,
  3165. * .beacon_int_infra_match = true,
  3166. * };
  3167. *
  3168. *
  3169. * 2. Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
  3170. *
  3171. * .. code-block:: c
  3172. *
  3173. * struct ieee80211_iface_limit limits2[] = {
  3174. * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
  3175. * BIT(NL80211_IFTYPE_P2P_GO), },
  3176. * };
  3177. * struct ieee80211_iface_combination combination2 = {
  3178. * .limits = limits2,
  3179. * .n_limits = ARRAY_SIZE(limits2),
  3180. * .max_interfaces = 8,
  3181. * .num_different_channels = 1,
  3182. * };
  3183. *
  3184. *
  3185. * 3. Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
  3186. *
  3187. * This allows for an infrastructure connection and three P2P connections.
  3188. *
  3189. * .. code-block:: c
  3190. *
  3191. * struct ieee80211_iface_limit limits3[] = {
  3192. * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
  3193. * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
  3194. * BIT(NL80211_IFTYPE_P2P_CLIENT), },
  3195. * };
  3196. * struct ieee80211_iface_combination combination3 = {
  3197. * .limits = limits3,
  3198. * .n_limits = ARRAY_SIZE(limits3),
  3199. * .max_interfaces = 4,
  3200. * .num_different_channels = 2,
  3201. * };
  3202. *
  3203. */
  3204. struct ieee80211_iface_combination {
  3205. /**
  3206. * @limits:
  3207. * limits for the given interface types
  3208. */
  3209. const struct ieee80211_iface_limit *limits;
  3210. /**
  3211. * @num_different_channels:
  3212. * can use up to this many different channels
  3213. */
  3214. u32 num_different_channels;
  3215. /**
  3216. * @max_interfaces:
  3217. * maximum number of interfaces in total allowed in this group
  3218. */
  3219. u16 max_interfaces;
  3220. /**
  3221. * @n_limits:
  3222. * number of limitations
  3223. */
  3224. u8 n_limits;
  3225. /**
  3226. * @beacon_int_infra_match:
  3227. * In this combination, the beacon intervals between infrastructure
  3228. * and AP types must match. This is required only in special cases.
  3229. */
  3230. bool beacon_int_infra_match;
  3231. /**
  3232. * @radar_detect_widths:
  3233. * bitmap of channel widths supported for radar detection
  3234. */
  3235. u8 radar_detect_widths;
  3236. /**
  3237. * @radar_detect_regions:
  3238. * bitmap of regions supported for radar detection
  3239. */
  3240. u8 radar_detect_regions;
  3241. /**
  3242. * @beacon_int_min_gcd:
  3243. * This interface combination supports different beacon intervals.
  3244. *
  3245. * = 0
  3246. * all beacon intervals for different interface must be same.
  3247. * > 0
  3248. * any beacon interval for the interface part of this combination AND
  3249. * GCD of all beacon intervals from beaconing interfaces of this
  3250. * combination must be greater or equal to this value.
  3251. */
  3252. u32 beacon_int_min_gcd;
  3253. };
  3254. struct ieee80211_txrx_stypes {
  3255. u16 tx, rx;
  3256. };
  3257. /**
  3258. * enum wiphy_wowlan_support_flags - WoWLAN support flags
  3259. * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any"
  3260. * trigger that keeps the device operating as-is and
  3261. * wakes up the host on any activity, for example a
  3262. * received packet that passed filtering; note that the
  3263. * packet should be preserved in that case
  3264. * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet
  3265. * (see nl80211.h)
  3266. * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect
  3267. * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep
  3268. * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure
  3269. * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request
  3270. * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure
  3271. * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release
  3272. * @WIPHY_WOWLAN_NET_DETECT: supports wakeup on network detection
  3273. */
  3274. enum wiphy_wowlan_support_flags {
  3275. WIPHY_WOWLAN_ANY = BIT(0),
  3276. WIPHY_WOWLAN_MAGIC_PKT = BIT(1),
  3277. WIPHY_WOWLAN_DISCONNECT = BIT(2),
  3278. WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3),
  3279. WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4),
  3280. WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5),
  3281. WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6),
  3282. WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7),
  3283. WIPHY_WOWLAN_NET_DETECT = BIT(8),
  3284. };
  3285. struct wiphy_wowlan_tcp_support {
  3286. const struct nl80211_wowlan_tcp_data_token_feature *tok;
  3287. u32 data_payload_max;
  3288. u32 data_interval_max;
  3289. u32 wake_payload_max;
  3290. bool seq;
  3291. };
  3292. /**
  3293. * struct wiphy_wowlan_support - WoWLAN support data
  3294. * @flags: see &enum wiphy_wowlan_support_flags
  3295. * @n_patterns: number of supported wakeup patterns
  3296. * (see nl80211.h for the pattern definition)
  3297. * @pattern_max_len: maximum length of each pattern
  3298. * @pattern_min_len: minimum length of each pattern
  3299. * @max_pkt_offset: maximum Rx packet offset
  3300. * @max_nd_match_sets: maximum number of matchsets for net-detect,
  3301. * similar, but not necessarily identical, to max_match_sets for
  3302. * scheduled scans.
  3303. * See &struct cfg80211_sched_scan_request.@match_sets for more
  3304. * details.
  3305. * @tcp: TCP wakeup support information
  3306. */
  3307. struct wiphy_wowlan_support {
  3308. u32 flags;
  3309. int n_patterns;
  3310. int pattern_max_len;
  3311. int pattern_min_len;
  3312. int max_pkt_offset;
  3313. int max_nd_match_sets;
  3314. const struct wiphy_wowlan_tcp_support *tcp;
  3315. };
  3316. /**
  3317. * struct wiphy_coalesce_support - coalesce support data
  3318. * @n_rules: maximum number of coalesce rules
  3319. * @max_delay: maximum supported coalescing delay in msecs
  3320. * @n_patterns: number of supported patterns in a rule
  3321. * (see nl80211.h for the pattern definition)
  3322. * @pattern_max_len: maximum length of each pattern
  3323. * @pattern_min_len: minimum length of each pattern
  3324. * @max_pkt_offset: maximum Rx packet offset
  3325. */
  3326. struct wiphy_coalesce_support {
  3327. int n_rules;
  3328. int max_delay;
  3329. int n_patterns;
  3330. int pattern_max_len;
  3331. int pattern_min_len;
  3332. int max_pkt_offset;
  3333. };
  3334. /**
  3335. * enum wiphy_vendor_command_flags - validation flags for vendor commands
  3336. * @WIPHY_VENDOR_CMD_NEED_WDEV: vendor command requires wdev
  3337. * @WIPHY_VENDOR_CMD_NEED_NETDEV: vendor command requires netdev
  3338. * @WIPHY_VENDOR_CMD_NEED_RUNNING: interface/wdev must be up & running
  3339. * (must be combined with %_WDEV or %_NETDEV)
  3340. */
  3341. enum wiphy_vendor_command_flags {
  3342. WIPHY_VENDOR_CMD_NEED_WDEV = BIT(0),
  3343. WIPHY_VENDOR_CMD_NEED_NETDEV = BIT(1),
  3344. WIPHY_VENDOR_CMD_NEED_RUNNING = BIT(2),
  3345. };
  3346. /**
  3347. * enum wiphy_opmode_flag - Station's ht/vht operation mode information flags
  3348. *
  3349. * @STA_OPMODE_MAX_BW_CHANGED: Max Bandwidth changed
  3350. * @STA_OPMODE_SMPS_MODE_CHANGED: SMPS mode changed
  3351. * @STA_OPMODE_N_SS_CHANGED: max N_SS (number of spatial streams) changed
  3352. *
  3353. */
  3354. enum wiphy_opmode_flag {
  3355. STA_OPMODE_MAX_BW_CHANGED = BIT(0),
  3356. STA_OPMODE_SMPS_MODE_CHANGED = BIT(1),
  3357. STA_OPMODE_N_SS_CHANGED = BIT(2),
  3358. };
  3359. /**
  3360. * struct sta_opmode_info - Station's ht/vht operation mode information
  3361. * @changed: contains value from &enum wiphy_opmode_flag
  3362. * @smps_mode: New SMPS mode of a station
  3363. * @bw: new max bandwidth value of a station
  3364. * @rx_nss: new rx_nss value of a station
  3365. */
  3366. struct sta_opmode_info {
  3367. u32 changed;
  3368. u8 smps_mode;
  3369. u8 bw;
  3370. u8 rx_nss;
  3371. };
  3372. /**
  3373. * struct wiphy_vendor_command - vendor command definition
  3374. * @info: vendor command identifying information, as used in nl80211
  3375. * @flags: flags, see &enum wiphy_vendor_command_flags
  3376. * @doit: callback for the operation, note that wdev is %NULL if the
  3377. * flags didn't ask for a wdev and non-%NULL otherwise; the data
  3378. * pointer may be %NULL if userspace provided no data at all
  3379. * @dumpit: dump callback, for transferring bigger/multiple items. The
  3380. * @storage points to cb->args[5], ie. is preserved over the multiple
  3381. * dumpit calls.
  3382. * It's recommended to not have the same sub command with both @doit and
  3383. * @dumpit, so that userspace can assume certain ones are get and others
  3384. * are used with dump requests.
  3385. */
  3386. struct wiphy_vendor_command {
  3387. struct nl80211_vendor_cmd_info info;
  3388. u32 flags;
  3389. int (*doit)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3390. const void *data, int data_len);
  3391. int (*dumpit)(struct wiphy *wiphy, struct wireless_dev *wdev,
  3392. struct sk_buff *skb, const void *data, int data_len,
  3393. unsigned long *storage);
  3394. };
  3395. /**
  3396. * struct wiphy_iftype_ext_capab - extended capabilities per interface type
  3397. * @iftype: interface type
  3398. * @extended_capabilities: extended capabilities supported by the driver,
  3399. * additional capabilities might be supported by userspace; these are the
  3400. * 802.11 extended capabilities ("Extended Capabilities element") and are
  3401. * in the same format as in the information element. See IEEE Std
  3402. * 802.11-2012 8.4.2.29 for the defined fields.
  3403. * @extended_capabilities_mask: mask of the valid values
  3404. * @extended_capabilities_len: length of the extended capabilities
  3405. */
  3406. struct wiphy_iftype_ext_capab {
  3407. enum nl80211_iftype iftype;
  3408. const u8 *extended_capabilities;
  3409. const u8 *extended_capabilities_mask;
  3410. u8 extended_capabilities_len;
  3411. };
  3412. /**
  3413. * struct wiphy - wireless hardware description
  3414. * @reg_notifier: the driver's regulatory notification callback,
  3415. * note that if your driver uses wiphy_apply_custom_regulatory()
  3416. * the reg_notifier's request can be passed as NULL
  3417. * @regd: the driver's regulatory domain, if one was requested via
  3418. * the regulatory_hint() API. This can be used by the driver
  3419. * on the reg_notifier() if it chooses to ignore future
  3420. * regulatory domain changes caused by other drivers.
  3421. * @signal_type: signal type reported in &struct cfg80211_bss.
  3422. * @cipher_suites: supported cipher suites
  3423. * @n_cipher_suites: number of supported cipher suites
  3424. * @retry_short: Retry limit for short frames (dot11ShortRetryLimit)
  3425. * @retry_long: Retry limit for long frames (dot11LongRetryLimit)
  3426. * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
  3427. * -1 = fragmentation disabled, only odd values >= 256 used
  3428. * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
  3429. * @_net: the network namespace this wiphy currently lives in
  3430. * @perm_addr: permanent MAC address of this device
  3431. * @addr_mask: If the device supports multiple MAC addresses by masking,
  3432. * set this to a mask with variable bits set to 1, e.g. if the last
  3433. * four bits are variable then set it to 00-00-00-00-00-0f. The actual
  3434. * variable bits shall be determined by the interfaces added, with
  3435. * interfaces not matching the mask being rejected to be brought up.
  3436. * @n_addresses: number of addresses in @addresses.
  3437. * @addresses: If the device has more than one address, set this pointer
  3438. * to a list of addresses (6 bytes each). The first one will be used
  3439. * by default for perm_addr. In this case, the mask should be set to
  3440. * all-zeroes. In this case it is assumed that the device can handle
  3441. * the same number of arbitrary MAC addresses.
  3442. * @registered: protects ->resume and ->suspend sysfs callbacks against
  3443. * unregister hardware
  3444. * @debugfsdir: debugfs directory used for this wiphy, will be renamed
  3445. * automatically on wiphy renames
  3446. * @dev: (virtual) struct device for this wiphy
  3447. * @registered: helps synchronize suspend/resume with wiphy unregister
  3448. * @wext: wireless extension handlers
  3449. * @priv: driver private data (sized according to wiphy_new() parameter)
  3450. * @interface_modes: bitmask of interfaces types valid for this wiphy,
  3451. * must be set by driver
  3452. * @iface_combinations: Valid interface combinations array, should not
  3453. * list single interface types.
  3454. * @n_iface_combinations: number of entries in @iface_combinations array.
  3455. * @software_iftypes: bitmask of software interface types, these are not
  3456. * subject to any restrictions since they are purely managed in SW.
  3457. * @flags: wiphy flags, see &enum wiphy_flags
  3458. * @regulatory_flags: wiphy regulatory flags, see
  3459. * &enum ieee80211_regulatory_flags
  3460. * @features: features advertised to nl80211, see &enum nl80211_feature_flags.
  3461. * @ext_features: extended features advertised to nl80211, see
  3462. * &enum nl80211_ext_feature_index.
  3463. * @bss_priv_size: each BSS struct has private data allocated with it,
  3464. * this variable determines its size
  3465. * @max_scan_ssids: maximum number of SSIDs the device can scan for in
  3466. * any given scan
  3467. * @max_sched_scan_reqs: maximum number of scheduled scan requests that
  3468. * the device can run concurrently.
  3469. * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
  3470. * for in any given scheduled scan
  3471. * @max_match_sets: maximum number of match sets the device can handle
  3472. * when performing a scheduled scan, 0 if filtering is not
  3473. * supported.
  3474. * @max_scan_ie_len: maximum length of user-controlled IEs device can
  3475. * add to probe request frames transmitted during a scan, must not
  3476. * include fixed IEs like supported rates
  3477. * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled
  3478. * scans
  3479. * @max_sched_scan_plans: maximum number of scan plans (scan interval and number
  3480. * of iterations) for scheduled scan supported by the device.
  3481. * @max_sched_scan_plan_interval: maximum interval (in seconds) for a
  3482. * single scan plan supported by the device.
  3483. * @max_sched_scan_plan_iterations: maximum number of iterations for a single
  3484. * scan plan supported by the device.
  3485. * @coverage_class: current coverage class
  3486. * @fw_version: firmware version for ethtool reporting
  3487. * @hw_version: hardware version for ethtool reporting
  3488. * @max_num_pmkids: maximum number of PMKIDs supported by device
  3489. * @privid: a pointer that drivers can use to identify if an arbitrary
  3490. * wiphy is theirs, e.g. in global notifiers
  3491. * @bands: information about bands/channels supported by this device
  3492. *
  3493. * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or
  3494. * transmitted through nl80211, points to an array indexed by interface
  3495. * type
  3496. *
  3497. * @available_antennas_tx: bitmap of antennas which are available to be
  3498. * configured as TX antennas. Antenna configuration commands will be
  3499. * rejected unless this or @available_antennas_rx is set.
  3500. *
  3501. * @available_antennas_rx: bitmap of antennas which are available to be
  3502. * configured as RX antennas. Antenna configuration commands will be
  3503. * rejected unless this or @available_antennas_tx is set.
  3504. *
  3505. * @probe_resp_offload:
  3506. * Bitmap of supported protocols for probe response offloading.
  3507. * See &enum nl80211_probe_resp_offload_support_attr. Only valid
  3508. * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
  3509. *
  3510. * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation
  3511. * may request, if implemented.
  3512. *
  3513. * @wowlan: WoWLAN support information
  3514. * @wowlan_config: current WoWLAN configuration; this should usually not be
  3515. * used since access to it is necessarily racy, use the parameter passed
  3516. * to the suspend() operation instead.
  3517. *
  3518. * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features.
  3519. * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden.
  3520. * If null, then none can be over-ridden.
  3521. * @vht_capa_mod_mask: Specify what VHT capabilities can be over-ridden.
  3522. * If null, then none can be over-ridden.
  3523. *
  3524. * @wdev_list: the list of associated (virtual) interfaces; this list must
  3525. * not be modified by the driver, but can be read with RTNL/RCU protection.
  3526. *
  3527. * @max_acl_mac_addrs: Maximum number of MAC addresses that the device
  3528. * supports for ACL.
  3529. *
  3530. * @extended_capabilities: extended capabilities supported by the driver,
  3531. * additional capabilities might be supported by userspace; these are
  3532. * the 802.11 extended capabilities ("Extended Capabilities element")
  3533. * and are in the same format as in the information element. See
  3534. * 802.11-2012 8.4.2.29 for the defined fields. These are the default
  3535. * extended capabilities to be used if the capabilities are not specified
  3536. * for a specific interface type in iftype_ext_capab.
  3537. * @extended_capabilities_mask: mask of the valid values
  3538. * @extended_capabilities_len: length of the extended capabilities
  3539. * @iftype_ext_capab: array of extended capabilities per interface type
  3540. * @num_iftype_ext_capab: number of interface types for which extended
  3541. * capabilities are specified separately.
  3542. * @coalesce: packet coalescing support information
  3543. *
  3544. * @vendor_commands: array of vendor commands supported by the hardware
  3545. * @n_vendor_commands: number of vendor commands
  3546. * @vendor_events: array of vendor events supported by the hardware
  3547. * @n_vendor_events: number of vendor events
  3548. *
  3549. * @max_ap_assoc_sta: maximum number of associated stations supported in AP mode
  3550. * (including P2P GO) or 0 to indicate no such limit is advertised. The
  3551. * driver is allowed to advertise a theoretical limit that it can reach in
  3552. * some cases, but may not always reach.
  3553. *
  3554. * @max_num_csa_counters: Number of supported csa_counters in beacons
  3555. * and probe responses. This value should be set if the driver
  3556. * wishes to limit the number of csa counters. Default (0) means
  3557. * infinite.
  3558. * @max_adj_channel_rssi_comp: max offset of between the channel on which the
  3559. * frame was sent and the channel on which the frame was heard for which
  3560. * the reported rssi is still valid. If a driver is able to compensate the
  3561. * low rssi when a frame is heard on different channel, then it should set
  3562. * this variable to the maximal offset for which it can compensate.
  3563. * This value should be set in MHz.
  3564. * @bss_select_support: bitmask indicating the BSS selection criteria supported
  3565. * by the driver in the .connect() callback. The bit position maps to the
  3566. * attribute indices defined in &enum nl80211_bss_select_attr.
  3567. *
  3568. * @cookie_counter: unique generic cookie counter, used to identify objects.
  3569. * @nan_supported_bands: bands supported by the device in NAN mode, a
  3570. * bitmap of &enum nl80211_band values. For instance, for
  3571. * NL80211_BAND_2GHZ, bit 0 would be set
  3572. * (i.e. BIT(NL80211_BAND_2GHZ)).
  3573. */
  3574. struct wiphy {
  3575. /* assign these fields before you register the wiphy */
  3576. /* permanent MAC address(es) */
  3577. u8 perm_addr[ETH_ALEN];
  3578. u8 addr_mask[ETH_ALEN];
  3579. struct mac_address *addresses;
  3580. const struct ieee80211_txrx_stypes *mgmt_stypes;
  3581. const struct ieee80211_iface_combination *iface_combinations;
  3582. int n_iface_combinations;
  3583. u16 software_iftypes;
  3584. u16 n_addresses;
  3585. /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
  3586. u16 interface_modes;
  3587. u16 max_acl_mac_addrs;
  3588. u32 flags, regulatory_flags, features;
  3589. u8 ext_features[DIV_ROUND_UP(NUM_NL80211_EXT_FEATURES, 8)];
  3590. u32 ap_sme_capa;
  3591. enum cfg80211_signal_type signal_type;
  3592. int bss_priv_size;
  3593. u8 max_scan_ssids;
  3594. u8 max_sched_scan_reqs;
  3595. u8 max_sched_scan_ssids;
  3596. u8 max_match_sets;
  3597. u16 max_scan_ie_len;
  3598. u16 max_sched_scan_ie_len;
  3599. u32 max_sched_scan_plans;
  3600. u32 max_sched_scan_plan_interval;
  3601. u32 max_sched_scan_plan_iterations;
  3602. int n_cipher_suites;
  3603. const u32 *cipher_suites;
  3604. u8 retry_short;
  3605. u8 retry_long;
  3606. u32 frag_threshold;
  3607. u32 rts_threshold;
  3608. u8 coverage_class;
  3609. char fw_version[ETHTOOL_FWVERS_LEN];
  3610. u32 hw_version;
  3611. #ifdef CONFIG_PM
  3612. const struct wiphy_wowlan_support *wowlan;
  3613. struct cfg80211_wowlan *wowlan_config;
  3614. #endif
  3615. u16 max_remain_on_channel_duration;
  3616. u8 max_num_pmkids;
  3617. u32 available_antennas_tx;
  3618. u32 available_antennas_rx;
  3619. /*
  3620. * Bitmap of supported protocols for probe response offloading
  3621. * see &enum nl80211_probe_resp_offload_support_attr. Only valid
  3622. * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set.
  3623. */
  3624. u32 probe_resp_offload;
  3625. const u8 *extended_capabilities, *extended_capabilities_mask;
  3626. u8 extended_capabilities_len;
  3627. const struct wiphy_iftype_ext_capab *iftype_ext_capab;
  3628. unsigned int num_iftype_ext_capab;
  3629. /* If multiple wiphys are registered and you're handed e.g.
  3630. * a regular netdev with assigned ieee80211_ptr, you won't
  3631. * know whether it points to a wiphy your driver has registered
  3632. * or not. Assign this to something global to your driver to
  3633. * help determine whether you own this wiphy or not. */
  3634. const void *privid;
  3635. struct ieee80211_supported_band *bands[NUM_NL80211_BANDS];
  3636. /* Lets us get back the wiphy on the callback */
  3637. void (*reg_notifier)(struct wiphy *wiphy,
  3638. struct regulatory_request *request);
  3639. /* fields below are read-only, assigned by cfg80211 */
  3640. const struct ieee80211_regdomain __rcu *regd;
  3641. /* the item in /sys/class/ieee80211/ points to this,
  3642. * you need use set_wiphy_dev() (see below) */
  3643. struct device dev;
  3644. /* protects ->resume, ->suspend sysfs callbacks against unregister hw */
  3645. bool registered;
  3646. /* dir in debugfs: ieee80211/<wiphyname> */
  3647. struct dentry *debugfsdir;
  3648. const struct ieee80211_ht_cap *ht_capa_mod_mask;
  3649. const struct ieee80211_vht_cap *vht_capa_mod_mask;
  3650. struct list_head wdev_list;
  3651. /* the network namespace this phy lives in currently */
  3652. possible_net_t _net;
  3653. #ifdef CONFIG_CFG80211_WEXT
  3654. const struct iw_handler_def *wext;
  3655. #endif
  3656. const struct wiphy_coalesce_support *coalesce;
  3657. const struct wiphy_vendor_command *vendor_commands;
  3658. const struct nl80211_vendor_cmd_info *vendor_events;
  3659. int n_vendor_commands, n_vendor_events;
  3660. u16 max_ap_assoc_sta;
  3661. u8 max_num_csa_counters;
  3662. u8 max_adj_channel_rssi_comp;
  3663. u32 bss_select_support;
  3664. u64 cookie_counter;
  3665. u8 nan_supported_bands;
  3666. char priv[0] __aligned(NETDEV_ALIGN);
  3667. };
  3668. static inline struct net *wiphy_net(struct wiphy *wiphy)
  3669. {
  3670. return read_pnet(&wiphy->_net);
  3671. }
  3672. static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net)
  3673. {
  3674. write_pnet(&wiphy->_net, net);
  3675. }
  3676. /**
  3677. * wiphy_priv - return priv from wiphy
  3678. *
  3679. * @wiphy: the wiphy whose priv pointer to return
  3680. * Return: The priv of @wiphy.
  3681. */
  3682. static inline void *wiphy_priv(struct wiphy *wiphy)
  3683. {
  3684. BUG_ON(!wiphy);
  3685. return &wiphy->priv;
  3686. }
  3687. /**
  3688. * priv_to_wiphy - return the wiphy containing the priv
  3689. *
  3690. * @priv: a pointer previously returned by wiphy_priv
  3691. * Return: The wiphy of @priv.
  3692. */
  3693. static inline struct wiphy *priv_to_wiphy(void *priv)
  3694. {
  3695. BUG_ON(!priv);
  3696. return container_of(priv, struct wiphy, priv);
  3697. }
  3698. /**
  3699. * set_wiphy_dev - set device pointer for wiphy
  3700. *
  3701. * @wiphy: The wiphy whose device to bind
  3702. * @dev: The device to parent it to
  3703. */
  3704. static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
  3705. {
  3706. wiphy->dev.parent = dev;
  3707. }
  3708. /**
  3709. * wiphy_dev - get wiphy dev pointer
  3710. *
  3711. * @wiphy: The wiphy whose device struct to look up
  3712. * Return: The dev of @wiphy.
  3713. */
  3714. static inline struct device *wiphy_dev(struct wiphy *wiphy)
  3715. {
  3716. return wiphy->dev.parent;
  3717. }
  3718. /**
  3719. * wiphy_name - get wiphy name
  3720. *
  3721. * @wiphy: The wiphy whose name to return
  3722. * Return: The name of @wiphy.
  3723. */
  3724. static inline const char *wiphy_name(const struct wiphy *wiphy)
  3725. {
  3726. return dev_name(&wiphy->dev);
  3727. }
  3728. /**
  3729. * wiphy_new_nm - create a new wiphy for use with cfg80211
  3730. *
  3731. * @ops: The configuration operations for this device
  3732. * @sizeof_priv: The size of the private area to allocate
  3733. * @requested_name: Request a particular name.
  3734. * NULL is valid value, and means use the default phy%d naming.
  3735. *
  3736. * Create a new wiphy and associate the given operations with it.
  3737. * @sizeof_priv bytes are allocated for private use.
  3738. *
  3739. * Return: A pointer to the new wiphy. This pointer must be
  3740. * assigned to each netdev's ieee80211_ptr for proper operation.
  3741. */
  3742. struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
  3743. const char *requested_name);
  3744. /**
  3745. * wiphy_new - create a new wiphy for use with cfg80211
  3746. *
  3747. * @ops: The configuration operations for this device
  3748. * @sizeof_priv: The size of the private area to allocate
  3749. *
  3750. * Create a new wiphy and associate the given operations with it.
  3751. * @sizeof_priv bytes are allocated for private use.
  3752. *
  3753. * Return: A pointer to the new wiphy. This pointer must be
  3754. * assigned to each netdev's ieee80211_ptr for proper operation.
  3755. */
  3756. static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
  3757. int sizeof_priv)
  3758. {
  3759. return wiphy_new_nm(ops, sizeof_priv, NULL);
  3760. }
  3761. /**
  3762. * wiphy_register - register a wiphy with cfg80211
  3763. *
  3764. * @wiphy: The wiphy to register.
  3765. *
  3766. * Return: A non-negative wiphy index or a negative error code.
  3767. */
  3768. int wiphy_register(struct wiphy *wiphy);
  3769. /**
  3770. * wiphy_unregister - deregister a wiphy from cfg80211
  3771. *
  3772. * @wiphy: The wiphy to unregister.
  3773. *
  3774. * After this call, no more requests can be made with this priv
  3775. * pointer, but the call may sleep to wait for an outstanding
  3776. * request that is being handled.
  3777. */
  3778. void wiphy_unregister(struct wiphy *wiphy);
  3779. /**
  3780. * wiphy_free - free wiphy
  3781. *
  3782. * @wiphy: The wiphy to free
  3783. */
  3784. void wiphy_free(struct wiphy *wiphy);
  3785. /* internal structs */
  3786. struct cfg80211_conn;
  3787. struct cfg80211_internal_bss;
  3788. struct cfg80211_cached_keys;
  3789. struct cfg80211_cqm_config;
  3790. /**
  3791. * struct wireless_dev - wireless device state
  3792. *
  3793. * For netdevs, this structure must be allocated by the driver
  3794. * that uses the ieee80211_ptr field in struct net_device (this
  3795. * is intentional so it can be allocated along with the netdev.)
  3796. * It need not be registered then as netdev registration will
  3797. * be intercepted by cfg80211 to see the new wireless device.
  3798. *
  3799. * For non-netdev uses, it must also be allocated by the driver
  3800. * in response to the cfg80211 callbacks that require it, as
  3801. * there's no netdev registration in that case it may not be
  3802. * allocated outside of callback operations that return it.
  3803. *
  3804. * @wiphy: pointer to hardware description
  3805. * @iftype: interface type
  3806. * @list: (private) Used to collect the interfaces
  3807. * @netdev: (private) Used to reference back to the netdev, may be %NULL
  3808. * @identifier: (private) Identifier used in nl80211 to identify this
  3809. * wireless device if it has no netdev
  3810. * @current_bss: (private) Used by the internal configuration code
  3811. * @chandef: (private) Used by the internal configuration code to track
  3812. * the user-set channel definition.
  3813. * @preset_chandef: (private) Used by the internal configuration code to
  3814. * track the channel to be used for AP later
  3815. * @bssid: (private) Used by the internal configuration code
  3816. * @ssid: (private) Used by the internal configuration code
  3817. * @ssid_len: (private) Used by the internal configuration code
  3818. * @mesh_id_len: (private) Used by the internal configuration code
  3819. * @mesh_id_up_len: (private) Used by the internal configuration code
  3820. * @wext: (private) Used by the internal wireless extensions compat code
  3821. * @use_4addr: indicates 4addr mode is used on this interface, must be
  3822. * set by driver (if supported) on add_interface BEFORE registering the
  3823. * netdev and may otherwise be used by driver read-only, will be update
  3824. * by cfg80211 on change_interface
  3825. * @mgmt_registrations: list of registrations for management frames
  3826. * @mgmt_registrations_lock: lock for the list
  3827. * @mtx: mutex used to lock data in this struct, may be used by drivers
  3828. * and some API functions require it held
  3829. * @beacon_interval: beacon interval used on this device for transmitting
  3830. * beacons, 0 when not valid
  3831. * @address: The address for this device, valid only if @netdev is %NULL
  3832. * @is_running: true if this is a non-netdev device that has been started, e.g.
  3833. * the P2P Device.
  3834. * @cac_started: true if DFS channel availability check has been started
  3835. * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
  3836. * @cac_time_ms: CAC time in ms
  3837. * @ps: powersave mode is enabled
  3838. * @ps_timeout: dynamic powersave timeout
  3839. * @ap_unexpected_nlportid: (private) netlink port ID of application
  3840. * registered for unexpected class 3 frames (AP mode)
  3841. * @conn: (private) cfg80211 software SME connection state machine data
  3842. * @connect_keys: (private) keys to set after connection is established
  3843. * @conn_bss_type: connecting/connected BSS type
  3844. * @conn_owner_nlportid: (private) connection owner socket port ID
  3845. * @disconnect_wk: (private) auto-disconnect work
  3846. * @disconnect_bssid: (private) the BSSID to use for auto-disconnect
  3847. * @ibss_fixed: (private) IBSS is using fixed BSSID
  3848. * @ibss_dfs_possible: (private) IBSS may change to a DFS channel
  3849. * @event_list: (private) list for internal event processing
  3850. * @event_lock: (private) lock for event list
  3851. * @owner_nlportid: (private) owner socket port ID
  3852. * @nl_owner_dead: (private) owner socket went away
  3853. * @cqm_config: (private) nl80211 RSSI monitor state
  3854. */
  3855. struct wireless_dev {
  3856. struct wiphy *wiphy;
  3857. enum nl80211_iftype iftype;
  3858. /* the remainder of this struct should be private to cfg80211 */
  3859. struct list_head list;
  3860. struct net_device *netdev;
  3861. u32 identifier;
  3862. struct list_head mgmt_registrations;
  3863. spinlock_t mgmt_registrations_lock;
  3864. struct mutex mtx;
  3865. bool use_4addr, is_running;
  3866. u8 address[ETH_ALEN] __aligned(sizeof(u16));
  3867. /* currently used for IBSS and SME - might be rearranged later */
  3868. u8 ssid[IEEE80211_MAX_SSID_LEN];
  3869. u8 ssid_len, mesh_id_len, mesh_id_up_len;
  3870. struct cfg80211_conn *conn;
  3871. struct cfg80211_cached_keys *connect_keys;
  3872. enum ieee80211_bss_type conn_bss_type;
  3873. u32 conn_owner_nlportid;
  3874. struct work_struct disconnect_wk;
  3875. u8 disconnect_bssid[ETH_ALEN];
  3876. struct list_head event_list;
  3877. spinlock_t event_lock;
  3878. struct cfg80211_internal_bss *current_bss; /* associated / joined */
  3879. struct cfg80211_chan_def preset_chandef;
  3880. struct cfg80211_chan_def chandef;
  3881. bool ibss_fixed;
  3882. bool ibss_dfs_possible;
  3883. bool ps;
  3884. int ps_timeout;
  3885. int beacon_interval;
  3886. u32 ap_unexpected_nlportid;
  3887. u32 owner_nlportid;
  3888. bool nl_owner_dead;
  3889. bool cac_started;
  3890. unsigned long cac_start_time;
  3891. unsigned int cac_time_ms;
  3892. #ifdef CONFIG_CFG80211_WEXT
  3893. /* wext data */
  3894. struct {
  3895. struct cfg80211_ibss_params ibss;
  3896. struct cfg80211_connect_params connect;
  3897. struct cfg80211_cached_keys *keys;
  3898. const u8 *ie;
  3899. size_t ie_len;
  3900. u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
  3901. u8 ssid[IEEE80211_MAX_SSID_LEN];
  3902. s8 default_key, default_mgmt_key;
  3903. bool prev_bssid_valid;
  3904. } wext;
  3905. #endif
  3906. struct cfg80211_cqm_config *cqm_config;
  3907. };
  3908. static inline u8 *wdev_address(struct wireless_dev *wdev)
  3909. {
  3910. if (wdev->netdev)
  3911. return wdev->netdev->dev_addr;
  3912. return wdev->address;
  3913. }
  3914. static inline bool wdev_running(struct wireless_dev *wdev)
  3915. {
  3916. if (wdev->netdev)
  3917. return netif_running(wdev->netdev);
  3918. return wdev->is_running;
  3919. }
  3920. /**
  3921. * wdev_priv - return wiphy priv from wireless_dev
  3922. *
  3923. * @wdev: The wireless device whose wiphy's priv pointer to return
  3924. * Return: The wiphy priv of @wdev.
  3925. */
  3926. static inline void *wdev_priv(struct wireless_dev *wdev)
  3927. {
  3928. BUG_ON(!wdev);
  3929. return wiphy_priv(wdev->wiphy);
  3930. }
  3931. /**
  3932. * DOC: Utility functions
  3933. *
  3934. * cfg80211 offers a number of utility functions that can be useful.
  3935. */
  3936. /**
  3937. * ieee80211_channel_to_frequency - convert channel number to frequency
  3938. * @chan: channel number
  3939. * @band: band, necessary due to channel number overlap
  3940. * Return: The corresponding frequency (in MHz), or 0 if the conversion failed.
  3941. */
  3942. int ieee80211_channel_to_frequency(int chan, enum nl80211_band band);
  3943. /**
  3944. * ieee80211_frequency_to_channel - convert frequency to channel number
  3945. * @freq: center frequency
  3946. * Return: The corresponding channel, or 0 if the conversion failed.
  3947. */
  3948. int ieee80211_frequency_to_channel(int freq);
  3949. /**
  3950. * ieee80211_get_channel - get channel struct from wiphy for specified frequency
  3951. *
  3952. * @wiphy: the struct wiphy to get the channel for
  3953. * @freq: the center frequency of the channel
  3954. *
  3955. * Return: The channel struct from @wiphy at @freq.
  3956. */
  3957. struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy, int freq);
  3958. /**
  3959. * ieee80211_get_response_rate - get basic rate for a given rate
  3960. *
  3961. * @sband: the band to look for rates in
  3962. * @basic_rates: bitmap of basic rates
  3963. * @bitrate: the bitrate for which to find the basic rate
  3964. *
  3965. * Return: The basic rate corresponding to a given bitrate, that
  3966. * is the next lower bitrate contained in the basic rate map,
  3967. * which is, for this function, given as a bitmap of indices of
  3968. * rates in the band's bitrate table.
  3969. */
  3970. struct ieee80211_rate *
  3971. ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
  3972. u32 basic_rates, int bitrate);
  3973. /**
  3974. * ieee80211_mandatory_rates - get mandatory rates for a given band
  3975. * @sband: the band to look for rates in
  3976. * @scan_width: width of the control channel
  3977. *
  3978. * This function returns a bitmap of the mandatory rates for the given
  3979. * band, bits are set according to the rate position in the bitrates array.
  3980. */
  3981. u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband,
  3982. enum nl80211_bss_scan_width scan_width);
  3983. /*
  3984. * Radiotap parsing functions -- for controlled injection support
  3985. *
  3986. * Implemented in net/wireless/radiotap.c
  3987. * Documentation in Documentation/networking/radiotap-headers.txt
  3988. */
  3989. struct radiotap_align_size {
  3990. uint8_t align:4, size:4;
  3991. };
  3992. struct ieee80211_radiotap_namespace {
  3993. const struct radiotap_align_size *align_size;
  3994. int n_bits;
  3995. uint32_t oui;
  3996. uint8_t subns;
  3997. };
  3998. struct ieee80211_radiotap_vendor_namespaces {
  3999. const struct ieee80211_radiotap_namespace *ns;
  4000. int n_ns;
  4001. };
  4002. /**
  4003. * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
  4004. * @this_arg_index: index of current arg, valid after each successful call
  4005. * to ieee80211_radiotap_iterator_next()
  4006. * @this_arg: pointer to current radiotap arg; it is valid after each
  4007. * call to ieee80211_radiotap_iterator_next() but also after
  4008. * ieee80211_radiotap_iterator_init() where it will point to
  4009. * the beginning of the actual data portion
  4010. * @this_arg_size: length of the current arg, for convenience
  4011. * @current_namespace: pointer to the current namespace definition
  4012. * (or internally %NULL if the current namespace is unknown)
  4013. * @is_radiotap_ns: indicates whether the current namespace is the default
  4014. * radiotap namespace or not
  4015. *
  4016. * @_rtheader: pointer to the radiotap header we are walking through
  4017. * @_max_length: length of radiotap header in cpu byte ordering
  4018. * @_arg_index: next argument index
  4019. * @_arg: next argument pointer
  4020. * @_next_bitmap: internal pointer to next present u32
  4021. * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  4022. * @_vns: vendor namespace definitions
  4023. * @_next_ns_data: beginning of the next namespace's data
  4024. * @_reset_on_ext: internal; reset the arg index to 0 when going to the
  4025. * next bitmap word
  4026. *
  4027. * Describes the radiotap parser state. Fields prefixed with an underscore
  4028. * must not be used by users of the parser, only by the parser internally.
  4029. */
  4030. struct ieee80211_radiotap_iterator {
  4031. struct ieee80211_radiotap_header *_rtheader;
  4032. const struct ieee80211_radiotap_vendor_namespaces *_vns;
  4033. const struct ieee80211_radiotap_namespace *current_namespace;
  4034. unsigned char *_arg, *_next_ns_data;
  4035. __le32 *_next_bitmap;
  4036. unsigned char *this_arg;
  4037. int this_arg_index;
  4038. int this_arg_size;
  4039. int is_radiotap_ns;
  4040. int _max_length;
  4041. int _arg_index;
  4042. uint32_t _bitmap_shifter;
  4043. int _reset_on_ext;
  4044. };
  4045. int
  4046. ieee80211_radiotap_iterator_init(struct ieee80211_radiotap_iterator *iterator,
  4047. struct ieee80211_radiotap_header *radiotap_header,
  4048. int max_length,
  4049. const struct ieee80211_radiotap_vendor_namespaces *vns);
  4050. int
  4051. ieee80211_radiotap_iterator_next(struct ieee80211_radiotap_iterator *iterator);
  4052. extern const unsigned char rfc1042_header[6];
  4053. extern const unsigned char bridge_tunnel_header[6];
  4054. /**
  4055. * ieee80211_get_hdrlen_from_skb - get header length from data
  4056. *
  4057. * @skb: the frame
  4058. *
  4059. * Given an skb with a raw 802.11 header at the data pointer this function
  4060. * returns the 802.11 header length.
  4061. *
  4062. * Return: The 802.11 header length in bytes (not including encryption
  4063. * headers). Or 0 if the data in the sk_buff is too short to contain a valid
  4064. * 802.11 header.
  4065. */
  4066. unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
  4067. /**
  4068. * ieee80211_hdrlen - get header length in bytes from frame control
  4069. * @fc: frame control field in little-endian format
  4070. * Return: The header length in bytes.
  4071. */
  4072. unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
  4073. /**
  4074. * ieee80211_get_mesh_hdrlen - get mesh extension header length
  4075. * @meshhdr: the mesh extension header, only the flags field
  4076. * (first byte) will be accessed
  4077. * Return: The length of the extension header, which is always at
  4078. * least 6 bytes and at most 18 if address 5 and 6 are present.
  4079. */
  4080. unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
  4081. /**
  4082. * DOC: Data path helpers
  4083. *
  4084. * In addition to generic utilities, cfg80211 also offers
  4085. * functions that help implement the data path for devices
  4086. * that do not do the 802.11/802.3 conversion on the device.
  4087. */
  4088. /**
  4089. * ieee80211_data_to_8023_exthdr - convert an 802.11 data frame to 802.3
  4090. * @skb: the 802.11 data frame
  4091. * @ehdr: pointer to a &struct ethhdr that will get the header, instead
  4092. * of it being pushed into the SKB
  4093. * @addr: the device MAC address
  4094. * @iftype: the virtual interface type
  4095. * @data_offset: offset of payload after the 802.11 header
  4096. * Return: 0 on success. Non-zero on error.
  4097. */
  4098. int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
  4099. const u8 *addr, enum nl80211_iftype iftype,
  4100. u8 data_offset);
  4101. /**
  4102. * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
  4103. * @skb: the 802.11 data frame
  4104. * @addr: the device MAC address
  4105. * @iftype: the virtual interface type
  4106. * Return: 0 on success. Non-zero on error.
  4107. */
  4108. static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
  4109. enum nl80211_iftype iftype)
  4110. {
  4111. return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0);
  4112. }
  4113. /**
  4114. * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame
  4115. *
  4116. * Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames.
  4117. * The @list will be empty if the decode fails. The @skb must be fully
  4118. * header-less before being passed in here; it is freed in this function.
  4119. *
  4120. * @skb: The input A-MSDU frame without any headers.
  4121. * @list: The output list of 802.3 frames. It must be allocated and
  4122. * initialized by by the caller.
  4123. * @addr: The device MAC address.
  4124. * @iftype: The device interface type.
  4125. * @extra_headroom: The hardware extra headroom for SKBs in the @list.
  4126. * @check_da: DA to check in the inner ethernet header, or NULL
  4127. * @check_sa: SA to check in the inner ethernet header, or NULL
  4128. */
  4129. void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
  4130. const u8 *addr, enum nl80211_iftype iftype,
  4131. const unsigned int extra_headroom,
  4132. const u8 *check_da, const u8 *check_sa);
  4133. /**
  4134. * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame
  4135. * @skb: the data frame
  4136. * @qos_map: Interworking QoS mapping or %NULL if not in use
  4137. * Return: The 802.1p/1d tag.
  4138. */
  4139. unsigned int cfg80211_classify8021d(struct sk_buff *skb,
  4140. struct cfg80211_qos_map *qos_map);
  4141. /**
  4142. * cfg80211_find_ie_match - match information element and byte array in data
  4143. *
  4144. * @eid: element ID
  4145. * @ies: data consisting of IEs
  4146. * @len: length of data
  4147. * @match: byte array to match
  4148. * @match_len: number of bytes in the match array
  4149. * @match_offset: offset in the IE where the byte array should match.
  4150. * If match_len is zero, this must also be set to zero.
  4151. * Otherwise this must be set to 2 or more, because the first
  4152. * byte is the element id, which is already compared to eid, and
  4153. * the second byte is the IE length.
  4154. *
  4155. * Return: %NULL if the element ID could not be found or if
  4156. * the element is invalid (claims to be longer than the given
  4157. * data) or if the byte array doesn't match, or a pointer to the first
  4158. * byte of the requested element, that is the byte containing the
  4159. * element ID.
  4160. *
  4161. * Note: There are no checks on the element length other than
  4162. * having to fit into the given data and being large enough for the
  4163. * byte array to match.
  4164. */
  4165. const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
  4166. const u8 *match, int match_len,
  4167. int match_offset);
  4168. /**
  4169. * cfg80211_find_ie - find information element in data
  4170. *
  4171. * @eid: element ID
  4172. * @ies: data consisting of IEs
  4173. * @len: length of data
  4174. *
  4175. * Return: %NULL if the element ID could not be found or if
  4176. * the element is invalid (claims to be longer than the given
  4177. * data), or a pointer to the first byte of the requested
  4178. * element, that is the byte containing the element ID.
  4179. *
  4180. * Note: There are no checks on the element length other than
  4181. * having to fit into the given data.
  4182. */
  4183. static inline const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
  4184. {
  4185. return cfg80211_find_ie_match(eid, ies, len, NULL, 0, 0);
  4186. }
  4187. /**
  4188. * cfg80211_find_ext_ie - find information element with EID Extension in data
  4189. *
  4190. * @ext_eid: element ID Extension
  4191. * @ies: data consisting of IEs
  4192. * @len: length of data
  4193. *
  4194. * Return: %NULL if the extended element ID could not be found or if
  4195. * the element is invalid (claims to be longer than the given
  4196. * data), or a pointer to the first byte of the requested
  4197. * element, that is the byte containing the element ID.
  4198. *
  4199. * Note: There are no checks on the element length other than
  4200. * having to fit into the given data.
  4201. */
  4202. static inline const u8 *cfg80211_find_ext_ie(u8 ext_eid, const u8 *ies, int len)
  4203. {
  4204. return cfg80211_find_ie_match(WLAN_EID_EXTENSION, ies, len,
  4205. &ext_eid, 1, 2);
  4206. }
  4207. /**
  4208. * cfg80211_find_vendor_ie - find vendor specific information element in data
  4209. *
  4210. * @oui: vendor OUI
  4211. * @oui_type: vendor-specific OUI type (must be < 0xff), negative means any
  4212. * @ies: data consisting of IEs
  4213. * @len: length of data
  4214. *
  4215. * Return: %NULL if the vendor specific element ID could not be found or if the
  4216. * element is invalid (claims to be longer than the given data), or a pointer to
  4217. * the first byte of the requested element, that is the byte containing the
  4218. * element ID.
  4219. *
  4220. * Note: There are no checks on the element length other than having to fit into
  4221. * the given data.
  4222. */
  4223. const u8 *cfg80211_find_vendor_ie(unsigned int oui, int oui_type,
  4224. const u8 *ies, int len);
  4225. /**
  4226. * DOC: Regulatory enforcement infrastructure
  4227. *
  4228. * TODO
  4229. */
  4230. /**
  4231. * regulatory_hint - driver hint to the wireless core a regulatory domain
  4232. * @wiphy: the wireless device giving the hint (used only for reporting
  4233. * conflicts)
  4234. * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
  4235. * should be in. If @rd is set this should be NULL. Note that if you
  4236. * set this to NULL you should still set rd->alpha2 to some accepted
  4237. * alpha2.
  4238. *
  4239. * Wireless drivers can use this function to hint to the wireless core
  4240. * what it believes should be the current regulatory domain by
  4241. * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
  4242. * domain should be in or by providing a completely build regulatory domain.
  4243. * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
  4244. * for a regulatory domain structure for the respective country.
  4245. *
  4246. * The wiphy must have been registered to cfg80211 prior to this call.
  4247. * For cfg80211 drivers this means you must first use wiphy_register(),
  4248. * for mac80211 drivers you must first use ieee80211_register_hw().
  4249. *
  4250. * Drivers should check the return value, its possible you can get
  4251. * an -ENOMEM.
  4252. *
  4253. * Return: 0 on success. -ENOMEM.
  4254. */
  4255. int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
  4256. /**
  4257. * regulatory_set_wiphy_regd - set regdom info for self managed drivers
  4258. * @wiphy: the wireless device we want to process the regulatory domain on
  4259. * @rd: the regulatory domain informatoin to use for this wiphy
  4260. *
  4261. * Set the regulatory domain information for self-managed wiphys, only they
  4262. * may use this function. See %REGULATORY_WIPHY_SELF_MANAGED for more
  4263. * information.
  4264. *
  4265. * Return: 0 on success. -EINVAL, -EPERM
  4266. */
  4267. int regulatory_set_wiphy_regd(struct wiphy *wiphy,
  4268. struct ieee80211_regdomain *rd);
  4269. /**
  4270. * regulatory_set_wiphy_regd_sync_rtnl - set regdom for self-managed drivers
  4271. * @wiphy: the wireless device we want to process the regulatory domain on
  4272. * @rd: the regulatory domain information to use for this wiphy
  4273. *
  4274. * This functions requires the RTNL to be held and applies the new regdomain
  4275. * synchronously to this wiphy. For more details see
  4276. * regulatory_set_wiphy_regd().
  4277. *
  4278. * Return: 0 on success. -EINVAL, -EPERM
  4279. */
  4280. int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
  4281. struct ieee80211_regdomain *rd);
  4282. /**
  4283. * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  4284. * @wiphy: the wireless device we want to process the regulatory domain on
  4285. * @regd: the custom regulatory domain to use for this wiphy
  4286. *
  4287. * Drivers can sometimes have custom regulatory domains which do not apply
  4288. * to a specific country. Drivers can use this to apply such custom regulatory
  4289. * domains. This routine must be called prior to wiphy registration. The
  4290. * custom regulatory domain will be trusted completely and as such previous
  4291. * default channel settings will be disregarded. If no rule is found for a
  4292. * channel on the regulatory domain the channel will be disabled.
  4293. * Drivers using this for a wiphy should also set the wiphy flag
  4294. * REGULATORY_CUSTOM_REG or cfg80211 will set it for the wiphy
  4295. * that called this helper.
  4296. */
  4297. void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
  4298. const struct ieee80211_regdomain *regd);
  4299. /**
  4300. * freq_reg_info - get regulatory information for the given frequency
  4301. * @wiphy: the wiphy for which we want to process this rule for
  4302. * @center_freq: Frequency in KHz for which we want regulatory information for
  4303. *
  4304. * Use this function to get the regulatory rule for a specific frequency on
  4305. * a given wireless device. If the device has a specific regulatory domain
  4306. * it wants to follow we respect that unless a country IE has been received
  4307. * and processed already.
  4308. *
  4309. * Return: A valid pointer, or, when an error occurs, for example if no rule
  4310. * can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to
  4311. * check and PTR_ERR() to obtain the numeric return value. The numeric return
  4312. * value will be -ERANGE if we determine the given center_freq does not even
  4313. * have a regulatory rule for a frequency range in the center_freq's band.
  4314. * See freq_in_rule_band() for our current definition of a band -- this is
  4315. * purely subjective and right now it's 802.11 specific.
  4316. */
  4317. const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
  4318. u32 center_freq);
  4319. /**
  4320. * reg_initiator_name - map regulatory request initiator enum to name
  4321. * @initiator: the regulatory request initiator
  4322. *
  4323. * You can use this to map the regulatory request initiator enum to a
  4324. * proper string representation.
  4325. */
  4326. const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
  4327. /*
  4328. * callbacks for asynchronous cfg80211 methods, notification
  4329. * functions and BSS handling helpers
  4330. */
  4331. /**
  4332. * cfg80211_scan_done - notify that scan finished
  4333. *
  4334. * @request: the corresponding scan request
  4335. * @info: information about the completed scan
  4336. */
  4337. void cfg80211_scan_done(struct cfg80211_scan_request *request,
  4338. struct cfg80211_scan_info *info);
  4339. /**
  4340. * cfg80211_sched_scan_results - notify that new scan results are available
  4341. *
  4342. * @wiphy: the wiphy which got scheduled scan results
  4343. * @reqid: identifier for the related scheduled scan request
  4344. */
  4345. void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
  4346. /**
  4347. * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
  4348. *
  4349. * @wiphy: the wiphy on which the scheduled scan stopped
  4350. * @reqid: identifier for the related scheduled scan request
  4351. *
  4352. * The driver can call this function to inform cfg80211 that the
  4353. * scheduled scan had to be stopped, for whatever reason. The driver
  4354. * is then called back via the sched_scan_stop operation when done.
  4355. */
  4356. void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
  4357. /**
  4358. * cfg80211_sched_scan_stopped_rtnl - notify that the scheduled scan has stopped
  4359. *
  4360. * @wiphy: the wiphy on which the scheduled scan stopped
  4361. * @reqid: identifier for the related scheduled scan request
  4362. *
  4363. * The driver can call this function to inform cfg80211 that the
  4364. * scheduled scan had to be stopped, for whatever reason. The driver
  4365. * is then called back via the sched_scan_stop operation when done.
  4366. * This function should be called with rtnl locked.
  4367. */
  4368. void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy, u64 reqid);
  4369. /**
  4370. * cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
  4371. * @wiphy: the wiphy reporting the BSS
  4372. * @data: the BSS metadata
  4373. * @mgmt: the management frame (probe response or beacon)
  4374. * @len: length of the management frame
  4375. * @gfp: context flags
  4376. *
  4377. * This informs cfg80211 that BSS information was found and
  4378. * the BSS should be updated/added.
  4379. *
  4380. * Return: A referenced struct, must be released with cfg80211_put_bss()!
  4381. * Or %NULL on error.
  4382. */
  4383. struct cfg80211_bss * __must_check
  4384. cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
  4385. struct cfg80211_inform_bss *data,
  4386. struct ieee80211_mgmt *mgmt, size_t len,
  4387. gfp_t gfp);
  4388. static inline struct cfg80211_bss * __must_check
  4389. cfg80211_inform_bss_width_frame(struct wiphy *wiphy,
  4390. struct ieee80211_channel *rx_channel,
  4391. enum nl80211_bss_scan_width scan_width,
  4392. struct ieee80211_mgmt *mgmt, size_t len,
  4393. s32 signal, gfp_t gfp)
  4394. {
  4395. struct cfg80211_inform_bss data = {
  4396. .chan = rx_channel,
  4397. .scan_width = scan_width,
  4398. .signal = signal,
  4399. };
  4400. return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
  4401. }
  4402. static inline struct cfg80211_bss * __must_check
  4403. cfg80211_inform_bss_frame(struct wiphy *wiphy,
  4404. struct ieee80211_channel *rx_channel,
  4405. struct ieee80211_mgmt *mgmt, size_t len,
  4406. s32 signal, gfp_t gfp)
  4407. {
  4408. struct cfg80211_inform_bss data = {
  4409. .chan = rx_channel,
  4410. .scan_width = NL80211_BSS_CHAN_WIDTH_20,
  4411. .signal = signal,
  4412. };
  4413. return cfg80211_inform_bss_frame_data(wiphy, &data, mgmt, len, gfp);
  4414. }
  4415. /**
  4416. * enum cfg80211_bss_frame_type - frame type that the BSS data came from
  4417. * @CFG80211_BSS_FTYPE_UNKNOWN: driver doesn't know whether the data is
  4418. * from a beacon or probe response
  4419. * @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon
  4420. * @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response
  4421. */
  4422. enum cfg80211_bss_frame_type {
  4423. CFG80211_BSS_FTYPE_UNKNOWN,
  4424. CFG80211_BSS_FTYPE_BEACON,
  4425. CFG80211_BSS_FTYPE_PRESP,
  4426. };
  4427. /**
  4428. * cfg80211_inform_bss_data - inform cfg80211 of a new BSS
  4429. *
  4430. * @wiphy: the wiphy reporting the BSS
  4431. * @data: the BSS metadata
  4432. * @ftype: frame type (if known)
  4433. * @bssid: the BSSID of the BSS
  4434. * @tsf: the TSF sent by the peer in the beacon/probe response (or 0)
  4435. * @capability: the capability field sent by the peer
  4436. * @beacon_interval: the beacon interval announced by the peer
  4437. * @ie: additional IEs sent by the peer
  4438. * @ielen: length of the additional IEs
  4439. * @gfp: context flags
  4440. *
  4441. * This informs cfg80211 that BSS information was found and
  4442. * the BSS should be updated/added.
  4443. *
  4444. * Return: A referenced struct, must be released with cfg80211_put_bss()!
  4445. * Or %NULL on error.
  4446. */
  4447. struct cfg80211_bss * __must_check
  4448. cfg80211_inform_bss_data(struct wiphy *wiphy,
  4449. struct cfg80211_inform_bss *data,
  4450. enum cfg80211_bss_frame_type ftype,
  4451. const u8 *bssid, u64 tsf, u16 capability,
  4452. u16 beacon_interval, const u8 *ie, size_t ielen,
  4453. gfp_t gfp);
  4454. static inline struct cfg80211_bss * __must_check
  4455. cfg80211_inform_bss_width(struct wiphy *wiphy,
  4456. struct ieee80211_channel *rx_channel,
  4457. enum nl80211_bss_scan_width scan_width,
  4458. enum cfg80211_bss_frame_type ftype,
  4459. const u8 *bssid, u64 tsf, u16 capability,
  4460. u16 beacon_interval, const u8 *ie, size_t ielen,
  4461. s32 signal, gfp_t gfp)
  4462. {
  4463. struct cfg80211_inform_bss data = {
  4464. .chan = rx_channel,
  4465. .scan_width = scan_width,
  4466. .signal = signal,
  4467. };
  4468. return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
  4469. capability, beacon_interval, ie, ielen,
  4470. gfp);
  4471. }
  4472. static inline struct cfg80211_bss * __must_check
  4473. cfg80211_inform_bss(struct wiphy *wiphy,
  4474. struct ieee80211_channel *rx_channel,
  4475. enum cfg80211_bss_frame_type ftype,
  4476. const u8 *bssid, u64 tsf, u16 capability,
  4477. u16 beacon_interval, const u8 *ie, size_t ielen,
  4478. s32 signal, gfp_t gfp)
  4479. {
  4480. struct cfg80211_inform_bss data = {
  4481. .chan = rx_channel,
  4482. .scan_width = NL80211_BSS_CHAN_WIDTH_20,
  4483. .signal = signal,
  4484. };
  4485. return cfg80211_inform_bss_data(wiphy, &data, ftype, bssid, tsf,
  4486. capability, beacon_interval, ie, ielen,
  4487. gfp);
  4488. }
  4489. /**
  4490. * cfg80211_get_bss - get a BSS reference
  4491. * @wiphy: the wiphy this BSS struct belongs to
  4492. * @channel: the channel to search on (or %NULL)
  4493. * @bssid: the desired BSSID (or %NULL)
  4494. * @ssid: the desired SSID (or %NULL)
  4495. * @ssid_len: length of the SSID (or 0)
  4496. * @bss_type: type of BSS, see &enum ieee80211_bss_type
  4497. * @privacy: privacy filter, see &enum ieee80211_privacy
  4498. */
  4499. struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
  4500. struct ieee80211_channel *channel,
  4501. const u8 *bssid,
  4502. const u8 *ssid, size_t ssid_len,
  4503. enum ieee80211_bss_type bss_type,
  4504. enum ieee80211_privacy privacy);
  4505. static inline struct cfg80211_bss *
  4506. cfg80211_get_ibss(struct wiphy *wiphy,
  4507. struct ieee80211_channel *channel,
  4508. const u8 *ssid, size_t ssid_len)
  4509. {
  4510. return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
  4511. IEEE80211_BSS_TYPE_IBSS,
  4512. IEEE80211_PRIVACY_ANY);
  4513. }
  4514. /**
  4515. * cfg80211_ref_bss - reference BSS struct
  4516. * @wiphy: the wiphy this BSS struct belongs to
  4517. * @bss: the BSS struct to reference
  4518. *
  4519. * Increments the refcount of the given BSS struct.
  4520. */
  4521. void cfg80211_ref_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  4522. /**
  4523. * cfg80211_put_bss - unref BSS struct
  4524. * @wiphy: the wiphy this BSS struct belongs to
  4525. * @bss: the BSS struct
  4526. *
  4527. * Decrements the refcount of the given BSS struct.
  4528. */
  4529. void cfg80211_put_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  4530. /**
  4531. * cfg80211_unlink_bss - unlink BSS from internal data structures
  4532. * @wiphy: the wiphy
  4533. * @bss: the bss to remove
  4534. *
  4535. * This function removes the given BSS from the internal data structures
  4536. * thereby making it no longer show up in scan results etc. Use this
  4537. * function when you detect a BSS is gone. Normally BSSes will also time
  4538. * out, so it is not necessary to use this function at all.
  4539. */
  4540. void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss);
  4541. static inline enum nl80211_bss_scan_width
  4542. cfg80211_chandef_to_scan_width(const struct cfg80211_chan_def *chandef)
  4543. {
  4544. switch (chandef->width) {
  4545. case NL80211_CHAN_WIDTH_5:
  4546. return NL80211_BSS_CHAN_WIDTH_5;
  4547. case NL80211_CHAN_WIDTH_10:
  4548. return NL80211_BSS_CHAN_WIDTH_10;
  4549. default:
  4550. return NL80211_BSS_CHAN_WIDTH_20;
  4551. }
  4552. }
  4553. /**
  4554. * cfg80211_rx_mlme_mgmt - notification of processed MLME management frame
  4555. * @dev: network device
  4556. * @buf: authentication frame (header + body)
  4557. * @len: length of the frame data
  4558. *
  4559. * This function is called whenever an authentication, disassociation or
  4560. * deauthentication frame has been received and processed in station mode.
  4561. * After being asked to authenticate via cfg80211_ops::auth() the driver must
  4562. * call either this function or cfg80211_auth_timeout().
  4563. * After being asked to associate via cfg80211_ops::assoc() the driver must
  4564. * call either this function or cfg80211_auth_timeout().
  4565. * While connected, the driver must calls this for received and processed
  4566. * disassociation and deauthentication frames. If the frame couldn't be used
  4567. * because it was unprotected, the driver must call the function
  4568. * cfg80211_rx_unprot_mlme_mgmt() instead.
  4569. *
  4570. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4571. */
  4572. void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
  4573. /**
  4574. * cfg80211_auth_timeout - notification of timed out authentication
  4575. * @dev: network device
  4576. * @addr: The MAC address of the device with which the authentication timed out
  4577. *
  4578. * This function may sleep. The caller must hold the corresponding wdev's
  4579. * mutex.
  4580. */
  4581. void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr);
  4582. /**
  4583. * cfg80211_rx_assoc_resp - notification of processed association response
  4584. * @dev: network device
  4585. * @bss: the BSS that association was requested with, ownership of the pointer
  4586. * moves to cfg80211 in this call
  4587. * @buf: authentication frame (header + body)
  4588. * @len: length of the frame data
  4589. * @uapsd_queues: bitmap of queues configured for uapsd. Same format
  4590. * as the AC bitmap in the QoS info field
  4591. *
  4592. * After being asked to associate via cfg80211_ops::assoc() the driver must
  4593. * call either this function or cfg80211_auth_timeout().
  4594. *
  4595. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4596. */
  4597. void cfg80211_rx_assoc_resp(struct net_device *dev,
  4598. struct cfg80211_bss *bss,
  4599. const u8 *buf, size_t len,
  4600. int uapsd_queues);
  4601. /**
  4602. * cfg80211_assoc_timeout - notification of timed out association
  4603. * @dev: network device
  4604. * @bss: The BSS entry with which association timed out.
  4605. *
  4606. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4607. */
  4608. void cfg80211_assoc_timeout(struct net_device *dev, struct cfg80211_bss *bss);
  4609. /**
  4610. * cfg80211_abandon_assoc - notify cfg80211 of abandoned association attempt
  4611. * @dev: network device
  4612. * @bss: The BSS entry with which association was abandoned.
  4613. *
  4614. * Call this whenever - for reasons reported through other API, like deauth RX,
  4615. * an association attempt was abandoned.
  4616. * This function may sleep. The caller must hold the corresponding wdev's mutex.
  4617. */
  4618. void cfg80211_abandon_assoc(struct net_device *dev, struct cfg80211_bss *bss);
  4619. /**
  4620. * cfg80211_tx_mlme_mgmt - notification of transmitted deauth/disassoc frame
  4621. * @dev: network device
  4622. * @buf: 802.11 frame (header + body)
  4623. * @len: length of the frame data
  4624. *
  4625. * This function is called whenever deauthentication has been processed in
  4626. * station mode. This includes both received deauthentication frames and
  4627. * locally generated ones. This function may sleep. The caller must hold the
  4628. * corresponding wdev's mutex.
  4629. */
  4630. void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);
  4631. /**
  4632. * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame
  4633. * @dev: network device
  4634. * @buf: deauthentication frame (header + body)
  4635. * @len: length of the frame data
  4636. *
  4637. * This function is called whenever a received deauthentication or dissassoc
  4638. * frame has been dropped in station mode because of MFP being used but the
  4639. * frame was not protected. This function may sleep.
  4640. */
  4641. void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev,
  4642. const u8 *buf, size_t len);
  4643. /**
  4644. * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP)
  4645. * @dev: network device
  4646. * @addr: The source MAC address of the frame
  4647. * @key_type: The key type that the received frame used
  4648. * @key_id: Key identifier (0..3). Can be -1 if missing.
  4649. * @tsc: The TSC value of the frame that generated the MIC failure (6 octets)
  4650. * @gfp: allocation flags
  4651. *
  4652. * This function is called whenever the local MAC detects a MIC failure in a
  4653. * received frame. This matches with MLME-MICHAELMICFAILURE.indication()
  4654. * primitive.
  4655. */
  4656. void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
  4657. enum nl80211_key_type key_type, int key_id,
  4658. const u8 *tsc, gfp_t gfp);
  4659. /**
  4660. * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS
  4661. *
  4662. * @dev: network device
  4663. * @bssid: the BSSID of the IBSS joined
  4664. * @channel: the channel of the IBSS joined
  4665. * @gfp: allocation flags
  4666. *
  4667. * This function notifies cfg80211 that the device joined an IBSS or
  4668. * switched to a different BSSID. Before this function can be called,
  4669. * either a beacon has to have been received from the IBSS, or one of
  4670. * the cfg80211_inform_bss{,_frame} functions must have been called
  4671. * with the locally generated beacon -- this guarantees that there is
  4672. * always a scan result for this IBSS. cfg80211 will handle the rest.
  4673. */
  4674. void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  4675. struct ieee80211_channel *channel, gfp_t gfp);
  4676. /**
  4677. * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
  4678. *
  4679. * @dev: network device
  4680. * @macaddr: the MAC address of the new candidate
  4681. * @ie: information elements advertised by the peer candidate
  4682. * @ie_len: lenght of the information elements buffer
  4683. * @gfp: allocation flags
  4684. *
  4685. * This function notifies cfg80211 that the mesh peer candidate has been
  4686. * detected, most likely via a beacon or, less likely, via a probe response.
  4687. * cfg80211 then sends a notification to userspace.
  4688. */
  4689. void cfg80211_notify_new_peer_candidate(struct net_device *dev,
  4690. const u8 *macaddr, const u8 *ie, u8 ie_len, gfp_t gfp);
  4691. /**
  4692. * DOC: RFkill integration
  4693. *
  4694. * RFkill integration in cfg80211 is almost invisible to drivers,
  4695. * as cfg80211 automatically registers an rfkill instance for each
  4696. * wireless device it knows about. Soft kill is also translated
  4697. * into disconnecting and turning all interfaces off, drivers are
  4698. * expected to turn off the device when all interfaces are down.
  4699. *
  4700. * However, devices may have a hard RFkill line, in which case they
  4701. * also need to interact with the rfkill subsystem, via cfg80211.
  4702. * They can do this with a few helper functions documented here.
  4703. */
  4704. /**
  4705. * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state
  4706. * @wiphy: the wiphy
  4707. * @blocked: block status
  4708. */
  4709. void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked);
  4710. /**
  4711. * wiphy_rfkill_start_polling - start polling rfkill
  4712. * @wiphy: the wiphy
  4713. */
  4714. void wiphy_rfkill_start_polling(struct wiphy *wiphy);
  4715. /**
  4716. * wiphy_rfkill_stop_polling - stop polling rfkill
  4717. * @wiphy: the wiphy
  4718. */
  4719. void wiphy_rfkill_stop_polling(struct wiphy *wiphy);
  4720. /**
  4721. * DOC: Vendor commands
  4722. *
  4723. * Occasionally, there are special protocol or firmware features that
  4724. * can't be implemented very openly. For this and similar cases, the
  4725. * vendor command functionality allows implementing the features with
  4726. * (typically closed-source) userspace and firmware, using nl80211 as
  4727. * the configuration mechanism.
  4728. *
  4729. * A driver supporting vendor commands must register them as an array
  4730. * in struct wiphy, with handlers for each one, each command has an
  4731. * OUI and sub command ID to identify it.
  4732. *
  4733. * Note that this feature should not be (ab)used to implement protocol
  4734. * features that could openly be shared across drivers. In particular,
  4735. * it must never be required to use vendor commands to implement any
  4736. * "normal" functionality that higher-level userspace like connection
  4737. * managers etc. need.
  4738. */
  4739. struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
  4740. enum nl80211_commands cmd,
  4741. enum nl80211_attrs attr,
  4742. int approxlen);
  4743. struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
  4744. struct wireless_dev *wdev,
  4745. enum nl80211_commands cmd,
  4746. enum nl80211_attrs attr,
  4747. int vendor_event_idx,
  4748. int approxlen, gfp_t gfp);
  4749. void __cfg80211_send_event_skb(struct sk_buff *skb, gfp_t gfp);
  4750. /**
  4751. * cfg80211_vendor_cmd_alloc_reply_skb - allocate vendor command reply
  4752. * @wiphy: the wiphy
  4753. * @approxlen: an upper bound of the length of the data that will
  4754. * be put into the skb
  4755. *
  4756. * This function allocates and pre-fills an skb for a reply to
  4757. * a vendor command. Since it is intended for a reply, calling
  4758. * it outside of a vendor command's doit() operation is invalid.
  4759. *
  4760. * The returned skb is pre-filled with some identifying data in
  4761. * a way that any data that is put into the skb (with skb_put(),
  4762. * nla_put() or similar) will end up being within the
  4763. * %NL80211_ATTR_VENDOR_DATA attribute, so all that needs to be done
  4764. * with the skb is adding data for the corresponding userspace tool
  4765. * which can then read that data out of the vendor data attribute.
  4766. * You must not modify the skb in any other way.
  4767. *
  4768. * When done, call cfg80211_vendor_cmd_reply() with the skb and return
  4769. * its error code as the result of the doit() operation.
  4770. *
  4771. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4772. */
  4773. static inline struct sk_buff *
  4774. cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
  4775. {
  4776. return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_VENDOR,
  4777. NL80211_ATTR_VENDOR_DATA, approxlen);
  4778. }
  4779. /**
  4780. * cfg80211_vendor_cmd_reply - send the reply skb
  4781. * @skb: The skb, must have been allocated with
  4782. * cfg80211_vendor_cmd_alloc_reply_skb()
  4783. *
  4784. * Since calling this function will usually be the last thing
  4785. * before returning from the vendor command doit() you should
  4786. * return the error code. Note that this function consumes the
  4787. * skb regardless of the return value.
  4788. *
  4789. * Return: An error code or 0 on success.
  4790. */
  4791. int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
  4792. /**
  4793. * cfg80211_vendor_event_alloc - allocate vendor-specific event skb
  4794. * @wiphy: the wiphy
  4795. * @wdev: the wireless device
  4796. * @event_idx: index of the vendor event in the wiphy's vendor_events
  4797. * @approxlen: an upper bound of the length of the data that will
  4798. * be put into the skb
  4799. * @gfp: allocation flags
  4800. *
  4801. * This function allocates and pre-fills an skb for an event on the
  4802. * vendor-specific multicast group.
  4803. *
  4804. * If wdev != NULL, both the ifindex and identifier of the specified
  4805. * wireless device are added to the event message before the vendor data
  4806. * attribute.
  4807. *
  4808. * When done filling the skb, call cfg80211_vendor_event() with the
  4809. * skb to send the event.
  4810. *
  4811. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4812. */
  4813. static inline struct sk_buff *
  4814. cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
  4815. int approxlen, int event_idx, gfp_t gfp)
  4816. {
  4817. return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
  4818. NL80211_ATTR_VENDOR_DATA,
  4819. event_idx, approxlen, gfp);
  4820. }
  4821. /**
  4822. * cfg80211_vendor_event - send the event
  4823. * @skb: The skb, must have been allocated with cfg80211_vendor_event_alloc()
  4824. * @gfp: allocation flags
  4825. *
  4826. * This function sends the given @skb, which must have been allocated
  4827. * by cfg80211_vendor_event_alloc(), as an event. It always consumes it.
  4828. */
  4829. static inline void cfg80211_vendor_event(struct sk_buff *skb, gfp_t gfp)
  4830. {
  4831. __cfg80211_send_event_skb(skb, gfp);
  4832. }
  4833. #ifdef CONFIG_NL80211_TESTMODE
  4834. /**
  4835. * DOC: Test mode
  4836. *
  4837. * Test mode is a set of utility functions to allow drivers to
  4838. * interact with driver-specific tools to aid, for instance,
  4839. * factory programming.
  4840. *
  4841. * This chapter describes how drivers interact with it, for more
  4842. * information see the nl80211 book's chapter on it.
  4843. */
  4844. /**
  4845. * cfg80211_testmode_alloc_reply_skb - allocate testmode reply
  4846. * @wiphy: the wiphy
  4847. * @approxlen: an upper bound of the length of the data that will
  4848. * be put into the skb
  4849. *
  4850. * This function allocates and pre-fills an skb for a reply to
  4851. * the testmode command. Since it is intended for a reply, calling
  4852. * it outside of the @testmode_cmd operation is invalid.
  4853. *
  4854. * The returned skb is pre-filled with the wiphy index and set up in
  4855. * a way that any data that is put into the skb (with skb_put(),
  4856. * nla_put() or similar) will end up being within the
  4857. * %NL80211_ATTR_TESTDATA attribute, so all that needs to be done
  4858. * with the skb is adding data for the corresponding userspace tool
  4859. * which can then read that data out of the testdata attribute. You
  4860. * must not modify the skb in any other way.
  4861. *
  4862. * When done, call cfg80211_testmode_reply() with the skb and return
  4863. * its error code as the result of the @testmode_cmd operation.
  4864. *
  4865. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4866. */
  4867. static inline struct sk_buff *
  4868. cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
  4869. {
  4870. return __cfg80211_alloc_reply_skb(wiphy, NL80211_CMD_TESTMODE,
  4871. NL80211_ATTR_TESTDATA, approxlen);
  4872. }
  4873. /**
  4874. * cfg80211_testmode_reply - send the reply skb
  4875. * @skb: The skb, must have been allocated with
  4876. * cfg80211_testmode_alloc_reply_skb()
  4877. *
  4878. * Since calling this function will usually be the last thing
  4879. * before returning from the @testmode_cmd you should return
  4880. * the error code. Note that this function consumes the skb
  4881. * regardless of the return value.
  4882. *
  4883. * Return: An error code or 0 on success.
  4884. */
  4885. static inline int cfg80211_testmode_reply(struct sk_buff *skb)
  4886. {
  4887. return cfg80211_vendor_cmd_reply(skb);
  4888. }
  4889. /**
  4890. * cfg80211_testmode_alloc_event_skb - allocate testmode event
  4891. * @wiphy: the wiphy
  4892. * @approxlen: an upper bound of the length of the data that will
  4893. * be put into the skb
  4894. * @gfp: allocation flags
  4895. *
  4896. * This function allocates and pre-fills an skb for an event on the
  4897. * testmode multicast group.
  4898. *
  4899. * The returned skb is set up in the same way as with
  4900. * cfg80211_testmode_alloc_reply_skb() but prepared for an event. As
  4901. * there, you should simply add data to it that will then end up in the
  4902. * %NL80211_ATTR_TESTDATA attribute. Again, you must not modify the skb
  4903. * in any other way.
  4904. *
  4905. * When done filling the skb, call cfg80211_testmode_event() with the
  4906. * skb to send the event.
  4907. *
  4908. * Return: An allocated and pre-filled skb. %NULL if any errors happen.
  4909. */
  4910. static inline struct sk_buff *
  4911. cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
  4912. {
  4913. return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
  4914. NL80211_ATTR_TESTDATA, -1,
  4915. approxlen, gfp);
  4916. }
  4917. /**
  4918. * cfg80211_testmode_event - send the event
  4919. * @skb: The skb, must have been allocated with
  4920. * cfg80211_testmode_alloc_event_skb()
  4921. * @gfp: allocation flags
  4922. *
  4923. * This function sends the given @skb, which must have been allocated
  4924. * by cfg80211_testmode_alloc_event_skb(), as an event. It always
  4925. * consumes it.
  4926. */
  4927. static inline void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
  4928. {
  4929. __cfg80211_send_event_skb(skb, gfp);
  4930. }
  4931. #define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd),
  4932. #define CFG80211_TESTMODE_DUMP(cmd) .testmode_dump = (cmd),
  4933. #else
  4934. #define CFG80211_TESTMODE_CMD(cmd)
  4935. #define CFG80211_TESTMODE_DUMP(cmd)
  4936. #endif
  4937. /**
  4938. * struct cfg80211_connect_resp_params - Connection response params
  4939. * @status: Status code, %WLAN_STATUS_SUCCESS for successful connection, use
  4940. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  4941. * the real status code for failures. If this call is used to report a
  4942. * failure due to a timeout (e.g., not receiving an Authentication frame
  4943. * from the AP) instead of an explicit rejection by the AP, -1 is used to
  4944. * indicate that this is a failure, but without a status code.
  4945. * @timeout_reason is used to report the reason for the timeout in that
  4946. * case.
  4947. * @bssid: The BSSID of the AP (may be %NULL)
  4948. * @bss: Entry of bss to which STA got connected to, can be obtained through
  4949. * cfg80211_get_bss() (may be %NULL). Only one parameter among @bssid and
  4950. * @bss needs to be specified.
  4951. * @req_ie: Association request IEs (may be %NULL)
  4952. * @req_ie_len: Association request IEs length
  4953. * @resp_ie: Association response IEs (may be %NULL)
  4954. * @resp_ie_len: Association response IEs length
  4955. * @fils_kek: KEK derived from a successful FILS connection (may be %NULL)
  4956. * @fils_kek_len: Length of @fils_kek in octets
  4957. * @update_erp_next_seq_num: Boolean value to specify whether the value in
  4958. * @fils_erp_next_seq_num is valid.
  4959. * @fils_erp_next_seq_num: The next sequence number to use in ERP message in
  4960. * FILS Authentication. This value should be specified irrespective of the
  4961. * status for a FILS connection.
  4962. * @pmk: A new PMK if derived from a successful FILS connection (may be %NULL).
  4963. * @pmk_len: Length of @pmk in octets
  4964. * @pmkid: A new PMKID if derived from a successful FILS connection or the PMKID
  4965. * used for this FILS connection (may be %NULL).
  4966. * @timeout_reason: Reason for connection timeout. This is used when the
  4967. * connection fails due to a timeout instead of an explicit rejection from
  4968. * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
  4969. * not known. This value is used only if @status < 0 to indicate that the
  4970. * failure is due to a timeout and not due to explicit rejection by the AP.
  4971. * This value is ignored in other cases (@status >= 0).
  4972. */
  4973. struct cfg80211_connect_resp_params {
  4974. int status;
  4975. const u8 *bssid;
  4976. struct cfg80211_bss *bss;
  4977. const u8 *req_ie;
  4978. size_t req_ie_len;
  4979. const u8 *resp_ie;
  4980. size_t resp_ie_len;
  4981. const u8 *fils_kek;
  4982. size_t fils_kek_len;
  4983. bool update_erp_next_seq_num;
  4984. u16 fils_erp_next_seq_num;
  4985. const u8 *pmk;
  4986. size_t pmk_len;
  4987. const u8 *pmkid;
  4988. enum nl80211_timeout_reason timeout_reason;
  4989. };
  4990. /**
  4991. * cfg80211_connect_done - notify cfg80211 of connection result
  4992. *
  4993. * @dev: network device
  4994. * @params: connection response parameters
  4995. * @gfp: allocation flags
  4996. *
  4997. * It should be called by the underlying driver once execution of the connection
  4998. * request from connect() has been completed. This is similar to
  4999. * cfg80211_connect_bss(), but takes a structure pointer for connection response
  5000. * parameters. Only one of the functions among cfg80211_connect_bss(),
  5001. * cfg80211_connect_result(), cfg80211_connect_timeout(),
  5002. * and cfg80211_connect_done() should be called.
  5003. */
  5004. void cfg80211_connect_done(struct net_device *dev,
  5005. struct cfg80211_connect_resp_params *params,
  5006. gfp_t gfp);
  5007. /**
  5008. * cfg80211_connect_bss - notify cfg80211 of connection result
  5009. *
  5010. * @dev: network device
  5011. * @bssid: the BSSID of the AP
  5012. * @bss: entry of bss to which STA got connected to, can be obtained
  5013. * through cfg80211_get_bss (may be %NULL)
  5014. * @req_ie: association request IEs (maybe be %NULL)
  5015. * @req_ie_len: association request IEs length
  5016. * @resp_ie: association response IEs (may be %NULL)
  5017. * @resp_ie_len: assoc response IEs length
  5018. * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  5019. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  5020. * the real status code for failures. If this call is used to report a
  5021. * failure due to a timeout (e.g., not receiving an Authentication frame
  5022. * from the AP) instead of an explicit rejection by the AP, -1 is used to
  5023. * indicate that this is a failure, but without a status code.
  5024. * @timeout_reason is used to report the reason for the timeout in that
  5025. * case.
  5026. * @gfp: allocation flags
  5027. * @timeout_reason: reason for connection timeout. This is used when the
  5028. * connection fails due to a timeout instead of an explicit rejection from
  5029. * the AP. %NL80211_TIMEOUT_UNSPECIFIED is used when the timeout reason is
  5030. * not known. This value is used only if @status < 0 to indicate that the
  5031. * failure is due to a timeout and not due to explicit rejection by the AP.
  5032. * This value is ignored in other cases (@status >= 0).
  5033. *
  5034. * It should be called by the underlying driver once execution of the connection
  5035. * request from connect() has been completed. This is similar to
  5036. * cfg80211_connect_result(), but with the option of identifying the exact bss
  5037. * entry for the connection. Only one of the functions among
  5038. * cfg80211_connect_bss(), cfg80211_connect_result(),
  5039. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  5040. */
  5041. static inline void
  5042. cfg80211_connect_bss(struct net_device *dev, const u8 *bssid,
  5043. struct cfg80211_bss *bss, const u8 *req_ie,
  5044. size_t req_ie_len, const u8 *resp_ie,
  5045. size_t resp_ie_len, int status, gfp_t gfp,
  5046. enum nl80211_timeout_reason timeout_reason)
  5047. {
  5048. struct cfg80211_connect_resp_params params;
  5049. memset(&params, 0, sizeof(params));
  5050. params.status = status;
  5051. params.bssid = bssid;
  5052. params.bss = bss;
  5053. params.req_ie = req_ie;
  5054. params.req_ie_len = req_ie_len;
  5055. params.resp_ie = resp_ie;
  5056. params.resp_ie_len = resp_ie_len;
  5057. params.timeout_reason = timeout_reason;
  5058. cfg80211_connect_done(dev, &params, gfp);
  5059. }
  5060. /**
  5061. * cfg80211_connect_result - notify cfg80211 of connection result
  5062. *
  5063. * @dev: network device
  5064. * @bssid: the BSSID of the AP
  5065. * @req_ie: association request IEs (maybe be %NULL)
  5066. * @req_ie_len: association request IEs length
  5067. * @resp_ie: association response IEs (may be %NULL)
  5068. * @resp_ie_len: assoc response IEs length
  5069. * @status: status code, %WLAN_STATUS_SUCCESS for successful connection, use
  5070. * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you
  5071. * the real status code for failures.
  5072. * @gfp: allocation flags
  5073. *
  5074. * It should be called by the underlying driver once execution of the connection
  5075. * request from connect() has been completed. This is similar to
  5076. * cfg80211_connect_bss() which allows the exact bss entry to be specified. Only
  5077. * one of the functions among cfg80211_connect_bss(), cfg80211_connect_result(),
  5078. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  5079. */
  5080. static inline void
  5081. cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
  5082. const u8 *req_ie, size_t req_ie_len,
  5083. const u8 *resp_ie, size_t resp_ie_len,
  5084. u16 status, gfp_t gfp)
  5085. {
  5086. cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, resp_ie,
  5087. resp_ie_len, status, gfp,
  5088. NL80211_TIMEOUT_UNSPECIFIED);
  5089. }
  5090. /**
  5091. * cfg80211_connect_timeout - notify cfg80211 of connection timeout
  5092. *
  5093. * @dev: network device
  5094. * @bssid: the BSSID of the AP
  5095. * @req_ie: association request IEs (maybe be %NULL)
  5096. * @req_ie_len: association request IEs length
  5097. * @gfp: allocation flags
  5098. * @timeout_reason: reason for connection timeout.
  5099. *
  5100. * It should be called by the underlying driver whenever connect() has failed
  5101. * in a sequence where no explicit authentication/association rejection was
  5102. * received from the AP. This could happen, e.g., due to not being able to send
  5103. * out the Authentication or Association Request frame or timing out while
  5104. * waiting for the response. Only one of the functions among
  5105. * cfg80211_connect_bss(), cfg80211_connect_result(),
  5106. * cfg80211_connect_timeout(), and cfg80211_connect_done() should be called.
  5107. */
  5108. static inline void
  5109. cfg80211_connect_timeout(struct net_device *dev, const u8 *bssid,
  5110. const u8 *req_ie, size_t req_ie_len, gfp_t gfp,
  5111. enum nl80211_timeout_reason timeout_reason)
  5112. {
  5113. cfg80211_connect_bss(dev, bssid, NULL, req_ie, req_ie_len, NULL, 0, -1,
  5114. gfp, timeout_reason);
  5115. }
  5116. /**
  5117. * struct cfg80211_roam_info - driver initiated roaming information
  5118. *
  5119. * @channel: the channel of the new AP
  5120. * @bss: entry of bss to which STA got roamed (may be %NULL if %bssid is set)
  5121. * @bssid: the BSSID of the new AP (may be %NULL if %bss is set)
  5122. * @req_ie: association request IEs (maybe be %NULL)
  5123. * @req_ie_len: association request IEs length
  5124. * @resp_ie: association response IEs (may be %NULL)
  5125. * @resp_ie_len: assoc response IEs length
  5126. */
  5127. struct cfg80211_roam_info {
  5128. struct ieee80211_channel *channel;
  5129. struct cfg80211_bss *bss;
  5130. const u8 *bssid;
  5131. const u8 *req_ie;
  5132. size_t req_ie_len;
  5133. const u8 *resp_ie;
  5134. size_t resp_ie_len;
  5135. };
  5136. /**
  5137. * cfg80211_roamed - notify cfg80211 of roaming
  5138. *
  5139. * @dev: network device
  5140. * @info: information about the new BSS. struct &cfg80211_roam_info.
  5141. * @gfp: allocation flags
  5142. *
  5143. * This function may be called with the driver passing either the BSSID of the
  5144. * new AP or passing the bss entry to avoid a race in timeout of the bss entry.
  5145. * It should be called by the underlying driver whenever it roamed from one AP
  5146. * to another while connected. Drivers which have roaming implemented in
  5147. * firmware should pass the bss entry to avoid a race in bss entry timeout where
  5148. * the bss entry of the new AP is seen in the driver, but gets timed out by the
  5149. * time it is accessed in __cfg80211_roamed() due to delay in scheduling
  5150. * rdev->event_work. In case of any failures, the reference is released
  5151. * either in cfg80211_roamed() or in __cfg80211_romed(), Otherwise, it will be
  5152. * released while diconneting from the current bss.
  5153. */
  5154. void cfg80211_roamed(struct net_device *dev, struct cfg80211_roam_info *info,
  5155. gfp_t gfp);
  5156. /**
  5157. * cfg80211_port_authorized - notify cfg80211 of successful security association
  5158. *
  5159. * @dev: network device
  5160. * @bssid: the BSSID of the AP
  5161. * @gfp: allocation flags
  5162. *
  5163. * This function should be called by a driver that supports 4 way handshake
  5164. * offload after a security association was successfully established (i.e.,
  5165. * the 4 way handshake was completed successfully). The call to this function
  5166. * should be preceded with a call to cfg80211_connect_result(),
  5167. * cfg80211_connect_done(), cfg80211_connect_bss() or cfg80211_roamed() to
  5168. * indicate the 802.11 association.
  5169. */
  5170. void cfg80211_port_authorized(struct net_device *dev, const u8 *bssid,
  5171. gfp_t gfp);
  5172. /**
  5173. * cfg80211_disconnected - notify cfg80211 that connection was dropped
  5174. *
  5175. * @dev: network device
  5176. * @ie: information elements of the deauth/disassoc frame (may be %NULL)
  5177. * @ie_len: length of IEs
  5178. * @reason: reason code for the disconnection, set it to 0 if unknown
  5179. * @locally_generated: disconnection was requested locally
  5180. * @gfp: allocation flags
  5181. *
  5182. * After it calls this function, the driver should enter an idle state
  5183. * and not try to connect to any AP any more.
  5184. */
  5185. void cfg80211_disconnected(struct net_device *dev, u16 reason,
  5186. const u8 *ie, size_t ie_len,
  5187. bool locally_generated, gfp_t gfp);
  5188. /**
  5189. * cfg80211_ready_on_channel - notification of remain_on_channel start
  5190. * @wdev: wireless device
  5191. * @cookie: the request cookie
  5192. * @chan: The current channel (from remain_on_channel request)
  5193. * @duration: Duration in milliseconds that the driver intents to remain on the
  5194. * channel
  5195. * @gfp: allocation flags
  5196. */
  5197. void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
  5198. struct ieee80211_channel *chan,
  5199. unsigned int duration, gfp_t gfp);
  5200. /**
  5201. * cfg80211_remain_on_channel_expired - remain_on_channel duration expired
  5202. * @wdev: wireless device
  5203. * @cookie: the request cookie
  5204. * @chan: The current channel (from remain_on_channel request)
  5205. * @gfp: allocation flags
  5206. */
  5207. void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
  5208. struct ieee80211_channel *chan,
  5209. gfp_t gfp);
  5210. /**
  5211. * cfg80211_new_sta - notify userspace about station
  5212. *
  5213. * @dev: the netdev
  5214. * @mac_addr: the station's address
  5215. * @sinfo: the station information
  5216. * @gfp: allocation flags
  5217. */
  5218. void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
  5219. struct station_info *sinfo, gfp_t gfp);
  5220. /**
  5221. * cfg80211_del_sta_sinfo - notify userspace about deletion of a station
  5222. * @dev: the netdev
  5223. * @mac_addr: the station's address
  5224. * @sinfo: the station information/statistics
  5225. * @gfp: allocation flags
  5226. */
  5227. void cfg80211_del_sta_sinfo(struct net_device *dev, const u8 *mac_addr,
  5228. struct station_info *sinfo, gfp_t gfp);
  5229. /**
  5230. * cfg80211_del_sta - notify userspace about deletion of a station
  5231. *
  5232. * @dev: the netdev
  5233. * @mac_addr: the station's address
  5234. * @gfp: allocation flags
  5235. */
  5236. static inline void cfg80211_del_sta(struct net_device *dev,
  5237. const u8 *mac_addr, gfp_t gfp)
  5238. {
  5239. cfg80211_del_sta_sinfo(dev, mac_addr, NULL, gfp);
  5240. }
  5241. /**
  5242. * cfg80211_conn_failed - connection request failed notification
  5243. *
  5244. * @dev: the netdev
  5245. * @mac_addr: the station's address
  5246. * @reason: the reason for connection failure
  5247. * @gfp: allocation flags
  5248. *
  5249. * Whenever a station tries to connect to an AP and if the station
  5250. * could not connect to the AP as the AP has rejected the connection
  5251. * for some reasons, this function is called.
  5252. *
  5253. * The reason for connection failure can be any of the value from
  5254. * nl80211_connect_failed_reason enum
  5255. */
  5256. void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
  5257. enum nl80211_connect_failed_reason reason,
  5258. gfp_t gfp);
  5259. /**
  5260. * cfg80211_rx_mgmt - notification of received, unprocessed management frame
  5261. * @wdev: wireless device receiving the frame
  5262. * @freq: Frequency on which the frame was received in MHz
  5263. * @sig_dbm: signal strength in dBm, or 0 if unknown
  5264. * @buf: Management frame (header + body)
  5265. * @len: length of the frame data
  5266. * @flags: flags, as defined in enum nl80211_rxmgmt_flags
  5267. *
  5268. * This function is called whenever an Action frame is received for a station
  5269. * mode interface, but is not processed in kernel.
  5270. *
  5271. * Return: %true if a user space application has registered for this frame.
  5272. * For action frames, that makes it responsible for rejecting unrecognized
  5273. * action frames; %false otherwise, in which case for action frames the
  5274. * driver is responsible for rejecting the frame.
  5275. */
  5276. bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm,
  5277. const u8 *buf, size_t len, u32 flags);
  5278. /**
  5279. * cfg80211_mgmt_tx_status - notification of TX status for management frame
  5280. * @wdev: wireless device receiving the frame
  5281. * @cookie: Cookie returned by cfg80211_ops::mgmt_tx()
  5282. * @buf: Management frame (header + body)
  5283. * @len: length of the frame data
  5284. * @ack: Whether frame was acknowledged
  5285. * @gfp: context flags
  5286. *
  5287. * This function is called whenever a management frame was requested to be
  5288. * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the
  5289. * transmission attempt.
  5290. */
  5291. void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
  5292. const u8 *buf, size_t len, bool ack, gfp_t gfp);
  5293. /**
  5294. * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
  5295. * @dev: network device
  5296. * @rssi_event: the triggered RSSI event
  5297. * @rssi_level: new RSSI level value or 0 if not available
  5298. * @gfp: context flags
  5299. *
  5300. * This function is called when a configured connection quality monitoring
  5301. * rssi threshold reached event occurs.
  5302. */
  5303. void cfg80211_cqm_rssi_notify(struct net_device *dev,
  5304. enum nl80211_cqm_rssi_threshold_event rssi_event,
  5305. s32 rssi_level, gfp_t gfp);
  5306. /**
  5307. * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
  5308. * @dev: network device
  5309. * @peer: peer's MAC address
  5310. * @num_packets: how many packets were lost -- should be a fixed threshold
  5311. * but probably no less than maybe 50, or maybe a throughput dependent
  5312. * threshold (to account for temporary interference)
  5313. * @gfp: context flags
  5314. */
  5315. void cfg80211_cqm_pktloss_notify(struct net_device *dev,
  5316. const u8 *peer, u32 num_packets, gfp_t gfp);
  5317. /**
  5318. * cfg80211_cqm_txe_notify - TX error rate event
  5319. * @dev: network device
  5320. * @peer: peer's MAC address
  5321. * @num_packets: how many packets were lost
  5322. * @rate: % of packets which failed transmission
  5323. * @intvl: interval (in s) over which the TX failure threshold was breached.
  5324. * @gfp: context flags
  5325. *
  5326. * Notify userspace when configured % TX failures over number of packets in a
  5327. * given interval is exceeded.
  5328. */
  5329. void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer,
  5330. u32 num_packets, u32 rate, u32 intvl, gfp_t gfp);
  5331. /**
  5332. * cfg80211_cqm_beacon_loss_notify - beacon loss event
  5333. * @dev: network device
  5334. * @gfp: context flags
  5335. *
  5336. * Notify userspace about beacon loss from the connected AP.
  5337. */
  5338. void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
  5339. /**
  5340. * cfg80211_radar_event - radar detection event
  5341. * @wiphy: the wiphy
  5342. * @chandef: chandef for the current channel
  5343. * @gfp: context flags
  5344. *
  5345. * This function is called when a radar is detected on the current chanenl.
  5346. */
  5347. void cfg80211_radar_event(struct wiphy *wiphy,
  5348. struct cfg80211_chan_def *chandef, gfp_t gfp);
  5349. /**
  5350. * cfg80211_sta_opmode_change_notify - STA's ht/vht operation mode change event
  5351. * @dev: network device
  5352. * @mac: MAC address of a station which opmode got modified
  5353. * @sta_opmode: station's current opmode value
  5354. * @gfp: context flags
  5355. *
  5356. * Driver should call this function when station's opmode modified via action
  5357. * frame.
  5358. */
  5359. void cfg80211_sta_opmode_change_notify(struct net_device *dev, const u8 *mac,
  5360. struct sta_opmode_info *sta_opmode,
  5361. gfp_t gfp);
  5362. /**
  5363. * cfg80211_cac_event - Channel availability check (CAC) event
  5364. * @netdev: network device
  5365. * @chandef: chandef for the current channel
  5366. * @event: type of event
  5367. * @gfp: context flags
  5368. *
  5369. * This function is called when a Channel availability check (CAC) is finished
  5370. * or aborted. This must be called to notify the completion of a CAC process,
  5371. * also by full-MAC drivers.
  5372. */
  5373. void cfg80211_cac_event(struct net_device *netdev,
  5374. const struct cfg80211_chan_def *chandef,
  5375. enum nl80211_radar_event event, gfp_t gfp);
  5376. /**
  5377. * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying
  5378. * @dev: network device
  5379. * @bssid: BSSID of AP (to avoid races)
  5380. * @replay_ctr: new replay counter
  5381. * @gfp: allocation flags
  5382. */
  5383. void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
  5384. const u8 *replay_ctr, gfp_t gfp);
  5385. /**
  5386. * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate
  5387. * @dev: network device
  5388. * @index: candidate index (the smaller the index, the higher the priority)
  5389. * @bssid: BSSID of AP
  5390. * @preauth: Whether AP advertises support for RSN pre-authentication
  5391. * @gfp: allocation flags
  5392. */
  5393. void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
  5394. const u8 *bssid, bool preauth, gfp_t gfp);
  5395. /**
  5396. * cfg80211_rx_spurious_frame - inform userspace about a spurious frame
  5397. * @dev: The device the frame matched to
  5398. * @addr: the transmitter address
  5399. * @gfp: context flags
  5400. *
  5401. * This function is used in AP mode (only!) to inform userspace that
  5402. * a spurious class 3 frame was received, to be able to deauth the
  5403. * sender.
  5404. * Return: %true if the frame was passed to userspace (or this failed
  5405. * for a reason other than not having a subscription.)
  5406. */
  5407. bool cfg80211_rx_spurious_frame(struct net_device *dev,
  5408. const u8 *addr, gfp_t gfp);
  5409. /**
  5410. * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame
  5411. * @dev: The device the frame matched to
  5412. * @addr: the transmitter address
  5413. * @gfp: context flags
  5414. *
  5415. * This function is used in AP mode (only!) to inform userspace that
  5416. * an associated station sent a 4addr frame but that wasn't expected.
  5417. * It is allowed and desirable to send this event only once for each
  5418. * station to avoid event flooding.
  5419. * Return: %true if the frame was passed to userspace (or this failed
  5420. * for a reason other than not having a subscription.)
  5421. */
  5422. bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
  5423. const u8 *addr, gfp_t gfp);
  5424. /**
  5425. * cfg80211_probe_status - notify userspace about probe status
  5426. * @dev: the device the probe was sent on
  5427. * @addr: the address of the peer
  5428. * @cookie: the cookie filled in @probe_client previously
  5429. * @acked: indicates whether probe was acked or not
  5430. * @ack_signal: signal strength (in dBm) of the ACK frame.
  5431. * @is_valid_ack_signal: indicates the ack_signal is valid or not.
  5432. * @gfp: allocation flags
  5433. */
  5434. void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
  5435. u64 cookie, bool acked, s32 ack_signal,
  5436. bool is_valid_ack_signal, gfp_t gfp);
  5437. /**
  5438. * cfg80211_report_obss_beacon - report beacon from other APs
  5439. * @wiphy: The wiphy that received the beacon
  5440. * @frame: the frame
  5441. * @len: length of the frame
  5442. * @freq: frequency the frame was received on
  5443. * @sig_dbm: signal strength in dBm, or 0 if unknown
  5444. *
  5445. * Use this function to report to userspace when a beacon was
  5446. * received. It is not useful to call this when there is no
  5447. * netdev that is in AP/GO mode.
  5448. */
  5449. void cfg80211_report_obss_beacon(struct wiphy *wiphy,
  5450. const u8 *frame, size_t len,
  5451. int freq, int sig_dbm);
  5452. /**
  5453. * cfg80211_reg_can_beacon - check if beaconing is allowed
  5454. * @wiphy: the wiphy
  5455. * @chandef: the channel definition
  5456. * @iftype: interface type
  5457. *
  5458. * Return: %true if there is no secondary channel or the secondary channel(s)
  5459. * can be used for beaconing (i.e. is not a radar channel etc.)
  5460. */
  5461. bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
  5462. struct cfg80211_chan_def *chandef,
  5463. enum nl80211_iftype iftype);
  5464. /**
  5465. * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation
  5466. * @wiphy: the wiphy
  5467. * @chandef: the channel definition
  5468. * @iftype: interface type
  5469. *
  5470. * Return: %true if there is no secondary channel or the secondary channel(s)
  5471. * can be used for beaconing (i.e. is not a radar channel etc.). This version
  5472. * also checks if IR-relaxation conditions apply, to allow beaconing under
  5473. * more permissive conditions.
  5474. *
  5475. * Requires the RTNL to be held.
  5476. */
  5477. bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
  5478. struct cfg80211_chan_def *chandef,
  5479. enum nl80211_iftype iftype);
  5480. /*
  5481. * cfg80211_ch_switch_notify - update wdev channel and notify userspace
  5482. * @dev: the device which switched channels
  5483. * @chandef: the new channel definition
  5484. *
  5485. * Caller must acquire wdev_lock, therefore must only be called from sleepable
  5486. * driver context!
  5487. */
  5488. void cfg80211_ch_switch_notify(struct net_device *dev,
  5489. struct cfg80211_chan_def *chandef);
  5490. /*
  5491. * cfg80211_ch_switch_started_notify - notify channel switch start
  5492. * @dev: the device on which the channel switch started
  5493. * @chandef: the future channel definition
  5494. * @count: the number of TBTTs until the channel switch happens
  5495. *
  5496. * Inform the userspace about the channel switch that has just
  5497. * started, so that it can take appropriate actions (eg. starting
  5498. * channel switch on other vifs), if necessary.
  5499. */
  5500. void cfg80211_ch_switch_started_notify(struct net_device *dev,
  5501. struct cfg80211_chan_def *chandef,
  5502. u8 count);
  5503. /**
  5504. * ieee80211_operating_class_to_band - convert operating class to band
  5505. *
  5506. * @operating_class: the operating class to convert
  5507. * @band: band pointer to fill
  5508. *
  5509. * Returns %true if the conversion was successful, %false otherwise.
  5510. */
  5511. bool ieee80211_operating_class_to_band(u8 operating_class,
  5512. enum nl80211_band *band);
  5513. /**
  5514. * ieee80211_chandef_to_operating_class - convert chandef to operation class
  5515. *
  5516. * @chandef: the chandef to convert
  5517. * @op_class: a pointer to the resulting operating class
  5518. *
  5519. * Returns %true if the conversion was successful, %false otherwise.
  5520. */
  5521. bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
  5522. u8 *op_class);
  5523. /*
  5524. * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
  5525. * @dev: the device on which the operation is requested
  5526. * @peer: the MAC address of the peer device
  5527. * @oper: the requested TDLS operation (NL80211_TDLS_SETUP or
  5528. * NL80211_TDLS_TEARDOWN)
  5529. * @reason_code: the reason code for teardown request
  5530. * @gfp: allocation flags
  5531. *
  5532. * This function is used to request userspace to perform TDLS operation that
  5533. * requires knowledge of keys, i.e., link setup or teardown when the AP
  5534. * connection uses encryption. This is optional mechanism for the driver to use
  5535. * if it can automatically determine when a TDLS link could be useful (e.g.,
  5536. * based on traffic and signal strength for a peer).
  5537. */
  5538. void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer,
  5539. enum nl80211_tdls_operation oper,
  5540. u16 reason_code, gfp_t gfp);
  5541. /*
  5542. * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units)
  5543. * @rate: given rate_info to calculate bitrate from
  5544. *
  5545. * return 0 if MCS index >= 32
  5546. */
  5547. u32 cfg80211_calculate_bitrate(struct rate_info *rate);
  5548. /**
  5549. * cfg80211_unregister_wdev - remove the given wdev
  5550. * @wdev: struct wireless_dev to remove
  5551. *
  5552. * Call this function only for wdevs that have no netdev assigned,
  5553. * e.g. P2P Devices. It removes the device from the list so that
  5554. * it can no longer be used. It is necessary to call this function
  5555. * even when cfg80211 requests the removal of the interface by
  5556. * calling the del_virtual_intf() callback. The function must also
  5557. * be called when the driver wishes to unregister the wdev, e.g.
  5558. * when the device is unbound from the driver.
  5559. *
  5560. * Requires the RTNL to be held.
  5561. */
  5562. void cfg80211_unregister_wdev(struct wireless_dev *wdev);
  5563. /**
  5564. * struct cfg80211_ft_event - FT Information Elements
  5565. * @ies: FT IEs
  5566. * @ies_len: length of the FT IE in bytes
  5567. * @target_ap: target AP's MAC address
  5568. * @ric_ies: RIC IE
  5569. * @ric_ies_len: length of the RIC IE in bytes
  5570. */
  5571. struct cfg80211_ft_event_params {
  5572. const u8 *ies;
  5573. size_t ies_len;
  5574. const u8 *target_ap;
  5575. const u8 *ric_ies;
  5576. size_t ric_ies_len;
  5577. };
  5578. /**
  5579. * cfg80211_ft_event - notify userspace about FT IE and RIC IE
  5580. * @netdev: network device
  5581. * @ft_event: IE information
  5582. */
  5583. void cfg80211_ft_event(struct net_device *netdev,
  5584. struct cfg80211_ft_event_params *ft_event);
  5585. /**
  5586. * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer
  5587. * @ies: the input IE buffer
  5588. * @len: the input length
  5589. * @attr: the attribute ID to find
  5590. * @buf: output buffer, can be %NULL if the data isn't needed, e.g.
  5591. * if the function is only called to get the needed buffer size
  5592. * @bufsize: size of the output buffer
  5593. *
  5594. * The function finds a given P2P attribute in the (vendor) IEs and
  5595. * copies its contents to the given buffer.
  5596. *
  5597. * Return: A negative error code (-%EILSEQ or -%ENOENT) if the data is
  5598. * malformed or the attribute can't be found (respectively), or the
  5599. * length of the found attribute (which can be zero).
  5600. */
  5601. int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
  5602. enum ieee80211_p2p_attr_id attr,
  5603. u8 *buf, unsigned int bufsize);
  5604. /**
  5605. * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
  5606. * @ies: the IE buffer
  5607. * @ielen: the length of the IE buffer
  5608. * @ids: an array with element IDs that are allowed before
  5609. * the split. A WLAN_EID_EXTENSION value means that the next
  5610. * EID in the list is a sub-element of the EXTENSION IE.
  5611. * @n_ids: the size of the element ID array
  5612. * @after_ric: array IE types that come after the RIC element
  5613. * @n_after_ric: size of the @after_ric array
  5614. * @offset: offset where to start splitting in the buffer
  5615. *
  5616. * This function splits an IE buffer by updating the @offset
  5617. * variable to point to the location where the buffer should be
  5618. * split.
  5619. *
  5620. * It assumes that the given IE buffer is well-formed, this
  5621. * has to be guaranteed by the caller!
  5622. *
  5623. * It also assumes that the IEs in the buffer are ordered
  5624. * correctly, if not the result of using this function will not
  5625. * be ordered correctly either, i.e. it does no reordering.
  5626. *
  5627. * The function returns the offset where the next part of the
  5628. * buffer starts, which may be @ielen if the entire (remainder)
  5629. * of the buffer should be used.
  5630. */
  5631. size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
  5632. const u8 *ids, int n_ids,
  5633. const u8 *after_ric, int n_after_ric,
  5634. size_t offset);
  5635. /**
  5636. * ieee80211_ie_split - split an IE buffer according to ordering
  5637. * @ies: the IE buffer
  5638. * @ielen: the length of the IE buffer
  5639. * @ids: an array with element IDs that are allowed before
  5640. * the split. A WLAN_EID_EXTENSION value means that the next
  5641. * EID in the list is a sub-element of the EXTENSION IE.
  5642. * @n_ids: the size of the element ID array
  5643. * @offset: offset where to start splitting in the buffer
  5644. *
  5645. * This function splits an IE buffer by updating the @offset
  5646. * variable to point to the location where the buffer should be
  5647. * split.
  5648. *
  5649. * It assumes that the given IE buffer is well-formed, this
  5650. * has to be guaranteed by the caller!
  5651. *
  5652. * It also assumes that the IEs in the buffer are ordered
  5653. * correctly, if not the result of using this function will not
  5654. * be ordered correctly either, i.e. it does no reordering.
  5655. *
  5656. * The function returns the offset where the next part of the
  5657. * buffer starts, which may be @ielen if the entire (remainder)
  5658. * of the buffer should be used.
  5659. */
  5660. static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
  5661. const u8 *ids, int n_ids, size_t offset)
  5662. {
  5663. return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
  5664. }
  5665. /**
  5666. * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
  5667. * @wdev: the wireless device reporting the wakeup
  5668. * @wakeup: the wakeup report
  5669. * @gfp: allocation flags
  5670. *
  5671. * This function reports that the given device woke up. If it
  5672. * caused the wakeup, report the reason(s), otherwise you may
  5673. * pass %NULL as the @wakeup parameter to advertise that something
  5674. * else caused the wakeup.
  5675. */
  5676. void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
  5677. struct cfg80211_wowlan_wakeup *wakeup,
  5678. gfp_t gfp);
  5679. /**
  5680. * cfg80211_crit_proto_stopped() - indicate critical protocol stopped by driver.
  5681. *
  5682. * @wdev: the wireless device for which critical protocol is stopped.
  5683. * @gfp: allocation flags
  5684. *
  5685. * This function can be called by the driver to indicate it has reverted
  5686. * operation back to normal. One reason could be that the duration given
  5687. * by .crit_proto_start() has expired.
  5688. */
  5689. void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
  5690. /**
  5691. * ieee80211_get_num_supported_channels - get number of channels device has
  5692. * @wiphy: the wiphy
  5693. *
  5694. * Return: the number of channels supported by the device.
  5695. */
  5696. unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy);
  5697. /**
  5698. * cfg80211_check_combinations - check interface combinations
  5699. *
  5700. * @wiphy: the wiphy
  5701. * @params: the interface combinations parameter
  5702. *
  5703. * This function can be called by the driver to check whether a
  5704. * combination of interfaces and their types are allowed according to
  5705. * the interface combinations.
  5706. */
  5707. int cfg80211_check_combinations(struct wiphy *wiphy,
  5708. struct iface_combination_params *params);
  5709. /**
  5710. * cfg80211_iter_combinations - iterate over matching combinations
  5711. *
  5712. * @wiphy: the wiphy
  5713. * @params: the interface combinations parameter
  5714. * @iter: function to call for each matching combination
  5715. * @data: pointer to pass to iter function
  5716. *
  5717. * This function can be called by the driver to check what possible
  5718. * combinations it fits in at a given moment, e.g. for channel switching
  5719. * purposes.
  5720. */
  5721. int cfg80211_iter_combinations(struct wiphy *wiphy,
  5722. struct iface_combination_params *params,
  5723. void (*iter)(const struct ieee80211_iface_combination *c,
  5724. void *data),
  5725. void *data);
  5726. /*
  5727. * cfg80211_stop_iface - trigger interface disconnection
  5728. *
  5729. * @wiphy: the wiphy
  5730. * @wdev: wireless device
  5731. * @gfp: context flags
  5732. *
  5733. * Trigger interface to be stopped as if AP was stopped, IBSS/mesh left, STA
  5734. * disconnected.
  5735. *
  5736. * Note: This doesn't need any locks and is asynchronous.
  5737. */
  5738. void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
  5739. gfp_t gfp);
  5740. /**
  5741. * cfg80211_shutdown_all_interfaces - shut down all interfaces for a wiphy
  5742. * @wiphy: the wiphy to shut down
  5743. *
  5744. * This function shuts down all interfaces belonging to this wiphy by
  5745. * calling dev_close() (and treating non-netdev interfaces as needed).
  5746. * It shouldn't really be used unless there are some fatal device errors
  5747. * that really can't be recovered in any other way.
  5748. *
  5749. * Callers must hold the RTNL and be able to deal with callbacks into
  5750. * the driver while the function is running.
  5751. */
  5752. void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
  5753. /**
  5754. * wiphy_ext_feature_set - set the extended feature flag
  5755. *
  5756. * @wiphy: the wiphy to modify.
  5757. * @ftidx: extended feature bit index.
  5758. *
  5759. * The extended features are flagged in multiple bytes (see
  5760. * &struct wiphy.@ext_features)
  5761. */
  5762. static inline void wiphy_ext_feature_set(struct wiphy *wiphy,
  5763. enum nl80211_ext_feature_index ftidx)
  5764. {
  5765. u8 *ft_byte;
  5766. ft_byte = &wiphy->ext_features[ftidx / 8];
  5767. *ft_byte |= BIT(ftidx % 8);
  5768. }
  5769. /**
  5770. * wiphy_ext_feature_isset - check the extended feature flag
  5771. *
  5772. * @wiphy: the wiphy to modify.
  5773. * @ftidx: extended feature bit index.
  5774. *
  5775. * The extended features are flagged in multiple bytes (see
  5776. * &struct wiphy.@ext_features)
  5777. */
  5778. static inline bool
  5779. wiphy_ext_feature_isset(struct wiphy *wiphy,
  5780. enum nl80211_ext_feature_index ftidx)
  5781. {
  5782. u8 ft_byte;
  5783. ft_byte = wiphy->ext_features[ftidx / 8];
  5784. return (ft_byte & BIT(ftidx % 8)) != 0;
  5785. }
  5786. /**
  5787. * cfg80211_free_nan_func - free NAN function
  5788. * @f: NAN function that should be freed
  5789. *
  5790. * Frees all the NAN function and all it's allocated members.
  5791. */
  5792. void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
  5793. /**
  5794. * struct cfg80211_nan_match_params - NAN match parameters
  5795. * @type: the type of the function that triggered a match. If it is
  5796. * %NL80211_NAN_FUNC_SUBSCRIBE it means that we replied to a subscriber.
  5797. * If it is %NL80211_NAN_FUNC_PUBLISH, it means that we got a discovery
  5798. * result.
  5799. * If it is %NL80211_NAN_FUNC_FOLLOW_UP, we received a follow up.
  5800. * @inst_id: the local instance id
  5801. * @peer_inst_id: the instance id of the peer's function
  5802. * @addr: the MAC address of the peer
  5803. * @info_len: the length of the &info
  5804. * @info: the Service Specific Info from the peer (if any)
  5805. * @cookie: unique identifier of the corresponding function
  5806. */
  5807. struct cfg80211_nan_match_params {
  5808. enum nl80211_nan_function_type type;
  5809. u8 inst_id;
  5810. u8 peer_inst_id;
  5811. const u8 *addr;
  5812. u8 info_len;
  5813. const u8 *info;
  5814. u64 cookie;
  5815. };
  5816. /**
  5817. * cfg80211_nan_match - report a match for a NAN function.
  5818. * @wdev: the wireless device reporting the match
  5819. * @match: match notification parameters
  5820. * @gfp: allocation flags
  5821. *
  5822. * This function reports that the a NAN function had a match. This
  5823. * can be a subscribe that had a match or a solicited publish that
  5824. * was sent. It can also be a follow up that was received.
  5825. */
  5826. void cfg80211_nan_match(struct wireless_dev *wdev,
  5827. struct cfg80211_nan_match_params *match, gfp_t gfp);
  5828. /**
  5829. * cfg80211_nan_func_terminated - notify about NAN function termination.
  5830. *
  5831. * @wdev: the wireless device reporting the match
  5832. * @inst_id: the local instance id
  5833. * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
  5834. * @cookie: unique NAN function identifier
  5835. * @gfp: allocation flags
  5836. *
  5837. * This function reports that the a NAN function is terminated.
  5838. */
  5839. void cfg80211_nan_func_terminated(struct wireless_dev *wdev,
  5840. u8 inst_id,
  5841. enum nl80211_nan_func_term_reason reason,
  5842. u64 cookie, gfp_t gfp);
  5843. /* ethtool helper */
  5844. void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
  5845. /**
  5846. * cfg80211_external_auth_request - userspace request for authentication
  5847. * @netdev: network device
  5848. * @params: External authentication parameters
  5849. * @gfp: allocation flags
  5850. * Returns: 0 on success, < 0 on error
  5851. */
  5852. int cfg80211_external_auth_request(struct net_device *netdev,
  5853. struct cfg80211_external_auth_params *params,
  5854. gfp_t gfp);
  5855. /* Logging, debugging and troubleshooting/diagnostic helpers. */
  5856. /* wiphy_printk helpers, similar to dev_printk */
  5857. #define wiphy_printk(level, wiphy, format, args...) \
  5858. dev_printk(level, &(wiphy)->dev, format, ##args)
  5859. #define wiphy_emerg(wiphy, format, args...) \
  5860. dev_emerg(&(wiphy)->dev, format, ##args)
  5861. #define wiphy_alert(wiphy, format, args...) \
  5862. dev_alert(&(wiphy)->dev, format, ##args)
  5863. #define wiphy_crit(wiphy, format, args...) \
  5864. dev_crit(&(wiphy)->dev, format, ##args)
  5865. #define wiphy_err(wiphy, format, args...) \
  5866. dev_err(&(wiphy)->dev, format, ##args)
  5867. #define wiphy_warn(wiphy, format, args...) \
  5868. dev_warn(&(wiphy)->dev, format, ##args)
  5869. #define wiphy_notice(wiphy, format, args...) \
  5870. dev_notice(&(wiphy)->dev, format, ##args)
  5871. #define wiphy_info(wiphy, format, args...) \
  5872. dev_info(&(wiphy)->dev, format, ##args)
  5873. #define wiphy_debug(wiphy, format, args...) \
  5874. wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
  5875. #define wiphy_dbg(wiphy, format, args...) \
  5876. dev_dbg(&(wiphy)->dev, format, ##args)
  5877. #if defined(VERBOSE_DEBUG)
  5878. #define wiphy_vdbg wiphy_dbg
  5879. #else
  5880. #define wiphy_vdbg(wiphy, format, args...) \
  5881. ({ \
  5882. if (0) \
  5883. wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \
  5884. 0; \
  5885. })
  5886. #endif
  5887. /*
  5888. * wiphy_WARN() acts like wiphy_printk(), but with the key difference
  5889. * of using a WARN/WARN_ON to get the message out, including the
  5890. * file/line information and a backtrace.
  5891. */
  5892. #define wiphy_WARN(wiphy, format, args...) \
  5893. WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args);
  5894. #endif /* __NET_CFG80211_H */