Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'wireless-next-2022-06-10' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next

Johannes Berg says:

====================
wireless-next patches for v5.20

Here's a first set of patches for v5.20. This is just a
queue flush, before we get things back from net-next that
are causing conflicts, and then can start merging a lot
of MLO (multi-link operation, part of 802.11be) code.

Lots of cleanups all over.

The only notable change is perhaps wilc1000 being the
first driver to disable WEP (while enabling WPA3).

* tag 'wireless-next-2022-06-10' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next: (29 commits)
wifi: mac80211_hwsim: Directly use ida_alloc()/free()
wifi: mac80211: refactor some key code
wifi: mac80211: remove cipher scheme support
wifi: nl80211: fix typo in comment
wifi: virt_wifi: fix typo in comment
rtw89: add new state to CFO state machine for UL-OFDMA
rtw89: 8852c: add trigger frame counter
ieee80211: add trigger frame definition
wifi: wfx: Remove redundant NULL check before release_firmware() call
wifi: rtw89: support MULTI_BSSID and correct BSSID mask of H2C
wifi: ray_cs: Drop useless status variable in parse_addr()
wifi: ray_cs: Utilize strnlen() in parse_addr()
wifi: rtw88: use %*ph to print small buffer
wifi: wilc1000: add IGTK support
wifi: wilc1000: add WPA3 SAE support
wifi: wilc1000: remove WEP security support
wifi: wilc1000: use correct sequence of RESET for chip Power-UP/Down
wifi: rtlwifi: fix error codes in rtl_debugfs_set_write_h2c()
wifi: rtw88: Fix Sparse warning for rtw8821c_hw_spec
wifi: rtw88: Fix Sparse warning for rtw8723d_hw_spec
...
====================

Link: https://lore.kernel.org/r/20220610142838.330862-1-johannes@sipsolutions.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+780 -831
+2 -3
drivers/net/wireless/mac80211_hwsim.c
··· 290 290 { 291 291 struct hwsim_net *hwsim_net = net_generic(net, hwsim_net_id); 292 292 293 - hwsim_net->netgroup = ida_simple_get(&hwsim_netgroup_ida, 294 - 0, 0, GFP_KERNEL); 293 + hwsim_net->netgroup = ida_alloc(&hwsim_netgroup_ida, GFP_KERNEL); 295 294 return hwsim_net->netgroup >= 0 ? 0 : -ENOMEM; 296 295 } 297 296 ··· 4732 4733 NULL); 4733 4734 } 4734 4735 4735 - ida_simple_remove(&hwsim_netgroup_ida, hwsim_net_get_netgroup(net)); 4736 + ida_free(&hwsim_netgroup_ida, hwsim_net_get_netgroup(net)); 4736 4737 } 4737 4738 4738 4739 static struct pernet_operations hwsim_net_ops = {
+147 -97
drivers/net/wireless/microchip/wilc1000/cfg80211.c
··· 20 20 static const struct ieee80211_txrx_stypes 21 21 wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = { 22 22 [NL80211_IFTYPE_STATION] = { 23 - .tx = 0xffff, 23 + .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | 24 + BIT(IEEE80211_STYPE_AUTH >> 4), 24 25 .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 25 - BIT(IEEE80211_STYPE_PROBE_REQ >> 4) 26 + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | 27 + BIT(IEEE80211_STYPE_AUTH >> 4) 26 28 }, 27 29 [NL80211_IFTYPE_AP] = { 28 30 .tx = 0xffff, ··· 307 305 int ret; 308 306 u32 i; 309 307 u8 security = WILC_FW_SEC_NO; 308 + enum mfptype mfp_type = WILC_FW_MFP_NONE; 310 309 enum authtype auth_type = WILC_FW_AUTH_ANY; 311 310 u32 cipher_group; 312 311 struct cfg80211_bss *bss; ··· 316 313 317 314 vif->connecting = true; 318 315 319 - memset(priv->wep_key, 0, sizeof(priv->wep_key)); 320 - memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len)); 321 - 322 316 cipher_group = sme->crypto.cipher_group; 323 317 if (cipher_group != 0) { 324 - if (cipher_group == WLAN_CIPHER_SUITE_WEP40) { 325 - security = WILC_FW_SEC_WEP; 326 - 327 - priv->wep_key_len[sme->key_idx] = sme->key_len; 328 - memcpy(priv->wep_key[sme->key_idx], sme->key, 329 - sme->key_len); 330 - 331 - wilc_set_wep_default_keyid(vif, sme->key_idx); 332 - wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, 333 - sme->key_idx); 334 - } else if (cipher_group == WLAN_CIPHER_SUITE_WEP104) { 335 - security = WILC_FW_SEC_WEP_EXTENDED; 336 - 337 - priv->wep_key_len[sme->key_idx] = sme->key_len; 338 - memcpy(priv->wep_key[sme->key_idx], sme->key, 339 - sme->key_len); 340 - 341 - wilc_set_wep_default_keyid(vif, sme->key_idx); 342 - wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, 343 - sme->key_idx); 344 - } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { 318 + if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { 345 319 if (cipher_group == WLAN_CIPHER_SUITE_TKIP) 346 320 security = WILC_FW_SEC_WPA2_TKIP; 347 321 else ··· 353 373 auth_type = WILC_FW_AUTH_OPEN_SYSTEM; 354 374 break; 355 375 356 - case NL80211_AUTHTYPE_SHARED_KEY: 357 - auth_type = WILC_FW_AUTH_SHARED_KEY; 376 + case NL80211_AUTHTYPE_SAE: 377 + auth_type = WILC_FW_AUTH_SAE; 378 + if (sme->ssid_len) { 379 + memcpy(vif->auth.ssid.ssid, sme->ssid, sme->ssid_len); 380 + vif->auth.ssid.ssid_len = sme->ssid_len; 381 + } 382 + vif->auth.key_mgmt_suite = cpu_to_be32(sme->crypto.akm_suites[0]); 383 + ether_addr_copy(vif->auth.bssid, sme->bssid); 358 384 break; 359 385 360 386 default: ··· 370 384 if (sme->crypto.n_akm_suites) { 371 385 if (sme->crypto.akm_suites[0] == WLAN_AKM_SUITE_8021X) 372 386 auth_type = WILC_FW_AUTH_IEEE8021; 387 + else if (sme->crypto.akm_suites[0] == WLAN_AKM_SUITE_PSK_SHA256) 388 + auth_type = WILC_FW_AUTH_OPEN_SYSTEM_SHA256; 389 + else if (sme->crypto.akm_suites[0] == WLAN_AKM_SUITE_8021X_SHA256) 390 + auth_type = WILC_FW_AUTH_IEE8021X_SHA256; 373 391 } 374 392 375 393 if (wfi_drv->usr_scan_req.scan_result) { ··· 416 426 wfi_drv->conn_info.conn_result = cfg_connect_result; 417 427 wfi_drv->conn_info.arg = priv; 418 428 wfi_drv->conn_info.param = join_params; 429 + 430 + if (sme->mfp == NL80211_MFP_OPTIONAL) 431 + mfp_type = WILC_FW_MFP_OPTIONAL; 432 + else if (sme->mfp == NL80211_MFP_REQUIRED) 433 + mfp_type = WILC_FW_MFP_REQUIRED; 434 + 435 + wfi_drv->conn_info.mfp_type = mfp_type; 419 436 420 437 ret = wilc_set_join_req(vif, bss->bssid, sme->ie, sme->ie_len); 421 438 if (ret) { ··· 484 487 return ret; 485 488 } 486 489 487 - static inline void wilc_wfi_cfg_copy_wep_info(struct wilc_priv *priv, 488 - u8 key_index, 489 - struct key_params *params) 490 - { 491 - priv->wep_key_len[key_index] = params->key_len; 492 - memcpy(priv->wep_key[key_index], params->key, params->key_len); 493 - } 494 - 495 490 static int wilc_wfi_cfg_allocate_wpa_entry(struct wilc_priv *priv, u8 idx) 496 491 { 497 492 if (!priv->wilc_gtk[idx]) { ··· 500 511 return -ENOMEM; 501 512 } 502 513 514 + return 0; 515 + } 516 + 517 + static int wilc_wfi_cfg_allocate_wpa_igtk_entry(struct wilc_priv *priv, u8 idx) 518 + { 519 + idx -= 4; 520 + if (!priv->wilc_igtk[idx]) { 521 + priv->wilc_igtk[idx] = kzalloc(sizeof(*priv->wilc_igtk[idx]), 522 + GFP_KERNEL); 523 + if (!priv->wilc_igtk[idx]) 524 + return -ENOMEM; 525 + } 503 526 return 0; 504 527 } 505 528 ··· 551 550 u8 op_mode; 552 551 struct wilc_vif *vif = netdev_priv(netdev); 553 552 struct wilc_priv *priv = &vif->priv; 553 + struct wilc_wfi_key *key; 554 554 555 555 switch (params->cipher) { 556 - case WLAN_CIPHER_SUITE_WEP40: 557 - case WLAN_CIPHER_SUITE_WEP104: 558 - if (priv->wdev.iftype == NL80211_IFTYPE_AP) { 559 - wilc_wfi_cfg_copy_wep_info(priv, key_index, params); 560 - 561 - if (params->cipher == WLAN_CIPHER_SUITE_WEP40) 562 - mode = WILC_FW_SEC_WEP; 563 - else 564 - mode = WILC_FW_SEC_WEP_EXTENDED; 565 - 566 - ret = wilc_add_wep_key_bss_ap(vif, params->key, 567 - params->key_len, 568 - key_index, mode, 569 - WILC_FW_AUTH_OPEN_SYSTEM); 570 - break; 571 - } 572 - if (memcmp(params->key, priv->wep_key[key_index], 573 - params->key_len)) { 574 - wilc_wfi_cfg_copy_wep_info(priv, key_index, params); 575 - 576 - ret = wilc_add_wep_key_bss_sta(vif, params->key, 577 - params->key_len, 578 - key_index); 579 - } 580 - 581 - break; 582 - 583 556 case WLAN_CIPHER_SUITE_TKIP: 584 557 case WLAN_CIPHER_SUITE_CCMP: 585 558 if (priv->wdev.iftype == NL80211_IFTYPE_AP || ··· 615 640 key_index); 616 641 617 642 break; 643 + case WLAN_CIPHER_SUITE_AES_CMAC: 644 + ret = wilc_wfi_cfg_allocate_wpa_igtk_entry(priv, key_index); 645 + if (ret) 646 + return -ENOMEM; 647 + 648 + key = priv->wilc_igtk[key_index - 4]; 649 + ret = wilc_wfi_cfg_copy_wpa_info(key, params); 650 + if (ret) 651 + return -ENOMEM; 652 + 653 + if (priv->wdev.iftype == NL80211_IFTYPE_AP || 654 + priv->wdev.iftype == NL80211_IFTYPE_P2P_GO) 655 + op_mode = WILC_AP_MODE; 656 + else 657 + op_mode = WILC_STATION_MODE; 658 + 659 + ret = wilc_add_igtk(vif, params->key, keylen, params->seq, 660 + params->seq_len, mac_addr, op_mode, 661 + key_index); 662 + break; 618 663 619 664 default: 620 665 netdev_err(netdev, "%s: Unsupported cipher\n", __func__); ··· 652 657 struct wilc_vif *vif = netdev_priv(netdev); 653 658 struct wilc_priv *priv = &vif->priv; 654 659 655 - if (priv->wilc_gtk[key_index]) { 656 - kfree(priv->wilc_gtk[key_index]->key); 657 - priv->wilc_gtk[key_index]->key = NULL; 658 - kfree(priv->wilc_gtk[key_index]->seq); 659 - priv->wilc_gtk[key_index]->seq = NULL; 660 + if (!pairwise && (key_index == 4 || key_index == 5)) { 661 + key_index -= 4; 662 + if (priv->wilc_igtk[key_index]) { 663 + kfree(priv->wilc_igtk[key_index]->key); 664 + priv->wilc_igtk[key_index]->key = NULL; 665 + kfree(priv->wilc_igtk[key_index]->seq); 666 + priv->wilc_igtk[key_index]->seq = NULL; 667 + kfree(priv->wilc_igtk[key_index]); 668 + priv->wilc_igtk[key_index] = NULL; 669 + } 670 + } else { 671 + if (priv->wilc_gtk[key_index]) { 672 + kfree(priv->wilc_gtk[key_index]->key); 673 + priv->wilc_gtk[key_index]->key = NULL; 674 + kfree(priv->wilc_gtk[key_index]->seq); 675 + priv->wilc_gtk[key_index]->seq = NULL; 660 676 661 - kfree(priv->wilc_gtk[key_index]); 662 - priv->wilc_gtk[key_index] = NULL; 663 - } 664 - 665 - if (priv->wilc_ptk[key_index]) { 666 - kfree(priv->wilc_ptk[key_index]->key); 667 - priv->wilc_ptk[key_index]->key = NULL; 668 - kfree(priv->wilc_ptk[key_index]->seq); 669 - priv->wilc_ptk[key_index]->seq = NULL; 670 - kfree(priv->wilc_ptk[key_index]); 671 - priv->wilc_ptk[key_index] = NULL; 672 - } 673 - 674 - if (key_index <= 3 && priv->wep_key_len[key_index]) { 675 - memset(priv->wep_key[key_index], 0, 676 - priv->wep_key_len[key_index]); 677 - priv->wep_key_len[key_index] = 0; 678 - wilc_remove_wep_key(vif, key_index); 677 + kfree(priv->wilc_gtk[key_index]); 678 + priv->wilc_gtk[key_index] = NULL; 679 + } 680 + if (priv->wilc_ptk[key_index]) { 681 + kfree(priv->wilc_ptk[key_index]->key); 682 + priv->wilc_ptk[key_index]->key = NULL; 683 + kfree(priv->wilc_ptk[key_index]->seq); 684 + priv->wilc_ptk[key_index]->seq = NULL; 685 + kfree(priv->wilc_ptk[key_index]); 686 + priv->wilc_ptk[key_index] = NULL; 687 + } 679 688 } 680 689 681 690 return 0; ··· 694 695 struct key_params key_params; 695 696 696 697 if (!pairwise) { 697 - key_params.key = priv->wilc_gtk[key_index]->key; 698 - key_params.cipher = priv->wilc_gtk[key_index]->cipher; 699 - key_params.key_len = priv->wilc_gtk[key_index]->key_len; 700 - key_params.seq = priv->wilc_gtk[key_index]->seq; 701 - key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; 698 + if (key_index == 4 || key_index == 5) { 699 + key_index -= 4; 700 + key_params.key = priv->wilc_igtk[key_index]->key; 701 + key_params.cipher = priv->wilc_igtk[key_index]->cipher; 702 + key_params.key_len = priv->wilc_igtk[key_index]->key_len; 703 + key_params.seq = priv->wilc_igtk[key_index]->seq; 704 + key_params.seq_len = priv->wilc_igtk[key_index]->seq_len; 705 + } else { 706 + key_params.key = priv->wilc_gtk[key_index]->key; 707 + key_params.cipher = priv->wilc_gtk[key_index]->cipher; 708 + key_params.key_len = priv->wilc_gtk[key_index]->key_len; 709 + key_params.seq = priv->wilc_gtk[key_index]->seq; 710 + key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; 711 + } 702 712 } else { 703 713 key_params.key = priv->wilc_ptk[key_index]->key; 704 714 key_params.cipher = priv->wilc_ptk[key_index]->cipher; ··· 721 713 return 0; 722 714 } 723 715 716 + /* wiphy_new_nm() will WARNON if not present */ 724 717 static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, 725 718 u8 key_index, bool unicast, bool multicast) 726 719 { 720 + return 0; 721 + } 722 + 723 + static int set_default_mgmt_key(struct wiphy *wiphy, struct net_device *netdev, 724 + u8 key_index) 725 + { 727 726 struct wilc_vif *vif = netdev_priv(netdev); 728 727 729 - wilc_set_wep_default_keyid(vif, key_index); 730 - 731 - return 0; 728 + return wilc_set_default_mgmt_key_index(vif, key_index); 732 729 } 733 730 734 731 static int get_station(struct wiphy *wiphy, struct net_device *dev, ··· 990 977 } 991 978 } 992 979 980 + bool wilc_wfi_mgmt_frame_rx(struct wilc_vif *vif, u8 *buff, u32 size) 981 + { 982 + struct wilc *wl = vif->wilc; 983 + struct wilc_priv *priv = &vif->priv; 984 + int freq, ret; 985 + 986 + freq = ieee80211_channel_to_frequency(wl->op_ch, NL80211_BAND_2GHZ); 987 + ret = cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); 988 + 989 + return ret; 990 + } 991 + 993 992 void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) 994 993 { 995 994 struct wilc *wl = vif->wilc; ··· 1187 1162 goto out_txq_add_pkt; 1188 1163 } 1189 1164 1190 - if (!ieee80211_is_public_action((struct ieee80211_hdr *)buf, len)) 1165 + if (!ieee80211_is_public_action((struct ieee80211_hdr *)buf, len)) { 1166 + if (chan) 1167 + wilc_set_mac_chnl_num(vif, chan->hw_value); 1168 + else 1169 + wilc_set_mac_chnl_num(vif, vif->wilc->op_ch); 1170 + 1191 1171 goto out_set_timeout; 1172 + } 1192 1173 1193 1174 d = (struct wilc_p2p_pub_act_frame *)(&mgmt->u.action); 1194 1175 if (d->oui_type != WLAN_OUI_TYPE_WFA_P2P || ··· 1261 1230 struct wilc_vif *vif = netdev_priv(wdev->netdev); 1262 1231 u32 presp_bit = BIT(IEEE80211_STYPE_PROBE_REQ >> 4); 1263 1232 u32 action_bit = BIT(IEEE80211_STYPE_ACTION >> 4); 1233 + u32 pauth_bit = BIT(IEEE80211_STYPE_AUTH >> 4); 1264 1234 1265 1235 if (wl->initialized) { 1266 1236 bool prev = vif->mgmt_reg_stypes & presp_bit; ··· 1275 1243 1276 1244 if (now != prev) 1277 1245 wilc_frame_register(vif, IEEE80211_STYPE_ACTION, now); 1246 + 1247 + prev = vif->mgmt_reg_stypes & pauth_bit; 1248 + now = upd->interface_stypes & pauth_bit; 1249 + if (now != prev) 1250 + wilc_frame_register(vif, IEEE80211_STYPE_AUTH, now); 1278 1251 } 1279 1252 1280 1253 vif->mgmt_reg_stypes = 1281 - upd->interface_stypes & (presp_bit | action_bit); 1254 + upd->interface_stypes & (presp_bit | action_bit | pauth_bit); 1255 + } 1256 + 1257 + static int external_auth(struct wiphy *wiphy, struct net_device *dev, 1258 + struct cfg80211_external_auth_params *auth) 1259 + { 1260 + struct wilc_vif *vif = netdev_priv(dev); 1261 + 1262 + if (auth->status == WLAN_STATUS_SUCCESS) 1263 + wilc_set_external_auth_param(vif, auth); 1264 + 1265 + return 0; 1282 1266 } 1283 1267 1284 1268 static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, ··· 1695 1647 .del_key = del_key, 1696 1648 .get_key = get_key, 1697 1649 .set_default_key = set_default_key, 1650 + .set_default_mgmt_key = set_default_mgmt_key, 1698 1651 .add_virtual_intf = add_virtual_intf, 1699 1652 .del_virtual_intf = del_virtual_intf, 1700 1653 .change_virtual_intf = change_virtual_intf, ··· 1711 1662 .change_bss = change_bss, 1712 1663 .set_wiphy_params = set_wiphy_params, 1713 1664 1665 + .external_auth = external_auth, 1714 1666 .set_pmksa = set_pmksa, 1715 1667 .del_pmksa = del_pmksa, 1716 1668 .flush_pmksa = flush_pmksa, ··· 1854 1804 BIT(NL80211_IFTYPE_P2P_GO) | 1855 1805 BIT(NL80211_IFTYPE_P2P_CLIENT); 1856 1806 wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; 1857 - 1807 + wiphy->features |= NL80211_FEATURE_SAE; 1858 1808 set_wiphy_dev(wiphy, dev); 1859 1809 wl->wiphy = wiphy; 1860 1810 ret = wiphy_register(wiphy);
+17 -6
drivers/net/wireless/microchip/wilc1000/fw.h
··· 41 41 u8 mode; 42 42 } __packed; 43 43 44 - struct wilc_wep_key { 45 - u8 index; 46 - u8 key_len; 47 - u8 key[]; 48 - } __packed; 49 - 50 44 struct wilc_sta_wpa_ptk { 51 45 u8 mac_addr[ETH_ALEN]; 52 46 u8 key_len; ··· 50 56 struct wilc_ap_wpa_ptk { 51 57 u8 mac_addr[ETH_ALEN]; 52 58 u8 index; 59 + u8 key_len; 60 + u8 key[]; 61 + } __packed; 62 + 63 + struct wilc_wpa_igtk { 64 + u8 index; 65 + u8 pn_len; 66 + u8 pn[6]; 53 67 u8 key_len; 54 68 u8 key[]; 55 69 } __packed; ··· 117 115 struct wilc_noa_opp_disable opp_dis; 118 116 struct wilc_noa_opp_enable opp_en; 119 117 }; 118 + } __packed; 119 + 120 + struct wilc_external_auth_param { 121 + u8 action; 122 + u8 bssid[ETH_ALEN]; 123 + u8 ssid[IEEE80211_MAX_SSID_LEN]; 124 + u8 ssid_len; 125 + __le32 key_mgmt_suites; 126 + __le16 status; 120 127 } __packed; 121 128 #endif
+96 -106
drivers/net/wireless/microchip/wilc1000/hif.c
··· 271 271 static int wilc_send_connect_wid(struct wilc_vif *vif) 272 272 { 273 273 int result = 0; 274 - struct wid wid_list[4]; 274 + struct wid wid_list[5]; 275 275 u32 wid_cnt = 0; 276 276 struct host_if_drv *hif_drv = vif->hif_drv; 277 277 struct wilc_conn_info *conn_attr = &hif_drv->conn_info; 278 278 struct wilc_join_bss_param *bss_param = conn_attr->param; 279 + 280 + 281 + wid_list[wid_cnt].id = WID_SET_MFP; 282 + wid_list[wid_cnt].type = WID_CHAR; 283 + wid_list[wid_cnt].size = sizeof(char); 284 + wid_list[wid_cnt].val = (s8 *)&conn_attr->mfp_type; 285 + wid_cnt++; 279 286 280 287 wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE; 281 288 wid_list[wid_cnt].type = WID_BIN_DATA; ··· 313 306 netdev_err(vif->ndev, "failed to send config packet\n"); 314 307 goto error; 315 308 } else { 316 - hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; 309 + if (conn_attr->auth_type == WILC_FW_AUTH_SAE) 310 + hif_drv->hif_state = HOST_IF_EXTERNAL_AUTH; 311 + else 312 + hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; 317 313 } 318 314 319 315 return 0; ··· 675 665 goto free_msg; 676 666 } 677 667 678 - if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { 668 + 669 + if (hif_drv->hif_state == HOST_IF_EXTERNAL_AUTH) { 670 + cfg80211_external_auth_request(vif->ndev, &vif->auth, 671 + GFP_KERNEL); 672 + hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; 673 + } else if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { 679 674 host_int_parse_assoc_resp_info(vif, mac_info->status); 680 675 } else if (mac_info->status == WILC_MAC_STATUS_DISCONNECTED) { 681 676 if (hif_drv->hif_state == HOST_IF_CONNECTED) { ··· 725 710 } 726 711 727 712 if (conn_info->conn_result) { 728 - if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) 713 + if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP || 714 + hif_drv->hif_state == HOST_IF_EXTERNAL_AUTH) 729 715 del_timer(&hif_drv->connect_timer); 730 716 731 717 conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, 0, ··· 1002 986 pr_err("Failed to send wowlan trigger config packet\n"); 1003 987 } 1004 988 989 + int wilc_set_external_auth_param(struct wilc_vif *vif, 990 + struct cfg80211_external_auth_params *auth) 991 + { 992 + int ret; 993 + struct wid wid; 994 + struct wilc_external_auth_param *param; 995 + 996 + wid.id = WID_EXTERNAL_AUTH_PARAM; 997 + wid.type = WID_BIN_DATA; 998 + wid.size = sizeof(*param); 999 + param = kzalloc(sizeof(*param), GFP_KERNEL); 1000 + if (!param) 1001 + return -EINVAL; 1002 + 1003 + wid.val = (u8 *)param; 1004 + param->action = auth->action; 1005 + ether_addr_copy(param->bssid, auth->bssid); 1006 + memcpy(param->ssid, auth->ssid.ssid, auth->ssid.ssid_len); 1007 + param->ssid_len = auth->ssid.ssid_len; 1008 + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1009 + 1010 + kfree(param); 1011 + return ret; 1012 + } 1013 + 1005 1014 static void handle_scan_timer(struct work_struct *work) 1006 1015 { 1007 1016 struct host_if_msg *msg = container_of(work, struct host_if_msg, work); ··· 1077 1036 result = wilc_enqueue_work(msg); 1078 1037 if (result) 1079 1038 kfree(msg); 1080 - } 1081 - 1082 - int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) 1083 - { 1084 - struct wid wid; 1085 - int result; 1086 - 1087 - wid.id = WID_REMOVE_WEP_KEY; 1088 - wid.type = WID_STR; 1089 - wid.size = sizeof(char); 1090 - wid.val = &index; 1091 - 1092 - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1093 - if (result) 1094 - netdev_err(vif->ndev, 1095 - "Failed to send remove wep key config packet\n"); 1096 - return result; 1097 - } 1098 - 1099 - int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) 1100 - { 1101 - struct wid wid; 1102 - int result; 1103 - 1104 - wid.id = WID_KEY_ID; 1105 - wid.type = WID_CHAR; 1106 - wid.size = sizeof(char); 1107 - wid.val = &index; 1108 - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1109 - if (result) 1110 - netdev_err(vif->ndev, 1111 - "Failed to send wep default key config packet\n"); 1112 - 1113 - return result; 1114 - } 1115 - 1116 - int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, 1117 - u8 index) 1118 - { 1119 - struct wid wid; 1120 - int result; 1121 - struct wilc_wep_key *wep_key; 1122 - 1123 - wid.id = WID_ADD_WEP_KEY; 1124 - wid.type = WID_STR; 1125 - wid.size = sizeof(*wep_key) + len; 1126 - wep_key = kzalloc(wid.size, GFP_KERNEL); 1127 - if (!wep_key) 1128 - return -ENOMEM; 1129 - 1130 - wid.val = (u8 *)wep_key; 1131 - 1132 - wep_key->index = index; 1133 - wep_key->key_len = len; 1134 - memcpy(wep_key->key, key, len); 1135 - 1136 - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1137 - if (result) 1138 - netdev_err(vif->ndev, 1139 - "Failed to add wep key config packet\n"); 1140 - 1141 - kfree(wep_key); 1142 - return result; 1143 - } 1144 - 1145 - int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, 1146 - u8 index, u8 mode, enum authtype auth_type) 1147 - { 1148 - struct wid wid_list[3]; 1149 - int result; 1150 - struct wilc_wep_key *wep_key; 1151 - 1152 - wid_list[0].id = WID_11I_MODE; 1153 - wid_list[0].type = WID_CHAR; 1154 - wid_list[0].size = sizeof(char); 1155 - wid_list[0].val = &mode; 1156 - 1157 - wid_list[1].id = WID_AUTH_TYPE; 1158 - wid_list[1].type = WID_CHAR; 1159 - wid_list[1].size = sizeof(char); 1160 - wid_list[1].val = (s8 *)&auth_type; 1161 - 1162 - wid_list[2].id = WID_WEP_KEY_VALUE; 1163 - wid_list[2].type = WID_STR; 1164 - wid_list[2].size = sizeof(*wep_key) + len; 1165 - wep_key = kzalloc(wid_list[2].size, GFP_KERNEL); 1166 - if (!wep_key) 1167 - return -ENOMEM; 1168 - 1169 - wid_list[2].val = (u8 *)wep_key; 1170 - 1171 - wep_key->index = index; 1172 - wep_key->key_len = len; 1173 - memcpy(wep_key->key, key, len); 1174 - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, 1175 - ARRAY_SIZE(wid_list)); 1176 - if (result) 1177 - netdev_err(vif->ndev, 1178 - "Failed to add wep ap key config packet\n"); 1179 - 1180 - kfree(wep_key); 1181 - return result; 1182 1039 } 1183 1040 1184 1041 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, ··· 1146 1207 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1147 1208 kfree(key_buf); 1148 1209 } 1210 + 1211 + return result; 1212 + } 1213 + 1214 + int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len, 1215 + const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode, u8 index) 1216 + { 1217 + int result = 0; 1218 + u8 t_key_len = igtk_key_len; 1219 + struct wid wid; 1220 + struct wilc_wpa_igtk *key_buf; 1221 + 1222 + key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); 1223 + if (!key_buf) 1224 + return -ENOMEM; 1225 + 1226 + key_buf->index = index; 1227 + 1228 + memcpy(&key_buf->pn[0], pn, pn_len); 1229 + key_buf->pn_len = pn_len; 1230 + 1231 + memcpy(&key_buf->key[0], igtk, igtk_key_len); 1232 + key_buf->key_len = t_key_len; 1233 + 1234 + wid.id = WID_ADD_IGTK; 1235 + wid.type = WID_STR; 1236 + wid.size = sizeof(*key_buf) + t_key_len; 1237 + wid.val = (s8 *)key_buf; 1238 + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1239 + kfree(key_buf); 1149 1240 1150 1241 return result; 1151 1242 } ··· 1718 1749 reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; 1719 1750 break; 1720 1751 1752 + case IEEE80211_STYPE_AUTH: 1753 + reg_frame.reg_id = WILC_FW_AUTH_REQ_IDX; 1754 + break; 1755 + 1721 1756 default: 1722 1757 break; 1723 1758 } ··· 1968 1995 wid.size = sizeof(char); 1969 1996 1970 1997 return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); 1998 + } 1999 + 2000 + int wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index) 2001 + { 2002 + struct wid wid; 2003 + int result; 2004 + 2005 + wid.id = WID_DEFAULT_MGMT_KEY_ID; 2006 + wid.type = WID_CHAR; 2007 + wid.size = sizeof(char); 2008 + wid.val = &index; 2009 + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 2010 + if (result) 2011 + netdev_err(vif->ndev, 2012 + "Failed to send default mgmt key index\n"); 2013 + 2014 + return result; 1971 2015 }
+8 -6
drivers/net/wireless/microchip/wilc1000/hif.h
··· 47 47 HOST_IF_WAITING_CONN_RESP = 3, 48 48 HOST_IF_CONNECTED = 4, 49 49 HOST_IF_P2P_LISTEN = 5, 50 + HOST_IF_EXTERNAL_AUTH = 6, 50 51 HOST_IF_FORCE_32BIT = 0xFFFFFFFF 51 52 }; 52 53 ··· 108 107 u8 bssid[ETH_ALEN]; 109 108 u8 security; 110 109 enum authtype auth_type; 110 + enum mfptype mfp_type; 111 111 u8 ch; 112 112 u8 *req_ies; 113 113 size_t req_ies_len; ··· 153 151 }; 154 152 155 153 struct wilc_vif; 156 - int wilc_remove_wep_key(struct wilc_vif *vif, u8 index); 157 - int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index); 158 - int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, 159 - u8 index); 160 - int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, 161 - u8 index, u8 mode, enum authtype auth_type); 162 154 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, 163 155 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, 164 156 u8 mode, u8 cipher_mode, u8 index); 157 + int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len, 158 + const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode, 159 + u8 index); 165 160 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, 166 161 u32 *out_val); 167 162 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, ··· 207 208 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power); 208 209 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power); 209 210 void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled); 211 + int wilc_set_external_auth_param(struct wilc_vif *vif, 212 + struct cfg80211_external_auth_params *param); 210 213 void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length); 211 214 void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length); 212 215 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length); 213 216 void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, 214 217 struct cfg80211_crypto_settings *crypto); 218 + int wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index); 215 219 #endif
+10 -1
drivers/net/wireless/microchip/wilc1000/netdev.c
··· 835 835 } 836 836 } 837 837 838 - void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) 838 + void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth) 839 839 { 840 840 int srcu_idx; 841 841 struct wilc_vif *vif; 842 842 843 843 srcu_idx = srcu_read_lock(&wilc->srcu); 844 844 list_for_each_entry_rcu(vif, &wilc->vif_list, list) { 845 + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buff; 845 846 u16 type = le16_to_cpup((__le16 *)buff); 846 847 u32 type_bit = BIT(type >> 4); 848 + u32 auth_bit = BIT(IEEE80211_STYPE_AUTH >> 4); 849 + 850 + if ((vif->mgmt_reg_stypes & auth_bit && 851 + ieee80211_is_auth(mgmt->frame_control)) && 852 + vif->iftype == WILC_STATION_MODE && is_auth) { 853 + wilc_wfi_mgmt_frame_rx(vif, buff, size); 854 + break; 855 + } 847 856 848 857 if (vif->priv.p2p_listen_state && 849 858 vif->mgmt_reg_stypes & type_bit)
+3 -11
drivers/net/wireless/microchip/wilc1000/netdev.h
··· 45 45 u32 cipher; 46 46 }; 47 47 48 - struct wilc_wfi_wep_key { 49 - u8 *key; 50 - u8 key_len; 51 - u8 key_idx; 52 - }; 53 - 54 48 struct sta_info { 55 49 u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN]; 56 50 }; ··· 57 63 }; 58 64 59 65 static const u32 wilc_cipher_suites[] = { 60 - WLAN_CIPHER_SUITE_WEP40, 61 - WLAN_CIPHER_SUITE_WEP104, 62 66 WLAN_CIPHER_SUITE_TKIP, 63 67 WLAN_CIPHER_SUITE_CCMP, 64 68 WLAN_CIPHER_SUITE_AES_CMAC ··· 124 132 struct net_device *dev; 125 133 struct host_if_drv *hif_drv; 126 134 struct wilc_pmkid_attr pmkid_list; 127 - u8 wep_key[4][WLAN_KEY_LEN_WEP104]; 128 - u8 wep_key_len[4]; 129 135 130 136 /* The real interface that the monitor is on */ 131 137 struct net_device *real_ndev; 132 138 struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA]; 133 139 struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA]; 140 + struct wilc_wfi_key *wilc_igtk[2]; 134 141 u8 wilc_groupkey; 135 142 136 143 /* mutexes */ ··· 186 195 struct wilc_priv priv; 187 196 struct list_head list; 188 197 struct cfg80211_bss *bss; 198 + struct cfg80211_external_auth_params auth; 189 199 }; 190 200 191 201 struct wilc_tx_queue_status { ··· 280 288 void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); 281 289 void wilc_mac_indicate(struct wilc *wilc); 282 290 void wilc_netdev_cleanup(struct wilc *wilc); 283 - void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); 291 + void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth); 284 292 void wilc_wlan_set_bssid(struct net_device *wilc_netdev, const u8 *bssid, 285 293 u8 mode); 286 294 struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
+3 -3
drivers/net/wireless/microchip/wilc1000/spi.c
··· 191 191 /* assert ENABLE: */ 192 192 gpiod_set_value(gpios->enable, 1); 193 193 mdelay(5); 194 - /* deassert RESET: */ 195 - gpiod_set_value(gpios->reset, 0); 196 - } else { 197 194 /* assert RESET: */ 198 195 gpiod_set_value(gpios->reset, 1); 196 + } else { 197 + /* deassert RESET: */ 198 + gpiod_set_value(gpios->reset, 0); 199 199 /* deassert ENABLE: */ 200 200 gpiod_set_value(gpios->enable, 0); 201 201 }
+2 -1
drivers/net/wireless/microchip/wilc1000/wlan.c
··· 968 968 969 969 if (pkt_offset & IS_MANAGMEMENT) { 970 970 buff_ptr += HOST_HDR_OFFSET; 971 - wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len); 971 + wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len, 972 + pkt_offset & IS_MGMT_AUTH_PKT); 972 973 } else { 973 974 if (!is_cfg_packet) { 974 975 wilc_frmw_to_host(wilc, buff_ptr, pkt_len,
+2
drivers/net/wireless/microchip/wilc1000/wlan.h
··· 305 305 #define IS_MANAGMEMENT 0x100 306 306 #define IS_MANAGMEMENT_CALLBACK 0x080 307 307 #define IS_MGMT_STATUS_SUCCES 0x040 308 + #define IS_MGMT_AUTH_PKT 0x010 308 309 309 310 #define WILC_WID_TYPE GENMASK(15, 12) 310 311 #define WILC_VMM_ENTRY_FULL_RETRY 1 ··· 424 423 netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); 425 424 426 425 void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size); 426 + bool wilc_wfi_mgmt_frame_rx(struct wilc_vif *vif, u8 *buff, u32 size); 427 427 void host_wakeup_notify(struct wilc *wilc); 428 428 void host_sleep_notify(struct wilc *wilc); 429 429 void chip_allow_sleep(struct wilc *wilc);
+17 -3
drivers/net/wireless/microchip/wilc1000/wlan_if.h
··· 85 85 WILC_FW_AUTH_OPEN_SYSTEM = 1, 86 86 WILC_FW_AUTH_SHARED_KEY = 2, 87 87 WILC_FW_AUTH_ANY = 3, 88 - WILC_FW_AUTH_IEEE8021 = 5 88 + WILC_FW_AUTH_IEEE8021 = 5, 89 + WILC_FW_AUTH_SAE = 7, 90 + WILC_FW_AUTH_IEE8021X_SHA256 = 9, 91 + WILC_FW_AUTH_OPEN_SYSTEM_SHA256 = 13 92 + }; 93 + 94 + enum mfptype { 95 + WILC_FW_MFP_NONE = 0x0, 96 + WILC_FW_MFP_OPTIONAL = 0x1, 97 + WILC_FW_MFP_REQUIRED = 0x2 89 98 }; 90 99 91 100 enum site_survey { ··· 185 176 186 177 enum { 187 178 WILC_FW_ACTION_FRM_IDX = 0, 188 - WILC_FW_PROBE_REQ_IDX = 1 179 + WILC_FW_PROBE_REQ_IDX = 1, 180 + WILC_FW_AUTH_REQ_IDX = 2 189 181 }; 190 182 191 183 enum wid_type { ··· 667 657 WID_LOG_TERMINAL_SWITCH = 0x00CD, 668 658 WID_TX_POWER = 0x00CE, 669 659 WID_WOWLAN_TRIGGER = 0X00CF, 660 + WID_SET_MFP = 0x00D0, 661 + 662 + WID_DEFAULT_MGMT_KEY_ID = 0x00D2, 670 663 /* EMAC Short WID list */ 671 664 /* RTS Threshold */ 672 665 /* ··· 759 746 WID_REMOVE_KEY = 0x301E, 760 747 WID_ASSOC_REQ_INFO = 0x301F, 761 748 WID_ASSOC_RES_INFO = 0x3020, 749 + WID_ADD_IGTK = 0x3022, 762 750 WID_MANUFACTURER = 0x3026, /* Added for CAPI tool */ 763 751 WID_MODEL_NAME = 0x3027, /* Added for CAPI tool */ 764 752 WID_MODEL_NUM = 0x3028, /* Added for CAPI tool */ ··· 803 789 WID_ADD_BEACON = 0x408a, 804 790 805 791 WID_SETUP_MULTICAST_FILTER = 0x408b, 806 - 792 + WID_EXTERNAL_AUTH_PARAM = 0x408d, 807 793 /* Miscellaneous WIDs */ 808 794 WID_ALL = 0x7FFE, 809 795 WID_MAX = 0xFFFF
+8 -12
drivers/net/wireless/ray_cs.c
··· 1643 1643 /*===========================================================================*/ 1644 1644 static int parse_addr(char *in_str, UCHAR *out) 1645 1645 { 1646 + int i, k; 1646 1647 int len; 1647 - int i, j, k; 1648 - int status; 1649 1648 1650 1649 if (in_str == NULL) 1651 1650 return 0; 1652 - if ((len = strlen(in_str)) < 2) 1651 + len = strnlen(in_str, ADDRLEN * 2 + 1) - 1; 1652 + if (len < 1) 1653 1653 return 0; 1654 1654 memset(out, 0, ADDRLEN); 1655 1655 1656 - status = 1; 1657 - j = len - 1; 1658 - if (j > 12) 1659 - j = 12; 1660 1656 i = 5; 1661 1657 1662 - while (j > 0) { 1663 - if ((k = hex_to_bin(in_str[j--])) != -1) 1658 + while (len > 0) { 1659 + if ((k = hex_to_bin(in_str[len--])) != -1) 1664 1660 out[i] = k; 1665 1661 else 1666 1662 return 0; 1667 1663 1668 - if (j == 0) 1664 + if (len == 0) 1669 1665 break; 1670 - if ((k = hex_to_bin(in_str[j--])) != -1) 1666 + if ((k = hex_to_bin(in_str[len--])) != -1) 1671 1667 out[i] += k << 4; 1672 1668 else 1673 1669 return 0; 1674 1670 if (!i--) 1675 1671 break; 1676 1672 } 1677 - return status; 1673 + return 1; 1678 1674 } 1679 1675 1680 1676 /*===========================================================================*/
+4 -4
drivers/net/wireless/realtek/rtlwifi/debug.c
··· 329 329 330 330 tmp_len = (count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count); 331 331 332 - if (!buffer || copy_from_user(tmp, buffer, tmp_len)) 333 - return count; 332 + if (copy_from_user(tmp, buffer, tmp_len)) 333 + return -EFAULT; 334 334 335 335 tmp[tmp_len] = '\0'; 336 336 ··· 340 340 &h2c_data[4], &h2c_data[5], 341 341 &h2c_data[6], &h2c_data[7]); 342 342 343 - if (h2c_len <= 0) 344 - return count; 343 + if (h2c_len == 0) 344 + return -EINVAL; 345 345 346 346 for (i = 0; i < h2c_len; i++) 347 347 h2c_data_packed[i] = (u8)h2c_data[i];
+1 -5
drivers/net/wireless/realtek/rtw88/debug.c
··· 269 269 for (i = 0 ; i < buf_size ; i += 8) { 270 270 if (i % page_size == 0) 271 271 seq_printf(m, "PAGE %d\n", (i + offset) / page_size); 272 - seq_printf(m, "%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 273 - *(buf + i), *(buf + i + 1), 274 - *(buf + i + 2), *(buf + i + 3), 275 - *(buf + i + 4), *(buf + i + 5), 276 - *(buf + i + 6), *(buf + i + 7)); 272 + seq_printf(m, "%8ph\n", buf + i); 277 273 } 278 274 vfree(buf); 279 275
+4 -1
drivers/net/wireless/realtek/rtw88/main.c
··· 1383 1383 void rtw_core_scan_complete(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, 1384 1384 bool hw_scan) 1385 1385 { 1386 - struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; 1386 + struct rtw_vif *rtwvif = vif ? (struct rtw_vif *)vif->drv_priv : NULL; 1387 1387 u32 config = 0; 1388 + 1389 + if (!rtwvif) 1390 + return; 1388 1391 1389 1392 clear_bit(RTW_FLAG_SCANNING, rtwdev->flags); 1390 1393 clear_bit(RTW_FLAG_DIG_DISABLE, rtwdev->flags);
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8723d.c
··· 2701 2701 {0x953, BIT(1), RTW_REG_DOMAIN_MAC8}, 2702 2702 }; 2703 2703 2704 - struct rtw_chip_info rtw8723d_hw_spec = { 2704 + const struct rtw_chip_info rtw8723d_hw_spec = { 2705 2705 .ops = &rtw8723d_ops, 2706 2706 .id = RTW_CHIP_TYPE_8723D, 2707 2707 .fw_name = "rtw88/rtw8723d_fw.bin",
+2
drivers/net/wireless/realtek/rtw88/rtw8723d.h
··· 72 72 struct rtw8723de_efuse e; 73 73 }; 74 74 75 + extern const struct rtw_chip_info rtw8723d_hw_spec; 76 + 75 77 /* phy status page0 */ 76 78 #define GET_PHY_STAT_P0_PWDB(phy_stat) \ 77 79 le32_get_bits(*((__le32 *)(phy_stat) + 0x00), GENMASK(15, 8))
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8723de.c
··· 5 5 #include <linux/module.h> 6 6 #include <linux/pci.h> 7 7 #include "pci.h" 8 - #include "rtw8723de.h" 8 + #include "rtw8723d.h" 9 9 10 10 static const struct pci_device_id rtw_8723de_id_table[] = { 11 11 {
-10
drivers/net/wireless/realtek/rtw88/rtw8723de.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 - /* Copyright(c) 2018-2019 Realtek Corporation 3 - */ 4 - 5 - #ifndef __RTW_8723DE_H_ 6 - #define __RTW_8723DE_H_ 7 - 8 - extern struct rtw_chip_info rtw8723d_hw_spec; 9 - 10 - #endif
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8821c.c
··· 1877 1877 {0x60A, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 1878 1878 }; 1879 1879 1880 - struct rtw_chip_info rtw8821c_hw_spec = { 1880 + const struct rtw_chip_info rtw8821c_hw_spec = { 1881 1881 .ops = &rtw8821c_ops, 1882 1882 .id = RTW_CHIP_TYPE_8821C, 1883 1883 .fw_name = "rtw88/rtw8821c_fw.bin",
+2
drivers/net/wireless/realtek/rtw88/rtw8821c.h
··· 84 84 rtw_write32_mask(rtwdev, addr + 0x200, mask, data); 85 85 } 86 86 87 + extern const struct rtw_chip_info rtw8821c_hw_spec; 88 + 87 89 #define rtw_write32s_mask(rtwdev, addr, mask, data) \ 88 90 do { \ 89 91 BUILD_BUG_ON((addr) < 0xC00 || (addr) >= 0xD00); \
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8821ce.c
··· 5 5 #include <linux/module.h> 6 6 #include <linux/pci.h> 7 7 #include "pci.h" 8 - #include "rtw8821ce.h" 8 + #include "rtw8821c.h" 9 9 10 10 static const struct pci_device_id rtw_8821ce_id_table[] = { 11 11 {
-10
drivers/net/wireless/realtek/rtw88/rtw8821ce.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 - /* Copyright(c) 2018-2019 Realtek Corporation 3 - */ 4 - 5 - #ifndef __RTW_8821CE_H_ 6 - #define __RTW_8821CE_H_ 7 - 8 - extern struct rtw_chip_info rtw8821c_hw_spec; 9 - 10 - #endif
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8822b.c
··· 2497 2497 [EDCCA_TH_H2L_IDX] = {{.addr = 0x8a4, .mask = MASKBYTE1}, .offset = 0}, 2498 2498 }; 2499 2499 2500 - struct rtw_chip_info rtw8822b_hw_spec = { 2500 + const struct rtw_chip_info rtw8822b_hw_spec = { 2501 2501 .ops = &rtw8822b_ops, 2502 2502 .id = RTW_CHIP_TYPE_8822B, 2503 2503 .fw_name = "rtw88/rtw8822b_fw.bin",
+2
drivers/net/wireless/realtek/rtw88/rtw8822b.h
··· 187 187 #define REG_ANTWT 0x1904 188 188 #define REG_IQKFAILMSK 0x1bf0 189 189 190 + extern const struct rtw_chip_info rtw8822b_hw_spec; 191 + 190 192 #endif
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8822be.c
··· 5 5 #include <linux/module.h> 6 6 #include <linux/pci.h> 7 7 #include "pci.h" 8 - #include "rtw8822be.h" 8 + #include "rtw8822b.h" 9 9 10 10 static const struct pci_device_id rtw_8822be_id_table[] = { 11 11 {
-10
drivers/net/wireless/realtek/rtw88/rtw8822be.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 - /* Copyright(c) 2018-2019 Realtek Corporation 3 - */ 4 - 5 - #ifndef __RTW_8822BE_H_ 6 - #define __RTW_8822BE_H_ 7 - 8 - extern struct rtw_chip_info rtw8822b_hw_spec; 9 - 10 - #endif
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8822c.c
··· 5310 5310 {0xc50, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 5311 5311 }; 5312 5312 5313 - struct rtw_chip_info rtw8822c_hw_spec = { 5313 + const struct rtw_chip_info rtw8822c_hw_spec = { 5314 5314 .ops = &rtw8822c_ops, 5315 5315 .id = RTW_CHIP_TYPE_8822C, 5316 5316 .fw_name = "rtw88/rtw8822c_fw.bin",
+2
drivers/net/wireless/realtek/rtw88/rtw8822c.h
··· 118 118 void rtw8822c_parse_tbl_dpk(struct rtw_dev *rtwdev, 119 119 const struct rtw_table *tbl); 120 120 121 + extern const struct rtw_chip_info rtw8822c_hw_spec; 122 + 121 123 #define RTW_DECL_TABLE_DPK(name) \ 122 124 const struct rtw_table name ## _tbl = { \ 123 125 .data = name, \
+1 -1
drivers/net/wireless/realtek/rtw88/rtw8822ce.c
··· 5 5 #include <linux/module.h> 6 6 #include <linux/pci.h> 7 7 #include "pci.h" 8 - #include "rtw8822ce.h" 8 + #include "rtw8822c.h" 9 9 10 10 static const struct pci_device_id rtw_8822ce_id_table[] = { 11 11 {
-10
drivers/net/wireless/realtek/rtw88/rtw8822ce.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 - /* Copyright(c) 2018-2019 Realtek Corporation 3 - */ 4 - 5 - #ifndef __RTW_8822CE_H_ 6 - #define __RTW_8822CE_H_ 7 - 8 - extern struct rtw_chip_info rtw8822c_hw_spec; 9 - 10 - #endif
+7
drivers/net/wireless/realtek/rtw89/cam.c
··· 602 602 struct ieee80211_vif *vif = rtwvif_to_vif(rtwvif); 603 603 struct rtw89_bssid_cam_entry *bssid_cam = &rtwvif->bssid_cam; 604 604 u8 bss_color = vif->bss_conf.he_bss_color.color; 605 + u8 bss_mask; 606 + 607 + if (vif->bss_conf.nontransmitted) 608 + bss_mask = RTW89_BSSID_MATCH_5_BYTES; 609 + else 610 + bss_mask = RTW89_BSSID_MATCH_ALL; 605 611 606 612 FWCMD_SET_ADDR_BSSID_IDX(cmd, bssid_cam->bssid_cam_idx); 607 613 FWCMD_SET_ADDR_BSSID_OFFSET(cmd, bssid_cam->offset); 608 614 FWCMD_SET_ADDR_BSSID_LEN(cmd, bssid_cam->len); 609 615 FWCMD_SET_ADDR_BSSID_VALID(cmd, bssid_cam->valid); 616 + FWCMD_SET_ADDR_BSSID_MASK(cmd, bss_mask); 610 617 FWCMD_SET_ADDR_BSSID_BB_SEL(cmd, bssid_cam->phy_idx); 611 618 FWCMD_SET_ADDR_BSSID_BSS_COLOR(cmd, bss_color); 612 619
+8
drivers/net/wireless/realtek/rtw89/cam.h
··· 9 9 10 10 #define RTW89_SEC_CAM_LEN 20 11 11 12 + #define RTW89_BSSID_MATCH_ALL GENMASK(5, 0) 13 + #define RTW89_BSSID_MATCH_5_BYTES GENMASK(4, 0) 14 + 12 15 static inline void FWCMD_SET_ADDR_IDX(void *cmd, u32 value) 13 16 { 14 17 le32p_replace_bits((__le32 *)(cmd) + 1, value, GENMASK(7, 0)); ··· 310 307 static inline void FWCMD_SET_ADDR_BSSID_BB_SEL(void *cmd, u32 value) 311 308 { 312 309 le32p_replace_bits((__le32 *)(cmd) + 13, value, BIT(1)); 310 + } 311 + 312 + static inline void FWCMD_SET_ADDR_BSSID_MASK(void *cmd, u32 value) 313 + { 314 + le32p_replace_bits((__le32 *)(cmd) + 13, value, GENMASK(7, 2)); 313 315 } 314 316 315 317 static inline void FWCMD_SET_ADDR_BSSID_BSS_COLOR(void *cmd, u32 value)
+54 -2
drivers/net/wireless/realtek/rtw89/core.c
··· 1343 1343 const u8 *bssid; 1344 1344 }; 1345 1345 1346 + static void rtw89_stats_trigger_frame(struct rtw89_dev *rtwdev, 1347 + struct ieee80211_vif *vif, 1348 + struct sk_buff *skb) 1349 + { 1350 + struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; 1351 + struct ieee80211_trigger *tf = (struct ieee80211_trigger *)skb->data; 1352 + u8 *pos, *end, type; 1353 + u16 aid; 1354 + 1355 + if (!ether_addr_equal(vif->bss_conf.bssid, tf->ta) || 1356 + rtwvif->wifi_role != RTW89_WIFI_ROLE_STATION || 1357 + rtwvif->net_type == RTW89_NET_TYPE_NO_LINK) 1358 + return; 1359 + 1360 + type = le64_get_bits(tf->common_info, IEEE80211_TRIGGER_TYPE_MASK); 1361 + if (type != IEEE80211_TRIGGER_TYPE_BASIC) 1362 + return; 1363 + 1364 + end = (u8 *)tf + skb->len; 1365 + pos = tf->variable; 1366 + 1367 + while (end - pos >= RTW89_TF_BASIC_USER_INFO_SZ) { 1368 + aid = RTW89_GET_TF_USER_INFO_AID12(pos); 1369 + rtw89_debug(rtwdev, RTW89_DBG_TXRX, 1370 + "[TF] aid: %d, ul_mcs: %d, rua: %d\n", 1371 + aid, RTW89_GET_TF_USER_INFO_UL_MCS(pos), 1372 + RTW89_GET_TF_USER_INFO_RUA(pos)); 1373 + 1374 + if (aid == RTW89_TF_PAD) 1375 + break; 1376 + 1377 + if (aid == vif->bss_conf.aid) { 1378 + rtwvif->stats.rx_tf_acc++; 1379 + rtwdev->stats.rx_tf_acc++; 1380 + break; 1381 + } 1382 + 1383 + pos += RTW89_TF_BASIC_USER_INFO_SZ; 1384 + } 1385 + } 1386 + 1346 1387 static void rtw89_vif_rx_stats_iter(void *data, u8 *mac, 1347 1388 struct ieee80211_vif *vif) 1348 1389 { ··· 1395 1354 struct sk_buff *skb = iter_data->skb; 1396 1355 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1397 1356 const u8 *bssid = iter_data->bssid; 1357 + 1358 + if (ieee80211_is_trigger(hdr->frame_control)) { 1359 + rtw89_stats_trigger_frame(rtwdev, vif, skb); 1360 + return; 1361 + } 1398 1362 1399 1363 if (!ether_addr_equal(vif->bss_conf.bssid, bssid)) 1400 1364 return; ··· 1654 1608 1655 1609 if (rtwdev->scanning && 1656 1610 RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw)) { 1657 - u8 chan = hal->current_channel; 1611 + u8 chan = hal->current_primary_channel; 1658 1612 u8 band = hal->current_band_type; 1659 1613 enum nl80211_band nl_band; 1660 1614 ··· 2069 2023 stats->rx_unicast = 0; 2070 2024 stats->tx_cnt = 0; 2071 2025 stats->rx_cnt = 0; 2026 + stats->rx_tf_periodic = stats->rx_tf_acc; 2027 + stats->rx_tf_acc = 0; 2072 2028 2073 2029 if (tx_tfc_lv != stats->tx_tfc_lv || rx_tfc_lv != stats->rx_tfc_lv) 2074 2030 return true; ··· 2923 2875 void rtw89_core_scan_complete(struct rtw89_dev *rtwdev, 2924 2876 struct ieee80211_vif *vif, bool hw_scan) 2925 2877 { 2926 - struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; 2878 + struct rtw89_vif *rtwvif = vif ? (struct rtw89_vif *)vif->drv_priv : NULL; 2879 + 2880 + if (!rtwvif) 2881 + return; 2927 2882 2928 2883 ether_addr_copy(rtwvif->mac_addr, vif->addr); 2929 2884 rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL, NULL); ··· 3059 3008 ieee80211_hw_set(hw, SUPPORTS_PS); 3060 3009 ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS); 3061 3010 ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS); 3011 + ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID); 3062 3012 3063 3013 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 3064 3014 BIT(NL80211_IFTYPE_AP);
+43 -2
drivers/net/wireless/realtek/rtw89/core.h
··· 55 55 #define RTW89_HTC_MASK_HTC_OM_DL_MU_MIMO_RR BIT(16) 56 56 #define RTW89_HTC_MASK_HTC_OM_UL_MU_DATA_DIS BIT(17) 57 57 58 + #define RTW89_TF_PAD GENMASK(11, 0) 59 + #define RTW89_TF_BASIC_USER_INFO_SZ 6 60 + 61 + #define RTW89_GET_TF_USER_INFO_AID12(data) \ 62 + le32_get_bits(*((const __le32 *)(data)), GENMASK(11, 0)) 63 + #define RTW89_GET_TF_USER_INFO_RUA(data) \ 64 + le32_get_bits(*((const __le32 *)(data)), GENMASK(19, 12)) 65 + #define RTW89_GET_TF_USER_INFO_UL_MCS(data) \ 66 + le32_get_bits(*((const __le32 *)(data)), GENMASK(24, 21)) 67 + 58 68 enum rtw89_subband { 59 69 RTW89_CH_2G = 0, 60 70 RTW89_CH_5G_BAND_1 = 1, ··· 953 943 u32 rx_throughput; 954 944 u32 tx_throughput_raw; 955 945 u32 rx_throughput_raw; 946 + 947 + u32 rx_tf_acc; 948 + u32 rx_tf_periodic; 949 + 956 950 enum rtw89_tfc_lv tx_tfc_lv; 957 951 enum rtw89_tfc_lv rx_tfc_lv; 958 952 struct ewma_tp tx_ewma_tp; ··· 2564 2550 RTW89_SAR_SOURCE_NR, 2565 2551 }; 2566 2552 2553 + enum rtw89_sar_subband { 2554 + RTW89_SAR_2GHZ_SUBBAND, 2555 + RTW89_SAR_5GHZ_SUBBAND_1_2, /* U-NII-1 and U-NII-2 */ 2556 + RTW89_SAR_5GHZ_SUBBAND_2_E, /* U-NII-2-Extended */ 2557 + RTW89_SAR_5GHZ_SUBBAND_3, /* U-NII-3 */ 2558 + RTW89_SAR_6GHZ_SUBBAND_5_L, /* U-NII-5 lower part */ 2559 + RTW89_SAR_6GHZ_SUBBAND_5_H, /* U-NII-5 higher part */ 2560 + RTW89_SAR_6GHZ_SUBBAND_6, /* U-NII-6 */ 2561 + RTW89_SAR_6GHZ_SUBBAND_7_L, /* U-NII-7 lower part */ 2562 + RTW89_SAR_6GHZ_SUBBAND_7_H, /* U-NII-7 higher part */ 2563 + RTW89_SAR_6GHZ_SUBBAND_8, /* U-NII-8 */ 2564 + 2565 + RTW89_SAR_SUBBAND_NR, 2566 + }; 2567 + 2567 2568 struct rtw89_sar_cfg_common { 2568 - bool set[RTW89_SUBBAND_NR]; 2569 - s32 cfg[RTW89_SUBBAND_NR]; 2569 + bool set[RTW89_SAR_SUBBAND_NR]; 2570 + s32 cfg[RTW89_SAR_SUBBAND_NR]; 2570 2571 }; 2571 2572 2572 2573 struct rtw89_sar_info { ··· 2672 2643 }; 2673 2644 2674 2645 struct rtw89_lck_info { 2646 + u8 thermal[RF_PATH_MAX]; 2647 + }; 2648 + 2649 + struct rtw89_rx_dck_info { 2675 2650 u8 thermal[RF_PATH_MAX]; 2676 2651 }; 2677 2652 ··· 2809 2776 enum rtw89_phy_cfo_status { 2810 2777 RTW89_PHY_DCFO_STATE_NORMAL = 0, 2811 2778 RTW89_PHY_DCFO_STATE_ENHANCE = 1, 2779 + RTW89_PHY_DCFO_STATE_HOLD = 2, 2812 2780 RTW89_PHY_DCFO_STATE_MAX 2781 + }; 2782 + 2783 + enum rtw89_phy_cfo_ul_ofdma_acc_mode { 2784 + RTW89_CFO_UL_OFDMA_ACC_DISABLE = 0, 2785 + RTW89_CFO_UL_OFDMA_ACC_ENABLE = 1 2813 2786 }; 2814 2787 2815 2788 struct rtw89_cfo_tracking_info { 2816 2789 u16 cfo_timer_ms; 2817 2790 bool cfo_trig_by_timer_en; 2818 2791 enum rtw89_phy_cfo_status phy_cfo_status; 2792 + enum rtw89_phy_cfo_ul_ofdma_acc_mode cfo_ul_ofdma_acc_mode; 2819 2793 u8 phy_cfo_trk_cnt; 2820 2794 bool is_adjust; 2821 2795 enum rtw89_multi_cfo_mode rtw89_multi_cfo_mode; ··· 3165 3125 struct rtw89_dpk_info dpk; 3166 3126 struct rtw89_mcc_info mcc; 3167 3127 struct rtw89_lck_info lck; 3128 + struct rtw89_rx_dck_info rx_dck; 3168 3129 bool is_tssi_mode[RF_PATH_MAX]; 3169 3130 bool is_bt_iqk_timeout; 3170 3131
+2 -1
drivers/net/wireless/realtek/rtw89/debug.c
··· 2376 2376 seq_printf(m, "TP TX: %u [%u] Mbps (lv: %d), RX: %u [%u] Mbps (lv: %d)\n", 2377 2377 stats->tx_throughput, stats->tx_throughput_raw, stats->tx_tfc_lv, 2378 2378 stats->rx_throughput, stats->rx_throughput_raw, stats->rx_tfc_lv); 2379 - seq_printf(m, "Beacon: %u\n", pkt_stat->beacon_nr); 2379 + seq_printf(m, "Beacon: %u, TF: %u\n", pkt_stat->beacon_nr, 2380 + stats->rx_tf_periodic); 2380 2381 seq_printf(m, "Avg packet length: TX=%u, RX=%u\n", stats->tx_avg_len, 2381 2382 stats->rx_avg_len); 2382 2383
+1
drivers/net/wireless/realtek/rtw89/debug.h
··· 24 24 RTW89_DBG_BTC = BIT(13), 25 25 RTW89_DBG_BF = BIT(14), 26 26 RTW89_DBG_HW_SCAN = BIT(15), 27 + RTW89_DBG_SAR = BIT(16), 27 28 }; 28 29 29 30 enum rtw89_debug_mac_reg_sel {
+17 -7
drivers/net/wireless/realtek/rtw89/fw.c
··· 2257 2257 list_add_tail(&ch_info->list, &chan_list); 2258 2258 off_chan_time += ch_info->period; 2259 2259 } 2260 - rtw89_fw_h2c_scan_list_offload(rtwdev, list_len, &chan_list); 2260 + ret = rtw89_fw_h2c_scan_list_offload(rtwdev, list_len, &chan_list); 2261 2261 2262 2262 out: 2263 2263 list_for_each_entry_safe(ch_info, tmp, &chan_list, list) { ··· 2339 2339 rtwvif->scan_req = NULL; 2340 2340 rtwvif->scan_ies = NULL; 2341 2341 rtwdev->scan_info.scanning_vif = NULL; 2342 + 2343 + if (rtwvif->net_type != RTW89_NET_TYPE_NO_LINK) 2344 + rtw89_store_op_chan(rtwdev, false); 2342 2345 } 2343 2346 2344 2347 void rtw89_hw_scan_abort(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif) ··· 2368 2365 if (ret) 2369 2366 goto out; 2370 2367 } 2371 - rtw89_fw_h2c_scan_offload(rtwdev, &opt, rtwvif); 2368 + ret = rtw89_fw_h2c_scan_offload(rtwdev, &opt, rtwvif); 2372 2369 out: 2373 2370 return ret; 2374 2371 } 2375 2372 2376 - void rtw89_store_op_chan(struct rtw89_dev *rtwdev) 2373 + void rtw89_store_op_chan(struct rtw89_dev *rtwdev, bool backup) 2377 2374 { 2378 2375 struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; 2379 2376 struct rtw89_hal *hal = &rtwdev->hal; 2380 2377 2381 - scan_info->op_pri_ch = hal->current_primary_channel; 2382 - scan_info->op_chan = hal->current_channel; 2383 - scan_info->op_bw = hal->current_band_width; 2384 - scan_info->op_band = hal->current_band_type; 2378 + if (backup) { 2379 + scan_info->op_pri_ch = hal->current_primary_channel; 2380 + scan_info->op_chan = hal->current_channel; 2381 + scan_info->op_bw = hal->current_band_width; 2382 + scan_info->op_band = hal->current_band_type; 2383 + } else { 2384 + hal->current_primary_channel = scan_info->op_pri_ch; 2385 + hal->current_channel = scan_info->op_chan; 2386 + hal->current_band_width = scan_info->op_bw; 2387 + hal->current_band_type = scan_info->op_band; 2388 + } 2385 2389 } 2386 2390 2387 2391 #define H2C_FW_CPU_EXCEPTION_LEN 4
+1 -4
drivers/net/wireless/realtek/rtw89/fw.h
··· 2633 2633 struct rtw89_mac_c2h_info *c2h_info); 2634 2634 int rtw89_fw_h2c_fw_log(struct rtw89_dev *rtwdev, bool enable); 2635 2635 void rtw89_fw_st_dbg_dump(struct rtw89_dev *rtwdev); 2636 - void rtw89_store_op_chan(struct rtw89_dev *rtwdev); 2636 + void rtw89_store_op_chan(struct rtw89_dev *rtwdev, bool backup); 2637 2637 void rtw89_hw_scan_start(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, 2638 2638 struct ieee80211_scan_request *req); 2639 2639 void rtw89_hw_scan_complete(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, 2640 2640 bool aborted); 2641 2641 int rtw89_hw_scan_offload(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif, 2642 2642 bool enable); 2643 - void rtw89_hw_scan_status_report(struct rtw89_dev *rtwdev, struct sk_buff *skb); 2644 - void rtw89_hw_scan_chan_switch(struct rtw89_dev *rtwdev, struct sk_buff *skb); 2645 2643 void rtw89_hw_scan_abort(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif); 2646 - void rtw89_store_op_chan(struct rtw89_dev *rtwdev); 2647 2644 int rtw89_fw_h2c_trigger_cpu_exception(struct rtw89_dev *rtwdev); 2648 2645 2649 2646 #endif
+9 -6
drivers/net/wireless/realtek/rtw89/mac.c
··· 3681 3681 rtw89_hw_scan_complete(rtwdev, vif, false); 3682 3682 break; 3683 3683 case RTW89_SCAN_ENTER_CH_NOTIFY: 3684 - if (rtw89_is_op_chan(rtwdev, band, chan)) 3684 + hal->prev_band_type = hal->current_band_type; 3685 + hal->current_band_type = band; 3686 + hal->prev_primary_channel = hal->current_primary_channel; 3687 + hal->current_primary_channel = chan; 3688 + hal->current_channel = chan; 3689 + hal->current_band_width = RTW89_CHANNEL_WIDTH_20; 3690 + if (rtw89_is_op_chan(rtwdev, band, chan)) { 3691 + rtw89_store_op_chan(rtwdev, false); 3685 3692 ieee80211_wake_queues(rtwdev->hw); 3693 + } 3686 3694 break; 3687 3695 default: 3688 3696 return; 3689 3697 } 3690 - 3691 - hal->prev_band_type = hal->current_band_type; 3692 - hal->prev_primary_channel = hal->current_channel; 3693 - hal->current_channel = chan; 3694 - hal->current_band_type = band; 3695 3698 } 3696 3699 3697 3700 static void
+1
drivers/net/wireless/realtek/rtw89/mac.h
··· 666 666 MAC_AX_ERR_L2_ERR_APB_BBRF_TO_RX4281 = 0x2360, 667 667 MAC_AX_ERR_L2_ERR_APB_BBRF_TO_OTHERS = 0x2370, 668 668 MAC_AX_ERR_L2_RESET_DONE = 0x2400, 669 + MAC_AX_ERR_L2_ERR_WDT_TIMEOUT_INT = 0x2599, 669 670 MAC_AX_ERR_CPU_EXCEPTION = 0x3000, 670 671 MAC_AX_ERR_ASSERTION = 0x4000, 671 672 MAC_AX_GET_ERR_MAX,
+1 -1
drivers/net/wireless/realtek/rtw89/mac80211.c
··· 350 350 rtw89_phy_set_bss_color(rtwdev, vif); 351 351 rtw89_chip_cfg_txpwr_ul_tb_offset(rtwdev, vif); 352 352 rtw89_mac_port_update(rtwdev, rtwvif); 353 - rtw89_store_op_chan(rtwdev); 353 + rtw89_store_op_chan(rtwdev, true); 354 354 } else { 355 355 /* Abort ongoing scan if cancel_scan isn't issued 356 356 * when disconnected by peer
+6 -3
drivers/net/wireless/realtek/rtw89/pci.c
··· 738 738 if (unlikely(isrs.halt_c2h_isrs & B_AX_HALT_C2H_INT_EN)) 739 739 rtw89_ser_notify(rtwdev, rtw89_mac_get_err_status(rtwdev)); 740 740 741 + if (unlikely(isrs.halt_c2h_isrs & B_AX_WDT_TIMEOUT_INT_EN)) 742 + rtw89_ser_notify(rtwdev, MAC_AX_ERR_L2_ERR_WDT_TIMEOUT_INT); 743 + 741 744 if (unlikely(rtwpci->under_recovery)) 742 745 goto enable_intr; 743 746 ··· 3129 3126 struct rtw89_pci *rtwpci = (struct rtw89_pci *)rtwdev->priv; 3130 3127 3131 3128 rtwpci->ind_intrs = B_AX_HS0ISR_IND_INT_EN; 3132 - rtwpci->halt_c2h_intrs = B_AX_HALT_C2H_INT_EN; 3129 + rtwpci->halt_c2h_intrs = B_AX_HALT_C2H_INT_EN | B_AX_WDT_TIMEOUT_INT_EN; 3133 3130 rtwpci->intrs[0] = 0; 3134 3131 rtwpci->intrs[1] = 0; 3135 3132 } ··· 3141 3138 rtwpci->ind_intrs = B_AX_HCI_AXIDMA_INT_EN | 3142 3139 B_AX_HS1ISR_IND_INT_EN | 3143 3140 B_AX_HS0ISR_IND_INT_EN; 3144 - rtwpci->halt_c2h_intrs = B_AX_HALT_C2H_INT_EN; 3141 + rtwpci->halt_c2h_intrs = B_AX_HALT_C2H_INT_EN | B_AX_WDT_TIMEOUT_INT_EN; 3145 3142 rtwpci->intrs[0] = B_AX_TXDMA_STUCK_INT_EN | 3146 3143 B_AX_RXDMA_INT_EN | 3147 3144 B_AX_RXP1DMA_INT_EN | ··· 3158 3155 3159 3156 rtwpci->ind_intrs = B_AX_HS1ISR_IND_INT_EN | 3160 3157 B_AX_HS0ISR_IND_INT_EN; 3161 - rtwpci->halt_c2h_intrs = B_AX_HALT_C2H_INT_EN; 3158 + rtwpci->halt_c2h_intrs = B_AX_HALT_C2H_INT_EN | B_AX_WDT_TIMEOUT_INT_EN; 3162 3159 rtwpci->intrs[0] = 0; 3163 3160 rtwpci->intrs[1] = B_AX_GPIO18_INT_EN; 3164 3161 }
+1
drivers/net/wireless/realtek/rtw89/pci.h
··· 94 94 95 95 /* Interrupts */ 96 96 #define R_AX_HIMR0 0x01A0 97 + #define B_AX_WDT_TIMEOUT_INT_EN BIT(22) 97 98 #define B_AX_HALT_C2H_INT_EN BIT(21) 98 99 #define R_AX_HISR0 0x01A4 99 100
+21 -3
drivers/net/wireless/realtek/rtw89/phy.c
··· 2151 2151 cfo->cfo_trig_by_timer_en = false; 2152 2152 cfo->phy_cfo_trk_cnt = 0; 2153 2153 cfo->phy_cfo_status = RTW89_PHY_DCFO_STATE_NORMAL; 2154 + cfo->cfo_ul_ofdma_acc_mode = RTW89_CFO_UL_OFDMA_ACC_ENABLE; 2154 2155 } 2155 2156 2156 2157 static void rtw89_phy_cfo_crystal_cap_adjust(struct rtw89_dev *rtwdev, ··· 2420 2419 { 2421 2420 struct rtw89_cfo_tracking_info *cfo = &rtwdev->cfo_tracking; 2422 2421 struct rtw89_traffic_stats *stats = &rtwdev->stats; 2422 + bool is_ul_ofdma = false, ofdma_acc_en = false; 2423 + 2424 + if (stats->rx_tf_periodic > CFO_TF_CNT_TH) 2425 + is_ul_ofdma = true; 2426 + if (cfo->cfo_ul_ofdma_acc_mode == RTW89_CFO_UL_OFDMA_ACC_ENABLE && 2427 + is_ul_ofdma) 2428 + ofdma_acc_en = true; 2423 2429 2424 2430 switch (cfo->phy_cfo_status) { 2425 2431 case RTW89_PHY_DCFO_STATE_NORMAL: ··· 2438 2430 } 2439 2431 break; 2440 2432 case RTW89_PHY_DCFO_STATE_ENHANCE: 2441 - if (cfo->phy_cfo_trk_cnt >= CFO_PERIOD_CNT) { 2433 + if (stats->tx_throughput <= CFO_TP_LOWER) 2434 + cfo->phy_cfo_status = RTW89_PHY_DCFO_STATE_NORMAL; 2435 + else if (ofdma_acc_en && 2436 + cfo->phy_cfo_trk_cnt >= CFO_PERIOD_CNT) 2437 + cfo->phy_cfo_status = RTW89_PHY_DCFO_STATE_HOLD; 2438 + else 2439 + cfo->phy_cfo_trk_cnt++; 2440 + 2441 + if (cfo->phy_cfo_status == RTW89_PHY_DCFO_STATE_NORMAL) { 2442 2442 cfo->phy_cfo_trk_cnt = 0; 2443 2443 cfo->cfo_trig_by_timer_en = false; 2444 2444 } 2445 - if (cfo->cfo_trig_by_timer_en == 1) 2446 - cfo->phy_cfo_trk_cnt++; 2445 + break; 2446 + case RTW89_PHY_DCFO_STATE_HOLD: 2447 2447 if (stats->tx_throughput <= CFO_TP_LOWER) { 2448 2448 cfo->phy_cfo_status = RTW89_PHY_DCFO_STATE_NORMAL; 2449 2449 cfo->phy_cfo_trk_cnt = 0; 2450 2450 cfo->cfo_trig_by_timer_en = false; 2451 + } else { 2452 + cfo->phy_cfo_trk_cnt++; 2451 2453 } 2452 2454 break; 2453 2455 default:
+1
drivers/net/wireless/realtek/rtw89/phy.h
··· 62 62 #define CFO_COMP_PERIOD 250 63 63 #define CFO_COMP_WEIGHT 8 64 64 #define MAX_CFO_TOLERANCE 30 65 + #define CFO_TF_CNT_TH 300 65 66 66 67 #define CCX_MAX_PERIOD 2097 67 68 #define CCX_MAX_PERIOD_UNIT 32
+1
drivers/net/wireless/realtek/rtw89/rtw8852c.c
··· 1861 1861 { 1862 1862 rtw8852c_dpk_track(rtwdev); 1863 1863 rtw8852c_lck_track(rtwdev); 1864 + rtw8852c_rx_dck_track(rtwdev); 1864 1865 } 1865 1866 1866 1867 static u32 rtw8852c_bb_cal_txpwr_ref(struct rtw89_dev *rtwdev,
+27
drivers/net/wireless/realtek/rtw89/rtw8852c_rfk.c
··· 3864 3864 3865 3865 void rtw8852c_rx_dck(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, bool is_afe) 3866 3866 { 3867 + struct rtw89_rx_dck_info *rx_dck = &rtwdev->rx_dck; 3867 3868 u8 path, kpath; 3868 3869 u32 rf_reg5; 3869 3870 ··· 3884 3883 rtw89_write_rf(rtwdev, path, RR_RSV1, RR_RSV1_RST, 0x0); 3885 3884 rtw89_write_rf(rtwdev, path, RR_MOD, RR_MOD_MASK, RR_MOD_V_RX); 3886 3885 _set_rx_dck(rtwdev, phy, path, is_afe); 3886 + rx_dck->thermal[path] = ewma_thermal_read(&rtwdev->phystat.avg_thermal[path]); 3887 3887 rtw89_write_rf(rtwdev, path, RR_RSV1, RFREG_MASK, rf_reg5); 3888 3888 3889 3889 if (rtwdev->is_tssi_mode[path]) 3890 3890 rtw89_phy_write32_mask(rtwdev, R_P0_TSSI_TRK + (path << 13), 3891 3891 B_P0_TSSI_TRK_EN, 0x0); 3892 + } 3893 + } 3894 + 3895 + #define RTW8852C_RX_DCK_TH 8 3896 + 3897 + void rtw8852c_rx_dck_track(struct rtw89_dev *rtwdev) 3898 + { 3899 + struct rtw89_rx_dck_info *rx_dck = &rtwdev->rx_dck; 3900 + u8 cur_thermal; 3901 + int delta; 3902 + int path; 3903 + 3904 + for (path = 0; path < RF_PATH_NUM_8852C; path++) { 3905 + cur_thermal = 3906 + ewma_thermal_read(&rtwdev->phystat.avg_thermal[path]); 3907 + delta = abs((int)cur_thermal - rx_dck->thermal[path]); 3908 + 3909 + rtw89_debug(rtwdev, RTW89_DBG_RFK_TRACK, 3910 + "[RX_DCK] path=%d current thermal=0x%x delta=0x%x\n", 3911 + path, cur_thermal, delta); 3912 + 3913 + if (delta >= RTW8852C_RX_DCK_TH) { 3914 + rtw8852c_rx_dck(rtwdev, RTW89_PHY_0, false); 3915 + return; 3916 + } 3892 3917 } 3893 3918 } 3894 3919
+1
drivers/net/wireless/realtek/rtw89/rtw8852c_rfk.h
··· 12 12 void rtw8852c_dack(struct rtw89_dev *rtwdev); 13 13 void rtw8852c_iqk(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx); 14 14 void rtw8852c_rx_dck(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx, bool is_afe); 15 + void rtw8852c_rx_dck_track(struct rtw89_dev *rtwdev); 15 16 void rtw8852c_dpk(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy); 16 17 void rtw8852c_dpk_track(struct rtw89_dev *rtwdev); 17 18 void rtw8852c_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy);
+122 -18
drivers/net/wireless/realtek/rtw89/sar.c
··· 5 5 #include "debug.h" 6 6 #include "sar.h" 7 7 8 + static enum rtw89_sar_subband rtw89_sar_get_subband(struct rtw89_dev *rtwdev, 9 + u32 center_freq) 10 + { 11 + switch (center_freq) { 12 + default: 13 + rtw89_debug(rtwdev, RTW89_DBG_SAR, 14 + "center freq: %u to SAR subband is unhandled\n", 15 + center_freq); 16 + fallthrough; 17 + case 2412 ... 2484: 18 + return RTW89_SAR_2GHZ_SUBBAND; 19 + case 5180 ... 5320: 20 + return RTW89_SAR_5GHZ_SUBBAND_1_2; 21 + case 5500 ... 5720: 22 + return RTW89_SAR_5GHZ_SUBBAND_2_E; 23 + case 5745 ... 5825: 24 + return RTW89_SAR_5GHZ_SUBBAND_3; 25 + case 5955 ... 6155: 26 + return RTW89_SAR_6GHZ_SUBBAND_5_L; 27 + case 6175 ... 6415: 28 + return RTW89_SAR_6GHZ_SUBBAND_5_H; 29 + case 6435 ... 6515: 30 + return RTW89_SAR_6GHZ_SUBBAND_6; 31 + case 6535 ... 6695: 32 + return RTW89_SAR_6GHZ_SUBBAND_7_L; 33 + case 6715 ... 6855: 34 + return RTW89_SAR_6GHZ_SUBBAND_7_H; 35 + 36 + /* freq 6875 (ch 185, 20MHz) spans RTW89_SAR_6GHZ_SUBBAND_7_H 37 + * and RTW89_SAR_6GHZ_SUBBAND_8, so directly describe it with 38 + * struct rtw89_sar_span in the following. 39 + */ 40 + 41 + case 6895 ... 7115: 42 + return RTW89_SAR_6GHZ_SUBBAND_8; 43 + } 44 + } 45 + 46 + struct rtw89_sar_span { 47 + enum rtw89_sar_subband subband_low; 48 + enum rtw89_sar_subband subband_high; 49 + }; 50 + 51 + #define RTW89_SAR_SPAN_VALID(span) ((span)->subband_high) 52 + 53 + #define RTW89_SAR_6GHZ_SPAN_HEAD 6145 54 + #define RTW89_SAR_6GHZ_SPAN_IDX(center_freq) \ 55 + ((((int)(center_freq) - RTW89_SAR_6GHZ_SPAN_HEAD) / 5) / 2) 56 + 57 + #define RTW89_DECL_SAR_6GHZ_SPAN(center_freq, subband_l, subband_h) \ 58 + [RTW89_SAR_6GHZ_SPAN_IDX(center_freq)] = { \ 59 + .subband_low = RTW89_SAR_6GHZ_ ## subband_l, \ 60 + .subband_high = RTW89_SAR_6GHZ_ ## subband_h, \ 61 + } 62 + 63 + /* Since 6GHz SAR subbands are not edge aligned, some cases span two SAR 64 + * subbands. In the following, we describe each of them with rtw89_sar_span. 65 + */ 66 + static const struct rtw89_sar_span rtw89_sar_overlapping_6ghz[] = { 67 + RTW89_DECL_SAR_6GHZ_SPAN(6145, SUBBAND_5_L, SUBBAND_5_H), 68 + RTW89_DECL_SAR_6GHZ_SPAN(6165, SUBBAND_5_L, SUBBAND_5_H), 69 + RTW89_DECL_SAR_6GHZ_SPAN(6185, SUBBAND_5_L, SUBBAND_5_H), 70 + RTW89_DECL_SAR_6GHZ_SPAN(6505, SUBBAND_6, SUBBAND_7_L), 71 + RTW89_DECL_SAR_6GHZ_SPAN(6525, SUBBAND_6, SUBBAND_7_L), 72 + RTW89_DECL_SAR_6GHZ_SPAN(6545, SUBBAND_6, SUBBAND_7_L), 73 + RTW89_DECL_SAR_6GHZ_SPAN(6665, SUBBAND_7_L, SUBBAND_7_H), 74 + RTW89_DECL_SAR_6GHZ_SPAN(6705, SUBBAND_7_L, SUBBAND_7_H), 75 + RTW89_DECL_SAR_6GHZ_SPAN(6825, SUBBAND_7_H, SUBBAND_8), 76 + RTW89_DECL_SAR_6GHZ_SPAN(6865, SUBBAND_7_H, SUBBAND_8), 77 + RTW89_DECL_SAR_6GHZ_SPAN(6875, SUBBAND_7_H, SUBBAND_8), 78 + RTW89_DECL_SAR_6GHZ_SPAN(6885, SUBBAND_7_H, SUBBAND_8), 79 + }; 80 + 8 81 static int rtw89_query_sar_config_common(struct rtw89_dev *rtwdev, s32 *cfg) 9 82 { 10 83 struct rtw89_sar_cfg_common *rtwsar = &rtwdev->sar.cfg_common; 11 - enum rtw89_subband subband = rtwdev->hal.current_subband; 84 + struct rtw89_hal *hal = &rtwdev->hal; 85 + enum rtw89_band band = hal->current_band_type; 86 + u32 center_freq = hal->current_freq; 87 + const struct rtw89_sar_span *span = NULL; 88 + enum rtw89_sar_subband subband_l, subband_h; 89 + int idx; 12 90 13 - if (!rtwsar->set[subband]) 91 + if (band == RTW89_BAND_6G) { 92 + idx = RTW89_SAR_6GHZ_SPAN_IDX(center_freq); 93 + /* To decrease size of rtw89_sar_overlapping_6ghz[], 94 + * RTW89_SAR_6GHZ_SPAN_IDX() truncates the leading NULLs 95 + * to make first span as index 0 of the table. So, if center 96 + * frequency is less than the first one, it will get netative. 97 + */ 98 + if (idx >= 0 && idx < ARRAY_SIZE(rtw89_sar_overlapping_6ghz)) 99 + span = &rtw89_sar_overlapping_6ghz[idx]; 100 + } 101 + 102 + if (span && RTW89_SAR_SPAN_VALID(span)) { 103 + subband_l = span->subband_low; 104 + subband_h = span->subband_high; 105 + } else { 106 + subband_l = rtw89_sar_get_subband(rtwdev, center_freq); 107 + subband_h = subband_l; 108 + } 109 + 110 + rtw89_debug(rtwdev, RTW89_DBG_SAR, 111 + "for {band %u, center_freq %u}, SAR subband: {%u, %u}\n", 112 + band, center_freq, subband_l, subband_h); 113 + 114 + if (!rtwsar->set[subband_l] && !rtwsar->set[subband_h]) 14 115 return -ENODATA; 15 116 16 - *cfg = rtwsar->cfg[subband]; 117 + if (!rtwsar->set[subband_l]) 118 + *cfg = rtwsar->cfg[subband_h]; 119 + else if (!rtwsar->set[subband_h]) 120 + *cfg = rtwsar->cfg[subband_l]; 121 + else 122 + *cfg = min(rtwsar->cfg[subband_l], rtwsar->cfg[subband_h]); 123 + 17 124 return 0; 18 125 } 19 126 ··· 235 128 return ret; 236 129 } 237 130 238 - static const u8 rtw89_common_sar_subband_map[] = { 239 - RTW89_CH_2G, 240 - RTW89_CH_5G_BAND_1, 241 - RTW89_CH_5G_BAND_3, 242 - RTW89_CH_5G_BAND_4, 243 - }; 244 - 245 131 static const struct cfg80211_sar_freq_ranges rtw89_common_sar_freq_ranges[] = { 246 132 { .start_freq = 2412, .end_freq = 2484, }, 247 133 { .start_freq = 5180, .end_freq = 5320, }, 248 134 { .start_freq = 5500, .end_freq = 5720, }, 249 135 { .start_freq = 5745, .end_freq = 5825, }, 136 + { .start_freq = 5955, .end_freq = 6155, }, 137 + { .start_freq = 6175, .end_freq = 6415, }, 138 + { .start_freq = 6435, .end_freq = 6515, }, 139 + { .start_freq = 6535, .end_freq = 6695, }, 140 + { .start_freq = 6715, .end_freq = 6875, }, 141 + { .start_freq = 6875, .end_freq = 7115, }, 250 142 }; 251 143 252 - static_assert(ARRAY_SIZE(rtw89_common_sar_subband_map) == 144 + static_assert(RTW89_SAR_SUBBAND_NR == 253 145 ARRAY_SIZE(rtw89_common_sar_freq_ranges)); 254 146 255 147 const struct cfg80211_sar_capa rtw89_sar_capa = { ··· 265 159 u8 fct; 266 160 u32 freq_start; 267 161 u32 freq_end; 268 - u32 band; 269 162 s32 power; 270 163 u32 i, idx; 271 164 ··· 280 175 281 176 freq_start = rtw89_common_sar_freq_ranges[idx].start_freq; 282 177 freq_end = rtw89_common_sar_freq_ranges[idx].end_freq; 283 - band = rtw89_common_sar_subband_map[idx]; 284 178 power = sar->sub_specs[i].power; 285 179 286 - rtw89_info(rtwdev, "On freq %u to %u, ", freq_start, freq_end); 287 - rtw89_info(rtwdev, "set SAR power limit %d (unit: 1/%lu dBm)\n", 288 - power, BIT(fct)); 180 + rtw89_debug(rtwdev, RTW89_DBG_SAR, 181 + "On freq %u to %u, set SAR limit %d (unit: 1/%lu dBm)\n", 182 + freq_start, freq_end, power, BIT(fct)); 289 183 290 - sar_common.set[band] = true; 291 - sar_common.cfg[band] = power; 184 + sar_common.set[idx] = true; 185 + sar_common.cfg[idx] = power; 292 186 } 293 187 294 188 return rtw89_apply_sar_common(rtwdev, &sar_common);
+1 -2
drivers/net/wireless/silabs/wfx/fwio.c
··· 286 286 287 287 error: 288 288 kfree(buf); 289 - if (fw) 290 - release_firmware(fw); 289 + release_firmware(fw); 291 290 if (ret) 292 291 print_boot_status(wdev); 293 292 return ret;
+2 -8
drivers/net/wireless/st/cw1200/bh.c
··· 327 327 if (WARN_ON(wsm_handle_rx(priv, wsm_id, wsm, &skb_rx))) 328 328 goto err; 329 329 330 - if (skb_rx) { 331 - dev_kfree_skb(skb_rx); 332 - skb_rx = NULL; 333 - } 330 + dev_kfree_skb(skb_rx); 334 331 335 332 return 0; 336 333 337 334 err: 338 - if (skb_rx) { 339 - dev_kfree_skb(skb_rx); 340 - skb_rx = NULL; 341 - } 335 + dev_kfree_skb(skb_rx); 342 336 return -1; 343 337 } 344 338
+1 -1
drivers/net/wireless/virt_wifi.c
··· 654 654 { 655 655 int err; 656 656 657 - /* Guaranteed to be locallly-administered and not multicast. */ 657 + /* Guaranteed to be locally-administered and not multicast. */ 658 658 eth_random_addr(fake_router_bssid); 659 659 660 660 err = register_netdevice_notifier(&virt_wifi_notifier);
+31
include/linux/ieee80211.h
··· 76 76 #define IEEE80211_STYPE_ACTION 0x00D0 77 77 78 78 /* control */ 79 + #define IEEE80211_STYPE_TRIGGER 0x0020 79 80 #define IEEE80211_STYPE_CTL_EXT 0x0060 80 81 #define IEEE80211_STYPE_BACK_REQ 0x0080 81 82 #define IEEE80211_STYPE_BACK 0x0090 ··· 296 295 297 296 #define IEEE80211_HT_CTL_LEN 4 298 297 298 + /* trigger type within common_info of trigger frame */ 299 + #define IEEE80211_TRIGGER_TYPE_MASK 0xf 300 + #define IEEE80211_TRIGGER_TYPE_BASIC 0x0 301 + #define IEEE80211_TRIGGER_TYPE_BFRP 0x1 302 + #define IEEE80211_TRIGGER_TYPE_MU_BAR 0x2 303 + #define IEEE80211_TRIGGER_TYPE_MU_RTS 0x3 304 + #define IEEE80211_TRIGGER_TYPE_BSRP 0x4 305 + #define IEEE80211_TRIGGER_TYPE_GCR_MU_BAR 0x5 306 + #define IEEE80211_TRIGGER_TYPE_BQRP 0x6 307 + #define IEEE80211_TRIGGER_TYPE_NFRP 0x7 308 + 299 309 struct ieee80211_hdr { 300 310 __le16 frame_control; 301 311 __le16 duration_id; ··· 334 322 u8 addr3[ETH_ALEN]; 335 323 __le16 seq_ctrl; 336 324 __le16 qos_ctrl; 325 + } __packed __aligned(2); 326 + 327 + struct ieee80211_trigger { 328 + __le16 frame_control; 329 + __le16 duration; 330 + u8 ra[ETH_ALEN]; 331 + u8 ta[ETH_ALEN]; 332 + __le64 common_info; 333 + u8 variable[]; 337 334 } __packed __aligned(2); 338 335 339 336 /** ··· 748 727 { 749 728 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 750 729 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC); 730 + } 731 + 732 + /** 733 + * ieee80211_is_trigger - check if frame is trigger frame 734 + * @fc: frame control field in little-endian byteorder 735 + */ 736 + static inline bool ieee80211_is_trigger(__le16 fc) 737 + { 738 + return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == 739 + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_TRIGGER); 751 740 } 752 741 753 742 /**
-35
include/net/mac80211.h
··· 1959 1959 }; 1960 1960 1961 1961 /** 1962 - * struct ieee80211_cipher_scheme - cipher scheme 1963 - * 1964 - * This structure contains a cipher scheme information defining 1965 - * the secure packet crypto handling. 1966 - * 1967 - * @cipher: a cipher suite selector 1968 - * @iftype: a cipher iftype bit mask indicating an allowed cipher usage 1969 - * @hdr_len: a length of a security header used the cipher 1970 - * @pn_len: a length of a packet number in the security header 1971 - * @pn_off: an offset of pn from the beginning of the security header 1972 - * @key_idx_off: an offset of key index byte in the security header 1973 - * @key_idx_mask: a bit mask of key_idx bits 1974 - * @key_idx_shift: a bit shift needed to get key_idx 1975 - * key_idx value calculation: 1976 - * (sec_header_base[key_idx_off] & key_idx_mask) >> key_idx_shift 1977 - * @mic_len: a mic length in bytes 1978 - */ 1979 - struct ieee80211_cipher_scheme { 1980 - u32 cipher; 1981 - u16 iftype; 1982 - u8 hdr_len; 1983 - u8 pn_len; 1984 - u8 pn_off; 1985 - u8 key_idx_off; 1986 - u8 key_idx_mask; 1987 - u8 key_idx_shift; 1988 - u8 mic_len; 1989 - }; 1990 - 1991 - /** 1992 1962 * enum set_key_cmd - key command 1993 1963 * 1994 1964 * Used with the set_key() callback in &struct ieee80211_ops, this ··· 2634 2664 * deliver to a WMM STA during any Service Period triggered by the WMM STA. 2635 2665 * Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct values. 2636 2666 * 2637 - * @n_cipher_schemes: a size of an array of cipher schemes definitions. 2638 - * @cipher_schemes: a pointer to an array of cipher scheme definitions 2639 - * supported by HW. 2640 2667 * @max_nan_de_entries: maximum number of NAN DE functions supported by the 2641 2668 * device. 2642 2669 * ··· 2683 2716 netdev_features_t netdev_features; 2684 2717 u8 uapsd_queues; 2685 2718 u8 uapsd_max_sp_len; 2686 - u8 n_cipher_schemes; 2687 - const struct ieee80211_cipher_scheme *cipher_schemes; 2688 2719 u8 max_nan_de_entries; 2689 2720 u8 tx_sk_pacing_shift; 2690 2721 u8 weight_multiplier;
+1 -1
include/uapi/linux/nl80211.h
··· 5874 5874 * @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up 5875 5875 * the connected inactive stations in AP mode. 5876 5876 * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested 5877 - * to work properly to suppport receiving regulatory hints from 5877 + * to work properly to support receiving regulatory hints from 5878 5878 * cellular base stations. 5879 5879 * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only 5880 5880 * here to reserve the value for API/ABI compatibility)
+41 -57
net/mac80211/cfg.c
··· 5 5 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> 6 6 * Copyright 2013-2015 Intel Mobile Communications GmbH 7 7 * Copyright (C) 2015-2017 Intel Deutschland GmbH 8 - * Copyright (C) 2018-2021 Intel Corporation 8 + * Copyright (C) 2018-2022 Intel Corporation 9 9 */ 10 10 11 11 #include <linux/ieee80211.h> ··· 438 438 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 439 439 struct ieee80211_local *local = sdata->local; 440 440 struct sta_info *sta = NULL; 441 - const struct ieee80211_cipher_scheme *cs = NULL; 442 441 struct ieee80211_key *key; 443 442 int err; 444 443 ··· 455 456 if (WARN_ON_ONCE(fips_enabled)) 456 457 return -EINVAL; 457 458 break; 458 - case WLAN_CIPHER_SUITE_CCMP: 459 - case WLAN_CIPHER_SUITE_CCMP_256: 460 - case WLAN_CIPHER_SUITE_AES_CMAC: 461 - case WLAN_CIPHER_SUITE_BIP_CMAC_256: 462 - case WLAN_CIPHER_SUITE_BIP_GMAC_128: 463 - case WLAN_CIPHER_SUITE_BIP_GMAC_256: 464 - case WLAN_CIPHER_SUITE_GCMP: 465 - case WLAN_CIPHER_SUITE_GCMP_256: 466 - break; 467 459 default: 468 - cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type); 469 460 break; 470 461 } 471 462 472 463 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, 473 - params->key, params->seq_len, params->seq, 474 - cs); 464 + params->key, params->seq_len, params->seq); 475 465 if (IS_ERR(key)) 476 466 return PTR_ERR(key); 477 467 ··· 525 537 break; 526 538 } 527 539 528 - if (sta) 529 - sta->cipher_scheme = cs; 530 - 531 540 err = ieee80211_key_link(key, sdata, sta); 532 541 533 542 out_unlock: ··· 533 548 return err; 534 549 } 535 550 551 + static struct ieee80211_key * 552 + ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, 553 + u8 key_idx, bool pairwise, const u8 *mac_addr) 554 + { 555 + struct ieee80211_local *local = sdata->local; 556 + struct sta_info *sta; 557 + 558 + if (mac_addr) { 559 + sta = sta_info_get_bss(sdata, mac_addr); 560 + if (!sta) 561 + return NULL; 562 + 563 + if (pairwise && key_idx < NUM_DEFAULT_KEYS) 564 + return rcu_dereference_check_key_mtx(local, 565 + sta->ptk[key_idx]); 566 + 567 + if (!pairwise && 568 + key_idx < NUM_DEFAULT_KEYS + 569 + NUM_DEFAULT_MGMT_KEYS + 570 + NUM_DEFAULT_BEACON_KEYS) 571 + return rcu_dereference_check_key_mtx(local, 572 + sta->deflink.gtk[key_idx]); 573 + 574 + return NULL; 575 + } 576 + 577 + if (key_idx < NUM_DEFAULT_KEYS + 578 + NUM_DEFAULT_MGMT_KEYS + 579 + NUM_DEFAULT_BEACON_KEYS) 580 + return rcu_dereference_check_key_mtx(local, 581 + sdata->keys[key_idx]); 582 + 583 + return NULL; 584 + } 585 + 536 586 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, 537 587 u8 key_idx, bool pairwise, const u8 *mac_addr) 538 588 { 539 589 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 540 590 struct ieee80211_local *local = sdata->local; 541 - struct sta_info *sta; 542 - struct ieee80211_key *key = NULL; 591 + struct ieee80211_key *key; 543 592 int ret; 544 593 545 594 mutex_lock(&local->sta_mtx); 546 595 mutex_lock(&local->key_mtx); 547 596 548 - if (mac_addr) { 549 - ret = -ENOENT; 550 - 551 - sta = sta_info_get_bss(sdata, mac_addr); 552 - if (!sta) 553 - goto out_unlock; 554 - 555 - if (pairwise) 556 - key = key_mtx_dereference(local, sta->ptk[key_idx]); 557 - else 558 - key = key_mtx_dereference(local, 559 - sta->deflink.gtk[key_idx]); 560 - } else 561 - key = key_mtx_dereference(local, sdata->keys[key_idx]); 562 - 597 + key = ieee80211_lookup_key(sdata, key_idx, pairwise, mac_addr); 563 598 if (!key) { 564 599 ret = -ENOENT; 565 600 goto out_unlock; ··· 602 597 struct key_params *params)) 603 598 { 604 599 struct ieee80211_sub_if_data *sdata; 605 - struct sta_info *sta = NULL; 606 600 u8 seq[6] = {0}; 607 601 struct key_params params; 608 - struct ieee80211_key *key = NULL; 602 + struct ieee80211_key *key; 609 603 u64 pn64; 610 604 u32 iv32; 611 605 u16 iv16; ··· 615 611 616 612 rcu_read_lock(); 617 613 618 - if (mac_addr) { 619 - sta = sta_info_get_bss(sdata, mac_addr); 620 - if (!sta) 621 - goto out; 622 - 623 - if (pairwise && key_idx < NUM_DEFAULT_KEYS) 624 - key = rcu_dereference(sta->ptk[key_idx]); 625 - else if (!pairwise && 626 - key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS + 627 - NUM_DEFAULT_BEACON_KEYS) 628 - key = rcu_dereference(sta->deflink.gtk[key_idx]); 629 - } else 630 - key = rcu_dereference(sdata->keys[key_idx]); 631 - 614 + key = ieee80211_lookup_key(sdata, key_idx, pairwise, mac_addr); 632 615 if (!key) 633 616 goto out; 634 617 ··· 1198 1207 params->crypto.control_port_over_nl80211; 1199 1208 sdata->control_port_no_preauth = 1200 1209 params->crypto.control_port_no_preauth; 1201 - sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local, 1202 - &params->crypto, 1203 - sdata->vif.type); 1204 1210 1205 1211 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { 1206 1212 vlan->control_port_protocol = ··· 1208 1220 params->crypto.control_port_over_nl80211; 1209 1221 vlan->control_port_no_preauth = 1210 1222 params->crypto.control_port_no_preauth; 1211 - vlan->encrypt_headroom = 1212 - ieee80211_cs_headroom(sdata->local, 1213 - &params->crypto, 1214 - vlan->vif.type); 1215 1223 } 1216 1224 1217 1225 sdata->vif.bss_conf.dtim_period = params->dtim_period;
+1 -10
net/mac80211/ieee80211_i.h
··· 5 5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 6 6 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net> 7 7 * Copyright 2013-2015 Intel Mobile Communications GmbH 8 - * Copyright (C) 2018-2021 Intel Corporation 8 + * Copyright (C) 2018-2022 Intel Corporation 9 9 */ 10 10 11 11 #ifndef IEEE80211_I_H ··· 944 944 bool control_port_no_encrypt; 945 945 bool control_port_no_preauth; 946 946 bool control_port_over_nl80211; 947 - int encrypt_headroom; 948 947 949 948 atomic_t num_tx_queued; 950 949 struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS]; ··· 2482 2483 int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata, 2483 2484 struct cfg80211_csa_settings *csa_settings); 2484 2485 2485 - bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs); 2486 - bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n); 2487 - const struct ieee80211_cipher_scheme * 2488 - ieee80211_cs_get(struct ieee80211_local *local, u32 cipher, 2489 - enum nl80211_iftype iftype); 2490 - int ieee80211_cs_headroom(struct ieee80211_local *local, 2491 - struct cfg80211_crypto_settings *crypto, 2492 - enum nl80211_iftype iftype); 2493 2486 void ieee80211_recalc_dtim(struct ieee80211_local *local, 2494 2487 struct ieee80211_sub_if_data *sdata); 2495 2488 int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
+1 -6
net/mac80211/iface.c
··· 8 8 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> 9 9 * Copyright 2013-2014 Intel Mobile Communications GmbH 10 10 * Copyright (c) 2016 Intel Deutschland GmbH 11 - * Copyright (C) 2018-2021 Intel Corporation 11 + * Copyright (C) 2018-2022 Intel Corporation 12 12 */ 13 13 #include <linux/slab.h> 14 14 #include <linux/kernel.h> ··· 1036 1036 wiphy_name(local->hw.wiphy)); 1037 1037 sdata->wdev.iftype = NL80211_IFTYPE_MONITOR; 1038 1038 1039 - sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; 1040 - 1041 1039 ieee80211_set_default_queues(sdata); 1042 1040 1043 1041 ret = drv_add_interface(local, sdata); ··· 1642 1644 sdata->control_port_no_encrypt = false; 1643 1645 sdata->control_port_over_nl80211 = false; 1644 1646 sdata->control_port_no_preauth = false; 1645 - sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; 1646 1647 sdata->vif.bss_conf.idle = true; 1647 1648 sdata->vif.bss_conf.txpower = INT_MIN; /* unset */ 1648 1649 ··· 2112 2115 2113 2116 sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL; 2114 2117 sdata->user_power_level = local->user_power_level; 2115 - 2116 - sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; 2117 2118 2118 2119 /* setup type-dependent data */ 2119 2120 ieee80211_setup_sdata(sdata, type);
+3 -19
net/mac80211/key.c
··· 6 6 * Copyright 2007-2008 Johannes Berg <johannes@sipsolutions.net> 7 7 * Copyright 2013-2014 Intel Mobile Communications GmbH 8 8 * Copyright 2015-2017 Intel Deutschland GmbH 9 - * Copyright 2018-2020 Intel Corporation 9 + * Copyright 2018-2020, 2022 Intel Corporation 10 10 */ 11 11 12 12 #include <linux/if_ether.h> ··· 531 531 struct ieee80211_key * 532 532 ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, 533 533 const u8 *key_data, 534 - size_t seq_len, const u8 *seq, 535 - const struct ieee80211_cipher_scheme *cs) 534 + size_t seq_len, const u8 *seq) 536 535 { 537 536 struct ieee80211_key *key; 538 537 int i, j, err; ··· 674 675 return ERR_PTR(err); 675 676 } 676 677 break; 677 - default: 678 - if (cs) { 679 - if (seq_len && seq_len != cs->pn_len) { 680 - kfree(key); 681 - return ERR_PTR(-EINVAL); 682 - } 683 - 684 - key->conf.iv_len = cs->hdr_len; 685 - key->conf.icv_len = cs->mic_len; 686 - for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) 687 - for (j = 0; j < seq_len; j++) 688 - key->u.gen.rx_pn[i][j] = 689 - seq[seq_len - j - 1]; 690 - key->flags |= KEY_FLAG_CIPHER_SCHEME; 691 - } 692 678 } 693 679 memcpy(key->conf.key, key_data, key_len); 694 680 INIT_LIST_HEAD(&key->list); ··· 1278 1294 1279 1295 key = ieee80211_key_alloc(keyconf->cipher, keyconf->keyidx, 1280 1296 keyconf->keylen, keyconf->key, 1281 - 0, NULL, NULL); 1297 + 0, NULL); 1282 1298 if (IS_ERR(key)) 1283 1299 return ERR_CAST(key); 1284 1300
+4 -5
net/mac80211/key.h
··· 2 2 /* 3 3 * Copyright 2002-2004, Instant802 Networks, Inc. 4 4 * Copyright 2005, Devicescape Software, Inc. 5 - * Copyright (C) 2019 Intel Corporation 5 + * Copyright (C) 2019, 2022 Intel Corporation 6 6 */ 7 7 8 8 #ifndef IEEE80211_KEY_H ··· 30 30 * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present 31 31 * in the hardware for TX crypto hardware acceleration. 32 32 * @KEY_FLAG_TAINTED: Key is tainted and packets should be dropped. 33 - * @KEY_FLAG_CIPHER_SCHEME: This key is for a hardware cipher scheme 34 33 */ 35 34 enum ieee80211_internal_key_flags { 36 35 KEY_FLAG_UPLOADED_TO_HARDWARE = BIT(0), 37 36 KEY_FLAG_TAINTED = BIT(1), 38 - KEY_FLAG_CIPHER_SCHEME = BIT(2), 39 37 }; 40 38 41 39 enum ieee80211_internal_tkip_state { ··· 138 140 struct ieee80211_key * 139 141 ieee80211_key_alloc(u32 cipher, int idx, size_t key_len, 140 142 const u8 *key_data, 141 - size_t seq_len, const u8 *seq, 142 - const struct ieee80211_cipher_scheme *cs); 143 + size_t seq_len, const u8 *seq); 143 144 /* 144 145 * Insert a key into data structures (sdata, sta if necessary) 145 146 * to make it used, free old key. On failure, also free the new key. ··· 163 166 164 167 #define key_mtx_dereference(local, ref) \ 165 168 rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx))) 169 + #define rcu_dereference_check_key_mtx(local, ref) \ 170 + rcu_dereference_check(ref, lockdep_is_held(&((local)->key_mtx))) 166 171 167 172 void ieee80211_delayed_tailroom_dec(struct work_struct *wk); 168 173
+5 -64
net/mac80211/main.c
··· 5 5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 6 6 * Copyright 2013-2014 Intel Mobile Communications GmbH 7 7 * Copyright (C) 2017 Intel Deutschland GmbH 8 - * Copyright (C) 2018-2021 Intel Corporation 8 + * Copyright (C) 2018-2022 Intel Corporation 9 9 */ 10 10 11 11 #include <net/mac80211.h> ··· 778 778 { 779 779 bool have_wep = !fips_enabled; /* FIPS does not permit the use of RC4 */ 780 780 bool have_mfp = ieee80211_hw_check(&local->hw, MFP_CAPABLE); 781 - int n_suites = 0, r = 0, w = 0; 781 + int r = 0, w = 0; 782 782 u32 *suites; 783 783 static const u32 cipher_suites[] = { 784 784 /* keep WEP first, it may be removed below */ ··· 824 824 continue; 825 825 suites[w++] = suite; 826 826 } 827 - } else if (!local->hw.cipher_schemes) { 828 - /* If the driver doesn't have cipher schemes, there's nothing 829 - * else to do other than assign the (software supported and 830 - * perhaps offloaded) cipher suites. 827 + } else { 828 + /* assign the (software supported and perhaps offloaded) 829 + * cipher suites 831 830 */ 832 831 local->hw.wiphy->cipher_suites = cipher_suites; 833 832 local->hw.wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); ··· 841 842 842 843 /* not dynamically allocated, so just return */ 843 844 return 0; 844 - } else { 845 - const struct ieee80211_cipher_scheme *cs; 846 - 847 - cs = local->hw.cipher_schemes; 848 - 849 - /* Driver specifies cipher schemes only (but not cipher suites 850 - * including the schemes) 851 - * 852 - * We start counting ciphers defined by schemes, TKIP, CCMP, 853 - * CCMP-256, GCMP, and GCMP-256 854 - */ 855 - n_suites = local->hw.n_cipher_schemes + 5; 856 - 857 - /* check if we have WEP40 and WEP104 */ 858 - if (have_wep) 859 - n_suites += 2; 860 - 861 - /* check if we have AES_CMAC, BIP-CMAC-256, BIP-GMAC-128, 862 - * BIP-GMAC-256 863 - */ 864 - if (have_mfp) 865 - n_suites += 4; 866 - 867 - suites = kmalloc_array(n_suites, sizeof(u32), GFP_KERNEL); 868 - if (!suites) 869 - return -ENOMEM; 870 - 871 - suites[w++] = WLAN_CIPHER_SUITE_CCMP; 872 - suites[w++] = WLAN_CIPHER_SUITE_CCMP_256; 873 - suites[w++] = WLAN_CIPHER_SUITE_TKIP; 874 - suites[w++] = WLAN_CIPHER_SUITE_GCMP; 875 - suites[w++] = WLAN_CIPHER_SUITE_GCMP_256; 876 - 877 - if (have_wep) { 878 - suites[w++] = WLAN_CIPHER_SUITE_WEP40; 879 - suites[w++] = WLAN_CIPHER_SUITE_WEP104; 880 - } 881 - 882 - if (have_mfp) { 883 - suites[w++] = WLAN_CIPHER_SUITE_AES_CMAC; 884 - suites[w++] = WLAN_CIPHER_SUITE_BIP_CMAC_256; 885 - suites[w++] = WLAN_CIPHER_SUITE_BIP_GMAC_128; 886 - suites[w++] = WLAN_CIPHER_SUITE_BIP_GMAC_256; 887 - } 888 - 889 - for (r = 0; r < local->hw.n_cipher_schemes; r++) { 890 - suites[w++] = cs[r].cipher; 891 - if (WARN_ON(cs[r].pn_len > IEEE80211_MAX_PN_LEN)) { 892 - kfree(suites); 893 - return -EINVAL; 894 - } 895 - } 896 845 } 897 846 898 847 local->hw.wiphy->cipher_suites = suites; ··· 1114 1167 */ 1115 1168 if (local->hw.wiphy->max_scan_ie_len) 1116 1169 local->hw.wiphy->max_scan_ie_len -= local->scan_ies_len; 1117 - 1118 - if (WARN_ON(!ieee80211_cs_list_valid(local->hw.cipher_schemes, 1119 - local->hw.n_cipher_schemes))) { 1120 - result = -EINVAL; 1121 - goto fail_workqueue; 1122 - } 1123 1170 1124 1171 result = ieee80211_init_cipher_suites(local); 1125 1172 if (result < 0)
+3 -3
net/mac80211/mesh_hwmp.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 3 * Copyright (c) 2008, 2009 open80211s Ltd. 4 - * Copyright (C) 2019, 2021 Intel Corporation 4 + * Copyright (C) 2019, 2021-2022 Intel Corporation 5 5 * Author: Luis Carlos Cobo <luisca@cozybit.com> 6 6 */ 7 7 ··· 247 247 return -EAGAIN; 248 248 249 249 skb = dev_alloc_skb(local->tx_headroom + 250 - sdata->encrypt_headroom + 250 + IEEE80211_ENCRYPT_HEADROOM + 251 251 IEEE80211_ENCRYPT_TAILROOM + 252 252 hdr_len + 253 253 2 + 15 /* PERR IE */); 254 254 if (!skb) 255 255 return -1; 256 - skb_reserve(skb, local->tx_headroom + sdata->encrypt_headroom); 256 + skb_reserve(skb, local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM); 257 257 mgmt = skb_put_zero(skb, hdr_len); 258 258 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 259 259 IEEE80211_STYPE_ACTION);
+1 -5
net/mac80211/mlme.c
··· 8 8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net> 9 9 * Copyright 2013-2014 Intel Mobile Communications GmbH 10 10 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH 11 - * Copyright (C) 2018 - 2021 Intel Corporation 11 + * Copyright (C) 2018 - 2022 Intel Corporation 12 12 */ 13 13 14 14 #include <linux/delay.h> ··· 2495 2495 /* existing TX TSPEC sessions no longer exist */ 2496 2496 memset(ifmgd->tx_tspec, 0, sizeof(ifmgd->tx_tspec)); 2497 2497 cancel_delayed_work_sync(&ifmgd->tx_tspec_wk); 2498 - 2499 - sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; 2500 2498 2501 2499 bss_conf->pwr_reduction = 0; 2502 2500 bss_conf->tx_pwr_env_num = 0; ··· 6069 6071 sdata->control_port_over_nl80211 = 6070 6072 req->crypto.control_port_over_nl80211; 6071 6073 sdata->control_port_no_preauth = req->crypto.control_port_no_preauth; 6072 - sdata->encrypt_headroom = ieee80211_cs_headroom(local, &req->crypto, 6073 - sdata->vif.type); 6074 6074 6075 6075 /* kick off associate process */ 6076 6076
+12 -37
net/mac80211/rx.c
··· 6 6 * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net> 7 7 * Copyright 2013-2014 Intel Mobile Communications GmbH 8 8 * Copyright(c) 2015 - 2017 Intel Deutschland GmbH 9 - * Copyright (C) 2018-2021 Intel Corporation 9 + * Copyright (C) 2018-2022 Intel Corporation 10 10 */ 11 11 12 12 #include <linux/jiffies.h> ··· 1009 1009 return -1; 1010 1010 } 1011 1011 1012 - static int ieee80211_get_keyid(struct sk_buff *skb, 1013 - const struct ieee80211_cipher_scheme *cs) 1012 + static int ieee80211_get_keyid(struct sk_buff *skb) 1014 1013 { 1015 1014 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1016 - __le16 fc; 1017 - int hdrlen; 1018 - int minlen; 1019 - u8 key_idx_off; 1020 - u8 key_idx_shift; 1015 + __le16 fc = hdr->frame_control; 1016 + int hdrlen = ieee80211_hdrlen(fc); 1021 1017 u8 keyid; 1022 1018 1023 - fc = hdr->frame_control; 1024 - hdrlen = ieee80211_hdrlen(fc); 1025 - 1026 - if (cs) { 1027 - minlen = hdrlen + cs->hdr_len; 1028 - key_idx_off = hdrlen + cs->key_idx_off; 1029 - key_idx_shift = cs->key_idx_shift; 1030 - } else { 1031 - /* WEP, TKIP, CCMP and GCMP */ 1032 - minlen = hdrlen + IEEE80211_WEP_IV_LEN; 1033 - key_idx_off = hdrlen + 3; 1034 - key_idx_shift = 6; 1035 - } 1036 - 1037 - if (unlikely(skb->len < minlen)) 1019 + /* WEP, TKIP, CCMP and GCMP */ 1020 + if (unlikely(skb->len < hdrlen + IEEE80211_WEP_IV_LEN)) 1038 1021 return -EINVAL; 1039 1022 1040 - skb_copy_bits(skb, key_idx_off, &keyid, 1); 1023 + skb_copy_bits(skb, hdrlen + 3, &keyid, 1); 1041 1024 1042 - if (cs) 1043 - keyid &= cs->key_idx_mask; 1044 - keyid >>= key_idx_shift; 1045 - 1046 - /* cs could use more than the usual two bits for the keyid */ 1047 - if (unlikely(keyid >= NUM_DEFAULT_KEYS)) 1048 - return -EINVAL; 1025 + keyid >>= 6; 1049 1026 1050 1027 return keyid; 1051 1028 } ··· 1893 1916 struct ieee80211_key *ptk_idx = NULL; 1894 1917 int mmie_keyidx = -1; 1895 1918 __le16 fc; 1896 - const struct ieee80211_cipher_scheme *cs = NULL; 1897 1919 1898 1920 if (ieee80211_is_ext(hdr->frame_control)) 1899 1921 return RX_CONTINUE; ··· 1935 1959 1936 1960 if (ieee80211_has_protected(fc) && 1937 1961 !(status->flag & RX_FLAG_IV_STRIPPED)) { 1938 - cs = rx->sta->cipher_scheme; 1939 - keyid = ieee80211_get_keyid(rx->skb, cs); 1962 + keyid = ieee80211_get_keyid(rx->skb); 1940 1963 1941 1964 if (unlikely(keyid < 0)) 1942 1965 return RX_DROP_UNUSABLE; ··· 2040 2065 (status->flag & RX_FLAG_IV_STRIPPED)) 2041 2066 return RX_CONTINUE; 2042 2067 2043 - keyidx = ieee80211_get_keyid(rx->skb, cs); 2068 + keyidx = ieee80211_get_keyid(rx->skb); 2044 2069 2045 2070 if (unlikely(keyidx < 0)) 2046 2071 return RX_DROP_UNUSABLE; ··· 2106 2131 result = ieee80211_crypto_gcmp_decrypt(rx); 2107 2132 break; 2108 2133 default: 2109 - result = ieee80211_crypto_hw_decrypt(rx); 2134 + result = RX_DROP_UNUSABLE; 2110 2135 } 2111 2136 2112 2137 /* the hdr variable is invalid after the decrypt handlers */ ··· 2920 2945 tailroom = IEEE80211_ENCRYPT_TAILROOM; 2921 2946 2922 2947 fwd_skb = skb_copy_expand(skb, local->tx_headroom + 2923 - sdata->encrypt_headroom, 2948 + IEEE80211_ENCRYPT_HEADROOM, 2924 2949 tailroom, GFP_ATOMIC); 2925 2950 if (!fwd_skb) 2926 2951 goto out;
+1 -3
net/mac80211/sta_info.h
··· 3 3 * Copyright 2002-2005, Devicescape Software, Inc. 4 4 * Copyright 2013-2014 Intel Mobile Communications GmbH 5 5 * Copyright(c) 2015-2017 Intel Deutschland GmbH 6 - * Copyright(c) 2020-2021 Intel Corporation 6 + * Copyright(c) 2020-2022 Intel Corporation 7 7 */ 8 8 9 9 #ifndef STA_INFO_H ··· 616 616 * taken from HT/VHT capabilities or VHT operating mode notification 617 617 * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for 618 618 * AP only. 619 - * @cipher_scheme: optional cipher scheme for this station 620 619 * @cparams: CoDel parameters for this station. 621 620 * @reserved_tid: reserved TID (if any, otherwise IEEE80211_TID_UNRESERVED) 622 621 * @fast_tx: TX fastpath information ··· 699 700 #endif 700 701 701 702 enum ieee80211_smps_mode known_smps_mode; 702 - const struct ieee80211_cipher_scheme *cipher_scheme; 703 703 704 704 struct codel_params cparams; 705 705
+5 -16
net/mac80211/tx.c
··· 5 5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 6 6 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 7 7 * Copyright 2013-2014 Intel Mobile Communications GmbH 8 - * Copyright (C) 2018-2021 Intel Corporation 8 + * Copyright (C) 2018-2022 Intel Corporation 9 9 * 10 10 * Transmit and frame generation functions. 11 11 */ ··· 882 882 rem -= fraglen; 883 883 tmp = dev_alloc_skb(local->tx_headroom + 884 884 frag_threshold + 885 - tx->sdata->encrypt_headroom + 885 + IEEE80211_ENCRYPT_HEADROOM + 886 886 IEEE80211_ENCRYPT_TAILROOM); 887 887 if (!tmp) 888 888 return -ENOMEM; ··· 890 890 __skb_queue_tail(&tx->skbs, tmp); 891 891 892 892 skb_reserve(tmp, 893 - local->tx_headroom + tx->sdata->encrypt_headroom); 893 + local->tx_headroom + IEEE80211_ENCRYPT_HEADROOM); 894 894 895 895 /* copy control information */ 896 896 memcpy(tmp->cb, skb->cb, sizeof(tmp->cb)); ··· 1040 1040 case WLAN_CIPHER_SUITE_GCMP: 1041 1041 case WLAN_CIPHER_SUITE_GCMP_256: 1042 1042 return ieee80211_crypto_gcmp_encrypt(tx); 1043 - default: 1044 - return ieee80211_crypto_hw_encrypt(tx); 1045 1043 } 1046 1044 1047 1045 return TX_DROP; ··· 2011 2013 2012 2014 headroom = local->tx_headroom; 2013 2015 if (encrypt != ENCRYPT_NO) 2014 - headroom += sdata->encrypt_headroom; 2016 + headroom += IEEE80211_ENCRYPT_HEADROOM; 2015 2017 headroom -= skb_headroom(skb); 2016 2018 headroom = max_t(int, 0, headroom); 2017 2019 ··· 2865 2867 */ 2866 2868 2867 2869 if (head_need > 0 || skb_cloned(skb)) { 2868 - head_need += sdata->encrypt_headroom; 2870 + head_need += IEEE80211_ENCRYPT_HEADROOM; 2869 2871 head_need += local->tx_headroom; 2870 2872 head_need = max_t(int, 0, head_need); 2871 2873 if (ieee80211_skb_resize(sdata, skb, head_need, ENCRYPT_DATA)) { ··· 3126 3128 /* we don't know how to generate IVs for this at all */ 3127 3129 if (WARN_ON(gen_iv)) 3128 3130 goto out; 3129 - /* pure hardware keys are OK, of course */ 3130 - if (!(build.key->flags & KEY_FLAG_CIPHER_SCHEME)) 3131 - break; 3132 - /* cipher scheme might require space allocation */ 3133 - if (iv_spc && 3134 - build.key->conf.iv_len > IEEE80211_FAST_XMIT_MAX_IV) 3135 - goto out; 3136 - if (iv_spc) 3137 - build.hdr_len += build.key->conf.iv_len; 3138 3131 } 3139 3132 3140 3133 fc |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
+1 -69
net/mac80211/util.c
··· 6 6 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 7 7 * Copyright 2013-2014 Intel Mobile Communications GmbH 8 8 * Copyright (C) 2015-2017 Intel Deutschland GmbH 9 - * Copyright (C) 2018-2021 Intel Corporation 9 + * Copyright (C) 2018-2022 Intel Corporation 10 10 * 11 11 * utilities for mac80211 12 12 */ ··· 4210 4210 4211 4211 ieee80211_tx_skb(sdata, skb); 4212 4212 return 0; 4213 - } 4214 - 4215 - bool ieee80211_cs_valid(const struct ieee80211_cipher_scheme *cs) 4216 - { 4217 - return !(cs == NULL || cs->cipher == 0 || 4218 - cs->hdr_len < cs->pn_len + cs->pn_off || 4219 - cs->hdr_len <= cs->key_idx_off || 4220 - cs->key_idx_shift > 7 || 4221 - cs->key_idx_mask == 0); 4222 - } 4223 - 4224 - bool ieee80211_cs_list_valid(const struct ieee80211_cipher_scheme *cs, int n) 4225 - { 4226 - int i; 4227 - 4228 - /* Ensure we have enough iftype bitmap space for all iftype values */ 4229 - WARN_ON((NUM_NL80211_IFTYPES / 8 + 1) > sizeof(cs[0].iftype)); 4230 - 4231 - for (i = 0; i < n; i++) 4232 - if (!ieee80211_cs_valid(&cs[i])) 4233 - return false; 4234 - 4235 - return true; 4236 - } 4237 - 4238 - const struct ieee80211_cipher_scheme * 4239 - ieee80211_cs_get(struct ieee80211_local *local, u32 cipher, 4240 - enum nl80211_iftype iftype) 4241 - { 4242 - const struct ieee80211_cipher_scheme *l = local->hw.cipher_schemes; 4243 - int n = local->hw.n_cipher_schemes; 4244 - int i; 4245 - const struct ieee80211_cipher_scheme *cs = NULL; 4246 - 4247 - for (i = 0; i < n; i++) { 4248 - if (l[i].cipher == cipher) { 4249 - cs = &l[i]; 4250 - break; 4251 - } 4252 - } 4253 - 4254 - if (!cs || !(cs->iftype & BIT(iftype))) 4255 - return NULL; 4256 - 4257 - return cs; 4258 - } 4259 - 4260 - int ieee80211_cs_headroom(struct ieee80211_local *local, 4261 - struct cfg80211_crypto_settings *crypto, 4262 - enum nl80211_iftype iftype) 4263 - { 4264 - const struct ieee80211_cipher_scheme *cs; 4265 - int headroom = IEEE80211_ENCRYPT_HEADROOM; 4266 - int i; 4267 - 4268 - for (i = 0; i < crypto->n_ciphers_pairwise; i++) { 4269 - cs = ieee80211_cs_get(local, crypto->ciphers_pairwise[i], 4270 - iftype); 4271 - 4272 - if (cs && headroom < cs->hdr_len) 4273 - headroom = cs->hdr_len; 4274 - } 4275 - 4276 - cs = ieee80211_cs_get(local, crypto->cipher_group, iftype); 4277 - if (cs && headroom < cs->hdr_len) 4278 - headroom = cs->hdr_len; 4279 - 4280 - return headroom; 4281 4213 } 4282 4214 4283 4215 static bool
+1 -132
net/mac80211/wpa.c
··· 3 3 * Copyright 2002-2004, Instant802 Networks, Inc. 4 4 * Copyright 2008, Jouni Malinen <j@w1.fi> 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 - * Copyright (C) 2020-2021 Intel Corporation 6 + * Copyright (C) 2020-2022 Intel Corporation 7 7 */ 8 8 9 9 #include <linux/netdevice.h> ··· 778 778 return RX_CONTINUE; 779 779 } 780 780 781 - static ieee80211_tx_result 782 - ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx, 783 - struct sk_buff *skb) 784 - { 785 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 786 - struct ieee80211_key *key = tx->key; 787 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 788 - int hdrlen; 789 - u8 *pos, iv_len = key->conf.iv_len; 790 - 791 - if (info->control.hw_key && 792 - !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { 793 - /* hwaccel has no need for preallocated head room */ 794 - return TX_CONTINUE; 795 - } 796 - 797 - if (unlikely(skb_headroom(skb) < iv_len && 798 - pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC))) 799 - return TX_DROP; 800 - 801 - hdrlen = ieee80211_hdrlen(hdr->frame_control); 802 - 803 - pos = skb_push(skb, iv_len); 804 - memmove(pos, pos + iv_len, hdrlen); 805 - 806 - return TX_CONTINUE; 807 - } 808 - 809 - static inline int ieee80211_crypto_cs_pn_compare(u8 *pn1, u8 *pn2, int len) 810 - { 811 - int i; 812 - 813 - /* pn is little endian */ 814 - for (i = len - 1; i >= 0; i--) { 815 - if (pn1[i] < pn2[i]) 816 - return -1; 817 - else if (pn1[i] > pn2[i]) 818 - return 1; 819 - } 820 - 821 - return 0; 822 - } 823 - 824 - static ieee80211_rx_result 825 - ieee80211_crypto_cs_decrypt(struct ieee80211_rx_data *rx) 826 - { 827 - struct ieee80211_key *key = rx->key; 828 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; 829 - const struct ieee80211_cipher_scheme *cs = NULL; 830 - int hdrlen = ieee80211_hdrlen(hdr->frame_control); 831 - struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); 832 - int data_len; 833 - u8 *rx_pn; 834 - u8 *skb_pn; 835 - u8 qos_tid; 836 - 837 - if (!rx->sta || !rx->sta->cipher_scheme || 838 - !(status->flag & RX_FLAG_DECRYPTED)) 839 - return RX_DROP_UNUSABLE; 840 - 841 - if (!ieee80211_is_data(hdr->frame_control)) 842 - return RX_CONTINUE; 843 - 844 - cs = rx->sta->cipher_scheme; 845 - 846 - data_len = rx->skb->len - hdrlen - cs->hdr_len; 847 - 848 - if (data_len < 0) 849 - return RX_DROP_UNUSABLE; 850 - 851 - if (ieee80211_is_data_qos(hdr->frame_control)) 852 - qos_tid = ieee80211_get_tid(hdr); 853 - else 854 - qos_tid = 0; 855 - 856 - if (skb_linearize(rx->skb)) 857 - return RX_DROP_UNUSABLE; 858 - 859 - rx_pn = key->u.gen.rx_pn[qos_tid]; 860 - skb_pn = rx->skb->data + hdrlen + cs->pn_off; 861 - 862 - if (ieee80211_crypto_cs_pn_compare(skb_pn, rx_pn, cs->pn_len) <= 0) 863 - return RX_DROP_UNUSABLE; 864 - 865 - memcpy(rx_pn, skb_pn, cs->pn_len); 866 - 867 - /* remove security header and MIC */ 868 - if (pskb_trim(rx->skb, rx->skb->len - cs->mic_len)) 869 - return RX_DROP_UNUSABLE; 870 - 871 - memmove(rx->skb->data + cs->hdr_len, rx->skb->data, hdrlen); 872 - skb_pull(rx->skb, cs->hdr_len); 873 - 874 - return RX_CONTINUE; 875 - } 876 - 877 781 static void bip_aad(struct sk_buff *skb, u8 *aad) 878 782 { 879 783 __le16 mask_fc; ··· 1115 1211 skb_trim(skb, skb->len - sizeof(*mmie)); 1116 1212 1117 1213 return RX_CONTINUE; 1118 - } 1119 - 1120 - ieee80211_tx_result 1121 - ieee80211_crypto_hw_encrypt(struct ieee80211_tx_data *tx) 1122 - { 1123 - struct sk_buff *skb; 1124 - struct ieee80211_tx_info *info = NULL; 1125 - ieee80211_tx_result res; 1126 - 1127 - skb_queue_walk(&tx->skbs, skb) { 1128 - info = IEEE80211_SKB_CB(skb); 1129 - 1130 - /* handle hw-only algorithm */ 1131 - if (!info->control.hw_key) 1132 - return TX_DROP; 1133 - 1134 - if (tx->key->flags & KEY_FLAG_CIPHER_SCHEME) { 1135 - res = ieee80211_crypto_cs_encrypt(tx, skb); 1136 - if (res != TX_CONTINUE) 1137 - return res; 1138 - } 1139 - } 1140 - 1141 - ieee80211_tx_set_protected(tx); 1142 - 1143 - return TX_CONTINUE; 1144 - } 1145 - 1146 - ieee80211_rx_result 1147 - ieee80211_crypto_hw_decrypt(struct ieee80211_rx_data *rx) 1148 - { 1149 - if (rx->sta && rx->sta->cipher_scheme) 1150 - return ieee80211_crypto_cs_decrypt(rx); 1151 - 1152 - return RX_DROP_UNUSABLE; 1153 1214 }
+1 -4
net/mac80211/wpa.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 2 /* 3 3 * Copyright 2002-2004, Instant802 Networks, Inc. 4 + * Copyright (C) 2022 Intel Corporation 4 5 */ 5 6 6 7 #ifndef WPA_H ··· 40 39 ieee80211_crypto_aes_gmac_encrypt(struct ieee80211_tx_data *tx); 41 40 ieee80211_rx_result 42 41 ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx); 43 - ieee80211_tx_result 44 - ieee80211_crypto_hw_encrypt(struct ieee80211_tx_data *tx); 45 - ieee80211_rx_result 46 - ieee80211_crypto_hw_decrypt(struct ieee80211_rx_data *rx); 47 42 48 43 ieee80211_tx_result 49 44 ieee80211_crypto_gcmp_encrypt(struct ieee80211_tx_data *tx);