cfg.c 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409
  1. /*
  2. * mac80211 configuration hooks for cfg80211
  3. *
  4. * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
  5. * Copyright 2013-2015 Intel Mobile Communications GmbH
  6. *
  7. * This file is GPLv2 as found in COPYING.
  8. */
  9. #include <linux/ieee80211.h>
  10. #include <linux/nl80211.h>
  11. #include <linux/rtnetlink.h>
  12. #include <linux/slab.h>
  13. #include <net/net_namespace.h>
  14. #include <linux/rcupdate.h>
  15. #include <linux/if_ether.h>
  16. #include <net/cfg80211.h>
  17. #include "ieee80211_i.h"
  18. #include "driver-ops.h"
  19. #include "rate.h"
  20. #include "mesh.h"
  21. #include "wme.h"
  22. static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,
  23. const char *name,
  24. unsigned char name_assign_type,
  25. enum nl80211_iftype type,
  26. u32 *flags,
  27. struct vif_params *params)
  28. {
  29. struct ieee80211_local *local = wiphy_priv(wiphy);
  30. struct wireless_dev *wdev;
  31. struct ieee80211_sub_if_data *sdata;
  32. int err;
  33. err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params);
  34. if (err)
  35. return ERR_PTR(err);
  36. if (type == NL80211_IFTYPE_MONITOR && flags) {
  37. sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  38. sdata->u.mntr_flags = *flags;
  39. }
  40. return wdev;
  41. }
  42. static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
  43. {
  44. ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
  45. return 0;
  46. }
  47. static int ieee80211_change_iface(struct wiphy *wiphy,
  48. struct net_device *dev,
  49. enum nl80211_iftype type, u32 *flags,
  50. struct vif_params *params)
  51. {
  52. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  53. int ret;
  54. ret = ieee80211_if_change_type(sdata, type);
  55. if (ret)
  56. return ret;
  57. if (type == NL80211_IFTYPE_AP_VLAN &&
  58. params && params->use_4addr == 0)
  59. RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
  60. else if (type == NL80211_IFTYPE_STATION &&
  61. params && params->use_4addr >= 0)
  62. sdata->u.mgd.use_4addr = params->use_4addr;
  63. if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
  64. struct ieee80211_local *local = sdata->local;
  65. if (ieee80211_sdata_running(sdata)) {
  66. u32 mask = MONITOR_FLAG_COOK_FRAMES |
  67. MONITOR_FLAG_ACTIVE;
  68. /*
  69. * Prohibit MONITOR_FLAG_COOK_FRAMES and
  70. * MONITOR_FLAG_ACTIVE to be changed while the
  71. * interface is up.
  72. * Else we would need to add a lot of cruft
  73. * to update everything:
  74. * cooked_mntrs, monitor and all fif_* counters
  75. * reconfigure hardware
  76. */
  77. if ((*flags & mask) != (sdata->u.mntr_flags & mask))
  78. return -EBUSY;
  79. ieee80211_adjust_monitor_flags(sdata, -1);
  80. sdata->u.mntr_flags = *flags;
  81. ieee80211_adjust_monitor_flags(sdata, 1);
  82. ieee80211_configure_filter(local);
  83. } else {
  84. /*
  85. * Because the interface is down, ieee80211_do_stop
  86. * and ieee80211_do_open take care of "everything"
  87. * mentioned in the comment above.
  88. */
  89. sdata->u.mntr_flags = *flags;
  90. }
  91. }
  92. return 0;
  93. }
  94. static int ieee80211_start_p2p_device(struct wiphy *wiphy,
  95. struct wireless_dev *wdev)
  96. {
  97. struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  98. int ret;
  99. mutex_lock(&sdata->local->chanctx_mtx);
  100. ret = ieee80211_check_combinations(sdata, NULL, 0, 0);
  101. mutex_unlock(&sdata->local->chanctx_mtx);
  102. if (ret < 0)
  103. return ret;
  104. return ieee80211_do_open(wdev, true);
  105. }
  106. static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
  107. struct wireless_dev *wdev)
  108. {
  109. ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev));
  110. }
  111. static int ieee80211_set_noack_map(struct wiphy *wiphy,
  112. struct net_device *dev,
  113. u16 noack_map)
  114. {
  115. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  116. sdata->noack_map = noack_map;
  117. ieee80211_check_fast_xmit_iface(sdata);
  118. return 0;
  119. }
  120. static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
  121. u8 key_idx, bool pairwise, const u8 *mac_addr,
  122. struct key_params *params)
  123. {
  124. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  125. struct ieee80211_local *local = sdata->local;
  126. struct sta_info *sta = NULL;
  127. const struct ieee80211_cipher_scheme *cs = NULL;
  128. struct ieee80211_key *key;
  129. int err;
  130. if (!ieee80211_sdata_running(sdata))
  131. return -ENETDOWN;
  132. /* reject WEP and TKIP keys if WEP failed to initialize */
  133. switch (params->cipher) {
  134. case WLAN_CIPHER_SUITE_WEP40:
  135. case WLAN_CIPHER_SUITE_TKIP:
  136. case WLAN_CIPHER_SUITE_WEP104:
  137. if (IS_ERR(local->wep_tx_tfm))
  138. return -EINVAL;
  139. break;
  140. case WLAN_CIPHER_SUITE_CCMP:
  141. case WLAN_CIPHER_SUITE_CCMP_256:
  142. case WLAN_CIPHER_SUITE_AES_CMAC:
  143. case WLAN_CIPHER_SUITE_BIP_CMAC_256:
  144. case WLAN_CIPHER_SUITE_BIP_GMAC_128:
  145. case WLAN_CIPHER_SUITE_BIP_GMAC_256:
  146. case WLAN_CIPHER_SUITE_GCMP:
  147. case WLAN_CIPHER_SUITE_GCMP_256:
  148. break;
  149. default:
  150. cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type);
  151. break;
  152. }
  153. key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
  154. params->key, params->seq_len, params->seq,
  155. cs);
  156. if (IS_ERR(key))
  157. return PTR_ERR(key);
  158. if (pairwise)
  159. key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
  160. mutex_lock(&local->sta_mtx);
  161. if (mac_addr) {
  162. if (ieee80211_vif_is_mesh(&sdata->vif))
  163. sta = sta_info_get(sdata, mac_addr);
  164. else
  165. sta = sta_info_get_bss(sdata, mac_addr);
  166. /*
  167. * The ASSOC test makes sure the driver is ready to
  168. * receive the key. When wpa_supplicant has roamed
  169. * using FT, it attempts to set the key before
  170. * association has completed, this rejects that attempt
  171. * so it will set the key again after association.
  172. *
  173. * TODO: accept the key if we have a station entry and
  174. * add it to the device after the station.
  175. */
  176. if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
  177. ieee80211_key_free_unused(key);
  178. err = -ENOENT;
  179. goto out_unlock;
  180. }
  181. }
  182. switch (sdata->vif.type) {
  183. case NL80211_IFTYPE_STATION:
  184. if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED)
  185. key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
  186. break;
  187. case NL80211_IFTYPE_AP:
  188. case NL80211_IFTYPE_AP_VLAN:
  189. /* Keys without a station are used for TX only */
  190. if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP))
  191. key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
  192. break;
  193. case NL80211_IFTYPE_ADHOC:
  194. /* no MFP (yet) */
  195. break;
  196. case NL80211_IFTYPE_MESH_POINT:
  197. #ifdef CONFIG_MAC80211_MESH
  198. if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)
  199. key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
  200. break;
  201. #endif
  202. case NL80211_IFTYPE_WDS:
  203. case NL80211_IFTYPE_MONITOR:
  204. case NL80211_IFTYPE_P2P_DEVICE:
  205. case NL80211_IFTYPE_UNSPECIFIED:
  206. case NUM_NL80211_IFTYPES:
  207. case NL80211_IFTYPE_P2P_CLIENT:
  208. case NL80211_IFTYPE_P2P_GO:
  209. case NL80211_IFTYPE_OCB:
  210. /* shouldn't happen */
  211. WARN_ON_ONCE(1);
  212. break;
  213. }
  214. if (sta)
  215. sta->cipher_scheme = cs;
  216. err = ieee80211_key_link(key, sdata, sta);
  217. out_unlock:
  218. mutex_unlock(&local->sta_mtx);
  219. return err;
  220. }
  221. static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
  222. u8 key_idx, bool pairwise, const u8 *mac_addr)
  223. {
  224. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  225. struct ieee80211_local *local = sdata->local;
  226. struct sta_info *sta;
  227. struct ieee80211_key *key = NULL;
  228. int ret;
  229. mutex_lock(&local->sta_mtx);
  230. mutex_lock(&local->key_mtx);
  231. if (mac_addr) {
  232. ret = -ENOENT;
  233. sta = sta_info_get_bss(sdata, mac_addr);
  234. if (!sta)
  235. goto out_unlock;
  236. if (pairwise)
  237. key = key_mtx_dereference(local, sta->ptk[key_idx]);
  238. else
  239. key = key_mtx_dereference(local, sta->gtk[key_idx]);
  240. } else
  241. key = key_mtx_dereference(local, sdata->keys[key_idx]);
  242. if (!key) {
  243. ret = -ENOENT;
  244. goto out_unlock;
  245. }
  246. ieee80211_key_free(key, true);
  247. ret = 0;
  248. out_unlock:
  249. mutex_unlock(&local->key_mtx);
  250. mutex_unlock(&local->sta_mtx);
  251. return ret;
  252. }
  253. static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
  254. u8 key_idx, bool pairwise, const u8 *mac_addr,
  255. void *cookie,
  256. void (*callback)(void *cookie,
  257. struct key_params *params))
  258. {
  259. struct ieee80211_sub_if_data *sdata;
  260. struct sta_info *sta = NULL;
  261. u8 seq[6] = {0};
  262. struct key_params params;
  263. struct ieee80211_key *key = NULL;
  264. u64 pn64;
  265. u32 iv32;
  266. u16 iv16;
  267. int err = -ENOENT;
  268. struct ieee80211_key_seq kseq = {};
  269. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  270. rcu_read_lock();
  271. if (mac_addr) {
  272. sta = sta_info_get_bss(sdata, mac_addr);
  273. if (!sta)
  274. goto out;
  275. if (pairwise && key_idx < NUM_DEFAULT_KEYS)
  276. key = rcu_dereference(sta->ptk[key_idx]);
  277. else if (!pairwise &&
  278. key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
  279. key = rcu_dereference(sta->gtk[key_idx]);
  280. } else
  281. key = rcu_dereference(sdata->keys[key_idx]);
  282. if (!key)
  283. goto out;
  284. memset(&params, 0, sizeof(params));
  285. params.cipher = key->conf.cipher;
  286. switch (key->conf.cipher) {
  287. case WLAN_CIPHER_SUITE_TKIP:
  288. iv32 = key->u.tkip.tx.iv32;
  289. iv16 = key->u.tkip.tx.iv16;
  290. if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
  291. !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
  292. drv_get_key_seq(sdata->local, key, &kseq);
  293. iv32 = kseq.tkip.iv32;
  294. iv16 = kseq.tkip.iv16;
  295. }
  296. seq[0] = iv16 & 0xff;
  297. seq[1] = (iv16 >> 8) & 0xff;
  298. seq[2] = iv32 & 0xff;
  299. seq[3] = (iv32 >> 8) & 0xff;
  300. seq[4] = (iv32 >> 16) & 0xff;
  301. seq[5] = (iv32 >> 24) & 0xff;
  302. params.seq = seq;
  303. params.seq_len = 6;
  304. break;
  305. case WLAN_CIPHER_SUITE_CCMP:
  306. case WLAN_CIPHER_SUITE_CCMP_256:
  307. case WLAN_CIPHER_SUITE_AES_CMAC:
  308. case WLAN_CIPHER_SUITE_BIP_CMAC_256:
  309. BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
  310. offsetof(typeof(kseq), aes_cmac));
  311. case WLAN_CIPHER_SUITE_BIP_GMAC_128:
  312. case WLAN_CIPHER_SUITE_BIP_GMAC_256:
  313. BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
  314. offsetof(typeof(kseq), aes_gmac));
  315. case WLAN_CIPHER_SUITE_GCMP:
  316. case WLAN_CIPHER_SUITE_GCMP_256:
  317. BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
  318. offsetof(typeof(kseq), gcmp));
  319. if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
  320. !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
  321. drv_get_key_seq(sdata->local, key, &kseq);
  322. memcpy(seq, kseq.ccmp.pn, 6);
  323. } else {
  324. pn64 = atomic64_read(&key->conf.tx_pn);
  325. seq[0] = pn64;
  326. seq[1] = pn64 >> 8;
  327. seq[2] = pn64 >> 16;
  328. seq[3] = pn64 >> 24;
  329. seq[4] = pn64 >> 32;
  330. seq[5] = pn64 >> 40;
  331. }
  332. params.seq = seq;
  333. params.seq_len = 6;
  334. break;
  335. default:
  336. if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
  337. break;
  338. if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))
  339. break;
  340. drv_get_key_seq(sdata->local, key, &kseq);
  341. params.seq = kseq.hw.seq;
  342. params.seq_len = kseq.hw.seq_len;
  343. break;
  344. }
  345. params.key = key->conf.key;
  346. params.key_len = key->conf.keylen;
  347. callback(cookie, &params);
  348. err = 0;
  349. out:
  350. rcu_read_unlock();
  351. return err;
  352. }
  353. static int ieee80211_config_default_key(struct wiphy *wiphy,
  354. struct net_device *dev,
  355. u8 key_idx, bool uni,
  356. bool multi)
  357. {
  358. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  359. ieee80211_set_default_key(sdata, key_idx, uni, multi);
  360. return 0;
  361. }
  362. static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
  363. struct net_device *dev,
  364. u8 key_idx)
  365. {
  366. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  367. ieee80211_set_default_mgmt_key(sdata, key_idx);
  368. return 0;
  369. }
  370. void sta_set_rate_info_tx(struct sta_info *sta,
  371. const struct ieee80211_tx_rate *rate,
  372. struct rate_info *rinfo)
  373. {
  374. rinfo->flags = 0;
  375. if (rate->flags & IEEE80211_TX_RC_MCS) {
  376. rinfo->flags |= RATE_INFO_FLAGS_MCS;
  377. rinfo->mcs = rate->idx;
  378. } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
  379. rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
  380. rinfo->mcs = ieee80211_rate_get_vht_mcs(rate);
  381. rinfo->nss = ieee80211_rate_get_vht_nss(rate);
  382. } else {
  383. struct ieee80211_supported_band *sband;
  384. int shift = ieee80211_vif_get_shift(&sta->sdata->vif);
  385. u16 brate;
  386. sband = sta->local->hw.wiphy->bands[
  387. ieee80211_get_sdata_band(sta->sdata)];
  388. brate = sband->bitrates[rate->idx].bitrate;
  389. rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift);
  390. }
  391. if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
  392. rinfo->bw = RATE_INFO_BW_40;
  393. else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
  394. rinfo->bw = RATE_INFO_BW_80;
  395. else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
  396. rinfo->bw = RATE_INFO_BW_160;
  397. else
  398. rinfo->bw = RATE_INFO_BW_20;
  399. if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
  400. rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
  401. }
  402. static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
  403. int idx, u8 *mac, struct station_info *sinfo)
  404. {
  405. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  406. struct ieee80211_local *local = sdata->local;
  407. struct sta_info *sta;
  408. int ret = -ENOENT;
  409. mutex_lock(&local->sta_mtx);
  410. sta = sta_info_get_by_idx(sdata, idx);
  411. if (sta) {
  412. ret = 0;
  413. memcpy(mac, sta->sta.addr, ETH_ALEN);
  414. sta_set_sinfo(sta, sinfo);
  415. }
  416. mutex_unlock(&local->sta_mtx);
  417. return ret;
  418. }
  419. static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
  420. int idx, struct survey_info *survey)
  421. {
  422. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  423. return drv_get_survey(local, idx, survey);
  424. }
  425. static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
  426. const u8 *mac, struct station_info *sinfo)
  427. {
  428. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  429. struct ieee80211_local *local = sdata->local;
  430. struct sta_info *sta;
  431. int ret = -ENOENT;
  432. mutex_lock(&local->sta_mtx);
  433. sta = sta_info_get_bss(sdata, mac);
  434. if (sta) {
  435. ret = 0;
  436. sta_set_sinfo(sta, sinfo);
  437. }
  438. mutex_unlock(&local->sta_mtx);
  439. return ret;
  440. }
  441. static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
  442. struct cfg80211_chan_def *chandef)
  443. {
  444. struct ieee80211_local *local = wiphy_priv(wiphy);
  445. struct ieee80211_sub_if_data *sdata;
  446. int ret = 0;
  447. if (cfg80211_chandef_identical(&local->monitor_chandef, chandef))
  448. return 0;
  449. mutex_lock(&local->mtx);
  450. mutex_lock(&local->iflist_mtx);
  451. if (local->use_chanctx) {
  452. sdata = rcu_dereference_protected(
  453. local->monitor_sdata,
  454. lockdep_is_held(&local->iflist_mtx));
  455. if (sdata) {
  456. ieee80211_vif_release_channel(sdata);
  457. ret = ieee80211_vif_use_channel(sdata, chandef,
  458. IEEE80211_CHANCTX_EXCLUSIVE);
  459. }
  460. } else if (local->open_count == local->monitors) {
  461. local->_oper_chandef = *chandef;
  462. ieee80211_hw_config(local, 0);
  463. }
  464. if (ret == 0)
  465. local->monitor_chandef = *chandef;
  466. mutex_unlock(&local->iflist_mtx);
  467. mutex_unlock(&local->mtx);
  468. return ret;
  469. }
  470. static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
  471. const u8 *resp, size_t resp_len,
  472. const struct ieee80211_csa_settings *csa)
  473. {
  474. struct probe_resp *new, *old;
  475. if (!resp || !resp_len)
  476. return 1;
  477. old = sdata_dereference(sdata->u.ap.probe_resp, sdata);
  478. new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL);
  479. if (!new)
  480. return -ENOMEM;
  481. new->len = resp_len;
  482. memcpy(new->data, resp, resp_len);
  483. if (csa)
  484. memcpy(new->csa_counter_offsets, csa->counter_offsets_presp,
  485. csa->n_counter_offsets_presp *
  486. sizeof(new->csa_counter_offsets[0]));
  487. rcu_assign_pointer(sdata->u.ap.probe_resp, new);
  488. if (old)
  489. kfree_rcu(old, rcu_head);
  490. return 0;
  491. }
  492. static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
  493. struct cfg80211_beacon_data *params,
  494. const struct ieee80211_csa_settings *csa)
  495. {
  496. struct beacon_data *new, *old;
  497. int new_head_len, new_tail_len;
  498. int size, err;
  499. u32 changed = BSS_CHANGED_BEACON;
  500. old = sdata_dereference(sdata->u.ap.beacon, sdata);
  501. /* Need to have a beacon head if we don't have one yet */
  502. if (!params->head && !old)
  503. return -EINVAL;
  504. /* new or old head? */
  505. if (params->head)
  506. new_head_len = params->head_len;
  507. else
  508. new_head_len = old->head_len;
  509. /* new or old tail? */
  510. if (params->tail || !old)
  511. /* params->tail_len will be zero for !params->tail */
  512. new_tail_len = params->tail_len;
  513. else
  514. new_tail_len = old->tail_len;
  515. size = sizeof(*new) + new_head_len + new_tail_len;
  516. new = kzalloc(size, GFP_KERNEL);
  517. if (!new)
  518. return -ENOMEM;
  519. /* start filling the new info now */
  520. /*
  521. * pointers go into the block we allocated,
  522. * memory is | beacon_data | head | tail |
  523. */
  524. new->head = ((u8 *) new) + sizeof(*new);
  525. new->tail = new->head + new_head_len;
  526. new->head_len = new_head_len;
  527. new->tail_len = new_tail_len;
  528. if (csa) {
  529. new->csa_current_counter = csa->count;
  530. memcpy(new->csa_counter_offsets, csa->counter_offsets_beacon,
  531. csa->n_counter_offsets_beacon *
  532. sizeof(new->csa_counter_offsets[0]));
  533. }
  534. /* copy in head */
  535. if (params->head)
  536. memcpy(new->head, params->head, new_head_len);
  537. else
  538. memcpy(new->head, old->head, new_head_len);
  539. /* copy in optional tail */
  540. if (params->tail)
  541. memcpy(new->tail, params->tail, new_tail_len);
  542. else
  543. if (old)
  544. memcpy(new->tail, old->tail, new_tail_len);
  545. err = ieee80211_set_probe_resp(sdata, params->probe_resp,
  546. params->probe_resp_len, csa);
  547. if (err < 0)
  548. return err;
  549. if (err == 0)
  550. changed |= BSS_CHANGED_AP_PROBE_RESP;
  551. rcu_assign_pointer(sdata->u.ap.beacon, new);
  552. if (old)
  553. kfree_rcu(old, rcu_head);
  554. return changed;
  555. }
  556. static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
  557. struct cfg80211_ap_settings *params)
  558. {
  559. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  560. struct ieee80211_local *local = sdata->local;
  561. struct beacon_data *old;
  562. struct ieee80211_sub_if_data *vlan;
  563. u32 changed = BSS_CHANGED_BEACON_INT |
  564. BSS_CHANGED_BEACON_ENABLED |
  565. BSS_CHANGED_BEACON |
  566. BSS_CHANGED_SSID |
  567. BSS_CHANGED_P2P_PS |
  568. BSS_CHANGED_TXPOWER;
  569. int err;
  570. old = sdata_dereference(sdata->u.ap.beacon, sdata);
  571. if (old)
  572. return -EALREADY;
  573. switch (params->smps_mode) {
  574. case NL80211_SMPS_OFF:
  575. sdata->smps_mode = IEEE80211_SMPS_OFF;
  576. break;
  577. case NL80211_SMPS_STATIC:
  578. sdata->smps_mode = IEEE80211_SMPS_STATIC;
  579. break;
  580. case NL80211_SMPS_DYNAMIC:
  581. sdata->smps_mode = IEEE80211_SMPS_DYNAMIC;
  582. break;
  583. default:
  584. return -EINVAL;
  585. }
  586. sdata->needed_rx_chains = sdata->local->rx_chains;
  587. mutex_lock(&local->mtx);
  588. err = ieee80211_vif_use_channel(sdata, &params->chandef,
  589. IEEE80211_CHANCTX_SHARED);
  590. if (!err)
  591. ieee80211_vif_copy_chanctx_to_vlans(sdata, false);
  592. mutex_unlock(&local->mtx);
  593. if (err)
  594. return err;
  595. /*
  596. * Apply control port protocol, this allows us to
  597. * not encrypt dynamic WEP control frames.
  598. */
  599. sdata->control_port_protocol = params->crypto.control_port_ethertype;
  600. sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
  601. sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
  602. &params->crypto,
  603. sdata->vif.type);
  604. list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
  605. vlan->control_port_protocol =
  606. params->crypto.control_port_ethertype;
  607. vlan->control_port_no_encrypt =
  608. params->crypto.control_port_no_encrypt;
  609. vlan->encrypt_headroom =
  610. ieee80211_cs_headroom(sdata->local,
  611. &params->crypto,
  612. vlan->vif.type);
  613. }
  614. sdata->vif.bss_conf.beacon_int = params->beacon_interval;
  615. sdata->vif.bss_conf.dtim_period = params->dtim_period;
  616. sdata->vif.bss_conf.enable_beacon = true;
  617. sdata->vif.bss_conf.ssid_len = params->ssid_len;
  618. if (params->ssid_len)
  619. memcpy(sdata->vif.bss_conf.ssid, params->ssid,
  620. params->ssid_len);
  621. sdata->vif.bss_conf.hidden_ssid =
  622. (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
  623. memset(&sdata->vif.bss_conf.p2p_noa_attr, 0,
  624. sizeof(sdata->vif.bss_conf.p2p_noa_attr));
  625. sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow =
  626. params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
  627. if (params->p2p_opp_ps)
  628. sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
  629. IEEE80211_P2P_OPPPS_ENABLE_BIT;
  630. err = ieee80211_assign_beacon(sdata, &params->beacon, NULL);
  631. if (err < 0) {
  632. ieee80211_vif_release_channel(sdata);
  633. return err;
  634. }
  635. changed |= err;
  636. err = drv_start_ap(sdata->local, sdata);
  637. if (err) {
  638. old = sdata_dereference(sdata->u.ap.beacon, sdata);
  639. if (old)
  640. kfree_rcu(old, rcu_head);
  641. RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
  642. ieee80211_vif_release_channel(sdata);
  643. return err;
  644. }
  645. ieee80211_recalc_dtim(local, sdata);
  646. ieee80211_bss_info_change_notify(sdata, changed);
  647. netif_carrier_on(dev);
  648. list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
  649. netif_carrier_on(vlan->dev);
  650. return 0;
  651. }
  652. static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
  653. struct cfg80211_beacon_data *params)
  654. {
  655. struct ieee80211_sub_if_data *sdata;
  656. struct beacon_data *old;
  657. int err;
  658. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  659. sdata_assert_lock(sdata);
  660. /* don't allow changing the beacon while CSA is in place - offset
  661. * of channel switch counter may change
  662. */
  663. if (sdata->vif.csa_active)
  664. return -EBUSY;
  665. old = sdata_dereference(sdata->u.ap.beacon, sdata);
  666. if (!old)
  667. return -ENOENT;
  668. err = ieee80211_assign_beacon(sdata, params, NULL);
  669. if (err < 0)
  670. return err;
  671. ieee80211_bss_info_change_notify(sdata, err);
  672. return 0;
  673. }
  674. static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
  675. {
  676. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  677. struct ieee80211_sub_if_data *vlan;
  678. struct ieee80211_local *local = sdata->local;
  679. struct beacon_data *old_beacon;
  680. struct probe_resp *old_probe_resp;
  681. struct cfg80211_chan_def chandef;
  682. sdata_assert_lock(sdata);
  683. old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
  684. if (!old_beacon)
  685. return -ENOENT;
  686. old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata);
  687. /* abort any running channel switch */
  688. mutex_lock(&local->mtx);
  689. sdata->vif.csa_active = false;
  690. if (sdata->csa_block_tx) {
  691. ieee80211_wake_vif_queues(local, sdata,
  692. IEEE80211_QUEUE_STOP_REASON_CSA);
  693. sdata->csa_block_tx = false;
  694. }
  695. mutex_unlock(&local->mtx);
  696. kfree(sdata->u.ap.next_beacon);
  697. sdata->u.ap.next_beacon = NULL;
  698. /* turn off carrier for this interface and dependent VLANs */
  699. list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
  700. netif_carrier_off(vlan->dev);
  701. netif_carrier_off(dev);
  702. /* remove beacon and probe response */
  703. RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
  704. RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL);
  705. kfree_rcu(old_beacon, rcu_head);
  706. if (old_probe_resp)
  707. kfree_rcu(old_probe_resp, rcu_head);
  708. sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
  709. __sta_info_flush(sdata, true);
  710. ieee80211_free_keys(sdata, true);
  711. sdata->vif.bss_conf.enable_beacon = false;
  712. sdata->vif.bss_conf.ssid_len = 0;
  713. clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state);
  714. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
  715. if (sdata->wdev.cac_started) {
  716. chandef = sdata->vif.bss_conf.chandef;
  717. cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
  718. cfg80211_cac_event(sdata->dev, &chandef,
  719. NL80211_RADAR_CAC_ABORTED,
  720. GFP_KERNEL);
  721. }
  722. drv_stop_ap(sdata->local, sdata);
  723. /* free all potentially still buffered bcast frames */
  724. local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
  725. skb_queue_purge(&sdata->u.ap.ps.bc_buf);
  726. mutex_lock(&local->mtx);
  727. ieee80211_vif_copy_chanctx_to_vlans(sdata, true);
  728. ieee80211_vif_release_channel(sdata);
  729. mutex_unlock(&local->mtx);
  730. return 0;
  731. }
  732. /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
  733. struct iapp_layer2_update {
  734. u8 da[ETH_ALEN]; /* broadcast */
  735. u8 sa[ETH_ALEN]; /* STA addr */
  736. __be16 len; /* 6 */
  737. u8 dsap; /* 0 */
  738. u8 ssap; /* 0 */
  739. u8 control;
  740. u8 xid_info[3];
  741. } __packed;
  742. static void ieee80211_send_layer2_update(struct sta_info *sta)
  743. {
  744. struct iapp_layer2_update *msg;
  745. struct sk_buff *skb;
  746. /* Send Level 2 Update Frame to update forwarding tables in layer 2
  747. * bridge devices */
  748. skb = dev_alloc_skb(sizeof(*msg));
  749. if (!skb)
  750. return;
  751. msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
  752. /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
  753. * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
  754. eth_broadcast_addr(msg->da);
  755. memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
  756. msg->len = htons(6);
  757. msg->dsap = 0;
  758. msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
  759. msg->control = 0xaf; /* XID response lsb.1111F101.
  760. * F=0 (no poll command; unsolicited frame) */
  761. msg->xid_info[0] = 0x81; /* XID format identifier */
  762. msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
  763. msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
  764. skb->dev = sta->sdata->dev;
  765. skb->protocol = eth_type_trans(skb, sta->sdata->dev);
  766. memset(skb->cb, 0, sizeof(skb->cb));
  767. netif_rx_ni(skb);
  768. }
  769. static int sta_apply_auth_flags(struct ieee80211_local *local,
  770. struct sta_info *sta,
  771. u32 mask, u32 set)
  772. {
  773. int ret;
  774. if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
  775. set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
  776. !test_sta_flag(sta, WLAN_STA_AUTH)) {
  777. ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
  778. if (ret)
  779. return ret;
  780. }
  781. if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
  782. set & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
  783. !test_sta_flag(sta, WLAN_STA_ASSOC)) {
  784. /*
  785. * When peer becomes associated, init rate control as
  786. * well. Some drivers require rate control initialized
  787. * before drv_sta_state() is called.
  788. */
  789. if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
  790. rate_control_rate_init(sta);
  791. ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
  792. if (ret)
  793. return ret;
  794. }
  795. if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
  796. if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
  797. ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
  798. else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
  799. ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
  800. else
  801. ret = 0;
  802. if (ret)
  803. return ret;
  804. }
  805. if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) &&
  806. !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
  807. test_sta_flag(sta, WLAN_STA_ASSOC)) {
  808. ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
  809. if (ret)
  810. return ret;
  811. }
  812. if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
  813. !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
  814. test_sta_flag(sta, WLAN_STA_AUTH)) {
  815. ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
  816. if (ret)
  817. return ret;
  818. }
  819. return 0;
  820. }
  821. static void sta_apply_mesh_params(struct ieee80211_local *local,
  822. struct sta_info *sta,
  823. struct station_parameters *params)
  824. {
  825. #ifdef CONFIG_MAC80211_MESH
  826. struct ieee80211_sub_if_data *sdata = sta->sdata;
  827. u32 changed = 0;
  828. if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) {
  829. switch (params->plink_state) {
  830. case NL80211_PLINK_ESTAB:
  831. if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
  832. changed = mesh_plink_inc_estab_count(sdata);
  833. sta->mesh->plink_state = params->plink_state;
  834. ieee80211_mps_sta_status_update(sta);
  835. changed |= ieee80211_mps_set_sta_local_pm(sta,
  836. sdata->u.mesh.mshcfg.power_mode);
  837. break;
  838. case NL80211_PLINK_LISTEN:
  839. case NL80211_PLINK_BLOCKED:
  840. case NL80211_PLINK_OPN_SNT:
  841. case NL80211_PLINK_OPN_RCVD:
  842. case NL80211_PLINK_CNF_RCVD:
  843. case NL80211_PLINK_HOLDING:
  844. if (sta->mesh->plink_state == NL80211_PLINK_ESTAB)
  845. changed = mesh_plink_dec_estab_count(sdata);
  846. sta->mesh->plink_state = params->plink_state;
  847. ieee80211_mps_sta_status_update(sta);
  848. changed |= ieee80211_mps_set_sta_local_pm(sta,
  849. NL80211_MESH_POWER_UNKNOWN);
  850. break;
  851. default:
  852. /* nothing */
  853. break;
  854. }
  855. }
  856. switch (params->plink_action) {
  857. case NL80211_PLINK_ACTION_NO_ACTION:
  858. /* nothing */
  859. break;
  860. case NL80211_PLINK_ACTION_OPEN:
  861. changed |= mesh_plink_open(sta);
  862. break;
  863. case NL80211_PLINK_ACTION_BLOCK:
  864. changed |= mesh_plink_block(sta);
  865. break;
  866. }
  867. if (params->local_pm)
  868. changed |= ieee80211_mps_set_sta_local_pm(sta,
  869. params->local_pm);
  870. ieee80211_mbss_info_change_notify(sdata, changed);
  871. #endif
  872. }
  873. static int sta_apply_parameters(struct ieee80211_local *local,
  874. struct sta_info *sta,
  875. struct station_parameters *params)
  876. {
  877. int ret = 0;
  878. struct ieee80211_supported_band *sband;
  879. struct ieee80211_sub_if_data *sdata = sta->sdata;
  880. enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
  881. u32 mask, set;
  882. sband = local->hw.wiphy->bands[band];
  883. mask = params->sta_flags_mask;
  884. set = params->sta_flags_set;
  885. if (ieee80211_vif_is_mesh(&sdata->vif)) {
  886. /*
  887. * In mesh mode, ASSOCIATED isn't part of the nl80211
  888. * API but must follow AUTHENTICATED for driver state.
  889. */
  890. if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED))
  891. mask |= BIT(NL80211_STA_FLAG_ASSOCIATED);
  892. if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
  893. set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
  894. } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
  895. /*
  896. * TDLS -- everything follows authorized, but
  897. * only becoming authorized is possible, not
  898. * going back
  899. */
  900. if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
  901. set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
  902. BIT(NL80211_STA_FLAG_ASSOCIATED);
  903. mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) |
  904. BIT(NL80211_STA_FLAG_ASSOCIATED);
  905. }
  906. }
  907. if (mask & BIT(NL80211_STA_FLAG_WME) &&
  908. local->hw.queues >= IEEE80211_NUM_ACS)
  909. sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME);
  910. /* auth flags will be set later for TDLS,
  911. * and for unassociated stations that move to assocaited */
  912. if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
  913. !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) &&
  914. (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) {
  915. ret = sta_apply_auth_flags(local, sta, mask, set);
  916. if (ret)
  917. return ret;
  918. }
  919. if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
  920. if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
  921. set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
  922. else
  923. clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
  924. }
  925. if (mask & BIT(NL80211_STA_FLAG_MFP)) {
  926. sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP));
  927. if (set & BIT(NL80211_STA_FLAG_MFP))
  928. set_sta_flag(sta, WLAN_STA_MFP);
  929. else
  930. clear_sta_flag(sta, WLAN_STA_MFP);
  931. }
  932. if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
  933. if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
  934. set_sta_flag(sta, WLAN_STA_TDLS_PEER);
  935. else
  936. clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
  937. }
  938. /* mark TDLS channel switch support, if the AP allows it */
  939. if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
  940. !sdata->u.mgd.tdls_chan_switch_prohibited &&
  941. params->ext_capab_len >= 4 &&
  942. params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH)
  943. set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH);
  944. if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
  945. !sdata->u.mgd.tdls_wider_bw_prohibited &&
  946. ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) &&
  947. params->ext_capab_len >= 8 &&
  948. params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED)
  949. set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW);
  950. if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
  951. sta->sta.uapsd_queues = params->uapsd_queues;
  952. sta->sta.max_sp = params->max_sp;
  953. }
  954. /*
  955. * cfg80211 validates this (1-2007) and allows setting the AID
  956. * only when creating a new station entry
  957. */
  958. if (params->aid)
  959. sta->sta.aid = params->aid;
  960. /*
  961. * Some of the following updates would be racy if called on an
  962. * existing station, via ieee80211_change_station(). However,
  963. * all such changes are rejected by cfg80211 except for updates
  964. * changing the supported rates on an existing but not yet used
  965. * TDLS peer.
  966. */
  967. if (params->listen_interval >= 0)
  968. sta->listen_interval = params->listen_interval;
  969. if (params->supported_rates) {
  970. ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
  971. sband, params->supported_rates,
  972. params->supported_rates_len,
  973. &sta->sta.supp_rates[band]);
  974. }
  975. if (params->ht_capa)
  976. ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
  977. params->ht_capa, sta);
  978. if (params->vht_capa)
  979. ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband,
  980. params->vht_capa, sta);
  981. if (params->opmode_notif_used) {
  982. /* returned value is only needed for rc update, but the
  983. * rc isn't initialized here yet, so ignore it
  984. */
  985. __ieee80211_vht_handle_opmode(sdata, sta,
  986. params->opmode_notif, band);
  987. }
  988. if (ieee80211_vif_is_mesh(&sdata->vif))
  989. sta_apply_mesh_params(local, sta, params);
  990. /* set the STA state after all sta info from usermode has been set */
  991. if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
  992. set & BIT(NL80211_STA_FLAG_ASSOCIATED)) {
  993. ret = sta_apply_auth_flags(local, sta, mask, set);
  994. if (ret)
  995. return ret;
  996. }
  997. return 0;
  998. }
  999. static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
  1000. const u8 *mac,
  1001. struct station_parameters *params)
  1002. {
  1003. struct ieee80211_local *local = wiphy_priv(wiphy);
  1004. struct sta_info *sta;
  1005. struct ieee80211_sub_if_data *sdata;
  1006. int err;
  1007. int layer2_update;
  1008. if (params->vlan) {
  1009. sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
  1010. if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  1011. sdata->vif.type != NL80211_IFTYPE_AP)
  1012. return -EINVAL;
  1013. } else
  1014. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1015. if (ether_addr_equal(mac, sdata->vif.addr))
  1016. return -EINVAL;
  1017. if (is_multicast_ether_addr(mac))
  1018. return -EINVAL;
  1019. sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
  1020. if (!sta)
  1021. return -ENOMEM;
  1022. if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
  1023. sta->sta.tdls = true;
  1024. err = sta_apply_parameters(local, sta, params);
  1025. if (err) {
  1026. sta_info_free(local, sta);
  1027. return err;
  1028. }
  1029. /*
  1030. * for TDLS and for unassociated station, rate control should be
  1031. * initialized only when rates are known and station is marked
  1032. * authorized/associated
  1033. */
  1034. if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) &&
  1035. test_sta_flag(sta, WLAN_STA_ASSOC))
  1036. rate_control_rate_init(sta);
  1037. layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
  1038. sdata->vif.type == NL80211_IFTYPE_AP;
  1039. err = sta_info_insert_rcu(sta);
  1040. if (err) {
  1041. rcu_read_unlock();
  1042. return err;
  1043. }
  1044. if (layer2_update)
  1045. ieee80211_send_layer2_update(sta);
  1046. rcu_read_unlock();
  1047. return 0;
  1048. }
  1049. static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
  1050. struct station_del_parameters *params)
  1051. {
  1052. struct ieee80211_sub_if_data *sdata;
  1053. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1054. if (params->mac)
  1055. return sta_info_destroy_addr_bss(sdata, params->mac);
  1056. sta_info_flush(sdata);
  1057. return 0;
  1058. }
  1059. static int ieee80211_change_station(struct wiphy *wiphy,
  1060. struct net_device *dev, const u8 *mac,
  1061. struct station_parameters *params)
  1062. {
  1063. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1064. struct ieee80211_local *local = wiphy_priv(wiphy);
  1065. struct sta_info *sta;
  1066. struct ieee80211_sub_if_data *vlansdata;
  1067. enum cfg80211_station_type statype;
  1068. int err;
  1069. mutex_lock(&local->sta_mtx);
  1070. sta = sta_info_get_bss(sdata, mac);
  1071. if (!sta) {
  1072. err = -ENOENT;
  1073. goto out_err;
  1074. }
  1075. switch (sdata->vif.type) {
  1076. case NL80211_IFTYPE_MESH_POINT:
  1077. if (sdata->u.mesh.user_mpm)
  1078. statype = CFG80211_STA_MESH_PEER_USER;
  1079. else
  1080. statype = CFG80211_STA_MESH_PEER_KERNEL;
  1081. break;
  1082. case NL80211_IFTYPE_ADHOC:
  1083. statype = CFG80211_STA_IBSS;
  1084. break;
  1085. case NL80211_IFTYPE_STATION:
  1086. if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
  1087. statype = CFG80211_STA_AP_STA;
  1088. break;
  1089. }
  1090. if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
  1091. statype = CFG80211_STA_TDLS_PEER_ACTIVE;
  1092. else
  1093. statype = CFG80211_STA_TDLS_PEER_SETUP;
  1094. break;
  1095. case NL80211_IFTYPE_AP:
  1096. case NL80211_IFTYPE_AP_VLAN:
  1097. if (test_sta_flag(sta, WLAN_STA_ASSOC))
  1098. statype = CFG80211_STA_AP_CLIENT;
  1099. else
  1100. statype = CFG80211_STA_AP_CLIENT_UNASSOC;
  1101. break;
  1102. default:
  1103. err = -EOPNOTSUPP;
  1104. goto out_err;
  1105. }
  1106. err = cfg80211_check_station_change(wiphy, params, statype);
  1107. if (err)
  1108. goto out_err;
  1109. if (params->vlan && params->vlan != sta->sdata->dev) {
  1110. bool prev_4addr = false;
  1111. bool new_4addr = false;
  1112. vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
  1113. if (params->vlan->ieee80211_ptr->use_4addr) {
  1114. if (vlansdata->u.vlan.sta) {
  1115. err = -EBUSY;
  1116. goto out_err;
  1117. }
  1118. rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
  1119. new_4addr = true;
  1120. }
  1121. if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
  1122. sta->sdata->u.vlan.sta) {
  1123. RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL);
  1124. prev_4addr = true;
  1125. }
  1126. sta->sdata = vlansdata;
  1127. ieee80211_check_fast_xmit(sta);
  1128. if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
  1129. prev_4addr != new_4addr) {
  1130. if (new_4addr)
  1131. atomic_dec(&sta->sdata->bss->num_mcast_sta);
  1132. else
  1133. atomic_inc(&sta->sdata->bss->num_mcast_sta);
  1134. }
  1135. ieee80211_send_layer2_update(sta);
  1136. }
  1137. err = sta_apply_parameters(local, sta, params);
  1138. if (err)
  1139. goto out_err;
  1140. mutex_unlock(&local->sta_mtx);
  1141. if ((sdata->vif.type == NL80211_IFTYPE_AP ||
  1142. sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
  1143. sta->known_smps_mode != sta->sdata->bss->req_smps &&
  1144. test_sta_flag(sta, WLAN_STA_AUTHORIZED) &&
  1145. sta_info_tx_streams(sta) != 1) {
  1146. ht_dbg(sta->sdata,
  1147. "%pM just authorized and MIMO capable - update SMPS\n",
  1148. sta->sta.addr);
  1149. ieee80211_send_smps_action(sta->sdata,
  1150. sta->sdata->bss->req_smps,
  1151. sta->sta.addr,
  1152. sta->sdata->vif.bss_conf.bssid);
  1153. }
  1154. if (sdata->vif.type == NL80211_IFTYPE_STATION &&
  1155. params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
  1156. ieee80211_recalc_ps(local);
  1157. ieee80211_recalc_ps_vif(sdata);
  1158. }
  1159. return 0;
  1160. out_err:
  1161. mutex_unlock(&local->sta_mtx);
  1162. return err;
  1163. }
  1164. #ifdef CONFIG_MAC80211_MESH
  1165. static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
  1166. const u8 *dst, const u8 *next_hop)
  1167. {
  1168. struct ieee80211_sub_if_data *sdata;
  1169. struct mesh_path *mpath;
  1170. struct sta_info *sta;
  1171. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1172. rcu_read_lock();
  1173. sta = sta_info_get(sdata, next_hop);
  1174. if (!sta) {
  1175. rcu_read_unlock();
  1176. return -ENOENT;
  1177. }
  1178. mpath = mesh_path_add(sdata, dst);
  1179. if (IS_ERR(mpath)) {
  1180. rcu_read_unlock();
  1181. return PTR_ERR(mpath);
  1182. }
  1183. mesh_path_fix_nexthop(mpath, sta);
  1184. rcu_read_unlock();
  1185. return 0;
  1186. }
  1187. static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
  1188. const u8 *dst)
  1189. {
  1190. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1191. if (dst)
  1192. return mesh_path_del(sdata, dst);
  1193. mesh_path_flush_by_iface(sdata);
  1194. return 0;
  1195. }
  1196. static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev,
  1197. const u8 *dst, const u8 *next_hop)
  1198. {
  1199. struct ieee80211_sub_if_data *sdata;
  1200. struct mesh_path *mpath;
  1201. struct sta_info *sta;
  1202. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1203. rcu_read_lock();
  1204. sta = sta_info_get(sdata, next_hop);
  1205. if (!sta) {
  1206. rcu_read_unlock();
  1207. return -ENOENT;
  1208. }
  1209. mpath = mesh_path_lookup(sdata, dst);
  1210. if (!mpath) {
  1211. rcu_read_unlock();
  1212. return -ENOENT;
  1213. }
  1214. mesh_path_fix_nexthop(mpath, sta);
  1215. rcu_read_unlock();
  1216. return 0;
  1217. }
  1218. static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
  1219. struct mpath_info *pinfo)
  1220. {
  1221. struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
  1222. if (next_hop_sta)
  1223. memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
  1224. else
  1225. eth_zero_addr(next_hop);
  1226. memset(pinfo, 0, sizeof(*pinfo));
  1227. pinfo->generation = mesh_paths_generation;
  1228. pinfo->filled = MPATH_INFO_FRAME_QLEN |
  1229. MPATH_INFO_SN |
  1230. MPATH_INFO_METRIC |
  1231. MPATH_INFO_EXPTIME |
  1232. MPATH_INFO_DISCOVERY_TIMEOUT |
  1233. MPATH_INFO_DISCOVERY_RETRIES |
  1234. MPATH_INFO_FLAGS;
  1235. pinfo->frame_qlen = mpath->frame_queue.qlen;
  1236. pinfo->sn = mpath->sn;
  1237. pinfo->metric = mpath->metric;
  1238. if (time_before(jiffies, mpath->exp_time))
  1239. pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
  1240. pinfo->discovery_timeout =
  1241. jiffies_to_msecs(mpath->discovery_timeout);
  1242. pinfo->discovery_retries = mpath->discovery_retries;
  1243. if (mpath->flags & MESH_PATH_ACTIVE)
  1244. pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
  1245. if (mpath->flags & MESH_PATH_RESOLVING)
  1246. pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
  1247. if (mpath->flags & MESH_PATH_SN_VALID)
  1248. pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
  1249. if (mpath->flags & MESH_PATH_FIXED)
  1250. pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
  1251. if (mpath->flags & MESH_PATH_RESOLVED)
  1252. pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
  1253. }
  1254. static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
  1255. u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
  1256. {
  1257. struct ieee80211_sub_if_data *sdata;
  1258. struct mesh_path *mpath;
  1259. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1260. rcu_read_lock();
  1261. mpath = mesh_path_lookup(sdata, dst);
  1262. if (!mpath) {
  1263. rcu_read_unlock();
  1264. return -ENOENT;
  1265. }
  1266. memcpy(dst, mpath->dst, ETH_ALEN);
  1267. mpath_set_pinfo(mpath, next_hop, pinfo);
  1268. rcu_read_unlock();
  1269. return 0;
  1270. }
  1271. static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
  1272. int idx, u8 *dst, u8 *next_hop,
  1273. struct mpath_info *pinfo)
  1274. {
  1275. struct ieee80211_sub_if_data *sdata;
  1276. struct mesh_path *mpath;
  1277. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1278. rcu_read_lock();
  1279. mpath = mesh_path_lookup_by_idx(sdata, idx);
  1280. if (!mpath) {
  1281. rcu_read_unlock();
  1282. return -ENOENT;
  1283. }
  1284. memcpy(dst, mpath->dst, ETH_ALEN);
  1285. mpath_set_pinfo(mpath, next_hop, pinfo);
  1286. rcu_read_unlock();
  1287. return 0;
  1288. }
  1289. static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp,
  1290. struct mpath_info *pinfo)
  1291. {
  1292. memset(pinfo, 0, sizeof(*pinfo));
  1293. memcpy(mpp, mpath->mpp, ETH_ALEN);
  1294. pinfo->generation = mpp_paths_generation;
  1295. }
  1296. static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev,
  1297. u8 *dst, u8 *mpp, struct mpath_info *pinfo)
  1298. {
  1299. struct ieee80211_sub_if_data *sdata;
  1300. struct mesh_path *mpath;
  1301. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1302. rcu_read_lock();
  1303. mpath = mpp_path_lookup(sdata, dst);
  1304. if (!mpath) {
  1305. rcu_read_unlock();
  1306. return -ENOENT;
  1307. }
  1308. memcpy(dst, mpath->dst, ETH_ALEN);
  1309. mpp_set_pinfo(mpath, mpp, pinfo);
  1310. rcu_read_unlock();
  1311. return 0;
  1312. }
  1313. static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev,
  1314. int idx, u8 *dst, u8 *mpp,
  1315. struct mpath_info *pinfo)
  1316. {
  1317. struct ieee80211_sub_if_data *sdata;
  1318. struct mesh_path *mpath;
  1319. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1320. rcu_read_lock();
  1321. mpath = mpp_path_lookup_by_idx(sdata, idx);
  1322. if (!mpath) {
  1323. rcu_read_unlock();
  1324. return -ENOENT;
  1325. }
  1326. memcpy(dst, mpath->dst, ETH_ALEN);
  1327. mpp_set_pinfo(mpath, mpp, pinfo);
  1328. rcu_read_unlock();
  1329. return 0;
  1330. }
  1331. static int ieee80211_get_mesh_config(struct wiphy *wiphy,
  1332. struct net_device *dev,
  1333. struct mesh_config *conf)
  1334. {
  1335. struct ieee80211_sub_if_data *sdata;
  1336. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1337. memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
  1338. return 0;
  1339. }
  1340. static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
  1341. {
  1342. return (mask >> (parm-1)) & 0x1;
  1343. }
  1344. static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
  1345. const struct mesh_setup *setup)
  1346. {
  1347. u8 *new_ie;
  1348. const u8 *old_ie;
  1349. struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
  1350. struct ieee80211_sub_if_data, u.mesh);
  1351. /* allocate information elements */
  1352. new_ie = NULL;
  1353. old_ie = ifmsh->ie;
  1354. if (setup->ie_len) {
  1355. new_ie = kmemdup(setup->ie, setup->ie_len,
  1356. GFP_KERNEL);
  1357. if (!new_ie)
  1358. return -ENOMEM;
  1359. }
  1360. ifmsh->ie_len = setup->ie_len;
  1361. ifmsh->ie = new_ie;
  1362. kfree(old_ie);
  1363. /* now copy the rest of the setup parameters */
  1364. ifmsh->mesh_id_len = setup->mesh_id_len;
  1365. memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
  1366. ifmsh->mesh_sp_id = setup->sync_method;
  1367. ifmsh->mesh_pp_id = setup->path_sel_proto;
  1368. ifmsh->mesh_pm_id = setup->path_metric;
  1369. ifmsh->user_mpm = setup->user_mpm;
  1370. ifmsh->mesh_auth_id = setup->auth_id;
  1371. ifmsh->security = IEEE80211_MESH_SEC_NONE;
  1372. if (setup->is_authenticated)
  1373. ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
  1374. if (setup->is_secure)
  1375. ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
  1376. /* mcast rate setting in Mesh Node */
  1377. memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
  1378. sizeof(setup->mcast_rate));
  1379. sdata->vif.bss_conf.basic_rates = setup->basic_rates;
  1380. sdata->vif.bss_conf.beacon_int = setup->beacon_interval;
  1381. sdata->vif.bss_conf.dtim_period = setup->dtim_period;
  1382. return 0;
  1383. }
  1384. static int ieee80211_update_mesh_config(struct wiphy *wiphy,
  1385. struct net_device *dev, u32 mask,
  1386. const struct mesh_config *nconf)
  1387. {
  1388. struct mesh_config *conf;
  1389. struct ieee80211_sub_if_data *sdata;
  1390. struct ieee80211_if_mesh *ifmsh;
  1391. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1392. ifmsh = &sdata->u.mesh;
  1393. /* Set the config options which we are interested in setting */
  1394. conf = &(sdata->u.mesh.mshcfg);
  1395. if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
  1396. conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
  1397. if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
  1398. conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
  1399. if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
  1400. conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
  1401. if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
  1402. conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
  1403. if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
  1404. conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
  1405. if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
  1406. conf->dot11MeshTTL = nconf->dot11MeshTTL;
  1407. if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
  1408. conf->element_ttl = nconf->element_ttl;
  1409. if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) {
  1410. if (ifmsh->user_mpm)
  1411. return -EBUSY;
  1412. conf->auto_open_plinks = nconf->auto_open_plinks;
  1413. }
  1414. if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
  1415. conf->dot11MeshNbrOffsetMaxNeighbor =
  1416. nconf->dot11MeshNbrOffsetMaxNeighbor;
  1417. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
  1418. conf->dot11MeshHWMPmaxPREQretries =
  1419. nconf->dot11MeshHWMPmaxPREQretries;
  1420. if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
  1421. conf->path_refresh_time = nconf->path_refresh_time;
  1422. if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
  1423. conf->min_discovery_timeout = nconf->min_discovery_timeout;
  1424. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
  1425. conf->dot11MeshHWMPactivePathTimeout =
  1426. nconf->dot11MeshHWMPactivePathTimeout;
  1427. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
  1428. conf->dot11MeshHWMPpreqMinInterval =
  1429. nconf->dot11MeshHWMPpreqMinInterval;
  1430. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
  1431. conf->dot11MeshHWMPperrMinInterval =
  1432. nconf->dot11MeshHWMPperrMinInterval;
  1433. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
  1434. mask))
  1435. conf->dot11MeshHWMPnetDiameterTraversalTime =
  1436. nconf->dot11MeshHWMPnetDiameterTraversalTime;
  1437. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
  1438. conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
  1439. ieee80211_mesh_root_setup(ifmsh);
  1440. }
  1441. if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
  1442. /* our current gate announcement implementation rides on root
  1443. * announcements, so require this ifmsh to also be a root node
  1444. * */
  1445. if (nconf->dot11MeshGateAnnouncementProtocol &&
  1446. !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) {
  1447. conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN;
  1448. ieee80211_mesh_root_setup(ifmsh);
  1449. }
  1450. conf->dot11MeshGateAnnouncementProtocol =
  1451. nconf->dot11MeshGateAnnouncementProtocol;
  1452. }
  1453. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask))
  1454. conf->dot11MeshHWMPRannInterval =
  1455. nconf->dot11MeshHWMPRannInterval;
  1456. if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
  1457. conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
  1458. if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
  1459. /* our RSSI threshold implementation is supported only for
  1460. * devices that report signal in dBm.
  1461. */
  1462. if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM))
  1463. return -ENOTSUPP;
  1464. conf->rssi_threshold = nconf->rssi_threshold;
  1465. }
  1466. if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
  1467. conf->ht_opmode = nconf->ht_opmode;
  1468. sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
  1469. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
  1470. }
  1471. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask))
  1472. conf->dot11MeshHWMPactivePathToRootTimeout =
  1473. nconf->dot11MeshHWMPactivePathToRootTimeout;
  1474. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask))
  1475. conf->dot11MeshHWMProotInterval =
  1476. nconf->dot11MeshHWMProotInterval;
  1477. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask))
  1478. conf->dot11MeshHWMPconfirmationInterval =
  1479. nconf->dot11MeshHWMPconfirmationInterval;
  1480. if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) {
  1481. conf->power_mode = nconf->power_mode;
  1482. ieee80211_mps_local_status_update(sdata);
  1483. }
  1484. if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask))
  1485. conf->dot11MeshAwakeWindowDuration =
  1486. nconf->dot11MeshAwakeWindowDuration;
  1487. if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask))
  1488. conf->plink_timeout = nconf->plink_timeout;
  1489. ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
  1490. return 0;
  1491. }
  1492. static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
  1493. const struct mesh_config *conf,
  1494. const struct mesh_setup *setup)
  1495. {
  1496. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1497. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  1498. int err;
  1499. memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
  1500. err = copy_mesh_setup(ifmsh, setup);
  1501. if (err)
  1502. return err;
  1503. /* can mesh use other SMPS modes? */
  1504. sdata->smps_mode = IEEE80211_SMPS_OFF;
  1505. sdata->needed_rx_chains = sdata->local->rx_chains;
  1506. mutex_lock(&sdata->local->mtx);
  1507. err = ieee80211_vif_use_channel(sdata, &setup->chandef,
  1508. IEEE80211_CHANCTX_SHARED);
  1509. mutex_unlock(&sdata->local->mtx);
  1510. if (err)
  1511. return err;
  1512. return ieee80211_start_mesh(sdata);
  1513. }
  1514. static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
  1515. {
  1516. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1517. ieee80211_stop_mesh(sdata);
  1518. mutex_lock(&sdata->local->mtx);
  1519. ieee80211_vif_release_channel(sdata);
  1520. mutex_unlock(&sdata->local->mtx);
  1521. return 0;
  1522. }
  1523. #endif
  1524. static int ieee80211_change_bss(struct wiphy *wiphy,
  1525. struct net_device *dev,
  1526. struct bss_parameters *params)
  1527. {
  1528. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1529. enum ieee80211_band band;
  1530. u32 changed = 0;
  1531. if (!sdata_dereference(sdata->u.ap.beacon, sdata))
  1532. return -ENOENT;
  1533. band = ieee80211_get_sdata_band(sdata);
  1534. if (params->use_cts_prot >= 0) {
  1535. sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
  1536. changed |= BSS_CHANGED_ERP_CTS_PROT;
  1537. }
  1538. if (params->use_short_preamble >= 0) {
  1539. sdata->vif.bss_conf.use_short_preamble =
  1540. params->use_short_preamble;
  1541. changed |= BSS_CHANGED_ERP_PREAMBLE;
  1542. }
  1543. if (!sdata->vif.bss_conf.use_short_slot &&
  1544. band == IEEE80211_BAND_5GHZ) {
  1545. sdata->vif.bss_conf.use_short_slot = true;
  1546. changed |= BSS_CHANGED_ERP_SLOT;
  1547. }
  1548. if (params->use_short_slot_time >= 0) {
  1549. sdata->vif.bss_conf.use_short_slot =
  1550. params->use_short_slot_time;
  1551. changed |= BSS_CHANGED_ERP_SLOT;
  1552. }
  1553. if (params->basic_rates) {
  1554. ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef,
  1555. wiphy->bands[band],
  1556. params->basic_rates,
  1557. params->basic_rates_len,
  1558. &sdata->vif.bss_conf.basic_rates);
  1559. changed |= BSS_CHANGED_BASIC_RATES;
  1560. }
  1561. if (params->ap_isolate >= 0) {
  1562. if (params->ap_isolate)
  1563. sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
  1564. else
  1565. sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
  1566. }
  1567. if (params->ht_opmode >= 0) {
  1568. sdata->vif.bss_conf.ht_operation_mode =
  1569. (u16) params->ht_opmode;
  1570. changed |= BSS_CHANGED_HT;
  1571. }
  1572. if (params->p2p_ctwindow >= 0) {
  1573. sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
  1574. ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
  1575. sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
  1576. params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK;
  1577. changed |= BSS_CHANGED_P2P_PS;
  1578. }
  1579. if (params->p2p_opp_ps > 0) {
  1580. sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
  1581. IEEE80211_P2P_OPPPS_ENABLE_BIT;
  1582. changed |= BSS_CHANGED_P2P_PS;
  1583. } else if (params->p2p_opp_ps == 0) {
  1584. sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &=
  1585. ~IEEE80211_P2P_OPPPS_ENABLE_BIT;
  1586. changed |= BSS_CHANGED_P2P_PS;
  1587. }
  1588. ieee80211_bss_info_change_notify(sdata, changed);
  1589. return 0;
  1590. }
  1591. static int ieee80211_set_txq_params(struct wiphy *wiphy,
  1592. struct net_device *dev,
  1593. struct ieee80211_txq_params *params)
  1594. {
  1595. struct ieee80211_local *local = wiphy_priv(wiphy);
  1596. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1597. struct ieee80211_tx_queue_params p;
  1598. if (!local->ops->conf_tx)
  1599. return -EOPNOTSUPP;
  1600. if (local->hw.queues < IEEE80211_NUM_ACS)
  1601. return -EOPNOTSUPP;
  1602. memset(&p, 0, sizeof(p));
  1603. p.aifs = params->aifs;
  1604. p.cw_max = params->cwmax;
  1605. p.cw_min = params->cwmin;
  1606. p.txop = params->txop;
  1607. /*
  1608. * Setting tx queue params disables u-apsd because it's only
  1609. * called in master mode.
  1610. */
  1611. p.uapsd = false;
  1612. sdata->tx_conf[params->ac] = p;
  1613. if (drv_conf_tx(local, sdata, params->ac, &p)) {
  1614. wiphy_debug(local->hw.wiphy,
  1615. "failed to set TX queue parameters for AC %d\n",
  1616. params->ac);
  1617. return -EINVAL;
  1618. }
  1619. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
  1620. return 0;
  1621. }
  1622. #ifdef CONFIG_PM
  1623. static int ieee80211_suspend(struct wiphy *wiphy,
  1624. struct cfg80211_wowlan *wowlan)
  1625. {
  1626. return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
  1627. }
  1628. static int ieee80211_resume(struct wiphy *wiphy)
  1629. {
  1630. return __ieee80211_resume(wiphy_priv(wiphy));
  1631. }
  1632. #else
  1633. #define ieee80211_suspend NULL
  1634. #define ieee80211_resume NULL
  1635. #endif
  1636. static int ieee80211_scan(struct wiphy *wiphy,
  1637. struct cfg80211_scan_request *req)
  1638. {
  1639. struct ieee80211_sub_if_data *sdata;
  1640. sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
  1641. switch (ieee80211_vif_type_p2p(&sdata->vif)) {
  1642. case NL80211_IFTYPE_STATION:
  1643. case NL80211_IFTYPE_ADHOC:
  1644. case NL80211_IFTYPE_MESH_POINT:
  1645. case NL80211_IFTYPE_P2P_CLIENT:
  1646. case NL80211_IFTYPE_P2P_DEVICE:
  1647. break;
  1648. case NL80211_IFTYPE_P2P_GO:
  1649. if (sdata->local->ops->hw_scan)
  1650. break;
  1651. /*
  1652. * FIXME: implement NoA while scanning in software,
  1653. * for now fall through to allow scanning only when
  1654. * beaconing hasn't been configured yet
  1655. */
  1656. case NL80211_IFTYPE_AP:
  1657. /*
  1658. * If the scan has been forced (and the driver supports
  1659. * forcing), don't care about being beaconing already.
  1660. * This will create problems to the attached stations (e.g. all
  1661. * the frames sent while scanning on other channel will be
  1662. * lost)
  1663. */
  1664. if (sdata->u.ap.beacon &&
  1665. (!(wiphy->features & NL80211_FEATURE_AP_SCAN) ||
  1666. !(req->flags & NL80211_SCAN_FLAG_AP)))
  1667. return -EOPNOTSUPP;
  1668. break;
  1669. default:
  1670. return -EOPNOTSUPP;
  1671. }
  1672. return ieee80211_request_scan(sdata, req);
  1673. }
  1674. static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
  1675. {
  1676. ieee80211_scan_cancel(wiphy_priv(wiphy));
  1677. }
  1678. static int
  1679. ieee80211_sched_scan_start(struct wiphy *wiphy,
  1680. struct net_device *dev,
  1681. struct cfg80211_sched_scan_request *req)
  1682. {
  1683. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1684. if (!sdata->local->ops->sched_scan_start)
  1685. return -EOPNOTSUPP;
  1686. return ieee80211_request_sched_scan_start(sdata, req);
  1687. }
  1688. static int
  1689. ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
  1690. {
  1691. struct ieee80211_local *local = wiphy_priv(wiphy);
  1692. if (!local->ops->sched_scan_stop)
  1693. return -EOPNOTSUPP;
  1694. return ieee80211_request_sched_scan_stop(local);
  1695. }
  1696. static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
  1697. struct cfg80211_auth_request *req)
  1698. {
  1699. return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
  1700. }
  1701. static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
  1702. struct cfg80211_assoc_request *req)
  1703. {
  1704. return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
  1705. }
  1706. static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
  1707. struct cfg80211_deauth_request *req)
  1708. {
  1709. return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
  1710. }
  1711. static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
  1712. struct cfg80211_disassoc_request *req)
  1713. {
  1714. return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
  1715. }
  1716. static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
  1717. struct cfg80211_ibss_params *params)
  1718. {
  1719. return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params);
  1720. }
  1721. static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
  1722. {
  1723. return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev));
  1724. }
  1725. static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev,
  1726. struct ocb_setup *setup)
  1727. {
  1728. return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup);
  1729. }
  1730. static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev)
  1731. {
  1732. return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev));
  1733. }
  1734. static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev,
  1735. int rate[IEEE80211_NUM_BANDS])
  1736. {
  1737. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1738. memcpy(sdata->vif.bss_conf.mcast_rate, rate,
  1739. sizeof(int) * IEEE80211_NUM_BANDS);
  1740. return 0;
  1741. }
  1742. static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
  1743. {
  1744. struct ieee80211_local *local = wiphy_priv(wiphy);
  1745. int err;
  1746. if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
  1747. ieee80211_check_fast_xmit_all(local);
  1748. err = drv_set_frag_threshold(local, wiphy->frag_threshold);
  1749. if (err) {
  1750. ieee80211_check_fast_xmit_all(local);
  1751. return err;
  1752. }
  1753. }
  1754. if ((changed & WIPHY_PARAM_COVERAGE_CLASS) ||
  1755. (changed & WIPHY_PARAM_DYN_ACK)) {
  1756. s16 coverage_class;
  1757. coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ?
  1758. wiphy->coverage_class : -1;
  1759. err = drv_set_coverage_class(local, coverage_class);
  1760. if (err)
  1761. return err;
  1762. }
  1763. if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
  1764. err = drv_set_rts_threshold(local, wiphy->rts_threshold);
  1765. if (err)
  1766. return err;
  1767. }
  1768. if (changed & WIPHY_PARAM_RETRY_SHORT) {
  1769. if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY)
  1770. return -EINVAL;
  1771. local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
  1772. }
  1773. if (changed & WIPHY_PARAM_RETRY_LONG) {
  1774. if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY)
  1775. return -EINVAL;
  1776. local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
  1777. }
  1778. if (changed &
  1779. (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
  1780. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
  1781. return 0;
  1782. }
  1783. static int ieee80211_set_tx_power(struct wiphy *wiphy,
  1784. struct wireless_dev *wdev,
  1785. enum nl80211_tx_power_setting type, int mbm)
  1786. {
  1787. struct ieee80211_local *local = wiphy_priv(wiphy);
  1788. struct ieee80211_sub_if_data *sdata;
  1789. enum nl80211_tx_power_setting txp_type = type;
  1790. bool update_txp_type = false;
  1791. if (wdev) {
  1792. sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  1793. switch (type) {
  1794. case NL80211_TX_POWER_AUTOMATIC:
  1795. sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
  1796. txp_type = NL80211_TX_POWER_LIMITED;
  1797. break;
  1798. case NL80211_TX_POWER_LIMITED:
  1799. case NL80211_TX_POWER_FIXED:
  1800. if (mbm < 0 || (mbm % 100))
  1801. return -EOPNOTSUPP;
  1802. sdata->user_power_level = MBM_TO_DBM(mbm);
  1803. break;
  1804. }
  1805. if (txp_type != sdata->vif.bss_conf.txpower_type) {
  1806. update_txp_type = true;
  1807. sdata->vif.bss_conf.txpower_type = txp_type;
  1808. }
  1809. ieee80211_recalc_txpower(sdata, update_txp_type);
  1810. return 0;
  1811. }
  1812. switch (type) {
  1813. case NL80211_TX_POWER_AUTOMATIC:
  1814. local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
  1815. txp_type = NL80211_TX_POWER_LIMITED;
  1816. break;
  1817. case NL80211_TX_POWER_LIMITED:
  1818. case NL80211_TX_POWER_FIXED:
  1819. if (mbm < 0 || (mbm % 100))
  1820. return -EOPNOTSUPP;
  1821. local->user_power_level = MBM_TO_DBM(mbm);
  1822. break;
  1823. }
  1824. mutex_lock(&local->iflist_mtx);
  1825. list_for_each_entry(sdata, &local->interfaces, list) {
  1826. sdata->user_power_level = local->user_power_level;
  1827. if (txp_type != sdata->vif.bss_conf.txpower_type)
  1828. update_txp_type = true;
  1829. sdata->vif.bss_conf.txpower_type = txp_type;
  1830. }
  1831. list_for_each_entry(sdata, &local->interfaces, list)
  1832. ieee80211_recalc_txpower(sdata, update_txp_type);
  1833. mutex_unlock(&local->iflist_mtx);
  1834. return 0;
  1835. }
  1836. static int ieee80211_get_tx_power(struct wiphy *wiphy,
  1837. struct wireless_dev *wdev,
  1838. int *dbm)
  1839. {
  1840. struct ieee80211_local *local = wiphy_priv(wiphy);
  1841. struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  1842. if (local->ops->get_txpower)
  1843. return drv_get_txpower(local, sdata, dbm);
  1844. if (!local->use_chanctx)
  1845. *dbm = local->hw.conf.power_level;
  1846. else
  1847. *dbm = sdata->vif.bss_conf.txpower;
  1848. return 0;
  1849. }
  1850. static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
  1851. const u8 *addr)
  1852. {
  1853. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1854. memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
  1855. return 0;
  1856. }
  1857. static void ieee80211_rfkill_poll(struct wiphy *wiphy)
  1858. {
  1859. struct ieee80211_local *local = wiphy_priv(wiphy);
  1860. drv_rfkill_poll(local);
  1861. }
  1862. #ifdef CONFIG_NL80211_TESTMODE
  1863. static int ieee80211_testmode_cmd(struct wiphy *wiphy,
  1864. struct wireless_dev *wdev,
  1865. void *data, int len)
  1866. {
  1867. struct ieee80211_local *local = wiphy_priv(wiphy);
  1868. struct ieee80211_vif *vif = NULL;
  1869. if (!local->ops->testmode_cmd)
  1870. return -EOPNOTSUPP;
  1871. if (wdev) {
  1872. struct ieee80211_sub_if_data *sdata;
  1873. sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  1874. if (sdata->flags & IEEE80211_SDATA_IN_DRIVER)
  1875. vif = &sdata->vif;
  1876. }
  1877. return local->ops->testmode_cmd(&local->hw, vif, data, len);
  1878. }
  1879. static int ieee80211_testmode_dump(struct wiphy *wiphy,
  1880. struct sk_buff *skb,
  1881. struct netlink_callback *cb,
  1882. void *data, int len)
  1883. {
  1884. struct ieee80211_local *local = wiphy_priv(wiphy);
  1885. if (!local->ops->testmode_dump)
  1886. return -EOPNOTSUPP;
  1887. return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
  1888. }
  1889. #endif
  1890. int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
  1891. enum ieee80211_smps_mode smps_mode)
  1892. {
  1893. struct sta_info *sta;
  1894. enum ieee80211_smps_mode old_req;
  1895. if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP))
  1896. return -EINVAL;
  1897. if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
  1898. return 0;
  1899. old_req = sdata->u.ap.req_smps;
  1900. sdata->u.ap.req_smps = smps_mode;
  1901. /* AUTOMATIC doesn't mean much for AP - don't allow it */
  1902. if (old_req == smps_mode ||
  1903. smps_mode == IEEE80211_SMPS_AUTOMATIC)
  1904. return 0;
  1905. /* If no associated stations, there's no need to do anything */
  1906. if (!atomic_read(&sdata->u.ap.num_mcast_sta)) {
  1907. sdata->smps_mode = smps_mode;
  1908. ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
  1909. return 0;
  1910. }
  1911. ht_dbg(sdata,
  1912. "SMPS %d requested in AP mode, sending Action frame to %d stations\n",
  1913. smps_mode, atomic_read(&sdata->u.ap.num_mcast_sta));
  1914. mutex_lock(&sdata->local->sta_mtx);
  1915. list_for_each_entry(sta, &sdata->local->sta_list, list) {
  1916. /*
  1917. * Only stations associated to our AP and
  1918. * associated VLANs
  1919. */
  1920. if (sta->sdata->bss != &sdata->u.ap)
  1921. continue;
  1922. /* This station doesn't support MIMO - skip it */
  1923. if (sta_info_tx_streams(sta) == 1)
  1924. continue;
  1925. /*
  1926. * Don't wake up a STA just to send the action frame
  1927. * unless we are getting more restrictive.
  1928. */
  1929. if (test_sta_flag(sta, WLAN_STA_PS_STA) &&
  1930. !ieee80211_smps_is_restrictive(sta->known_smps_mode,
  1931. smps_mode)) {
  1932. ht_dbg(sdata, "Won't send SMPS to sleeping STA %pM\n",
  1933. sta->sta.addr);
  1934. continue;
  1935. }
  1936. /*
  1937. * If the STA is not authorized, wait until it gets
  1938. * authorized and the action frame will be sent then.
  1939. */
  1940. if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED))
  1941. continue;
  1942. ht_dbg(sdata, "Sending SMPS to %pM\n", sta->sta.addr);
  1943. ieee80211_send_smps_action(sdata, smps_mode, sta->sta.addr,
  1944. sdata->vif.bss_conf.bssid);
  1945. }
  1946. mutex_unlock(&sdata->local->sta_mtx);
  1947. sdata->smps_mode = smps_mode;
  1948. ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps);
  1949. return 0;
  1950. }
  1951. int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
  1952. enum ieee80211_smps_mode smps_mode)
  1953. {
  1954. const u8 *ap;
  1955. enum ieee80211_smps_mode old_req;
  1956. int err;
  1957. struct sta_info *sta;
  1958. bool tdls_peer_found = false;
  1959. lockdep_assert_held(&sdata->wdev.mtx);
  1960. if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION))
  1961. return -EINVAL;
  1962. old_req = sdata->u.mgd.req_smps;
  1963. sdata->u.mgd.req_smps = smps_mode;
  1964. if (old_req == smps_mode &&
  1965. smps_mode != IEEE80211_SMPS_AUTOMATIC)
  1966. return 0;
  1967. /*
  1968. * If not associated, or current association is not an HT
  1969. * association, there's no need to do anything, just store
  1970. * the new value until we associate.
  1971. */
  1972. if (!sdata->u.mgd.associated ||
  1973. sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT)
  1974. return 0;
  1975. ap = sdata->u.mgd.associated->bssid;
  1976. rcu_read_lock();
  1977. list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) {
  1978. if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded ||
  1979. !test_sta_flag(sta, WLAN_STA_AUTHORIZED))
  1980. continue;
  1981. tdls_peer_found = true;
  1982. break;
  1983. }
  1984. rcu_read_unlock();
  1985. if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
  1986. if (tdls_peer_found || !sdata->u.mgd.powersave)
  1987. smps_mode = IEEE80211_SMPS_OFF;
  1988. else
  1989. smps_mode = IEEE80211_SMPS_DYNAMIC;
  1990. }
  1991. /* send SM PS frame to AP */
  1992. err = ieee80211_send_smps_action(sdata, smps_mode,
  1993. ap, ap);
  1994. if (err)
  1995. sdata->u.mgd.req_smps = old_req;
  1996. else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found)
  1997. ieee80211_teardown_tdls_peers(sdata);
  1998. return err;
  1999. }
  2000. static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
  2001. bool enabled, int timeout)
  2002. {
  2003. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2004. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  2005. if (sdata->vif.type != NL80211_IFTYPE_STATION)
  2006. return -EOPNOTSUPP;
  2007. if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS))
  2008. return -EOPNOTSUPP;
  2009. if (enabled == sdata->u.mgd.powersave &&
  2010. timeout == local->dynamic_ps_forced_timeout)
  2011. return 0;
  2012. sdata->u.mgd.powersave = enabled;
  2013. local->dynamic_ps_forced_timeout = timeout;
  2014. /* no change, but if automatic follow powersave */
  2015. sdata_lock(sdata);
  2016. __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps);
  2017. sdata_unlock(sdata);
  2018. if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS))
  2019. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
  2020. ieee80211_recalc_ps(local);
  2021. ieee80211_recalc_ps_vif(sdata);
  2022. return 0;
  2023. }
  2024. static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
  2025. struct net_device *dev,
  2026. s32 rssi_thold, u32 rssi_hyst)
  2027. {
  2028. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2029. struct ieee80211_vif *vif = &sdata->vif;
  2030. struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
  2031. if (rssi_thold == bss_conf->cqm_rssi_thold &&
  2032. rssi_hyst == bss_conf->cqm_rssi_hyst)
  2033. return 0;
  2034. if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER &&
  2035. !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
  2036. return -EOPNOTSUPP;
  2037. bss_conf->cqm_rssi_thold = rssi_thold;
  2038. bss_conf->cqm_rssi_hyst = rssi_hyst;
  2039. sdata->u.mgd.last_cqm_event_signal = 0;
  2040. /* tell the driver upon association, unless already associated */
  2041. if (sdata->u.mgd.associated &&
  2042. sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
  2043. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
  2044. return 0;
  2045. }
  2046. static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
  2047. struct net_device *dev,
  2048. const u8 *addr,
  2049. const struct cfg80211_bitrate_mask *mask)
  2050. {
  2051. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2052. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  2053. int i, ret;
  2054. if (!ieee80211_sdata_running(sdata))
  2055. return -ENETDOWN;
  2056. if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) {
  2057. ret = drv_set_bitrate_mask(local, sdata, mask);
  2058. if (ret)
  2059. return ret;
  2060. }
  2061. for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
  2062. struct ieee80211_supported_band *sband = wiphy->bands[i];
  2063. int j;
  2064. sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
  2065. memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs,
  2066. sizeof(mask->control[i].ht_mcs));
  2067. memcpy(sdata->rc_rateidx_vht_mcs_mask[i],
  2068. mask->control[i].vht_mcs,
  2069. sizeof(mask->control[i].vht_mcs));
  2070. sdata->rc_has_mcs_mask[i] = false;
  2071. sdata->rc_has_vht_mcs_mask[i] = false;
  2072. if (!sband)
  2073. continue;
  2074. for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
  2075. if (~sdata->rc_rateidx_mcs_mask[i][j]) {
  2076. sdata->rc_has_mcs_mask[i] = true;
  2077. break;
  2078. }
  2079. }
  2080. for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
  2081. if (~sdata->rc_rateidx_vht_mcs_mask[i][j]) {
  2082. sdata->rc_has_vht_mcs_mask[i] = true;
  2083. break;
  2084. }
  2085. }
  2086. }
  2087. return 0;
  2088. }
  2089. static int ieee80211_start_radar_detection(struct wiphy *wiphy,
  2090. struct net_device *dev,
  2091. struct cfg80211_chan_def *chandef,
  2092. u32 cac_time_ms)
  2093. {
  2094. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2095. struct ieee80211_local *local = sdata->local;
  2096. int err;
  2097. mutex_lock(&local->mtx);
  2098. if (!list_empty(&local->roc_list) || local->scanning) {
  2099. err = -EBUSY;
  2100. goto out_unlock;
  2101. }
  2102. /* whatever, but channel contexts should not complain about that one */
  2103. sdata->smps_mode = IEEE80211_SMPS_OFF;
  2104. sdata->needed_rx_chains = local->rx_chains;
  2105. err = ieee80211_vif_use_channel(sdata, chandef,
  2106. IEEE80211_CHANCTX_SHARED);
  2107. if (err)
  2108. goto out_unlock;
  2109. ieee80211_queue_delayed_work(&sdata->local->hw,
  2110. &sdata->dfs_cac_timer_work,
  2111. msecs_to_jiffies(cac_time_ms));
  2112. out_unlock:
  2113. mutex_unlock(&local->mtx);
  2114. return err;
  2115. }
  2116. static struct cfg80211_beacon_data *
  2117. cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
  2118. {
  2119. struct cfg80211_beacon_data *new_beacon;
  2120. u8 *pos;
  2121. int len;
  2122. len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
  2123. beacon->proberesp_ies_len + beacon->assocresp_ies_len +
  2124. beacon->probe_resp_len;
  2125. new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
  2126. if (!new_beacon)
  2127. return NULL;
  2128. pos = (u8 *)(new_beacon + 1);
  2129. if (beacon->head_len) {
  2130. new_beacon->head_len = beacon->head_len;
  2131. new_beacon->head = pos;
  2132. memcpy(pos, beacon->head, beacon->head_len);
  2133. pos += beacon->head_len;
  2134. }
  2135. if (beacon->tail_len) {
  2136. new_beacon->tail_len = beacon->tail_len;
  2137. new_beacon->tail = pos;
  2138. memcpy(pos, beacon->tail, beacon->tail_len);
  2139. pos += beacon->tail_len;
  2140. }
  2141. if (beacon->beacon_ies_len) {
  2142. new_beacon->beacon_ies_len = beacon->beacon_ies_len;
  2143. new_beacon->beacon_ies = pos;
  2144. memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
  2145. pos += beacon->beacon_ies_len;
  2146. }
  2147. if (beacon->proberesp_ies_len) {
  2148. new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
  2149. new_beacon->proberesp_ies = pos;
  2150. memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
  2151. pos += beacon->proberesp_ies_len;
  2152. }
  2153. if (beacon->assocresp_ies_len) {
  2154. new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
  2155. new_beacon->assocresp_ies = pos;
  2156. memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
  2157. pos += beacon->assocresp_ies_len;
  2158. }
  2159. if (beacon->probe_resp_len) {
  2160. new_beacon->probe_resp_len = beacon->probe_resp_len;
  2161. beacon->probe_resp = pos;
  2162. memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
  2163. pos += beacon->probe_resp_len;
  2164. }
  2165. return new_beacon;
  2166. }
  2167. void ieee80211_csa_finish(struct ieee80211_vif *vif)
  2168. {
  2169. struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
  2170. ieee80211_queue_work(&sdata->local->hw,
  2171. &sdata->csa_finalize_work);
  2172. }
  2173. EXPORT_SYMBOL(ieee80211_csa_finish);
  2174. static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
  2175. u32 *changed)
  2176. {
  2177. int err;
  2178. switch (sdata->vif.type) {
  2179. case NL80211_IFTYPE_AP:
  2180. err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
  2181. NULL);
  2182. kfree(sdata->u.ap.next_beacon);
  2183. sdata->u.ap.next_beacon = NULL;
  2184. if (err < 0)
  2185. return err;
  2186. *changed |= err;
  2187. break;
  2188. case NL80211_IFTYPE_ADHOC:
  2189. err = ieee80211_ibss_finish_csa(sdata);
  2190. if (err < 0)
  2191. return err;
  2192. *changed |= err;
  2193. break;
  2194. #ifdef CONFIG_MAC80211_MESH
  2195. case NL80211_IFTYPE_MESH_POINT:
  2196. err = ieee80211_mesh_finish_csa(sdata);
  2197. if (err < 0)
  2198. return err;
  2199. *changed |= err;
  2200. break;
  2201. #endif
  2202. default:
  2203. WARN_ON(1);
  2204. return -EINVAL;
  2205. }
  2206. return 0;
  2207. }
  2208. static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
  2209. {
  2210. struct ieee80211_local *local = sdata->local;
  2211. u32 changed = 0;
  2212. int err;
  2213. sdata_assert_lock(sdata);
  2214. lockdep_assert_held(&local->mtx);
  2215. lockdep_assert_held(&local->chanctx_mtx);
  2216. /*
  2217. * using reservation isn't immediate as it may be deferred until later
  2218. * with multi-vif. once reservation is complete it will re-schedule the
  2219. * work with no reserved_chanctx so verify chandef to check if it
  2220. * completed successfully
  2221. */
  2222. if (sdata->reserved_chanctx) {
  2223. /*
  2224. * with multi-vif csa driver may call ieee80211_csa_finish()
  2225. * many times while waiting for other interfaces to use their
  2226. * reservations
  2227. */
  2228. if (sdata->reserved_ready)
  2229. return 0;
  2230. return ieee80211_vif_use_reserved_context(sdata);
  2231. }
  2232. if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
  2233. &sdata->csa_chandef))
  2234. return -EINVAL;
  2235. sdata->vif.csa_active = false;
  2236. err = ieee80211_set_after_csa_beacon(sdata, &changed);
  2237. if (err)
  2238. return err;
  2239. ieee80211_bss_info_change_notify(sdata, changed);
  2240. if (sdata->csa_block_tx) {
  2241. ieee80211_wake_vif_queues(local, sdata,
  2242. IEEE80211_QUEUE_STOP_REASON_CSA);
  2243. sdata->csa_block_tx = false;
  2244. }
  2245. err = drv_post_channel_switch(sdata);
  2246. if (err)
  2247. return err;
  2248. cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef);
  2249. return 0;
  2250. }
  2251. static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
  2252. {
  2253. if (__ieee80211_csa_finalize(sdata)) {
  2254. sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
  2255. cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
  2256. GFP_KERNEL);
  2257. }
  2258. }
  2259. void ieee80211_csa_finalize_work(struct work_struct *work)
  2260. {
  2261. struct ieee80211_sub_if_data *sdata =
  2262. container_of(work, struct ieee80211_sub_if_data,
  2263. csa_finalize_work);
  2264. struct ieee80211_local *local = sdata->local;
  2265. sdata_lock(sdata);
  2266. mutex_lock(&local->mtx);
  2267. mutex_lock(&local->chanctx_mtx);
  2268. /* AP might have been stopped while waiting for the lock. */
  2269. if (!sdata->vif.csa_active)
  2270. goto unlock;
  2271. if (!ieee80211_sdata_running(sdata))
  2272. goto unlock;
  2273. ieee80211_csa_finalize(sdata);
  2274. unlock:
  2275. mutex_unlock(&local->chanctx_mtx);
  2276. mutex_unlock(&local->mtx);
  2277. sdata_unlock(sdata);
  2278. }
  2279. static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata,
  2280. struct cfg80211_csa_settings *params,
  2281. u32 *changed)
  2282. {
  2283. struct ieee80211_csa_settings csa = {};
  2284. int err;
  2285. switch (sdata->vif.type) {
  2286. case NL80211_IFTYPE_AP:
  2287. sdata->u.ap.next_beacon =
  2288. cfg80211_beacon_dup(&params->beacon_after);
  2289. if (!sdata->u.ap.next_beacon)
  2290. return -ENOMEM;
  2291. /*
  2292. * With a count of 0, we don't have to wait for any
  2293. * TBTT before switching, so complete the CSA
  2294. * immediately. In theory, with a count == 1 we
  2295. * should delay the switch until just before the next
  2296. * TBTT, but that would complicate things so we switch
  2297. * immediately too. If we would delay the switch
  2298. * until the next TBTT, we would have to set the probe
  2299. * response here.
  2300. *
  2301. * TODO: A channel switch with count <= 1 without
  2302. * sending a CSA action frame is kind of useless,
  2303. * because the clients won't know we're changing
  2304. * channels. The action frame must be implemented
  2305. * either here or in the userspace.
  2306. */
  2307. if (params->count <= 1)
  2308. break;
  2309. if ((params->n_counter_offsets_beacon >
  2310. IEEE80211_MAX_CSA_COUNTERS_NUM) ||
  2311. (params->n_counter_offsets_presp >
  2312. IEEE80211_MAX_CSA_COUNTERS_NUM))
  2313. return -EINVAL;
  2314. csa.counter_offsets_beacon = params->counter_offsets_beacon;
  2315. csa.counter_offsets_presp = params->counter_offsets_presp;
  2316. csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
  2317. csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
  2318. csa.count = params->count;
  2319. err = ieee80211_assign_beacon(sdata, &params->beacon_csa, &csa);
  2320. if (err < 0) {
  2321. kfree(sdata->u.ap.next_beacon);
  2322. return err;
  2323. }
  2324. *changed |= err;
  2325. break;
  2326. case NL80211_IFTYPE_ADHOC:
  2327. if (!sdata->vif.bss_conf.ibss_joined)
  2328. return -EINVAL;
  2329. if (params->chandef.width != sdata->u.ibss.chandef.width)
  2330. return -EINVAL;
  2331. switch (params->chandef.width) {
  2332. case NL80211_CHAN_WIDTH_40:
  2333. if (cfg80211_get_chandef_type(&params->chandef) !=
  2334. cfg80211_get_chandef_type(&sdata->u.ibss.chandef))
  2335. return -EINVAL;
  2336. case NL80211_CHAN_WIDTH_5:
  2337. case NL80211_CHAN_WIDTH_10:
  2338. case NL80211_CHAN_WIDTH_20_NOHT:
  2339. case NL80211_CHAN_WIDTH_20:
  2340. break;
  2341. default:
  2342. return -EINVAL;
  2343. }
  2344. /* changes into another band are not supported */
  2345. if (sdata->u.ibss.chandef.chan->band !=
  2346. params->chandef.chan->band)
  2347. return -EINVAL;
  2348. /* see comments in the NL80211_IFTYPE_AP block */
  2349. if (params->count > 1) {
  2350. err = ieee80211_ibss_csa_beacon(sdata, params);
  2351. if (err < 0)
  2352. return err;
  2353. *changed |= err;
  2354. }
  2355. ieee80211_send_action_csa(sdata, params);
  2356. break;
  2357. #ifdef CONFIG_MAC80211_MESH
  2358. case NL80211_IFTYPE_MESH_POINT: {
  2359. struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
  2360. if (params->chandef.width != sdata->vif.bss_conf.chandef.width)
  2361. return -EINVAL;
  2362. /* changes into another band are not supported */
  2363. if (sdata->vif.bss_conf.chandef.chan->band !=
  2364. params->chandef.chan->band)
  2365. return -EINVAL;
  2366. if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) {
  2367. ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT;
  2368. if (!ifmsh->pre_value)
  2369. ifmsh->pre_value = 1;
  2370. else
  2371. ifmsh->pre_value++;
  2372. }
  2373. /* see comments in the NL80211_IFTYPE_AP block */
  2374. if (params->count > 1) {
  2375. err = ieee80211_mesh_csa_beacon(sdata, params);
  2376. if (err < 0) {
  2377. ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE;
  2378. return err;
  2379. }
  2380. *changed |= err;
  2381. }
  2382. if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT)
  2383. ieee80211_send_action_csa(sdata, params);
  2384. break;
  2385. }
  2386. #endif
  2387. default:
  2388. return -EOPNOTSUPP;
  2389. }
  2390. return 0;
  2391. }
  2392. static int
  2393. __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
  2394. struct cfg80211_csa_settings *params)
  2395. {
  2396. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2397. struct ieee80211_local *local = sdata->local;
  2398. struct ieee80211_channel_switch ch_switch;
  2399. struct ieee80211_chanctx_conf *conf;
  2400. struct ieee80211_chanctx *chanctx;
  2401. u32 changed = 0;
  2402. int err;
  2403. sdata_assert_lock(sdata);
  2404. lockdep_assert_held(&local->mtx);
  2405. if (!list_empty(&local->roc_list) || local->scanning)
  2406. return -EBUSY;
  2407. if (sdata->wdev.cac_started)
  2408. return -EBUSY;
  2409. if (cfg80211_chandef_identical(&params->chandef,
  2410. &sdata->vif.bss_conf.chandef))
  2411. return -EINVAL;
  2412. /* don't allow another channel switch if one is already active. */
  2413. if (sdata->vif.csa_active)
  2414. return -EBUSY;
  2415. mutex_lock(&local->chanctx_mtx);
  2416. conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
  2417. lockdep_is_held(&local->chanctx_mtx));
  2418. if (!conf) {
  2419. err = -EBUSY;
  2420. goto out;
  2421. }
  2422. chanctx = container_of(conf, struct ieee80211_chanctx, conf);
  2423. if (!chanctx) {
  2424. err = -EBUSY;
  2425. goto out;
  2426. }
  2427. ch_switch.timestamp = 0;
  2428. ch_switch.device_timestamp = 0;
  2429. ch_switch.block_tx = params->block_tx;
  2430. ch_switch.chandef = params->chandef;
  2431. ch_switch.count = params->count;
  2432. err = drv_pre_channel_switch(sdata, &ch_switch);
  2433. if (err)
  2434. goto out;
  2435. err = ieee80211_vif_reserve_chanctx(sdata, &params->chandef,
  2436. chanctx->mode,
  2437. params->radar_required);
  2438. if (err)
  2439. goto out;
  2440. /* if reservation is invalid then this will fail */
  2441. err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0);
  2442. if (err) {
  2443. ieee80211_vif_unreserve_chanctx(sdata);
  2444. goto out;
  2445. }
  2446. err = ieee80211_set_csa_beacon(sdata, params, &changed);
  2447. if (err) {
  2448. ieee80211_vif_unreserve_chanctx(sdata);
  2449. goto out;
  2450. }
  2451. sdata->csa_chandef = params->chandef;
  2452. sdata->csa_block_tx = params->block_tx;
  2453. sdata->vif.csa_active = true;
  2454. if (sdata->csa_block_tx)
  2455. ieee80211_stop_vif_queues(local, sdata,
  2456. IEEE80211_QUEUE_STOP_REASON_CSA);
  2457. cfg80211_ch_switch_started_notify(sdata->dev, &sdata->csa_chandef,
  2458. params->count);
  2459. if (changed) {
  2460. ieee80211_bss_info_change_notify(sdata, changed);
  2461. drv_channel_switch_beacon(sdata, &params->chandef);
  2462. } else {
  2463. /* if the beacon didn't change, we can finalize immediately */
  2464. ieee80211_csa_finalize(sdata);
  2465. }
  2466. out:
  2467. mutex_unlock(&local->chanctx_mtx);
  2468. return err;
  2469. }
  2470. int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
  2471. struct cfg80211_csa_settings *params)
  2472. {
  2473. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2474. struct ieee80211_local *local = sdata->local;
  2475. int err;
  2476. mutex_lock(&local->mtx);
  2477. err = __ieee80211_channel_switch(wiphy, dev, params);
  2478. mutex_unlock(&local->mtx);
  2479. return err;
  2480. }
  2481. u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local)
  2482. {
  2483. lockdep_assert_held(&local->mtx);
  2484. local->roc_cookie_counter++;
  2485. /* wow, you wrapped 64 bits ... more likely a bug */
  2486. if (WARN_ON(local->roc_cookie_counter == 0))
  2487. local->roc_cookie_counter++;
  2488. return local->roc_cookie_counter;
  2489. }
  2490. int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb,
  2491. u64 *cookie, gfp_t gfp)
  2492. {
  2493. unsigned long spin_flags;
  2494. struct sk_buff *ack_skb;
  2495. int id;
  2496. ack_skb = skb_copy(skb, gfp);
  2497. if (!ack_skb)
  2498. return -ENOMEM;
  2499. spin_lock_irqsave(&local->ack_status_lock, spin_flags);
  2500. id = idr_alloc(&local->ack_status_frames, ack_skb,
  2501. 1, 0x10000, GFP_ATOMIC);
  2502. spin_unlock_irqrestore(&local->ack_status_lock, spin_flags);
  2503. if (id < 0) {
  2504. kfree_skb(ack_skb);
  2505. return -ENOMEM;
  2506. }
  2507. IEEE80211_SKB_CB(skb)->ack_frame_id = id;
  2508. *cookie = ieee80211_mgmt_tx_cookie(local);
  2509. IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie;
  2510. return 0;
  2511. }
  2512. static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
  2513. struct wireless_dev *wdev,
  2514. u16 frame_type, bool reg)
  2515. {
  2516. struct ieee80211_local *local = wiphy_priv(wiphy);
  2517. struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  2518. switch (frame_type) {
  2519. case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ:
  2520. if (reg) {
  2521. local->probe_req_reg++;
  2522. sdata->vif.probe_req_reg++;
  2523. } else {
  2524. if (local->probe_req_reg)
  2525. local->probe_req_reg--;
  2526. if (sdata->vif.probe_req_reg)
  2527. sdata->vif.probe_req_reg--;
  2528. }
  2529. if (!local->open_count)
  2530. break;
  2531. if (sdata->vif.probe_req_reg == 1)
  2532. drv_config_iface_filter(local, sdata, FIF_PROBE_REQ,
  2533. FIF_PROBE_REQ);
  2534. else if (sdata->vif.probe_req_reg == 0)
  2535. drv_config_iface_filter(local, sdata, 0,
  2536. FIF_PROBE_REQ);
  2537. ieee80211_configure_filter(local);
  2538. break;
  2539. default:
  2540. break;
  2541. }
  2542. }
  2543. static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
  2544. {
  2545. struct ieee80211_local *local = wiphy_priv(wiphy);
  2546. if (local->started)
  2547. return -EOPNOTSUPP;
  2548. return drv_set_antenna(local, tx_ant, rx_ant);
  2549. }
  2550. static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
  2551. {
  2552. struct ieee80211_local *local = wiphy_priv(wiphy);
  2553. return drv_get_antenna(local, tx_ant, rx_ant);
  2554. }
  2555. static int ieee80211_set_rekey_data(struct wiphy *wiphy,
  2556. struct net_device *dev,
  2557. struct cfg80211_gtk_rekey_data *data)
  2558. {
  2559. struct ieee80211_local *local = wiphy_priv(wiphy);
  2560. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2561. if (!local->ops->set_rekey_data)
  2562. return -EOPNOTSUPP;
  2563. drv_set_rekey_data(local, sdata, data);
  2564. return 0;
  2565. }
  2566. static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
  2567. const u8 *peer, u64 *cookie)
  2568. {
  2569. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2570. struct ieee80211_local *local = sdata->local;
  2571. struct ieee80211_qos_hdr *nullfunc;
  2572. struct sk_buff *skb;
  2573. int size = sizeof(*nullfunc);
  2574. __le16 fc;
  2575. bool qos;
  2576. struct ieee80211_tx_info *info;
  2577. struct sta_info *sta;
  2578. struct ieee80211_chanctx_conf *chanctx_conf;
  2579. enum ieee80211_band band;
  2580. int ret;
  2581. /* the lock is needed to assign the cookie later */
  2582. mutex_lock(&local->mtx);
  2583. rcu_read_lock();
  2584. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  2585. if (WARN_ON(!chanctx_conf)) {
  2586. ret = -EINVAL;
  2587. goto unlock;
  2588. }
  2589. band = chanctx_conf->def.chan->band;
  2590. sta = sta_info_get_bss(sdata, peer);
  2591. if (sta) {
  2592. qos = sta->sta.wme;
  2593. } else {
  2594. ret = -ENOLINK;
  2595. goto unlock;
  2596. }
  2597. if (qos) {
  2598. fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
  2599. IEEE80211_STYPE_QOS_NULLFUNC |
  2600. IEEE80211_FCTL_FROMDS);
  2601. } else {
  2602. size -= 2;
  2603. fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
  2604. IEEE80211_STYPE_NULLFUNC |
  2605. IEEE80211_FCTL_FROMDS);
  2606. }
  2607. skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
  2608. if (!skb) {
  2609. ret = -ENOMEM;
  2610. goto unlock;
  2611. }
  2612. skb->dev = dev;
  2613. skb_reserve(skb, local->hw.extra_tx_headroom);
  2614. nullfunc = (void *) skb_put(skb, size);
  2615. nullfunc->frame_control = fc;
  2616. nullfunc->duration_id = 0;
  2617. memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
  2618. memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
  2619. memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
  2620. nullfunc->seq_ctrl = 0;
  2621. info = IEEE80211_SKB_CB(skb);
  2622. info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
  2623. IEEE80211_TX_INTFL_NL80211_FRAME_TX;
  2624. info->band = band;
  2625. skb_set_queue_mapping(skb, IEEE80211_AC_VO);
  2626. skb->priority = 7;
  2627. if (qos)
  2628. nullfunc->qos_ctrl = cpu_to_le16(7);
  2629. ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC);
  2630. if (ret) {
  2631. kfree_skb(skb);
  2632. goto unlock;
  2633. }
  2634. local_bh_disable();
  2635. ieee80211_xmit(sdata, sta, skb);
  2636. local_bh_enable();
  2637. ret = 0;
  2638. unlock:
  2639. rcu_read_unlock();
  2640. mutex_unlock(&local->mtx);
  2641. return ret;
  2642. }
  2643. static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
  2644. struct wireless_dev *wdev,
  2645. struct cfg80211_chan_def *chandef)
  2646. {
  2647. struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  2648. struct ieee80211_local *local = wiphy_priv(wiphy);
  2649. struct ieee80211_chanctx_conf *chanctx_conf;
  2650. int ret = -ENODATA;
  2651. rcu_read_lock();
  2652. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  2653. if (chanctx_conf) {
  2654. *chandef = sdata->vif.bss_conf.chandef;
  2655. ret = 0;
  2656. } else if (local->open_count > 0 &&
  2657. local->open_count == local->monitors &&
  2658. sdata->vif.type == NL80211_IFTYPE_MONITOR) {
  2659. if (local->use_chanctx)
  2660. *chandef = local->monitor_chandef;
  2661. else
  2662. *chandef = local->_oper_chandef;
  2663. ret = 0;
  2664. }
  2665. rcu_read_unlock();
  2666. return ret;
  2667. }
  2668. #ifdef CONFIG_PM
  2669. static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
  2670. {
  2671. drv_set_wakeup(wiphy_priv(wiphy), enabled);
  2672. }
  2673. #endif
  2674. static int ieee80211_set_qos_map(struct wiphy *wiphy,
  2675. struct net_device *dev,
  2676. struct cfg80211_qos_map *qos_map)
  2677. {
  2678. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2679. struct mac80211_qos_map *new_qos_map, *old_qos_map;
  2680. if (qos_map) {
  2681. new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL);
  2682. if (!new_qos_map)
  2683. return -ENOMEM;
  2684. memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map));
  2685. } else {
  2686. /* A NULL qos_map was passed to disable QoS mapping */
  2687. new_qos_map = NULL;
  2688. }
  2689. old_qos_map = sdata_dereference(sdata->qos_map, sdata);
  2690. rcu_assign_pointer(sdata->qos_map, new_qos_map);
  2691. if (old_qos_map)
  2692. kfree_rcu(old_qos_map, rcu_head);
  2693. return 0;
  2694. }
  2695. static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy,
  2696. struct net_device *dev,
  2697. struct cfg80211_chan_def *chandef)
  2698. {
  2699. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2700. int ret;
  2701. u32 changed = 0;
  2702. ret = ieee80211_vif_change_bandwidth(sdata, chandef, &changed);
  2703. if (ret == 0)
  2704. ieee80211_bss_info_change_notify(sdata, changed);
  2705. return ret;
  2706. }
  2707. static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev,
  2708. u8 tsid, const u8 *peer, u8 up,
  2709. u16 admitted_time)
  2710. {
  2711. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2712. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  2713. int ac = ieee802_1d_to_ac[up];
  2714. if (sdata->vif.type != NL80211_IFTYPE_STATION)
  2715. return -EOPNOTSUPP;
  2716. if (!(sdata->wmm_acm & BIT(up)))
  2717. return -EINVAL;
  2718. if (ifmgd->tx_tspec[ac].admitted_time)
  2719. return -EBUSY;
  2720. if (admitted_time) {
  2721. ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time;
  2722. ifmgd->tx_tspec[ac].tsid = tsid;
  2723. ifmgd->tx_tspec[ac].up = up;
  2724. }
  2725. return 0;
  2726. }
  2727. static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev,
  2728. u8 tsid, const u8 *peer)
  2729. {
  2730. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  2731. struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
  2732. struct ieee80211_local *local = wiphy_priv(wiphy);
  2733. int ac;
  2734. for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
  2735. struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac];
  2736. /* skip unused entries */
  2737. if (!tx_tspec->admitted_time)
  2738. continue;
  2739. if (tx_tspec->tsid != tsid)
  2740. continue;
  2741. /* due to this new packets will be reassigned to non-ACM ACs */
  2742. tx_tspec->up = -1;
  2743. /* Make sure that all packets have been sent to avoid to
  2744. * restore the QoS params on packets that are still on the
  2745. * queues.
  2746. */
  2747. synchronize_net();
  2748. ieee80211_flush_queues(local, sdata, false);
  2749. /* restore the normal QoS parameters
  2750. * (unconditionally to avoid races)
  2751. */
  2752. tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE;
  2753. tx_tspec->downgraded = false;
  2754. ieee80211_sta_handle_tspec_ac_params(sdata);
  2755. /* finally clear all the data */
  2756. memset(tx_tspec, 0, sizeof(*tx_tspec));
  2757. return 0;
  2758. }
  2759. return -ENOENT;
  2760. }
  2761. const struct cfg80211_ops mac80211_config_ops = {
  2762. .add_virtual_intf = ieee80211_add_iface,
  2763. .del_virtual_intf = ieee80211_del_iface,
  2764. .change_virtual_intf = ieee80211_change_iface,
  2765. .start_p2p_device = ieee80211_start_p2p_device,
  2766. .stop_p2p_device = ieee80211_stop_p2p_device,
  2767. .add_key = ieee80211_add_key,
  2768. .del_key = ieee80211_del_key,
  2769. .get_key = ieee80211_get_key,
  2770. .set_default_key = ieee80211_config_default_key,
  2771. .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
  2772. .start_ap = ieee80211_start_ap,
  2773. .change_beacon = ieee80211_change_beacon,
  2774. .stop_ap = ieee80211_stop_ap,
  2775. .add_station = ieee80211_add_station,
  2776. .del_station = ieee80211_del_station,
  2777. .change_station = ieee80211_change_station,
  2778. .get_station = ieee80211_get_station,
  2779. .dump_station = ieee80211_dump_station,
  2780. .dump_survey = ieee80211_dump_survey,
  2781. #ifdef CONFIG_MAC80211_MESH
  2782. .add_mpath = ieee80211_add_mpath,
  2783. .del_mpath = ieee80211_del_mpath,
  2784. .change_mpath = ieee80211_change_mpath,
  2785. .get_mpath = ieee80211_get_mpath,
  2786. .dump_mpath = ieee80211_dump_mpath,
  2787. .get_mpp = ieee80211_get_mpp,
  2788. .dump_mpp = ieee80211_dump_mpp,
  2789. .update_mesh_config = ieee80211_update_mesh_config,
  2790. .get_mesh_config = ieee80211_get_mesh_config,
  2791. .join_mesh = ieee80211_join_mesh,
  2792. .leave_mesh = ieee80211_leave_mesh,
  2793. #endif
  2794. .join_ocb = ieee80211_join_ocb,
  2795. .leave_ocb = ieee80211_leave_ocb,
  2796. .change_bss = ieee80211_change_bss,
  2797. .set_txq_params = ieee80211_set_txq_params,
  2798. .set_monitor_channel = ieee80211_set_monitor_channel,
  2799. .suspend = ieee80211_suspend,
  2800. .resume = ieee80211_resume,
  2801. .scan = ieee80211_scan,
  2802. .abort_scan = ieee80211_abort_scan,
  2803. .sched_scan_start = ieee80211_sched_scan_start,
  2804. .sched_scan_stop = ieee80211_sched_scan_stop,
  2805. .auth = ieee80211_auth,
  2806. .assoc = ieee80211_assoc,
  2807. .deauth = ieee80211_deauth,
  2808. .disassoc = ieee80211_disassoc,
  2809. .join_ibss = ieee80211_join_ibss,
  2810. .leave_ibss = ieee80211_leave_ibss,
  2811. .set_mcast_rate = ieee80211_set_mcast_rate,
  2812. .set_wiphy_params = ieee80211_set_wiphy_params,
  2813. .set_tx_power = ieee80211_set_tx_power,
  2814. .get_tx_power = ieee80211_get_tx_power,
  2815. .set_wds_peer = ieee80211_set_wds_peer,
  2816. .rfkill_poll = ieee80211_rfkill_poll,
  2817. CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
  2818. CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
  2819. .set_power_mgmt = ieee80211_set_power_mgmt,
  2820. .set_bitrate_mask = ieee80211_set_bitrate_mask,
  2821. .remain_on_channel = ieee80211_remain_on_channel,
  2822. .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
  2823. .mgmt_tx = ieee80211_mgmt_tx,
  2824. .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
  2825. .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
  2826. .mgmt_frame_register = ieee80211_mgmt_frame_register,
  2827. .set_antenna = ieee80211_set_antenna,
  2828. .get_antenna = ieee80211_get_antenna,
  2829. .set_rekey_data = ieee80211_set_rekey_data,
  2830. .tdls_oper = ieee80211_tdls_oper,
  2831. .tdls_mgmt = ieee80211_tdls_mgmt,
  2832. .tdls_channel_switch = ieee80211_tdls_channel_switch,
  2833. .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch,
  2834. .probe_client = ieee80211_probe_client,
  2835. .set_noack_map = ieee80211_set_noack_map,
  2836. #ifdef CONFIG_PM
  2837. .set_wakeup = ieee80211_set_wakeup,
  2838. #endif
  2839. .get_channel = ieee80211_cfg_get_channel,
  2840. .start_radar_detection = ieee80211_start_radar_detection,
  2841. .channel_switch = ieee80211_channel_switch,
  2842. .set_qos_map = ieee80211_set_qos_map,
  2843. .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
  2844. .add_tx_ts = ieee80211_add_tx_ts,
  2845. .del_tx_ts = ieee80211_del_tx_ts,
  2846. };