cfg.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788
  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 <net/cfg80211.h>
  15. #include "ieee80211_i.h"
  16. #include "driver-ops.h"
  17. #include "cfg.h"
  18. #include "rate.h"
  19. #include "mesh.h"
  20. static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
  21. enum nl80211_iftype type, u32 *flags,
  22. struct vif_params *params)
  23. {
  24. struct ieee80211_local *local = wiphy_priv(wiphy);
  25. struct net_device *dev;
  26. struct ieee80211_sub_if_data *sdata;
  27. int err;
  28. err = ieee80211_if_add(local, name, &dev, type, params);
  29. if (err || type != NL80211_IFTYPE_MONITOR || !flags)
  30. return err;
  31. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  32. sdata->u.mntr_flags = *flags;
  33. return 0;
  34. }
  35. static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev)
  36. {
  37. ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev));
  38. return 0;
  39. }
  40. static int ieee80211_change_iface(struct wiphy *wiphy,
  41. struct net_device *dev,
  42. enum nl80211_iftype type, u32 *flags,
  43. struct vif_params *params)
  44. {
  45. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  46. int ret;
  47. ret = ieee80211_if_change_type(sdata, type);
  48. if (ret)
  49. return ret;
  50. if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len)
  51. ieee80211_sdata_set_mesh_id(sdata,
  52. params->mesh_id_len,
  53. params->mesh_id);
  54. if (type == NL80211_IFTYPE_AP_VLAN &&
  55. params && params->use_4addr == 0)
  56. rcu_assign_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_add_key(struct wiphy *wiphy, struct net_device *dev,
  90. u8 key_idx, bool pairwise, const u8 *mac_addr,
  91. struct key_params *params)
  92. {
  93. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  94. struct sta_info *sta = NULL;
  95. struct ieee80211_key *key;
  96. int err;
  97. if (!ieee80211_sdata_running(sdata))
  98. return -ENETDOWN;
  99. /* reject WEP and TKIP keys if WEP failed to initialize */
  100. switch (params->cipher) {
  101. case WLAN_CIPHER_SUITE_WEP40:
  102. case WLAN_CIPHER_SUITE_TKIP:
  103. case WLAN_CIPHER_SUITE_WEP104:
  104. if (IS_ERR(sdata->local->wep_tx_tfm))
  105. return -EINVAL;
  106. break;
  107. default:
  108. break;
  109. }
  110. key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
  111. params->key, params->seq_len, params->seq);
  112. if (IS_ERR(key))
  113. return PTR_ERR(key);
  114. if (pairwise)
  115. key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
  116. mutex_lock(&sdata->local->sta_mtx);
  117. if (mac_addr) {
  118. sta = sta_info_get_bss(sdata, mac_addr);
  119. if (!sta) {
  120. ieee80211_key_free(sdata->local, key);
  121. err = -ENOENT;
  122. goto out_unlock;
  123. }
  124. }
  125. err = ieee80211_key_link(key, sdata, sta);
  126. if (err)
  127. ieee80211_key_free(sdata->local, key);
  128. out_unlock:
  129. mutex_unlock(&sdata->local->sta_mtx);
  130. return err;
  131. }
  132. static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
  133. u8 key_idx, bool pairwise, const u8 *mac_addr)
  134. {
  135. struct ieee80211_sub_if_data *sdata;
  136. struct sta_info *sta;
  137. int ret;
  138. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  139. mutex_lock(&sdata->local->sta_mtx);
  140. if (mac_addr) {
  141. ret = -ENOENT;
  142. sta = sta_info_get_bss(sdata, mac_addr);
  143. if (!sta)
  144. goto out_unlock;
  145. if (pairwise) {
  146. if (sta->ptk) {
  147. ieee80211_key_free(sdata->local, sta->ptk);
  148. ret = 0;
  149. }
  150. } else {
  151. if (sta->gtk[key_idx]) {
  152. ieee80211_key_free(sdata->local,
  153. sta->gtk[key_idx]);
  154. ret = 0;
  155. }
  156. }
  157. goto out_unlock;
  158. }
  159. if (!sdata->keys[key_idx]) {
  160. ret = -ENOENT;
  161. goto out_unlock;
  162. }
  163. ieee80211_key_free(sdata->local, sdata->keys[key_idx]);
  164. WARN_ON(sdata->keys[key_idx]);
  165. ret = 0;
  166. out_unlock:
  167. mutex_unlock(&sdata->local->sta_mtx);
  168. return ret;
  169. }
  170. static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
  171. u8 key_idx, bool pairwise, const u8 *mac_addr,
  172. void *cookie,
  173. void (*callback)(void *cookie,
  174. struct key_params *params))
  175. {
  176. struct ieee80211_sub_if_data *sdata;
  177. struct sta_info *sta = NULL;
  178. u8 seq[6] = {0};
  179. struct key_params params;
  180. struct ieee80211_key *key = NULL;
  181. u32 iv32;
  182. u16 iv16;
  183. int err = -ENOENT;
  184. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  185. rcu_read_lock();
  186. if (mac_addr) {
  187. sta = sta_info_get_bss(sdata, mac_addr);
  188. if (!sta)
  189. goto out;
  190. if (pairwise)
  191. key = sta->ptk;
  192. else if (key_idx < NUM_DEFAULT_KEYS)
  193. key = sta->gtk[key_idx];
  194. } else
  195. key = sdata->keys[key_idx];
  196. if (!key)
  197. goto out;
  198. memset(&params, 0, sizeof(params));
  199. params.cipher = key->conf.cipher;
  200. switch (key->conf.cipher) {
  201. case WLAN_CIPHER_SUITE_TKIP:
  202. iv32 = key->u.tkip.tx.iv32;
  203. iv16 = key->u.tkip.tx.iv16;
  204. if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
  205. drv_get_tkip_seq(sdata->local,
  206. key->conf.hw_key_idx,
  207. &iv32, &iv16);
  208. seq[0] = iv16 & 0xff;
  209. seq[1] = (iv16 >> 8) & 0xff;
  210. seq[2] = iv32 & 0xff;
  211. seq[3] = (iv32 >> 8) & 0xff;
  212. seq[4] = (iv32 >> 16) & 0xff;
  213. seq[5] = (iv32 >> 24) & 0xff;
  214. params.seq = seq;
  215. params.seq_len = 6;
  216. break;
  217. case WLAN_CIPHER_SUITE_CCMP:
  218. seq[0] = key->u.ccmp.tx_pn[5];
  219. seq[1] = key->u.ccmp.tx_pn[4];
  220. seq[2] = key->u.ccmp.tx_pn[3];
  221. seq[3] = key->u.ccmp.tx_pn[2];
  222. seq[4] = key->u.ccmp.tx_pn[1];
  223. seq[5] = key->u.ccmp.tx_pn[0];
  224. params.seq = seq;
  225. params.seq_len = 6;
  226. break;
  227. case WLAN_CIPHER_SUITE_AES_CMAC:
  228. seq[0] = key->u.aes_cmac.tx_pn[5];
  229. seq[1] = key->u.aes_cmac.tx_pn[4];
  230. seq[2] = key->u.aes_cmac.tx_pn[3];
  231. seq[3] = key->u.aes_cmac.tx_pn[2];
  232. seq[4] = key->u.aes_cmac.tx_pn[1];
  233. seq[5] = key->u.aes_cmac.tx_pn[0];
  234. params.seq = seq;
  235. params.seq_len = 6;
  236. break;
  237. }
  238. params.key = key->conf.key;
  239. params.key_len = key->conf.keylen;
  240. callback(cookie, &params);
  241. err = 0;
  242. out:
  243. rcu_read_unlock();
  244. return err;
  245. }
  246. static int ieee80211_config_default_key(struct wiphy *wiphy,
  247. struct net_device *dev,
  248. u8 key_idx)
  249. {
  250. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  251. ieee80211_set_default_key(sdata, key_idx);
  252. return 0;
  253. }
  254. static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
  255. struct net_device *dev,
  256. u8 key_idx)
  257. {
  258. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  259. ieee80211_set_default_mgmt_key(sdata, key_idx);
  260. return 0;
  261. }
  262. static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
  263. {
  264. struct ieee80211_sub_if_data *sdata = sta->sdata;
  265. sinfo->generation = sdata->local->sta_generation;
  266. sinfo->filled = STATION_INFO_INACTIVE_TIME |
  267. STATION_INFO_RX_BYTES |
  268. STATION_INFO_TX_BYTES |
  269. STATION_INFO_RX_PACKETS |
  270. STATION_INFO_TX_PACKETS |
  271. STATION_INFO_TX_RETRIES |
  272. STATION_INFO_TX_FAILED |
  273. STATION_INFO_TX_BITRATE |
  274. STATION_INFO_RX_DROP_MISC;
  275. sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
  276. sinfo->rx_bytes = sta->rx_bytes;
  277. sinfo->tx_bytes = sta->tx_bytes;
  278. sinfo->rx_packets = sta->rx_packets;
  279. sinfo->tx_packets = sta->tx_packets;
  280. sinfo->tx_retries = sta->tx_retry_count;
  281. sinfo->tx_failed = sta->tx_retry_failed;
  282. sinfo->rx_dropped_misc = sta->rx_dropped;
  283. if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
  284. (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
  285. sinfo->filled |= STATION_INFO_SIGNAL;
  286. sinfo->signal = (s8)sta->last_signal;
  287. }
  288. sinfo->txrate.flags = 0;
  289. if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
  290. sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
  291. if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
  292. sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
  293. if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
  294. sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
  295. if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) {
  296. struct ieee80211_supported_band *sband;
  297. sband = sta->local->hw.wiphy->bands[
  298. sta->local->hw.conf.channel->band];
  299. sinfo->txrate.legacy =
  300. sband->bitrates[sta->last_tx_rate.idx].bitrate;
  301. } else
  302. sinfo->txrate.mcs = sta->last_tx_rate.idx;
  303. if (ieee80211_vif_is_mesh(&sdata->vif)) {
  304. #ifdef CONFIG_MAC80211_MESH
  305. sinfo->filled |= STATION_INFO_LLID |
  306. STATION_INFO_PLID |
  307. STATION_INFO_PLINK_STATE;
  308. sinfo->llid = le16_to_cpu(sta->llid);
  309. sinfo->plid = le16_to_cpu(sta->plid);
  310. sinfo->plink_state = sta->plink_state;
  311. #endif
  312. }
  313. }
  314. static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
  315. int idx, u8 *mac, struct station_info *sinfo)
  316. {
  317. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  318. struct sta_info *sta;
  319. int ret = -ENOENT;
  320. rcu_read_lock();
  321. sta = sta_info_get_by_idx(sdata, idx);
  322. if (sta) {
  323. ret = 0;
  324. memcpy(mac, sta->sta.addr, ETH_ALEN);
  325. sta_set_sinfo(sta, sinfo);
  326. }
  327. rcu_read_unlock();
  328. return ret;
  329. }
  330. static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
  331. int idx, struct survey_info *survey)
  332. {
  333. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  334. return drv_get_survey(local, idx, survey);
  335. }
  336. static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
  337. u8 *mac, struct station_info *sinfo)
  338. {
  339. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  340. struct sta_info *sta;
  341. int ret = -ENOENT;
  342. rcu_read_lock();
  343. sta = sta_info_get_bss(sdata, mac);
  344. if (sta) {
  345. ret = 0;
  346. sta_set_sinfo(sta, sinfo);
  347. }
  348. rcu_read_unlock();
  349. return ret;
  350. }
  351. /*
  352. * This handles both adding a beacon and setting new beacon info
  353. */
  354. static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
  355. struct beacon_parameters *params)
  356. {
  357. struct beacon_data *new, *old;
  358. int new_head_len, new_tail_len;
  359. int size;
  360. int err = -EINVAL;
  361. old = sdata->u.ap.beacon;
  362. /* head must not be zero-length */
  363. if (params->head && !params->head_len)
  364. return -EINVAL;
  365. /*
  366. * This is a kludge. beacon interval should really be part
  367. * of the beacon information.
  368. */
  369. if (params->interval &&
  370. (sdata->vif.bss_conf.beacon_int != params->interval)) {
  371. sdata->vif.bss_conf.beacon_int = params->interval;
  372. ieee80211_bss_info_change_notify(sdata,
  373. BSS_CHANGED_BEACON_INT);
  374. }
  375. /* Need to have a beacon head if we don't have one yet */
  376. if (!params->head && !old)
  377. return err;
  378. /* sorry, no way to start beaconing without dtim period */
  379. if (!params->dtim_period && !old)
  380. return err;
  381. /* new or old head? */
  382. if (params->head)
  383. new_head_len = params->head_len;
  384. else
  385. new_head_len = old->head_len;
  386. /* new or old tail? */
  387. if (params->tail || !old)
  388. /* params->tail_len will be zero for !params->tail */
  389. new_tail_len = params->tail_len;
  390. else
  391. new_tail_len = old->tail_len;
  392. size = sizeof(*new) + new_head_len + new_tail_len;
  393. new = kzalloc(size, GFP_KERNEL);
  394. if (!new)
  395. return -ENOMEM;
  396. /* start filling the new info now */
  397. /* new or old dtim period? */
  398. if (params->dtim_period)
  399. new->dtim_period = params->dtim_period;
  400. else
  401. new->dtim_period = old->dtim_period;
  402. /*
  403. * pointers go into the block we allocated,
  404. * memory is | beacon_data | head | tail |
  405. */
  406. new->head = ((u8 *) new) + sizeof(*new);
  407. new->tail = new->head + new_head_len;
  408. new->head_len = new_head_len;
  409. new->tail_len = new_tail_len;
  410. /* copy in head */
  411. if (params->head)
  412. memcpy(new->head, params->head, new_head_len);
  413. else
  414. memcpy(new->head, old->head, new_head_len);
  415. /* copy in optional tail */
  416. if (params->tail)
  417. memcpy(new->tail, params->tail, new_tail_len);
  418. else
  419. if (old)
  420. memcpy(new->tail, old->tail, new_tail_len);
  421. sdata->vif.bss_conf.dtim_period = new->dtim_period;
  422. rcu_assign_pointer(sdata->u.ap.beacon, new);
  423. synchronize_rcu();
  424. kfree(old);
  425. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
  426. BSS_CHANGED_BEACON);
  427. return 0;
  428. }
  429. static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
  430. struct beacon_parameters *params)
  431. {
  432. struct ieee80211_sub_if_data *sdata;
  433. struct beacon_data *old;
  434. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  435. old = sdata->u.ap.beacon;
  436. if (old)
  437. return -EALREADY;
  438. return ieee80211_config_beacon(sdata, params);
  439. }
  440. static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
  441. struct beacon_parameters *params)
  442. {
  443. struct ieee80211_sub_if_data *sdata;
  444. struct beacon_data *old;
  445. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  446. old = sdata->u.ap.beacon;
  447. if (!old)
  448. return -ENOENT;
  449. return ieee80211_config_beacon(sdata, params);
  450. }
  451. static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
  452. {
  453. struct ieee80211_sub_if_data *sdata;
  454. struct beacon_data *old;
  455. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  456. old = sdata->u.ap.beacon;
  457. if (!old)
  458. return -ENOENT;
  459. rcu_assign_pointer(sdata->u.ap.beacon, NULL);
  460. synchronize_rcu();
  461. kfree(old);
  462. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
  463. return 0;
  464. }
  465. /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
  466. struct iapp_layer2_update {
  467. u8 da[ETH_ALEN]; /* broadcast */
  468. u8 sa[ETH_ALEN]; /* STA addr */
  469. __be16 len; /* 6 */
  470. u8 dsap; /* 0 */
  471. u8 ssap; /* 0 */
  472. u8 control;
  473. u8 xid_info[3];
  474. } __packed;
  475. static void ieee80211_send_layer2_update(struct sta_info *sta)
  476. {
  477. struct iapp_layer2_update *msg;
  478. struct sk_buff *skb;
  479. /* Send Level 2 Update Frame to update forwarding tables in layer 2
  480. * bridge devices */
  481. skb = dev_alloc_skb(sizeof(*msg));
  482. if (!skb)
  483. return;
  484. msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
  485. /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
  486. * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
  487. memset(msg->da, 0xff, ETH_ALEN);
  488. memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
  489. msg->len = htons(6);
  490. msg->dsap = 0;
  491. msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
  492. msg->control = 0xaf; /* XID response lsb.1111F101.
  493. * F=0 (no poll command; unsolicited frame) */
  494. msg->xid_info[0] = 0x81; /* XID format identifier */
  495. msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
  496. msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
  497. skb->dev = sta->sdata->dev;
  498. skb->protocol = eth_type_trans(skb, sta->sdata->dev);
  499. memset(skb->cb, 0, sizeof(skb->cb));
  500. netif_rx_ni(skb);
  501. }
  502. static void sta_apply_parameters(struct ieee80211_local *local,
  503. struct sta_info *sta,
  504. struct station_parameters *params)
  505. {
  506. unsigned long flags;
  507. u32 rates;
  508. int i, j;
  509. struct ieee80211_supported_band *sband;
  510. struct ieee80211_sub_if_data *sdata = sta->sdata;
  511. u32 mask, set;
  512. sband = local->hw.wiphy->bands[local->oper_channel->band];
  513. spin_lock_irqsave(&sta->flaglock, flags);
  514. mask = params->sta_flags_mask;
  515. set = params->sta_flags_set;
  516. if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
  517. sta->flags &= ~WLAN_STA_AUTHORIZED;
  518. if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
  519. sta->flags |= WLAN_STA_AUTHORIZED;
  520. }
  521. if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
  522. sta->flags &= ~WLAN_STA_SHORT_PREAMBLE;
  523. if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
  524. sta->flags |= WLAN_STA_SHORT_PREAMBLE;
  525. }
  526. if (mask & BIT(NL80211_STA_FLAG_WME)) {
  527. sta->flags &= ~WLAN_STA_WME;
  528. if (set & BIT(NL80211_STA_FLAG_WME))
  529. sta->flags |= WLAN_STA_WME;
  530. }
  531. if (mask & BIT(NL80211_STA_FLAG_MFP)) {
  532. sta->flags &= ~WLAN_STA_MFP;
  533. if (set & BIT(NL80211_STA_FLAG_MFP))
  534. sta->flags |= WLAN_STA_MFP;
  535. }
  536. spin_unlock_irqrestore(&sta->flaglock, flags);
  537. /*
  538. * cfg80211 validates this (1-2007) and allows setting the AID
  539. * only when creating a new station entry
  540. */
  541. if (params->aid)
  542. sta->sta.aid = params->aid;
  543. /*
  544. * FIXME: updating the following information is racy when this
  545. * function is called from ieee80211_change_station().
  546. * However, all this information should be static so
  547. * maybe we should just reject attemps to change it.
  548. */
  549. if (params->listen_interval >= 0)
  550. sta->listen_interval = params->listen_interval;
  551. if (params->supported_rates) {
  552. rates = 0;
  553. for (i = 0; i < params->supported_rates_len; i++) {
  554. int rate = (params->supported_rates[i] & 0x7f) * 5;
  555. for (j = 0; j < sband->n_bitrates; j++) {
  556. if (sband->bitrates[j].bitrate == rate)
  557. rates |= BIT(j);
  558. }
  559. }
  560. sta->sta.supp_rates[local->oper_channel->band] = rates;
  561. }
  562. if (params->ht_capa)
  563. ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
  564. params->ht_capa,
  565. &sta->sta.ht_cap);
  566. if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
  567. switch (params->plink_action) {
  568. case PLINK_ACTION_OPEN:
  569. mesh_plink_open(sta);
  570. break;
  571. case PLINK_ACTION_BLOCK:
  572. mesh_plink_block(sta);
  573. break;
  574. }
  575. }
  576. }
  577. static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
  578. u8 *mac, struct station_parameters *params)
  579. {
  580. struct ieee80211_local *local = wiphy_priv(wiphy);
  581. struct sta_info *sta;
  582. struct ieee80211_sub_if_data *sdata;
  583. int err;
  584. int layer2_update;
  585. if (params->vlan) {
  586. sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
  587. if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  588. sdata->vif.type != NL80211_IFTYPE_AP)
  589. return -EINVAL;
  590. } else
  591. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  592. if (compare_ether_addr(mac, sdata->vif.addr) == 0)
  593. return -EINVAL;
  594. if (is_multicast_ether_addr(mac))
  595. return -EINVAL;
  596. sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
  597. if (!sta)
  598. return -ENOMEM;
  599. sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC;
  600. sta_apply_parameters(local, sta, params);
  601. rate_control_rate_init(sta);
  602. layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
  603. sdata->vif.type == NL80211_IFTYPE_AP;
  604. err = sta_info_insert_rcu(sta);
  605. if (err) {
  606. rcu_read_unlock();
  607. return err;
  608. }
  609. if (layer2_update)
  610. ieee80211_send_layer2_update(sta);
  611. rcu_read_unlock();
  612. return 0;
  613. }
  614. static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
  615. u8 *mac)
  616. {
  617. struct ieee80211_local *local = wiphy_priv(wiphy);
  618. struct ieee80211_sub_if_data *sdata;
  619. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  620. if (mac)
  621. return sta_info_destroy_addr_bss(sdata, mac);
  622. sta_info_flush(local, sdata);
  623. return 0;
  624. }
  625. static int ieee80211_change_station(struct wiphy *wiphy,
  626. struct net_device *dev,
  627. u8 *mac,
  628. struct station_parameters *params)
  629. {
  630. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  631. struct ieee80211_local *local = wiphy_priv(wiphy);
  632. struct sta_info *sta;
  633. struct ieee80211_sub_if_data *vlansdata;
  634. rcu_read_lock();
  635. sta = sta_info_get_bss(sdata, mac);
  636. if (!sta) {
  637. rcu_read_unlock();
  638. return -ENOENT;
  639. }
  640. if (params->vlan && params->vlan != sta->sdata->dev) {
  641. vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
  642. if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  643. vlansdata->vif.type != NL80211_IFTYPE_AP) {
  644. rcu_read_unlock();
  645. return -EINVAL;
  646. }
  647. if (params->vlan->ieee80211_ptr->use_4addr) {
  648. if (vlansdata->u.vlan.sta) {
  649. rcu_read_unlock();
  650. return -EBUSY;
  651. }
  652. rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
  653. }
  654. sta->sdata = vlansdata;
  655. ieee80211_send_layer2_update(sta);
  656. }
  657. sta_apply_parameters(local, sta, params);
  658. rcu_read_unlock();
  659. return 0;
  660. }
  661. #ifdef CONFIG_MAC80211_MESH
  662. static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
  663. u8 *dst, u8 *next_hop)
  664. {
  665. struct ieee80211_sub_if_data *sdata;
  666. struct mesh_path *mpath;
  667. struct sta_info *sta;
  668. int err;
  669. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  670. rcu_read_lock();
  671. sta = sta_info_get(sdata, next_hop);
  672. if (!sta) {
  673. rcu_read_unlock();
  674. return -ENOENT;
  675. }
  676. err = mesh_path_add(dst, sdata);
  677. if (err) {
  678. rcu_read_unlock();
  679. return err;
  680. }
  681. mpath = mesh_path_lookup(dst, sdata);
  682. if (!mpath) {
  683. rcu_read_unlock();
  684. return -ENXIO;
  685. }
  686. mesh_path_fix_nexthop(mpath, sta);
  687. rcu_read_unlock();
  688. return 0;
  689. }
  690. static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
  691. u8 *dst)
  692. {
  693. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  694. if (dst)
  695. return mesh_path_del(dst, sdata);
  696. mesh_path_flush(sdata);
  697. return 0;
  698. }
  699. static int ieee80211_change_mpath(struct wiphy *wiphy,
  700. struct net_device *dev,
  701. u8 *dst, u8 *next_hop)
  702. {
  703. struct ieee80211_sub_if_data *sdata;
  704. struct mesh_path *mpath;
  705. struct sta_info *sta;
  706. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  707. rcu_read_lock();
  708. sta = sta_info_get(sdata, next_hop);
  709. if (!sta) {
  710. rcu_read_unlock();
  711. return -ENOENT;
  712. }
  713. mpath = mesh_path_lookup(dst, sdata);
  714. if (!mpath) {
  715. rcu_read_unlock();
  716. return -ENOENT;
  717. }
  718. mesh_path_fix_nexthop(mpath, sta);
  719. rcu_read_unlock();
  720. return 0;
  721. }
  722. static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
  723. struct mpath_info *pinfo)
  724. {
  725. if (mpath->next_hop)
  726. memcpy(next_hop, mpath->next_hop->sta.addr, ETH_ALEN);
  727. else
  728. memset(next_hop, 0, ETH_ALEN);
  729. pinfo->generation = mesh_paths_generation;
  730. pinfo->filled = MPATH_INFO_FRAME_QLEN |
  731. MPATH_INFO_SN |
  732. MPATH_INFO_METRIC |
  733. MPATH_INFO_EXPTIME |
  734. MPATH_INFO_DISCOVERY_TIMEOUT |
  735. MPATH_INFO_DISCOVERY_RETRIES |
  736. MPATH_INFO_FLAGS;
  737. pinfo->frame_qlen = mpath->frame_queue.qlen;
  738. pinfo->sn = mpath->sn;
  739. pinfo->metric = mpath->metric;
  740. if (time_before(jiffies, mpath->exp_time))
  741. pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
  742. pinfo->discovery_timeout =
  743. jiffies_to_msecs(mpath->discovery_timeout);
  744. pinfo->discovery_retries = mpath->discovery_retries;
  745. pinfo->flags = 0;
  746. if (mpath->flags & MESH_PATH_ACTIVE)
  747. pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
  748. if (mpath->flags & MESH_PATH_RESOLVING)
  749. pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
  750. if (mpath->flags & MESH_PATH_SN_VALID)
  751. pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
  752. if (mpath->flags & MESH_PATH_FIXED)
  753. pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
  754. if (mpath->flags & MESH_PATH_RESOLVING)
  755. pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
  756. pinfo->flags = mpath->flags;
  757. }
  758. static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
  759. u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
  760. {
  761. struct ieee80211_sub_if_data *sdata;
  762. struct mesh_path *mpath;
  763. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  764. rcu_read_lock();
  765. mpath = mesh_path_lookup(dst, sdata);
  766. if (!mpath) {
  767. rcu_read_unlock();
  768. return -ENOENT;
  769. }
  770. memcpy(dst, mpath->dst, ETH_ALEN);
  771. mpath_set_pinfo(mpath, next_hop, pinfo);
  772. rcu_read_unlock();
  773. return 0;
  774. }
  775. static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
  776. int idx, u8 *dst, u8 *next_hop,
  777. struct mpath_info *pinfo)
  778. {
  779. struct ieee80211_sub_if_data *sdata;
  780. struct mesh_path *mpath;
  781. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  782. rcu_read_lock();
  783. mpath = mesh_path_lookup_by_idx(idx, sdata);
  784. if (!mpath) {
  785. rcu_read_unlock();
  786. return -ENOENT;
  787. }
  788. memcpy(dst, mpath->dst, ETH_ALEN);
  789. mpath_set_pinfo(mpath, next_hop, pinfo);
  790. rcu_read_unlock();
  791. return 0;
  792. }
  793. static int ieee80211_get_mesh_params(struct wiphy *wiphy,
  794. struct net_device *dev,
  795. struct mesh_config *conf)
  796. {
  797. struct ieee80211_sub_if_data *sdata;
  798. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  799. memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
  800. return 0;
  801. }
  802. static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
  803. {
  804. return (mask >> (parm-1)) & 0x1;
  805. }
  806. static int ieee80211_set_mesh_params(struct wiphy *wiphy,
  807. struct net_device *dev,
  808. const struct mesh_config *nconf, u32 mask)
  809. {
  810. struct mesh_config *conf;
  811. struct ieee80211_sub_if_data *sdata;
  812. struct ieee80211_if_mesh *ifmsh;
  813. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  814. ifmsh = &sdata->u.mesh;
  815. /* Set the config options which we are interested in setting */
  816. conf = &(sdata->u.mesh.mshcfg);
  817. if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
  818. conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
  819. if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
  820. conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
  821. if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
  822. conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
  823. if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
  824. conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
  825. if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
  826. conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
  827. if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
  828. conf->dot11MeshTTL = nconf->dot11MeshTTL;
  829. if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
  830. conf->auto_open_plinks = nconf->auto_open_plinks;
  831. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
  832. conf->dot11MeshHWMPmaxPREQretries =
  833. nconf->dot11MeshHWMPmaxPREQretries;
  834. if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
  835. conf->path_refresh_time = nconf->path_refresh_time;
  836. if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
  837. conf->min_discovery_timeout = nconf->min_discovery_timeout;
  838. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
  839. conf->dot11MeshHWMPactivePathTimeout =
  840. nconf->dot11MeshHWMPactivePathTimeout;
  841. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
  842. conf->dot11MeshHWMPpreqMinInterval =
  843. nconf->dot11MeshHWMPpreqMinInterval;
  844. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
  845. mask))
  846. conf->dot11MeshHWMPnetDiameterTraversalTime =
  847. nconf->dot11MeshHWMPnetDiameterTraversalTime;
  848. if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
  849. conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
  850. ieee80211_mesh_root_setup(ifmsh);
  851. }
  852. return 0;
  853. }
  854. #endif
  855. static int ieee80211_change_bss(struct wiphy *wiphy,
  856. struct net_device *dev,
  857. struct bss_parameters *params)
  858. {
  859. struct ieee80211_sub_if_data *sdata;
  860. u32 changed = 0;
  861. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  862. if (params->use_cts_prot >= 0) {
  863. sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
  864. changed |= BSS_CHANGED_ERP_CTS_PROT;
  865. }
  866. if (params->use_short_preamble >= 0) {
  867. sdata->vif.bss_conf.use_short_preamble =
  868. params->use_short_preamble;
  869. changed |= BSS_CHANGED_ERP_PREAMBLE;
  870. }
  871. if (!sdata->vif.bss_conf.use_short_slot &&
  872. sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) {
  873. sdata->vif.bss_conf.use_short_slot = true;
  874. changed |= BSS_CHANGED_ERP_SLOT;
  875. }
  876. if (params->use_short_slot_time >= 0) {
  877. sdata->vif.bss_conf.use_short_slot =
  878. params->use_short_slot_time;
  879. changed |= BSS_CHANGED_ERP_SLOT;
  880. }
  881. if (params->basic_rates) {
  882. int i, j;
  883. u32 rates = 0;
  884. struct ieee80211_local *local = wiphy_priv(wiphy);
  885. struct ieee80211_supported_band *sband =
  886. wiphy->bands[local->oper_channel->band];
  887. for (i = 0; i < params->basic_rates_len; i++) {
  888. int rate = (params->basic_rates[i] & 0x7f) * 5;
  889. for (j = 0; j < sband->n_bitrates; j++) {
  890. if (sband->bitrates[j].bitrate == rate)
  891. rates |= BIT(j);
  892. }
  893. }
  894. sdata->vif.bss_conf.basic_rates = rates;
  895. changed |= BSS_CHANGED_BASIC_RATES;
  896. }
  897. if (params->ap_isolate >= 0) {
  898. if (params->ap_isolate)
  899. sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
  900. else
  901. sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
  902. }
  903. ieee80211_bss_info_change_notify(sdata, changed);
  904. return 0;
  905. }
  906. static int ieee80211_set_txq_params(struct wiphy *wiphy,
  907. struct ieee80211_txq_params *params)
  908. {
  909. struct ieee80211_local *local = wiphy_priv(wiphy);
  910. struct ieee80211_tx_queue_params p;
  911. if (!local->ops->conf_tx)
  912. return -EOPNOTSUPP;
  913. memset(&p, 0, sizeof(p));
  914. p.aifs = params->aifs;
  915. p.cw_max = params->cwmax;
  916. p.cw_min = params->cwmin;
  917. p.txop = params->txop;
  918. /*
  919. * Setting tx queue params disables u-apsd because it's only
  920. * called in master mode.
  921. */
  922. p.uapsd = false;
  923. if (drv_conf_tx(local, params->queue, &p)) {
  924. wiphy_debug(local->hw.wiphy,
  925. "failed to set TX queue parameters for queue %d\n",
  926. params->queue);
  927. return -EINVAL;
  928. }
  929. return 0;
  930. }
  931. static int ieee80211_set_channel(struct wiphy *wiphy,
  932. struct net_device *netdev,
  933. struct ieee80211_channel *chan,
  934. enum nl80211_channel_type channel_type)
  935. {
  936. struct ieee80211_local *local = wiphy_priv(wiphy);
  937. struct ieee80211_sub_if_data *sdata = NULL;
  938. if (netdev)
  939. sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
  940. switch (ieee80211_get_channel_mode(local, NULL)) {
  941. case CHAN_MODE_HOPPING:
  942. return -EBUSY;
  943. case CHAN_MODE_FIXED:
  944. if (local->oper_channel != chan)
  945. return -EBUSY;
  946. if (!sdata && local->_oper_channel_type == channel_type)
  947. return 0;
  948. break;
  949. case CHAN_MODE_UNDEFINED:
  950. break;
  951. }
  952. local->oper_channel = chan;
  953. if (!ieee80211_set_channel_type(local, sdata, channel_type))
  954. return -EBUSY;
  955. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
  956. if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR)
  957. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
  958. return 0;
  959. }
  960. #ifdef CONFIG_PM
  961. static int ieee80211_suspend(struct wiphy *wiphy)
  962. {
  963. return __ieee80211_suspend(wiphy_priv(wiphy));
  964. }
  965. static int ieee80211_resume(struct wiphy *wiphy)
  966. {
  967. return __ieee80211_resume(wiphy_priv(wiphy));
  968. }
  969. #else
  970. #define ieee80211_suspend NULL
  971. #define ieee80211_resume NULL
  972. #endif
  973. static int ieee80211_scan(struct wiphy *wiphy,
  974. struct net_device *dev,
  975. struct cfg80211_scan_request *req)
  976. {
  977. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  978. switch (ieee80211_vif_type_p2p(&sdata->vif)) {
  979. case NL80211_IFTYPE_STATION:
  980. case NL80211_IFTYPE_ADHOC:
  981. case NL80211_IFTYPE_MESH_POINT:
  982. case NL80211_IFTYPE_P2P_CLIENT:
  983. break;
  984. case NL80211_IFTYPE_P2P_GO:
  985. if (sdata->local->ops->hw_scan)
  986. break;
  987. /* FIXME: implement NoA while scanning in software */
  988. return -EOPNOTSUPP;
  989. case NL80211_IFTYPE_AP:
  990. if (sdata->u.ap.beacon)
  991. return -EOPNOTSUPP;
  992. break;
  993. default:
  994. return -EOPNOTSUPP;
  995. }
  996. return ieee80211_request_scan(sdata, req);
  997. }
  998. static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
  999. struct cfg80211_auth_request *req)
  1000. {
  1001. return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
  1002. }
  1003. static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
  1004. struct cfg80211_assoc_request *req)
  1005. {
  1006. struct ieee80211_local *local = wiphy_priv(wiphy);
  1007. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1008. switch (ieee80211_get_channel_mode(local, sdata)) {
  1009. case CHAN_MODE_HOPPING:
  1010. return -EBUSY;
  1011. case CHAN_MODE_FIXED:
  1012. if (local->oper_channel == req->bss->channel)
  1013. break;
  1014. return -EBUSY;
  1015. case CHAN_MODE_UNDEFINED:
  1016. break;
  1017. }
  1018. return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
  1019. }
  1020. static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
  1021. struct cfg80211_deauth_request *req,
  1022. void *cookie)
  1023. {
  1024. return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev),
  1025. req, cookie);
  1026. }
  1027. static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
  1028. struct cfg80211_disassoc_request *req,
  1029. void *cookie)
  1030. {
  1031. return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev),
  1032. req, cookie);
  1033. }
  1034. static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
  1035. struct cfg80211_ibss_params *params)
  1036. {
  1037. struct ieee80211_local *local = wiphy_priv(wiphy);
  1038. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1039. switch (ieee80211_get_channel_mode(local, sdata)) {
  1040. case CHAN_MODE_HOPPING:
  1041. return -EBUSY;
  1042. case CHAN_MODE_FIXED:
  1043. if (!params->channel_fixed)
  1044. return -EBUSY;
  1045. if (local->oper_channel == params->channel)
  1046. break;
  1047. return -EBUSY;
  1048. case CHAN_MODE_UNDEFINED:
  1049. break;
  1050. }
  1051. return ieee80211_ibss_join(sdata, params);
  1052. }
  1053. static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
  1054. {
  1055. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1056. return ieee80211_ibss_leave(sdata);
  1057. }
  1058. static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
  1059. {
  1060. struct ieee80211_local *local = wiphy_priv(wiphy);
  1061. int err;
  1062. if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
  1063. err = drv_set_frag_threshold(local, wiphy->frag_threshold);
  1064. if (err)
  1065. return err;
  1066. }
  1067. if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
  1068. err = drv_set_coverage_class(local, wiphy->coverage_class);
  1069. if (err)
  1070. return err;
  1071. }
  1072. if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
  1073. err = drv_set_rts_threshold(local, wiphy->rts_threshold);
  1074. if (err)
  1075. return err;
  1076. }
  1077. if (changed & WIPHY_PARAM_RETRY_SHORT)
  1078. local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
  1079. if (changed & WIPHY_PARAM_RETRY_LONG)
  1080. local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
  1081. if (changed &
  1082. (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
  1083. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
  1084. return 0;
  1085. }
  1086. static int ieee80211_set_tx_power(struct wiphy *wiphy,
  1087. enum nl80211_tx_power_setting type, int mbm)
  1088. {
  1089. struct ieee80211_local *local = wiphy_priv(wiphy);
  1090. struct ieee80211_channel *chan = local->hw.conf.channel;
  1091. u32 changes = 0;
  1092. switch (type) {
  1093. case NL80211_TX_POWER_AUTOMATIC:
  1094. local->user_power_level = -1;
  1095. break;
  1096. case NL80211_TX_POWER_LIMITED:
  1097. if (mbm < 0 || (mbm % 100))
  1098. return -EOPNOTSUPP;
  1099. local->user_power_level = MBM_TO_DBM(mbm);
  1100. break;
  1101. case NL80211_TX_POWER_FIXED:
  1102. if (mbm < 0 || (mbm % 100))
  1103. return -EOPNOTSUPP;
  1104. /* TODO: move to cfg80211 when it knows the channel */
  1105. if (MBM_TO_DBM(mbm) > chan->max_power)
  1106. return -EINVAL;
  1107. local->user_power_level = MBM_TO_DBM(mbm);
  1108. break;
  1109. }
  1110. ieee80211_hw_config(local, changes);
  1111. return 0;
  1112. }
  1113. static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
  1114. {
  1115. struct ieee80211_local *local = wiphy_priv(wiphy);
  1116. *dbm = local->hw.conf.power_level;
  1117. return 0;
  1118. }
  1119. static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
  1120. const u8 *addr)
  1121. {
  1122. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1123. memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
  1124. return 0;
  1125. }
  1126. static void ieee80211_rfkill_poll(struct wiphy *wiphy)
  1127. {
  1128. struct ieee80211_local *local = wiphy_priv(wiphy);
  1129. drv_rfkill_poll(local);
  1130. }
  1131. #ifdef CONFIG_NL80211_TESTMODE
  1132. static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
  1133. {
  1134. struct ieee80211_local *local = wiphy_priv(wiphy);
  1135. if (!local->ops->testmode_cmd)
  1136. return -EOPNOTSUPP;
  1137. return local->ops->testmode_cmd(&local->hw, data, len);
  1138. }
  1139. #endif
  1140. int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
  1141. enum ieee80211_smps_mode smps_mode)
  1142. {
  1143. const u8 *ap;
  1144. enum ieee80211_smps_mode old_req;
  1145. int err;
  1146. old_req = sdata->u.mgd.req_smps;
  1147. sdata->u.mgd.req_smps = smps_mode;
  1148. if (old_req == smps_mode &&
  1149. smps_mode != IEEE80211_SMPS_AUTOMATIC)
  1150. return 0;
  1151. /*
  1152. * If not associated, or current association is not an HT
  1153. * association, there's no need to send an action frame.
  1154. */
  1155. if (!sdata->u.mgd.associated ||
  1156. sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
  1157. mutex_lock(&sdata->local->iflist_mtx);
  1158. ieee80211_recalc_smps(sdata->local);
  1159. mutex_unlock(&sdata->local->iflist_mtx);
  1160. return 0;
  1161. }
  1162. ap = sdata->u.mgd.associated->bssid;
  1163. if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
  1164. if (sdata->u.mgd.powersave)
  1165. smps_mode = IEEE80211_SMPS_DYNAMIC;
  1166. else
  1167. smps_mode = IEEE80211_SMPS_OFF;
  1168. }
  1169. /* send SM PS frame to AP */
  1170. err = ieee80211_send_smps_action(sdata, smps_mode,
  1171. ap, ap);
  1172. if (err)
  1173. sdata->u.mgd.req_smps = old_req;
  1174. return err;
  1175. }
  1176. static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
  1177. bool enabled, int timeout)
  1178. {
  1179. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1180. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1181. if (sdata->vif.type != NL80211_IFTYPE_STATION)
  1182. return -EOPNOTSUPP;
  1183. if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
  1184. return -EOPNOTSUPP;
  1185. if (enabled == sdata->u.mgd.powersave &&
  1186. timeout == local->dynamic_ps_forced_timeout)
  1187. return 0;
  1188. sdata->u.mgd.powersave = enabled;
  1189. local->dynamic_ps_forced_timeout = timeout;
  1190. /* no change, but if automatic follow powersave */
  1191. mutex_lock(&sdata->u.mgd.mtx);
  1192. __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
  1193. mutex_unlock(&sdata->u.mgd.mtx);
  1194. if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
  1195. ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
  1196. ieee80211_recalc_ps(local, -1);
  1197. return 0;
  1198. }
  1199. static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
  1200. struct net_device *dev,
  1201. s32 rssi_thold, u32 rssi_hyst)
  1202. {
  1203. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1204. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1205. struct ieee80211_vif *vif = &sdata->vif;
  1206. struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
  1207. if (rssi_thold == bss_conf->cqm_rssi_thold &&
  1208. rssi_hyst == bss_conf->cqm_rssi_hyst)
  1209. return 0;
  1210. bss_conf->cqm_rssi_thold = rssi_thold;
  1211. bss_conf->cqm_rssi_hyst = rssi_hyst;
  1212. if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) {
  1213. if (sdata->vif.type != NL80211_IFTYPE_STATION)
  1214. return -EOPNOTSUPP;
  1215. return 0;
  1216. }
  1217. /* tell the driver upon association, unless already associated */
  1218. if (sdata->u.mgd.associated)
  1219. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
  1220. return 0;
  1221. }
  1222. static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
  1223. struct net_device *dev,
  1224. const u8 *addr,
  1225. const struct cfg80211_bitrate_mask *mask)
  1226. {
  1227. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1228. struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
  1229. int i;
  1230. /*
  1231. * This _could_ be supported by providing a hook for
  1232. * drivers for this function, but at this point it
  1233. * doesn't seem worth bothering.
  1234. */
  1235. if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL)
  1236. return -EOPNOTSUPP;
  1237. for (i = 0; i < IEEE80211_NUM_BANDS; i++)
  1238. sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
  1239. return 0;
  1240. }
  1241. static int ieee80211_remain_on_channel(struct wiphy *wiphy,
  1242. struct net_device *dev,
  1243. struct ieee80211_channel *chan,
  1244. enum nl80211_channel_type channel_type,
  1245. unsigned int duration,
  1246. u64 *cookie)
  1247. {
  1248. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1249. return ieee80211_wk_remain_on_channel(sdata, chan, channel_type,
  1250. duration, cookie);
  1251. }
  1252. static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
  1253. struct net_device *dev,
  1254. u64 cookie)
  1255. {
  1256. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1257. return ieee80211_wk_cancel_remain_on_channel(sdata, cookie);
  1258. }
  1259. static enum work_done_result
  1260. ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb)
  1261. {
  1262. /*
  1263. * Use the data embedded in the work struct for reporting
  1264. * here so if the driver mangled the SKB before dropping
  1265. * it (which is the only way we really should get here)
  1266. * then we don't report mangled data.
  1267. *
  1268. * If there was no wait time, then by the time we get here
  1269. * the driver will likely not have reported the status yet,
  1270. * so in that case userspace will have to deal with it.
  1271. */
  1272. if (wk->offchan_tx.wait && wk->offchan_tx.frame)
  1273. cfg80211_mgmt_tx_status(wk->sdata->dev,
  1274. (unsigned long) wk->offchan_tx.frame,
  1275. wk->ie, wk->ie_len, false, GFP_KERNEL);
  1276. return WORK_DONE_DESTROY;
  1277. }
  1278. static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
  1279. struct ieee80211_channel *chan, bool offchan,
  1280. enum nl80211_channel_type channel_type,
  1281. bool channel_type_valid, unsigned int wait,
  1282. const u8 *buf, size_t len, u64 *cookie)
  1283. {
  1284. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1285. struct ieee80211_local *local = sdata->local;
  1286. struct sk_buff *skb;
  1287. struct sta_info *sta;
  1288. struct ieee80211_work *wk;
  1289. const struct ieee80211_mgmt *mgmt = (void *)buf;
  1290. u32 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
  1291. IEEE80211_TX_CTL_REQ_TX_STATUS;
  1292. bool is_offchan = false;
  1293. /* Check that we are on the requested channel for transmission */
  1294. if (chan != local->tmp_channel &&
  1295. chan != local->oper_channel)
  1296. is_offchan = true;
  1297. if (channel_type_valid &&
  1298. (channel_type != local->tmp_channel_type &&
  1299. channel_type != local->_oper_channel_type))
  1300. is_offchan = true;
  1301. if (is_offchan && !offchan)
  1302. return -EBUSY;
  1303. switch (sdata->vif.type) {
  1304. case NL80211_IFTYPE_ADHOC:
  1305. case NL80211_IFTYPE_AP:
  1306. case NL80211_IFTYPE_AP_VLAN:
  1307. case NL80211_IFTYPE_P2P_GO:
  1308. if (!ieee80211_is_action(mgmt->frame_control) ||
  1309. mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
  1310. break;
  1311. rcu_read_lock();
  1312. sta = sta_info_get(sdata, mgmt->da);
  1313. rcu_read_unlock();
  1314. if (!sta)
  1315. return -ENOLINK;
  1316. break;
  1317. case NL80211_IFTYPE_STATION:
  1318. case NL80211_IFTYPE_P2P_CLIENT:
  1319. break;
  1320. default:
  1321. return -EOPNOTSUPP;
  1322. }
  1323. skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
  1324. if (!skb)
  1325. return -ENOMEM;
  1326. skb_reserve(skb, local->hw.extra_tx_headroom);
  1327. memcpy(skb_put(skb, len), buf, len);
  1328. IEEE80211_SKB_CB(skb)->flags = flags;
  1329. skb->dev = sdata->dev;
  1330. *cookie = (unsigned long) skb;
  1331. /*
  1332. * Can transmit right away if the channel was the
  1333. * right one and there's no wait involved... If a
  1334. * wait is involved, we might otherwise not be on
  1335. * the right channel for long enough!
  1336. */
  1337. if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) {
  1338. ieee80211_tx_skb(sdata, skb);
  1339. return 0;
  1340. }
  1341. wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL);
  1342. if (!wk) {
  1343. kfree_skb(skb);
  1344. return -ENOMEM;
  1345. }
  1346. wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
  1347. wk->chan = chan;
  1348. wk->sdata = sdata;
  1349. wk->done = ieee80211_offchan_tx_done;
  1350. wk->offchan_tx.frame = skb;
  1351. wk->offchan_tx.wait = wait;
  1352. wk->ie_len = len;
  1353. memcpy(wk->ie, buf, len);
  1354. ieee80211_add_work(wk);
  1355. return 0;
  1356. }
  1357. static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
  1358. struct net_device *dev,
  1359. u64 cookie)
  1360. {
  1361. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1362. struct ieee80211_local *local = sdata->local;
  1363. struct ieee80211_work *wk;
  1364. int ret = -ENOENT;
  1365. mutex_lock(&local->mtx);
  1366. list_for_each_entry(wk, &local->work_list, list) {
  1367. if (wk->sdata != sdata)
  1368. continue;
  1369. if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
  1370. continue;
  1371. if (cookie != (unsigned long) wk->offchan_tx.frame)
  1372. continue;
  1373. wk->timeout = jiffies;
  1374. ieee80211_queue_work(&local->hw, &local->work_work);
  1375. ret = 0;
  1376. break;
  1377. }
  1378. mutex_unlock(&local->mtx);
  1379. return ret;
  1380. }
  1381. static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
  1382. struct net_device *dev,
  1383. u16 frame_type, bool reg)
  1384. {
  1385. struct ieee80211_local *local = wiphy_priv(wiphy);
  1386. if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
  1387. return;
  1388. if (reg)
  1389. local->probe_req_reg++;
  1390. else
  1391. local->probe_req_reg--;
  1392. ieee80211_queue_work(&local->hw, &local->reconfig_filter);
  1393. }
  1394. static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
  1395. {
  1396. struct ieee80211_local *local = wiphy_priv(wiphy);
  1397. if (local->started)
  1398. return -EOPNOTSUPP;
  1399. return drv_set_antenna(local, tx_ant, rx_ant);
  1400. }
  1401. static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
  1402. {
  1403. struct ieee80211_local *local = wiphy_priv(wiphy);
  1404. return drv_get_antenna(local, tx_ant, rx_ant);
  1405. }
  1406. struct cfg80211_ops mac80211_config_ops = {
  1407. .add_virtual_intf = ieee80211_add_iface,
  1408. .del_virtual_intf = ieee80211_del_iface,
  1409. .change_virtual_intf = ieee80211_change_iface,
  1410. .add_key = ieee80211_add_key,
  1411. .del_key = ieee80211_del_key,
  1412. .get_key = ieee80211_get_key,
  1413. .set_default_key = ieee80211_config_default_key,
  1414. .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
  1415. .add_beacon = ieee80211_add_beacon,
  1416. .set_beacon = ieee80211_set_beacon,
  1417. .del_beacon = ieee80211_del_beacon,
  1418. .add_station = ieee80211_add_station,
  1419. .del_station = ieee80211_del_station,
  1420. .change_station = ieee80211_change_station,
  1421. .get_station = ieee80211_get_station,
  1422. .dump_station = ieee80211_dump_station,
  1423. .dump_survey = ieee80211_dump_survey,
  1424. #ifdef CONFIG_MAC80211_MESH
  1425. .add_mpath = ieee80211_add_mpath,
  1426. .del_mpath = ieee80211_del_mpath,
  1427. .change_mpath = ieee80211_change_mpath,
  1428. .get_mpath = ieee80211_get_mpath,
  1429. .dump_mpath = ieee80211_dump_mpath,
  1430. .set_mesh_params = ieee80211_set_mesh_params,
  1431. .get_mesh_params = ieee80211_get_mesh_params,
  1432. #endif
  1433. .change_bss = ieee80211_change_bss,
  1434. .set_txq_params = ieee80211_set_txq_params,
  1435. .set_channel = ieee80211_set_channel,
  1436. .suspend = ieee80211_suspend,
  1437. .resume = ieee80211_resume,
  1438. .scan = ieee80211_scan,
  1439. .auth = ieee80211_auth,
  1440. .assoc = ieee80211_assoc,
  1441. .deauth = ieee80211_deauth,
  1442. .disassoc = ieee80211_disassoc,
  1443. .join_ibss = ieee80211_join_ibss,
  1444. .leave_ibss = ieee80211_leave_ibss,
  1445. .set_wiphy_params = ieee80211_set_wiphy_params,
  1446. .set_tx_power = ieee80211_set_tx_power,
  1447. .get_tx_power = ieee80211_get_tx_power,
  1448. .set_wds_peer = ieee80211_set_wds_peer,
  1449. .rfkill_poll = ieee80211_rfkill_poll,
  1450. CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
  1451. .set_power_mgmt = ieee80211_set_power_mgmt,
  1452. .set_bitrate_mask = ieee80211_set_bitrate_mask,
  1453. .remain_on_channel = ieee80211_remain_on_channel,
  1454. .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
  1455. .mgmt_tx = ieee80211_mgmt_tx,
  1456. .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
  1457. .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
  1458. .mgmt_frame_register = ieee80211_mgmt_frame_register,
  1459. .set_antenna = ieee80211_set_antenna,
  1460. .get_antenna = ieee80211_get_antenna,
  1461. };