cfg80211.h 179 KB

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