2 * Copyright (c) 2012-2016 Qualcomm Atheros, Inc.
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.
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.
17 #include <linux/etherdevice.h>
21 #define WIL_MAX_ROC_DURATION_MS 5000
23 #define CHAN60G(_channel, _flags) { \
24 .band = NL80211_BAND_60GHZ, \
25 .center_freq = 56160 + (2160 * (_channel)), \
26 .hw_value = (_channel), \
28 .max_antenna_gain = 0, \
32 static struct ieee80211_channel wil_60ghz_channels[] = {
36 /* channel 4 not supported yet */
39 static struct ieee80211_supported_band wil_band_60ghz = {
40 .channels = wil_60ghz_channels,
41 .n_channels = ARRAY_SIZE(wil_60ghz_channels),
45 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, /* TODO */
46 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_8, /* TODO */
48 /* MCS 1..12 - SC PHY */
49 .rx_mask = {0xfe, 0x1f}, /* 1..12 */
50 .tx_params = IEEE80211_HT_MCS_TX_DEFINED, /* TODO */
55 static const struct ieee80211_txrx_stypes
56 wil_mgmt_stypes[NUM_NL80211_IFTYPES] = {
57 [NL80211_IFTYPE_STATION] = {
58 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
59 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
60 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
61 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
63 [NL80211_IFTYPE_AP] = {
64 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
65 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
66 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
67 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
69 [NL80211_IFTYPE_P2P_CLIENT] = {
70 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
71 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
72 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
73 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
75 [NL80211_IFTYPE_P2P_GO] = {
76 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
77 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
78 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
79 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
81 [NL80211_IFTYPE_P2P_DEVICE] = {
82 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
83 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
84 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
85 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
89 static const u32 wil_cipher_suites[] = {
90 WLAN_CIPHER_SUITE_GCMP,
93 static const char * const key_usage_str[] = {
94 [WMI_KEY_USE_PAIRWISE] = "PTK",
95 [WMI_KEY_USE_RX_GROUP] = "RX_GTK",
96 [WMI_KEY_USE_TX_GROUP] = "TX_GTK",
99 int wil_iftype_nl2wmi(enum nl80211_iftype type)
101 static const struct {
102 enum nl80211_iftype nl;
103 enum wmi_network_type wmi;
105 {NL80211_IFTYPE_ADHOC, WMI_NETTYPE_ADHOC},
106 {NL80211_IFTYPE_STATION, WMI_NETTYPE_INFRA},
107 {NL80211_IFTYPE_AP, WMI_NETTYPE_AP},
108 {NL80211_IFTYPE_P2P_CLIENT, WMI_NETTYPE_P2P},
109 {NL80211_IFTYPE_P2P_GO, WMI_NETTYPE_P2P},
110 {NL80211_IFTYPE_MONITOR, WMI_NETTYPE_ADHOC}, /* FIXME */
114 for (i = 0; i < ARRAY_SIZE(__nl2wmi); i++) {
115 if (__nl2wmi[i].nl == type)
116 return __nl2wmi[i].wmi;
122 int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
123 struct station_info *sinfo)
125 struct wmi_notify_req_cmd cmd = {
130 struct wmi_cmd_hdr wmi;
131 struct wmi_notify_req_done_event evt;
133 struct wil_net_stats *stats = &wil->sta[cid].stats;
136 rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd),
137 WMI_NOTIFY_REQ_DONE_EVENTID, &reply, sizeof(reply), 20);
141 wil_dbg_wmi(wil, "Link status for CID %d: {\n"
142 " MCS %d TSF 0x%016llx\n"
143 " BF status 0x%08x SNR 0x%08x SQI %d%%\n"
144 " Tx Tpt %d goodput %d Rx goodput %d\n"
145 " Sectors(rx:tx) my %d:%d peer %d:%d\n""}\n",
146 cid, le16_to_cpu(reply.evt.bf_mcs),
147 le64_to_cpu(reply.evt.tsf), reply.evt.status,
148 le32_to_cpu(reply.evt.snr_val),
150 le32_to_cpu(reply.evt.tx_tpt),
151 le32_to_cpu(reply.evt.tx_goodput),
152 le32_to_cpu(reply.evt.rx_goodput),
153 le16_to_cpu(reply.evt.my_rx_sector),
154 le16_to_cpu(reply.evt.my_tx_sector),
155 le16_to_cpu(reply.evt.other_rx_sector),
156 le16_to_cpu(reply.evt.other_tx_sector));
158 sinfo->generation = wil->sinfo_gen;
160 sinfo->filled = BIT(NL80211_STA_INFO_RX_BYTES) |
161 BIT(NL80211_STA_INFO_TX_BYTES) |
162 BIT(NL80211_STA_INFO_RX_PACKETS) |
163 BIT(NL80211_STA_INFO_TX_PACKETS) |
164 BIT(NL80211_STA_INFO_RX_BITRATE) |
165 BIT(NL80211_STA_INFO_TX_BITRATE) |
166 BIT(NL80211_STA_INFO_RX_DROP_MISC) |
167 BIT(NL80211_STA_INFO_TX_FAILED);
169 sinfo->txrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
170 sinfo->txrate.mcs = le16_to_cpu(reply.evt.bf_mcs);
171 sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
172 sinfo->rxrate.mcs = stats->last_mcs_rx;
173 sinfo->rx_bytes = stats->rx_bytes;
174 sinfo->rx_packets = stats->rx_packets;
175 sinfo->rx_dropped_misc = stats->rx_dropped;
176 sinfo->tx_bytes = stats->tx_bytes;
177 sinfo->tx_packets = stats->tx_packets;
178 sinfo->tx_failed = stats->tx_errors;
180 if (test_bit(wil_status_fwconnected, wil->status)) {
181 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
182 sinfo->signal = reply.evt.sqi;
188 static int wil_cfg80211_get_station(struct wiphy *wiphy,
189 struct net_device *ndev,
190 const u8 *mac, struct station_info *sinfo)
192 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
195 int cid = wil_find_cid(wil, mac);
197 wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
201 rc = wil_cid_fill_sinfo(wil, cid, sinfo);
207 * Find @idx-th active STA for station dump.
209 static int wil_find_cid_by_idx(struct wil6210_priv *wil, int idx)
213 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
214 if (wil->sta[i].status == wil_sta_unused)
224 static int wil_cfg80211_dump_station(struct wiphy *wiphy,
225 struct net_device *dev, int idx,
226 u8 *mac, struct station_info *sinfo)
228 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
230 int cid = wil_find_cid_by_idx(wil, idx);
235 ether_addr_copy(mac, wil->sta[cid].addr);
236 wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
238 rc = wil_cid_fill_sinfo(wil, cid, sinfo);
243 static struct wireless_dev *
244 wil_cfg80211_add_iface(struct wiphy *wiphy, const char *name,
245 unsigned char name_assign_type,
246 enum nl80211_iftype type,
247 u32 *flags, struct vif_params *params)
249 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
250 struct net_device *ndev = wil_to_ndev(wil);
251 struct wireless_dev *p2p_wdev;
253 wil_dbg_misc(wil, "%s()\n", __func__);
255 if (type != NL80211_IFTYPE_P2P_DEVICE) {
256 wil_err(wil, "%s: unsupported iftype %d\n", __func__, type);
257 return ERR_PTR(-EINVAL);
261 wil_err(wil, "%s: P2P_DEVICE interface already created\n",
263 return ERR_PTR(-EINVAL);
266 p2p_wdev = kzalloc(sizeof(*p2p_wdev), GFP_KERNEL);
268 return ERR_PTR(-ENOMEM);
270 p2p_wdev->iftype = type;
271 p2p_wdev->wiphy = wiphy;
272 /* use our primary ethernet address */
273 ether_addr_copy(p2p_wdev->address, ndev->perm_addr);
275 wil->p2p_wdev = p2p_wdev;
280 static int wil_cfg80211_del_iface(struct wiphy *wiphy,
281 struct wireless_dev *wdev)
283 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
285 wil_dbg_misc(wil, "%s()\n", __func__);
287 if (wdev != wil->p2p_wdev) {
288 wil_err(wil, "%s: delete of incorrect interface 0x%p\n",
293 wil_p2p_wdev_free(wil);
298 static int wil_cfg80211_change_iface(struct wiphy *wiphy,
299 struct net_device *ndev,
300 enum nl80211_iftype type, u32 *flags,
301 struct vif_params *params)
303 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
304 struct wireless_dev *wdev = wil_to_wdev(wil);
307 wil_dbg_misc(wil, "%s() type=%d\n", __func__, type);
309 if (netif_running(wil_to_ndev(wil)) && !wil_is_recovery_blocked(wil)) {
310 wil_dbg_misc(wil, "interface is up. resetting...\n");
311 mutex_lock(&wil->mutex);
314 mutex_unlock(&wil->mutex);
321 case NL80211_IFTYPE_STATION:
322 case NL80211_IFTYPE_AP:
323 case NL80211_IFTYPE_P2P_CLIENT:
324 case NL80211_IFTYPE_P2P_GO:
326 case NL80211_IFTYPE_MONITOR:
328 wil->monitor_flags = *flags;
330 wil->monitor_flags = 0;
342 static int wil_cfg80211_scan(struct wiphy *wiphy,
343 struct cfg80211_scan_request *request)
345 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
346 struct wireless_dev *wdev = request->wdev;
348 struct wmi_start_scan_cmd cmd;
354 wil_dbg_misc(wil, "%s(), wdev=0x%p iftype=%d\n",
355 __func__, wdev, wdev->iftype);
357 if (wil->scan_request) {
358 wil_err(wil, "Already scanning\n");
362 /* check we are client side */
363 switch (wdev->iftype) {
364 case NL80211_IFTYPE_STATION:
365 case NL80211_IFTYPE_P2P_CLIENT:
366 case NL80211_IFTYPE_P2P_DEVICE:
372 /* FW don't support scan after connection attempt */
373 if (test_bit(wil_status_dontscan, wil->status)) {
374 wil_err(wil, "Can't scan now\n");
378 /* social scan on P2P_DEVICE is handled as p2p search */
379 if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE &&
380 wil_p2p_is_social_scan(request)) {
381 wil->scan_request = request;
382 wil->radio_wdev = wdev;
383 rc = wil_p2p_search(wil, request);
385 wil->radio_wdev = wil_to_wdev(wil);
386 wil->scan_request = NULL;
391 (void)wil_p2p_stop_discovery(wil);
393 wil_dbg_misc(wil, "Start scan_request 0x%p\n", request);
394 wil_dbg_misc(wil, "SSID count: %d", request->n_ssids);
396 for (i = 0; i < request->n_ssids; i++) {
397 wil_dbg_misc(wil, "SSID[%d]", i);
398 print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
399 request->ssids[i].ssid,
400 request->ssids[i].ssid_len);
403 if (request->n_ssids)
404 rc = wmi_set_ssid(wil, request->ssids[0].ssid_len,
405 request->ssids[0].ssid);
407 rc = wmi_set_ssid(wil, 0, NULL);
410 wil_err(wil, "set SSID for scan request failed: %d\n", rc);
414 wil->scan_request = request;
415 mod_timer(&wil->scan_timer, jiffies + WIL6210_SCAN_TO);
417 memset(&cmd, 0, sizeof(cmd));
418 cmd.cmd.scan_type = WMI_ACTIVE_SCAN;
419 cmd.cmd.num_channels = 0;
420 n = min(request->n_channels, 4U);
421 for (i = 0; i < n; i++) {
422 int ch = request->channels[i]->hw_value;
426 "Scan requested for unknown frequency %dMhz\n",
427 request->channels[i]->center_freq);
430 /* 0-based channel indexes */
431 cmd.cmd.channel_list[cmd.cmd.num_channels++].channel = ch - 1;
432 wil_dbg_misc(wil, "Scan for ch %d : %d MHz\n", ch,
433 request->channels[i]->center_freq);
437 print_hex_dump_bytes("Scan IE ", DUMP_PREFIX_OFFSET,
438 request->ie, request->ie_len);
440 wil_dbg_misc(wil, "Scan has no IE's\n");
442 rc = wmi_set_ie(wil, WMI_FRAME_PROBE_REQ, request->ie_len, request->ie);
446 if (wil->discovery_mode && cmd.cmd.scan_type == WMI_ACTIVE_SCAN) {
447 cmd.cmd.discovery_mode = 1;
448 wil_dbg_misc(wil, "active scan with discovery_mode=1\n");
451 wil->radio_wdev = wdev;
452 rc = wmi_send(wil, WMI_START_SCAN_CMDID, &cmd, sizeof(cmd.cmd) +
453 cmd.cmd.num_channels * sizeof(cmd.cmd.channel_list[0]));
457 del_timer_sync(&wil->scan_timer);
458 wil->radio_wdev = wil_to_wdev(wil);
459 wil->scan_request = NULL;
465 static void wil_print_crypto(struct wil6210_priv *wil,
466 struct cfg80211_crypto_settings *c)
470 wil_dbg_misc(wil, "WPA versions: 0x%08x cipher group 0x%08x\n",
471 c->wpa_versions, c->cipher_group);
472 wil_dbg_misc(wil, "Pairwise ciphers [%d] {\n", c->n_ciphers_pairwise);
473 n = min_t(int, c->n_ciphers_pairwise, ARRAY_SIZE(c->ciphers_pairwise));
474 for (i = 0; i < n; i++)
475 wil_dbg_misc(wil, " [%d] = 0x%08x\n", i,
476 c->ciphers_pairwise[i]);
477 wil_dbg_misc(wil, "}\n");
478 wil_dbg_misc(wil, "AKM suites [%d] {\n", c->n_akm_suites);
479 n = min_t(int, c->n_akm_suites, ARRAY_SIZE(c->akm_suites));
480 for (i = 0; i < n; i++)
481 wil_dbg_misc(wil, " [%d] = 0x%08x\n", i,
483 wil_dbg_misc(wil, "}\n");
484 wil_dbg_misc(wil, "Control port : %d, eth_type 0x%04x no_encrypt %d\n",
485 c->control_port, be16_to_cpu(c->control_port_ethertype),
486 c->control_port_no_encrypt);
489 static void wil_print_connect_params(struct wil6210_priv *wil,
490 struct cfg80211_connect_params *sme)
492 wil_info(wil, "Connecting to:\n");
494 wil_info(wil, " Channel: %d freq %d\n",
495 sme->channel->hw_value, sme->channel->center_freq);
498 wil_info(wil, " BSSID: %pM\n", sme->bssid);
500 print_hex_dump(KERN_INFO, " SSID: ", DUMP_PREFIX_OFFSET,
501 16, 1, sme->ssid, sme->ssid_len, true);
502 wil_info(wil, " Privacy: %s\n", sme->privacy ? "secure" : "open");
503 wil_info(wil, " PBSS: %d\n", sme->pbss);
504 wil_print_crypto(wil, &sme->crypto);
507 static int wil_cfg80211_connect(struct wiphy *wiphy,
508 struct net_device *ndev,
509 struct cfg80211_connect_params *sme)
511 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
512 struct cfg80211_bss *bss;
513 struct wmi_connect_cmd conn;
518 enum ieee80211_bss_type bss_type = IEEE80211_BSS_TYPE_ESS;
520 wil_dbg_misc(wil, "%s()\n", __func__);
521 wil_print_connect_params(wil, sme);
523 if (test_bit(wil_status_fwconnecting, wil->status) ||
524 test_bit(wil_status_fwconnected, wil->status))
527 if (sme->ie_len > WMI_MAX_IE_LEN) {
528 wil_err(wil, "IE too large (%td bytes)\n", sme->ie_len);
533 cfg80211_find_ie(WLAN_EID_RSN, sme->ie, sme->ie_len) :
535 if (sme->privacy && !rsn_eid)
536 wil_info(wil, "WSC connection\n");
539 bss_type = IEEE80211_BSS_TYPE_PBSS;
541 bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid,
542 sme->ssid, sme->ssid_len,
543 bss_type, IEEE80211_PRIVACY_ANY);
545 wil_err(wil, "Unable to find BSS\n");
549 ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
551 wil_err(wil, "No SSID\n");
555 wil->privacy = sme->privacy;
558 /* For secure assoc, remove old keys */
559 rc = wmi_del_cipher_key(wil, 0, bss->bssid,
560 WMI_KEY_USE_PAIRWISE);
562 wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD(PTK) failed\n");
565 rc = wmi_del_cipher_key(wil, 0, bss->bssid,
566 WMI_KEY_USE_RX_GROUP);
568 wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD(GTK) failed\n");
573 /* WMI_SET_APPIE_CMD. ie may contain rsn info as well as other info
574 * elements. Send it also in case it's empty, to erase previously set
577 rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_REQ, sme->ie_len, sme->ie);
581 /* WMI_CONNECT_CMD */
582 memset(&conn, 0, sizeof(conn));
583 switch (bss->capability & WLAN_CAPABILITY_DMG_TYPE_MASK) {
584 case WLAN_CAPABILITY_DMG_TYPE_AP:
585 conn.network_type = WMI_NETTYPE_INFRA;
587 case WLAN_CAPABILITY_DMG_TYPE_PBSS:
588 conn.network_type = WMI_NETTYPE_P2P;
591 wil_err(wil, "Unsupported BSS type, capability= 0x%04x\n",
596 if (rsn_eid) { /* regular secure connection */
597 conn.dot11_auth_mode = WMI_AUTH11_SHARED;
598 conn.auth_mode = WMI_AUTH_WPA2_PSK;
599 conn.pairwise_crypto_type = WMI_CRYPT_AES_GCMP;
600 conn.pairwise_crypto_len = 16;
601 conn.group_crypto_type = WMI_CRYPT_AES_GCMP;
602 conn.group_crypto_len = 16;
604 conn.dot11_auth_mode = WMI_AUTH11_WSC;
605 conn.auth_mode = WMI_AUTH_NONE;
607 } else { /* insecure connection */
608 conn.dot11_auth_mode = WMI_AUTH11_OPEN;
609 conn.auth_mode = WMI_AUTH_NONE;
612 conn.ssid_len = min_t(u8, ssid_eid[1], 32);
613 memcpy(conn.ssid, ssid_eid+2, conn.ssid_len);
615 ch = bss->channel->hw_value;
617 wil_err(wil, "BSS at unknown frequency %dMhz\n",
618 bss->channel->center_freq);
622 conn.channel = ch - 1;
624 ether_addr_copy(conn.bssid, bss->bssid);
625 ether_addr_copy(conn.dst_mac, bss->bssid);
627 set_bit(wil_status_fwconnecting, wil->status);
629 rc = wmi_send(wil, WMI_CONNECT_CMDID, &conn, sizeof(conn));
631 netif_carrier_on(ndev);
632 /* Connect can take lots of time */
633 mod_timer(&wil->connect_timer,
634 jiffies + msecs_to_jiffies(2000));
636 clear_bit(wil_status_fwconnecting, wil->status);
640 cfg80211_put_bss(wiphy, bss);
645 static int wil_cfg80211_disconnect(struct wiphy *wiphy,
646 struct net_device *ndev,
650 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
652 wil_dbg_misc(wil, "%s(reason=%d)\n", __func__, reason_code);
654 if (!(test_bit(wil_status_fwconnecting, wil->status) ||
655 test_bit(wil_status_fwconnected, wil->status))) {
656 wil_err(wil, "%s: Disconnect was called while disconnected\n",
661 rc = wmi_call(wil, WMI_DISCONNECT_CMDID, NULL, 0,
662 WMI_DISCONNECT_EVENTID, NULL, 0,
663 WIL6210_DISCONNECT_TO_MS);
665 wil_err(wil, "%s: disconnect error %d\n", __func__, rc);
670 int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
671 struct cfg80211_mgmt_tx_params *params,
674 const u8 *buf = params->buf;
675 size_t len = params->len;
676 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
678 bool tx_status = false;
679 struct ieee80211_mgmt *mgmt_frame = (void *)buf;
680 struct wmi_sw_tx_req_cmd *cmd;
682 struct wmi_cmd_hdr wmi;
683 struct wmi_sw_tx_complete_event evt;
686 /* Note, currently we do not support the "wait" parameter, user-space
687 * must call remain_on_channel before mgmt_tx or listen on a channel
688 * another way (AP/PCP or connected station)
689 * in addition we need to check if specified "chan" argument is
690 * different from currently "listened" channel and fail if it is.
693 wil_dbg_misc(wil, "%s()\n", __func__);
694 print_hex_dump_bytes("mgmt tx frame ", DUMP_PREFIX_OFFSET, buf, len);
696 cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL);
702 memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN);
703 cmd->len = cpu_to_le16(len);
704 memcpy(cmd->payload, buf, len);
706 rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, cmd, sizeof(*cmd) + len,
707 WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000);
709 tx_status = !evt.evt.status;
713 cfg80211_mgmt_tx_status(wdev, cookie ? *cookie : 0, buf, len,
714 tx_status, GFP_KERNEL);
718 static int wil_cfg80211_set_channel(struct wiphy *wiphy,
719 struct cfg80211_chan_def *chandef)
721 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
722 struct wireless_dev *wdev = wil_to_wdev(wil);
724 wdev->preset_chandef = *chandef;
729 static enum wmi_key_usage wil_detect_key_usage(struct wil6210_priv *wil,
732 struct wireless_dev *wdev = wil_to_wdev(wil);
733 enum wmi_key_usage rc;
736 rc = WMI_KEY_USE_PAIRWISE;
738 switch (wdev->iftype) {
739 case NL80211_IFTYPE_STATION:
740 case NL80211_IFTYPE_P2P_CLIENT:
741 rc = WMI_KEY_USE_RX_GROUP;
743 case NL80211_IFTYPE_AP:
744 case NL80211_IFTYPE_P2P_GO:
745 rc = WMI_KEY_USE_TX_GROUP;
748 /* TODO: Rx GTK or Tx GTK? */
749 wil_err(wil, "Can't determine GTK type\n");
750 rc = WMI_KEY_USE_RX_GROUP;
754 wil_dbg_misc(wil, "%s() -> %s\n", __func__, key_usage_str[rc]);
759 static struct wil_tid_crypto_rx_single *
760 wil_find_crypto_ctx(struct wil6210_priv *wil, u8 key_index,
761 enum wmi_key_usage key_usage, const u8 *mac_addr)
765 struct wil_sta_info *s;
766 struct wil_tid_crypto_rx *c;
768 if (key_usage == WMI_KEY_USE_TX_GROUP)
769 return NULL; /* not needed */
771 /* supplicant provides Rx group key in STA mode with NULL MAC address */
773 cid = wil_find_cid(wil, mac_addr);
774 else if (key_usage == WMI_KEY_USE_RX_GROUP)
775 cid = wil_find_cid_by_idx(wil, 0);
777 wil_err(wil, "No CID for %pM %s[%d]\n", mac_addr,
778 key_usage_str[key_usage], key_index);
783 if (key_usage == WMI_KEY_USE_PAIRWISE)
784 c = &s->tid_crypto_rx[tid];
786 c = &s->group_crypto_rx;
788 return &c->key_id[key_index];
791 static int wil_cfg80211_add_key(struct wiphy *wiphy,
792 struct net_device *ndev,
793 u8 key_index, bool pairwise,
795 struct key_params *params)
798 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
799 enum wmi_key_usage key_usage = wil_detect_key_usage(wil, pairwise);
800 struct wil_tid_crypto_rx_single *cc = wil_find_crypto_ctx(wil,
805 wil_dbg_misc(wil, "%s(%pM %s[%d] PN %*phN)\n", __func__,
806 mac_addr, key_usage_str[key_usage], key_index,
807 params->seq_len, params->seq);
810 wil_err(wil, "Not connected, %s(%pM %s[%d] PN %*phN)\n",
811 __func__, mac_addr, key_usage_str[key_usage], key_index,
812 params->seq_len, params->seq);
819 if (params->seq && params->seq_len != IEEE80211_GCMP_PN_LEN) {
821 "Wrong PN len %d, %s(%pM %s[%d] PN %*phN)\n",
822 params->seq_len, __func__, mac_addr,
823 key_usage_str[key_usage], key_index,
824 params->seq_len, params->seq);
828 rc = wmi_add_cipher_key(wil, key_index, mac_addr, params->key_len,
829 params->key, key_usage);
830 if ((rc == 0) && cc) {
832 memcpy(cc->pn, params->seq, IEEE80211_GCMP_PN_LEN);
834 memset(cc->pn, 0, IEEE80211_GCMP_PN_LEN);
841 static int wil_cfg80211_del_key(struct wiphy *wiphy,
842 struct net_device *ndev,
843 u8 key_index, bool pairwise,
846 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
847 enum wmi_key_usage key_usage = wil_detect_key_usage(wil, pairwise);
848 struct wil_tid_crypto_rx_single *cc = wil_find_crypto_ctx(wil,
853 wil_dbg_misc(wil, "%s(%pM %s[%d])\n", __func__, mac_addr,
854 key_usage_str[key_usage], key_index);
857 wil_info(wil, "Not connected, %s(%pM %s[%d])\n", __func__,
858 mac_addr, key_usage_str[key_usage], key_index);
860 if (!IS_ERR_OR_NULL(cc))
863 return wmi_del_cipher_key(wil, key_index, mac_addr, key_usage);
866 /* Need to be present or wiphy_new() will WARN */
867 static int wil_cfg80211_set_default_key(struct wiphy *wiphy,
868 struct net_device *ndev,
869 u8 key_index, bool unicast,
872 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
874 wil_dbg_misc(wil, "%s: entered\n", __func__);
878 static int wil_remain_on_channel(struct wiphy *wiphy,
879 struct wireless_dev *wdev,
880 struct ieee80211_channel *chan,
881 unsigned int duration,
884 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
887 wil_dbg_misc(wil, "%s() center_freq=%d, duration=%d iftype=%d\n",
888 __func__, chan->center_freq, duration, wdev->iftype);
890 rc = wil_p2p_listen(wil, duration, chan, cookie);
894 wil->radio_wdev = wdev;
896 cfg80211_ready_on_channel(wdev, *cookie, chan, duration,
902 static int wil_cancel_remain_on_channel(struct wiphy *wiphy,
903 struct wireless_dev *wdev,
906 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
908 wil_dbg_misc(wil, "%s()\n", __func__);
910 return wil_p2p_cancel_listen(wil, cookie);
914 * find a specific IE in a list of IEs
915 * return a pointer to the beginning of IE in the list
916 * or NULL if not found
918 static const u8 *_wil_cfg80211_find_ie(const u8 *ies, u16 ies_len, const u8 *ie,
921 struct ieee80211_vendor_ie *vie;
924 /* IE tag at offset 0, length at offset 1 */
925 if (ie_len < 2 || 2 + ie[1] > ie_len)
928 if (ie[0] != WLAN_EID_VENDOR_SPECIFIC)
929 return cfg80211_find_ie(ie[0], ies, ies_len);
931 /* make sure there is room for 3 bytes OUI + 1 byte OUI type */
934 vie = (struct ieee80211_vendor_ie *)ie;
935 oui = vie->oui[0] << 16 | vie->oui[1] << 8 | vie->oui[2];
936 return cfg80211_find_vendor_ie(oui, vie->oui_type, ies,
941 * merge the IEs in two lists into a single list.
942 * do not include IEs from the second list which exist in the first list.
943 * add only vendor specific IEs from second list to keep
944 * the merged list sorted (since vendor-specific IE has the
945 * highest tag number)
946 * caller must free the allocated memory for merged IEs
948 static int _wil_cfg80211_merge_extra_ies(const u8 *ies1, u16 ies1_len,
949 const u8 *ies2, u16 ies2_len,
950 u8 **merged_ies, u16 *merged_len)
955 if (ies1_len == 0 && ies2_len == 0) {
961 buf = kmalloc(ies1_len + ies2_len, GFP_KERNEL);
964 memcpy(buf, ies1, ies1_len);
965 dpos = buf + ies1_len;
967 while (spos + 1 < ies2 + ies2_len) {
968 /* IE tag at offset 0, length at offset 1 */
969 u16 ielen = 2 + spos[1];
971 if (spos + ielen > ies2 + ies2_len)
973 if (spos[0] == WLAN_EID_VENDOR_SPECIFIC &&
974 !_wil_cfg80211_find_ie(ies1, ies1_len, spos, ielen)) {
975 memcpy(dpos, spos, ielen);
982 *merged_len = dpos - buf;
986 static void wil_print_bcon_data(struct cfg80211_beacon_data *b)
988 print_hex_dump_bytes("head ", DUMP_PREFIX_OFFSET,
989 b->head, b->head_len);
990 print_hex_dump_bytes("tail ", DUMP_PREFIX_OFFSET,
991 b->tail, b->tail_len);
992 print_hex_dump_bytes("BCON IE ", DUMP_PREFIX_OFFSET,
993 b->beacon_ies, b->beacon_ies_len);
994 print_hex_dump_bytes("PROBE ", DUMP_PREFIX_OFFSET,
995 b->probe_resp, b->probe_resp_len);
996 print_hex_dump_bytes("PROBE IE ", DUMP_PREFIX_OFFSET,
997 b->proberesp_ies, b->proberesp_ies_len);
998 print_hex_dump_bytes("ASSOC IE ", DUMP_PREFIX_OFFSET,
999 b->assocresp_ies, b->assocresp_ies_len);
1002 /* internal functions for device reset and starting AP */
1003 static int _wil_cfg80211_set_ies(struct wiphy *wiphy,
1004 struct cfg80211_beacon_data *bcon)
1007 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1008 u16 len = 0, proberesp_len = 0;
1009 u8 *ies = NULL, *proberesp = NULL;
1011 if (bcon->probe_resp) {
1012 struct ieee80211_mgmt *f =
1013 (struct ieee80211_mgmt *)bcon->probe_resp;
1014 size_t hlen = offsetof(struct ieee80211_mgmt,
1015 u.probe_resp.variable);
1016 proberesp = f->u.probe_resp.variable;
1017 proberesp_len = bcon->probe_resp_len - hlen;
1019 rc = _wil_cfg80211_merge_extra_ies(proberesp,
1021 bcon->proberesp_ies,
1022 bcon->proberesp_ies_len,
1028 rc = wmi_set_ie(wil, WMI_FRAME_PROBE_RESP, len, ies);
1032 if (bcon->assocresp_ies)
1033 rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP,
1034 bcon->assocresp_ies_len, bcon->assocresp_ies);
1036 rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP, len, ies);
1037 #if 0 /* to use beacon IE's, remove this #if 0 */
1041 rc = wmi_set_ie(wil, WMI_FRAME_BEACON, bcon->tail_len, bcon->tail);
1048 static int _wil_cfg80211_start_ap(struct wiphy *wiphy,
1049 struct net_device *ndev,
1050 const u8 *ssid, size_t ssid_len, u32 privacy,
1052 struct cfg80211_beacon_data *bcon,
1053 u8 hidden_ssid, u32 pbss)
1055 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1057 struct wireless_dev *wdev = ndev->ieee80211_ptr;
1058 u8 wmi_nettype = wil_iftype_nl2wmi(wdev->iftype);
1059 u8 is_go = (wdev->iftype == NL80211_IFTYPE_P2P_GO);
1062 wmi_nettype = WMI_NETTYPE_P2P;
1064 wil_dbg_misc(wil, "%s: is_go=%d\n", __func__, is_go);
1065 if (is_go && !pbss) {
1066 wil_err(wil, "%s: P2P GO must be in PBSS\n", __func__);
1070 wil_set_recovery_state(wil, fw_recovery_idle);
1072 mutex_lock(&wil->mutex);
1079 rc = wmi_set_ssid(wil, ssid_len, ssid);
1083 rc = _wil_cfg80211_set_ies(wiphy, bcon);
1087 wil->privacy = privacy;
1088 wil->channel = chan;
1089 wil->hidden_ssid = hidden_ssid;
1092 netif_carrier_on(ndev);
1094 rc = wmi_pcp_start(wil, bi, wmi_nettype, chan, hidden_ssid, is_go);
1098 rc = wil_bcast_init(wil);
1102 goto out; /* success */
1107 netif_carrier_off(ndev);
1109 mutex_unlock(&wil->mutex);
1113 static int wil_cfg80211_change_beacon(struct wiphy *wiphy,
1114 struct net_device *ndev,
1115 struct cfg80211_beacon_data *bcon)
1117 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1121 wil_dbg_misc(wil, "%s()\n", __func__);
1122 wil_print_bcon_data(bcon);
1125 cfg80211_find_ie(WLAN_EID_RSN, bcon->tail,
1129 /* in case privacy has changed, need to restart the AP */
1130 if (wil->privacy != privacy) {
1131 struct wireless_dev *wdev = ndev->ieee80211_ptr;
1133 wil_dbg_misc(wil, "privacy changed %d=>%d. Restarting AP\n",
1134 wil->privacy, privacy);
1136 rc = _wil_cfg80211_start_ap(wiphy, ndev, wdev->ssid,
1137 wdev->ssid_len, privacy,
1138 wdev->beacon_interval,
1143 rc = _wil_cfg80211_set_ies(wiphy, bcon);
1149 static int wil_cfg80211_start_ap(struct wiphy *wiphy,
1150 struct net_device *ndev,
1151 struct cfg80211_ap_settings *info)
1154 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1155 struct ieee80211_channel *channel = info->chandef.chan;
1156 struct cfg80211_beacon_data *bcon = &info->beacon;
1157 struct cfg80211_crypto_settings *crypto = &info->crypto;
1160 wil_dbg_misc(wil, "%s()\n", __func__);
1163 wil_err(wil, "AP: No channel???\n");
1167 switch (info->hidden_ssid) {
1168 case NL80211_HIDDEN_SSID_NOT_IN_USE:
1169 hidden_ssid = WMI_HIDDEN_SSID_DISABLED;
1172 case NL80211_HIDDEN_SSID_ZERO_LEN:
1173 hidden_ssid = WMI_HIDDEN_SSID_SEND_EMPTY;
1176 case NL80211_HIDDEN_SSID_ZERO_CONTENTS:
1177 hidden_ssid = WMI_HIDDEN_SSID_CLEAR;
1181 wil_err(wil, "AP: Invalid hidden SSID %d\n", info->hidden_ssid);
1184 wil_dbg_misc(wil, "AP on Channel %d %d MHz, %s\n", channel->hw_value,
1185 channel->center_freq, info->privacy ? "secure" : "open");
1186 wil_dbg_misc(wil, "Privacy: %d auth_type %d\n",
1187 info->privacy, info->auth_type);
1188 wil_dbg_misc(wil, "Hidden SSID mode: %d\n",
1190 wil_dbg_misc(wil, "BI %d DTIM %d\n", info->beacon_interval,
1192 wil_dbg_misc(wil, "PBSS %d\n", info->pbss);
1193 print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
1194 info->ssid, info->ssid_len);
1195 wil_print_bcon_data(bcon);
1196 wil_print_crypto(wil, crypto);
1198 rc = _wil_cfg80211_start_ap(wiphy, ndev,
1199 info->ssid, info->ssid_len, info->privacy,
1200 info->beacon_interval, channel->hw_value,
1201 bcon, hidden_ssid, info->pbss);
1206 static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
1207 struct net_device *ndev)
1209 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1211 wil_dbg_misc(wil, "%s()\n", __func__);
1213 netif_carrier_off(ndev);
1214 wil_set_recovery_state(wil, fw_recovery_idle);
1216 mutex_lock(&wil->mutex);
1222 mutex_unlock(&wil->mutex);
1227 static int wil_cfg80211_del_station(struct wiphy *wiphy,
1228 struct net_device *dev,
1229 struct station_del_parameters *params)
1231 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1233 wil_dbg_misc(wil, "%s(%pM, reason=%d)\n", __func__, params->mac,
1234 params->reason_code);
1236 mutex_lock(&wil->mutex);
1237 wil6210_disconnect(wil, params->mac, params->reason_code, false);
1238 mutex_unlock(&wil->mutex);
1243 /* probe_client handling */
1244 static void wil_probe_client_handle(struct wil6210_priv *wil,
1245 struct wil_probe_client_req *req)
1247 struct net_device *ndev = wil_to_ndev(wil);
1248 struct wil_sta_info *sta = &wil->sta[req->cid];
1249 /* assume STA is alive if it is still connected,
1250 * else FW will disconnect it
1252 bool alive = (sta->status == wil_sta_connected);
1254 cfg80211_probe_status(ndev, sta->addr, req->cookie, alive, GFP_KERNEL);
1257 static struct list_head *next_probe_client(struct wil6210_priv *wil)
1259 struct list_head *ret = NULL;
1261 mutex_lock(&wil->probe_client_mutex);
1263 if (!list_empty(&wil->probe_client_pending)) {
1264 ret = wil->probe_client_pending.next;
1268 mutex_unlock(&wil->probe_client_mutex);
1273 void wil_probe_client_worker(struct work_struct *work)
1275 struct wil6210_priv *wil = container_of(work, struct wil6210_priv,
1276 probe_client_worker);
1277 struct wil_probe_client_req *req;
1278 struct list_head *lh;
1280 while ((lh = next_probe_client(wil)) != NULL) {
1281 req = list_entry(lh, struct wil_probe_client_req, list);
1283 wil_probe_client_handle(wil, req);
1288 void wil_probe_client_flush(struct wil6210_priv *wil)
1290 struct wil_probe_client_req *req, *t;
1292 wil_dbg_misc(wil, "%s()\n", __func__);
1294 mutex_lock(&wil->probe_client_mutex);
1296 list_for_each_entry_safe(req, t, &wil->probe_client_pending, list) {
1297 list_del(&req->list);
1301 mutex_unlock(&wil->probe_client_mutex);
1304 static int wil_cfg80211_probe_client(struct wiphy *wiphy,
1305 struct net_device *dev,
1306 const u8 *peer, u64 *cookie)
1308 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1309 struct wil_probe_client_req *req;
1310 int cid = wil_find_cid(wil, peer);
1312 wil_dbg_misc(wil, "%s(%pM => CID %d)\n", __func__, peer, cid);
1317 req = kzalloc(sizeof(*req), GFP_KERNEL);
1324 mutex_lock(&wil->probe_client_mutex);
1325 list_add_tail(&req->list, &wil->probe_client_pending);
1326 mutex_unlock(&wil->probe_client_mutex);
1328 *cookie = req->cookie;
1329 queue_work(wil->wq_service, &wil->probe_client_worker);
1333 static int wil_cfg80211_change_bss(struct wiphy *wiphy,
1334 struct net_device *dev,
1335 struct bss_parameters *params)
1337 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1339 if (params->ap_isolate >= 0) {
1340 wil_dbg_misc(wil, "%s(ap_isolate %d => %d)\n", __func__,
1341 wil->ap_isolate, params->ap_isolate);
1342 wil->ap_isolate = params->ap_isolate;
1348 static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
1349 struct wireless_dev *wdev)
1351 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1353 wil_dbg_misc(wil, "%s: entered\n", __func__);
1357 static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
1358 struct wireless_dev *wdev)
1360 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1362 wil_dbg_misc(wil, "%s: entered\n", __func__);
1365 static struct cfg80211_ops wil_cfg80211_ops = {
1366 .add_virtual_intf = wil_cfg80211_add_iface,
1367 .del_virtual_intf = wil_cfg80211_del_iface,
1368 .scan = wil_cfg80211_scan,
1369 .connect = wil_cfg80211_connect,
1370 .disconnect = wil_cfg80211_disconnect,
1371 .change_virtual_intf = wil_cfg80211_change_iface,
1372 .get_station = wil_cfg80211_get_station,
1373 .dump_station = wil_cfg80211_dump_station,
1374 .remain_on_channel = wil_remain_on_channel,
1375 .cancel_remain_on_channel = wil_cancel_remain_on_channel,
1376 .mgmt_tx = wil_cfg80211_mgmt_tx,
1377 .set_monitor_channel = wil_cfg80211_set_channel,
1378 .add_key = wil_cfg80211_add_key,
1379 .del_key = wil_cfg80211_del_key,
1380 .set_default_key = wil_cfg80211_set_default_key,
1382 .change_beacon = wil_cfg80211_change_beacon,
1383 .start_ap = wil_cfg80211_start_ap,
1384 .stop_ap = wil_cfg80211_stop_ap,
1385 .del_station = wil_cfg80211_del_station,
1386 .probe_client = wil_cfg80211_probe_client,
1387 .change_bss = wil_cfg80211_change_bss,
1389 .start_p2p_device = wil_cfg80211_start_p2p_device,
1390 .stop_p2p_device = wil_cfg80211_stop_p2p_device,
1393 static void wil_wiphy_init(struct wiphy *wiphy)
1395 wiphy->max_scan_ssids = 1;
1396 wiphy->max_scan_ie_len = WMI_MAX_IE_LEN;
1397 wiphy->max_remain_on_channel_duration = WIL_MAX_ROC_DURATION_MS;
1398 wiphy->max_num_pmkids = 0 /* TODO: */;
1399 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1400 BIT(NL80211_IFTYPE_AP) |
1401 BIT(NL80211_IFTYPE_P2P_CLIENT) |
1402 BIT(NL80211_IFTYPE_P2P_GO) |
1403 BIT(NL80211_IFTYPE_P2P_DEVICE) |
1404 BIT(NL80211_IFTYPE_MONITOR);
1405 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
1406 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
1407 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
1408 dev_dbg(wiphy_dev(wiphy), "%s : flags = 0x%08x\n",
1409 __func__, wiphy->flags);
1410 wiphy->probe_resp_offload =
1411 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
1412 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
1413 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
1415 wiphy->bands[NL80211_BAND_60GHZ] = &wil_band_60ghz;
1417 /* TODO: figure this out */
1418 wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
1420 wiphy->cipher_suites = wil_cipher_suites;
1421 wiphy->n_cipher_suites = ARRAY_SIZE(wil_cipher_suites);
1422 wiphy->mgmt_stypes = wil_mgmt_stypes;
1423 wiphy->features |= NL80211_FEATURE_SK_TX_STATUS;
1426 struct wireless_dev *wil_cfg80211_init(struct device *dev)
1429 struct wireless_dev *wdev;
1431 dev_dbg(dev, "%s()\n", __func__);
1433 wdev = kzalloc(sizeof(*wdev), GFP_KERNEL);
1435 return ERR_PTR(-ENOMEM);
1437 wdev->wiphy = wiphy_new(&wil_cfg80211_ops,
1438 sizeof(struct wil6210_priv));
1444 set_wiphy_dev(wdev->wiphy, dev);
1445 wil_wiphy_init(wdev->wiphy);
1447 rc = wiphy_register(wdev->wiphy);
1449 goto out_failed_reg;
1454 wiphy_free(wdev->wiphy);
1461 void wil_wdev_free(struct wil6210_priv *wil)
1463 struct wireless_dev *wdev = wil_to_wdev(wil);
1465 dev_dbg(wil_to_dev(wil), "%s()\n", __func__);
1470 wiphy_unregister(wdev->wiphy);
1471 wiphy_free(wdev->wiphy);
1475 void wil_p2p_wdev_free(struct wil6210_priv *wil)
1477 struct wireless_dev *p2p_wdev;
1479 mutex_lock(&wil->p2p_wdev_mutex);
1480 p2p_wdev = wil->p2p_wdev;
1482 wil->p2p_wdev = NULL;
1483 wil->radio_wdev = wil_to_wdev(wil);
1484 cfg80211_unregister_wdev(p2p_wdev);
1487 mutex_unlock(&wil->p2p_wdev_mutex);