1 // SPDX-License-Identifier: ISC
3 * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
4 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
7 #include <linux/etherdevice.h>
8 #include <linux/moduleparam.h>
9 #include <net/netlink.h>
10 #include <net/cfg80211.h>
15 #define WIL_MAX_ROC_DURATION_MS 5000
17 #define WIL_EDMG_CHANNEL_9_SUBCHANNELS (BIT(0) | BIT(1))
18 #define WIL_EDMG_CHANNEL_10_SUBCHANNELS (BIT(1) | BIT(2))
19 #define WIL_EDMG_CHANNEL_11_SUBCHANNELS (BIT(2) | BIT(3))
21 /* WIL_EDMG_BW_CONFIGURATION define the allowed channel bandwidth
22 * configurations as defined by IEEE 802.11 section 9.4.2.251, Table 13.
23 * The value 5 allowing CB1 and CB2 of adjacent channels.
25 #define WIL_EDMG_BW_CONFIGURATION 5
27 /* WIL_EDMG_CHANNELS is a bitmap that indicates the 2.16 GHz channel(s) that
28 * are allowed to be used for EDMG transmissions in the BSS as defined by
29 * IEEE 802.11 section 9.4.2.251.
31 #define WIL_EDMG_CHANNELS (BIT(0) | BIT(1) | BIT(2) | BIT(3))
34 module_param(disable_ap_sme
, bool, 0444);
35 MODULE_PARM_DESC(disable_ap_sme
, " let user space handle AP mode SME");
38 static struct wiphy_wowlan_support wil_wowlan_support
= {
39 .flags
= WIPHY_WOWLAN_ANY
| WIPHY_WOWLAN_DISCONNECT
,
43 #define CHAN60G(_channel, _flags) { \
44 .band = NL80211_BAND_60GHZ, \
45 .center_freq = 56160 + (2160 * (_channel)), \
46 .hw_value = (_channel), \
48 .max_antenna_gain = 0, \
52 static struct ieee80211_channel wil_60ghz_channels
[] = {
59 /* Rx channel bonding mode */
66 static int wil_rx_cb_mode_to_n_bonded(u8 cb_mode
)
69 case WIL_RX_CB_MODE_DMG
:
70 case WIL_RX_CB_MODE_EDMG
:
72 case WIL_RX_CB_MODE_WIDE
:
79 static int wil_tx_cb_mode_to_n_bonded(u8 cb_mode
)
83 case WMI_TX_MODE_EDMG_CB1
:
85 case WMI_TX_MODE_EDMG_CB2
:
93 wil_memdup_ie(u8
**pdst
, size_t *pdst_len
, const u8
*src
, size_t src_len
)
99 *pdst
= kmemdup(src
, src_len
, GFP_KERNEL
);
105 static int wil_num_supported_channels(struct wil6210_priv
*wil
)
107 int num_channels
= ARRAY_SIZE(wil_60ghz_channels
);
109 if (!test_bit(WMI_FW_CAPABILITY_CHANNEL_4
, wil
->fw_capabilities
))
115 void update_supported_bands(struct wil6210_priv
*wil
)
117 struct wiphy
*wiphy
= wil_to_wiphy(wil
);
119 wil_dbg_misc(wil
, "update supported bands");
121 wiphy
->bands
[NL80211_BAND_60GHZ
]->n_channels
=
122 wil_num_supported_channels(wil
);
124 if (test_bit(WMI_FW_CAPABILITY_CHANNEL_BONDING
, wil
->fw_capabilities
)) {
125 wiphy
->bands
[NL80211_BAND_60GHZ
]->edmg_cap
.channels
=
127 wiphy
->bands
[NL80211_BAND_60GHZ
]->edmg_cap
.bw_config
=
128 WIL_EDMG_BW_CONFIGURATION
;
132 /* Vendor id to be used in vendor specific command and events
134 * NOTE: The authoritative place for definition of QCA_NL80211_VENDOR_ID,
135 * vendor subcmd definitions prefixed with QCA_NL80211_VENDOR_SUBCMD, and
136 * qca_wlan_vendor_attr is open source file src/common/qca-vendor.h in
137 * git://w1.fi/srv/git/hostap.git; the values here are just a copy of that
140 #define QCA_NL80211_VENDOR_ID 0x001374
142 #define WIL_MAX_RF_SECTORS (128)
143 #define WIL_CID_ALL (0xff)
145 enum qca_wlan_vendor_attr_rf_sector
{
146 QCA_ATTR_MAC_ADDR
= 6,
149 QCA_ATTR_DMG_RF_SECTOR_INDEX
= 30,
150 QCA_ATTR_DMG_RF_SECTOR_TYPE
= 31,
151 QCA_ATTR_DMG_RF_MODULE_MASK
= 32,
152 QCA_ATTR_DMG_RF_SECTOR_CFG
= 33,
153 QCA_ATTR_DMG_RF_SECTOR_MAX
,
156 enum qca_wlan_vendor_attr_dmg_rf_sector_type
{
157 QCA_ATTR_DMG_RF_SECTOR_TYPE_RX
,
158 QCA_ATTR_DMG_RF_SECTOR_TYPE_TX
,
159 QCA_ATTR_DMG_RF_SECTOR_TYPE_MAX
162 enum qca_wlan_vendor_attr_dmg_rf_sector_cfg
{
163 QCA_ATTR_DMG_RF_SECTOR_CFG_INVALID
= 0,
164 QCA_ATTR_DMG_RF_SECTOR_CFG_MODULE_INDEX
,
165 QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE0
,
166 QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE1
,
167 QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE2
,
168 QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_HI
,
169 QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_LO
,
170 QCA_ATTR_DMG_RF_SECTOR_CFG_DTYPE_X16
,
173 QCA_ATTR_DMG_RF_SECTOR_CFG_AFTER_LAST
,
174 QCA_ATTR_DMG_RF_SECTOR_CFG_MAX
=
175 QCA_ATTR_DMG_RF_SECTOR_CFG_AFTER_LAST
- 1
179 nla_policy wil_rf_sector_policy
[QCA_ATTR_DMG_RF_SECTOR_MAX
+ 1] = {
180 [QCA_ATTR_MAC_ADDR
] = { .len
= ETH_ALEN
},
181 [QCA_ATTR_DMG_RF_SECTOR_INDEX
] = { .type
= NLA_U16
},
182 [QCA_ATTR_DMG_RF_SECTOR_TYPE
] = { .type
= NLA_U8
},
183 [QCA_ATTR_DMG_RF_MODULE_MASK
] = { .type
= NLA_U32
},
184 [QCA_ATTR_DMG_RF_SECTOR_CFG
] = { .type
= NLA_NESTED
},
188 nla_policy wil_rf_sector_cfg_policy
[QCA_ATTR_DMG_RF_SECTOR_CFG_MAX
+ 1] = {
189 [QCA_ATTR_DMG_RF_SECTOR_CFG_MODULE_INDEX
] = { .type
= NLA_U8
},
190 [QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE0
] = { .type
= NLA_U32
},
191 [QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE1
] = { .type
= NLA_U32
},
192 [QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE2
] = { .type
= NLA_U32
},
193 [QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_HI
] = { .type
= NLA_U32
},
194 [QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_LO
] = { .type
= NLA_U32
},
195 [QCA_ATTR_DMG_RF_SECTOR_CFG_DTYPE_X16
] = { .type
= NLA_U32
},
198 enum qca_nl80211_vendor_subcmds
{
199 QCA_NL80211_VENDOR_SUBCMD_DMG_RF_GET_SECTOR_CFG
= 139,
200 QCA_NL80211_VENDOR_SUBCMD_DMG_RF_SET_SECTOR_CFG
= 140,
201 QCA_NL80211_VENDOR_SUBCMD_DMG_RF_GET_SELECTED_SECTOR
= 141,
202 QCA_NL80211_VENDOR_SUBCMD_DMG_RF_SET_SELECTED_SECTOR
= 142,
205 static int wil_rf_sector_get_cfg(struct wiphy
*wiphy
,
206 struct wireless_dev
*wdev
,
207 const void *data
, int data_len
);
208 static int wil_rf_sector_set_cfg(struct wiphy
*wiphy
,
209 struct wireless_dev
*wdev
,
210 const void *data
, int data_len
);
211 static int wil_rf_sector_get_selected(struct wiphy
*wiphy
,
212 struct wireless_dev
*wdev
,
213 const void *data
, int data_len
);
214 static int wil_rf_sector_set_selected(struct wiphy
*wiphy
,
215 struct wireless_dev
*wdev
,
216 const void *data
, int data_len
);
218 /* vendor specific commands */
219 static const struct wiphy_vendor_command wil_nl80211_vendor_commands
[] = {
221 .info
.vendor_id
= QCA_NL80211_VENDOR_ID
,
222 .info
.subcmd
= QCA_NL80211_VENDOR_SUBCMD_DMG_RF_GET_SECTOR_CFG
,
223 .flags
= WIPHY_VENDOR_CMD_NEED_WDEV
|
224 WIPHY_VENDOR_CMD_NEED_RUNNING
,
225 .policy
= wil_rf_sector_policy
,
226 .doit
= wil_rf_sector_get_cfg
229 .info
.vendor_id
= QCA_NL80211_VENDOR_ID
,
230 .info
.subcmd
= QCA_NL80211_VENDOR_SUBCMD_DMG_RF_SET_SECTOR_CFG
,
231 .flags
= WIPHY_VENDOR_CMD_NEED_WDEV
|
232 WIPHY_VENDOR_CMD_NEED_RUNNING
,
233 .policy
= wil_rf_sector_policy
,
234 .doit
= wil_rf_sector_set_cfg
237 .info
.vendor_id
= QCA_NL80211_VENDOR_ID
,
239 QCA_NL80211_VENDOR_SUBCMD_DMG_RF_GET_SELECTED_SECTOR
,
240 .flags
= WIPHY_VENDOR_CMD_NEED_WDEV
|
241 WIPHY_VENDOR_CMD_NEED_RUNNING
,
242 .policy
= wil_rf_sector_policy
,
243 .doit
= wil_rf_sector_get_selected
246 .info
.vendor_id
= QCA_NL80211_VENDOR_ID
,
248 QCA_NL80211_VENDOR_SUBCMD_DMG_RF_SET_SELECTED_SECTOR
,
249 .flags
= WIPHY_VENDOR_CMD_NEED_WDEV
|
250 WIPHY_VENDOR_CMD_NEED_RUNNING
,
251 .policy
= wil_rf_sector_policy
,
252 .doit
= wil_rf_sector_set_selected
256 static struct ieee80211_supported_band wil_band_60ghz
= {
257 .channels
= wil_60ghz_channels
,
258 .n_channels
= ARRAY_SIZE(wil_60ghz_channels
),
260 .ht_supported
= true,
262 .ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
, /* TODO */
263 .ampdu_density
= IEEE80211_HT_MPDU_DENSITY_8
, /* TODO */
265 /* MCS 1..12 - SC PHY */
266 .rx_mask
= {0xfe, 0x1f}, /* 1..12 */
267 .tx_params
= IEEE80211_HT_MCS_TX_DEFINED
, /* TODO */
272 static const struct ieee80211_txrx_stypes
273 wil_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
274 [NL80211_IFTYPE_STATION
] = {
275 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
276 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
277 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
278 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4)
280 [NL80211_IFTYPE_AP
] = {
281 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
282 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4) |
283 BIT(IEEE80211_STYPE_ASSOC_RESP
>> 4) |
284 BIT(IEEE80211_STYPE_DISASSOC
>> 4) |
285 BIT(IEEE80211_STYPE_AUTH
>> 4) |
286 BIT(IEEE80211_STYPE_REASSOC_RESP
>> 4),
287 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
288 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4) |
289 BIT(IEEE80211_STYPE_ASSOC_REQ
>> 4) |
290 BIT(IEEE80211_STYPE_DISASSOC
>> 4) |
291 BIT(IEEE80211_STYPE_AUTH
>> 4) |
292 BIT(IEEE80211_STYPE_DEAUTH
>> 4) |
293 BIT(IEEE80211_STYPE_REASSOC_REQ
>> 4)
295 [NL80211_IFTYPE_P2P_CLIENT
] = {
296 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
297 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
298 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
299 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4)
301 [NL80211_IFTYPE_P2P_GO
] = {
302 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
303 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
304 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
305 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4)
307 [NL80211_IFTYPE_P2P_DEVICE
] = {
308 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
309 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
310 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
311 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4)
315 static const u32 wil_cipher_suites
[] = {
316 WLAN_CIPHER_SUITE_GCMP
,
319 static const char * const key_usage_str
[] = {
320 [WMI_KEY_USE_PAIRWISE
] = "PTK",
321 [WMI_KEY_USE_RX_GROUP
] = "RX_GTK",
322 [WMI_KEY_USE_TX_GROUP
] = "TX_GTK",
323 [WMI_KEY_USE_STORE_PTK
] = "STORE_PTK",
324 [WMI_KEY_USE_APPLY_PTK
] = "APPLY_PTK",
327 int wil_iftype_nl2wmi(enum nl80211_iftype type
)
329 static const struct {
330 enum nl80211_iftype nl
;
331 enum wmi_network_type wmi
;
333 {NL80211_IFTYPE_ADHOC
, WMI_NETTYPE_ADHOC
},
334 {NL80211_IFTYPE_STATION
, WMI_NETTYPE_INFRA
},
335 {NL80211_IFTYPE_AP
, WMI_NETTYPE_AP
},
336 {NL80211_IFTYPE_P2P_CLIENT
, WMI_NETTYPE_P2P
},
337 {NL80211_IFTYPE_P2P_GO
, WMI_NETTYPE_P2P
},
338 {NL80211_IFTYPE_MONITOR
, WMI_NETTYPE_ADHOC
}, /* FIXME */
342 for (i
= 0; i
< ARRAY_SIZE(__nl2wmi
); i
++) {
343 if (__nl2wmi
[i
].nl
== type
)
344 return __nl2wmi
[i
].wmi
;
350 int wil_spec2wmi_ch(u8 spec_ch
, u8
*wmi_ch
)
354 *wmi_ch
= WMI_CHANNEL_1
;
357 *wmi_ch
= WMI_CHANNEL_2
;
360 *wmi_ch
= WMI_CHANNEL_3
;
363 *wmi_ch
= WMI_CHANNEL_4
;
366 *wmi_ch
= WMI_CHANNEL_5
;
369 *wmi_ch
= WMI_CHANNEL_6
;
372 *wmi_ch
= WMI_CHANNEL_9
;
375 *wmi_ch
= WMI_CHANNEL_10
;
378 *wmi_ch
= WMI_CHANNEL_11
;
381 *wmi_ch
= WMI_CHANNEL_12
;
390 int wil_wmi2spec_ch(u8 wmi_ch
, u8
*spec_ch
)
430 int wil_cid_fill_sinfo(struct wil6210_vif
*vif
, int cid
,
431 struct station_info
*sinfo
)
433 struct wil6210_priv
*wil
= vif_to_wil(vif
);
434 struct wmi_notify_req_cmd cmd
= {
439 struct wmi_cmd_hdr wmi
;
440 struct wmi_notify_req_done_event evt
;
442 struct wil_net_stats
*stats
= &wil
->sta
[cid
].stats
;
444 u8 txflag
= RATE_INFO_FLAGS_DMG
;
446 memset(&reply
, 0, sizeof(reply
));
448 rc
= wmi_call(wil
, WMI_NOTIFY_REQ_CMDID
, vif
->mid
, &cmd
, sizeof(cmd
),
449 WMI_NOTIFY_REQ_DONE_EVENTID
, &reply
, sizeof(reply
),
450 WIL_WMI_CALL_GENERAL_TO_MS
);
454 wil_dbg_wmi(wil
, "Link status for CID %d MID %d: {\n"
455 " MCS %d TSF 0x%016llx\n"
456 " BF status 0x%08x RSSI %d SQI %d%%\n"
457 " Tx Tpt %d goodput %d Rx goodput %d\n"
458 " Sectors(rx:tx) my %d:%d peer %d:%d\n"
460 cid
, vif
->mid
, le16_to_cpu(reply
.evt
.bf_mcs
),
461 le64_to_cpu(reply
.evt
.tsf
), reply
.evt
.status
,
464 le32_to_cpu(reply
.evt
.tx_tpt
),
465 le32_to_cpu(reply
.evt
.tx_goodput
),
466 le32_to_cpu(reply
.evt
.rx_goodput
),
467 le16_to_cpu(reply
.evt
.my_rx_sector
),
468 le16_to_cpu(reply
.evt
.my_tx_sector
),
469 le16_to_cpu(reply
.evt
.other_rx_sector
),
470 le16_to_cpu(reply
.evt
.other_tx_sector
),
473 sinfo
->generation
= wil
->sinfo_gen
;
475 sinfo
->filled
= BIT_ULL(NL80211_STA_INFO_RX_BYTES
) |
476 BIT_ULL(NL80211_STA_INFO_TX_BYTES
) |
477 BIT_ULL(NL80211_STA_INFO_RX_PACKETS
) |
478 BIT_ULL(NL80211_STA_INFO_TX_PACKETS
) |
479 BIT_ULL(NL80211_STA_INFO_RX_BITRATE
) |
480 BIT_ULL(NL80211_STA_INFO_TX_BITRATE
) |
481 BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC
) |
482 BIT_ULL(NL80211_STA_INFO_TX_FAILED
);
484 if (wil
->use_enhanced_dma_hw
&& reply
.evt
.tx_mode
!= WMI_TX_MODE_DMG
)
485 txflag
= RATE_INFO_FLAGS_EDMG
;
487 sinfo
->txrate
.flags
= txflag
;
488 sinfo
->txrate
.mcs
= le16_to_cpu(reply
.evt
.bf_mcs
);
489 sinfo
->rxrate
.mcs
= stats
->last_mcs_rx
;
490 sinfo
->txrate
.n_bonded_ch
=
491 wil_tx_cb_mode_to_n_bonded(reply
.evt
.tx_mode
);
492 sinfo
->rxrate
.n_bonded_ch
=
493 wil_rx_cb_mode_to_n_bonded(stats
->last_cb_mode_rx
);
494 sinfo
->rx_bytes
= stats
->rx_bytes
;
495 sinfo
->rx_packets
= stats
->rx_packets
;
496 sinfo
->rx_dropped_misc
= stats
->rx_dropped
;
497 sinfo
->tx_bytes
= stats
->tx_bytes
;
498 sinfo
->tx_packets
= stats
->tx_packets
;
499 sinfo
->tx_failed
= stats
->tx_errors
;
501 if (test_bit(wil_vif_fwconnected
, vif
->status
)) {
502 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_SIGNAL
);
503 if (test_bit(WMI_FW_CAPABILITY_RSSI_REPORTING
,
504 wil
->fw_capabilities
))
505 sinfo
->signal
= reply
.evt
.rssi
;
507 sinfo
->signal
= reply
.evt
.sqi
;
513 static int wil_cfg80211_get_station(struct wiphy
*wiphy
,
514 struct net_device
*ndev
,
515 const u8
*mac
, struct station_info
*sinfo
)
517 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
518 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
521 int cid
= wil_find_cid(wil
, vif
->mid
, mac
);
523 wil_dbg_misc(wil
, "get_station: %pM CID %d MID %d\n", mac
, cid
,
525 if (!wil_cid_valid(wil
, cid
))
528 rc
= wil_cid_fill_sinfo(vif
, cid
, sinfo
);
534 * Find @idx-th active STA for specific MID for station dump.
536 int wil_find_cid_by_idx(struct wil6210_priv
*wil
, u8 mid
, int idx
)
540 for (i
= 0; i
< wil
->max_assoc_sta
; i
++) {
541 if (wil
->sta
[i
].status
== wil_sta_unused
)
543 if (wil
->sta
[i
].mid
!= mid
)
553 static int wil_cfg80211_dump_station(struct wiphy
*wiphy
,
554 struct net_device
*dev
, int idx
,
555 u8
*mac
, struct station_info
*sinfo
)
557 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
558 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
560 int cid
= wil_find_cid_by_idx(wil
, vif
->mid
, idx
);
562 if (!wil_cid_valid(wil
, cid
))
565 ether_addr_copy(mac
, wil
->sta
[cid
].addr
);
566 wil_dbg_misc(wil
, "dump_station: %pM CID %d MID %d\n", mac
, cid
,
569 rc
= wil_cid_fill_sinfo(vif
, cid
, sinfo
);
574 static int wil_cfg80211_start_p2p_device(struct wiphy
*wiphy
,
575 struct wireless_dev
*wdev
)
577 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
579 wil_dbg_misc(wil
, "start_p2p_device: entered\n");
580 wil
->p2p_dev_started
= 1;
584 static void wil_cfg80211_stop_p2p_device(struct wiphy
*wiphy
,
585 struct wireless_dev
*wdev
)
587 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
589 if (!wil
->p2p_dev_started
)
592 wil_dbg_misc(wil
, "stop_p2p_device: entered\n");
593 mutex_lock(&wil
->mutex
);
594 mutex_lock(&wil
->vif_mutex
);
595 wil_p2p_stop_radio_operations(wil
);
596 wil
->p2p_dev_started
= 0;
597 mutex_unlock(&wil
->vif_mutex
);
598 mutex_unlock(&wil
->mutex
);
601 static int wil_cfg80211_validate_add_iface(struct wil6210_priv
*wil
,
602 enum nl80211_iftype new_type
)
605 struct wireless_dev
*wdev
;
606 struct iface_combination_params params
= {
607 .num_different_channels
= 1,
610 for (i
= 0; i
< GET_MAX_VIFS(wil
); i
++) {
612 wdev
= vif_to_wdev(wil
->vifs
[i
]);
613 params
.iftype_num
[wdev
->iftype
]++;
616 params
.iftype_num
[new_type
]++;
617 return cfg80211_check_combinations(wil
->wiphy
, ¶ms
);
620 static int wil_cfg80211_validate_change_iface(struct wil6210_priv
*wil
,
621 struct wil6210_vif
*vif
,
622 enum nl80211_iftype new_type
)
625 struct wireless_dev
*wdev
;
626 struct iface_combination_params params
= {
627 .num_different_channels
= 1,
629 bool check_combos
= false;
631 for (i
= 0; i
< GET_MAX_VIFS(wil
); i
++) {
632 struct wil6210_vif
*vif_pos
= wil
->vifs
[i
];
634 if (vif_pos
&& vif
!= vif_pos
) {
635 wdev
= vif_to_wdev(vif_pos
);
636 params
.iftype_num
[wdev
->iftype
]++;
642 params
.iftype_num
[new_type
]++;
643 ret
= cfg80211_check_combinations(wil
->wiphy
, ¶ms
);
648 static struct wireless_dev
*
649 wil_cfg80211_add_iface(struct wiphy
*wiphy
, const char *name
,
650 unsigned char name_assign_type
,
651 enum nl80211_iftype type
,
652 struct vif_params
*params
)
654 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
655 struct net_device
*ndev_main
= wil
->main_ndev
, *ndev
;
656 struct wil6210_vif
*vif
;
657 struct wireless_dev
*p2p_wdev
, *wdev
;
660 wil_dbg_misc(wil
, "add_iface, type %d\n", type
);
662 /* P2P device is not a real virtual interface, it is a management-only
663 * interface that shares the main interface.
664 * Skip concurrency checks here.
666 if (type
== NL80211_IFTYPE_P2P_DEVICE
) {
668 wil_err(wil
, "P2P_DEVICE interface already created\n");
669 return ERR_PTR(-EINVAL
);
672 p2p_wdev
= kzalloc(sizeof(*p2p_wdev
), GFP_KERNEL
);
674 return ERR_PTR(-ENOMEM
);
676 p2p_wdev
->iftype
= type
;
677 p2p_wdev
->wiphy
= wiphy
;
678 /* use our primary ethernet address */
679 ether_addr_copy(p2p_wdev
->address
, ndev_main
->perm_addr
);
681 wil
->p2p_wdev
= p2p_wdev
;
686 if (!wil
->wiphy
->n_iface_combinations
) {
687 wil_err(wil
, "virtual interfaces not supported\n");
688 return ERR_PTR(-EINVAL
);
691 rc
= wil_cfg80211_validate_add_iface(wil
, type
);
693 wil_err(wil
, "iface validation failed, err=%d\n", rc
);
697 vif
= wil_vif_alloc(wil
, name
, name_assign_type
, type
);
699 return ERR_CAST(vif
);
701 ndev
= vif_to_ndev(vif
);
702 ether_addr_copy(ndev
->perm_addr
, ndev_main
->perm_addr
);
703 if (is_valid_ether_addr(params
->macaddr
)) {
704 ether_addr_copy(ndev
->dev_addr
, params
->macaddr
);
706 ether_addr_copy(ndev
->dev_addr
, ndev_main
->perm_addr
);
707 ndev
->dev_addr
[0] = (ndev
->dev_addr
[0] ^ (1 << vif
->mid
)) |
708 0x2; /* locally administered */
710 wdev
= vif_to_wdev(vif
);
711 ether_addr_copy(wdev
->address
, ndev
->dev_addr
);
713 rc
= wil_vif_add(wil
, vif
);
717 wil_info(wil
, "added VIF, mid %d iftype %d MAC %pM\n",
718 vif
->mid
, type
, wdev
->address
);
725 int wil_vif_prepare_stop(struct wil6210_vif
*vif
)
727 struct wil6210_priv
*wil
= vif_to_wil(vif
);
728 struct wireless_dev
*wdev
= vif_to_wdev(vif
);
729 struct net_device
*ndev
;
732 if (wdev
->iftype
!= NL80211_IFTYPE_AP
)
735 ndev
= vif_to_ndev(vif
);
736 if (netif_carrier_ok(ndev
)) {
737 rc
= wmi_pcp_stop(vif
);
739 wil_info(wil
, "failed to stop AP, status %d\n",
744 netif_carrier_off(ndev
);
750 static int wil_cfg80211_del_iface(struct wiphy
*wiphy
,
751 struct wireless_dev
*wdev
)
753 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
754 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
757 wil_dbg_misc(wil
, "del_iface\n");
759 if (wdev
->iftype
== NL80211_IFTYPE_P2P_DEVICE
) {
760 if (wdev
!= wil
->p2p_wdev
) {
761 wil_err(wil
, "delete of incorrect interface 0x%p\n",
766 wil_cfg80211_stop_p2p_device(wiphy
, wdev
);
767 wil_p2p_wdev_free(wil
);
772 wil_err(wil
, "cannot remove the main interface\n");
776 rc
= wil_vif_prepare_stop(vif
);
780 wil_info(wil
, "deleted VIF, mid %d iftype %d MAC %pM\n",
781 vif
->mid
, wdev
->iftype
, wdev
->address
);
783 wil_vif_remove(wil
, vif
->mid
);
788 static bool wil_is_safe_switch(enum nl80211_iftype from
,
789 enum nl80211_iftype to
)
791 if (from
== NL80211_IFTYPE_STATION
&&
792 to
== NL80211_IFTYPE_P2P_CLIENT
)
798 static int wil_cfg80211_change_iface(struct wiphy
*wiphy
,
799 struct net_device
*ndev
,
800 enum nl80211_iftype type
,
801 struct vif_params
*params
)
803 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
804 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
805 struct wireless_dev
*wdev
= vif_to_wdev(vif
);
807 bool fw_reset
= false;
809 wil_dbg_misc(wil
, "change_iface: type=%d\n", type
);
811 if (wiphy
->n_iface_combinations
) {
812 rc
= wil_cfg80211_validate_change_iface(wil
, vif
, type
);
814 wil_err(wil
, "iface validation failed, err=%d\n", rc
);
819 /* do not reset FW when there are active VIFs,
820 * because it can cause significant disruption
822 if (!wil_has_other_active_ifaces(wil
, ndev
, true, false) &&
823 netif_running(ndev
) && !wil_is_recovery_blocked(wil
) &&
824 !wil_is_safe_switch(wdev
->iftype
, type
)) {
825 wil_dbg_misc(wil
, "interface is up. resetting...\n");
826 mutex_lock(&wil
->mutex
);
829 mutex_unlock(&wil
->mutex
);
837 case NL80211_IFTYPE_STATION
:
838 case NL80211_IFTYPE_AP
:
839 case NL80211_IFTYPE_P2P_CLIENT
:
840 case NL80211_IFTYPE_P2P_GO
:
842 case NL80211_IFTYPE_MONITOR
:
844 wil
->monitor_flags
= params
->flags
;
850 if (vif
->mid
!= 0 && wil_has_active_ifaces(wil
, true, false)) {
852 wil_vif_prepare_stop(vif
);
853 rc
= wmi_port_delete(wil
, vif
->mid
);
856 rc
= wmi_port_allocate(wil
, vif
->mid
, ndev
->dev_addr
, type
);
865 static int wil_cfg80211_scan(struct wiphy
*wiphy
,
866 struct cfg80211_scan_request
*request
)
868 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
869 struct wireless_dev
*wdev
= request
->wdev
;
870 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
872 struct wmi_start_scan_cmd cmd
;
878 wil_dbg_misc(wil
, "scan: wdev=0x%p iftype=%d\n", wdev
, wdev
->iftype
);
880 /* scan is supported on client interfaces and on AP interface */
881 switch (wdev
->iftype
) {
882 case NL80211_IFTYPE_STATION
:
883 case NL80211_IFTYPE_P2P_CLIENT
:
884 case NL80211_IFTYPE_P2P_DEVICE
:
885 case NL80211_IFTYPE_AP
:
891 /* FW don't support scan after connection attempt */
892 if (test_bit(wil_status_dontscan
, wil
->status
)) {
893 wil_err(wil
, "Can't scan now\n");
897 mutex_lock(&wil
->mutex
);
899 mutex_lock(&wil
->vif_mutex
);
900 if (vif
->scan_request
|| vif
->p2p
.discovery_started
) {
901 wil_err(wil
, "Already scanning\n");
902 mutex_unlock(&wil
->vif_mutex
);
906 mutex_unlock(&wil
->vif_mutex
);
908 if (wdev
->iftype
== NL80211_IFTYPE_P2P_DEVICE
) {
909 if (!wil
->p2p_dev_started
) {
910 wil_err(wil
, "P2P search requested on stopped P2P device\n");
914 /* social scan on P2P_DEVICE is handled as p2p search */
915 if (wil_p2p_is_social_scan(request
)) {
916 vif
->scan_request
= request
;
918 wil
->radio_wdev
= wdev
;
919 rc
= wil_p2p_search(vif
, request
);
923 wil
->main_ndev
->ieee80211_ptr
;
924 vif
->scan_request
= NULL
;
930 (void)wil_p2p_stop_discovery(vif
);
932 wil_dbg_misc(wil
, "Start scan_request 0x%p\n", request
);
933 wil_dbg_misc(wil
, "SSID count: %d", request
->n_ssids
);
935 for (i
= 0; i
< request
->n_ssids
; i
++) {
936 wil_dbg_misc(wil
, "SSID[%d]", i
);
937 wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET
, 16, 1,
938 request
->ssids
[i
].ssid
,
939 request
->ssids
[i
].ssid_len
, true);
942 if (request
->n_ssids
)
943 rc
= wmi_set_ssid(vif
, request
->ssids
[0].ssid_len
,
944 request
->ssids
[0].ssid
);
946 rc
= wmi_set_ssid(vif
, 0, NULL
);
949 wil_err(wil
, "set SSID for scan request failed: %d\n", rc
);
953 vif
->scan_request
= request
;
954 mod_timer(&vif
->scan_timer
, jiffies
+ WIL6210_SCAN_TO
);
956 memset(&cmd
, 0, sizeof(cmd
));
957 cmd
.cmd
.scan_type
= WMI_ACTIVE_SCAN
;
958 cmd
.cmd
.num_channels
= 0;
959 n
= min(request
->n_channels
, 4U);
960 for (i
= 0; i
< n
; i
++) {
961 int ch
= request
->channels
[i
]->hw_value
;
965 "Scan requested for unknown frequency %dMhz\n",
966 request
->channels
[i
]->center_freq
);
969 /* 0-based channel indexes */
970 cmd
.cmd
.channel_list
[cmd
.cmd
.num_channels
++].channel
= ch
- 1;
971 wil_dbg_misc(wil
, "Scan for ch %d : %d MHz\n", ch
,
972 request
->channels
[i
]->center_freq
);
976 wil_hex_dump_misc("Scan IE ", DUMP_PREFIX_OFFSET
, 16, 1,
977 request
->ie
, request
->ie_len
, true);
979 wil_dbg_misc(wil
, "Scan has no IE's\n");
981 rc
= wmi_set_ie(vif
, WMI_FRAME_PROBE_REQ
,
982 request
->ie_len
, request
->ie
);
986 if (wil
->discovery_mode
&& cmd
.cmd
.scan_type
== WMI_ACTIVE_SCAN
) {
987 cmd
.cmd
.discovery_mode
= 1;
988 wil_dbg_misc(wil
, "active scan with discovery_mode=1\n");
992 wil
->radio_wdev
= wdev
;
993 rc
= wmi_send(wil
, WMI_START_SCAN_CMDID
, vif
->mid
,
994 &cmd
, sizeof(cmd
.cmd
) +
995 cmd
.cmd
.num_channels
* sizeof(cmd
.cmd
.channel_list
[0]));
999 del_timer_sync(&vif
->scan_timer
);
1001 wil
->radio_wdev
= wil
->main_ndev
->ieee80211_ptr
;
1002 vif
->scan_request
= NULL
;
1005 mutex_unlock(&wil
->mutex
);
1009 static void wil_cfg80211_abort_scan(struct wiphy
*wiphy
,
1010 struct wireless_dev
*wdev
)
1012 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1013 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
1015 wil_dbg_misc(wil
, "wdev=0x%p iftype=%d\n", wdev
, wdev
->iftype
);
1017 mutex_lock(&wil
->mutex
);
1018 mutex_lock(&wil
->vif_mutex
);
1020 if (!vif
->scan_request
)
1023 if (wdev
!= vif
->scan_request
->wdev
) {
1024 wil_dbg_misc(wil
, "abort scan was called on the wrong iface\n");
1028 if (wdev
== wil
->p2p_wdev
&& wil
->radio_wdev
== wil
->p2p_wdev
)
1029 wil_p2p_stop_radio_operations(wil
);
1031 wil_abort_scan(vif
, true);
1034 mutex_unlock(&wil
->vif_mutex
);
1035 mutex_unlock(&wil
->mutex
);
1038 static void wil_print_crypto(struct wil6210_priv
*wil
,
1039 struct cfg80211_crypto_settings
*c
)
1043 wil_dbg_misc(wil
, "WPA versions: 0x%08x cipher group 0x%08x\n",
1044 c
->wpa_versions
, c
->cipher_group
);
1045 wil_dbg_misc(wil
, "Pairwise ciphers [%d] {\n", c
->n_ciphers_pairwise
);
1046 n
= min_t(int, c
->n_ciphers_pairwise
, ARRAY_SIZE(c
->ciphers_pairwise
));
1047 for (i
= 0; i
< n
; i
++)
1048 wil_dbg_misc(wil
, " [%d] = 0x%08x\n", i
,
1049 c
->ciphers_pairwise
[i
]);
1050 wil_dbg_misc(wil
, "}\n");
1051 wil_dbg_misc(wil
, "AKM suites [%d] {\n", c
->n_akm_suites
);
1052 n
= min_t(int, c
->n_akm_suites
, ARRAY_SIZE(c
->akm_suites
));
1053 for (i
= 0; i
< n
; i
++)
1054 wil_dbg_misc(wil
, " [%d] = 0x%08x\n", i
,
1056 wil_dbg_misc(wil
, "}\n");
1057 wil_dbg_misc(wil
, "Control port : %d, eth_type 0x%04x no_encrypt %d\n",
1058 c
->control_port
, be16_to_cpu(c
->control_port_ethertype
),
1059 c
->control_port_no_encrypt
);
1063 wil_get_auth_type_name(enum nl80211_auth_type auth_type
)
1065 switch (auth_type
) {
1066 case NL80211_AUTHTYPE_OPEN_SYSTEM
:
1067 return "OPEN_SYSTEM";
1068 case NL80211_AUTHTYPE_SHARED_KEY
:
1069 return "SHARED_KEY";
1070 case NL80211_AUTHTYPE_FT
:
1072 case NL80211_AUTHTYPE_NETWORK_EAP
:
1073 return "NETWORK_EAP";
1074 case NL80211_AUTHTYPE_SAE
:
1076 case NL80211_AUTHTYPE_AUTOMATIC
:
1082 static void wil_print_connect_params(struct wil6210_priv
*wil
,
1083 struct cfg80211_connect_params
*sme
)
1085 wil_info(wil
, "Connecting to:\n");
1087 wil_info(wil
, " Channel: %d freq %d\n",
1088 sme
->channel
->hw_value
, sme
->channel
->center_freq
);
1091 wil_info(wil
, " BSSID: %pM\n", sme
->bssid
);
1093 print_hex_dump(KERN_INFO
, " SSID: ", DUMP_PREFIX_OFFSET
,
1094 16, 1, sme
->ssid
, sme
->ssid_len
, true);
1095 if (sme
->prev_bssid
)
1096 wil_info(wil
, " Previous BSSID=%pM\n", sme
->prev_bssid
);
1097 wil_info(wil
, " Auth Type: %s\n",
1098 wil_get_auth_type_name(sme
->auth_type
));
1099 wil_info(wil
, " Privacy: %s\n", sme
->privacy
? "secure" : "open");
1100 wil_info(wil
, " PBSS: %d\n", sme
->pbss
);
1101 wil_print_crypto(wil
, &sme
->crypto
);
1104 static int wil_ft_connect(struct wiphy
*wiphy
,
1105 struct net_device
*ndev
,
1106 struct cfg80211_connect_params
*sme
)
1108 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1109 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
1110 struct wmi_ft_auth_cmd auth_cmd
;
1113 if (!test_bit(WMI_FW_CAPABILITY_FT_ROAMING
, wil
->fw_capabilities
)) {
1114 wil_err(wil
, "FT: FW does not support FT roaming\n");
1118 if (!sme
->prev_bssid
) {
1119 wil_err(wil
, "FT: prev_bssid was not set\n");
1123 if (ether_addr_equal(sme
->prev_bssid
, sme
->bssid
)) {
1124 wil_err(wil
, "FT: can not roam to same AP\n");
1128 if (!test_bit(wil_vif_fwconnected
, vif
->status
)) {
1129 wil_err(wil
, "FT: roam while not connected\n");
1133 if (vif
->privacy
!= sme
->privacy
) {
1134 wil_err(wil
, "FT: privacy mismatch, current (%d) roam (%d)\n",
1135 vif
->privacy
, sme
->privacy
);
1140 wil_err(wil
, "FT: roam is not valid for PBSS\n");
1144 memset(&auth_cmd
, 0, sizeof(auth_cmd
));
1145 auth_cmd
.channel
= sme
->channel
->hw_value
- 1;
1146 ether_addr_copy(auth_cmd
.bssid
, sme
->bssid
);
1148 wil_info(wil
, "FT: roaming\n");
1150 set_bit(wil_vif_ft_roam
, vif
->status
);
1151 rc
= wmi_send(wil
, WMI_FT_AUTH_CMDID
, vif
->mid
,
1152 &auth_cmd
, sizeof(auth_cmd
));
1154 mod_timer(&vif
->connect_timer
,
1155 jiffies
+ msecs_to_jiffies(5000));
1157 clear_bit(wil_vif_ft_roam
, vif
->status
);
1162 static int wil_get_wmi_edmg_channel(struct wil6210_priv
*wil
, u8 edmg_bw_config
,
1163 u8 edmg_channels
, u8
*wmi_ch
)
1165 if (!edmg_bw_config
) {
1168 } else if (edmg_bw_config
== WIL_EDMG_BW_CONFIGURATION
) {
1169 /* convert from edmg channel bitmap into edmg channel number */
1170 switch (edmg_channels
) {
1171 case WIL_EDMG_CHANNEL_9_SUBCHANNELS
:
1172 return wil_spec2wmi_ch(9, wmi_ch
);
1173 case WIL_EDMG_CHANNEL_10_SUBCHANNELS
:
1174 return wil_spec2wmi_ch(10, wmi_ch
);
1175 case WIL_EDMG_CHANNEL_11_SUBCHANNELS
:
1176 return wil_spec2wmi_ch(11, wmi_ch
);
1178 wil_err(wil
, "Unsupported edmg channel bitmap 0x%x\n",
1183 wil_err(wil
, "Unsupported EDMG BW configuration %d\n",
1189 static int wil_cfg80211_connect(struct wiphy
*wiphy
,
1190 struct net_device
*ndev
,
1191 struct cfg80211_connect_params
*sme
)
1193 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1194 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
1195 struct cfg80211_bss
*bss
;
1196 struct wmi_connect_cmd conn
;
1201 bool is_ft_roam
= false;
1203 enum ieee80211_bss_type bss_type
= IEEE80211_BSS_TYPE_ESS
;
1205 wil_dbg_misc(wil
, "connect, mid=%d\n", vif
->mid
);
1206 wil_print_connect_params(wil
, sme
);
1208 if (sme
->auth_type
== NL80211_AUTHTYPE_FT
)
1210 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
&&
1211 test_bit(wil_vif_fwconnected
, vif
->status
))
1215 if (test_bit(wil_vif_fwconnecting
, vif
->status
) ||
1216 test_bit(wil_vif_fwconnected
, vif
->status
))
1219 if (sme
->ie_len
> WMI_MAX_IE_LEN
) {
1220 wil_err(wil
, "IE too large (%td bytes)\n", sme
->ie_len
);
1225 cfg80211_find_ie(WLAN_EID_RSN
, sme
->ie
, sme
->ie_len
) :
1227 if (sme
->privacy
&& !rsn_eid
) {
1228 wil_info(wil
, "WSC connection\n");
1230 wil_err(wil
, "No WSC with FT roam\n");
1236 bss_type
= IEEE80211_BSS_TYPE_PBSS
;
1238 bss
= cfg80211_get_bss(wiphy
, sme
->channel
, sme
->bssid
,
1239 sme
->ssid
, sme
->ssid_len
,
1240 bss_type
, IEEE80211_PRIVACY_ANY
);
1242 wil_err(wil
, "Unable to find BSS\n");
1246 ssid_eid
= ieee80211_bss_get_ie(bss
, WLAN_EID_SSID
);
1248 wil_err(wil
, "No SSID\n");
1252 vif
->privacy
= sme
->privacy
;
1253 vif
->pbss
= sme
->pbss
;
1255 rc
= wmi_set_ie(vif
, WMI_FRAME_ASSOC_REQ
, sme
->ie_len
, sme
->ie
);
1259 switch (bss
->capability
& WLAN_CAPABILITY_DMG_TYPE_MASK
) {
1260 case WLAN_CAPABILITY_DMG_TYPE_AP
:
1261 network_type
= WMI_NETTYPE_INFRA
;
1263 case WLAN_CAPABILITY_DMG_TYPE_PBSS
:
1264 network_type
= WMI_NETTYPE_P2P
;
1267 wil_err(wil
, "Unsupported BSS type, capability= 0x%04x\n",
1273 ch
= bss
->channel
->hw_value
;
1275 wil_err(wil
, "BSS at unknown frequency %dMhz\n",
1276 bss
->channel
->center_freq
);
1282 if (network_type
!= WMI_NETTYPE_INFRA
) {
1283 wil_err(wil
, "FT: Unsupported BSS type, capability= 0x%04x\n",
1288 rc
= wil_ft_connect(wiphy
, ndev
, sme
);
1295 /* For secure assoc, remove old keys */
1296 rc
= wmi_del_cipher_key(vif
, 0, bss
->bssid
,
1297 WMI_KEY_USE_PAIRWISE
);
1299 wil_err(wil
, "WMI_DELETE_CIPHER_KEY_CMD(PTK) failed\n");
1302 rc
= wmi_del_cipher_key(vif
, 0, bss
->bssid
,
1303 WMI_KEY_USE_RX_GROUP
);
1305 wil_err(wil
, "WMI_DELETE_CIPHER_KEY_CMD(GTK) failed\n");
1310 /* WMI_CONNECT_CMD */
1311 memset(&conn
, 0, sizeof(conn
));
1312 conn
.network_type
= network_type
;
1314 if (rsn_eid
) { /* regular secure connection */
1315 conn
.dot11_auth_mode
= WMI_AUTH11_SHARED
;
1316 conn
.auth_mode
= WMI_AUTH_WPA2_PSK
;
1317 conn
.pairwise_crypto_type
= WMI_CRYPT_AES_GCMP
;
1318 conn
.pairwise_crypto_len
= 16;
1319 conn
.group_crypto_type
= WMI_CRYPT_AES_GCMP
;
1320 conn
.group_crypto_len
= 16;
1322 conn
.dot11_auth_mode
= WMI_AUTH11_WSC
;
1323 conn
.auth_mode
= WMI_AUTH_NONE
;
1325 } else { /* insecure connection */
1326 conn
.dot11_auth_mode
= WMI_AUTH11_OPEN
;
1327 conn
.auth_mode
= WMI_AUTH_NONE
;
1330 conn
.ssid_len
= min_t(u8
, ssid_eid
[1], 32);
1331 memcpy(conn
.ssid
, ssid_eid
+2, conn
.ssid_len
);
1332 conn
.channel
= ch
- 1;
1334 rc
= wil_get_wmi_edmg_channel(wil
, sme
->edmg
.bw_config
,
1335 sme
->edmg
.channels
, &conn
.edmg_channel
);
1339 ether_addr_copy(conn
.bssid
, bss
->bssid
);
1340 ether_addr_copy(conn
.dst_mac
, bss
->bssid
);
1342 set_bit(wil_vif_fwconnecting
, vif
->status
);
1344 rc
= wmi_send(wil
, WMI_CONNECT_CMDID
, vif
->mid
, &conn
, sizeof(conn
));
1346 netif_carrier_on(ndev
);
1347 if (!wil_has_other_active_ifaces(wil
, ndev
, false, true))
1348 wil6210_bus_request(wil
, WIL_MAX_BUS_REQUEST_KBPS
);
1350 /* Connect can take lots of time */
1351 mod_timer(&vif
->connect_timer
,
1352 jiffies
+ msecs_to_jiffies(5000));
1354 clear_bit(wil_vif_fwconnecting
, vif
->status
);
1358 cfg80211_put_bss(wiphy
, bss
);
1363 static int wil_cfg80211_disconnect(struct wiphy
*wiphy
,
1364 struct net_device
*ndev
,
1368 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1369 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
1371 wil_dbg_misc(wil
, "disconnect: reason=%d, mid=%d\n",
1372 reason_code
, vif
->mid
);
1374 if (!(test_bit(wil_vif_fwconnecting
, vif
->status
) ||
1375 test_bit(wil_vif_fwconnected
, vif
->status
))) {
1376 wil_err(wil
, "Disconnect was called while disconnected\n");
1380 vif
->locally_generated_disc
= true;
1381 rc
= wmi_call(wil
, WMI_DISCONNECT_CMDID
, vif
->mid
, NULL
, 0,
1382 WMI_DISCONNECT_EVENTID
, NULL
, 0,
1383 WIL6210_DISCONNECT_TO_MS
);
1385 wil_err(wil
, "disconnect error %d\n", rc
);
1390 static int wil_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
1392 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1395 /* these parameters are explicitly not supported */
1396 if (changed
& (WIPHY_PARAM_RETRY_LONG
|
1397 WIPHY_PARAM_FRAG_THRESHOLD
|
1398 WIPHY_PARAM_RTS_THRESHOLD
))
1401 if (changed
& WIPHY_PARAM_RETRY_SHORT
) {
1402 rc
= wmi_set_mgmt_retry(wil
, wiphy
->retry_short
);
1410 int wil_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
1411 struct cfg80211_mgmt_tx_params
*params
,
1414 const u8
*buf
= params
->buf
;
1415 size_t len
= params
->len
;
1416 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1417 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
1421 wil_dbg_misc(wil
, "mgmt_tx: channel %d offchan %d, wait %d\n",
1422 params
->chan
? params
->chan
->hw_value
: -1,
1426 /* Note, currently we support the "wait" parameter only on AP mode.
1427 * In other modes, user-space must call remain_on_channel before
1428 * mgmt_tx or listen on a channel other than active one.
1431 if (params
->chan
&& params
->chan
->hw_value
== 0) {
1432 wil_err(wil
, "invalid channel\n");
1436 if (wdev
->iftype
!= NL80211_IFTYPE_AP
) {
1438 "send WMI_SW_TX_REQ_CMDID on non-AP interfaces\n");
1439 rc
= wmi_mgmt_tx(vif
, buf
, len
);
1443 if (!params
->chan
|| params
->chan
->hw_value
== vif
->channel
) {
1445 "send WMI_SW_TX_REQ_CMDID for on-channel\n");
1446 rc
= wmi_mgmt_tx(vif
, buf
, len
);
1450 if (params
->offchan
== 0) {
1452 "invalid channel params: current %d requested %d, off-channel not allowed\n",
1453 vif
->channel
, params
->chan
->hw_value
);
1457 /* use the wmi_mgmt_tx_ext only on AP mode and off-channel */
1458 rc
= wmi_mgmt_tx_ext(vif
, buf
, len
, params
->chan
->hw_value
,
1462 /* when the sent packet was not acked by receiver(ACK=0), rc will
1463 * be -EAGAIN. In this case this function needs to return success,
1464 * the ACK=0 will be reflected in tx_status.
1466 tx_status
= (rc
== 0);
1467 rc
= (rc
== -EAGAIN
) ? 0 : rc
;
1468 cfg80211_mgmt_tx_status(wdev
, cookie
? *cookie
: 0, buf
, len
,
1469 tx_status
, GFP_KERNEL
);
1474 static int wil_cfg80211_set_channel(struct wiphy
*wiphy
,
1475 struct cfg80211_chan_def
*chandef
)
1477 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1479 wil
->monitor_chandef
= *chandef
;
1484 static enum wmi_key_usage
wil_detect_key_usage(struct wireless_dev
*wdev
,
1487 struct wil6210_priv
*wil
= wdev_to_wil(wdev
);
1488 enum wmi_key_usage rc
;
1491 rc
= WMI_KEY_USE_PAIRWISE
;
1493 switch (wdev
->iftype
) {
1494 case NL80211_IFTYPE_STATION
:
1495 case NL80211_IFTYPE_P2P_CLIENT
:
1496 rc
= WMI_KEY_USE_RX_GROUP
;
1498 case NL80211_IFTYPE_AP
:
1499 case NL80211_IFTYPE_P2P_GO
:
1500 rc
= WMI_KEY_USE_TX_GROUP
;
1503 /* TODO: Rx GTK or Tx GTK? */
1504 wil_err(wil
, "Can't determine GTK type\n");
1505 rc
= WMI_KEY_USE_RX_GROUP
;
1509 wil_dbg_misc(wil
, "detect_key_usage: -> %s\n", key_usage_str
[rc
]);
1514 static struct wil_sta_info
*
1515 wil_find_sta_by_key_usage(struct wil6210_priv
*wil
, u8 mid
,
1516 enum wmi_key_usage key_usage
, const u8
*mac_addr
)
1520 if (key_usage
== WMI_KEY_USE_TX_GROUP
)
1521 return NULL
; /* not needed */
1523 /* supplicant provides Rx group key in STA mode with NULL MAC address */
1525 cid
= wil_find_cid(wil
, mid
, mac_addr
);
1526 else if (key_usage
== WMI_KEY_USE_RX_GROUP
)
1527 cid
= wil_find_cid_by_idx(wil
, mid
, 0);
1529 wil_err(wil
, "No CID for %pM %s\n", mac_addr
,
1530 key_usage_str
[key_usage
]);
1531 return ERR_PTR(cid
);
1534 return &wil
->sta
[cid
];
1537 void wil_set_crypto_rx(u8 key_index
, enum wmi_key_usage key_usage
,
1538 struct wil_sta_info
*cs
,
1539 struct key_params
*params
)
1541 struct wil_tid_crypto_rx_single
*cc
;
1547 switch (key_usage
) {
1548 case WMI_KEY_USE_STORE_PTK
:
1549 case WMI_KEY_USE_PAIRWISE
:
1550 for (tid
= 0; tid
< WIL_STA_TID_NUM
; tid
++) {
1551 cc
= &cs
->tid_crypto_rx
[tid
].key_id
[key_index
];
1553 memcpy(cc
->pn
, params
->seq
,
1554 IEEE80211_GCMP_PN_LEN
);
1556 memset(cc
->pn
, 0, IEEE80211_GCMP_PN_LEN
);
1560 case WMI_KEY_USE_RX_GROUP
:
1561 cc
= &cs
->group_crypto_rx
.key_id
[key_index
];
1563 memcpy(cc
->pn
, params
->seq
, IEEE80211_GCMP_PN_LEN
);
1565 memset(cc
->pn
, 0, IEEE80211_GCMP_PN_LEN
);
1573 static void wil_del_rx_key(u8 key_index
, enum wmi_key_usage key_usage
,
1574 struct wil_sta_info
*cs
)
1576 struct wil_tid_crypto_rx_single
*cc
;
1582 switch (key_usage
) {
1583 case WMI_KEY_USE_PAIRWISE
:
1584 for (tid
= 0; tid
< WIL_STA_TID_NUM
; tid
++) {
1585 cc
= &cs
->tid_crypto_rx
[tid
].key_id
[key_index
];
1586 cc
->key_set
= false;
1589 case WMI_KEY_USE_RX_GROUP
:
1590 cc
= &cs
->group_crypto_rx
.key_id
[key_index
];
1591 cc
->key_set
= false;
1598 static int wil_cfg80211_add_key(struct wiphy
*wiphy
,
1599 struct net_device
*ndev
,
1600 u8 key_index
, bool pairwise
,
1602 struct key_params
*params
)
1605 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
1606 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1607 struct wireless_dev
*wdev
= vif_to_wdev(vif
);
1608 enum wmi_key_usage key_usage
= wil_detect_key_usage(wdev
, pairwise
);
1609 struct wil_sta_info
*cs
= wil_find_sta_by_key_usage(wil
, vif
->mid
,
1614 wil_err(wil
, "NULL params\n");
1618 wil_dbg_misc(wil
, "add_key: %pM %s[%d] PN %*phN\n",
1619 mac_addr
, key_usage_str
[key_usage
], key_index
,
1620 params
->seq_len
, params
->seq
);
1623 /* in FT, sta info may not be available as add_key may be
1624 * sent by host before FW sends WMI_CONNECT_EVENT
1626 if (!test_bit(wil_vif_ft_roam
, vif
->status
)) {
1627 wil_err(wil
, "Not connected, %pM %s[%d] PN %*phN\n",
1628 mac_addr
, key_usage_str
[key_usage
], key_index
,
1629 params
->seq_len
, params
->seq
);
1635 wil_del_rx_key(key_index
, key_usage
, cs
);
1637 if (params
->seq
&& params
->seq_len
!= IEEE80211_GCMP_PN_LEN
) {
1639 "Wrong PN len %d, %pM %s[%d] PN %*phN\n",
1640 params
->seq_len
, mac_addr
,
1641 key_usage_str
[key_usage
], key_index
,
1642 params
->seq_len
, params
->seq
);
1646 spin_lock_bh(&wil
->eap_lock
);
1647 if (pairwise
&& wdev
->iftype
== NL80211_IFTYPE_STATION
&&
1648 (vif
->ptk_rekey_state
== WIL_REKEY_M3_RECEIVED
||
1649 vif
->ptk_rekey_state
== WIL_REKEY_WAIT_M4_SENT
)) {
1650 key_usage
= WMI_KEY_USE_STORE_PTK
;
1651 vif
->ptk_rekey_state
= WIL_REKEY_WAIT_M4_SENT
;
1652 wil_dbg_misc(wil
, "Store EAPOL key\n");
1654 spin_unlock_bh(&wil
->eap_lock
);
1656 rc
= wmi_add_cipher_key(vif
, key_index
, mac_addr
, params
->key_len
,
1657 params
->key
, key_usage
);
1658 if (!rc
&& !IS_ERR(cs
)) {
1659 /* update local storage used for AP recovery */
1660 if (key_usage
== WMI_KEY_USE_TX_GROUP
&& params
->key
&&
1661 params
->key_len
<= WMI_MAX_KEY_LEN
) {
1662 vif
->gtk_index
= key_index
;
1663 memcpy(vif
->gtk
, params
->key
, params
->key_len
);
1664 vif
->gtk_len
= params
->key_len
;
1666 /* in FT set crypto will take place upon receiving
1667 * WMI_RING_EN_EVENTID event
1669 wil_set_crypto_rx(key_index
, key_usage
, cs
, params
);
1675 static int wil_cfg80211_del_key(struct wiphy
*wiphy
,
1676 struct net_device
*ndev
,
1677 u8 key_index
, bool pairwise
,
1680 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
1681 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1682 struct wireless_dev
*wdev
= vif_to_wdev(vif
);
1683 enum wmi_key_usage key_usage
= wil_detect_key_usage(wdev
, pairwise
);
1684 struct wil_sta_info
*cs
= wil_find_sta_by_key_usage(wil
, vif
->mid
,
1688 wil_dbg_misc(wil
, "del_key: %pM %s[%d]\n", mac_addr
,
1689 key_usage_str
[key_usage
], key_index
);
1692 wil_info(wil
, "Not connected, %pM %s[%d]\n",
1693 mac_addr
, key_usage_str
[key_usage
], key_index
);
1695 if (!IS_ERR_OR_NULL(cs
))
1696 wil_del_rx_key(key_index
, key_usage
, cs
);
1698 return wmi_del_cipher_key(vif
, key_index
, mac_addr
, key_usage
);
1701 /* Need to be present or wiphy_new() will WARN */
1702 static int wil_cfg80211_set_default_key(struct wiphy
*wiphy
,
1703 struct net_device
*ndev
,
1704 u8 key_index
, bool unicast
,
1707 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1709 wil_dbg_misc(wil
, "set_default_key: entered\n");
1713 static int wil_remain_on_channel(struct wiphy
*wiphy
,
1714 struct wireless_dev
*wdev
,
1715 struct ieee80211_channel
*chan
,
1716 unsigned int duration
,
1719 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1723 "remain_on_channel: center_freq=%d, duration=%d iftype=%d\n",
1724 chan
->center_freq
, duration
, wdev
->iftype
);
1726 rc
= wil_p2p_listen(wil
, wdev
, duration
, chan
, cookie
);
1730 static int wil_cancel_remain_on_channel(struct wiphy
*wiphy
,
1731 struct wireless_dev
*wdev
,
1734 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1735 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
1737 wil_dbg_misc(wil
, "cancel_remain_on_channel\n");
1739 return wil_p2p_cancel_listen(vif
, cookie
);
1743 * find a specific IE in a list of IEs
1744 * return a pointer to the beginning of IE in the list
1745 * or NULL if not found
1747 static const u8
*_wil_cfg80211_find_ie(const u8
*ies
, u16 ies_len
, const u8
*ie
,
1750 struct ieee80211_vendor_ie
*vie
;
1753 /* IE tag at offset 0, length at offset 1 */
1754 if (ie_len
< 2 || 2 + ie
[1] > ie_len
)
1757 if (ie
[0] != WLAN_EID_VENDOR_SPECIFIC
)
1758 return cfg80211_find_ie(ie
[0], ies
, ies_len
);
1760 /* make sure there is room for 3 bytes OUI + 1 byte OUI type */
1763 vie
= (struct ieee80211_vendor_ie
*)ie
;
1764 oui
= vie
->oui
[0] << 16 | vie
->oui
[1] << 8 | vie
->oui
[2];
1765 return cfg80211_find_vendor_ie(oui
, vie
->oui_type
, ies
,
1770 * merge the IEs in two lists into a single list.
1771 * do not include IEs from the second list which exist in the first list.
1772 * add only vendor specific IEs from second list to keep
1773 * the merged list sorted (since vendor-specific IE has the
1774 * highest tag number)
1775 * caller must free the allocated memory for merged IEs
1777 static int _wil_cfg80211_merge_extra_ies(const u8
*ies1
, u16 ies1_len
,
1778 const u8
*ies2
, u16 ies2_len
,
1779 u8
**merged_ies
, u16
*merged_len
)
1790 if (ies1_len
== 0 && ies2_len
== 0) {
1796 buf
= kmalloc(ies1_len
+ ies2_len
, GFP_KERNEL
);
1800 memcpy(buf
, ies1
, ies1_len
);
1801 dpos
= buf
+ ies1_len
;
1803 while (spos
&& (spos
+ 1 < ies2
+ ies2_len
)) {
1804 /* IE tag at offset 0, length at offset 1 */
1805 u16 ielen
= 2 + spos
[1];
1807 if (spos
+ ielen
> ies2
+ ies2_len
)
1809 if (spos
[0] == WLAN_EID_VENDOR_SPECIFIC
&&
1810 (!ies1
|| !_wil_cfg80211_find_ie(ies1
, ies1_len
,
1812 memcpy(dpos
, spos
, ielen
);
1819 *merged_len
= dpos
- buf
;
1823 static void wil_print_bcon_data(struct cfg80211_beacon_data
*b
)
1825 wil_hex_dump_misc("head ", DUMP_PREFIX_OFFSET
, 16, 1,
1826 b
->head
, b
->head_len
, true);
1827 wil_hex_dump_misc("tail ", DUMP_PREFIX_OFFSET
, 16, 1,
1828 b
->tail
, b
->tail_len
, true);
1829 wil_hex_dump_misc("BCON IE ", DUMP_PREFIX_OFFSET
, 16, 1,
1830 b
->beacon_ies
, b
->beacon_ies_len
, true);
1831 wil_hex_dump_misc("PROBE ", DUMP_PREFIX_OFFSET
, 16, 1,
1832 b
->probe_resp
, b
->probe_resp_len
, true);
1833 wil_hex_dump_misc("PROBE IE ", DUMP_PREFIX_OFFSET
, 16, 1,
1834 b
->proberesp_ies
, b
->proberesp_ies_len
, true);
1835 wil_hex_dump_misc("ASSOC IE ", DUMP_PREFIX_OFFSET
, 16, 1,
1836 b
->assocresp_ies
, b
->assocresp_ies_len
, true);
1839 /* internal functions for device reset and starting AP */
1841 _wil_cfg80211_get_proberesp_ies(const u8
*proberesp
, u16 proberesp_len
,
1847 struct ieee80211_mgmt
*f
=
1848 (struct ieee80211_mgmt
*)proberesp
;
1849 size_t hlen
= offsetof(struct ieee80211_mgmt
,
1850 u
.probe_resp
.variable
);
1852 ies
= f
->u
.probe_resp
.variable
;
1854 *ies_len
= proberesp_len
- hlen
;
1860 static int _wil_cfg80211_set_ies(struct wil6210_vif
*vif
,
1861 struct cfg80211_beacon_data
*bcon
)
1864 u16 len
= 0, proberesp_len
= 0;
1865 u8
*ies
= NULL
, *proberesp
;
1867 /* update local storage used for AP recovery */
1868 wil_memdup_ie(&vif
->proberesp
, &vif
->proberesp_len
, bcon
->probe_resp
,
1869 bcon
->probe_resp_len
);
1870 wil_memdup_ie(&vif
->proberesp_ies
, &vif
->proberesp_ies_len
,
1871 bcon
->proberesp_ies
, bcon
->proberesp_ies_len
);
1872 wil_memdup_ie(&vif
->assocresp_ies
, &vif
->assocresp_ies_len
,
1873 bcon
->assocresp_ies
, bcon
->assocresp_ies_len
);
1875 proberesp
= _wil_cfg80211_get_proberesp_ies(bcon
->probe_resp
,
1876 bcon
->probe_resp_len
,
1878 rc
= _wil_cfg80211_merge_extra_ies(proberesp
,
1880 bcon
->proberesp_ies
,
1881 bcon
->proberesp_ies_len
,
1887 rc
= wmi_set_ie(vif
, WMI_FRAME_PROBE_RESP
, len
, ies
);
1891 if (bcon
->assocresp_ies
)
1892 rc
= wmi_set_ie(vif
, WMI_FRAME_ASSOC_RESP
,
1893 bcon
->assocresp_ies_len
, bcon
->assocresp_ies
);
1895 rc
= wmi_set_ie(vif
, WMI_FRAME_ASSOC_RESP
, len
, ies
);
1896 #if 0 /* to use beacon IE's, remove this #if 0 */
1900 rc
= wmi_set_ie(vif
, WMI_FRAME_BEACON
,
1901 bcon
->tail_len
, bcon
->tail
);
1908 static int _wil_cfg80211_start_ap(struct wiphy
*wiphy
,
1909 struct net_device
*ndev
,
1910 const u8
*ssid
, size_t ssid_len
, u32 privacy
,
1911 int bi
, u8 chan
, u8 wmi_edmg_channel
,
1912 struct cfg80211_beacon_data
*bcon
,
1913 u8 hidden_ssid
, u32 pbss
)
1915 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
1916 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
1918 struct wireless_dev
*wdev
= ndev
->ieee80211_ptr
;
1919 u8 wmi_nettype
= wil_iftype_nl2wmi(wdev
->iftype
);
1920 u8 is_go
= (wdev
->iftype
== NL80211_IFTYPE_P2P_GO
);
1921 u16 proberesp_len
= 0;
1926 wmi_nettype
= WMI_NETTYPE_P2P
;
1928 wil_dbg_misc(wil
, "start_ap: mid=%d, is_go=%d\n", vif
->mid
, is_go
);
1929 if (is_go
&& !pbss
) {
1930 wil_err(wil
, "P2P GO must be in PBSS\n");
1934 wil_set_recovery_state(wil
, fw_recovery_idle
);
1936 proberesp
= _wil_cfg80211_get_proberesp_ies(bcon
->probe_resp
,
1937 bcon
->probe_resp_len
,
1939 /* check that the probe response IEs has a MDE */
1940 if ((proberesp
&& proberesp_len
> 0 &&
1941 cfg80211_find_ie(WLAN_EID_MOBILITY_DOMAIN
,
1947 if (!test_bit(WMI_FW_CAPABILITY_FT_ROAMING
,
1948 wil
->fw_capabilities
)) {
1949 wil_err(wil
, "FW does not support FT roaming\n");
1952 set_bit(wil_vif_ft_roam
, vif
->status
);
1955 mutex_lock(&wil
->mutex
);
1957 if (!wil_has_other_active_ifaces(wil
, ndev
, true, false)) {
1964 rc
= wmi_set_ssid(vif
, ssid_len
, ssid
);
1968 rc
= _wil_cfg80211_set_ies(vif
, bcon
);
1972 vif
->privacy
= privacy
;
1973 vif
->channel
= chan
;
1974 vif
->wmi_edmg_channel
= wmi_edmg_channel
;
1975 vif
->hidden_ssid
= hidden_ssid
;
1978 memcpy(vif
->ssid
, ssid
, ssid_len
);
1979 vif
->ssid_len
= ssid_len
;
1981 netif_carrier_on(ndev
);
1982 if (!wil_has_other_active_ifaces(wil
, ndev
, false, true))
1983 wil6210_bus_request(wil
, WIL_MAX_BUS_REQUEST_KBPS
);
1985 rc
= wmi_pcp_start(vif
, bi
, wmi_nettype
, chan
, wmi_edmg_channel
,
1986 hidden_ssid
, is_go
);
1990 rc
= wil_bcast_init(vif
);
1994 goto out
; /* success */
1999 netif_carrier_off(ndev
);
2000 if (!wil_has_other_active_ifaces(wil
, ndev
, false, true))
2001 wil6210_bus_request(wil
, WIL_DEFAULT_BUS_REQUEST_KBPS
);
2003 mutex_unlock(&wil
->mutex
);
2007 void wil_cfg80211_ap_recovery(struct wil6210_priv
*wil
)
2010 struct wiphy
*wiphy
= wil_to_wiphy(wil
);
2012 for (i
= 0; i
< GET_MAX_VIFS(wil
); i
++) {
2013 struct wil6210_vif
*vif
= wil
->vifs
[i
];
2014 struct net_device
*ndev
;
2015 struct cfg80211_beacon_data bcon
= {};
2016 struct key_params key_params
= {};
2018 if (!vif
|| vif
->ssid_len
== 0)
2021 ndev
= vif_to_ndev(vif
);
2022 bcon
.proberesp_ies
= vif
->proberesp_ies
;
2023 bcon
.assocresp_ies
= vif
->assocresp_ies
;
2024 bcon
.probe_resp
= vif
->proberesp
;
2025 bcon
.proberesp_ies_len
= vif
->proberesp_ies_len
;
2026 bcon
.assocresp_ies_len
= vif
->assocresp_ies_len
;
2027 bcon
.probe_resp_len
= vif
->proberesp_len
;
2030 "AP (vif %d) recovery: privacy %d, bi %d, channel %d, hidden %d, pbss %d\n",
2031 i
, vif
->privacy
, vif
->bi
, vif
->channel
,
2032 vif
->hidden_ssid
, vif
->pbss
);
2033 wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET
, 16, 1,
2034 vif
->ssid
, vif
->ssid_len
, true);
2035 rc
= _wil_cfg80211_start_ap(wiphy
, ndev
,
2036 vif
->ssid
, vif
->ssid_len
,
2037 vif
->privacy
, vif
->bi
,
2039 vif
->wmi_edmg_channel
, &bcon
,
2040 vif
->hidden_ssid
, vif
->pbss
);
2042 wil_err(wil
, "vif %d recovery failed (%d)\n", i
, rc
);
2046 if (!vif
->privacy
|| vif
->gtk_len
== 0)
2049 key_params
.key
= vif
->gtk
;
2050 key_params
.key_len
= vif
->gtk_len
;
2051 key_params
.seq_len
= IEEE80211_GCMP_PN_LEN
;
2052 rc
= wil_cfg80211_add_key(wiphy
, ndev
, vif
->gtk_index
, false,
2055 wil_err(wil
, "vif %d recovery add key failed (%d)\n",
2060 static int wil_cfg80211_change_beacon(struct wiphy
*wiphy
,
2061 struct net_device
*ndev
,
2062 struct cfg80211_beacon_data
*bcon
)
2064 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2065 struct wireless_dev
*wdev
= ndev
->ieee80211_ptr
;
2066 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
2070 wil_dbg_misc(wil
, "change_beacon, mid=%d\n", vif
->mid
);
2071 wil_print_bcon_data(bcon
);
2074 cfg80211_find_ie(WLAN_EID_RSN
, bcon
->tail
,
2078 memcpy(vif
->ssid
, wdev
->ssid
, wdev
->ssid_len
);
2079 vif
->ssid_len
= wdev
->ssid_len
;
2081 /* in case privacy has changed, need to restart the AP */
2082 if (vif
->privacy
!= privacy
) {
2083 wil_dbg_misc(wil
, "privacy changed %d=>%d. Restarting AP\n",
2084 vif
->privacy
, privacy
);
2086 rc
= _wil_cfg80211_start_ap(wiphy
, ndev
, vif
->ssid
,
2087 vif
->ssid_len
, privacy
,
2088 wdev
->beacon_interval
,
2090 vif
->wmi_edmg_channel
, bcon
,
2094 rc
= _wil_cfg80211_set_ies(vif
, bcon
);
2100 static int wil_cfg80211_start_ap(struct wiphy
*wiphy
,
2101 struct net_device
*ndev
,
2102 struct cfg80211_ap_settings
*info
)
2105 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2106 struct ieee80211_channel
*channel
= info
->chandef
.chan
;
2107 struct cfg80211_beacon_data
*bcon
= &info
->beacon
;
2108 struct cfg80211_crypto_settings
*crypto
= &info
->crypto
;
2109 u8 wmi_edmg_channel
;
2112 wil_dbg_misc(wil
, "start_ap\n");
2114 rc
= wil_get_wmi_edmg_channel(wil
, info
->chandef
.edmg
.bw_config
,
2115 info
->chandef
.edmg
.channels
,
2121 wil_err(wil
, "AP: No channel???\n");
2125 switch (info
->hidden_ssid
) {
2126 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
2127 hidden_ssid
= WMI_HIDDEN_SSID_DISABLED
;
2130 case NL80211_HIDDEN_SSID_ZERO_LEN
:
2131 hidden_ssid
= WMI_HIDDEN_SSID_SEND_EMPTY
;
2134 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
2135 hidden_ssid
= WMI_HIDDEN_SSID_CLEAR
;
2139 wil_err(wil
, "AP: Invalid hidden SSID %d\n", info
->hidden_ssid
);
2142 wil_dbg_misc(wil
, "AP on Channel %d %d MHz, %s\n", channel
->hw_value
,
2143 channel
->center_freq
, info
->privacy
? "secure" : "open");
2144 wil_dbg_misc(wil
, "Privacy: %d auth_type %d\n",
2145 info
->privacy
, info
->auth_type
);
2146 wil_dbg_misc(wil
, "Hidden SSID mode: %d\n",
2148 wil_dbg_misc(wil
, "BI %d DTIM %d\n", info
->beacon_interval
,
2150 wil_dbg_misc(wil
, "PBSS %d\n", info
->pbss
);
2151 wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET
, 16, 1,
2152 info
->ssid
, info
->ssid_len
, true);
2153 wil_print_bcon_data(bcon
);
2154 wil_print_crypto(wil
, crypto
);
2156 rc
= _wil_cfg80211_start_ap(wiphy
, ndev
,
2157 info
->ssid
, info
->ssid_len
, info
->privacy
,
2158 info
->beacon_interval
, channel
->hw_value
,
2159 wmi_edmg_channel
, bcon
, hidden_ssid
,
2165 static int wil_cfg80211_stop_ap(struct wiphy
*wiphy
,
2166 struct net_device
*ndev
)
2168 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2169 struct wil6210_vif
*vif
= ndev_to_vif(ndev
);
2172 wil_dbg_misc(wil
, "stop_ap, mid=%d\n", vif
->mid
);
2174 netif_carrier_off(ndev
);
2175 last
= !wil_has_other_active_ifaces(wil
, ndev
, false, true);
2177 wil6210_bus_request(wil
, WIL_DEFAULT_BUS_REQUEST_KBPS
);
2178 wil_set_recovery_state(wil
, fw_recovery_idle
);
2179 set_bit(wil_status_resetting
, wil
->status
);
2182 mutex_lock(&wil
->mutex
);
2185 clear_bit(wil_vif_ft_roam
, vif
->status
);
2187 wil_memdup_ie(&vif
->proberesp
, &vif
->proberesp_len
, NULL
, 0);
2188 wil_memdup_ie(&vif
->proberesp_ies
, &vif
->proberesp_ies_len
, NULL
, 0);
2189 wil_memdup_ie(&vif
->assocresp_ies
, &vif
->assocresp_ies_len
, NULL
, 0);
2190 memset(vif
->gtk
, 0, WMI_MAX_KEY_LEN
);
2196 wil_bcast_fini(vif
);
2198 mutex_unlock(&wil
->mutex
);
2203 static int wil_cfg80211_add_station(struct wiphy
*wiphy
,
2204 struct net_device
*dev
,
2206 struct station_parameters
*params
)
2208 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2209 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2211 wil_dbg_misc(wil
, "add station %pM aid %d mid %d mask 0x%x set 0x%x\n",
2212 mac
, params
->aid
, vif
->mid
,
2213 params
->sta_flags_mask
, params
->sta_flags_set
);
2215 if (!disable_ap_sme
) {
2216 wil_err(wil
, "not supported with AP SME enabled\n");
2220 if (params
->aid
> WIL_MAX_DMG_AID
) {
2221 wil_err(wil
, "invalid aid\n");
2225 return wmi_new_sta(vif
, mac
, params
->aid
);
2228 static int wil_cfg80211_del_station(struct wiphy
*wiphy
,
2229 struct net_device
*dev
,
2230 struct station_del_parameters
*params
)
2232 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2233 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2235 wil_dbg_misc(wil
, "del_station: %pM, reason=%d mid=%d\n",
2236 params
->mac
, params
->reason_code
, vif
->mid
);
2238 mutex_lock(&wil
->mutex
);
2239 wil6210_disconnect(vif
, params
->mac
, params
->reason_code
);
2240 mutex_unlock(&wil
->mutex
);
2245 static int wil_cfg80211_change_station(struct wiphy
*wiphy
,
2246 struct net_device
*dev
,
2248 struct station_parameters
*params
)
2250 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2251 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2254 struct wil_ring_tx_data
*txdata
= NULL
;
2256 wil_dbg_misc(wil
, "change station %pM mask 0x%x set 0x%x mid %d\n",
2257 mac
, params
->sta_flags_mask
, params
->sta_flags_set
,
2260 if (!disable_ap_sme
) {
2261 wil_dbg_misc(wil
, "not supported with AP SME enabled\n");
2265 if (!(params
->sta_flags_mask
& BIT(NL80211_STA_FLAG_AUTHORIZED
)))
2268 cid
= wil_find_cid(wil
, vif
->mid
, mac
);
2270 wil_err(wil
, "station not found\n");
2274 for (i
= 0; i
< ARRAY_SIZE(wil
->ring2cid_tid
); i
++)
2275 if (wil
->ring2cid_tid
[i
][0] == cid
) {
2276 txdata
= &wil
->ring_tx_data
[i
];
2281 wil_err(wil
, "ring data not found\n");
2285 authorize
= params
->sta_flags_set
& BIT(NL80211_STA_FLAG_AUTHORIZED
);
2286 txdata
->dot1x_open
= authorize
? 1 : 0;
2287 wil_dbg_misc(wil
, "cid %d ring %d authorize %d\n", cid
, i
,
2288 txdata
->dot1x_open
);
2293 /* probe_client handling */
2294 static void wil_probe_client_handle(struct wil6210_priv
*wil
,
2295 struct wil6210_vif
*vif
,
2296 struct wil_probe_client_req
*req
)
2298 struct net_device
*ndev
= vif_to_ndev(vif
);
2299 struct wil_sta_info
*sta
= &wil
->sta
[req
->cid
];
2300 /* assume STA is alive if it is still connected,
2301 * else FW will disconnect it
2303 bool alive
= (sta
->status
== wil_sta_connected
);
2305 cfg80211_probe_status(ndev
, sta
->addr
, req
->cookie
, alive
,
2306 0, false, GFP_KERNEL
);
2309 static struct list_head
*next_probe_client(struct wil6210_vif
*vif
)
2311 struct list_head
*ret
= NULL
;
2313 mutex_lock(&vif
->probe_client_mutex
);
2315 if (!list_empty(&vif
->probe_client_pending
)) {
2316 ret
= vif
->probe_client_pending
.next
;
2320 mutex_unlock(&vif
->probe_client_mutex
);
2325 void wil_probe_client_worker(struct work_struct
*work
)
2327 struct wil6210_vif
*vif
= container_of(work
, struct wil6210_vif
,
2328 probe_client_worker
);
2329 struct wil6210_priv
*wil
= vif_to_wil(vif
);
2330 struct wil_probe_client_req
*req
;
2331 struct list_head
*lh
;
2333 while ((lh
= next_probe_client(vif
)) != NULL
) {
2334 req
= list_entry(lh
, struct wil_probe_client_req
, list
);
2336 wil_probe_client_handle(wil
, vif
, req
);
2341 void wil_probe_client_flush(struct wil6210_vif
*vif
)
2343 struct wil_probe_client_req
*req
, *t
;
2344 struct wil6210_priv
*wil
= vif_to_wil(vif
);
2346 wil_dbg_misc(wil
, "probe_client_flush\n");
2348 mutex_lock(&vif
->probe_client_mutex
);
2350 list_for_each_entry_safe(req
, t
, &vif
->probe_client_pending
, list
) {
2351 list_del(&req
->list
);
2355 mutex_unlock(&vif
->probe_client_mutex
);
2358 static int wil_cfg80211_probe_client(struct wiphy
*wiphy
,
2359 struct net_device
*dev
,
2360 const u8
*peer
, u64
*cookie
)
2362 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2363 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2364 struct wil_probe_client_req
*req
;
2365 int cid
= wil_find_cid(wil
, vif
->mid
, peer
);
2367 wil_dbg_misc(wil
, "probe_client: %pM => CID %d MID %d\n",
2368 peer
, cid
, vif
->mid
);
2373 req
= kzalloc(sizeof(*req
), GFP_KERNEL
);
2380 mutex_lock(&vif
->probe_client_mutex
);
2381 list_add_tail(&req
->list
, &vif
->probe_client_pending
);
2382 mutex_unlock(&vif
->probe_client_mutex
);
2384 *cookie
= req
->cookie
;
2385 queue_work(wil
->wq_service
, &vif
->probe_client_worker
);
2389 static int wil_cfg80211_change_bss(struct wiphy
*wiphy
,
2390 struct net_device
*dev
,
2391 struct bss_parameters
*params
)
2393 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2394 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2396 if (params
->ap_isolate
>= 0) {
2397 wil_dbg_misc(wil
, "change_bss: ap_isolate MID %d, %d => %d\n",
2398 vif
->mid
, vif
->ap_isolate
, params
->ap_isolate
);
2399 vif
->ap_isolate
= params
->ap_isolate
;
2405 static int wil_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
2406 struct net_device
*dev
,
2407 bool enabled
, int timeout
)
2409 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2410 enum wmi_ps_profile_type ps_profile
;
2412 wil_dbg_misc(wil
, "enabled=%d, timeout=%d\n",
2416 ps_profile
= WMI_PS_PROFILE_TYPE_DEFAULT
;
2418 ps_profile
= WMI_PS_PROFILE_TYPE_PS_DISABLED
;
2420 return wil_ps_update(wil
, ps_profile
);
2423 static int wil_cfg80211_suspend(struct wiphy
*wiphy
,
2424 struct cfg80211_wowlan
*wow
)
2426 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2429 /* Setting the wakeup trigger based on wow is TBD */
2431 if (test_bit(wil_status_suspended
, wil
->status
)) {
2432 wil_dbg_pm(wil
, "trying to suspend while suspended\n");
2436 rc
= wil_can_suspend(wil
, false);
2440 wil_dbg_pm(wil
, "suspending\n");
2442 mutex_lock(&wil
->mutex
);
2443 mutex_lock(&wil
->vif_mutex
);
2444 wil_p2p_stop_radio_operations(wil
);
2445 wil_abort_scan_all_vifs(wil
, true);
2446 mutex_unlock(&wil
->vif_mutex
);
2447 mutex_unlock(&wil
->mutex
);
2453 static int wil_cfg80211_resume(struct wiphy
*wiphy
)
2455 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2457 wil_dbg_pm(wil
, "resuming\n");
2463 wil_cfg80211_sched_scan_start(struct wiphy
*wiphy
,
2464 struct net_device
*dev
,
2465 struct cfg80211_sched_scan_request
*request
)
2467 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2468 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2475 "sched scan start: n_ssids %d, ie_len %zu, flags 0x%x\n",
2476 request
->n_ssids
, request
->ie_len
, request
->flags
);
2477 for (i
= 0; i
< request
->n_ssids
; i
++) {
2478 wil_dbg_misc(wil
, "SSID[%d]:", i
);
2479 wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET
, 16, 1,
2480 request
->ssids
[i
].ssid
,
2481 request
->ssids
[i
].ssid_len
, true);
2483 wil_dbg_misc(wil
, "channels:");
2484 for (i
= 0; i
< request
->n_channels
; i
++)
2485 wil_dbg_misc(wil
, " %d%s", request
->channels
[i
]->hw_value
,
2486 i
== request
->n_channels
- 1 ? "\n" : "");
2487 wil_dbg_misc(wil
, "n_match_sets %d, min_rssi_thold %d, delay %d\n",
2488 request
->n_match_sets
, request
->min_rssi_thold
,
2490 for (i
= 0; i
< request
->n_match_sets
; i
++) {
2491 struct cfg80211_match_set
*ms
= &request
->match_sets
[i
];
2493 wil_dbg_misc(wil
, "MATCHSET[%d]: rssi_thold %d\n",
2495 wil_hex_dump_misc("SSID ", DUMP_PREFIX_OFFSET
, 16, 1,
2497 ms
->ssid
.ssid_len
, true);
2499 wil_dbg_misc(wil
, "n_scan_plans %d\n", request
->n_scan_plans
);
2500 for (i
= 0; i
< request
->n_scan_plans
; i
++) {
2501 struct cfg80211_sched_scan_plan
*sp
= &request
->scan_plans
[i
];
2503 wil_dbg_misc(wil
, "SCAN PLAN[%d]: interval %d iterations %d\n",
2504 i
, sp
->interval
, sp
->iterations
);
2507 rc
= wmi_set_ie(vif
, WMI_FRAME_PROBE_REQ
,
2508 request
->ie_len
, request
->ie
);
2511 return wmi_start_sched_scan(wil
, request
);
2515 wil_cfg80211_sched_scan_stop(struct wiphy
*wiphy
, struct net_device
*dev
,
2518 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2519 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2525 rc
= wmi_stop_sched_scan(wil
);
2526 /* device would return error if it thinks PNO is already stopped.
2527 * ignore the return code so user space and driver gets back in-sync
2529 wil_dbg_misc(wil
, "sched scan stopped (%d)\n", rc
);
2535 wil_cfg80211_update_ft_ies(struct wiphy
*wiphy
, struct net_device
*dev
,
2536 struct cfg80211_update_ft_ies_params
*ftie
)
2538 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2539 struct wil6210_vif
*vif
= ndev_to_vif(dev
);
2540 struct cfg80211_bss
*bss
;
2541 struct wmi_ft_reassoc_cmd reassoc
;
2544 wil_dbg_misc(wil
, "update ft ies, mid=%d\n", vif
->mid
);
2545 wil_hex_dump_misc("FT IE ", DUMP_PREFIX_OFFSET
, 16, 1,
2546 ftie
->ie
, ftie
->ie_len
, true);
2548 if (!test_bit(WMI_FW_CAPABILITY_FT_ROAMING
, wil
->fw_capabilities
)) {
2549 wil_err(wil
, "FW does not support FT roaming\n");
2553 rc
= wmi_update_ft_ies(vif
, ftie
->ie_len
, ftie
->ie
);
2557 if (!test_bit(wil_vif_ft_roam
, vif
->status
))
2558 /* vif is not roaming */
2561 /* wil_vif_ft_roam is set. wil_cfg80211_update_ft_ies is used as
2562 * a trigger for reassoc
2567 wil_err(wil
, "FT: bss is NULL\n");
2571 memset(&reassoc
, 0, sizeof(reassoc
));
2572 ether_addr_copy(reassoc
.bssid
, bss
->bssid
);
2574 rc
= wmi_send(wil
, WMI_FT_REASSOC_CMDID
, vif
->mid
,
2575 &reassoc
, sizeof(reassoc
));
2577 wil_err(wil
, "FT: reassoc failed (%d)\n", rc
);
2582 static int wil_cfg80211_set_multicast_to_unicast(struct wiphy
*wiphy
,
2583 struct net_device
*dev
,
2586 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2588 if (wil
->multicast_to_unicast
== enabled
)
2591 wil_info(wil
, "set multicast to unicast, enabled=%d\n", enabled
);
2592 wil
->multicast_to_unicast
= enabled
;
2597 static int wil_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
2598 struct net_device
*dev
,
2599 s32 rssi_thold
, u32 rssi_hyst
)
2601 struct wil6210_priv
*wil
= wiphy_to_wil(wiphy
);
2604 wil
->cqm_rssi_thold
= rssi_thold
;
2606 rc
= wmi_set_cqm_rssi_config(wil
, rssi_thold
, rssi_hyst
);
2608 /* reset stored value upon failure */
2609 wil
->cqm_rssi_thold
= 0;
2614 static const struct cfg80211_ops wil_cfg80211_ops
= {
2615 .add_virtual_intf
= wil_cfg80211_add_iface
,
2616 .del_virtual_intf
= wil_cfg80211_del_iface
,
2617 .scan
= wil_cfg80211_scan
,
2618 .abort_scan
= wil_cfg80211_abort_scan
,
2619 .connect
= wil_cfg80211_connect
,
2620 .disconnect
= wil_cfg80211_disconnect
,
2621 .set_wiphy_params
= wil_cfg80211_set_wiphy_params
,
2622 .change_virtual_intf
= wil_cfg80211_change_iface
,
2623 .get_station
= wil_cfg80211_get_station
,
2624 .dump_station
= wil_cfg80211_dump_station
,
2625 .remain_on_channel
= wil_remain_on_channel
,
2626 .cancel_remain_on_channel
= wil_cancel_remain_on_channel
,
2627 .mgmt_tx
= wil_cfg80211_mgmt_tx
,
2628 .set_monitor_channel
= wil_cfg80211_set_channel
,
2629 .add_key
= wil_cfg80211_add_key
,
2630 .del_key
= wil_cfg80211_del_key
,
2631 .set_default_key
= wil_cfg80211_set_default_key
,
2633 .change_beacon
= wil_cfg80211_change_beacon
,
2634 .start_ap
= wil_cfg80211_start_ap
,
2635 .stop_ap
= wil_cfg80211_stop_ap
,
2636 .add_station
= wil_cfg80211_add_station
,
2637 .del_station
= wil_cfg80211_del_station
,
2638 .change_station
= wil_cfg80211_change_station
,
2639 .probe_client
= wil_cfg80211_probe_client
,
2640 .change_bss
= wil_cfg80211_change_bss
,
2642 .start_p2p_device
= wil_cfg80211_start_p2p_device
,
2643 .stop_p2p_device
= wil_cfg80211_stop_p2p_device
,
2644 .set_power_mgmt
= wil_cfg80211_set_power_mgmt
,
2645 .set_cqm_rssi_config
= wil_cfg80211_set_cqm_rssi_config
,
2646 .suspend
= wil_cfg80211_suspend
,
2647 .resume
= wil_cfg80211_resume
,
2648 .sched_scan_start
= wil_cfg80211_sched_scan_start
,
2649 .sched_scan_stop
= wil_cfg80211_sched_scan_stop
,
2650 .update_ft_ies
= wil_cfg80211_update_ft_ies
,
2651 .set_multicast_to_unicast
= wil_cfg80211_set_multicast_to_unicast
,
2654 static void wil_wiphy_init(struct wiphy
*wiphy
)
2656 wiphy
->max_scan_ssids
= 1;
2657 wiphy
->max_scan_ie_len
= WMI_MAX_IE_LEN
;
2658 wiphy
->max_remain_on_channel_duration
= WIL_MAX_ROC_DURATION_MS
;
2659 wiphy
->max_num_pmkids
= 0 /* TODO: */;
2660 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
2661 BIT(NL80211_IFTYPE_AP
) |
2662 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
2663 BIT(NL80211_IFTYPE_P2P_GO
) |
2664 BIT(NL80211_IFTYPE_P2P_DEVICE
) |
2665 BIT(NL80211_IFTYPE_MONITOR
);
2666 wiphy
->flags
|= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
2667 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
2668 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
2669 if (!disable_ap_sme
)
2670 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
;
2671 dev_dbg(wiphy_dev(wiphy
), "%s : flags = 0x%08x\n",
2672 __func__
, wiphy
->flags
);
2673 wiphy
->probe_resp_offload
=
2674 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
2675 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
2676 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
2678 wiphy
->bands
[NL80211_BAND_60GHZ
] = &wil_band_60ghz
;
2680 /* may change after reading FW capabilities */
2681 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_UNSPEC
;
2683 wiphy
->cipher_suites
= wil_cipher_suites
;
2684 wiphy
->n_cipher_suites
= ARRAY_SIZE(wil_cipher_suites
);
2685 wiphy
->mgmt_stypes
= wil_mgmt_stypes
;
2686 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
2688 wiphy
->n_vendor_commands
= ARRAY_SIZE(wil_nl80211_vendor_commands
);
2689 wiphy
->vendor_commands
= wil_nl80211_vendor_commands
;
2692 wiphy
->wowlan
= &wil_wowlan_support
;
2696 int wil_cfg80211_iface_combinations_from_fw(
2697 struct wil6210_priv
*wil
, const struct wil_fw_record_concurrency
*conc
)
2699 struct wiphy
*wiphy
= wil_to_wiphy(wil
);
2700 u32 total_limits
= 0;
2702 const struct wil_fw_concurrency_combo
*combo
;
2703 const struct wil_fw_concurrency_limit
*limit
;
2704 struct ieee80211_iface_combination
*iface_combinations
;
2705 struct ieee80211_iface_limit
*iface_limit
;
2708 if (wiphy
->iface_combinations
) {
2709 wil_dbg_misc(wil
, "iface_combinations already set, skipping\n");
2713 combo
= conc
->combos
;
2714 n_combos
= le16_to_cpu(conc
->n_combos
);
2715 for (i
= 0; i
< n_combos
; i
++) {
2716 total_limits
+= combo
->n_limits
;
2717 limit
= combo
->limits
+ combo
->n_limits
;
2718 combo
= (struct wil_fw_concurrency_combo
*)limit
;
2721 iface_combinations
=
2722 kzalloc(n_combos
* sizeof(struct ieee80211_iface_combination
) +
2723 total_limits
* sizeof(struct ieee80211_iface_limit
),
2725 if (!iface_combinations
)
2727 iface_limit
= (struct ieee80211_iface_limit
*)(iface_combinations
+
2729 combo
= conc
->combos
;
2730 for (i
= 0; i
< n_combos
; i
++) {
2731 iface_combinations
[i
].max_interfaces
= combo
->max_interfaces
;
2732 iface_combinations
[i
].num_different_channels
=
2733 combo
->n_diff_channels
;
2734 iface_combinations
[i
].beacon_int_infra_match
=
2736 iface_combinations
[i
].n_limits
= combo
->n_limits
;
2738 "iface_combination %d: max_if %d, num_ch %d, bi_match %d\n",
2739 i
, iface_combinations
[i
].max_interfaces
,
2740 iface_combinations
[i
].num_different_channels
,
2741 iface_combinations
[i
].beacon_int_infra_match
);
2742 limit
= combo
->limits
;
2743 for (j
= 0; j
< combo
->n_limits
; j
++) {
2744 iface_limit
[j
].max
= le16_to_cpu(limit
[j
].max
);
2745 iface_limit
[j
].types
= le16_to_cpu(limit
[j
].types
);
2747 "limit %d: max %d types 0x%x\n", j
,
2748 iface_limit
[j
].max
, iface_limit
[j
].types
);
2750 iface_combinations
[i
].limits
= iface_limit
;
2751 iface_limit
+= combo
->n_limits
;
2752 limit
+= combo
->n_limits
;
2753 combo
= (struct wil_fw_concurrency_combo
*)limit
;
2756 wil_dbg_misc(wil
, "multiple VIFs supported, n_mids %d\n", conc
->n_mids
);
2757 wil
->max_vifs
= conc
->n_mids
+ 1; /* including main interface */
2758 if (wil
->max_vifs
> WIL_MAX_VIFS
) {
2759 wil_info(wil
, "limited number of VIFs supported(%d, FW %d)\n",
2760 WIL_MAX_VIFS
, wil
->max_vifs
);
2761 wil
->max_vifs
= WIL_MAX_VIFS
;
2763 wiphy
->n_iface_combinations
= n_combos
;
2764 wiphy
->iface_combinations
= iface_combinations
;
2768 struct wil6210_priv
*wil_cfg80211_init(struct device
*dev
)
2770 struct wiphy
*wiphy
;
2771 struct wil6210_priv
*wil
;
2772 struct ieee80211_channel
*ch
;
2774 dev_dbg(dev
, "%s()\n", __func__
);
2776 /* Note: the wireless_dev structure is no longer allocated here.
2777 * Instead, it is allocated as part of the net_device structure
2778 * for main interface and each VIF.
2780 wiphy
= wiphy_new(&wil_cfg80211_ops
, sizeof(struct wil6210_priv
));
2782 return ERR_PTR(-ENOMEM
);
2784 set_wiphy_dev(wiphy
, dev
);
2785 wil_wiphy_init(wiphy
);
2787 wil
= wiphy_to_wil(wiphy
);
2790 /* default monitor channel */
2791 ch
= wiphy
->bands
[NL80211_BAND_60GHZ
]->channels
;
2792 cfg80211_chandef_create(&wil
->monitor_chandef
, ch
, NL80211_CHAN_NO_HT
);
2797 void wil_cfg80211_deinit(struct wil6210_priv
*wil
)
2799 struct wiphy
*wiphy
= wil_to_wiphy(wil
);
2801 dev_dbg(wil_to_dev(wil
), "%s()\n", __func__
);
2806 kfree(wiphy
->iface_combinations
);
2807 wiphy
->iface_combinations
= NULL
;
2810 /* do not access wil6210_priv after returning from here */
2813 void wil_p2p_wdev_free(struct wil6210_priv
*wil
)
2815 struct wireless_dev
*p2p_wdev
;
2817 mutex_lock(&wil
->vif_mutex
);
2818 p2p_wdev
= wil
->p2p_wdev
;
2819 wil
->p2p_wdev
= NULL
;
2820 wil
->radio_wdev
= wil
->main_ndev
->ieee80211_ptr
;
2821 mutex_unlock(&wil
->vif_mutex
);
2823 cfg80211_unregister_wdev(p2p_wdev
);
2828 static int wil_rf_sector_status_to_rc(u8 status
)
2831 case WMI_RF_SECTOR_STATUS_SUCCESS
:
2833 case WMI_RF_SECTOR_STATUS_BAD_PARAMETERS_ERROR
:
2835 case WMI_RF_SECTOR_STATUS_BUSY_ERROR
:
2837 case WMI_RF_SECTOR_STATUS_NOT_SUPPORTED_ERROR
:
2844 static int wil_rf_sector_get_cfg(struct wiphy
*wiphy
,
2845 struct wireless_dev
*wdev
,
2846 const void *data
, int data_len
)
2848 struct wil6210_priv
*wil
= wdev_to_wil(wdev
);
2849 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
2851 struct nlattr
*tb
[QCA_ATTR_DMG_RF_SECTOR_MAX
+ 1];
2855 struct wmi_get_rf_sector_params_cmd cmd
;
2857 struct wmi_cmd_hdr wmi
;
2858 struct wmi_get_rf_sector_params_done_event evt
;
2859 } __packed reply
= {
2860 .evt
= {.status
= WMI_RF_SECTOR_STATUS_NOT_SUPPORTED_ERROR
},
2862 struct sk_buff
*msg
;
2863 struct nlattr
*nl_cfgs
, *nl_cfg
;
2865 struct wmi_rf_sector_info
*si
;
2867 if (!test_bit(WMI_FW_CAPABILITY_RF_SECTORS
, wil
->fw_capabilities
))
2870 rc
= nla_parse_deprecated(tb
, QCA_ATTR_DMG_RF_SECTOR_MAX
, data
,
2871 data_len
, wil_rf_sector_policy
, NULL
);
2873 wil_err(wil
, "Invalid rf sector ATTR\n");
2877 if (!tb
[QCA_ATTR_DMG_RF_SECTOR_INDEX
] ||
2878 !tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
] ||
2879 !tb
[QCA_ATTR_DMG_RF_MODULE_MASK
]) {
2880 wil_err(wil
, "Invalid rf sector spec\n");
2884 sector_index
= nla_get_u16(
2885 tb
[QCA_ATTR_DMG_RF_SECTOR_INDEX
]);
2886 if (sector_index
>= WIL_MAX_RF_SECTORS
) {
2887 wil_err(wil
, "Invalid sector index %d\n", sector_index
);
2891 sector_type
= nla_get_u8(tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
]);
2892 if (sector_type
>= QCA_ATTR_DMG_RF_SECTOR_TYPE_MAX
) {
2893 wil_err(wil
, "Invalid sector type %d\n", sector_type
);
2897 rf_modules_vec
= nla_get_u32(
2898 tb
[QCA_ATTR_DMG_RF_MODULE_MASK
]);
2899 if (rf_modules_vec
>= BIT(WMI_MAX_RF_MODULES_NUM
)) {
2900 wil_err(wil
, "Invalid rf module mask 0x%x\n", rf_modules_vec
);
2904 cmd
.sector_idx
= cpu_to_le16(sector_index
);
2905 cmd
.sector_type
= sector_type
;
2906 cmd
.rf_modules_vec
= rf_modules_vec
& 0xFF;
2907 rc
= wmi_call(wil
, WMI_GET_RF_SECTOR_PARAMS_CMDID
, vif
->mid
,
2908 &cmd
, sizeof(cmd
), WMI_GET_RF_SECTOR_PARAMS_DONE_EVENTID
,
2909 &reply
, sizeof(reply
),
2913 if (reply
.evt
.status
) {
2914 wil_err(wil
, "get rf sector cfg failed with status %d\n",
2916 return wil_rf_sector_status_to_rc(reply
.evt
.status
);
2919 msg
= cfg80211_vendor_cmd_alloc_reply_skb(
2920 wiphy
, 64 * WMI_MAX_RF_MODULES_NUM
);
2924 if (nla_put_u64_64bit(msg
, QCA_ATTR_TSF
,
2925 le64_to_cpu(reply
.evt
.tsf
),
2927 goto nla_put_failure
;
2929 nl_cfgs
= nla_nest_start_noflag(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG
);
2931 goto nla_put_failure
;
2932 for (i
= 0; i
< WMI_MAX_RF_MODULES_NUM
; i
++) {
2933 if (!(rf_modules_vec
& BIT(i
)))
2935 nl_cfg
= nla_nest_start_noflag(msg
, i
);
2937 goto nla_put_failure
;
2938 si
= &reply
.evt
.sectors_info
[i
];
2939 if (nla_put_u8(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG_MODULE_INDEX
,
2941 nla_put_u32(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE0
,
2942 le32_to_cpu(si
->etype0
)) ||
2943 nla_put_u32(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE1
,
2944 le32_to_cpu(si
->etype1
)) ||
2945 nla_put_u32(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE2
,
2946 le32_to_cpu(si
->etype2
)) ||
2947 nla_put_u32(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_HI
,
2948 le32_to_cpu(si
->psh_hi
)) ||
2949 nla_put_u32(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_LO
,
2950 le32_to_cpu(si
->psh_lo
)) ||
2951 nla_put_u32(msg
, QCA_ATTR_DMG_RF_SECTOR_CFG_DTYPE_X16
,
2952 le32_to_cpu(si
->dtype_swch_off
)))
2953 goto nla_put_failure
;
2954 nla_nest_end(msg
, nl_cfg
);
2957 nla_nest_end(msg
, nl_cfgs
);
2958 rc
= cfg80211_vendor_cmd_reply(msg
);
2965 static int wil_rf_sector_set_cfg(struct wiphy
*wiphy
,
2966 struct wireless_dev
*wdev
,
2967 const void *data
, int data_len
)
2969 struct wil6210_priv
*wil
= wdev_to_wil(wdev
);
2970 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
2972 struct nlattr
*tb
[QCA_ATTR_DMG_RF_SECTOR_MAX
+ 1];
2973 struct nlattr
*tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_MAX
+ 1];
2974 u16 sector_index
, rf_module_index
;
2976 u32 rf_modules_vec
= 0;
2977 struct wmi_set_rf_sector_params_cmd cmd
;
2979 struct wmi_cmd_hdr wmi
;
2980 struct wmi_set_rf_sector_params_done_event evt
;
2981 } __packed reply
= {
2982 .evt
= {.status
= WMI_RF_SECTOR_STATUS_NOT_SUPPORTED_ERROR
},
2984 struct nlattr
*nl_cfg
;
2985 struct wmi_rf_sector_info
*si
;
2987 if (!test_bit(WMI_FW_CAPABILITY_RF_SECTORS
, wil
->fw_capabilities
))
2990 rc
= nla_parse_deprecated(tb
, QCA_ATTR_DMG_RF_SECTOR_MAX
, data
,
2991 data_len
, wil_rf_sector_policy
, NULL
);
2993 wil_err(wil
, "Invalid rf sector ATTR\n");
2997 if (!tb
[QCA_ATTR_DMG_RF_SECTOR_INDEX
] ||
2998 !tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
] ||
2999 !tb
[QCA_ATTR_DMG_RF_SECTOR_CFG
]) {
3000 wil_err(wil
, "Invalid rf sector spec\n");
3004 sector_index
= nla_get_u16(
3005 tb
[QCA_ATTR_DMG_RF_SECTOR_INDEX
]);
3006 if (sector_index
>= WIL_MAX_RF_SECTORS
) {
3007 wil_err(wil
, "Invalid sector index %d\n", sector_index
);
3011 sector_type
= nla_get_u8(tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
]);
3012 if (sector_type
>= QCA_ATTR_DMG_RF_SECTOR_TYPE_MAX
) {
3013 wil_err(wil
, "Invalid sector type %d\n", sector_type
);
3017 memset(&cmd
, 0, sizeof(cmd
));
3019 cmd
.sector_idx
= cpu_to_le16(sector_index
);
3020 cmd
.sector_type
= sector_type
;
3021 nla_for_each_nested(nl_cfg
, tb
[QCA_ATTR_DMG_RF_SECTOR_CFG
],
3023 rc
= nla_parse_nested_deprecated(tb2
,
3024 QCA_ATTR_DMG_RF_SECTOR_CFG_MAX
,
3026 wil_rf_sector_cfg_policy
,
3029 wil_err(wil
, "invalid sector cfg\n");
3033 if (!tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_MODULE_INDEX
] ||
3034 !tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE0
] ||
3035 !tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE1
] ||
3036 !tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE2
] ||
3037 !tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_HI
] ||
3038 !tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_LO
] ||
3039 !tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_DTYPE_X16
]) {
3040 wil_err(wil
, "missing cfg params\n");
3044 rf_module_index
= nla_get_u8(
3045 tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_MODULE_INDEX
]);
3046 if (rf_module_index
>= WMI_MAX_RF_MODULES_NUM
) {
3047 wil_err(wil
, "invalid RF module index %d\n",
3051 rf_modules_vec
|= BIT(rf_module_index
);
3052 si
= &cmd
.sectors_info
[rf_module_index
];
3053 si
->etype0
= cpu_to_le32(nla_get_u32(
3054 tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE0
]));
3055 si
->etype1
= cpu_to_le32(nla_get_u32(
3056 tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE1
]));
3057 si
->etype2
= cpu_to_le32(nla_get_u32(
3058 tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_ETYPE2
]));
3059 si
->psh_hi
= cpu_to_le32(nla_get_u32(
3060 tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_HI
]));
3061 si
->psh_lo
= cpu_to_le32(nla_get_u32(
3062 tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_PSH_LO
]));
3063 si
->dtype_swch_off
= cpu_to_le32(nla_get_u32(
3064 tb2
[QCA_ATTR_DMG_RF_SECTOR_CFG_DTYPE_X16
]));
3067 cmd
.rf_modules_vec
= rf_modules_vec
& 0xFF;
3068 rc
= wmi_call(wil
, WMI_SET_RF_SECTOR_PARAMS_CMDID
, vif
->mid
,
3069 &cmd
, sizeof(cmd
), WMI_SET_RF_SECTOR_PARAMS_DONE_EVENTID
,
3070 &reply
, sizeof(reply
),
3074 return wil_rf_sector_status_to_rc(reply
.evt
.status
);
3077 static int wil_rf_sector_get_selected(struct wiphy
*wiphy
,
3078 struct wireless_dev
*wdev
,
3079 const void *data
, int data_len
)
3081 struct wil6210_priv
*wil
= wdev_to_wil(wdev
);
3082 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
3084 struct nlattr
*tb
[QCA_ATTR_DMG_RF_SECTOR_MAX
+ 1];
3085 u8 sector_type
, mac_addr
[ETH_ALEN
];
3087 struct wmi_get_selected_rf_sector_index_cmd cmd
;
3089 struct wmi_cmd_hdr wmi
;
3090 struct wmi_get_selected_rf_sector_index_done_event evt
;
3091 } __packed reply
= {
3092 .evt
= {.status
= WMI_RF_SECTOR_STATUS_NOT_SUPPORTED_ERROR
},
3094 struct sk_buff
*msg
;
3096 if (!test_bit(WMI_FW_CAPABILITY_RF_SECTORS
, wil
->fw_capabilities
))
3099 rc
= nla_parse_deprecated(tb
, QCA_ATTR_DMG_RF_SECTOR_MAX
, data
,
3100 data_len
, wil_rf_sector_policy
, NULL
);
3102 wil_err(wil
, "Invalid rf sector ATTR\n");
3106 if (!tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
]) {
3107 wil_err(wil
, "Invalid rf sector spec\n");
3110 sector_type
= nla_get_u8(tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
]);
3111 if (sector_type
>= QCA_ATTR_DMG_RF_SECTOR_TYPE_MAX
) {
3112 wil_err(wil
, "Invalid sector type %d\n", sector_type
);
3116 if (tb
[QCA_ATTR_MAC_ADDR
]) {
3117 ether_addr_copy(mac_addr
, nla_data(tb
[QCA_ATTR_MAC_ADDR
]));
3118 cid
= wil_find_cid(wil
, vif
->mid
, mac_addr
);
3120 wil_err(wil
, "invalid MAC address %pM\n", mac_addr
);
3124 if (test_bit(wil_vif_fwconnected
, vif
->status
)) {
3125 wil_err(wil
, "must specify MAC address when connected\n");
3130 memset(&cmd
, 0, sizeof(cmd
));
3132 cmd
.sector_type
= sector_type
;
3133 rc
= wmi_call(wil
, WMI_GET_SELECTED_RF_SECTOR_INDEX_CMDID
, vif
->mid
,
3135 WMI_GET_SELECTED_RF_SECTOR_INDEX_DONE_EVENTID
,
3136 &reply
, sizeof(reply
),
3140 if (reply
.evt
.status
) {
3141 wil_err(wil
, "get rf selected sector cfg failed with status %d\n",
3143 return wil_rf_sector_status_to_rc(reply
.evt
.status
);
3146 msg
= cfg80211_vendor_cmd_alloc_reply_skb(
3147 wiphy
, 64 * WMI_MAX_RF_MODULES_NUM
);
3151 if (nla_put_u64_64bit(msg
, QCA_ATTR_TSF
,
3152 le64_to_cpu(reply
.evt
.tsf
),
3154 nla_put_u16(msg
, QCA_ATTR_DMG_RF_SECTOR_INDEX
,
3155 le16_to_cpu(reply
.evt
.sector_idx
)))
3156 goto nla_put_failure
;
3158 rc
= cfg80211_vendor_cmd_reply(msg
);
3165 static int wil_rf_sector_wmi_set_selected(struct wil6210_priv
*wil
,
3166 u8 mid
, u16 sector_index
,
3167 u8 sector_type
, u8 cid
)
3169 struct wmi_set_selected_rf_sector_index_cmd cmd
;
3171 struct wmi_cmd_hdr wmi
;
3172 struct wmi_set_selected_rf_sector_index_done_event evt
;
3173 } __packed reply
= {
3174 .evt
= {.status
= WMI_RF_SECTOR_STATUS_NOT_SUPPORTED_ERROR
},
3178 memset(&cmd
, 0, sizeof(cmd
));
3179 cmd
.sector_idx
= cpu_to_le16(sector_index
);
3180 cmd
.sector_type
= sector_type
;
3182 rc
= wmi_call(wil
, WMI_SET_SELECTED_RF_SECTOR_INDEX_CMDID
, mid
,
3184 WMI_SET_SELECTED_RF_SECTOR_INDEX_DONE_EVENTID
,
3185 &reply
, sizeof(reply
),
3189 return wil_rf_sector_status_to_rc(reply
.evt
.status
);
3192 static int wil_rf_sector_set_selected(struct wiphy
*wiphy
,
3193 struct wireless_dev
*wdev
,
3194 const void *data
, int data_len
)
3196 struct wil6210_priv
*wil
= wdev_to_wil(wdev
);
3197 struct wil6210_vif
*vif
= wdev_to_vif(wil
, wdev
);
3199 struct nlattr
*tb
[QCA_ATTR_DMG_RF_SECTOR_MAX
+ 1];
3201 u8 sector_type
, mac_addr
[ETH_ALEN
], i
;
3204 if (!test_bit(WMI_FW_CAPABILITY_RF_SECTORS
, wil
->fw_capabilities
))
3207 rc
= nla_parse_deprecated(tb
, QCA_ATTR_DMG_RF_SECTOR_MAX
, data
,
3208 data_len
, wil_rf_sector_policy
, NULL
);
3210 wil_err(wil
, "Invalid rf sector ATTR\n");
3214 if (!tb
[QCA_ATTR_DMG_RF_SECTOR_INDEX
] ||
3215 !tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
]) {
3216 wil_err(wil
, "Invalid rf sector spec\n");
3220 sector_index
= nla_get_u16(
3221 tb
[QCA_ATTR_DMG_RF_SECTOR_INDEX
]);
3222 if (sector_index
>= WIL_MAX_RF_SECTORS
&&
3223 sector_index
!= WMI_INVALID_RF_SECTOR_INDEX
) {
3224 wil_err(wil
, "Invalid sector index %d\n", sector_index
);
3228 sector_type
= nla_get_u8(tb
[QCA_ATTR_DMG_RF_SECTOR_TYPE
]);
3229 if (sector_type
>= QCA_ATTR_DMG_RF_SECTOR_TYPE_MAX
) {
3230 wil_err(wil
, "Invalid sector type %d\n", sector_type
);
3234 if (tb
[QCA_ATTR_MAC_ADDR
]) {
3235 ether_addr_copy(mac_addr
, nla_data(tb
[QCA_ATTR_MAC_ADDR
]));
3236 if (!is_broadcast_ether_addr(mac_addr
)) {
3237 cid
= wil_find_cid(wil
, vif
->mid
, mac_addr
);
3239 wil_err(wil
, "invalid MAC address %pM\n",
3244 if (sector_index
!= WMI_INVALID_RF_SECTOR_INDEX
) {
3245 wil_err(wil
, "broadcast MAC valid only with unlocking\n");
3251 if (test_bit(wil_vif_fwconnected
, vif
->status
)) {
3252 wil_err(wil
, "must specify MAC address when connected\n");
3255 /* otherwise, using cid=0 for unassociated station */
3259 rc
= wil_rf_sector_wmi_set_selected(wil
, vif
->mid
, sector_index
,
3262 /* unlock all cids */
3263 rc
= wil_rf_sector_wmi_set_selected(
3264 wil
, vif
->mid
, WMI_INVALID_RF_SECTOR_INDEX
,
3265 sector_type
, WIL_CID_ALL
);
3266 if (rc
== -EINVAL
) {
3267 for (i
= 0; i
< wil
->max_assoc_sta
; i
++) {
3268 if (wil
->sta
[i
].mid
!= vif
->mid
)
3270 rc
= wil_rf_sector_wmi_set_selected(
3272 WMI_INVALID_RF_SECTOR_INDEX
,
3274 /* the FW will silently ignore and return
3275 * success for unused cid, so abort the loop
3276 * on any other error
3279 wil_err(wil
, "unlock cid %d failed with status %d\n",