cfg80211.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. /*
  2. * Copyright (c) 2012-2012 Quantenna Communications, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/etherdevice.h>
  18. #include <linux/vmalloc.h>
  19. #include <linux/ieee80211.h>
  20. #include <net/cfg80211.h>
  21. #include <net/netlink.h>
  22. #include "cfg80211.h"
  23. #include "commands.h"
  24. #include "core.h"
  25. #include "util.h"
  26. #include "bus.h"
  27. /* Supported rates to be advertised to the cfg80211 */
  28. static struct ieee80211_rate qtnf_rates_2g[] = {
  29. {.bitrate = 10, .hw_value = 2, },
  30. {.bitrate = 20, .hw_value = 4, },
  31. {.bitrate = 55, .hw_value = 11, },
  32. {.bitrate = 110, .hw_value = 22, },
  33. {.bitrate = 60, .hw_value = 12, },
  34. {.bitrate = 90, .hw_value = 18, },
  35. {.bitrate = 120, .hw_value = 24, },
  36. {.bitrate = 180, .hw_value = 36, },
  37. {.bitrate = 240, .hw_value = 48, },
  38. {.bitrate = 360, .hw_value = 72, },
  39. {.bitrate = 480, .hw_value = 96, },
  40. {.bitrate = 540, .hw_value = 108, },
  41. };
  42. /* Supported rates to be advertised to the cfg80211 */
  43. static struct ieee80211_rate qtnf_rates_5g[] = {
  44. {.bitrate = 60, .hw_value = 12, },
  45. {.bitrate = 90, .hw_value = 18, },
  46. {.bitrate = 120, .hw_value = 24, },
  47. {.bitrate = 180, .hw_value = 36, },
  48. {.bitrate = 240, .hw_value = 48, },
  49. {.bitrate = 360, .hw_value = 72, },
  50. {.bitrate = 480, .hw_value = 96, },
  51. {.bitrate = 540, .hw_value = 108, },
  52. };
  53. /* Supported crypto cipher suits to be advertised to cfg80211 */
  54. static const u32 qtnf_cipher_suites[] = {
  55. WLAN_CIPHER_SUITE_TKIP,
  56. WLAN_CIPHER_SUITE_CCMP,
  57. WLAN_CIPHER_SUITE_AES_CMAC,
  58. };
  59. /* Supported mgmt frame types to be advertised to cfg80211 */
  60. static const struct ieee80211_txrx_stypes
  61. qtnf_mgmt_stypes[NUM_NL80211_IFTYPES] = {
  62. [NL80211_IFTYPE_STATION] = {
  63. .tx = BIT(IEEE80211_STYPE_ACTION >> 4),
  64. .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  65. BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
  66. },
  67. [NL80211_IFTYPE_AP] = {
  68. .tx = BIT(IEEE80211_STYPE_ACTION >> 4),
  69. .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  70. BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
  71. },
  72. };
  73. static int
  74. qtnf_change_virtual_intf(struct wiphy *wiphy,
  75. struct net_device *dev,
  76. enum nl80211_iftype type,
  77. struct vif_params *params)
  78. {
  79. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  80. u8 *mac_addr;
  81. int ret;
  82. if (params)
  83. mac_addr = params->macaddr;
  84. else
  85. mac_addr = NULL;
  86. qtnf_scan_done(vif->mac, true);
  87. ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr);
  88. if (ret) {
  89. pr_err("VIF%u.%u: failed to change VIF type: %d\n",
  90. vif->mac->macid, vif->vifid, ret);
  91. return ret;
  92. }
  93. vif->wdev.iftype = type;
  94. return 0;
  95. }
  96. int qtnf_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
  97. {
  98. struct net_device *netdev = wdev->netdev;
  99. struct qtnf_vif *vif;
  100. if (WARN_ON(!netdev))
  101. return -EFAULT;
  102. vif = qtnf_netdev_get_priv(wdev->netdev);
  103. qtnf_scan_done(vif->mac, true);
  104. if (qtnf_cmd_send_del_intf(vif))
  105. pr_err("VIF%u.%u: failed to delete VIF\n", vif->mac->macid,
  106. vif->vifid);
  107. /* Stop data */
  108. netif_tx_stop_all_queues(netdev);
  109. if (netif_carrier_ok(netdev))
  110. netif_carrier_off(netdev);
  111. if (netdev->reg_state == NETREG_REGISTERED)
  112. unregister_netdevice(netdev);
  113. vif->netdev->ieee80211_ptr = NULL;
  114. vif->netdev = NULL;
  115. vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
  116. eth_zero_addr(vif->mac_addr);
  117. return 0;
  118. }
  119. static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
  120. const char *name,
  121. unsigned char name_assign_t,
  122. enum nl80211_iftype type,
  123. struct vif_params *params)
  124. {
  125. struct qtnf_wmac *mac;
  126. struct qtnf_vif *vif;
  127. u8 *mac_addr = NULL;
  128. mac = wiphy_priv(wiphy);
  129. if (!mac)
  130. return ERR_PTR(-EFAULT);
  131. switch (type) {
  132. case NL80211_IFTYPE_STATION:
  133. case NL80211_IFTYPE_AP:
  134. vif = qtnf_mac_get_free_vif(mac);
  135. if (!vif) {
  136. pr_err("MAC%u: no free VIF available\n", mac->macid);
  137. return ERR_PTR(-EFAULT);
  138. }
  139. eth_zero_addr(vif->mac_addr);
  140. vif->bss_priority = QTNF_DEF_BSS_PRIORITY;
  141. vif->wdev.wiphy = wiphy;
  142. vif->wdev.iftype = type;
  143. vif->sta_state = QTNF_STA_DISCONNECTED;
  144. break;
  145. default:
  146. pr_err("MAC%u: unsupported IF type %d\n", mac->macid, type);
  147. return ERR_PTR(-ENOTSUPP);
  148. }
  149. if (params)
  150. mac_addr = params->macaddr;
  151. if (qtnf_cmd_send_add_intf(vif, type, mac_addr)) {
  152. pr_err("VIF%u.%u: failed to add VIF\n", mac->macid, vif->vifid);
  153. goto err_cmd;
  154. }
  155. if (!is_valid_ether_addr(vif->mac_addr)) {
  156. pr_err("VIF%u.%u: FW reported bad MAC: %pM\n",
  157. mac->macid, vif->vifid, vif->mac_addr);
  158. goto err_mac;
  159. }
  160. if (qtnf_core_net_attach(mac, vif, name, name_assign_t, type)) {
  161. pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid,
  162. vif->vifid);
  163. goto err_net;
  164. }
  165. vif->wdev.netdev = vif->netdev;
  166. return &vif->wdev;
  167. err_net:
  168. vif->netdev = NULL;
  169. err_mac:
  170. qtnf_cmd_send_del_intf(vif);
  171. err_cmd:
  172. vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
  173. return ERR_PTR(-EFAULT);
  174. }
  175. static int qtnf_mgmt_set_appie(struct qtnf_vif *vif,
  176. const struct cfg80211_beacon_data *info)
  177. {
  178. int ret = 0;
  179. if (!info->beacon_ies || !info->beacon_ies_len) {
  180. ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_MGMT_FRAME_BEACON,
  181. NULL, 0);
  182. } else {
  183. ret = qtnf_cmd_send_mgmt_set_appie(vif, QLINK_MGMT_FRAME_BEACON,
  184. info->beacon_ies,
  185. info->beacon_ies_len);
  186. }
  187. if (ret)
  188. goto out;
  189. if (!info->proberesp_ies || !info->proberesp_ies_len) {
  190. ret = qtnf_cmd_send_mgmt_set_appie(vif,
  191. QLINK_MGMT_FRAME_PROBE_RESP,
  192. NULL, 0);
  193. } else {
  194. ret = qtnf_cmd_send_mgmt_set_appie(vif,
  195. QLINK_MGMT_FRAME_PROBE_RESP,
  196. info->proberesp_ies,
  197. info->proberesp_ies_len);
  198. }
  199. if (ret)
  200. goto out;
  201. if (!info->assocresp_ies || !info->assocresp_ies_len) {
  202. ret = qtnf_cmd_send_mgmt_set_appie(vif,
  203. QLINK_MGMT_FRAME_ASSOC_RESP,
  204. NULL, 0);
  205. } else {
  206. ret = qtnf_cmd_send_mgmt_set_appie(vif,
  207. QLINK_MGMT_FRAME_ASSOC_RESP,
  208. info->assocresp_ies,
  209. info->assocresp_ies_len);
  210. }
  211. out:
  212. return ret;
  213. }
  214. static int qtnf_change_beacon(struct wiphy *wiphy, struct net_device *dev,
  215. struct cfg80211_beacon_data *info)
  216. {
  217. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  218. if (!(vif->bss_status & QTNF_STATE_AP_START)) {
  219. pr_err("VIF%u.%u: not started\n", vif->mac->macid, vif->vifid);
  220. return -EFAULT;
  221. }
  222. return qtnf_mgmt_set_appie(vif, info);
  223. }
  224. static int qtnf_start_ap(struct wiphy *wiphy, struct net_device *dev,
  225. struct cfg80211_ap_settings *settings)
  226. {
  227. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  228. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  229. struct qtnf_bss_config *bss_cfg;
  230. int ret;
  231. if (!cfg80211_chandef_identical(&mac->chandef, &settings->chandef)) {
  232. memcpy(&mac->chandef, &settings->chandef, sizeof(mac->chandef));
  233. if (vif->vifid != 0)
  234. pr_warn("%s: unexpected chan %u (%u MHz)\n", dev->name,
  235. settings->chandef.chan->hw_value,
  236. settings->chandef.chan->center_freq);
  237. }
  238. bss_cfg = &vif->bss_cfg;
  239. memset(bss_cfg, 0, sizeof(*bss_cfg));
  240. bss_cfg->bcn_period = settings->beacon_interval;
  241. bss_cfg->dtim = settings->dtim_period;
  242. bss_cfg->auth_type = settings->auth_type;
  243. bss_cfg->privacy = settings->privacy;
  244. bss_cfg->ssid_len = settings->ssid_len;
  245. memcpy(&bss_cfg->ssid, settings->ssid, bss_cfg->ssid_len);
  246. memcpy(&bss_cfg->crypto, &settings->crypto,
  247. sizeof(struct cfg80211_crypto_settings));
  248. ret = qtnf_cmd_send_config_ap(vif);
  249. if (ret) {
  250. pr_err("VIF%u.%u: failed to push config to FW\n",
  251. vif->mac->macid, vif->vifid);
  252. goto out;
  253. }
  254. if (!(vif->bss_status & QTNF_STATE_AP_CONFIG)) {
  255. pr_err("VIF%u.%u: AP config failed in FW\n", vif->mac->macid,
  256. vif->vifid);
  257. ret = -EFAULT;
  258. goto out;
  259. }
  260. ret = qtnf_mgmt_set_appie(vif, &settings->beacon);
  261. if (ret) {
  262. pr_err("VIF%u.%u: failed to add IEs to beacon\n",
  263. vif->mac->macid, vif->vifid);
  264. goto out;
  265. }
  266. ret = qtnf_cmd_send_start_ap(vif);
  267. if (ret) {
  268. pr_err("VIF%u.%u: failed to start AP\n", vif->mac->macid,
  269. vif->vifid);
  270. goto out;
  271. }
  272. if (!(vif->bss_status & QTNF_STATE_AP_START)) {
  273. pr_err("VIF%u.%u: FW failed to start AP operation\n",
  274. vif->mac->macid, vif->vifid);
  275. ret = -EFAULT;
  276. }
  277. out:
  278. return ret;
  279. }
  280. static int qtnf_stop_ap(struct wiphy *wiphy, struct net_device *dev)
  281. {
  282. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  283. int ret;
  284. qtnf_scan_done(vif->mac, true);
  285. ret = qtnf_cmd_send_stop_ap(vif);
  286. if (ret) {
  287. pr_err("VIF%u.%u: failed to stop AP operation in FW\n",
  288. vif->mac->macid, vif->vifid);
  289. vif->bss_status &= ~QTNF_STATE_AP_START;
  290. vif->bss_status &= ~QTNF_STATE_AP_CONFIG;
  291. netif_carrier_off(vif->netdev);
  292. }
  293. return ret;
  294. }
  295. static int qtnf_set_wiphy_params(struct wiphy *wiphy, u32 changed)
  296. {
  297. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  298. struct qtnf_vif *vif;
  299. int ret;
  300. vif = qtnf_mac_get_base_vif(mac);
  301. if (!vif) {
  302. pr_err("MAC%u: primary VIF is not configured\n", mac->macid);
  303. return -EFAULT;
  304. }
  305. if (changed & (WIPHY_PARAM_RETRY_LONG | WIPHY_PARAM_RETRY_SHORT)) {
  306. pr_err("MAC%u: can't modify retry params\n", mac->macid);
  307. return -EOPNOTSUPP;
  308. }
  309. ret = qtnf_cmd_send_update_phy_params(mac, changed);
  310. if (ret)
  311. pr_err("MAC%u: failed to update PHY params\n", mac->macid);
  312. return ret;
  313. }
  314. static void
  315. qtnf_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
  316. u16 frame_type, bool reg)
  317. {
  318. struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev);
  319. u16 mgmt_type;
  320. u16 new_mask;
  321. u16 qlink_frame_type = 0;
  322. mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
  323. if (reg)
  324. new_mask = vif->mgmt_frames_bitmask | BIT(mgmt_type);
  325. else
  326. new_mask = vif->mgmt_frames_bitmask & ~BIT(mgmt_type);
  327. if (new_mask == vif->mgmt_frames_bitmask)
  328. return;
  329. switch (frame_type & IEEE80211_FCTL_STYPE) {
  330. case IEEE80211_STYPE_PROBE_REQ:
  331. qlink_frame_type = QLINK_MGMT_FRAME_PROBE_REQ;
  332. break;
  333. case IEEE80211_STYPE_ACTION:
  334. qlink_frame_type = QLINK_MGMT_FRAME_ACTION;
  335. break;
  336. default:
  337. pr_warn("VIF%u.%u: unsupported frame type: %X\n",
  338. vif->mac->macid, vif->vifid,
  339. (frame_type & IEEE80211_FCTL_STYPE) >> 4);
  340. return;
  341. }
  342. if (qtnf_cmd_send_register_mgmt(vif, qlink_frame_type, reg)) {
  343. pr_warn("VIF%u.%u: failed to %sregister mgmt frame type 0x%x\n",
  344. vif->mac->macid, vif->vifid, reg ? "" : "un",
  345. frame_type);
  346. return;
  347. }
  348. vif->mgmt_frames_bitmask = new_mask;
  349. pr_debug("VIF%u.%u: %sregistered mgmt frame type 0x%x\n",
  350. vif->mac->macid, vif->vifid, reg ? "" : "un", frame_type);
  351. }
  352. static int
  353. qtnf_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
  354. struct cfg80211_mgmt_tx_params *params, u64 *cookie)
  355. {
  356. struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev);
  357. const struct ieee80211_mgmt *mgmt_frame = (void *)params->buf;
  358. u32 short_cookie = prandom_u32();
  359. u16 flags = 0;
  360. *cookie = short_cookie;
  361. if (params->offchan)
  362. flags |= QLINK_MGMT_FRAME_TX_FLAG_OFFCHAN;
  363. if (params->no_cck)
  364. flags |= QLINK_MGMT_FRAME_TX_FLAG_NO_CCK;
  365. if (params->dont_wait_for_ack)
  366. flags |= QLINK_MGMT_FRAME_TX_FLAG_ACK_NOWAIT;
  367. pr_debug("%s freq:%u; FC:%.4X; DA:%pM; len:%zu; C:%.8X; FL:%.4X\n",
  368. wdev->netdev->name, params->chan->center_freq,
  369. le16_to_cpu(mgmt_frame->frame_control), mgmt_frame->da,
  370. params->len, short_cookie, flags);
  371. return qtnf_cmd_send_mgmt_frame(vif, short_cookie, flags,
  372. params->chan->center_freq,
  373. params->buf, params->len);
  374. }
  375. static int
  376. qtnf_get_station(struct wiphy *wiphy, struct net_device *dev,
  377. const u8 *mac, struct station_info *sinfo)
  378. {
  379. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  380. return qtnf_cmd_get_sta_info(vif, mac, sinfo);
  381. }
  382. static int
  383. qtnf_dump_station(struct wiphy *wiphy, struct net_device *dev,
  384. int idx, u8 *mac, struct station_info *sinfo)
  385. {
  386. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  387. const struct qtnf_sta_node *sta_node;
  388. int ret;
  389. sta_node = qtnf_sta_list_lookup_index(&vif->sta_list, idx);
  390. if (unlikely(!sta_node))
  391. return -ENOENT;
  392. ether_addr_copy(mac, sta_node->mac_addr);
  393. ret = qtnf_cmd_get_sta_info(vif, sta_node->mac_addr, sinfo);
  394. if (unlikely(ret == -ENOENT)) {
  395. qtnf_sta_list_del(&vif->sta_list, mac);
  396. cfg80211_del_sta(vif->netdev, mac, GFP_KERNEL);
  397. sinfo->filled = 0;
  398. }
  399. return ret;
  400. }
  401. static int qtnf_add_key(struct wiphy *wiphy, struct net_device *dev,
  402. u8 key_index, bool pairwise, const u8 *mac_addr,
  403. struct key_params *params)
  404. {
  405. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  406. int ret;
  407. ret = qtnf_cmd_send_add_key(vif, key_index, pairwise, mac_addr, params);
  408. if (ret)
  409. pr_err("VIF%u.%u: failed to add key: cipher=%x idx=%u pw=%u\n",
  410. vif->mac->macid, vif->vifid, params->cipher, key_index,
  411. pairwise);
  412. return ret;
  413. }
  414. static int qtnf_del_key(struct wiphy *wiphy, struct net_device *dev,
  415. u8 key_index, bool pairwise, const u8 *mac_addr)
  416. {
  417. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  418. int ret;
  419. ret = qtnf_cmd_send_del_key(vif, key_index, pairwise, mac_addr);
  420. if (ret)
  421. pr_err("VIF%u.%u: failed to delete key: idx=%u pw=%u\n",
  422. vif->mac->macid, vif->vifid, key_index, pairwise);
  423. return ret;
  424. }
  425. static int qtnf_set_default_key(struct wiphy *wiphy, struct net_device *dev,
  426. u8 key_index, bool unicast, bool multicast)
  427. {
  428. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  429. int ret;
  430. ret = qtnf_cmd_send_set_default_key(vif, key_index, unicast, multicast);
  431. if (ret)
  432. pr_err("VIF%u.%u: failed to set dflt key: idx=%u uc=%u mc=%u\n",
  433. vif->mac->macid, vif->vifid, key_index, unicast,
  434. multicast);
  435. return ret;
  436. }
  437. static int
  438. qtnf_set_default_mgmt_key(struct wiphy *wiphy, struct net_device *dev,
  439. u8 key_index)
  440. {
  441. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  442. int ret;
  443. ret = qtnf_cmd_send_set_default_mgmt_key(vif, key_index);
  444. if (ret)
  445. pr_err("VIF%u.%u: failed to set default MGMT key: idx=%u\n",
  446. vif->mac->macid, vif->vifid, key_index);
  447. return ret;
  448. }
  449. static int
  450. qtnf_change_station(struct wiphy *wiphy, struct net_device *dev,
  451. const u8 *mac, struct station_parameters *params)
  452. {
  453. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  454. int ret;
  455. ret = qtnf_cmd_send_change_sta(vif, mac, params);
  456. if (ret)
  457. pr_err("VIF%u.%u: failed to change STA %pM\n",
  458. vif->mac->macid, vif->vifid, mac);
  459. return ret;
  460. }
  461. static int
  462. qtnf_del_station(struct wiphy *wiphy, struct net_device *dev,
  463. struct station_del_parameters *params)
  464. {
  465. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  466. int ret;
  467. if (params->mac &&
  468. (vif->wdev.iftype == NL80211_IFTYPE_AP) &&
  469. !is_broadcast_ether_addr(params->mac) &&
  470. !qtnf_sta_list_lookup(&vif->sta_list, params->mac))
  471. return 0;
  472. ret = qtnf_cmd_send_del_sta(vif, params);
  473. if (ret)
  474. pr_err("VIF%u.%u: failed to delete STA %pM\n",
  475. vif->mac->macid, vif->vifid, params->mac);
  476. return ret;
  477. }
  478. static void qtnf_scan_timeout(unsigned long data)
  479. {
  480. struct qtnf_wmac *mac = (struct qtnf_wmac *)data;
  481. pr_warn("mac%d scan timed out\n", mac->macid);
  482. qtnf_scan_done(mac, true);
  483. }
  484. static int
  485. qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
  486. {
  487. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  488. mac->scan_req = request;
  489. if (qtnf_cmd_send_scan(mac)) {
  490. pr_err("MAC%u: failed to start scan\n", mac->macid);
  491. mac->scan_req = NULL;
  492. return -EFAULT;
  493. }
  494. mac->scan_timeout.data = (unsigned long)mac;
  495. mac->scan_timeout.function = qtnf_scan_timeout;
  496. mod_timer(&mac->scan_timeout,
  497. jiffies + QTNF_SCAN_TIMEOUT_SEC * HZ);
  498. return 0;
  499. }
  500. static int
  501. qtnf_connect(struct wiphy *wiphy, struct net_device *dev,
  502. struct cfg80211_connect_params *sme)
  503. {
  504. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  505. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  506. struct cfg80211_chan_def chandef;
  507. struct qtnf_bss_config *bss_cfg;
  508. int ret;
  509. if (vif->wdev.iftype != NL80211_IFTYPE_STATION)
  510. return -EOPNOTSUPP;
  511. if (vif->sta_state != QTNF_STA_DISCONNECTED)
  512. return -EBUSY;
  513. bss_cfg = &vif->bss_cfg;
  514. memset(bss_cfg, 0, sizeof(*bss_cfg));
  515. if (sme->channel) {
  516. /* FIXME: need to set proper nl80211_channel_type value */
  517. cfg80211_chandef_create(&chandef, sme->channel,
  518. NL80211_CHAN_HT20);
  519. /* fall-back to minimal safe chandef description */
  520. if (!cfg80211_chandef_valid(&chandef))
  521. cfg80211_chandef_create(&chandef, sme->channel,
  522. NL80211_CHAN_HT20);
  523. memcpy(&mac->chandef, &chandef, sizeof(mac->chandef));
  524. }
  525. bss_cfg->ssid_len = sme->ssid_len;
  526. memcpy(&bss_cfg->ssid, sme->ssid, bss_cfg->ssid_len);
  527. bss_cfg->auth_type = sme->auth_type;
  528. bss_cfg->privacy = sme->privacy;
  529. bss_cfg->mfp = sme->mfp;
  530. if ((sme->bg_scan_period > 0) &&
  531. (sme->bg_scan_period <= QTNF_MAX_BG_SCAN_PERIOD))
  532. bss_cfg->bg_scan_period = sme->bg_scan_period;
  533. else if (sme->bg_scan_period == -1)
  534. bss_cfg->bg_scan_period = QTNF_DEFAULT_BG_SCAN_PERIOD;
  535. else
  536. bss_cfg->bg_scan_period = 0; /* disabled */
  537. bss_cfg->connect_flags = 0;
  538. if (sme->flags & ASSOC_REQ_DISABLE_HT)
  539. bss_cfg->connect_flags |= QLINK_STA_CONNECT_DISABLE_HT;
  540. if (sme->flags & ASSOC_REQ_DISABLE_VHT)
  541. bss_cfg->connect_flags |= QLINK_STA_CONNECT_DISABLE_VHT;
  542. if (sme->flags & ASSOC_REQ_USE_RRM)
  543. bss_cfg->connect_flags |= QLINK_STA_CONNECT_USE_RRM;
  544. memcpy(&bss_cfg->crypto, &sme->crypto, sizeof(bss_cfg->crypto));
  545. if (sme->bssid)
  546. ether_addr_copy(bss_cfg->bssid, sme->bssid);
  547. else
  548. eth_zero_addr(bss_cfg->bssid);
  549. ret = qtnf_cmd_send_connect(vif, sme);
  550. if (ret) {
  551. pr_err("VIF%u.%u: failed to connect\n", vif->mac->macid,
  552. vif->vifid);
  553. return ret;
  554. }
  555. vif->sta_state = QTNF_STA_CONNECTING;
  556. return 0;
  557. }
  558. static int
  559. qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev,
  560. u16 reason_code)
  561. {
  562. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  563. struct qtnf_vif *vif;
  564. int ret;
  565. vif = qtnf_mac_get_base_vif(mac);
  566. if (!vif) {
  567. pr_err("MAC%u: primary VIF is not configured\n", mac->macid);
  568. return -EFAULT;
  569. }
  570. if (vif->wdev.iftype != NL80211_IFTYPE_STATION)
  571. return -EOPNOTSUPP;
  572. if (vif->sta_state == QTNF_STA_DISCONNECTED)
  573. return 0;
  574. ret = qtnf_cmd_send_disconnect(vif, reason_code);
  575. if (ret) {
  576. pr_err("VIF%u.%u: failed to disconnect\n", mac->macid,
  577. vif->vifid);
  578. return ret;
  579. }
  580. vif->sta_state = QTNF_STA_DISCONNECTED;
  581. return 0;
  582. }
  583. static int
  584. qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,
  585. int idx, struct survey_info *survey)
  586. {
  587. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  588. struct ieee80211_supported_band *sband;
  589. struct cfg80211_chan_def *chandef;
  590. struct ieee80211_channel *chan;
  591. struct qtnf_chan_stats stats;
  592. struct qtnf_vif *vif;
  593. int ret;
  594. vif = qtnf_netdev_get_priv(dev);
  595. chandef = &mac->chandef;
  596. sband = wiphy->bands[NL80211_BAND_2GHZ];
  597. if (sband && idx >= sband->n_channels) {
  598. idx -= sband->n_channels;
  599. sband = NULL;
  600. }
  601. if (!sband)
  602. sband = wiphy->bands[NL80211_BAND_5GHZ];
  603. if (!sband || idx >= sband->n_channels)
  604. return -ENOENT;
  605. chan = &sband->channels[idx];
  606. memset(&stats, 0, sizeof(stats));
  607. survey->channel = chan;
  608. survey->filled = 0x0;
  609. if (chandef->chan) {
  610. if (chan->hw_value == chandef->chan->hw_value)
  611. survey->filled = SURVEY_INFO_IN_USE;
  612. }
  613. ret = qtnf_cmd_get_chan_stats(mac, chan->hw_value, &stats);
  614. switch (ret) {
  615. case 0:
  616. if (unlikely(stats.chan_num != chan->hw_value)) {
  617. pr_err("received stats for channel %d instead of %d\n",
  618. stats.chan_num, chan->hw_value);
  619. ret = -EINVAL;
  620. break;
  621. }
  622. survey->filled |= SURVEY_INFO_TIME |
  623. SURVEY_INFO_TIME_SCAN |
  624. SURVEY_INFO_TIME_BUSY |
  625. SURVEY_INFO_TIME_RX |
  626. SURVEY_INFO_TIME_TX |
  627. SURVEY_INFO_NOISE_DBM;
  628. survey->time_scan = stats.cca_try;
  629. survey->time = stats.cca_try;
  630. survey->time_tx = stats.cca_tx;
  631. survey->time_rx = stats.cca_rx;
  632. survey->time_busy = stats.cca_busy;
  633. survey->noise = stats.chan_noise;
  634. break;
  635. case -ENOENT:
  636. pr_debug("no stats for channel %u\n", chan->hw_value);
  637. ret = 0;
  638. break;
  639. default:
  640. pr_debug("failed to get chan(%d) stats from card\n",
  641. chan->hw_value);
  642. ret = -EINVAL;
  643. break;
  644. }
  645. return ret;
  646. }
  647. static int
  648. qtnf_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
  649. struct cfg80211_chan_def *chandef)
  650. {
  651. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  652. struct net_device *ndev = wdev->netdev;
  653. struct qtnf_vif *vif;
  654. if (!ndev)
  655. return -ENODEV;
  656. vif = qtnf_netdev_get_priv(wdev->netdev);
  657. switch (vif->wdev.iftype) {
  658. case NL80211_IFTYPE_STATION:
  659. if (vif->sta_state == QTNF_STA_DISCONNECTED) {
  660. pr_warn("%s: STA disconnected\n", ndev->name);
  661. return -ENODATA;
  662. }
  663. break;
  664. case NL80211_IFTYPE_AP:
  665. if (!(vif->bss_status & QTNF_STATE_AP_START)) {
  666. pr_warn("%s: AP not started\n", ndev->name);
  667. return -ENODATA;
  668. }
  669. break;
  670. default:
  671. pr_err("unsupported vif type (%d)\n", vif->wdev.iftype);
  672. return -ENODATA;
  673. }
  674. if (!cfg80211_chandef_valid(&mac->chandef)) {
  675. pr_err("invalid channel settings on %s\n", ndev->name);
  676. return -ENODATA;
  677. }
  678. memcpy(chandef, &mac->chandef, sizeof(*chandef));
  679. return 0;
  680. }
  681. static int qtnf_channel_switch(struct wiphy *wiphy, struct net_device *dev,
  682. struct cfg80211_csa_settings *params)
  683. {
  684. struct qtnf_wmac *mac = wiphy_priv(wiphy);
  685. struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
  686. int ret;
  687. pr_debug("%s: chan(%u) count(%u) radar(%u) block_tx(%u)\n", dev->name,
  688. params->chandef.chan->hw_value, params->count,
  689. params->radar_required, params->block_tx);
  690. switch (vif->wdev.iftype) {
  691. case NL80211_IFTYPE_AP:
  692. if (!(vif->bss_status & QTNF_STATE_AP_START)) {
  693. pr_warn("AP not started on %s\n", dev->name);
  694. return -ENOTCONN;
  695. }
  696. break;
  697. default:
  698. pr_err("unsupported vif type (%d) on %s\n",
  699. vif->wdev.iftype, dev->name);
  700. return -EOPNOTSUPP;
  701. }
  702. if (vif->vifid != 0) {
  703. if (!(mac->status & QTNF_MAC_CSA_ACTIVE))
  704. return -EOPNOTSUPP;
  705. if (!cfg80211_chandef_identical(&params->chandef,
  706. &mac->csa_chandef))
  707. return -EINVAL;
  708. return 0;
  709. }
  710. if (!cfg80211_chandef_valid(&params->chandef)) {
  711. pr_err("%s: invalid channel\n", dev->name);
  712. return -EINVAL;
  713. }
  714. if (cfg80211_chandef_identical(&params->chandef, &mac->chandef)) {
  715. pr_err("%s: switch request to the same channel\n", dev->name);
  716. return -EALREADY;
  717. }
  718. ret = qtnf_cmd_send_chan_switch(mac, params);
  719. if (ret)
  720. pr_warn("%s: failed to switch to channel (%u)\n",
  721. dev->name, params->chandef.chan->hw_value);
  722. return ret;
  723. }
  724. static struct cfg80211_ops qtn_cfg80211_ops = {
  725. .add_virtual_intf = qtnf_add_virtual_intf,
  726. .change_virtual_intf = qtnf_change_virtual_intf,
  727. .del_virtual_intf = qtnf_del_virtual_intf,
  728. .start_ap = qtnf_start_ap,
  729. .change_beacon = qtnf_change_beacon,
  730. .stop_ap = qtnf_stop_ap,
  731. .set_wiphy_params = qtnf_set_wiphy_params,
  732. .mgmt_frame_register = qtnf_mgmt_frame_register,
  733. .mgmt_tx = qtnf_mgmt_tx,
  734. .change_station = qtnf_change_station,
  735. .del_station = qtnf_del_station,
  736. .get_station = qtnf_get_station,
  737. .dump_station = qtnf_dump_station,
  738. .add_key = qtnf_add_key,
  739. .del_key = qtnf_del_key,
  740. .set_default_key = qtnf_set_default_key,
  741. .set_default_mgmt_key = qtnf_set_default_mgmt_key,
  742. .scan = qtnf_scan,
  743. .connect = qtnf_connect,
  744. .disconnect = qtnf_disconnect,
  745. .dump_survey = qtnf_dump_survey,
  746. .get_channel = qtnf_get_channel,
  747. .channel_switch = qtnf_channel_switch
  748. };
  749. static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
  750. struct regulatory_request *req)
  751. {
  752. struct qtnf_wmac *mac = wiphy_priv(wiphy_in);
  753. struct qtnf_bus *bus = mac->bus;
  754. struct wiphy *wiphy;
  755. unsigned int mac_idx;
  756. enum nl80211_band band;
  757. int ret;
  758. pr_debug("MAC%u: initiator=%d alpha=%c%c\n", mac->macid, req->initiator,
  759. req->alpha2[0], req->alpha2[1]);
  760. ret = qtnf_cmd_reg_notify(bus, req);
  761. if (ret) {
  762. if (ret != -EOPNOTSUPP && ret != -EALREADY)
  763. pr_err("failed to update reg domain to %c%c\n",
  764. req->alpha2[0], req->alpha2[1]);
  765. return;
  766. }
  767. for (mac_idx = 0; mac_idx < QTNF_MAX_MAC; ++mac_idx) {
  768. if (!(bus->hw_info.mac_bitmap & (1 << mac_idx)))
  769. continue;
  770. mac = bus->mac[mac_idx];
  771. wiphy = priv_to_wiphy(mac);
  772. for (band = 0; band < NUM_NL80211_BANDS; ++band) {
  773. if (!wiphy->bands[band])
  774. continue;
  775. ret = qtnf_cmd_get_mac_chan_info(mac,
  776. wiphy->bands[band]);
  777. if (ret)
  778. pr_err("failed to get chan info for mac %u band %u\n",
  779. mac_idx, band);
  780. }
  781. }
  782. }
  783. void qtnf_band_setup_htvht_caps(struct qtnf_mac_info *macinfo,
  784. struct ieee80211_supported_band *band)
  785. {
  786. struct ieee80211_sta_ht_cap *ht_cap;
  787. struct ieee80211_sta_vht_cap *vht_cap;
  788. ht_cap = &band->ht_cap;
  789. ht_cap->ht_supported = true;
  790. memcpy(&ht_cap->cap, &macinfo->ht_cap.cap_info,
  791. sizeof(u16));
  792. ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
  793. ht_cap->ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
  794. memcpy(&ht_cap->mcs, &macinfo->ht_cap.mcs,
  795. sizeof(ht_cap->mcs));
  796. if (macinfo->phymode_cap & QLINK_PHYMODE_AC) {
  797. vht_cap = &band->vht_cap;
  798. vht_cap->vht_supported = true;
  799. memcpy(&vht_cap->cap,
  800. &macinfo->vht_cap.vht_cap_info, sizeof(u32));
  801. /* Update MCS support for VHT */
  802. memcpy(&vht_cap->vht_mcs,
  803. &macinfo->vht_cap.supp_mcs,
  804. sizeof(struct ieee80211_vht_mcs_info));
  805. }
  806. }
  807. struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus)
  808. {
  809. struct wiphy *wiphy;
  810. wiphy = wiphy_new(&qtn_cfg80211_ops, sizeof(struct qtnf_wmac));
  811. if (!wiphy)
  812. return NULL;
  813. set_wiphy_dev(wiphy, bus->dev);
  814. return wiphy;
  815. }
  816. static int qtnf_wiphy_setup_if_comb(struct wiphy *wiphy,
  817. struct ieee80211_iface_combination *if_comb,
  818. const struct qtnf_mac_info *mac_info)
  819. {
  820. size_t max_interfaces = 0;
  821. u16 interface_modes = 0;
  822. size_t i;
  823. if (unlikely(!mac_info->limits || !mac_info->n_limits))
  824. return -ENOENT;
  825. if_comb->limits = mac_info->limits;
  826. if_comb->n_limits = mac_info->n_limits;
  827. for (i = 0; i < mac_info->n_limits; i++) {
  828. max_interfaces += mac_info->limits[i].max;
  829. interface_modes |= mac_info->limits[i].types;
  830. }
  831. if_comb->num_different_channels = 1;
  832. if_comb->beacon_int_infra_match = true;
  833. if_comb->max_interfaces = max_interfaces;
  834. if_comb->radar_detect_widths = mac_info->radar_detect_widths;
  835. wiphy->interface_modes = interface_modes;
  836. return 0;
  837. }
  838. int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
  839. {
  840. struct wiphy *wiphy = priv_to_wiphy(mac);
  841. struct ieee80211_iface_combination *iface_comb = NULL;
  842. int ret;
  843. if (!wiphy) {
  844. pr_err("invalid wiphy pointer\n");
  845. return -EFAULT;
  846. }
  847. iface_comb = kzalloc(sizeof(*iface_comb), GFP_KERNEL);
  848. if (!iface_comb)
  849. return -ENOMEM;
  850. ret = qtnf_wiphy_setup_if_comb(wiphy, iface_comb, &mac->macinfo);
  851. if (ret)
  852. goto out;
  853. pr_info("MAC%u: phymode=%#x radar=%#x\n", mac->macid,
  854. mac->macinfo.phymode_cap, mac->macinfo.radar_detect_widths);
  855. wiphy->frag_threshold = mac->macinfo.frag_thr;
  856. wiphy->rts_threshold = mac->macinfo.rts_thr;
  857. wiphy->retry_short = mac->macinfo.sretry_limit;
  858. wiphy->retry_long = mac->macinfo.lretry_limit;
  859. wiphy->coverage_class = mac->macinfo.coverage_class;
  860. wiphy->max_scan_ssids = QTNF_MAX_SSID_LIST_LENGTH;
  861. wiphy->max_scan_ie_len = QTNF_MAX_VSIE_LEN;
  862. wiphy->mgmt_stypes = qtnf_mgmt_stypes;
  863. wiphy->max_remain_on_channel_duration = 5000;
  864. wiphy->iface_combinations = iface_comb;
  865. wiphy->n_iface_combinations = 1;
  866. wiphy->max_num_csa_counters = 2;
  867. /* Initialize cipher suits */
  868. wiphy->cipher_suites = qtnf_cipher_suites;
  869. wiphy->n_cipher_suites = ARRAY_SIZE(qtnf_cipher_suites);
  870. wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
  871. wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
  872. WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
  873. WIPHY_FLAG_AP_UAPSD |
  874. WIPHY_FLAG_HAS_CHANNEL_SWITCH;
  875. wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
  876. NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2;
  877. wiphy->available_antennas_tx = mac->macinfo.num_tx_chain;
  878. wiphy->available_antennas_rx = mac->macinfo.num_rx_chain;
  879. wiphy->max_ap_assoc_sta = mac->macinfo.max_ap_assoc_sta;
  880. ether_addr_copy(wiphy->perm_addr, mac->macaddr);
  881. if (hw_info->hw_capab & QLINK_HW_SUPPORTS_REG_UPDATE) {
  882. wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
  883. REGULATORY_CUSTOM_REG;
  884. wiphy->reg_notifier = qtnf_cfg80211_reg_notifier;
  885. wiphy_apply_custom_regulatory(wiphy, hw_info->rd);
  886. } else {
  887. wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;
  888. }
  889. ret = wiphy_register(wiphy);
  890. if (ret < 0)
  891. goto out;
  892. if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
  893. ret = regulatory_set_wiphy_regd(wiphy, hw_info->rd);
  894. else if (isalpha(hw_info->rd->alpha2[0]) &&
  895. isalpha(hw_info->rd->alpha2[1]))
  896. ret = regulatory_hint(wiphy, hw_info->rd->alpha2);
  897. out:
  898. if (ret) {
  899. kfree(iface_comb);
  900. return ret;
  901. }
  902. return 0;
  903. }
  904. void qtnf_netdev_updown(struct net_device *ndev, bool up)
  905. {
  906. struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
  907. if (qtnf_cmd_send_updown_intf(vif, up))
  908. pr_err("failed to send up/down command to FW\n");
  909. }
  910. void qtnf_virtual_intf_cleanup(struct net_device *ndev)
  911. {
  912. struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
  913. struct qtnf_wmac *mac = wiphy_priv(vif->wdev.wiphy);
  914. if (vif->wdev.iftype == NL80211_IFTYPE_STATION) {
  915. switch (vif->sta_state) {
  916. case QTNF_STA_DISCONNECTED:
  917. break;
  918. case QTNF_STA_CONNECTING:
  919. cfg80211_connect_result(vif->netdev,
  920. vif->bss_cfg.bssid, NULL, 0,
  921. NULL, 0,
  922. WLAN_STATUS_UNSPECIFIED_FAILURE,
  923. GFP_KERNEL);
  924. qtnf_disconnect(vif->wdev.wiphy, ndev,
  925. WLAN_REASON_DEAUTH_LEAVING);
  926. break;
  927. case QTNF_STA_CONNECTED:
  928. cfg80211_disconnected(vif->netdev,
  929. WLAN_REASON_DEAUTH_LEAVING,
  930. NULL, 0, 1, GFP_KERNEL);
  931. qtnf_disconnect(vif->wdev.wiphy, ndev,
  932. WLAN_REASON_DEAUTH_LEAVING);
  933. break;
  934. }
  935. vif->sta_state = QTNF_STA_DISCONNECTED;
  936. }
  937. qtnf_scan_done(mac, true);
  938. }
  939. void qtnf_cfg80211_vif_reset(struct qtnf_vif *vif)
  940. {
  941. if (vif->wdev.iftype == NL80211_IFTYPE_STATION) {
  942. switch (vif->sta_state) {
  943. case QTNF_STA_CONNECTING:
  944. cfg80211_connect_result(vif->netdev,
  945. vif->bss_cfg.bssid, NULL, 0,
  946. NULL, 0,
  947. WLAN_STATUS_UNSPECIFIED_FAILURE,
  948. GFP_KERNEL);
  949. break;
  950. case QTNF_STA_CONNECTED:
  951. cfg80211_disconnected(vif->netdev,
  952. WLAN_REASON_DEAUTH_LEAVING,
  953. NULL, 0, 1, GFP_KERNEL);
  954. break;
  955. case QTNF_STA_DISCONNECTED:
  956. break;
  957. }
  958. }
  959. cfg80211_shutdown_all_interfaces(vif->wdev.wiphy);
  960. vif->sta_state = QTNF_STA_DISCONNECTED;
  961. }
  962. void qtnf_band_init_rates(struct ieee80211_supported_band *band)
  963. {
  964. switch (band->band) {
  965. case NL80211_BAND_2GHZ:
  966. band->bitrates = qtnf_rates_2g;
  967. band->n_bitrates = ARRAY_SIZE(qtnf_rates_2g);
  968. break;
  969. case NL80211_BAND_5GHZ:
  970. band->bitrates = qtnf_rates_5g;
  971. band->n_bitrates = ARRAY_SIZE(qtnf_rates_5g);
  972. break;
  973. default:
  974. band->bitrates = NULL;
  975. band->n_bitrates = 0;
  976. break;
  977. }
  978. }