hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
....@@ -1,18 +1,5 @@
1
-/*
2
- * Copyright (c) 2012-2012 Quantenna Communications, Inc.
3
- * All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License
7
- * as published by the Free Software Foundation; either version 2
8
- * of the License, or (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+/* Copyright (c) 2015-2016 Quantenna Communications. All rights reserved. */
163
174 #include <linux/kernel.h>
185 #include <linux/etherdevice.h>
....@@ -66,12 +53,15 @@
6653 static const struct ieee80211_txrx_stypes
6754 qtnf_mgmt_stypes[NUM_NL80211_IFTYPES] = {
6855 [NL80211_IFTYPE_STATION] = {
69
- .tx = BIT(IEEE80211_STYPE_ACTION >> 4),
56
+ .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
57
+ BIT(IEEE80211_STYPE_AUTH >> 4),
7058 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
71
- BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
59
+ BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
60
+ BIT(IEEE80211_STYPE_AUTH >> 4),
7261 },
7362 [NL80211_IFTYPE_AP] = {
74
- .tx = BIT(IEEE80211_STYPE_ACTION >> 4),
63
+ .tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
64
+ BIT(IEEE80211_STYPE_AUTH >> 4),
7565 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
7666 BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
7767 BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
....@@ -112,6 +102,21 @@
112102
113103 ret = cfg80211_check_combinations(wiphy, &params);
114104
105
+ if (ret)
106
+ return ret;
107
+
108
+ /* Check repeater interface combination: primary VIF should be STA only.
109
+ * STA (primary) + AP (secondary) is OK.
110
+ * AP (primary) + STA (secondary) is not supported.
111
+ */
112
+ vif = qtnf_mac_get_base_vif(mac);
113
+ if (vif && vif->wdev.iftype == NL80211_IFTYPE_AP &&
114
+ vif != change_vif && new_type == NL80211_IFTYPE_STATION) {
115
+ ret = -EINVAL;
116
+ pr_err("MAC%u invalid combination: AP as primary repeater interface is not supported\n",
117
+ mac->macid);
118
+ }
119
+
115120 return ret;
116121 }
117122
....@@ -122,7 +127,8 @@
122127 struct vif_params *params)
123128 {
124129 struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
125
- u8 *mac_addr;
130
+ u8 *mac_addr = NULL;
131
+ int use4addr = 0;
126132 int ret;
127133
128134 ret = qtnf_validate_iface_combinations(wiphy, vif, type);
....@@ -132,17 +138,17 @@
132138 return ret;
133139 }
134140
135
- if (params)
141
+ if (params) {
136142 mac_addr = params->macaddr;
137
- else
138
- mac_addr = NULL;
143
+ use4addr = params->use_4addr;
144
+ }
139145
140146 qtnf_scan_done(vif->mac, true);
141147
142
- ret = qtnf_cmd_send_change_intf_type(vif, type, mac_addr);
148
+ ret = qtnf_cmd_send_change_intf_type(vif, type, use4addr, mac_addr);
143149 if (ret) {
144
- pr_err("VIF%u.%u: failed to change VIF type: %d\n",
145
- vif->mac->macid, vif->vifid, ret);
150
+ pr_err("VIF%u.%u: failed to change type to %d\n",
151
+ vif->mac->macid, vif->vifid, type);
146152 return ret;
147153 }
148154
....@@ -154,6 +160,7 @@
154160 {
155161 struct net_device *netdev = wdev->netdev;
156162 struct qtnf_vif *vif;
163
+ struct sk_buff *skb;
157164
158165 if (WARN_ON(!netdev))
159166 return -EFAULT;
....@@ -166,6 +173,11 @@
166173 netif_tx_stop_all_queues(netdev);
167174 if (netif_carrier_ok(netdev))
168175 netif_carrier_off(netdev);
176
+
177
+ while ((skb = skb_dequeue(&vif->high_pri_tx_queue)))
178
+ dev_kfree_skb_any(skb);
179
+
180
+ cancel_work_sync(&vif->high_pri_tx_work);
169181
170182 if (netdev->reg_state == NETREG_REGISTERED)
171183 unregister_netdevice(netdev);
....@@ -190,6 +202,7 @@
190202 struct qtnf_wmac *mac;
191203 struct qtnf_vif *vif;
192204 u8 *mac_addr = NULL;
205
+ int use4addr = 0;
193206 int ret;
194207
195208 mac = wiphy_priv(wiphy);
....@@ -216,7 +229,6 @@
216229 eth_zero_addr(vif->mac_addr);
217230 eth_zero_addr(vif->bssid);
218231 vif->bss_priority = QTNF_DEF_BSS_PRIORITY;
219
- vif->sta_state = QTNF_STA_DISCONNECTED;
220232 memset(&vif->wdev, 0, sizeof(vif->wdev));
221233 vif->wdev.wiphy = wiphy;
222234 vif->wdev.iftype = type;
....@@ -226,37 +238,50 @@
226238 return ERR_PTR(-ENOTSUPP);
227239 }
228240
229
- if (params)
241
+ if (params) {
230242 mac_addr = params->macaddr;
243
+ use4addr = params->use_4addr;
244
+ }
231245
232
- if (qtnf_cmd_send_add_intf(vif, type, mac_addr)) {
233
- pr_err("VIF%u.%u: failed to add VIF\n", mac->macid, vif->vifid);
246
+ ret = qtnf_cmd_send_add_intf(vif, type, use4addr, mac_addr);
247
+ if (ret) {
248
+ pr_err("VIF%u.%u: failed to add VIF %pM\n",
249
+ mac->macid, vif->vifid, mac_addr);
234250 goto err_cmd;
235251 }
236252
237253 if (!is_valid_ether_addr(vif->mac_addr)) {
238254 pr_err("VIF%u.%u: FW reported bad MAC: %pM\n",
239255 mac->macid, vif->vifid, vif->mac_addr);
240
- goto err_mac;
256
+ ret = -EINVAL;
257
+ goto error_del_vif;
241258 }
242259
243
- if (qtnf_core_net_attach(mac, vif, name, name_assign_t)) {
260
+ ret = qtnf_core_net_attach(mac, vif, name, name_assign_t);
261
+ if (ret) {
244262 pr_err("VIF%u.%u: failed to attach netdev\n", mac->macid,
245263 vif->vifid);
246
- goto err_net;
264
+ goto error_del_vif;
265
+ }
266
+
267
+ if (qtnf_hwcap_is_set(&mac->bus->hw_info, QLINK_HW_CAPAB_HW_BRIDGE)) {
268
+ ret = qtnf_cmd_netdev_changeupper(vif, vif->netdev->ifindex);
269
+ if (ret) {
270
+ unregister_netdevice(vif->netdev);
271
+ vif->netdev = NULL;
272
+ goto error_del_vif;
273
+ }
247274 }
248275
249276 vif->wdev.netdev = vif->netdev;
250277 return &vif->wdev;
251278
252
-err_net:
253
- vif->netdev = NULL;
254
-err_mac:
279
+error_del_vif:
255280 qtnf_cmd_send_del_intf(vif);
256281 err_cmd:
257282 vif->wdev.iftype = NL80211_IFTYPE_UNSPECIFIED;
258283
259
- return ERR_PTR(-EFAULT);
284
+ return ERR_PTR(ret);
260285 }
261286
262287 static int qtnf_mgmt_set_appie(struct qtnf_vif *vif,
....@@ -335,12 +360,11 @@
335360 qtnf_scan_done(vif->mac, true);
336361
337362 ret = qtnf_cmd_send_stop_ap(vif);
338
- if (ret) {
363
+ if (ret)
339364 pr_err("VIF%u.%u: failed to stop AP operation in FW\n",
340365 vif->mac->macid, vif->vifid);
341366
342
- netif_carrier_off(vif->netdev);
343
- }
367
+ netif_carrier_off(vif->netdev);
344368
345369 return ret;
346370 }
....@@ -357,11 +381,6 @@
357381 return -EFAULT;
358382 }
359383
360
- if (changed & (WIPHY_PARAM_RETRY_LONG | WIPHY_PARAM_RETRY_SHORT)) {
361
- pr_err("MAC%u: can't modify retry params\n", mac->macid);
362
- return -EOPNOTSUPP;
363
- }
364
-
365384 ret = qtnf_cmd_send_update_phy_params(mac, changed);
366385 if (ret)
367386 pr_err("MAC%u: failed to update PHY params\n", mac->macid);
....@@ -370,55 +389,57 @@
370389 }
371390
372391 static void
373
-qtnf_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev,
374
- u16 frame_type, bool reg)
392
+qtnf_update_mgmt_frame_registrations(struct wiphy *wiphy,
393
+ struct wireless_dev *wdev,
394
+ struct mgmt_frame_regs *upd)
375395 {
376396 struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev);
377
- u16 mgmt_type;
378
- u16 new_mask;
379
- u16 qlink_frame_type = 0;
397
+ u16 new_mask = upd->interface_stypes;
398
+ u16 old_mask = vif->mgmt_frames_bitmask;
399
+ static const struct {
400
+ u16 mask, qlink_type;
401
+ } updates[] = {
402
+ {
403
+ .mask = BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
404
+ BIT(IEEE80211_STYPE_ASSOC_REQ >> 4),
405
+ .qlink_type = QLINK_MGMT_FRAME_ASSOC_REQ,
406
+ },
407
+ {
408
+ .mask = BIT(IEEE80211_STYPE_AUTH >> 4),
409
+ .qlink_type = QLINK_MGMT_FRAME_AUTH,
410
+ },
411
+ {
412
+ .mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4),
413
+ .qlink_type = QLINK_MGMT_FRAME_PROBE_REQ,
414
+ },
415
+ {
416
+ .mask = BIT(IEEE80211_STYPE_ACTION >> 4),
417
+ .qlink_type = QLINK_MGMT_FRAME_ACTION,
418
+ },
419
+ };
420
+ unsigned int i;
380421
381
- mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
382
-
383
- if (reg)
384
- new_mask = vif->mgmt_frames_bitmask | BIT(mgmt_type);
385
- else
386
- new_mask = vif->mgmt_frames_bitmask & ~BIT(mgmt_type);
387
-
388
- if (new_mask == vif->mgmt_frames_bitmask)
422
+ if (new_mask == old_mask)
389423 return;
390424
391
- switch (frame_type & IEEE80211_FCTL_STYPE) {
392
- case IEEE80211_STYPE_REASSOC_REQ:
393
- case IEEE80211_STYPE_ASSOC_REQ:
394
- qlink_frame_type = QLINK_MGMT_FRAME_ASSOC_REQ;
395
- break;
396
- case IEEE80211_STYPE_AUTH:
397
- qlink_frame_type = QLINK_MGMT_FRAME_AUTH;
398
- break;
399
- case IEEE80211_STYPE_PROBE_REQ:
400
- qlink_frame_type = QLINK_MGMT_FRAME_PROBE_REQ;
401
- break;
402
- case IEEE80211_STYPE_ACTION:
403
- qlink_frame_type = QLINK_MGMT_FRAME_ACTION;
404
- break;
405
- default:
406
- pr_warn("VIF%u.%u: unsupported frame type: %X\n",
407
- vif->mac->macid, vif->vifid,
408
- (frame_type & IEEE80211_FCTL_STYPE) >> 4);
409
- return;
410
- }
425
+ for (i = 0; i < ARRAY_SIZE(updates); i++) {
426
+ u16 mask = updates[i].mask;
427
+ u16 qlink_frame_type = updates[i].qlink_type;
428
+ bool reg;
411429
412
- if (qtnf_cmd_send_register_mgmt(vif, qlink_frame_type, reg)) {
413
- pr_warn("VIF%u.%u: failed to %sregister mgmt frame type 0x%x\n",
414
- vif->mac->macid, vif->vifid, reg ? "" : "un",
415
- frame_type);
416
- return;
430
+ /* the ! are here due to the assoc/reassoc merge */
431
+ if (!(new_mask & mask) == !(old_mask & mask))
432
+ continue;
433
+
434
+ reg = new_mask & mask;
435
+
436
+ if (qtnf_cmd_send_register_mgmt(vif, qlink_frame_type, reg))
437
+ pr_warn("VIF%u.%u: failed to %sregister qlink frame type 0x%x\n",
438
+ vif->mac->macid, vif->vifid, reg ? "" : "un",
439
+ qlink_frame_type);
417440 }
418441
419442 vif->mgmt_frames_bitmask = new_mask;
420
- pr_debug("VIF%u.%u: %sregistered mgmt frame type 0x%x\n",
421
- vif->mac->macid, vif->vifid, reg ? "" : "un", frame_type);
422443 }
423444
424445 static int
....@@ -434,13 +455,13 @@
434455 *cookie = short_cookie;
435456
436457 if (params->offchan)
437
- flags |= QLINK_MGMT_FRAME_TX_FLAG_OFFCHAN;
458
+ flags |= QLINK_FRAME_TX_FLAG_OFFCHAN;
438459
439460 if (params->no_cck)
440
- flags |= QLINK_MGMT_FRAME_TX_FLAG_NO_CCK;
461
+ flags |= QLINK_FRAME_TX_FLAG_NO_CCK;
441462
442463 if (params->dont_wait_for_ack)
443
- flags |= QLINK_MGMT_FRAME_TX_FLAG_ACK_NOWAIT;
464
+ flags |= QLINK_FRAME_TX_FLAG_ACK_NOWAIT;
444465
445466 /* If channel is not specified, pass "freq = 0" to tell device
446467 * firmware to use current channel.
....@@ -455,9 +476,8 @@
455476 le16_to_cpu(mgmt_frame->frame_control), mgmt_frame->da,
456477 params->len, short_cookie, flags);
457478
458
- return qtnf_cmd_send_mgmt_frame(vif, short_cookie, flags,
459
- freq,
460
- params->buf, params->len);
479
+ return qtnf_cmd_send_frame(vif, short_cookie, flags,
480
+ freq, params->buf, params->len);
461481 }
462482
463483 static int
....@@ -478,19 +498,31 @@
478498 const struct qtnf_sta_node *sta_node;
479499 int ret;
480500
481
- sta_node = qtnf_sta_list_lookup_index(&vif->sta_list, idx);
501
+ switch (vif->wdev.iftype) {
502
+ case NL80211_IFTYPE_STATION:
503
+ if (idx != 0 || !vif->wdev.current_bss)
504
+ return -ENOENT;
482505
483
- if (unlikely(!sta_node))
484
- return -ENOENT;
506
+ ether_addr_copy(mac, vif->bssid);
507
+ break;
508
+ case NL80211_IFTYPE_AP:
509
+ sta_node = qtnf_sta_list_lookup_index(&vif->sta_list, idx);
510
+ if (unlikely(!sta_node))
511
+ return -ENOENT;
485512
486
- ether_addr_copy(mac, sta_node->mac_addr);
513
+ ether_addr_copy(mac, sta_node->mac_addr);
514
+ break;
515
+ default:
516
+ return -ENOTSUPP;
517
+ }
487518
488
- ret = qtnf_cmd_get_sta_info(vif, sta_node->mac_addr, sinfo);
519
+ ret = qtnf_cmd_get_sta_info(vif, mac, sinfo);
489520
490
- if (unlikely(ret == -ENOENT)) {
491
- qtnf_sta_list_del(vif, mac);
492
- cfg80211_del_sta(vif->netdev, mac, GFP_KERNEL);
493
- sinfo->filled = 0;
521
+ if (vif->wdev.iftype == NL80211_IFTYPE_AP) {
522
+ if (ret == -ENOENT) {
523
+ cfg80211_del_sta(vif->netdev, mac, GFP_KERNEL);
524
+ sinfo->filled = 0;
525
+ }
494526 }
495527
496528 sinfo->generation = vif->generation;
....@@ -597,6 +629,7 @@
597629 if (ret)
598630 pr_err("VIF%u.%u: failed to delete STA %pM\n",
599631 vif->mac->macid, vif->vifid, params->mac);
632
+
600633 return ret;
601634 }
602635
....@@ -604,21 +637,25 @@
604637 qtnf_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
605638 {
606639 struct qtnf_wmac *mac = wiphy_priv(wiphy);
640
+ int ret;
607641
608642 cancel_delayed_work_sync(&mac->scan_timeout);
609643
610644 mac->scan_req = request;
611645
612
- if (qtnf_cmd_send_scan(mac)) {
646
+ ret = qtnf_cmd_send_scan(mac);
647
+ if (ret) {
613648 pr_err("MAC%u: failed to start scan\n", mac->macid);
614649 mac->scan_req = NULL;
615
- return -EFAULT;
650
+ goto out;
616651 }
617652
653
+ pr_debug("MAC%u: scan started\n", mac->macid);
618654 queue_delayed_work(mac->bus->workqueue, &mac->scan_timeout,
619655 QTNF_SCAN_TIMEOUT_SEC * HZ);
620656
621
- return 0;
657
+out:
658
+ return ret;
622659 }
623660
624661 static int
....@@ -631,8 +668,11 @@
631668 if (vif->wdev.iftype != NL80211_IFTYPE_STATION)
632669 return -EOPNOTSUPP;
633670
634
- if (vif->sta_state != QTNF_STA_DISCONNECTED)
635
- return -EBUSY;
671
+ if (sme->auth_type == NL80211_AUTHTYPE_SAE &&
672
+ !(sme->flags & CONNECT_REQ_EXTERNAL_AUTH_SUPPORT)) {
673
+ pr_err("can not offload authentication to userspace\n");
674
+ return -EOPNOTSUPP;
675
+ }
636676
637677 if (sme->bssid)
638678 ether_addr_copy(vif->bssid, sme->bssid);
....@@ -641,13 +681,35 @@
641681
642682 ret = qtnf_cmd_send_connect(vif, sme);
643683 if (ret) {
644
- pr_err("VIF%u.%u: failed to connect\n", vif->mac->macid,
645
- vif->vifid);
646
- return ret;
684
+ pr_err("VIF%u.%u: failed to connect\n",
685
+ vif->mac->macid, vif->vifid);
686
+ goto out;
647687 }
648688
649
- vif->sta_state = QTNF_STA_CONNECTING;
650
- return 0;
689
+out:
690
+ return ret;
691
+}
692
+
693
+static int
694
+qtnf_external_auth(struct wiphy *wiphy, struct net_device *dev,
695
+ struct cfg80211_external_auth_params *auth)
696
+{
697
+ struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
698
+ int ret;
699
+
700
+ if (vif->wdev.iftype == NL80211_IFTYPE_STATION &&
701
+ !ether_addr_equal(vif->bssid, auth->bssid))
702
+ pr_warn("unexpected bssid: %pM", auth->bssid);
703
+
704
+ ret = qtnf_cmd_send_external_auth(vif, auth);
705
+ if (ret) {
706
+ pr_err("VIF%u.%u: failed to report external auth\n",
707
+ vif->mac->macid, vif->vifid);
708
+ goto out;
709
+ }
710
+
711
+out:
712
+ return ret;
651713 }
652714
653715 static int
....@@ -669,22 +731,18 @@
669731 goto out;
670732 }
671733
672
- qtnf_scan_done(mac, true);
673
-
674
- if (vif->sta_state == QTNF_STA_DISCONNECTED)
675
- goto out;
676
-
677734 ret = qtnf_cmd_send_disconnect(vif, reason_code);
678
- if (ret) {
679
- pr_err("VIF%u.%u: failed to disconnect\n", mac->macid,
680
- vif->vifid);
681
- goto out;
735
+ if (ret)
736
+ pr_err("VIF%u.%u: failed to disconnect\n",
737
+ mac->macid, vif->vifid);
738
+
739
+ if (vif->wdev.current_bss) {
740
+ netif_carrier_off(vif->netdev);
741
+ cfg80211_disconnected(vif->netdev, reason_code,
742
+ NULL, 0, true, GFP_KERNEL);
682743 }
683744
684745 out:
685
- if (vif->sta_state == QTNF_STA_CONNECTING)
686
- vif->sta_state = QTNF_STA_DISCONNECTED;
687
-
688746 return ret;
689747 }
690748
....@@ -697,11 +755,7 @@
697755 struct ieee80211_supported_band *sband;
698756 const struct cfg80211_chan_def *chandef = &wdev->chandef;
699757 struct ieee80211_channel *chan;
700
- struct qtnf_chan_stats stats;
701
- struct qtnf_vif *vif;
702758 int ret;
703
-
704
- vif = qtnf_netdev_get_priv(dev);
705759
706760 sband = wiphy->bands[NL80211_BAND_2GHZ];
707761 if (sband && idx >= sband->n_channels) {
....@@ -716,50 +770,16 @@
716770 return -ENOENT;
717771
718772 chan = &sband->channels[idx];
719
- memset(&stats, 0, sizeof(stats));
720
-
721773 survey->channel = chan;
722774 survey->filled = 0x0;
723775
724
- if (chandef->chan) {
725
- if (chan->hw_value == chandef->chan->hw_value)
726
- survey->filled = SURVEY_INFO_IN_USE;
727
- }
776
+ if (chan == chandef->chan)
777
+ survey->filled = SURVEY_INFO_IN_USE;
728778
729
- ret = qtnf_cmd_get_chan_stats(mac, chan->hw_value, &stats);
730
- switch (ret) {
731
- case 0:
732
- if (unlikely(stats.chan_num != chan->hw_value)) {
733
- pr_err("received stats for channel %d instead of %d\n",
734
- stats.chan_num, chan->hw_value);
735
- ret = -EINVAL;
736
- break;
737
- }
738
-
739
- survey->filled |= SURVEY_INFO_TIME |
740
- SURVEY_INFO_TIME_SCAN |
741
- SURVEY_INFO_TIME_BUSY |
742
- SURVEY_INFO_TIME_RX |
743
- SURVEY_INFO_TIME_TX |
744
- SURVEY_INFO_NOISE_DBM;
745
-
746
- survey->time_scan = stats.cca_try;
747
- survey->time = stats.cca_try;
748
- survey->time_tx = stats.cca_tx;
749
- survey->time_rx = stats.cca_rx;
750
- survey->time_busy = stats.cca_busy;
751
- survey->noise = stats.chan_noise;
752
- break;
753
- case -ENOENT:
754
- pr_debug("no stats for channel %u\n", chan->hw_value);
755
- ret = 0;
756
- break;
757
- default:
779
+ ret = qtnf_cmd_get_chan_stats(mac, chan->center_freq, survey);
780
+ if (ret)
758781 pr_debug("failed to get chan(%d) stats from card\n",
759782 chan->hw_value);
760
- ret = -EINVAL;
761
- break;
762
- }
763783
764784 return ret;
765785 }
....@@ -780,6 +800,7 @@
780800 ret = qtnf_cmd_get_channel(vif, chandef);
781801 if (ret) {
782802 pr_err("%s: failed to get channel: %d\n", ndev->name, ret);
803
+ ret = -ENODATA;
783804 goto out;
784805 }
785806
....@@ -789,6 +810,7 @@
789810 chandef->center_freq1, chandef->center_freq2,
790811 chandef->width);
791812 ret = -ENODATA;
813
+ goto out;
792814 }
793815
794816 out:
....@@ -858,11 +880,68 @@
858880
859881 ret = qtnf_cmd_send_pm_set(vif, enabled ? QLINK_PM_AUTO_STANDBY :
860882 QLINK_PM_OFF, timeout);
861
- if (ret) {
883
+ if (ret)
862884 pr_err("%s: failed to set PM mode ret=%d\n", dev->name, ret);
863
- return ret;
885
+
886
+ return ret;
887
+}
888
+
889
+static int qtnf_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
890
+ int *dbm)
891
+{
892
+ struct qtnf_vif *vif = qtnf_netdev_get_priv(wdev->netdev);
893
+ int ret;
894
+
895
+ ret = qtnf_cmd_get_tx_power(vif, dbm);
896
+ if (ret)
897
+ pr_err("MAC%u: failed to get Tx power\n", vif->mac->macid);
898
+
899
+ return ret;
900
+}
901
+
902
+static int qtnf_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
903
+ enum nl80211_tx_power_setting type, int mbm)
904
+{
905
+ struct qtnf_vif *vif;
906
+ int ret;
907
+
908
+ if (wdev) {
909
+ vif = qtnf_netdev_get_priv(wdev->netdev);
910
+ } else {
911
+ struct qtnf_wmac *mac = wiphy_priv(wiphy);
912
+
913
+ vif = qtnf_mac_get_base_vif(mac);
914
+ if (!vif) {
915
+ pr_err("MAC%u: primary VIF is not configured\n",
916
+ mac->macid);
917
+ return -EFAULT;
918
+ }
864919 }
865920
921
+ ret = qtnf_cmd_set_tx_power(vif, type, mbm);
922
+ if (ret)
923
+ pr_err("MAC%u: failed to set Tx power\n", vif->mac->macid);
924
+
925
+ return ret;
926
+}
927
+
928
+static int qtnf_update_owe_info(struct wiphy *wiphy, struct net_device *dev,
929
+ struct cfg80211_update_owe_info *owe_info)
930
+{
931
+ struct qtnf_vif *vif = qtnf_netdev_get_priv(dev);
932
+ int ret;
933
+
934
+ if (vif->wdev.iftype != NL80211_IFTYPE_AP)
935
+ return -EOPNOTSUPP;
936
+
937
+ ret = qtnf_cmd_send_update_owe(vif, owe_info);
938
+ if (ret) {
939
+ pr_err("VIF%u.%u: failed to update owe info\n",
940
+ vif->mac->macid, vif->vifid);
941
+ goto out;
942
+ }
943
+
944
+out:
866945 return ret;
867946 }
868947
....@@ -940,7 +1019,8 @@
9401019 .change_beacon = qtnf_change_beacon,
9411020 .stop_ap = qtnf_stop_ap,
9421021 .set_wiphy_params = qtnf_set_wiphy_params,
943
- .mgmt_frame_register = qtnf_mgmt_frame_register,
1022
+ .update_mgmt_frame_registrations =
1023
+ qtnf_update_mgmt_frame_registrations,
9441024 .mgmt_tx = qtnf_mgmt_tx,
9451025 .change_station = qtnf_change_station,
9461026 .del_station = qtnf_del_station,
....@@ -952,6 +1032,7 @@
9521032 .set_default_mgmt_key = qtnf_set_default_mgmt_key,
9531033 .scan = qtnf_scan,
9541034 .connect = qtnf_connect,
1035
+ .external_auth = qtnf_external_auth,
9551036 .disconnect = qtnf_disconnect,
9561037 .dump_survey = qtnf_dump_survey,
9571038 .get_channel = qtnf_get_channel,
....@@ -959,6 +1040,9 @@
9591040 .start_radar_detection = qtnf_start_radar_detection,
9601041 .set_mac_acl = qtnf_set_mac_acl,
9611042 .set_power_mgmt = qtnf_set_power_mgmt,
1043
+ .get_tx_power = qtnf_get_tx_power,
1044
+ .set_tx_power = qtnf_set_tx_power,
1045
+ .update_owe_info = qtnf_update_owe_info,
9621046 #ifdef CONFIG_PM
9631047 .suspend = qtnf_suspend,
9641048 .resume = qtnf_resume,
....@@ -966,64 +1050,55 @@
9661050 #endif
9671051 };
9681052
969
-static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in,
1053
+static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy,
9701054 struct regulatory_request *req)
9711055 {
972
- struct qtnf_wmac *mac = wiphy_priv(wiphy_in);
973
- struct qtnf_bus *bus = mac->bus;
974
- struct wiphy *wiphy;
975
- unsigned int mac_idx;
1056
+ struct qtnf_wmac *mac = wiphy_priv(wiphy);
9761057 enum nl80211_band band;
9771058 int ret;
9781059
9791060 pr_debug("MAC%u: initiator=%d alpha=%c%c\n", mac->macid, req->initiator,
9801061 req->alpha2[0], req->alpha2[1]);
9811062
982
- ret = qtnf_cmd_reg_notify(bus, req);
1063
+ ret = qtnf_cmd_reg_notify(mac, req, qtnf_slave_radar_get(),
1064
+ qtnf_dfs_offload_get());
9831065 if (ret) {
984
- if (ret != -EOPNOTSUPP && ret != -EALREADY)
985
- pr_err("failed to update reg domain to %c%c\n",
986
- req->alpha2[0], req->alpha2[1]);
1066
+ pr_err("MAC%u: failed to update region to %c%c: %d\n",
1067
+ mac->macid, req->alpha2[0], req->alpha2[1], ret);
9871068 return;
9881069 }
9891070
990
- for (mac_idx = 0; mac_idx < QTNF_MAX_MAC; ++mac_idx) {
991
- if (!(bus->hw_info.mac_bitmap & (1 << mac_idx)))
1071
+ for (band = 0; band < NUM_NL80211_BANDS; ++band) {
1072
+ if (!wiphy->bands[band])
9921073 continue;
9931074
994
- mac = bus->mac[mac_idx];
995
- if (!mac)
996
- continue;
997
-
998
- wiphy = priv_to_wiphy(mac);
999
-
1000
- for (band = 0; band < NUM_NL80211_BANDS; ++band) {
1001
- if (!wiphy->bands[band])
1002
- continue;
1003
-
1004
- ret = qtnf_cmd_band_info_get(mac, wiphy->bands[band]);
1005
- if (ret)
1006
- pr_err("failed to get chan info for mac %u band %u\n",
1007
- mac_idx, band);
1008
- }
1075
+ ret = qtnf_cmd_band_info_get(mac, wiphy->bands[band]);
1076
+ if (ret)
1077
+ pr_err("MAC%u: failed to update band %u\n",
1078
+ mac->macid, band);
10091079 }
10101080 }
10111081
1012
-struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus)
1082
+struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus,
1083
+ struct platform_device *pdev)
10131084 {
10141085 struct wiphy *wiphy;
10151086
1016
- if (bus->hw_info.hw_capab & QLINK_HW_CAPAB_DFS_OFFLOAD)
1087
+ if (qtnf_dfs_offload_get() &&
1088
+ qtnf_hwcap_is_set(&bus->hw_info, QLINK_HW_CAPAB_DFS_OFFLOAD))
10171089 qtn_cfg80211_ops.start_radar_detection = NULL;
10181090
1019
- if (!(bus->hw_info.hw_capab & QLINK_HW_CAPAB_PWR_MGMT))
1091
+ if (!qtnf_hwcap_is_set(&bus->hw_info, QLINK_HW_CAPAB_PWR_MGMT))
10201092 qtn_cfg80211_ops.set_power_mgmt = NULL;
10211093
10221094 wiphy = wiphy_new(&qtn_cfg80211_ops, sizeof(struct qtnf_wmac));
10231095 if (!wiphy)
10241096 return NULL;
10251097
1026
- set_wiphy_dev(wiphy, bus->dev);
1098
+ if (pdev)
1099
+ set_wiphy_dev(wiphy, &pdev->dev);
1100
+ else
1101
+ set_wiphy_dev(wiphy, bus->dev);
10271102
10281103 return wiphy;
10291104 }
....@@ -1061,6 +1136,7 @@
10611136 struct wiphy *wiphy = priv_to_wiphy(mac);
10621137 struct qtnf_mac_info *macinfo = &mac->macinfo;
10631138 int ret;
1139
+ bool regdomain_is_known;
10641140
10651141 if (!wiphy) {
10661142 pr_err("invalid wiphy pointer\n");
....@@ -1074,7 +1150,7 @@
10741150 wiphy->coverage_class = macinfo->coverage_class;
10751151
10761152 wiphy->max_scan_ssids =
1077
- (hw_info->max_scan_ssids) ? hw_info->max_scan_ssids : 1;
1153
+ (macinfo->max_scan_ssids) ? macinfo->max_scan_ssids : 1;
10781154 wiphy->max_scan_ie_len = QTNF_MAX_VSIE_LEN;
10791155 wiphy->mgmt_stypes = qtnf_mgmt_stypes;
10801156 wiphy->max_remain_on_channel_duration = 5000;
....@@ -1092,11 +1168,18 @@
10921168 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
10931169 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
10941170 WIPHY_FLAG_AP_UAPSD |
1095
- WIPHY_FLAG_HAS_CHANNEL_SWITCH;
1171
+ WIPHY_FLAG_HAS_CHANNEL_SWITCH |
1172
+ WIPHY_FLAG_4ADDR_STATION |
1173
+ WIPHY_FLAG_NETNS_OK;
10961174 wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
10971175
1098
- if (hw_info->hw_capab & QLINK_HW_CAPAB_DFS_OFFLOAD)
1176
+ if (qtnf_dfs_offload_get() &&
1177
+ qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_DFS_OFFLOAD))
10991178 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_DFS_OFFLOAD);
1179
+
1180
+ if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SCAN_DWELL))
1181
+ wiphy_ext_feature_set(wiphy,
1182
+ NL80211_EXT_FEATURE_SET_SCAN_DWELL);
11001183
11011184 wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
11021185 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2;
....@@ -1110,25 +1193,36 @@
11101193
11111194 ether_addr_copy(wiphy->perm_addr, mac->macaddr);
11121195
1113
- if (hw_info->hw_capab & QLINK_HW_CAPAB_STA_INACT_TIMEOUT)
1196
+ if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_STA_INACT_TIMEOUT))
11141197 wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER;
11151198
1116
- if (hw_info->hw_capab & QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR)
1199
+ if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR))
11171200 wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
11181201
1119
- if (!(hw_info->hw_capab & QLINK_HW_CAPAB_OBSS_SCAN))
1202
+ if (!qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_OBSS_SCAN))
11201203 wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN;
1204
+
1205
+ if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_SAE))
1206
+ wiphy->features |= NL80211_FEATURE_SAE;
11211207
11221208 #ifdef CONFIG_PM
11231209 if (macinfo->wowlan)
11241210 wiphy->wowlan = macinfo->wowlan;
11251211 #endif
11261212
1127
- if (hw_info->hw_capab & QLINK_HW_CAPAB_REG_UPDATE) {
1128
- wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
1129
- REGULATORY_CUSTOM_REG;
1213
+ regdomain_is_known = isalpha(mac->rd->alpha2[0]) &&
1214
+ isalpha(mac->rd->alpha2[1]);
1215
+
1216
+ if (qtnf_hwcap_is_set(hw_info, QLINK_HW_CAPAB_REG_UPDATE)) {
11301217 wiphy->reg_notifier = qtnf_cfg80211_reg_notifier;
1131
- wiphy_apply_custom_regulatory(wiphy, hw_info->rd);
1218
+
1219
+ if (mac->rd->alpha2[0] == '9' && mac->rd->alpha2[1] == '9') {
1220
+ wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG |
1221
+ REGULATORY_STRICT_REG;
1222
+ wiphy_apply_custom_regulatory(wiphy, mac->rd);
1223
+ } else if (regdomain_is_known) {
1224
+ wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
1225
+ }
11321226 } else {
11331227 wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;
11341228 }
....@@ -1151,10 +1245,9 @@
11511245 goto out;
11521246
11531247 if (wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED)
1154
- ret = regulatory_set_wiphy_regd(wiphy, hw_info->rd);
1155
- else if (isalpha(hw_info->rd->alpha2[0]) &&
1156
- isalpha(hw_info->rd->alpha2[1]))
1157
- ret = regulatory_hint(wiphy, hw_info->rd->alpha2);
1248
+ ret = regulatory_set_wiphy_regd(wiphy, mac->rd);
1249
+ else if (regdomain_is_known)
1250
+ ret = regulatory_hint(wiphy, mac->rd->alpha2);
11581251
11591252 out:
11601253 return ret;
....@@ -1165,7 +1258,8 @@
11651258 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
11661259
11671260 if (qtnf_cmd_send_updown_intf(vif, up))
1168
- pr_err("failed to send up/down command to FW\n");
1261
+ pr_err("failed to send %s command to VIF%u.%u\n",
1262
+ up ? "UP" : "DOWN", vif->mac->macid, vif->vifid);
11691263 }
11701264
11711265 void qtnf_virtual_intf_cleanup(struct net_device *ndev)
....@@ -1173,57 +1267,20 @@
11731267 struct qtnf_vif *vif = qtnf_netdev_get_priv(ndev);
11741268 struct qtnf_wmac *mac = wiphy_priv(vif->wdev.wiphy);
11751269
1176
- if (vif->wdev.iftype == NL80211_IFTYPE_STATION) {
1177
- switch (vif->sta_state) {
1178
- case QTNF_STA_DISCONNECTED:
1179
- break;
1180
- case QTNF_STA_CONNECTING:
1181
- cfg80211_connect_result(vif->netdev,
1182
- vif->bssid, NULL, 0,
1183
- NULL, 0,
1184
- WLAN_STATUS_UNSPECIFIED_FAILURE,
1185
- GFP_KERNEL);
1186
- qtnf_disconnect(vif->wdev.wiphy, ndev,
1187
- WLAN_REASON_DEAUTH_LEAVING);
1188
- break;
1189
- case QTNF_STA_CONNECTED:
1190
- cfg80211_disconnected(vif->netdev,
1191
- WLAN_REASON_DEAUTH_LEAVING,
1192
- NULL, 0, 1, GFP_KERNEL);
1193
- qtnf_disconnect(vif->wdev.wiphy, ndev,
1194
- WLAN_REASON_DEAUTH_LEAVING);
1195
- break;
1196
- }
1197
-
1198
- vif->sta_state = QTNF_STA_DISCONNECTED;
1199
- }
1270
+ if (vif->wdev.iftype == NL80211_IFTYPE_STATION)
1271
+ qtnf_disconnect(vif->wdev.wiphy, ndev,
1272
+ WLAN_REASON_DEAUTH_LEAVING);
12001273
12011274 qtnf_scan_done(mac, true);
12021275 }
12031276
12041277 void qtnf_cfg80211_vif_reset(struct qtnf_vif *vif)
12051278 {
1206
- if (vif->wdev.iftype == NL80211_IFTYPE_STATION) {
1207
- switch (vif->sta_state) {
1208
- case QTNF_STA_CONNECTING:
1209
- cfg80211_connect_result(vif->netdev,
1210
- vif->bssid, NULL, 0,
1211
- NULL, 0,
1212
- WLAN_STATUS_UNSPECIFIED_FAILURE,
1213
- GFP_KERNEL);
1214
- break;
1215
- case QTNF_STA_CONNECTED:
1216
- cfg80211_disconnected(vif->netdev,
1217
- WLAN_REASON_DEAUTH_LEAVING,
1218
- NULL, 0, 1, GFP_KERNEL);
1219
- break;
1220
- case QTNF_STA_DISCONNECTED:
1221
- break;
1222
- }
1223
- }
1279
+ if (vif->wdev.iftype == NL80211_IFTYPE_STATION)
1280
+ cfg80211_disconnected(vif->netdev, WLAN_REASON_DEAUTH_LEAVING,
1281
+ NULL, 0, 1, GFP_KERNEL);
12241282
12251283 cfg80211_shutdown_all_interfaces(vif->wdev.wiphy);
1226
- vif->sta_state = QTNF_STA_DISCONNECTED;
12271284 }
12281285
12291286 void qtnf_band_init_rates(struct ieee80211_supported_band *band)