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 /* scan on P2P_DEVICE is handled as p2p search */
379 if (wdev
->iftype
== NL80211_IFTYPE_P2P_DEVICE
) {
380 wil
->scan_request
= request
;
381 wil
->radio_wdev
= wdev
;
382 rc
= wil_p2p_search(wil
, request
);
384 wil
->radio_wdev
= wil_to_wdev(wil
);
385 wil
->scan_request
= NULL
;
390 (void)wil_p2p_stop_discovery(wil
);
392 wil_dbg_misc(wil
, "Start scan_request 0x%p\n", request
);
393 wil_dbg_misc(wil
, "SSID count: %d", request
->n_ssids
);
395 for (i
= 0; i
< request
->n_ssids
; i
++) {
396 wil_dbg_misc(wil
, "SSID[%d]", i
);
397 print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET
,
398 request
->ssids
[i
].ssid
,
399 request
->ssids
[i
].ssid_len
);
402 if (request
->n_ssids
)
403 rc
= wmi_set_ssid(wil
, request
->ssids
[0].ssid_len
,
404 request
->ssids
[0].ssid
);
406 rc
= wmi_set_ssid(wil
, 0, NULL
);
409 wil_err(wil
, "set SSID for scan request failed: %d\n", rc
);
413 wil
->scan_request
= request
;
414 mod_timer(&wil
->scan_timer
, jiffies
+ WIL6210_SCAN_TO
);
416 memset(&cmd
, 0, sizeof(cmd
));
417 cmd
.cmd
.scan_type
= WMI_ACTIVE_SCAN
;
418 cmd
.cmd
.num_channels
= 0;
419 n
= min(request
->n_channels
, 4U);
420 for (i
= 0; i
< n
; i
++) {
421 int ch
= request
->channels
[i
]->hw_value
;
425 "Scan requested for unknown frequency %dMhz\n",
426 request
->channels
[i
]->center_freq
);
429 /* 0-based channel indexes */
430 cmd
.cmd
.channel_list
[cmd
.cmd
.num_channels
++].channel
= ch
- 1;
431 wil_dbg_misc(wil
, "Scan for ch %d : %d MHz\n", ch
,
432 request
->channels
[i
]->center_freq
);
436 print_hex_dump_bytes("Scan IE ", DUMP_PREFIX_OFFSET
,
437 request
->ie
, request
->ie_len
);
439 wil_dbg_misc(wil
, "Scan has no IE's\n");
441 rc
= wmi_set_ie(wil
, WMI_FRAME_PROBE_REQ
, request
->ie_len
, request
->ie
);
445 if (wil
->discovery_mode
&& cmd
.cmd
.scan_type
== WMI_ACTIVE_SCAN
) {
446 cmd
.cmd
.discovery_mode
= 1;
447 wil_dbg_misc(wil
, "active scan with discovery_mode=1\n");
450 wil
->radio_wdev
= wdev
;
451 rc
= wmi_send(wil
, WMI_START_SCAN_CMDID
, &cmd
, sizeof(cmd
.cmd
) +
452 cmd
.cmd
.num_channels
* sizeof(cmd
.cmd
.channel_list
[0]));
456 del_timer_sync(&wil
->scan_timer
);
457 wil
->radio_wdev
= wil_to_wdev(wil
);
458 wil
->scan_request
= NULL
;
464 static void wil_print_crypto(struct wil6210_priv
*wil
,
465 struct cfg80211_crypto_settings
*c
)
469 wil_dbg_misc(wil
, "WPA versions: 0x%08x cipher group 0x%08x\n",
470 c
->wpa_versions
, c
->cipher_group
);
471 wil_dbg_misc(wil
, "Pairwise ciphers [%d] {\n", c
->n_ciphers_pairwise
);
472 n
= min_t(int, c
->n_ciphers_pairwise
, ARRAY_SIZE(c
->ciphers_pairwise
));
473 for (i
= 0; i
< n
; i
++)
474 wil_dbg_misc(wil
, " [%d] = 0x%08x\n", i
,
475 c
->ciphers_pairwise
[i
]);
476 wil_dbg_misc(wil
, "}\n");
477 wil_dbg_misc(wil
, "AKM suites [%d] {\n", c
->n_akm_suites
);
478 n
= min_t(int, c
->n_akm_suites
, ARRAY_SIZE(c
->akm_suites
));
479 for (i
= 0; i
< n
; i
++)
480 wil_dbg_misc(wil
, " [%d] = 0x%08x\n", i
,
482 wil_dbg_misc(wil
, "}\n");
483 wil_dbg_misc(wil
, "Control port : %d, eth_type 0x%04x no_encrypt %d\n",
484 c
->control_port
, be16_to_cpu(c
->control_port_ethertype
),
485 c
->control_port_no_encrypt
);
488 static void wil_print_connect_params(struct wil6210_priv
*wil
,
489 struct cfg80211_connect_params
*sme
)
491 wil_info(wil
, "Connecting to:\n");
493 wil_info(wil
, " Channel: %d freq %d\n",
494 sme
->channel
->hw_value
, sme
->channel
->center_freq
);
497 wil_info(wil
, " BSSID: %pM\n", sme
->bssid
);
499 print_hex_dump(KERN_INFO
, " SSID: ", DUMP_PREFIX_OFFSET
,
500 16, 1, sme
->ssid
, sme
->ssid_len
, true);
501 wil_info(wil
, " Privacy: %s\n", sme
->privacy
? "secure" : "open");
502 wil_info(wil
, " PBSS: %d\n", sme
->pbss
);
503 wil_print_crypto(wil
, &sme
->crypto
);
506 static int wil_cfg80211_connect(struct wiphy
*wiphy
,
507 struct net_device
*ndev
,
508 struct cfg80211_connect_params
*sme
)
510 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
511 struct cfg80211_bss
*bss
;
512 struct wmi_connect_cmd conn
;
517 enum ieee80211_bss_type bss_type
= IEEE80211_BSS_TYPE_ESS
;
519 wil_dbg_misc(wil
, "%s()\n", __func__
);
520 wil_print_connect_params(wil
, sme
);
522 if (test_bit(wil_status_fwconnecting
, wil
->status
) ||
523 test_bit(wil_status_fwconnected
, wil
->status
))
526 if (sme
->ie_len
> WMI_MAX_IE_LEN
) {
527 wil_err(wil
, "IE too large (%td bytes)\n", sme
->ie_len
);
532 cfg80211_find_ie(WLAN_EID_RSN
, sme
->ie
, sme
->ie_len
) :
534 if (sme
->privacy
&& !rsn_eid
)
535 wil_info(wil
, "WSC connection\n");
538 bss_type
= IEEE80211_BSS_TYPE_PBSS
;
540 bss
= cfg80211_get_bss(wiphy
, sme
->channel
, sme
->bssid
,
541 sme
->ssid
, sme
->ssid_len
,
542 bss_type
, IEEE80211_PRIVACY_ANY
);
544 wil_err(wil
, "Unable to find BSS\n");
548 ssid_eid
= ieee80211_bss_get_ie(bss
, WLAN_EID_SSID
);
550 wil_err(wil
, "No SSID\n");
554 wil
->privacy
= sme
->privacy
;
557 /* For secure assoc, remove old keys */
558 rc
= wmi_del_cipher_key(wil
, 0, bss
->bssid
,
559 WMI_KEY_USE_PAIRWISE
);
561 wil_err(wil
, "WMI_DELETE_CIPHER_KEY_CMD(PTK) failed\n");
564 rc
= wmi_del_cipher_key(wil
, 0, bss
->bssid
,
565 WMI_KEY_USE_RX_GROUP
);
567 wil_err(wil
, "WMI_DELETE_CIPHER_KEY_CMD(GTK) failed\n");
572 /* WMI_SET_APPIE_CMD. ie may contain rsn info as well as other info
573 * elements. Send it also in case it's empty, to erase previously set
576 rc
= wmi_set_ie(wil
, WMI_FRAME_ASSOC_REQ
, sme
->ie_len
, sme
->ie
);
580 /* WMI_CONNECT_CMD */
581 memset(&conn
, 0, sizeof(conn
));
582 switch (bss
->capability
& WLAN_CAPABILITY_DMG_TYPE_MASK
) {
583 case WLAN_CAPABILITY_DMG_TYPE_AP
:
584 conn
.network_type
= WMI_NETTYPE_INFRA
;
586 case WLAN_CAPABILITY_DMG_TYPE_PBSS
:
587 conn
.network_type
= WMI_NETTYPE_P2P
;
590 wil_err(wil
, "Unsupported BSS type, capability= 0x%04x\n",
595 if (rsn_eid
) { /* regular secure connection */
596 conn
.dot11_auth_mode
= WMI_AUTH11_SHARED
;
597 conn
.auth_mode
= WMI_AUTH_WPA2_PSK
;
598 conn
.pairwise_crypto_type
= WMI_CRYPT_AES_GCMP
;
599 conn
.pairwise_crypto_len
= 16;
600 conn
.group_crypto_type
= WMI_CRYPT_AES_GCMP
;
601 conn
.group_crypto_len
= 16;
603 conn
.dot11_auth_mode
= WMI_AUTH11_WSC
;
604 conn
.auth_mode
= WMI_AUTH_NONE
;
606 } else { /* insecure connection */
607 conn
.dot11_auth_mode
= WMI_AUTH11_OPEN
;
608 conn
.auth_mode
= WMI_AUTH_NONE
;
611 conn
.ssid_len
= min_t(u8
, ssid_eid
[1], 32);
612 memcpy(conn
.ssid
, ssid_eid
+2, conn
.ssid_len
);
614 ch
= bss
->channel
->hw_value
;
616 wil_err(wil
, "BSS at unknown frequency %dMhz\n",
617 bss
->channel
->center_freq
);
621 conn
.channel
= ch
- 1;
623 ether_addr_copy(conn
.bssid
, bss
->bssid
);
624 ether_addr_copy(conn
.dst_mac
, bss
->bssid
);
626 set_bit(wil_status_fwconnecting
, wil
->status
);
628 rc
= wmi_send(wil
, WMI_CONNECT_CMDID
, &conn
, sizeof(conn
));
630 netif_carrier_on(ndev
);
631 /* Connect can take lots of time */
632 mod_timer(&wil
->connect_timer
,
633 jiffies
+ msecs_to_jiffies(2000));
635 clear_bit(wil_status_fwconnecting
, wil
->status
);
639 cfg80211_put_bss(wiphy
, bss
);
644 static int wil_cfg80211_disconnect(struct wiphy
*wiphy
,
645 struct net_device
*ndev
,
649 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
651 wil_dbg_misc(wil
, "%s(reason=%d)\n", __func__
, reason_code
);
653 if (!(test_bit(wil_status_fwconnecting
, wil
->status
) ||
654 test_bit(wil_status_fwconnected
, wil
->status
))) {
655 wil_err(wil
, "%s: Disconnect was called while disconnected\n",
660 rc
= wmi_call(wil
, WMI_DISCONNECT_CMDID
, NULL
, 0,
661 WMI_DISCONNECT_EVENTID
, NULL
, 0,
662 WIL6210_DISCONNECT_TO_MS
);
664 wil_err(wil
, "%s: disconnect error %d\n", __func__
, rc
);
669 int wil_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
670 struct cfg80211_mgmt_tx_params
*params
,
673 const u8
*buf
= params
->buf
;
674 size_t len
= params
->len
;
675 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
677 bool tx_status
= false;
678 struct ieee80211_mgmt
*mgmt_frame
= (void *)buf
;
679 struct wmi_sw_tx_req_cmd
*cmd
;
681 struct wmi_cmd_hdr wmi
;
682 struct wmi_sw_tx_complete_event evt
;
685 /* Note, currently we do not support the "wait" parameter, user-space
686 * must call remain_on_channel before mgmt_tx or listen on a channel
687 * another way (AP/PCP or connected station)
688 * in addition we need to check if specified "chan" argument is
689 * different from currently "listened" channel and fail if it is.
692 wil_dbg_misc(wil
, "%s()\n", __func__
);
693 print_hex_dump_bytes("mgmt tx frame ", DUMP_PREFIX_OFFSET
, buf
, len
);
695 cmd
= kmalloc(sizeof(*cmd
) + len
, GFP_KERNEL
);
701 memcpy(cmd
->dst_mac
, mgmt_frame
->da
, WMI_MAC_LEN
);
702 cmd
->len
= cpu_to_le16(len
);
703 memcpy(cmd
->payload
, buf
, len
);
705 rc
= wmi_call(wil
, WMI_SW_TX_REQ_CMDID
, cmd
, sizeof(*cmd
) + len
,
706 WMI_SW_TX_COMPLETE_EVENTID
, &evt
, sizeof(evt
), 2000);
708 tx_status
= !evt
.evt
.status
;
712 cfg80211_mgmt_tx_status(wdev
, cookie
? *cookie
: 0, buf
, len
,
713 tx_status
, GFP_KERNEL
);
717 static int wil_cfg80211_set_channel(struct wiphy
*wiphy
,
718 struct cfg80211_chan_def
*chandef
)
720 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
721 struct wireless_dev
*wdev
= wil_to_wdev(wil
);
723 wdev
->preset_chandef
= *chandef
;
728 static enum wmi_key_usage
wil_detect_key_usage(struct wil6210_priv
*wil
,
731 struct wireless_dev
*wdev
= wil_to_wdev(wil
);
732 enum wmi_key_usage rc
;
735 rc
= WMI_KEY_USE_PAIRWISE
;
737 switch (wdev
->iftype
) {
738 case NL80211_IFTYPE_STATION
:
739 case NL80211_IFTYPE_P2P_CLIENT
:
740 rc
= WMI_KEY_USE_RX_GROUP
;
742 case NL80211_IFTYPE_AP
:
743 case NL80211_IFTYPE_P2P_GO
:
744 rc
= WMI_KEY_USE_TX_GROUP
;
747 /* TODO: Rx GTK or Tx GTK? */
748 wil_err(wil
, "Can't determine GTK type\n");
749 rc
= WMI_KEY_USE_RX_GROUP
;
753 wil_dbg_misc(wil
, "%s() -> %s\n", __func__
, key_usage_str
[rc
]);
758 static struct wil_tid_crypto_rx_single
*
759 wil_find_crypto_ctx(struct wil6210_priv
*wil
, u8 key_index
,
760 enum wmi_key_usage key_usage
, const u8
*mac_addr
)
764 struct wil_sta_info
*s
;
765 struct wil_tid_crypto_rx
*c
;
767 if (key_usage
== WMI_KEY_USE_TX_GROUP
)
768 return NULL
; /* not needed */
770 /* supplicant provides Rx group key in STA mode with NULL MAC address */
772 cid
= wil_find_cid(wil
, mac_addr
);
773 else if (key_usage
== WMI_KEY_USE_RX_GROUP
)
774 cid
= wil_find_cid_by_idx(wil
, 0);
776 wil_err(wil
, "No CID for %pM %s[%d]\n", mac_addr
,
777 key_usage_str
[key_usage
], key_index
);
782 if (key_usage
== WMI_KEY_USE_PAIRWISE
)
783 c
= &s
->tid_crypto_rx
[tid
];
785 c
= &s
->group_crypto_rx
;
787 return &c
->key_id
[key_index
];
790 static int wil_cfg80211_add_key(struct wiphy
*wiphy
,
791 struct net_device
*ndev
,
792 u8 key_index
, bool pairwise
,
794 struct key_params
*params
)
797 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
798 enum wmi_key_usage key_usage
= wil_detect_key_usage(wil
, pairwise
);
799 struct wil_tid_crypto_rx_single
*cc
= wil_find_crypto_ctx(wil
,
804 wil_dbg_misc(wil
, "%s(%pM %s[%d] PN %*phN)\n", __func__
,
805 mac_addr
, key_usage_str
[key_usage
], key_index
,
806 params
->seq_len
, params
->seq
);
809 wil_err(wil
, "Not connected, %s(%pM %s[%d] PN %*phN)\n",
810 __func__
, mac_addr
, key_usage_str
[key_usage
], key_index
,
811 params
->seq_len
, params
->seq
);
818 if (params
->seq
&& params
->seq_len
!= IEEE80211_GCMP_PN_LEN
) {
820 "Wrong PN len %d, %s(%pM %s[%d] PN %*phN)\n",
821 params
->seq_len
, __func__
, mac_addr
,
822 key_usage_str
[key_usage
], key_index
,
823 params
->seq_len
, params
->seq
);
827 rc
= wmi_add_cipher_key(wil
, key_index
, mac_addr
, params
->key_len
,
828 params
->key
, key_usage
);
829 if ((rc
== 0) && cc
) {
831 memcpy(cc
->pn
, params
->seq
, IEEE80211_GCMP_PN_LEN
);
833 memset(cc
->pn
, 0, IEEE80211_GCMP_PN_LEN
);
840 static int wil_cfg80211_del_key(struct wiphy
*wiphy
,
841 struct net_device
*ndev
,
842 u8 key_index
, bool pairwise
,
845 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
846 enum wmi_key_usage key_usage
= wil_detect_key_usage(wil
, pairwise
);
847 struct wil_tid_crypto_rx_single
*cc
= wil_find_crypto_ctx(wil
,
852 wil_dbg_misc(wil
, "%s(%pM %s[%d])\n", __func__
, mac_addr
,
853 key_usage_str
[key_usage
], key_index
);
856 wil_info(wil
, "Not connected, %s(%pM %s[%d])\n", __func__
,
857 mac_addr
, key_usage_str
[key_usage
], key_index
);
859 if (!IS_ERR_OR_NULL(cc
))
862 return wmi_del_cipher_key(wil
, key_index
, mac_addr
, key_usage
);
865 /* Need to be present or wiphy_new() will WARN */
866 static int wil_cfg80211_set_default_key(struct wiphy
*wiphy
,
867 struct net_device
*ndev
,
868 u8 key_index
, bool unicast
,
871 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
873 wil_dbg_misc(wil
, "%s: entered\n", __func__
);
877 static int wil_remain_on_channel(struct wiphy
*wiphy
,
878 struct wireless_dev
*wdev
,
879 struct ieee80211_channel
*chan
,
880 unsigned int duration
,
883 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
886 wil_dbg_misc(wil
, "%s() center_freq=%d, duration=%d iftype=%d\n",
887 __func__
, chan
->center_freq
, duration
, wdev
->iftype
);
889 rc
= wil_p2p_listen(wil
, duration
, chan
, cookie
);
893 wil
->radio_wdev
= wdev
;
895 cfg80211_ready_on_channel(wdev
, *cookie
, chan
, duration
,
901 static int wil_cancel_remain_on_channel(struct wiphy
*wiphy
,
902 struct wireless_dev
*wdev
,
905 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
907 wil_dbg_misc(wil
, "%s()\n", __func__
);
909 return wil_p2p_cancel_listen(wil
, cookie
);
913 * find a specific IE in a list of IEs
914 * return a pointer to the beginning of IE in the list
915 * or NULL if not found
917 static const u8
*_wil_cfg80211_find_ie(const u8
*ies
, u16 ies_len
, const u8
*ie
,
920 struct ieee80211_vendor_ie
*vie
;
923 /* IE tag at offset 0, length at offset 1 */
924 if (ie_len
< 2 || 2 + ie
[1] > ie_len
)
927 if (ie
[0] != WLAN_EID_VENDOR_SPECIFIC
)
928 return cfg80211_find_ie(ie
[0], ies
, ies_len
);
930 /* make sure there is room for 3 bytes OUI + 1 byte OUI type */
933 vie
= (struct ieee80211_vendor_ie
*)ie
;
934 oui
= vie
->oui
[0] << 16 | vie
->oui
[1] << 8 | vie
->oui
[2];
935 return cfg80211_find_vendor_ie(oui
, vie
->oui_type
, ies
,
940 * merge the IEs in two lists into a single list.
941 * do not include IEs from the second list which exist in the first list.
942 * add only vendor specific IEs from second list to keep
943 * the merged list sorted (since vendor-specific IE has the
944 * highest tag number)
945 * caller must free the allocated memory for merged IEs
947 static int _wil_cfg80211_merge_extra_ies(const u8
*ies1
, u16 ies1_len
,
948 const u8
*ies2
, u16 ies2_len
,
949 u8
**merged_ies
, u16
*merged_len
)
954 if (ies1_len
== 0 && ies2_len
== 0) {
960 buf
= kmalloc(ies1_len
+ ies2_len
, GFP_KERNEL
);
963 memcpy(buf
, ies1
, ies1_len
);
964 dpos
= buf
+ ies1_len
;
966 while (spos
+ 1 < ies2
+ ies2_len
) {
967 /* IE tag at offset 0, length at offset 1 */
968 u16 ielen
= 2 + spos
[1];
970 if (spos
+ ielen
> ies2
+ ies2_len
)
972 if (spos
[0] == WLAN_EID_VENDOR_SPECIFIC
&&
973 !_wil_cfg80211_find_ie(ies1
, ies1_len
, spos
, ielen
)) {
974 memcpy(dpos
, spos
, ielen
);
981 *merged_len
= dpos
- buf
;
985 static void wil_print_bcon_data(struct cfg80211_beacon_data
*b
)
987 print_hex_dump_bytes("head ", DUMP_PREFIX_OFFSET
,
988 b
->head
, b
->head_len
);
989 print_hex_dump_bytes("tail ", DUMP_PREFIX_OFFSET
,
990 b
->tail
, b
->tail_len
);
991 print_hex_dump_bytes("BCON IE ", DUMP_PREFIX_OFFSET
,
992 b
->beacon_ies
, b
->beacon_ies_len
);
993 print_hex_dump_bytes("PROBE ", DUMP_PREFIX_OFFSET
,
994 b
->probe_resp
, b
->probe_resp_len
);
995 print_hex_dump_bytes("PROBE IE ", DUMP_PREFIX_OFFSET
,
996 b
->proberesp_ies
, b
->proberesp_ies_len
);
997 print_hex_dump_bytes("ASSOC IE ", DUMP_PREFIX_OFFSET
,
998 b
->assocresp_ies
, b
->assocresp_ies_len
);
1001 /* internal functions for device reset and starting AP */
1002 static int _wil_cfg80211_set_ies(struct wiphy
*wiphy
,
1003 struct cfg80211_beacon_data
*bcon
)
1006 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1007 u16 len
= 0, proberesp_len
= 0;
1008 u8
*ies
= NULL
, *proberesp
= NULL
;
1010 if (bcon
->probe_resp
) {
1011 struct ieee80211_mgmt
*f
=
1012 (struct ieee80211_mgmt
*)bcon
->probe_resp
;
1013 size_t hlen
= offsetof(struct ieee80211_mgmt
,
1014 u
.probe_resp
.variable
);
1015 proberesp
= f
->u
.probe_resp
.variable
;
1016 proberesp_len
= bcon
->probe_resp_len
- hlen
;
1018 rc
= _wil_cfg80211_merge_extra_ies(proberesp
,
1020 bcon
->proberesp_ies
,
1021 bcon
->proberesp_ies_len
,
1027 rc
= wmi_set_ie(wil
, WMI_FRAME_PROBE_RESP
, len
, ies
);
1031 if (bcon
->assocresp_ies
)
1032 rc
= wmi_set_ie(wil
, WMI_FRAME_ASSOC_RESP
,
1033 bcon
->assocresp_ies_len
, bcon
->assocresp_ies
);
1035 rc
= wmi_set_ie(wil
, WMI_FRAME_ASSOC_RESP
, len
, ies
);
1036 #if 0 /* to use beacon IE's, remove this #if 0 */
1040 rc
= wmi_set_ie(wil
, WMI_FRAME_BEACON
, bcon
->tail_len
, bcon
->tail
);
1047 static int _wil_cfg80211_start_ap(struct wiphy
*wiphy
,
1048 struct net_device
*ndev
,
1049 const u8
*ssid
, size_t ssid_len
, u32 privacy
,
1051 struct cfg80211_beacon_data
*bcon
,
1052 u8 hidden_ssid
, u32 pbss
)
1054 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1056 struct wireless_dev
*wdev
= ndev
->ieee80211_ptr
;
1057 u8 wmi_nettype
= wil_iftype_nl2wmi(wdev
->iftype
);
1058 u8 is_go
= (wdev
->iftype
== NL80211_IFTYPE_P2P_GO
);
1061 wmi_nettype
= WMI_NETTYPE_P2P
;
1063 wil_dbg_misc(wil
, "%s: is_go=%d\n", __func__
, is_go
);
1064 if (is_go
&& !pbss
) {
1065 wil_err(wil
, "%s: P2P GO must be in PBSS\n", __func__
);
1069 wil_set_recovery_state(wil
, fw_recovery_idle
);
1071 mutex_lock(&wil
->mutex
);
1078 rc
= wmi_set_ssid(wil
, ssid_len
, ssid
);
1082 rc
= _wil_cfg80211_set_ies(wiphy
, bcon
);
1086 wil
->privacy
= privacy
;
1087 wil
->channel
= chan
;
1088 wil
->hidden_ssid
= hidden_ssid
;
1091 netif_carrier_on(ndev
);
1093 rc
= wmi_pcp_start(wil
, bi
, wmi_nettype
, chan
, hidden_ssid
, is_go
);
1097 rc
= wil_bcast_init(wil
);
1101 goto out
; /* success */
1106 netif_carrier_off(ndev
);
1108 mutex_unlock(&wil
->mutex
);
1112 static int wil_cfg80211_change_beacon(struct wiphy
*wiphy
,
1113 struct net_device
*ndev
,
1114 struct cfg80211_beacon_data
*bcon
)
1116 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1120 wil_dbg_misc(wil
, "%s()\n", __func__
);
1121 wil_print_bcon_data(bcon
);
1124 cfg80211_find_ie(WLAN_EID_RSN
, bcon
->tail
,
1128 /* in case privacy has changed, need to restart the AP */
1129 if (wil
->privacy
!= privacy
) {
1130 struct wireless_dev
*wdev
= ndev
->ieee80211_ptr
;
1132 wil_dbg_misc(wil
, "privacy changed %d=>%d. Restarting AP\n",
1133 wil
->privacy
, privacy
);
1135 rc
= _wil_cfg80211_start_ap(wiphy
, ndev
, wdev
->ssid
,
1136 wdev
->ssid_len
, privacy
,
1137 wdev
->beacon_interval
,
1142 rc
= _wil_cfg80211_set_ies(wiphy
, bcon
);
1148 static int wil_cfg80211_start_ap(struct wiphy
*wiphy
,
1149 struct net_device
*ndev
,
1150 struct cfg80211_ap_settings
*info
)
1153 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1154 struct ieee80211_channel
*channel
= info
->chandef
.chan
;
1155 struct cfg80211_beacon_data
*bcon
= &info
->beacon
;
1156 struct cfg80211_crypto_settings
*crypto
= &info
->crypto
;
1159 wil_dbg_misc(wil
, "%s()\n", __func__
);
1162 wil_err(wil
, "AP: No channel???\n");
1166 switch (info
->hidden_ssid
) {
1167 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1168 hidden_ssid
= WMI_HIDDEN_SSID_DISABLED
;
1171 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1172 hidden_ssid
= WMI_HIDDEN_SSID_SEND_EMPTY
;
1175 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1176 hidden_ssid
= WMI_HIDDEN_SSID_CLEAR
;
1180 wil_err(wil
, "AP: Invalid hidden SSID %d\n", info
->hidden_ssid
);
1183 wil_dbg_misc(wil
, "AP on Channel %d %d MHz, %s\n", channel
->hw_value
,
1184 channel
->center_freq
, info
->privacy
? "secure" : "open");
1185 wil_dbg_misc(wil
, "Privacy: %d auth_type %d\n",
1186 info
->privacy
, info
->auth_type
);
1187 wil_dbg_misc(wil
, "Hidden SSID mode: %d\n",
1189 wil_dbg_misc(wil
, "BI %d DTIM %d\n", info
->beacon_interval
,
1191 wil_dbg_misc(wil
, "PBSS %d\n", info
->pbss
);
1192 print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET
,
1193 info
->ssid
, info
->ssid_len
);
1194 wil_print_bcon_data(bcon
);
1195 wil_print_crypto(wil
, crypto
);
1197 rc
= _wil_cfg80211_start_ap(wiphy
, ndev
,
1198 info
->ssid
, info
->ssid_len
, info
->privacy
,
1199 info
->beacon_interval
, channel
->hw_value
,
1200 bcon
, hidden_ssid
, info
->pbss
);
1205 static int wil_cfg80211_stop_ap(struct wiphy
*wiphy
,
1206 struct net_device
*ndev
)
1208 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1210 wil_dbg_misc(wil
, "%s()\n", __func__
);
1212 netif_carrier_off(ndev
);
1213 wil_set_recovery_state(wil
, fw_recovery_idle
);
1215 mutex_lock(&wil
->mutex
);
1221 mutex_unlock(&wil
->mutex
);
1226 static int wil_cfg80211_del_station(struct wiphy
*wiphy
,
1227 struct net_device
*dev
,
1228 struct station_del_parameters
*params
)
1230 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1232 wil_dbg_misc(wil
, "%s(%pM, reason=%d)\n", __func__
, params
->mac
,
1233 params
->reason_code
);
1235 mutex_lock(&wil
->mutex
);
1236 wil6210_disconnect(wil
, params
->mac
, params
->reason_code
, false);
1237 mutex_unlock(&wil
->mutex
);
1242 /* probe_client handling */
1243 static void wil_probe_client_handle(struct wil6210_priv
*wil
,
1244 struct wil_probe_client_req
*req
)
1246 struct net_device
*ndev
= wil_to_ndev(wil
);
1247 struct wil_sta_info
*sta
= &wil
->sta
[req
->cid
];
1248 /* assume STA is alive if it is still connected,
1249 * else FW will disconnect it
1251 bool alive
= (sta
->status
== wil_sta_connected
);
1253 cfg80211_probe_status(ndev
, sta
->addr
, req
->cookie
, alive
, GFP_KERNEL
);
1256 static struct list_head
*next_probe_client(struct wil6210_priv
*wil
)
1258 struct list_head
*ret
= NULL
;
1260 mutex_lock(&wil
->probe_client_mutex
);
1262 if (!list_empty(&wil
->probe_client_pending
)) {
1263 ret
= wil
->probe_client_pending
.next
;
1267 mutex_unlock(&wil
->probe_client_mutex
);
1272 void wil_probe_client_worker(struct work_struct
*work
)
1274 struct wil6210_priv
*wil
= container_of(work
, struct wil6210_priv
,
1275 probe_client_worker
);
1276 struct wil_probe_client_req
*req
;
1277 struct list_head
*lh
;
1279 while ((lh
= next_probe_client(wil
)) != NULL
) {
1280 req
= list_entry(lh
, struct wil_probe_client_req
, list
);
1282 wil_probe_client_handle(wil
, req
);
1287 void wil_probe_client_flush(struct wil6210_priv
*wil
)
1289 struct wil_probe_client_req
*req
, *t
;
1291 wil_dbg_misc(wil
, "%s()\n", __func__
);
1293 mutex_lock(&wil
->probe_client_mutex
);
1295 list_for_each_entry_safe(req
, t
, &wil
->probe_client_pending
, list
) {
1296 list_del(&req
->list
);
1300 mutex_unlock(&wil
->probe_client_mutex
);
1303 static int wil_cfg80211_probe_client(struct wiphy
*wiphy
,
1304 struct net_device
*dev
,
1305 const u8
*peer
, u64
*cookie
)
1307 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1308 struct wil_probe_client_req
*req
;
1309 int cid
= wil_find_cid(wil
, peer
);
1311 wil_dbg_misc(wil
, "%s(%pM => CID %d)\n", __func__
, peer
, cid
);
1316 req
= kzalloc(sizeof(*req
), GFP_KERNEL
);
1323 mutex_lock(&wil
->probe_client_mutex
);
1324 list_add_tail(&req
->list
, &wil
->probe_client_pending
);
1325 mutex_unlock(&wil
->probe_client_mutex
);
1327 *cookie
= req
->cookie
;
1328 queue_work(wil
->wq_service
, &wil
->probe_client_worker
);
1332 static int wil_cfg80211_change_bss(struct wiphy
*wiphy
,
1333 struct net_device
*dev
,
1334 struct bss_parameters
*params
)
1336 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1338 if (params
->ap_isolate
>= 0) {
1339 wil_dbg_misc(wil
, "%s(ap_isolate %d => %d)\n", __func__
,
1340 wil
->ap_isolate
, params
->ap_isolate
);
1341 wil
->ap_isolate
= params
->ap_isolate
;
1347 static int wil_cfg80211_start_p2p_device(struct wiphy
*wiphy
,
1348 struct wireless_dev
*wdev
)
1350 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1352 wil_dbg_misc(wil
, "%s: entered\n", __func__
);
1356 static void wil_cfg80211_stop_p2p_device(struct wiphy
*wiphy
,
1357 struct wireless_dev
*wdev
)
1359 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1361 wil_dbg_misc(wil
, "%s: entered\n", __func__
);
1364 static struct cfg80211_ops wil_cfg80211_ops
= {
1365 .add_virtual_intf
= wil_cfg80211_add_iface
,
1366 .del_virtual_intf
= wil_cfg80211_del_iface
,
1367 .scan
= wil_cfg80211_scan
,
1368 .connect
= wil_cfg80211_connect
,
1369 .disconnect
= wil_cfg80211_disconnect
,
1370 .change_virtual_intf
= wil_cfg80211_change_iface
,
1371 .get_station
= wil_cfg80211_get_station
,
1372 .dump_station
= wil_cfg80211_dump_station
,
1373 .remain_on_channel
= wil_remain_on_channel
,
1374 .cancel_remain_on_channel
= wil_cancel_remain_on_channel
,
1375 .mgmt_tx
= wil_cfg80211_mgmt_tx
,
1376 .set_monitor_channel
= wil_cfg80211_set_channel
,
1377 .add_key
= wil_cfg80211_add_key
,
1378 .del_key
= wil_cfg80211_del_key
,
1379 .set_default_key
= wil_cfg80211_set_default_key
,
1381 .change_beacon
= wil_cfg80211_change_beacon
,
1382 .start_ap
= wil_cfg80211_start_ap
,
1383 .stop_ap
= wil_cfg80211_stop_ap
,
1384 .del_station
= wil_cfg80211_del_station
,
1385 .probe_client
= wil_cfg80211_probe_client
,
1386 .change_bss
= wil_cfg80211_change_bss
,
1388 .start_p2p_device
= wil_cfg80211_start_p2p_device
,
1389 .stop_p2p_device
= wil_cfg80211_stop_p2p_device
,
1392 static void wil_wiphy_init(struct wiphy
*wiphy
)
1394 wiphy
->max_scan_ssids
= 1;
1395 wiphy
->max_scan_ie_len
= WMI_MAX_IE_LEN
;
1396 wiphy
->max_remain_on_channel_duration
= WIL_MAX_ROC_DURATION_MS
;
1397 wiphy
->max_num_pmkids
= 0 /* TODO: */;
1398 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
1399 BIT(NL80211_IFTYPE_AP
) |
1400 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
1401 BIT(NL80211_IFTYPE_P2P_GO
) |
1402 BIT(NL80211_IFTYPE_P2P_DEVICE
) |
1403 BIT(NL80211_IFTYPE_MONITOR
);
1404 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
1405 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
1406 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
;
1407 dev_dbg(wiphy_dev(wiphy
), "%s : flags = 0x%08x\n",
1408 __func__
, wiphy
->flags
);
1409 wiphy
->probe_resp_offload
=
1410 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
1411 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
1412 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
1414 wiphy
->bands
[NL80211_BAND_60GHZ
] = &wil_band_60ghz
;
1416 /* TODO: figure this out */
1417 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_UNSPEC
;
1419 wiphy
->cipher_suites
= wil_cipher_suites
;
1420 wiphy
->n_cipher_suites
= ARRAY_SIZE(wil_cipher_suites
);
1421 wiphy
->mgmt_stypes
= wil_mgmt_stypes
;
1422 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
1425 struct wireless_dev
*wil_cfg80211_init(struct device
*dev
)
1428 struct wireless_dev
*wdev
;
1430 dev_dbg(dev
, "%s()\n", __func__
);
1432 wdev
= kzalloc(sizeof(*wdev
), GFP_KERNEL
);
1434 return ERR_PTR(-ENOMEM
);
1436 wdev
->wiphy
= wiphy_new(&wil_cfg80211_ops
,
1437 sizeof(struct wil6210_priv
));
1443 set_wiphy_dev(wdev
->wiphy
, dev
);
1444 wil_wiphy_init(wdev
->wiphy
);
1446 rc
= wiphy_register(wdev
->wiphy
);
1448 goto out_failed_reg
;
1453 wiphy_free(wdev
->wiphy
);
1460 void wil_wdev_free(struct wil6210_priv
*wil
)
1462 struct wireless_dev
*wdev
= wil_to_wdev(wil
);
1464 dev_dbg(wil_to_dev(wil
), "%s()\n", __func__
);
1469 wiphy_unregister(wdev
->wiphy
);
1470 wiphy_free(wdev
->wiphy
);
1474 void wil_p2p_wdev_free(struct wil6210_priv
*wil
)
1476 struct wireless_dev
*p2p_wdev
;
1478 mutex_lock(&wil
->p2p_wdev_mutex
);
1479 p2p_wdev
= wil
->p2p_wdev
;
1481 wil
->p2p_wdev
= NULL
;
1482 wil
->radio_wdev
= wil_to_wdev(wil
);
1483 cfg80211_unregister_wdev(p2p_wdev
);
1486 mutex_unlock(&wil
->p2p_wdev_mutex
);