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

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

Johannes Berg says:

====================
Highlights this time are:

- cfg80211/nl80211:
* improvements for 6 GHz regulatory flexibility

- mac80211:
* use generic netdev stats
* multi-link improvements/fixes

- brcmfmac:
* MFP support (to enable WPA3)

- wilc1000:
* suspend/resume improvements

- iwlwifi:
* remove support for older FW for new devices
* fast resume (keeping the device configured)

- wl18xx:
* support newer firmware versions

* tag 'wireless-next-2024-06-27' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next: (100 commits)
wifi: brcmfmac: of: Support interrupts-extended
wifi: brcmsmac: advertise MFP_CAPABLE to enable WPA3
net: rfkill: Correct return value in invalid parameter case
wifi: mac80211: fix NULL dereference at band check in starting tx ba session
wifi: iwlwifi: mvm: fix rs.h kernel-doc
wifi: iwlwifi: fw: api: datapath: fix kernel-doc
wifi: iwlwifi: fix remaining mistagged kernel-doc comments
wifi: iwlwifi: fix prototype mismatch kernel-doc warnings
wifi: iwlwifi: fix kernel-doc in iwl-fh.h
wifi: iwlwifi: fix kernel-doc in iwl-trans.h
wifi: iwlwifi: pcie: fix kernel-doc
wifi: iwlwifi: dvm: fix kernel-doc warnings
wifi: iwlwifi: mvm: don't log error for failed UATS table read
wifi: iwlwifi: trans: make bad state warnings
wifi: iwlwifi: fw: api: fix some kernel-doc
wifi: iwlwifi: mvm: remove init_dbg module parameter
wifi: iwlwifi: update the BA notification API
wifi: iwlwifi: mvm: always unblock EMLSR on ROC end
wifi: iwlwifi: mvm: use IWL_FW_CHECK for link ID check
wifi: iwlwifi: mvm: don't flush BSSes on restart with MLD API
...
====================

Link: https://patch.msgid.link/20240627114135.28507-3-johannes@sipsolutions.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+4705 -4312
+1 -1
drivers/net/wireless/admtek/adm8211.c
··· 1550 1550 return retval; 1551 1551 } 1552 1552 1553 - static void adm8211_stop(struct ieee80211_hw *dev) 1553 + static void adm8211_stop(struct ieee80211_hw *dev, bool suspend) 1554 1554 { 1555 1555 struct adm8211_priv *priv = dev->priv; 1556 1556
+1 -1
drivers/net/wireless/ath/ar5523/ar5523.c
··· 1061 1061 return error; 1062 1062 } 1063 1063 1064 - static void ar5523_stop(struct ieee80211_hw *hw) 1064 + static void ar5523_stop(struct ieee80211_hw *hw, bool suspend) 1065 1065 { 1066 1066 struct ar5523 *ar = hw->priv; 1067 1067
+1 -1
drivers/net/wireless/ath/ath10k/mac.c
··· 5363 5363 return ret; 5364 5364 } 5365 5365 5366 - static void ath10k_stop(struct ieee80211_hw *hw) 5366 + static void ath10k_stop(struct ieee80211_hw *hw, bool suspend) 5367 5367 { 5368 5368 struct ath10k *ar = hw->priv; 5369 5369 u32 opt;
+1 -1
drivers/net/wireless/ath/ath11k/mac.c
··· 6278 6278 return ret; 6279 6279 } 6280 6280 6281 - static void ath11k_mac_op_stop(struct ieee80211_hw *hw) 6281 + static void ath11k_mac_op_stop(struct ieee80211_hw *hw, bool suspend) 6282 6282 { 6283 6283 struct ath11k *ar = hw->priv; 6284 6284 struct htt_ppdu_stats_info *ppdu_stats, *tmp;
+1 -1
drivers/net/wireless/ath/ath12k/mac.c
··· 6112 6112 atomic_set(&ar->num_pending_mgmt_tx, 0); 6113 6113 } 6114 6114 6115 - static void ath12k_mac_op_stop(struct ieee80211_hw *hw) 6115 + static void ath12k_mac_op_stop(struct ieee80211_hw *hw, bool suspend) 6116 6116 { 6117 6117 struct ath12k_hw *ah = ath12k_hw_to_ah(hw); 6118 6118 struct ath12k *ar;
+1 -1
drivers/net/wireless/ath/ath5k/base.c
··· 2847 2847 * if another thread does a system call and the thread doing the 2848 2848 * stop is preempted). 2849 2849 */ 2850 - void ath5k_stop(struct ieee80211_hw *hw) 2850 + void ath5k_stop(struct ieee80211_hw *hw, bool suspend) 2851 2851 { 2852 2852 struct ath5k_hw *ah = hw->priv; 2853 2853 int ret;
+1 -1
drivers/net/wireless/ath/ath5k/base.h
··· 92 92 bool ath5k_any_vif_assoc(struct ath5k_hw *ah); 93 93 94 94 int ath5k_start(struct ieee80211_hw *hw); 95 - void ath5k_stop(struct ieee80211_hw *hw); 95 + void ath5k_stop(struct ieee80211_hw *hw, bool suspend); 96 96 97 97 void ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf); 98 98 int ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
+1 -1
drivers/net/wireless/ath/ath9k/htc_drv_main.c
··· 973 973 return ret; 974 974 } 975 975 976 - static void ath9k_htc_stop(struct ieee80211_hw *hw) 976 + static void ath9k_htc_stop(struct ieee80211_hw *hw, bool suspend) 977 977 { 978 978 struct ath9k_htc_priv *priv = hw->priv; 979 979 struct ath_hw *ah = priv->ah;
+1 -1
drivers/net/wireless/ath/ath9k/main.c
··· 895 895 ath_key_delete(common, keyix); 896 896 } 897 897 898 - static void ath9k_stop(struct ieee80211_hw *hw) 898 + static void ath9k_stop(struct ieee80211_hw *hw, bool suspend) 899 899 { 900 900 struct ath_softc *sc = hw->priv; 901 901 struct ath_hw *ah = sc->sc_ah;
+1 -1
drivers/net/wireless/ath/carl9170/main.c
··· 439 439 cancel_work_sync(&ar->ampdu_work); 440 440 } 441 441 442 - static void carl9170_op_stop(struct ieee80211_hw *hw) 442 + static void carl9170_op_stop(struct ieee80211_hw *hw, bool suspend) 443 443 { 444 444 struct ar9170 *ar = hw->priv; 445 445
+1 -1
drivers/net/wireless/ath/wcn36xx/main.c
··· 278 278 return ret; 279 279 } 280 280 281 - static void wcn36xx_stop(struct ieee80211_hw *hw) 281 + static void wcn36xx_stop(struct ieee80211_hw *hw, bool suspend) 282 282 { 283 283 struct wcn36xx *wcn = hw->priv; 284 284
+26 -32
drivers/net/wireless/atmel/at76c50x-usb.c
··· 332 332 333 333 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), DFU_GETSTATUS, 334 334 USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, 335 - 0, 0, status, sizeof(struct dfu_status), 335 + 0, 0, status, sizeof(*status), 336 336 USB_CTRL_GET_TIMEOUT); 337 337 return ret; 338 338 } ··· 366 366 u32 dfu_timeout = 0; 367 367 int bsize = 0; 368 368 int blockno = 0; 369 - struct dfu_status *dfu_stat_buf = NULL; 369 + struct dfu_status *dfu_stat_buf; 370 370 u8 *dfu_state = NULL; 371 371 u8 *block = NULL; 372 372 ··· 378 378 return -EINVAL; 379 379 } 380 380 381 - dfu_stat_buf = kmalloc(sizeof(struct dfu_status), GFP_KERNEL); 381 + dfu_stat_buf = kmalloc(sizeof(*dfu_stat_buf), GFP_KERNEL); 382 382 if (!dfu_stat_buf) { 383 383 ret = -ENOMEM; 384 384 goto exit; ··· 721 721 int buf_size) 722 722 { 723 723 int ret; 724 - struct at76_command *cmd_buf = kmalloc(sizeof(struct at76_command) + 725 - buf_size, GFP_KERNEL); 724 + size_t total_size; 725 + struct at76_command *cmd_buf; 726 726 727 + total_size = struct_size(cmd_buf, data, buf_size); 728 + cmd_buf = kmalloc(total_size, GFP_KERNEL); 727 729 if (!cmd_buf) 728 730 return -ENOMEM; 729 731 ··· 734 732 cmd_buf->size = cpu_to_le16(buf_size); 735 733 memcpy(cmd_buf->data, buf, buf_size); 736 734 737 - at76_dbg_dump(DBG_CMD, cmd_buf, sizeof(struct at76_command) + buf_size, 735 + at76_dbg_dump(DBG_CMD, cmd_buf, total_size, 738 736 "issuing command %s (0x%02x)", 739 737 at76_get_cmd_string(cmd), cmd); 740 738 741 739 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e, 742 740 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 743 - 0, 0, cmd_buf, 744 - sizeof(struct at76_command) + buf_size, 745 - USB_CTRL_GET_TIMEOUT); 741 + 0, 0, cmd_buf, total_size, USB_CTRL_GET_TIMEOUT); 746 742 kfree(cmd_buf); 747 743 return ret; 748 744 } ··· 931 931 { 932 932 int i; 933 933 int ret; 934 - struct mib_mac_addr *m = kmalloc(sizeof(struct mib_mac_addr), 935 - GFP_KERNEL); 934 + struct mib_mac_addr *m = kmalloc(sizeof(*m), GFP_KERNEL); 936 935 937 936 if (!m) 938 937 return; 939 938 940 - ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, 941 - sizeof(struct mib_mac_addr)); 939 + ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, sizeof(*m)); 942 940 if (ret < 0) { 943 941 wiphy_err(priv->hw->wiphy, 944 942 "at76_get_mib (MAC_ADDR) failed: %d\n", ret); ··· 959 961 int i; 960 962 int ret; 961 963 int key_len; 962 - struct mib_mac_wep *m = kmalloc(sizeof(struct mib_mac_wep), GFP_KERNEL); 964 + struct mib_mac_wep *m = kmalloc(sizeof(*m), GFP_KERNEL); 963 965 964 966 if (!m) 965 967 return; 966 968 967 - ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, 968 - sizeof(struct mib_mac_wep)); 969 + ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, sizeof(*m)); 969 970 if (ret < 0) { 970 971 wiphy_err(priv->hw->wiphy, 971 972 "at76_get_mib (MAC_WEP) failed: %d\n", ret); ··· 994 997 static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) 995 998 { 996 999 int ret; 997 - struct mib_mac_mgmt *m = kmalloc(sizeof(struct mib_mac_mgmt), 998 - GFP_KERNEL); 1000 + struct mib_mac_mgmt *m = kmalloc(sizeof(*m), GFP_KERNEL); 999 1001 1000 1002 if (!m) 1001 1003 return; 1002 1004 1003 - ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, 1004 - sizeof(struct mib_mac_mgmt)); 1005 + ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, sizeof(*m)); 1005 1006 if (ret < 0) { 1006 1007 wiphy_err(priv->hw->wiphy, 1007 1008 "at76_get_mib (MAC_MGMT) failed: %d\n", ret); ··· 1030 1035 static void at76_dump_mib_mac(struct at76_priv *priv) 1031 1036 { 1032 1037 int ret; 1033 - struct mib_mac *m = kmalloc(sizeof(struct mib_mac), GFP_KERNEL); 1038 + struct mib_mac *m = kmalloc(sizeof(*m), GFP_KERNEL); 1034 1039 1035 1040 if (!m) 1036 1041 return; 1037 1042 1038 - ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); 1043 + ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(*m)); 1039 1044 if (ret < 0) { 1040 1045 wiphy_err(priv->hw->wiphy, 1041 1046 "at76_get_mib (MAC) failed: %d\n", ret); ··· 1067 1072 static void at76_dump_mib_phy(struct at76_priv *priv) 1068 1073 { 1069 1074 int ret; 1070 - struct mib_phy *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL); 1075 + struct mib_phy *m = kmalloc(sizeof(*m), GFP_KERNEL); 1071 1076 1072 1077 if (!m) 1073 1078 return; 1074 1079 1075 - ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); 1080 + ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(*m)); 1076 1081 if (ret < 0) { 1077 1082 wiphy_err(priv->hw->wiphy, 1078 1083 "at76_get_mib (PHY) failed: %d\n", ret); ··· 1125 1130 static void at76_dump_mib_mdomain(struct at76_priv *priv) 1126 1131 { 1127 1132 int ret; 1128 - struct mib_mdomain *m = kmalloc(sizeof(struct mib_mdomain), GFP_KERNEL); 1133 + struct mib_mdomain *m = kmalloc(sizeof(*m), GFP_KERNEL); 1129 1134 1130 1135 if (!m) 1131 1136 return; 1132 1137 1133 - ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, 1134 - sizeof(struct mib_mdomain)); 1138 + ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, sizeof(*m)); 1135 1139 if (ret < 0) { 1136 1140 wiphy_err(priv->hw->wiphy, 1137 1141 "at76_get_mib (MDOMAIN) failed: %d\n", ret); ··· 1369 1375 priv->scan_min_time, priv->scan_max_time, 1370 1376 priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive"); 1371 1377 1372 - memset(ccfg, 0, sizeof(struct at76_card_config)); 1378 + memset(ccfg, 0, sizeof(*ccfg)); 1373 1379 ccfg->promiscuous_mode = 0; 1374 1380 ccfg->short_retry_limit = priv->short_retry_limit; 1375 1381 ··· 1405 1411 ccfg->beacon_period = cpu_to_le16(priv->beacon_period); 1406 1412 1407 1413 ret = at76_set_card_command(priv->udev, CMD_STARTUP, &priv->card_config, 1408 - sizeof(struct at76_card_config)); 1414 + sizeof(*ccfg)); 1409 1415 if (ret < 0) { 1410 1416 wiphy_err(priv->hw->wiphy, "at76_set_card_command failed: %d\n", 1411 1417 ret); ··· 1850 1856 return 0; 1851 1857 } 1852 1858 1853 - static void at76_mac80211_stop(struct ieee80211_hw *hw) 1859 + static void at76_mac80211_stop(struct ieee80211_hw *hw, bool suspend) 1854 1860 { 1855 1861 struct at76_priv *priv = hw->priv; 1856 1862 ··· 2437 2443 struct usb_device *udev; 2438 2444 int op_mode; 2439 2445 int need_ext_fw = 0; 2440 - struct mib_fw_version *fwv = NULL; 2446 + struct mib_fw_version *fwv; 2441 2447 int board_type = (int)id->driver_info; 2442 2448 2443 2449 udev = usb_get_dev(interface_to_usbdev(interface)); ··· 2525 2531 2526 2532 usb_set_intfdata(interface, priv); 2527 2533 2528 - memcpy(&priv->fw_version, fwv, sizeof(struct mib_fw_version)); 2534 + memcpy(&priv->fw_version, fwv, sizeof(*fwv)); 2529 2535 priv->board_type = board_type; 2530 2536 2531 2537 ret = at76_init_new_device(priv, interface);
+1 -1
drivers/net/wireless/atmel/at76c50x-usb.h
··· 151 151 u8 cmd; 152 152 u8 reserved; 153 153 __le16 size; 154 - u8 data[]; 154 + u8 data[] __counted_by_le(size); 155 155 } __packed; 156 156 157 157 /* Length of Atmel-specific Rx header before 802.11 frame */
+1 -1
drivers/net/wireless/broadcom/b43/main.c
··· 5078 5078 return err; 5079 5079 } 5080 5080 5081 - static void b43_op_stop(struct ieee80211_hw *hw) 5081 + static void b43_op_stop(struct ieee80211_hw *hw, bool suspend) 5082 5082 { 5083 5083 struct b43_wl *wl = hw_to_b43_wl(hw); 5084 5084 struct b43_wldev *dev = wl->current_dev;
+1 -1
drivers/net/wireless/broadcom/b43legacy/main.c
··· 3485 3485 return err; 3486 3486 } 3487 3487 3488 - static void b43legacy_op_stop(struct ieee80211_hw *hw) 3488 + static void b43legacy_op_stop(struct ieee80211_hw *hw, bool suspend) 3489 3489 { 3490 3490 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); 3491 3491 struct b43legacy_wldev *dev = wl->current_dev;
+5 -5
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
··· 4071 4071 struct cfg80211_wowlan_wakeup *wakeup; 4072 4072 u32 wakeind; 4073 4073 s32 err; 4074 - int timeout; 4074 + long time_left; 4075 4075 4076 4076 err = brcmf_fil_iovar_data_get(ifp, "wowl_wakeind", &wake_ind_le, 4077 4077 sizeof(wake_ind_le)); ··· 4113 4113 } 4114 4114 if (wakeind & BRCMF_WOWL_PFN_FOUND) { 4115 4115 brcmf_dbg(INFO, "WOWL Wake indicator: BRCMF_WOWL_PFN_FOUND\n"); 4116 - timeout = wait_event_timeout(cfg->wowl.nd_data_wait, 4117 - cfg->wowl.nd_data_completed, 4118 - BRCMF_ND_INFO_TIMEOUT); 4119 - if (!timeout) 4116 + time_left = wait_event_timeout(cfg->wowl.nd_data_wait, 4117 + cfg->wowl.nd_data_completed, 4118 + BRCMF_ND_INFO_TIMEOUT); 4119 + if (!time_left) 4120 4120 bphy_err(drvr, "No result for wowl net detect\n"); 4121 4121 else 4122 4122 wakeup_data.net_detect = cfg->wowl.nd_info;
+3 -2
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
··· 70 70 { 71 71 struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio; 72 72 struct device_node *root, *np = dev->of_node; 73 + struct of_phandle_args oirq; 73 74 const char *prop; 74 75 int irq; 75 76 int err; ··· 130 129 sdio->drive_strength = val; 131 130 132 131 /* make sure there are interrupts defined in the node */ 133 - if (!of_property_present(np, "interrupts")) 132 + if (of_irq_parse_one(np, 0, &oirq)) 134 133 return; 135 134 136 - irq = irq_of_parse_and_map(np, 0); 135 + irq = irq_create_of_mapping(&oirq); 137 136 if (!irq) { 138 137 brcmf_err("interrupt could not be mapped\n"); 139 138 return;
+2 -1
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
··· 457 457 return err; 458 458 } 459 459 460 - static void brcms_ops_stop(struct ieee80211_hw *hw) 460 + static void brcms_ops_stop(struct ieee80211_hw *hw, bool suspend) 461 461 { 462 462 struct brcms_info *wl = hw->priv; 463 463 int status; ··· 1090 1090 ieee80211_hw_set(hw, AMPDU_AGGREGATION); 1091 1091 ieee80211_hw_set(hw, SIGNAL_DBM); 1092 1092 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS); 1093 + ieee80211_hw_set(hw, MFP_CAPABLE); 1093 1094 1094 1095 hw->extra_tx_headroom = brcms_c_get_header_len(); 1095 1096 hw->queues = N_TX_QUEUES;
+1 -1
drivers/net/wireless/intel/iwlegacy/3945-mac.c
··· 2813 2813 } 2814 2814 2815 2815 static void 2816 - il3945_mac_stop(struct ieee80211_hw *hw) 2816 + il3945_mac_stop(struct ieee80211_hw *hw, bool suspend) 2817 2817 { 2818 2818 struct il_priv *il = hw->priv; 2819 2819
+1 -1
drivers/net/wireless/intel/iwlegacy/4965-mac.c
··· 5820 5820 } 5821 5821 5822 5822 void 5823 - il4965_mac_stop(struct ieee80211_hw *hw) 5823 + il4965_mac_stop(struct ieee80211_hw *hw, bool suspend) 5824 5824 { 5825 5825 struct il_priv *il = hw->priv; 5826 5826
+1 -1
drivers/net/wireless/intel/iwlegacy/4965.h
··· 151 151 struct ieee80211_tx_control *control, 152 152 struct sk_buff *skb); 153 153 int il4965_mac_start(struct ieee80211_hw *hw); 154 - void il4965_mac_stop(struct ieee80211_hw *hw); 154 + void il4965_mac_stop(struct ieee80211_hw *hw, bool suspend); 155 155 void il4965_configure_filter(struct ieee80211_hw *hw, 156 156 unsigned int changed_flags, 157 157 unsigned int *total_flags, u64 multicast);
-1
drivers/net/wireless/intel/iwlwifi/Makefile
··· 14 14 iwlwifi-$(CONFIG_IWLMVM) += cfg/ax210.o cfg/bz.o cfg/sc.o 15 15 iwlwifi-objs += iwl-dbg-tlv.o 16 16 iwlwifi-objs += iwl-trans.o 17 - iwlwifi-objs += queue/tx.o 18 17 19 18 iwlwifi-objs += fw/img.o fw/notif-wait.o fw/rs.o 20 19 iwlwifi-objs += fw/dbg.o fw/pnvm.o fw/dump.o
+2 -2
drivers/net/wireless/intel/iwlwifi/cfg/22000.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 3 * Copyright (C) 2015-2017 Intel Deutschland GmbH 4 - * Copyright (C) 2018-2023 Intel Corporation 4 + * Copyright (C) 2018-2024 Intel Corporation 5 5 */ 6 6 #include <linux/module.h> 7 7 #include <linux/stringify.h> ··· 13 13 #define IWL_22000_UCODE_API_MAX 77 14 14 15 15 /* Lowest firmware API version supported */ 16 - #define IWL_22000_UCODE_API_MIN 50 16 + #define IWL_22000_UCODE_API_MIN 77 17 17 18 18 /* NVM versions */ 19 19 #define IWL_22000_NVM_VERSION 0x0a1d
+1 -1
drivers/net/wireless/intel/iwlwifi/cfg/ax210.c
··· 13 13 #define IWL_AX210_UCODE_API_MAX 89 14 14 15 15 /* Lowest firmware API version supported */ 16 - #define IWL_AX210_UCODE_API_MIN 59 16 + #define IWL_AX210_UCODE_API_MIN 77 17 17 18 18 /* NVM versions */ 19 19 #define IWL_AX210_NVM_VERSION 0x0a1d
+2 -2
drivers/net/wireless/intel/iwlwifi/cfg/bz.c
··· 10 10 #include "fw/api/txq.h" 11 11 12 12 /* Highest firmware API version supported */ 13 - #define IWL_BZ_UCODE_API_MAX 91 13 + #define IWL_BZ_UCODE_API_MAX 92 14 14 15 15 /* Lowest firmware API version supported */ 16 - #define IWL_BZ_UCODE_API_MIN 80 16 + #define IWL_BZ_UCODE_API_MIN 90 17 17 18 18 /* NVM versions */ 19 19 #define IWL_BZ_NVM_VERSION 0x0a1d
+2 -2
drivers/net/wireless/intel/iwlwifi/cfg/sc.c
··· 10 10 #include "fw/api/txq.h" 11 11 12 12 /* Highest firmware API version supported */ 13 - #define IWL_SC_UCODE_API_MAX 91 13 + #define IWL_SC_UCODE_API_MAX 92 14 14 15 15 /* Lowest firmware API version supported */ 16 - #define IWL_SC_UCODE_API_MIN 82 16 + #define IWL_SC_UCODE_API_MIN 90 17 17 18 18 /* NVM versions */ 19 19 #define IWL_SC_NVM_VERSION 0x0a1d
+4 -4
drivers/net/wireless/intel/iwlwifi/dvm/commands.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2005-2014, 2023 Intel Corporation 3 + * Copyright (C) 2005-2014, 2023-2024 Intel Corporation 4 4 */ 5 5 /* 6 6 * Please use this file (commands.h) only for uCode API definitions. ··· 177 177 * 178 178 *****************************************************************************/ 179 179 180 - /** 180 + /* 181 181 * iwlagn rate_n_flags bit fields 182 182 * 183 183 * rate_n_flags format is used in following iwlagn commands: ··· 251 251 #define RATE_MCS_SGI_POS 13 252 252 #define RATE_MCS_SGI_MSK 0x2000 253 253 254 - /** 254 + /* 255 255 * rate_n_flags Tx antenna masks 256 256 * bit14:16 257 257 */ ··· 2767 2767 * 2768 2768 *****************************************************************************/ 2769 2769 2770 - /** 2770 + /* 2771 2771 * SENSITIVITY_CMD = 0xa8 (command, has simple generic response) 2772 2772 * 2773 2773 * This command sets up the Rx signal detector for a sensitivity level that
+2 -6
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
··· 2 2 /****************************************************************************** 3 3 * 4 4 * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved. 5 - * Copyright(C) 2018 - 2019, 2022 - 2023 Intel Corporation 5 + * Copyright(C) 2018 - 2019, 2022 - 2024 Intel Corporation 6 6 * 7 7 * Portions of this file are derived from the ipw3945 project, as well 8 8 * as portions of the ieee80211 subsystem header files. ··· 145 145 146 146 #ifdef CONFIG_PM_SLEEP 147 147 if (priv->fw->img[IWL_UCODE_WOWLAN].num_sec && 148 - priv->trans->ops->d3_suspend && 149 - priv->trans->ops->d3_resume && 150 148 device_can_wakeup(priv->trans->dev)) { 151 149 priv->wowlan_support.flags = WIPHY_WOWLAN_MAGIC_PKT | 152 150 WIPHY_WOWLAN_DISCONNECT | ··· 300 302 return ret; 301 303 } 302 304 303 - static void iwlagn_mac_stop(struct ieee80211_hw *hw) 305 + static void iwlagn_mac_stop(struct ieee80211_hw *hw, bool suspend) 304 306 { 305 307 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 306 308 ··· 728 730 ret = iwl_sta_rx_agg_stop(priv, sta, tid); 729 731 break; 730 732 case IEEE80211_AMPDU_TX_START: 731 - if (!priv->trans->ops->txq_enable) 732 - break; 733 733 if (!iwl_enable_tx_ampdu()) 734 734 break; 735 735 IWL_DEBUG_HT(priv, "start Tx\n");
+2 -2
drivers/net/wireless/intel/iwlwifi/dvm/tt.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 2 /****************************************************************************** 3 3 * 4 - * Copyright(c) 2007 - 2014, 2023 Intel Corporation. All rights reserved. 4 + * Copyright(c) 2007 - 2014, 2023-2024 Intel Corporation. All rights reserved. 5 5 * 6 6 * Portions of this file are derived from the ipw3945 project, as well 7 7 * as portions of the ieee80211 subsystem header files. ··· 64 64 }; 65 65 66 66 /** 67 - * struct iwl_tt_mgnt - Thermal Throttling Management structure 67 + * struct iwl_tt_mgmt - Thermal Throttling Management structure 68 68 * @advanced_tt: advanced thermal throttle required 69 69 * @state: current Thermal Throttling state 70 70 * @tt_power_mode: Thermal Throttling power mode index
+3 -3
drivers/net/wireless/intel/iwlwifi/fw/api/alive.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2012-2014, 2018, 2020-2021 Intel Corporation 3 + * Copyright (C) 2012-2014, 2018, 2020-2021, 2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 113 113 } __packed; /* UCODE_ALIVE_NTFY_API_S_VER_6 */ 114 114 115 115 /** 116 - * enum iwl_extended_cfg_flag - commands driver may send before 116 + * enum iwl_extended_cfg_flags - commands driver may send before 117 117 * finishing init flow 118 118 * @IWL_INIT_DEBUG_CFG: driver is going to send debug config command 119 119 * @IWL_INIT_NVM: driver is going to send NVM_ACCESS commands ··· 126 126 }; 127 127 128 128 /** 129 - * struct iwl_extended_cfg_cmd - mark what commands ucode should wait for 129 + * struct iwl_init_extended_cfg_cmd - mark what commands ucode should wait for 130 130 * before finishing init flows 131 131 * @init_flags: values from iwl_extended_cfg_flags 132 132 */
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/api/binding.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2012-2014, 2020, 2022 Intel Corporation 3 + * Copyright (C) 2012-2014, 2020, 2022, 2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 77 77 } __packed; /* TIME_QUOTA_DATA_API_S_VER_1 */ 78 78 79 79 /** 80 - * struct iwl_time_quota_cmd - configuration of time quota between bindings 80 + * struct iwl_time_quota_cmd_v1 - configuration of time quota between bindings 81 81 * ( TIME_QUOTA_CMD = 0x2c ) 82 82 * @quotas: allocations per binding 83 83 * Note: on non-CDB the fourth one is the auxilary mac and is
+1 -68
drivers/net/wireless/intel/iwlwifi/fw/api/coex.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2023 Intel Corporation 3 + * Copyright (C) 2023-2024 Intel Corporation 4 4 * Copyright (C) 2013-2014, 2018-2019 Intel Corporation 5 5 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH 6 6 * Copyright (C) 2017 Intel Deutschland GmbH ··· 77 77 __le32 secondary_ch_phy_id; 78 78 } __packed; /* BT_CI_MSG_API_S_VER_2 */ 79 79 80 - #define BT_MBOX(n_dw, _msg, _pos, _nbits) \ 81 - BT_MBOX##n_dw##_##_msg##_POS = (_pos), \ 82 - BT_MBOX##n_dw##_##_msg = BITS(_nbits) << BT_MBOX##n_dw##_##_msg##_POS 83 - 84 - enum iwl_bt_mxbox_dw0 { 85 - BT_MBOX(0, LE_SLAVE_LAT, 0, 3), 86 - BT_MBOX(0, LE_PROF1, 3, 1), 87 - BT_MBOX(0, LE_PROF2, 4, 1), 88 - BT_MBOX(0, LE_PROF_OTHER, 5, 1), 89 - BT_MBOX(0, CHL_SEQ_N, 8, 4), 90 - BT_MBOX(0, INBAND_S, 13, 1), 91 - BT_MBOX(0, LE_MIN_RSSI, 16, 4), 92 - BT_MBOX(0, LE_SCAN, 20, 1), 93 - BT_MBOX(0, LE_ADV, 21, 1), 94 - BT_MBOX(0, LE_MAX_TX_POWER, 24, 4), 95 - BT_MBOX(0, OPEN_CON_1, 28, 2), 96 - }; 97 - 98 - enum iwl_bt_mxbox_dw1 { 99 - BT_MBOX(1, BR_MAX_TX_POWER, 0, 4), 100 - BT_MBOX(1, IP_SR, 4, 1), 101 - BT_MBOX(1, LE_MSTR, 5, 1), 102 - BT_MBOX(1, AGGR_TRFC_LD, 8, 6), 103 - BT_MBOX(1, MSG_TYPE, 16, 3), 104 - BT_MBOX(1, SSN, 19, 2), 105 - }; 106 - 107 - enum iwl_bt_mxbox_dw2 { 108 - BT_MBOX(2, SNIFF_ACT, 0, 3), 109 - BT_MBOX(2, PAG, 3, 1), 110 - BT_MBOX(2, INQUIRY, 4, 1), 111 - BT_MBOX(2, CONN, 5, 1), 112 - BT_MBOX(2, SNIFF_INTERVAL, 8, 5), 113 - BT_MBOX(2, DISC, 13, 1), 114 - BT_MBOX(2, SCO_TX_ACT, 16, 2), 115 - BT_MBOX(2, SCO_RX_ACT, 18, 2), 116 - BT_MBOX(2, ESCO_RE_TX, 20, 2), 117 - BT_MBOX(2, SCO_DURATION, 24, 6), 118 - }; 119 - 120 - enum iwl_bt_mxbox_dw3 { 121 - BT_MBOX(3, SCO_STATE, 0, 1), 122 - BT_MBOX(3, SNIFF_STATE, 1, 1), 123 - BT_MBOX(3, A2DP_STATE, 2, 1), 124 - BT_MBOX(3, ACL_STATE, 3, 1), 125 - BT_MBOX(3, MSTR_STATE, 4, 1), 126 - BT_MBOX(3, OBX_STATE, 5, 1), 127 - BT_MBOX(3, A2DP_SRC, 6, 1), 128 - BT_MBOX(3, OPEN_CON_2, 8, 2), 129 - BT_MBOX(3, TRAFFIC_LOAD, 10, 2), 130 - BT_MBOX(3, CHL_SEQN_LSB, 12, 1), 131 - BT_MBOX(3, INBAND_P, 13, 1), 132 - BT_MBOX(3, MSG_TYPE_2, 16, 3), 133 - BT_MBOX(3, SSN_2, 19, 2), 134 - BT_MBOX(3, UPDATE_REQUEST, 21, 1), 135 - }; 136 - 137 - #define BT_MBOX_MSG(_notif, _num, _field) \ 138 - ((le32_to_cpu((_notif)->mbox_msg[(_num)]) & BT_MBOX##_num##_##_field)\ 139 - >> BT_MBOX##_num##_##_field##_POS) 140 - 141 - #define BT_MBOX_PRINT(_num, _field, _end) \ 142 - pos += scnprintf(buf + pos, bufsz - pos, \ 143 - "\t%s: %d%s", \ 144 - #_field, \ 145 - BT_MBOX_MSG(notif, _num, _field), \ 146 - true ? "\n" : ", ") 147 80 enum iwl_bt_activity_grading { 148 81 BT_OFF = 0, 149 82 BT_ON_NO_CONNECTION = 1,
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/api/config.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2012-2014, 2018-2019, 2023 Intel Corporation 3 + * Copyright (C) 2012-2014, 2018-2019, 2023-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 76 76 } __packed; /* PHY_SPECIFIC_CONFIGURATION_API_VER_1*/ 77 77 78 78 /** 79 - * struct iwl_phy_cfg_cmd - Phy configuration command 79 + * struct iwl_phy_cfg_cmd_v1 - Phy configuration command 80 80 * 81 81 * @phy_cfg: PHY configuration value, uses &enum iwl_fw_phy_cfg 82 82 * @calib_control: calibration control data
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/api/d3.h
··· 42 42 /* TODO: OFFLOADS_QUERY_API_S_VER_1 */ 43 43 44 44 /** 45 - * enum iwl_d3_proto_offloads - enabled protocol offloads 45 + * enum iwl_proto_offloads - enabled protocol offloads 46 46 * @IWL_D3_PROTO_OFFLOAD_ARP: ARP data is enabled 47 47 * @IWL_D3_PROTO_OFFLOAD_NS: NS (Neighbor Solicitation) is enabled 48 48 * @IWL_D3_PROTO_IPV4_VALID: IPv4 data is valid ··· 195 195 #define IWL_WOWLAN_MAX_PATTERNS 20 196 196 197 197 /** 198 - * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns 198 + * struct iwl_wowlan_patterns_cmd_v1 - WoWLAN wakeup patterns 199 199 */ 200 200 struct iwl_wowlan_patterns_cmd_v1 { 201 201 /**
+19 -8
drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h
··· 231 231 #define PTP_CTX_MAX_DATA_SIZE 128 232 232 233 233 /** 234 - * struct iwl_time_msmt_ptp_ctx - Vendor specific information element 234 + * struct iwl_time_msmt_ptp_ctx - Vendor specific element 235 235 * to allow a space for flexibility for the userspace App 236 236 * 237 - * @element_id: element id of vendor specific ie 238 - * @length: length of vendor specific ie 239 - * @reserved: for alignment 240 - * @data: vendor specific data blob 237 + * @ftm: FTM specific vendor element 238 + * @ftm.element_id: element id of vendor specific ie 239 + * @ftm.length: length of vendor specific ie 240 + * @ftm.reserved: for alignment 241 + * @ftm.data: vendor specific data blob 242 + * @tm: TM specific vendor element 243 + * @tm.element_id: element id of vendor specific ie 244 + * @tm.length: length of vendor specific ie 245 + * @tm.data: vendor specific data blob 241 246 */ 242 247 struct iwl_time_msmt_ptp_ctx { 243 - /* Differentiate between FTM and TM specific Vendor IEs */ 248 + /* Differentiate between FTM and TM specific Vendor elements */ 244 249 union { 245 250 struct { 246 251 u8 element_id; 247 252 u8 length; 248 253 __le16 reserved; 249 254 u8 data[PTP_CTX_MAX_DATA_SIZE]; 250 - } ftm; /* FTM specific vendor IE */ 255 + } ftm; 251 256 struct { 252 257 u8 element_id; 253 258 u8 length; 254 259 u8 data[PTP_CTX_MAX_DATA_SIZE]; 255 - } tm; /* TM specific vendor IE */ 260 + } tm; 256 261 }; 257 262 } __packed /* PTP_CTX_VER_1 */; 258 263 ··· 536 531 /** 537 532 * struct iwl_rx_baid_cfg_cmd - BAID allocation/config command 538 533 * @action: the action, from &enum iwl_rx_baid_action 534 + * @alloc: allocation data 535 + * @modify: modify data 536 + * @remove_v1: remove data (version 1) 537 + * @remove: remove data 539 538 */ 540 539 struct iwl_rx_baid_cfg_cmd { 541 540 __le32 action; ··· 574 565 /** 575 566 * struct iwl_scd_queue_cfg_cmd - scheduler queue allocation command 576 567 * @operation: the operation, see &enum iwl_scd_queue_cfg_operation 568 + * @u: union depending on command usage 577 569 * @u.add.sta_mask: station mask 578 570 * @u.add.tid: TID 579 571 * @u.add.reserved: reserved ··· 644 634 /** 645 635 * struct iwl_sec_key_cmd - security key command 646 636 * @action: action from &enum iwl_ctxt_action 637 + * @u: union depending on command type 647 638 * @u.add.sta_mask: station mask for the new key 648 639 * @u.add.key_id: key ID (0-7) for the new key 649 640 * @u.add.key_flags: key flags per &enum iwl_sec_key_flags
+1 -1
drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
··· 291 291 } __packed; /* FW_TLV_DEBUG_ADDR_VALUE_VER_1 */ 292 292 293 293 /** 294 - * struct iwl_fw_ini_conf_tlv - configuration TLV to set register/memory. 294 + * struct iwl_fw_ini_conf_set_tlv - configuration TLV to set register/memory. 295 295 * 296 296 * @hdr: debug header 297 297 * @time_point: time point to apply config. One of &enum iwl_fw_ini_time_point
+2 -1
drivers/net/wireless/intel/iwlwifi/fw/api/debug.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2005-2014, 2018-2023 Intel Corporation 3 + * Copyright (C) 2005-2014, 2018-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ 7 7 #ifndef __iwl_fw_api_debug_h__ 8 8 #define __iwl_fw_api_debug_h__ 9 + #include "dbg-tlv.h" 9 10 10 11 /** 11 12 * enum iwl_debug_cmds - debug commands
+1 -1
drivers/net/wireless/intel/iwlwifi/fw/api/location.h
··· 446 446 #define IWL_LCI_CIVIC_IE_MAX_SIZE 400 447 447 448 448 /** 449 - * struct iwl_tof_responder_dyn_config_cmd - Dynamic responder settings 449 + * struct iwl_tof_responder_dyn_config_cmd_v2 - Dynamic responder settings 450 450 * @lci_len: The length of the 1st (LCI) part in the @lci_civic buffer 451 451 * @civic_len: The length of the 2nd (CIVIC) part in the @lci_civic buffer 452 452 * @lci_civic: The LCI/CIVIC buffer. LCI data (if exists) comes first, then, if
+1 -1
drivers/net/wireless/intel/iwlwifi/fw/api/mac-cfg.h
··· 144 144 } __packed; /* MISSED_VAP_NTFY_API_S_VER_1 */ 145 145 146 146 /** 147 - * struct iwl_channel_switch_start_notif - Channel switch start notification 147 + * struct iwl_channel_switch_start_notif_v1 - Channel switch start notification 148 148 * 149 149 * @id_and_color: ID and color of the MAC 150 150 */
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h
··· 120 120 } __packed; /* NVM_ACCESS_CMD_API_S_VER_2 */ 121 121 122 122 /** 123 - * struct iwl_nvm_access_resp_ver2 - response to NVM_ACCESS_CMD 123 + * struct iwl_nvm_access_resp - response to NVM_ACCESS_CMD 124 124 * @offset: offset in bytes into the section 125 125 * @length: in bytes, either how much was written or read 126 126 * @type: NVM_SECTION_TYPE_* ··· 212 212 #define IWL_NUM_CHANNELS 110 213 213 214 214 /** 215 - * struct iwl_nvm_get_info_regulatory - regulatory information 215 + * struct iwl_nvm_get_info_regulatory_v1 - regulatory information 216 216 * @lar_enabled: is LAR enabled 217 217 * @channel_profile: regulatory data of this channel 218 218 * @reserved: reserved
+1 -1
drivers/net/wireless/intel/iwlwifi/fw/api/offload.h
··· 60 60 } __packed; 61 61 62 62 /** 63 - * struct iwl_stored_beacon_notif - Stored beacon notification 63 + * struct iwl_stored_beacon_notif_v2 - Stored beacon notification 64 64 * 65 65 * @common: fields common for all versions 66 66 * @data: beacon data, length in @byte_count
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/api/phy-ctxt.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2012-2014, 2018, 2020-2023 Intel Corporation 3 + * Copyright (C) 2012-2014, 2018, 2020-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 113 113 } __packed; 114 114 115 115 /** 116 - * struct iwl_phy_context_cmd - config of the PHY context 116 + * struct iwl_phy_context_cmd_v1 - config of the PHY context 117 117 * ( PHY_CONTEXT_CMD = 0x8 ) 118 118 * @id_and_color: ID and color of the relevant Binding 119 119 * @action: action to perform, see &enum iwl_ctxt_action
+1 -1
drivers/net/wireless/intel/iwlwifi/fw/api/phy.h
··· 195 195 } __packed; /* CT_KILL_NOTIFICATION_API_S_VER_1, CT_KILL_NOTIFICATION_API_S_VER_2 */ 196 196 197 197 /** 198 - * enum ctdp_cmd_operation - CTDP command operations 198 + * enum iwl_mvm_ctdp_cmd_operation - CTDP command operations 199 199 * @CTDP_CMD_OPERATION_START: update the current budget 200 200 * @CTDP_CMD_OPERATION_STOP: stop ctdp 201 201 * @CTDP_CMD_OPERATION_REPORT: get the average budget
+5 -5
drivers/net/wireless/intel/iwlwifi/fw/api/power.h
··· 462 462 } __packed; /* PER_CHAIN_LIMIT_OFFSET_PER_CHAIN_S_VER_1 */ 463 463 464 464 /** 465 - * struct iwl_geo_tx_power_profile_cmd_v1 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 465 + * struct iwl_geo_tx_power_profiles_cmd_v1 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 466 466 * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation 467 467 * @table: offset profile per band. 468 468 */ ··· 472 472 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_1 */ 473 473 474 474 /** 475 - * struct iwl_geo_tx_power_profile_cmd_v2 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 475 + * struct iwl_geo_tx_power_profiles_cmd_v2 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 476 476 * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation 477 477 * @table: offset profile per band. 478 478 * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading) ··· 484 484 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_2 */ 485 485 486 486 /** 487 - * struct iwl_geo_tx_power_profile_cmd_v3 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 487 + * struct iwl_geo_tx_power_profiles_cmd_v3 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 488 488 * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation 489 489 * @table: offset profile per band. 490 490 * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading) ··· 496 496 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_3 */ 497 497 498 498 /** 499 - * struct iwl_geo_tx_power_profile_cmd_v4 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 499 + * struct iwl_geo_tx_power_profiles_cmd_v4 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 500 500 * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation 501 501 * @table: offset profile per band. 502 502 * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading) ··· 508 508 } __packed; /* PER_CHAIN_LIMIT_OFFSET_CMD_VER_4 */ 509 509 510 510 /** 511 - * struct iwl_geo_tx_power_profile_cmd_v5 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 511 + * struct iwl_geo_tx_power_profiles_cmd_v5 - struct for PER_CHAIN_LIMIT_OFFSET_CMD cmd. 512 512 * @ops: operations, value from &enum iwl_geo_per_chain_offset_operation 513 513 * @table: offset profile per band. 514 514 * @table_revision: 0 for not-South Korea, 1 for South Korea (the name is misleading)
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/api/rs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2012-2014, 2018-2022 Intel Corporation 3 + * Copyright (C) 2012-2014, 2018-2022, 2024 Intel Corporation 4 4 * Copyright (C) 2017 Intel Deutschland GmbH 5 5 */ 6 6 #ifndef __iwl_fw_api_rs_h__ ··· 9 9 #include "mac.h" 10 10 11 11 /** 12 - * enum iwl_tlc_mng_cfg_flags_enum - options for TLC config flags 12 + * enum iwl_tlc_mng_cfg_flags - options for TLC config flags 13 13 * @IWL_TLC_MNG_CFG_FLAGS_STBC_MSK: enable STBC. For HE this enables STBC for 14 14 * bandwidths <= 80MHz 15 15 * @IWL_TLC_MNG_CFG_FLAGS_LDPC_MSK: enable LDPC
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/api/rx.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2012-2014, 2018-2023 Intel Corporation 3 + * Copyright (C) 2012-2014, 2018-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2015-2017 Intel Deutschland GmbH 6 6 */ ··· 976 976 } __packed; /* BA_WINDOW_STATUS_NTFY_API_S_VER_1 */ 977 977 978 978 /** 979 - * struct iwl_rfh_queue_config - RX queue configuration 979 + * struct iwl_rfh_queue_data - RX queue configuration 980 980 * @q_num: Q num 981 981 * @enable: enable queue 982 982 * @reserved: alignment
+8 -8
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
··· 149 149 } __packed; 150 150 151 151 /** 152 - * struct iwl_scan_offload_profile_cfg 152 + * struct iwl_scan_offload_profile_cfg_v1 - scan offload profile config 153 153 * @profiles: profiles to search for match 154 154 * @data: the rest of the data for profile_cfg 155 155 */ ··· 423 423 } __packed; 424 424 425 425 /** 426 - * struct iwl_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2 426 + * struct iwl_periodic_scan_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2 427 427 * @last_schedule_line: last schedule line executed (fast or regular) 428 428 * @last_schedule_iteration: last scan iteration executed before scan abort 429 429 * @status: &enum iwl_scan_offload_complete_status ··· 443 443 /* UMAC Scan API */ 444 444 445 445 /* The maximum of either of these cannot exceed 8, because we use an 446 - * 8-bit mask (see IWL_MVM_SCAN_MASK in mvm.h). 446 + * 8-bit mask (see enum iwl_scan_status). 447 447 */ 448 - #define IWL_MVM_MAX_UMAC_SCANS 4 449 - #define IWL_MVM_MAX_LMAC_SCANS 1 448 + #define IWL_MAX_UMAC_SCANS 4 449 + #define IWL_MAX_LMAC_SCANS 1 450 450 451 451 enum scan_config_flags { 452 452 SCAN_CONFIG_FLAG_ACTIVATE = BIT(0), ··· 789 789 } __packed; 790 790 791 791 /** 792 - * struct iwl_scan_req_umac_tail - the rest of the UMAC scan request command 792 + * struct iwl_scan_req_umac_tail_v2 - the rest of the UMAC scan request command 793 793 * parameters following channels configuration array. 794 794 * @schedule: two scheduling plans. 795 795 * @delay: delay in TUs before starting the first scan iteration ··· 1085 1085 } __packed; /* SCAN_REQUEST_PARAMS_API_S_VER_12 */ 1086 1086 1087 1087 /** 1088 - * struct iwl_scan_req_params_v16 1088 + * struct iwl_scan_req_params_v17 - scan request parameters (v17) 1089 1089 * @general_params: &struct iwl_scan_general_params_v11 1090 1090 * @channel_params: &struct iwl_scan_channel_params_v7 1091 1091 * @periodic_params: &struct iwl_scan_periodic_parms_v1 ··· 1111 1111 } __packed; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_12 */ 1112 1112 1113 1113 /** 1114 - * struct iwl_scan_req_umac_v16 1114 + * struct iwl_scan_req_umac_v17 - scan request command (v17) 1115 1115 * @uid: scan id, &enum iwl_umac_scan_uid_offsets 1116 1116 * @ooc_priority: out of channel priority - &enum iwl_scan_priority 1117 1117 * @scan_params: scan parameters
+3 -1
drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2012-2014, 2018-2020, 2022-2023 Intel Corporation 3 + * Copyright (C) 2012-2014, 2018-2020, 2022-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 340 340 * @ROC_ACTIVITY_HOTSPOT: ROC for hs20 activity 341 341 * @ROC_ACTIVITY_P2P_DISC: ROC for p2p discoverability activity 342 342 * @ROC_ACTIVITY_P2P_TXRX: ROC for p2p action frames activity 343 + * @ROC_ACTIVITY_P2P_NEG: ROC for p2p negotiation (used also for TX) 343 344 */ 344 345 enum iwl_roc_activity { 345 346 ROC_ACTIVITY_HOTSPOT, 346 347 ROC_ACTIVITY_P2P_DISC, 347 348 ROC_ACTIVITY_P2P_TXRX, 349 + ROC_ACTIVITY_P2P_NEG, 348 350 ROC_NUM_ACTIVITIES 349 351 }; /* ROC_ACTIVITY_API_E_VER_1 */ 350 352
+4 -2
drivers/net/wireless/intel/iwlwifi/fw/api/tx.h
··· 698 698 * @query_frame_cnt: SCD query frame count 699 699 * @txed: number of frames sent in the aggregation (all-TIDs) 700 700 * @done: number of frames that were Acked by the BA (all-TIDs) 701 + * @rts_retry_cnt: RTS retry count 701 702 * @reserved: reserved (for alignment) 702 703 * @wireless_time: Wireless-media time 703 704 * @tx_rate: the rate the aggregation was sent at ··· 719 718 __le16 query_frame_cnt; 720 719 __le16 txed; 721 720 __le16 done; 722 - __le16 reserved; 721 + u8 rts_retry_cnt; 722 + u8 reserved; 723 723 __le32 wireless_time; 724 724 __le32 tx_rate; 725 725 __le16 tfd_cnt; ··· 866 864 }; 867 865 868 866 /** 869 - * struct iwl_tx_path_flush_cmd -- queue/FIFO flush command 867 + * struct iwl_tx_path_flush_cmd_v1 -- queue/FIFO flush command 870 868 * @queues_ctl: bitmap of queues to flush 871 869 * @flush_ctl: control flags 872 870 * @reserved: reserved
+1 -5
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
··· 1168 1168 le32_to_cpu(reg->dev_addr.offset); 1169 1169 int i; 1170 1170 1171 - /* we shouldn't get here if the trans doesn't have read_config32 */ 1172 - if (WARN_ON_ONCE(!trans->ops->read_config32)) 1173 - return -EOPNOTSUPP; 1174 - 1175 1171 range->internal_base_addr = cpu_to_le32(addr); 1176 1172 range->range_data_size = reg->dev_addr.size; 1177 1173 for (i = 0; i < le32_to_cpu(reg->dev_addr.size); i += 4) { 1178 1174 int ret; 1179 1175 u32 tmp; 1180 1176 1181 - ret = trans->ops->read_config32(trans, addr + i, &tmp); 1177 + ret = iwl_trans_read_config32(trans, addr + i, &tmp); 1182 1178 if (ret < 0) 1183 1179 return ret; 1184 1180
+2 -2
drivers/net/wireless/intel/iwlwifi/fw/error-dump.h
··· 248 248 #define IWL_INI_DUMP_NAME_TYPE (BIT(31) | BIT(24)) 249 249 250 250 /** 251 - * struct iwl_fw_error_dump_data - data for one type 251 + * struct iwl_fw_ini_error_dump_data - data for one type 252 252 * @type: &enum iwl_fw_ini_region_type 253 253 * @sub_type: sub type id 254 254 * @sub_type_ver: sub type version ··· 278 278 } __packed; 279 279 280 280 /** 281 - * struct iwl_fw_error_dump_file - header of dump file 281 + * struct iwl_fw_ini_dump_file_hdr - header of dump file 282 282 * @barker: must be %IWL_FW_INI_ERROR_DUMP_BARKER 283 283 * @file_len: the length of all the file including the header 284 284 */
-2
drivers/net/wireless/intel/iwlwifi/fw/runtime.h
··· 103 103 * @cur_fw_img: current firmware image, must be maintained by 104 104 * the driver by calling &iwl_fw_set_current_image() 105 105 * @dump: debug dump data 106 - * @uats_enabled: VLP or AFC AP is enabled 107 106 * @uats_table: AP type table 108 107 * @uefi_tables_lock_status: The status of the WIFI GUID UEFI variables lock: 109 108 * 0: Unlocked, 1 and 2: Locked. ··· 182 183 bool sgom_enabled; 183 184 struct iwl_mcc_allowed_ap_type_cmd uats_table; 184 185 u8 uefi_tables_lock_status; 185 - bool uats_enabled; 186 186 }; 187 187 188 188 void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans,
+2 -1
drivers/net/wireless/intel/iwlwifi/iwl-config.h
··· 241 241 }; 242 242 243 243 /** 244 - * struct iwl_cfg_trans - information needed to start the trans 244 + * struct iwl_cfg_trans_params - information needed to start the trans 245 245 * 246 246 * These values are specific to the device ID and do not change when 247 247 * multiple configs are used for a single device ID. They values are ··· 258 258 * @mq_rx_supported: multi-queue rx support 259 259 * @integrated: discrete or integrated 260 260 * @low_latency_xtal: use the low latency xtal if supported 261 + * @bisr_workaround: BISR hardware workaround (for 22260 series devices) 261 262 * @ltr_delay: LTR delay parameter, &enum iwl_cfg_trans_ltr_delay. 262 263 * @imr_enabled: use the IMR if supported. 263 264 */
+2 -4
drivers/net/wireless/intel/iwlwifi/iwl-csr.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2005-2014, 2018-2023 Intel Corporation 3 + * Copyright (C) 2005-2014, 2018-2024 Intel Corporation 4 4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016 Intel Deutschland GmbH 6 6 */ ··· 304 304 #define CSR_HW_RFID_IS_CDB(_val) (((_val) & 0x10000000) >> 28) 305 305 #define CSR_HW_RFID_IS_JACKET(_val) (((_val) & 0x20000000) >> 29) 306 306 307 - /** 308 - * hw_rev values 309 - */ 307 + /* hw_rev values */ 310 308 enum { 311 309 SILICON_A_STEP = 0, 312 310 SILICON_B_STEP,
-6
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
··· 223 223 return -EINVAL; 224 224 } 225 225 226 - if (type == IWL_FW_INI_REGION_PCI_IOSF_CONFIG && 227 - !trans->ops->read_config32) { 228 - IWL_ERR(trans, "WRT: Unsupported region type %u\n", type); 229 - return -EOPNOTSUPP; 230 - } 231 - 232 226 if (type == IWL_FW_INI_REGION_INTERNAL_BUFFER) { 233 227 trans->dbg.imr_data.sram_addr = 234 228 le32_to_cpu(reg->internal_buffer.base_addr);
+1 -1
drivers/net/wireless/intel/iwlwifi/iwl-drv.c
··· 1836 1836 mutex_unlock(&iwlwifi_opmode_table_mtx); 1837 1837 1838 1838 #ifdef CONFIG_IWLWIFI_DEBUGFS 1839 - drv->trans->ops->debugfs_cleanup(drv->trans); 1839 + iwl_trans_debugfs_cleanup(drv->trans); 1840 1840 1841 1841 debugfs_remove_recursive(drv->dbgfs_drv); 1842 1842 #endif
+17 -17
drivers/net/wireless/intel/iwlwifi/iwl-fh.h
··· 15 15 /* Flow Handler Definitions */ 16 16 /****************************/ 17 17 18 - /** 18 + /* 19 19 * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) 20 20 * Addresses are offsets from device's PCI hardware base address. 21 21 */ ··· 24 24 #define FH_MEM_LOWER_BOUND_GEN2 (0xa06000) 25 25 #define FH_MEM_UPPER_BOUND_GEN2 (0xa08000) 26 26 27 - /** 27 + /* 28 28 * Keep-Warm (KW) buffer base address. 29 29 * 30 30 * Driver must allocate a 4KByte buffer that is for keeping the ··· 44 44 #define FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C) 45 45 46 46 47 - /** 47 + /* 48 48 * TFD Circular Buffers Base (CBBC) addresses 49 49 * 50 50 * Device has 16 base pointer registers, one for each of 16 host-DRAM-resident ··· 143 143 */ 144 144 #define TFH_SRV_DMA_CHNL0_BC (0x1F70) 145 145 146 - /** 146 + /* 147 147 * Rx SRAM Control and Status Registers (RSCSR) 148 148 * 149 149 * These registers provide handshake between driver and device for the Rx queue ··· 216 216 #define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00) 217 217 #define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND) 218 218 219 - /** 219 + /* 220 220 * Physical base address of 8-byte Rx Status buffer. 221 221 * Bit fields: 222 222 * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. 223 223 */ 224 224 #define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0) 225 225 226 - /** 226 + /* 227 227 * Physical base address of Rx Buffer Descriptor Circular Buffer. 228 228 * Bit fields: 229 229 * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. 230 230 */ 231 231 #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004) 232 232 233 - /** 233 + /* 234 234 * Rx write pointer (index, really!). 235 235 * Bit fields: 236 236 * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. ··· 242 242 #define FW_RSCSR_CHNL0_RXDCB_RDPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x00c) 243 243 #define FH_RSCSR_CHNL0_RDPTR FW_RSCSR_CHNL0_RXDCB_RDPTR_REG 244 244 245 - /** 245 + /* 246 246 * Rx Config/Status Registers (RCSR) 247 247 * Rx Config Reg for channel 0 (only channel used) 248 248 * ··· 300 300 #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) 301 301 #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) 302 302 303 - /** 303 + /* 304 304 * Rx Shared Status Registers (RSSR) 305 305 * 306 306 * After stopping Rx DMA channel (writing 0 to ··· 356 356 #define RFH_RBDBUF_RBD0_LSB 0xA08300 357 357 #define RFH_RBDBUF_RBD_LSB(q) (RFH_RBDBUF_RBD0_LSB + (q) * 8) 358 358 359 - /** 359 + /* 360 360 * RFH Status Register 361 361 * 362 362 * Bit fields: ··· 440 440 #define FH_TFDIB_CTRL0_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) 441 441 #define FH_TFDIB_CTRL1_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) 442 442 443 - /** 443 + /* 444 444 * Transmit DMA Channel Control/Status Registers (TCSR) 445 445 * 446 446 * Device has one configuration register for each of 8 Tx DMA/FIFO channels ··· 501 501 #define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) 502 502 #define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) 503 503 504 - /** 504 + /* 505 505 * Tx Shared Status Registers (TSSR) 506 506 * 507 507 * After stopping Tx DMA channel (writing 0 to ··· 518 518 519 519 #define FH_TSSR_TX_STATUS_REG (FH_TSSR_LOWER_BOUND + 0x010) 520 520 521 - /** 521 + /* 522 522 * Bit fields for TSSR(Tx Shared Status & Control) error status register: 523 523 * 31: Indicates an address error when accessed to internal memory 524 524 * uCode/driver must write "1" in order to clear this flag ··· 634 634 }; 635 635 636 636 /** 637 - * struct iwl_tfd_tb transmit buffer descriptor within transmit frame descriptor 637 + * struct iwl_tfd_tb - transmit buffer descriptor within transmit frame descriptor 638 638 * 639 639 * This structure contains dma address and length of transmission address 640 640 * ··· 648 648 } __packed; 649 649 650 650 /** 651 - * struct iwl_tfh_tb transmit buffer descriptor within transmit frame descriptor 651 + * struct iwl_tfh_tb - transmit buffer descriptor within transmit frame descriptor 652 652 * 653 653 * This structure contains dma address and length of transmission address 654 654 * ··· 717 717 /* Fixed (non-configurable) rx data from phy */ 718 718 719 719 /** 720 - * struct iwlagn_schedq_bc_tbl scheduler byte count table 720 + * struct iwlagn_scd_bc_tbl - scheduler byte count table 721 721 * base physical address provided by SCD_DRAM_BASE_ADDR 722 722 * For devices up to 22000: 723 723 * @tfd_offset: ··· 734 734 } __packed; 735 735 736 736 /** 737 - * struct iwl_gen3_bc_tbl_entry scheduler byte count table entry gen3 737 + * struct iwl_gen3_bc_tbl_entry - scheduler byte count table entry gen3 738 738 * For AX210 and on: 739 739 * @tfd_offset: 0-12 - tx command byte count 740 740 * 12-13 - number of 64 byte chunks
+2 -2
drivers/net/wireless/intel/iwlwifi/iwl-io.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 - * Copyright (C) 2003-2014, 2018-2022 Intel Corporation 3 + * Copyright (C) 2003-2014, 2018-2022, 2024 Intel Corporation 4 4 * Copyright (C) 2015-2016 Intel Deutschland GmbH 5 5 */ 6 6 #include <linux/delay.h> ··· 460 460 */ 461 461 if (cfg_trans->device_family >= IWL_DEVICE_FAMILY_BZ) { 462 462 iwl_set_bit(trans, CSR_GP_CNTRL, 463 - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | 463 + CSR_GP_CNTRL_REG_FLAG_BZ_MAC_ACCESS_REQ | 464 464 CSR_GP_CNTRL_REG_FLAG_MAC_INIT); 465 465 poll_ready = CSR_GP_CNTRL_REG_FLAG_MAC_STATUS; 466 466 } else {
+12 -11
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
··· 370 370 flags |= IEEE80211_CHAN_IR_CONCURRENT; 371 371 372 372 /* Set the AP type for the UHB case. */ 373 - if (!(nvm_flags & NVM_CHANNEL_VLP)) 373 + if (nvm_flags & NVM_CHANNEL_VLP) 374 + flags |= IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP; 375 + else 374 376 flags |= IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT; 375 377 if (!(nvm_flags & NVM_CHANNEL_AFC)) 376 378 flags |= IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT; ··· 1610 1608 static u32 iwl_nvm_get_regdom_bw_flags(const u16 *nvm_chan, 1611 1609 int ch_idx, u16 nvm_flags, 1612 1610 struct iwl_reg_capa reg_capa, 1613 - const struct iwl_cfg *cfg, 1614 - bool uats_enabled) 1611 + const struct iwl_cfg *cfg) 1615 1612 { 1616 1613 u32 flags = NL80211_RRF_NO_HT40; 1617 1614 ··· 1661 1660 } 1662 1661 1663 1662 /* Set the AP type for the UHB case. */ 1664 - if (uats_enabled) { 1665 - if (!(nvm_flags & NVM_CHANNEL_VLP)) 1666 - flags |= NL80211_RRF_NO_6GHZ_VLP_CLIENT; 1663 + if (nvm_flags & NVM_CHANNEL_VLP) 1664 + flags |= NL80211_RRF_ALLOW_6GHZ_VLP_AP; 1665 + else 1666 + flags |= NL80211_RRF_NO_6GHZ_VLP_CLIENT; 1667 1667 1668 - if (!(nvm_flags & NVM_CHANNEL_AFC)) 1669 - flags |= NL80211_RRF_NO_6GHZ_AFC_CLIENT; 1670 - } 1668 + if (!(nvm_flags & NVM_CHANNEL_AFC)) 1669 + flags |= NL80211_RRF_NO_6GHZ_AFC_CLIENT; 1671 1670 1672 1671 /* 1673 1672 * reg_capa is per regulatory domain so apply it for every channel ··· 1723 1722 struct ieee80211_regdomain * 1724 1723 iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, 1725 1724 int num_of_ch, __le32 *channels, u16 fw_mcc, 1726 - u16 geo_info, u32 cap, u8 resp_ver, bool uats_enabled) 1725 + u16 geo_info, u32 cap, u8 resp_ver) 1727 1726 { 1728 1727 int ch_idx; 1729 1728 u16 ch_flags; ··· 1790 1789 1791 1790 reg_rule_flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx, 1792 1791 ch_flags, reg_capa, 1793 - cfg, uats_enabled); 1792 + cfg); 1794 1793 1795 1794 /* we can't continue the same rule */ 1796 1795 if (ch_idx == 0 || prev_reg_rule_flags != reg_rule_flags ||
+3 -3
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2005-2015, 2018-2023 Intel Corporation 3 + * Copyright (C) 2005-2015, 2018-2024 Intel Corporation 4 4 * Copyright (C) 2016-2017 Intel Deutschland GmbH 5 5 */ 6 6 #ifndef __iwl_nvm_parse_h__ ··· 38 38 u8 tx_chains, u8 rx_chains); 39 39 40 40 /** 41 - * iwl_parse_mcc_info - parse MCC (mobile country code) info coming from FW 41 + * iwl_parse_nvm_mcc_info - parse MCC (mobile country code) info coming from FW 42 42 * 43 43 * This function parses the regulatory channel data received as a 44 44 * MCC_UPDATE_CMD command. It returns a newly allocation regulatory domain, ··· 50 50 struct ieee80211_regdomain * 51 51 iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, 52 52 int num_of_ch, __le32 *channels, u16 fw_mcc, 53 - u16 geo_info, u32 cap, u8 resp_ver, bool uats_enabled); 53 + u16 geo_info, u32 cap, u8 resp_ver); 54 54 55 55 /** 56 56 * struct iwl_nvm_section - describes an NVM section in memory.
+3 -2
drivers/net/wireless/intel/iwlwifi/iwl-op-mode.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2005-2014, 2018-2021 Intel Corporation 3 + * Copyright (C) 2005-2014, 2018-2021, 2024 Intel Corporation 4 4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2015 Intel Deutschland GmbH 6 6 */ ··· 185 185 static inline void iwl_op_mode_nic_config(struct iwl_op_mode *op_mode) 186 186 { 187 187 might_sleep(); 188 - op_mode->ops->nic_config(op_mode); 188 + if (op_mode->ops->nic_config) 189 + op_mode->ops->nic_config(op_mode); 189 190 } 190 191 191 192 static inline void iwl_op_mode_wimax_active(struct iwl_op_mode *op_mode)
+2 -2
drivers/net/wireless/intel/iwlwifi/iwl-prph.h
··· 96 96 #define DTSC_PTAT_AVG (0x00a10650) 97 97 98 98 99 - /** 99 + /* 100 100 * Tx Scheduler 101 101 * 102 102 * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs ··· 169 169 */ 170 170 #define SCD_MEM_LOWER_BOUND (0x0000) 171 171 172 - /** 172 + /* 173 173 * Max Tx window size is the max number of contiguous TFDs that the scheduler 174 174 * can keep track of at one time when creating block-ack chains of frames. 175 175 * Note that "64" matches the number of ack bits in a block-ack packet.
+382 -66
drivers/net/wireless/intel/iwlwifi/iwl-trans.c
··· 2 2 /* 3 3 * Copyright (C) 2015 Intel Mobile Communications GmbH 4 4 * Copyright (C) 2016-2017 Intel Deutschland GmbH 5 - * Copyright (C) 2019-2021, 2023 Intel Corporation 5 + * Copyright (C) 2019-2021, 2023-2024 Intel Corporation 6 6 */ 7 7 #include <linux/kernel.h> 8 8 #include <linux/bsearch.h> ··· 11 11 #include "iwl-trans.h" 12 12 #include "iwl-drv.h" 13 13 #include "iwl-fh.h" 14 - #include "queue/tx.h" 15 14 #include <linux/dmapool.h> 16 15 #include "fw/api/commands.h" 16 + #include "pcie/internal.h" 17 + #include "iwl-context-info-gen3.h" 17 18 18 19 struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, 19 20 struct device *dev, 20 - const struct iwl_trans_ops *ops, 21 21 const struct iwl_cfg_trans_params *cfg_trans) 22 22 { 23 23 struct iwl_trans *trans; ··· 37 37 #endif 38 38 39 39 trans->dev = dev; 40 - trans->ops = ops; 41 40 trans->num_rx_queues = 1; 42 - 43 - WARN_ON(!ops->wait_txq_empty && !ops->wait_tx_queues_empty); 44 - 45 - if (trans->trans_cfg->gen2) { 46 - trans->txqs.tfd.addr_size = 64; 47 - trans->txqs.tfd.max_tbs = IWL_TFH_NUM_TBS; 48 - trans->txqs.tfd.size = sizeof(struct iwl_tfh_tfd); 49 - } else { 50 - trans->txqs.tfd.addr_size = 36; 51 - trans->txqs.tfd.max_tbs = IWL_NUM_OF_TBS; 52 - trans->txqs.tfd.size = sizeof(struct iwl_tfd); 53 - } 54 - trans->max_skb_frags = IWL_TRANS_MAX_FRAGS(trans); 55 41 56 42 return trans; 57 43 } ··· 64 78 if (WARN_ON(trans->trans_cfg->gen2 && txcmd_size >= txcmd_align)) 65 79 return -EINVAL; 66 80 67 - if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) 68 - trans->txqs.bc_tbl_size = 69 - sizeof(struct iwl_gen3_bc_tbl_entry) * TFD_QUEUE_BC_SIZE_GEN3_BZ; 70 - else if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) 71 - trans->txqs.bc_tbl_size = 72 - sizeof(struct iwl_gen3_bc_tbl_entry) * TFD_QUEUE_BC_SIZE_GEN3_AX210; 73 - else 74 - trans->txqs.bc_tbl_size = sizeof(struct iwlagn_scd_bc_tbl); 75 - /* 76 - * For gen2 devices, we use a single allocation for each byte-count 77 - * table, but they're pretty small (1k) so use a DMA pool that we 78 - * allocate here. 79 - */ 80 - if (trans->trans_cfg->gen2) { 81 - trans->txqs.bc_pool = dmam_pool_create("iwlwifi:bc", trans->dev, 82 - trans->txqs.bc_tbl_size, 83 - 256, 0); 84 - if (!trans->txqs.bc_pool) 85 - return -ENOMEM; 86 - } 87 - 88 - /* Some things must not change even if the config does */ 89 - WARN_ON(trans->txqs.tfd.addr_size != 90 - (trans->trans_cfg->gen2 ? 64 : 36)); 91 - 92 81 snprintf(trans->dev_cmd_pool_name, sizeof(trans->dev_cmd_pool_name), 93 82 "iwl_cmd_pool:%s", dev_name(trans->dev)); 94 83 trans->dev_cmd_pool = ··· 73 112 if (!trans->dev_cmd_pool) 74 113 return -ENOMEM; 75 114 76 - trans->txqs.tso_hdr_page = alloc_percpu(struct iwl_tso_hdr_page); 77 - if (!trans->txqs.tso_hdr_page) { 78 - kmem_cache_destroy(trans->dev_cmd_pool); 79 - return -ENOMEM; 80 - } 81 - 82 115 /* Initialize the wait queue for commands */ 83 116 init_waitqueue_head(&trans->wait_command_queue); 84 117 ··· 81 126 82 127 void iwl_trans_free(struct iwl_trans *trans) 83 128 { 84 - int i; 85 - 86 - if (trans->txqs.tso_hdr_page) { 87 - for_each_possible_cpu(i) { 88 - struct iwl_tso_hdr_page *p = 89 - per_cpu_ptr(trans->txqs.tso_hdr_page, i); 90 - 91 - if (p && p->page) 92 - __free_page(p->page); 93 - } 94 - 95 - free_percpu(trans->txqs.tso_hdr_page); 96 - } 97 - 98 129 kmem_cache_destroy(trans->dev_cmd_pool); 99 130 } 100 131 ··· 108 167 if (unlikely(test_bit(STATUS_FW_ERROR, &trans->status))) 109 168 return -EIO; 110 169 111 - if (unlikely(trans->state != IWL_TRANS_FW_ALIVE)) { 112 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 170 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 171 + "bad state = %d\n", trans->state)) 113 172 return -EIO; 114 - } 115 173 116 174 if (!(cmd->flags & CMD_ASYNC)) 117 175 lock_map_acquire_read(&trans->sync_cmd_lockdep_map); ··· 120 180 cmd->id = DEF_ID(cmd->id); 121 181 } 122 182 123 - ret = iwl_trans_txq_send_hcmd(trans, cmd); 183 + ret = iwl_trans_pcie_send_hcmd(trans, cmd); 124 184 125 185 if (!(cmd->flags & CMD_ASYNC)) 126 186 lock_map_release(&trans->sync_cmd_lockdep_map); ··· 187 247 return 0; 188 248 } 189 249 IWL_EXPORT_SYMBOL(iwl_cmd_groups_verify_sorted); 250 + 251 + void iwl_trans_configure(struct iwl_trans *trans, 252 + const struct iwl_trans_config *trans_cfg) 253 + { 254 + trans->op_mode = trans_cfg->op_mode; 255 + 256 + iwl_trans_pcie_configure(trans, trans_cfg); 257 + WARN_ON(iwl_cmd_groups_verify_sorted(trans_cfg)); 258 + } 259 + IWL_EXPORT_SYMBOL(iwl_trans_configure); 260 + 261 + int iwl_trans_start_hw(struct iwl_trans *trans) 262 + { 263 + might_sleep(); 264 + 265 + return iwl_trans_pcie_start_hw(trans); 266 + } 267 + IWL_EXPORT_SYMBOL(iwl_trans_start_hw); 268 + 269 + void iwl_trans_op_mode_leave(struct iwl_trans *trans) 270 + { 271 + might_sleep(); 272 + 273 + iwl_trans_pcie_op_mode_leave(trans); 274 + 275 + trans->op_mode = NULL; 276 + 277 + trans->state = IWL_TRANS_NO_FW; 278 + } 279 + IWL_EXPORT_SYMBOL(iwl_trans_op_mode_leave); 280 + 281 + void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val) 282 + { 283 + iwl_trans_pcie_write8(trans, ofs, val); 284 + } 285 + IWL_EXPORT_SYMBOL(iwl_trans_write8); 286 + 287 + void iwl_trans_write32(struct iwl_trans *trans, u32 ofs, u32 val) 288 + { 289 + iwl_trans_pcie_write32(trans, ofs, val); 290 + } 291 + IWL_EXPORT_SYMBOL(iwl_trans_write32); 292 + 293 + u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) 294 + { 295 + return iwl_trans_pcie_read32(trans, ofs); 296 + } 297 + IWL_EXPORT_SYMBOL(iwl_trans_read32); 298 + 299 + u32 iwl_trans_read_prph(struct iwl_trans *trans, u32 ofs) 300 + { 301 + return iwl_trans_pcie_read_prph(trans, ofs); 302 + } 303 + IWL_EXPORT_SYMBOL(iwl_trans_read_prph); 304 + 305 + void iwl_trans_write_prph(struct iwl_trans *trans, u32 ofs, u32 val) 306 + { 307 + return iwl_trans_pcie_write_prph(trans, ofs, val); 308 + } 309 + IWL_EXPORT_SYMBOL(iwl_trans_write_prph); 310 + 311 + int iwl_trans_read_mem(struct iwl_trans *trans, u32 addr, 312 + void *buf, int dwords) 313 + { 314 + return iwl_trans_pcie_read_mem(trans, addr, buf, dwords); 315 + } 316 + IWL_EXPORT_SYMBOL(iwl_trans_read_mem); 317 + 318 + int iwl_trans_write_mem(struct iwl_trans *trans, u32 addr, 319 + const void *buf, int dwords) 320 + { 321 + return iwl_trans_pcie_write_mem(trans, addr, buf, dwords); 322 + } 323 + IWL_EXPORT_SYMBOL(iwl_trans_write_mem); 324 + 325 + void iwl_trans_set_pmi(struct iwl_trans *trans, bool state) 326 + { 327 + if (state) 328 + set_bit(STATUS_TPOWER_PMI, &trans->status); 329 + else 330 + clear_bit(STATUS_TPOWER_PMI, &trans->status); 331 + } 332 + IWL_EXPORT_SYMBOL(iwl_trans_set_pmi); 333 + 334 + int iwl_trans_sw_reset(struct iwl_trans *trans, bool retake_ownership) 335 + { 336 + return iwl_trans_pcie_sw_reset(trans, retake_ownership); 337 + } 338 + IWL_EXPORT_SYMBOL(iwl_trans_sw_reset); 339 + 340 + struct iwl_trans_dump_data * 341 + iwl_trans_dump_data(struct iwl_trans *trans, u32 dump_mask, 342 + const struct iwl_dump_sanitize_ops *sanitize_ops, 343 + void *sanitize_ctx) 344 + { 345 + return iwl_trans_pcie_dump_data(trans, dump_mask, 346 + sanitize_ops, sanitize_ctx); 347 + } 348 + IWL_EXPORT_SYMBOL(iwl_trans_dump_data); 349 + 350 + int iwl_trans_d3_suspend(struct iwl_trans *trans, bool test, bool reset) 351 + { 352 + might_sleep(); 353 + 354 + return iwl_trans_pcie_d3_suspend(trans, test, reset); 355 + } 356 + IWL_EXPORT_SYMBOL(iwl_trans_d3_suspend); 357 + 358 + int iwl_trans_d3_resume(struct iwl_trans *trans, enum iwl_d3_status *status, 359 + bool test, bool reset) 360 + { 361 + might_sleep(); 362 + 363 + return iwl_trans_pcie_d3_resume(trans, status, test, reset); 364 + } 365 + IWL_EXPORT_SYMBOL(iwl_trans_d3_resume); 366 + 367 + void iwl_trans_interrupts(struct iwl_trans *trans, bool enable) 368 + { 369 + iwl_trans_pci_interrupts(trans, enable); 370 + } 371 + IWL_EXPORT_SYMBOL(iwl_trans_interrupts); 372 + 373 + void iwl_trans_sync_nmi(struct iwl_trans *trans) 374 + { 375 + iwl_trans_pcie_sync_nmi(trans); 376 + } 377 + IWL_EXPORT_SYMBOL(iwl_trans_sync_nmi); 378 + 379 + int iwl_trans_write_imr_mem(struct iwl_trans *trans, u32 dst_addr, 380 + u64 src_addr, u32 byte_cnt) 381 + { 382 + return iwl_trans_pcie_copy_imr(trans, dst_addr, src_addr, byte_cnt); 383 + } 384 + IWL_EXPORT_SYMBOL(iwl_trans_write_imr_mem); 385 + 386 + void iwl_trans_set_bits_mask(struct iwl_trans *trans, u32 reg, 387 + u32 mask, u32 value) 388 + { 389 + iwl_trans_pcie_set_bits_mask(trans, reg, mask, value); 390 + } 391 + IWL_EXPORT_SYMBOL(iwl_trans_set_bits_mask); 392 + 393 + int iwl_trans_read_config32(struct iwl_trans *trans, u32 ofs, 394 + u32 *val) 395 + { 396 + return iwl_trans_pcie_read_config32(trans, ofs, val); 397 + } 398 + IWL_EXPORT_SYMBOL(iwl_trans_read_config32); 399 + 400 + bool _iwl_trans_grab_nic_access(struct iwl_trans *trans) 401 + { 402 + return iwl_trans_pcie_grab_nic_access(trans); 403 + } 404 + IWL_EXPORT_SYMBOL(_iwl_trans_grab_nic_access); 405 + 406 + void __releases(nic_access) 407 + iwl_trans_release_nic_access(struct iwl_trans *trans) 408 + { 409 + iwl_trans_pcie_release_nic_access(trans); 410 + __release(nic_access); 411 + } 412 + IWL_EXPORT_SYMBOL(iwl_trans_release_nic_access); 413 + 414 + void iwl_trans_fw_alive(struct iwl_trans *trans, u32 scd_addr) 415 + { 416 + might_sleep(); 417 + 418 + trans->state = IWL_TRANS_FW_ALIVE; 419 + 420 + if (trans->trans_cfg->gen2) 421 + iwl_trans_pcie_gen2_fw_alive(trans); 422 + else 423 + iwl_trans_pcie_fw_alive(trans, scd_addr); 424 + } 425 + IWL_EXPORT_SYMBOL(iwl_trans_fw_alive); 426 + 427 + int iwl_trans_start_fw(struct iwl_trans *trans, const struct fw_img *fw, 428 + bool run_in_rfkill) 429 + { 430 + int ret; 431 + 432 + might_sleep(); 433 + 434 + WARN_ON_ONCE(!trans->rx_mpdu_cmd); 435 + 436 + clear_bit(STATUS_FW_ERROR, &trans->status); 437 + 438 + if (trans->trans_cfg->gen2) 439 + ret = iwl_trans_pcie_gen2_start_fw(trans, fw, run_in_rfkill); 440 + else 441 + ret = iwl_trans_pcie_start_fw(trans, fw, run_in_rfkill); 442 + 443 + if (ret == 0) 444 + trans->state = IWL_TRANS_FW_STARTED; 445 + 446 + return ret; 447 + } 448 + IWL_EXPORT_SYMBOL(iwl_trans_start_fw); 449 + 450 + void iwl_trans_stop_device(struct iwl_trans *trans) 451 + { 452 + might_sleep(); 453 + 454 + if (trans->trans_cfg->gen2) 455 + iwl_trans_pcie_gen2_stop_device(trans); 456 + else 457 + iwl_trans_pcie_stop_device(trans); 458 + 459 + trans->state = IWL_TRANS_NO_FW; 460 + } 461 + IWL_EXPORT_SYMBOL(iwl_trans_stop_device); 462 + 463 + int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb, 464 + struct iwl_device_tx_cmd *dev_cmd, int queue) 465 + { 466 + if (unlikely(test_bit(STATUS_FW_ERROR, &trans->status))) 467 + return -EIO; 468 + 469 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 470 + "bad state = %d\n", trans->state)) 471 + return -EIO; 472 + 473 + if (trans->trans_cfg->gen2) 474 + return iwl_txq_gen2_tx(trans, skb, dev_cmd, queue); 475 + 476 + return iwl_trans_pcie_tx(trans, skb, dev_cmd, queue); 477 + } 478 + IWL_EXPORT_SYMBOL(iwl_trans_tx); 479 + 480 + void iwl_trans_reclaim(struct iwl_trans *trans, int queue, int ssn, 481 + struct sk_buff_head *skbs, bool is_flush) 482 + { 483 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 484 + "bad state = %d\n", trans->state)) 485 + return; 486 + 487 + iwl_pcie_reclaim(trans, queue, ssn, skbs, is_flush); 488 + } 489 + IWL_EXPORT_SYMBOL(iwl_trans_reclaim); 490 + 491 + void iwl_trans_txq_disable(struct iwl_trans *trans, int queue, 492 + bool configure_scd) 493 + { 494 + iwl_trans_pcie_txq_disable(trans, queue, configure_scd); 495 + } 496 + IWL_EXPORT_SYMBOL(iwl_trans_txq_disable); 497 + 498 + bool iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int queue, u16 ssn, 499 + const struct iwl_trans_txq_scd_cfg *cfg, 500 + unsigned int queue_wdg_timeout) 501 + { 502 + might_sleep(); 503 + 504 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 505 + "bad state = %d\n", trans->state)) 506 + return false; 507 + 508 + return iwl_trans_pcie_txq_enable(trans, queue, ssn, 509 + cfg, queue_wdg_timeout); 510 + } 511 + IWL_EXPORT_SYMBOL(iwl_trans_txq_enable_cfg); 512 + 513 + int iwl_trans_wait_txq_empty(struct iwl_trans *trans, int queue) 514 + { 515 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 516 + "bad state = %d\n", trans->state)) 517 + return -EIO; 518 + 519 + return iwl_trans_pcie_wait_txq_empty(trans, queue); 520 + } 521 + IWL_EXPORT_SYMBOL(iwl_trans_wait_txq_empty); 522 + 523 + int iwl_trans_wait_tx_queues_empty(struct iwl_trans *trans, u32 txqs) 524 + { 525 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 526 + "bad state = %d\n", trans->state)) 527 + return -EIO; 528 + 529 + return iwl_trans_pcie_wait_txqs_empty(trans, txqs); 530 + } 531 + IWL_EXPORT_SYMBOL(iwl_trans_wait_tx_queues_empty); 532 + 533 + void iwl_trans_freeze_txq_timer(struct iwl_trans *trans, 534 + unsigned long txqs, bool freeze) 535 + { 536 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 537 + "bad state = %d\n", trans->state)) 538 + return; 539 + 540 + iwl_pcie_freeze_txq_timer(trans, txqs, freeze); 541 + } 542 + IWL_EXPORT_SYMBOL(iwl_trans_freeze_txq_timer); 543 + 544 + void iwl_trans_txq_set_shared_mode(struct iwl_trans *trans, 545 + int txq_id, bool shared_mode) 546 + { 547 + iwl_trans_pcie_txq_set_shared_mode(trans, txq_id, shared_mode); 548 + } 549 + IWL_EXPORT_SYMBOL(iwl_trans_txq_set_shared_mode); 550 + 551 + #ifdef CONFIG_IWLWIFI_DEBUGFS 552 + void iwl_trans_debugfs_cleanup(struct iwl_trans *trans) 553 + { 554 + iwl_trans_pcie_debugfs_cleanup(trans); 555 + } 556 + IWL_EXPORT_SYMBOL(iwl_trans_debugfs_cleanup); 557 + #endif 558 + 559 + void iwl_trans_set_q_ptrs(struct iwl_trans *trans, int queue, int ptr) 560 + { 561 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 562 + "bad state = %d\n", trans->state)) 563 + return; 564 + 565 + iwl_pcie_set_q_ptrs(trans, queue, ptr); 566 + } 567 + IWL_EXPORT_SYMBOL(iwl_trans_set_q_ptrs); 568 + 569 + int iwl_trans_txq_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask, 570 + u8 tid, int size, unsigned int wdg_timeout) 571 + { 572 + might_sleep(); 573 + 574 + if (WARN_ONCE(trans->state != IWL_TRANS_FW_ALIVE, 575 + "bad state = %d\n", trans->state)) 576 + return -EIO; 577 + 578 + return iwl_txq_dyn_alloc(trans, flags, sta_mask, tid, 579 + size, wdg_timeout); 580 + } 581 + IWL_EXPORT_SYMBOL(iwl_trans_txq_alloc); 582 + 583 + void iwl_trans_txq_free(struct iwl_trans *trans, int queue) 584 + { 585 + iwl_txq_dyn_free(trans, queue); 586 + } 587 + IWL_EXPORT_SYMBOL(iwl_trans_txq_free); 588 + 589 + int iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue, 590 + struct iwl_trans_rxq_dma_data *data) 591 + { 592 + return iwl_trans_pcie_rxq_dma_data(trans, queue, data); 593 + } 594 + IWL_EXPORT_SYMBOL(iwl_trans_get_rxq_dma_data); 595 + 596 + int iwl_trans_load_pnvm(struct iwl_trans *trans, 597 + const struct iwl_pnvm_image *pnvm_data, 598 + const struct iwl_ucode_capabilities *capa) 599 + { 600 + return iwl_trans_pcie_ctx_info_gen3_load_pnvm(trans, pnvm_data, capa); 601 + } 602 + IWL_EXPORT_SYMBOL(iwl_trans_load_pnvm); 603 + 604 + void iwl_trans_set_pnvm(struct iwl_trans *trans, 605 + const struct iwl_ucode_capabilities *capa) 606 + { 607 + iwl_trans_pcie_ctx_info_gen3_set_pnvm(trans, capa); 608 + } 609 + IWL_EXPORT_SYMBOL(iwl_trans_set_pnvm); 610 + 611 + int iwl_trans_load_reduce_power(struct iwl_trans *trans, 612 + const struct iwl_pnvm_image *payloads, 613 + const struct iwl_ucode_capabilities *capa) 614 + { 615 + return iwl_trans_pcie_ctx_info_gen3_load_reduce_power(trans, payloads, 616 + capa); 617 + } 618 + IWL_EXPORT_SYMBOL(iwl_trans_load_reduce_power); 619 + 620 + void iwl_trans_set_reduce_power(struct iwl_trans *trans, 621 + const struct iwl_ucode_capabilities *capa) 622 + { 623 + iwl_trans_pcie_ctx_info_gen3_set_reduce_power(trans, capa); 624 + } 625 + IWL_EXPORT_SYMBOL(iwl_trans_set_reduce_power);
+85 -564
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
··· 26 26 * DOC: Transport layer - what is it ? 27 27 * 28 28 * The transport layer is the layer that deals with the HW directly. It provides 29 - * an abstraction of the underlying HW to the upper layer. The transport layer 30 - * doesn't provide any policy, algorithm or anything of this kind, but only 31 - * mechanisms to make the HW do something. It is not completely stateless but 32 - * close to it. 33 - * We will have an implementation for each different supported bus. 29 + * the PCIe access to the underlying hardwarwe. The transport layer doesn't 30 + * provide any policy, algorithm or anything of this kind, but only mechanisms 31 + * to make the HW do something. It is not completely stateless but close to it. 34 32 */ 35 33 36 34 /** ··· 129 131 * For allocation of the command and tx queues, this establishes the overall 130 132 * size of the largest command we send to uCode, except for commands that 131 133 * aren't fully copied and use other TFD space. 134 + * 135 + * @hdr: command header 136 + * @payload: payload for the command 137 + * @hdr_wide: wide command header 138 + * @payload_wide: payload for the wide command 132 139 */ 133 140 struct iwl_device_cmd { 134 141 union { ··· 169 166 * this is just the driver's idea, the hardware supports 20 170 167 */ 171 168 #define IWL_MAX_CMD_TBS_PER_TFD 2 172 - 173 - /* We need 2 entries for the TX command and header, and another one might 174 - * be needed for potential data in the SKB's head. The remaining ones can 175 - * be used for frags. 176 - */ 177 - #define IWL_TRANS_MAX_FRAGS(trans) ((trans)->txqs.tfd.max_tbs - 3) 178 169 179 170 /** 180 171 * enum iwl_hcmd_dataflag - flag for each one of the chunks of the command ··· 278 281 #define IWL_9000_MAX_RX_HW_QUEUES 1 279 282 280 283 /** 281 - * enum iwl_wowlan_status - WoWLAN image/device status 284 + * enum iwl_d3_status - WoWLAN image/device status 282 285 * @IWL_D3_STATUS_ALIVE: firmware is still running after resume 283 286 * @IWL_D3_STATUS_RESET: device was reset while suspended 284 287 */ ··· 296 299 * @STATUS_RFKILL_HW: the actual HW state of the RF-kill switch 297 300 * @STATUS_RFKILL_OPMODE: RF-kill state reported to opmode 298 301 * @STATUS_FW_ERROR: the fw is in error state 299 - * @STATUS_TRANS_GOING_IDLE: shutting down the trans, only special commands 300 - * are sent 301 - * @STATUS_TRANS_IDLE: the trans is idle - general commands are not to be sent 302 302 * @STATUS_TRANS_DEAD: trans is dead - avoid any read/write operation 303 303 * @STATUS_SUPPRESS_CMD_ERROR_ONCE: suppress "FW error in SYNC CMD" once, 304 304 * e.g. for testing ··· 308 314 STATUS_RFKILL_HW, 309 315 STATUS_RFKILL_OPMODE, 310 316 STATUS_FW_ERROR, 311 - STATUS_TRANS_GOING_IDLE, 312 - STATUS_TRANS_IDLE, 313 317 STATUS_TRANS_DEAD, 314 318 STATUS_SUPPRESS_CMD_ERROR_ONCE, 315 319 }; ··· 471 479 } chunks[IPC_DRAM_MAP_ENTRY_NUM_MAX]; 472 480 u32 n_chunks; 473 481 u32 version; 474 - }; 475 - 476 - /** 477 - * struct iwl_trans_ops - transport specific operations 478 - * 479 - * All the handlers MUST be implemented 480 - * 481 - * @start_hw: starts the HW. From that point on, the HW can send interrupts. 482 - * May sleep. 483 - * @op_mode_leave: Turn off the HW RF kill indication if on 484 - * May sleep 485 - * @start_fw: allocates and inits all the resources for the transport 486 - * layer. Also kick a fw image. 487 - * May sleep 488 - * @fw_alive: called when the fw sends alive notification. If the fw provides 489 - * the SCD base address in SRAM, then provide it here, or 0 otherwise. 490 - * May sleep 491 - * @stop_device: stops the whole device (embedded CPU put to reset) and stops 492 - * the HW. From that point on, the HW will be stopped but will still issue 493 - * an interrupt if the HW RF kill switch is triggered. 494 - * This callback must do the right thing and not crash even if %start_hw() 495 - * was called but not &start_fw(). May sleep. 496 - * @d3_suspend: put the device into the correct mode for WoWLAN during 497 - * suspend. This is optional, if not implemented WoWLAN will not be 498 - * supported. This callback may sleep. 499 - * @d3_resume: resume the device after WoWLAN, enabling the opmode to 500 - * talk to the WoWLAN image to get its status. This is optional, if not 501 - * implemented WoWLAN will not be supported. This callback may sleep. 502 - * @send_cmd:send a host command. Must return -ERFKILL if RFkill is asserted. 503 - * If RFkill is asserted in the middle of a SYNC host command, it must 504 - * return -ERFKILL straight away. 505 - * May sleep only if CMD_ASYNC is not set 506 - * @tx: send an skb. The transport relies on the op_mode to zero the 507 - * the ieee80211_tx_info->driver_data. If the MPDU is an A-MSDU, all 508 - * the CSUM will be taken care of (TCP CSUM and IP header in case of 509 - * IPv4). If the MPDU is a single MSDU, the op_mode must compute the IP 510 - * header if it is IPv4. 511 - * Must be atomic 512 - * @reclaim: free packet until ssn. Returns a list of freed packets. 513 - * Must be atomic 514 - * @set_q_ptrs: set queue pointers internally, after D3 when HW state changed 515 - * @txq_enable: setup a queue. To setup an AC queue, use the 516 - * iwl_trans_ac_txq_enable wrapper. fw_alive must have been called before 517 - * this one. The op_mode must not configure the HCMD queue. The scheduler 518 - * configuration may be %NULL, in which case the hardware will not be 519 - * configured. If true is returned, the operation mode needs to increment 520 - * the sequence number of the packets routed to this queue because of a 521 - * hardware scheduler bug. May sleep. 522 - * @txq_disable: de-configure a Tx queue to send AMPDUs 523 - * Must be atomic 524 - * @txq_alloc: Allocate a new TX queue, may sleep. 525 - * @txq_free: Free a previously allocated TX queue. 526 - * @txq_set_shared_mode: change Tx queue shared/unshared marking 527 - * @wait_tx_queues_empty: wait until tx queues are empty. May sleep. 528 - * @wait_txq_empty: wait until specific tx queue is empty. May sleep. 529 - * @freeze_txq_timer: prevents the timer of the queue from firing until the 530 - * queue is set to awake. Must be atomic. 531 - * @write8: write a u8 to a register at offset ofs from the BAR 532 - * @write32: write a u32 to a register at offset ofs from the BAR 533 - * @read32: read a u32 register at offset ofs from the BAR 534 - * @read_prph: read a DWORD from a periphery register 535 - * @write_prph: write a DWORD to a periphery register 536 - * @read_mem: read device's SRAM in DWORD 537 - * @write_mem: write device's SRAM in DWORD. If %buf is %NULL, then the memory 538 - * will be zeroed. 539 - * @read_config32: read a u32 value from the device's config space at 540 - * the given offset. 541 - * @configure: configure parameters required by the transport layer from 542 - * the op_mode. May be called several times before start_fw, can't be 543 - * called after that. 544 - * @set_pmi: set the power pmi state 545 - * @sw_reset: trigger software reset of the NIC 546 - * @grab_nic_access: wake the NIC to be able to access non-HBUS regs. 547 - * Sleeping is not allowed between grab_nic_access and 548 - * release_nic_access. 549 - * @release_nic_access: let the NIC go to sleep. The "flags" parameter 550 - * must be the same one that was sent before to the grab_nic_access. 551 - * @set_bits_mask: set SRAM register according to value and mask. 552 - * @dump_data: return a vmalloc'ed buffer with debug data, maybe containing last 553 - * TX'ed commands and similar. The buffer will be vfree'd by the caller. 554 - * Note that the transport must fill in the proper file headers. 555 - * @debugfs_cleanup: used in the driver unload flow to make a proper cleanup 556 - * of the trans debugfs 557 - * @sync_nmi: trigger a firmware NMI and wait for it to complete 558 - * @load_pnvm: save the pnvm data in DRAM 559 - * @set_pnvm: set the pnvm data in the prph scratch buffer, inside the 560 - * context info. 561 - * @load_reduce_power: copy reduce power table to the corresponding DRAM memory 562 - * @set_reduce_power: set reduce power table addresses in the sratch buffer 563 - * @interrupts: disable/enable interrupts to transport 564 - * @imr_dma_data: set up IMR DMA 565 - * @rxq_dma_data: retrieve RX queue DMA data, see @struct iwl_trans_rxq_dma_data 566 - */ 567 - struct iwl_trans_ops { 568 - 569 - int (*start_hw)(struct iwl_trans *iwl_trans); 570 - void (*op_mode_leave)(struct iwl_trans *iwl_trans); 571 - int (*start_fw)(struct iwl_trans *trans, const struct fw_img *fw, 572 - bool run_in_rfkill); 573 - void (*fw_alive)(struct iwl_trans *trans, u32 scd_addr); 574 - void (*stop_device)(struct iwl_trans *trans); 575 - 576 - int (*d3_suspend)(struct iwl_trans *trans, bool test, bool reset); 577 - int (*d3_resume)(struct iwl_trans *trans, enum iwl_d3_status *status, 578 - bool test, bool reset); 579 - 580 - int (*send_cmd)(struct iwl_trans *trans, struct iwl_host_cmd *cmd); 581 - 582 - int (*tx)(struct iwl_trans *trans, struct sk_buff *skb, 583 - struct iwl_device_tx_cmd *dev_cmd, int queue); 584 - void (*reclaim)(struct iwl_trans *trans, int queue, int ssn, 585 - struct sk_buff_head *skbs, bool is_flush); 586 - 587 - void (*set_q_ptrs)(struct iwl_trans *trans, int queue, int ptr); 588 - 589 - bool (*txq_enable)(struct iwl_trans *trans, int queue, u16 ssn, 590 - const struct iwl_trans_txq_scd_cfg *cfg, 591 - unsigned int queue_wdg_timeout); 592 - void (*txq_disable)(struct iwl_trans *trans, int queue, 593 - bool configure_scd); 594 - /* 22000 functions */ 595 - int (*txq_alloc)(struct iwl_trans *trans, u32 flags, 596 - u32 sta_mask, u8 tid, 597 - int size, unsigned int queue_wdg_timeout); 598 - void (*txq_free)(struct iwl_trans *trans, int queue); 599 - int (*rxq_dma_data)(struct iwl_trans *trans, int queue, 600 - struct iwl_trans_rxq_dma_data *data); 601 - 602 - void (*txq_set_shared_mode)(struct iwl_trans *trans, u32 txq_id, 603 - bool shared); 604 - 605 - int (*wait_tx_queues_empty)(struct iwl_trans *trans, u32 txq_bm); 606 - int (*wait_txq_empty)(struct iwl_trans *trans, int queue); 607 - void (*freeze_txq_timer)(struct iwl_trans *trans, unsigned long txqs, 608 - bool freeze); 609 - 610 - void (*write8)(struct iwl_trans *trans, u32 ofs, u8 val); 611 - void (*write32)(struct iwl_trans *trans, u32 ofs, u32 val); 612 - u32 (*read32)(struct iwl_trans *trans, u32 ofs); 613 - u32 (*read_prph)(struct iwl_trans *trans, u32 ofs); 614 - void (*write_prph)(struct iwl_trans *trans, u32 ofs, u32 val); 615 - int (*read_mem)(struct iwl_trans *trans, u32 addr, 616 - void *buf, int dwords); 617 - int (*write_mem)(struct iwl_trans *trans, u32 addr, 618 - const void *buf, int dwords); 619 - int (*read_config32)(struct iwl_trans *trans, u32 ofs, u32 *val); 620 - void (*configure)(struct iwl_trans *trans, 621 - const struct iwl_trans_config *trans_cfg); 622 - void (*set_pmi)(struct iwl_trans *trans, bool state); 623 - int (*sw_reset)(struct iwl_trans *trans, bool retake_ownership); 624 - bool (*grab_nic_access)(struct iwl_trans *trans); 625 - void (*release_nic_access)(struct iwl_trans *trans); 626 - void (*set_bits_mask)(struct iwl_trans *trans, u32 reg, u32 mask, 627 - u32 value); 628 - 629 - struct iwl_trans_dump_data *(*dump_data)(struct iwl_trans *trans, 630 - u32 dump_mask, 631 - const struct iwl_dump_sanitize_ops *sanitize_ops, 632 - void *sanitize_ctx); 633 - void (*debugfs_cleanup)(struct iwl_trans *trans); 634 - void (*sync_nmi)(struct iwl_trans *trans); 635 - int (*load_pnvm)(struct iwl_trans *trans, 636 - const struct iwl_pnvm_image *pnvm_payloads, 637 - const struct iwl_ucode_capabilities *capa); 638 - void (*set_pnvm)(struct iwl_trans *trans, 639 - const struct iwl_ucode_capabilities *capa); 640 - int (*load_reduce_power)(struct iwl_trans *trans, 641 - const struct iwl_pnvm_image *payloads, 642 - const struct iwl_ucode_capabilities *capa); 643 - void (*set_reduce_power)(struct iwl_trans *trans, 644 - const struct iwl_ucode_capabilities *capa); 645 - 646 - void (*interrupts)(struct iwl_trans *trans, bool enable); 647 - int (*imr_dma_data)(struct iwl_trans *trans, 648 - u32 dst_addr, u64 src_addr, 649 - u32 byte_cnt); 650 - 651 482 }; 652 483 653 484 /** ··· 814 999 }; 815 1000 816 1001 /** 817 - * struct iwl_trans_txqs - transport tx queues data 818 - * 819 - * @bc_table_dword: true if the BC table expects DWORD (as opposed to bytes) 820 - * @page_offs: offset from skb->cb to mac header page pointer 821 - * @dev_cmd_offs: offset from skb->cb to iwl_device_tx_cmd pointer 822 - * @queue_used: bit mask of used queues 823 - * @queue_stopped: bit mask of stopped queues 824 - * @txq: array of TXQ data structures representing the TXQs 825 - * @scd_bc_tbls: gen1 pointer to the byte count table of the scheduler 826 - * @queue_alloc_cmd_ver: queue allocation command version 827 - * @bc_pool: bytecount DMA allocations pool 828 - * @bc_tbl_size: bytecount table size 829 - * @tso_hdr_page: page allocated (per CPU) for A-MSDU headers when doing TSO 830 - * (and similar usage) 831 - * @tfd: TFD data 832 - * @tfd.max_tbs: max number of buffers per TFD 833 - * @tfd.size: TFD size 834 - * @tfd.addr_size: TFD/TB address size 835 - */ 836 - struct iwl_trans_txqs { 837 - unsigned long queue_used[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)]; 838 - unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)]; 839 - struct iwl_txq *txq[IWL_MAX_TVQM_QUEUES]; 840 - struct dma_pool *bc_pool; 841 - size_t bc_tbl_size; 842 - bool bc_table_dword; 843 - u8 page_offs; 844 - u8 dev_cmd_offs; 845 - struct iwl_tso_hdr_page __percpu *tso_hdr_page; 846 - 847 - struct { 848 - u8 fifo; 849 - u8 q_id; 850 - unsigned int wdg_timeout; 851 - } cmd; 852 - 853 - struct { 854 - u8 max_tbs; 855 - u16 size; 856 - u8 addr_size; 857 - } tfd; 858 - 859 - struct iwl_dma_ptr scd_bc_tbls; 860 - 861 - u8 queue_alloc_cmd_ver; 862 - }; 863 - 864 - /** 865 1002 * struct iwl_trans - transport common data 866 1003 * 867 1004 * @csme_own: true if we couldn't get ownership on the device 868 - * @ops: pointer to iwl_trans_ops 869 1005 * @op_mode: pointer to the op_mode 870 1006 * @trans_cfg: the trans-specific configuration part 871 1007 * @cfg: pointer to the configuration ··· 865 1099 * This mode is set dynamically, depending on the WoWLAN values 866 1100 * configured from the userspace at runtime. 867 1101 * @name: the device name 868 - * @txqs: transport tx queues data. 869 1102 * @mbx_addr_0_step: step address data 0 870 1103 * @mbx_addr_1_step: step address data 1 871 1104 * @pcie_link_speed: current PCIe link speed (%PCI_EXP_LNKSTA_CLS_*), ··· 877 1112 */ 878 1113 struct iwl_trans { 879 1114 bool csme_own; 880 - const struct iwl_trans_ops *ops; 881 1115 struct iwl_op_mode *op_mode; 882 1116 const struct iwl_cfg_trans_params *trans_cfg; 883 1117 const struct iwl_cfg *cfg; ··· 933 1169 enum iwl_plat_pm_mode system_pm_mode; 934 1170 935 1171 const char *name; 936 - struct iwl_trans_txqs txqs; 937 1172 u32 mbx_addr_0_step; 938 1173 u32 mbx_addr_1_step; 939 1174 ··· 948 1185 const char *iwl_get_cmd_string(struct iwl_trans *trans, u32 id); 949 1186 int iwl_cmd_groups_verify_sorted(const struct iwl_trans_config *trans); 950 1187 951 - static inline void iwl_trans_configure(struct iwl_trans *trans, 952 - const struct iwl_trans_config *trans_cfg) 953 - { 954 - trans->op_mode = trans_cfg->op_mode; 1188 + void iwl_trans_configure(struct iwl_trans *trans, 1189 + const struct iwl_trans_config *trans_cfg); 955 1190 956 - trans->ops->configure(trans, trans_cfg); 957 - WARN_ON(iwl_cmd_groups_verify_sorted(trans_cfg)); 958 - } 1191 + int iwl_trans_start_hw(struct iwl_trans *trans); 959 1192 960 - static inline int iwl_trans_start_hw(struct iwl_trans *trans) 961 - { 962 - might_sleep(); 1193 + void iwl_trans_op_mode_leave(struct iwl_trans *trans); 963 1194 964 - return trans->ops->start_hw(trans); 965 - } 1195 + void iwl_trans_fw_alive(struct iwl_trans *trans, u32 scd_addr); 966 1196 967 - static inline void iwl_trans_op_mode_leave(struct iwl_trans *trans) 968 - { 969 - might_sleep(); 1197 + int iwl_trans_start_fw(struct iwl_trans *trans, const struct fw_img *fw, 1198 + bool run_in_rfkill); 970 1199 971 - if (trans->ops->op_mode_leave) 972 - trans->ops->op_mode_leave(trans); 1200 + void iwl_trans_stop_device(struct iwl_trans *trans); 973 1201 974 - trans->op_mode = NULL; 1202 + int iwl_trans_d3_suspend(struct iwl_trans *trans, bool test, bool reset); 975 1203 976 - trans->state = IWL_TRANS_NO_FW; 977 - } 1204 + int iwl_trans_d3_resume(struct iwl_trans *trans, enum iwl_d3_status *status, 1205 + bool test, bool reset); 978 1206 979 - static inline void iwl_trans_fw_alive(struct iwl_trans *trans, u32 scd_addr) 980 - { 981 - might_sleep(); 982 - 983 - trans->state = IWL_TRANS_FW_ALIVE; 984 - 985 - trans->ops->fw_alive(trans, scd_addr); 986 - } 987 - 988 - static inline int iwl_trans_start_fw(struct iwl_trans *trans, 989 - const struct fw_img *fw, 990 - bool run_in_rfkill) 991 - { 992 - int ret; 993 - 994 - might_sleep(); 995 - 996 - WARN_ON_ONCE(!trans->rx_mpdu_cmd); 997 - 998 - clear_bit(STATUS_FW_ERROR, &trans->status); 999 - ret = trans->ops->start_fw(trans, fw, run_in_rfkill); 1000 - if (ret == 0) 1001 - trans->state = IWL_TRANS_FW_STARTED; 1002 - 1003 - return ret; 1004 - } 1005 - 1006 - static inline void iwl_trans_stop_device(struct iwl_trans *trans) 1007 - { 1008 - might_sleep(); 1009 - 1010 - trans->ops->stop_device(trans); 1011 - 1012 - trans->state = IWL_TRANS_NO_FW; 1013 - } 1014 - 1015 - static inline int iwl_trans_d3_suspend(struct iwl_trans *trans, bool test, 1016 - bool reset) 1017 - { 1018 - might_sleep(); 1019 - if (!trans->ops->d3_suspend) 1020 - return -EOPNOTSUPP; 1021 - 1022 - return trans->ops->d3_suspend(trans, test, reset); 1023 - } 1024 - 1025 - static inline int iwl_trans_d3_resume(struct iwl_trans *trans, 1026 - enum iwl_d3_status *status, 1027 - bool test, bool reset) 1028 - { 1029 - might_sleep(); 1030 - if (!trans->ops->d3_resume) 1031 - return -EOPNOTSUPP; 1032 - 1033 - return trans->ops->d3_resume(trans, status, test, reset); 1034 - } 1035 - 1036 - static inline struct iwl_trans_dump_data * 1207 + struct iwl_trans_dump_data * 1037 1208 iwl_trans_dump_data(struct iwl_trans *trans, u32 dump_mask, 1038 1209 const struct iwl_dump_sanitize_ops *sanitize_ops, 1039 - void *sanitize_ctx) 1040 - { 1041 - if (!trans->ops->dump_data) 1042 - return NULL; 1043 - return trans->ops->dump_data(trans, dump_mask, 1044 - sanitize_ops, sanitize_ctx); 1045 - } 1210 + void *sanitize_ctx); 1046 1211 1047 1212 static inline struct iwl_device_tx_cmd * 1048 1213 iwl_trans_alloc_tx_cmd(struct iwl_trans *trans) ··· 986 1295 kmem_cache_free(trans->dev_cmd_pool, dev_cmd); 987 1296 } 988 1297 989 - static inline int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb, 990 - struct iwl_device_tx_cmd *dev_cmd, int queue) 991 - { 992 - if (unlikely(test_bit(STATUS_FW_ERROR, &trans->status))) 993 - return -EIO; 1298 + int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb, 1299 + struct iwl_device_tx_cmd *dev_cmd, int queue); 994 1300 995 - if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) { 996 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 997 - return -EIO; 998 - } 1301 + void iwl_trans_reclaim(struct iwl_trans *trans, int queue, int ssn, 1302 + struct sk_buff_head *skbs, bool is_flush); 999 1303 1000 - return trans->ops->tx(trans, skb, dev_cmd, queue); 1001 - } 1304 + void iwl_trans_set_q_ptrs(struct iwl_trans *trans, int queue, int ptr); 1002 1305 1003 - static inline void iwl_trans_reclaim(struct iwl_trans *trans, int queue, 1004 - int ssn, struct sk_buff_head *skbs, 1005 - bool is_flush) 1006 - { 1007 - if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) { 1008 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 1009 - return; 1010 - } 1306 + void iwl_trans_txq_disable(struct iwl_trans *trans, int queue, 1307 + bool configure_scd); 1011 1308 1012 - trans->ops->reclaim(trans, queue, ssn, skbs, is_flush); 1013 - } 1309 + bool iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int queue, u16 ssn, 1310 + const struct iwl_trans_txq_scd_cfg *cfg, 1311 + unsigned int queue_wdg_timeout); 1014 1312 1015 - static inline void iwl_trans_set_q_ptrs(struct iwl_trans *trans, int queue, 1016 - int ptr) 1017 - { 1018 - if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) { 1019 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 1020 - return; 1021 - } 1313 + int iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue, 1314 + struct iwl_trans_rxq_dma_data *data); 1022 1315 1023 - trans->ops->set_q_ptrs(trans, queue, ptr); 1024 - } 1316 + void iwl_trans_txq_free(struct iwl_trans *trans, int queue); 1025 1317 1026 - static inline void iwl_trans_txq_disable(struct iwl_trans *trans, int queue, 1027 - bool configure_scd) 1028 - { 1029 - trans->ops->txq_disable(trans, queue, configure_scd); 1030 - } 1318 + int iwl_trans_txq_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask, 1319 + u8 tid, int size, unsigned int wdg_timeout); 1031 1320 1032 - static inline bool 1033 - iwl_trans_txq_enable_cfg(struct iwl_trans *trans, int queue, u16 ssn, 1034 - const struct iwl_trans_txq_scd_cfg *cfg, 1035 - unsigned int queue_wdg_timeout) 1036 - { 1037 - might_sleep(); 1038 - 1039 - if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) { 1040 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 1041 - return false; 1042 - } 1043 - 1044 - return trans->ops->txq_enable(trans, queue, ssn, 1045 - cfg, queue_wdg_timeout); 1046 - } 1047 - 1048 - static inline int 1049 - iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue, 1050 - struct iwl_trans_rxq_dma_data *data) 1051 - { 1052 - if (WARN_ON_ONCE(!trans->ops->rxq_dma_data)) 1053 - return -EOPNOTSUPP; 1054 - 1055 - return trans->ops->rxq_dma_data(trans, queue, data); 1056 - } 1057 - 1058 - static inline void 1059 - iwl_trans_txq_free(struct iwl_trans *trans, int queue) 1060 - { 1061 - if (WARN_ON_ONCE(!trans->ops->txq_free)) 1062 - return; 1063 - 1064 - trans->ops->txq_free(trans, queue); 1065 - } 1066 - 1067 - static inline int 1068 - iwl_trans_txq_alloc(struct iwl_trans *trans, 1069 - u32 flags, u32 sta_mask, u8 tid, 1070 - int size, unsigned int wdg_timeout) 1071 - { 1072 - might_sleep(); 1073 - 1074 - if (WARN_ON_ONCE(!trans->ops->txq_alloc)) 1075 - return -EOPNOTSUPP; 1076 - 1077 - if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) { 1078 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 1079 - return -EIO; 1080 - } 1081 - 1082 - return trans->ops->txq_alloc(trans, flags, sta_mask, tid, 1083 - size, wdg_timeout); 1084 - } 1085 - 1086 - static inline void iwl_trans_txq_set_shared_mode(struct iwl_trans *trans, 1087 - int queue, bool shared_mode) 1088 - { 1089 - if (trans->ops->txq_set_shared_mode) 1090 - trans->ops->txq_set_shared_mode(trans, queue, shared_mode); 1091 - } 1321 + void iwl_trans_txq_set_shared_mode(struct iwl_trans *trans, 1322 + int txq_id, bool shared_mode); 1092 1323 1093 1324 static inline void iwl_trans_txq_enable(struct iwl_trans *trans, int queue, 1094 1325 int fifo, int sta_id, int tid, ··· 1043 1430 iwl_trans_txq_enable_cfg(trans, queue, 0, &cfg, queue_wdg_timeout); 1044 1431 } 1045 1432 1046 - static inline void iwl_trans_freeze_txq_timer(struct iwl_trans *trans, 1047 - unsigned long txqs, 1048 - bool freeze) 1049 - { 1050 - if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) { 1051 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 1052 - return; 1053 - } 1433 + void iwl_trans_freeze_txq_timer(struct iwl_trans *trans, 1434 + unsigned long txqs, bool freeze); 1054 1435 1055 - if (trans->ops->freeze_txq_timer) 1056 - trans->ops->freeze_txq_timer(trans, txqs, freeze); 1057 - } 1436 + int iwl_trans_wait_tx_queues_empty(struct iwl_trans *trans, u32 txqs); 1058 1437 1059 - static inline int iwl_trans_wait_tx_queues_empty(struct iwl_trans *trans, 1060 - u32 txqs) 1061 - { 1062 - if (WARN_ON_ONCE(!trans->ops->wait_tx_queues_empty)) 1063 - return -EOPNOTSUPP; 1438 + int iwl_trans_wait_txq_empty(struct iwl_trans *trans, int queue); 1064 1439 1065 - /* No need to wait if the firmware is not alive */ 1066 - if (trans->state != IWL_TRANS_FW_ALIVE) { 1067 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 1068 - return -EIO; 1069 - } 1440 + void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val); 1070 1441 1071 - return trans->ops->wait_tx_queues_empty(trans, txqs); 1072 - } 1442 + void iwl_trans_write32(struct iwl_trans *trans, u32 ofs, u32 val); 1073 1443 1074 - static inline int iwl_trans_wait_txq_empty(struct iwl_trans *trans, int queue) 1075 - { 1076 - if (WARN_ON_ONCE(!trans->ops->wait_txq_empty)) 1077 - return -EOPNOTSUPP; 1444 + u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs); 1078 1445 1079 - if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) { 1080 - IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state); 1081 - return -EIO; 1082 - } 1446 + u32 iwl_trans_read_prph(struct iwl_trans *trans, u32 ofs); 1083 1447 1084 - return trans->ops->wait_txq_empty(trans, queue); 1085 - } 1448 + void iwl_trans_write_prph(struct iwl_trans *trans, u32 ofs, u32 val); 1086 1449 1087 - static inline void iwl_trans_write8(struct iwl_trans *trans, u32 ofs, u8 val) 1088 - { 1089 - trans->ops->write8(trans, ofs, val); 1090 - } 1450 + int iwl_trans_read_mem(struct iwl_trans *trans, u32 addr, 1451 + void *buf, int dwords); 1091 1452 1092 - static inline void iwl_trans_write32(struct iwl_trans *trans, u32 ofs, u32 val) 1093 - { 1094 - trans->ops->write32(trans, ofs, val); 1095 - } 1453 + int iwl_trans_read_config32(struct iwl_trans *trans, u32 ofs, 1454 + u32 *val); 1096 1455 1097 - static inline u32 iwl_trans_read32(struct iwl_trans *trans, u32 ofs) 1098 - { 1099 - return trans->ops->read32(trans, ofs); 1100 - } 1101 - 1102 - static inline u32 iwl_trans_read_prph(struct iwl_trans *trans, u32 ofs) 1103 - { 1104 - return trans->ops->read_prph(trans, ofs); 1105 - } 1106 - 1107 - static inline void iwl_trans_write_prph(struct iwl_trans *trans, u32 ofs, 1108 - u32 val) 1109 - { 1110 - return trans->ops->write_prph(trans, ofs, val); 1111 - } 1112 - 1113 - static inline int iwl_trans_read_mem(struct iwl_trans *trans, u32 addr, 1114 - void *buf, int dwords) 1115 - { 1116 - return trans->ops->read_mem(trans, addr, buf, dwords); 1117 - } 1456 + #ifdef CONFIG_IWLWIFI_DEBUGFS 1457 + void iwl_trans_debugfs_cleanup(struct iwl_trans *trans); 1458 + #endif 1118 1459 1119 1460 #define iwl_trans_read_mem_bytes(trans, addr, buf, bufsize) \ 1120 1461 do { \ ··· 1077 1510 iwl_trans_read_mem(trans, addr, buf, (bufsize) / sizeof(u32));\ 1078 1511 } while (0) 1079 1512 1080 - static inline int iwl_trans_write_imr_mem(struct iwl_trans *trans, 1081 - u32 dst_addr, u64 src_addr, 1082 - u32 byte_cnt) 1083 - { 1084 - if (trans->ops->imr_dma_data) 1085 - return trans->ops->imr_dma_data(trans, dst_addr, src_addr, byte_cnt); 1086 - return 0; 1087 - } 1513 + int iwl_trans_write_imr_mem(struct iwl_trans *trans, u32 dst_addr, 1514 + u64 src_addr, u32 byte_cnt); 1088 1515 1089 1516 static inline u32 iwl_trans_read_mem32(struct iwl_trans *trans, u32 addr) 1090 1517 { ··· 1090 1529 return value; 1091 1530 } 1092 1531 1093 - static inline int iwl_trans_write_mem(struct iwl_trans *trans, u32 addr, 1094 - const void *buf, int dwords) 1095 - { 1096 - return trans->ops->write_mem(trans, addr, buf, dwords); 1097 - } 1532 + int iwl_trans_write_mem(struct iwl_trans *trans, u32 addr, 1533 + const void *buf, int dwords); 1098 1534 1099 1535 static inline u32 iwl_trans_write_mem32(struct iwl_trans *trans, u32 addr, 1100 1536 u32 val) ··· 1099 1541 return iwl_trans_write_mem(trans, addr, &val, 1); 1100 1542 } 1101 1543 1102 - static inline void iwl_trans_set_pmi(struct iwl_trans *trans, bool state) 1103 - { 1104 - if (trans->ops->set_pmi) 1105 - trans->ops->set_pmi(trans, state); 1106 - } 1544 + void iwl_trans_set_pmi(struct iwl_trans *trans, bool state); 1107 1545 1108 - static inline int iwl_trans_sw_reset(struct iwl_trans *trans, 1109 - bool retake_ownership) 1110 - { 1111 - if (trans->ops->sw_reset) 1112 - return trans->ops->sw_reset(trans, retake_ownership); 1113 - return 0; 1114 - } 1546 + int iwl_trans_sw_reset(struct iwl_trans *trans, bool retake_ownership); 1115 1547 1116 - static inline void 1117 - iwl_trans_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value) 1118 - { 1119 - trans->ops->set_bits_mask(trans, reg, mask, value); 1120 - } 1548 + void iwl_trans_set_bits_mask(struct iwl_trans *trans, u32 reg, 1549 + u32 mask, u32 value); 1550 + 1551 + bool _iwl_trans_grab_nic_access(struct iwl_trans *trans); 1121 1552 1122 1553 #define iwl_trans_grab_nic_access(trans) \ 1123 1554 __cond_lock(nic_access, \ 1124 - likely((trans)->ops->grab_nic_access(trans))) 1555 + likely(_iwl_trans_grab_nic_access(trans))) 1125 1556 1126 - static inline void __releases(nic_access) 1127 - iwl_trans_release_nic_access(struct iwl_trans *trans) 1128 - { 1129 - trans->ops->release_nic_access(trans); 1130 - __release(nic_access); 1131 - } 1557 + void __releases(nic_access) 1558 + iwl_trans_release_nic_access(struct iwl_trans *trans); 1132 1559 1133 1560 static inline void iwl_trans_fw_error(struct iwl_trans *trans, bool sync) 1134 1561 { ··· 1132 1589 return trans->state == IWL_TRANS_FW_ALIVE; 1133 1590 } 1134 1591 1135 - static inline void iwl_trans_sync_nmi(struct iwl_trans *trans) 1136 - { 1137 - if (trans->ops->sync_nmi) 1138 - trans->ops->sync_nmi(trans); 1139 - } 1592 + void iwl_trans_sync_nmi(struct iwl_trans *trans); 1140 1593 1141 1594 void iwl_trans_sync_nmi_with_addr(struct iwl_trans *trans, u32 inta_addr, 1142 1595 u32 sw_err_bit); 1143 1596 1144 - static inline int iwl_trans_load_pnvm(struct iwl_trans *trans, 1145 - const struct iwl_pnvm_image *pnvm_data, 1146 - const struct iwl_ucode_capabilities *capa) 1147 - { 1148 - return trans->ops->load_pnvm(trans, pnvm_data, capa); 1149 - } 1597 + int iwl_trans_load_pnvm(struct iwl_trans *trans, 1598 + const struct iwl_pnvm_image *pnvm_data, 1599 + const struct iwl_ucode_capabilities *capa); 1150 1600 1151 - static inline void iwl_trans_set_pnvm(struct iwl_trans *trans, 1152 - const struct iwl_ucode_capabilities *capa) 1153 - { 1154 - if (trans->ops->set_pnvm) 1155 - trans->ops->set_pnvm(trans, capa); 1156 - } 1601 + void iwl_trans_set_pnvm(struct iwl_trans *trans, 1602 + const struct iwl_ucode_capabilities *capa); 1157 1603 1158 - static inline int iwl_trans_load_reduce_power 1159 - (struct iwl_trans *trans, 1160 - const struct iwl_pnvm_image *payloads, 1161 - const struct iwl_ucode_capabilities *capa) 1162 - { 1163 - return trans->ops->load_reduce_power(trans, payloads, capa); 1164 - } 1604 + int iwl_trans_load_reduce_power(struct iwl_trans *trans, 1605 + const struct iwl_pnvm_image *payloads, 1606 + const struct iwl_ucode_capabilities *capa); 1165 1607 1166 - static inline void 1167 - iwl_trans_set_reduce_power(struct iwl_trans *trans, 1168 - const struct iwl_ucode_capabilities *capa) 1169 - { 1170 - if (trans->ops->set_reduce_power) 1171 - trans->ops->set_reduce_power(trans, capa); 1172 - } 1608 + void iwl_trans_set_reduce_power(struct iwl_trans *trans, 1609 + const struct iwl_ucode_capabilities *capa); 1173 1610 1174 1611 static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans) 1175 1612 { ··· 1157 1634 trans->dbg.external_ini_cfg != IWL_INI_CFG_STATE_NOT_LOADED; 1158 1635 } 1159 1636 1160 - static inline void iwl_trans_interrupts(struct iwl_trans *trans, bool enable) 1161 - { 1162 - if (trans->ops->interrupts) 1163 - trans->ops->interrupts(trans, enable); 1164 - } 1637 + void iwl_trans_interrupts(struct iwl_trans *trans, bool enable); 1165 1638 1166 1639 /***************************************************** 1167 1640 * transport helper functions 1168 1641 *****************************************************/ 1169 1642 struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, 1170 1643 struct device *dev, 1171 - const struct iwl_trans_ops *ops, 1172 1644 const struct iwl_cfg_trans_params *cfg_trans); 1173 1645 int iwl_trans_init(struct iwl_trans *trans); 1174 1646 void iwl_trans_free(struct iwl_trans *trans); ··· 1174 1656 } 1175 1657 1176 1658 /***************************************************** 1177 - * driver (transport) register/unregister functions 1178 - ******************************************************/ 1659 + * PCIe handling 1660 + *****************************************************/ 1179 1661 int __must_check iwl_pci_register_driver(void); 1180 1662 void iwl_pci_unregister_driver(void); 1181 1663 void iwl_trans_pcie_remove(struct iwl_trans *trans, bool rescan); 1664 + 1665 + int iwl_trans_pcie_send_hcmd(struct iwl_trans *trans, 1666 + struct iwl_host_cmd *cmd); 1182 1667 1183 1668 #endif /* __iwl_trans_h__ */
+5 -2
drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h
··· 456 456 /** 457 457 * iwl_mei_pldr_req() - must be called before loading the fw 458 458 * 459 - * Return: 0 if the PLDR flow was successful and the fw can be loaded, negative 460 - * value otherwise. 459 + * Requests from the ME that it releases its potential bus access to 460 + * the WiFi NIC so that the device can safely undergo product reset. 461 + * 462 + * Return: 0 if the request was successful and the device can be 463 + * reset, a negative error value otherwise 461 464 */ 462 465 int iwl_mei_pldr_req(void); 463 466
-1
drivers/net/wireless/intel/iwlwifi/mvm/constants.h
··· 56 56 #define IWL_MVM_RS_80_20_FAR_RANGE_TWEAK 1 57 57 #define IWL_MVM_TOF_IS_RESPONDER 0 58 58 #define IWL_MVM_HW_CSUM_DISABLE 0 59 - #define IWL_MVM_PARSE_NVM 0 60 59 #define IWL_MVM_ADWELL_ENABLE 1 61 60 #define IWL_MVM_ADWELL_MAX_BUDGET 0 62 61 #define IWL_MVM_TCM_LOAD_MEDIUM_THRESH 10 /* percentage */
+80 -5
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
··· 2493 2493 return; 2494 2494 } 2495 2495 2496 + if (mvm->fast_resume) 2497 + return; 2498 + 2496 2499 iwl_mvm_convert_key_counters_v5(status, &data->gtk[0].sc); 2497 2500 iwl_mvm_convert_gtk_v3(status, data->gtk); 2498 2501 iwl_mvm_convert_igtk(status, &data->igtk[0]); ··· 3052 3049 if (iwl_mvm_rt_status(mvm->trans, 3053 3050 mvm->trans->dbg.lmac_error_event_table[0], 3054 3051 &err_id)) { 3055 - if (err_id == RF_KILL_INDICATOR_FOR_WOWLAN) { 3052 + if (err_id == RF_KILL_INDICATOR_FOR_WOWLAN && vif) { 3056 3053 struct cfg80211_wowlan_wakeup wakeup = { 3057 3054 .rfkill_release = true, 3058 3055 }; ··· 3369 3366 return ret; 3370 3367 } 3371 3368 3372 - #define IWL_MVM_D3_NOTIF_TIMEOUT (HZ / 5) 3369 + #define IWL_MVM_D3_NOTIF_TIMEOUT (HZ / 3) 3373 3370 3374 3371 static int iwl_mvm_d3_notif_wait(struct iwl_mvm *mvm, 3375 3372 struct iwl_d3_data *d3_data) ··· 3380 3377 WIDE_ID(SCAN_GROUP, OFFLOAD_MATCH_INFO_NOTIF), 3381 3378 WIDE_ID(PROT_OFFLOAD_GROUP, D3_END_NOTIFICATION) 3382 3379 }; 3380 + static const u16 d3_fast_resume_notif[] = { 3381 + WIDE_ID(PROT_OFFLOAD_GROUP, D3_END_NOTIFICATION) 3382 + }; 3383 3383 struct iwl_notification_wait wait_d3_notif; 3384 3384 int ret; 3385 3385 3386 - iwl_init_notification_wait(&mvm->notif_wait, &wait_d3_notif, 3387 - d3_resume_notif, ARRAY_SIZE(d3_resume_notif), 3388 - iwl_mvm_wait_d3_notif, d3_data); 3386 + if (mvm->fast_resume) 3387 + iwl_init_notification_wait(&mvm->notif_wait, &wait_d3_notif, 3388 + d3_fast_resume_notif, 3389 + ARRAY_SIZE(d3_fast_resume_notif), 3390 + iwl_mvm_wait_d3_notif, d3_data); 3391 + else 3392 + iwl_init_notification_wait(&mvm->notif_wait, &wait_d3_notif, 3393 + d3_resume_notif, 3394 + ARRAY_SIZE(d3_resume_notif), 3395 + iwl_mvm_wait_d3_notif, d3_data); 3389 3396 3390 3397 ret = iwl_mvm_resume_firmware(mvm, d3_data->test); 3391 3398 if (ret) { ··· 3578 3565 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 3579 3566 3580 3567 device_set_wakeup_enable(mvm->trans->dev, enabled); 3568 + } 3569 + 3570 + void iwl_mvm_fast_suspend(struct iwl_mvm *mvm) 3571 + { 3572 + struct iwl_d3_manager_config d3_cfg_cmd_data = {}; 3573 + int ret; 3574 + 3575 + lockdep_assert_held(&mvm->mutex); 3576 + 3577 + IWL_DEBUG_WOWLAN(mvm, "Starting fast suspend flow\n"); 3578 + 3579 + mvm->fast_resume = true; 3580 + set_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); 3581 + 3582 + WARN_ON(iwl_mvm_power_update_device(mvm)); 3583 + mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_D3; 3584 + ret = iwl_mvm_send_cmd_pdu(mvm, D3_CONFIG_CMD, CMD_SEND_IN_D3, 3585 + sizeof(d3_cfg_cmd_data), &d3_cfg_cmd_data); 3586 + if (ret) 3587 + IWL_ERR(mvm, 3588 + "fast suspend: couldn't send D3_CONFIG_CMD %d\n", ret); 3589 + 3590 + WARN_ON(iwl_mvm_power_update_mac(mvm)); 3591 + 3592 + ret = iwl_trans_d3_suspend(mvm->trans, false, false); 3593 + if (ret) 3594 + IWL_ERR(mvm, "fast suspend: trans_d3_suspend failed %d\n", ret); 3595 + } 3596 + 3597 + int iwl_mvm_fast_resume(struct iwl_mvm *mvm) 3598 + { 3599 + struct iwl_d3_data d3_data = { 3600 + .notif_expected = 3601 + IWL_D3_NOTIF_D3_END_NOTIF, 3602 + }; 3603 + int ret; 3604 + 3605 + lockdep_assert_held(&mvm->mutex); 3606 + 3607 + IWL_DEBUG_WOWLAN(mvm, "Starting the fast resume flow\n"); 3608 + 3609 + mvm->last_reset_or_resume_time_jiffies = jiffies; 3610 + iwl_fw_dbg_read_d3_debug_data(&mvm->fwrt); 3611 + 3612 + if (iwl_mvm_check_rt_status(mvm, NULL)) { 3613 + set_bit(STATUS_FW_ERROR, &mvm->trans->status); 3614 + iwl_mvm_dump_nic_error_log(mvm); 3615 + iwl_dbg_tlv_time_point(&mvm->fwrt, 3616 + IWL_FW_INI_TIME_POINT_FW_ASSERT, NULL); 3617 + iwl_fw_dbg_collect_desc(&mvm->fwrt, &iwl_dump_desc_assert, 3618 + false, 0); 3619 + return -ENODEV; 3620 + } 3621 + ret = iwl_mvm_d3_notif_wait(mvm, &d3_data); 3622 + clear_bit(IWL_MVM_STATUS_IN_D3, &mvm->status); 3623 + mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED; 3624 + mvm->fast_resume = false; 3625 + 3626 + if (ret) 3627 + IWL_ERR(mvm, "Couldn't get the d3 notif %d\n", ret); 3628 + 3629 + return ret; 3581 3630 } 3582 3631 3583 3632 #ifdef CONFIG_IWLWIFI_DEBUGFS
-221
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
··· 151 151 return ret; 152 152 } 153 153 154 - static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf, 155 - size_t count, loff_t *ppos) 156 - { 157 - struct iwl_mvm_sta *mvmsta; 158 - int sta_id, drain, ret; 159 - 160 - if (!iwl_mvm_firmware_running(mvm) || 161 - mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) 162 - return -EIO; 163 - 164 - if (sscanf(buf, "%d %d", &sta_id, &drain) != 2) 165 - return -EINVAL; 166 - if (sta_id < 0 || sta_id >= mvm->fw->ucode_capa.num_stations) 167 - return -EINVAL; 168 - if (drain < 0 || drain > 1) 169 - return -EINVAL; 170 - 171 - mutex_lock(&mvm->mutex); 172 - 173 - mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id); 174 - 175 - if (!mvmsta) 176 - ret = -ENOENT; 177 - else 178 - ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count; 179 - 180 - mutex_unlock(&mvm->mutex); 181 - 182 - return ret; 183 - } 184 - 185 154 static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf, 186 155 size_t count, loff_t *ppos) 187 156 { ··· 534 565 ret = iwl_mvm_power_update_device(mvm); 535 566 mutex_unlock(&mvm->mutex); 536 567 537 - return ret ?: count; 538 - } 539 - 540 - static 541 - int iwl_mvm_coex_dump_mbox(struct iwl_bt_coex_profile_notif *notif, char *buf, 542 - int pos, int bufsz) 543 - { 544 - pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw0:\n"); 545 - 546 - BT_MBOX_PRINT(0, LE_SLAVE_LAT, false); 547 - BT_MBOX_PRINT(0, LE_PROF1, false); 548 - BT_MBOX_PRINT(0, LE_PROF2, false); 549 - BT_MBOX_PRINT(0, LE_PROF_OTHER, false); 550 - BT_MBOX_PRINT(0, CHL_SEQ_N, false); 551 - BT_MBOX_PRINT(0, INBAND_S, false); 552 - BT_MBOX_PRINT(0, LE_MIN_RSSI, false); 553 - BT_MBOX_PRINT(0, LE_SCAN, false); 554 - BT_MBOX_PRINT(0, LE_ADV, false); 555 - BT_MBOX_PRINT(0, LE_MAX_TX_POWER, false); 556 - BT_MBOX_PRINT(0, OPEN_CON_1, true); 557 - 558 - pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw1:\n"); 559 - 560 - BT_MBOX_PRINT(1, BR_MAX_TX_POWER, false); 561 - BT_MBOX_PRINT(1, IP_SR, false); 562 - BT_MBOX_PRINT(1, LE_MSTR, false); 563 - BT_MBOX_PRINT(1, AGGR_TRFC_LD, false); 564 - BT_MBOX_PRINT(1, MSG_TYPE, false); 565 - BT_MBOX_PRINT(1, SSN, true); 566 - 567 - pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw2:\n"); 568 - 569 - BT_MBOX_PRINT(2, SNIFF_ACT, false); 570 - BT_MBOX_PRINT(2, PAG, false); 571 - BT_MBOX_PRINT(2, INQUIRY, false); 572 - BT_MBOX_PRINT(2, CONN, false); 573 - BT_MBOX_PRINT(2, SNIFF_INTERVAL, false); 574 - BT_MBOX_PRINT(2, DISC, false); 575 - BT_MBOX_PRINT(2, SCO_TX_ACT, false); 576 - BT_MBOX_PRINT(2, SCO_RX_ACT, false); 577 - BT_MBOX_PRINT(2, ESCO_RE_TX, false); 578 - BT_MBOX_PRINT(2, SCO_DURATION, true); 579 - 580 - pos += scnprintf(buf+pos, bufsz-pos, "MBOX dw3:\n"); 581 - 582 - BT_MBOX_PRINT(3, SCO_STATE, false); 583 - BT_MBOX_PRINT(3, SNIFF_STATE, false); 584 - BT_MBOX_PRINT(3, A2DP_STATE, false); 585 - BT_MBOX_PRINT(3, A2DP_SRC, false); 586 - BT_MBOX_PRINT(3, ACL_STATE, false); 587 - BT_MBOX_PRINT(3, MSTR_STATE, false); 588 - BT_MBOX_PRINT(3, OBX_STATE, false); 589 - BT_MBOX_PRINT(3, OPEN_CON_2, false); 590 - BT_MBOX_PRINT(3, TRAFFIC_LOAD, false); 591 - BT_MBOX_PRINT(3, CHL_SEQN_LSB, false); 592 - BT_MBOX_PRINT(3, INBAND_P, false); 593 - BT_MBOX_PRINT(3, MSG_TYPE_2, false); 594 - BT_MBOX_PRINT(3, SSN_2, false); 595 - BT_MBOX_PRINT(3, UPDATE_REQUEST, true); 596 - 597 - return pos; 598 - } 599 - 600 - static ssize_t iwl_dbgfs_bt_notif_read(struct file *file, char __user *user_buf, 601 - size_t count, loff_t *ppos) 602 - { 603 - struct iwl_mvm *mvm = file->private_data; 604 - struct iwl_bt_coex_profile_notif *notif = &mvm->last_bt_notif; 605 - char *buf; 606 - int ret, pos = 0, bufsz = sizeof(char) * 1024; 607 - 608 - buf = kmalloc(bufsz, GFP_KERNEL); 609 - if (!buf) 610 - return -ENOMEM; 611 - 612 - mutex_lock(&mvm->mutex); 613 - 614 - pos += iwl_mvm_coex_dump_mbox(notif, buf, pos, bufsz); 615 - 616 - pos += scnprintf(buf + pos, bufsz - pos, "bt_ci_compliance = %d\n", 617 - notif->bt_ci_compliance); 618 - pos += scnprintf(buf + pos, bufsz - pos, "primary_ch_lut = %d\n", 619 - le32_to_cpu(notif->primary_ch_lut)); 620 - pos += scnprintf(buf + pos, bufsz - pos, "secondary_ch_lut = %d\n", 621 - le32_to_cpu(notif->secondary_ch_lut)); 622 - pos += scnprintf(buf + pos, 623 - bufsz - pos, "bt_activity_grading = %d\n", 624 - le32_to_cpu(notif->bt_activity_grading)); 625 - pos += scnprintf(buf + pos, bufsz - pos, "bt_rrc = %d\n", 626 - notif->rrc_status & 0xF); 627 - pos += scnprintf(buf + pos, bufsz - pos, "bt_ttc = %d\n", 628 - notif->ttc_status & 0xF); 629 - 630 - pos += scnprintf(buf + pos, bufsz - pos, "sync_sco = %d\n", 631 - IWL_MVM_BT_COEX_SYNC2SCO); 632 - pos += scnprintf(buf + pos, bufsz - pos, "mplut = %d\n", 633 - IWL_MVM_BT_COEX_MPLUT); 634 - 635 - mutex_unlock(&mvm->mutex); 636 - 637 - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 638 - kfree(buf); 639 - 640 - return ret; 641 - } 642 - #undef BT_MBOX_PRINT 643 - 644 - static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf, 645 - size_t count, loff_t *ppos) 646 - { 647 - struct iwl_mvm *mvm = file->private_data; 648 - struct iwl_bt_coex_ci_cmd *cmd = &mvm->last_bt_ci_cmd; 649 - char buf[256]; 650 - int bufsz = sizeof(buf); 651 - int pos = 0; 652 - 653 - mutex_lock(&mvm->mutex); 654 - 655 - pos += scnprintf(buf + pos, bufsz - pos, "Channel inhibition CMD\n"); 656 - pos += scnprintf(buf + pos, bufsz - pos, 657 - "\tPrimary Channel Bitmap 0x%016llx\n", 658 - le64_to_cpu(cmd->bt_primary_ci)); 659 - pos += scnprintf(buf + pos, bufsz - pos, 660 - "\tSecondary Channel Bitmap 0x%016llx\n", 661 - le64_to_cpu(cmd->bt_secondary_ci)); 662 - 663 - mutex_unlock(&mvm->mutex); 664 - 665 - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 666 - } 667 - 668 - static ssize_t 669 - iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf, 670 - size_t count, loff_t *ppos) 671 - { 672 - u32 bt_tx_prio; 673 - 674 - if (sscanf(buf, "%u", &bt_tx_prio) != 1) 675 - return -EINVAL; 676 - if (bt_tx_prio > 4) 677 - return -EINVAL; 678 - 679 - mvm->bt_tx_prio = bt_tx_prio; 680 - 681 - return count; 682 - } 683 - 684 - static ssize_t 685 - iwl_dbgfs_bt_force_ant_write(struct iwl_mvm *mvm, char *buf, 686 - size_t count, loff_t *ppos) 687 - { 688 - static const char * const modes_str[BT_FORCE_ANT_MAX] = { 689 - [BT_FORCE_ANT_DIS] = "dis", 690 - [BT_FORCE_ANT_AUTO] = "auto", 691 - [BT_FORCE_ANT_BT] = "bt", 692 - [BT_FORCE_ANT_WIFI] = "wifi", 693 - }; 694 - int ret, bt_force_ant_mode; 695 - 696 - ret = match_string(modes_str, ARRAY_SIZE(modes_str), buf); 697 - if (ret < 0) 698 - return ret; 699 - 700 - bt_force_ant_mode = ret; 701 - ret = 0; 702 - mutex_lock(&mvm->mutex); 703 - if (mvm->bt_force_ant_mode == bt_force_ant_mode) 704 - goto out; 705 - 706 - mvm->bt_force_ant_mode = bt_force_ant_mode; 707 - IWL_DEBUG_COEX(mvm, "Force mode: %s\n", 708 - modes_str[mvm->bt_force_ant_mode]); 709 - 710 - if (iwl_mvm_firmware_running(mvm)) 711 - ret = iwl_mvm_send_bt_init_conf(mvm); 712 - else 713 - ret = 0; 714 - 715 - out: 716 - mutex_unlock(&mvm->mutex); 717 568 return ret ?: count; 718 569 } 719 570 ··· 1954 2165 MVM_DEBUGFS_WRITE_FILE_OPS(start_ctdp, 8); 1955 2166 MVM_DEBUGFS_WRITE_FILE_OPS(force_ctkill, 8); 1956 2167 MVM_DEBUGFS_WRITE_FILE_OPS(tx_flush, 16); 1957 - MVM_DEBUGFS_WRITE_FILE_OPS(sta_drain, 8); 1958 2168 MVM_DEBUGFS_WRITE_FILE_OPS(send_echo_cmd, 8); 1959 2169 MVM_DEBUGFS_READ_WRITE_FILE_OPS(sram, 64); 1960 2170 MVM_DEBUGFS_READ_WRITE_FILE_OPS(set_nic_temperature, 64); 1961 2171 MVM_DEBUGFS_READ_FILE_OPS(nic_temp); 1962 2172 MVM_DEBUGFS_READ_FILE_OPS(stations); 1963 2173 MVM_DEBUGFS_READ_LINK_STA_FILE_OPS(rs_data); 1964 - MVM_DEBUGFS_READ_FILE_OPS(bt_notif); 1965 - MVM_DEBUGFS_READ_FILE_OPS(bt_cmd); 1966 2174 MVM_DEBUGFS_READ_WRITE_FILE_OPS(disable_power_off, 64); 1967 2175 MVM_DEBUGFS_READ_FILE_OPS(fw_rx_stats); 1968 2176 MVM_DEBUGFS_READ_FILE_OPS(drv_rx_stats); ··· 1969 2183 MVM_DEBUGFS_READ_FILE_OPS(tas_get_status); 1970 2184 MVM_DEBUGFS_WRITE_FILE_OPS(fw_restart, 10); 1971 2185 MVM_DEBUGFS_WRITE_FILE_OPS(fw_nmi, 10); 1972 - MVM_DEBUGFS_WRITE_FILE_OPS(bt_tx_prio, 10); 1973 - MVM_DEBUGFS_WRITE_FILE_OPS(bt_force_ant, 10); 1974 2186 MVM_DEBUGFS_READ_WRITE_FILE_OPS(scan_ant_rxchain, 8); 1975 2187 MVM_DEBUGFS_READ_WRITE_FILE_OPS(fw_dbg_conf, 8); 1976 2188 MVM_DEBUGFS_WRITE_FILE_OPS(fw_dbg_collect, 64); ··· 2155 2371 spin_lock_init(&mvm->drv_stats_lock); 2156 2372 2157 2373 MVM_DEBUGFS_ADD_FILE(tx_flush, mvm->debugfs_dir, 0200); 2158 - MVM_DEBUGFS_ADD_FILE(sta_drain, mvm->debugfs_dir, 0200); 2159 2374 MVM_DEBUGFS_ADD_FILE(sram, mvm->debugfs_dir, 0600); 2160 2375 MVM_DEBUGFS_ADD_FILE(set_nic_temperature, mvm->debugfs_dir, 0600); 2161 2376 MVM_DEBUGFS_ADD_FILE(nic_temp, mvm->debugfs_dir, 0400); ··· 2163 2380 MVM_DEBUGFS_ADD_FILE(start_ctdp, mvm->debugfs_dir, 0200); 2164 2381 MVM_DEBUGFS_ADD_FILE(force_ctkill, mvm->debugfs_dir, 0200); 2165 2382 MVM_DEBUGFS_ADD_FILE(stations, mvm->debugfs_dir, 0400); 2166 - MVM_DEBUGFS_ADD_FILE(bt_notif, mvm->debugfs_dir, 0400); 2167 - MVM_DEBUGFS_ADD_FILE(bt_cmd, mvm->debugfs_dir, 0400); 2168 2383 MVM_DEBUGFS_ADD_FILE(disable_power_off, mvm->debugfs_dir, 0600); 2169 2384 MVM_DEBUGFS_ADD_FILE(fw_ver, mvm->debugfs_dir, 0400); 2170 2385 MVM_DEBUGFS_ADD_FILE(fw_rx_stats, mvm->debugfs_dir, 0400); ··· 2170 2389 MVM_DEBUGFS_ADD_FILE(fw_system_stats, mvm->debugfs_dir, 0400); 2171 2390 MVM_DEBUGFS_ADD_FILE(fw_restart, mvm->debugfs_dir, 0200); 2172 2391 MVM_DEBUGFS_ADD_FILE(fw_nmi, mvm->debugfs_dir, 0200); 2173 - MVM_DEBUGFS_ADD_FILE(bt_tx_prio, mvm->debugfs_dir, 0200); 2174 - MVM_DEBUGFS_ADD_FILE(bt_force_ant, mvm->debugfs_dir, 0200); 2175 2392 MVM_DEBUGFS_ADD_FILE(scan_ant_rxchain, mvm->debugfs_dir, 0600); 2176 2393 MVM_DEBUGFS_ADD_FILE(prph_reg, mvm->debugfs_dir, 0600); 2177 2394 MVM_DEBUGFS_ADD_FILE(fw_dbg_conf, mvm->debugfs_dir, 0600);
+1 -6
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c
··· 732 732 733 733 WARN_ON(!sta->mfp); 734 734 735 - if (WARN_ON(key->keylen > sizeof(target->tk))) 736 - return; 737 - 738 - memcpy(target->tk, key->key, key->keylen); 735 + target->tk = key->key; 739 736 *target->cipher = iwl_mvm_cipher_to_location_cipher(key->cipher); 740 737 WARN_ON(*target->cipher == IWL_LOCATION_CIPHER_INVALID); 741 738 } ··· 771 774 !memcmp(vif->bss_conf.bssid, bssid, ETH_ALEN)) { 772 775 struct iwl_mvm_ftm_iter_data target; 773 776 774 - target.cipher = cipher; 775 777 target.bssid = bssid; 776 - target.tk = tk; 777 778 ieee80211_iter_keys(mvm->hw, vif, iter, &target); 778 779 } else { 779 780 memcpy(tk, entry->tk, sizeof(entry->tk));
+14 -37
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
··· 28 28 #define MVM_UCODE_ALIVE_TIMEOUT (2 * HZ) 29 29 #define MVM_UCODE_CALIB_TIMEOUT (2 * HZ) 30 30 31 - #define IWL_UATS_VLP_AP_SUPPORTED BIT(29) 32 - #define IWL_UATS_AFC_AP_SUPPORTED BIT(30) 33 - 34 31 struct iwl_mvm_alive_data { 35 32 bool valid; 36 33 u32 scd_base_addr; ··· 405 408 UREG_LMAC2_CURRENT_PC)); 406 409 } 407 410 408 - if (ret == -ETIMEDOUT && !mvm->pldr_sync) 411 + if (ret == -ETIMEDOUT && !mvm->fw_product_reset) 409 412 iwl_fw_dbg_error_collect(&mvm->fwrt, 410 413 FW_DBG_TRIGGER_ALIVE_TIMEOUT); 411 414 ··· 457 460 #endif 458 461 459 462 /* 463 + * For pre-MLD API (MLD API doesn't use the timestamps): 460 464 * All the BSSes in the BSS table include the GP2 in the system 461 465 * at the beacon Rx time, this is of course no longer relevant 462 466 * since we are resetting the firmware. 463 467 * Purge all the BSS table. 464 468 */ 465 - cfg80211_bss_flush(mvm->hw->wiphy); 469 + if (!mvm->mld_api_is_used) 470 + cfg80211_bss_flush(mvm->hw->wiphy); 466 471 467 472 return 0; 468 473 } ··· 490 491 .dataflags[0] = IWL_HCMD_DFL_NOCOPY, 491 492 }; 492 493 493 - if (!(mvm->trans->trans_cfg->device_family >= 494 - IWL_DEVICE_FAMILY_AX210)) { 494 + if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210) { 495 495 IWL_DEBUG_RADIO(mvm, "UATS feature is not supported\n"); 496 - return; 497 - } 498 - 499 - if (!mvm->fwrt.uats_enabled) { 500 - IWL_DEBUG_RADIO(mvm, "UATS feature is disabled\n"); 501 496 return; 502 497 } 503 498 ··· 506 513 507 514 ret = iwl_uefi_get_uats_table(mvm->trans, &mvm->fwrt); 508 515 if (ret < 0) { 509 - IWL_ERR(mvm, "failed to read UATS table (%d)\n", ret); 516 + IWL_DEBUG_FW(mvm, "failed to read UATS table (%d)\n", ret); 510 517 return; 511 518 } 512 519 ··· 620 627 if (mvm->trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_AX210) { 621 628 sb_cfg = iwl_read_umac_prph(mvm->trans, SB_MODIFY_CFG_FLAG); 622 629 /* if needed, we'll reset this on our way out later */ 623 - mvm->pldr_sync = sb_cfg == SB_CFG_RESIDES_IN_ROM; 624 - if (mvm->pldr_sync && iwl_mei_pldr_req()) 630 + mvm->fw_product_reset = sb_cfg == SB_CFG_RESIDES_IN_ROM; 631 + if (mvm->fw_product_reset && iwl_mei_pldr_req()) 625 632 return -EBUSY; 626 633 } 627 634 ··· 640 647 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); 641 648 642 649 /* if we needed reset then fail here, but notify and remove */ 643 - if (mvm->pldr_sync) { 650 + if (mvm->fw_product_reset) { 644 651 iwl_mei_alive_notif(false); 645 652 iwl_trans_pcie_remove(mvm->trans, true); 646 653 } ··· 679 686 goto error; 680 687 } 681 688 682 - if (IWL_MVM_PARSE_NVM && !mvm->nvm_data) { 683 - ret = iwl_nvm_init(mvm); 684 - if (ret) { 685 - IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 686 - goto error; 687 - } 688 - } 689 - 690 689 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(REGULATORY_AND_NVM_GROUP, 691 690 NVM_ACCESS_COMPLETE), 692 691 CMD_SEND_IN_RFKILL, ··· 703 718 return ret; 704 719 705 720 /* Read the NVM only at driver load time, no need to do this twice */ 706 - if (!IWL_MVM_PARSE_NVM && !mvm->nvm_data) { 721 + if (!mvm->nvm_data) { 707 722 mvm->nvm_data = iwl_get_nvm(mvm->trans, mvm->fw, 708 723 mvm->set_tx_ant, mvm->set_rx_ant); 709 724 if (IS_ERR(mvm->nvm_data)) { ··· 828 843 iwl_remove_notification(&mvm->notif_wait, &calib_wait); 829 844 out: 830 845 mvm->rfkill_safe_init_done = false; 831 - if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { 846 + if (!mvm->nvm_data) { 832 847 /* we want to debug INIT and we have no NVM - fake */ 833 848 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + 834 849 sizeof(struct ieee80211_channel) + ··· 1216 1231 "Failed to send LARI_CONFIG_CHANGE (%d)\n", 1217 1232 ret); 1218 1233 } 1219 - 1220 - if (le32_to_cpu(cmd.oem_uhb_allow_bitmap) & IWL_UATS_VLP_AP_SUPPORTED || 1221 - le32_to_cpu(cmd.oem_uhb_allow_bitmap) & IWL_UATS_AFC_AP_SUPPORTED) 1222 - mvm->fwrt.uats_enabled = true; 1223 1234 } 1224 1235 1225 1236 void iwl_mvm_get_bios_tables(struct iwl_mvm *mvm) ··· 1357 1376 1358 1377 if (ret) { 1359 1378 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); 1360 - 1361 - if (iwlmvm_mod_params.init_dbg) 1362 - return 0; 1363 1379 return ret; 1364 1380 } 1365 1381 ··· 1393 1415 ret = iwl_mvm_load_rt_fw(mvm); 1394 1416 if (ret) { 1395 1417 IWL_ERR(mvm, "Failed to start RT ucode: %d\n", ret); 1396 - if (ret != -ERFKILL && !mvm->pldr_sync) 1418 + if (ret != -ERFKILL && !mvm->fw_product_reset) 1397 1419 iwl_fw_dbg_error_collect(&mvm->fwrt, 1398 1420 FW_DBG_TRIGGER_DRIVER); 1399 1421 goto error; 1400 1422 } 1401 1423 1402 1424 /* FW loaded successfully */ 1403 - mvm->pldr_sync = false; 1425 + mvm->fw_product_reset = false; 1404 1426 1405 1427 iwl_fw_disable_dbg_asserts(&mvm->fwrt); 1406 1428 iwl_get_shared_mem_conf(&mvm->fwrt); ··· 1595 1617 IWL_DEBUG_INFO(mvm, "RT uCode started.\n"); 1596 1618 return 0; 1597 1619 error: 1598 - if (!iwlmvm_mod_params.init_dbg || !ret) 1599 - iwl_mvm_stop_device(mvm); 1620 + iwl_mvm_stop_device(mvm); 1600 1621 return ret; 1601 1622 } 1602 1623
+4 -2
drivers/net/wireless/intel/iwlwifi/mvm/link.c
··· 1086 1086 1087 1087 IWL_DEBUG_INFO(mvm, "EMLSR is unblocked\n"); 1088 1088 1089 - /* We exited due to an EXIT reason, so MLO scan was scheduled already */ 1090 - if (mvmvif->last_esr_exit.reason && 1089 + /* If we exited due to an EXIT reason, and the exit was in less than 1090 + * 30 seconds, then a MLO scan was scheduled already. 1091 + */ 1092 + if (!need_new_sel && 1091 1093 !(mvmvif->last_esr_exit.reason & IWL_MVM_BLOCK_ESR_REASONS)) { 1092 1094 IWL_DEBUG_INFO(mvm, "Wait for MLO scan\n"); 1093 1095 return;
+1
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
··· 296 296 297 297 INIT_LIST_HEAD(&mvmvif->time_event_data.list); 298 298 mvmvif->time_event_data.id = TE_MAX; 299 + mvmvif->roc_activity = ROC_NUM_ACTIVITIES; 299 300 300 301 mvmvif->deflink.bcast_sta.sta_id = IWL_MVM_INVALID_STA; 301 302 mvmvif->deflink.mcast_sta.sta_id = IWL_MVM_INVALID_STA;
+118 -50
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
··· 30 30 #include "iwl-nvm-parse.h" 31 31 #include "time-sync.h" 32 32 33 + #define IWL_MVM_LIMITS(ap) \ 34 + { \ 35 + .max = 1, \ 36 + .types = BIT(NL80211_IFTYPE_STATION), \ 37 + }, \ 38 + { \ 39 + .max = 1, \ 40 + .types = ap | \ 41 + BIT(NL80211_IFTYPE_P2P_CLIENT) | \ 42 + BIT(NL80211_IFTYPE_P2P_GO), \ 43 + }, \ 44 + { \ 45 + .max = 1, \ 46 + .types = BIT(NL80211_IFTYPE_P2P_DEVICE), \ 47 + } 48 + 33 49 static const struct ieee80211_iface_limit iwl_mvm_limits[] = { 34 - { 35 - .max = 1, 36 - .types = BIT(NL80211_IFTYPE_STATION), 37 - }, 38 - { 39 - .max = 1, 40 - .types = BIT(NL80211_IFTYPE_AP) | 41 - BIT(NL80211_IFTYPE_P2P_CLIENT) | 42 - BIT(NL80211_IFTYPE_P2P_GO), 43 - }, 44 - { 45 - .max = 1, 46 - .types = BIT(NL80211_IFTYPE_P2P_DEVICE), 47 - }, 50 + IWL_MVM_LIMITS(0) 51 + }; 52 + 53 + static const struct ieee80211_iface_limit iwl_mvm_limits_ap[] = { 54 + IWL_MVM_LIMITS(BIT(NL80211_IFTYPE_AP)) 48 55 }; 49 56 50 57 static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { ··· 59 52 .num_different_channels = 2, 60 53 .max_interfaces = 3, 61 54 .limits = iwl_mvm_limits, 62 - .n_limits = ARRAY_SIZE(iwl_mvm_limits), 55 + .n_limits = ARRAY_SIZE(iwl_mvm_limits) - 1, 56 + }, 57 + { 58 + .num_different_channels = 1, 59 + .max_interfaces = 3, 60 + .limits = iwl_mvm_limits_ap, 61 + .n_limits = ARRAY_SIZE(iwl_mvm_limits_ap) - 1, 63 62 }, 64 63 }; 65 64 ··· 151 138 resp->channels, 152 139 __le16_to_cpu(resp->mcc), 153 140 __le16_to_cpu(resp->geo_info), 154 - le32_to_cpu(resp->cap), resp_ver, 155 - mvm->fwrt.uats_enabled); 141 + le32_to_cpu(resp->cap), resp_ver); 156 142 /* Store the return source id */ 157 143 src_id = resp->source_id; 158 144 if (IS_ERR_OR_NULL(regd)) { ··· 591 579 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; 592 580 593 581 BUILD_BUG_ON(IWL_MVM_SCAN_STOPPING_MASK & IWL_MVM_SCAN_MASK); 594 - BUILD_BUG_ON(IWL_MVM_MAX_UMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK) || 595 - IWL_MVM_MAX_LMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK)); 582 + BUILD_BUG_ON(IWL_MAX_UMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK) || 583 + IWL_MAX_LMAC_SCANS > HWEIGHT32(IWL_MVM_SCAN_MASK)); 596 584 597 585 if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) 598 - mvm->max_scans = IWL_MVM_MAX_UMAC_SCANS; 586 + mvm->max_scans = IWL_MAX_UMAC_SCANS; 599 587 else 600 - mvm->max_scans = IWL_MVM_MAX_LMAC_SCANS; 588 + mvm->max_scans = IWL_MAX_LMAC_SCANS; 601 589 602 590 if (mvm->nvm_data->bands[NL80211_BAND_2GHZ].n_channels) 603 591 hw->wiphy->bands[NL80211_BAND_2GHZ] = ··· 739 727 740 728 #ifdef CONFIG_PM_SLEEP 741 729 if ((unified || mvm->fw->img[IWL_UCODE_WOWLAN].num_sec) && 742 - mvm->trans->ops->d3_suspend && 743 - mvm->trans->ops->d3_resume && 744 730 device_can_wakeup(mvm->trans->dev)) { 745 731 mvm->wowlan.flags |= WIPHY_WOWLAN_MAGIC_PKT | 746 732 WIPHY_WOWLAN_DISCONNECT | ··· 833 823 } 834 824 835 825 if (offchannel && 836 - !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) && 826 + !test_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status) && 837 827 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) 838 828 goto drop; 839 829 ··· 1114 1104 iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); 1115 1105 spin_unlock_bh(&mvm->time_event_lock); 1116 1106 1107 + mvmvif->roc_activity = ROC_NUM_ACTIVITIES; 1108 + 1117 1109 mvmvif->bf_enabled = false; 1118 1110 mvmvif->ba_enabled = false; 1119 1111 mvmvif->ap_sta = NULL; ··· 1221 1209 1222 1210 int __iwl_mvm_mac_start(struct iwl_mvm *mvm) 1223 1211 { 1212 + bool fast_resume = false; 1224 1213 int ret; 1225 1214 1226 1215 lockdep_assert_held(&mvm->mutex); ··· 1247 1234 mvm->nvm_data = NULL; 1248 1235 } 1249 1236 1237 + #ifdef CONFIG_PM 1238 + /* fast_resume will be cleared by iwl_mvm_fast_resume */ 1239 + fast_resume = mvm->fast_resume; 1240 + 1241 + if (fast_resume) { 1242 + ret = iwl_mvm_fast_resume(mvm); 1243 + if (ret) { 1244 + iwl_mvm_stop_device(mvm); 1245 + /* iwl_mvm_up() will be called further down */ 1246 + } else { 1247 + /* 1248 + * We clear IWL_MVM_STATUS_FIRMWARE_RUNNING upon 1249 + * mac_down() so that debugfs will stop honoring 1250 + * requests after we flush all the workers. 1251 + * Set the IWL_MVM_STATUS_FIRMWARE_RUNNING bit again 1252 + * now that we are back. This is a bit abusing the 1253 + * flag since the firmware wasn't really ever stopped, 1254 + * but this still serves the purpose. 1255 + */ 1256 + set_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 1257 + } 1258 + } 1259 + #endif /* CONFIG_PM */ 1260 + 1250 1261 if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status)) { 1251 1262 /* 1252 1263 * Now convert the HW_RESTART_REQUESTED flag to IN_HW_RESTART ··· 1281 1244 /* Clean up some internal and mac80211 state on restart */ 1282 1245 iwl_mvm_restart_cleanup(mvm); 1283 1246 } 1284 - ret = iwl_mvm_up(mvm); 1247 + 1248 + /* we also want to load the firmware if fast_resume failed */ 1249 + if (!fast_resume || ret) 1250 + ret = iwl_mvm_up(mvm); 1285 1251 1286 1252 iwl_dbg_tlv_time_point(&mvm->fwrt, IWL_FW_INI_TIME_POINT_POST_INIT, 1287 1253 NULL); ··· 1367 1327 } 1368 1328 } 1369 1329 1370 - void __iwl_mvm_mac_stop(struct iwl_mvm *mvm) 1330 + void __iwl_mvm_mac_stop(struct iwl_mvm *mvm, bool suspend) 1371 1331 { 1372 1332 lockdep_assert_held(&mvm->mutex); 1373 1333 ··· 1383 1343 if (!iwl_mvm_has_new_station_api(mvm->fw)) 1384 1344 iwl_mvm_rm_aux_sta(mvm); 1385 1345 1386 - iwl_mvm_stop_device(mvm); 1346 + if (suspend && 1347 + mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) 1348 + iwl_mvm_fast_suspend(mvm); 1349 + else 1350 + iwl_mvm_stop_device(mvm); 1387 1351 1388 1352 iwl_mvm_async_handlers_purge(mvm); 1389 1353 /* async_handlers_list is empty and will stay empty: HW is stopped */ ··· 1420 1376 } 1421 1377 } 1422 1378 1423 - void iwl_mvm_mac_stop(struct ieee80211_hw *hw) 1379 + void iwl_mvm_mac_stop(struct ieee80211_hw *hw, bool suspend) 1424 1380 { 1425 1381 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 1426 1382 ··· 1456 1412 iwl_mvm_mei_set_sw_rfkill_state(mvm); 1457 1413 1458 1414 mutex_lock(&mvm->mutex); 1459 - __iwl_mvm_mac_stop(mvm); 1415 + __iwl_mvm_mac_stop(mvm, suspend); 1460 1416 mutex_unlock(&mvm->mutex); 1461 1417 1462 1418 /* ··· 1898 1854 cancel_delayed_work_sync(&mvmvif->csa_work); 1899 1855 } 1900 1856 1901 - /* This function is doing the common part of removing the interface for 1902 - * both - MLD and non-MLD modes. Returns true if removing the interface 1903 - * is done 1904 - */ 1905 - static bool iwl_mvm_mac_remove_interface_common(struct ieee80211_hw *hw, 1906 - struct ieee80211_vif *vif) 1857 + static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, 1858 + struct ieee80211_vif *vif) 1907 1859 { 1908 1860 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 1909 1861 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); ··· 1947 1907 mvm->noa_duration = 0; 1948 1908 } 1949 1909 #endif 1950 - return true; 1910 + goto out; 1951 1911 } 1952 1912 1953 1913 iwl_mvm_power_update_mac(mvm); 1954 - return false; 1955 - } 1956 - 1957 - static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, 1958 - struct ieee80211_vif *vif) 1959 - { 1960 - struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 1961 - struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1962 - 1963 - if (iwl_mvm_mac_remove_interface_common(hw, vif)) 1964 - goto out; 1965 1914 1966 1915 /* Before the interface removal, mac80211 would cancel the ROC, and the 1967 1916 * ROC worker would be scheduled if needed. The worker would be flushed ··· 4802 4773 return ret; 4803 4774 } 4804 4775 4776 + static int iwl_mvm_roc_p2p(struct iwl_mvm *mvm, 4777 + struct ieee80211_channel *channel, 4778 + struct ieee80211_vif *vif, 4779 + int duration, 4780 + enum ieee80211_roc_type type) 4781 + { 4782 + enum iwl_roc_activity activity; 4783 + int ret; 4784 + 4785 + lockdep_assert_held(&mvm->mutex); 4786 + 4787 + switch (type) { 4788 + case IEEE80211_ROC_TYPE_NORMAL: 4789 + activity = ROC_ACTIVITY_P2P_DISC; 4790 + break; 4791 + case IEEE80211_ROC_TYPE_MGMT_TX: 4792 + activity = ROC_ACTIVITY_P2P_NEG; 4793 + break; 4794 + default: 4795 + WARN_ONCE(1, "Got an invalid P2P ROC type\n"); 4796 + return -EINVAL; 4797 + } 4798 + 4799 + ret = iwl_mvm_mld_add_aux_sta(mvm, 4800 + iwl_mvm_get_lmac_id(mvm, channel->band)); 4801 + if (ret) 4802 + return ret; 4803 + 4804 + return iwl_mvm_roc_add_cmd(mvm, channel, vif, duration, activity); 4805 + } 4806 + 4805 4807 static int iwl_mvm_p2p_find_phy_ctxt(struct iwl_mvm *mvm, 4806 4808 struct ieee80211_vif *vif, 4807 4809 struct ieee80211_channel *channel) ··· 4886 4826 const struct iwl_mvm_roc_ops *ops) 4887 4827 { 4888 4828 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 4829 + struct ieee80211_vif *bss_vif = iwl_mvm_get_bss_vif(mvm); 4889 4830 u32 lmac_id; 4890 4831 int ret; 4891 4832 ··· 4899 4838 */ 4900 4839 flush_work(&mvm->roc_done_wk); 4901 4840 4902 - ret = iwl_mvm_esr_non_bss_link(mvm, vif, 0, true); 4903 - if (ret) 4904 - return ret; 4841 + if (!IS_ERR_OR_NULL(bss_vif)) { 4842 + ret = iwl_mvm_block_esr_sync(mvm, bss_vif, 4843 + IWL_MVM_ESR_BLOCKED_ROC); 4844 + if (ret) 4845 + return ret; 4846 + } 4905 4847 4906 4848 guard(mvm)(mvm); 4907 4849 ··· 4925 4861 return -EINVAL; 4926 4862 } 4927 4863 4864 + if (iwl_mvm_has_p2p_over_aux(mvm)) { 4865 + ret = iwl_mvm_roc_p2p(mvm, channel, vif, duration, type); 4866 + return ret; 4867 + } 4928 4868 4929 4869 ret = iwl_mvm_p2p_find_phy_ctxt(mvm, vif, channel); 4930 4870 if (ret)
+44 -17
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
··· 83 83 84 84 /** 85 85 * struct iwl_mvm_mod_params - module parameters for iwlmvm 86 - * @init_dbg: if true, then the NIC won't be stopped if the INIT fw asserted. 87 - * We will register to mac80211 to have testmode working. The NIC must not 88 - * be up'ed after the INIT fw asserted. This is useful to be able to use 89 - * proprietary tools over testmode to debug the INIT fw. 90 86 * @power_scheme: one of enum iwl_power_scheme 91 87 */ 92 88 struct iwl_mvm_mod_params { 93 - bool init_dbg; 94 89 int power_scheme; 95 90 }; 96 91 extern struct iwl_mvm_mod_params iwlmvm_mod_params; ··· 356 361 * @IWL_MVM_ESR_BLOCKED_WOWLAN: WOWLAN is preventing the enablement of EMLSR 357 362 * @IWL_MVM_ESR_BLOCKED_TPT: block EMLSR when there is not enough traffic 358 363 * @IWL_MVM_ESR_BLOCKED_FW: FW didn't recommended/forced exit from EMLSR 359 - * @IWL_MVM_ESR_BLOCKED_NON_BSS: An active non-bssid link's preventing EMLSR 364 + * @IWL_MVM_ESR_BLOCKED_NON_BSS: An active non-BSS interface's link is 365 + * preventing EMLSR 366 + * @IWL_MVM_ESR_BLOCKED_ROC: remain-on-channel is preventing EMLSR 360 367 * @IWL_MVM_ESR_EXIT_MISSED_BEACON: exited EMLSR due to missed beacons 361 368 * @IWL_MVM_ESR_EXIT_LOW_RSSI: link is deactivated/not allowed for EMLSR 362 369 * due to low RSSI. ··· 375 378 IWL_MVM_ESR_BLOCKED_TPT = 0x4, 376 379 IWL_MVM_ESR_BLOCKED_FW = 0x8, 377 380 IWL_MVM_ESR_BLOCKED_NON_BSS = 0x10, 381 + IWL_MVM_ESR_BLOCKED_ROC = 0x20, 378 382 IWL_MVM_ESR_EXIT_MISSED_BEACON = 0x10000, 379 383 IWL_MVM_ESR_EXIT_LOW_RSSI = 0x20000, 380 384 IWL_MVM_ESR_EXIT_COEX = 0x40000, ··· 448 450 * @prevent_esr_done_wk: work that should be done when esr prevention ends. 449 451 * @mlo_int_scan_wk: work for the internal MLO scan. 450 452 * @unblock_esr_tpt_wk: work for unblocking EMLSR when tpt is high enough. 453 + * @roc_activity: currently running ROC activity for this vif (or 454 + * ROC_NUM_ACTIVITIES if no activity is running). 451 455 */ 452 456 struct iwl_mvm_vif { 453 457 struct iwl_mvm *mvm; ··· 527 527 528 528 struct iwl_mvm_time_event_data time_event_data; 529 529 struct iwl_mvm_time_event_data hs_time_event_data; 530 + enum iwl_roc_activity roc_activity; 530 531 531 532 /* TCP Checksum Offload */ 532 533 netdev_features_t features; ··· 612 611 }; 613 612 614 613 /** 615 - * struct iwl_mvm_tt_mgnt - Thermal Throttling Management structure 614 + * struct iwl_mvm_tt_mgmt - Thermal Throttling Management structure 616 615 * @ct_kill_exit: worker to exit thermal kill 617 616 * @dynamic_smps: Is thermal throttling enabled dynamic_smps? 618 617 * @tx_backoff: The current thremal throttling tx backoff in uSec. ··· 1066 1065 unsigned int max_scans; 1067 1066 1068 1067 /* UMAC scan tracking */ 1069 - u32 scan_uid_status[IWL_MVM_MAX_UMAC_SCANS]; 1068 + u32 scan_uid_status[IWL_MAX_UMAC_SCANS]; 1070 1069 1071 1070 /* start time of last scan in TSF of the mac that requested the scan */ 1072 1071 u64 scan_start; ··· 1156 1155 struct ieee80211_channel **nd_channels; 1157 1156 int n_nd_channels; 1158 1157 bool net_detect; 1158 + bool fast_resume; 1159 1159 u8 offload_tid; 1160 1160 #ifdef CONFIG_IWLWIFI_DEBUGFS 1161 1161 bool d3_wake_sysassert; ··· 1320 1318 bool sta_remove_requires_queue_remove; 1321 1319 bool mld_api_is_used; 1322 1320 1323 - bool pldr_sync; 1321 + /* 1322 + * Indicates that firmware will do a product reset (and then 1323 + * therefore fail to load) when we start it (due to OTP burn), 1324 + * if so don't dump errors etc. since this is expected. 1325 + */ 1326 + bool fw_product_reset; 1324 1327 1325 1328 struct iwl_time_sync_data time_sync; 1326 1329 ··· 1349 1342 * enum iwl_mvm_status - MVM status bits 1350 1343 * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted 1351 1344 * @IWL_MVM_STATUS_HW_CTKILL: CT-kill is active 1352 - * @IWL_MVM_STATUS_ROC_RUNNING: remain-on-channel is running 1345 + * @IWL_MVM_STATUS_ROC_P2P_RUNNING: remain-on-channel on P2P is running (when 1346 + * P2P is not over AUX) 1353 1347 * @IWL_MVM_STATUS_HW_RESTART_REQUESTED: HW restart was requested 1354 1348 * @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active 1355 1349 * @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running ··· 1364 1356 enum iwl_mvm_status { 1365 1357 IWL_MVM_STATUS_HW_RFKILL, 1366 1358 IWL_MVM_STATUS_HW_CTKILL, 1367 - IWL_MVM_STATUS_ROC_RUNNING, 1359 + IWL_MVM_STATUS_ROC_P2P_RUNNING, 1368 1360 IWL_MVM_STATUS_HW_RESTART_REQUESTED, 1369 1361 IWL_MVM_STATUS_IN_HW_RESTART, 1370 1362 IWL_MVM_STATUS_ROC_AUX_RUNNING, ··· 1455 1447 static inline struct ieee80211_bss_conf * 1456 1448 iwl_mvm_rcu_fw_link_id_to_link_conf(struct iwl_mvm *mvm, u8 link_id, bool rcu) 1457 1449 { 1458 - if (WARN_ON(link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf))) 1450 + if (IWL_FW_CHECK(mvm, link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf), 1451 + "erroneous FW link ID: %d\n", link_id)) 1459 1452 return NULL; 1460 1453 1461 1454 if (rcu) ··· 1741 1732 u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ 1742 1733 }; 1743 1734 1744 - void __iwl_mvm_mac_stop(struct iwl_mvm *mvm); 1735 + void __iwl_mvm_mac_stop(struct iwl_mvm *mvm, bool suspend); 1745 1736 int __iwl_mvm_mac_start(struct iwl_mvm *mvm); 1746 1737 1747 1738 /****************** ··· 1877 1868 1878 1869 static inline u8 iwl_mvm_get_valid_rx_ant(struct iwl_mvm *mvm) 1879 1870 { 1880 - u8 rx_ant = mvm->fw->valid_tx_ant; 1871 + u8 rx_ant = mvm->fw->valid_rx_ant; 1881 1872 1882 1873 if (mvm->nvm_data && mvm->nvm_data->valid_rx_ant) 1883 - rx_ant &= mvm->nvm_data->valid_tx_ant; 1874 + rx_ant &= mvm->nvm_data->valid_rx_ant; 1884 1875 1885 1876 if (mvm->set_rx_ant) 1886 1877 rx_ant &= mvm->set_rx_ant; ··· 2263 2254 #ifdef CONFIG_PM 2264 2255 void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, 2265 2256 struct ieee80211_vif *vif); 2257 + void iwl_mvm_fast_suspend(struct iwl_mvm *mvm); 2258 + int iwl_mvm_fast_resume(struct iwl_mvm *mvm); 2266 2259 #else 2267 2260 static inline void 2268 2261 iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 2269 2262 { 2263 + } 2264 + 2265 + static inline void iwl_mvm_fast_suspend(struct iwl_mvm *mvm) 2266 + { 2267 + } 2268 + 2269 + static inline int iwl_mvm_fast_resume(struct iwl_mvm *mvm) 2270 + { 2271 + return 0; 2270 2272 } 2271 2273 #endif 2272 2274 void iwl_mvm_set_wowlan_qos_seq(struct iwl_mvm_sta *mvm_ap_sta, ··· 2790 2770 sw_rfkill); 2791 2771 } 2792 2772 2773 + static inline bool iwl_mvm_has_p2p_over_aux(struct iwl_mvm *mvm) 2774 + { 2775 + u32 cmd_id = WIDE_ID(MAC_CONF_GROUP, ROC_CMD); 2776 + 2777 + return iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 0) >= 4; 2778 + } 2779 + 2793 2780 static inline bool iwl_mvm_mei_filter_scan(struct iwl_mvm *mvm, 2794 2781 struct sk_buff *skb) 2795 2782 { ··· 2831 2804 int iwl_mvm_mac_start(struct ieee80211_hw *hw); 2832 2805 void iwl_mvm_mac_reconfig_complete(struct ieee80211_hw *hw, 2833 2806 enum ieee80211_reconfig_type reconfig_type); 2834 - void iwl_mvm_mac_stop(struct ieee80211_hw *hw); 2807 + void iwl_mvm_mac_stop(struct ieee80211_hw *hw, bool suspend); 2835 2808 static inline int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) 2836 2809 { 2837 2810 return 0; ··· 2962 2935 int iwl_mvm_roc_add_cmd(struct iwl_mvm *mvm, 2963 2936 struct ieee80211_channel *channel, 2964 2937 struct ieee80211_vif *vif, 2965 - int duration, u32 activity); 2938 + int duration, enum iwl_roc_activity activity); 2966 2939 2967 2940 /* EMLSR */ 2968 2941 bool iwl_mvm_vif_has_esr_cap(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
+3 -10
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
··· 41 41 42 42 struct iwl_mvm_mod_params iwlmvm_mod_params = { 43 43 .power_scheme = IWL_POWER_SCHEME_BPS, 44 - /* rest of fields are 0 by default */ 45 44 }; 46 45 47 - module_param_named(init_dbg, iwlmvm_mod_params.init_dbg, bool, 0444); 48 - MODULE_PARM_DESC(init_dbg, 49 - "set to true to debug an ASSERT in INIT fw (default: false"); 50 46 module_param_named(power_scheme, iwlmvm_mod_params.power_scheme, int, 0444); 51 47 MODULE_PARM_DESC(power_scheme, 52 48 "power management scheme: 1-active, 2-balanced, 3-low power, default: 2"); ··· 467 471 iwl_mvm_time_sync_msmt_confirm_event, RX_HANDLER_SYNC, 468 472 struct iwl_time_msmt_cfm_notify), 469 473 RX_HANDLER_GRP(MAC_CONF_GROUP, ROC_NOTIF, 470 - iwl_mvm_rx_roc_notif, RX_HANDLER_SYNC, 474 + iwl_mvm_rx_roc_notif, RX_HANDLER_ASYNC_LOCKED, 471 475 struct iwl_roc_notif), 472 476 RX_HANDLER_GRP(SCAN_GROUP, CHANNEL_SURVEY_NOTIF, 473 477 iwl_mvm_rx_channel_survey_notif, RX_HANDLER_ASYNC_LOCKED, ··· 860 864 ret = iwl_mvm_init_mcc(mvm); 861 865 } 862 866 863 - if (!iwlmvm_mod_params.init_dbg || !ret) 864 - iwl_mvm_stop_device(mvm); 867 + iwl_mvm_stop_device(mvm); 865 868 866 869 mutex_unlock(&mvm->mutex); 867 870 wiphy_unlock(mvm->hw->wiphy); ··· 870 875 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); 871 876 872 877 /* no longer need this regardless of failure or not */ 873 - mvm->pldr_sync = false; 878 + mvm->fw_product_reset = false; 874 879 875 880 return ret; 876 881 } ··· 1495 1500 iwl_fw_flush_dumps(&mvm->fwrt); 1496 1501 iwl_fw_runtime_free(&mvm->fwrt); 1497 1502 1498 - if (iwlmvm_mod_params.init_dbg) 1499 - return op_mode; 1500 1503 iwl_phy_db_free(mvm->phy_db); 1501 1504 kfree(mvm->scan_cmd); 1502 1505 iwl_trans_op_mode_leave(trans);
+37 -35
drivers/net/wireless/intel/iwlwifi/mvm/power.c
··· 282 282 return data.allow_uapsd; 283 283 } 284 284 285 - static bool iwl_mvm_power_is_radar(struct ieee80211_vif *vif) 285 + static bool iwl_mvm_power_is_radar(struct ieee80211_bss_conf *link_conf) 286 286 { 287 287 struct ieee80211_chanctx_conf *chanctx_conf; 288 - struct ieee80211_bss_conf *link_conf; 289 - bool radar_detect = false; 290 - unsigned int link_id; 291 288 292 - rcu_read_lock(); 293 - for_each_vif_active_link(vif, link_conf, link_id) { 294 - chanctx_conf = rcu_dereference(link_conf->chanctx_conf); 295 - /* this happens on link switching, just ignore inactive ones */ 296 - if (!chanctx_conf) 297 - continue; 289 + chanctx_conf = rcu_dereference(link_conf->chanctx_conf); 298 290 299 - radar_detect = !!(chanctx_conf->def.chan->flags & 300 - IEEE80211_CHAN_RADAR); 301 - if (radar_detect) 302 - goto out; 303 - } 291 + /* this happens on link switching, just ignore inactive ones */ 292 + if (!chanctx_conf) 293 + return false; 304 294 305 - out: 306 - rcu_read_unlock(); 307 - return radar_detect; 295 + return chanctx_conf->def.chan->flags & IEEE80211_CHAN_RADAR; 308 296 } 309 297 310 298 static void iwl_mvm_power_config_skip_dtim(struct iwl_mvm *mvm, 311 299 struct ieee80211_vif *vif, 312 300 struct iwl_mac_power_cmd *cmd) 313 301 { 314 - int dtimper = vif->bss_conf.dtim_period ?: 1; 315 - int skip; 302 + struct ieee80211_bss_conf *link_conf; 303 + unsigned int min_link_skip = ~0; 304 + unsigned int link_id; 316 305 317 306 /* disable, in case we're supposed to override */ 318 307 cmd->skip_dtim_periods = 0; 319 308 cmd->flags &= ~cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); 320 309 321 - if (iwl_mvm_power_is_radar(vif)) 322 - return; 323 - 324 - if (dtimper >= 10) 325 - return; 326 - 327 310 if (!test_bit(IWL_MVM_STATUS_IN_D3, &mvm->status)) { 328 311 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_LP) 329 312 return; 330 - skip = 2; 331 - } else { 332 - int dtimper_tu = dtimper * vif->bss_conf.beacon_int; 333 - 334 - if (WARN_ON(!dtimper_tu)) 335 - return; 336 - /* configure skip over dtim up to 900 TU DTIM interval */ 337 - skip = max_t(u8, 1, 900 / dtimper_tu); 313 + cmd->skip_dtim_periods = 2; 314 + cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); 315 + return; 338 316 } 339 317 340 - cmd->skip_dtim_periods = skip; 318 + rcu_read_lock(); 319 + for_each_vif_active_link(vif, link_conf, link_id) { 320 + unsigned int dtimper = link_conf->dtim_period ?: 1; 321 + unsigned int dtimper_tu = dtimper * link_conf->beacon_int; 322 + unsigned int skip; 323 + 324 + if (dtimper >= 10 || iwl_mvm_power_is_radar(link_conf)) { 325 + rcu_read_unlock(); 326 + return; 327 + } 328 + 329 + if (WARN_ON(!dtimper_tu)) 330 + continue; 331 + 332 + /* configure skip over dtim up to 900 TU DTIM interval */ 333 + skip = max_t(int, 1, 900 / dtimper_tu); 334 + min_link_skip = min(min_link_skip, skip); 335 + } 336 + rcu_read_unlock(); 337 + 338 + /* no WARN_ON, can only happen with WARN_ON above */ 339 + if (min_link_skip == ~0) 340 + return; 341 + 342 + cmd->skip_dtim_periods = min_link_skip; 341 343 cmd->flags |= cpu_to_le16(POWER_FLAGS_SKIP_OVER_DTIM_MSK); 342 344 } 343 345
+10 -9
drivers/net/wireless/intel/iwlwifi/mvm/rs.h
··· 3 3 * 4 4 * Copyright(c) 2015 Intel Mobile Communications GmbH 5 5 * Copyright(c) 2017 Intel Deutschland GmbH 6 - * Copyright (C) 2003 - 2014, 2018 - 2023 Intel Corporation 6 + * Copyright (C) 2003 - 2014, 2018 - 2024 Intel Corporation 7 7 *****************************************************************************/ 8 8 9 9 #ifndef __rs_h__ ··· 198 198 /** 199 199 * struct iwl_lq_sta_rs_fw - rate and related statistics for RS in FW 200 200 * @last_rate_n_flags: last rate reported by FW 201 + * @pers: persistent fields 201 202 * @pers.sta_id: the id of the station 202 - * @chains: bitmask of chains reported in %chain_signal 203 - * @chain_signal: per chain signal strength 204 - * @last_rssi: last rssi reported 205 - * @drv: pointer back to the driver data 203 + * @pers.chains: bitmask of chains reported in %chain_signal 204 + * @pers.chain_signal: per chain signal strength 205 + * @pers.last_rssi: last rssi reported 206 + * @pers.drv: pointer back to the driver data 206 207 */ 207 208 struct iwl_lq_sta_rs_fw { 208 209 /* last tx rate_n_flags */ ··· 214 213 u32 sta_id; 215 214 #ifdef CONFIG_MAC80211_DEBUGFS 216 215 /** 217 - * @dbg_fixed_rate: for debug, use fixed rate if not 0 216 + * @pers.dbg_fixed_rate: for debug, use fixed rate if not 0 218 217 */ 219 218 u32 dbg_fixed_rate; 220 219 /** 221 - * @dbg_agg_frame_count_lim: for debug, max number of 220 + * @pers.dbg_agg_frame_count_lim: for debug, max number of 222 221 * frames in A-MPDU 223 222 */ 224 223 u16 dbg_agg_frame_count_lim; ··· 403 402 int tid, struct ieee80211_tx_info *info, bool ndp); 404 403 405 404 /** 406 - * iwl_rate_control_register - Register the rate control algorithm callbacks 405 + * iwl_mvm_rate_control_register - Register the rate control algorithm callbacks 407 406 * 408 407 * Since the rate control algorithm is hardware specific, there is no need 409 408 * or reason to place it as a stand alone module. The driver can call ··· 415 414 int iwl_mvm_rate_control_register(void); 416 415 417 416 /** 418 - * iwl_rate_control_unregister - Unregister the rate control callbacks 417 + * iwl_mvm_rate_control_unregister - Unregister the rate control callbacks 419 418 * 420 419 * This should be called after calling ieee80211_unregister_hw, but before 421 420 * the driver is unloaded.
+6 -21
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
··· 857 857 size = iwl_mvm_get_queue_size(sta); 858 858 } 859 859 860 - /* take the min with bc tbl entries allowed */ 861 - size = min_t(u32, size, mvm->trans->txqs.bc_tbl_size / sizeof(u16)); 862 - 863 - /* size needs to be power of 2 values for calculating read/write pointers */ 864 - size = rounddown_pow_of_two(size); 865 - 866 860 if (sta) { 867 861 struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); 868 862 struct ieee80211_link_sta *link_sta; ··· 881 887 if (!sta_mask) 882 888 return -EINVAL; 883 889 884 - do { 885 - queue = iwl_trans_txq_alloc(mvm->trans, 0, sta_mask, 886 - tid, size, timeout); 890 + queue = iwl_trans_txq_alloc(mvm->trans, 0, sta_mask, 891 + tid, size, timeout); 887 892 888 - if (queue < 0) 889 - IWL_DEBUG_TX_QUEUES(mvm, 890 - "Failed allocating TXQ of size %d for sta mask %x tid %d, ret: %d\n", 891 - size, sta_mask, tid, queue); 892 - size /= 2; 893 - } while (queue < 0 && size >= 16); 894 - 895 - if (queue < 0) 896 - return queue; 897 - 898 - IWL_DEBUG_TX_QUEUES(mvm, "Enabling TXQ #%d for sta mask 0x%x tid %d\n", 899 - queue, sta_mask, tid); 893 + if (queue >= 0) 894 + IWL_DEBUG_TX_QUEUES(mvm, 895 + "Enabling TXQ #%d for sta mask 0x%x tid %d\n", 896 + queue, sta_mask, tid); 900 897 901 898 return queue; 902 899 }
+1 -1
drivers/net/wireless/intel/iwlwifi/mvm/sta.h
··· 478 478 }; 479 479 480 480 /** 481 - * Send the STA info to the FW. 481 + * iwl_mvm_sta_send_to_fw - Send the STA info to the FW. 482 482 * 483 483 * @mvm: the iwl_mvm* to use 484 484 * @sta: the STA
+119 -63
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
··· 47 47 48 48 static void iwl_mvm_cleanup_roc(struct iwl_mvm *mvm) 49 49 { 50 + struct ieee80211_vif *bss_vif = iwl_mvm_get_bss_vif(mvm); 50 51 struct ieee80211_vif *vif = mvm->p2p_device_vif; 51 52 52 53 lockdep_assert_held(&mvm->mutex); 53 54 54 55 /* 55 - * Clear the ROC_RUNNING status bit. 56 + * Clear the ROC_P2P_RUNNING status bit. 56 57 * This will cause the TX path to drop offchannel transmissions. 57 58 * That would also be done by mac80211, but it is racy, in particular 58 59 * in the case that the time event actually completed in the firmware. ··· 63 62 * won't get stuck on the queue and be transmitted in the next 64 63 * time event. 65 64 */ 66 - if (test_and_clear_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) { 65 + if (test_and_clear_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status)) { 67 66 struct iwl_mvm_vif *mvmvif; 68 67 69 68 synchronize_net(); ··· 100 99 } 101 100 } 102 101 103 - /* Do the same for AUX ROC */ 102 + /* 103 + * P2P AUX ROC and HS2.0 ROC do not run simultaneously. 104 + * Clear the ROC_AUX_RUNNING status bit. 105 + * This will cause the TX path to drop offchannel transmissions. 106 + * That would also be done by mac80211, but it is racy, in particular 107 + * in the case that the time event actually completed in the firmware 108 + * (which is handled in iwl_mvm_te_handle_notif). 109 + */ 104 110 if (test_and_clear_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) { 105 111 synchronize_net(); 106 112 ··· 127 119 iwl_mvm_rm_aux_sta(mvm); 128 120 } 129 121 122 + if (!IS_ERR_OR_NULL(bss_vif)) 123 + iwl_mvm_unblock_esr(mvm, bss_vif, IWL_MVM_ESR_BLOCKED_ROC); 130 124 mutex_unlock(&mvm->mutex); 131 - if (vif) 132 - iwl_mvm_esr_non_bss_link(mvm, vif, 0, false); 133 125 } 134 126 135 127 void iwl_mvm_roc_done_wk(struct work_struct *wk) ··· 386 378 te_data->end_jiffies = TU_TO_EXP_TIME(te_data->duration); 387 379 388 380 if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) { 389 - set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status); 381 + set_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status); 390 382 ieee80211_ready_on_channel(mvm->hw); 391 383 } else if (te_data->id == TE_CHANNEL_SWITCH_PERIOD) { 392 384 iwl_mvm_te_handle_notify_csa(mvm, te_data, notif); ··· 396 388 } 397 389 } 398 390 391 + struct iwl_mvm_rx_roc_iterator_data { 392 + u32 activity; 393 + bool end_activity; 394 + bool found; 395 + }; 396 + 397 + static void iwl_mvm_rx_roc_iterator(void *_data, u8 *mac, 398 + struct ieee80211_vif *vif) 399 + { 400 + struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 401 + struct iwl_mvm_rx_roc_iterator_data *data = _data; 402 + 403 + if (mvmvif->roc_activity == data->activity) { 404 + data->found = true; 405 + if (data->end_activity) 406 + mvmvif->roc_activity = ROC_NUM_ACTIVITIES; 407 + } 408 + } 409 + 399 410 void iwl_mvm_rx_roc_notif(struct iwl_mvm *mvm, 400 411 struct iwl_rx_cmd_buffer *rxb) 401 412 { 402 413 struct iwl_rx_packet *pkt = rxb_addr(rxb); 403 414 struct iwl_roc_notif *notif = (void *)pkt->data; 415 + u32 activity = le32_to_cpu(notif->activity); 416 + bool started = le32_to_cpu(notif->success) && 417 + le32_to_cpu(notif->started); 418 + struct iwl_mvm_rx_roc_iterator_data data = { 419 + .activity = activity, 420 + .end_activity = !started, 421 + }; 404 422 405 - if (le32_to_cpu(notif->success) && le32_to_cpu(notif->started) && 406 - le32_to_cpu(notif->activity) == ROC_ACTIVITY_HOTSPOT) { 423 + /* Clear vif roc_activity if done (set to ROC_NUM_ACTIVITIES) */ 424 + ieee80211_iterate_active_interfaces_atomic(mvm->hw, 425 + IEEE80211_IFACE_ITER_NORMAL, 426 + iwl_mvm_rx_roc_iterator, 427 + &data); 428 + /* 429 + * It is possible that the ROC was canceled 430 + * but the notification was already fired. 431 + */ 432 + if (!data.found) 433 + return; 434 + 435 + if (started) { 407 436 set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status); 408 437 ieee80211_ready_on_channel(mvm->hw); 409 438 } else { ··· 769 724 "Couldn't send the SESSION_PROTECTION_CMD: %d\n", ret); 770 725 } 771 726 727 + static void iwl_mvm_roc_rm_cmd(struct iwl_mvm *mvm, u32 activity) 728 + { 729 + struct iwl_roc_req roc_cmd = { 730 + .action = cpu_to_le32(FW_CTXT_ACTION_REMOVE), 731 + .activity = cpu_to_le32(activity), 732 + }; 733 + int ret; 734 + 735 + lockdep_assert_held(&mvm->mutex); 736 + ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(MAC_CONF_GROUP, ROC_CMD), 0, 737 + sizeof(roc_cmd), &roc_cmd); 738 + if (ret) 739 + IWL_ERR(mvm, "Couldn't send the ROC_CMD: %d\n", ret); 740 + } 741 + 772 742 static bool __iwl_mvm_remove_time_event(struct iwl_mvm *mvm, 773 743 struct iwl_mvm_time_event_data *te_data, 774 744 u32 *uid) ··· 793 733 struct iwl_mvm_vif *mvmvif; 794 734 enum nl80211_iftype iftype; 795 735 s8 link_id; 736 + bool p2p_aux = iwl_mvm_has_p2p_over_aux(mvm); 737 + u8 roc_ver = iwl_fw_lookup_cmd_ver(mvm->fw, 738 + WIDE_ID(MAC_CONF_GROUP, ROC_CMD), 0); 796 739 797 740 if (!vif) 798 741 return false; ··· 820 757 iwl_mvm_te_clear_data(mvm, te_data); 821 758 spin_unlock_bh(&mvm->time_event_lock); 822 759 823 - /* When session protection is used, the te_data->id field 824 - * is reused to save session protection's configuration. 825 - * For AUX ROC, HOT_SPOT_CMD is used and the te_data->id field is set 826 - * to HOT_SPOT_CMD. 827 - */ 828 - if (fw_has_capa(&mvm->fw->ucode_capa, 829 - IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD) && 830 - id != HOT_SPOT_CMD) { 760 + if ((p2p_aux && iftype == NL80211_IFTYPE_P2P_DEVICE) || 761 + (roc_ver >= 3 && mvmvif->roc_activity == ROC_ACTIVITY_HOTSPOT)) { 762 + if (mvmvif->roc_activity < ROC_NUM_ACTIVITIES) { 763 + iwl_mvm_roc_rm_cmd(mvm, mvmvif->roc_activity); 764 + mvmvif->roc_activity = ROC_NUM_ACTIVITIES; 765 + iwl_mvm_roc_finished(mvm); 766 + } 767 + return false; 768 + } else if (fw_has_capa(&mvm->fw->ucode_capa, 769 + IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD) && 770 + id != HOT_SPOT_CMD) { 771 + /* When session protection is used, the te_data->id field 772 + * is reused to save session protection's configuration. 773 + * For AUX ROC, HOT_SPOT_CMD is used and the te_data->id 774 + * field is set to HOT_SPOT_CMD. 775 + */ 831 776 if (mvmvif && id < SESSION_PROTECT_CONF_MAX_ID) { 832 777 /* Session protection is still ongoing. Cancel it */ 833 778 iwl_mvm_cancel_session_protection(mvm, vif, id, ··· 1036 965 if (WARN_ON(mvmvif->time_event_data.id != 1037 966 le32_to_cpu(notif->conf_id))) 1038 967 goto out_unlock; 1039 - set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status); 968 + set_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status); 1040 969 ieee80211_ready_on_channel(mvm->hw); /* Start TE */ 1041 970 } 1042 971 ··· 1085 1014 int iwl_mvm_roc_add_cmd(struct iwl_mvm *mvm, 1086 1015 struct ieee80211_channel *channel, 1087 1016 struct ieee80211_vif *vif, 1088 - int duration, u32 activity) 1017 + int duration, enum iwl_roc_activity activity) 1089 1018 { 1090 1019 int res; 1091 1020 u32 duration_tu, delay; ··· 1094 1023 .activity = cpu_to_le32(activity), 1095 1024 .sta_id = cpu_to_le32(mvm->aux_sta.sta_id), 1096 1025 }; 1026 + struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1097 1027 1098 1028 lockdep_assert_held(&mvm->mutex); 1029 + 1030 + if (WARN_ON(mvmvif->roc_activity != ROC_NUM_ACTIVITIES)) 1031 + return -EBUSY; 1099 1032 1100 1033 /* Set the channel info data */ 1101 1034 iwl_mvm_set_chan_info(mvm, &roc_req.channel_info, ··· 1116 1041 "\t(requested = %ums, max_delay = %ums)\n", 1117 1042 duration, delay); 1118 1043 IWL_DEBUG_TE(mvm, 1119 - "Requesting to remain on channel %u for %utu\n", 1120 - channel->hw_value, duration_tu); 1044 + "Requesting to remain on channel %u for %utu. activity %u\n", 1045 + channel->hw_value, duration_tu, activity); 1121 1046 1122 1047 /* Set the node address */ 1123 1048 memcpy(roc_req.node_addr, vif->addr, ETH_ALEN); 1124 1049 1125 1050 res = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(MAC_CONF_GROUP, ROC_CMD), 1126 1051 0, sizeof(roc_req), &roc_req); 1052 + if (!res) 1053 + mvmvif->roc_activity = activity; 1127 1054 1128 1055 return res; 1129 1056 } ··· 1268 1191 __iwl_mvm_remove_time_event(mvm, te_data, &uid); 1269 1192 } 1270 1193 1271 - static void iwl_mvm_roc_rm_cmd(struct iwl_mvm *mvm, u32 activity) 1272 - { 1273 - int ret; 1274 - struct iwl_roc_req roc_cmd = { 1275 - .action = cpu_to_le32(FW_CTXT_ACTION_REMOVE), 1276 - .activity = cpu_to_le32(activity), 1277 - }; 1278 - 1279 - lockdep_assert_held(&mvm->mutex); 1280 - ret = iwl_mvm_send_cmd_pdu(mvm, 1281 - WIDE_ID(MAC_CONF_GROUP, ROC_CMD), 1282 - 0, sizeof(roc_cmd), &roc_cmd); 1283 - WARN_ON(ret); 1284 - } 1285 - 1286 - static void iwl_mvm_roc_station_remove(struct iwl_mvm *mvm, 1287 - struct iwl_mvm_vif *mvmvif) 1288 - { 1289 - u32 cmd_id = WIDE_ID(MAC_CONF_GROUP, ROC_CMD); 1290 - u8 fw_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 1291 - IWL_FW_CMD_VER_UNKNOWN); 1292 - 1293 - if (fw_ver == IWL_FW_CMD_VER_UNKNOWN) 1294 - iwl_mvm_remove_aux_roc_te(mvm, mvmvif, 1295 - &mvmvif->hs_time_event_data); 1296 - else if (fw_ver == 3) 1297 - iwl_mvm_roc_rm_cmd(mvm, ROC_ACTIVITY_HOTSPOT); 1298 - else 1299 - IWL_ERR(mvm, "ROC command version %d mismatch!\n", fw_ver); 1300 - } 1301 - 1302 1194 void iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif) 1303 1195 { 1304 - struct iwl_mvm_vif *mvmvif; 1196 + struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1305 1197 struct iwl_mvm_time_event_data *te_data; 1198 + bool p2p_aux = iwl_mvm_has_p2p_over_aux(mvm); 1199 + u8 roc_ver = iwl_fw_lookup_cmd_ver(mvm->fw, 1200 + WIDE_ID(MAC_CONF_GROUP, ROC_CMD), 0); 1201 + int iftype = vif->type; 1306 1202 1307 1203 mutex_lock(&mvm->mutex); 1308 1204 1309 - if (fw_has_capa(&mvm->fw->ucode_capa, 1310 - IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) { 1311 - mvmvif = iwl_mvm_vif_from_mac80211(vif); 1205 + if (p2p_aux || (roc_ver >= 3 && iftype != NL80211_IFTYPE_P2P_DEVICE)) { 1206 + if (mvmvif->roc_activity < ROC_NUM_ACTIVITIES) { 1207 + iwl_mvm_roc_rm_cmd(mvm, mvmvif->roc_activity); 1208 + mvmvif->roc_activity = ROC_NUM_ACTIVITIES; 1209 + } 1210 + goto cleanup_roc; 1211 + } else if (fw_has_capa(&mvm->fw->ucode_capa, 1212 + IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) { 1312 1213 te_data = &mvmvif->time_event_data; 1313 1214 1314 - if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { 1215 + if (iftype == NL80211_IFTYPE_P2P_DEVICE) { 1315 1216 if (te_data->id >= SESSION_PROTECT_CONF_MAX_ID) { 1316 1217 IWL_DEBUG_TE(mvm, 1317 1218 "No remain on channel event\n"); 1318 1219 mutex_unlock(&mvm->mutex); 1319 1220 return; 1320 1221 } 1321 - 1322 1222 iwl_mvm_cancel_session_protection(mvm, vif, 1323 1223 te_data->id, 1324 1224 te_data->link_id); 1325 1225 } else { 1326 - iwl_mvm_roc_station_remove(mvm, mvmvif); 1226 + iwl_mvm_remove_aux_roc_te(mvm, mvmvif, 1227 + &mvmvif->hs_time_event_data); 1327 1228 } 1328 1229 goto cleanup_roc; 1329 1230 } ··· 1314 1259 } 1315 1260 1316 1261 mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif); 1317 - 1318 - if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) 1262 + iftype = te_data->vif->type; 1263 + if (iftype == NL80211_IFTYPE_P2P_DEVICE) 1319 1264 iwl_mvm_remove_time_event(mvm, mvmvif, te_data); 1320 1265 else 1321 1266 iwl_mvm_remove_aux_roc_te(mvm, mvmvif, te_data); ··· 1326 1271 * (so the status bit isn't set) set it here so iwl_mvm_cleanup_roc will 1327 1272 * cleanup things properly 1328 1273 */ 1329 - set_bit(vif->type == NL80211_IFTYPE_P2P_DEVICE ? 1330 - IWL_MVM_STATUS_ROC_RUNNING : IWL_MVM_STATUS_ROC_AUX_RUNNING, 1331 - &mvm->status); 1274 + if (p2p_aux || iftype != NL80211_IFTYPE_P2P_DEVICE) 1275 + set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status); 1276 + else 1277 + set_bit(IWL_MVM_STATUS_ROC_P2P_RUNNING, &mvm->status); 1332 1278 1333 1279 /* Mutex is released inside this function */ 1334 1280 iwl_mvm_cleanup_roc(mvm);
+1 -1
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
··· 299 299 300 300 ret = iwl_mvm_get_temp(mvm, &temp); 301 301 302 - __iwl_mvm_mac_stop(mvm); 302 + __iwl_mvm_mac_stop(mvm, false); 303 303 304 304 if (ret) 305 305 goto reschedule;
+23 -15
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
··· 802 802 if (info.control.vif) { 803 803 struct iwl_mvm_vif *mvmvif = 804 804 iwl_mvm_vif_from_mac80211(info.control.vif); 805 + bool p2p_aux = iwl_mvm_has_p2p_over_aux(mvm); 805 806 806 - if (info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE || 807 - info.control.vif->type == NL80211_IFTYPE_AP || 808 - info.control.vif->type == NL80211_IFTYPE_ADHOC) { 807 + if ((info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE && 808 + p2p_aux) || 809 + (info.control.vif->type == NL80211_IFTYPE_STATION && 810 + offchannel)) { 811 + /* 812 + * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets 813 + * that can be used in 2 different types of vifs, P2P 814 + * Device and STATION. 815 + * P2P Device uses the offchannel queue. 816 + * STATION (HS2.0) uses the auxiliary context of the FW, 817 + * and hence needs to be sent on the aux queue. 818 + * If P2P_DEV_OVER_AUX is supported (p2p_aux = true) 819 + * also P2P Device uses the aux queue. 820 + */ 821 + sta_id = mvm->aux_sta.sta_id; 822 + queue = mvm->aux_queue; 823 + if (WARN_ON(queue == IWL_MVM_INVALID_QUEUE)) 824 + return -1; 825 + } else if (info.control.vif->type == 826 + NL80211_IFTYPE_P2P_DEVICE || 827 + info.control.vif->type == NL80211_IFTYPE_AP || 828 + info.control.vif->type == NL80211_IFTYPE_ADHOC) { 809 829 u32 link_id = u32_get_bits(info.control.flags, 810 830 IEEE80211_TX_CTRL_MLO_LINK); 811 831 struct iwl_mvm_vif_link_info *link; ··· 851 831 } else if (info.control.vif->type == NL80211_IFTYPE_MONITOR) { 852 832 queue = mvm->snif_queue; 853 833 sta_id = mvm->snif_sta.sta_id; 854 - } else if (info.control.vif->type == NL80211_IFTYPE_STATION && 855 - offchannel) { 856 - /* 857 - * IWL_MVM_OFFCHANNEL_QUEUE is used for ROC packets 858 - * that can be used in 2 different types of vifs, P2P & 859 - * STATION. 860 - * P2P uses the offchannel queue. 861 - * STATION (HS2.0) uses the auxiliary context of the FW, 862 - * and hence needs to be sent on the aux queue. 863 - */ 864 - sta_id = mvm->aux_sta.sta_id; 865 - queue = mvm->aux_queue; 866 834 } 867 835 } 868 836
+1 -1
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
··· 216 216 ctxt_info_gen3->cr_tail_idx_arr_base_addr = 217 217 cpu_to_le64(trans_pcie->prph_info_dma_addr + 3 * PAGE_SIZE / 4); 218 218 ctxt_info_gen3->mtr_base_addr = 219 - cpu_to_le64(trans->txqs.txq[trans->txqs.cmd.q_id]->dma_addr); 219 + cpu_to_le64(trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]->dma_addr); 220 220 ctxt_info_gen3->mcr_base_addr = 221 221 cpu_to_le64(trans_pcie->rxq->used_bd_dma); 222 222 ctxt_info_gen3->mtr_size =
+2 -2
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 3 * Copyright (C) 2017 Intel Deutschland GmbH 4 - * Copyright (C) 2018-2023 Intel Corporation 4 + * Copyright (C) 2018-2024 Intel Corporation 5 5 */ 6 6 #include "iwl-trans.h" 7 7 #include "iwl-fh.h" ··· 218 218 219 219 /* initialize TX command queue */ 220 220 ctxt_info->hcmd_cfg.cmd_queue_addr = 221 - cpu_to_le64(trans->txqs.txq[trans->txqs.cmd.q_id]->dma_addr); 221 + cpu_to_le64(trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]->dma_addr); 222 222 ctxt_info->hcmd_cfg.cmd_queue_size = 223 223 TFD_QUEUE_CB_SIZE(IWL_CMD_QUEUE_SIZE); 224 224
+31 -1
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
··· 503 503 {IWL_PCI_DEVICE(0x2727, PCI_ANY_ID, iwl_bz_trans_cfg)}, 504 504 {IWL_PCI_DEVICE(0x272D, PCI_ANY_ID, iwl_bz_trans_cfg)}, 505 505 {IWL_PCI_DEVICE(0x272b, PCI_ANY_ID, iwl_bz_trans_cfg)}, 506 - {IWL_PCI_DEVICE(0xA840, PCI_ANY_ID, iwl_bz_trans_cfg)}, 506 + {IWL_PCI_DEVICE(0xA840, 0x0000, iwl_bz_trans_cfg)}, 507 + {IWL_PCI_DEVICE(0xA840, 0x0090, iwl_bz_trans_cfg)}, 508 + {IWL_PCI_DEVICE(0xA840, 0x0094, iwl_bz_trans_cfg)}, 509 + {IWL_PCI_DEVICE(0xA840, 0x0098, iwl_bz_trans_cfg)}, 510 + {IWL_PCI_DEVICE(0xA840, 0x009C, iwl_bz_trans_cfg)}, 511 + {IWL_PCI_DEVICE(0xA840, 0x00C0, iwl_bz_trans_cfg)}, 512 + {IWL_PCI_DEVICE(0xA840, 0x00C4, iwl_bz_trans_cfg)}, 513 + {IWL_PCI_DEVICE(0xA840, 0x00E0, iwl_bz_trans_cfg)}, 514 + {IWL_PCI_DEVICE(0xA840, 0x00E4, iwl_bz_trans_cfg)}, 515 + {IWL_PCI_DEVICE(0xA840, 0x00E8, iwl_bz_trans_cfg)}, 516 + {IWL_PCI_DEVICE(0xA840, 0x00EC, iwl_bz_trans_cfg)}, 517 + {IWL_PCI_DEVICE(0xA840, 0x0100, iwl_bz_trans_cfg)}, 518 + {IWL_PCI_DEVICE(0xA840, 0x0110, iwl_bz_trans_cfg)}, 519 + {IWL_PCI_DEVICE(0xA840, 0x0114, iwl_bz_trans_cfg)}, 520 + {IWL_PCI_DEVICE(0xA840, 0x0118, iwl_bz_trans_cfg)}, 521 + {IWL_PCI_DEVICE(0xA840, 0x011C, iwl_bz_trans_cfg)}, 522 + {IWL_PCI_DEVICE(0xA840, 0x0310, iwl_bz_trans_cfg)}, 523 + {IWL_PCI_DEVICE(0xA840, 0x0314, iwl_bz_trans_cfg)}, 524 + {IWL_PCI_DEVICE(0xA840, 0x0510, iwl_bz_trans_cfg)}, 525 + {IWL_PCI_DEVICE(0xA840, 0x0A10, iwl_bz_trans_cfg)}, 526 + {IWL_PCI_DEVICE(0xA840, 0x1671, iwl_bz_trans_cfg)}, 527 + {IWL_PCI_DEVICE(0xA840, 0x1672, iwl_bz_trans_cfg)}, 528 + {IWL_PCI_DEVICE(0xA840, 0x1771, iwl_bz_trans_cfg)}, 529 + {IWL_PCI_DEVICE(0xA840, 0x1772, iwl_bz_trans_cfg)}, 530 + {IWL_PCI_DEVICE(0xA840, 0x1791, iwl_bz_trans_cfg)}, 531 + {IWL_PCI_DEVICE(0xA840, 0x1792, iwl_bz_trans_cfg)}, 532 + {IWL_PCI_DEVICE(0xA840, 0x4090, iwl_bz_trans_cfg)}, 533 + {IWL_PCI_DEVICE(0xA840, 0x40C4, iwl_bz_trans_cfg)}, 534 + {IWL_PCI_DEVICE(0xA840, 0x40E0, iwl_bz_trans_cfg)}, 535 + {IWL_PCI_DEVICE(0xA840, 0x4110, iwl_bz_trans_cfg)}, 536 + {IWL_PCI_DEVICE(0xA840, 0x4314, iwl_bz_trans_cfg)}, 507 537 {IWL_PCI_DEVICE(0x7740, PCI_ANY_ID, iwl_bz_trans_cfg)}, 508 538 {IWL_PCI_DEVICE(0x4D40, PCI_ANY_ID, iwl_bz_trans_cfg)}, 509 539
+257 -5
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2003-2015, 2018-2023 Intel Corporation 3 + * Copyright (C) 2003-2015, 2018-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 22 22 #include "iwl-io.h" 23 23 #include "iwl-op-mode.h" 24 24 #include "iwl-drv.h" 25 - #include "queue/tx.h" 26 25 #include "iwl-context-info.h" 27 26 28 27 /* ··· 272 273 }; 273 274 274 275 /** 275 - * enum wl_pcie_imr_status - imr dma transfer state 276 + * enum iwl_pcie_imr_status - imr dma transfer state 276 277 * @IMR_D2S_IDLE: default value of the dma transfer 277 278 * @IMR_D2S_REQUESTED: dma transfer requested 278 279 * @IMR_D2S_COMPLETED: dma transfer completed ··· 283 284 IMR_D2S_REQUESTED, 284 285 IMR_D2S_COMPLETED, 285 286 IMR_D2S_ERROR, 287 + }; 288 + 289 + /** 290 + * struct iwl_pcie_txqs - TX queues data 291 + * 292 + * @bc_table_dword: true if the BC table expects DWORD (as opposed to bytes) 293 + * @page_offs: offset from skb->cb to mac header page pointer 294 + * @dev_cmd_offs: offset from skb->cb to iwl_device_tx_cmd pointer 295 + * @queue_used: bit mask of used queues 296 + * @queue_stopped: bit mask of stopped queues 297 + * @txq: array of TXQ data structures representing the TXQs 298 + * @scd_bc_tbls: gen1 pointer to the byte count table of the scheduler 299 + * @queue_alloc_cmd_ver: queue allocation command version 300 + * @bc_pool: bytecount DMA allocations pool 301 + * @bc_tbl_size: bytecount table size 302 + * @tso_hdr_page: page allocated (per CPU) for A-MSDU headers when doing TSO 303 + * (and similar usage) 304 + * @cmd: command queue data 305 + * @cmd.fifo: FIFO number 306 + * @cmd.q_id: queue ID 307 + * @cmd.wdg_timeout: watchdog timeout 308 + * @tfd: TFD data 309 + * @tfd.max_tbs: max number of buffers per TFD 310 + * @tfd.size: TFD size 311 + * @tfd.addr_size: TFD/TB address size 312 + */ 313 + struct iwl_pcie_txqs { 314 + unsigned long queue_used[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)]; 315 + unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)]; 316 + struct iwl_txq *txq[IWL_MAX_TVQM_QUEUES]; 317 + struct dma_pool *bc_pool; 318 + size_t bc_tbl_size; 319 + bool bc_table_dword; 320 + u8 page_offs; 321 + u8 dev_cmd_offs; 322 + struct iwl_tso_hdr_page __percpu *tso_hdr_page; 323 + 324 + struct { 325 + u8 fifo; 326 + u8 q_id; 327 + unsigned int wdg_timeout; 328 + } cmd; 329 + 330 + struct { 331 + u8 max_tbs; 332 + u16 size; 333 + u8 addr_size; 334 + } tfd; 335 + 336 + struct iwl_dma_ptr scd_bc_tbls; 337 + 338 + u8 queue_alloc_cmd_ver; 286 339 }; 287 340 288 341 /** ··· 418 367 * @is_down: indicates the NIC is down 419 368 * @isr_stats: interrupt statistics 420 369 * @napi_dev: (fake) netdev for NAPI registration 370 + * @txqs: transport tx queues data. 421 371 */ 422 372 struct iwl_trans_pcie { 423 373 struct iwl_rxq *rxq; ··· 516 464 enum iwl_pcie_imr_status imr_status; 517 465 wait_queue_head_t imr_waitq; 518 466 char rf_name[32]; 467 + 468 + struct iwl_pcie_txqs txqs; 519 469 }; 520 470 521 471 static inline struct iwl_trans_pcie * ··· 592 538 /***************************************************** 593 539 * TX / HCMD 594 540 ******************************************************/ 541 + /* We need 2 entries for the TX command and header, and another one might 542 + * be needed for potential data in the SKB's head. The remaining ones can 543 + * be used for frags. 544 + */ 545 + #define IWL_TRANS_PCIE_MAX_FRAGS(trans_pcie) ((trans_pcie)->txqs.tfd.max_tbs - 3) 546 + 547 + struct iwl_tso_hdr_page { 548 + struct page *page; 549 + u8 *pos; 550 + }; 551 + 595 552 int iwl_pcie_tx_init(struct iwl_trans *trans); 596 553 void iwl_pcie_tx_start(struct iwl_trans *trans, u32 scd_base_addr); 597 554 int iwl_pcie_tx_stop(struct iwl_trans *trans); ··· 617 552 int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, 618 553 struct iwl_device_tx_cmd *dev_cmd, int txq_id); 619 554 void iwl_pcie_txq_check_wrptrs(struct iwl_trans *trans); 620 - int iwl_trans_pcie_send_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd); 621 555 void iwl_pcie_hcmd_complete(struct iwl_trans *trans, 622 556 struct iwl_rx_cmd_buffer *rxb); 623 557 void iwl_trans_pcie_tx_reset(struct iwl_trans *trans); 558 + int iwl_pcie_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, 559 + int slots_num, bool cmd_queue); 560 + 561 + struct iwl_tso_hdr_page *iwl_pcie_get_page_hdr(struct iwl_trans *trans, 562 + size_t len, struct sk_buff *skb); 563 + void iwl_pcie_free_tso_page(struct iwl_trans *trans, struct sk_buff *skb); 564 + 565 + static inline dma_addr_t 566 + iwl_txq_get_first_tb_dma(struct iwl_txq *txq, int idx) 567 + { 568 + return txq->first_tb_dma + 569 + sizeof(struct iwl_pcie_first_tb_buf) * idx; 570 + } 571 + 572 + static inline u16 iwl_txq_get_cmd_index(const struct iwl_txq *q, u32 index) 573 + { 574 + return index & (q->n_window - 1); 575 + } 576 + 577 + static inline void *iwl_txq_get_tfd(struct iwl_trans *trans, 578 + struct iwl_txq *txq, int idx) 579 + { 580 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 581 + 582 + if (trans->trans_cfg->gen2) 583 + idx = iwl_txq_get_cmd_index(txq, idx); 584 + 585 + return (u8 *)txq->tfds + trans_pcie->txqs.tfd.size * idx; 586 + } 587 + 588 + /* 589 + * We need this inline in case dma_addr_t is only 32-bits - since the 590 + * hardware is always 64-bit, the issue can still occur in that case, 591 + * so use u64 for 'phys' here to force the addition in 64-bit. 592 + */ 593 + static inline bool iwl_txq_crosses_4g_boundary(u64 phys, u16 len) 594 + { 595 + return upper_32_bits(phys) != upper_32_bits(phys + len); 596 + } 597 + 598 + int iwl_txq_space(struct iwl_trans *trans, const struct iwl_txq *q); 599 + 600 + static inline void iwl_txq_stop(struct iwl_trans *trans, struct iwl_txq *txq) 601 + { 602 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 603 + 604 + if (!test_and_set_bit(txq->id, trans_pcie->txqs.queue_stopped)) { 605 + iwl_op_mode_queue_full(trans->op_mode, txq->id); 606 + IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d\n", txq->id); 607 + } else { 608 + IWL_DEBUG_TX_QUEUES(trans, "hwq %d already stopped\n", 609 + txq->id); 610 + } 611 + } 612 + 613 + /** 614 + * iwl_txq_inc_wrap - increment queue index, wrap back to beginning 615 + * @trans: the transport (for configuration data) 616 + * @index: current index 617 + */ 618 + static inline int iwl_txq_inc_wrap(struct iwl_trans *trans, int index) 619 + { 620 + return ++index & 621 + (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 622 + } 623 + 624 + /** 625 + * iwl_txq_dec_wrap - decrement queue index, wrap back to end 626 + * @trans: the transport (for configuration data) 627 + * @index: current index 628 + */ 629 + static inline int iwl_txq_dec_wrap(struct iwl_trans *trans, int index) 630 + { 631 + return --index & 632 + (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 633 + } 634 + 635 + void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq); 636 + 637 + static inline void 638 + iwl_trans_pcie_wake_queue(struct iwl_trans *trans, struct iwl_txq *txq) 639 + { 640 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 641 + 642 + if (test_and_clear_bit(txq->id, trans_pcie->txqs.queue_stopped)) { 643 + IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d\n", txq->id); 644 + iwl_op_mode_queue_not_full(trans->op_mode, txq->id); 645 + } 646 + } 647 + 648 + int iwl_txq_gen2_set_tb(struct iwl_trans *trans, 649 + struct iwl_tfh_tfd *tfd, dma_addr_t addr, 650 + u16 len); 651 + 652 + static inline void iwl_txq_set_tfd_invalid_gen2(struct iwl_trans *trans, 653 + struct iwl_tfh_tfd *tfd) 654 + { 655 + tfd->num_tbs = 0; 656 + 657 + iwl_txq_gen2_set_tb(trans, tfd, trans->invalid_tx_cmd.dma, 658 + trans->invalid_tx_cmd.size); 659 + } 660 + 661 + void iwl_txq_gen2_tfd_unmap(struct iwl_trans *trans, 662 + struct iwl_cmd_meta *meta, 663 + struct iwl_tfh_tfd *tfd); 664 + 665 + int iwl_txq_dyn_alloc(struct iwl_trans *trans, u32 flags, 666 + u32 sta_mask, u8 tid, 667 + int size, unsigned int timeout); 668 + 669 + int iwl_txq_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb, 670 + struct iwl_device_tx_cmd *dev_cmd, int txq_id); 671 + 672 + void iwl_txq_dyn_free(struct iwl_trans *trans, int queue); 673 + void iwl_txq_gen2_tx_free(struct iwl_trans *trans); 674 + int iwl_txq_init(struct iwl_trans *trans, struct iwl_txq *txq, 675 + int slots_num, bool cmd_queue); 676 + int iwl_txq_gen2_init(struct iwl_trans *trans, int txq_id, 677 + int queue_size); 678 + 679 + static inline u16 iwl_txq_gen1_tfd_tb_get_len(struct iwl_trans *trans, 680 + void *_tfd, u8 idx) 681 + { 682 + struct iwl_tfd *tfd; 683 + struct iwl_tfd_tb *tb; 684 + 685 + if (trans->trans_cfg->gen2) { 686 + struct iwl_tfh_tfd *tfh_tfd = _tfd; 687 + struct iwl_tfh_tb *tfh_tb = &tfh_tfd->tbs[idx]; 688 + 689 + return le16_to_cpu(tfh_tb->tb_len); 690 + } 691 + 692 + tfd = (struct iwl_tfd *)_tfd; 693 + tb = &tfd->tbs[idx]; 694 + 695 + return le16_to_cpu(tb->hi_n_len) >> 4; 696 + } 697 + 698 + void iwl_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn, 699 + struct sk_buff_head *skbs, bool is_flush); 700 + void iwl_pcie_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr); 701 + void iwl_pcie_freeze_txq_timer(struct iwl_trans *trans, 702 + unsigned long txqs, bool freeze); 703 + int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, int txq_idx); 704 + int iwl_trans_pcie_wait_txqs_empty(struct iwl_trans *trans, u32 txq_bm); 624 705 625 706 /***************************************************** 626 707 * Error handling ··· 1033 822 1034 823 #ifdef CONFIG_IWLWIFI_DEBUGFS 1035 824 void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans); 825 + void iwl_trans_pcie_debugfs_cleanup(struct iwl_trans *trans); 1036 826 #else 1037 827 static inline void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans) { } 1038 828 #endif 1039 829 1040 830 void iwl_pcie_rx_allocator_work(struct work_struct *data); 831 + 832 + /* common trans ops for all generations transports */ 833 + void iwl_trans_pcie_configure(struct iwl_trans *trans, 834 + const struct iwl_trans_config *trans_cfg); 835 + int iwl_trans_pcie_start_hw(struct iwl_trans *trans); 836 + void iwl_trans_pcie_op_mode_leave(struct iwl_trans *trans); 837 + void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val); 838 + void iwl_trans_pcie_write32(struct iwl_trans *trans, u32 ofs, u32 val); 839 + u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs); 840 + u32 iwl_trans_pcie_read_prph(struct iwl_trans *trans, u32 reg); 841 + void iwl_trans_pcie_write_prph(struct iwl_trans *trans, u32 addr, u32 val); 842 + int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, 843 + void *buf, int dwords); 844 + int iwl_trans_pcie_write_mem(struct iwl_trans *trans, u32 addr, 845 + const void *buf, int dwords); 846 + int iwl_trans_pcie_sw_reset(struct iwl_trans *trans, bool retake_ownership); 847 + struct iwl_trans_dump_data * 848 + iwl_trans_pcie_dump_data(struct iwl_trans *trans, u32 dump_mask, 849 + const struct iwl_dump_sanitize_ops *sanitize_ops, 850 + void *sanitize_ctx); 851 + int iwl_trans_pcie_d3_resume(struct iwl_trans *trans, 852 + enum iwl_d3_status *status, 853 + bool test, bool reset); 854 + int iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test, bool reset); 855 + void iwl_trans_pci_interrupts(struct iwl_trans *trans, bool enable); 856 + void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans); 857 + void iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, u32 reg, 858 + u32 mask, u32 value); 859 + int iwl_trans_pcie_read_config32(struct iwl_trans *trans, u32 ofs, 860 + u32 *val); 861 + bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans); 862 + void iwl_trans_pcie_release_nic_access(struct iwl_trans *trans); 863 + 864 + /* transport gen 1 exported functions */ 865 + void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr); 866 + int iwl_trans_pcie_start_fw(struct iwl_trans *trans, 867 + const struct fw_img *fw, bool run_in_rfkill); 868 + void iwl_trans_pcie_stop_device(struct iwl_trans *trans); 1041 869 1042 870 /* common functions that are used by gen2 transport */ 1043 871 int iwl_pcie_gen2_apm_init(struct iwl_trans *trans); ··· 1099 849 /* transport gen 2 exported functions */ 1100 850 int iwl_trans_pcie_gen2_start_fw(struct iwl_trans *trans, 1101 851 const struct fw_img *fw, bool run_in_rfkill); 1102 - void iwl_trans_pcie_gen2_fw_alive(struct iwl_trans *trans, u32 scd_addr); 852 + void iwl_trans_pcie_gen2_fw_alive(struct iwl_trans *trans); 1103 853 int iwl_trans_pcie_gen2_send_hcmd(struct iwl_trans *trans, 1104 854 struct iwl_host_cmd *cmd); 1105 855 void iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans); ··· 1114 864 u32 dst_addr, u64 src_addr, u32 byte_cnt); 1115 865 int iwl_trans_pcie_copy_imr(struct iwl_trans *trans, 1116 866 u32 dst_addr, u64 src_addr, u32 byte_cnt); 867 + int iwl_trans_pcie_rxq_dma_data(struct iwl_trans *trans, int queue, 868 + struct iwl_trans_rxq_dma_data *data); 1117 869 1118 870 #endif /* __iwl_trans_int_pcie_h__ */
+5 -4
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 - * Copyright (C) 2003-2014, 2018-2023 Intel Corporation 3 + * Copyright (C) 2003-2014, 2018-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 1301 1301 int i) 1302 1302 { 1303 1303 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1304 - struct iwl_txq *txq = trans->txqs.txq[trans->txqs.cmd.q_id]; 1304 + struct iwl_txq *txq = trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]; 1305 1305 bool page_stolen = false; 1306 1306 int max_len = trans_pcie->rx_buf_bytes; 1307 1307 u32 offset = 0; ··· 1678 1678 */ 1679 1679 static void iwl_pcie_irq_handle_error(struct iwl_trans *trans) 1680 1680 { 1681 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1681 1682 int i; 1682 1683 1683 1684 /* W/A for WiFi/WiMAX coex and WiMAX own the RF */ ··· 1695 1694 } 1696 1695 1697 1696 for (i = 0; i < trans->trans_cfg->base_params->num_of_queues; i++) { 1698 - if (!trans->txqs.txq[i]) 1697 + if (!trans_pcie->txqs.txq[i]) 1699 1698 continue; 1700 - del_timer(&trans->txqs.txq[i]->stuck_timer); 1699 + del_timer(&trans_pcie->txqs.txq[i]->stuck_timer); 1701 1700 } 1702 1701 1703 1702 /* The STATUS_FW_ERROR bit is set in this function. This must happen
+7 -6
drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 3 * Copyright (C) 2017 Intel Deutschland GmbH 4 - * Copyright (C) 2018-2023 Intel Corporation 4 + * Copyright (C) 2018-2024 Intel Corporation 5 5 */ 6 6 #include "iwl-trans.h" 7 7 #include "iwl-prph.h" ··· 247 247 return -ENOMEM; 248 248 249 249 /* Allocate or reset and init all Tx and Command queues */ 250 - if (iwl_txq_gen2_init(trans, trans->txqs.cmd.q_id, queue_size)) 250 + if (iwl_txq_gen2_init(trans, trans_pcie->txqs.cmd.q_id, queue_size)) 251 251 return -ENOMEM; 252 252 253 253 /* enable shadow regs in HW */ ··· 339 339 pos += scnprintf(buf + pos, buflen - pos, "\n"); 340 340 } 341 341 342 - void iwl_trans_pcie_gen2_fw_alive(struct iwl_trans *trans, u32 scd_addr) 342 + void iwl_trans_pcie_gen2_fw_alive(struct iwl_trans *trans) 343 343 { 344 344 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 345 345 346 346 iwl_pcie_reset_ict(trans); 347 347 348 348 /* make sure all queue are not stopped/used */ 349 - memset(trans->txqs.queue_stopped, 0, 350 - sizeof(trans->txqs.queue_stopped)); 351 - memset(trans->txqs.queue_used, 0, sizeof(trans->txqs.queue_used)); 349 + memset(trans_pcie->txqs.queue_stopped, 0, 350 + sizeof(trans_pcie->txqs.queue_stopped)); 351 + memset(trans_pcie->txqs.queue_used, 0, 352 + sizeof(trans_pcie->txqs.queue_used)); 352 353 353 354 /* now that we got alive we can free the fw image & the context info. 354 355 * paging memory cannot be freed included since FW will still use it
+140 -155
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 - * Copyright (C) 2007-2015, 2018-2023 Intel Corporation 3 + * Copyright (C) 2007-2015, 2018-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ ··· 127 127 kfree(buf); 128 128 } 129 129 130 - static int iwl_trans_pcie_sw_reset(struct iwl_trans *trans, 131 - bool retake_ownership) 130 + int iwl_trans_pcie_sw_reset(struct iwl_trans *trans, bool retake_ownership) 132 131 { 133 132 /* Reset entire device - do controller reset (results in SHRD_HW_RST) */ 134 133 if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) { ··· 1335 1336 } 1336 1337 } 1337 1338 1338 - static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, 1339 - const struct fw_img *fw, bool run_in_rfkill) 1339 + int iwl_trans_pcie_start_fw(struct iwl_trans *trans, 1340 + const struct fw_img *fw, bool run_in_rfkill) 1340 1341 { 1341 1342 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1342 1343 bool hw_rfkill; ··· 1422 1423 return ret; 1423 1424 } 1424 1425 1425 - static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr) 1426 + void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr) 1426 1427 { 1427 1428 iwl_pcie_reset_ict(trans); 1428 1429 iwl_pcie_tx_start(trans, scd_addr); ··· 1457 1458 iwl_trans_pcie_rf_kill(trans, hw_rfkill, false); 1458 1459 } 1459 1460 1460 - static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) 1461 + void iwl_trans_pcie_stop_device(struct iwl_trans *trans) 1461 1462 { 1462 1463 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1463 1464 bool was_in_rfkill; ··· 1504 1505 1505 1506 iwl_pcie_synchronize_irqs(trans); 1506 1507 1507 - iwl_clear_bit(trans, CSR_GP_CNTRL, 1508 - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 1509 - iwl_clear_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 1508 + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) { 1509 + iwl_clear_bit(trans, CSR_GP_CNTRL, 1510 + CSR_GP_CNTRL_REG_FLAG_BZ_MAC_ACCESS_REQ); 1511 + iwl_clear_bit(trans, CSR_GP_CNTRL, 1512 + CSR_GP_CNTRL_REG_FLAG_MAC_INIT); 1513 + } else { 1514 + iwl_clear_bit(trans, CSR_GP_CNTRL, 1515 + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 1516 + iwl_clear_bit(trans, CSR_GP_CNTRL, 1517 + CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 1518 + } 1510 1519 1511 1520 if (reset) { 1512 1521 /* ··· 1559 1552 return 0; 1560 1553 } 1561 1554 1562 - static int iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test, 1563 - bool reset) 1555 + int iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test, bool reset) 1564 1556 { 1565 1557 int ret; 1566 1558 ··· 1577 1571 return 0; 1578 1572 } 1579 1573 1580 - static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans, 1581 - enum iwl_d3_status *status, 1582 - bool test, bool reset) 1574 + int iwl_trans_pcie_d3_resume(struct iwl_trans *trans, 1575 + enum iwl_d3_status *status, 1576 + bool test, bool reset) 1583 1577 { 1584 1578 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1585 1579 u32 val; ··· 1592 1586 goto out; 1593 1587 } 1594 1588 1595 - iwl_set_bit(trans, CSR_GP_CNTRL, 1596 - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 1589 + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) 1590 + iwl_set_bit(trans, CSR_GP_CNTRL, 1591 + CSR_GP_CNTRL_REG_FLAG_BZ_MAC_ACCESS_REQ); 1592 + else 1593 + iwl_set_bit(trans, CSR_GP_CNTRL, 1594 + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 1597 1595 1598 1596 ret = iwl_finish_nic_init(trans); 1599 1597 if (ret) ··· 1884 1874 return 0; 1885 1875 } 1886 1876 1887 - static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) 1877 + int iwl_trans_pcie_start_hw(struct iwl_trans *trans) 1888 1878 { 1889 1879 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1890 1880 int ret; ··· 1896 1886 return ret; 1897 1887 } 1898 1888 1899 - static void iwl_trans_pcie_op_mode_leave(struct iwl_trans *trans) 1889 + void iwl_trans_pcie_op_mode_leave(struct iwl_trans *trans) 1900 1890 { 1901 1891 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1902 1892 ··· 1916 1906 iwl_pcie_synchronize_irqs(trans); 1917 1907 } 1918 1908 1919 - static void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val) 1909 + void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val) 1920 1910 { 1921 1911 writeb(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); 1922 1912 } 1923 1913 1924 - static void iwl_trans_pcie_write32(struct iwl_trans *trans, u32 ofs, u32 val) 1914 + void iwl_trans_pcie_write32(struct iwl_trans *trans, u32 ofs, u32 val) 1925 1915 { 1926 1916 writel(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); 1927 1917 } 1928 1918 1929 - static u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs) 1919 + u32 iwl_trans_pcie_read32(struct iwl_trans *trans, u32 ofs) 1930 1920 { 1931 1921 return readl(IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); 1932 1922 } ··· 1939 1929 return 0x000FFFFF; 1940 1930 } 1941 1931 1942 - static u32 iwl_trans_pcie_read_prph(struct iwl_trans *trans, u32 reg) 1932 + u32 iwl_trans_pcie_read_prph(struct iwl_trans *trans, u32 reg) 1943 1933 { 1944 1934 u32 mask = iwl_trans_pcie_prph_msk(trans); 1945 1935 ··· 1948 1938 return iwl_trans_pcie_read32(trans, HBUS_TARG_PRPH_RDAT); 1949 1939 } 1950 1940 1951 - static void iwl_trans_pcie_write_prph(struct iwl_trans *trans, u32 addr, 1952 - u32 val) 1941 + void iwl_trans_pcie_write_prph(struct iwl_trans *trans, u32 addr, u32 val) 1953 1942 { 1954 1943 u32 mask = iwl_trans_pcie_prph_msk(trans); 1955 1944 ··· 1957 1948 iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WDAT, val); 1958 1949 } 1959 1950 1960 - static void iwl_trans_pcie_configure(struct iwl_trans *trans, 1961 - const struct iwl_trans_config *trans_cfg) 1951 + void iwl_trans_pcie_configure(struct iwl_trans *trans, 1952 + const struct iwl_trans_config *trans_cfg) 1962 1953 { 1963 1954 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1964 1955 1965 1956 /* free all first - we might be reconfigured for a different size */ 1966 1957 iwl_pcie_free_rbs_pool(trans); 1967 1958 1968 - trans->txqs.cmd.q_id = trans_cfg->cmd_queue; 1969 - trans->txqs.cmd.fifo = trans_cfg->cmd_fifo; 1970 - trans->txqs.cmd.wdg_timeout = trans_cfg->cmd_q_wdg_timeout; 1971 - trans->txqs.page_offs = trans_cfg->cb_data_offs; 1972 - trans->txqs.dev_cmd_offs = trans_cfg->cb_data_offs + sizeof(void *); 1973 - trans->txqs.queue_alloc_cmd_ver = trans_cfg->queue_alloc_cmd_ver; 1959 + trans_pcie->txqs.cmd.q_id = trans_cfg->cmd_queue; 1960 + trans_pcie->txqs.cmd.fifo = trans_cfg->cmd_fifo; 1961 + trans_pcie->txqs.cmd.wdg_timeout = trans_cfg->cmd_q_wdg_timeout; 1962 + trans_pcie->txqs.page_offs = trans_cfg->cb_data_offs; 1963 + trans_pcie->txqs.dev_cmd_offs = trans_cfg->cb_data_offs + sizeof(void *); 1964 + trans_pcie->txqs.queue_alloc_cmd_ver = trans_cfg->queue_alloc_cmd_ver; 1974 1965 1975 1966 if (WARN_ON(trans_cfg->n_no_reclaim_cmds > MAX_NO_RECLAIM_CMDS)) 1976 1967 trans_pcie->n_no_reclaim_cmds = 0; ··· 1989 1980 if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) 1990 1981 trans_pcie->supported_dma_mask = DMA_BIT_MASK(11); 1991 1982 1992 - trans->txqs.bc_table_dword = trans_cfg->bc_table_dword; 1983 + trans_pcie->txqs.bc_table_dword = trans_cfg->bc_table_dword; 1993 1984 trans_pcie->scd_set_active = trans_cfg->scd_set_active; 1994 1985 1995 1986 trans->command_groups = trans_cfg->command_groups; ··· 2088 2079 trans->dev); 2089 2080 2090 2081 mutex_destroy(&trans_pcie->mutex); 2091 - iwl_trans_free(trans); 2092 - } 2093 2082 2094 - static void iwl_trans_pcie_set_pmi(struct iwl_trans *trans, bool state) 2095 - { 2096 - if (state) 2097 - set_bit(STATUS_TPOWER_PMI, &trans->status); 2098 - else 2099 - clear_bit(STATUS_TPOWER_PMI, &trans->status); 2083 + if (trans_pcie->txqs.tso_hdr_page) { 2084 + for_each_possible_cpu(i) { 2085 + struct iwl_tso_hdr_page *p = 2086 + per_cpu_ptr(trans_pcie->txqs.tso_hdr_page, i); 2087 + 2088 + if (p && p->page) 2089 + __free_page(p->page); 2090 + } 2091 + 2092 + free_percpu(trans_pcie->txqs.tso_hdr_page); 2093 + } 2094 + 2095 + iwl_trans_free(trans); 2100 2096 } 2101 2097 2102 2098 struct iwl_trans_pcie_removal { ··· 2267 2253 return true; 2268 2254 } 2269 2255 2270 - static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans) 2256 + bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans) 2271 2257 { 2272 2258 bool ret; 2273 2259 ··· 2281 2267 return false; 2282 2268 } 2283 2269 2284 - static void iwl_trans_pcie_release_nic_access(struct iwl_trans *trans) 2270 + void iwl_trans_pcie_release_nic_access(struct iwl_trans *trans) 2285 2271 { 2286 2272 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2287 2273 ··· 2311 2297 spin_unlock_bh(&trans_pcie->reg_lock); 2312 2298 } 2313 2299 2314 - static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, 2315 - void *buf, int dwords) 2300 + int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr, 2301 + void *buf, int dwords) 2316 2302 { 2317 2303 #define IWL_MAX_HW_ERRS 5 2318 2304 unsigned int num_consec_hw_errors = 0; ··· 2361 2347 return 0; 2362 2348 } 2363 2349 2364 - static int iwl_trans_pcie_write_mem(struct iwl_trans *trans, u32 addr, 2365 - const void *buf, int dwords) 2350 + int iwl_trans_pcie_write_mem(struct iwl_trans *trans, u32 addr, 2351 + const void *buf, int dwords) 2366 2352 { 2367 2353 int offs, ret = 0; 2368 2354 const u32 *vals = buf; ··· 2379 2365 return ret; 2380 2366 } 2381 2367 2382 - static int iwl_trans_pcie_read_config32(struct iwl_trans *trans, u32 ofs, 2383 - u32 *val) 2368 + int iwl_trans_pcie_read_config32(struct iwl_trans *trans, u32 ofs, 2369 + u32 *val) 2384 2370 { 2385 2371 return pci_read_config_dword(IWL_TRANS_GET_PCIE_TRANS(trans)->pci_dev, 2386 2372 ofs, val); ··· 2388 2374 2389 2375 #define IWL_FLUSH_WAIT_MS 2000 2390 2376 2391 - static int iwl_trans_pcie_rxq_dma_data(struct iwl_trans *trans, int queue, 2392 - struct iwl_trans_rxq_dma_data *data) 2377 + int iwl_trans_pcie_rxq_dma_data(struct iwl_trans *trans, int queue, 2378 + struct iwl_trans_rxq_dma_data *data) 2393 2379 { 2394 2380 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2395 2381 ··· 2404 2390 return 0; 2405 2391 } 2406 2392 2407 - static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, int txq_idx) 2393 + int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans, int txq_idx) 2408 2394 { 2395 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2409 2396 struct iwl_txq *txq; 2410 2397 unsigned long now = jiffies; 2411 2398 bool overflow_tx; ··· 2416 2401 if (test_bit(STATUS_TRANS_DEAD, &trans->status)) 2417 2402 return -ENODEV; 2418 2403 2419 - if (!test_bit(txq_idx, trans->txqs.queue_used)) 2404 + if (!test_bit(txq_idx, trans_pcie->txqs.queue_used)) 2420 2405 return -EINVAL; 2421 2406 2422 2407 IWL_DEBUG_TX_QUEUES(trans, "Emptying queue %d...\n", txq_idx); 2423 - txq = trans->txqs.txq[txq_idx]; 2408 + txq = trans_pcie->txqs.txq[txq_idx]; 2424 2409 2425 2410 spin_lock_bh(&txq->lock); 2426 2411 overflow_tx = txq->overflow_tx || ··· 2466 2451 return 0; 2467 2452 } 2468 2453 2469 - static int iwl_trans_pcie_wait_txqs_empty(struct iwl_trans *trans, u32 txq_bm) 2454 + int iwl_trans_pcie_wait_txqs_empty(struct iwl_trans *trans, u32 txq_bm) 2470 2455 { 2456 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2471 2457 int cnt; 2472 2458 int ret = 0; 2473 2459 ··· 2477 2461 cnt < trans->trans_cfg->base_params->num_of_queues; 2478 2462 cnt++) { 2479 2463 2480 - if (cnt == trans->txqs.cmd.q_id) 2464 + if (cnt == trans_pcie->txqs.cmd.q_id) 2481 2465 continue; 2482 - if (!test_bit(cnt, trans->txqs.queue_used)) 2466 + if (!test_bit(cnt, trans_pcie->txqs.queue_used)) 2483 2467 continue; 2484 2468 if (!(BIT(cnt) & txq_bm)) 2485 2469 continue; ··· 2492 2476 return ret; 2493 2477 } 2494 2478 2495 - static void iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, u32 reg, 2496 - u32 mask, u32 value) 2479 + void iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, u32 reg, 2480 + u32 mask, u32 value) 2497 2481 { 2498 2482 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2499 2483 ··· 2652 2636 struct iwl_dbgfs_tx_queue_priv *priv = seq->private; 2653 2637 struct iwl_dbgfs_tx_queue_state *state = v; 2654 2638 struct iwl_trans *trans = priv->trans; 2655 - struct iwl_txq *txq = trans->txqs.txq[state->pos]; 2639 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 2640 + struct iwl_txq *txq = trans_pcie->txqs.txq[state->pos]; 2656 2641 2657 2642 seq_printf(seq, "hwq %.3u: used=%d stopped=%d ", 2658 2643 (unsigned int)state->pos, 2659 - !!test_bit(state->pos, trans->txqs.queue_used), 2660 - !!test_bit(state->pos, trans->txqs.queue_stopped)); 2644 + !!test_bit(state->pos, trans_pcie->txqs.queue_used), 2645 + !!test_bit(state->pos, trans_pcie->txqs.queue_stopped)); 2661 2646 if (txq) 2662 2647 seq_printf(seq, 2663 2648 "read=%u write=%u need_update=%d frozen=%d n_window=%d ampdu=%d", ··· 2668 2651 else 2669 2652 seq_puts(seq, "(unallocated)"); 2670 2653 2671 - if (state->pos == trans->txqs.cmd.q_id) 2654 + if (state->pos == trans_pcie->txqs.cmd.q_id) 2672 2655 seq_puts(seq, " (HCMD)"); 2673 2656 seq_puts(seq, "\n"); 2674 2657 ··· 3072 3055 DEBUGFS_ADD_FILE(rf, dir, 0400); 3073 3056 } 3074 3057 3075 - static void iwl_trans_pcie_debugfs_cleanup(struct iwl_trans *trans) 3058 + void iwl_trans_pcie_debugfs_cleanup(struct iwl_trans *trans) 3076 3059 { 3077 3060 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 3078 3061 struct cont_rec *data = &trans_pcie->fw_mon_data; ··· 3085 3068 3086 3069 static u32 iwl_trans_pcie_get_cmdlen(struct iwl_trans *trans, void *tfd) 3087 3070 { 3071 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 3088 3072 u32 cmdlen = 0; 3089 3073 int i; 3090 3074 3091 - for (i = 0; i < trans->txqs.tfd.max_tbs; i++) 3075 + for (i = 0; i < trans_pcie->txqs.tfd.max_tbs; i++) 3092 3076 cmdlen += iwl_txq_gen1_tfd_tb_get_len(trans, tfd, i); 3093 3077 3094 3078 return cmdlen; ··· 3350 3332 return 0; 3351 3333 } 3352 3334 3353 - static struct iwl_trans_dump_data * 3354 - iwl_trans_pcie_dump_data(struct iwl_trans *trans, 3355 - u32 dump_mask, 3335 + struct iwl_trans_dump_data * 3336 + iwl_trans_pcie_dump_data(struct iwl_trans *trans, u32 dump_mask, 3356 3337 const struct iwl_dump_sanitize_ops *sanitize_ops, 3357 3338 void *sanitize_ctx) 3358 3339 { 3359 3340 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 3360 3341 struct iwl_fw_error_dump_data *data; 3361 - struct iwl_txq *cmdq = trans->txqs.txq[trans->txqs.cmd.q_id]; 3342 + struct iwl_txq *cmdq = trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]; 3362 3343 struct iwl_fw_error_dump_txcmd *txcmd; 3363 3344 struct iwl_trans_dump_data *dump_data; 3364 3345 u32 len, num_rbs = 0, monitor_len = 0; ··· 3424 3407 data = (void *)dump_data->data; 3425 3408 3426 3409 if (dump_mask & BIT(IWL_FW_ERROR_DUMP_TXCMD) && cmdq) { 3427 - u16 tfd_size = trans->txqs.tfd.size; 3410 + u16 tfd_size = trans_pcie->txqs.tfd.size; 3428 3411 3429 3412 data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_TXCMD); 3430 3413 txcmd = (void *)data->data; ··· 3500 3483 return dump_data; 3501 3484 } 3502 3485 3503 - static void iwl_trans_pci_interrupts(struct iwl_trans *trans, bool enable) 3486 + void iwl_trans_pci_interrupts(struct iwl_trans *trans, bool enable) 3504 3487 { 3505 3488 if (enable) 3506 3489 iwl_enable_interrupts(trans); ··· 3508 3491 iwl_disable_interrupts(trans); 3509 3492 } 3510 3493 3511 - static void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans) 3494 + void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans) 3512 3495 { 3513 3496 u32 inta_addr, sw_err_bit; 3514 3497 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); ··· 3527 3510 iwl_trans_sync_nmi_with_addr(trans, inta_addr, sw_err_bit); 3528 3511 } 3529 3512 3530 - #define IWL_TRANS_COMMON_OPS \ 3531 - .op_mode_leave = iwl_trans_pcie_op_mode_leave, \ 3532 - .write8 = iwl_trans_pcie_write8, \ 3533 - .write32 = iwl_trans_pcie_write32, \ 3534 - .read32 = iwl_trans_pcie_read32, \ 3535 - .read_prph = iwl_trans_pcie_read_prph, \ 3536 - .write_prph = iwl_trans_pcie_write_prph, \ 3537 - .read_mem = iwl_trans_pcie_read_mem, \ 3538 - .write_mem = iwl_trans_pcie_write_mem, \ 3539 - .read_config32 = iwl_trans_pcie_read_config32, \ 3540 - .configure = iwl_trans_pcie_configure, \ 3541 - .set_pmi = iwl_trans_pcie_set_pmi, \ 3542 - .sw_reset = iwl_trans_pcie_sw_reset, \ 3543 - .grab_nic_access = iwl_trans_pcie_grab_nic_access, \ 3544 - .release_nic_access = iwl_trans_pcie_release_nic_access, \ 3545 - .set_bits_mask = iwl_trans_pcie_set_bits_mask, \ 3546 - .dump_data = iwl_trans_pcie_dump_data, \ 3547 - .d3_suspend = iwl_trans_pcie_d3_suspend, \ 3548 - .d3_resume = iwl_trans_pcie_d3_resume, \ 3549 - .interrupts = iwl_trans_pci_interrupts, \ 3550 - .sync_nmi = iwl_trans_pcie_sync_nmi, \ 3551 - .imr_dma_data = iwl_trans_pcie_copy_imr \ 3552 - 3553 - static const struct iwl_trans_ops trans_ops_pcie = { 3554 - IWL_TRANS_COMMON_OPS, 3555 - .start_hw = iwl_trans_pcie_start_hw, 3556 - .fw_alive = iwl_trans_pcie_fw_alive, 3557 - .start_fw = iwl_trans_pcie_start_fw, 3558 - .stop_device = iwl_trans_pcie_stop_device, 3559 - 3560 - .send_cmd = iwl_pcie_enqueue_hcmd, 3561 - 3562 - .tx = iwl_trans_pcie_tx, 3563 - .reclaim = iwl_txq_reclaim, 3564 - 3565 - .txq_disable = iwl_trans_pcie_txq_disable, 3566 - .txq_enable = iwl_trans_pcie_txq_enable, 3567 - 3568 - .txq_set_shared_mode = iwl_trans_pcie_txq_set_shared_mode, 3569 - 3570 - .wait_tx_queues_empty = iwl_trans_pcie_wait_txqs_empty, 3571 - 3572 - .freeze_txq_timer = iwl_trans_txq_freeze_timer, 3573 - #ifdef CONFIG_IWLWIFI_DEBUGFS 3574 - .debugfs_cleanup = iwl_trans_pcie_debugfs_cleanup, 3575 - #endif 3576 - }; 3577 - 3578 - static const struct iwl_trans_ops trans_ops_pcie_gen2 = { 3579 - IWL_TRANS_COMMON_OPS, 3580 - .start_hw = iwl_trans_pcie_start_hw, 3581 - .fw_alive = iwl_trans_pcie_gen2_fw_alive, 3582 - .start_fw = iwl_trans_pcie_gen2_start_fw, 3583 - .stop_device = iwl_trans_pcie_gen2_stop_device, 3584 - 3585 - .send_cmd = iwl_pcie_gen2_enqueue_hcmd, 3586 - 3587 - .tx = iwl_txq_gen2_tx, 3588 - .reclaim = iwl_txq_reclaim, 3589 - 3590 - .set_q_ptrs = iwl_txq_set_q_ptrs, 3591 - 3592 - .txq_alloc = iwl_txq_dyn_alloc, 3593 - .txq_free = iwl_txq_dyn_free, 3594 - .wait_txq_empty = iwl_trans_pcie_wait_txq_empty, 3595 - .rxq_dma_data = iwl_trans_pcie_rxq_dma_data, 3596 - .load_pnvm = iwl_trans_pcie_ctx_info_gen3_load_pnvm, 3597 - .set_pnvm = iwl_trans_pcie_ctx_info_gen3_set_pnvm, 3598 - .load_reduce_power = iwl_trans_pcie_ctx_info_gen3_load_reduce_power, 3599 - .set_reduce_power = iwl_trans_pcie_ctx_info_gen3_set_reduce_power, 3600 - #ifdef CONFIG_IWLWIFI_DEBUGFS 3601 - .debugfs_cleanup = iwl_trans_pcie_debugfs_cleanup, 3602 - #endif 3603 - }; 3604 - 3605 3513 struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, 3606 3514 const struct pci_device_id *ent, 3607 3515 const struct iwl_cfg_trans_params *cfg_trans) ··· 3534 3592 struct iwl_trans_pcie *trans_pcie, **priv; 3535 3593 struct iwl_trans *trans; 3536 3594 int ret, addr_size; 3537 - const struct iwl_trans_ops *ops = &trans_ops_pcie_gen2; 3538 3595 void __iomem * const *table; 3539 3596 u32 bar0; 3540 - 3541 - if (!cfg_trans->gen2) 3542 - ops = &trans_ops_pcie; 3543 3597 3544 3598 /* reassign our BAR 0 if invalid due to possible runtime PM races */ 3545 3599 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &bar0); ··· 3549 3611 if (ret) 3550 3612 return ERR_PTR(ret); 3551 3613 3552 - trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), &pdev->dev, ops, 3614 + trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), &pdev->dev, 3553 3615 cfg_trans); 3554 3616 if (!trans) 3555 3617 return ERR_PTR(-ENOMEM); 3556 3618 3557 3619 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 3620 + 3621 + if (trans->trans_cfg->gen2) { 3622 + trans_pcie->txqs.tfd.addr_size = 64; 3623 + trans_pcie->txqs.tfd.max_tbs = IWL_TFH_NUM_TBS; 3624 + trans_pcie->txqs.tfd.size = sizeof(struct iwl_tfh_tfd); 3625 + } else { 3626 + trans_pcie->txqs.tfd.addr_size = 36; 3627 + trans_pcie->txqs.tfd.max_tbs = IWL_NUM_OF_TBS; 3628 + trans_pcie->txqs.tfd.size = sizeof(struct iwl_tfd); 3629 + } 3630 + trans->max_skb_frags = IWL_TRANS_PCIE_MAX_FRAGS(trans_pcie); 3631 + 3632 + trans_pcie->txqs.tso_hdr_page = alloc_percpu(struct iwl_tso_hdr_page); 3633 + if (!trans_pcie->txqs.tso_hdr_page) { 3634 + ret = -ENOMEM; 3635 + goto out_free_trans; 3636 + } 3637 + 3638 + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) 3639 + trans_pcie->txqs.bc_tbl_size = 3640 + sizeof(struct iwl_gen3_bc_tbl_entry) * TFD_QUEUE_BC_SIZE_GEN3_BZ; 3641 + else if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) 3642 + trans_pcie->txqs.bc_tbl_size = 3643 + sizeof(struct iwl_gen3_bc_tbl_entry) * TFD_QUEUE_BC_SIZE_GEN3_AX210; 3644 + else 3645 + trans_pcie->txqs.bc_tbl_size = sizeof(struct iwlagn_scd_bc_tbl); 3646 + /* 3647 + * For gen2 devices, we use a single allocation for each byte-count 3648 + * table, but they're pretty small (1k) so use a DMA pool that we 3649 + * allocate here. 3650 + */ 3651 + if (trans->trans_cfg->gen2) { 3652 + trans_pcie->txqs.bc_pool = 3653 + dmam_pool_create("iwlwifi:bc", trans->dev, 3654 + trans_pcie->txqs.bc_tbl_size, 3655 + 256, 0); 3656 + if (!trans_pcie->txqs.bc_pool) { 3657 + ret = -ENOMEM; 3658 + goto out_free_tso; 3659 + } 3660 + } 3661 + 3662 + /* Some things must not change even if the config does */ 3663 + WARN_ON(trans_pcie->txqs.tfd.addr_size != 3664 + (trans->trans_cfg->gen2 ? 64 : 36)); 3558 3665 3559 3666 /* Initialize NAPI here - it should be before registering to mac80211 3560 3667 * in the opmode but after the HW struct is allocated. ··· 3607 3624 trans_pcie->napi_dev = alloc_netdev_dummy(sizeof(struct iwl_trans_pcie *)); 3608 3625 if (!trans_pcie->napi_dev) { 3609 3626 ret = -ENOMEM; 3610 - goto out_free_trans; 3627 + goto out_free_tso; 3611 3628 } 3612 3629 /* The private struct in netdev is a pointer to struct iwl_trans_pcie */ 3613 3630 priv = netdev_priv(trans_pcie->napi_dev); ··· 3646 3663 3647 3664 pci_set_master(pdev); 3648 3665 3649 - addr_size = trans->txqs.tfd.addr_size; 3666 + addr_size = trans_pcie->txqs.tfd.addr_size; 3650 3667 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(addr_size)); 3651 3668 if (ret) { 3652 3669 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); ··· 3749 3766 destroy_workqueue(trans_pcie->rba.alloc_wq); 3750 3767 out_free_ndev: 3751 3768 free_netdev(trans_pcie->napi_dev); 3769 + out_free_tso: 3770 + free_percpu(trans_pcie->txqs.tso_hdr_page); 3752 3771 out_free_trans: 3753 3772 iwl_trans_free(trans); 3754 3773 return ERR_PTR(ret);
+1125 -5
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 3 * Copyright (C) 2017 Intel Deutschland GmbH 4 - * Copyright (C) 2018-2020, 2023 Intel Corporation 4 + * Copyright (C) 2018-2020, 2023-2024 Intel Corporation 5 5 */ 6 6 #include <net/tso.h> 7 7 #include <linux/tcp.h> ··· 11 11 #include "iwl-io.h" 12 12 #include "internal.h" 13 13 #include "fw/api/tx.h" 14 - #include "queue/tx.h" 14 + #include "fw/api/commands.h" 15 + #include "fw/api/datapath.h" 16 + #include "iwl-scd.h" 17 + 18 + static struct page *get_workaround_page(struct iwl_trans *trans, 19 + struct sk_buff *skb) 20 + { 21 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 22 + struct page **page_ptr; 23 + struct page *ret; 24 + 25 + page_ptr = (void *)((u8 *)skb->cb + trans_pcie->txqs.page_offs); 26 + 27 + ret = alloc_page(GFP_ATOMIC); 28 + if (!ret) 29 + return NULL; 30 + 31 + /* set the chaining pointer to the previous page if there */ 32 + *(void **)((u8 *)page_address(ret) + PAGE_SIZE - sizeof(void *)) = *page_ptr; 33 + *page_ptr = ret; 34 + 35 + return ret; 36 + } 37 + 38 + /* 39 + * Add a TB and if needed apply the FH HW bug workaround; 40 + * meta != NULL indicates that it's a page mapping and we 41 + * need to dma_unmap_page() and set the meta->tbs bit in 42 + * this case. 43 + */ 44 + static int iwl_txq_gen2_set_tb_with_wa(struct iwl_trans *trans, 45 + struct sk_buff *skb, 46 + struct iwl_tfh_tfd *tfd, 47 + dma_addr_t phys, void *virt, 48 + u16 len, struct iwl_cmd_meta *meta) 49 + { 50 + dma_addr_t oldphys = phys; 51 + struct page *page; 52 + int ret; 53 + 54 + if (unlikely(dma_mapping_error(trans->dev, phys))) 55 + return -ENOMEM; 56 + 57 + if (likely(!iwl_txq_crosses_4g_boundary(phys, len))) { 58 + ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); 59 + 60 + if (ret < 0) 61 + goto unmap; 62 + 63 + if (meta) 64 + meta->tbs |= BIT(ret); 65 + 66 + ret = 0; 67 + goto trace; 68 + } 69 + 70 + /* 71 + * Work around a hardware bug. If (as expressed in the 72 + * condition above) the TB ends on a 32-bit boundary, 73 + * then the next TB may be accessed with the wrong 74 + * address. 75 + * To work around it, copy the data elsewhere and make 76 + * a new mapping for it so the device will not fail. 77 + */ 78 + 79 + if (WARN_ON(len > PAGE_SIZE - sizeof(void *))) { 80 + ret = -ENOBUFS; 81 + goto unmap; 82 + } 83 + 84 + page = get_workaround_page(trans, skb); 85 + if (!page) { 86 + ret = -ENOMEM; 87 + goto unmap; 88 + } 89 + 90 + memcpy(page_address(page), virt, len); 91 + 92 + phys = dma_map_single(trans->dev, page_address(page), len, 93 + DMA_TO_DEVICE); 94 + if (unlikely(dma_mapping_error(trans->dev, phys))) 95 + return -ENOMEM; 96 + ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); 97 + if (ret < 0) { 98 + /* unmap the new allocation as single */ 99 + oldphys = phys; 100 + meta = NULL; 101 + goto unmap; 102 + } 103 + IWL_DEBUG_TX(trans, 104 + "TB bug workaround: copied %d bytes from 0x%llx to 0x%llx\n", 105 + len, (unsigned long long)oldphys, 106 + (unsigned long long)phys); 107 + 108 + ret = 0; 109 + unmap: 110 + if (meta) 111 + dma_unmap_page(trans->dev, oldphys, len, DMA_TO_DEVICE); 112 + else 113 + dma_unmap_single(trans->dev, oldphys, len, DMA_TO_DEVICE); 114 + trace: 115 + trace_iwlwifi_dev_tx_tb(trans->dev, skb, virt, phys, len); 116 + 117 + return ret; 118 + } 119 + 120 + static int iwl_txq_gen2_build_amsdu(struct iwl_trans *trans, 121 + struct sk_buff *skb, 122 + struct iwl_tfh_tfd *tfd, int start_len, 123 + u8 hdr_len, 124 + struct iwl_device_tx_cmd *dev_cmd) 125 + { 126 + #ifdef CONFIG_INET 127 + struct iwl_tx_cmd_gen2 *tx_cmd = (void *)dev_cmd->payload; 128 + struct ieee80211_hdr *hdr = (void *)skb->data; 129 + unsigned int snap_ip_tcp_hdrlen, ip_hdrlen, total_len, hdr_room; 130 + unsigned int mss = skb_shinfo(skb)->gso_size; 131 + u16 length, amsdu_pad; 132 + u8 *start_hdr; 133 + struct iwl_tso_hdr_page *hdr_page; 134 + struct tso_t tso; 135 + 136 + trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), 137 + &dev_cmd->hdr, start_len, 0); 138 + 139 + ip_hdrlen = skb_network_header_len(skb); 140 + snap_ip_tcp_hdrlen = 8 + ip_hdrlen + tcp_hdrlen(skb); 141 + total_len = skb->len - snap_ip_tcp_hdrlen - hdr_len; 142 + amsdu_pad = 0; 143 + 144 + /* total amount of header we may need for this A-MSDU */ 145 + hdr_room = DIV_ROUND_UP(total_len, mss) * 146 + (3 + snap_ip_tcp_hdrlen + sizeof(struct ethhdr)); 147 + 148 + /* Our device supports 9 segments at most, it will fit in 1 page */ 149 + hdr_page = iwl_pcie_get_page_hdr(trans, hdr_room, skb); 150 + if (!hdr_page) 151 + return -ENOMEM; 152 + 153 + start_hdr = hdr_page->pos; 154 + 155 + /* 156 + * Pull the ieee80211 header to be able to use TSO core, 157 + * we will restore it for the tx_status flow. 158 + */ 159 + skb_pull(skb, hdr_len); 160 + 161 + /* 162 + * Remove the length of all the headers that we don't actually 163 + * have in the MPDU by themselves, but that we duplicate into 164 + * all the different MSDUs inside the A-MSDU. 165 + */ 166 + le16_add_cpu(&tx_cmd->len, -snap_ip_tcp_hdrlen); 167 + 168 + tso_start(skb, &tso); 169 + 170 + while (total_len) { 171 + /* this is the data left for this subframe */ 172 + unsigned int data_left = min_t(unsigned int, mss, total_len); 173 + unsigned int tb_len; 174 + dma_addr_t tb_phys; 175 + u8 *subf_hdrs_start = hdr_page->pos; 176 + 177 + total_len -= data_left; 178 + 179 + memset(hdr_page->pos, 0, amsdu_pad); 180 + hdr_page->pos += amsdu_pad; 181 + amsdu_pad = (4 - (sizeof(struct ethhdr) + snap_ip_tcp_hdrlen + 182 + data_left)) & 0x3; 183 + ether_addr_copy(hdr_page->pos, ieee80211_get_DA(hdr)); 184 + hdr_page->pos += ETH_ALEN; 185 + ether_addr_copy(hdr_page->pos, ieee80211_get_SA(hdr)); 186 + hdr_page->pos += ETH_ALEN; 187 + 188 + length = snap_ip_tcp_hdrlen + data_left; 189 + *((__be16 *)hdr_page->pos) = cpu_to_be16(length); 190 + hdr_page->pos += sizeof(length); 191 + 192 + /* 193 + * This will copy the SNAP as well which will be considered 194 + * as MAC header. 195 + */ 196 + tso_build_hdr(skb, hdr_page->pos, &tso, data_left, !total_len); 197 + 198 + hdr_page->pos += snap_ip_tcp_hdrlen; 199 + 200 + tb_len = hdr_page->pos - start_hdr; 201 + tb_phys = dma_map_single(trans->dev, start_hdr, 202 + tb_len, DMA_TO_DEVICE); 203 + if (unlikely(dma_mapping_error(trans->dev, tb_phys))) 204 + goto out_err; 205 + /* 206 + * No need for _with_wa, this is from the TSO page and 207 + * we leave some space at the end of it so can't hit 208 + * the buggy scenario. 209 + */ 210 + iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb_len); 211 + trace_iwlwifi_dev_tx_tb(trans->dev, skb, start_hdr, 212 + tb_phys, tb_len); 213 + /* add this subframe's headers' length to the tx_cmd */ 214 + le16_add_cpu(&tx_cmd->len, hdr_page->pos - subf_hdrs_start); 215 + 216 + /* prepare the start_hdr for the next subframe */ 217 + start_hdr = hdr_page->pos; 218 + 219 + /* put the payload */ 220 + while (data_left) { 221 + int ret; 222 + 223 + tb_len = min_t(unsigned int, tso.size, data_left); 224 + tb_phys = dma_map_single(trans->dev, tso.data, 225 + tb_len, DMA_TO_DEVICE); 226 + ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, 227 + tb_phys, tso.data, 228 + tb_len, NULL); 229 + if (ret) 230 + goto out_err; 231 + 232 + data_left -= tb_len; 233 + tso_build_data(skb, &tso, tb_len); 234 + } 235 + } 236 + 237 + /* re -add the WiFi header */ 238 + skb_push(skb, hdr_len); 239 + 240 + return 0; 241 + 242 + out_err: 243 + #endif 244 + return -EINVAL; 245 + } 246 + 247 + static struct 248 + iwl_tfh_tfd *iwl_txq_gen2_build_tx_amsdu(struct iwl_trans *trans, 249 + struct iwl_txq *txq, 250 + struct iwl_device_tx_cmd *dev_cmd, 251 + struct sk_buff *skb, 252 + struct iwl_cmd_meta *out_meta, 253 + int hdr_len, 254 + int tx_cmd_len) 255 + { 256 + int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 257 + struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); 258 + dma_addr_t tb_phys; 259 + int len; 260 + void *tb1_addr; 261 + 262 + tb_phys = iwl_txq_get_first_tb_dma(txq, idx); 263 + 264 + /* 265 + * No need for _with_wa, the first TB allocation is aligned up 266 + * to a 64-byte boundary and thus can't be at the end or cross 267 + * a page boundary (much less a 2^32 boundary). 268 + */ 269 + iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); 270 + 271 + /* 272 + * The second TB (tb1) points to the remainder of the TX command 273 + * and the 802.11 header - dword aligned size 274 + * (This calculation modifies the TX command, so do it before the 275 + * setup of the first TB) 276 + */ 277 + len = tx_cmd_len + sizeof(struct iwl_cmd_header) + hdr_len - 278 + IWL_FIRST_TB_SIZE; 279 + 280 + /* do not align A-MSDU to dword as the subframe header aligns it */ 281 + 282 + /* map the data for TB1 */ 283 + tb1_addr = ((u8 *)&dev_cmd->hdr) + IWL_FIRST_TB_SIZE; 284 + tb_phys = dma_map_single(trans->dev, tb1_addr, len, DMA_TO_DEVICE); 285 + if (unlikely(dma_mapping_error(trans->dev, tb_phys))) 286 + goto out_err; 287 + /* 288 + * No need for _with_wa(), we ensure (via alignment) that the data 289 + * here can never cross or end at a page boundary. 290 + */ 291 + iwl_txq_gen2_set_tb(trans, tfd, tb_phys, len); 292 + 293 + if (iwl_txq_gen2_build_amsdu(trans, skb, tfd, len + IWL_FIRST_TB_SIZE, 294 + hdr_len, dev_cmd)) 295 + goto out_err; 296 + 297 + /* building the A-MSDU might have changed this data, memcpy it now */ 298 + memcpy(&txq->first_tb_bufs[idx], dev_cmd, IWL_FIRST_TB_SIZE); 299 + return tfd; 300 + 301 + out_err: 302 + iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); 303 + return NULL; 304 + } 305 + 306 + static int iwl_txq_gen2_tx_add_frags(struct iwl_trans *trans, 307 + struct sk_buff *skb, 308 + struct iwl_tfh_tfd *tfd, 309 + struct iwl_cmd_meta *out_meta) 310 + { 311 + int i; 312 + 313 + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 314 + const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 315 + dma_addr_t tb_phys; 316 + unsigned int fragsz = skb_frag_size(frag); 317 + int ret; 318 + 319 + if (!fragsz) 320 + continue; 321 + 322 + tb_phys = skb_frag_dma_map(trans->dev, frag, 0, 323 + fragsz, DMA_TO_DEVICE); 324 + ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, 325 + skb_frag_address(frag), 326 + fragsz, out_meta); 327 + if (ret) 328 + return ret; 329 + } 330 + 331 + return 0; 332 + } 333 + 334 + static struct 335 + iwl_tfh_tfd *iwl_txq_gen2_build_tx(struct iwl_trans *trans, 336 + struct iwl_txq *txq, 337 + struct iwl_device_tx_cmd *dev_cmd, 338 + struct sk_buff *skb, 339 + struct iwl_cmd_meta *out_meta, 340 + int hdr_len, 341 + int tx_cmd_len, 342 + bool pad) 343 + { 344 + int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 345 + struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); 346 + dma_addr_t tb_phys; 347 + int len, tb1_len, tb2_len; 348 + void *tb1_addr; 349 + struct sk_buff *frag; 350 + 351 + tb_phys = iwl_txq_get_first_tb_dma(txq, idx); 352 + 353 + /* The first TB points to bi-directional DMA data */ 354 + memcpy(&txq->first_tb_bufs[idx], dev_cmd, IWL_FIRST_TB_SIZE); 355 + 356 + /* 357 + * No need for _with_wa, the first TB allocation is aligned up 358 + * to a 64-byte boundary and thus can't be at the end or cross 359 + * a page boundary (much less a 2^32 boundary). 360 + */ 361 + iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); 362 + 363 + /* 364 + * The second TB (tb1) points to the remainder of the TX command 365 + * and the 802.11 header - dword aligned size 366 + * (This calculation modifies the TX command, so do it before the 367 + * setup of the first TB) 368 + */ 369 + len = tx_cmd_len + sizeof(struct iwl_cmd_header) + hdr_len - 370 + IWL_FIRST_TB_SIZE; 371 + 372 + if (pad) 373 + tb1_len = ALIGN(len, 4); 374 + else 375 + tb1_len = len; 376 + 377 + /* map the data for TB1 */ 378 + tb1_addr = ((u8 *)&dev_cmd->hdr) + IWL_FIRST_TB_SIZE; 379 + tb_phys = dma_map_single(trans->dev, tb1_addr, tb1_len, DMA_TO_DEVICE); 380 + if (unlikely(dma_mapping_error(trans->dev, tb_phys))) 381 + goto out_err; 382 + /* 383 + * No need for _with_wa(), we ensure (via alignment) that the data 384 + * here can never cross or end at a page boundary. 385 + */ 386 + iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb1_len); 387 + trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), &dev_cmd->hdr, 388 + IWL_FIRST_TB_SIZE + tb1_len, hdr_len); 389 + 390 + /* set up TFD's third entry to point to remainder of skb's head */ 391 + tb2_len = skb_headlen(skb) - hdr_len; 392 + 393 + if (tb2_len > 0) { 394 + int ret; 395 + 396 + tb_phys = dma_map_single(trans->dev, skb->data + hdr_len, 397 + tb2_len, DMA_TO_DEVICE); 398 + ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, 399 + skb->data + hdr_len, tb2_len, 400 + NULL); 401 + if (ret) 402 + goto out_err; 403 + } 404 + 405 + if (iwl_txq_gen2_tx_add_frags(trans, skb, tfd, out_meta)) 406 + goto out_err; 407 + 408 + skb_walk_frags(skb, frag) { 409 + int ret; 410 + 411 + tb_phys = dma_map_single(trans->dev, frag->data, 412 + skb_headlen(frag), DMA_TO_DEVICE); 413 + ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, 414 + frag->data, 415 + skb_headlen(frag), NULL); 416 + if (ret) 417 + goto out_err; 418 + if (iwl_txq_gen2_tx_add_frags(trans, frag, tfd, out_meta)) 419 + goto out_err; 420 + } 421 + 422 + return tfd; 423 + 424 + out_err: 425 + iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); 426 + return NULL; 427 + } 428 + 429 + static 430 + struct iwl_tfh_tfd *iwl_txq_gen2_build_tfd(struct iwl_trans *trans, 431 + struct iwl_txq *txq, 432 + struct iwl_device_tx_cmd *dev_cmd, 433 + struct sk_buff *skb, 434 + struct iwl_cmd_meta *out_meta) 435 + { 436 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 437 + int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 438 + struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); 439 + int len, hdr_len; 440 + bool amsdu; 441 + 442 + /* There must be data left over for TB1 or this code must be changed */ 443 + BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen2) < IWL_FIRST_TB_SIZE); 444 + BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + 445 + offsetofend(struct iwl_tx_cmd_gen2, dram_info) > 446 + IWL_FIRST_TB_SIZE); 447 + BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen3) < IWL_FIRST_TB_SIZE); 448 + BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + 449 + offsetofend(struct iwl_tx_cmd_gen3, dram_info) > 450 + IWL_FIRST_TB_SIZE); 451 + 452 + memset(tfd, 0, sizeof(*tfd)); 453 + 454 + if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210) 455 + len = sizeof(struct iwl_tx_cmd_gen2); 456 + else 457 + len = sizeof(struct iwl_tx_cmd_gen3); 458 + 459 + amsdu = ieee80211_is_data_qos(hdr->frame_control) && 460 + (*ieee80211_get_qos_ctl(hdr) & 461 + IEEE80211_QOS_CTL_A_MSDU_PRESENT); 462 + 463 + hdr_len = ieee80211_hdrlen(hdr->frame_control); 464 + 465 + /* 466 + * Only build A-MSDUs here if doing so by GSO, otherwise it may be 467 + * an A-MSDU for other reasons, e.g. NAN or an A-MSDU having been 468 + * built in the higher layers already. 469 + */ 470 + if (amsdu && skb_shinfo(skb)->gso_size) 471 + return iwl_txq_gen2_build_tx_amsdu(trans, txq, dev_cmd, skb, 472 + out_meta, hdr_len, len); 473 + return iwl_txq_gen2_build_tx(trans, txq, dev_cmd, skb, out_meta, 474 + hdr_len, len, !amsdu); 475 + } 476 + 477 + int iwl_txq_space(struct iwl_trans *trans, const struct iwl_txq *q) 478 + { 479 + unsigned int max; 480 + unsigned int used; 481 + 482 + /* 483 + * To avoid ambiguity between empty and completely full queues, there 484 + * should always be less than max_tfd_queue_size elements in the queue. 485 + * If q->n_window is smaller than max_tfd_queue_size, there is no need 486 + * to reserve any queue entries for this purpose. 487 + */ 488 + if (q->n_window < trans->trans_cfg->base_params->max_tfd_queue_size) 489 + max = q->n_window; 490 + else 491 + max = trans->trans_cfg->base_params->max_tfd_queue_size - 1; 492 + 493 + /* 494 + * max_tfd_queue_size is a power of 2, so the following is equivalent to 495 + * modulo by max_tfd_queue_size and is well defined. 496 + */ 497 + used = (q->write_ptr - q->read_ptr) & 498 + (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 499 + 500 + if (WARN_ON(used > max)) 501 + return 0; 502 + 503 + return max - used; 504 + } 505 + 506 + /* 507 + * iwl_pcie_gen2_update_byte_tbl - Set up entry in Tx byte-count array 508 + */ 509 + static void iwl_pcie_gen2_update_byte_tbl(struct iwl_trans *trans, 510 + struct iwl_txq *txq, u16 byte_cnt, 511 + int num_tbs) 512 + { 513 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 514 + int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 515 + u8 filled_tfd_size, num_fetch_chunks; 516 + u16 len = byte_cnt; 517 + __le16 bc_ent; 518 + 519 + if (WARN(idx >= txq->n_window, "%d >= %d\n", idx, txq->n_window)) 520 + return; 521 + 522 + filled_tfd_size = offsetof(struct iwl_tfh_tfd, tbs) + 523 + num_tbs * sizeof(struct iwl_tfh_tb); 524 + /* 525 + * filled_tfd_size contains the number of filled bytes in the TFD. 526 + * Dividing it by 64 will give the number of chunks to fetch 527 + * to SRAM- 0 for one chunk, 1 for 2 and so on. 528 + * If, for example, TFD contains only 3 TBs then 32 bytes 529 + * of the TFD are used, and only one chunk of 64 bytes should 530 + * be fetched 531 + */ 532 + num_fetch_chunks = DIV_ROUND_UP(filled_tfd_size, 64) - 1; 533 + 534 + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { 535 + struct iwl_gen3_bc_tbl_entry *scd_bc_tbl_gen3 = txq->bc_tbl.addr; 536 + 537 + /* Starting from AX210, the HW expects bytes */ 538 + WARN_ON(trans_pcie->txqs.bc_table_dword); 539 + WARN_ON(len > 0x3FFF); 540 + bc_ent = cpu_to_le16(len | (num_fetch_chunks << 14)); 541 + scd_bc_tbl_gen3[idx].tfd_offset = bc_ent; 542 + } else { 543 + struct iwlagn_scd_bc_tbl *scd_bc_tbl = txq->bc_tbl.addr; 544 + 545 + /* Before AX210, the HW expects DW */ 546 + WARN_ON(!trans_pcie->txqs.bc_table_dword); 547 + len = DIV_ROUND_UP(len, 4); 548 + WARN_ON(len > 0xFFF); 549 + bc_ent = cpu_to_le16(len | (num_fetch_chunks << 12)); 550 + scd_bc_tbl->tfd_offset[idx] = bc_ent; 551 + } 552 + } 553 + 554 + static u8 iwl_txq_gen2_get_num_tbs(struct iwl_tfh_tfd *tfd) 555 + { 556 + return le16_to_cpu(tfd->num_tbs) & 0x1f; 557 + } 558 + 559 + int iwl_txq_gen2_set_tb(struct iwl_trans *trans, struct iwl_tfh_tfd *tfd, 560 + dma_addr_t addr, u16 len) 561 + { 562 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 563 + int idx = iwl_txq_gen2_get_num_tbs(tfd); 564 + struct iwl_tfh_tb *tb; 565 + 566 + /* Only WARN here so we know about the issue, but we mess up our 567 + * unmap path because not every place currently checks for errors 568 + * returned from this function - it can only return an error if 569 + * there's no more space, and so when we know there is enough we 570 + * don't always check ... 571 + */ 572 + WARN(iwl_txq_crosses_4g_boundary(addr, len), 573 + "possible DMA problem with iova:0x%llx, len:%d\n", 574 + (unsigned long long)addr, len); 575 + 576 + if (WARN_ON(idx >= IWL_TFH_NUM_TBS)) 577 + return -EINVAL; 578 + tb = &tfd->tbs[idx]; 579 + 580 + /* Each TFD can point to a maximum max_tbs Tx buffers */ 581 + if (le16_to_cpu(tfd->num_tbs) >= trans_pcie->txqs.tfd.max_tbs) { 582 + IWL_ERR(trans, "Error can not send more than %d chunks\n", 583 + trans_pcie->txqs.tfd.max_tbs); 584 + return -EINVAL; 585 + } 586 + 587 + put_unaligned_le64(addr, &tb->addr); 588 + tb->tb_len = cpu_to_le16(len); 589 + 590 + tfd->num_tbs = cpu_to_le16(idx + 1); 591 + 592 + return idx; 593 + } 594 + 595 + void iwl_txq_gen2_tfd_unmap(struct iwl_trans *trans, 596 + struct iwl_cmd_meta *meta, 597 + struct iwl_tfh_tfd *tfd) 598 + { 599 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 600 + int i, num_tbs; 601 + 602 + /* Sanity check on number of chunks */ 603 + num_tbs = iwl_txq_gen2_get_num_tbs(tfd); 604 + 605 + if (num_tbs > trans_pcie->txqs.tfd.max_tbs) { 606 + IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); 607 + return; 608 + } 609 + 610 + /* first TB is never freed - it's the bidirectional DMA data */ 611 + for (i = 1; i < num_tbs; i++) { 612 + if (meta->tbs & BIT(i)) 613 + dma_unmap_page(trans->dev, 614 + le64_to_cpu(tfd->tbs[i].addr), 615 + le16_to_cpu(tfd->tbs[i].tb_len), 616 + DMA_TO_DEVICE); 617 + else 618 + dma_unmap_single(trans->dev, 619 + le64_to_cpu(tfd->tbs[i].addr), 620 + le16_to_cpu(tfd->tbs[i].tb_len), 621 + DMA_TO_DEVICE); 622 + } 623 + 624 + iwl_txq_set_tfd_invalid_gen2(trans, tfd); 625 + } 626 + 627 + static void iwl_txq_gen2_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) 628 + { 629 + /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and 630 + * idx is bounded by n_window 631 + */ 632 + int idx = iwl_txq_get_cmd_index(txq, txq->read_ptr); 633 + struct sk_buff *skb; 634 + 635 + lockdep_assert_held(&txq->lock); 636 + 637 + if (!txq->entries) 638 + return; 639 + 640 + iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta, 641 + iwl_txq_get_tfd(trans, txq, idx)); 642 + 643 + skb = txq->entries[idx].skb; 644 + 645 + /* Can be called from irqs-disabled context 646 + * If skb is not NULL, it means that the whole queue is being 647 + * freed and that the queue is not empty - free the skb 648 + */ 649 + if (skb) { 650 + iwl_op_mode_free_skb(trans->op_mode, skb); 651 + txq->entries[idx].skb = NULL; 652 + } 653 + } 654 + 655 + /* 656 + * iwl_txq_inc_wr_ptr - Send new write index to hardware 657 + */ 658 + static void iwl_txq_inc_wr_ptr(struct iwl_trans *trans, struct iwl_txq *txq) 659 + { 660 + lockdep_assert_held(&txq->lock); 661 + 662 + IWL_DEBUG_TX(trans, "Q:%d WR: 0x%x\n", txq->id, txq->write_ptr); 663 + 664 + /* 665 + * if not in power-save mode, uCode will never sleep when we're 666 + * trying to tx (during RFKILL, we're not trying to tx). 667 + */ 668 + iwl_write32(trans, HBUS_TARG_WRPTR, txq->write_ptr | (txq->id << 16)); 669 + } 670 + 671 + int iwl_txq_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb, 672 + struct iwl_device_tx_cmd *dev_cmd, int txq_id) 673 + { 674 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 675 + struct iwl_cmd_meta *out_meta; 676 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 677 + u16 cmd_len; 678 + int idx; 679 + void *tfd; 680 + 681 + if (WARN_ONCE(txq_id >= IWL_MAX_TVQM_QUEUES, 682 + "queue %d out of range", txq_id)) 683 + return -EINVAL; 684 + 685 + if (WARN_ONCE(!test_bit(txq_id, trans_pcie->txqs.queue_used), 686 + "TX on unused queue %d\n", txq_id)) 687 + return -EINVAL; 688 + 689 + if (skb_is_nonlinear(skb) && 690 + skb_shinfo(skb)->nr_frags > IWL_TRANS_PCIE_MAX_FRAGS(trans_pcie) && 691 + __skb_linearize(skb)) 692 + return -ENOMEM; 693 + 694 + spin_lock(&txq->lock); 695 + 696 + if (iwl_txq_space(trans, txq) < txq->high_mark) { 697 + iwl_txq_stop(trans, txq); 698 + 699 + /* don't put the packet on the ring, if there is no room */ 700 + if (unlikely(iwl_txq_space(trans, txq) < 3)) { 701 + struct iwl_device_tx_cmd **dev_cmd_ptr; 702 + 703 + dev_cmd_ptr = (void *)((u8 *)skb->cb + 704 + trans_pcie->txqs.dev_cmd_offs); 705 + 706 + *dev_cmd_ptr = dev_cmd; 707 + __skb_queue_tail(&txq->overflow_q, skb); 708 + spin_unlock(&txq->lock); 709 + return 0; 710 + } 711 + } 712 + 713 + idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 714 + 715 + /* Set up driver data for this TFD */ 716 + txq->entries[idx].skb = skb; 717 + txq->entries[idx].cmd = dev_cmd; 718 + 719 + dev_cmd->hdr.sequence = 720 + cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | 721 + INDEX_TO_SEQ(idx))); 722 + 723 + /* Set up first empty entry in queue's array of Tx/cmd buffers */ 724 + out_meta = &txq->entries[idx].meta; 725 + out_meta->flags = 0; 726 + 727 + tfd = iwl_txq_gen2_build_tfd(trans, txq, dev_cmd, skb, out_meta); 728 + if (!tfd) { 729 + spin_unlock(&txq->lock); 730 + return -1; 731 + } 732 + 733 + if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { 734 + struct iwl_tx_cmd_gen3 *tx_cmd_gen3 = 735 + (void *)dev_cmd->payload; 736 + 737 + cmd_len = le16_to_cpu(tx_cmd_gen3->len); 738 + } else { 739 + struct iwl_tx_cmd_gen2 *tx_cmd_gen2 = 740 + (void *)dev_cmd->payload; 741 + 742 + cmd_len = le16_to_cpu(tx_cmd_gen2->len); 743 + } 744 + 745 + /* Set up entry for this TFD in Tx byte-count array */ 746 + iwl_pcie_gen2_update_byte_tbl(trans, txq, cmd_len, 747 + iwl_txq_gen2_get_num_tbs(tfd)); 748 + 749 + /* start timer if queue currently empty */ 750 + if (txq->read_ptr == txq->write_ptr && txq->wd_timeout) 751 + mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); 752 + 753 + /* Tell device the write index *just past* this latest filled TFD */ 754 + txq->write_ptr = iwl_txq_inc_wrap(trans, txq->write_ptr); 755 + iwl_txq_inc_wr_ptr(trans, txq); 756 + /* 757 + * At this point the frame is "transmitted" successfully 758 + * and we will get a TX status notification eventually. 759 + */ 760 + spin_unlock(&txq->lock); 761 + return 0; 762 + } 763 + 764 + /*************** HOST COMMAND QUEUE FUNCTIONS *****/ 765 + 766 + /* 767 + * iwl_txq_gen2_unmap - Unmap any remaining DMA mappings and free skb's 768 + */ 769 + static void iwl_txq_gen2_unmap(struct iwl_trans *trans, int txq_id) 770 + { 771 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 772 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 773 + 774 + spin_lock_bh(&txq->lock); 775 + while (txq->write_ptr != txq->read_ptr) { 776 + IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n", 777 + txq_id, txq->read_ptr); 778 + 779 + if (txq_id != trans_pcie->txqs.cmd.q_id) { 780 + int idx = iwl_txq_get_cmd_index(txq, txq->read_ptr); 781 + struct sk_buff *skb = txq->entries[idx].skb; 782 + 783 + if (!WARN_ON_ONCE(!skb)) 784 + iwl_pcie_free_tso_page(trans, skb); 785 + } 786 + iwl_txq_gen2_free_tfd(trans, txq); 787 + txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr); 788 + } 789 + 790 + while (!skb_queue_empty(&txq->overflow_q)) { 791 + struct sk_buff *skb = __skb_dequeue(&txq->overflow_q); 792 + 793 + iwl_op_mode_free_skb(trans->op_mode, skb); 794 + } 795 + 796 + spin_unlock_bh(&txq->lock); 797 + 798 + /* just in case - this queue may have been stopped */ 799 + iwl_trans_pcie_wake_queue(trans, txq); 800 + } 801 + 802 + static void iwl_txq_gen2_free_memory(struct iwl_trans *trans, 803 + struct iwl_txq *txq) 804 + { 805 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 806 + struct device *dev = trans->dev; 807 + 808 + /* De-alloc circular buffer of TFDs */ 809 + if (txq->tfds) { 810 + dma_free_coherent(dev, 811 + trans_pcie->txqs.tfd.size * txq->n_window, 812 + txq->tfds, txq->dma_addr); 813 + dma_free_coherent(dev, 814 + sizeof(*txq->first_tb_bufs) * txq->n_window, 815 + txq->first_tb_bufs, txq->first_tb_dma); 816 + } 817 + 818 + kfree(txq->entries); 819 + if (txq->bc_tbl.addr) 820 + dma_pool_free(trans_pcie->txqs.bc_pool, 821 + txq->bc_tbl.addr, txq->bc_tbl.dma); 822 + kfree(txq); 823 + } 824 + 825 + /* 826 + * iwl_pcie_txq_free - Deallocate DMA queue. 827 + * @txq: Transmit queue to deallocate. 828 + * 829 + * Empty queue by removing and destroying all BD's. 830 + * Free all buffers. 831 + * 0-fill, but do not free "txq" descriptor structure. 832 + */ 833 + static void iwl_txq_gen2_free(struct iwl_trans *trans, int txq_id) 834 + { 835 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 836 + struct iwl_txq *txq; 837 + int i; 838 + 839 + if (WARN_ONCE(txq_id >= IWL_MAX_TVQM_QUEUES, 840 + "queue %d out of range", txq_id)) 841 + return; 842 + 843 + txq = trans_pcie->txqs.txq[txq_id]; 844 + 845 + if (WARN_ON(!txq)) 846 + return; 847 + 848 + iwl_txq_gen2_unmap(trans, txq_id); 849 + 850 + /* De-alloc array of command/tx buffers */ 851 + if (txq_id == trans_pcie->txqs.cmd.q_id) 852 + for (i = 0; i < txq->n_window; i++) { 853 + kfree_sensitive(txq->entries[i].cmd); 854 + kfree_sensitive(txq->entries[i].free_buf); 855 + } 856 + del_timer_sync(&txq->stuck_timer); 857 + 858 + iwl_txq_gen2_free_memory(trans, txq); 859 + 860 + trans_pcie->txqs.txq[txq_id] = NULL; 861 + 862 + clear_bit(txq_id, trans_pcie->txqs.queue_used); 863 + } 864 + 865 + static struct iwl_txq * 866 + iwl_txq_dyn_alloc_dma(struct iwl_trans *trans, int size, unsigned int timeout) 867 + { 868 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 869 + size_t bc_tbl_size, bc_tbl_entries; 870 + struct iwl_txq *txq; 871 + int ret; 872 + 873 + WARN_ON(!trans_pcie->txqs.bc_tbl_size); 874 + 875 + bc_tbl_size = trans_pcie->txqs.bc_tbl_size; 876 + bc_tbl_entries = bc_tbl_size / sizeof(u16); 877 + 878 + if (WARN_ON(size > bc_tbl_entries)) 879 + return ERR_PTR(-EINVAL); 880 + 881 + txq = kzalloc(sizeof(*txq), GFP_KERNEL); 882 + if (!txq) 883 + return ERR_PTR(-ENOMEM); 884 + 885 + txq->bc_tbl.addr = dma_pool_alloc(trans_pcie->txqs.bc_pool, GFP_KERNEL, 886 + &txq->bc_tbl.dma); 887 + if (!txq->bc_tbl.addr) { 888 + IWL_ERR(trans, "Scheduler BC Table allocation failed\n"); 889 + kfree(txq); 890 + return ERR_PTR(-ENOMEM); 891 + } 892 + 893 + ret = iwl_pcie_txq_alloc(trans, txq, size, false); 894 + if (ret) { 895 + IWL_ERR(trans, "Tx queue alloc failed\n"); 896 + goto error; 897 + } 898 + ret = iwl_txq_init(trans, txq, size, false); 899 + if (ret) { 900 + IWL_ERR(trans, "Tx queue init failed\n"); 901 + goto error; 902 + } 903 + 904 + txq->wd_timeout = msecs_to_jiffies(timeout); 905 + 906 + return txq; 907 + 908 + error: 909 + iwl_txq_gen2_free_memory(trans, txq); 910 + return ERR_PTR(ret); 911 + } 912 + 913 + static int iwl_pcie_txq_alloc_response(struct iwl_trans *trans, 914 + struct iwl_txq *txq, 915 + struct iwl_host_cmd *hcmd) 916 + { 917 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 918 + struct iwl_tx_queue_cfg_rsp *rsp; 919 + int ret, qid; 920 + u32 wr_ptr; 921 + 922 + if (WARN_ON(iwl_rx_packet_payload_len(hcmd->resp_pkt) != 923 + sizeof(*rsp))) { 924 + ret = -EINVAL; 925 + goto error_free_resp; 926 + } 927 + 928 + rsp = (void *)hcmd->resp_pkt->data; 929 + qid = le16_to_cpu(rsp->queue_number); 930 + wr_ptr = le16_to_cpu(rsp->write_pointer); 931 + 932 + if (qid >= ARRAY_SIZE(trans_pcie->txqs.txq)) { 933 + WARN_ONCE(1, "queue index %d unsupported", qid); 934 + ret = -EIO; 935 + goto error_free_resp; 936 + } 937 + 938 + if (test_and_set_bit(qid, trans_pcie->txqs.queue_used)) { 939 + WARN_ONCE(1, "queue %d already used", qid); 940 + ret = -EIO; 941 + goto error_free_resp; 942 + } 943 + 944 + if (WARN_ONCE(trans_pcie->txqs.txq[qid], 945 + "queue %d already allocated\n", qid)) { 946 + ret = -EIO; 947 + goto error_free_resp; 948 + } 949 + 950 + txq->id = qid; 951 + trans_pcie->txqs.txq[qid] = txq; 952 + wr_ptr &= (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 953 + 954 + /* Place first TFD at index corresponding to start sequence number */ 955 + txq->read_ptr = wr_ptr; 956 + txq->write_ptr = wr_ptr; 957 + 958 + IWL_DEBUG_TX_QUEUES(trans, "Activate queue %d\n", qid); 959 + 960 + iwl_free_resp(hcmd); 961 + return qid; 962 + 963 + error_free_resp: 964 + iwl_free_resp(hcmd); 965 + iwl_txq_gen2_free_memory(trans, txq); 966 + return ret; 967 + } 968 + 969 + int iwl_txq_dyn_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask, 970 + u8 tid, int size, unsigned int timeout) 971 + { 972 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 973 + struct iwl_txq *txq; 974 + union { 975 + struct iwl_tx_queue_cfg_cmd old; 976 + struct iwl_scd_queue_cfg_cmd new; 977 + } cmd; 978 + struct iwl_host_cmd hcmd = { 979 + .flags = CMD_WANT_SKB, 980 + }; 981 + int ret; 982 + 983 + /* take the min with bytecount table entries allowed */ 984 + size = min_t(u32, size, trans_pcie->txqs.bc_tbl_size / sizeof(u16)); 985 + /* but must be power of 2 values for calculating read/write pointers */ 986 + size = rounddown_pow_of_two(size); 987 + 988 + if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_BZ && 989 + trans->hw_rev_step == SILICON_A_STEP) { 990 + size = 4096; 991 + txq = iwl_txq_dyn_alloc_dma(trans, size, timeout); 992 + } else { 993 + do { 994 + txq = iwl_txq_dyn_alloc_dma(trans, size, timeout); 995 + if (!IS_ERR(txq)) 996 + break; 997 + 998 + IWL_DEBUG_TX_QUEUES(trans, 999 + "Failed allocating TXQ of size %d for sta mask %x tid %d, ret: %ld\n", 1000 + size, sta_mask, tid, 1001 + PTR_ERR(txq)); 1002 + size /= 2; 1003 + } while (size >= 16); 1004 + } 1005 + 1006 + if (IS_ERR(txq)) 1007 + return PTR_ERR(txq); 1008 + 1009 + if (trans_pcie->txqs.queue_alloc_cmd_ver == 0) { 1010 + memset(&cmd.old, 0, sizeof(cmd.old)); 1011 + cmd.old.tfdq_addr = cpu_to_le64(txq->dma_addr); 1012 + cmd.old.byte_cnt_addr = cpu_to_le64(txq->bc_tbl.dma); 1013 + cmd.old.cb_size = cpu_to_le32(TFD_QUEUE_CB_SIZE(size)); 1014 + cmd.old.flags = cpu_to_le16(flags | TX_QUEUE_CFG_ENABLE_QUEUE); 1015 + cmd.old.tid = tid; 1016 + 1017 + if (hweight32(sta_mask) != 1) { 1018 + ret = -EINVAL; 1019 + goto error; 1020 + } 1021 + cmd.old.sta_id = ffs(sta_mask) - 1; 1022 + 1023 + hcmd.id = SCD_QUEUE_CFG; 1024 + hcmd.len[0] = sizeof(cmd.old); 1025 + hcmd.data[0] = &cmd.old; 1026 + } else if (trans_pcie->txqs.queue_alloc_cmd_ver == 3) { 1027 + memset(&cmd.new, 0, sizeof(cmd.new)); 1028 + cmd.new.operation = cpu_to_le32(IWL_SCD_QUEUE_ADD); 1029 + cmd.new.u.add.tfdq_dram_addr = cpu_to_le64(txq->dma_addr); 1030 + cmd.new.u.add.bc_dram_addr = cpu_to_le64(txq->bc_tbl.dma); 1031 + cmd.new.u.add.cb_size = cpu_to_le32(TFD_QUEUE_CB_SIZE(size)); 1032 + cmd.new.u.add.flags = cpu_to_le32(flags); 1033 + cmd.new.u.add.sta_mask = cpu_to_le32(sta_mask); 1034 + cmd.new.u.add.tid = tid; 1035 + 1036 + hcmd.id = WIDE_ID(DATA_PATH_GROUP, SCD_QUEUE_CONFIG_CMD); 1037 + hcmd.len[0] = sizeof(cmd.new); 1038 + hcmd.data[0] = &cmd.new; 1039 + } else { 1040 + ret = -EOPNOTSUPP; 1041 + goto error; 1042 + } 1043 + 1044 + ret = iwl_trans_send_cmd(trans, &hcmd); 1045 + if (ret) 1046 + goto error; 1047 + 1048 + return iwl_pcie_txq_alloc_response(trans, txq, &hcmd); 1049 + 1050 + error: 1051 + iwl_txq_gen2_free_memory(trans, txq); 1052 + return ret; 1053 + } 1054 + 1055 + void iwl_txq_dyn_free(struct iwl_trans *trans, int queue) 1056 + { 1057 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1058 + 1059 + if (WARN(queue >= IWL_MAX_TVQM_QUEUES, 1060 + "queue %d out of range", queue)) 1061 + return; 1062 + 1063 + /* 1064 + * Upon HW Rfkill - we stop the device, and then stop the queues 1065 + * in the op_mode. Just for the sake of the simplicity of the op_mode, 1066 + * allow the op_mode to call txq_disable after it already called 1067 + * stop_device. 1068 + */ 1069 + if (!test_and_clear_bit(queue, trans_pcie->txqs.queue_used)) { 1070 + WARN_ONCE(test_bit(STATUS_DEVICE_ENABLED, &trans->status), 1071 + "queue %d not used", queue); 1072 + return; 1073 + } 1074 + 1075 + iwl_txq_gen2_free(trans, queue); 1076 + 1077 + IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", queue); 1078 + } 1079 + 1080 + void iwl_txq_gen2_tx_free(struct iwl_trans *trans) 1081 + { 1082 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1083 + int i; 1084 + 1085 + memset(trans_pcie->txqs.queue_used, 0, 1086 + sizeof(trans_pcie->txqs.queue_used)); 1087 + 1088 + /* Free all TX queues */ 1089 + for (i = 0; i < ARRAY_SIZE(trans_pcie->txqs.txq); i++) { 1090 + if (!trans_pcie->txqs.txq[i]) 1091 + continue; 1092 + 1093 + iwl_txq_gen2_free(trans, i); 1094 + } 1095 + } 1096 + 1097 + int iwl_txq_gen2_init(struct iwl_trans *trans, int txq_id, int queue_size) 1098 + { 1099 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1100 + struct iwl_txq *queue; 1101 + int ret; 1102 + 1103 + /* alloc and init the tx queue */ 1104 + if (!trans_pcie->txqs.txq[txq_id]) { 1105 + queue = kzalloc(sizeof(*queue), GFP_KERNEL); 1106 + if (!queue) { 1107 + IWL_ERR(trans, "Not enough memory for tx queue\n"); 1108 + return -ENOMEM; 1109 + } 1110 + trans_pcie->txqs.txq[txq_id] = queue; 1111 + ret = iwl_pcie_txq_alloc(trans, queue, queue_size, true); 1112 + if (ret) { 1113 + IWL_ERR(trans, "Tx %d queue init failed\n", txq_id); 1114 + goto error; 1115 + } 1116 + } else { 1117 + queue = trans_pcie->txqs.txq[txq_id]; 1118 + } 1119 + 1120 + ret = iwl_txq_init(trans, queue, queue_size, 1121 + (txq_id == trans_pcie->txqs.cmd.q_id)); 1122 + if (ret) { 1123 + IWL_ERR(trans, "Tx %d queue alloc failed\n", txq_id); 1124 + goto error; 1125 + } 1126 + trans_pcie->txqs.txq[txq_id]->id = txq_id; 1127 + set_bit(txq_id, trans_pcie->txqs.queue_used); 1128 + 1129 + return 0; 1130 + 1131 + error: 1132 + iwl_txq_gen2_tx_free(trans); 1133 + return ret; 1134 + } 15 1135 16 1136 /*************** HOST COMMAND QUEUE FUNCTIONS *****/ 17 1137 ··· 1148 28 struct iwl_host_cmd *cmd) 1149 29 { 1150 30 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1151 - struct iwl_txq *txq = trans->txqs.txq[trans->txqs.cmd.q_id]; 31 + struct iwl_txq *txq = trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]; 1152 32 struct iwl_device_cmd *out_cmd; 1153 33 struct iwl_cmd_meta *out_meta; 1154 34 void *dup_buf = NULL; ··· 1263 143 cpu_to_le16(cmd_size - sizeof(struct iwl_cmd_header_wide)); 1264 144 out_cmd->hdr_wide.reserved = 0; 1265 145 out_cmd->hdr_wide.sequence = 1266 - cpu_to_le16(QUEUE_TO_SEQ(trans->txqs.cmd.q_id) | 146 + cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->txqs.cmd.q_id) | 1267 147 INDEX_TO_SEQ(txq->write_ptr)); 1268 148 1269 149 cmd_pos = sizeof(struct iwl_cmd_header_wide); ··· 1311 191 "Sending command %s (%.2x.%.2x), seq: 0x%04X, %d bytes at %d[%d]:%d\n", 1312 192 iwl_get_cmd_string(trans, cmd->id), group_id, 1313 193 out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), 1314 - cmd_size, txq->write_ptr, idx, trans->txqs.cmd.q_id); 194 + cmd_size, txq->write_ptr, idx, trans_pcie->txqs.cmd.q_id); 1315 195 1316 196 /* start the TFD with the minimum copy bytes */ 1317 197 tb0_size = min_t(int, copy_size, IWL_FIRST_TB_SIZE);
+928 -71
drivers/net/wireless/intel/iwlwifi/pcie/tx.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 2 /* 3 - * Copyright (C) 2003-2014, 2018-2021, 2023 Intel Corporation 3 + * Copyright (C) 2003-2014, 2018-2021, 2023-2024 Intel Corporation 4 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 6 */ 7 7 #include <linux/etherdevice.h> 8 8 #include <linux/ieee80211.h> 9 + #include <linux/dmapool.h> 9 10 #include <linux/slab.h> 10 11 #include <linux/sched.h> 12 + #include <linux/tcp.h> 11 13 #include <net/ip6_checksum.h> 12 14 #include <net/tso.h> 13 15 16 + #include "fw/api/commands.h" 17 + #include "fw/api/datapath.h" 18 + #include "fw/api/debug.h" 19 + #include "iwl-fh.h" 14 20 #include "iwl-debug.h" 15 21 #include "iwl-csr.h" 16 22 #include "iwl-prph.h" ··· 78 72 static void iwl_pcie_txq_inc_wr_ptr(struct iwl_trans *trans, 79 73 struct iwl_txq *txq) 80 74 { 75 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 81 76 u32 reg = 0; 82 77 int txq_id = txq->id; 83 78 ··· 91 84 * 3. there is a chance that the NIC is asleep 92 85 */ 93 86 if (!trans->trans_cfg->base_params->shadow_reg_enable && 94 - txq_id != trans->txqs.cmd.q_id && 87 + txq_id != trans_pcie->txqs.cmd.q_id && 95 88 test_bit(STATUS_TPOWER_PMI, &trans->status)) { 96 89 /* 97 90 * wake up nic if it's powered down ... ··· 122 115 123 116 void iwl_pcie_txq_check_wrptrs(struct iwl_trans *trans) 124 117 { 118 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 125 119 int i; 126 120 127 121 for (i = 0; i < trans->trans_cfg->base_params->num_of_queues; i++) { 128 - struct iwl_txq *txq = trans->txqs.txq[i]; 122 + struct iwl_txq *txq = trans_pcie->txqs.txq[i]; 129 123 130 - if (!test_bit(i, trans->txqs.queue_used)) 124 + if (!test_bit(i, trans_pcie->txqs.queue_used)) 131 125 continue; 132 126 133 127 spin_lock_bh(&txq->lock); ··· 140 132 } 141 133 } 142 134 135 + static inline void iwl_pcie_gen1_tfd_set_tb(struct iwl_tfd *tfd, 136 + u8 idx, dma_addr_t addr, u16 len) 137 + { 138 + struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 139 + u16 hi_n_len = len << 4; 140 + 141 + put_unaligned_le32(addr, &tb->lo); 142 + hi_n_len |= iwl_get_dma_hi_addr(addr); 143 + 144 + tb->hi_n_len = cpu_to_le16(hi_n_len); 145 + 146 + tfd->num_tbs = idx + 1; 147 + } 148 + 149 + static inline u8 iwl_txq_gen1_tfd_get_num_tbs(struct iwl_tfd *tfd) 150 + { 151 + return tfd->num_tbs & 0x1f; 152 + } 153 + 143 154 static int iwl_pcie_txq_build_tfd(struct iwl_trans *trans, struct iwl_txq *txq, 144 155 dma_addr_t addr, u16 len, bool reset) 145 156 { 157 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 146 158 void *tfd; 147 159 u32 num_tbs; 148 160 149 - tfd = (u8 *)txq->tfds + trans->txqs.tfd.size * txq->write_ptr; 161 + tfd = (u8 *)txq->tfds + trans_pcie->txqs.tfd.size * txq->write_ptr; 150 162 151 163 if (reset) 152 - memset(tfd, 0, trans->txqs.tfd.size); 164 + memset(tfd, 0, trans_pcie->txqs.tfd.size); 153 165 154 - num_tbs = iwl_txq_gen1_tfd_get_num_tbs(trans, tfd); 166 + num_tbs = iwl_txq_gen1_tfd_get_num_tbs(tfd); 155 167 156 168 /* Each TFD can point to a maximum max_tbs Tx buffers */ 157 - if (num_tbs >= trans->txqs.tfd.max_tbs) { 169 + if (num_tbs >= trans_pcie->txqs.tfd.max_tbs) { 158 170 IWL_ERR(trans, "Error can not send more than %d chunks\n", 159 - trans->txqs.tfd.max_tbs); 171 + trans_pcie->txqs.tfd.max_tbs); 160 172 return -EINVAL; 161 173 } 162 174 ··· 184 156 "Unaligned address = %llx\n", (unsigned long long)addr)) 185 157 return -EINVAL; 186 158 187 - iwl_pcie_gen1_tfd_set_tb(trans, tfd, num_tbs, addr, len); 159 + iwl_pcie_gen1_tfd_set_tb(tfd, num_tbs, addr, len); 188 160 189 161 return num_tbs; 190 162 } ··· 209 181 spin_unlock(&trans_pcie->reg_lock); 210 182 } 211 183 184 + void iwl_pcie_free_tso_page(struct iwl_trans *trans, struct sk_buff *skb) 185 + { 186 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 187 + struct page **page_ptr; 188 + struct page *next; 189 + 190 + page_ptr = (void *)((u8 *)skb->cb + trans_pcie->txqs.page_offs); 191 + next = *page_ptr; 192 + *page_ptr = NULL; 193 + 194 + while (next) { 195 + struct page *tmp = next; 196 + 197 + next = *(void **)((u8 *)page_address(next) + PAGE_SIZE - 198 + sizeof(void *)); 199 + __free_page(tmp); 200 + } 201 + } 202 + 203 + static inline dma_addr_t 204 + iwl_txq_gen1_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx) 205 + { 206 + struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 207 + dma_addr_t addr; 208 + dma_addr_t hi_len; 209 + 210 + addr = get_unaligned_le32(&tb->lo); 211 + 212 + if (sizeof(dma_addr_t) <= sizeof(u32)) 213 + return addr; 214 + 215 + hi_len = le16_to_cpu(tb->hi_n_len) & 0xF; 216 + 217 + /* 218 + * shift by 16 twice to avoid warnings on 32-bit 219 + * (where this code never runs anyway due to the 220 + * if statement above) 221 + */ 222 + return addr | ((hi_len << 16) << 16); 223 + } 224 + 225 + static void iwl_txq_set_tfd_invalid_gen1(struct iwl_trans *trans, 226 + struct iwl_tfd *tfd) 227 + { 228 + tfd->num_tbs = 0; 229 + 230 + iwl_pcie_gen1_tfd_set_tb(tfd, 0, trans->invalid_tx_cmd.dma, 231 + trans->invalid_tx_cmd.size); 232 + } 233 + 234 + static void iwl_txq_gen1_tfd_unmap(struct iwl_trans *trans, 235 + struct iwl_cmd_meta *meta, 236 + struct iwl_txq *txq, int index) 237 + { 238 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 239 + int i, num_tbs; 240 + struct iwl_tfd *tfd = iwl_txq_get_tfd(trans, txq, index); 241 + 242 + /* Sanity check on number of chunks */ 243 + num_tbs = iwl_txq_gen1_tfd_get_num_tbs(tfd); 244 + 245 + if (num_tbs > trans_pcie->txqs.tfd.max_tbs) { 246 + IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); 247 + /* @todo issue fatal error, it is quite serious situation */ 248 + return; 249 + } 250 + 251 + /* first TB is never freed - it's the bidirectional DMA data */ 252 + 253 + for (i = 1; i < num_tbs; i++) { 254 + if (meta->tbs & BIT(i)) 255 + dma_unmap_page(trans->dev, 256 + iwl_txq_gen1_tfd_tb_get_addr(tfd, i), 257 + iwl_txq_gen1_tfd_tb_get_len(trans, 258 + tfd, i), 259 + DMA_TO_DEVICE); 260 + else 261 + dma_unmap_single(trans->dev, 262 + iwl_txq_gen1_tfd_tb_get_addr(tfd, i), 263 + iwl_txq_gen1_tfd_tb_get_len(trans, 264 + tfd, i), 265 + DMA_TO_DEVICE); 266 + } 267 + 268 + meta->tbs = 0; 269 + 270 + iwl_txq_set_tfd_invalid_gen1(trans, tfd); 271 + } 272 + 273 + /** 274 + * iwl_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] 275 + * @trans: transport private data 276 + * @txq: tx queue 277 + * 278 + * Does NOT advance any TFD circular buffer read/write indexes 279 + * Does NOT free the TFD itself (which is within circular buffer) 280 + */ 281 + static void iwl_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) 282 + { 283 + /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and 284 + * idx is bounded by n_window 285 + */ 286 + int rd_ptr = txq->read_ptr; 287 + int idx = iwl_txq_get_cmd_index(txq, rd_ptr); 288 + struct sk_buff *skb; 289 + 290 + lockdep_assert_held(&txq->lock); 291 + 292 + if (!txq->entries) 293 + return; 294 + 295 + /* We have only q->n_window txq->entries, but we use 296 + * TFD_QUEUE_SIZE_MAX tfds 297 + */ 298 + if (trans->trans_cfg->gen2) 299 + iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta, 300 + iwl_txq_get_tfd(trans, txq, rd_ptr)); 301 + else 302 + iwl_txq_gen1_tfd_unmap(trans, &txq->entries[idx].meta, 303 + txq, rd_ptr); 304 + 305 + /* free SKB */ 306 + skb = txq->entries[idx].skb; 307 + 308 + /* Can be called from irqs-disabled context 309 + * If skb is not NULL, it means that the whole queue is being 310 + * freed and that the queue is not empty - free the skb 311 + */ 312 + if (skb) { 313 + iwl_op_mode_free_skb(trans->op_mode, skb); 314 + txq->entries[idx].skb = NULL; 315 + } 316 + } 317 + 212 318 /* 213 319 * iwl_pcie_txq_unmap - Unmap any remaining DMA mappings and free skb's 214 320 */ 215 321 static void iwl_pcie_txq_unmap(struct iwl_trans *trans, int txq_id) 216 322 { 217 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 323 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 324 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 218 325 219 326 if (!txq) { 220 327 IWL_ERR(trans, "Trying to free a queue that wasn't allocated?\n"); ··· 361 198 IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n", 362 199 txq_id, txq->read_ptr); 363 200 364 - if (txq_id != trans->txqs.cmd.q_id) { 201 + if (txq_id != trans_pcie->txqs.cmd.q_id) { 365 202 struct sk_buff *skb = txq->entries[txq->read_ptr].skb; 366 203 367 204 if (WARN_ON_ONCE(!skb)) 368 205 continue; 369 206 370 - iwl_txq_free_tso_page(trans, skb); 207 + iwl_pcie_free_tso_page(trans, skb); 371 208 } 372 209 iwl_txq_free_tfd(trans, txq); 373 210 txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr); 374 211 375 212 if (txq->read_ptr == txq->write_ptr && 376 - txq_id == trans->txqs.cmd.q_id) 213 + txq_id == trans_pcie->txqs.cmd.q_id) 377 214 iwl_pcie_clear_cmd_in_flight(trans); 378 215 } 379 216 ··· 386 223 spin_unlock_bh(&txq->lock); 387 224 388 225 /* just in case - this queue may have been stopped */ 389 - iwl_wake_queue(trans, txq); 226 + iwl_trans_pcie_wake_queue(trans, txq); 390 227 } 391 228 392 229 /* ··· 399 236 */ 400 237 static void iwl_pcie_txq_free(struct iwl_trans *trans, int txq_id) 401 238 { 402 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 239 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 240 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 403 241 struct device *dev = trans->dev; 404 242 int i; 405 243 ··· 410 246 iwl_pcie_txq_unmap(trans, txq_id); 411 247 412 248 /* De-alloc array of command/tx buffers */ 413 - if (txq_id == trans->txqs.cmd.q_id) 249 + if (txq_id == trans_pcie->txqs.cmd.q_id) 414 250 for (i = 0; i < txq->n_window; i++) { 415 251 kfree_sensitive(txq->entries[i].cmd); 416 252 kfree_sensitive(txq->entries[i].free_buf); ··· 419 255 /* De-alloc circular buffer of TFDs */ 420 256 if (txq->tfds) { 421 257 dma_free_coherent(dev, 422 - trans->txqs.tfd.size * 258 + trans_pcie->txqs.tfd.size * 423 259 trans->trans_cfg->base_params->max_tfd_queue_size, 424 260 txq->tfds, txq->dma_addr); 425 261 txq->dma_addr = 0; ··· 449 285 SCD_CONTEXT_MEM_LOWER_BOUND) / sizeof(u32); 450 286 451 287 /* make sure all queue are not stopped/used */ 452 - memset(trans->txqs.queue_stopped, 0, 453 - sizeof(trans->txqs.queue_stopped)); 454 - memset(trans->txqs.queue_used, 0, sizeof(trans->txqs.queue_used)); 288 + memset(trans_pcie->txqs.queue_stopped, 0, 289 + sizeof(trans_pcie->txqs.queue_stopped)); 290 + memset(trans_pcie->txqs.queue_used, 0, 291 + sizeof(trans_pcie->txqs.queue_used)); 455 292 456 293 trans_pcie->scd_base_addr = 457 294 iwl_read_prph(trans, SCD_SRAM_BASE_ADDR); ··· 466 301 NULL, clear_dwords); 467 302 468 303 iwl_write_prph(trans, SCD_DRAM_BASE_ADDR, 469 - trans->txqs.scd_bc_tbls.dma >> 10); 304 + trans_pcie->txqs.scd_bc_tbls.dma >> 10); 470 305 471 306 /* The chain extension of the SCD doesn't work well. This feature is 472 307 * enabled by default by the HW, so we need to disable it manually. ··· 474 309 if (trans->trans_cfg->base_params->scd_chain_ext_wa) 475 310 iwl_write_prph(trans, SCD_CHAINEXT_EN, 0); 476 311 477 - iwl_trans_ac_txq_enable(trans, trans->txqs.cmd.q_id, 478 - trans->txqs.cmd.fifo, 479 - trans->txqs.cmd.wdg_timeout); 312 + iwl_trans_ac_txq_enable(trans, trans_pcie->txqs.cmd.q_id, 313 + trans_pcie->txqs.cmd.fifo, 314 + trans_pcie->txqs.cmd.wdg_timeout); 480 315 481 316 /* Activate all Tx DMA/FIFO channels */ 482 317 iwl_scd_activate_fifos(trans); ··· 512 347 513 348 for (txq_id = 0; txq_id < trans->trans_cfg->base_params->num_of_queues; 514 349 txq_id++) { 515 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 350 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 516 351 if (trans->trans_cfg->gen2) 517 352 iwl_write_direct64(trans, 518 353 FH_MEM_CBBC_QUEUE(trans, txq_id), ··· 587 422 * queues. This happens when we have an rfkill interrupt. 588 423 * Since we stop Tx altogether - mark the queues as stopped. 589 424 */ 590 - memset(trans->txqs.queue_stopped, 0, 591 - sizeof(trans->txqs.queue_stopped)); 592 - memset(trans->txqs.queue_used, 0, sizeof(trans->txqs.queue_used)); 425 + memset(trans_pcie->txqs.queue_stopped, 0, 426 + sizeof(trans_pcie->txqs.queue_stopped)); 427 + memset(trans_pcie->txqs.queue_used, 0, 428 + sizeof(trans_pcie->txqs.queue_used)); 593 429 594 430 /* This can happen: start_hw, stop_device */ 595 431 if (!trans_pcie->txq_memory) ··· 614 448 int txq_id; 615 449 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 616 450 617 - memset(trans->txqs.queue_used, 0, sizeof(trans->txqs.queue_used)); 451 + memset(trans_pcie->txqs.queue_used, 0, 452 + sizeof(trans_pcie->txqs.queue_used)); 618 453 619 454 /* Tx queues */ 620 455 if (trans_pcie->txq_memory) { ··· 623 456 txq_id < trans->trans_cfg->base_params->num_of_queues; 624 457 txq_id++) { 625 458 iwl_pcie_txq_free(trans, txq_id); 626 - trans->txqs.txq[txq_id] = NULL; 459 + trans_pcie->txqs.txq[txq_id] = NULL; 627 460 } 628 461 } 629 462 ··· 632 465 633 466 iwl_pcie_free_dma_ptr(trans, &trans_pcie->kw); 634 467 635 - iwl_pcie_free_dma_ptr(trans, &trans->txqs.scd_bc_tbls); 468 + iwl_pcie_free_dma_ptr(trans, &trans_pcie->txqs.scd_bc_tbls); 469 + } 470 + 471 + void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq) 472 + { 473 + u32 txq_id = txq->id; 474 + u32 status; 475 + bool active; 476 + u8 fifo; 477 + 478 + if (trans->trans_cfg->gen2) { 479 + IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id, 480 + txq->read_ptr, txq->write_ptr); 481 + /* TODO: access new SCD registers and dump them */ 482 + return; 483 + } 484 + 485 + status = iwl_read_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id)); 486 + fifo = (status >> SCD_QUEUE_STTS_REG_POS_TXF) & 0x7; 487 + active = !!(status & BIT(SCD_QUEUE_STTS_REG_POS_ACTIVE)); 488 + 489 + IWL_ERR(trans, 490 + "Queue %d is %sactive on fifo %d and stuck for %u ms. SW [%d, %d] HW [%d, %d] FH TRB=0x0%x\n", 491 + txq_id, active ? "" : "in", fifo, 492 + jiffies_to_msecs(txq->wd_timeout), 493 + txq->read_ptr, txq->write_ptr, 494 + iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & 495 + (trans->trans_cfg->base_params->max_tfd_queue_size - 1), 496 + iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id)) & 497 + (trans->trans_cfg->base_params->max_tfd_queue_size - 1), 498 + iwl_read_direct32(trans, FH_TX_TRB_REG(fifo))); 499 + } 500 + 501 + static void iwl_txq_stuck_timer(struct timer_list *t) 502 + { 503 + struct iwl_txq *txq = from_timer(txq, t, stuck_timer); 504 + struct iwl_trans *trans = txq->trans; 505 + 506 + spin_lock(&txq->lock); 507 + /* check if triggered erroneously */ 508 + if (txq->read_ptr == txq->write_ptr) { 509 + spin_unlock(&txq->lock); 510 + return; 511 + } 512 + spin_unlock(&txq->lock); 513 + 514 + iwl_txq_log_scd_error(trans, txq); 515 + 516 + iwl_force_nmi(trans); 517 + } 518 + 519 + int iwl_pcie_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, 520 + int slots_num, bool cmd_queue) 521 + { 522 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 523 + size_t num_entries = trans->trans_cfg->gen2 ? 524 + slots_num : trans->trans_cfg->base_params->max_tfd_queue_size; 525 + size_t tfd_sz; 526 + size_t tb0_buf_sz; 527 + int i; 528 + 529 + if (WARN_ONCE(slots_num <= 0, "Invalid slots num:%d\n", slots_num)) 530 + return -EINVAL; 531 + 532 + if (WARN_ON(txq->entries || txq->tfds)) 533 + return -EINVAL; 534 + 535 + tfd_sz = trans_pcie->txqs.tfd.size * num_entries; 536 + 537 + timer_setup(&txq->stuck_timer, iwl_txq_stuck_timer, 0); 538 + txq->trans = trans; 539 + 540 + txq->n_window = slots_num; 541 + 542 + txq->entries = kcalloc(slots_num, 543 + sizeof(struct iwl_pcie_txq_entry), 544 + GFP_KERNEL); 545 + 546 + if (!txq->entries) 547 + goto error; 548 + 549 + if (cmd_queue) 550 + for (i = 0; i < slots_num; i++) { 551 + txq->entries[i].cmd = 552 + kmalloc(sizeof(struct iwl_device_cmd), 553 + GFP_KERNEL); 554 + if (!txq->entries[i].cmd) 555 + goto error; 556 + } 557 + 558 + /* Circular buffer of transmit frame descriptors (TFDs), 559 + * shared with device 560 + */ 561 + txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz, 562 + &txq->dma_addr, GFP_KERNEL); 563 + if (!txq->tfds) 564 + goto error; 565 + 566 + BUILD_BUG_ON(sizeof(*txq->first_tb_bufs) != IWL_FIRST_TB_SIZE_ALIGN); 567 + 568 + tb0_buf_sz = sizeof(*txq->first_tb_bufs) * slots_num; 569 + 570 + txq->first_tb_bufs = dma_alloc_coherent(trans->dev, tb0_buf_sz, 571 + &txq->first_tb_dma, 572 + GFP_KERNEL); 573 + if (!txq->first_tb_bufs) 574 + goto err_free_tfds; 575 + 576 + for (i = 0; i < num_entries; i++) { 577 + void *tfd = iwl_txq_get_tfd(trans, txq, i); 578 + 579 + if (trans->trans_cfg->gen2) 580 + iwl_txq_set_tfd_invalid_gen2(trans, tfd); 581 + else 582 + iwl_txq_set_tfd_invalid_gen1(trans, tfd); 583 + } 584 + 585 + return 0; 586 + err_free_tfds: 587 + dma_free_coherent(trans->dev, tfd_sz, txq->tfds, txq->dma_addr); 588 + txq->tfds = NULL; 589 + error: 590 + if (txq->entries && cmd_queue) 591 + for (i = 0; i < slots_num; i++) 592 + kfree(txq->entries[i].cmd); 593 + kfree(txq->entries); 594 + txq->entries = NULL; 595 + 596 + return -ENOMEM; 636 597 } 637 598 638 599 /* ··· 786 491 goto error; 787 492 } 788 493 789 - ret = iwl_pcie_alloc_dma_ptr(trans, &trans->txqs.scd_bc_tbls, 494 + ret = iwl_pcie_alloc_dma_ptr(trans, &trans_pcie->txqs.scd_bc_tbls, 790 495 bc_tbls_size); 791 496 if (ret) { 792 497 IWL_ERR(trans, "Scheduler BC Table allocation failed\n"); ··· 812 517 /* Alloc and init all Tx queues, including the command queue (#4/#9) */ 813 518 for (txq_id = 0; txq_id < trans->trans_cfg->base_params->num_of_queues; 814 519 txq_id++) { 815 - bool cmd_queue = (txq_id == trans->txqs.cmd.q_id); 520 + bool cmd_queue = (txq_id == trans_pcie->txqs.cmd.q_id); 816 521 817 522 if (cmd_queue) 818 523 slots_num = max_t(u32, IWL_CMD_QUEUE_SIZE, ··· 820 525 else 821 526 slots_num = max_t(u32, IWL_DEFAULT_QUEUE_SIZE, 822 527 trans->cfg->min_ba_txq_size); 823 - trans->txqs.txq[txq_id] = &trans_pcie->txq_memory[txq_id]; 824 - ret = iwl_txq_alloc(trans, trans->txqs.txq[txq_id], slots_num, 825 - cmd_queue); 528 + trans_pcie->txqs.txq[txq_id] = &trans_pcie->txq_memory[txq_id]; 529 + ret = iwl_pcie_txq_alloc(trans, trans_pcie->txqs.txq[txq_id], 530 + slots_num, cmd_queue); 826 531 if (ret) { 827 532 IWL_ERR(trans, "Tx %d queue alloc failed\n", txq_id); 828 533 goto error; 829 534 } 830 - trans->txqs.txq[txq_id]->id = txq_id; 535 + trans_pcie->txqs.txq[txq_id]->id = txq_id; 831 536 } 832 537 833 538 return 0; ··· 836 541 iwl_pcie_tx_free(trans); 837 542 838 543 return ret; 544 + } 545 + 546 + /* 547 + * iwl_queue_init - Initialize queue's high/low-water and read/write indexes 548 + */ 549 + static int iwl_queue_init(struct iwl_txq *q, int slots_num) 550 + { 551 + q->n_window = slots_num; 552 + 553 + /* slots_num must be power-of-two size, otherwise 554 + * iwl_txq_get_cmd_index is broken. 555 + */ 556 + if (WARN_ON(!is_power_of_2(slots_num))) 557 + return -EINVAL; 558 + 559 + q->low_mark = q->n_window / 4; 560 + if (q->low_mark < 4) 561 + q->low_mark = 4; 562 + 563 + q->high_mark = q->n_window / 8; 564 + if (q->high_mark < 2) 565 + q->high_mark = 2; 566 + 567 + q->write_ptr = 0; 568 + q->read_ptr = 0; 569 + 570 + return 0; 571 + } 572 + 573 + int iwl_txq_init(struct iwl_trans *trans, struct iwl_txq *txq, 574 + int slots_num, bool cmd_queue) 575 + { 576 + u32 tfd_queue_max_size = 577 + trans->trans_cfg->base_params->max_tfd_queue_size; 578 + int ret; 579 + 580 + txq->need_update = false; 581 + 582 + /* max_tfd_queue_size must be power-of-two size, otherwise 583 + * iwl_txq_inc_wrap and iwl_txq_dec_wrap are broken. 584 + */ 585 + if (WARN_ONCE(tfd_queue_max_size & (tfd_queue_max_size - 1), 586 + "Max tfd queue size must be a power of two, but is %d", 587 + tfd_queue_max_size)) 588 + return -EINVAL; 589 + 590 + /* Initialize queue's high/low-water marks, and head/tail indexes */ 591 + ret = iwl_queue_init(txq, slots_num); 592 + if (ret) 593 + return ret; 594 + 595 + spin_lock_init(&txq->lock); 596 + 597 + if (cmd_queue) { 598 + static struct lock_class_key iwl_txq_cmd_queue_lock_class; 599 + 600 + lockdep_set_class(&txq->lock, &iwl_txq_cmd_queue_lock_class); 601 + } 602 + 603 + __skb_queue_head_init(&txq->overflow_q); 604 + 605 + return 0; 839 606 } 840 607 841 608 int iwl_pcie_tx_init(struct iwl_trans *trans) ··· 928 571 /* Alloc and init all Tx queues, including the command queue (#4/#9) */ 929 572 for (txq_id = 0; txq_id < trans->trans_cfg->base_params->num_of_queues; 930 573 txq_id++) { 931 - bool cmd_queue = (txq_id == trans->txqs.cmd.q_id); 574 + bool cmd_queue = (txq_id == trans_pcie->txqs.cmd.q_id); 932 575 933 576 if (cmd_queue) 934 577 slots_num = max_t(u32, IWL_CMD_QUEUE_SIZE, ··· 936 579 else 937 580 slots_num = max_t(u32, IWL_DEFAULT_QUEUE_SIZE, 938 581 trans->cfg->min_ba_txq_size); 939 - ret = iwl_txq_init(trans, trans->txqs.txq[txq_id], slots_num, 582 + ret = iwl_txq_init(trans, trans_pcie->txqs.txq[txq_id], slots_num, 940 583 cmd_queue); 941 584 if (ret) { 942 585 IWL_ERR(trans, "Tx %d queue init failed\n", txq_id); ··· 950 593 * Circular buffer (TFD queue in DRAM) physical base address 951 594 */ 952 595 iwl_write_direct32(trans, FH_MEM_CBBC_QUEUE(trans, txq_id), 953 - trans->txqs.txq[txq_id]->dma_addr >> 8); 596 + trans_pcie->txqs.txq[txq_id]->dma_addr >> 8); 954 597 } 955 598 956 599 iwl_set_bits_prph(trans, SCD_GP_CTRL, SCD_GP_CTRL_AUTO_ACTIVE_MODE); ··· 998 641 return 0; 999 642 } 1000 643 644 + static void iwl_txq_progress(struct iwl_txq *txq) 645 + { 646 + lockdep_assert_held(&txq->lock); 647 + 648 + if (!txq->wd_timeout) 649 + return; 650 + 651 + /* 652 + * station is asleep and we send data - that must 653 + * be uAPSD or PS-Poll. Don't rearm the timer. 654 + */ 655 + if (txq->frozen) 656 + return; 657 + 658 + /* 659 + * if empty delete timer, otherwise move timer forward 660 + * since we're making progress on this queue 661 + */ 662 + if (txq->read_ptr == txq->write_ptr) 663 + del_timer(&txq->stuck_timer); 664 + else 665 + mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); 666 + } 667 + 668 + static inline bool iwl_txq_used(const struct iwl_txq *q, int i) 669 + { 670 + int index = iwl_txq_get_cmd_index(q, i); 671 + int r = iwl_txq_get_cmd_index(q, q->read_ptr); 672 + int w = iwl_txq_get_cmd_index(q, q->write_ptr); 673 + 674 + return w >= r ? 675 + (index >= r && index < w) : 676 + !(index < r && index >= w); 677 + } 678 + 1001 679 /* 1002 680 * iwl_pcie_cmdq_reclaim - Reclaim TX command queue entries already Tx'd 1003 681 * ··· 1042 650 */ 1043 651 static void iwl_pcie_cmdq_reclaim(struct iwl_trans *trans, int txq_id, int idx) 1044 652 { 1045 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 653 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 654 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 1046 655 int nfreed = 0; 1047 656 u16 r; 1048 657 ··· 1054 661 1055 662 if (idx >= trans->trans_cfg->base_params->max_tfd_queue_size || 1056 663 (!iwl_txq_used(txq, idx))) { 1057 - WARN_ONCE(test_bit(txq_id, trans->txqs.queue_used), 664 + WARN_ONCE(test_bit(txq_id, trans_pcie->txqs.queue_used), 1058 665 "%s: Read index for DMA queue txq id (%d), index %d is out of range [0-%d] %d %d.\n", 1059 666 __func__, txq_id, idx, 1060 667 trans->trans_cfg->base_params->max_tfd_queue_size, ··· 1113 720 unsigned int wdg_timeout) 1114 721 { 1115 722 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1116 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 723 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 1117 724 int fifo = -1; 1118 725 bool scd_bug = false; 1119 726 1120 - if (test_and_set_bit(txq_id, trans->txqs.queue_used)) 727 + if (test_and_set_bit(txq_id, trans_pcie->txqs.queue_used)) 1121 728 WARN_ONCE(1, "queue %d already used - expect issues", txq_id); 1122 729 1123 730 txq->wd_timeout = msecs_to_jiffies(wdg_timeout); ··· 1126 733 fifo = cfg->fifo; 1127 734 1128 735 /* Disable the scheduler prior configuring the cmd queue */ 1129 - if (txq_id == trans->txqs.cmd.q_id && 736 + if (txq_id == trans_pcie->txqs.cmd.q_id && 1130 737 trans_pcie->scd_set_active) 1131 738 iwl_scd_enable_set_active(trans, 0); 1132 739 ··· 1134 741 iwl_scd_txq_set_inactive(trans, txq_id); 1135 742 1136 743 /* Set this queue as a chain-building queue unless it is CMD */ 1137 - if (txq_id != trans->txqs.cmd.q_id) 744 + if (txq_id != trans_pcie->txqs.cmd.q_id) 1138 745 iwl_scd_txq_set_chain(trans, txq_id); 1139 746 1140 747 if (cfg->aggregate) { ··· 1204 811 SCD_QUEUE_STTS_REG_MSK); 1205 812 1206 813 /* enable the scheduler for this queue (only) */ 1207 - if (txq_id == trans->txqs.cmd.q_id && 814 + if (txq_id == trans_pcie->txqs.cmd.q_id && 1208 815 trans_pcie->scd_set_active) 1209 816 iwl_scd_enable_set_active(trans, BIT(txq_id)); 1210 817 ··· 1223 830 void iwl_trans_pcie_txq_set_shared_mode(struct iwl_trans *trans, u32 txq_id, 1224 831 bool shared_mode) 1225 832 { 1226 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 833 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 834 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 1227 835 1228 836 txq->ampdu = !shared_mode; 1229 837 } ··· 1237 843 SCD_TX_STTS_QUEUE_OFFSET(txq_id); 1238 844 static const u32 zero_val[4] = {}; 1239 845 1240 - trans->txqs.txq[txq_id]->frozen_expiry_remainder = 0; 1241 - trans->txqs.txq[txq_id]->frozen = false; 846 + trans_pcie->txqs.txq[txq_id]->frozen_expiry_remainder = 0; 847 + trans_pcie->txqs.txq[txq_id]->frozen = false; 1242 848 1243 849 /* 1244 850 * Upon HW Rfkill - we stop the device, and then stop the queues ··· 1246 852 * allow the op_mode to call txq_disable after it already called 1247 853 * stop_device. 1248 854 */ 1249 - if (!test_and_clear_bit(txq_id, trans->txqs.queue_used)) { 855 + if (!test_and_clear_bit(txq_id, trans_pcie->txqs.queue_used)) { 1250 856 WARN_ONCE(test_bit(STATUS_DEVICE_ENABLED, &trans->status), 1251 857 "queue %d not used", txq_id); 1252 858 return; ··· 1260 866 } 1261 867 1262 868 iwl_pcie_txq_unmap(trans, txq_id); 1263 - trans->txqs.txq[txq_id]->ampdu = false; 869 + trans_pcie->txqs.txq[txq_id]->ampdu = false; 1264 870 1265 871 IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", txq_id); 1266 872 } ··· 1269 875 1270 876 static void iwl_trans_pcie_block_txq_ptrs(struct iwl_trans *trans, bool block) 1271 877 { 878 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1272 879 int i; 1273 880 1274 881 for (i = 0; i < trans->trans_cfg->base_params->num_of_queues; i++) { 1275 - struct iwl_txq *txq = trans->txqs.txq[i]; 882 + struct iwl_txq *txq = trans_pcie->txqs.txq[i]; 1276 883 1277 - if (i == trans->txqs.cmd.q_id) 884 + if (i == trans_pcie->txqs.cmd.q_id) 1278 885 continue; 1279 886 1280 887 /* we skip the command queue (obviously) so it's OK to nest */ ··· 1307 912 int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans, 1308 913 struct iwl_host_cmd *cmd) 1309 914 { 1310 - struct iwl_txq *txq = trans->txqs.txq[trans->txqs.cmd.q_id]; 915 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 916 + struct iwl_txq *txq = trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]; 1311 917 struct iwl_device_cmd *out_cmd; 1312 918 struct iwl_cmd_meta *out_meta; 1313 919 void *dup_buf = NULL; ··· 1434 1038 sizeof(struct iwl_cmd_header_wide)); 1435 1039 out_cmd->hdr_wide.reserved = 0; 1436 1040 out_cmd->hdr_wide.sequence = 1437 - cpu_to_le16(QUEUE_TO_SEQ(trans->txqs.cmd.q_id) | 1041 + cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->txqs.cmd.q_id) | 1438 1042 INDEX_TO_SEQ(txq->write_ptr)); 1439 1043 1440 1044 cmd_pos = sizeof(struct iwl_cmd_header_wide); ··· 1442 1046 } else { 1443 1047 out_cmd->hdr.cmd = iwl_cmd_opcode(cmd->id); 1444 1048 out_cmd->hdr.sequence = 1445 - cpu_to_le16(QUEUE_TO_SEQ(trans->txqs.cmd.q_id) | 1049 + cpu_to_le16(QUEUE_TO_SEQ(trans_pcie->txqs.cmd.q_id) | 1446 1050 INDEX_TO_SEQ(txq->write_ptr)); 1447 1051 out_cmd->hdr.group_id = 0; 1448 1052 ··· 1493 1097 iwl_get_cmd_string(trans, cmd->id), 1494 1098 group_id, out_cmd->hdr.cmd, 1495 1099 le16_to_cpu(out_cmd->hdr.sequence), 1496 - cmd_size, txq->write_ptr, idx, trans->txqs.cmd.q_id); 1100 + cmd_size, txq->write_ptr, idx, trans_pcie->txqs.cmd.q_id); 1497 1101 1498 1102 /* start the TFD with the minimum copy bytes */ 1499 1103 tb0_size = min_t(int, copy_size, IWL_FIRST_TB_SIZE); ··· 1592 1196 struct iwl_device_cmd *cmd; 1593 1197 struct iwl_cmd_meta *meta; 1594 1198 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1595 - struct iwl_txq *txq = trans->txqs.txq[trans->txqs.cmd.q_id]; 1199 + struct iwl_txq *txq = trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]; 1596 1200 1597 1201 /* If a Tx command is being handled and it isn't in the actual 1598 1202 * command queue then there a command routing bug has been introduced 1599 1203 * in the queue management code. */ 1600 - if (WARN(txq_id != trans->txqs.cmd.q_id, 1204 + if (WARN(txq_id != trans_pcie->txqs.cmd.q_id, 1601 1205 "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", 1602 - txq_id, trans->txqs.cmd.q_id, sequence, txq->read_ptr, 1206 + txq_id, trans_pcie->txqs.cmd.q_id, sequence, txq->read_ptr, 1603 1207 txq->write_ptr)) { 1604 1208 iwl_print_hex_error(trans, pkt, 32); 1605 1209 return; ··· 1702 1306 } 1703 1307 1704 1308 #ifdef CONFIG_INET 1309 + struct iwl_tso_hdr_page *iwl_pcie_get_page_hdr(struct iwl_trans *trans, 1310 + size_t len, struct sk_buff *skb) 1311 + { 1312 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1313 + struct iwl_tso_hdr_page *p = this_cpu_ptr(trans_pcie->txqs.tso_hdr_page); 1314 + struct page **page_ptr; 1315 + 1316 + page_ptr = (void *)((u8 *)skb->cb + trans_pcie->txqs.page_offs); 1317 + 1318 + if (WARN_ON(*page_ptr)) 1319 + return NULL; 1320 + 1321 + if (!p->page) 1322 + goto alloc; 1323 + 1324 + /* 1325 + * Check if there's enough room on this page 1326 + * 1327 + * Note that we put a page chaining pointer *last* in the 1328 + * page - we need it somewhere, and if it's there then we 1329 + * avoid DMA mapping the last bits of the page which may 1330 + * trigger the 32-bit boundary hardware bug. 1331 + * 1332 + * (see also get_workaround_page() in tx-gen2.c) 1333 + */ 1334 + if (p->pos + len < (u8 *)page_address(p->page) + PAGE_SIZE - 1335 + sizeof(void *)) 1336 + goto out; 1337 + 1338 + /* We don't have enough room on this page, get a new one. */ 1339 + __free_page(p->page); 1340 + 1341 + alloc: 1342 + p->page = alloc_page(GFP_ATOMIC); 1343 + if (!p->page) 1344 + return NULL; 1345 + p->pos = page_address(p->page); 1346 + /* set the chaining pointer to NULL */ 1347 + *(void **)((u8 *)page_address(p->page) + PAGE_SIZE - sizeof(void *)) = NULL; 1348 + out: 1349 + *page_ptr = p->page; 1350 + get_page(p->page); 1351 + return p; 1352 + } 1353 + 1705 1354 static int iwl_fill_data_tbs_amsdu(struct iwl_trans *trans, struct sk_buff *skb, 1706 1355 struct iwl_txq *txq, u8 hdr_len, 1707 1356 struct iwl_cmd_meta *out_meta, 1708 1357 struct iwl_device_tx_cmd *dev_cmd, 1709 1358 u16 tb1_len) 1710 1359 { 1360 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1711 1361 struct iwl_tx_cmd *tx_cmd = (void *)dev_cmd->payload; 1712 1362 struct ieee80211_hdr *hdr = (void *)skb->data; 1713 1363 unsigned int snap_ip_tcp_hdrlen, ip_hdrlen, total_len, hdr_room; ··· 1770 1328 1771 1329 trace_iwlwifi_dev_tx(trans->dev, skb, 1772 1330 iwl_txq_get_tfd(trans, txq, txq->write_ptr), 1773 - trans->txqs.tfd.size, 1331 + trans_pcie->txqs.tfd.size, 1774 1332 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len, 0); 1775 1333 1776 1334 ip_hdrlen = skb_network_header_len(skb); ··· 1783 1341 (3 + snap_ip_tcp_hdrlen + sizeof(struct ethhdr)) + iv_len; 1784 1342 1785 1343 /* Our device supports 9 segments at most, it will fit in 1 page */ 1786 - hdr_page = get_page_hdr(trans, hdr_room, skb); 1344 + hdr_page = iwl_pcie_get_page_hdr(trans, hdr_room, skb); 1787 1345 if (!hdr_page) 1788 1346 return -ENOMEM; 1789 1347 ··· 1892 1450 } 1893 1451 #endif /* CONFIG_INET */ 1894 1452 1453 + #define IWL_TX_CRC_SIZE 4 1454 + #define IWL_TX_DELIMITER_SIZE 4 1455 + 1456 + /* 1457 + * iwl_txq_gen1_update_byte_cnt_tbl - Set up entry in Tx byte-count array 1458 + */ 1459 + static void iwl_txq_gen1_update_byte_cnt_tbl(struct iwl_trans *trans, 1460 + struct iwl_txq *txq, u16 byte_cnt, 1461 + int num_tbs) 1462 + { 1463 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1464 + struct iwlagn_scd_bc_tbl *scd_bc_tbl; 1465 + int write_ptr = txq->write_ptr; 1466 + int txq_id = txq->id; 1467 + u8 sec_ctl = 0; 1468 + u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; 1469 + __le16 bc_ent; 1470 + struct iwl_device_tx_cmd *dev_cmd = txq->entries[txq->write_ptr].cmd; 1471 + struct iwl_tx_cmd *tx_cmd = (void *)dev_cmd->payload; 1472 + u8 sta_id = tx_cmd->sta_id; 1473 + 1474 + scd_bc_tbl = trans_pcie->txqs.scd_bc_tbls.addr; 1475 + 1476 + sec_ctl = tx_cmd->sec_ctl; 1477 + 1478 + switch (sec_ctl & TX_CMD_SEC_MSK) { 1479 + case TX_CMD_SEC_CCM: 1480 + len += IEEE80211_CCMP_MIC_LEN; 1481 + break; 1482 + case TX_CMD_SEC_TKIP: 1483 + len += IEEE80211_TKIP_ICV_LEN; 1484 + break; 1485 + case TX_CMD_SEC_WEP: 1486 + len += IEEE80211_WEP_IV_LEN + IEEE80211_WEP_ICV_LEN; 1487 + break; 1488 + } 1489 + if (trans_pcie->txqs.bc_table_dword) 1490 + len = DIV_ROUND_UP(len, 4); 1491 + 1492 + if (WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX)) 1493 + return; 1494 + 1495 + bc_ent = cpu_to_le16(len | (sta_id << 12)); 1496 + 1497 + scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent; 1498 + 1499 + if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) 1500 + scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = 1501 + bc_ent; 1502 + } 1503 + 1895 1504 int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, 1896 1505 struct iwl_device_tx_cmd *dev_cmd, int txq_id) 1897 1506 { 1507 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1898 1508 struct ieee80211_hdr *hdr; 1899 1509 struct iwl_tx_cmd *tx_cmd = (struct iwl_tx_cmd *)dev_cmd->payload; 1900 1510 struct iwl_cmd_meta *out_meta; ··· 1961 1467 u16 wifi_seq; 1962 1468 bool amsdu; 1963 1469 1964 - txq = trans->txqs.txq[txq_id]; 1470 + txq = trans_pcie->txqs.txq[txq_id]; 1965 1471 1966 - if (WARN_ONCE(!test_bit(txq_id, trans->txqs.queue_used), 1472 + if (WARN_ONCE(!test_bit(txq_id, trans_pcie->txqs.queue_used), 1967 1473 "TX on unused queue %d\n", txq_id)) 1968 1474 return -EINVAL; 1969 1475 1970 1476 if (skb_is_nonlinear(skb) && 1971 - skb_shinfo(skb)->nr_frags > IWL_TRANS_MAX_FRAGS(trans) && 1477 + skb_shinfo(skb)->nr_frags > IWL_TRANS_PCIE_MAX_FRAGS(trans_pcie) && 1972 1478 __skb_linearize(skb)) 1973 1479 return -ENOMEM; 1974 1480 ··· 1989 1495 struct iwl_device_tx_cmd **dev_cmd_ptr; 1990 1496 1991 1497 dev_cmd_ptr = (void *)((u8 *)skb->cb + 1992 - trans->txqs.dev_cmd_offs); 1498 + trans_pcie->txqs.dev_cmd_offs); 1993 1499 1994 1500 *dev_cmd_ptr = dev_cmd; 1995 1501 __skb_queue_tail(&txq->overflow_q, skb); ··· 2072 1578 2073 1579 trace_iwlwifi_dev_tx(trans->dev, skb, 2074 1580 iwl_txq_get_tfd(trans, txq, txq->write_ptr), 2075 - trans->txqs.tfd.size, 1581 + trans_pcie->txqs.tfd.size, 2076 1582 &dev_cmd->hdr, IWL_FIRST_TB_SIZE + tb1_len, 2077 1583 hdr_len); 2078 1584 ··· 2107 1613 tfd = iwl_txq_get_tfd(trans, txq, txq->write_ptr); 2108 1614 /* Set up entry for this TFD in Tx byte-count array */ 2109 1615 iwl_txq_gen1_update_byte_cnt_tbl(trans, txq, le16_to_cpu(tx_cmd->len), 2110 - iwl_txq_gen1_tfd_get_num_tbs(trans, 2111 - tfd)); 1616 + iwl_txq_gen1_tfd_get_num_tbs(tfd)); 2112 1617 2113 1618 wait_write_ptr = ieee80211_has_morefrags(fc); 2114 1619 ··· 2142 1649 spin_unlock(&txq->lock); 2143 1650 return -1; 2144 1651 } 1652 + 1653 + static void iwl_txq_gen1_inval_byte_cnt_tbl(struct iwl_trans *trans, 1654 + struct iwl_txq *txq) 1655 + { 1656 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1657 + struct iwlagn_scd_bc_tbl *scd_bc_tbl = trans_pcie->txqs.scd_bc_tbls.addr; 1658 + int txq_id = txq->id; 1659 + int read_ptr = txq->read_ptr; 1660 + u8 sta_id = 0; 1661 + __le16 bc_ent; 1662 + struct iwl_device_tx_cmd *dev_cmd = txq->entries[read_ptr].cmd; 1663 + struct iwl_tx_cmd *tx_cmd = (void *)dev_cmd->payload; 1664 + 1665 + WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX); 1666 + 1667 + if (txq_id != trans_pcie->txqs.cmd.q_id) 1668 + sta_id = tx_cmd->sta_id; 1669 + 1670 + bc_ent = cpu_to_le16(1 | (sta_id << 12)); 1671 + 1672 + scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent; 1673 + 1674 + if (read_ptr < TFD_QUEUE_SIZE_BC_DUP) 1675 + scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = 1676 + bc_ent; 1677 + } 1678 + 1679 + /* Frees buffers until index _not_ inclusive */ 1680 + void iwl_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn, 1681 + struct sk_buff_head *skbs, bool is_flush) 1682 + { 1683 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1684 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 1685 + int tfd_num, read_ptr, last_to_free; 1686 + 1687 + /* This function is not meant to release cmd queue*/ 1688 + if (WARN_ON(txq_id == trans_pcie->txqs.cmd.q_id)) 1689 + return; 1690 + 1691 + if (WARN_ON(!txq)) 1692 + return; 1693 + 1694 + tfd_num = iwl_txq_get_cmd_index(txq, ssn); 1695 + 1696 + spin_lock_bh(&txq->lock); 1697 + read_ptr = iwl_txq_get_cmd_index(txq, txq->read_ptr); 1698 + 1699 + if (!test_bit(txq_id, trans_pcie->txqs.queue_used)) { 1700 + IWL_DEBUG_TX_QUEUES(trans, "Q %d inactive - ignoring idx %d\n", 1701 + txq_id, ssn); 1702 + goto out; 1703 + } 1704 + 1705 + if (read_ptr == tfd_num) 1706 + goto out; 1707 + 1708 + IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d (%d) -> %d (%d)\n", 1709 + txq_id, read_ptr, txq->read_ptr, tfd_num, ssn); 1710 + 1711 + /* Since we free until index _not_ inclusive, the one before index is 1712 + * the last we will free. This one must be used 1713 + */ 1714 + last_to_free = iwl_txq_dec_wrap(trans, tfd_num); 1715 + 1716 + if (!iwl_txq_used(txq, last_to_free)) { 1717 + IWL_ERR(trans, 1718 + "%s: Read index for txq id (%d), last_to_free %d is out of range [0-%d] %d %d.\n", 1719 + __func__, txq_id, last_to_free, 1720 + trans->trans_cfg->base_params->max_tfd_queue_size, 1721 + txq->write_ptr, txq->read_ptr); 1722 + 1723 + iwl_op_mode_time_point(trans->op_mode, 1724 + IWL_FW_INI_TIME_POINT_FAKE_TX, 1725 + NULL); 1726 + goto out; 1727 + } 1728 + 1729 + if (WARN_ON(!skb_queue_empty(skbs))) 1730 + goto out; 1731 + 1732 + for (; 1733 + read_ptr != tfd_num; 1734 + txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr), 1735 + read_ptr = iwl_txq_get_cmd_index(txq, txq->read_ptr)) { 1736 + struct sk_buff *skb = txq->entries[read_ptr].skb; 1737 + 1738 + if (WARN_ONCE(!skb, "no SKB at %d (%d) on queue %d\n", 1739 + read_ptr, txq->read_ptr, txq_id)) 1740 + continue; 1741 + 1742 + iwl_pcie_free_tso_page(trans, skb); 1743 + 1744 + __skb_queue_tail(skbs, skb); 1745 + 1746 + txq->entries[read_ptr].skb = NULL; 1747 + 1748 + if (!trans->trans_cfg->gen2) 1749 + iwl_txq_gen1_inval_byte_cnt_tbl(trans, txq); 1750 + 1751 + iwl_txq_free_tfd(trans, txq); 1752 + } 1753 + 1754 + iwl_txq_progress(txq); 1755 + 1756 + if (iwl_txq_space(trans, txq) > txq->low_mark && 1757 + test_bit(txq_id, trans_pcie->txqs.queue_stopped)) { 1758 + struct sk_buff_head overflow_skbs; 1759 + struct sk_buff *skb; 1760 + 1761 + __skb_queue_head_init(&overflow_skbs); 1762 + skb_queue_splice_init(&txq->overflow_q, 1763 + is_flush ? skbs : &overflow_skbs); 1764 + 1765 + /* 1766 + * We are going to transmit from the overflow queue. 1767 + * Remember this state so that wait_for_txq_empty will know we 1768 + * are adding more packets to the TFD queue. It cannot rely on 1769 + * the state of &txq->overflow_q, as we just emptied it, but 1770 + * haven't TXed the content yet. 1771 + */ 1772 + txq->overflow_tx = true; 1773 + 1774 + /* 1775 + * This is tricky: we are in reclaim path which is non 1776 + * re-entrant, so noone will try to take the access the 1777 + * txq data from that path. We stopped tx, so we can't 1778 + * have tx as well. Bottom line, we can unlock and re-lock 1779 + * later. 1780 + */ 1781 + spin_unlock_bh(&txq->lock); 1782 + 1783 + while ((skb = __skb_dequeue(&overflow_skbs))) { 1784 + struct iwl_device_tx_cmd *dev_cmd_ptr; 1785 + 1786 + dev_cmd_ptr = *(void **)((u8 *)skb->cb + 1787 + trans_pcie->txqs.dev_cmd_offs); 1788 + 1789 + /* 1790 + * Note that we can very well be overflowing again. 1791 + * In that case, iwl_txq_space will be small again 1792 + * and we won't wake mac80211's queue. 1793 + */ 1794 + iwl_trans_tx(trans, skb, dev_cmd_ptr, txq_id); 1795 + } 1796 + 1797 + if (iwl_txq_space(trans, txq) > txq->low_mark) 1798 + iwl_trans_pcie_wake_queue(trans, txq); 1799 + 1800 + spin_lock_bh(&txq->lock); 1801 + txq->overflow_tx = false; 1802 + } 1803 + 1804 + out: 1805 + spin_unlock_bh(&txq->lock); 1806 + } 1807 + 1808 + /* Set wr_ptr of specific device and txq */ 1809 + void iwl_pcie_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr) 1810 + { 1811 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1812 + struct iwl_txq *txq = trans_pcie->txqs.txq[txq_id]; 1813 + 1814 + spin_lock_bh(&txq->lock); 1815 + 1816 + txq->write_ptr = ptr; 1817 + txq->read_ptr = txq->write_ptr; 1818 + 1819 + spin_unlock_bh(&txq->lock); 1820 + } 1821 + 1822 + void iwl_pcie_freeze_txq_timer(struct iwl_trans *trans, 1823 + unsigned long txqs, bool freeze) 1824 + { 1825 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1826 + int queue; 1827 + 1828 + for_each_set_bit(queue, &txqs, BITS_PER_LONG) { 1829 + struct iwl_txq *txq = trans_pcie->txqs.txq[queue]; 1830 + unsigned long now; 1831 + 1832 + spin_lock_bh(&txq->lock); 1833 + 1834 + now = jiffies; 1835 + 1836 + if (txq->frozen == freeze) 1837 + goto next_queue; 1838 + 1839 + IWL_DEBUG_TX_QUEUES(trans, "%s TXQ %d\n", 1840 + freeze ? "Freezing" : "Waking", queue); 1841 + 1842 + txq->frozen = freeze; 1843 + 1844 + if (txq->read_ptr == txq->write_ptr) 1845 + goto next_queue; 1846 + 1847 + if (freeze) { 1848 + if (unlikely(time_after(now, 1849 + txq->stuck_timer.expires))) { 1850 + /* 1851 + * The timer should have fired, maybe it is 1852 + * spinning right now on the lock. 1853 + */ 1854 + goto next_queue; 1855 + } 1856 + /* remember how long until the timer fires */ 1857 + txq->frozen_expiry_remainder = 1858 + txq->stuck_timer.expires - now; 1859 + del_timer(&txq->stuck_timer); 1860 + goto next_queue; 1861 + } 1862 + 1863 + /* 1864 + * Wake a non-empty queue -> arm timer with the 1865 + * remainder before it froze 1866 + */ 1867 + mod_timer(&txq->stuck_timer, 1868 + now + txq->frozen_expiry_remainder); 1869 + 1870 + next_queue: 1871 + spin_unlock_bh(&txq->lock); 1872 + } 1873 + } 1874 + 1875 + #define HOST_COMPLETE_TIMEOUT (2 * HZ) 1876 + 1877 + static int iwl_trans_pcie_send_hcmd_sync(struct iwl_trans *trans, 1878 + struct iwl_host_cmd *cmd) 1879 + { 1880 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1881 + const char *cmd_str = iwl_get_cmd_string(trans, cmd->id); 1882 + struct iwl_txq *txq = trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]; 1883 + int cmd_idx; 1884 + int ret; 1885 + 1886 + IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", cmd_str); 1887 + 1888 + if (WARN(test_and_set_bit(STATUS_SYNC_HCMD_ACTIVE, 1889 + &trans->status), 1890 + "Command %s: a command is already active!\n", cmd_str)) 1891 + return -EIO; 1892 + 1893 + IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", cmd_str); 1894 + 1895 + if (trans->trans_cfg->gen2) 1896 + cmd_idx = iwl_pcie_gen2_enqueue_hcmd(trans, cmd); 1897 + else 1898 + cmd_idx = iwl_pcie_enqueue_hcmd(trans, cmd); 1899 + 1900 + if (cmd_idx < 0) { 1901 + ret = cmd_idx; 1902 + clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 1903 + IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", 1904 + cmd_str, ret); 1905 + return ret; 1906 + } 1907 + 1908 + ret = wait_event_timeout(trans->wait_command_queue, 1909 + !test_bit(STATUS_SYNC_HCMD_ACTIVE, 1910 + &trans->status), 1911 + HOST_COMPLETE_TIMEOUT); 1912 + if (!ret) { 1913 + IWL_ERR(trans, "Error sending %s: time out after %dms.\n", 1914 + cmd_str, jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); 1915 + 1916 + IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n", 1917 + txq->read_ptr, txq->write_ptr); 1918 + 1919 + clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 1920 + IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", 1921 + cmd_str); 1922 + ret = -ETIMEDOUT; 1923 + 1924 + iwl_trans_sync_nmi(trans); 1925 + goto cancel; 1926 + } 1927 + 1928 + if (test_bit(STATUS_FW_ERROR, &trans->status)) { 1929 + if (!test_and_clear_bit(STATUS_SUPPRESS_CMD_ERROR_ONCE, 1930 + &trans->status)) { 1931 + IWL_ERR(trans, "FW error in SYNC CMD %s\n", cmd_str); 1932 + dump_stack(); 1933 + } 1934 + ret = -EIO; 1935 + goto cancel; 1936 + } 1937 + 1938 + if (!(cmd->flags & CMD_SEND_IN_RFKILL) && 1939 + test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { 1940 + IWL_DEBUG_RF_KILL(trans, "RFKILL in SYNC CMD... no rsp\n"); 1941 + ret = -ERFKILL; 1942 + goto cancel; 1943 + } 1944 + 1945 + if ((cmd->flags & CMD_WANT_SKB) && !cmd->resp_pkt) { 1946 + IWL_ERR(trans, "Error: Response NULL in '%s'\n", cmd_str); 1947 + ret = -EIO; 1948 + goto cancel; 1949 + } 1950 + 1951 + return 0; 1952 + 1953 + cancel: 1954 + if (cmd->flags & CMD_WANT_SKB) { 1955 + /* 1956 + * Cancel the CMD_WANT_SKB flag for the cmd in the 1957 + * TX cmd queue. Otherwise in case the cmd comes 1958 + * in later, it will possibly set an invalid 1959 + * address (cmd->meta.source). 1960 + */ 1961 + txq->entries[cmd_idx].meta.flags &= ~CMD_WANT_SKB; 1962 + } 1963 + 1964 + if (cmd->resp_pkt) { 1965 + iwl_free_resp(cmd); 1966 + cmd->resp_pkt = NULL; 1967 + } 1968 + 1969 + return ret; 1970 + } 1971 + 1972 + int iwl_trans_pcie_send_hcmd(struct iwl_trans *trans, 1973 + struct iwl_host_cmd *cmd) 1974 + { 1975 + /* Make sure the NIC is still alive in the bus */ 1976 + if (test_bit(STATUS_TRANS_DEAD, &trans->status)) 1977 + return -ENODEV; 1978 + 1979 + if (!(cmd->flags & CMD_SEND_IN_RFKILL) && 1980 + test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { 1981 + IWL_DEBUG_RF_KILL(trans, "Dropping CMD 0x%x: RF KILL\n", 1982 + cmd->id); 1983 + return -ERFKILL; 1984 + } 1985 + 1986 + if (unlikely(trans->system_pm_mode == IWL_PLAT_PM_MODE_D3 && 1987 + !(cmd->flags & CMD_SEND_IN_D3))) { 1988 + IWL_DEBUG_WOWLAN(trans, "Dropping CMD 0x%x: D3\n", cmd->id); 1989 + return -EHOSTDOWN; 1990 + } 1991 + 1992 + if (cmd->flags & CMD_ASYNC) { 1993 + int ret; 1994 + 1995 + /* An asynchronous command can not expect an SKB to be set. */ 1996 + if (WARN_ON(cmd->flags & CMD_WANT_SKB)) 1997 + return -EINVAL; 1998 + 1999 + if (trans->trans_cfg->gen2) 2000 + ret = iwl_pcie_gen2_enqueue_hcmd(trans, cmd); 2001 + else 2002 + ret = iwl_pcie_enqueue_hcmd(trans, cmd); 2003 + 2004 + if (ret < 0) { 2005 + IWL_ERR(trans, 2006 + "Error sending %s: enqueue_hcmd failed: %d\n", 2007 + iwl_get_cmd_string(trans, cmd->id), ret); 2008 + return ret; 2009 + } 2010 + return 0; 2011 + } 2012 + 2013 + return iwl_trans_pcie_send_hcmd_sync(trans, cmd); 2014 + } 2015 + IWL_EXPORT_SYMBOL(iwl_trans_pcie_send_hcmd);
-1900
drivers/net/wireless/intel/iwlwifi/queue/tx.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 - /* 3 - * Copyright (C) 2020-2024 Intel Corporation 4 - */ 5 - #include <net/tso.h> 6 - #include <linux/tcp.h> 7 - 8 - #include "iwl-debug.h" 9 - #include "iwl-io.h" 10 - #include "fw/api/commands.h" 11 - #include "fw/api/tx.h" 12 - #include "fw/api/datapath.h" 13 - #include "fw/api/debug.h" 14 - #include "queue/tx.h" 15 - #include "iwl-fh.h" 16 - #include "iwl-scd.h" 17 - #include <linux/dmapool.h> 18 - 19 - /* 20 - * iwl_txq_update_byte_tbl - Set up entry in Tx byte-count array 21 - */ 22 - static void iwl_pcie_gen2_update_byte_tbl(struct iwl_trans *trans, 23 - struct iwl_txq *txq, u16 byte_cnt, 24 - int num_tbs) 25 - { 26 - int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 27 - u8 filled_tfd_size, num_fetch_chunks; 28 - u16 len = byte_cnt; 29 - __le16 bc_ent; 30 - 31 - if (WARN(idx >= txq->n_window, "%d >= %d\n", idx, txq->n_window)) 32 - return; 33 - 34 - filled_tfd_size = offsetof(struct iwl_tfh_tfd, tbs) + 35 - num_tbs * sizeof(struct iwl_tfh_tb); 36 - /* 37 - * filled_tfd_size contains the number of filled bytes in the TFD. 38 - * Dividing it by 64 will give the number of chunks to fetch 39 - * to SRAM- 0 for one chunk, 1 for 2 and so on. 40 - * If, for example, TFD contains only 3 TBs then 32 bytes 41 - * of the TFD are used, and only one chunk of 64 bytes should 42 - * be fetched 43 - */ 44 - num_fetch_chunks = DIV_ROUND_UP(filled_tfd_size, 64) - 1; 45 - 46 - if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { 47 - struct iwl_gen3_bc_tbl_entry *scd_bc_tbl_gen3 = txq->bc_tbl.addr; 48 - 49 - /* Starting from AX210, the HW expects bytes */ 50 - WARN_ON(trans->txqs.bc_table_dword); 51 - WARN_ON(len > 0x3FFF); 52 - bc_ent = cpu_to_le16(len | (num_fetch_chunks << 14)); 53 - scd_bc_tbl_gen3[idx].tfd_offset = bc_ent; 54 - } else { 55 - struct iwlagn_scd_bc_tbl *scd_bc_tbl = txq->bc_tbl.addr; 56 - 57 - /* Before AX210, the HW expects DW */ 58 - WARN_ON(!trans->txqs.bc_table_dword); 59 - len = DIV_ROUND_UP(len, 4); 60 - WARN_ON(len > 0xFFF); 61 - bc_ent = cpu_to_le16(len | (num_fetch_chunks << 12)); 62 - scd_bc_tbl->tfd_offset[idx] = bc_ent; 63 - } 64 - } 65 - 66 - /* 67 - * iwl_txq_inc_wr_ptr - Send new write index to hardware 68 - */ 69 - void iwl_txq_inc_wr_ptr(struct iwl_trans *trans, struct iwl_txq *txq) 70 - { 71 - lockdep_assert_held(&txq->lock); 72 - 73 - IWL_DEBUG_TX(trans, "Q:%d WR: 0x%x\n", txq->id, txq->write_ptr); 74 - 75 - /* 76 - * if not in power-save mode, uCode will never sleep when we're 77 - * trying to tx (during RFKILL, we're not trying to tx). 78 - */ 79 - iwl_write32(trans, HBUS_TARG_WRPTR, txq->write_ptr | (txq->id << 16)); 80 - } 81 - 82 - static u8 iwl_txq_gen2_get_num_tbs(struct iwl_trans *trans, 83 - struct iwl_tfh_tfd *tfd) 84 - { 85 - return le16_to_cpu(tfd->num_tbs) & 0x1f; 86 - } 87 - 88 - int iwl_txq_gen2_set_tb(struct iwl_trans *trans, struct iwl_tfh_tfd *tfd, 89 - dma_addr_t addr, u16 len) 90 - { 91 - int idx = iwl_txq_gen2_get_num_tbs(trans, tfd); 92 - struct iwl_tfh_tb *tb; 93 - 94 - /* Only WARN here so we know about the issue, but we mess up our 95 - * unmap path because not every place currently checks for errors 96 - * returned from this function - it can only return an error if 97 - * there's no more space, and so when we know there is enough we 98 - * don't always check ... 99 - */ 100 - WARN(iwl_txq_crosses_4g_boundary(addr, len), 101 - "possible DMA problem with iova:0x%llx, len:%d\n", 102 - (unsigned long long)addr, len); 103 - 104 - if (WARN_ON(idx >= IWL_TFH_NUM_TBS)) 105 - return -EINVAL; 106 - tb = &tfd->tbs[idx]; 107 - 108 - /* Each TFD can point to a maximum max_tbs Tx buffers */ 109 - if (le16_to_cpu(tfd->num_tbs) >= trans->txqs.tfd.max_tbs) { 110 - IWL_ERR(trans, "Error can not send more than %d chunks\n", 111 - trans->txqs.tfd.max_tbs); 112 - return -EINVAL; 113 - } 114 - 115 - put_unaligned_le64(addr, &tb->addr); 116 - tb->tb_len = cpu_to_le16(len); 117 - 118 - tfd->num_tbs = cpu_to_le16(idx + 1); 119 - 120 - return idx; 121 - } 122 - 123 - static void iwl_txq_set_tfd_invalid_gen2(struct iwl_trans *trans, 124 - struct iwl_tfh_tfd *tfd) 125 - { 126 - tfd->num_tbs = 0; 127 - 128 - iwl_txq_gen2_set_tb(trans, tfd, trans->invalid_tx_cmd.dma, 129 - trans->invalid_tx_cmd.size); 130 - } 131 - 132 - void iwl_txq_gen2_tfd_unmap(struct iwl_trans *trans, struct iwl_cmd_meta *meta, 133 - struct iwl_tfh_tfd *tfd) 134 - { 135 - int i, num_tbs; 136 - 137 - /* Sanity check on number of chunks */ 138 - num_tbs = iwl_txq_gen2_get_num_tbs(trans, tfd); 139 - 140 - if (num_tbs > trans->txqs.tfd.max_tbs) { 141 - IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); 142 - return; 143 - } 144 - 145 - /* first TB is never freed - it's the bidirectional DMA data */ 146 - for (i = 1; i < num_tbs; i++) { 147 - if (meta->tbs & BIT(i)) 148 - dma_unmap_page(trans->dev, 149 - le64_to_cpu(tfd->tbs[i].addr), 150 - le16_to_cpu(tfd->tbs[i].tb_len), 151 - DMA_TO_DEVICE); 152 - else 153 - dma_unmap_single(trans->dev, 154 - le64_to_cpu(tfd->tbs[i].addr), 155 - le16_to_cpu(tfd->tbs[i].tb_len), 156 - DMA_TO_DEVICE); 157 - } 158 - 159 - iwl_txq_set_tfd_invalid_gen2(trans, tfd); 160 - } 161 - 162 - void iwl_txq_gen2_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) 163 - { 164 - /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and 165 - * idx is bounded by n_window 166 - */ 167 - int idx = iwl_txq_get_cmd_index(txq, txq->read_ptr); 168 - struct sk_buff *skb; 169 - 170 - lockdep_assert_held(&txq->lock); 171 - 172 - if (!txq->entries) 173 - return; 174 - 175 - iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta, 176 - iwl_txq_get_tfd(trans, txq, idx)); 177 - 178 - skb = txq->entries[idx].skb; 179 - 180 - /* Can be called from irqs-disabled context 181 - * If skb is not NULL, it means that the whole queue is being 182 - * freed and that the queue is not empty - free the skb 183 - */ 184 - if (skb) { 185 - iwl_op_mode_free_skb(trans->op_mode, skb); 186 - txq->entries[idx].skb = NULL; 187 - } 188 - } 189 - 190 - static struct page *get_workaround_page(struct iwl_trans *trans, 191 - struct sk_buff *skb) 192 - { 193 - struct page **page_ptr; 194 - struct page *ret; 195 - 196 - page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); 197 - 198 - ret = alloc_page(GFP_ATOMIC); 199 - if (!ret) 200 - return NULL; 201 - 202 - /* set the chaining pointer to the previous page if there */ 203 - *(void **)((u8 *)page_address(ret) + PAGE_SIZE - sizeof(void *)) = *page_ptr; 204 - *page_ptr = ret; 205 - 206 - return ret; 207 - } 208 - 209 - /* 210 - * Add a TB and if needed apply the FH HW bug workaround; 211 - * meta != NULL indicates that it's a page mapping and we 212 - * need to dma_unmap_page() and set the meta->tbs bit in 213 - * this case. 214 - */ 215 - static int iwl_txq_gen2_set_tb_with_wa(struct iwl_trans *trans, 216 - struct sk_buff *skb, 217 - struct iwl_tfh_tfd *tfd, 218 - dma_addr_t phys, void *virt, 219 - u16 len, struct iwl_cmd_meta *meta) 220 - { 221 - dma_addr_t oldphys = phys; 222 - struct page *page; 223 - int ret; 224 - 225 - if (unlikely(dma_mapping_error(trans->dev, phys))) 226 - return -ENOMEM; 227 - 228 - if (likely(!iwl_txq_crosses_4g_boundary(phys, len))) { 229 - ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); 230 - 231 - if (ret < 0) 232 - goto unmap; 233 - 234 - if (meta) 235 - meta->tbs |= BIT(ret); 236 - 237 - ret = 0; 238 - goto trace; 239 - } 240 - 241 - /* 242 - * Work around a hardware bug. If (as expressed in the 243 - * condition above) the TB ends on a 32-bit boundary, 244 - * then the next TB may be accessed with the wrong 245 - * address. 246 - * To work around it, copy the data elsewhere and make 247 - * a new mapping for it so the device will not fail. 248 - */ 249 - 250 - if (WARN_ON(len > PAGE_SIZE - sizeof(void *))) { 251 - ret = -ENOBUFS; 252 - goto unmap; 253 - } 254 - 255 - page = get_workaround_page(trans, skb); 256 - if (!page) { 257 - ret = -ENOMEM; 258 - goto unmap; 259 - } 260 - 261 - memcpy(page_address(page), virt, len); 262 - 263 - phys = dma_map_single(trans->dev, page_address(page), len, 264 - DMA_TO_DEVICE); 265 - if (unlikely(dma_mapping_error(trans->dev, phys))) 266 - return -ENOMEM; 267 - ret = iwl_txq_gen2_set_tb(trans, tfd, phys, len); 268 - if (ret < 0) { 269 - /* unmap the new allocation as single */ 270 - oldphys = phys; 271 - meta = NULL; 272 - goto unmap; 273 - } 274 - IWL_DEBUG_TX(trans, 275 - "TB bug workaround: copied %d bytes from 0x%llx to 0x%llx\n", 276 - len, (unsigned long long)oldphys, 277 - (unsigned long long)phys); 278 - 279 - ret = 0; 280 - unmap: 281 - if (meta) 282 - dma_unmap_page(trans->dev, oldphys, len, DMA_TO_DEVICE); 283 - else 284 - dma_unmap_single(trans->dev, oldphys, len, DMA_TO_DEVICE); 285 - trace: 286 - trace_iwlwifi_dev_tx_tb(trans->dev, skb, virt, phys, len); 287 - 288 - return ret; 289 - } 290 - 291 - #ifdef CONFIG_INET 292 - struct iwl_tso_hdr_page *get_page_hdr(struct iwl_trans *trans, size_t len, 293 - struct sk_buff *skb) 294 - { 295 - struct iwl_tso_hdr_page *p = this_cpu_ptr(trans->txqs.tso_hdr_page); 296 - struct page **page_ptr; 297 - 298 - page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); 299 - 300 - if (WARN_ON(*page_ptr)) 301 - return NULL; 302 - 303 - if (!p->page) 304 - goto alloc; 305 - 306 - /* 307 - * Check if there's enough room on this page 308 - * 309 - * Note that we put a page chaining pointer *last* in the 310 - * page - we need it somewhere, and if it's there then we 311 - * avoid DMA mapping the last bits of the page which may 312 - * trigger the 32-bit boundary hardware bug. 313 - * 314 - * (see also get_workaround_page() in tx-gen2.c) 315 - */ 316 - if (p->pos + len < (u8 *)page_address(p->page) + PAGE_SIZE - 317 - sizeof(void *)) 318 - goto out; 319 - 320 - /* We don't have enough room on this page, get a new one. */ 321 - __free_page(p->page); 322 - 323 - alloc: 324 - p->page = alloc_page(GFP_ATOMIC); 325 - if (!p->page) 326 - return NULL; 327 - p->pos = page_address(p->page); 328 - /* set the chaining pointer to NULL */ 329 - *(void **)((u8 *)page_address(p->page) + PAGE_SIZE - sizeof(void *)) = NULL; 330 - out: 331 - *page_ptr = p->page; 332 - get_page(p->page); 333 - return p; 334 - } 335 - #endif 336 - 337 - static int iwl_txq_gen2_build_amsdu(struct iwl_trans *trans, 338 - struct sk_buff *skb, 339 - struct iwl_tfh_tfd *tfd, int start_len, 340 - u8 hdr_len, 341 - struct iwl_device_tx_cmd *dev_cmd) 342 - { 343 - #ifdef CONFIG_INET 344 - struct iwl_tx_cmd_gen2 *tx_cmd = (void *)dev_cmd->payload; 345 - struct ieee80211_hdr *hdr = (void *)skb->data; 346 - unsigned int snap_ip_tcp_hdrlen, ip_hdrlen, total_len, hdr_room; 347 - unsigned int mss = skb_shinfo(skb)->gso_size; 348 - u16 length, amsdu_pad; 349 - u8 *start_hdr; 350 - struct iwl_tso_hdr_page *hdr_page; 351 - struct tso_t tso; 352 - 353 - trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), 354 - &dev_cmd->hdr, start_len, 0); 355 - 356 - ip_hdrlen = skb_network_header_len(skb); 357 - snap_ip_tcp_hdrlen = 8 + ip_hdrlen + tcp_hdrlen(skb); 358 - total_len = skb->len - snap_ip_tcp_hdrlen - hdr_len; 359 - amsdu_pad = 0; 360 - 361 - /* total amount of header we may need for this A-MSDU */ 362 - hdr_room = DIV_ROUND_UP(total_len, mss) * 363 - (3 + snap_ip_tcp_hdrlen + sizeof(struct ethhdr)); 364 - 365 - /* Our device supports 9 segments at most, it will fit in 1 page */ 366 - hdr_page = get_page_hdr(trans, hdr_room, skb); 367 - if (!hdr_page) 368 - return -ENOMEM; 369 - 370 - start_hdr = hdr_page->pos; 371 - 372 - /* 373 - * Pull the ieee80211 header to be able to use TSO core, 374 - * we will restore it for the tx_status flow. 375 - */ 376 - skb_pull(skb, hdr_len); 377 - 378 - /* 379 - * Remove the length of all the headers that we don't actually 380 - * have in the MPDU by themselves, but that we duplicate into 381 - * all the different MSDUs inside the A-MSDU. 382 - */ 383 - le16_add_cpu(&tx_cmd->len, -snap_ip_tcp_hdrlen); 384 - 385 - tso_start(skb, &tso); 386 - 387 - while (total_len) { 388 - /* this is the data left for this subframe */ 389 - unsigned int data_left = min_t(unsigned int, mss, total_len); 390 - unsigned int tb_len; 391 - dma_addr_t tb_phys; 392 - u8 *subf_hdrs_start = hdr_page->pos; 393 - 394 - total_len -= data_left; 395 - 396 - memset(hdr_page->pos, 0, amsdu_pad); 397 - hdr_page->pos += amsdu_pad; 398 - amsdu_pad = (4 - (sizeof(struct ethhdr) + snap_ip_tcp_hdrlen + 399 - data_left)) & 0x3; 400 - ether_addr_copy(hdr_page->pos, ieee80211_get_DA(hdr)); 401 - hdr_page->pos += ETH_ALEN; 402 - ether_addr_copy(hdr_page->pos, ieee80211_get_SA(hdr)); 403 - hdr_page->pos += ETH_ALEN; 404 - 405 - length = snap_ip_tcp_hdrlen + data_left; 406 - *((__be16 *)hdr_page->pos) = cpu_to_be16(length); 407 - hdr_page->pos += sizeof(length); 408 - 409 - /* 410 - * This will copy the SNAP as well which will be considered 411 - * as MAC header. 412 - */ 413 - tso_build_hdr(skb, hdr_page->pos, &tso, data_left, !total_len); 414 - 415 - hdr_page->pos += snap_ip_tcp_hdrlen; 416 - 417 - tb_len = hdr_page->pos - start_hdr; 418 - tb_phys = dma_map_single(trans->dev, start_hdr, 419 - tb_len, DMA_TO_DEVICE); 420 - if (unlikely(dma_mapping_error(trans->dev, tb_phys))) 421 - goto out_err; 422 - /* 423 - * No need for _with_wa, this is from the TSO page and 424 - * we leave some space at the end of it so can't hit 425 - * the buggy scenario. 426 - */ 427 - iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb_len); 428 - trace_iwlwifi_dev_tx_tb(trans->dev, skb, start_hdr, 429 - tb_phys, tb_len); 430 - /* add this subframe's headers' length to the tx_cmd */ 431 - le16_add_cpu(&tx_cmd->len, hdr_page->pos - subf_hdrs_start); 432 - 433 - /* prepare the start_hdr for the next subframe */ 434 - start_hdr = hdr_page->pos; 435 - 436 - /* put the payload */ 437 - while (data_left) { 438 - int ret; 439 - 440 - tb_len = min_t(unsigned int, tso.size, data_left); 441 - tb_phys = dma_map_single(trans->dev, tso.data, 442 - tb_len, DMA_TO_DEVICE); 443 - ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, 444 - tb_phys, tso.data, 445 - tb_len, NULL); 446 - if (ret) 447 - goto out_err; 448 - 449 - data_left -= tb_len; 450 - tso_build_data(skb, &tso, tb_len); 451 - } 452 - } 453 - 454 - /* re -add the WiFi header */ 455 - skb_push(skb, hdr_len); 456 - 457 - return 0; 458 - 459 - out_err: 460 - #endif 461 - return -EINVAL; 462 - } 463 - 464 - static struct 465 - iwl_tfh_tfd *iwl_txq_gen2_build_tx_amsdu(struct iwl_trans *trans, 466 - struct iwl_txq *txq, 467 - struct iwl_device_tx_cmd *dev_cmd, 468 - struct sk_buff *skb, 469 - struct iwl_cmd_meta *out_meta, 470 - int hdr_len, 471 - int tx_cmd_len) 472 - { 473 - int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 474 - struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); 475 - dma_addr_t tb_phys; 476 - int len; 477 - void *tb1_addr; 478 - 479 - tb_phys = iwl_txq_get_first_tb_dma(txq, idx); 480 - 481 - /* 482 - * No need for _with_wa, the first TB allocation is aligned up 483 - * to a 64-byte boundary and thus can't be at the end or cross 484 - * a page boundary (much less a 2^32 boundary). 485 - */ 486 - iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); 487 - 488 - /* 489 - * The second TB (tb1) points to the remainder of the TX command 490 - * and the 802.11 header - dword aligned size 491 - * (This calculation modifies the TX command, so do it before the 492 - * setup of the first TB) 493 - */ 494 - len = tx_cmd_len + sizeof(struct iwl_cmd_header) + hdr_len - 495 - IWL_FIRST_TB_SIZE; 496 - 497 - /* do not align A-MSDU to dword as the subframe header aligns it */ 498 - 499 - /* map the data for TB1 */ 500 - tb1_addr = ((u8 *)&dev_cmd->hdr) + IWL_FIRST_TB_SIZE; 501 - tb_phys = dma_map_single(trans->dev, tb1_addr, len, DMA_TO_DEVICE); 502 - if (unlikely(dma_mapping_error(trans->dev, tb_phys))) 503 - goto out_err; 504 - /* 505 - * No need for _with_wa(), we ensure (via alignment) that the data 506 - * here can never cross or end at a page boundary. 507 - */ 508 - iwl_txq_gen2_set_tb(trans, tfd, tb_phys, len); 509 - 510 - if (iwl_txq_gen2_build_amsdu(trans, skb, tfd, len + IWL_FIRST_TB_SIZE, 511 - hdr_len, dev_cmd)) 512 - goto out_err; 513 - 514 - /* building the A-MSDU might have changed this data, memcpy it now */ 515 - memcpy(&txq->first_tb_bufs[idx], dev_cmd, IWL_FIRST_TB_SIZE); 516 - return tfd; 517 - 518 - out_err: 519 - iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); 520 - return NULL; 521 - } 522 - 523 - static int iwl_txq_gen2_tx_add_frags(struct iwl_trans *trans, 524 - struct sk_buff *skb, 525 - struct iwl_tfh_tfd *tfd, 526 - struct iwl_cmd_meta *out_meta) 527 - { 528 - int i; 529 - 530 - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 531 - const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 532 - dma_addr_t tb_phys; 533 - unsigned int fragsz = skb_frag_size(frag); 534 - int ret; 535 - 536 - if (!fragsz) 537 - continue; 538 - 539 - tb_phys = skb_frag_dma_map(trans->dev, frag, 0, 540 - fragsz, DMA_TO_DEVICE); 541 - ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, 542 - skb_frag_address(frag), 543 - fragsz, out_meta); 544 - if (ret) 545 - return ret; 546 - } 547 - 548 - return 0; 549 - } 550 - 551 - static struct 552 - iwl_tfh_tfd *iwl_txq_gen2_build_tx(struct iwl_trans *trans, 553 - struct iwl_txq *txq, 554 - struct iwl_device_tx_cmd *dev_cmd, 555 - struct sk_buff *skb, 556 - struct iwl_cmd_meta *out_meta, 557 - int hdr_len, 558 - int tx_cmd_len, 559 - bool pad) 560 - { 561 - int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 562 - struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); 563 - dma_addr_t tb_phys; 564 - int len, tb1_len, tb2_len; 565 - void *tb1_addr; 566 - struct sk_buff *frag; 567 - 568 - tb_phys = iwl_txq_get_first_tb_dma(txq, idx); 569 - 570 - /* The first TB points to bi-directional DMA data */ 571 - memcpy(&txq->first_tb_bufs[idx], dev_cmd, IWL_FIRST_TB_SIZE); 572 - 573 - /* 574 - * No need for _with_wa, the first TB allocation is aligned up 575 - * to a 64-byte boundary and thus can't be at the end or cross 576 - * a page boundary (much less a 2^32 boundary). 577 - */ 578 - iwl_txq_gen2_set_tb(trans, tfd, tb_phys, IWL_FIRST_TB_SIZE); 579 - 580 - /* 581 - * The second TB (tb1) points to the remainder of the TX command 582 - * and the 802.11 header - dword aligned size 583 - * (This calculation modifies the TX command, so do it before the 584 - * setup of the first TB) 585 - */ 586 - len = tx_cmd_len + sizeof(struct iwl_cmd_header) + hdr_len - 587 - IWL_FIRST_TB_SIZE; 588 - 589 - if (pad) 590 - tb1_len = ALIGN(len, 4); 591 - else 592 - tb1_len = len; 593 - 594 - /* map the data for TB1 */ 595 - tb1_addr = ((u8 *)&dev_cmd->hdr) + IWL_FIRST_TB_SIZE; 596 - tb_phys = dma_map_single(trans->dev, tb1_addr, tb1_len, DMA_TO_DEVICE); 597 - if (unlikely(dma_mapping_error(trans->dev, tb_phys))) 598 - goto out_err; 599 - /* 600 - * No need for _with_wa(), we ensure (via alignment) that the data 601 - * here can never cross or end at a page boundary. 602 - */ 603 - iwl_txq_gen2_set_tb(trans, tfd, tb_phys, tb1_len); 604 - trace_iwlwifi_dev_tx(trans->dev, skb, tfd, sizeof(*tfd), &dev_cmd->hdr, 605 - IWL_FIRST_TB_SIZE + tb1_len, hdr_len); 606 - 607 - /* set up TFD's third entry to point to remainder of skb's head */ 608 - tb2_len = skb_headlen(skb) - hdr_len; 609 - 610 - if (tb2_len > 0) { 611 - int ret; 612 - 613 - tb_phys = dma_map_single(trans->dev, skb->data + hdr_len, 614 - tb2_len, DMA_TO_DEVICE); 615 - ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, 616 - skb->data + hdr_len, tb2_len, 617 - NULL); 618 - if (ret) 619 - goto out_err; 620 - } 621 - 622 - if (iwl_txq_gen2_tx_add_frags(trans, skb, tfd, out_meta)) 623 - goto out_err; 624 - 625 - skb_walk_frags(skb, frag) { 626 - int ret; 627 - 628 - tb_phys = dma_map_single(trans->dev, frag->data, 629 - skb_headlen(frag), DMA_TO_DEVICE); 630 - ret = iwl_txq_gen2_set_tb_with_wa(trans, skb, tfd, tb_phys, 631 - frag->data, 632 - skb_headlen(frag), NULL); 633 - if (ret) 634 - goto out_err; 635 - if (iwl_txq_gen2_tx_add_frags(trans, frag, tfd, out_meta)) 636 - goto out_err; 637 - } 638 - 639 - return tfd; 640 - 641 - out_err: 642 - iwl_txq_gen2_tfd_unmap(trans, out_meta, tfd); 643 - return NULL; 644 - } 645 - 646 - static 647 - struct iwl_tfh_tfd *iwl_txq_gen2_build_tfd(struct iwl_trans *trans, 648 - struct iwl_txq *txq, 649 - struct iwl_device_tx_cmd *dev_cmd, 650 - struct sk_buff *skb, 651 - struct iwl_cmd_meta *out_meta) 652 - { 653 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 654 - int idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 655 - struct iwl_tfh_tfd *tfd = iwl_txq_get_tfd(trans, txq, idx); 656 - int len, hdr_len; 657 - bool amsdu; 658 - 659 - /* There must be data left over for TB1 or this code must be changed */ 660 - BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen2) < IWL_FIRST_TB_SIZE); 661 - BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + 662 - offsetofend(struct iwl_tx_cmd_gen2, dram_info) > 663 - IWL_FIRST_TB_SIZE); 664 - BUILD_BUG_ON(sizeof(struct iwl_tx_cmd_gen3) < IWL_FIRST_TB_SIZE); 665 - BUILD_BUG_ON(sizeof(struct iwl_cmd_header) + 666 - offsetofend(struct iwl_tx_cmd_gen3, dram_info) > 667 - IWL_FIRST_TB_SIZE); 668 - 669 - memset(tfd, 0, sizeof(*tfd)); 670 - 671 - if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210) 672 - len = sizeof(struct iwl_tx_cmd_gen2); 673 - else 674 - len = sizeof(struct iwl_tx_cmd_gen3); 675 - 676 - amsdu = ieee80211_is_data_qos(hdr->frame_control) && 677 - (*ieee80211_get_qos_ctl(hdr) & 678 - IEEE80211_QOS_CTL_A_MSDU_PRESENT); 679 - 680 - hdr_len = ieee80211_hdrlen(hdr->frame_control); 681 - 682 - /* 683 - * Only build A-MSDUs here if doing so by GSO, otherwise it may be 684 - * an A-MSDU for other reasons, e.g. NAN or an A-MSDU having been 685 - * built in the higher layers already. 686 - */ 687 - if (amsdu && skb_shinfo(skb)->gso_size) 688 - return iwl_txq_gen2_build_tx_amsdu(trans, txq, dev_cmd, skb, 689 - out_meta, hdr_len, len); 690 - return iwl_txq_gen2_build_tx(trans, txq, dev_cmd, skb, out_meta, 691 - hdr_len, len, !amsdu); 692 - } 693 - 694 - int iwl_txq_space(struct iwl_trans *trans, const struct iwl_txq *q) 695 - { 696 - unsigned int max; 697 - unsigned int used; 698 - 699 - /* 700 - * To avoid ambiguity between empty and completely full queues, there 701 - * should always be less than max_tfd_queue_size elements in the queue. 702 - * If q->n_window is smaller than max_tfd_queue_size, there is no need 703 - * to reserve any queue entries for this purpose. 704 - */ 705 - if (q->n_window < trans->trans_cfg->base_params->max_tfd_queue_size) 706 - max = q->n_window; 707 - else 708 - max = trans->trans_cfg->base_params->max_tfd_queue_size - 1; 709 - 710 - /* 711 - * max_tfd_queue_size is a power of 2, so the following is equivalent to 712 - * modulo by max_tfd_queue_size and is well defined. 713 - */ 714 - used = (q->write_ptr - q->read_ptr) & 715 - (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 716 - 717 - if (WARN_ON(used > max)) 718 - return 0; 719 - 720 - return max - used; 721 - } 722 - 723 - int iwl_txq_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb, 724 - struct iwl_device_tx_cmd *dev_cmd, int txq_id) 725 - { 726 - struct iwl_cmd_meta *out_meta; 727 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 728 - u16 cmd_len; 729 - int idx; 730 - void *tfd; 731 - 732 - if (WARN_ONCE(txq_id >= IWL_MAX_TVQM_QUEUES, 733 - "queue %d out of range", txq_id)) 734 - return -EINVAL; 735 - 736 - if (WARN_ONCE(!test_bit(txq_id, trans->txqs.queue_used), 737 - "TX on unused queue %d\n", txq_id)) 738 - return -EINVAL; 739 - 740 - if (skb_is_nonlinear(skb) && 741 - skb_shinfo(skb)->nr_frags > IWL_TRANS_MAX_FRAGS(trans) && 742 - __skb_linearize(skb)) 743 - return -ENOMEM; 744 - 745 - spin_lock(&txq->lock); 746 - 747 - if (iwl_txq_space(trans, txq) < txq->high_mark) { 748 - iwl_txq_stop(trans, txq); 749 - 750 - /* don't put the packet on the ring, if there is no room */ 751 - if (unlikely(iwl_txq_space(trans, txq) < 3)) { 752 - struct iwl_device_tx_cmd **dev_cmd_ptr; 753 - 754 - dev_cmd_ptr = (void *)((u8 *)skb->cb + 755 - trans->txqs.dev_cmd_offs); 756 - 757 - *dev_cmd_ptr = dev_cmd; 758 - __skb_queue_tail(&txq->overflow_q, skb); 759 - spin_unlock(&txq->lock); 760 - return 0; 761 - } 762 - } 763 - 764 - idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); 765 - 766 - /* Set up driver data for this TFD */ 767 - txq->entries[idx].skb = skb; 768 - txq->entries[idx].cmd = dev_cmd; 769 - 770 - dev_cmd->hdr.sequence = 771 - cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | 772 - INDEX_TO_SEQ(idx))); 773 - 774 - /* Set up first empty entry in queue's array of Tx/cmd buffers */ 775 - out_meta = &txq->entries[idx].meta; 776 - out_meta->flags = 0; 777 - 778 - tfd = iwl_txq_gen2_build_tfd(trans, txq, dev_cmd, skb, out_meta); 779 - if (!tfd) { 780 - spin_unlock(&txq->lock); 781 - return -1; 782 - } 783 - 784 - if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { 785 - struct iwl_tx_cmd_gen3 *tx_cmd_gen3 = 786 - (void *)dev_cmd->payload; 787 - 788 - cmd_len = le16_to_cpu(tx_cmd_gen3->len); 789 - } else { 790 - struct iwl_tx_cmd_gen2 *tx_cmd_gen2 = 791 - (void *)dev_cmd->payload; 792 - 793 - cmd_len = le16_to_cpu(tx_cmd_gen2->len); 794 - } 795 - 796 - /* Set up entry for this TFD in Tx byte-count array */ 797 - iwl_pcie_gen2_update_byte_tbl(trans, txq, cmd_len, 798 - iwl_txq_gen2_get_num_tbs(trans, tfd)); 799 - 800 - /* start timer if queue currently empty */ 801 - if (txq->read_ptr == txq->write_ptr && txq->wd_timeout) 802 - mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); 803 - 804 - /* Tell device the write index *just past* this latest filled TFD */ 805 - txq->write_ptr = iwl_txq_inc_wrap(trans, txq->write_ptr); 806 - iwl_txq_inc_wr_ptr(trans, txq); 807 - /* 808 - * At this point the frame is "transmitted" successfully 809 - * and we will get a TX status notification eventually. 810 - */ 811 - spin_unlock(&txq->lock); 812 - return 0; 813 - } 814 - 815 - /*************** HOST COMMAND QUEUE FUNCTIONS *****/ 816 - 817 - /* 818 - * iwl_txq_gen2_unmap - Unmap any remaining DMA mappings and free skb's 819 - */ 820 - void iwl_txq_gen2_unmap(struct iwl_trans *trans, int txq_id) 821 - { 822 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 823 - 824 - spin_lock_bh(&txq->lock); 825 - while (txq->write_ptr != txq->read_ptr) { 826 - IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n", 827 - txq_id, txq->read_ptr); 828 - 829 - if (txq_id != trans->txqs.cmd.q_id) { 830 - int idx = iwl_txq_get_cmd_index(txq, txq->read_ptr); 831 - struct sk_buff *skb = txq->entries[idx].skb; 832 - 833 - if (!WARN_ON_ONCE(!skb)) 834 - iwl_txq_free_tso_page(trans, skb); 835 - } 836 - iwl_txq_gen2_free_tfd(trans, txq); 837 - txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr); 838 - } 839 - 840 - while (!skb_queue_empty(&txq->overflow_q)) { 841 - struct sk_buff *skb = __skb_dequeue(&txq->overflow_q); 842 - 843 - iwl_op_mode_free_skb(trans->op_mode, skb); 844 - } 845 - 846 - spin_unlock_bh(&txq->lock); 847 - 848 - /* just in case - this queue may have been stopped */ 849 - iwl_wake_queue(trans, txq); 850 - } 851 - 852 - static void iwl_txq_gen2_free_memory(struct iwl_trans *trans, 853 - struct iwl_txq *txq) 854 - { 855 - struct device *dev = trans->dev; 856 - 857 - /* De-alloc circular buffer of TFDs */ 858 - if (txq->tfds) { 859 - dma_free_coherent(dev, 860 - trans->txqs.tfd.size * txq->n_window, 861 - txq->tfds, txq->dma_addr); 862 - dma_free_coherent(dev, 863 - sizeof(*txq->first_tb_bufs) * txq->n_window, 864 - txq->first_tb_bufs, txq->first_tb_dma); 865 - } 866 - 867 - kfree(txq->entries); 868 - if (txq->bc_tbl.addr) 869 - dma_pool_free(trans->txqs.bc_pool, 870 - txq->bc_tbl.addr, txq->bc_tbl.dma); 871 - kfree(txq); 872 - } 873 - 874 - /* 875 - * iwl_pcie_txq_free - Deallocate DMA queue. 876 - * @txq: Transmit queue to deallocate. 877 - * 878 - * Empty queue by removing and destroying all BD's. 879 - * Free all buffers. 880 - * 0-fill, but do not free "txq" descriptor structure. 881 - */ 882 - static void iwl_txq_gen2_free(struct iwl_trans *trans, int txq_id) 883 - { 884 - struct iwl_txq *txq; 885 - int i; 886 - 887 - if (WARN_ONCE(txq_id >= IWL_MAX_TVQM_QUEUES, 888 - "queue %d out of range", txq_id)) 889 - return; 890 - 891 - txq = trans->txqs.txq[txq_id]; 892 - 893 - if (WARN_ON(!txq)) 894 - return; 895 - 896 - iwl_txq_gen2_unmap(trans, txq_id); 897 - 898 - /* De-alloc array of command/tx buffers */ 899 - if (txq_id == trans->txqs.cmd.q_id) 900 - for (i = 0; i < txq->n_window; i++) { 901 - kfree_sensitive(txq->entries[i].cmd); 902 - kfree_sensitive(txq->entries[i].free_buf); 903 - } 904 - del_timer_sync(&txq->stuck_timer); 905 - 906 - iwl_txq_gen2_free_memory(trans, txq); 907 - 908 - trans->txqs.txq[txq_id] = NULL; 909 - 910 - clear_bit(txq_id, trans->txqs.queue_used); 911 - } 912 - 913 - /* 914 - * iwl_queue_init - Initialize queue's high/low-water and read/write indexes 915 - */ 916 - static int iwl_queue_init(struct iwl_txq *q, int slots_num) 917 - { 918 - q->n_window = slots_num; 919 - 920 - /* slots_num must be power-of-two size, otherwise 921 - * iwl_txq_get_cmd_index is broken. */ 922 - if (WARN_ON(!is_power_of_2(slots_num))) 923 - return -EINVAL; 924 - 925 - q->low_mark = q->n_window / 4; 926 - if (q->low_mark < 4) 927 - q->low_mark = 4; 928 - 929 - q->high_mark = q->n_window / 8; 930 - if (q->high_mark < 2) 931 - q->high_mark = 2; 932 - 933 - q->write_ptr = 0; 934 - q->read_ptr = 0; 935 - 936 - return 0; 937 - } 938 - 939 - int iwl_txq_init(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, 940 - bool cmd_queue) 941 - { 942 - int ret; 943 - u32 tfd_queue_max_size = 944 - trans->trans_cfg->base_params->max_tfd_queue_size; 945 - 946 - txq->need_update = false; 947 - 948 - /* max_tfd_queue_size must be power-of-two size, otherwise 949 - * iwl_txq_inc_wrap and iwl_txq_dec_wrap are broken. */ 950 - if (WARN_ONCE(tfd_queue_max_size & (tfd_queue_max_size - 1), 951 - "Max tfd queue size must be a power of two, but is %d", 952 - tfd_queue_max_size)) 953 - return -EINVAL; 954 - 955 - /* Initialize queue's high/low-water marks, and head/tail indexes */ 956 - ret = iwl_queue_init(txq, slots_num); 957 - if (ret) 958 - return ret; 959 - 960 - spin_lock_init(&txq->lock); 961 - 962 - if (cmd_queue) { 963 - static struct lock_class_key iwl_txq_cmd_queue_lock_class; 964 - 965 - lockdep_set_class(&txq->lock, &iwl_txq_cmd_queue_lock_class); 966 - } 967 - 968 - __skb_queue_head_init(&txq->overflow_q); 969 - 970 - return 0; 971 - } 972 - 973 - void iwl_txq_free_tso_page(struct iwl_trans *trans, struct sk_buff *skb) 974 - { 975 - struct page **page_ptr; 976 - struct page *next; 977 - 978 - page_ptr = (void *)((u8 *)skb->cb + trans->txqs.page_offs); 979 - next = *page_ptr; 980 - *page_ptr = NULL; 981 - 982 - while (next) { 983 - struct page *tmp = next; 984 - 985 - next = *(void **)((u8 *)page_address(next) + PAGE_SIZE - 986 - sizeof(void *)); 987 - __free_page(tmp); 988 - } 989 - } 990 - 991 - void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq) 992 - { 993 - u32 txq_id = txq->id; 994 - u32 status; 995 - bool active; 996 - u8 fifo; 997 - 998 - if (trans->trans_cfg->gen2) { 999 - IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id, 1000 - txq->read_ptr, txq->write_ptr); 1001 - /* TODO: access new SCD registers and dump them */ 1002 - return; 1003 - } 1004 - 1005 - status = iwl_read_prph(trans, SCD_QUEUE_STATUS_BITS(txq_id)); 1006 - fifo = (status >> SCD_QUEUE_STTS_REG_POS_TXF) & 0x7; 1007 - active = !!(status & BIT(SCD_QUEUE_STTS_REG_POS_ACTIVE)); 1008 - 1009 - IWL_ERR(trans, 1010 - "Queue %d is %sactive on fifo %d and stuck for %u ms. SW [%d, %d] HW [%d, %d] FH TRB=0x0%x\n", 1011 - txq_id, active ? "" : "in", fifo, 1012 - jiffies_to_msecs(txq->wd_timeout), 1013 - txq->read_ptr, txq->write_ptr, 1014 - iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & 1015 - (trans->trans_cfg->base_params->max_tfd_queue_size - 1), 1016 - iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id)) & 1017 - (trans->trans_cfg->base_params->max_tfd_queue_size - 1), 1018 - iwl_read_direct32(trans, FH_TX_TRB_REG(fifo))); 1019 - } 1020 - 1021 - static void iwl_txq_stuck_timer(struct timer_list *t) 1022 - { 1023 - struct iwl_txq *txq = from_timer(txq, t, stuck_timer); 1024 - struct iwl_trans *trans = txq->trans; 1025 - 1026 - spin_lock(&txq->lock); 1027 - /* check if triggered erroneously */ 1028 - if (txq->read_ptr == txq->write_ptr) { 1029 - spin_unlock(&txq->lock); 1030 - return; 1031 - } 1032 - spin_unlock(&txq->lock); 1033 - 1034 - iwl_txq_log_scd_error(trans, txq); 1035 - 1036 - iwl_force_nmi(trans); 1037 - } 1038 - 1039 - static void iwl_txq_set_tfd_invalid_gen1(struct iwl_trans *trans, 1040 - struct iwl_tfd *tfd) 1041 - { 1042 - tfd->num_tbs = 0; 1043 - 1044 - iwl_pcie_gen1_tfd_set_tb(trans, tfd, 0, trans->invalid_tx_cmd.dma, 1045 - trans->invalid_tx_cmd.size); 1046 - } 1047 - 1048 - int iwl_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, 1049 - bool cmd_queue) 1050 - { 1051 - size_t num_entries = trans->trans_cfg->gen2 ? 1052 - slots_num : trans->trans_cfg->base_params->max_tfd_queue_size; 1053 - size_t tfd_sz; 1054 - size_t tb0_buf_sz; 1055 - int i; 1056 - 1057 - if (WARN_ONCE(slots_num <= 0, "Invalid slots num:%d\n", slots_num)) 1058 - return -EINVAL; 1059 - 1060 - if (WARN_ON(txq->entries || txq->tfds)) 1061 - return -EINVAL; 1062 - 1063 - tfd_sz = trans->txqs.tfd.size * num_entries; 1064 - 1065 - timer_setup(&txq->stuck_timer, iwl_txq_stuck_timer, 0); 1066 - txq->trans = trans; 1067 - 1068 - txq->n_window = slots_num; 1069 - 1070 - txq->entries = kcalloc(slots_num, 1071 - sizeof(struct iwl_pcie_txq_entry), 1072 - GFP_KERNEL); 1073 - 1074 - if (!txq->entries) 1075 - goto error; 1076 - 1077 - if (cmd_queue) 1078 - for (i = 0; i < slots_num; i++) { 1079 - txq->entries[i].cmd = 1080 - kmalloc(sizeof(struct iwl_device_cmd), 1081 - GFP_KERNEL); 1082 - if (!txq->entries[i].cmd) 1083 - goto error; 1084 - } 1085 - 1086 - /* Circular buffer of transmit frame descriptors (TFDs), 1087 - * shared with device */ 1088 - txq->tfds = dma_alloc_coherent(trans->dev, tfd_sz, 1089 - &txq->dma_addr, GFP_KERNEL); 1090 - if (!txq->tfds) 1091 - goto error; 1092 - 1093 - BUILD_BUG_ON(sizeof(*txq->first_tb_bufs) != IWL_FIRST_TB_SIZE_ALIGN); 1094 - 1095 - tb0_buf_sz = sizeof(*txq->first_tb_bufs) * slots_num; 1096 - 1097 - txq->first_tb_bufs = dma_alloc_coherent(trans->dev, tb0_buf_sz, 1098 - &txq->first_tb_dma, 1099 - GFP_KERNEL); 1100 - if (!txq->first_tb_bufs) 1101 - goto err_free_tfds; 1102 - 1103 - for (i = 0; i < num_entries; i++) { 1104 - void *tfd = iwl_txq_get_tfd(trans, txq, i); 1105 - 1106 - if (trans->trans_cfg->gen2) 1107 - iwl_txq_set_tfd_invalid_gen2(trans, tfd); 1108 - else 1109 - iwl_txq_set_tfd_invalid_gen1(trans, tfd); 1110 - } 1111 - 1112 - return 0; 1113 - err_free_tfds: 1114 - dma_free_coherent(trans->dev, tfd_sz, txq->tfds, txq->dma_addr); 1115 - txq->tfds = NULL; 1116 - error: 1117 - if (txq->entries && cmd_queue) 1118 - for (i = 0; i < slots_num; i++) 1119 - kfree(txq->entries[i].cmd); 1120 - kfree(txq->entries); 1121 - txq->entries = NULL; 1122 - 1123 - return -ENOMEM; 1124 - } 1125 - 1126 - static struct iwl_txq * 1127 - iwl_txq_dyn_alloc_dma(struct iwl_trans *trans, int size, unsigned int timeout) 1128 - { 1129 - size_t bc_tbl_size, bc_tbl_entries; 1130 - struct iwl_txq *txq; 1131 - int ret; 1132 - 1133 - WARN_ON(!trans->txqs.bc_tbl_size); 1134 - 1135 - bc_tbl_size = trans->txqs.bc_tbl_size; 1136 - bc_tbl_entries = bc_tbl_size / sizeof(u16); 1137 - 1138 - if (WARN_ON(size > bc_tbl_entries)) 1139 - return ERR_PTR(-EINVAL); 1140 - 1141 - txq = kzalloc(sizeof(*txq), GFP_KERNEL); 1142 - if (!txq) 1143 - return ERR_PTR(-ENOMEM); 1144 - 1145 - txq->bc_tbl.addr = dma_pool_alloc(trans->txqs.bc_pool, GFP_KERNEL, 1146 - &txq->bc_tbl.dma); 1147 - if (!txq->bc_tbl.addr) { 1148 - IWL_ERR(trans, "Scheduler BC Table allocation failed\n"); 1149 - kfree(txq); 1150 - return ERR_PTR(-ENOMEM); 1151 - } 1152 - 1153 - ret = iwl_txq_alloc(trans, txq, size, false); 1154 - if (ret) { 1155 - IWL_ERR(trans, "Tx queue alloc failed\n"); 1156 - goto error; 1157 - } 1158 - ret = iwl_txq_init(trans, txq, size, false); 1159 - if (ret) { 1160 - IWL_ERR(trans, "Tx queue init failed\n"); 1161 - goto error; 1162 - } 1163 - 1164 - txq->wd_timeout = msecs_to_jiffies(timeout); 1165 - 1166 - return txq; 1167 - 1168 - error: 1169 - iwl_txq_gen2_free_memory(trans, txq); 1170 - return ERR_PTR(ret); 1171 - } 1172 - 1173 - static int iwl_txq_alloc_response(struct iwl_trans *trans, struct iwl_txq *txq, 1174 - struct iwl_host_cmd *hcmd) 1175 - { 1176 - struct iwl_tx_queue_cfg_rsp *rsp; 1177 - int ret, qid; 1178 - u32 wr_ptr; 1179 - 1180 - if (WARN_ON(iwl_rx_packet_payload_len(hcmd->resp_pkt) != 1181 - sizeof(*rsp))) { 1182 - ret = -EINVAL; 1183 - goto error_free_resp; 1184 - } 1185 - 1186 - rsp = (void *)hcmd->resp_pkt->data; 1187 - qid = le16_to_cpu(rsp->queue_number); 1188 - wr_ptr = le16_to_cpu(rsp->write_pointer); 1189 - 1190 - if (qid >= ARRAY_SIZE(trans->txqs.txq)) { 1191 - WARN_ONCE(1, "queue index %d unsupported", qid); 1192 - ret = -EIO; 1193 - goto error_free_resp; 1194 - } 1195 - 1196 - if (test_and_set_bit(qid, trans->txqs.queue_used)) { 1197 - WARN_ONCE(1, "queue %d already used", qid); 1198 - ret = -EIO; 1199 - goto error_free_resp; 1200 - } 1201 - 1202 - if (WARN_ONCE(trans->txqs.txq[qid], 1203 - "queue %d already allocated\n", qid)) { 1204 - ret = -EIO; 1205 - goto error_free_resp; 1206 - } 1207 - 1208 - txq->id = qid; 1209 - trans->txqs.txq[qid] = txq; 1210 - wr_ptr &= (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 1211 - 1212 - /* Place first TFD at index corresponding to start sequence number */ 1213 - txq->read_ptr = wr_ptr; 1214 - txq->write_ptr = wr_ptr; 1215 - 1216 - IWL_DEBUG_TX_QUEUES(trans, "Activate queue %d\n", qid); 1217 - 1218 - iwl_free_resp(hcmd); 1219 - return qid; 1220 - 1221 - error_free_resp: 1222 - iwl_free_resp(hcmd); 1223 - iwl_txq_gen2_free_memory(trans, txq); 1224 - return ret; 1225 - } 1226 - 1227 - int iwl_txq_dyn_alloc(struct iwl_trans *trans, u32 flags, u32 sta_mask, 1228 - u8 tid, int size, unsigned int timeout) 1229 - { 1230 - struct iwl_txq *txq; 1231 - union { 1232 - struct iwl_tx_queue_cfg_cmd old; 1233 - struct iwl_scd_queue_cfg_cmd new; 1234 - } cmd; 1235 - struct iwl_host_cmd hcmd = { 1236 - .flags = CMD_WANT_SKB, 1237 - }; 1238 - int ret; 1239 - 1240 - if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_BZ && 1241 - trans->hw_rev_step == SILICON_A_STEP) 1242 - size = 4096; 1243 - 1244 - txq = iwl_txq_dyn_alloc_dma(trans, size, timeout); 1245 - if (IS_ERR(txq)) 1246 - return PTR_ERR(txq); 1247 - 1248 - if (trans->txqs.queue_alloc_cmd_ver == 0) { 1249 - memset(&cmd.old, 0, sizeof(cmd.old)); 1250 - cmd.old.tfdq_addr = cpu_to_le64(txq->dma_addr); 1251 - cmd.old.byte_cnt_addr = cpu_to_le64(txq->bc_tbl.dma); 1252 - cmd.old.cb_size = cpu_to_le32(TFD_QUEUE_CB_SIZE(size)); 1253 - cmd.old.flags = cpu_to_le16(flags | TX_QUEUE_CFG_ENABLE_QUEUE); 1254 - cmd.old.tid = tid; 1255 - 1256 - if (hweight32(sta_mask) != 1) { 1257 - ret = -EINVAL; 1258 - goto error; 1259 - } 1260 - cmd.old.sta_id = ffs(sta_mask) - 1; 1261 - 1262 - hcmd.id = SCD_QUEUE_CFG; 1263 - hcmd.len[0] = sizeof(cmd.old); 1264 - hcmd.data[0] = &cmd.old; 1265 - } else if (trans->txqs.queue_alloc_cmd_ver == 3) { 1266 - memset(&cmd.new, 0, sizeof(cmd.new)); 1267 - cmd.new.operation = cpu_to_le32(IWL_SCD_QUEUE_ADD); 1268 - cmd.new.u.add.tfdq_dram_addr = cpu_to_le64(txq->dma_addr); 1269 - cmd.new.u.add.bc_dram_addr = cpu_to_le64(txq->bc_tbl.dma); 1270 - cmd.new.u.add.cb_size = cpu_to_le32(TFD_QUEUE_CB_SIZE(size)); 1271 - cmd.new.u.add.flags = cpu_to_le32(flags); 1272 - cmd.new.u.add.sta_mask = cpu_to_le32(sta_mask); 1273 - cmd.new.u.add.tid = tid; 1274 - 1275 - hcmd.id = WIDE_ID(DATA_PATH_GROUP, SCD_QUEUE_CONFIG_CMD); 1276 - hcmd.len[0] = sizeof(cmd.new); 1277 - hcmd.data[0] = &cmd.new; 1278 - } else { 1279 - ret = -EOPNOTSUPP; 1280 - goto error; 1281 - } 1282 - 1283 - ret = iwl_trans_send_cmd(trans, &hcmd); 1284 - if (ret) 1285 - goto error; 1286 - 1287 - return iwl_txq_alloc_response(trans, txq, &hcmd); 1288 - 1289 - error: 1290 - iwl_txq_gen2_free_memory(trans, txq); 1291 - return ret; 1292 - } 1293 - 1294 - void iwl_txq_dyn_free(struct iwl_trans *trans, int queue) 1295 - { 1296 - if (WARN(queue >= IWL_MAX_TVQM_QUEUES, 1297 - "queue %d out of range", queue)) 1298 - return; 1299 - 1300 - /* 1301 - * Upon HW Rfkill - we stop the device, and then stop the queues 1302 - * in the op_mode. Just for the sake of the simplicity of the op_mode, 1303 - * allow the op_mode to call txq_disable after it already called 1304 - * stop_device. 1305 - */ 1306 - if (!test_and_clear_bit(queue, trans->txqs.queue_used)) { 1307 - WARN_ONCE(test_bit(STATUS_DEVICE_ENABLED, &trans->status), 1308 - "queue %d not used", queue); 1309 - return; 1310 - } 1311 - 1312 - iwl_txq_gen2_free(trans, queue); 1313 - 1314 - IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", queue); 1315 - } 1316 - 1317 - void iwl_txq_gen2_tx_free(struct iwl_trans *trans) 1318 - { 1319 - int i; 1320 - 1321 - memset(trans->txqs.queue_used, 0, sizeof(trans->txqs.queue_used)); 1322 - 1323 - /* Free all TX queues */ 1324 - for (i = 0; i < ARRAY_SIZE(trans->txqs.txq); i++) { 1325 - if (!trans->txqs.txq[i]) 1326 - continue; 1327 - 1328 - iwl_txq_gen2_free(trans, i); 1329 - } 1330 - } 1331 - 1332 - int iwl_txq_gen2_init(struct iwl_trans *trans, int txq_id, int queue_size) 1333 - { 1334 - struct iwl_txq *queue; 1335 - int ret; 1336 - 1337 - /* alloc and init the tx queue */ 1338 - if (!trans->txqs.txq[txq_id]) { 1339 - queue = kzalloc(sizeof(*queue), GFP_KERNEL); 1340 - if (!queue) { 1341 - IWL_ERR(trans, "Not enough memory for tx queue\n"); 1342 - return -ENOMEM; 1343 - } 1344 - trans->txqs.txq[txq_id] = queue; 1345 - ret = iwl_txq_alloc(trans, queue, queue_size, true); 1346 - if (ret) { 1347 - IWL_ERR(trans, "Tx %d queue init failed\n", txq_id); 1348 - goto error; 1349 - } 1350 - } else { 1351 - queue = trans->txqs.txq[txq_id]; 1352 - } 1353 - 1354 - ret = iwl_txq_init(trans, queue, queue_size, 1355 - (txq_id == trans->txqs.cmd.q_id)); 1356 - if (ret) { 1357 - IWL_ERR(trans, "Tx %d queue alloc failed\n", txq_id); 1358 - goto error; 1359 - } 1360 - trans->txqs.txq[txq_id]->id = txq_id; 1361 - set_bit(txq_id, trans->txqs.queue_used); 1362 - 1363 - return 0; 1364 - 1365 - error: 1366 - iwl_txq_gen2_tx_free(trans); 1367 - return ret; 1368 - } 1369 - 1370 - static inline dma_addr_t iwl_txq_gen1_tfd_tb_get_addr(struct iwl_trans *trans, 1371 - struct iwl_tfd *tfd, u8 idx) 1372 - { 1373 - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 1374 - dma_addr_t addr; 1375 - dma_addr_t hi_len; 1376 - 1377 - addr = get_unaligned_le32(&tb->lo); 1378 - 1379 - if (sizeof(dma_addr_t) <= sizeof(u32)) 1380 - return addr; 1381 - 1382 - hi_len = le16_to_cpu(tb->hi_n_len) & 0xF; 1383 - 1384 - /* 1385 - * shift by 16 twice to avoid warnings on 32-bit 1386 - * (where this code never runs anyway due to the 1387 - * if statement above) 1388 - */ 1389 - return addr | ((hi_len << 16) << 16); 1390 - } 1391 - 1392 - void iwl_txq_gen1_tfd_unmap(struct iwl_trans *trans, 1393 - struct iwl_cmd_meta *meta, 1394 - struct iwl_txq *txq, int index) 1395 - { 1396 - int i, num_tbs; 1397 - struct iwl_tfd *tfd = iwl_txq_get_tfd(trans, txq, index); 1398 - 1399 - /* Sanity check on number of chunks */ 1400 - num_tbs = iwl_txq_gen1_tfd_get_num_tbs(trans, tfd); 1401 - 1402 - if (num_tbs > trans->txqs.tfd.max_tbs) { 1403 - IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); 1404 - /* @todo issue fatal error, it is quite serious situation */ 1405 - return; 1406 - } 1407 - 1408 - /* first TB is never freed - it's the bidirectional DMA data */ 1409 - 1410 - for (i = 1; i < num_tbs; i++) { 1411 - if (meta->tbs & BIT(i)) 1412 - dma_unmap_page(trans->dev, 1413 - iwl_txq_gen1_tfd_tb_get_addr(trans, 1414 - tfd, i), 1415 - iwl_txq_gen1_tfd_tb_get_len(trans, 1416 - tfd, i), 1417 - DMA_TO_DEVICE); 1418 - else 1419 - dma_unmap_single(trans->dev, 1420 - iwl_txq_gen1_tfd_tb_get_addr(trans, 1421 - tfd, i), 1422 - iwl_txq_gen1_tfd_tb_get_len(trans, 1423 - tfd, i), 1424 - DMA_TO_DEVICE); 1425 - } 1426 - 1427 - meta->tbs = 0; 1428 - 1429 - iwl_txq_set_tfd_invalid_gen1(trans, tfd); 1430 - } 1431 - 1432 - #define IWL_TX_CRC_SIZE 4 1433 - #define IWL_TX_DELIMITER_SIZE 4 1434 - 1435 - /* 1436 - * iwl_txq_gen1_update_byte_cnt_tbl - Set up entry in Tx byte-count array 1437 - */ 1438 - void iwl_txq_gen1_update_byte_cnt_tbl(struct iwl_trans *trans, 1439 - struct iwl_txq *txq, u16 byte_cnt, 1440 - int num_tbs) 1441 - { 1442 - struct iwlagn_scd_bc_tbl *scd_bc_tbl; 1443 - int write_ptr = txq->write_ptr; 1444 - int txq_id = txq->id; 1445 - u8 sec_ctl = 0; 1446 - u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; 1447 - __le16 bc_ent; 1448 - struct iwl_device_tx_cmd *dev_cmd = txq->entries[txq->write_ptr].cmd; 1449 - struct iwl_tx_cmd *tx_cmd = (void *)dev_cmd->payload; 1450 - u8 sta_id = tx_cmd->sta_id; 1451 - 1452 - scd_bc_tbl = trans->txqs.scd_bc_tbls.addr; 1453 - 1454 - sec_ctl = tx_cmd->sec_ctl; 1455 - 1456 - switch (sec_ctl & TX_CMD_SEC_MSK) { 1457 - case TX_CMD_SEC_CCM: 1458 - len += IEEE80211_CCMP_MIC_LEN; 1459 - break; 1460 - case TX_CMD_SEC_TKIP: 1461 - len += IEEE80211_TKIP_ICV_LEN; 1462 - break; 1463 - case TX_CMD_SEC_WEP: 1464 - len += IEEE80211_WEP_IV_LEN + IEEE80211_WEP_ICV_LEN; 1465 - break; 1466 - } 1467 - if (trans->txqs.bc_table_dword) 1468 - len = DIV_ROUND_UP(len, 4); 1469 - 1470 - if (WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX)) 1471 - return; 1472 - 1473 - bc_ent = cpu_to_le16(len | (sta_id << 12)); 1474 - 1475 - scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent; 1476 - 1477 - if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) 1478 - scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = 1479 - bc_ent; 1480 - } 1481 - 1482 - void iwl_txq_gen1_inval_byte_cnt_tbl(struct iwl_trans *trans, 1483 - struct iwl_txq *txq) 1484 - { 1485 - struct iwlagn_scd_bc_tbl *scd_bc_tbl = trans->txqs.scd_bc_tbls.addr; 1486 - int txq_id = txq->id; 1487 - int read_ptr = txq->read_ptr; 1488 - u8 sta_id = 0; 1489 - __le16 bc_ent; 1490 - struct iwl_device_tx_cmd *dev_cmd = txq->entries[read_ptr].cmd; 1491 - struct iwl_tx_cmd *tx_cmd = (void *)dev_cmd->payload; 1492 - 1493 - WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX); 1494 - 1495 - if (txq_id != trans->txqs.cmd.q_id) 1496 - sta_id = tx_cmd->sta_id; 1497 - 1498 - bc_ent = cpu_to_le16(1 | (sta_id << 12)); 1499 - 1500 - scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent; 1501 - 1502 - if (read_ptr < TFD_QUEUE_SIZE_BC_DUP) 1503 - scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = 1504 - bc_ent; 1505 - } 1506 - 1507 - /* 1508 - * iwl_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] 1509 - * @trans - transport private data 1510 - * @txq - tx queue 1511 - * @dma_dir - the direction of the DMA mapping 1512 - * 1513 - * Does NOT advance any TFD circular buffer read/write indexes 1514 - * Does NOT free the TFD itself (which is within circular buffer) 1515 - */ 1516 - void iwl_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq) 1517 - { 1518 - /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and 1519 - * idx is bounded by n_window 1520 - */ 1521 - int rd_ptr = txq->read_ptr; 1522 - int idx = iwl_txq_get_cmd_index(txq, rd_ptr); 1523 - struct sk_buff *skb; 1524 - 1525 - lockdep_assert_held(&txq->lock); 1526 - 1527 - if (!txq->entries) 1528 - return; 1529 - 1530 - /* We have only q->n_window txq->entries, but we use 1531 - * TFD_QUEUE_SIZE_MAX tfds 1532 - */ 1533 - if (trans->trans_cfg->gen2) 1534 - iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta, 1535 - iwl_txq_get_tfd(trans, txq, rd_ptr)); 1536 - else 1537 - iwl_txq_gen1_tfd_unmap(trans, &txq->entries[idx].meta, 1538 - txq, rd_ptr); 1539 - 1540 - /* free SKB */ 1541 - skb = txq->entries[idx].skb; 1542 - 1543 - /* Can be called from irqs-disabled context 1544 - * If skb is not NULL, it means that the whole queue is being 1545 - * freed and that the queue is not empty - free the skb 1546 - */ 1547 - if (skb) { 1548 - iwl_op_mode_free_skb(trans->op_mode, skb); 1549 - txq->entries[idx].skb = NULL; 1550 - } 1551 - } 1552 - 1553 - void iwl_txq_progress(struct iwl_txq *txq) 1554 - { 1555 - lockdep_assert_held(&txq->lock); 1556 - 1557 - if (!txq->wd_timeout) 1558 - return; 1559 - 1560 - /* 1561 - * station is asleep and we send data - that must 1562 - * be uAPSD or PS-Poll. Don't rearm the timer. 1563 - */ 1564 - if (txq->frozen) 1565 - return; 1566 - 1567 - /* 1568 - * if empty delete timer, otherwise move timer forward 1569 - * since we're making progress on this queue 1570 - */ 1571 - if (txq->read_ptr == txq->write_ptr) 1572 - del_timer(&txq->stuck_timer); 1573 - else 1574 - mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); 1575 - } 1576 - 1577 - /* Frees buffers until index _not_ inclusive */ 1578 - void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn, 1579 - struct sk_buff_head *skbs, bool is_flush) 1580 - { 1581 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 1582 - int tfd_num, read_ptr, last_to_free; 1583 - 1584 - /* This function is not meant to release cmd queue*/ 1585 - if (WARN_ON(txq_id == trans->txqs.cmd.q_id)) 1586 - return; 1587 - 1588 - if (WARN_ON(!txq)) 1589 - return; 1590 - 1591 - tfd_num = iwl_txq_get_cmd_index(txq, ssn); 1592 - 1593 - spin_lock_bh(&txq->lock); 1594 - read_ptr = iwl_txq_get_cmd_index(txq, txq->read_ptr); 1595 - 1596 - if (!test_bit(txq_id, trans->txqs.queue_used)) { 1597 - IWL_DEBUG_TX_QUEUES(trans, "Q %d inactive - ignoring idx %d\n", 1598 - txq_id, ssn); 1599 - goto out; 1600 - } 1601 - 1602 - if (read_ptr == tfd_num) 1603 - goto out; 1604 - 1605 - IWL_DEBUG_TX_REPLY(trans, "[Q %d] %d (%d) -> %d (%d)\n", 1606 - txq_id, read_ptr, txq->read_ptr, tfd_num, ssn); 1607 - 1608 - /*Since we free until index _not_ inclusive, the one before index is 1609 - * the last we will free. This one must be used */ 1610 - last_to_free = iwl_txq_dec_wrap(trans, tfd_num); 1611 - 1612 - if (!iwl_txq_used(txq, last_to_free)) { 1613 - IWL_ERR(trans, 1614 - "%s: Read index for txq id (%d), last_to_free %d is out of range [0-%d] %d %d.\n", 1615 - __func__, txq_id, last_to_free, 1616 - trans->trans_cfg->base_params->max_tfd_queue_size, 1617 - txq->write_ptr, txq->read_ptr); 1618 - 1619 - iwl_op_mode_time_point(trans->op_mode, 1620 - IWL_FW_INI_TIME_POINT_FAKE_TX, 1621 - NULL); 1622 - goto out; 1623 - } 1624 - 1625 - if (WARN_ON(!skb_queue_empty(skbs))) 1626 - goto out; 1627 - 1628 - for (; 1629 - read_ptr != tfd_num; 1630 - txq->read_ptr = iwl_txq_inc_wrap(trans, txq->read_ptr), 1631 - read_ptr = iwl_txq_get_cmd_index(txq, txq->read_ptr)) { 1632 - struct sk_buff *skb = txq->entries[read_ptr].skb; 1633 - 1634 - if (WARN_ONCE(!skb, "no SKB at %d (%d) on queue %d\n", 1635 - read_ptr, txq->read_ptr, txq_id)) 1636 - continue; 1637 - 1638 - iwl_txq_free_tso_page(trans, skb); 1639 - 1640 - __skb_queue_tail(skbs, skb); 1641 - 1642 - txq->entries[read_ptr].skb = NULL; 1643 - 1644 - if (!trans->trans_cfg->gen2) 1645 - iwl_txq_gen1_inval_byte_cnt_tbl(trans, txq); 1646 - 1647 - iwl_txq_free_tfd(trans, txq); 1648 - } 1649 - 1650 - iwl_txq_progress(txq); 1651 - 1652 - if (iwl_txq_space(trans, txq) > txq->low_mark && 1653 - test_bit(txq_id, trans->txqs.queue_stopped)) { 1654 - struct sk_buff_head overflow_skbs; 1655 - struct sk_buff *skb; 1656 - 1657 - __skb_queue_head_init(&overflow_skbs); 1658 - skb_queue_splice_init(&txq->overflow_q, 1659 - is_flush ? skbs : &overflow_skbs); 1660 - 1661 - /* 1662 - * We are going to transmit from the overflow queue. 1663 - * Remember this state so that wait_for_txq_empty will know we 1664 - * are adding more packets to the TFD queue. It cannot rely on 1665 - * the state of &txq->overflow_q, as we just emptied it, but 1666 - * haven't TXed the content yet. 1667 - */ 1668 - txq->overflow_tx = true; 1669 - 1670 - /* 1671 - * This is tricky: we are in reclaim path which is non 1672 - * re-entrant, so noone will try to take the access the 1673 - * txq data from that path. We stopped tx, so we can't 1674 - * have tx as well. Bottom line, we can unlock and re-lock 1675 - * later. 1676 - */ 1677 - spin_unlock_bh(&txq->lock); 1678 - 1679 - while ((skb = __skb_dequeue(&overflow_skbs))) { 1680 - struct iwl_device_tx_cmd *dev_cmd_ptr; 1681 - 1682 - dev_cmd_ptr = *(void **)((u8 *)skb->cb + 1683 - trans->txqs.dev_cmd_offs); 1684 - 1685 - /* 1686 - * Note that we can very well be overflowing again. 1687 - * In that case, iwl_txq_space will be small again 1688 - * and we won't wake mac80211's queue. 1689 - */ 1690 - iwl_trans_tx(trans, skb, dev_cmd_ptr, txq_id); 1691 - } 1692 - 1693 - if (iwl_txq_space(trans, txq) > txq->low_mark) 1694 - iwl_wake_queue(trans, txq); 1695 - 1696 - spin_lock_bh(&txq->lock); 1697 - txq->overflow_tx = false; 1698 - } 1699 - 1700 - out: 1701 - spin_unlock_bh(&txq->lock); 1702 - } 1703 - 1704 - /* Set wr_ptr of specific device and txq */ 1705 - void iwl_txq_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr) 1706 - { 1707 - struct iwl_txq *txq = trans->txqs.txq[txq_id]; 1708 - 1709 - spin_lock_bh(&txq->lock); 1710 - 1711 - txq->write_ptr = ptr; 1712 - txq->read_ptr = txq->write_ptr; 1713 - 1714 - spin_unlock_bh(&txq->lock); 1715 - } 1716 - 1717 - void iwl_trans_txq_freeze_timer(struct iwl_trans *trans, unsigned long txqs, 1718 - bool freeze) 1719 - { 1720 - int queue; 1721 - 1722 - for_each_set_bit(queue, &txqs, BITS_PER_LONG) { 1723 - struct iwl_txq *txq = trans->txqs.txq[queue]; 1724 - unsigned long now; 1725 - 1726 - spin_lock_bh(&txq->lock); 1727 - 1728 - now = jiffies; 1729 - 1730 - if (txq->frozen == freeze) 1731 - goto next_queue; 1732 - 1733 - IWL_DEBUG_TX_QUEUES(trans, "%s TXQ %d\n", 1734 - freeze ? "Freezing" : "Waking", queue); 1735 - 1736 - txq->frozen = freeze; 1737 - 1738 - if (txq->read_ptr == txq->write_ptr) 1739 - goto next_queue; 1740 - 1741 - if (freeze) { 1742 - if (unlikely(time_after(now, 1743 - txq->stuck_timer.expires))) { 1744 - /* 1745 - * The timer should have fired, maybe it is 1746 - * spinning right now on the lock. 1747 - */ 1748 - goto next_queue; 1749 - } 1750 - /* remember how long until the timer fires */ 1751 - txq->frozen_expiry_remainder = 1752 - txq->stuck_timer.expires - now; 1753 - del_timer(&txq->stuck_timer); 1754 - goto next_queue; 1755 - } 1756 - 1757 - /* 1758 - * Wake a non-empty queue -> arm timer with the 1759 - * remainder before it froze 1760 - */ 1761 - mod_timer(&txq->stuck_timer, 1762 - now + txq->frozen_expiry_remainder); 1763 - 1764 - next_queue: 1765 - spin_unlock_bh(&txq->lock); 1766 - } 1767 - } 1768 - 1769 - #define HOST_COMPLETE_TIMEOUT (2 * HZ) 1770 - 1771 - static int iwl_trans_txq_send_hcmd_sync(struct iwl_trans *trans, 1772 - struct iwl_host_cmd *cmd) 1773 - { 1774 - const char *cmd_str = iwl_get_cmd_string(trans, cmd->id); 1775 - struct iwl_txq *txq = trans->txqs.txq[trans->txqs.cmd.q_id]; 1776 - int cmd_idx; 1777 - int ret; 1778 - 1779 - IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", cmd_str); 1780 - 1781 - if (WARN(test_and_set_bit(STATUS_SYNC_HCMD_ACTIVE, 1782 - &trans->status), 1783 - "Command %s: a command is already active!\n", cmd_str)) 1784 - return -EIO; 1785 - 1786 - IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", cmd_str); 1787 - 1788 - cmd_idx = trans->ops->send_cmd(trans, cmd); 1789 - if (cmd_idx < 0) { 1790 - ret = cmd_idx; 1791 - clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 1792 - IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", 1793 - cmd_str, ret); 1794 - return ret; 1795 - } 1796 - 1797 - ret = wait_event_timeout(trans->wait_command_queue, 1798 - !test_bit(STATUS_SYNC_HCMD_ACTIVE, 1799 - &trans->status), 1800 - HOST_COMPLETE_TIMEOUT); 1801 - if (!ret) { 1802 - IWL_ERR(trans, "Error sending %s: time out after %dms.\n", 1803 - cmd_str, jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); 1804 - 1805 - IWL_ERR(trans, "Current CMD queue read_ptr %d write_ptr %d\n", 1806 - txq->read_ptr, txq->write_ptr); 1807 - 1808 - clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 1809 - IWL_DEBUG_INFO(trans, "Clearing HCMD_ACTIVE for command %s\n", 1810 - cmd_str); 1811 - ret = -ETIMEDOUT; 1812 - 1813 - iwl_trans_sync_nmi(trans); 1814 - goto cancel; 1815 - } 1816 - 1817 - if (test_bit(STATUS_FW_ERROR, &trans->status)) { 1818 - if (!test_and_clear_bit(STATUS_SUPPRESS_CMD_ERROR_ONCE, 1819 - &trans->status)) { 1820 - IWL_ERR(trans, "FW error in SYNC CMD %s\n", cmd_str); 1821 - dump_stack(); 1822 - } 1823 - ret = -EIO; 1824 - goto cancel; 1825 - } 1826 - 1827 - if (!(cmd->flags & CMD_SEND_IN_RFKILL) && 1828 - test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { 1829 - IWL_DEBUG_RF_KILL(trans, "RFKILL in SYNC CMD... no rsp\n"); 1830 - ret = -ERFKILL; 1831 - goto cancel; 1832 - } 1833 - 1834 - if ((cmd->flags & CMD_WANT_SKB) && !cmd->resp_pkt) { 1835 - IWL_ERR(trans, "Error: Response NULL in '%s'\n", cmd_str); 1836 - ret = -EIO; 1837 - goto cancel; 1838 - } 1839 - 1840 - return 0; 1841 - 1842 - cancel: 1843 - if (cmd->flags & CMD_WANT_SKB) { 1844 - /* 1845 - * Cancel the CMD_WANT_SKB flag for the cmd in the 1846 - * TX cmd queue. Otherwise in case the cmd comes 1847 - * in later, it will possibly set an invalid 1848 - * address (cmd->meta.source). 1849 - */ 1850 - txq->entries[cmd_idx].meta.flags &= ~CMD_WANT_SKB; 1851 - } 1852 - 1853 - if (cmd->resp_pkt) { 1854 - iwl_free_resp(cmd); 1855 - cmd->resp_pkt = NULL; 1856 - } 1857 - 1858 - return ret; 1859 - } 1860 - 1861 - int iwl_trans_txq_send_hcmd(struct iwl_trans *trans, 1862 - struct iwl_host_cmd *cmd) 1863 - { 1864 - /* Make sure the NIC is still alive in the bus */ 1865 - if (test_bit(STATUS_TRANS_DEAD, &trans->status)) 1866 - return -ENODEV; 1867 - 1868 - if (!(cmd->flags & CMD_SEND_IN_RFKILL) && 1869 - test_bit(STATUS_RFKILL_OPMODE, &trans->status)) { 1870 - IWL_DEBUG_RF_KILL(trans, "Dropping CMD 0x%x: RF KILL\n", 1871 - cmd->id); 1872 - return -ERFKILL; 1873 - } 1874 - 1875 - if (unlikely(trans->system_pm_mode == IWL_PLAT_PM_MODE_D3 && 1876 - !(cmd->flags & CMD_SEND_IN_D3))) { 1877 - IWL_DEBUG_WOWLAN(trans, "Dropping CMD 0x%x: D3\n", cmd->id); 1878 - return -EHOSTDOWN; 1879 - } 1880 - 1881 - if (cmd->flags & CMD_ASYNC) { 1882 - int ret; 1883 - 1884 - /* An asynchronous command can not expect an SKB to be set. */ 1885 - if (WARN_ON(cmd->flags & CMD_WANT_SKB)) 1886 - return -EINVAL; 1887 - 1888 - ret = trans->ops->send_cmd(trans, cmd); 1889 - if (ret < 0) { 1890 - IWL_ERR(trans, 1891 - "Error sending %s: enqueue_hcmd failed: %d\n", 1892 - iwl_get_cmd_string(trans, cmd->id), ret); 1893 - return ret; 1894 - } 1895 - return 0; 1896 - } 1897 - 1898 - return iwl_trans_txq_send_hcmd_sync(trans, cmd); 1899 - } 1900 -
-191
drivers/net/wireless/intel/iwlwifi/queue/tx.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 - /* 3 - * Copyright (C) 2020-2023 Intel Corporation 4 - */ 5 - #ifndef __iwl_trans_queue_tx_h__ 6 - #define __iwl_trans_queue_tx_h__ 7 - #include "iwl-fh.h" 8 - #include "fw/api/tx.h" 9 - 10 - struct iwl_tso_hdr_page { 11 - struct page *page; 12 - u8 *pos; 13 - }; 14 - 15 - static inline dma_addr_t 16 - iwl_txq_get_first_tb_dma(struct iwl_txq *txq, int idx) 17 - { 18 - return txq->first_tb_dma + 19 - sizeof(struct iwl_pcie_first_tb_buf) * idx; 20 - } 21 - 22 - static inline u16 iwl_txq_get_cmd_index(const struct iwl_txq *q, u32 index) 23 - { 24 - return index & (q->n_window - 1); 25 - } 26 - 27 - void iwl_txq_gen2_unmap(struct iwl_trans *trans, int txq_id); 28 - 29 - static inline void iwl_wake_queue(struct iwl_trans *trans, 30 - struct iwl_txq *txq) 31 - { 32 - if (test_and_clear_bit(txq->id, trans->txqs.queue_stopped)) { 33 - IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d\n", txq->id); 34 - iwl_op_mode_queue_not_full(trans->op_mode, txq->id); 35 - } 36 - } 37 - 38 - static inline void *iwl_txq_get_tfd(struct iwl_trans *trans, 39 - struct iwl_txq *txq, int idx) 40 - { 41 - if (trans->trans_cfg->gen2) 42 - idx = iwl_txq_get_cmd_index(txq, idx); 43 - 44 - return (u8 *)txq->tfds + trans->txqs.tfd.size * idx; 45 - } 46 - 47 - int iwl_txq_alloc(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, 48 - bool cmd_queue); 49 - /* 50 - * We need this inline in case dma_addr_t is only 32-bits - since the 51 - * hardware is always 64-bit, the issue can still occur in that case, 52 - * so use u64 for 'phys' here to force the addition in 64-bit. 53 - */ 54 - static inline bool iwl_txq_crosses_4g_boundary(u64 phys, u16 len) 55 - { 56 - return upper_32_bits(phys) != upper_32_bits(phys + len); 57 - } 58 - 59 - int iwl_txq_space(struct iwl_trans *trans, const struct iwl_txq *q); 60 - 61 - static inline void iwl_txq_stop(struct iwl_trans *trans, struct iwl_txq *txq) 62 - { 63 - if (!test_and_set_bit(txq->id, trans->txqs.queue_stopped)) { 64 - iwl_op_mode_queue_full(trans->op_mode, txq->id); 65 - IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d\n", txq->id); 66 - } else { 67 - IWL_DEBUG_TX_QUEUES(trans, "hwq %d already stopped\n", 68 - txq->id); 69 - } 70 - } 71 - 72 - /** 73 - * iwl_txq_inc_wrap - increment queue index, wrap back to beginning 74 - * @trans: the transport (for configuration data) 75 - * @index: current index 76 - */ 77 - static inline int iwl_txq_inc_wrap(struct iwl_trans *trans, int index) 78 - { 79 - return ++index & 80 - (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 81 - } 82 - 83 - /** 84 - * iwl_txq_dec_wrap - decrement queue index, wrap back to end 85 - * @trans: the transport (for configuration data) 86 - * @index: current index 87 - */ 88 - static inline int iwl_txq_dec_wrap(struct iwl_trans *trans, int index) 89 - { 90 - return --index & 91 - (trans->trans_cfg->base_params->max_tfd_queue_size - 1); 92 - } 93 - 94 - static inline bool iwl_txq_used(const struct iwl_txq *q, int i) 95 - { 96 - int index = iwl_txq_get_cmd_index(q, i); 97 - int r = iwl_txq_get_cmd_index(q, q->read_ptr); 98 - int w = iwl_txq_get_cmd_index(q, q->write_ptr); 99 - 100 - return w >= r ? 101 - (index >= r && index < w) : 102 - !(index < r && index >= w); 103 - } 104 - 105 - void iwl_txq_free_tso_page(struct iwl_trans *trans, struct sk_buff *skb); 106 - 107 - void iwl_txq_log_scd_error(struct iwl_trans *trans, struct iwl_txq *txq); 108 - 109 - int iwl_txq_gen2_set_tb(struct iwl_trans *trans, 110 - struct iwl_tfh_tfd *tfd, dma_addr_t addr, 111 - u16 len); 112 - 113 - void iwl_txq_gen2_tfd_unmap(struct iwl_trans *trans, 114 - struct iwl_cmd_meta *meta, 115 - struct iwl_tfh_tfd *tfd); 116 - 117 - int iwl_txq_dyn_alloc(struct iwl_trans *trans, u32 flags, 118 - u32 sta_mask, u8 tid, 119 - int size, unsigned int timeout); 120 - 121 - int iwl_txq_gen2_tx(struct iwl_trans *trans, struct sk_buff *skb, 122 - struct iwl_device_tx_cmd *dev_cmd, int txq_id); 123 - 124 - void iwl_txq_dyn_free(struct iwl_trans *trans, int queue); 125 - void iwl_txq_gen2_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq); 126 - void iwl_txq_inc_wr_ptr(struct iwl_trans *trans, struct iwl_txq *txq); 127 - void iwl_txq_gen2_tx_free(struct iwl_trans *trans); 128 - int iwl_txq_init(struct iwl_trans *trans, struct iwl_txq *txq, int slots_num, 129 - bool cmd_queue); 130 - int iwl_txq_gen2_init(struct iwl_trans *trans, int txq_id, int queue_size); 131 - #ifdef CONFIG_INET 132 - struct iwl_tso_hdr_page *get_page_hdr(struct iwl_trans *trans, size_t len, 133 - struct sk_buff *skb); 134 - #endif 135 - static inline u8 iwl_txq_gen1_tfd_get_num_tbs(struct iwl_trans *trans, 136 - struct iwl_tfd *tfd) 137 - { 138 - return tfd->num_tbs & 0x1f; 139 - } 140 - 141 - static inline u16 iwl_txq_gen1_tfd_tb_get_len(struct iwl_trans *trans, 142 - void *_tfd, u8 idx) 143 - { 144 - struct iwl_tfd *tfd; 145 - struct iwl_tfd_tb *tb; 146 - 147 - if (trans->trans_cfg->gen2) { 148 - struct iwl_tfh_tfd *tfh_tfd = _tfd; 149 - struct iwl_tfh_tb *tfh_tb = &tfh_tfd->tbs[idx]; 150 - 151 - return le16_to_cpu(tfh_tb->tb_len); 152 - } 153 - 154 - tfd = (struct iwl_tfd *)_tfd; 155 - tb = &tfd->tbs[idx]; 156 - 157 - return le16_to_cpu(tb->hi_n_len) >> 4; 158 - } 159 - 160 - static inline void iwl_pcie_gen1_tfd_set_tb(struct iwl_trans *trans, 161 - struct iwl_tfd *tfd, 162 - u8 idx, dma_addr_t addr, u16 len) 163 - { 164 - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 165 - u16 hi_n_len = len << 4; 166 - 167 - put_unaligned_le32(addr, &tb->lo); 168 - hi_n_len |= iwl_get_dma_hi_addr(addr); 169 - 170 - tb->hi_n_len = cpu_to_le16(hi_n_len); 171 - 172 - tfd->num_tbs = idx + 1; 173 - } 174 - 175 - void iwl_txq_gen1_tfd_unmap(struct iwl_trans *trans, 176 - struct iwl_cmd_meta *meta, 177 - struct iwl_txq *txq, int index); 178 - void iwl_txq_gen1_inval_byte_cnt_tbl(struct iwl_trans *trans, 179 - struct iwl_txq *txq); 180 - void iwl_txq_gen1_update_byte_cnt_tbl(struct iwl_trans *trans, 181 - struct iwl_txq *txq, u16 byte_cnt, 182 - int num_tbs); 183 - void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn, 184 - struct sk_buff_head *skbs, bool is_flush); 185 - void iwl_txq_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr); 186 - void iwl_trans_txq_freeze_timer(struct iwl_trans *trans, unsigned long txqs, 187 - bool freeze); 188 - void iwl_txq_progress(struct iwl_txq *txq); 189 - void iwl_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq); 190 - int iwl_trans_txq_send_hcmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd); 191 - #endif /* __iwl_trans_queue_tx_h__ */
+3 -3
drivers/net/wireless/intersil/p54/fwio.c
··· 216 216 struct sk_buff *skb; 217 217 size_t eeprom_hdr_size; 218 218 int ret = 0; 219 - long timeout; 219 + long time_left; 220 220 221 221 if (priv->fw_var >= 0x509) 222 222 eeprom_hdr_size = sizeof(*eeprom_hdr); ··· 245 245 246 246 p54_tx(priv, skb); 247 247 248 - timeout = wait_for_completion_interruptible_timeout( 248 + time_left = wait_for_completion_interruptible_timeout( 249 249 &priv->eeprom_comp, HZ); 250 - if (timeout <= 0) { 250 + if (time_left <= 0) { 251 251 wiphy_err(priv->hw->wiphy, 252 252 "device does not respond or signal received!\n"); 253 253 ret = -EBUSY;
+1 -1
drivers/net/wireless/intersil/p54/main.c
··· 197 197 return err; 198 198 } 199 199 200 - static void p54_stop(struct ieee80211_hw *dev) 200 + static void p54_stop(struct ieee80211_hw *dev, bool suspend) 201 201 { 202 202 struct p54_common *priv = dev->priv; 203 203 int i;
+4 -4
drivers/net/wireless/intersil/p54/p54pci.c
··· 434 434 { 435 435 struct p54p_priv *priv = dev->priv; 436 436 int err; 437 - long timeout; 437 + long time_left; 438 438 439 439 init_completion(&priv->boot_comp); 440 440 err = request_irq(priv->pdev->irq, p54p_interrupt, ··· 472 472 P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET)); 473 473 P54P_READ(dev_int); 474 474 475 - timeout = wait_for_completion_interruptible_timeout( 475 + time_left = wait_for_completion_interruptible_timeout( 476 476 &priv->boot_comp, HZ); 477 - if (timeout <= 0) { 477 + if (time_left <= 0) { 478 478 wiphy_err(dev->wiphy, "Cannot boot firmware!\n"); 479 479 p54p_stop(dev); 480 - return timeout ? -ERESTARTSYS : -ETIMEDOUT; 480 + return time_left ? -ERESTARTSYS : -ETIMEDOUT; 481 481 } 482 482 483 483 P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_UPDATE));
+5 -5
drivers/net/wireless/intersil/p54/p54spi.c
··· 518 518 static int p54spi_op_start(struct ieee80211_hw *dev) 519 519 { 520 520 struct p54s_priv *priv = dev->priv; 521 - unsigned long timeout; 521 + long time_left; 522 522 int ret = 0; 523 523 524 524 if (mutex_lock_interruptible(&priv->mutex)) { ··· 538 538 539 539 mutex_unlock(&priv->mutex); 540 540 541 - timeout = msecs_to_jiffies(2000); 542 - timeout = wait_for_completion_interruptible_timeout(&priv->fw_comp, 543 - timeout); 544 - if (!timeout) { 541 + time_left = msecs_to_jiffies(2000); 542 + time_left = wait_for_completion_interruptible_timeout(&priv->fw_comp, 543 + time_left); 544 + if (!time_left) { 545 545 dev_err(&priv->spi->dev, "firmware boot failed"); 546 546 p54spi_power_off(priv); 547 547 ret = -1;
+1 -1
drivers/net/wireless/marvell/libertas_tf/main.c
··· 267 267 return 0; 268 268 } 269 269 270 - static void lbtf_op_stop(struct ieee80211_hw *hw) 270 + static void lbtf_op_stop(struct ieee80211_hw *hw, bool suspend) 271 271 { 272 272 struct lbtf_private *priv = hw->priv; 273 273 unsigned long flags;
+7 -7
drivers/net/wireless/marvell/mwl8k.c
··· 2211 2211 dma_addr_t dma_addr; 2212 2212 unsigned int dma_size; 2213 2213 int rc; 2214 - unsigned long timeout = 0; 2214 + unsigned long time_left = 0; 2215 2215 u8 buf[32]; 2216 2216 u32 bitmap = 0; 2217 2217 ··· 2258 2258 iowrite32(MWL8K_H2A_INT_DUMMY, 2259 2259 regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS); 2260 2260 2261 - timeout = wait_for_completion_timeout(&cmd_wait, 2262 - msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS)); 2261 + time_left = wait_for_completion_timeout(&cmd_wait, 2262 + msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS)); 2263 2263 2264 2264 priv->hostcmd_wait = NULL; 2265 2265 ··· 2267 2267 dma_unmap_single(&priv->pdev->dev, dma_addr, dma_size, 2268 2268 DMA_BIDIRECTIONAL); 2269 2269 2270 - if (!timeout) { 2270 + if (!time_left) { 2271 2271 wiphy_err(hw->wiphy, "Command %s timeout after %u ms\n", 2272 2272 mwl8k_cmd_name(cmd->code, buf, sizeof(buf)), 2273 2273 MWL8K_CMD_TIMEOUT_MS); ··· 2275 2275 } else { 2276 2276 int ms; 2277 2277 2278 - ms = MWL8K_CMD_TIMEOUT_MS - jiffies_to_msecs(timeout); 2278 + ms = MWL8K_CMD_TIMEOUT_MS - jiffies_to_msecs(time_left); 2279 2279 2280 2280 rc = cmd->result ? -EINVAL : 0; 2281 2281 if (rc) ··· 4768 4768 return rc; 4769 4769 } 4770 4770 4771 - static void mwl8k_stop(struct ieee80211_hw *hw) 4771 + static void mwl8k_stop(struct ieee80211_hw *hw, bool suspend) 4772 4772 { 4773 4773 struct mwl8k_priv *priv = hw->priv; 4774 4774 int i; ··· 6023 6023 struct mwl8k_priv *priv = hw->priv; 6024 6024 struct mwl8k_vif *vif, *tmp_vif; 6025 6025 6026 - mwl8k_stop(hw); 6026 + mwl8k_stop(hw, false); 6027 6027 mwl8k_rxq_deinit(hw, 0); 6028 6028 6029 6029 /*
+1 -1
drivers/net/wireless/mediatek/mt76/mt7603/main.c
··· 23 23 } 24 24 25 25 static void 26 - mt7603_stop(struct ieee80211_hw *hw) 26 + mt7603_stop(struct ieee80211_hw *hw, bool suspend) 27 27 { 28 28 struct mt7603_dev *dev = hw->priv; 29 29
+1 -1
drivers/net/wireless/mediatek/mt76/mt7615/main.c
··· 91 91 return ret; 92 92 } 93 93 94 - static void mt7615_stop(struct ieee80211_hw *hw) 94 + static void mt7615_stop(struct ieee80211_hw *hw, bool suspend) 95 95 { 96 96 struct mt7615_dev *dev = mt7615_hw_dev(hw); 97 97 struct mt7615_phy *phy = mt7615_hw_phy(hw);
+1 -1
drivers/net/wireless/mediatek/mt76/mt7615/usb.c
··· 79 79 mutex_unlock(&usb->usb_ctrl_mtx); 80 80 } 81 81 82 - static void mt7663u_stop(struct ieee80211_hw *hw) 82 + static void mt7663u_stop(struct ieee80211_hw *hw, bool suspend) 83 83 { 84 84 struct mt7615_phy *phy = mt7615_hw_phy(hw); 85 85 struct mt7615_dev *dev = hw->priv;
+1 -1
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
··· 44 44 mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_RX_DMA_EN); 45 45 } 46 46 47 - static void mt76x0e_stop(struct ieee80211_hw *hw) 47 + static void mt76x0e_stop(struct ieee80211_hw *hw, bool suspend) 48 48 { 49 49 struct mt76x02_dev *dev = hw->priv; 50 50
+1 -1
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
··· 77 77 mt76u_queues_deinit(&dev->mt76); 78 78 } 79 79 80 - static void mt76x0u_stop(struct ieee80211_hw *hw) 80 + static void mt76x0u_stop(struct ieee80211_hw *hw, bool suspend) 81 81 { 82 82 struct mt76x02_dev *dev = hw->priv; 83 83
+1 -1
drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
··· 24 24 } 25 25 26 26 static void 27 - mt76x2_stop(struct ieee80211_hw *hw) 27 + mt76x2_stop(struct ieee80211_hw *hw, bool suspend) 28 28 { 29 29 struct mt76x02_dev *dev = hw->priv; 30 30
+1 -1
drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
··· 22 22 return 0; 23 23 } 24 24 25 - static void mt76x2u_stop(struct ieee80211_hw *hw) 25 + static void mt76x2u_stop(struct ieee80211_hw *hw, bool suspend) 26 26 { 27 27 struct mt76x02_dev *dev = hw->priv; 28 28
+1 -1
drivers/net/wireless/mediatek/mt76/mt7915/main.c
··· 108 108 return ret; 109 109 } 110 110 111 - static void mt7915_stop(struct ieee80211_hw *hw) 111 + static void mt7915_stop(struct ieee80211_hw *hw, bool suspend) 112 112 { 113 113 struct mt7915_dev *dev = mt7915_hw_dev(hw); 114 114 struct mt7915_phy *phy = mt7915_hw_phy(hw);
+2 -2
drivers/net/wireless/mediatek/mt76/mt7921/main.c
··· 268 268 return err; 269 269 } 270 270 271 - static void mt7921_stop(struct ieee80211_hw *hw) 271 + static void mt7921_stop(struct ieee80211_hw *hw, bool suspend) 272 272 { 273 273 struct mt792x_dev *dev = mt792x_hw_dev(hw); 274 274 int err = 0; ··· 281 281 return; 282 282 } 283 283 284 - mt792x_stop(hw); 284 + mt792x_stop(hw, false); 285 285 } 286 286 287 287 static int
+2 -2
drivers/net/wireless/mediatek/mt76/mt792x.h
··· 251 251 #define mt792x_mutex_release(dev) \ 252 252 mt76_connac_mutex_release(&(dev)->mt76, &(dev)->pm) 253 253 254 - void mt792x_stop(struct ieee80211_hw *hw); 254 + void mt792x_stop(struct ieee80211_hw *hw, bool suspend); 255 255 void mt792x_pm_wake_work(struct work_struct *work); 256 256 void mt792x_pm_power_save_work(struct work_struct *work); 257 257 void mt792x_reset(struct mt76_dev *mdev); ··· 368 368 u32 mt792xu_rmw(struct mt76_dev *dev, u32 addr, u32 mask, u32 val); 369 369 void mt792xu_copy(struct mt76_dev *dev, u32 offset, const void *data, int len); 370 370 void mt792xu_disconnect(struct usb_interface *usb_intf); 371 - void mt792xu_stop(struct ieee80211_hw *hw); 371 + void mt792xu_stop(struct ieee80211_hw *hw, bool suspend); 372 372 373 373 static inline void 374 374 mt792x_skb_add_usb_sdio_hdr(struct mt792x_dev *dev, struct sk_buff *skb,
+1 -1
drivers/net/wireless/mediatek/mt76/mt792x_core.c
··· 91 91 } 92 92 EXPORT_SYMBOL_GPL(mt792x_tx); 93 93 94 - void mt792x_stop(struct ieee80211_hw *hw) 94 + void mt792x_stop(struct ieee80211_hw *hw, bool suspend) 95 95 { 96 96 struct mt792x_dev *dev = mt792x_hw_dev(hw); 97 97 struct mt792x_phy *phy = mt792x_hw_phy(hw);
+2 -2
drivers/net/wireless/mediatek/mt76/mt792x_usb.c
··· 285 285 } 286 286 EXPORT_SYMBOL_GPL(mt792xu_init_reset); 287 287 288 - void mt792xu_stop(struct ieee80211_hw *hw) 288 + void mt792xu_stop(struct ieee80211_hw *hw, bool suspend) 289 289 { 290 290 struct mt792x_dev *dev = mt792x_hw_dev(hw); 291 291 292 292 mt76u_stop_tx(&dev->mt76); 293 - mt792x_stop(hw); 293 + mt792x_stop(hw, false); 294 294 } 295 295 EXPORT_SYMBOL_GPL(mt792xu_stop); 296 296
+1 -1
drivers/net/wireless/mediatek/mt76/mt7996/main.c
··· 93 93 return ret; 94 94 } 95 95 96 - static void mt7996_stop(struct ieee80211_hw *hw) 96 + static void mt7996_stop(struct ieee80211_hw *hw, bool suspend) 97 97 { 98 98 struct mt7996_dev *dev = mt7996_hw_dev(hw); 99 99 struct mt7996_phy *phy = mt7996_hw_phy(hw);
+1 -1
drivers/net/wireless/mediatek/mt7601u/main.c
··· 28 28 return ret; 29 29 } 30 30 31 - static void mt7601u_stop(struct ieee80211_hw *hw) 31 + static void mt7601u_stop(struct ieee80211_hw *hw, bool suspend) 32 32 { 33 33 struct mt7601u_dev *dev = hw->priv; 34 34
-19
drivers/net/wireless/microchip/wilc1000/cfg80211.c
··· 1617 1617 return 0; 1618 1618 } 1619 1619 1620 - static int wilc_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow) 1621 - { 1622 - struct wilc *wl = wiphy_priv(wiphy); 1623 - 1624 - if (!wow && wilc_wlan_get_num_conn_ifcs(wl)) 1625 - wl->suspend_event = true; 1626 - else 1627 - wl->suspend_event = false; 1628 - 1629 - return 0; 1630 - } 1631 - 1632 - static int wilc_resume(struct wiphy *wiphy) 1633 - { 1634 - return 0; 1635 - } 1636 - 1637 1620 static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) 1638 1621 { 1639 1622 struct wilc *wl = wiphy_priv(wiphy); ··· 1722 1739 .set_power_mgmt = set_power_mgmt, 1723 1740 .set_cqm_rssi_config = set_cqm_rssi_config, 1724 1741 1725 - .suspend = wilc_suspend, 1726 - .resume = wilc_resume, 1727 1742 .set_wakeup = wilc_set_wakeup, 1728 1743 .set_tx_power = set_tx_power, 1729 1744 .get_tx_power = get_tx_power,
-1
drivers/net/wireless/microchip/wilc1000/netdev.h
··· 272 272 const struct firmware *firmware; 273 273 274 274 struct device *dev; 275 - bool suspend_event; 276 275 277 276 struct workqueue_struct *hif_workqueue; 278 277 struct wilc_cfg cfg;
+26 -48
drivers/net/wireless/microchip/wilc1000/sdio.c
··· 249 249 return sdio_priv->isinit; 250 250 } 251 251 252 - static int wilc_sdio_suspend(struct device *dev) 253 - { 254 - struct sdio_func *func = dev_to_sdio_func(dev); 255 - struct wilc *wilc = sdio_get_drvdata(func); 256 - int ret; 257 - 258 - dev_info(dev, "sdio suspend\n"); 259 - chip_wakeup(wilc); 260 - 261 - if (!IS_ERR(wilc->rtc_clk)) 262 - clk_disable_unprepare(wilc->rtc_clk); 263 - 264 - if (wilc->suspend_event) { 265 - host_sleep_notify(wilc); 266 - chip_allow_sleep(wilc); 267 - } 268 - 269 - ret = wilc_sdio_reset(wilc); 270 - if (ret) { 271 - dev_err(&func->dev, "Fail reset sdio\n"); 272 - return ret; 273 - } 274 - sdio_claim_host(func); 275 - 276 - return 0; 277 - } 278 - 279 252 static int wilc_sdio_enable_interrupt(struct wilc *dev) 280 253 { 281 254 struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev); ··· 880 907 { 881 908 struct sdio_func *func = dev_to_sdio_func(wilc->dev); 882 909 struct wilc_sdio *sdio_priv = wilc->bus_data; 883 - u32 reg; 884 910 885 911 if (nint > MAX_NUM_INT) { 886 912 dev_err(&func->dev, "Too many interrupts (%d)...\n", nint); 887 - return -EINVAL; 888 - } 889 - 890 - /** 891 - * Disable power sequencer 892 - **/ 893 - if (wilc_sdio_read_reg(wilc, WILC_MISC, &reg)) { 894 - dev_err(&func->dev, "Failed read misc reg...\n"); 895 - return -EINVAL; 896 - } 897 - 898 - reg &= ~BIT(8); 899 - if (wilc_sdio_write_reg(wilc, WILC_MISC, reg)) { 900 - dev_err(&func->dev, "Failed write misc reg...\n"); 901 913 return -EINVAL; 902 914 } 903 915 ··· 969 1011 .hif_is_init = wilc_sdio_is_init, 970 1012 }; 971 1013 1014 + static int wilc_sdio_suspend(struct device *dev) 1015 + { 1016 + struct sdio_func *func = dev_to_sdio_func(dev); 1017 + struct wilc *wilc = sdio_get_drvdata(func); 1018 + int ret; 1019 + 1020 + dev_info(dev, "sdio suspend\n"); 1021 + 1022 + if (!IS_ERR(wilc->rtc_clk)) 1023 + clk_disable_unprepare(wilc->rtc_clk); 1024 + 1025 + host_sleep_notify(wilc); 1026 + 1027 + wilc_sdio_disable_interrupt(wilc); 1028 + 1029 + ret = wilc_sdio_reset(wilc); 1030 + if (ret) { 1031 + dev_err(&func->dev, "Fail reset sdio\n"); 1032 + return ret; 1033 + } 1034 + 1035 + return 0; 1036 + } 1037 + 972 1038 static int wilc_sdio_resume(struct device *dev) 973 1039 { 974 1040 struct sdio_func *func = dev_to_sdio_func(dev); 975 1041 struct wilc *wilc = sdio_get_drvdata(func); 976 1042 977 1043 dev_info(dev, "sdio resume\n"); 978 - sdio_release_host(func); 979 - chip_wakeup(wilc); 980 1044 wilc_sdio_init(wilc, true); 1045 + wilc_sdio_enable_interrupt(wilc); 981 1046 982 - if (wilc->suspend_event) 983 - host_wakeup_notify(wilc); 984 - 985 - chip_allow_sleep(wilc); 1047 + host_wakeup_notify(wilc); 986 1048 987 1049 return 0; 988 1050 }
+4 -4
drivers/net/wireless/microchip/wilc1000/wlan.c
··· 678 678 679 679 void host_wakeup_notify(struct wilc *wilc) 680 680 { 681 - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); 681 + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); 682 682 wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_2, 1); 683 - release_bus(wilc, WILC_BUS_RELEASE_ONLY); 683 + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); 684 684 } 685 685 EXPORT_SYMBOL_GPL(host_wakeup_notify); 686 686 687 687 void host_sleep_notify(struct wilc *wilc) 688 688 { 689 - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); 689 + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); 690 690 wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_1, 1); 691 - release_bus(wilc, WILC_BUS_RELEASE_ONLY); 691 + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); 692 692 } 693 693 EXPORT_SYMBOL_GPL(host_sleep_notify); 694 694
-1
drivers/net/wireless/microchip/wilc1000/wlan.h
··· 56 56 #define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80) 57 57 #define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84) 58 58 #define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88) 59 - #define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428) 60 59 #define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00) 61 60 #define WILC_INTR_ENABLE WILC_INTR_REG_BASE 62 61 #define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4)
+1 -1
drivers/net/wireless/purelifi/plfxlc/mac.c
··· 111 111 return 0; 112 112 } 113 113 114 - void plfxlc_op_stop(struct ieee80211_hw *hw) 114 + void plfxlc_op_stop(struct ieee80211_hw *hw, bool suspend) 115 115 { 116 116 struct plfxlc_mac *mac = plfxlc_hw_mac(hw); 117 117
+1 -1
drivers/net/wireless/purelifi/plfxlc/mac.h
··· 178 178 void plfxlc_mac_tx_failed(struct urb *urb); 179 179 void plfxlc_mac_tx_to_dev(struct sk_buff *skb, int error); 180 180 int plfxlc_op_start(struct ieee80211_hw *hw); 181 - void plfxlc_op_stop(struct ieee80211_hw *hw); 181 + void plfxlc_op_stop(struct ieee80211_hw *hw, bool suspend); 182 182 int plfxlc_restore_settings(struct plfxlc_mac *mac); 183 183 184 184 #endif /* PLFXLC_MAC_H */
+2 -2
drivers/net/wireless/purelifi/plfxlc/usb.c
··· 408 408 409 409 void plfxlc_usb_release(struct plfxlc_usb *usb) 410 410 { 411 - plfxlc_op_stop(plfxlc_usb_to_hw(usb)); 411 + plfxlc_op_stop(plfxlc_usb_to_hw(usb), false); 412 412 plfxlc_usb_disable_tx(usb); 413 413 plfxlc_usb_disable_rx(usb); 414 414 usb_set_intfdata(usb->intf, NULL); ··· 761 761 762 762 static void plfxlc_usb_stop(struct plfxlc_usb *usb) 763 763 { 764 - plfxlc_op_stop(plfxlc_usb_to_hw(usb)); 764 + plfxlc_op_stop(plfxlc_usb_to_hw(usb), false); 765 765 plfxlc_usb_disable_tx(usb); 766 766 plfxlc_usb_disable_rx(usb); 767 767
+1 -1
drivers/net/wireless/ralink/rt2x00/rt2x00.h
··· 1450 1450 struct ieee80211_tx_control *control, 1451 1451 struct sk_buff *skb); 1452 1452 int rt2x00mac_start(struct ieee80211_hw *hw); 1453 - void rt2x00mac_stop(struct ieee80211_hw *hw); 1453 + void rt2x00mac_stop(struct ieee80211_hw *hw, bool suspend); 1454 1454 void rt2x00mac_reconfig_complete(struct ieee80211_hw *hw, 1455 1455 enum ieee80211_reconfig_type reconfig_type); 1456 1456 int rt2x00mac_add_interface(struct ieee80211_hw *hw,
+1 -1
drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
··· 178 178 } 179 179 EXPORT_SYMBOL_GPL(rt2x00mac_start); 180 180 181 - void rt2x00mac_stop(struct ieee80211_hw *hw) 181 + void rt2x00mac_stop(struct ieee80211_hw *hw, bool suspend) 182 182 { 183 183 struct rt2x00_dev *rt2x00dev = hw->priv; 184 184
+1 -1
drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
··· 1249 1249 return ret; 1250 1250 } 1251 1251 1252 - static void rtl8180_stop(struct ieee80211_hw *dev) 1252 + static void rtl8180_stop(struct ieee80211_hw *dev, bool suspend) 1253 1253 { 1254 1254 struct rtl8180_priv *priv = dev->priv; 1255 1255 u8 reg;
+1 -1
drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
··· 1019 1019 return ret; 1020 1020 } 1021 1021 1022 - static void rtl8187_stop(struct ieee80211_hw *dev) 1022 + static void rtl8187_stop(struct ieee80211_hw *dev, bool suspend) 1023 1023 { 1024 1024 struct rtl8187_priv *priv = dev->priv; 1025 1025 struct sk_buff *skb;
+1 -1
drivers/net/wireless/realtek/rtl8xxxu/core.c
··· 7521 7521 return ret; 7522 7522 } 7523 7523 7524 - static void rtl8xxxu_stop(struct ieee80211_hw *hw) 7524 + static void rtl8xxxu_stop(struct ieee80211_hw *hw, bool suspend) 7525 7525 { 7526 7526 struct rtl8xxxu_priv *priv = hw->priv; 7527 7527 unsigned long flags;
+2 -2
drivers/net/wireless/realtek/rtlwifi/core.c
··· 144 144 return err; 145 145 } 146 146 147 - static void rtl_op_stop(struct ieee80211_hw *hw) 147 + static void rtl_op_stop(struct ieee80211_hw *hw, bool suspend) 148 148 { 149 149 struct rtl_priv *rtlpriv = rtl_priv(hw); 150 150 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); ··· 547 547 rtlhal->enter_pnp_sleep = true; 548 548 549 549 rtl_lps_leave(hw, true); 550 - rtl_op_stop(hw); 550 + rtl_op_stop(hw, false); 551 551 device_set_wakeup_enable(wiphy_dev(hw->wiphy), true); 552 552 return 0; 553 553 }
+1 -1
drivers/net/wireless/realtek/rtw88/mac80211.c
··· 62 62 return ret; 63 63 } 64 64 65 - static void rtw_ops_stop(struct ieee80211_hw *hw) 65 + static void rtw_ops_stop(struct ieee80211_hw *hw, bool suspend) 66 66 { 67 67 struct rtw_dev *rtwdev = hw->priv; 68 68
+1 -1
drivers/net/wireless/realtek/rtw89/mac80211.c
··· 66 66 return ret; 67 67 } 68 68 69 - static void rtw89_ops_stop(struct ieee80211_hw *hw) 69 + static void rtw89_ops_stop(struct ieee80211_hw *hw, bool suspend) 70 70 { 71 71 struct rtw89_dev *rtwdev = hw->priv; 72 72
+2 -1
drivers/net/wireless/rsi/rsi_91x_mac80211.c
··· 410 410 /** 411 411 * rsi_mac80211_stop() - This is the last handler that 802.11 module calls. 412 412 * @hw: Pointer to the ieee80211_hw structure. 413 + * @suspend: true if the this was called from suspend flow. 413 414 * 414 415 * Return: None. 415 416 */ 416 - static void rsi_mac80211_stop(struct ieee80211_hw *hw) 417 + static void rsi_mac80211_stop(struct ieee80211_hw *hw, bool suspend) 417 418 { 418 419 struct rsi_hw *adapter = hw->priv; 419 420 struct rsi_common *common = adapter->priv;
+1 -1
drivers/net/wireless/silabs/wfx/sta.c
··· 805 805 return 0; 806 806 } 807 807 808 - void wfx_stop(struct ieee80211_hw *hw) 808 + void wfx_stop(struct ieee80211_hw *hw, bool suspend) 809 809 { 810 810 struct wfx_dev *wdev = hw->priv; 811 811
+1 -1
drivers/net/wireless/silabs/wfx/sta.h
··· 20 20 21 21 /* mac80211 interface */ 22 22 int wfx_start(struct ieee80211_hw *hw); 23 - void wfx_stop(struct ieee80211_hw *hw); 23 + void wfx_stop(struct ieee80211_hw *hw, bool suspend); 24 24 int wfx_config(struct ieee80211_hw *hw, u32 changed); 25 25 int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value); 26 26 void wfx_set_default_unicast_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int idx);
+1 -1
drivers/net/wireless/st/cw1200/sta.c
··· 90 90 return ret; 91 91 } 92 92 93 - void cw1200_stop(struct ieee80211_hw *dev) 93 + void cw1200_stop(struct ieee80211_hw *dev, bool suspend) 94 94 { 95 95 struct cw1200_common *priv = dev->priv; 96 96 LIST_HEAD(list);
+1 -1
drivers/net/wireless/st/cw1200/sta.h
··· 13 13 /* mac80211 API */ 14 14 15 15 int cw1200_start(struct ieee80211_hw *dev); 16 - void cw1200_stop(struct ieee80211_hw *dev); 16 + void cw1200_stop(struct ieee80211_hw *dev, bool suspend); 17 17 int cw1200_add_interface(struct ieee80211_hw *dev, 18 18 struct ieee80211_vif *vif); 19 19 void cw1200_remove_interface(struct ieee80211_hw *dev,
+1 -1
drivers/net/wireless/ti/wl1251/main.c
··· 415 415 return ret; 416 416 } 417 417 418 - static void wl1251_op_stop(struct ieee80211_hw *hw) 418 + static void wl1251_op_stop(struct ieee80211_hw *hw, bool suspend) 419 419 { 420 420 struct wl1251 *wl = hw->priv; 421 421
+69 -2
drivers/net/wireless/ti/wl18xx/main.c
··· 1177 1177 return ret; 1178 1178 } 1179 1179 1180 - static void wl18xx_convert_fw_status(struct wl1271 *wl, void *raw_fw_status, 1181 - struct wl_fw_status *fw_status) 1180 + static void wl18xx_convert_fw_status_8_9_1(struct wl1271 *wl, 1181 + void *raw_fw_status, 1182 + struct wl_fw_status *fw_status) 1183 + { 1184 + struct wl18xx_fw_status_8_9_1 *int_fw_status = raw_fw_status; 1185 + 1186 + fw_status->intr = le32_to_cpu(int_fw_status->intr); 1187 + fw_status->fw_rx_counter = int_fw_status->fw_rx_counter; 1188 + fw_status->drv_rx_counter = int_fw_status->drv_rx_counter; 1189 + fw_status->tx_results_counter = int_fw_status->tx_results_counter; 1190 + fw_status->rx_pkt_descs = int_fw_status->rx_pkt_descs; 1191 + 1192 + fw_status->fw_localtime = le32_to_cpu(int_fw_status->fw_localtime); 1193 + fw_status->link_ps_bitmap = le32_to_cpu(int_fw_status->link_ps_bitmap); 1194 + fw_status->link_fast_bitmap = 1195 + le32_to_cpu(int_fw_status->link_fast_bitmap); 1196 + fw_status->total_released_blks = 1197 + le32_to_cpu(int_fw_status->total_released_blks); 1198 + fw_status->tx_total = le32_to_cpu(int_fw_status->tx_total); 1199 + 1200 + fw_status->counters.tx_released_pkts = 1201 + int_fw_status->counters.tx_released_pkts; 1202 + fw_status->counters.tx_lnk_free_pkts = 1203 + int_fw_status->counters.tx_lnk_free_pkts; 1204 + fw_status->counters.tx_lnk_sec_pn16 = 1205 + int_fw_status->counters.tx_lnk_sec_pn16; 1206 + fw_status->counters.tx_voice_released_blks = 1207 + int_fw_status->counters.tx_voice_released_blks; 1208 + fw_status->counters.tx_last_rate = 1209 + int_fw_status->counters.tx_last_rate; 1210 + fw_status->counters.tx_last_rate_mbps = 1211 + int_fw_status->counters.tx_last_rate_mbps; 1212 + fw_status->counters.hlid = 1213 + int_fw_status->counters.hlid; 1214 + 1215 + fw_status->log_start_addr = le32_to_cpu(int_fw_status->log_start_addr); 1216 + 1217 + fw_status->priv = &int_fw_status->priv; 1218 + } 1219 + 1220 + static void wl18xx_convert_fw_status_8_9_0(struct wl1271 *wl, 1221 + void *raw_fw_status, 1222 + struct wl_fw_status *fw_status) 1182 1223 { 1183 1224 struct wl18xx_fw_status *int_fw_status = raw_fw_status; 1184 1225 ··· 1253 1212 fw_status->log_start_addr = le32_to_cpu(int_fw_status->log_start_addr); 1254 1213 1255 1214 fw_status->priv = &int_fw_status->priv; 1215 + } 1216 + 1217 + static void wl18xx_convert_fw_status(struct wl1271 *wl, void *raw_fw_status, 1218 + struct wl_fw_status *fw_status) 1219 + { 1220 + if (wl->chip.fw_ver[FW_VER_MAJOR] == 0) 1221 + wl18xx_convert_fw_status_8_9_0(wl, raw_fw_status, fw_status); 1222 + else 1223 + wl18xx_convert_fw_status_8_9_1(wl, raw_fw_status, fw_status); 1256 1224 } 1257 1225 1258 1226 static void wl18xx_set_tx_desc_csum(struct wl1271 *wl, ··· 1565 1515 { 1566 1516 struct wl18xx_static_data_priv *static_data_priv = 1567 1517 (struct wl18xx_static_data_priv *) static_data->priv; 1518 + size_t fw_status_len; 1568 1519 1569 1520 strscpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version, 1570 1521 sizeof(wl->chip.phy_fw_ver_str)); 1571 1522 1572 1523 wl1271_info("PHY firmware version: %s", static_data_priv->phy_version); 1524 + 1525 + /* Adjust the firmware status size according to the firmware version */ 1526 + if (wl->chip.fw_ver[FW_VER_MAJOR] == 0) 1527 + fw_status_len = sizeof(struct wl18xx_fw_status); 1528 + else 1529 + fw_status_len = sizeof(struct wl18xx_fw_status_8_9_1); 1530 + 1531 + if (wl->fw_status_len != fw_status_len) { 1532 + void *new_status = krealloc(wl->raw_fw_status, fw_status_len, 1533 + GFP_KERNEL | __GFP_ZERO); 1534 + if (!new_status) 1535 + return -ENOMEM; 1536 + 1537 + wl->raw_fw_status = new_status; 1538 + wl->fw_status_len = fw_status_len; 1539 + } 1573 1540 1574 1541 return 0; 1575 1542 }
+10 -3
drivers/net/wireless/ti/wl18xx/tx.c
··· 129 129 wl1271_free_tx_id(wl, id); 130 130 } 131 131 132 + static u8 wl18xx_next_tx_idx(u8 idx) 133 + { 134 + if (++idx >= WL18XX_FW_MAX_TX_STATUS_DESC) 135 + idx = 0; 136 + 137 + return idx; 138 + } 139 + 132 140 void wl18xx_tx_immediate_complete(struct wl1271 *wl) 133 141 { 134 142 struct wl18xx_fw_status_priv *status_priv = ··· 169 161 return; 170 162 } 171 163 172 - for (i = priv->last_fw_rls_idx; 173 - i != status_priv->fw_release_idx; 174 - i = (i + 1) % WL18XX_FW_MAX_TX_STATUS_DESC) { 164 + for (i = priv->last_fw_rls_idx; i != status_priv->fw_release_idx; 165 + i = wl18xx_next_tx_idx(i)) { 175 166 wl18xx_tx_complete_packet(wl, 176 167 status_priv->released_tx_desc[i]); 177 168
+61 -1
drivers/net/wireless/ti/wl18xx/wl18xx.h
··· 13 13 /* minimum FW required for driver */ 14 14 #define WL18XX_CHIP_VER 8 15 15 #define WL18XX_IFTYPE_VER 9 16 - #define WL18XX_MAJOR_VER WLCORE_FW_VER_IGNORE 16 + #define WL18XX_MAJOR_VER 0 17 17 #define WL18XX_SUBTYPE_VER WLCORE_FW_VER_IGNORE 18 18 #define WL18XX_MINOR_VER 58 19 19 ··· 148 148 __le32 tx_total; 149 149 150 150 struct wl18xx_fw_packet_counters counters; 151 + 152 + __le32 log_start_addr; 153 + 154 + /* Private status to be used by the lower drivers */ 155 + struct wl18xx_fw_status_priv priv; 156 + } __packed; 157 + 158 + struct wl18xx_fw_packet_counters_8_9_1 { 159 + /* Cumulative counter of released packets per AC */ 160 + u8 tx_released_pkts[NUM_TX_QUEUES]; 161 + 162 + /* Cumulative counter of freed packets per HLID */ 163 + u8 tx_lnk_free_pkts[WL18XX_MAX_LINKS]; 164 + 165 + /* PN16 of last TKIP/AES seq-num per HLID */ 166 + __le16 tx_lnk_sec_pn16[WL18XX_MAX_LINKS]; 167 + 168 + /* Cumulative counter of released Voice memory blocks */ 169 + u8 tx_voice_released_blks; 170 + 171 + /* Tx rate of the last transmitted packet */ 172 + u8 tx_last_rate; 173 + 174 + /* Tx rate or Tx rate estimate pre-calculated by fw in mbps units */ 175 + u8 tx_last_rate_mbps; 176 + 177 + /* hlid for which the rates were reported */ 178 + u8 hlid; 179 + } __packed; 180 + 181 + /* FW status registers */ 182 + struct wl18xx_fw_status_8_9_1 { 183 + __le32 intr; 184 + u8 fw_rx_counter; 185 + u8 drv_rx_counter; 186 + u8 reserved; 187 + u8 tx_results_counter; 188 + __le32 rx_pkt_descs[WL18XX_NUM_RX_DESCRIPTORS]; 189 + 190 + __le32 fw_localtime; 191 + 192 + /* 193 + * A bitmap (where each bit represents a single HLID) 194 + * to indicate if the station is in PS mode. 195 + */ 196 + __le32 link_ps_bitmap; 197 + 198 + /* 199 + * A bitmap (where each bit represents a single HLID) to indicate 200 + * if the station is in Fast mode 201 + */ 202 + __le32 link_fast_bitmap; 203 + 204 + /* Cumulative counter of total released mem blocks since FW-reset */ 205 + __le32 total_released_blks; 206 + 207 + /* Size (in Memory Blocks) of TX pool */ 208 + __le32 tx_total; 209 + 210 + struct wl18xx_fw_packet_counters_8_9_1 counters; 151 211 152 212 __le32 log_start_addr; 153 213
+9
drivers/net/wireless/ti/wlcore/cmd.c
··· 333 333 wl->links[link].wlvif = wlvif; 334 334 335 335 /* 336 + * Take the last sec_pn16 value from the current FW status. On recovery, 337 + * we might not have fw_status yet, and tx_lnk_sec_pn16[] will be NULL. 338 + */ 339 + if (wl->fw_status->counters.tx_lnk_sec_pn16) 340 + wl->links[link].prev_sec_pn16 = 341 + le16_to_cpu(wl->fw_status->counters.tx_lnk_sec_pn16[link]); 342 + 343 + /* 336 344 * Take saved value for total freed packets from wlvif, in case this is 337 345 * recovery/resume 338 346 */ ··· 368 360 369 361 wl->links[*hlid].allocated_pkts = 0; 370 362 wl->links[*hlid].prev_freed_pkts = 0; 363 + wl->links[*hlid].prev_sec_pn16 = 0; 371 364 wl->links[*hlid].ba_bitmap = 0; 372 365 eth_zero_addr(wl->links[*hlid].addr); 373 366
+1 -1
drivers/net/wireless/ti/wlcore/event.c
··· 83 83 /* Copy initial part up to the end of ring buffer */ 84 84 len = min(actual_len, available_len); 85 85 wl12xx_copy_fwlog(wl, &buffer[start_loc], len); 86 - clear_ptr = addr_ptr + start_loc + actual_len; 86 + clear_ptr = addr_ptr + start_loc + len; 87 87 if (clear_ptr == buff_end_ptr) 88 88 clear_ptr = buff_start_ptr; 89 89
+93 -10
drivers/net/wireless/ti/wlcore/main.c
··· 379 379 380 380 static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) 381 381 { 382 + struct wl12xx_vif *wlvifsta; 383 + struct wl12xx_vif *wlvifap; 382 384 struct wl12xx_vif *wlvif; 383 385 u32 old_tx_blk_count = wl->tx_blocks_available; 384 386 int avail, freed_blocks; ··· 394 392 if (ret < 0) 395 393 return ret; 396 394 397 - wlcore_hw_convert_fw_status(wl, wl->raw_fw_status, wl->fw_status); 395 + wlcore_hw_convert_fw_status(wl, wl->raw_fw_status, status); 398 396 399 397 wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, " 400 398 "drv_rx_counter = %d, tx_results_counter = %d)", ··· 412 410 wl->tx_pkts_freed[i] = status->counters.tx_released_pkts[i]; 413 411 } 414 412 413 + /* Find an authorized STA vif */ 414 + wlvifsta = NULL; 415 + wl12xx_for_each_wlvif_sta(wl, wlvif) { 416 + if (wlvif->sta.hlid != WL12XX_INVALID_LINK_ID && 417 + test_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags)) { 418 + wlvifsta = wlvif; 419 + break; 420 + } 421 + } 422 + 423 + /* Find a started AP vif */ 424 + wlvifap = NULL; 425 + wl12xx_for_each_wlvif(wl, wlvif) { 426 + if (wlvif->bss_type == BSS_TYPE_AP_BSS && 427 + wlvif->inconn_count == 0 && 428 + test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { 429 + wlvifap = wlvif; 430 + break; 431 + } 432 + } 415 433 416 434 for_each_set_bit(i, wl->links_map, wl->num_links) { 417 - u8 diff; 435 + u16 diff16, sec_pn16; 436 + u8 diff, tx_lnk_free_pkts; 437 + 418 438 lnk = &wl->links[i]; 419 439 420 440 /* prevent wrap-around in freed-packets counter */ 421 - diff = (status->counters.tx_lnk_free_pkts[i] - 422 - lnk->prev_freed_pkts) & 0xff; 441 + tx_lnk_free_pkts = status->counters.tx_lnk_free_pkts[i]; 442 + diff = (tx_lnk_free_pkts - lnk->prev_freed_pkts) & 0xff; 423 443 424 - if (diff == 0) 444 + if (diff) { 445 + lnk->allocated_pkts -= diff; 446 + lnk->prev_freed_pkts = tx_lnk_free_pkts; 447 + } 448 + 449 + /* Get the current sec_pn16 value if present */ 450 + if (status->counters.tx_lnk_sec_pn16) 451 + sec_pn16 = __le16_to_cpu(status->counters.tx_lnk_sec_pn16[i]); 452 + else 453 + sec_pn16 = 0; 454 + /* prevent wrap-around in pn16 counter */ 455 + diff16 = (sec_pn16 - lnk->prev_sec_pn16) & 0xffff; 456 + 457 + /* FIXME: since free_pkts is a 8-bit counter of packets that 458 + * rolls over, it can become zero. If it is zero, then we 459 + * omit processing below. Is that really correct? 460 + */ 461 + if (tx_lnk_free_pkts <= 0) 425 462 continue; 426 463 427 - lnk->allocated_pkts -= diff; 428 - lnk->prev_freed_pkts = status->counters.tx_lnk_free_pkts[i]; 464 + /* For a station that has an authorized link: */ 465 + if (wlvifsta && wlvifsta->sta.hlid == i) { 466 + if (wlvifsta->encryption_type == KEY_TKIP || 467 + wlvifsta->encryption_type == KEY_AES) { 468 + if (diff16) { 469 + lnk->prev_sec_pn16 = sec_pn16; 470 + /* accumulate the prev_freed_pkts 471 + * counter according to the PN from 472 + * firmware 473 + */ 474 + lnk->total_freed_pkts += diff16; 475 + } 476 + } else { 477 + if (diff) 478 + /* accumulate the prev_freed_pkts 479 + * counter according to the free packets 480 + * count from firmware 481 + */ 482 + lnk->total_freed_pkts += diff; 483 + } 484 + } 429 485 430 - /* accumulate the prev_freed_pkts counter */ 431 - lnk->total_freed_pkts += diff; 486 + /* For an AP that has been started */ 487 + if (wlvifap && test_bit(i, wlvifap->ap.sta_hlid_map)) { 488 + if (wlvifap->encryption_type == KEY_TKIP || 489 + wlvifap->encryption_type == KEY_AES) { 490 + if (diff16) { 491 + lnk->prev_sec_pn16 = sec_pn16; 492 + /* accumulate the prev_freed_pkts 493 + * counter according to the PN from 494 + * firmware 495 + */ 496 + lnk->total_freed_pkts += diff16; 497 + } 498 + } else { 499 + if (diff) 500 + /* accumulate the prev_freed_pkts 501 + * counter according to the free packets 502 + * count from firmware 503 + */ 504 + lnk->total_freed_pkts += diff; 505 + } 506 + } 432 507 } 433 508 434 509 /* prevent wrap-around in total blocks counter */ ··· 2085 2006 memset(wl->reg_ch_conf_last, 0, sizeof(wl->reg_ch_conf_last)); 2086 2007 } 2087 2008 2088 - static void wlcore_op_stop(struct ieee80211_hw *hw) 2009 + static void wlcore_op_stop(struct ieee80211_hw *hw, bool suspend) 2089 2010 { 2090 2011 struct wl1271 *wl = hw->priv; 2091 2012 ··· 3615 3536 wl1271_error("Could not add or replace key"); 3616 3537 return ret; 3617 3538 } 3539 + 3540 + /* Store AP encryption key type */ 3541 + if (wlvif->bss_type == BSS_TYPE_AP_BSS) 3542 + wlvif->encryption_type = key_type; 3618 3543 3619 3544 /* 3620 3545 * reconfiguring arp response if the unicast (or common)
+4
drivers/net/wireless/ti/wlcore/wlcore_i.h
··· 151 151 */ 152 152 u8 *tx_lnk_free_pkts; 153 153 154 + /* PN16 of last TKIP/AES seq-num per HLID */ 155 + __le16 *tx_lnk_sec_pn16; 156 + 154 157 /* Cumulative counter of released Voice memory blocks */ 155 158 u8 tx_voice_released_blks; 156 159 ··· 262 259 /* accounting for allocated / freed packets in FW */ 263 260 u8 allocated_pkts; 264 261 u8 prev_freed_pkts; 262 + u16 prev_sec_pn16; 265 263 266 264 u8 addr[ETH_ALEN]; 267 265
+2 -1
drivers/net/wireless/virtual/mac80211_hwsim.c
··· 2098 2098 } 2099 2099 2100 2100 2101 - static void mac80211_hwsim_stop(struct ieee80211_hw *hw) 2101 + static void mac80211_hwsim_stop(struct ieee80211_hw *hw, bool suspend) 2102 2102 { 2103 2103 struct mac80211_hwsim_data *data = hw->priv; 2104 2104 int i; ··· 2361 2361 [NL80211_CHAN_WIDTH_4] = "4MHz", 2362 2362 [NL80211_CHAN_WIDTH_8] = "8MHz", 2363 2363 [NL80211_CHAN_WIDTH_16] = "16MHz", 2364 + [NL80211_CHAN_WIDTH_320] = "eht320", 2364 2365 }; 2365 2366 2366 2367 static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
+1 -1
drivers/net/wireless/zydas/zd1211rw/zd_mac.c
··· 326 326 return r; 327 327 } 328 328 329 - void zd_op_stop(struct ieee80211_hw *hw) 329 + void zd_op_stop(struct ieee80211_hw *hw, bool suspend) 330 330 { 331 331 struct zd_mac *mac = zd_hw_mac(hw); 332 332 struct zd_chip *chip = &mac->chip;
+1 -1
drivers/net/wireless/zydas/zd1211rw/zd_mac.h
··· 303 303 void zd_mac_tx_to_dev(struct sk_buff *skb, int error); 304 304 305 305 int zd_op_start(struct ieee80211_hw *hw); 306 - void zd_op_stop(struct ieee80211_hw *hw); 306 + void zd_op_stop(struct ieee80211_hw *hw, bool suspend); 307 307 int zd_restore_settings(struct zd_mac *mac); 308 308 309 309 #ifdef DEBUG
+5 -5
drivers/net/wireless/zydas/zd1211rw/zd_usb.c
··· 1476 1476 { 1477 1477 dev_dbg_f(zd_usb_dev(usb), "\n"); 1478 1478 1479 - zd_op_stop(zd_usb_to_hw(usb)); 1479 + zd_op_stop(zd_usb_to_hw(usb), false); 1480 1480 1481 1481 zd_usb_disable_tx(usb); 1482 1482 zd_usb_disable_rx(usb); ··· 1698 1698 int r, i, req_len, actual_req_len, try_count = 0; 1699 1699 struct usb_device *udev; 1700 1700 struct usb_req_read_regs *req = NULL; 1701 - unsigned long timeout; 1701 + unsigned long time_left; 1702 1702 bool retry = false; 1703 1703 1704 1704 if (count < 1) { ··· 1748 1748 goto error; 1749 1749 } 1750 1750 1751 - timeout = wait_for_completion_timeout(&usb->intr.read_regs.completion, 1752 - msecs_to_jiffies(50)); 1753 - if (!timeout) { 1751 + time_left = wait_for_completion_timeout(&usb->intr.read_regs.completion, 1752 + msecs_to_jiffies(50)); 1753 + if (!time_left) { 1754 1754 disable_read_regs_int(usb); 1755 1755 dev_dbg_f(zd_usb_dev(usb), "read timed out\n"); 1756 1756 r = -ETIMEDOUT;
+1 -1
drivers/staging/vt6655/device_main.c
··· 1339 1339 return ret; 1340 1340 } 1341 1341 1342 - static void vnt_stop(struct ieee80211_hw *hw) 1342 + static void vnt_stop(struct ieee80211_hw *hw, bool suspend) 1343 1343 { 1344 1344 struct vnt_private *priv = hw->priv; 1345 1345
+1 -1
drivers/staging/vt6656/main_usb.c
··· 613 613 return ret; 614 614 } 615 615 616 - static void vnt_stop(struct ieee80211_hw *hw) 616 + static void vnt_stop(struct ieee80211_hw *hw, bool suspend) 617 617 { 618 618 struct vnt_private *priv = hw->priv; 619 619 int i;
-38
include/linux/ieee80211.h
··· 2406 2406 int mcs, bool ext_nss_bw_capable, 2407 2407 unsigned int max_vht_nss); 2408 2408 2409 - /** 2410 - * enum ieee80211_ap_reg_power - regulatory power for a Access Point 2411 - * 2412 - * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power mode 2413 - * @IEEE80211_REG_LPI_AP: Indoor Access Point 2414 - * @IEEE80211_REG_SP_AP: Standard power Access Point 2415 - * @IEEE80211_REG_VLP_AP: Very low power Access Point 2416 - * @IEEE80211_REG_AP_POWER_AFTER_LAST: internal 2417 - * @IEEE80211_REG_AP_POWER_MAX: maximum value 2418 - */ 2419 - enum ieee80211_ap_reg_power { 2420 - IEEE80211_REG_UNSET_AP, 2421 - IEEE80211_REG_LPI_AP, 2422 - IEEE80211_REG_SP_AP, 2423 - IEEE80211_REG_VLP_AP, 2424 - IEEE80211_REG_AP_POWER_AFTER_LAST, 2425 - IEEE80211_REG_AP_POWER_MAX = 2426 - IEEE80211_REG_AP_POWER_AFTER_LAST - 1, 2427 - }; 2428 - 2429 - /** 2430 - * enum ieee80211_client_reg_power - regulatory power for a client 2431 - * 2432 - * @IEEE80211_REG_UNSET_CLIENT: Client has no regulatory power mode 2433 - * @IEEE80211_REG_DEFAULT_CLIENT: Default Client 2434 - * @IEEE80211_REG_SUBORDINATE_CLIENT: Subordinate Client 2435 - * @IEEE80211_REG_CLIENT_POWER_AFTER_LAST: internal 2436 - * @IEEE80211_REG_CLIENT_POWER_MAX: maximum value 2437 - */ 2438 - enum ieee80211_client_reg_power { 2439 - IEEE80211_REG_UNSET_CLIENT, 2440 - IEEE80211_REG_DEFAULT_CLIENT, 2441 - IEEE80211_REG_SUBORDINATE_CLIENT, 2442 - IEEE80211_REG_CLIENT_POWER_AFTER_LAST, 2443 - IEEE80211_REG_CLIENT_POWER_MAX = 2444 - IEEE80211_REG_CLIENT_POWER_AFTER_LAST - 1, 2445 - }; 2446 - 2447 2409 /* 802.11ax HE MAC capabilities */ 2448 2410 #define IEEE80211_HE_MAC_CAP0_HTC_HE 0x01 2449 2411 #define IEEE80211_HE_MAC_CAP0_TWT_REQ 0x02
+120 -57
include/net/cfg80211.h
··· 125 125 * @IEEE80211_CHAN_CAN_MONITOR: This channel can be used for monitor 126 126 * mode even in the presence of other (regulatory) restrictions, 127 127 * even if it is otherwise disabled. 128 + * @IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP: Allow using this channel for AP operation 129 + * with very low power (VLP), even if otherwise set to NO_IR. 128 130 */ 129 131 enum ieee80211_channel_flags { 130 - IEEE80211_CHAN_DISABLED = 1<<0, 131 - IEEE80211_CHAN_NO_IR = 1<<1, 132 - IEEE80211_CHAN_PSD = 1<<2, 133 - IEEE80211_CHAN_RADAR = 1<<3, 134 - IEEE80211_CHAN_NO_HT40PLUS = 1<<4, 135 - IEEE80211_CHAN_NO_HT40MINUS = 1<<5, 136 - IEEE80211_CHAN_NO_OFDM = 1<<6, 137 - IEEE80211_CHAN_NO_80MHZ = 1<<7, 138 - IEEE80211_CHAN_NO_160MHZ = 1<<8, 139 - IEEE80211_CHAN_INDOOR_ONLY = 1<<9, 140 - IEEE80211_CHAN_IR_CONCURRENT = 1<<10, 141 - IEEE80211_CHAN_NO_20MHZ = 1<<11, 142 - IEEE80211_CHAN_NO_10MHZ = 1<<12, 143 - IEEE80211_CHAN_NO_HE = 1<<13, 144 - IEEE80211_CHAN_1MHZ = 1<<14, 145 - IEEE80211_CHAN_2MHZ = 1<<15, 146 - IEEE80211_CHAN_4MHZ = 1<<16, 147 - IEEE80211_CHAN_8MHZ = 1<<17, 148 - IEEE80211_CHAN_16MHZ = 1<<18, 149 - IEEE80211_CHAN_NO_320MHZ = 1<<19, 150 - IEEE80211_CHAN_NO_EHT = 1<<20, 151 - IEEE80211_CHAN_DFS_CONCURRENT = 1<<21, 152 - IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT = 1<<22, 153 - IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT = 1<<23, 154 - IEEE80211_CHAN_CAN_MONITOR = 1<<24, 132 + IEEE80211_CHAN_DISABLED = BIT(0), 133 + IEEE80211_CHAN_NO_IR = BIT(1), 134 + IEEE80211_CHAN_PSD = BIT(2), 135 + IEEE80211_CHAN_RADAR = BIT(3), 136 + IEEE80211_CHAN_NO_HT40PLUS = BIT(4), 137 + IEEE80211_CHAN_NO_HT40MINUS = BIT(5), 138 + IEEE80211_CHAN_NO_OFDM = BIT(6), 139 + IEEE80211_CHAN_NO_80MHZ = BIT(7), 140 + IEEE80211_CHAN_NO_160MHZ = BIT(8), 141 + IEEE80211_CHAN_INDOOR_ONLY = BIT(9), 142 + IEEE80211_CHAN_IR_CONCURRENT = BIT(10), 143 + IEEE80211_CHAN_NO_20MHZ = BIT(11), 144 + IEEE80211_CHAN_NO_10MHZ = BIT(12), 145 + IEEE80211_CHAN_NO_HE = BIT(13), 146 + IEEE80211_CHAN_1MHZ = BIT(14), 147 + IEEE80211_CHAN_2MHZ = BIT(15), 148 + IEEE80211_CHAN_4MHZ = BIT(16), 149 + IEEE80211_CHAN_8MHZ = BIT(17), 150 + IEEE80211_CHAN_16MHZ = BIT(18), 151 + IEEE80211_CHAN_NO_320MHZ = BIT(19), 152 + IEEE80211_CHAN_NO_EHT = BIT(20), 153 + IEEE80211_CHAN_DFS_CONCURRENT = BIT(21), 154 + IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT = BIT(22), 155 + IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT = BIT(23), 156 + IEEE80211_CHAN_CAN_MONITOR = BIT(24), 157 + IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP = BIT(25), 155 158 }; 156 159 157 160 #define IEEE80211_CHAN_NO_HT40 \ ··· 232 229 * @IEEE80211_RATE_SUPPORTS_10MHZ: Rate can be used in 10 MHz mode 233 230 */ 234 231 enum ieee80211_rate_flags { 235 - IEEE80211_RATE_SHORT_PREAMBLE = 1<<0, 236 - IEEE80211_RATE_MANDATORY_A = 1<<1, 237 - IEEE80211_RATE_MANDATORY_B = 1<<2, 238 - IEEE80211_RATE_MANDATORY_G = 1<<3, 239 - IEEE80211_RATE_ERP_G = 1<<4, 240 - IEEE80211_RATE_SUPPORTS_5MHZ = 1<<5, 241 - IEEE80211_RATE_SUPPORTS_10MHZ = 1<<6, 232 + IEEE80211_RATE_SHORT_PREAMBLE = BIT(0), 233 + IEEE80211_RATE_MANDATORY_A = BIT(1), 234 + IEEE80211_RATE_MANDATORY_B = BIT(2), 235 + IEEE80211_RATE_MANDATORY_G = BIT(3), 236 + IEEE80211_RATE_ERP_G = BIT(4), 237 + IEEE80211_RATE_SUPPORTS_5MHZ = BIT(5), 238 + IEEE80211_RATE_SUPPORTS_10MHZ = BIT(6), 242 239 }; 243 240 244 241 /** ··· 1960 1957 * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled 1961 1958 */ 1962 1959 enum bss_param_flags { 1963 - BSS_PARAM_FLAGS_CTS_PROT = 1<<0, 1964 - BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1, 1965 - BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2, 1960 + BSS_PARAM_FLAGS_CTS_PROT = BIT(0), 1961 + BSS_PARAM_FLAGS_SHORT_PREAMBLE = BIT(1), 1962 + BSS_PARAM_FLAGS_SHORT_SLOT_TIME = BIT(2), 1966 1963 }; 1967 1964 1968 1965 /** ··· 2269 2266 * @MONITOR_FLAG_ACTIVE: active monitor, ACKs frames on its MAC address 2270 2267 */ 2271 2268 enum monitor_flags { 2272 - MONITOR_FLAG_CHANGED = 1<<__NL80211_MNTR_FLAG_INVALID, 2273 - MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL, 2274 - MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL, 2275 - MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL, 2276 - MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS, 2277 - MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES, 2278 - MONITOR_FLAG_ACTIVE = 1<<NL80211_MNTR_FLAG_ACTIVE, 2269 + MONITOR_FLAG_CHANGED = BIT(__NL80211_MNTR_FLAG_INVALID), 2270 + MONITOR_FLAG_FCSFAIL = BIT(NL80211_MNTR_FLAG_FCSFAIL), 2271 + MONITOR_FLAG_PLCPFAIL = BIT(NL80211_MNTR_FLAG_PLCPFAIL), 2272 + MONITOR_FLAG_CONTROL = BIT(NL80211_MNTR_FLAG_CONTROL), 2273 + MONITOR_FLAG_OTHER_BSS = BIT(NL80211_MNTR_FLAG_OTHER_BSS), 2274 + MONITOR_FLAG_COOK_FRAMES = BIT(NL80211_MNTR_FLAG_COOK_FRAMES), 2275 + MONITOR_FLAG_ACTIVE = BIT(NL80211_MNTR_FLAG_ACTIVE), 2279 2276 }; 2280 2277 2281 2278 /** ··· 3402 3399 * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum 3403 3400 */ 3404 3401 enum wiphy_params_flags { 3405 - WIPHY_PARAM_RETRY_SHORT = 1 << 0, 3406 - WIPHY_PARAM_RETRY_LONG = 1 << 1, 3407 - WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2, 3408 - WIPHY_PARAM_RTS_THRESHOLD = 1 << 3, 3409 - WIPHY_PARAM_COVERAGE_CLASS = 1 << 4, 3410 - WIPHY_PARAM_DYN_ACK = 1 << 5, 3411 - WIPHY_PARAM_TXQ_LIMIT = 1 << 6, 3412 - WIPHY_PARAM_TXQ_MEMORY_LIMIT = 1 << 7, 3413 - WIPHY_PARAM_TXQ_QUANTUM = 1 << 8, 3402 + WIPHY_PARAM_RETRY_SHORT = BIT(0), 3403 + WIPHY_PARAM_RETRY_LONG = BIT(1), 3404 + WIPHY_PARAM_FRAG_THRESHOLD = BIT(2), 3405 + WIPHY_PARAM_RTS_THRESHOLD = BIT(3), 3406 + WIPHY_PARAM_COVERAGE_CLASS = BIT(4), 3407 + WIPHY_PARAM_DYN_ACK = BIT(5), 3408 + WIPHY_PARAM_TXQ_LIMIT = BIT(6), 3409 + WIPHY_PARAM_TXQ_MEMORY_LIMIT = BIT(7), 3410 + WIPHY_PARAM_TXQ_QUANTUM = BIT(8), 3414 3411 }; 3415 3412 3416 3413 #define IEEE80211_DEFAULT_AIRTIME_WEIGHT 256 ··· 6083 6080 */ 6084 6081 void wiphy_delayed_work_flush(struct wiphy *wiphy, 6085 6082 struct wiphy_delayed_work *dwork); 6083 + 6084 + /** 6085 + * enum ieee80211_ap_reg_power - regulatory power for an Access Point 6086 + * 6087 + * @IEEE80211_REG_UNSET_AP: Access Point has no regulatory power mode 6088 + * @IEEE80211_REG_LPI_AP: Indoor Access Point 6089 + * @IEEE80211_REG_SP_AP: Standard power Access Point 6090 + * @IEEE80211_REG_VLP_AP: Very low power Access Point 6091 + */ 6092 + enum ieee80211_ap_reg_power { 6093 + IEEE80211_REG_UNSET_AP, 6094 + IEEE80211_REG_LPI_AP, 6095 + IEEE80211_REG_SP_AP, 6096 + IEEE80211_REG_VLP_AP, 6097 + }; 6086 6098 6087 6099 /** 6088 6100 * struct wireless_dev - wireless device state ··· 8804 8786 } 8805 8787 8806 8788 /** 8789 + * struct cfg80211_beaconing_check_config - beacon check configuration 8790 + * @iftype: the interface type to check for 8791 + * @relax: allow IR-relaxation conditions to apply (e.g. another 8792 + * interface connected already on the same channel) 8793 + * NOTE: If this is set, wiphy mutex must be held. 8794 + * @reg_power: &enum ieee80211_ap_reg_power value indicating the 8795 + * advertised/used 6 GHz regulatory power setting 8796 + */ 8797 + struct cfg80211_beaconing_check_config { 8798 + enum nl80211_iftype iftype; 8799 + enum ieee80211_ap_reg_power reg_power; 8800 + bool relax; 8801 + }; 8802 + 8803 + /** 8804 + * cfg80211_reg_check_beaconing - check if beaconing is allowed 8805 + * @wiphy: the wiphy 8806 + * @chandef: the channel definition 8807 + * @cfg: additional parameters for the checking 8808 + * 8809 + * Return: %true if there is no secondary channel or the secondary channel(s) 8810 + * can be used for beaconing (i.e. is not a radar channel etc.) 8811 + */ 8812 + bool cfg80211_reg_check_beaconing(struct wiphy *wiphy, 8813 + struct cfg80211_chan_def *chandef, 8814 + struct cfg80211_beaconing_check_config *cfg); 8815 + 8816 + /** 8807 8817 * cfg80211_reg_can_beacon - check if beaconing is allowed 8808 8818 * @wiphy: the wiphy 8809 8819 * @chandef: the channel definition ··· 8840 8794 * Return: %true if there is no secondary channel or the secondary channel(s) 8841 8795 * can be used for beaconing (i.e. is not a radar channel etc.) 8842 8796 */ 8843 - bool cfg80211_reg_can_beacon(struct wiphy *wiphy, 8844 - struct cfg80211_chan_def *chandef, 8845 - enum nl80211_iftype iftype); 8797 + static inline bool 8798 + cfg80211_reg_can_beacon(struct wiphy *wiphy, 8799 + struct cfg80211_chan_def *chandef, 8800 + enum nl80211_iftype iftype) 8801 + { 8802 + struct cfg80211_beaconing_check_config config = { 8803 + .iftype = iftype, 8804 + }; 8805 + 8806 + return cfg80211_reg_check_beaconing(wiphy, chandef, &config); 8807 + } 8846 8808 8847 8809 /** 8848 8810 * cfg80211_reg_can_beacon_relax - check if beaconing is allowed with relaxation ··· 8865 8811 * 8866 8812 * Context: Requires the wiphy mutex to be held. 8867 8813 */ 8868 - bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy, 8869 - struct cfg80211_chan_def *chandef, 8870 - enum nl80211_iftype iftype); 8814 + static inline bool 8815 + cfg80211_reg_can_beacon_relax(struct wiphy *wiphy, 8816 + struct cfg80211_chan_def *chandef, 8817 + enum nl80211_iftype iftype) 8818 + { 8819 + struct cfg80211_beaconing_check_config config = { 8820 + .iftype = iftype, 8821 + .relax = true, 8822 + }; 8823 + 8824 + return cfg80211_reg_check_beaconing(wiphy, chandef, &config); 8825 + } 8871 8826 8872 8827 /** 8873 8828 * cfg80211_ch_switch_notify - update wdev channel and notify userspace
+1 -1
include/net/mac80211.h
··· 4444 4444 struct ieee80211_tx_control *control, 4445 4445 struct sk_buff *skb); 4446 4446 int (*start)(struct ieee80211_hw *hw); 4447 - void (*stop)(struct ieee80211_hw *hw); 4447 + void (*stop)(struct ieee80211_hw *hw, bool suspend); 4448 4448 #ifdef CONFIG_PM 4449 4449 int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); 4450 4450 int (*resume)(struct ieee80211_hw *hw);
+6
include/uapi/linux/nl80211.h
··· 4277 4277 * @NL80211_FREQUENCY_ATTR_CAN_MONITOR: This channel can be used in monitor 4278 4278 * mode despite other (regulatory) restrictions, even if the channel is 4279 4279 * otherwise completely disabled. 4280 + * @NL80211_FREQUENCY_ATTR_ALLOW_6GHZ_VLP_AP: This channel can be used for a 4281 + * very low power (VLP) AP, despite being NO_IR. 4280 4282 * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number 4281 4283 * currently defined 4282 4284 * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use ··· 4322 4320 NL80211_FREQUENCY_ATTR_NO_6GHZ_VLP_CLIENT, 4323 4321 NL80211_FREQUENCY_ATTR_NO_6GHZ_AFC_CLIENT, 4324 4322 NL80211_FREQUENCY_ATTR_CAN_MONITOR, 4323 + NL80211_FREQUENCY_ATTR_ALLOW_6GHZ_VLP_AP, 4325 4324 4326 4325 /* keep last */ 4327 4326 __NL80211_FREQUENCY_ATTR_AFTER_LAST, ··· 4532 4529 * Should be used together with %NL80211_RRF_DFS only. 4533 4530 * @NL80211_RRF_NO_6GHZ_VLP_CLIENT: Client connection to VLP AP not allowed 4534 4531 * @NL80211_RRF_NO_6GHZ_AFC_CLIENT: Client connection to AFC AP not allowed 4532 + * @NL80211_RRF_ALLOW_6GHZ_VLP_AP: Very low power (VLP) AP can be permitted 4533 + * despite NO_IR configuration. 4535 4534 */ 4536 4535 enum nl80211_reg_rule_flags { 4537 4536 NL80211_RRF_NO_OFDM = 1<<0, ··· 4558 4553 NL80211_RRF_DFS_CONCURRENT = 1<<21, 4559 4554 NL80211_RRF_NO_6GHZ_VLP_CLIENT = 1<<22, 4560 4555 NL80211_RRF_NO_6GHZ_AFC_CLIENT = 1<<23, 4556 + NL80211_RRF_ALLOW_6GHZ_VLP_AP = 1<<24, 4561 4557 }; 4562 4558 4563 4559 #define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
+3 -1
net/mac80211/agg-tx.c
··· 616 616 return -EINVAL; 617 617 618 618 if (!pubsta->deflink.ht_cap.ht_supported && 619 - sta->sdata->vif.bss_conf.chanreq.oper.chan->band != NL80211_BAND_6GHZ) 619 + !pubsta->deflink.vht_cap.vht_supported && 620 + !pubsta->deflink.he_cap.has_he && 621 + !pubsta->deflink.eht_cap.has_eht) 620 622 return -EINVAL; 621 623 622 624 if (WARN_ON_ONCE(!local->ops->ampdu_action))
+42 -36
net/mac80211/cfg.c
··· 1615 1615 /* abort any running channel switch or color change */ 1616 1616 link_conf->csa_active = false; 1617 1617 link_conf->color_change_active = false; 1618 - if (sdata->csa_blocked_queues) { 1619 - ieee80211_wake_vif_queues(local, sdata, 1620 - IEEE80211_QUEUE_STOP_REASON_CSA); 1621 - sdata->csa_blocked_queues = false; 1622 - } 1618 + ieee80211_vif_unblock_queues_csa(sdata); 1623 1619 1624 1620 ieee80211_free_next_beacon(link); 1625 1621 ··· 1810 1814 #endif 1811 1815 } 1812 1816 1817 + enum sta_link_apply_mode { 1818 + STA_LINK_MODE_NEW, 1819 + STA_LINK_MODE_STA_MODIFY, 1820 + STA_LINK_MODE_LINK_MODIFY, 1821 + }; 1822 + 1813 1823 static int sta_link_apply_parameters(struct ieee80211_local *local, 1814 - struct sta_info *sta, bool new_link, 1824 + struct sta_info *sta, 1825 + enum sta_link_apply_mode mode, 1815 1826 struct link_station_parameters *params) 1816 1827 { 1817 - int ret = 0; 1818 1828 struct ieee80211_supported_band *sband; 1819 1829 struct ieee80211_sub_if_data *sdata = sta->sdata; 1820 1830 u32 link_id = params->link_id < 0 ? 0 : params->link_id; ··· 1829 1827 struct link_sta_info *link_sta = 1830 1828 rcu_dereference_protected(sta->link[link_id], 1831 1829 lockdep_is_held(&local->hw.wiphy->mtx)); 1830 + bool changes = params->link_mac || 1831 + params->txpwr_set || 1832 + params->supported_rates_len || 1833 + params->ht_capa || 1834 + params->vht_capa || 1835 + params->he_capa || 1836 + params->eht_capa || 1837 + params->opmode_notif_used; 1832 1838 1833 - /* 1834 - * If there are no changes, then accept a link that exist, 1835 - * unless it's a new link. 1836 - */ 1837 - if (params->link_id >= 0 && !new_link && 1838 - !params->link_mac && !params->txpwr_set && 1839 - !params->supported_rates_len && 1840 - !params->ht_capa && !params->vht_capa && 1841 - !params->he_capa && !params->eht_capa && 1842 - !params->opmode_notif_used) 1843 - return 0; 1839 + switch (mode) { 1840 + case STA_LINK_MODE_NEW: 1841 + if (!params->link_mac) 1842 + return -EINVAL; 1843 + break; 1844 + case STA_LINK_MODE_LINK_MODIFY: 1845 + break; 1846 + case STA_LINK_MODE_STA_MODIFY: 1847 + if (params->link_id >= 0) 1848 + break; 1849 + if (!changes) 1850 + return 0; 1851 + break; 1852 + } 1844 1853 1845 1854 if (!link || !link_sta) 1846 1855 return -EINVAL; ··· 1861 1848 return -EINVAL; 1862 1849 1863 1850 if (params->link_mac) { 1864 - if (new_link) { 1851 + if (mode == STA_LINK_MODE_NEW) { 1865 1852 memcpy(link_sta->addr, params->link_mac, ETH_ALEN); 1866 1853 memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN); 1867 1854 } else if (!ether_addr_equal(link_sta->addr, 1868 1855 params->link_mac)) { 1869 1856 return -EINVAL; 1870 1857 } 1871 - } else if (new_link) { 1872 - return -EINVAL; 1873 1858 } 1874 1859 1875 1860 if (params->txpwr_set) { 1861 + int ret; 1862 + 1876 1863 link_sta->pub->txpwr.type = params->txpwr.type; 1877 1864 if (params->txpwr.type == NL80211_TX_POWER_LIMITED) 1878 1865 link_sta->pub->txpwr.power = params->txpwr.power; ··· 1925 1912 1926 1913 ieee80211_sta_init_nss(link_sta); 1927 1914 1928 - return ret; 1915 + return 0; 1929 1916 } 1930 1917 1931 1918 static int sta_apply_parameters(struct ieee80211_local *local, ··· 2041 2028 if (params->listen_interval >= 0) 2042 2029 sta->listen_interval = params->listen_interval; 2043 2030 2044 - ret = sta_link_apply_parameters(local, sta, false, 2031 + ret = sta_link_apply_parameters(local, sta, STA_LINK_MODE_STA_MODIFY, 2045 2032 &params->link_sta_params); 2046 2033 if (ret) 2047 2034 return ret; ··· 3753 3740 3754 3741 ieee80211_link_info_change_notify(sdata, link_data, changed); 3755 3742 3756 - if (sdata->csa_blocked_queues) { 3757 - ieee80211_wake_vif_queues(local, sdata, 3758 - IEEE80211_QUEUE_STOP_REASON_CSA); 3759 - sdata->csa_blocked_queues = false; 3760 - } 3743 + ieee80211_vif_unblock_queues_csa(sdata); 3761 3744 3762 3745 err = drv_post_channel_switch(link_data); 3763 3746 if (err) ··· 4030 4021 link_data->csa.chanreq = chanreq; 4031 4022 link_conf->csa_active = true; 4032 4023 4033 - if (params->block_tx && 4034 - !ieee80211_hw_check(&local->hw, HANDLES_QUIET_CSA)) { 4035 - ieee80211_stop_vif_queues(local, sdata, 4036 - IEEE80211_QUEUE_STOP_REASON_CSA); 4037 - sdata->csa_blocked_queues = true; 4038 - } 4024 + if (params->block_tx) 4025 + ieee80211_vif_block_queues_csa(sdata); 4039 4026 4040 4027 cfg80211_ch_switch_started_notify(sdata->dev, 4041 4028 &link_data->csa.chanreq.oper, link_id, ··· 5010 5005 if (ret) 5011 5006 return ret; 5012 5007 5013 - ret = sta_link_apply_parameters(local, sta, true, params); 5008 + ret = sta_link_apply_parameters(local, sta, STA_LINK_MODE_NEW, params); 5014 5009 if (ret) { 5015 5010 ieee80211_sta_free_link(sta, params->link_id); 5016 5011 return ret; ··· 5037 5032 if (!(sta->sta.valid_links & BIT(params->link_id))) 5038 5033 return -EINVAL; 5039 5034 5040 - return sta_link_apply_parameters(local, sta, false, params); 5035 + return sta_link_apply_parameters(local, sta, STA_LINK_MODE_LINK_MODIFY, 5036 + params); 5041 5037 } 5042 5038 5043 5039 static int
+82 -27
net/mac80211/chan.c
··· 295 295 static enum nl80211_chan_width 296 296 ieee80211_get_chanctx_max_required_bw(struct ieee80211_local *local, 297 297 struct ieee80211_chanctx *ctx, 298 - struct ieee80211_link_data *rsvd_for) 298 + struct ieee80211_link_data *rsvd_for, 299 + bool check_reserved) 299 300 { 300 301 struct ieee80211_sub_if_data *sdata; 301 302 struct ieee80211_link_data *link; 302 303 enum nl80211_chan_width max_bw = NL80211_CHAN_WIDTH_20_NOHT; 303 304 305 + if (WARN_ON(check_reserved && rsvd_for)) 306 + return ctx->conf.def.width; 307 + 304 308 for_each_sdata_link(local, link) { 305 309 enum nl80211_chan_width width = NL80211_CHAN_WIDTH_20_NOHT; 306 310 307 - if (link != rsvd_for && 308 - rcu_access_pointer(link->conf->chanctx_conf) != &ctx->conf) 311 + if (check_reserved) { 312 + if (link->reserved_chanctx != ctx) 313 + continue; 314 + } else if (link != rsvd_for && 315 + rcu_access_pointer(link->conf->chanctx_conf) != &ctx->conf) 309 316 continue; 310 317 311 318 switch (link->sdata->vif.type) { ··· 366 359 static u32 367 360 _ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local, 368 361 struct ieee80211_chanctx *ctx, 369 - struct ieee80211_link_data *rsvd_for) 362 + struct ieee80211_link_data *rsvd_for, 363 + bool check_reserved) 370 364 { 371 365 enum nl80211_chan_width max_bw; 372 366 struct cfg80211_chan_def min_def; ··· 387 379 return 0; 388 380 } 389 381 390 - max_bw = ieee80211_get_chanctx_max_required_bw(local, ctx, rsvd_for); 382 + max_bw = ieee80211_get_chanctx_max_required_bw(local, ctx, rsvd_for, 383 + check_reserved); 391 384 392 385 /* downgrade chandef up to max_bw */ 393 386 min_def = ctx->conf.def; ··· 405 396 return IEEE80211_CHANCTX_CHANGE_MIN_WIDTH; 406 397 } 407 398 408 - /* calling this function is assuming that station vif is updated to 409 - * lates changes by calling ieee80211_link_update_chanreq 410 - */ 411 399 static void ieee80211_chan_bw_change(struct ieee80211_local *local, 412 400 struct ieee80211_chanctx *ctx, 413 - bool narrowed) 401 + bool reserved, bool narrowed) 414 402 { 415 403 struct sta_info *sta; 416 404 struct ieee80211_supported_band *sband = ··· 424 418 continue; 425 419 426 420 for (link_id = 0; link_id < ARRAY_SIZE(sta->sdata->link); link_id++) { 427 - struct ieee80211_bss_conf *link_conf = 428 - rcu_dereference(sdata->vif.link_conf[link_id]); 421 + struct ieee80211_link_data *link = 422 + rcu_dereference(sdata->link[link_id]); 423 + struct ieee80211_bss_conf *link_conf; 424 + struct cfg80211_chan_def *new_chandef; 429 425 struct link_sta_info *link_sta; 430 426 431 - if (!link_conf) 427 + if (!link) 432 428 continue; 429 + 430 + link_conf = link->conf; 433 431 434 432 if (rcu_access_pointer(link_conf->chanctx_conf) != &ctx->conf) 435 433 continue; ··· 442 432 if (!link_sta) 443 433 continue; 444 434 445 - new_sta_bw = ieee80211_sta_cur_vht_bw(link_sta); 435 + if (reserved) 436 + new_chandef = &link->reserved.oper; 437 + else 438 + new_chandef = &link_conf->chanreq.oper; 439 + 440 + new_sta_bw = _ieee80211_sta_cur_vht_bw(link_sta, 441 + new_chandef); 446 442 447 443 /* nothing change */ 448 444 if (new_sta_bw == link_sta->pub->bandwidth) ··· 474 458 */ 475 459 void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local, 476 460 struct ieee80211_chanctx *ctx, 477 - struct ieee80211_link_data *rsvd_for) 461 + struct ieee80211_link_data *rsvd_for, 462 + bool check_reserved) 478 463 { 479 - u32 changed = _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); 464 + u32 changed = _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for, 465 + check_reserved); 480 466 481 467 if (!changed) 482 468 return; 483 469 484 470 /* check is BW narrowed */ 485 - ieee80211_chan_bw_change(local, ctx, true); 471 + ieee80211_chan_bw_change(local, ctx, false, true); 486 472 487 473 drv_change_chanctx(local, ctx, changed); 488 474 489 475 /* check is BW wider */ 490 - ieee80211_chan_bw_change(local, ctx, false); 476 + ieee80211_chan_bw_change(local, ctx, false, false); 491 477 } 492 478 493 479 static void _ieee80211_change_chanctx(struct ieee80211_local *local, ··· 523 505 * due to maybe not returning from it, e.g in case new context was added 524 506 * first time with all parameters up to date. 525 507 */ 526 - ieee80211_chan_bw_change(local, old_ctx, true); 508 + ieee80211_chan_bw_change(local, old_ctx, false, true); 527 509 528 510 if (ieee80211_chanreq_identical(&ctx_req, chanreq)) { 529 - ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); 511 + ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for, false); 530 512 return; 531 513 } 532 514 ··· 547 529 ctx->conf.ap = chanreq->ap; 548 530 549 531 /* check if min chanctx also changed */ 550 - changed |= _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); 532 + changed |= _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for, false); 551 533 552 534 ieee80211_add_wbrf(local, &ctx->conf.def); 553 535 554 536 drv_change_chanctx(local, ctx, changed); 555 537 556 538 /* check if BW is wider */ 557 - ieee80211_chan_bw_change(local, old_ctx, false); 539 + ieee80211_chan_bw_change(local, old_ctx, false, false); 558 540 } 559 541 560 542 static void ieee80211_change_chanctx(struct ieee80211_local *local, ··· 674 656 ctx->conf.rx_chains_dynamic = 1; 675 657 ctx->mode = mode; 676 658 ctx->conf.radar_enabled = false; 677 - _ieee80211_recalc_chanctx_min_def(local, ctx, NULL); 659 + _ieee80211_recalc_chanctx_min_def(local, ctx, NULL, false); 678 660 679 661 return ctx; 680 662 } ··· 793 775 794 776 /* TDLS peers can sometimes affect the chandef width */ 795 777 list_for_each_entry(sta, &local->sta_list, list) { 778 + struct ieee80211_sub_if_data *sdata = sta->sdata; 796 779 struct ieee80211_chan_req tdls_chanreq = {}; 780 + int tdls_link_id; 781 + 797 782 if (!sta->uploaded || 798 783 !test_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW) || 799 784 !test_sta_flag(sta, WLAN_STA_AUTHORIZED) || 800 785 !sta->tdls_chandef.chan) 786 + continue; 787 + 788 + tdls_link_id = ieee80211_tdls_sta_link_id(sta); 789 + link = sdata_dereference(sdata->link[tdls_link_id], sdata); 790 + if (!link) 791 + continue; 792 + 793 + if (rcu_access_pointer(link->conf->chanctx_conf) != conf) 801 794 continue; 802 795 803 796 tdls_chanreq.oper = sta->tdls_chandef; ··· 867 838 868 839 if (new_ctx) { 869 840 /* recalc considering the link we'll use it for now */ 870 - ieee80211_recalc_chanctx_min_def(local, new_ctx, link); 841 + ieee80211_recalc_chanctx_min_def(local, new_ctx, link, false); 871 842 872 843 ret = drv_assign_vif_chanctx(local, sdata, link->conf, new_ctx); 873 844 if (assign_on_failure || !ret) { ··· 890 861 ieee80211_recalc_chanctx_chantype(local, curr_ctx); 891 862 ieee80211_recalc_smps_chanctx(local, curr_ctx); 892 863 ieee80211_recalc_radar_chanctx(local, curr_ctx); 893 - ieee80211_recalc_chanctx_min_def(local, curr_ctx, NULL); 864 + ieee80211_recalc_chanctx_min_def(local, curr_ctx, NULL, false); 894 865 } 895 866 896 867 if (new_ctx && ieee80211_chanctx_num_assigned(local, new_ctx) > 0) { 897 868 ieee80211_recalc_txpower(sdata, false); 898 - ieee80211_recalc_chanctx_min_def(local, new_ctx, NULL); 869 + ieee80211_recalc_chanctx_min_def(local, new_ctx, NULL, false); 899 870 } 900 871 901 872 if (conf) { ··· 1308 1279 if (ieee80211_chanctx_refcount(local, old_ctx) == 0) 1309 1280 ieee80211_free_chanctx(local, old_ctx, false); 1310 1281 1311 - ieee80211_recalc_chanctx_min_def(local, new_ctx, NULL); 1282 + ieee80211_recalc_chanctx_min_def(local, new_ctx, NULL, false); 1312 1283 ieee80211_recalc_smps_chanctx(local, new_ctx); 1313 1284 ieee80211_recalc_radar_chanctx(local, new_ctx); 1314 1285 ··· 1574 1545 goto err; 1575 1546 } 1576 1547 1548 + /* update station rate control and min width before switch */ 1549 + list_for_each_entry(ctx, &local->chanctx_list, list) { 1550 + struct ieee80211_link_data *link; 1551 + 1552 + if (ctx->replace_state != IEEE80211_CHANCTX_REPLACES_OTHER) 1553 + continue; 1554 + 1555 + if (WARN_ON(!ctx->replace_ctx)) { 1556 + err = -EINVAL; 1557 + goto err; 1558 + } 1559 + 1560 + list_for_each_entry(link, &ctx->reserved_links, 1561 + reserved_chanctx_list) { 1562 + if (!ieee80211_link_has_in_place_reservation(link)) 1563 + continue; 1564 + 1565 + ieee80211_chan_bw_change(local, 1566 + ieee80211_link_get_chanctx(link), 1567 + true, true); 1568 + } 1569 + 1570 + ieee80211_recalc_chanctx_min_def(local, ctx, NULL, true); 1571 + } 1572 + 1577 1573 /* 1578 1574 * All necessary vifs are ready. Perform the switch now depending on 1579 1575 * reservations and driver capabilities. ··· 1666 1612 ieee80211_recalc_chanctx_chantype(local, ctx); 1667 1613 ieee80211_recalc_smps_chanctx(local, ctx); 1668 1614 ieee80211_recalc_radar_chanctx(local, ctx); 1669 - ieee80211_recalc_chanctx_min_def(local, ctx, NULL); 1615 + ieee80211_recalc_chanctx_min_def(local, ctx, NULL, false); 1670 1616 1671 1617 list_for_each_entry_safe(link, link_tmp, &ctx->reserved_links, 1672 1618 reserved_chanctx_list) { ··· 1679 1625 link->reserved_chanctx = NULL; 1680 1626 1681 1627 ieee80211_link_chanctx_reservation_complete(link); 1628 + ieee80211_chan_bw_change(local, ctx, false, false); 1682 1629 } 1683 1630 1684 1631 /*
+3 -3
net/mac80211/driver-ops.c
··· 33 33 return ret; 34 34 } 35 35 36 - void drv_stop(struct ieee80211_local *local) 36 + void drv_stop(struct ieee80211_local *local, bool suspend) 37 37 { 38 38 might_sleep(); 39 39 lockdep_assert_wiphy(local->hw.wiphy); ··· 41 41 if (WARN_ON(!local->started)) 42 42 return; 43 43 44 - trace_drv_stop(local); 45 - local->ops->stop(&local->hw); 44 + trace_drv_stop(local, suspend); 45 + local->ops->stop(&local->hw, suspend); 46 46 trace_drv_return_void(local); 47 47 48 48 /* sync away all work on the tasklet before clearing started */
+1 -1
net/mac80211/driver-ops.h
··· 88 88 } 89 89 90 90 int drv_start(struct ieee80211_local *local); 91 - void drv_stop(struct ieee80211_local *local); 91 + void drv_stop(struct ieee80211_local *local, bool suspend); 92 92 93 93 #ifdef CONFIG_PM 94 94 static inline int drv_suspend(struct ieee80211_local *local,
+2 -1
net/mac80211/ibss.c
··· 785 785 err = ieee80211_parse_ch_switch_ie(sdata, elems, 786 786 ifibss->chandef.chan->band, 787 787 vht_cap_info, &conn, 788 - ifibss->bssid, &csa_ie); 788 + ifibss->bssid, false, 789 + &csa_ie); 789 790 /* can't switch to destination channel, fail */ 790 791 if (err < 0) 791 792 goto disconnect;
+23 -5
net/mac80211/ieee80211_i.h
··· 1823 1823 void ieee80211_vif_inc_num_mcast(struct ieee80211_sub_if_data *sdata); 1824 1824 void ieee80211_vif_dec_num_mcast(struct ieee80211_sub_if_data *sdata); 1825 1825 1826 + void ieee80211_vif_block_queues_csa(struct ieee80211_sub_if_data *sdata); 1827 + void ieee80211_vif_unblock_queues_csa(struct ieee80211_sub_if_data *sdata); 1828 + 1826 1829 /* This function returns the number of multicast stations connected to this 1827 1830 * interface. It returns -1 if that number is not tracked, that is for netdevs 1828 1831 * not in AP or AP_VLAN mode or when using 4addr. ··· 2158 2155 const struct ieee80211_vht_cap *vht_cap_ie2, 2159 2156 struct link_sta_info *link_sta); 2160 2157 enum ieee80211_sta_rx_bandwidth 2161 - ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta); 2158 + _ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta, 2159 + struct cfg80211_chan_def *chandef); 2160 + static inline enum ieee80211_sta_rx_bandwidth 2161 + ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta) 2162 + { 2163 + return _ieee80211_sta_cap_rx_bw(link_sta, NULL); 2164 + } 2162 2165 enum ieee80211_sta_rx_bandwidth 2163 - ieee80211_sta_cur_vht_bw(struct link_sta_info *link_sta); 2166 + _ieee80211_sta_cur_vht_bw(struct link_sta_info *link_sta, 2167 + struct cfg80211_chan_def *chandef); 2168 + static inline enum ieee80211_sta_rx_bandwidth 2169 + ieee80211_sta_cur_vht_bw(struct link_sta_info *link_sta) 2170 + { 2171 + return _ieee80211_sta_cur_vht_bw(link_sta, NULL); 2172 + } 2164 2173 void ieee80211_sta_init_nss(struct link_sta_info *link_sta); 2165 2174 enum ieee80211_sta_rx_bandwidth 2166 2175 ieee80211_chan_width_to_rx_bw(enum nl80211_chan_width width); ··· 2230 2215 * @conn: contains information about own capabilities and restrictions 2231 2216 * to decide which channel switch announcements can be accepted 2232 2217 * @bssid: the currently connected bssid (for reporting) 2218 + * @unprot_action: whether the frame was an unprotected frame or not, 2219 + * used for reporting 2233 2220 * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl. 2234 2221 * All of them will be filled with if success only. 2235 2222 * Return: 0 on success, <0 on error and >0 if there is nothing to parse. ··· 2241 2224 enum nl80211_band current_band, 2242 2225 u32 vht_cap_info, 2243 2226 struct ieee80211_conn_settings *conn, 2244 - u8 *bssid, 2227 + u8 *bssid, bool unprot_action, 2245 2228 struct ieee80211_csa_ie *csa_ie); 2246 2229 2247 2230 /* Suspend/resume and hw reconfiguration */ 2248 2231 int ieee80211_reconfig(struct ieee80211_local *local); 2249 - void ieee80211_stop_device(struct ieee80211_local *local); 2232 + void ieee80211_stop_device(struct ieee80211_local *local, bool suspend); 2250 2233 2251 2234 int __ieee80211_suspend(struct ieee80211_hw *hw, 2252 2235 struct cfg80211_wowlan *wowlan); ··· 2624 2607 struct ieee80211_chanctx *chanctx); 2625 2608 void ieee80211_recalc_chanctx_min_def(struct ieee80211_local *local, 2626 2609 struct ieee80211_chanctx *ctx, 2627 - struct ieee80211_link_data *rsvd_for); 2610 + struct ieee80211_link_data *rsvd_for, 2611 + bool check_reserved); 2628 2612 bool ieee80211_is_radar_required(struct ieee80211_local *local); 2629 2613 2630 2614 void ieee80211_dfs_cac_timer_work(struct wiphy *wiphy, struct wiphy_work *work);
+27 -28
net/mac80211/iface.c
··· 544 544 sdata->vif.bss_conf.csa_active = false; 545 545 if (sdata->vif.type == NL80211_IFTYPE_STATION) 546 546 sdata->deflink.u.mgd.csa.waiting_bcn = false; 547 - if (sdata->csa_blocked_queues) { 548 - ieee80211_wake_vif_queues(local, sdata, 549 - IEEE80211_QUEUE_STOP_REASON_CSA); 550 - sdata->csa_blocked_queues = false; 551 - } 547 + ieee80211_vif_unblock_queues_csa(sdata); 552 548 553 549 wiphy_work_cancel(local->hw.wiphy, &sdata->deflink.csa.finalize_work); 554 550 wiphy_work_cancel(local->hw.wiphy, ··· 699 703 wiphy_delayed_work_flush(local->hw.wiphy, &local->scan_work); 700 704 701 705 if (local->open_count == 0) { 702 - ieee80211_stop_device(local); 706 + ieee80211_stop_device(local, false); 703 707 704 708 /* no reconfiguring after stop! */ 705 709 return; ··· 812 816 ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev)); 813 817 } 814 818 815 - static void 816 - ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) 817 - { 818 - dev_fetch_sw_netstats(stats, dev->tstats); 819 - } 820 - 821 819 static int ieee80211_netdev_setup_tc(struct net_device *dev, 822 820 enum tc_setup_type type, void *type_data) 823 821 { ··· 828 838 .ndo_start_xmit = ieee80211_subif_start_xmit, 829 839 .ndo_set_rx_mode = ieee80211_set_multicast_list, 830 840 .ndo_set_mac_address = ieee80211_change_mac, 831 - .ndo_get_stats64 = ieee80211_get_stats64, 832 841 .ndo_setup_tc = ieee80211_netdev_setup_tc, 833 842 }; 834 843 ··· 867 878 .ndo_set_rx_mode = ieee80211_set_multicast_list, 868 879 .ndo_set_mac_address = ieee80211_change_mac, 869 880 .ndo_select_queue = ieee80211_monitor_select_queue, 870 - .ndo_get_stats64 = ieee80211_get_stats64, 871 881 }; 872 882 873 883 static int ieee80211_netdev_fill_forward_path(struct net_device_path_ctx *ctx, ··· 934 946 .ndo_start_xmit = ieee80211_subif_start_xmit_8023, 935 947 .ndo_set_rx_mode = ieee80211_set_multicast_list, 936 948 .ndo_set_mac_address = ieee80211_change_mac, 937 - .ndo_get_stats64 = ieee80211_get_stats64, 938 949 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path, 939 950 .ndo_setup_tc = ieee80211_netdev_setup_tc, 940 951 }; ··· 1433 1446 drv_remove_interface(local, sdata); 1434 1447 err_stop: 1435 1448 if (!local->open_count) 1436 - drv_stop(local); 1449 + drv_stop(local, false); 1437 1450 err_del_bss: 1438 1451 sdata->bss = NULL; 1439 1452 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) ··· 1443 1456 return res; 1444 1457 } 1445 1458 1446 - static void ieee80211_if_free(struct net_device *dev) 1447 - { 1448 - free_percpu(dev->tstats); 1449 - } 1450 - 1451 1459 static void ieee80211_if_setup(struct net_device *dev) 1452 1460 { 1453 1461 ether_setup(dev); ··· 1450 1468 dev->priv_flags |= IFF_NO_QUEUE; 1451 1469 dev->netdev_ops = &ieee80211_dataif_ops; 1452 1470 dev->needs_free_netdev = true; 1453 - dev->priv_destructor = ieee80211_if_free; 1454 1471 } 1455 1472 1456 1473 static void ieee80211_iface_process_skb(struct ieee80211_local *local, ··· 2082 2101 2083 2102 dev_net_set(ndev, wiphy_net(local->hw.wiphy)); 2084 2103 2085 - ndev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 2086 - if (!ndev->tstats) { 2087 - free_netdev(ndev); 2088 - return -ENOMEM; 2089 - } 2104 + ndev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; 2090 2105 2091 2106 ndev->needed_headroom = local->tx_headroom + 2092 2107 4*6 /* four MAC addresses */ ··· 2095 2118 2096 2119 ret = dev_alloc_name(ndev, ndev->name); 2097 2120 if (ret < 0) { 2098 - ieee80211_if_free(ndev); 2099 2121 free_netdev(ndev); 2100 2122 return ret; 2101 2123 } ··· 2338 2362 atomic_dec(&sdata->u.ap.num_mcast_sta); 2339 2363 else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 2340 2364 atomic_dec(&sdata->u.vlan.num_mcast_sta); 2365 + } 2366 + 2367 + void ieee80211_vif_block_queues_csa(struct ieee80211_sub_if_data *sdata) 2368 + { 2369 + struct ieee80211_local *local = sdata->local; 2370 + 2371 + if (ieee80211_hw_check(&local->hw, HANDLES_QUIET_CSA)) 2372 + return; 2373 + 2374 + ieee80211_stop_vif_queues(local, sdata, 2375 + IEEE80211_QUEUE_STOP_REASON_CSA); 2376 + sdata->csa_blocked_queues = true; 2377 + } 2378 + 2379 + void ieee80211_vif_unblock_queues_csa(struct ieee80211_sub_if_data *sdata) 2380 + { 2381 + struct ieee80211_local *local = sdata->local; 2382 + 2383 + if (sdata->csa_blocked_queues) { 2384 + ieee80211_wake_vif_queues(local, sdata, 2385 + IEEE80211_QUEUE_STOP_REASON_CSA); 2386 + sdata->csa_blocked_queues = false; 2387 + } 2341 2388 }
+1 -1
net/mac80211/mesh.c
··· 1312 1312 memset(&params, 0, sizeof(params)); 1313 1313 err = ieee80211_parse_ch_switch_ie(sdata, elems, sband->band, 1314 1314 vht_cap_info, &conn, 1315 - sdata->vif.addr, 1315 + sdata->vif.addr, false, 1316 1316 &csa_ie); 1317 1317 if (err < 0) 1318 1318 return false;
+100 -42
net/mac80211/mlme.c
··· 2166 2166 static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link) 2167 2167 { 2168 2168 struct ieee80211_sub_if_data *sdata = link->sdata; 2169 - struct ieee80211_local *local = sdata->local; 2170 2169 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2171 2170 int ret; 2172 2171 ··· 2173 2174 2174 2175 WARN_ON(!link->conf->csa_active); 2175 2176 2176 - if (sdata->csa_blocked_queues) { 2177 - ieee80211_wake_vif_queues(local, sdata, 2178 - IEEE80211_QUEUE_STOP_REASON_CSA); 2179 - sdata->csa_blocked_queues = false; 2180 - } 2177 + ieee80211_vif_unblock_queues_csa(sdata); 2181 2178 2182 2179 link->conf->csa_active = false; 2183 2180 link->u.mgd.csa.blocked_tx = false; ··· 2237 2242 2238 2243 ieee80211_link_unreserve_chanctx(link); 2239 2244 2240 - if (sdata->csa_blocked_queues) { 2241 - ieee80211_wake_vif_queues(local, sdata, 2242 - IEEE80211_QUEUE_STOP_REASON_CSA); 2243 - sdata->csa_blocked_queues = false; 2244 - } 2245 + ieee80211_vif_unblock_queues_csa(sdata); 2245 2246 2246 2247 link->conf->csa_active = false; 2247 2248 link->u.mgd.csa.blocked_tx = false; ··· 2352 2361 enum ieee80211_csa_source { 2353 2362 IEEE80211_CSA_SOURCE_BEACON, 2354 2363 IEEE80211_CSA_SOURCE_OTHER_LINK, 2355 - IEEE80211_CSA_SOURCE_ACTION, 2364 + IEEE80211_CSA_SOURCE_PROT_ACTION, 2365 + IEEE80211_CSA_SOURCE_UNPROT_ACTION, 2356 2366 }; 2357 2367 2358 2368 static void ··· 2394 2402 current_band, 2395 2403 bss->vht_cap_info, 2396 2404 &link->u.mgd.conn, 2397 - link->u.mgd.bssid, &csa_ie); 2405 + link->u.mgd.bssid, 2406 + source == IEEE80211_CSA_SOURCE_UNPROT_ACTION, 2407 + &csa_ie); 2398 2408 if (res == 0) { 2399 2409 ch_switch.block_tx = csa_ie.mode; 2400 2410 ch_switch.chandef = csa_ie.chanreq.oper; ··· 2415 2421 res = 1; 2416 2422 } 2417 2423 2418 - if (res < 0) 2424 + if (res < 0) { 2425 + /* ignore this case, not a protected frame */ 2426 + if (source == IEEE80211_CSA_SOURCE_UNPROT_ACTION) 2427 + return; 2419 2428 goto drop_connection; 2429 + } 2420 2430 2421 2431 if (link->conf->csa_active) { 2422 2432 switch (source) { 2423 - case IEEE80211_CSA_SOURCE_ACTION: 2433 + case IEEE80211_CSA_SOURCE_PROT_ACTION: 2434 + case IEEE80211_CSA_SOURCE_UNPROT_ACTION: 2424 2435 /* already processing - disregard action frames */ 2425 2436 return; 2426 2437 case IEEE80211_CSA_SOURCE_BEACON: ··· 2474 2475 } 2475 2476 } 2476 2477 2477 - /* nothing to do at all - no active CSA nor a new one */ 2478 - if (res) 2478 + /* no active CSA nor a new one */ 2479 + if (res) { 2480 + /* 2481 + * However, we may have stopped queues when receiving a public 2482 + * action frame that couldn't be protected, if it had the quiet 2483 + * bit set. This is a trade-off, we want to be quiet as soon as 2484 + * possible, but also don't trust the public action frame much, 2485 + * as it can't be protected. 2486 + */ 2487 + if (unlikely(link->u.mgd.csa.blocked_tx)) { 2488 + link->u.mgd.csa.blocked_tx = false; 2489 + ieee80211_vif_unblock_queues_csa(sdata); 2490 + } 2479 2491 return; 2492 + } 2493 + 2494 + /* 2495 + * We don't really trust public action frames, but block queues (go to 2496 + * quiet mode) for them anyway, we should get a beacon soon to either 2497 + * know what the CSA really is, or figure out the public action frame 2498 + * was actually an attack. 2499 + */ 2500 + if (source == IEEE80211_CSA_SOURCE_UNPROT_ACTION) { 2501 + if (csa_ie.mode) { 2502 + link->u.mgd.csa.blocked_tx = true; 2503 + ieee80211_vif_block_queues_csa(sdata); 2504 + } 2505 + return; 2506 + } 2480 2507 2481 2508 if (link->conf->chanreq.oper.chan->band != 2482 2509 csa_ie.chanreq.oper.chan->band) { ··· 2596 2571 link->u.mgd.beacon_crc_valid = false; 2597 2572 link->u.mgd.csa.blocked_tx = csa_ie.mode; 2598 2573 2599 - if (csa_ie.mode && 2600 - !ieee80211_hw_check(&local->hw, HANDLES_QUIET_CSA)) { 2601 - ieee80211_stop_vif_queues(local, sdata, 2602 - IEEE80211_QUEUE_STOP_REASON_CSA); 2603 - sdata->csa_blocked_queues = true; 2604 - } 2574 + if (csa_ie.mode) 2575 + ieee80211_vif_block_queues_csa(sdata); 2605 2576 2606 2577 cfg80211_ch_switch_started_notify(sdata->dev, &csa_ie.chanreq.oper, 2607 2578 link->link_id, csa_ie.count, ··· 3691 3670 sdata->deflink.u.mgd.csa.blocked_tx = false; 3692 3671 sdata->deflink.u.mgd.csa.waiting_bcn = false; 3693 3672 sdata->deflink.u.mgd.csa.ignored_same_chan = false; 3694 - if (sdata->csa_blocked_queues) { 3695 - ieee80211_wake_vif_queues(local, sdata, 3696 - IEEE80211_QUEUE_STOP_REASON_CSA); 3697 - sdata->csa_blocked_queues = false; 3698 - } 3673 + ieee80211_vif_unblock_queues_csa(sdata); 3699 3674 3700 3675 /* existing TX TSPEC sessions no longer exist */ 3701 3676 memset(ifmgd->tx_tspec, 0, sizeof(ifmgd->tx_tspec)); ··· 4062 4045 sdata->vif.bss_conf.csa_active = false; 4063 4046 sdata->deflink.u.mgd.csa.waiting_bcn = false; 4064 4047 sdata->deflink.u.mgd.csa.blocked_tx = false; 4065 - if (sdata->csa_blocked_queues) { 4066 - ieee80211_wake_vif_queues(local, sdata, 4067 - IEEE80211_QUEUE_STOP_REASON_CSA); 4068 - sdata->csa_blocked_queues = false; 4069 - } 4048 + ieee80211_vif_unblock_queues_csa(sdata); 4070 4049 4071 4050 ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), tx, 4072 4051 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY, ··· 6667 6654 } 6668 6655 } 6669 6656 6657 + static bool ieee80211_mgd_ssid_mismatch(struct ieee80211_sub_if_data *sdata, 6658 + const struct ieee802_11_elems *elems) 6659 + { 6660 + struct ieee80211_vif_cfg *cfg = &sdata->vif.cfg; 6661 + static u8 zero_ssid[IEEE80211_MAX_SSID_LEN]; 6662 + 6663 + if (!elems->ssid) 6664 + return false; 6665 + 6666 + /* hidden SSID: zero length */ 6667 + if (elems->ssid_len == 0) 6668 + return false; 6669 + 6670 + if (elems->ssid_len != cfg->ssid_len) 6671 + return true; 6672 + 6673 + /* hidden SSID: zeroed out */ 6674 + if (memcmp(elems->ssid, zero_ssid, elems->ssid_len)) 6675 + return false; 6676 + 6677 + return memcmp(elems->ssid, cfg->ssid, cfg->ssid_len); 6678 + } 6679 + 6670 6680 static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, 6671 6681 struct ieee80211_hdr *hdr, size_t len, 6672 6682 struct ieee80211_rx_status *rx_status) ··· 6831 6795 elems = ieee802_11_parse_elems_full(&parse_params); 6832 6796 if (!elems) 6833 6797 return; 6798 + 6799 + if (rx_status->flag & RX_FLAG_DECRYPTED && 6800 + ieee80211_mgd_ssid_mismatch(sdata, elems)) { 6801 + sdata_info(sdata, "SSID mismatch for AP %pM, disconnect\n", 6802 + sdata->vif.cfg.ap_addr); 6803 + __ieee80211_disconnect(sdata); 6804 + return; 6805 + } 6806 + 6834 6807 ncrc = elems->crc; 6835 6808 6836 6809 if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && ··· 7461 7416 { 7462 7417 struct ieee80211_link_data *link = &sdata->deflink; 7463 7418 struct ieee80211_rx_status *rx_status; 7419 + struct ieee802_11_elems *elems; 7464 7420 struct ieee80211_mgmt *mgmt; 7465 7421 u16 fc; 7466 7422 int ies_len; ··· 7505 7459 !ether_addr_equal(mgmt->bssid, sdata->vif.cfg.ap_addr)) 7506 7460 break; 7507 7461 7508 - if (mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) { 7509 - struct ieee802_11_elems *elems; 7510 - 7462 + switch (mgmt->u.action.category) { 7463 + case WLAN_CATEGORY_SPECTRUM_MGMT: 7511 7464 ies_len = skb->len - 7512 7465 offsetof(struct ieee80211_mgmt, 7513 7466 u.action.u.chan_switch.variable); ··· 7519 7474 mgmt->u.action.u.chan_switch.variable, 7520 7475 ies_len, true, NULL); 7521 7476 7522 - if (elems && !elems->parse_error) 7477 + if (elems && !elems->parse_error) { 7478 + enum ieee80211_csa_source src = 7479 + IEEE80211_CSA_SOURCE_PROT_ACTION; 7480 + 7523 7481 ieee80211_sta_process_chanswitch(link, 7524 7482 rx_status->mactime, 7525 7483 rx_status->device_timestamp, 7526 7484 elems, elems, 7527 - IEEE80211_CSA_SOURCE_ACTION); 7485 + src); 7486 + } 7528 7487 kfree(elems); 7529 - } else if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) { 7530 - struct ieee802_11_elems *elems; 7531 - 7488 + break; 7489 + case WLAN_CATEGORY_PUBLIC: 7490 + case WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION: 7532 7491 ies_len = skb->len - 7533 7492 offsetof(struct ieee80211_mgmt, 7534 7493 u.action.u.ext_chan_switch.variable); ··· 7549 7500 ies_len, true, NULL); 7550 7501 7551 7502 if (elems && !elems->parse_error) { 7503 + enum ieee80211_csa_source src; 7504 + 7505 + if (mgmt->u.action.category == 7506 + WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION) 7507 + src = IEEE80211_CSA_SOURCE_PROT_ACTION; 7508 + else 7509 + src = IEEE80211_CSA_SOURCE_UNPROT_ACTION; 7510 + 7552 7511 /* for the handling code pretend it was an IE */ 7553 7512 elems->ext_chansw_ie = 7554 7513 &mgmt->u.action.u.ext_chan_switch.data; ··· 7565 7508 rx_status->mactime, 7566 7509 rx_status->device_timestamp, 7567 7510 elems, elems, 7568 - IEEE80211_CSA_SOURCE_ACTION); 7511 + src); 7569 7512 } 7570 7513 7571 7514 kfree(elems); 7515 + break; 7572 7516 } 7573 7517 break; 7574 7518 }
+1 -1
net/mac80211/parse.c
··· 235 235 *cnt_out = count + 1; 236 236 /* separately take 320 MHz if present */ 237 237 if (count == 3 && len > sizeof(*env) + count + 1) { 238 - out[4] = env->variable[count + 2]; 238 + out[4] = env->variable[4]; 239 239 *cnt_out = 5; 240 240 } 241 241 break;
+2 -2
net/mac80211/pm.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 3 * Portions 4 - * Copyright (C) 2020-2021, 2023 Intel Corporation 4 + * Copyright (C) 2020-2021, 2023-2024 Intel Corporation 5 5 */ 6 6 #include <net/mac80211.h> 7 7 #include <net/rtnetlink.h> ··· 171 171 WARN_ON(!list_empty(&local->chanctx_list)); 172 172 173 173 /* stop hardware - this must stop RX */ 174 - ieee80211_stop_device(local); 174 + ieee80211_stop_device(local, true); 175 175 176 176 suspend: 177 177 local->suspended = true;
+1
net/mac80211/rx.c
··· 3617 3617 3618 3618 break; 3619 3619 case WLAN_CATEGORY_PUBLIC: 3620 + case WLAN_CATEGORY_PROTECTED_DUAL_OF_ACTION: 3620 3621 if (len < IEEE80211_MIN_ACTION_SIZE + 1) 3621 3622 goto invalid; 3622 3623 if (sdata->vif.type != NL80211_IFTYPE_STATION)
+9 -6
net/mac80211/spectmgmt.c
··· 223 223 enum nl80211_band current_band, 224 224 u32 vht_cap_info, 225 225 struct ieee80211_conn_settings *conn, 226 - u8 *bssid, 226 + u8 *bssid, bool unprot_action, 227 227 struct ieee80211_csa_ie *csa_ie) 228 228 { 229 229 enum nl80211_band new_band = current_band; ··· 258 258 259 259 if (!ieee80211_operating_class_to_band(new_op_class, &new_band)) { 260 260 new_op_class = 0; 261 - sdata_info(sdata, "cannot understand ECSA IE operating class, %d, ignoring\n", 262 - ext_chansw_elem->new_operating_class); 261 + if (!unprot_action) 262 + sdata_info(sdata, 263 + "cannot understand ECSA IE operating class, %d, ignoring\n", 264 + ext_chansw_elem->new_operating_class); 263 265 } else { 264 266 new_chan_no = ext_chansw_elem->new_ch_num; 265 267 csa_ie->count = ext_chansw_elem->count; ··· 295 293 new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band); 296 294 new_chan = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq); 297 295 if (!new_chan || new_chan->flags & IEEE80211_CHAN_DISABLED) { 298 - sdata_info(sdata, 299 - "BSS %pM switches to unsupported channel (%d MHz), disconnecting\n", 300 - bssid, new_freq); 296 + if (!unprot_action) 297 + sdata_info(sdata, 298 + "BSS %pM switches to unsupported channel (%d MHz), disconnecting\n", 299 + bssid, new_freq); 301 300 return -EINVAL; 302 301 } 303 302
+6
net/mac80211/sta_info.h
··· 727 727 struct ieee80211_sta sta; 728 728 }; 729 729 730 + static inline int ieee80211_tdls_sta_link_id(struct sta_info *sta) 731 + { 732 + /* TDLS STA can only have a single link */ 733 + return sta->sta.valid_links ? __ffs(sta->sta.valid_links) : 0; 734 + } 735 + 730 736 static inline enum nl80211_plink_state sta_plink_state(struct sta_info *sta) 731 737 { 732 738 #ifdef CONFIG_MAC80211_MESH
+12 -3
net/mac80211/trace.h
··· 328 328 TP_printk(LOCAL_PR_FMT " enabled:%d", LOCAL_PR_ARG, __entry->enabled) 329 329 ); 330 330 331 - DEFINE_EVENT(local_only_evt, drv_stop, 332 - TP_PROTO(struct ieee80211_local *local), 333 - TP_ARGS(local) 331 + TRACE_EVENT(drv_stop, 332 + TP_PROTO(struct ieee80211_local *local, bool suspend), 333 + TP_ARGS(local, suspend), 334 + TP_STRUCT__entry( 335 + LOCAL_ENTRY 336 + __field(bool, suspend) 337 + ), 338 + TP_fast_assign( 339 + LOCAL_ASSIGN; 340 + __entry->suspend = suspend; 341 + ), 342 + TP_printk(LOCAL_PR_FMT " suspend:%d", LOCAL_PR_ARG, __entry->suspend) 334 343 ); 335 344 336 345 DEFINE_EVENT(local_sdata_addr_evt, drv_add_interface,
+2 -4
net/mac80211/tx.c
··· 2774 2774 2775 2775 if (tdls_peer) { 2776 2776 /* For TDLS only one link can be valid with peer STA */ 2777 - int tdls_link_id = sta->sta.valid_links ? 2778 - __ffs(sta->sta.valid_links) : 0; 2777 + int tdls_link_id = ieee80211_tdls_sta_link_id(sta); 2779 2778 struct ieee80211_link_data *link; 2780 2779 2781 2780 /* DA SA BSSID */ ··· 3100 3101 case NL80211_IFTYPE_STATION: 3101 3102 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { 3102 3103 /* For TDLS only one link can be valid with peer STA */ 3103 - int tdls_link_id = sta->sta.valid_links ? 3104 - __ffs(sta->sta.valid_links) : 0; 3104 + int tdls_link_id = ieee80211_tdls_sta_link_id(sta); 3105 3105 struct ieee80211_link_data *link; 3106 3106 3107 3107 /* DA SA BSSID */
+3 -3
net/mac80211/util.c
··· 1565 1565 return supp_rates; 1566 1566 } 1567 1567 1568 - void ieee80211_stop_device(struct ieee80211_local *local) 1568 + void ieee80211_stop_device(struct ieee80211_local *local, bool suspend) 1569 1569 { 1570 1570 local_bh_disable(); 1571 1571 ieee80211_handle_queued_frames(local); ··· 1578 1578 1579 1579 flush_workqueue(local->workqueue); 1580 1580 wiphy_work_flush(local->hw.wiphy, NULL); 1581 - drv_stop(local); 1581 + drv_stop(local, suspend); 1582 1582 } 1583 1583 1584 1584 static void ieee80211_flush_completed_scan(struct ieee80211_local *local, ··· 2336 2336 2337 2337 chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, 2338 2338 conf); 2339 - ieee80211_recalc_chanctx_min_def(local, chanctx, NULL); 2339 + ieee80211_recalc_chanctx_min_def(local, chanctx, NULL, false); 2340 2340 } 2341 2341 } 2342 2342
+41 -34
net/mac80211/vht.c
··· 351 351 352 352 /* FIXME: move this to some better location - parses HE/EHT now */ 353 353 enum ieee80211_sta_rx_bandwidth 354 - ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta) 354 + _ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta, 355 + struct cfg80211_chan_def *chandef) 355 356 { 356 357 unsigned int link_id = link_sta->link_id; 357 358 struct ieee80211_sub_if_data *sdata = link_sta->sta->sdata; ··· 362 361 u32 cap_width; 363 362 364 363 if (he_cap->has_he) { 365 - struct ieee80211_bss_conf *link_conf; 366 - enum ieee80211_sta_rx_bandwidth ret; 364 + enum nl80211_band band; 367 365 u8 info; 368 366 369 - rcu_read_lock(); 370 - link_conf = rcu_dereference(sdata->vif.link_conf[link_id]); 367 + if (chandef) { 368 + band = chandef->chan->band; 369 + } else { 370 + struct ieee80211_bss_conf *link_conf; 371 371 372 - if (eht_cap->has_eht && 373 - link_conf->chanreq.oper.chan->band == NL80211_BAND_6GHZ) { 372 + rcu_read_lock(); 373 + link_conf = rcu_dereference(sdata->vif.link_conf[link_id]); 374 + band = link_conf->chanreq.oper.chan->band; 375 + rcu_read_unlock(); 376 + } 377 + 378 + if (eht_cap->has_eht && band == NL80211_BAND_6GHZ) { 374 379 info = eht_cap->eht_cap_elem.phy_cap_info[0]; 375 380 376 - if (info & IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ) { 377 - ret = IEEE80211_STA_RX_BW_320; 378 - goto out; 379 - } 381 + if (info & IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ) 382 + return IEEE80211_STA_RX_BW_320; 380 383 } 381 384 382 385 info = he_cap->he_cap_elem.phy_cap_info[0]; 383 386 384 - if (link_conf->chanreq.oper.chan->band == NL80211_BAND_2GHZ) { 387 + if (band == NL80211_BAND_2GHZ) { 385 388 if (info & IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G) 386 - ret = IEEE80211_STA_RX_BW_40; 387 - else 388 - ret = IEEE80211_STA_RX_BW_20; 389 - goto out; 389 + return IEEE80211_STA_RX_BW_40; 390 + return IEEE80211_STA_RX_BW_20; 390 391 } 391 392 392 393 if (info & IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G || 393 394 info & IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G) 394 - ret = IEEE80211_STA_RX_BW_160; 395 - else if (info & IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G) 396 - ret = IEEE80211_STA_RX_BW_80; 397 - else 398 - ret = IEEE80211_STA_RX_BW_20; 399 - out: 400 - rcu_read_unlock(); 395 + return IEEE80211_STA_RX_BW_160; 401 396 402 - return ret; 397 + if (info & IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G) 398 + return IEEE80211_STA_RX_BW_80; 399 + 400 + return IEEE80211_STA_RX_BW_20; 403 401 } 404 402 405 403 if (!vht_cap->vht_supported) ··· 503 503 504 504 /* FIXME: rename/move - this deals with everything not just VHT */ 505 505 enum ieee80211_sta_rx_bandwidth 506 - ieee80211_sta_cur_vht_bw(struct link_sta_info *link_sta) 506 + _ieee80211_sta_cur_vht_bw(struct link_sta_info *link_sta, 507 + struct cfg80211_chan_def *chandef) 507 508 { 508 509 struct sta_info *sta = link_sta->sta; 509 - struct ieee80211_bss_conf *link_conf; 510 510 enum nl80211_chan_width bss_width; 511 511 enum ieee80211_sta_rx_bandwidth bw; 512 512 513 - rcu_read_lock(); 514 - link_conf = rcu_dereference(sta->sdata->vif.link_conf[link_sta->link_id]); 515 - if (WARN_ON(!link_conf)) 516 - bss_width = NL80211_CHAN_WIDTH_20_NOHT; 517 - else 518 - bss_width = link_conf->chanreq.oper.width; 519 - rcu_read_unlock(); 513 + if (chandef) { 514 + bss_width = chandef->width; 515 + } else { 516 + struct ieee80211_bss_conf *link_conf; 520 517 521 - bw = ieee80211_sta_cap_rx_bw(link_sta); 518 + rcu_read_lock(); 519 + link_conf = rcu_dereference(sta->sdata->vif.link_conf[link_sta->link_id]); 520 + if (WARN_ON_ONCE(!link_conf)) { 521 + rcu_read_unlock(); 522 + return IEEE80211_STA_RX_BW_20; 523 + } 524 + bss_width = link_conf->chanreq.oper.width; 525 + rcu_read_unlock(); 526 + } 527 + 528 + bw = _ieee80211_sta_cap_rx_bw(link_sta, chandef); 522 529 bw = min(bw, link_sta->cur_max_bandwidth); 523 530 524 531 /* Don't consider AP's bandwidth for TDLS peers, section 11.23.1 of
+4 -4
net/rfkill/core.c
··· 546 546 547 547 BUG_ON(!rfkill); 548 548 549 - if (WARN(reason & 550 - ~(RFKILL_HARD_BLOCK_SIGNAL | RFKILL_HARD_BLOCK_NOT_OWNER), 551 - "hw_state reason not supported: 0x%lx", reason)) 552 - return blocked; 549 + if (WARN(reason & ~(RFKILL_HARD_BLOCK_SIGNAL | 550 + RFKILL_HARD_BLOCK_NOT_OWNER), 551 + "hw_state reason not supported: 0x%lx", reason)) 552 + return rfkill_blocked(rfkill); 553 553 554 554 spin_lock_irqsave(&rfkill->lock, flags); 555 555 prev = !!(rfkill->hard_block_reasons & reason);
+85 -35
net/wireless/chan.c
··· 263 263 return nl80211_chan_width_to_mhz(c->width); 264 264 } 265 265 266 + static bool cfg80211_valid_center_freq(u32 center, 267 + enum nl80211_chan_width width) 268 + { 269 + int bw; 270 + int step; 271 + 272 + /* We only do strict verification on 6 GHz */ 273 + if (center < 5955 || center > 7115) 274 + return true; 275 + 276 + bw = nl80211_chan_width_to_mhz(width); 277 + if (bw < 0) 278 + return false; 279 + 280 + /* Validate that the channels bw is entirely within the 6 GHz band */ 281 + if (center - bw / 2 < 5945 || center + bw / 2 > 7125) 282 + return false; 283 + 284 + /* With 320 MHz the permitted channels overlap */ 285 + if (bw == 320) 286 + step = 160; 287 + else 288 + step = bw; 289 + 290 + /* 291 + * Valid channels are packed from lowest frequency towards higher ones. 292 + * So test that the lower frequency alignes with one of these steps. 293 + */ 294 + return (center - bw / 2 - 5945) % step == 0; 295 + } 296 + 266 297 bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef) 267 298 { 268 299 u32 control_freq, oper_freq; ··· 404 373 default: 405 374 return false; 406 375 } 376 + 377 + if (!cfg80211_valid_center_freq(chandef->center_freq1, chandef->width)) 378 + return false; 379 + 380 + if (chandef->width == NL80211_CHAN_WIDTH_80P80 && 381 + !cfg80211_valid_center_freq(chandef->center_freq2, chandef->width)) 382 + return false; 407 383 408 384 /* channel 14 is only for IEEE 802.11b */ 409 385 if (chandef->center_freq1 == 2484 && ··· 1183 1145 1184 1146 static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy, 1185 1147 u32 center_freq, u32 bandwidth, 1186 - u32 prohibited_flags, bool monitor) 1148 + u32 prohibited_flags, 1149 + u32 permitting_flags) 1187 1150 { 1188 1151 struct ieee80211_channel *c; 1189 1152 u32 freq, start_freq, end_freq; ··· 1196 1157 c = ieee80211_get_channel_khz(wiphy, freq); 1197 1158 if (!c) 1198 1159 return false; 1199 - if (monitor && c->flags & IEEE80211_CHAN_CAN_MONITOR) 1160 + if (c->flags & permitting_flags) 1200 1161 continue; 1201 1162 if (c->flags & prohibited_flags) 1202 1163 return false; ··· 1260 1221 1261 1222 bool _cfg80211_chandef_usable(struct wiphy *wiphy, 1262 1223 const struct cfg80211_chan_def *chandef, 1263 - u32 prohibited_flags, bool monitor) 1224 + u32 prohibited_flags, 1225 + u32 permitting_flags) 1264 1226 { 1265 1227 struct ieee80211_sta_ht_cap *ht_cap; 1266 1228 struct ieee80211_sta_vht_cap *vht_cap; ··· 1423 1383 1424 1384 if (!cfg80211_secondary_chans_ok(wiphy, 1425 1385 ieee80211_chandef_to_khz(chandef), 1426 - width, prohibited_flags, monitor)) 1386 + width, prohibited_flags, 1387 + permitting_flags)) 1427 1388 return false; 1428 1389 1429 1390 if (!chandef->center_freq2) 1430 1391 return true; 1431 1392 return cfg80211_secondary_chans_ok(wiphy, 1432 1393 MHZ_TO_KHZ(chandef->center_freq2), 1433 - width, prohibited_flags, monitor); 1394 + width, prohibited_flags, 1395 + permitting_flags); 1434 1396 } 1435 1397 1436 1398 bool cfg80211_chandef_usable(struct wiphy *wiphy, 1437 1399 const struct cfg80211_chan_def *chandef, 1438 1400 u32 prohibited_flags) 1439 1401 { 1440 - return _cfg80211_chandef_usable(wiphy, chandef, prohibited_flags, 1441 - false); 1402 + return _cfg80211_chandef_usable(wiphy, chandef, prohibited_flags, 0); 1442 1403 } 1443 1404 EXPORT_SYMBOL(cfg80211_chandef_usable); 1444 1405 ··· 1561 1520 static bool _cfg80211_reg_can_beacon(struct wiphy *wiphy, 1562 1521 struct cfg80211_chan_def *chandef, 1563 1522 enum nl80211_iftype iftype, 1564 - bool check_no_ir) 1523 + u32 prohibited_flags, 1524 + u32 permitting_flags) 1565 1525 { 1566 - bool res; 1567 - u32 prohibited_flags = IEEE80211_CHAN_DISABLED; 1526 + bool res, check_radar; 1568 1527 int dfs_required; 1569 1528 1570 - trace_cfg80211_reg_can_beacon(wiphy, chandef, iftype, check_no_ir); 1529 + trace_cfg80211_reg_can_beacon(wiphy, chandef, iftype, 1530 + prohibited_flags, 1531 + permitting_flags); 1571 1532 1572 - if (check_no_ir) 1573 - prohibited_flags |= IEEE80211_CHAN_NO_IR; 1533 + if (!_cfg80211_chandef_usable(wiphy, chandef, 1534 + IEEE80211_CHAN_DISABLED, 0)) 1535 + return false; 1574 1536 1575 1537 dfs_required = cfg80211_chandef_dfs_required(wiphy, chandef, iftype); 1576 - if (dfs_required != 0) 1577 - prohibited_flags |= IEEE80211_CHAN_RADAR; 1538 + check_radar = dfs_required != 0; 1578 1539 1579 1540 if (dfs_required > 0 && 1580 1541 cfg80211_chandef_dfs_available(wiphy, chandef)) { 1581 1542 /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */ 1582 - prohibited_flags = IEEE80211_CHAN_DISABLED; 1543 + prohibited_flags &= ~IEEE80211_CHAN_NO_IR; 1544 + check_radar = false; 1583 1545 } 1584 1546 1585 - res = cfg80211_chandef_usable(wiphy, chandef, prohibited_flags); 1547 + if (check_radar && 1548 + !_cfg80211_chandef_usable(wiphy, chandef, 1549 + IEEE80211_CHAN_RADAR, 0)) 1550 + return false; 1551 + 1552 + res = _cfg80211_chandef_usable(wiphy, chandef, 1553 + prohibited_flags, 1554 + permitting_flags); 1586 1555 1587 1556 trace_cfg80211_return_bool(res); 1588 1557 return res; 1589 1558 } 1590 1559 1591 - bool cfg80211_reg_can_beacon(struct wiphy *wiphy, 1592 - struct cfg80211_chan_def *chandef, 1593 - enum nl80211_iftype iftype) 1594 - { 1595 - return _cfg80211_reg_can_beacon(wiphy, chandef, iftype, true); 1596 - } 1597 - EXPORT_SYMBOL(cfg80211_reg_can_beacon); 1598 - 1599 - bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy, 1600 - struct cfg80211_chan_def *chandef, 1601 - enum nl80211_iftype iftype) 1560 + bool cfg80211_reg_check_beaconing(struct wiphy *wiphy, 1561 + struct cfg80211_chan_def *chandef, 1562 + struct cfg80211_beaconing_check_config *cfg) 1602 1563 { 1603 1564 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 1604 - bool check_no_ir; 1605 - 1606 - lockdep_assert_held(&rdev->wiphy.mtx); 1565 + u32 permitting_flags = 0; 1566 + bool check_no_ir = true; 1607 1567 1608 1568 /* 1609 1569 * Under certain conditions suggested by some regulatory bodies a ··· 1612 1570 * only if such relaxations are not enabled and the conditions are not 1613 1571 * met. 1614 1572 */ 1615 - check_no_ir = !cfg80211_ir_permissive_chan(wiphy, iftype, 1616 - chandef->chan); 1573 + if (cfg->relax) { 1574 + lockdep_assert_held(&rdev->wiphy.mtx); 1575 + check_no_ir = !cfg80211_ir_permissive_chan(wiphy, cfg->iftype, 1576 + chandef->chan); 1577 + } 1617 1578 1618 - return _cfg80211_reg_can_beacon(wiphy, chandef, iftype, check_no_ir); 1579 + if (cfg->reg_power == IEEE80211_REG_VLP_AP) 1580 + permitting_flags |= IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP; 1581 + 1582 + return _cfg80211_reg_can_beacon(wiphy, chandef, cfg->iftype, 1583 + check_no_ir ? IEEE80211_CHAN_NO_IR : 0, 1584 + permitting_flags); 1619 1585 } 1620 - EXPORT_SYMBOL(cfg80211_reg_can_beacon_relax); 1586 + EXPORT_SYMBOL(cfg80211_reg_check_beaconing); 1621 1587 1622 1588 int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, 1623 1589 struct cfg80211_chan_def *chandef)
+6 -1
net/wireless/core.h
··· 494 494 bool primary_only); 495 495 bool _cfg80211_chandef_usable(struct wiphy *wiphy, 496 496 const struct cfg80211_chan_def *chandef, 497 - u32 prohibited_flags, bool monitor); 497 + u32 prohibited_flags, 498 + u32 permitting_flags); 498 499 499 500 static inline unsigned int elapsed_jiffies_msecs(unsigned long start) 500 501 { ··· 533 532 cfg80211_bss_update(struct cfg80211_registered_device *rdev, 534 533 struct cfg80211_internal_bss *tmp, 535 534 bool signal_valid, unsigned long ts); 535 + 536 + enum ieee80211_ap_reg_power 537 + cfg80211_get_6ghz_power_type(const u8 *elems, size_t elems_len); 538 + 536 539 #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS 537 540 #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond) 538 541 #else
+30 -5
net/wireless/nl80211.c
··· 315 315 [NL80211_PMSR_FTM_REQ_ATTR_BURST_PERIOD] = { .type = NLA_U16 }, 316 316 [NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION] = 317 317 NLA_POLICY_MAX(NLA_U8, 15), 318 - [NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST] = 319 - NLA_POLICY_MAX(NLA_U8, 31), 318 + [NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST] = { .type = NLA_U8 }, 320 319 [NL80211_PMSR_FTM_REQ_ATTR_NUM_FTMR_RETRIES] = { .type = NLA_U8 }, 321 320 [NL80211_PMSR_FTM_REQ_ATTR_REQUEST_LCI] = { .type = NLA_FLAG }, 322 321 [NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC] = { .type = NLA_FLAG }, ··· 1206 1207 goto nla_put_failure; 1207 1208 if ((chan->flags & IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT) && 1208 1209 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_6GHZ_AFC_CLIENT)) 1210 + goto nla_put_failure; 1211 + if ((chan->flags & IEEE80211_CHAN_CAN_MONITOR) && 1212 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_CAN_MONITOR)) 1213 + goto nla_put_failure; 1214 + if ((chan->flags & IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP) && 1215 + nla_put_flag(msg, NL80211_FREQUENCY_ATTR_ALLOW_6GHZ_VLP_AP)) 1209 1216 goto nla_put_failure; 1210 1217 } 1211 1218 ··· 3353 3348 3354 3349 if (!_cfg80211_chandef_usable(&rdev->wiphy, chandef, 3355 3350 IEEE80211_CHAN_DISABLED, 3356 - monitor)) { 3351 + monitor ? IEEE80211_CHAN_CAN_MONITOR : 0)) { 3357 3352 NL_SET_ERR_MSG(extack, "(extension) channel is disabled"); 3358 3353 return -EINVAL; 3359 3354 } ··· 5960 5955 static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) 5961 5956 { 5962 5957 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 5958 + struct cfg80211_beaconing_check_config beacon_check = {}; 5963 5959 unsigned int link_id = nl80211_link_id(info->attrs); 5964 5960 struct net_device *dev = info->user_ptr[1]; 5965 5961 struct wireless_dev *wdev = dev->ieee80211_ptr; ··· 6110 6104 goto out; 6111 6105 } 6112 6106 6113 - if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &params->chandef, 6114 - wdev->iftype)) { 6107 + beacon_check.iftype = wdev->iftype; 6108 + beacon_check.relax = true; 6109 + beacon_check.reg_power = 6110 + cfg80211_get_6ghz_power_type(params->beacon.tail, 6111 + params->beacon.tail_len); 6112 + if (!cfg80211_reg_check_beaconing(&rdev->wiphy, &params->chandef, 6113 + &beacon_check)) { 6115 6114 err = -EINVAL; 6116 6115 goto out; 6117 6116 } ··· 6273 6262 static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) 6274 6263 { 6275 6264 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 6265 + struct cfg80211_beaconing_check_config beacon_check = {}; 6276 6266 unsigned int link_id = nl80211_link_id(info->attrs); 6277 6267 struct net_device *dev = info->user_ptr[1]; 6278 6268 struct wireless_dev *wdev = dev->ieee80211_ptr; ··· 6299 6287 info->extack); 6300 6288 if (err) 6301 6289 goto out; 6290 + 6291 + /* recheck beaconing is permitted with possibly changed power type */ 6292 + beacon_check.iftype = wdev->iftype; 6293 + beacon_check.relax = true; 6294 + beacon_check.reg_power = 6295 + cfg80211_get_6ghz_power_type(params->beacon.tail, 6296 + params->beacon.tail_len); 6297 + if (!cfg80211_reg_check_beaconing(&rdev->wiphy, 6298 + &wdev->links[link_id].ap.chandef, 6299 + &beacon_check)) { 6300 + err = -EINVAL; 6301 + goto out; 6302 + } 6302 6303 6303 6304 attr = info->attrs[NL80211_ATTR_FILS_DISCOVERY]; 6304 6305 if (attr) {
+9 -1
net/wireless/pmsr.c
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 - * Copyright (C) 2018 - 2021, 2023 Intel Corporation 3 + * Copyright (C) 2018 - 2021, 2023 - 2024 Intel Corporation 4 4 */ 5 5 #include <net/cfg80211.h> 6 6 #include "core.h" ··· 146 146 NL_SET_ERR_MSG(info->extack, 147 147 "FTM: can't set both trigger based and non trigger based"); 148 148 return -EINVAL; 149 + } 150 + 151 + if (out->ftm.ftms_per_burst > 31 && !out->ftm.non_trigger_based && 152 + !out->ftm.trigger_based) { 153 + NL_SET_ERR_MSG_ATTR(info->extack, 154 + tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST], 155 + "FTM: FTMs per burst must be set lower than 31"); 156 + return -ERANGE; 149 157 } 150 158 151 159 if ((out->ftm.trigger_based || out->ftm.non_trigger_based) &&
+21 -35
net/wireless/rdev-ops.h
··· 578 578 static inline int 579 579 rdev_set_wiphy_params(struct cfg80211_registered_device *rdev, u32 changed) 580 580 { 581 - int ret; 582 - 583 - if (!rdev->ops->set_wiphy_params) 584 - return -EOPNOTSUPP; 581 + int ret = -EOPNOTSUPP; 585 582 586 583 trace_rdev_set_wiphy_params(&rdev->wiphy, changed); 587 - ret = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); 584 + if (rdev->ops->set_wiphy_params) 585 + ret = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); 588 586 trace_rdev_return_int(&rdev->wiphy, ret); 589 587 return ret; 590 588 } ··· 1423 1425 struct cfg80211_chan_def *chandef) 1424 1426 { 1425 1427 struct wiphy *wiphy = &rdev->wiphy; 1426 - int ret; 1427 - 1428 - if (!rdev->ops->set_radar_background) 1429 - return -EOPNOTSUPP; 1428 + int ret = -EOPNOTSUPP; 1430 1429 1431 1430 trace_rdev_set_radar_background(wiphy, chandef); 1432 - ret = rdev->ops->set_radar_background(wiphy, chandef); 1431 + if (rdev->ops->set_radar_background) 1432 + ret = rdev->ops->set_radar_background(wiphy, chandef); 1433 1433 trace_rdev_return_int(wiphy, ret); 1434 1434 1435 1435 return ret; ··· 1464 1468 struct net_device *dev, 1465 1469 struct link_station_parameters *params) 1466 1470 { 1467 - int ret; 1468 - 1469 - if (!rdev->ops->add_link_station) 1470 - return -EOPNOTSUPP; 1471 + int ret = -EOPNOTSUPP; 1471 1472 1472 1473 trace_rdev_add_link_station(&rdev->wiphy, dev, params); 1473 - ret = rdev->ops->add_link_station(&rdev->wiphy, dev, params); 1474 + if (rdev->ops->add_link_station) 1475 + ret = rdev->ops->add_link_station(&rdev->wiphy, dev, params); 1474 1476 trace_rdev_return_int(&rdev->wiphy, ret); 1475 1477 return ret; 1476 1478 } ··· 1478 1484 struct net_device *dev, 1479 1485 struct link_station_parameters *params) 1480 1486 { 1481 - int ret; 1482 - 1483 - if (!rdev->ops->mod_link_station) 1484 - return -EOPNOTSUPP; 1487 + int ret = -EOPNOTSUPP; 1485 1488 1486 1489 trace_rdev_mod_link_station(&rdev->wiphy, dev, params); 1487 - ret = rdev->ops->mod_link_station(&rdev->wiphy, dev, params); 1490 + if (rdev->ops->mod_link_station) 1491 + ret = rdev->ops->mod_link_station(&rdev->wiphy, dev, params); 1488 1492 trace_rdev_return_int(&rdev->wiphy, ret); 1489 1493 return ret; 1490 1494 } ··· 1492 1500 struct net_device *dev, 1493 1501 struct link_station_del_parameters *params) 1494 1502 { 1495 - int ret; 1496 - 1497 - if (!rdev->ops->del_link_station) 1498 - return -EOPNOTSUPP; 1503 + int ret = -EOPNOTSUPP; 1499 1504 1500 1505 trace_rdev_del_link_station(&rdev->wiphy, dev, params); 1501 - ret = rdev->ops->del_link_station(&rdev->wiphy, dev, params); 1506 + if (rdev->ops->del_link_station) 1507 + ret = rdev->ops->del_link_station(&rdev->wiphy, dev, params); 1502 1508 trace_rdev_return_int(&rdev->wiphy, ret); 1503 1509 return ret; 1504 1510 } ··· 1507 1517 struct cfg80211_set_hw_timestamp *hwts) 1508 1518 { 1509 1519 struct wiphy *wiphy = &rdev->wiphy; 1510 - int ret; 1511 - 1512 - if (!rdev->ops->set_hw_timestamp) 1513 - return -EOPNOTSUPP; 1520 + int ret = -EOPNOTSUPP; 1514 1521 1515 1522 trace_rdev_set_hw_timestamp(wiphy, dev, hwts); 1516 - ret = rdev->ops->set_hw_timestamp(wiphy, dev, hwts); 1523 + if (rdev->ops->set_hw_timestamp) 1524 + ret = rdev->ops->set_hw_timestamp(wiphy, dev, hwts); 1517 1525 trace_rdev_return_int(wiphy, ret); 1518 1526 1519 1527 return ret; ··· 1523 1535 struct cfg80211_ttlm_params *params) 1524 1536 { 1525 1537 struct wiphy *wiphy = &rdev->wiphy; 1526 - int ret; 1527 - 1528 - if (!rdev->ops->set_ttlm) 1529 - return -EOPNOTSUPP; 1538 + int ret = -EOPNOTSUPP; 1530 1539 1531 1540 trace_rdev_set_ttlm(wiphy, dev, params); 1532 - ret = rdev->ops->set_ttlm(wiphy, dev, params); 1541 + if (rdev->ops->set_ttlm) 1542 + ret = rdev->ops->set_ttlm(wiphy, dev, params); 1533 1543 trace_rdev_return_int(wiphy, ret); 1534 1544 1535 1545 return ret;
+2
net/wireless/reg.c
··· 1600 1600 channel_flags |= IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT; 1601 1601 if (rd_flags & NL80211_RRF_PSD) 1602 1602 channel_flags |= IEEE80211_CHAN_PSD; 1603 + if (rd_flags & NL80211_RRF_ALLOW_6GHZ_VLP_AP) 1604 + channel_flags |= IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP; 1603 1605 return channel_flags; 1604 1606 } 1605 1607
+78 -41
net/wireless/scan.c
··· 1604 1604 } 1605 1605 EXPORT_SYMBOL(__cfg80211_get_bss); 1606 1606 1607 - static void rb_insert_bss(struct cfg80211_registered_device *rdev, 1607 + static bool rb_insert_bss(struct cfg80211_registered_device *rdev, 1608 1608 struct cfg80211_internal_bss *bss) 1609 1609 { 1610 1610 struct rb_node **p = &rdev->bss_tree.rb_node; ··· 1620 1620 1621 1621 if (WARN_ON(!cmp)) { 1622 1622 /* will sort of leak this BSS */ 1623 - return; 1623 + return false; 1624 1624 } 1625 1625 1626 1626 if (cmp < 0) ··· 1631 1631 1632 1632 rb_link_node(&bss->rbn, parent, p); 1633 1633 rb_insert_color(&bss->rbn, &rdev->bss_tree); 1634 + return true; 1634 1635 } 1635 1636 1636 1637 static struct cfg80211_internal_bss * ··· 1656 1655 } 1657 1656 1658 1657 return NULL; 1658 + } 1659 + 1660 + static void cfg80211_insert_bss(struct cfg80211_registered_device *rdev, 1661 + struct cfg80211_internal_bss *bss) 1662 + { 1663 + lockdep_assert_held(&rdev->bss_lock); 1664 + 1665 + if (!rb_insert_bss(rdev, bss)) 1666 + return; 1667 + list_add_tail(&bss->list, &rdev->bss_list); 1668 + rdev->bss_entries++; 1669 + } 1670 + 1671 + static void cfg80211_rehash_bss(struct cfg80211_registered_device *rdev, 1672 + struct cfg80211_internal_bss *bss) 1673 + { 1674 + lockdep_assert_held(&rdev->bss_lock); 1675 + 1676 + rb_erase(&bss->rbn, &rdev->bss_tree); 1677 + if (!rb_insert_bss(rdev, bss)) { 1678 + list_del(&bss->list); 1679 + if (!list_empty(&bss->hidden_list)) 1680 + list_del_init(&bss->hidden_list); 1681 + if (!list_empty(&bss->pub.nontrans_list)) 1682 + list_del_init(&bss->pub.nontrans_list); 1683 + rdev->bss_entries--; 1684 + } 1685 + rdev->bss_generation++; 1659 1686 } 1660 1687 1661 1688 static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev, ··· 1998 1969 bss_ref_get(rdev, bss_from_pub(tmp->pub.transmitted_bss)); 1999 1970 } 2000 1971 2001 - list_add_tail(&new->list, &rdev->bss_list); 2002 - rdev->bss_entries++; 2003 - rb_insert_bss(rdev, new); 1972 + cfg80211_insert_bss(rdev, new); 2004 1973 found = new; 2005 1974 } 2006 1975 ··· 2163 2136 u64 cannot_use_reasons; 2164 2137 }; 2165 2138 2166 - static bool cfg80211_6ghz_power_type_valid(const u8 *ie, size_t ielen, 2139 + enum ieee80211_ap_reg_power 2140 + cfg80211_get_6ghz_power_type(const u8 *elems, size_t elems_len) 2141 + { 2142 + const struct ieee80211_he_6ghz_oper *he_6ghz_oper; 2143 + struct ieee80211_he_operation *he_oper; 2144 + const struct element *tmp; 2145 + 2146 + tmp = cfg80211_find_ext_elem(WLAN_EID_EXT_HE_OPERATION, 2147 + elems, elems_len); 2148 + if (!tmp || tmp->datalen < sizeof(*he_oper) + 1 || 2149 + tmp->datalen < ieee80211_he_oper_size(tmp->data + 1)) 2150 + return IEEE80211_REG_UNSET_AP; 2151 + 2152 + he_oper = (void *)&tmp->data[1]; 2153 + he_6ghz_oper = ieee80211_he_6ghz_oper(he_oper); 2154 + 2155 + if (!he_6ghz_oper) 2156 + return IEEE80211_REG_UNSET_AP; 2157 + 2158 + switch (u8_get_bits(he_6ghz_oper->control, 2159 + IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO)) { 2160 + case IEEE80211_6GHZ_CTRL_REG_LPI_AP: 2161 + case IEEE80211_6GHZ_CTRL_REG_INDOOR_LPI_AP: 2162 + return IEEE80211_REG_LPI_AP; 2163 + case IEEE80211_6GHZ_CTRL_REG_SP_AP: 2164 + case IEEE80211_6GHZ_CTRL_REG_INDOOR_SP_AP: 2165 + return IEEE80211_REG_SP_AP; 2166 + case IEEE80211_6GHZ_CTRL_REG_VLP_AP: 2167 + return IEEE80211_REG_VLP_AP; 2168 + default: 2169 + return IEEE80211_REG_UNSET_AP; 2170 + } 2171 + } 2172 + 2173 + static bool cfg80211_6ghz_power_type_valid(const u8 *elems, size_t elems_len, 2167 2174 const u32 flags) 2168 2175 { 2169 - const struct element *tmp; 2170 - struct ieee80211_he_operation *he_oper; 2171 - 2172 - tmp = cfg80211_find_ext_elem(WLAN_EID_EXT_HE_OPERATION, ie, ielen); 2173 - if (tmp && tmp->datalen >= sizeof(*he_oper) + 1 && 2174 - tmp->datalen >= ieee80211_he_oper_size(tmp->data + 1)) { 2175 - const struct ieee80211_he_6ghz_oper *he_6ghz_oper; 2176 - 2177 - he_oper = (void *)&tmp->data[1]; 2178 - he_6ghz_oper = ieee80211_he_6ghz_oper(he_oper); 2179 - 2180 - if (!he_6ghz_oper) 2181 - return false; 2182 - 2183 - switch (u8_get_bits(he_6ghz_oper->control, 2184 - IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO)) { 2185 - case IEEE80211_6GHZ_CTRL_REG_LPI_AP: 2186 - case IEEE80211_6GHZ_CTRL_REG_INDOOR_LPI_AP: 2187 - return true; 2188 - case IEEE80211_6GHZ_CTRL_REG_SP_AP: 2189 - case IEEE80211_6GHZ_CTRL_REG_INDOOR_SP_AP: 2190 - return !(flags & IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT); 2191 - case IEEE80211_6GHZ_CTRL_REG_VLP_AP: 2192 - return !(flags & IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT); 2193 - default: 2194 - return false; 2195 - } 2176 + switch (cfg80211_get_6ghz_power_type(elems, elems_len)) { 2177 + case IEEE80211_REG_LPI_AP: 2178 + return true; 2179 + case IEEE80211_REG_SP_AP: 2180 + return !(flags & IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT); 2181 + case IEEE80211_REG_VLP_AP: 2182 + return !(flags & IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT); 2183 + default: 2184 + return false; 2196 2185 } 2197 - return false; 2198 2186 } 2199 2187 2200 2188 /* Returned bss is reference counted and must be cleaned up appropriately. */ ··· 3391 3349 if (!WARN_ON(!__cfg80211_unlink_bss(rdev, new))) 3392 3350 rdev->bss_generation++; 3393 3351 } 3394 - 3395 - rb_erase(&cbss->rbn, &rdev->bss_tree); 3396 - rb_insert_bss(rdev, cbss); 3397 - rdev->bss_generation++; 3352 + cfg80211_rehash_bss(rdev, cbss); 3398 3353 3399 3354 list_for_each_entry_safe(nontrans_bss, tmp, 3400 3355 &cbss->pub.nontrans_list, 3401 3356 nontrans_list) { 3402 3357 bss = bss_from_pub(nontrans_bss); 3403 3358 bss->pub.channel = chan; 3404 - rb_erase(&bss->rbn, &rdev->bss_tree); 3405 - rb_insert_bss(rdev, bss); 3406 - rdev->bss_generation++; 3359 + cfg80211_rehash_bss(rdev, bss); 3407 3360 } 3408 3361 3409 3362 done:
+2 -2
net/wireless/sme.c
··· 5 5 * (for nl80211's connect() and wext) 6 6 * 7 7 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> 8 - * Copyright (C) 2009, 2020, 2022-2023 Intel Corporation. All rights reserved. 8 + * Copyright (C) 2009, 2020, 2022-2024 Intel Corporation. All rights reserved. 9 9 * Copyright 2017 Intel Deutschland GmbH 10 10 */ 11 11 ··· 130 130 131 131 rdev->scan_req = request; 132 132 133 - err = rdev_scan(rdev, request); 133 + err = cfg80211_scan(rdev); 134 134 if (!err) { 135 135 wdev->conn->state = CFG80211_CONN_SCANNING; 136 136 nl80211_send_scan_start(rdev, wdev);
+11 -11
net/wireless/tests/chan.c
··· 113 113 }, 114 114 }, 115 115 { 116 - .desc = "different primary 160 MHz", 116 + .desc = "different primary 320 MHz", 117 117 .c1 = { 118 118 .width = NL80211_CHAN_WIDTH_320, 119 119 .chan = &chan_6ghz_105, 120 - .center_freq1 = 6475 + 150, 120 + .center_freq1 = 6475 + 110, 121 121 }, 122 122 .c2 = { 123 123 .width = NL80211_CHAN_WIDTH_320, 124 124 .chan = &chan_6ghz_105, 125 - .center_freq1 = 6475 - 10, 125 + .center_freq1 = 6475 - 50, 126 126 }, 127 127 }, 128 128 { ··· 131 131 .c1 = { 132 132 .width = NL80211_CHAN_WIDTH_160, 133 133 .chan = &chan_6ghz_105, 134 - .center_freq1 = 6475 + 70, 134 + .center_freq1 = 6475 + 30, 135 135 }, 136 136 .c2 = { 137 137 .width = NL80211_CHAN_WIDTH_320, 138 138 .chan = &chan_6ghz_105, 139 - .center_freq1 = 6475 - 10, 139 + .center_freq1 = 6475 - 50, 140 140 }, 141 141 .compat = true, 142 142 }, ··· 145 145 .c1 = { 146 146 .width = NL80211_CHAN_WIDTH_160, 147 147 .chan = &chan_6ghz_105, 148 - .center_freq1 = 6475 + 70, 148 + .center_freq1 = 6475 + 30, 149 149 }, 150 150 .c2 = { 151 151 .width = NL80211_CHAN_WIDTH_320, 152 152 .chan = &chan_6ghz_105, 153 - .center_freq1 = 6475 - 10, 153 + .center_freq1 = 6475 - 50, 154 154 .punctured = 0xf, 155 155 }, 156 156 .compat = true, ··· 160 160 .c1 = { 161 161 .width = NL80211_CHAN_WIDTH_160, 162 162 .chan = &chan_6ghz_105, 163 - .center_freq1 = 6475 + 70, 163 + .center_freq1 = 6475 + 30, 164 164 .punctured = 0xc0, 165 165 }, 166 166 .c2 = { 167 167 .width = NL80211_CHAN_WIDTH_320, 168 168 .chan = &chan_6ghz_105, 169 - .center_freq1 = 6475 - 10, 169 + .center_freq1 = 6475 - 50, 170 170 .punctured = 0xc000, 171 171 }, 172 172 .compat = true, ··· 176 176 .c1 = { 177 177 .width = NL80211_CHAN_WIDTH_160, 178 178 .chan = &chan_6ghz_105, 179 - .center_freq1 = 6475 + 70, 179 + .center_freq1 = 6475 + 30, 180 180 .punctured = 0x80, 181 181 }, 182 182 .c2 = { 183 183 .width = NL80211_CHAN_WIDTH_320, 184 184 .chan = &chan_6ghz_105, 185 - .center_freq1 = 6475 - 10, 185 + .center_freq1 = 6475 - 50, 186 186 .punctured = 0xc000, 187 187 }, 188 188 },
+9 -6
net/wireless/trace.h
··· 3389 3389 3390 3390 TRACE_EVENT(cfg80211_reg_can_beacon, 3391 3391 TP_PROTO(struct wiphy *wiphy, struct cfg80211_chan_def *chandef, 3392 - enum nl80211_iftype iftype, bool check_no_ir), 3393 - TP_ARGS(wiphy, chandef, iftype, check_no_ir), 3392 + enum nl80211_iftype iftype, u32 prohibited_flags, 3393 + u32 permitting_flags), 3394 + TP_ARGS(wiphy, chandef, iftype, prohibited_flags, permitting_flags), 3394 3395 TP_STRUCT__entry( 3395 3396 WIPHY_ENTRY 3396 3397 CHAN_DEF_ENTRY 3397 3398 __field(enum nl80211_iftype, iftype) 3398 - __field(bool, check_no_ir) 3399 + __field(u32, prohibited_flags) 3400 + __field(u32, permitting_flags) 3399 3401 ), 3400 3402 TP_fast_assign( 3401 3403 WIPHY_ASSIGN; 3402 3404 CHAN_DEF_ASSIGN(chandef); 3403 3405 __entry->iftype = iftype; 3404 - __entry->check_no_ir = check_no_ir; 3406 + __entry->prohibited_flags = prohibited_flags; 3407 + __entry->permitting_flags = permitting_flags; 3405 3408 ), 3406 - TP_printk(WIPHY_PR_FMT ", " CHAN_DEF_PR_FMT ", iftype=%d check_no_ir=%s", 3409 + TP_printk(WIPHY_PR_FMT ", " CHAN_DEF_PR_FMT ", iftype=%d prohibited_flags=0x%x permitting_flags=0x%x", 3407 3410 WIPHY_PR_ARG, CHAN_DEF_PR_ARG, __entry->iftype, 3408 - BOOL_TO_STR(__entry->check_no_ir)) 3411 + __entry->prohibited_flags, __entry->permitting_flags) 3409 3412 ); 3410 3413 3411 3414 TRACE_EVENT(cfg80211_chandef_dfs_required,
+5 -3
net/wireless/util.c
··· 1504 1504 5120, /* 0.833333... */ 1505 1505 }; 1506 1506 u32 rates_160M[3] = { 960777777, 907400000, 816666666 }; 1507 - u32 rates_969[3] = { 480388888, 453700000, 408333333 }; 1507 + u32 rates_996[3] = { 480388888, 453700000, 408333333 }; 1508 1508 u32 rates_484[3] = { 229411111, 216666666, 195000000 }; 1509 1509 u32 rates_242[3] = { 114711111, 108333333, 97500000 }; 1510 1510 u32 rates_106[3] = { 40000000, 37777777, 34000000 }; ··· 1524 1524 if (WARN_ON_ONCE(rate->nss < 1 || rate->nss > 8)) 1525 1525 return 0; 1526 1526 1527 - if (rate->bw == RATE_INFO_BW_160) 1527 + if (rate->bw == RATE_INFO_BW_160 || 1528 + (rate->bw == RATE_INFO_BW_HE_RU && 1529 + rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_2x996)) 1528 1530 result = rates_160M[rate->he_gi]; 1529 1531 else if (rate->bw == RATE_INFO_BW_80 || 1530 1532 (rate->bw == RATE_INFO_BW_HE_RU && 1531 1533 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_996)) 1532 - result = rates_969[rate->he_gi]; 1534 + result = rates_996[rate->he_gi]; 1533 1535 else if (rate->bw == RATE_INFO_BW_40 || 1534 1536 (rate->bw == RATE_INFO_BW_HE_RU && 1535 1537 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_484))