cfg80211.h 191 KB

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