cfg80211.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /*
  2. * Copyright (c) 2012 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/netdevice.h>
  18. #include <linux/sched.h>
  19. #include <linux/etherdevice.h>
  20. #include <linux/wireless.h>
  21. #include <linux/ieee80211.h>
  22. #include <linux/slab.h>
  23. #include <linux/version.h>
  24. #include <net/cfg80211.h>
  25. #include "wil6210.h"
  26. #include "wmi.h"
  27. #define CHAN60G(_channel, _flags) { \
  28. .band = IEEE80211_BAND_60GHZ, \
  29. .center_freq = 56160 + (2160 * (_channel)), \
  30. .hw_value = (_channel), \
  31. .flags = (_flags), \
  32. .max_antenna_gain = 0, \
  33. .max_power = 40, \
  34. }
  35. static struct ieee80211_channel wil_60ghz_channels[] = {
  36. CHAN60G(1, 0),
  37. CHAN60G(2, 0),
  38. CHAN60G(3, 0),
  39. /* channel 4 not supported yet */
  40. };
  41. static struct ieee80211_supported_band wil_band_60ghz = {
  42. .channels = wil_60ghz_channels,
  43. .n_channels = ARRAY_SIZE(wil_60ghz_channels),
  44. .ht_cap = {
  45. .ht_supported = true,
  46. .cap = 0, /* TODO */
  47. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, /* TODO */
  48. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_8, /* TODO */
  49. .mcs = {
  50. /* MCS 1..12 - SC PHY */
  51. .rx_mask = {0xfe, 0x1f}, /* 1..12 */
  52. .tx_params = IEEE80211_HT_MCS_TX_DEFINED, /* TODO */
  53. },
  54. },
  55. };
  56. static const struct ieee80211_txrx_stypes
  57. wil_mgmt_stypes[NUM_NL80211_IFTYPES] = {
  58. [NL80211_IFTYPE_STATION] = {
  59. .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  60. BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
  61. .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  62. BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
  63. },
  64. [NL80211_IFTYPE_AP] = {
  65. .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  66. BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
  67. .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  68. BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
  69. },
  70. [NL80211_IFTYPE_P2P_CLIENT] = {
  71. .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  72. BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
  73. .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  74. BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
  75. },
  76. [NL80211_IFTYPE_P2P_GO] = {
  77. .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  78. BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
  79. .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
  80. BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
  81. },
  82. };
  83. static const u32 wil_cipher_suites[] = {
  84. WLAN_CIPHER_SUITE_GCMP,
  85. };
  86. int wil_iftype_nl2wmi(enum nl80211_iftype type)
  87. {
  88. static const struct {
  89. enum nl80211_iftype nl;
  90. enum wmi_network_type wmi;
  91. } __nl2wmi[] = {
  92. {NL80211_IFTYPE_ADHOC, WMI_NETTYPE_ADHOC},
  93. {NL80211_IFTYPE_STATION, WMI_NETTYPE_INFRA},
  94. {NL80211_IFTYPE_AP, WMI_NETTYPE_AP},
  95. {NL80211_IFTYPE_P2P_CLIENT, WMI_NETTYPE_P2P},
  96. {NL80211_IFTYPE_P2P_GO, WMI_NETTYPE_P2P},
  97. {NL80211_IFTYPE_MONITOR, WMI_NETTYPE_ADHOC}, /* FIXME */
  98. };
  99. uint i;
  100. for (i = 0; i < ARRAY_SIZE(__nl2wmi); i++) {
  101. if (__nl2wmi[i].nl == type)
  102. return __nl2wmi[i].wmi;
  103. }
  104. return -EOPNOTSUPP;
  105. }
  106. static int wil_cfg80211_get_station(struct wiphy *wiphy,
  107. struct net_device *ndev,
  108. u8 *mac, struct station_info *sinfo)
  109. {
  110. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  111. int rc;
  112. struct wmi_notify_req_cmd cmd = {
  113. .cid = 0,
  114. .interval_usec = 0,
  115. };
  116. if (memcmp(mac, wil->dst_addr[0], ETH_ALEN))
  117. return -ENOENT;
  118. /* WMI_NOTIFY_REQ_DONE_EVENTID handler fills wil->stats.bf_mcs */
  119. rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd),
  120. WMI_NOTIFY_REQ_DONE_EVENTID, NULL, 0, 20);
  121. if (rc)
  122. return rc;
  123. sinfo->generation = wil->sinfo_gen;
  124. sinfo->filled |= STATION_INFO_TX_BITRATE;
  125. sinfo->txrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
  126. sinfo->txrate.mcs = wil->stats.bf_mcs;
  127. sinfo->filled |= STATION_INFO_RX_BITRATE;
  128. sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
  129. sinfo->rxrate.mcs = wil->stats.last_mcs_rx;
  130. if (test_bit(wil_status_fwconnected, &wil->status)) {
  131. sinfo->filled |= STATION_INFO_SIGNAL;
  132. sinfo->signal = 12; /* TODO: provide real value */
  133. }
  134. return 0;
  135. }
  136. static int wil_cfg80211_change_iface(struct wiphy *wiphy,
  137. struct net_device *ndev,
  138. enum nl80211_iftype type, u32 *flags,
  139. struct vif_params *params)
  140. {
  141. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  142. struct wireless_dev *wdev = wil->wdev;
  143. switch (type) {
  144. case NL80211_IFTYPE_STATION:
  145. case NL80211_IFTYPE_AP:
  146. case NL80211_IFTYPE_P2P_CLIENT:
  147. case NL80211_IFTYPE_P2P_GO:
  148. break;
  149. case NL80211_IFTYPE_MONITOR:
  150. if (flags)
  151. wil->monitor_flags = *flags;
  152. else
  153. wil->monitor_flags = 0;
  154. break;
  155. default:
  156. return -EOPNOTSUPP;
  157. }
  158. wdev->iftype = type;
  159. return 0;
  160. }
  161. static int wil_cfg80211_scan(struct wiphy *wiphy,
  162. struct cfg80211_scan_request *request)
  163. {
  164. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  165. struct wireless_dev *wdev = wil->wdev;
  166. struct {
  167. struct wmi_start_scan_cmd cmd;
  168. u16 chnl[4];
  169. } __packed cmd;
  170. uint i, n;
  171. if (wil->scan_request) {
  172. wil_err(wil, "Already scanning\n");
  173. return -EAGAIN;
  174. }
  175. /* check we are client side */
  176. switch (wdev->iftype) {
  177. case NL80211_IFTYPE_STATION:
  178. case NL80211_IFTYPE_P2P_CLIENT:
  179. break;
  180. default:
  181. return -EOPNOTSUPP;
  182. }
  183. /* FW don't support scan after connection attempt */
  184. if (test_bit(wil_status_dontscan, &wil->status)) {
  185. wil_err(wil, "Scan after connect attempt not supported\n");
  186. return -EBUSY;
  187. }
  188. wil->scan_request = request;
  189. memset(&cmd, 0, sizeof(cmd));
  190. cmd.cmd.num_channels = 0;
  191. n = min(request->n_channels, 4U);
  192. for (i = 0; i < n; i++) {
  193. int ch = request->channels[i]->hw_value;
  194. if (ch == 0) {
  195. wil_err(wil,
  196. "Scan requested for unknown frequency %dMhz\n",
  197. request->channels[i]->center_freq);
  198. continue;
  199. }
  200. /* 0-based channel indexes */
  201. cmd.cmd.channel_list[cmd.cmd.num_channels++].channel = ch - 1;
  202. wil_dbg_misc(wil, "Scan for ch %d : %d MHz\n", ch,
  203. request->channels[i]->center_freq);
  204. }
  205. return wmi_send(wil, WMI_START_SCAN_CMDID, &cmd, sizeof(cmd.cmd) +
  206. cmd.cmd.num_channels * sizeof(cmd.cmd.channel_list[0]));
  207. }
  208. static int wil_cfg80211_connect(struct wiphy *wiphy,
  209. struct net_device *ndev,
  210. struct cfg80211_connect_params *sme)
  211. {
  212. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  213. struct cfg80211_bss *bss;
  214. struct wmi_connect_cmd conn;
  215. const u8 *ssid_eid;
  216. const u8 *rsn_eid;
  217. int ch;
  218. int rc = 0;
  219. bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid,
  220. sme->ssid, sme->ssid_len,
  221. WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
  222. if (!bss) {
  223. wil_err(wil, "Unable to find BSS\n");
  224. return -ENOENT;
  225. }
  226. ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
  227. if (!ssid_eid) {
  228. wil_err(wil, "No SSID\n");
  229. rc = -ENOENT;
  230. goto out;
  231. }
  232. rsn_eid = sme->ie ?
  233. cfg80211_find_ie(WLAN_EID_RSN, sme->ie, sme->ie_len) :
  234. NULL;
  235. if (rsn_eid) {
  236. if (sme->ie_len > WMI_MAX_IE_LEN) {
  237. rc = -ERANGE;
  238. wil_err(wil, "IE too large (%td bytes)\n",
  239. sme->ie_len);
  240. goto out;
  241. }
  242. /*
  243. * For secure assoc, send:
  244. * (1) WMI_DELETE_CIPHER_KEY_CMD
  245. * (2) WMI_SET_APPIE_CMD
  246. */
  247. rc = wmi_del_cipher_key(wil, 0, bss->bssid);
  248. if (rc) {
  249. wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD failed\n");
  250. goto out;
  251. }
  252. /* WMI_SET_APPIE_CMD */
  253. rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_REQ, sme->ie_len, sme->ie);
  254. if (rc) {
  255. wil_err(wil, "WMI_SET_APPIE_CMD failed\n");
  256. goto out;
  257. }
  258. }
  259. /* WMI_CONNECT_CMD */
  260. memset(&conn, 0, sizeof(conn));
  261. switch (bss->capability & 0x03) {
  262. case WLAN_CAPABILITY_DMG_TYPE_AP:
  263. conn.network_type = WMI_NETTYPE_INFRA;
  264. break;
  265. case WLAN_CAPABILITY_DMG_TYPE_PBSS:
  266. conn.network_type = WMI_NETTYPE_P2P;
  267. break;
  268. default:
  269. wil_err(wil, "Unsupported BSS type, capability= 0x%04x\n",
  270. bss->capability);
  271. goto out;
  272. }
  273. if (rsn_eid) {
  274. conn.dot11_auth_mode = WMI_AUTH11_SHARED;
  275. conn.auth_mode = WMI_AUTH_WPA2_PSK;
  276. conn.pairwise_crypto_type = WMI_CRYPT_AES_GCMP;
  277. conn.pairwise_crypto_len = 16;
  278. } else {
  279. conn.dot11_auth_mode = WMI_AUTH11_OPEN;
  280. conn.auth_mode = WMI_AUTH_NONE;
  281. }
  282. conn.ssid_len = min_t(u8, ssid_eid[1], 32);
  283. memcpy(conn.ssid, ssid_eid+2, conn.ssid_len);
  284. ch = bss->channel->hw_value;
  285. if (ch == 0) {
  286. wil_err(wil, "BSS at unknown frequency %dMhz\n",
  287. bss->channel->center_freq);
  288. rc = -EOPNOTSUPP;
  289. goto out;
  290. }
  291. conn.channel = ch - 1;
  292. memcpy(conn.bssid, bss->bssid, 6);
  293. memcpy(conn.dst_mac, bss->bssid, 6);
  294. /*
  295. * FW don't support scan after connection attempt
  296. */
  297. set_bit(wil_status_dontscan, &wil->status);
  298. rc = wmi_send(wil, WMI_CONNECT_CMDID, &conn, sizeof(conn));
  299. if (rc == 0) {
  300. /* Connect can take lots of time */
  301. mod_timer(&wil->connect_timer,
  302. jiffies + msecs_to_jiffies(2000));
  303. }
  304. out:
  305. cfg80211_put_bss(wiphy, bss);
  306. return rc;
  307. }
  308. static int wil_cfg80211_disconnect(struct wiphy *wiphy,
  309. struct net_device *ndev,
  310. u16 reason_code)
  311. {
  312. int rc;
  313. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  314. rc = wmi_send(wil, WMI_DISCONNECT_CMDID, NULL, 0);
  315. return rc;
  316. }
  317. static int wil_cfg80211_set_channel(struct wiphy *wiphy,
  318. struct cfg80211_chan_def *chandef)
  319. {
  320. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  321. struct wireless_dev *wdev = wil->wdev;
  322. wdev->preset_chandef = *chandef;
  323. return 0;
  324. }
  325. static int wil_cfg80211_add_key(struct wiphy *wiphy,
  326. struct net_device *ndev,
  327. u8 key_index, bool pairwise,
  328. const u8 *mac_addr,
  329. struct key_params *params)
  330. {
  331. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  332. /* group key is not used */
  333. if (!pairwise)
  334. return 0;
  335. return wmi_add_cipher_key(wil, key_index, mac_addr,
  336. params->key_len, params->key);
  337. }
  338. static int wil_cfg80211_del_key(struct wiphy *wiphy,
  339. struct net_device *ndev,
  340. u8 key_index, bool pairwise,
  341. const u8 *mac_addr)
  342. {
  343. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  344. /* group key is not used */
  345. if (!pairwise)
  346. return 0;
  347. return wmi_del_cipher_key(wil, key_index, mac_addr);
  348. }
  349. /* Need to be present or wiphy_new() will WARN */
  350. static int wil_cfg80211_set_default_key(struct wiphy *wiphy,
  351. struct net_device *ndev,
  352. u8 key_index, bool unicast,
  353. bool multicast)
  354. {
  355. return 0;
  356. }
  357. static int wil_cfg80211_start_ap(struct wiphy *wiphy,
  358. struct net_device *ndev,
  359. struct cfg80211_ap_settings *info)
  360. {
  361. int rc = 0;
  362. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  363. struct wireless_dev *wdev = ndev->ieee80211_ptr;
  364. struct ieee80211_channel *channel = info->chandef.chan;
  365. struct cfg80211_beacon_data *bcon = &info->beacon;
  366. u8 wmi_nettype = wil_iftype_nl2wmi(wdev->iftype);
  367. if (!channel) {
  368. wil_err(wil, "AP: No channel???\n");
  369. return -EINVAL;
  370. }
  371. wil_dbg_misc(wil, "AP on Channel %d %d MHz, %s\n", channel->hw_value,
  372. channel->center_freq, info->privacy ? "secure" : "open");
  373. print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
  374. info->ssid, info->ssid_len);
  375. rc = wil_reset(wil);
  376. if (rc)
  377. return rc;
  378. rc = wmi_set_ssid(wil, info->ssid_len, info->ssid);
  379. if (rc)
  380. return rc;
  381. rc = wmi_set_channel(wil, channel->hw_value);
  382. if (rc)
  383. return rc;
  384. /* MAC address - pre-requisite for other commands */
  385. wmi_set_mac_address(wil, ndev->dev_addr);
  386. /* IE's */
  387. /* bcon 'head IE's are not relevant for 60g band */
  388. wmi_set_ie(wil, WMI_FRAME_BEACON, bcon->beacon_ies_len,
  389. bcon->beacon_ies);
  390. wmi_set_ie(wil, WMI_FRAME_PROBE_RESP, bcon->proberesp_ies_len,
  391. bcon->proberesp_ies);
  392. wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP, bcon->assocresp_ies_len,
  393. bcon->assocresp_ies);
  394. wil->secure_pcp = info->privacy;
  395. rc = wmi_set_bcon(wil, info->beacon_interval, wmi_nettype);
  396. if (rc)
  397. return rc;
  398. /* Rx VRING. After MAC and beacon */
  399. rc = wil_rx_init(wil);
  400. netif_carrier_on(ndev);
  401. return rc;
  402. }
  403. static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
  404. struct net_device *ndev)
  405. {
  406. int rc = 0;
  407. struct wil6210_priv *wil = wiphy_to_wil(wiphy);
  408. struct wireless_dev *wdev = ndev->ieee80211_ptr;
  409. u8 wmi_nettype = wil_iftype_nl2wmi(wdev->iftype);
  410. /* To stop beaconing, set BI to 0 */
  411. rc = wmi_set_bcon(wil, 0, wmi_nettype);
  412. return rc;
  413. }
  414. static struct cfg80211_ops wil_cfg80211_ops = {
  415. .scan = wil_cfg80211_scan,
  416. .connect = wil_cfg80211_connect,
  417. .disconnect = wil_cfg80211_disconnect,
  418. .change_virtual_intf = wil_cfg80211_change_iface,
  419. .get_station = wil_cfg80211_get_station,
  420. .set_monitor_channel = wil_cfg80211_set_channel,
  421. .add_key = wil_cfg80211_add_key,
  422. .del_key = wil_cfg80211_del_key,
  423. .set_default_key = wil_cfg80211_set_default_key,
  424. /* AP mode */
  425. .start_ap = wil_cfg80211_start_ap,
  426. .stop_ap = wil_cfg80211_stop_ap,
  427. };
  428. static void wil_wiphy_init(struct wiphy *wiphy)
  429. {
  430. /* TODO: set real value */
  431. wiphy->max_scan_ssids = 10;
  432. wiphy->max_num_pmkids = 0 /* TODO: */;
  433. wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
  434. BIT(NL80211_IFTYPE_AP) |
  435. BIT(NL80211_IFTYPE_MONITOR);
  436. /* TODO: enable P2P when integrated with supplicant:
  437. * BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO)
  438. */
  439. wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
  440. WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
  441. dev_warn(wiphy_dev(wiphy), "%s : flags = 0x%08x\n",
  442. __func__, wiphy->flags);
  443. wiphy->probe_resp_offload =
  444. NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
  445. NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
  446. NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
  447. wiphy->bands[IEEE80211_BAND_60GHZ] = &wil_band_60ghz;
  448. /* TODO: figure this out */
  449. wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
  450. wiphy->cipher_suites = wil_cipher_suites;
  451. wiphy->n_cipher_suites = ARRAY_SIZE(wil_cipher_suites);
  452. wiphy->mgmt_stypes = wil_mgmt_stypes;
  453. }
  454. struct wireless_dev *wil_cfg80211_init(struct device *dev)
  455. {
  456. int rc = 0;
  457. struct wireless_dev *wdev;
  458. wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
  459. if (!wdev)
  460. return ERR_PTR(-ENOMEM);
  461. wdev->wiphy = wiphy_new(&wil_cfg80211_ops,
  462. sizeof(struct wil6210_priv));
  463. if (!wdev->wiphy) {
  464. rc = -ENOMEM;
  465. goto out;
  466. }
  467. set_wiphy_dev(wdev->wiphy, dev);
  468. wil_wiphy_init(wdev->wiphy);
  469. rc = wiphy_register(wdev->wiphy);
  470. if (rc < 0)
  471. goto out_failed_reg;
  472. return wdev;
  473. out_failed_reg:
  474. wiphy_free(wdev->wiphy);
  475. out:
  476. kfree(wdev);
  477. return ERR_PTR(rc);
  478. }
  479. void wil_wdev_free(struct wil6210_priv *wil)
  480. {
  481. struct wireless_dev *wdev = wil_to_wdev(wil);
  482. if (!wdev)
  483. return;
  484. wiphy_unregister(wdev->wiphy);
  485. wiphy_free(wdev->wiphy);
  486. kfree(wdev);
  487. }