cfg.c 87 KB

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