cfg.c 75 KB

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