cfg80211.h 190 KB

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