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 if (!wil->p2p.p2p_dev_started) {
382 wil_err(wil, "P2P search requested on stopped P2P device\n");
385 wil->scan_request = request;
386 wil->radio_wdev = wdev;
387 rc = wil_p2p_search(wil, request);
389 wil->radio_wdev = wil_to_wdev(wil);
390 wil->scan_request = NULL;
395 (void)wil_p2p_stop_discovery(wil);
397 wil_dbg_misc(wil, "Start scan_request 0x%p\n", request);
398 wil_dbg_misc(wil, "SSID count: %d", request->n_ssids);
400 for (i = 0; i < request->n_ssids; i++) {
401 wil_dbg_misc(wil, "SSID[%d]", i);
402 print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
403 request->ssids[i].ssid,
404 request->ssids[i].ssid_len);
407 if (request->n_ssids)
408 rc = wmi_set_ssid(wil, request->ssids[0].ssid_len,
409 request->ssids[0].ssid);
411 rc = wmi_set_ssid(wil, 0, NULL);
414 wil_err(wil, "set SSID for scan request failed: %d\n", rc);
418 wil->scan_request = request;
419 mod_timer(&wil->scan_timer, jiffies + WIL6210_SCAN_TO);
421 memset(&cmd, 0, sizeof(cmd));
422 cmd.cmd.scan_type = WMI_ACTIVE_SCAN;
423 cmd.cmd.num_channels = 0;
424 n = min(request->n_channels, 4U);
425 for (i = 0; i < n; i++) {
426 int ch = request->channels[i]->hw_value;
430 "Scan requested for unknown frequency %dMhz\n",
431 request->channels[i]->center_freq);
434 /* 0-based channel indexes */
435 cmd.cmd.channel_list[cmd.cmd.num_channels++].channel = ch - 1;
436 wil_dbg_misc(wil, "Scan for ch %d : %d MHz\n", ch,
437 request->channels[i]->center_freq);
441 print_hex_dump_bytes("Scan IE ", DUMP_PREFIX_OFFSET,
442 request->ie, request->ie_len);
444 wil_dbg_misc(wil, "Scan has no IE's\n");
446 rc = wmi_set_ie(wil, WMI_FRAME_PROBE_REQ, request->ie_len, request->ie);
450 if (wil->discovery_mode && cmd.cmd.scan_type == WMI_ACTIVE_SCAN) {
451 cmd.cmd.discovery_mode = 1;
452 wil_dbg_misc(wil, "active scan with discovery_mode=1\n");
455 wil->radio_wdev = wdev;
456 rc = wmi_send(wil, WMI_START_SCAN_CMDID, &cmd, sizeof(cmd.cmd) +
457 cmd.cmd.num_channels * sizeof(cmd.cmd.channel_list[0]));
461 del_timer_sync(&wil->scan_timer);
462 wil->radio_wdev = wil_to_wdev(wil);
463 wil->scan_request = NULL;
469 static void wil_print_crypto(struct wil6210_priv *wil,
470 struct cfg80211_crypto_settings *c)
474 wil_dbg_misc(wil, "WPA versions: 0x%08x cipher group 0x%08x\n",
475 c->wpa_versions, c->cipher_group);
476 wil_dbg_misc(wil, "Pairwise ciphers [%d] {\n", c->n_ciphers_pairwise);
477 n = min_t(int, c->n_ciphers_pairwise, ARRAY_SIZE(c->ciphers_pairwise));
478 for (i = 0; i < n; i++)
479 wil_dbg_misc(wil, " [%d] = 0x%08x\n", i,
480 c->ciphers_pairwise[i]);
481 wil_dbg_misc(wil, "}\n");
482 wil_dbg_misc(wil, "AKM suites [%d] {\n", c->n_akm_suites);
483 n = min_t(int, c->n_akm_suites, ARRAY_SIZE(c->akm_suites));
484 for (i = 0; i < n; i++)
485 wil_dbg_misc(wil, " [%d] = 0x%08x\n", i,
487 wil_dbg_misc(wil, "}\n");
488 wil_dbg_misc(wil, "Control port : %d, eth_type 0x%04x no_encrypt %d\n",
489 c->control_port, be16_to_cpu(c->control_port_ethertype),
490 c->control_port_no_encrypt);
493 static void wil_print_connect_params(struct wil6210_priv *wil,
494 struct cfg80211_connect_params *sme)
496 wil_info(wil, "Connecting to:\n");
498 wil_info(wil, " Channel: %d freq %d\n",
499 sme->channel->hw_value, sme->channel->center_freq);
502 wil_info(wil, " BSSID: %pM\n", sme->bssid);
504 print_hex_dump(KERN_INFO, " SSID: ", DUMP_PREFIX_OFFSET,
505 16, 1, sme->ssid, sme->ssid_len, true);
506 wil_info(wil, " Privacy: %s\n", sme->privacy ? "secure" : "open");
507 wil_info(wil, " PBSS: %d\n", sme->pbss);
508 wil_print_crypto(wil, &sme->crypto);
511 static int wil_cfg80211_connect(struct wiphy *wiphy,
512 struct net_device *ndev,
513 struct cfg80211_connect_params *sme)
515 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
516 struct cfg80211_bss *bss;
517 struct wmi_connect_cmd conn;
522 enum ieee80211_bss_type bss_type = IEEE80211_BSS_TYPE_ESS;
524 wil_dbg_misc(wil, "%s()\n", __func__);
525 wil_print_connect_params(wil, sme);
527 if (test_bit(wil_status_fwconnecting, wil->status) ||
528 test_bit(wil_status_fwconnected, wil->status))
531 if (sme->ie_len > WMI_MAX_IE_LEN) {
532 wil_err(wil, "IE too large (%td bytes)\n", sme->ie_len);
537 cfg80211_find_ie(WLAN_EID_RSN, sme->ie, sme->ie_len) :
539 if (sme->privacy && !rsn_eid)
540 wil_info(wil, "WSC connection\n");
543 bss_type = IEEE80211_BSS_TYPE_PBSS;
545 bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid,
546 sme->ssid, sme->ssid_len,
547 bss_type, IEEE80211_PRIVACY_ANY);
549 wil_err(wil, "Unable to find BSS\n");
553 ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
555 wil_err(wil, "No SSID\n");
559 wil->privacy = sme->privacy;
562 /* For secure assoc, remove old keys */
563 rc = wmi_del_cipher_key(wil, 0, bss->bssid,
564 WMI_KEY_USE_PAIRWISE);
566 wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD(PTK) failed\n");
569 rc = wmi_del_cipher_key(wil, 0, bss->bssid,
570 WMI_KEY_USE_RX_GROUP);
572 wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD(GTK) failed\n");
577 /* WMI_SET_APPIE_CMD. ie may contain rsn info as well as other info
578 * elements. Send it also in case it's empty, to erase previously set
581 rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_REQ, sme->ie_len, sme->ie);
585 /* WMI_CONNECT_CMD */
586 memset(&conn, 0, sizeof(conn));
587 switch (bss->capability & WLAN_CAPABILITY_DMG_TYPE_MASK) {
588 case WLAN_CAPABILITY_DMG_TYPE_AP:
589 conn.network_type = WMI_NETTYPE_INFRA;
591 case WLAN_CAPABILITY_DMG_TYPE_PBSS:
592 conn.network_type = WMI_NETTYPE_P2P;
595 wil_err(wil, "Unsupported BSS type, capability= 0x%04x\n",
600 if (rsn_eid) { /* regular secure connection */
601 conn.dot11_auth_mode = WMI_AUTH11_SHARED;
602 conn.auth_mode = WMI_AUTH_WPA2_PSK;
603 conn.pairwise_crypto_type = WMI_CRYPT_AES_GCMP;
604 conn.pairwise_crypto_len = 16;
605 conn.group_crypto_type = WMI_CRYPT_AES_GCMP;
606 conn.group_crypto_len = 16;
608 conn.dot11_auth_mode = WMI_AUTH11_WSC;
609 conn.auth_mode = WMI_AUTH_NONE;
611 } else { /* insecure connection */
612 conn.dot11_auth_mode = WMI_AUTH11_OPEN;
613 conn.auth_mode = WMI_AUTH_NONE;
616 conn.ssid_len = min_t(u8, ssid_eid[1], 32);
617 memcpy(conn.ssid, ssid_eid+2, conn.ssid_len);
619 ch = bss->channel->hw_value;
621 wil_err(wil, "BSS at unknown frequency %dMhz\n",
622 bss->channel->center_freq);
626 conn.channel = ch - 1;
628 ether_addr_copy(conn.bssid, bss->bssid);
629 ether_addr_copy(conn.dst_mac, bss->bssid);
631 set_bit(wil_status_fwconnecting, wil->status);
633 rc = wmi_send(wil, WMI_CONNECT_CMDID, &conn, sizeof(conn));
635 netif_carrier_on(ndev);
636 /* Connect can take lots of time */
637 mod_timer(&wil->connect_timer,
638 jiffies + msecs_to_jiffies(2000));
640 clear_bit(wil_status_fwconnecting, wil->status);
644 cfg80211_put_bss(wiphy, bss);
649 static int wil_cfg80211_disconnect(struct wiphy *wiphy,
650 struct net_device *ndev,
654 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
656 wil_dbg_misc(wil, "%s(reason=%d)\n", __func__, reason_code);
658 if (!(test_bit(wil_status_fwconnecting, wil->status) ||
659 test_bit(wil_status_fwconnected, wil->status))) {
660 wil_err(wil, "%s: Disconnect was called while disconnected\n",
665 rc = wmi_call(wil, WMI_DISCONNECT_CMDID, NULL, 0,
666 WMI_DISCONNECT_EVENTID, NULL, 0,
667 WIL6210_DISCONNECT_TO_MS);
669 wil_err(wil, "%s: disconnect error %d\n", __func__, rc);
674 int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
675 struct cfg80211_mgmt_tx_params *params,
678 const u8 *buf = params->buf;
679 size_t len = params->len;
680 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
682 bool tx_status = false;
683 struct ieee80211_mgmt *mgmt_frame = (void *)buf;
684 struct wmi_sw_tx_req_cmd *cmd;
686 struct wmi_cmd_hdr wmi;
687 struct wmi_sw_tx_complete_event evt;
690 /* Note, currently we do not support the "wait" parameter, user-space
691 * must call remain_on_channel before mgmt_tx or listen on a channel
692 * another way (AP/PCP or connected station)
693 * in addition we need to check if specified "chan" argument is
694 * different from currently "listened" channel and fail if it is.
697 wil_dbg_misc(wil, "%s()\n", __func__);
698 print_hex_dump_bytes("mgmt tx frame ", DUMP_PREFIX_OFFSET, buf, len);
700 cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL);
706 memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN);
707 cmd->len = cpu_to_le16(len);
708 memcpy(cmd->payload, buf, len);
710 rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, cmd, sizeof(*cmd) + len,
711 WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000);
713 tx_status = !evt.evt.status;
717 cfg80211_mgmt_tx_status(wdev, cookie ? *cookie : 0, buf, len,
718 tx_status, GFP_KERNEL);
722 static int wil_cfg80211_set_channel(struct wiphy *wiphy,
723 struct cfg80211_chan_def *chandef)
725 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
726 struct wireless_dev *wdev = wil_to_wdev(wil);
728 wdev->preset_chandef = *chandef;
733 static enum wmi_key_usage wil_detect_key_usage(struct wil6210_priv *wil,
736 struct wireless_dev *wdev = wil_to_wdev(wil);
737 enum wmi_key_usage rc;
740 rc = WMI_KEY_USE_PAIRWISE;
742 switch (wdev->iftype) {
743 case NL80211_IFTYPE_STATION:
744 case NL80211_IFTYPE_P2P_CLIENT:
745 rc = WMI_KEY_USE_RX_GROUP;
747 case NL80211_IFTYPE_AP:
748 case NL80211_IFTYPE_P2P_GO:
749 rc = WMI_KEY_USE_TX_GROUP;
752 /* TODO: Rx GTK or Tx GTK? */
753 wil_err(wil, "Can't determine GTK type\n");
754 rc = WMI_KEY_USE_RX_GROUP;
758 wil_dbg_misc(wil, "%s() -> %s\n", __func__, key_usage_str[rc]);
763 static struct wil_tid_crypto_rx_single *
764 wil_find_crypto_ctx(struct wil6210_priv *wil, u8 key_index,
765 enum wmi_key_usage key_usage, const u8 *mac_addr)
769 struct wil_sta_info *s;
770 struct wil_tid_crypto_rx *c;
772 if (key_usage == WMI_KEY_USE_TX_GROUP)
773 return NULL; /* not needed */
775 /* supplicant provides Rx group key in STA mode with NULL MAC address */
777 cid = wil_find_cid(wil, mac_addr);
778 else if (key_usage == WMI_KEY_USE_RX_GROUP)
779 cid = wil_find_cid_by_idx(wil, 0);
781 wil_err(wil, "No CID for %pM %s[%d]\n", mac_addr,
782 key_usage_str[key_usage], key_index);
787 if (key_usage == WMI_KEY_USE_PAIRWISE)
788 c = &s->tid_crypto_rx[tid];
790 c = &s->group_crypto_rx;
792 return &c->key_id[key_index];
795 static int wil_cfg80211_add_key(struct wiphy *wiphy,
796 struct net_device *ndev,
797 u8 key_index, bool pairwise,
799 struct key_params *params)
802 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
803 enum wmi_key_usage key_usage = wil_detect_key_usage(wil, pairwise);
804 struct wil_tid_crypto_rx_single *cc = wil_find_crypto_ctx(wil,
809 wil_dbg_misc(wil, "%s(%pM %s[%d] PN %*phN)\n", __func__,
810 mac_addr, key_usage_str[key_usage], key_index,
811 params->seq_len, params->seq);
814 wil_err(wil, "Not connected, %s(%pM %s[%d] PN %*phN)\n",
815 __func__, mac_addr, key_usage_str[key_usage], key_index,
816 params->seq_len, params->seq);
823 if (params->seq && params->seq_len != IEEE80211_GCMP_PN_LEN) {
825 "Wrong PN len %d, %s(%pM %s[%d] PN %*phN)\n",
826 params->seq_len, __func__, mac_addr,
827 key_usage_str[key_usage], key_index,
828 params->seq_len, params->seq);
832 rc = wmi_add_cipher_key(wil, key_index, mac_addr, params->key_len,
833 params->key, key_usage);
834 if ((rc == 0) && cc) {
836 memcpy(cc->pn, params->seq, IEEE80211_GCMP_PN_LEN);
838 memset(cc->pn, 0, IEEE80211_GCMP_PN_LEN);
845 static int wil_cfg80211_del_key(struct wiphy *wiphy,
846 struct net_device *ndev,
847 u8 key_index, bool pairwise,
850 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
851 enum wmi_key_usage key_usage = wil_detect_key_usage(wil, pairwise);
852 struct wil_tid_crypto_rx_single *cc = wil_find_crypto_ctx(wil,
857 wil_dbg_misc(wil, "%s(%pM %s[%d])\n", __func__, mac_addr,
858 key_usage_str[key_usage], key_index);
861 wil_info(wil, "Not connected, %s(%pM %s[%d])\n", __func__,
862 mac_addr, key_usage_str[key_usage], key_index);
864 if (!IS_ERR_OR_NULL(cc))
867 return wmi_del_cipher_key(wil, key_index, mac_addr, key_usage);
870 /* Need to be present or wiphy_new() will WARN */
871 static int wil_cfg80211_set_default_key(struct wiphy *wiphy,
872 struct net_device *ndev,
873 u8 key_index, bool unicast,
876 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
878 wil_dbg_misc(wil, "%s: entered\n", __func__);
882 static int wil_remain_on_channel(struct wiphy *wiphy,
883 struct wireless_dev *wdev,
884 struct ieee80211_channel *chan,
885 unsigned int duration,
888 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
891 wil_dbg_misc(wil, "%s() center_freq=%d, duration=%d iftype=%d\n",
892 __func__, chan->center_freq, duration, wdev->iftype);
894 rc = wil_p2p_listen(wil, duration, chan, cookie);
898 wil->radio_wdev = wdev;
900 cfg80211_ready_on_channel(wdev, *cookie, chan, duration,
906 static int wil_cancel_remain_on_channel(struct wiphy *wiphy,
907 struct wireless_dev *wdev,
910 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
912 wil_dbg_misc(wil, "%s()\n", __func__);
914 return wil_p2p_cancel_listen(wil, cookie);
918 * find a specific IE in a list of IEs
919 * return a pointer to the beginning of IE in the list
920 * or NULL if not found
922 static const u8 *_wil_cfg80211_find_ie(const u8 *ies, u16 ies_len, const u8 *ie,
925 struct ieee80211_vendor_ie *vie;
928 /* IE tag at offset 0, length at offset 1 */
929 if (ie_len < 2 || 2 + ie[1] > ie_len)
932 if (ie[0] != WLAN_EID_VENDOR_SPECIFIC)
933 return cfg80211_find_ie(ie[0], ies, ies_len);
935 /* make sure there is room for 3 bytes OUI + 1 byte OUI type */
938 vie = (struct ieee80211_vendor_ie *)ie;
939 oui = vie->oui[0] << 16 | vie->oui[1] << 8 | vie->oui[2];
940 return cfg80211_find_vendor_ie(oui, vie->oui_type, ies,
945 * merge the IEs in two lists into a single list.
946 * do not include IEs from the second list which exist in the first list.
947 * add only vendor specific IEs from second list to keep
948 * the merged list sorted (since vendor-specific IE has the
949 * highest tag number)
950 * caller must free the allocated memory for merged IEs
952 static int _wil_cfg80211_merge_extra_ies(const u8 *ies1, u16 ies1_len,
953 const u8 *ies2, u16 ies2_len,
954 u8 **merged_ies, u16 *merged_len)
959 if (ies1_len == 0 && ies2_len == 0) {
965 buf = kmalloc(ies1_len + ies2_len, GFP_KERNEL);
968 memcpy(buf, ies1, ies1_len);
969 dpos = buf + ies1_len;
971 while (spos + 1 < ies2 + ies2_len) {
972 /* IE tag at offset 0, length at offset 1 */
973 u16 ielen = 2 + spos[1];
975 if (spos + ielen > ies2 + ies2_len)
977 if (spos[0] == WLAN_EID_VENDOR_SPECIFIC &&
978 !_wil_cfg80211_find_ie(ies1, ies1_len, spos, ielen)) {
979 memcpy(dpos, spos, ielen);
986 *merged_len = dpos - buf;
990 static void wil_print_bcon_data(struct cfg80211_beacon_data *b)
992 print_hex_dump_bytes("head ", DUMP_PREFIX_OFFSET,
993 b->head, b->head_len);
994 print_hex_dump_bytes("tail ", DUMP_PREFIX_OFFSET,
995 b->tail, b->tail_len);
996 print_hex_dump_bytes("BCON IE ", DUMP_PREFIX_OFFSET,
997 b->beacon_ies, b->beacon_ies_len);
998 print_hex_dump_bytes("PROBE ", DUMP_PREFIX_OFFSET,
999 b->probe_resp, b->probe_resp_len);
1000 print_hex_dump_bytes("PROBE IE ", DUMP_PREFIX_OFFSET,
1001 b->proberesp_ies, b->proberesp_ies_len);
1002 print_hex_dump_bytes("ASSOC IE ", DUMP_PREFIX_OFFSET,
1003 b->assocresp_ies, b->assocresp_ies_len);
1006 /* internal functions for device reset and starting AP */
1007 static int _wil_cfg80211_set_ies(struct wiphy *wiphy,
1008 struct cfg80211_beacon_data *bcon)
1011 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1012 u16 len = 0, proberesp_len = 0;
1013 u8 *ies = NULL, *proberesp = NULL;
1015 if (bcon->probe_resp) {
1016 struct ieee80211_mgmt *f =
1017 (struct ieee80211_mgmt *)bcon->probe_resp;
1018 size_t hlen = offsetof(struct ieee80211_mgmt,
1019 u.probe_resp.variable);
1020 proberesp = f->u.probe_resp.variable;
1021 proberesp_len = bcon->probe_resp_len - hlen;
1023 rc = _wil_cfg80211_merge_extra_ies(proberesp,
1025 bcon->proberesp_ies,
1026 bcon->proberesp_ies_len,
1032 rc = wmi_set_ie(wil, WMI_FRAME_PROBE_RESP, len, ies);
1036 if (bcon->assocresp_ies)
1037 rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP,
1038 bcon->assocresp_ies_len, bcon->assocresp_ies);
1040 rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP, len, ies);
1041 #if 0 /* to use beacon IE's, remove this #if 0 */
1045 rc = wmi_set_ie(wil, WMI_FRAME_BEACON, bcon->tail_len, bcon->tail);
1052 static int _wil_cfg80211_start_ap(struct wiphy *wiphy,
1053 struct net_device *ndev,
1054 const u8 *ssid, size_t ssid_len, u32 privacy,
1056 struct cfg80211_beacon_data *bcon,
1057 u8 hidden_ssid, u32 pbss)
1059 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1061 struct wireless_dev *wdev = ndev->ieee80211_ptr;
1062 u8 wmi_nettype = wil_iftype_nl2wmi(wdev->iftype);
1063 u8 is_go = (wdev->iftype == NL80211_IFTYPE_P2P_GO);
1066 wmi_nettype = WMI_NETTYPE_P2P;
1068 wil_dbg_misc(wil, "%s: is_go=%d\n", __func__, is_go);
1069 if (is_go && !pbss) {
1070 wil_err(wil, "%s: P2P GO must be in PBSS\n", __func__);
1074 wil_set_recovery_state(wil, fw_recovery_idle);
1076 mutex_lock(&wil->mutex);
1083 rc = wmi_set_ssid(wil, ssid_len, ssid);
1087 rc = _wil_cfg80211_set_ies(wiphy, bcon);
1091 wil->privacy = privacy;
1092 wil->channel = chan;
1093 wil->hidden_ssid = hidden_ssid;
1096 netif_carrier_on(ndev);
1098 rc = wmi_pcp_start(wil, bi, wmi_nettype, chan, hidden_ssid, is_go);
1102 rc = wil_bcast_init(wil);
1106 goto out; /* success */
1111 netif_carrier_off(ndev);
1113 mutex_unlock(&wil->mutex);
1117 static int wil_cfg80211_change_beacon(struct wiphy *wiphy,
1118 struct net_device *ndev,
1119 struct cfg80211_beacon_data *bcon)
1121 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1125 wil_dbg_misc(wil, "%s()\n", __func__);
1126 wil_print_bcon_data(bcon);
1129 cfg80211_find_ie(WLAN_EID_RSN, bcon->tail,
1133 /* in case privacy has changed, need to restart the AP */
1134 if (wil->privacy != privacy) {
1135 struct wireless_dev *wdev = ndev->ieee80211_ptr;
1137 wil_dbg_misc(wil, "privacy changed %d=>%d. Restarting AP\n",
1138 wil->privacy, privacy);
1140 rc = _wil_cfg80211_start_ap(wiphy, ndev, wdev->ssid,
1141 wdev->ssid_len, privacy,
1142 wdev->beacon_interval,
1147 rc = _wil_cfg80211_set_ies(wiphy, bcon);
1153 static int wil_cfg80211_start_ap(struct wiphy *wiphy,
1154 struct net_device *ndev,
1155 struct cfg80211_ap_settings *info)
1158 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1159 struct ieee80211_channel *channel = info->chandef.chan;
1160 struct cfg80211_beacon_data *bcon = &info->beacon;
1161 struct cfg80211_crypto_settings *crypto = &info->crypto;
1164 wil_dbg_misc(wil, "%s()\n", __func__);
1167 wil_err(wil, "AP: No channel???\n");
1171 switch (info->hidden_ssid) {
1172 case NL80211_HIDDEN_SSID_NOT_IN_USE:
1173 hidden_ssid = WMI_HIDDEN_SSID_DISABLED;
1176 case NL80211_HIDDEN_SSID_ZERO_LEN:
1177 hidden_ssid = WMI_HIDDEN_SSID_SEND_EMPTY;
1180 case NL80211_HIDDEN_SSID_ZERO_CONTENTS:
1181 hidden_ssid = WMI_HIDDEN_SSID_CLEAR;
1185 wil_err(wil, "AP: Invalid hidden SSID %d\n", info->hidden_ssid);
1188 wil_dbg_misc(wil, "AP on Channel %d %d MHz, %s\n", channel->hw_value,
1189 channel->center_freq, info->privacy ? "secure" : "open");
1190 wil_dbg_misc(wil, "Privacy: %d auth_type %d\n",
1191 info->privacy, info->auth_type);
1192 wil_dbg_misc(wil, "Hidden SSID mode: %d\n",
1194 wil_dbg_misc(wil, "BI %d DTIM %d\n", info->beacon_interval,
1196 wil_dbg_misc(wil, "PBSS %d\n", info->pbss);
1197 print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
1198 info->ssid, info->ssid_len);
1199 wil_print_bcon_data(bcon);
1200 wil_print_crypto(wil, crypto);
1202 rc = _wil_cfg80211_start_ap(wiphy, ndev,
1203 info->ssid, info->ssid_len, info->privacy,
1204 info->beacon_interval, channel->hw_value,
1205 bcon, hidden_ssid, info->pbss);
1210 static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
1211 struct net_device *ndev)
1213 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1215 wil_dbg_misc(wil, "%s()\n", __func__);
1217 netif_carrier_off(ndev);
1218 wil_set_recovery_state(wil, fw_recovery_idle);
1220 mutex_lock(&wil->mutex);
1226 mutex_unlock(&wil->mutex);
1231 static int wil_cfg80211_del_station(struct wiphy *wiphy,
1232 struct net_device *dev,
1233 struct station_del_parameters *params)
1235 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1237 wil_dbg_misc(wil, "%s(%pM, reason=%d)\n", __func__, params->mac,
1238 params->reason_code);
1240 mutex_lock(&wil->mutex);
1241 wil6210_disconnect(wil, params->mac, params->reason_code, false);
1242 mutex_unlock(&wil->mutex);
1247 /* probe_client handling */
1248 static void wil_probe_client_handle(struct wil6210_priv *wil,
1249 struct wil_probe_client_req *req)
1251 struct net_device *ndev = wil_to_ndev(wil);
1252 struct wil_sta_info *sta = &wil->sta[req->cid];
1253 /* assume STA is alive if it is still connected,
1254 * else FW will disconnect it
1256 bool alive = (sta->status == wil_sta_connected);
1258 cfg80211_probe_status(ndev, sta->addr, req->cookie, alive, GFP_KERNEL);
1261 static struct list_head *next_probe_client(struct wil6210_priv *wil)
1263 struct list_head *ret = NULL;
1265 mutex_lock(&wil->probe_client_mutex);
1267 if (!list_empty(&wil->probe_client_pending)) {
1268 ret = wil->probe_client_pending.next;
1272 mutex_unlock(&wil->probe_client_mutex);
1277 void wil_probe_client_worker(struct work_struct *work)
1279 struct wil6210_priv *wil = container_of(work, struct wil6210_priv,
1280 probe_client_worker);
1281 struct wil_probe_client_req *req;
1282 struct list_head *lh;
1284 while ((lh = next_probe_client(wil)) != NULL) {
1285 req = list_entry(lh, struct wil_probe_client_req, list);
1287 wil_probe_client_handle(wil, req);
1292 void wil_probe_client_flush(struct wil6210_priv *wil)
1294 struct wil_probe_client_req *req, *t;
1296 wil_dbg_misc(wil, "%s()\n", __func__);
1298 mutex_lock(&wil->probe_client_mutex);
1300 list_for_each_entry_safe(req, t, &wil->probe_client_pending, list) {
1301 list_del(&req->list);
1305 mutex_unlock(&wil->probe_client_mutex);
1308 static int wil_cfg80211_probe_client(struct wiphy *wiphy,
1309 struct net_device *dev,
1310 const u8 *peer, u64 *cookie)
1312 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1313 struct wil_probe_client_req *req;
1314 int cid = wil_find_cid(wil, peer);
1316 wil_dbg_misc(wil, "%s(%pM => CID %d)\n", __func__, peer, cid);
1321 req = kzalloc(sizeof(*req), GFP_KERNEL);
1328 mutex_lock(&wil->probe_client_mutex);
1329 list_add_tail(&req->list, &wil->probe_client_pending);
1330 mutex_unlock(&wil->probe_client_mutex);
1332 *cookie = req->cookie;
1333 queue_work(wil->wq_service, &wil->probe_client_worker);
1337 static int wil_cfg80211_change_bss(struct wiphy *wiphy,
1338 struct net_device *dev,
1339 struct bss_parameters *params)
1341 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1343 if (params->ap_isolate >= 0) {
1344 wil_dbg_misc(wil, "%s(ap_isolate %d => %d)\n", __func__,
1345 wil->ap_isolate, params->ap_isolate);
1346 wil->ap_isolate = params->ap_isolate;
1352 static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy,
1353 struct wireless_dev *wdev)
1355 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1357 wil_dbg_misc(wil, "%s: entered\n", __func__);
1358 wil->p2p.p2p_dev_started = 1;
1362 static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy,
1363 struct wireless_dev *wdev)
1365 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
1368 wil_dbg_misc(wil, "%s: entered\n", __func__);
1369 mutex_lock(&wil->mutex);
1370 started = wil_p2p_stop_discovery(wil);
1371 if (started && wil->scan_request) {
1372 struct cfg80211_scan_info info = {
1376 cfg80211_scan_done(wil->scan_request, &info);
1377 wil->scan_request = NULL;
1378 wil->radio_wdev = wil->wdev;
1380 mutex_unlock(&wil->mutex);
1382 wil->p2p.p2p_dev_started = 0;
1385 static struct cfg80211_ops wil_cfg80211_ops = {
1386 .add_virtual_intf = wil_cfg80211_add_iface,
1387 .del_virtual_intf = wil_cfg80211_del_iface,
1388 .scan = wil_cfg80211_scan,
1389 .connect = wil_cfg80211_connect,
1390 .disconnect = wil_cfg80211_disconnect,
1391 .change_virtual_intf = wil_cfg80211_change_iface,
1392 .get_station = wil_cfg80211_get_station,
1393 .dump_station = wil_cfg80211_dump_station,
1394 .remain_on_channel = wil_remain_on_channel,
1395 .cancel_remain_on_channel = wil_cancel_remain_on_channel,
1396 .mgmt_tx = wil_cfg80211_mgmt_tx,
1397 .set_monitor_channel = wil_cfg80211_set_channel,
1398 .add_key = wil_cfg80211_add_key,
1399 .del_key = wil_cfg80211_del_key,
1400 .set_default_key = wil_cfg80211_set_default_key,
1402 .change_beacon = wil_cfg80211_change_beacon,
1403 .start_ap = wil_cfg80211_start_ap,
1404 .stop_ap = wil_cfg80211_stop_ap,
1405 .del_station = wil_cfg80211_del_station,
1406 .probe_client = wil_cfg80211_probe_client,
1407 .change_bss = wil_cfg80211_change_bss,
1409 .start_p2p_device = wil_cfg80211_start_p2p_device,
1410 .stop_p2p_device = wil_cfg80211_stop_p2p_device,
1413 static void wil_wiphy_init(struct wiphy *wiphy)
1415 wiphy->max_scan_ssids = 1;
1416 wiphy->max_scan_ie_len = WMI_MAX_IE_LEN;
1417 wiphy->max_remain_on_channel_duration = WIL_MAX_ROC_DURATION_MS;
1418 wiphy->max_num_pmkids = 0 /* TODO: */;
1419 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1420 BIT(NL80211_IFTYPE_AP) |
1421 BIT(NL80211_IFTYPE_P2P_CLIENT) |
1422 BIT(NL80211_IFTYPE_P2P_GO) |
1423 BIT(NL80211_IFTYPE_P2P_DEVICE) |
1424 BIT(NL80211_IFTYPE_MONITOR);
1425 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
1426 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
1427 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
1428 dev_dbg(wiphy_dev(wiphy), "%s : flags = 0x%08x\n",
1429 __func__, wiphy->flags);
1430 wiphy->probe_resp_offload =
1431 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
1432 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
1433 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
1435 wiphy->bands[NL80211_BAND_60GHZ] = &wil_band_60ghz;
1437 /* TODO: figure this out */
1438 wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
1440 wiphy->cipher_suites = wil_cipher_suites;
1441 wiphy->n_cipher_suites = ARRAY_SIZE(wil_cipher_suites);
1442 wiphy->mgmt_stypes = wil_mgmt_stypes;
1443 wiphy->features |= NL80211_FEATURE_SK_TX_STATUS;
1446 struct wireless_dev *wil_cfg80211_init(struct device *dev)
1449 struct wireless_dev *wdev;
1451 dev_dbg(dev, "%s()\n", __func__);
1453 wdev = kzalloc(sizeof(*wdev), GFP_KERNEL);
1455 return ERR_PTR(-ENOMEM);
1457 wdev->wiphy = wiphy_new(&wil_cfg80211_ops,
1458 sizeof(struct wil6210_priv));
1464 set_wiphy_dev(wdev->wiphy, dev);
1465 wil_wiphy_init(wdev->wiphy);
1467 rc = wiphy_register(wdev->wiphy);
1469 goto out_failed_reg;
1474 wiphy_free(wdev->wiphy);
1481 void wil_wdev_free(struct wil6210_priv *wil)
1483 struct wireless_dev *wdev = wil_to_wdev(wil);
1485 dev_dbg(wil_to_dev(wil), "%s()\n", __func__);
1490 wiphy_unregister(wdev->wiphy);
1491 wiphy_free(wdev->wiphy);
1495 void wil_p2p_wdev_free(struct wil6210_priv *wil)
1497 struct wireless_dev *p2p_wdev;
1499 mutex_lock(&wil->p2p_wdev_mutex);
1500 p2p_wdev = wil->p2p_wdev;
1502 wil->p2p_wdev = NULL;
1503 wil->radio_wdev = wil_to_wdev(wil);
1504 cfg80211_unregister_wdev(p2p_wdev);
1507 mutex_unlock(&wil->p2p_wdev_mutex);