2 * Copyright (c) 2012 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.
20 #define CHAN60G(_channel, _flags) { \
21 .band = IEEE80211_BAND_60GHZ, \
22 .center_freq = 56160 + (2160 * (_channel)), \
23 .hw_value = (_channel), \
25 .max_antenna_gain = 0, \
29 static struct ieee80211_channel wil_60ghz_channels[] = {
33 /* channel 4 not supported yet */
36 static struct ieee80211_supported_band wil_band_60ghz = {
37 .channels = wil_60ghz_channels,
38 .n_channels = ARRAY_SIZE(wil_60ghz_channels),
42 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, /* TODO */
43 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_8, /* TODO */
45 /* MCS 1..12 - SC PHY */
46 .rx_mask = {0xfe, 0x1f}, /* 1..12 */
47 .tx_params = IEEE80211_HT_MCS_TX_DEFINED, /* TODO */
52 static const struct ieee80211_txrx_stypes
53 wil_mgmt_stypes[NUM_NL80211_IFTYPES] = {
54 [NL80211_IFTYPE_STATION] = {
55 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
56 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
57 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
58 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
60 [NL80211_IFTYPE_AP] = {
61 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
62 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
63 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
64 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
66 [NL80211_IFTYPE_P2P_CLIENT] = {
67 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
68 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
69 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
70 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
72 [NL80211_IFTYPE_P2P_GO] = {
73 .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
74 BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
75 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
76 BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
80 static const u32 wil_cipher_suites[] = {
81 WLAN_CIPHER_SUITE_GCMP,
84 int wil_iftype_nl2wmi(enum nl80211_iftype type)
87 enum nl80211_iftype nl;
88 enum wmi_network_type wmi;
90 {NL80211_IFTYPE_ADHOC, WMI_NETTYPE_ADHOC},
91 {NL80211_IFTYPE_STATION, WMI_NETTYPE_INFRA},
92 {NL80211_IFTYPE_AP, WMI_NETTYPE_AP},
93 {NL80211_IFTYPE_P2P_CLIENT, WMI_NETTYPE_P2P},
94 {NL80211_IFTYPE_P2P_GO, WMI_NETTYPE_P2P},
95 {NL80211_IFTYPE_MONITOR, WMI_NETTYPE_ADHOC}, /* FIXME */
99 for (i = 0; i < ARRAY_SIZE(__nl2wmi); i++) {
100 if (__nl2wmi[i].nl == type)
101 return __nl2wmi[i].wmi;
107 int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid,
108 struct station_info *sinfo)
110 struct wmi_notify_req_cmd cmd = {
115 struct wil6210_mbox_hdr_wmi wmi;
116 struct wmi_notify_req_done_event evt;
118 struct wil_net_stats *stats = &wil->sta[cid].stats;
121 rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd),
122 WMI_NOTIFY_REQ_DONE_EVENTID, &reply, sizeof(reply), 20);
126 wil_dbg_wmi(wil, "Link status for CID %d: {\n"
127 " MCS %d TSF 0x%016llx\n"
128 " BF status 0x%08x SNR 0x%08x SQI %d%%\n"
129 " Tx Tpt %d goodput %d Rx goodput %d\n"
130 " Sectors(rx:tx) my %d:%d peer %d:%d\n""}\n",
131 cid, le16_to_cpu(reply.evt.bf_mcs),
132 le64_to_cpu(reply.evt.tsf), reply.evt.status,
133 le32_to_cpu(reply.evt.snr_val),
135 le32_to_cpu(reply.evt.tx_tpt),
136 le32_to_cpu(reply.evt.tx_goodput),
137 le32_to_cpu(reply.evt.rx_goodput),
138 le16_to_cpu(reply.evt.my_rx_sector),
139 le16_to_cpu(reply.evt.my_tx_sector),
140 le16_to_cpu(reply.evt.other_rx_sector),
141 le16_to_cpu(reply.evt.other_tx_sector));
143 sinfo->generation = wil->sinfo_gen;
145 sinfo->filled = STATION_INFO_RX_BYTES |
146 STATION_INFO_TX_BYTES |
147 STATION_INFO_RX_PACKETS |
148 STATION_INFO_TX_PACKETS |
149 STATION_INFO_RX_BITRATE |
150 STATION_INFO_TX_BITRATE |
151 STATION_INFO_RX_DROP_MISC |
152 STATION_INFO_TX_FAILED;
154 sinfo->txrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
155 sinfo->txrate.mcs = le16_to_cpu(reply.evt.bf_mcs);
156 sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G;
157 sinfo->rxrate.mcs = stats->last_mcs_rx;
158 sinfo->rx_bytes = stats->rx_bytes;
159 sinfo->rx_packets = stats->rx_packets;
160 sinfo->rx_dropped_misc = stats->rx_dropped;
161 sinfo->tx_bytes = stats->tx_bytes;
162 sinfo->tx_packets = stats->tx_packets;
163 sinfo->tx_failed = stats->tx_errors;
165 if (test_bit(wil_status_fwconnected, &wil->status)) {
166 sinfo->filled |= STATION_INFO_SIGNAL;
167 sinfo->signal = reply.evt.sqi;
173 static int wil_cfg80211_get_station(struct wiphy *wiphy,
174 struct net_device *ndev,
175 const u8 *mac, struct station_info *sinfo)
177 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
180 int cid = wil_find_cid(wil, mac);
182 wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
186 rc = wil_cid_fill_sinfo(wil, cid, sinfo);
192 * Find @idx-th active STA for station dump.
194 static int wil_find_cid_by_idx(struct wil6210_priv *wil, int idx)
198 for (i = 0; i < ARRAY_SIZE(wil->sta); i++) {
199 if (wil->sta[i].status == wil_sta_unused)
209 static int wil_cfg80211_dump_station(struct wiphy *wiphy,
210 struct net_device *dev, int idx,
211 u8 *mac, struct station_info *sinfo)
213 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
215 int cid = wil_find_cid_by_idx(wil, idx);
220 memcpy(mac, wil->sta[cid].addr, ETH_ALEN);
221 wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid);
223 rc = wil_cid_fill_sinfo(wil, cid, sinfo);
228 static int wil_cfg80211_change_iface(struct wiphy *wiphy,
229 struct net_device *ndev,
230 enum nl80211_iftype type, u32 *flags,
231 struct vif_params *params)
233 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
234 struct wireless_dev *wdev = wil->wdev;
237 case NL80211_IFTYPE_STATION:
238 case NL80211_IFTYPE_AP:
239 case NL80211_IFTYPE_P2P_CLIENT:
240 case NL80211_IFTYPE_P2P_GO:
242 case NL80211_IFTYPE_MONITOR:
244 wil->monitor_flags = *flags;
246 wil->monitor_flags = 0;
258 static int wil_cfg80211_scan(struct wiphy *wiphy,
259 struct cfg80211_scan_request *request)
261 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
262 struct wireless_dev *wdev = wil->wdev;
264 struct wmi_start_scan_cmd cmd;
270 if (wil->scan_request) {
271 wil_err(wil, "Already scanning\n");
275 /* check we are client side */
276 switch (wdev->iftype) {
277 case NL80211_IFTYPE_STATION:
278 case NL80211_IFTYPE_P2P_CLIENT:
284 /* FW don't support scan after connection attempt */
285 if (test_bit(wil_status_dontscan, &wil->status)) {
286 wil_err(wil, "Can't scan now\n");
290 wil_dbg_misc(wil, "Start scan_request 0x%p\n", request);
291 wil->scan_request = request;
292 mod_timer(&wil->scan_timer, jiffies + WIL6210_SCAN_TO);
294 memset(&cmd, 0, sizeof(cmd));
295 cmd.cmd.num_channels = 0;
296 n = min(request->n_channels, 4U);
297 for (i = 0; i < n; i++) {
298 int ch = request->channels[i]->hw_value;
301 "Scan requested for unknown frequency %dMhz\n",
302 request->channels[i]->center_freq);
305 /* 0-based channel indexes */
306 cmd.cmd.channel_list[cmd.cmd.num_channels++].channel = ch - 1;
307 wil_dbg_misc(wil, "Scan for ch %d : %d MHz\n", ch,
308 request->channels[i]->center_freq);
311 rc = wmi_send(wil, WMI_START_SCAN_CMDID, &cmd, sizeof(cmd.cmd) +
312 cmd.cmd.num_channels * sizeof(cmd.cmd.channel_list[0]));
315 wil->scan_request = NULL;
320 static int wil_cfg80211_connect(struct wiphy *wiphy,
321 struct net_device *ndev,
322 struct cfg80211_connect_params *sme)
324 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
325 struct cfg80211_bss *bss;
326 struct wmi_connect_cmd conn;
332 if (test_bit(wil_status_fwconnecting, &wil->status) ||
333 test_bit(wil_status_fwconnected, &wil->status))
336 bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid,
337 sme->ssid, sme->ssid_len,
338 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
340 wil_err(wil, "Unable to find BSS\n");
344 ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
346 wil_err(wil, "No SSID\n");
352 cfg80211_find_ie(WLAN_EID_RSN, sme->ie, sme->ie_len) :
355 if (sme->ie_len > WMI_MAX_IE_LEN) {
357 wil_err(wil, "IE too large (%td bytes)\n",
362 * For secure assoc, send:
363 * (1) WMI_DELETE_CIPHER_KEY_CMD
364 * (2) WMI_SET_APPIE_CMD
366 rc = wmi_del_cipher_key(wil, 0, bss->bssid);
368 wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD failed\n");
371 /* WMI_SET_APPIE_CMD */
372 rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_REQ, sme->ie_len, sme->ie);
374 wil_err(wil, "WMI_SET_APPIE_CMD failed\n");
379 /* WMI_CONNECT_CMD */
380 memset(&conn, 0, sizeof(conn));
381 switch (bss->capability & WLAN_CAPABILITY_DMG_TYPE_MASK) {
382 case WLAN_CAPABILITY_DMG_TYPE_AP:
383 conn.network_type = WMI_NETTYPE_INFRA;
385 case WLAN_CAPABILITY_DMG_TYPE_PBSS:
386 conn.network_type = WMI_NETTYPE_P2P;
389 wil_err(wil, "Unsupported BSS type, capability= 0x%04x\n",
394 conn.dot11_auth_mode = WMI_AUTH11_SHARED;
395 conn.auth_mode = WMI_AUTH_WPA2_PSK;
396 conn.pairwise_crypto_type = WMI_CRYPT_AES_GCMP;
397 conn.pairwise_crypto_len = 16;
399 conn.dot11_auth_mode = WMI_AUTH11_OPEN;
400 conn.auth_mode = WMI_AUTH_NONE;
403 conn.ssid_len = min_t(u8, ssid_eid[1], 32);
404 memcpy(conn.ssid, ssid_eid+2, conn.ssid_len);
406 ch = bss->channel->hw_value;
408 wil_err(wil, "BSS at unknown frequency %dMhz\n",
409 bss->channel->center_freq);
413 conn.channel = ch - 1;
415 memcpy(conn.bssid, bss->bssid, ETH_ALEN);
416 memcpy(conn.dst_mac, bss->bssid, ETH_ALEN);
418 set_bit(wil_status_fwconnecting, &wil->status);
420 rc = wmi_send(wil, WMI_CONNECT_CMDID, &conn, sizeof(conn));
422 /* Connect can take lots of time */
423 mod_timer(&wil->connect_timer,
424 jiffies + msecs_to_jiffies(2000));
426 clear_bit(wil_status_fwconnecting, &wil->status);
430 cfg80211_put_bss(wiphy, bss);
435 static int wil_cfg80211_disconnect(struct wiphy *wiphy,
436 struct net_device *ndev,
440 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
442 rc = wmi_send(wil, WMI_DISCONNECT_CMDID, NULL, 0);
447 int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
448 struct cfg80211_mgmt_tx_params *params,
451 const u8 *buf = params->buf;
452 size_t len = params->len;
453 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
455 bool tx_status = false;
456 struct ieee80211_mgmt *mgmt_frame = (void *)buf;
457 struct wmi_sw_tx_req_cmd *cmd;
459 struct wil6210_mbox_hdr_wmi wmi;
460 struct wmi_sw_tx_complete_event evt;
463 cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL);
469 memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN);
470 cmd->len = cpu_to_le16(len);
471 memcpy(cmd->payload, buf, len);
473 rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, cmd, sizeof(*cmd) + len,
474 WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000);
476 tx_status = !evt.evt.status;
480 cfg80211_mgmt_tx_status(wdev, cookie ? *cookie : 0, buf, len,
481 tx_status, GFP_KERNEL);
485 static int wil_cfg80211_set_channel(struct wiphy *wiphy,
486 struct cfg80211_chan_def *chandef)
488 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
489 struct wireless_dev *wdev = wil->wdev;
491 wdev->preset_chandef = *chandef;
496 static int wil_cfg80211_add_key(struct wiphy *wiphy,
497 struct net_device *ndev,
498 u8 key_index, bool pairwise,
500 struct key_params *params)
502 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
504 /* group key is not used */
508 return wmi_add_cipher_key(wil, key_index, mac_addr,
509 params->key_len, params->key);
512 static int wil_cfg80211_del_key(struct wiphy *wiphy,
513 struct net_device *ndev,
514 u8 key_index, bool pairwise,
517 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
519 /* group key is not used */
523 return wmi_del_cipher_key(wil, key_index, mac_addr);
526 /* Need to be present or wiphy_new() will WARN */
527 static int wil_cfg80211_set_default_key(struct wiphy *wiphy,
528 struct net_device *ndev,
529 u8 key_index, bool unicast,
535 static int wil_remain_on_channel(struct wiphy *wiphy,
536 struct wireless_dev *wdev,
537 struct ieee80211_channel *chan,
538 unsigned int duration,
541 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
544 /* TODO: handle duration */
545 wil_info(wil, "%s(%d, %d ms)\n", __func__, chan->center_freq, duration);
547 rc = wmi_set_channel(wil, chan->hw_value);
551 rc = wmi_rxon(wil, true);
556 static int wil_cancel_remain_on_channel(struct wiphy *wiphy,
557 struct wireless_dev *wdev,
560 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
563 wil_info(wil, "%s()\n", __func__);
565 rc = wmi_rxon(wil, false);
570 static void wil_print_bcon_data(struct cfg80211_beacon_data *b)
572 print_hex_dump_bytes("head ", DUMP_PREFIX_OFFSET,
573 b->head, b->head_len);
574 print_hex_dump_bytes("tail ", DUMP_PREFIX_OFFSET,
575 b->tail, b->tail_len);
576 print_hex_dump_bytes("BCON IE ", DUMP_PREFIX_OFFSET,
577 b->beacon_ies, b->beacon_ies_len);
578 print_hex_dump_bytes("PROBE ", DUMP_PREFIX_OFFSET,
579 b->probe_resp, b->probe_resp_len);
580 print_hex_dump_bytes("PROBE IE ", DUMP_PREFIX_OFFSET,
581 b->proberesp_ies, b->proberesp_ies_len);
582 print_hex_dump_bytes("ASSOC IE ", DUMP_PREFIX_OFFSET,
583 b->assocresp_ies, b->assocresp_ies_len);
586 static void wil_print_crypto(struct wil6210_priv *wil,
587 struct cfg80211_crypto_settings *c)
589 wil_dbg_misc(wil, "WPA versions: 0x%08x cipher group 0x%08x\n",
590 c->wpa_versions, c->cipher_group);
591 wil_dbg_misc(wil, "Pairwise ciphers [%d]\n", c->n_ciphers_pairwise);
592 wil_dbg_misc(wil, "AKM suites [%d]\n", c->n_akm_suites);
593 wil_dbg_misc(wil, "Control port : %d, eth_type 0x%04x no_encrypt %d\n",
594 c->control_port, be16_to_cpu(c->control_port_ethertype),
595 c->control_port_no_encrypt);
598 static int wil_fix_bcon(struct wil6210_priv *wil,
599 struct cfg80211_beacon_data *bcon)
601 struct ieee80211_mgmt *f = (struct ieee80211_mgmt *)bcon->probe_resp;
602 size_t hlen = offsetof(struct ieee80211_mgmt, u.probe_resp.variable);
605 if (bcon->probe_resp_len <= hlen)
608 if (!bcon->proberesp_ies) {
609 bcon->proberesp_ies = f->u.probe_resp.variable;
610 bcon->proberesp_ies_len = bcon->probe_resp_len - hlen;
613 if (!bcon->assocresp_ies) {
614 bcon->assocresp_ies = f->u.probe_resp.variable;
615 bcon->assocresp_ies_len = bcon->probe_resp_len - hlen;
622 static int wil_cfg80211_start_ap(struct wiphy *wiphy,
623 struct net_device *ndev,
624 struct cfg80211_ap_settings *info)
627 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
628 struct wireless_dev *wdev = ndev->ieee80211_ptr;
629 struct ieee80211_channel *channel = info->chandef.chan;
630 struct cfg80211_beacon_data *bcon = &info->beacon;
631 struct cfg80211_crypto_settings *crypto = &info->crypto;
632 u8 wmi_nettype = wil_iftype_nl2wmi(wdev->iftype);
634 wil_dbg_misc(wil, "%s()\n", __func__);
637 wil_err(wil, "AP: No channel???\n");
641 wil_dbg_misc(wil, "AP on Channel %d %d MHz, %s\n", channel->hw_value,
642 channel->center_freq, info->privacy ? "secure" : "open");
643 wil_dbg_misc(wil, "Privacy: %d auth_type %d\n",
644 info->privacy, info->auth_type);
645 wil_dbg_misc(wil, "BI %d DTIM %d\n", info->beacon_interval,
647 print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET,
648 info->ssid, info->ssid_len);
649 wil_print_bcon_data(bcon);
650 wil_print_crypto(wil, crypto);
652 if (wil_fix_bcon(wil, bcon)) {
653 wil_dbg_misc(wil, "Fixed bcon\n");
654 wil_print_bcon_data(bcon);
657 mutex_lock(&wil->mutex);
664 rc = wil_rx_init(wil);
668 rc = wmi_set_ssid(wil, info->ssid_len, info->ssid);
672 /* MAC address - pre-requisite for other commands */
673 wmi_set_mac_address(wil, ndev->dev_addr);
676 /* bcon 'head IE's are not relevant for 60g band */
678 * FW do not form regular beacon, so bcon IE's are not set
679 * For the DMG bcon, when it will be supported, bcon IE's will
680 * be reused; add something like:
681 * wmi_set_ie(wil, WMI_FRAME_BEACON, bcon->beacon_ies_len,
684 wmi_set_ie(wil, WMI_FRAME_PROBE_RESP, bcon->proberesp_ies_len,
685 bcon->proberesp_ies);
686 wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP, bcon->assocresp_ies_len,
687 bcon->assocresp_ies);
689 wil->secure_pcp = info->privacy;
691 rc = wmi_pcp_start(wil, info->beacon_interval, wmi_nettype,
697 netif_carrier_on(ndev);
700 mutex_unlock(&wil->mutex);
704 static int wil_cfg80211_stop_ap(struct wiphy *wiphy,
705 struct net_device *ndev)
708 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
710 wil_dbg_misc(wil, "%s()\n", __func__);
712 mutex_lock(&wil->mutex);
714 rc = wmi_pcp_stop(wil);
716 mutex_unlock(&wil->mutex);
720 static int wil_cfg80211_del_station(struct wiphy *wiphy,
721 struct net_device *dev, const u8 *mac)
723 struct wil6210_priv *wil = wiphy_to_wil(wiphy);
725 mutex_lock(&wil->mutex);
726 wil6210_disconnect(wil, mac);
727 mutex_unlock(&wil->mutex);
732 static struct cfg80211_ops wil_cfg80211_ops = {
733 .scan = wil_cfg80211_scan,
734 .connect = wil_cfg80211_connect,
735 .disconnect = wil_cfg80211_disconnect,
736 .change_virtual_intf = wil_cfg80211_change_iface,
737 .get_station = wil_cfg80211_get_station,
738 .dump_station = wil_cfg80211_dump_station,
739 .remain_on_channel = wil_remain_on_channel,
740 .cancel_remain_on_channel = wil_cancel_remain_on_channel,
741 .mgmt_tx = wil_cfg80211_mgmt_tx,
742 .set_monitor_channel = wil_cfg80211_set_channel,
743 .add_key = wil_cfg80211_add_key,
744 .del_key = wil_cfg80211_del_key,
745 .set_default_key = wil_cfg80211_set_default_key,
747 .start_ap = wil_cfg80211_start_ap,
748 .stop_ap = wil_cfg80211_stop_ap,
749 .del_station = wil_cfg80211_del_station,
752 static void wil_wiphy_init(struct wiphy *wiphy)
754 /* TODO: set real value */
755 wiphy->max_scan_ssids = 10;
756 wiphy->max_num_pmkids = 0 /* TODO: */;
757 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
758 BIT(NL80211_IFTYPE_AP) |
759 BIT(NL80211_IFTYPE_MONITOR);
760 /* TODO: enable P2P when integrated with supplicant:
761 * BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO)
763 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
764 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
765 dev_warn(wiphy_dev(wiphy), "%s : flags = 0x%08x\n",
766 __func__, wiphy->flags);
767 wiphy->probe_resp_offload =
768 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
769 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
770 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
772 wiphy->bands[IEEE80211_BAND_60GHZ] = &wil_band_60ghz;
774 /* TODO: figure this out */
775 wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC;
777 wiphy->cipher_suites = wil_cipher_suites;
778 wiphy->n_cipher_suites = ARRAY_SIZE(wil_cipher_suites);
779 wiphy->mgmt_stypes = wil_mgmt_stypes;
782 struct wireless_dev *wil_cfg80211_init(struct device *dev)
785 struct wireless_dev *wdev;
787 wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
789 return ERR_PTR(-ENOMEM);
791 wdev->wiphy = wiphy_new(&wil_cfg80211_ops,
792 sizeof(struct wil6210_priv));
798 set_wiphy_dev(wdev->wiphy, dev);
799 wil_wiphy_init(wdev->wiphy);
801 rc = wiphy_register(wdev->wiphy);
808 wiphy_free(wdev->wiphy);
815 void wil_wdev_free(struct wil6210_priv *wil)
817 struct wireless_dev *wdev = wil_to_wdev(wil);
822 wiphy_unregister(wdev->wiphy);
823 wiphy_free(wdev->wiphy);