cfg80211.h 180 KB

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