The restrictions on the host command data chunks (a chunk can be either NOCOPY or DUP, only a single DUP chunk, no COPY chunk after a NOCOPY/DUP one, and the size limit of the copied part) should be unified to all bus types, so that the opmode will face the same policy regardless of the bus. Move these checks out of the PCIe enqueue functions into iwl_trans_send_cmd(). Assisted-by: LLM Reviewed-by: Emmanuel Grumbach Signed-off-by: Miri Korenblit --- .../net/wireless/intel/iwlwifi/iwl-trans.c | 50 +++++++++++++++++-- .../net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 40 +-------------- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 42 +--------------- 3 files changed, 51 insertions(+), 81 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c index 5c38297dd4df..ff44ce35f703 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c @@ -300,6 +300,46 @@ void iwl_trans_free(struct iwl_trans *trans) cancel_delayed_work_sync(&trans->restart.wk); } +static int iwl_trans_validate_hcmd(struct iwl_trans *trans, + const struct iwl_host_cmd *cmd) +{ + u32 copy_size = iwl_cmd_groupid(cmd->id) ? + sizeof(struct iwl_cmd_header_wide) : + sizeof(struct iwl_cmd_header); + bool had_nocopy = false; + bool had_dup = false; + + for (int i = 0; i < IWL_MAX_CMD_CHUNKS_PER_HCMD; i++) { + if (!cmd->len[i]) + continue; + + if (cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY) { + if (WARN_ON(cmd->dataflags[i] & IWL_HCMD_DFL_DUP)) + return -EINVAL; + had_nocopy = true; + } else if (cmd->dataflags[i] & IWL_HCMD_DFL_DUP) { + /* only allowed once */ + if (WARN_ON(had_dup)) + return -EINVAL; + /* also not copied to the static buffer */ + had_nocopy = true; + had_dup = true; + } else { + /* NOCOPY/DUP must not be followed by normal! */ + if (WARN_ON(had_nocopy)) + return -EINVAL; + copy_size += cmd->len[i]; + } + } + + if (WARN(copy_size > TFD_MAX_PAYLOAD_SIZE, + "Command %s (%#x) is too large (%u bytes)\n", + iwl_get_cmd_string(trans, cmd->id), cmd->id, copy_size)) + return -EINVAL; + + return 0; +} + int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) { int ret; @@ -318,14 +358,18 @@ int iwl_trans_send_cmd(struct iwl_trans *trans, struct iwl_host_cmd *cmd) "bad state = %d\n", trans->state)) return -EIO; - if (!(cmd->flags & CMD_ASYNC)) - lock_map_acquire_read(&trans->sync_cmd_lockdep_map); - if (trans->conf.wide_cmd_header && !iwl_cmd_groupid(cmd->id)) { if (cmd->id != REPLY_ERROR) cmd->id = DEF_ID(cmd->id); } + ret = iwl_trans_validate_hcmd(trans, cmd); + if (ret) + return ret; + + if (!(cmd->flags & CMD_ASYNC)) + lock_map_acquire_read(&trans->sync_cmd_lockdep_map); + ret = trans->ops->send_cmd(trans, cmd); if (!(cmd->flags & CMD_ASYNC)) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c index d9e29b5f8297..317cfccc6426 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c @@ -1154,7 +1154,6 @@ int iwl_pcie_gen2_enqueue_hcmd(struct iwl_trans *trans, dma_addr_t phys_addr; int i, cmd_pos, idx; u16 copy_size, cmd_size, tb0_size; - bool had_nocopy = false; u8 group_id = iwl_cmd_groupid(cmd->id); const u8 *cmddata[IWL_MAX_CMD_CHUNKS_PER_HCMD]; u16 cmdlen[IWL_MAX_CMD_CHUNKS_PER_HCMD]; @@ -1184,52 +1183,17 @@ int iwl_pcie_gen2_enqueue_hcmd(struct iwl_trans *trans, copy_size += copy; } - if (cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY) { - had_nocopy = true; - if (WARN_ON(cmd->dataflags[i] & IWL_HCMD_DFL_DUP)) { - idx = -EINVAL; - goto free_dup_buf; - } - } else if (cmd->dataflags[i] & IWL_HCMD_DFL_DUP) { - /* - * This is also a chunk that isn't copied - * to the static buffer so set had_nocopy. - */ - had_nocopy = true; - - /* only allowed once */ - if (WARN_ON(dup_buf)) { - idx = -EINVAL; - goto free_dup_buf; - } - + if (cmd->dataflags[i] & IWL_HCMD_DFL_DUP) { dup_buf = kmemdup(cmddata[i], cmdlen[i], GFP_ATOMIC); if (!dup_buf) return -ENOMEM; - } else { - /* NOCOPY must not be followed by normal! */ - if (WARN_ON(had_nocopy)) { - idx = -EINVAL; - goto free_dup_buf; - } + } else if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY)) { copy_size += cmdlen[i]; } cmd_size += cmd->len[i]; } - /* - * If any of the command structures end up being larger than the - * TFD_MAX_PAYLOAD_SIZE and they aren't dynamically allocated into - * separate TFDs, then we will need to increase the size of the buffers - */ - if (WARN(copy_size > TFD_MAX_PAYLOAD_SIZE, - "Command %s (%#x) is too large (%d bytes)\n", - iwl_get_cmd_string(trans, cmd->id), cmd->id, copy_size)) { - idx = -EINVAL; - goto free_dup_buf; - } - spin_lock_bh(&txq->lock); idx = iwl_txq_get_cmd_index(txq, txq->write_ptr); diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c index 2dc83a9932c3..ea0279948ef4 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c @@ -1366,7 +1366,6 @@ int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans, dma_addr_t phys_addr; int idx; u16 copy_size, cmd_size, tb0_size; - bool had_nocopy = false; u8 group_id = iwl_cmd_groupid(cmd->id); int i, ret; u32 cmd_pos; @@ -1407,54 +1406,17 @@ int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans, copy_size += copy; } - if (cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY) { - had_nocopy = true; - if (WARN_ON(cmd->dataflags[i] & IWL_HCMD_DFL_DUP)) { - idx = -EINVAL; - goto free_dup_buf; - } - } else if (cmd->dataflags[i] & IWL_HCMD_DFL_DUP) { - /* - * This is also a chunk that isn't copied - * to the static buffer so set had_nocopy. - */ - had_nocopy = true; - - /* only allowed once */ - if (WARN_ON(dup_buf)) { - idx = -EINVAL; - goto free_dup_buf; - } - + if (cmd->dataflags[i] & IWL_HCMD_DFL_DUP) { dup_buf = kmemdup(cmddata[i], cmdlen[i], GFP_ATOMIC); if (!dup_buf) return -ENOMEM; - } else { - /* NOCOPY must not be followed by normal! */ - if (WARN_ON(had_nocopy)) { - idx = -EINVAL; - goto free_dup_buf; - } + } else if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY)) { copy_size += cmdlen[i]; } cmd_size += cmd->len[i]; } - /* - * If any of the command structures end up being larger than - * the TFD_MAX_PAYLOAD_SIZE and they aren't dynamically - * allocated into separate TFDs, then we will need to - * increase the size of the buffers. - */ - if (WARN(copy_size > TFD_MAX_PAYLOAD_SIZE, - "Command %s (%#x) is too large (%d bytes)\n", - iwl_get_cmd_string(trans, cmd->id), - cmd->id, copy_size)) { - idx = -EINVAL; - goto free_dup_buf; - } - spin_lock_bh(&txq->lock); if (iwl_txq_space(trans, txq) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { -- 2.34.1 From: Benjamin Berg The FW actually only ever reports PLCP_RX_OK, AID_NOT_FOR_US or UNKNOWN_ERROR. As such, there is no point in decoding the other information. Fixes: 92e87cee465c ("wifi: iwlwifi: mld: update to new sniffer API") Signed-off-by: Benjamin Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/fw/api/rx.h | 8 +------- drivers/net/wireless/intel/iwlwifi/mld/rx.c | 8 -------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h index 20460534fc99..5dc714164349 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* - * Copyright (C) 2012-2014, 2018-2025 Intel Corporation + * Copyright (C) 2012-2014, 2018-2026 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2015-2017 Intel Deutschland GmbH */ @@ -1393,12 +1393,6 @@ union iwl_sigs { enum iwl_sniffer_status { IWL_SNIF_STAT_PLCP_RX_OK = 0, IWL_SNIF_STAT_AID_NOT_FOR_US = 1, - IWL_SNIF_STAT_PLCP_RX_LSIG_ERR = 2, - IWL_SNIF_STAT_PLCP_RX_SIGA_ERR = 3, - IWL_SNIF_STAT_PLCP_RX_SIGB_ERR = 4, - IWL_SNIF_STAT_UNEXPECTED_TB = 5, - IWL_SNIF_STAT_UNSUPPORTED_RATE = 6, - IWL_SNIF_STAT_UNKNOWN_ERROR = 7, }; /* AIR_SNIFFER_STATUS_E_VER_1 */ enum iwl_sniffer_flags { diff --git a/drivers/net/wireless/intel/iwlwifi/mld/rx.c b/drivers/net/wireless/intel/iwlwifi/mld/rx.c index 0401b19f8b09..70bc766bb2ff 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/rx.c @@ -2940,19 +2940,11 @@ static void iwl_mld_no_data_rx(struct iwl_mld *mld, rx_status->zero_length_psdu_type = IEEE80211_RADIOTAP_ZERO_LEN_PSDU_NOT_CAPTURED; break; - case IWL_SNIF_STAT_PLCP_RX_LSIG_ERR: - case IWL_SNIF_STAT_PLCP_RX_SIGA_ERR: - case IWL_SNIF_STAT_PLCP_RX_SIGB_ERR: - case IWL_SNIF_STAT_UNKNOWN_ERROR: default: /* some kind of PLCP error - no details from FW */ rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; - fallthrough; - case IWL_SNIF_STAT_UNEXPECTED_TB: - case IWL_SNIF_STAT_UNSUPPORTED_RATE: rx_status->zero_length_psdu_type = IEEE80211_RADIOTAP_ZERO_LEN_PSDU_VENDOR; - /* we could include the real reason in a vendor TLV */ } if (format == RATE_MCS_MOD_TYPE_CCK && -- 2.34.1 From: Benjamin Berg The IWL_RX_MPDU_PHY_TSF_OVERLOAD was used to flag whether the TSF is included in the RX MPDU descriptor. However, its always set when in monitor mode and otherwise it is not set. If set, the PHY data is encoded in those bits. The driver knows how the hardware is configured and the bit can be removed then. Fixes: 92e87cee465c ("wifi: iwlwifi: mld: update to new sniffer API") Signed-off-by: Benjamin Berg Signed-off-by: Miri Korenblit --- .../net/wireless/intel/iwlwifi/fw/api/rx.h | 22 ++++++++++++------- drivers/net/wireless/intel/iwlwifi/mld/rx.c | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h index 5dc714164349..b2cea36c3213 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h @@ -271,6 +271,10 @@ enum iwl_rx_mpdu_phy_info { IWL_RX_MPDU_PHY_SHORT_PREAMBLE = BIT(7), /* short preamble is only for CCK, for non-CCK overridden by this */ IWL_RX_MPDU_PHY_NCCK_ADDTL_NTFY = BIT(7), + /* + * Reserved if the FW supports PHY_AIR_SNIFFER_NOTIF, + * otherwise always set in monitor mode and never in non-monitor mode. + */ IWL_RX_MPDU_PHY_TSF_OVERLOAD = BIT(8), }; @@ -620,8 +624,9 @@ struct iwl_rx_mpdu_desc_v3 { union { /** * @tsf_on_air_rise: - * TSF value on air rise (INA), only valid if - * %IWL_RX_MPDU_PHY_TSF_OVERLOAD isn't set + * TSF value on air rise (INA), valid when not in monitor mode. + * Some FW versions will set %IWL_RX_MPDU_PHY_TSF_OVERLOAD when + * it is not valid. */ __le64 tsf_on_air_rise; @@ -631,18 +636,19 @@ struct iwl_rx_mpdu_desc_v3 { */ __le32 phy_data0; /** - * @phy_data1: valid only if - * %IWL_RX_MPDU_PHY_TSF_OVERLOAD is set, - * see &enum iwl_rx_phy_data1. + * @phy_data1: valid only if in sniffer mode, and + * @tsf_on_air_rise is not reported, + * see &enum iwl_rx_phy_common_data1 or + * &enum iwl_rx_phy_he_data1 or + * &enum iwl_rx_phy_eht_data1. */ __le32 phy_data1; }; }; /* DW16 */ /** - * @phy_data5: valid only if - * %IWL_RX_MPDU_PHY_TSF_OVERLOAD is set, - * see &enum iwl_rx_phy_data5. + * @phy_data5: valid only if in sniffer mode, and @tsf_on_air_rise is + * not reported, see &enum iwl_rx_phy_data5. */ __le32 phy_data5; /* DW17 */ diff --git a/drivers/net/wireless/intel/iwlwifi/mld/rx.c b/drivers/net/wireless/intel/iwlwifi/mld/rx.c index 70bc766bb2ff..69867c10a7b1 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/rx.c @@ -2707,7 +2707,7 @@ void iwl_mld_rx_mpdu(struct iwl_mld *mld, struct napi_struct *napi, rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; } - if (likely(!(phy_data.phy_info & IWL_RX_MPDU_PHY_TSF_OVERLOAD))) { + if (likely(!mld->monitor.on)) { rx_status->mactime = le64_to_cpu(mpdu_desc->v3.tsf_on_air_rise); -- 2.34.1 The PNVM and reduced power transport APIs get the whole firmware capabilities structure, but the only thing the transport needs out of it is whether the firmware supports a fragmented PNVM image. Move this indication to trans.conf, which contains the opmodes configurations to the transport. Assisted-by: LLM Reviewed-by: Emmanuel Grumbach Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 11 ++++--- .../net/wireless/intel/iwlwifi/iwl-trans.c | 20 +++++-------- .../net/wireless/intel/iwlwifi/iwl-trans.h | 30 ++++++++----------- drivers/net/wireless/intel/iwlwifi/mld/mld.c | 3 ++ drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 4 +++ .../intel/iwlwifi/pcie/ctxt-info-v2.c | 21 +++++-------- .../intel/iwlwifi/pcie/iwl-context-info-v2.h | 13 +++----- 7 files changed, 45 insertions(+), 57 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c index ccd190ab8a55..884937522ff0 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c @@ -402,13 +402,13 @@ iwl_pnvm_load_pnvm_to_trans(struct iwl_trans *trans, goto free; } - ret = iwl_trans_load_pnvm(trans, pnvm_data, &fw->ucode_capa); + ret = iwl_trans_load_pnvm(trans, pnvm_data); if (ret) goto free; IWL_DEBUG_INFO(trans, "loaded PNVM version %08x\n", pnvm_data->version); set: - iwl_trans_set_pnvm(trans, &fw->ucode_capa); + iwl_trans_set_pnvm(trans); free: /* free only if it was allocated, i.e. not just embedded PNVM data */ if (data != fw->pnvm_data) @@ -418,7 +418,6 @@ iwl_pnvm_load_pnvm_to_trans(struct iwl_trans *trans, static void iwl_pnvm_load_reduce_power_to_trans(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa, __le32 sku_id[3]) { struct iwl_pnvm_image *pnvm_data = NULL; @@ -449,7 +448,7 @@ iwl_pnvm_load_reduce_power_to_trans(struct iwl_trans *trans, goto free; } - ret = iwl_trans_load_reduce_power(trans, pnvm_data, capa); + ret = iwl_trans_load_reduce_power(trans, pnvm_data); if (ret) { IWL_DEBUG_FW(trans, "Failed to load reduce power table %d\n", @@ -459,7 +458,7 @@ iwl_pnvm_load_reduce_power_to_trans(struct iwl_trans *trans, } set: - iwl_trans_set_reduce_power(trans, capa); + iwl_trans_set_reduce_power(trans); free: kfree(data); kfree(pnvm_data); @@ -478,7 +477,7 @@ int iwl_pnvm_load(struct iwl_trans *trans, return 0; iwl_pnvm_load_pnvm_to_trans(trans, fw, sku_id); - iwl_pnvm_load_reduce_power_to_trans(trans, &fw->ucode_capa, sku_id); + iwl_pnvm_load_reduce_power_to_trans(trans, sku_id); iwl_init_notification_wait(notif_wait, &pnvm_wait, ntf_cmds, ARRAY_SIZE(ntf_cmds), diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c index ff44ce35f703..c2c106d4dd6d 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c @@ -990,38 +990,34 @@ int iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue, IWL_EXPORT_SYMBOL(iwl_trans_get_rxq_dma_data); int iwl_trans_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_data, - const struct iwl_ucode_capabilities *capa) + const struct iwl_pnvm_image *pnvm_data) { if (WARN_ON_ONCE(!trans->ops->load_pnvm)) return -EOPNOTSUPP; - return trans->ops->load_pnvm(trans, pnvm_data, capa); + return trans->ops->load_pnvm(trans, pnvm_data); } IWL_EXPORT_SYMBOL(iwl_trans_load_pnvm); -void iwl_trans_set_pnvm(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa) +void iwl_trans_set_pnvm(struct iwl_trans *trans) { if (WARN_ON_ONCE(!trans->ops->set_pnvm)) return; - trans->ops->set_pnvm(trans, capa); + trans->ops->set_pnvm(trans); } int iwl_trans_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads, - const struct iwl_ucode_capabilities *capa) + const struct iwl_pnvm_image *payloads) { if (WARN_ON_ONCE(!trans->ops->load_reduce_power)) return -EOPNOTSUPP; - return trans->ops->load_reduce_power(trans, payloads, capa); + return trans->ops->load_reduce_power(trans, payloads); } -void iwl_trans_set_reduce_power(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa) +void iwl_trans_set_reduce_power(struct iwl_trans *trans) { if (WARN_ON_ONCE(!trans->ops->set_reduce_power)) return; - trans->ops->set_reduce_power(trans, capa); + trans->ops->set_reduce_power(trans); } bool iwl_trans_is_pm_supported(struct iwl_trans *trans) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h index e4f1cb0fd1ff..f5fa6b5791af 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h @@ -406,6 +406,9 @@ struct iwl_dump_sanitize_ops { * @mbx_addr_0_step: step address data 0 * @mbx_addr_1_step: step address data 1 * @ext_32khz_clock_valid: if true, the external 32 KHz clock can be used + * @fragmented_pnvm: the firmware supports a fragmented PNVM image, i.e. + * the PNVM and reduced power tables can be split into several DRAM + * sections */ struct iwl_trans_config { u8 cmd_queue; @@ -426,7 +429,8 @@ struct iwl_trans_config { u8 dsbr_urm_fw_dependent:1, dsbr_urm_permanent:1, - ext_32khz_clock_valid:1; + ext_32khz_clock_valid:1, + fragmented_pnvm:1; u32 mbx_addr_0_step; u32 mbx_addr_1_step; @@ -1179,18 +1183,14 @@ void iwl_trans_sync_nmi(struct iwl_trans *trans); void iwl_trans_force_nmi(struct iwl_trans *trans); int iwl_trans_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_data, - const struct iwl_ucode_capabilities *capa); + const struct iwl_pnvm_image *pnvm_data); -void iwl_trans_set_pnvm(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa); +void iwl_trans_set_pnvm(struct iwl_trans *trans); int iwl_trans_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads, - const struct iwl_ucode_capabilities *capa); + const struct iwl_pnvm_image *payloads); -void iwl_trans_set_reduce_power(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa); +void iwl_trans_set_reduce_power(struct iwl_trans *trans); static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans) { @@ -1415,15 +1415,11 @@ struct iwl_trans_ops { struct iwl_trans_rxq_dma_data *data); int (*load_pnvm)(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_data, - const struct iwl_ucode_capabilities *capa); - void (*set_pnvm)(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa); + const struct iwl_pnvm_image *pnvm_data); + void (*set_pnvm)(struct iwl_trans *trans); int (*load_reduce_power)(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads, - const struct iwl_ucode_capabilities *capa); - void (*set_reduce_power)(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa); + const struct iwl_pnvm_image *payloads); + void (*set_reduce_power)(struct iwl_trans *trans); bool (*is_pm_supported)(struct iwl_trans *trans); bool (*is_ltr_enabled)(struct iwl_trans *trans); diff --git a/drivers/net/wireless/intel/iwlwifi/mld/mld.c b/drivers/net/wireless/intel/iwlwifi/mld/mld.c index 17d272b3518e..59091f392e77 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/mld.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/mld.c @@ -380,6 +380,9 @@ iwl_mld_configure_trans(struct iwl_op_mode *op_mode) trans->conf.cb_data_offs = offsetof(struct ieee80211_tx_info, driver_data[2]); trans->conf.fseq_img = &mld->fw->fseq; + trans->conf.fragmented_pnvm = + fw_has_capa(&mld->fw->ucode_capa, + IWL_UCODE_TLV_CAPA_FRAGMENTED_PNVM_IMG); BUILD_BUG_ON(sizeof(no_reclaim_cmds) > sizeof(trans->conf.no_reclaim_cmds)); memcpy(trans->conf.no_reclaim_cmds, no_reclaim_cmds, diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index 870304112421..b81ecc98bcba 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -1422,6 +1422,10 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, if (IWL_UCODE_MAJOR(mvm->fw->ucode_ver) <= 77) trans->conf.fw_reset_handshake = false; + trans->conf.fragmented_pnvm = + fw_has_capa(&mvm->fw->ucode_capa, + IWL_UCODE_TLV_CAPA_FRAGMENTED_PNVM_IMG); + mvm->sta_remove_requires_queue_remove = iwl_fw_lookup_cmd_ver(mvm->fw, WIDE_ID(DATA_PATH_GROUP, diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c index d76fd8f91ebd..c914fd0ca505 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c @@ -527,8 +527,7 @@ static int iwl_pcie_load_payloads_segments } int iwl_trans_pcie_ctx_info_v2_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_payloads, - const struct iwl_ucode_capabilities *capa) + const struct iwl_pnvm_image *pnvm_payloads) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl = @@ -552,7 +551,7 @@ int iwl_trans_pcie_ctx_info_v2_load_pnvm(struct iwl_trans *trans, } /* save payloads in several DRAM sections */ - if (fw_has_capa(capa, IWL_UCODE_TLV_CAPA_FRAGMENTED_PNVM_IMG)) { + if (trans->conf.fragmented_pnvm) { ret = iwl_pcie_load_payloads_segments(trans, dram_regions, pnvm_payloads); @@ -608,21 +607,19 @@ static void iwl_pcie_set_contig_pnvm(struct iwl_trans *trans) cpu_to_le32(trans_pcie->pnvm_data.drams[0].size); } -void iwl_trans_pcie_ctx_info_v2_set_pnvm(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa) +void iwl_trans_pcie_ctx_info_v2_set_pnvm(struct iwl_trans *trans) { if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) return; - if (fw_has_capa(capa, IWL_UCODE_TLV_CAPA_FRAGMENTED_PNVM_IMG)) + if (trans->conf.fragmented_pnvm) iwl_pcie_set_pnvm_segments(trans); else iwl_pcie_set_contig_pnvm(trans); } int iwl_trans_pcie_ctx_info_v2_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads, - const struct iwl_ucode_capabilities *capa) + const struct iwl_pnvm_image *payloads) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl = @@ -646,7 +643,7 @@ int iwl_trans_pcie_ctx_info_v2_load_reduce_power(struct iwl_trans *trans, } /* save payloads in several DRAM sections */ - if (fw_has_capa(capa, IWL_UCODE_TLV_CAPA_FRAGMENTED_PNVM_IMG)) { + if (trans->conf.fragmented_pnvm) { ret = iwl_pcie_load_payloads_segments(trans, dram_regions, payloads); @@ -690,14 +687,12 @@ static void iwl_pcie_set_contig_reduce_power(struct iwl_trans *trans) cpu_to_le32(trans_pcie->reduced_tables_data.drams[0].size); } -void -iwl_trans_pcie_ctx_info_v2_set_reduce_power(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa) +void iwl_trans_pcie_ctx_info_v2_set_reduce_power(struct iwl_trans *trans) { if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) return; - if (fw_has_capa(capa, IWL_UCODE_TLV_CAPA_FRAGMENTED_PNVM_IMG)) + if (trans->conf.fragmented_pnvm) iwl_pcie_set_reduce_power_segments(trans); else iwl_pcie_set_contig_reduce_power(trans); diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h b/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h index a50e80cccadb..b432e37ff257 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h +++ b/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h @@ -14,15 +14,10 @@ void iwl_pcie_ctxt_info_v2_kick(struct iwl_trans *trans); void iwl_pcie_ctxt_info_v2_free(struct iwl_trans *trans, bool alive); int iwl_trans_pcie_ctx_info_v2_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_payloads, - const struct iwl_ucode_capabilities *capa); -void iwl_trans_pcie_ctx_info_v2_set_pnvm(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa); + const struct iwl_pnvm_image *pnvm_payloads); +void iwl_trans_pcie_ctx_info_v2_set_pnvm(struct iwl_trans *trans); int iwl_trans_pcie_ctx_info_v2_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads, - const struct iwl_ucode_capabilities *capa); -void -iwl_trans_pcie_ctx_info_v2_set_reduce_power(struct iwl_trans *trans, - const struct iwl_ucode_capabilities *capa); + const struct iwl_pnvm_image *payloads); +void iwl_trans_pcie_ctx_info_v2_set_reduce_power(struct iwl_trans *trans); #endif /* __iwl_context_info_file_v2_h__ */ -- 2.34.1 Currently, we have two APIs towards the transport: 1. load_pnvm/reduced_power: this really tells the transport to allocate the DRAM for the PNVM/reduced power 2. set_pnvm/reduced_power: this tells the transport to point the context info to the previousely allocated DRAM. Then, the PNVM code triggers the doorbell on its own. In order to be prepared for future bus types, rework the APIs: 1. merge the load_* APIs into a single alloc_pnvm API, with a boolean that indicates whether the payloads are of the PNVM or of the reduced power table, and rename it to better indicate what it does. 2. remove the set_* APIs, and replace them by a new kick_pnvm API, which will both setup the context info and kick the doorbel, as this is bus specific. Assisted-by: LLM Reviewed-by: Emmanuel Grumbach Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 20 +-- .../net/wireless/intel/iwlwifi/iwl-trans.c | 32 ++-- .../net/wireless/intel/iwlwifi/iwl-trans.h | 37 ++--- .../intel/iwlwifi/pcie/ctxt-info-v2.c | 140 ++++++++++-------- .../intel/iwlwifi/pcie/iwl-context-info-v2.h | 11 +- .../net/wireless/intel/iwlwifi/pcie/trans.c | 6 +- 6 files changed, 116 insertions(+), 130 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c index 884937522ff0..12fad19109bf 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c @@ -383,8 +383,8 @@ iwl_pnvm_load_pnvm_to_trans(struct iwl_trans *trans, if (trans->fail_to_parse_pnvm_image) return; - if (trans->pnvm_loaded) - goto set; + if (trans->pnvm_allocated) + return; data = iwl_get_pnvm_image(trans, &length, sku_id, fw); if (!data) { @@ -402,13 +402,11 @@ iwl_pnvm_load_pnvm_to_trans(struct iwl_trans *trans, goto free; } - ret = iwl_trans_load_pnvm(trans, pnvm_data); + ret = iwl_trans_alloc_pnvm(trans, pnvm_data, false); if (ret) goto free; IWL_DEBUG_INFO(trans, "loaded PNVM version %08x\n", pnvm_data->version); -set: - iwl_trans_set_pnvm(trans); free: /* free only if it was allocated, i.e. not just embedded PNVM data */ if (data != fw->pnvm_data) @@ -428,8 +426,8 @@ iwl_pnvm_load_reduce_power_to_trans(struct iwl_trans *trans, if (trans->failed_to_load_reduce_power_image) return; - if (trans->reduce_power_loaded) - goto set; + if (trans->reduce_power_allocated) + return; data = iwl_uefi_get_reduced_power(trans, &length); if (IS_ERR(data)) { @@ -448,7 +446,7 @@ iwl_pnvm_load_reduce_power_to_trans(struct iwl_trans *trans, goto free; } - ret = iwl_trans_load_reduce_power(trans, pnvm_data); + ret = iwl_trans_alloc_pnvm(trans, pnvm_data, true); if (ret) { IWL_DEBUG_FW(trans, "Failed to load reduce power table %d\n", @@ -457,8 +455,6 @@ iwl_pnvm_load_reduce_power_to_trans(struct iwl_trans *trans, goto free; } -set: - iwl_trans_set_reduce_power(trans); free: kfree(data); kfree(pnvm_data); @@ -483,9 +479,7 @@ int iwl_pnvm_load(struct iwl_trans *trans, ntf_cmds, ARRAY_SIZE(ntf_cmds), iwl_pnvm_complete_fn, trans); - /* kick the doorbell */ - iwl_trans_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6, - UREG_DOORBELL_TO_ISR6_PNVM); + iwl_trans_kick_pnvm(trans); return iwl_wait_notification(notif_wait, &pnvm_wait, MVM_UCODE_PNVM_TIMEOUT); diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c index c2c106d4dd6d..3d805654d232 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c @@ -989,35 +989,21 @@ int iwl_trans_get_rxq_dma_data(struct iwl_trans *trans, int queue, } IWL_EXPORT_SYMBOL(iwl_trans_get_rxq_dma_data); -int iwl_trans_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_data) +int iwl_trans_alloc_pnvm(struct iwl_trans *trans, + const struct iwl_pnvm_image *payloads, + bool reduce_power) { - if (WARN_ON_ONCE(!trans->ops->load_pnvm)) + if (WARN_ON_ONCE(!trans->ops->alloc_pnvm)) return -EOPNOTSUPP; - return trans->ops->load_pnvm(trans, pnvm_data); + return trans->ops->alloc_pnvm(trans, payloads, reduce_power); } -IWL_EXPORT_SYMBOL(iwl_trans_load_pnvm); +IWL_EXPORT_SYMBOL(iwl_trans_alloc_pnvm); -void iwl_trans_set_pnvm(struct iwl_trans *trans) +void iwl_trans_kick_pnvm(struct iwl_trans *trans) { - if (WARN_ON_ONCE(!trans->ops->set_pnvm)) + if (WARN_ON_ONCE(!trans->ops->kick_pnvm)) return; - trans->ops->set_pnvm(trans); -} - -int iwl_trans_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads) -{ - if (WARN_ON_ONCE(!trans->ops->load_reduce_power)) - return -EOPNOTSUPP; - return trans->ops->load_reduce_power(trans, payloads); -} - -void iwl_trans_set_reduce_power(struct iwl_trans *trans) -{ - if (WARN_ON_ONCE(!trans->ops->set_reduce_power)) - return; - trans->ops->set_reduce_power(trans); + trans->ops->kick_pnvm(trans); } bool iwl_trans_is_pm_supported(struct iwl_trans *trans) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h index f5fa6b5791af..f97bde14cdc8 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h @@ -754,11 +754,11 @@ struct iwl_trans_ops; * @status: a bit-mask of transport status flags * @dev: pointer to struct device * that represents the device * @info: device information for use by other layers - * @pnvm_loaded: indicates PNVM was loaded + * @pnvm_allocated: indicates PNVM was allocated * @suppress_cmd_error_once: suppress "FW error in SYNC CMD" once, * e.g. for testing * @fail_to_parse_pnvm_image: set to true if pnvm parsing failed - * @reduce_power_loaded: indicates reduced power section was loaded + * @reduce_power_allocated: indicates reduced power section was allocated * @failed_to_load_reduce_power_image: set to true if pnvm loading failed * @dbgfs_dir: iwlwifi debugfs base dir for this device * @sync_cmd_lockdep_map: lockdep map for checking sync commands @@ -797,9 +797,9 @@ struct iwl_trans { bool step_urm; bool suppress_cmd_error_once; - u8 pnvm_loaded:1; + u8 pnvm_allocated:1; u8 fail_to_parse_pnvm_image:1; - u8 reduce_power_loaded:1; + u8 reduce_power_allocated:1; u8 failed_to_load_reduce_power_image:1; struct dentry *dbgfs_dir; @@ -1182,15 +1182,11 @@ void iwl_trans_sync_nmi(struct iwl_trans *trans); void iwl_trans_force_nmi(struct iwl_trans *trans); -int iwl_trans_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_data); +int iwl_trans_alloc_pnvm(struct iwl_trans *trans, + const struct iwl_pnvm_image *payloads, + bool reduce_power); -void iwl_trans_set_pnvm(struct iwl_trans *trans); - -int iwl_trans_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads); - -void iwl_trans_set_reduce_power(struct iwl_trans *trans); +void iwl_trans_kick_pnvm(struct iwl_trans *trans); static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans) { @@ -1332,10 +1328,9 @@ void iwl_trans_fw_reset_handshake(struct iwl_trans *trans); * @txq_alloc: allocate a TX queue (gen2) * @txq_free: free a TX queue allocated by @txq_alloc * @rxq_dma_data: get the DMA addresses of an RX queue - * @load_pnvm: load the PNVM image - * @set_pnvm: tell the firmware to use the loaded PNVM - * @load_reduce_power: load the reduced power table - * @set_reduce_power: tell the firmware to use the reduced power table + * @alloc_pnvm: allocate and store a copy of the PNVM image, or of the + * reduced power table if @reduce_power is set + * @kick_pnvm: tell the firmware that the PNVM is ready * @is_pm_supported: whether bus power management is supported * @is_ltr_enabled: whether LTR is enabled on the bus * @activate_nic: bring the NIC out of low power and make it accessible @@ -1414,12 +1409,10 @@ struct iwl_trans_ops { int (*rxq_dma_data)(struct iwl_trans *trans, int queue, struct iwl_trans_rxq_dma_data *data); - int (*load_pnvm)(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_data); - void (*set_pnvm)(struct iwl_trans *trans); - int (*load_reduce_power)(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads); - void (*set_reduce_power)(struct iwl_trans *trans); + int (*alloc_pnvm)(struct iwl_trans *trans, + const struct iwl_pnvm_image *payloads, + bool reduce_power); + void (*kick_pnvm)(struct iwl_trans *trans); bool (*is_pm_supported)(struct iwl_trans *trans); bool (*is_ltr_enabled)(struct iwl_trans *trans); diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c index c914fd0ca505..804f85006b38 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-v2.c @@ -437,9 +437,9 @@ void iwl_pcie_ctxt_info_v2_free(struct iwl_trans *trans, bool alive) trans_pcie->prph_info = NULL; } -static int iwl_pcie_load_payloads_contig(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_data, - struct iwl_dram_data *dram) +static int iwl_pcie_alloc_payloads_contig(struct iwl_trans *trans, + const struct iwl_pnvm_image *pnvm_data, + struct iwl_dram_data *dram) { u32 len, len0, len1; @@ -471,7 +471,7 @@ static int iwl_pcie_load_payloads_contig(struct iwl_trans *trans, return 0; } -static int iwl_pcie_load_payloads_segments +static int iwl_pcie_alloc_payloads_segments (struct iwl_trans *trans, struct iwl_dram_regions *dram_regions, const struct iwl_pnvm_image *pnvm_data) @@ -526,8 +526,54 @@ static int iwl_pcie_load_payloads_segments } -int iwl_trans_pcie_ctx_info_v2_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_payloads) +static int +iwl_pcie_ctx_info_v2_alloc_reduce_power(struct iwl_trans *trans, + const struct iwl_pnvm_image *payloads) +{ + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl = + &trans_pcie->prph_scratch->ctrl_cfg; + struct iwl_dram_regions *dram_regions = &trans_pcie->reduced_tables_data; + int ret = 0; + + /* only allocate the DRAM if not allocated yet */ + if (trans->reduce_power_allocated) + return 0; + + if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) + return 0; + + if (WARN_ON(prph_sc_ctrl->reduce_power_cfg.size)) + return -EBUSY; + + if (!payloads->n_chunks) { + IWL_DEBUG_FW(trans, "no payloads\n"); + return -EINVAL; + } + + /* save payloads in several DRAM sections */ + if (trans->conf.fragmented_pnvm) { + ret = iwl_pcie_alloc_payloads_segments(trans, + dram_regions, + payloads); + if (!ret) + trans->reduce_power_allocated = true; + } else { + /* save only in one DRAM section */ + ret = iwl_pcie_alloc_payloads_contig(trans, payloads, + &dram_regions->drams[0]); + if (!ret) { + dram_regions->n_regions = 1; + trans->reduce_power_allocated = true; + } + } + + return ret; +} + +int iwl_trans_pcie_ctx_info_v2_alloc_pnvm(struct iwl_trans *trans, + const struct iwl_pnvm_image *payloads, + bool reduce_power) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl = @@ -535,8 +581,11 @@ int iwl_trans_pcie_ctx_info_v2_load_pnvm(struct iwl_trans *trans, struct iwl_dram_regions *dram_regions = &trans_pcie->pnvm_data; int ret = 0; + if (reduce_power) + return iwl_pcie_ctx_info_v2_alloc_reduce_power(trans, payloads); + /* only allocate the DRAM if not allocated yet */ - if (trans->pnvm_loaded) + if (trans->pnvm_allocated) return 0; if (WARN_ON(prph_sc_ctrl->pnvm_cfg.pnvm_size)) @@ -545,25 +594,25 @@ int iwl_trans_pcie_ctx_info_v2_load_pnvm(struct iwl_trans *trans, if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) return 0; - if (!pnvm_payloads->n_chunks) { + if (!payloads->n_chunks) { IWL_DEBUG_FW(trans, "no payloads\n"); return -EINVAL; } /* save payloads in several DRAM sections */ if (trans->conf.fragmented_pnvm) { - ret = iwl_pcie_load_payloads_segments(trans, - dram_regions, - pnvm_payloads); + ret = iwl_pcie_alloc_payloads_segments(trans, + dram_regions, + payloads); if (!ret) - trans->pnvm_loaded = true; + trans->pnvm_allocated = true; } else { /* save only in one DRAM section */ - ret = iwl_pcie_load_payloads_contig(trans, pnvm_payloads, - &dram_regions->drams[0]); + ret = iwl_pcie_alloc_payloads_contig(trans, payloads, + &dram_regions->drams[0]); if (!ret) { dram_regions->n_regions = 1; - trans->pnvm_loaded = true; + trans->pnvm_allocated = true; } } @@ -607,61 +656,20 @@ static void iwl_pcie_set_contig_pnvm(struct iwl_trans *trans) cpu_to_le32(trans_pcie->pnvm_data.drams[0].size); } -void iwl_trans_pcie_ctx_info_v2_set_pnvm(struct iwl_trans *trans) +static void iwl_trans_pcie_ctx_info_v2_set_pnvm(struct iwl_trans *trans) { if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) return; + if (!trans->pnvm_allocated) + return; + if (trans->conf.fragmented_pnvm) iwl_pcie_set_pnvm_segments(trans); else iwl_pcie_set_contig_pnvm(trans); } -int iwl_trans_pcie_ctx_info_v2_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads) -{ - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl = - &trans_pcie->prph_scratch->ctrl_cfg; - struct iwl_dram_regions *dram_regions = &trans_pcie->reduced_tables_data; - int ret = 0; - - /* only allocate the DRAM if not allocated yet */ - if (trans->reduce_power_loaded) - return 0; - - if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) - return 0; - - if (WARN_ON(prph_sc_ctrl->reduce_power_cfg.size)) - return -EBUSY; - - if (!payloads->n_chunks) { - IWL_DEBUG_FW(trans, "no payloads\n"); - return -EINVAL; - } - - /* save payloads in several DRAM sections */ - if (trans->conf.fragmented_pnvm) { - ret = iwl_pcie_load_payloads_segments(trans, - dram_regions, - payloads); - if (!ret) - trans->reduce_power_loaded = true; - } else { - /* save only in one DRAM section */ - ret = iwl_pcie_load_payloads_contig(trans, payloads, - &dram_regions->drams[0]); - if (!ret) { - dram_regions->n_regions = 1; - trans->reduce_power_loaded = true; - } - } - - return ret; -} - static void iwl_pcie_set_reduce_power_segments(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); @@ -687,14 +695,24 @@ static void iwl_pcie_set_contig_reduce_power(struct iwl_trans *trans) cpu_to_le32(trans_pcie->reduced_tables_data.drams[0].size); } -void iwl_trans_pcie_ctx_info_v2_set_reduce_power(struct iwl_trans *trans) +static void iwl_trans_pcie_ctx_info_v2_set_reduce_power(struct iwl_trans *trans) { if (trans->mac_cfg->device_family < IWL_DEVICE_FAMILY_AX210) return; + if (!trans->reduce_power_allocated) + return; + if (trans->conf.fragmented_pnvm) iwl_pcie_set_reduce_power_segments(trans); else iwl_pcie_set_contig_reduce_power(trans); } +void iwl_trans_pcie_kick_pnvm(struct iwl_trans *trans) +{ + iwl_trans_pcie_ctx_info_v2_set_pnvm(trans); + iwl_trans_pcie_ctx_info_v2_set_reduce_power(trans); + iwl_trans_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6, + UREG_DOORBELL_TO_ISR6_PNVM); +} diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h b/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h index b432e37ff257..691465d7b376 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h +++ b/drivers/net/wireless/intel/iwlwifi/pcie/iwl-context-info-v2.h @@ -13,11 +13,8 @@ int iwl_pcie_ctxt_info_v2_alloc(struct iwl_trans *trans, void iwl_pcie_ctxt_info_v2_kick(struct iwl_trans *trans); void iwl_pcie_ctxt_info_v2_free(struct iwl_trans *trans, bool alive); -int iwl_trans_pcie_ctx_info_v2_load_pnvm(struct iwl_trans *trans, - const struct iwl_pnvm_image *pnvm_payloads); -void iwl_trans_pcie_ctx_info_v2_set_pnvm(struct iwl_trans *trans); -int -iwl_trans_pcie_ctx_info_v2_load_reduce_power(struct iwl_trans *trans, - const struct iwl_pnvm_image *payloads); -void iwl_trans_pcie_ctx_info_v2_set_reduce_power(struct iwl_trans *trans); +int iwl_trans_pcie_ctx_info_v2_alloc_pnvm(struct iwl_trans *trans, + const struct iwl_pnvm_image *payloads, + bool reduce_power); +void iwl_trans_pcie_kick_pnvm(struct iwl_trans *trans); #endif /* __iwl_context_info_file_v2_h__ */ diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index 10bc61fe7ea5..cd7b94b287bb 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -3750,10 +3750,8 @@ const struct iwl_trans_ops iwl_trans_pcie_ops = { .txq_free = iwl_txq_dyn_free, .rxq_dma_data = iwl_trans_pcie_rxq_dma_data, - .load_pnvm = iwl_trans_pcie_ctx_info_v2_load_pnvm, - .set_pnvm = iwl_trans_pcie_ctx_info_v2_set_pnvm, - .load_reduce_power = iwl_trans_pcie_ctx_info_v2_load_reduce_power, - .set_reduce_power = iwl_trans_pcie_ctx_info_v2_set_reduce_power, + .alloc_pnvm = iwl_trans_pcie_ctx_info_v2_alloc_pnvm, + .kick_pnvm = iwl_trans_pcie_kick_pnvm, .is_pm_supported = iwl_pcie_gen1_is_pm_supported, .is_ltr_enabled = iwl_pcie_is_ltr_enabled, -- 2.34.1 From: Emmanuel Grumbach When dumping the PHY periphery registers, we check the status register before reading the actual value. This status register is duplicated for each LMAC. If we use LMAC1's copy of it while reading PHY prph from LMAC2 we will get an error value and we won't get the actual data for LMAC2. Also make sure we properly check against error values since we also need to match for 0xA5A5A5A1 as an error value. Poll the status register of the LMAC being dumped, and abort the PHY dump on any HW error value. Fixes: 7a7cb2eb5459 ("wifi: iwlwifi: phy periph read - flow modification") Assisted-by: LLM Signed-off-by: Emmanuel Grumbach Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 7 ++++--- drivers/net/wireless/intel/iwlwifi/iwl-prph.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c index 95103b9fb649..513ad2aa888f 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c @@ -147,6 +147,7 @@ static int iwl_dump_ini_prph_phy_iter_common(struct iwl_fw_runtime *fwrt, __le32 *val = range->data; u32 indirect_wr_addr = WMAL_INDRCT_RD_CMD1; u32 indirect_rd_addr = WMAL_MRSPF_1; + u32 stts_addr = WMAL_MRSPF_STTS; u32 prph_val; u32 dphy_state; u32 dphy_addr; @@ -161,6 +162,7 @@ static int iwl_dump_ini_prph_phy_iter_common(struct iwl_fw_runtime *fwrt, indirect_wr_addr += le32_to_cpu(offset); indirect_rd_addr += le32_to_cpu(offset); + stts_addr += le32_to_cpu(offset); dphy_addr = (offset) ? WFPM_LMAC2_PS_CTL_RW : WFPM_LMAC1_PS_CTL_RW; dphy_state = iwl_trans_read_umac_prph_no_grab(fwrt->trans, dphy_addr); @@ -182,10 +184,9 @@ static int iwl_dump_ini_prph_phy_iter_common(struct iwl_fw_runtime *fwrt, fwrt->trans->info.hw_rf_id != IWL_CFG_RF_TYPE_HR2) { udelay(2); prph_stts = iwl_trans_read_prph_no_grab(fwrt->trans, - WMAL_MRSPF_STTS); + stts_addr); - /* Abort dump if status is 0xA5A5A5A2 or FIFO1 empty */ - if (prph_stts == WMAL_TIMEOUT_VAL || + if (iwl_trans_is_hw_error_value(prph_stts) || !WMAL_MRSPF_STTS_IS_FIFO1_NOT_EMPTY(prph_stts)) break; } diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h index 50acfe0d4f79..66d23bcbda4d 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h @@ -523,7 +523,6 @@ enum { #define WMAL_MRSPF_STTS 0xADFC24 #define WMAL_MRSPF_STTS_FIFO1_NOT_EMPTY_POS 15 #define WMAL_MRSPF_STTS_FIFO1_NOT_EMPTY_MSK 0x8000 -#define WMAL_TIMEOUT_VAL 0xA5A5A5A2 #define WMAL_MRSPF_STTS_IS_FIFO1_NOT_EMPTY(val) \ (((val) >> (WMAL_MRSPF_STTS_FIFO1_NOT_EMPTY_POS)) & \ ((WMAL_MRSPF_STTS_FIFO1_NOT_EMPTY_MSK) >> \ -- 2.34.1 From: Johannes Berg The RTNL was only needed here because setting regulatory required it in the past. Now it doesn't, so drop the RTNL. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index b81ecc98bcba..c8035023c724 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -852,7 +852,6 @@ static int iwl_mvm_start_get_nvm(struct iwl_mvm *mvm) } get_nvm_from_fw: - rtnl_lock(); wiphy_lock(mvm->hw->wiphy); mutex_lock(&mvm->mutex); @@ -860,7 +859,6 @@ static int iwl_mvm_start_get_nvm(struct iwl_mvm *mvm) if (ret) { mutex_unlock(&mvm->mutex); wiphy_unlock(mvm->hw->wiphy); - rtnl_unlock(); return ret; } @@ -876,7 +874,6 @@ static int iwl_mvm_start_get_nvm(struct iwl_mvm *mvm) mutex_unlock(&mvm->mutex); wiphy_unlock(mvm->hw->wiphy); - rtnl_unlock(); if (ret) IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); -- 2.34.1 From: Johannes Berg The RTNL was only needed here because setting regulatory required it in the past. Now it doesn't, so drop the RTNL. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mld/mld.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mld/mld.c b/drivers/net/wireless/intel/iwlwifi/mld/mld.c index 59091f392e77..0be947337038 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/mld.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/mld.c @@ -438,8 +438,6 @@ iwl_op_mode_mld_start(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, iwl_mld_tx_gp2_init(mld); - /* needed for regulatory init */ - rtnl_lock(); /* Needed for sending commands */ wiphy_lock(mld->wiphy); @@ -461,7 +459,6 @@ iwl_op_mode_mld_start(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, /* wiphy memory is about to be freed, we should cancel any pending work */ wiphy_work_cancel(mld->wiphy, &mld->async_handlers_wk); wiphy_unlock(mld->wiphy); - rtnl_unlock(); goto err; } @@ -473,7 +470,6 @@ iwl_op_mode_mld_start(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, iwl_mld_stop_fw(mld); wiphy_unlock(mld->wiphy); - rtnl_unlock(); ret = iwl_mld_leds_init(mld); if (ret) -- 2.34.1 From: Johannes Berg Instead of having one check, provide an inline for the check whether or not flags are needed. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mld/mld.h | 8 ++++++++ drivers/net/wireless/intel/iwlwifi/mld/tx.c | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mld/mld.h b/drivers/net/wireless/intel/iwlwifi/mld/mld.h index a9e65b216fd3..b50f97d336a5 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/mld.h +++ b/drivers/net/wireless/intel/iwlwifi/mld/mld.h @@ -625,4 +625,12 @@ static inline bool iwl_mld_error_before_recovery(struct iwl_mld *mld) int iwl_mld_tdls_sta_count(struct iwl_mld *mld); +static inline bool iwl_mld_queue_cmd_has_flags(struct iwl_mld *mld) +{ + return iwl_fw_lookup_cmd_ver(mld->fw, + WIDE_ID(DATA_PATH_GROUP, + SCD_QUEUE_CONFIG_CMD), + 0) >= 4; +} + #endif /* __iwl_mld_h__ */ diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tx.c b/drivers/net/wireless/intel/iwlwifi/mld/tx.c index 43056206a1d8..5e57909f5d16 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/tx.c @@ -1543,9 +1543,7 @@ int iwl_mld_update_sta_txqs(struct iwl_mld *mld, lockdep_assert_wiphy(mld->wiphy); - if (iwl_fw_lookup_cmd_ver(mld->fw, - WIDE_ID(DATA_PATH_GROUP, SCD_QUEUE_CONFIG_CMD), - 0) >= 4) + if (iwl_mld_queue_cmd_has_flags(mld)) cmd.u.modify.flags = cpu_to_le16(IWL_SCD_QUEUE_MODIFY_FLAG_STA_MSK); -- 2.34.1 From: Johannes Berg Update the firmware API for the BAID modify command to the latest version, in preparation for SMD Transition. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- .../wireless/intel/iwlwifi/fw/api/datapath.h | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h index 78c991719c28..9ff3b4fd0f6c 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h @@ -533,20 +533,37 @@ struct iwl_rx_baid_cfg_cmd_modify_v2 { __le32 tid; } __packed; /* RX_BAID_ALLOCATION_MODIFY_CMD_API_S_VER_2 */ +/** + * enum iwl_rx_baid_modify_flags - BAID modification flags + * @IWL_RX_BAID_MODIFY_RESET_SN: reset SN/NSSN to zero on this BA session, + * after flushing as with %IWL_RX_BAID_MODIFY_FLUSH_REORDER, and send + * another %BAR_FRAME_RELEASE notification with NSSN 0 so the (empty) + * reorder buffers restart at zero as well + * @IWL_RX_BAID_MODIFY_FLUSH_REORDER: flush reorder buffer (fill all holes) + * and send %BAR_FRAME_RELEASE notification with the new NSSN to the host + * @IWL_RX_BAID_MODIFY_BA_WIN_SIZE: update BA window size, only together + * with %IWL_RX_BAID_MODIFY_RESET_SN or %IWL_RX_BAID_MODIFY_FLUSH_REORDER + */ +enum iwl_rx_baid_modify_flags { + IWL_RX_BAID_MODIFY_RESET_SN = BIT(0), + IWL_RX_BAID_MODIFY_FLUSH_REORDER = BIT(1), + IWL_RX_BAID_MODIFY_BA_WIN_SIZE = BIT(2), +}; + /** * struct iwl_rx_baid_cfg_cmd_modify - BAID modification data * @old_sta_id_mask: old station ID mask * @new_sta_id_mask: new station ID mask * @tid: TID of the BAID - * @reserved: reserved + * @flags: flags, see &enum iwl_rx_baid_modify_flags * @win_size: RX BA session window size to apply to the modified BAID, - * 0 means keep the current one + * when %IWL_RX_BAID_MODIFY_BA_WIN_SIZE is set */ struct iwl_rx_baid_cfg_cmd_modify { __le32 old_sta_id_mask; __le32 new_sta_id_mask; u8 tid; - u8 reserved; + u8 flags; __le16 win_size; } __packed; /* RX_BAID_ALLOCATION_MODIFY_CMD_API_S_VER_3 */ -- 2.34.1 From: Johannes Berg For SMD transition in per-AP MLD PTK mode we need to be able to continue with the PN/replay counters of the old key when adding the new one. Update the FW API to the new version enabling that transfer. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- .../net/wireless/intel/iwlwifi/fw/api/datapath.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h index 9ff3b4fd0f6c..255bf6a484b4 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h @@ -695,6 +695,11 @@ struct iwl_scd_queue_cfg_cmd { * @IWL_SEC_KEY_FLAG_SPP_AMSDU: SPP A-MSDU should be used * @IWL_SEC_KEY_FLAG_CTRL_FRAME: key is used for CIP * @IWL_SEC_KEY_FLAG_ASSOC_ENC: use this key for (Re)Assoc Req/Resp encryption + * @IWL_SEC_KEY_FLAG_SMD_CONT_PN: (add only, version 2) continue the PN of the + * existing key with the same key ID (SMD transition), in this case the + * station mask must have both old and new station (but the old isn't + * actually persisted), the key will be copied and the old one must be + * removed later */ enum iwl_sec_key_flags { IWL_SEC_KEY_FLAG_CIPHER_MASK = 0x07, @@ -709,6 +714,7 @@ enum iwl_sec_key_flags { IWL_SEC_KEY_FLAG_SPP_AMSDU = 0x80, IWL_SEC_KEY_FLAG_CTRL_FRAME = 0x100, IWL_SEC_KEY_FLAG_ASSOC_ENC = 0x200, + IWL_SEC_KEY_FLAG_SMD_CONT_PN = 0x800, }; #define IWL_SEC_WEP_KEY_OFFSET 3 @@ -745,19 +751,19 @@ struct iwl_sec_key_cmd { u8 tkip_mic_tx_key[8]; __le64 rx_seq; __le64 tx_seq; - } __packed add; /* SEC_KEY_ADD_CMD_API_S_VER_1 */ + } __packed add; /* SEC_KEY_ADD_CMD_API_S_VER_1, _VER_2 */ struct { __le32 old_sta_mask; __le32 new_sta_mask; __le32 key_id; __le32 key_flags; - } __packed modify; /* SEC_KEY_MODIFY_CMD_API_S_VER_1 */ + } __packed modify; /* SEC_KEY_MODIFY_CMD_API_S_VER_1, _VER_2 */ struct { __le32 sta_mask; __le32 key_id; __le32 key_flags; - } __packed remove; /* SEC_KEY_REMOVE_CMD_API_S_VER_1 */ - } __packed u; /* SEC_KEY_OPERATION_API_U_VER_1 */ -} __packed; /* SEC_KEY_CMD_API_S_VER_1 */ + } __packed remove; /* SEC_KEY_REMOVE_CMD_API_S_VER_1, _VER_2 */ + } __packed u; /* SEC_KEY_OPERATION_API_U_VER_1, _VER_2 */ +} __packed; /* SEC_KEY_CMD_API_S_VER_1, _VER_2 */ #endif /* __iwl_fw_api_datapath_h__ */ -- 2.34.1 From: Benjamin Berg Split out two helpers from iwl_pcie_rx_handle_rb to simplify the function a bit. This is in preparation for further changes that implement split RB handling. Assisted-by: LLM Signed-off-by: Benjamin Berg Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 197 +++++++++++-------- 1 file changed, 115 insertions(+), 82 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index f033bb51dcca..a6ad557a4548 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -1297,6 +1297,118 @@ static void iwl_pcie_rx_reuse_rbd(struct iwl_trans *trans, } } +/* + * iwl_pcie_rx_recycle_rbd - give an RB descriptor back to the free/used lists + * + * Re-maps the page for the device if we still own it, otherwise hands the + * (now page-less) RBD over to the allocator. + */ +static void iwl_pcie_rx_recycle_rbd(struct iwl_trans *trans, + struct iwl_rxq *rxq, + struct iwl_rx_mem_buffer *rxb, + bool emergency, bool page_stolen) +{ + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + + /* page was stolen from us -- free our reference */ + if (page_stolen) { + __free_pages(rxb->page, trans_pcie->rx_page_order); + rxb->page = NULL; + } + + /* + * Reuse the page if possible. For notification packets and + * SKBs that fail to Rx correctly, add them back into the + * rx_free list for reuse later. + */ + if (rxb->page) { + rxb->page_dma = + dma_map_page(trans->dev, rxb->page, rxb->offset, + trans_pcie->rx_buf_bytes, + DMA_FROM_DEVICE); + if (dma_mapping_error(trans->dev, rxb->page_dma)) { + /* + * free the page(s) as well to not break + * the invariant that the items on the used + * list have no page(s) + */ + __free_pages(rxb->page, trans_pcie->rx_page_order); + rxb->page = NULL; + iwl_pcie_rx_reuse_rbd(trans, rxb, rxq, emergency); + } else { + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + } + } else { + iwl_pcie_rx_reuse_rbd(trans, rxb, rxq, emergency); + } +} + +/* + * iwl_pcie_rx_handle_pkt - hand a single RX packet to the op mode + * + * Returns true if the page was stolen. + */ +static bool iwl_pcie_rx_handle_pkt(struct iwl_trans *trans, + struct iwl_rxq *rxq, + struct iwl_rx_cmd_buffer *rxcb, + struct iwl_rx_packet *pkt, int len) +{ + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_txq *txq = trans_pcie->txqs.txq[trans->conf.cmd_queue]; + bool reclaim; + + maybe_trace_iwlwifi_dev_rx(trans, pkt, len); + + /* Reclaim a command buffer only if this packet is a response + * to a (driver-originated) command. + * If the packet (e.g. Rx frame) originated from uCode, + * there is no command buffer to reclaim. + * Ucode should set SEQ_RX_FRAME bit if ucode-originated, + * but apparently a few don't get set; catch them here. + */ + reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME); + if (reclaim && !pkt->hdr.group_id) { + for (int i = 0; i < trans->conf.n_no_reclaim_cmds; i++) { + if (trans->conf.no_reclaim_cmds[i] == pkt->hdr.cmd) { + reclaim = false; + break; + } + } + } + + if (rxq->id == IWL_DEFAULT_RX_QUEUE) + iwl_op_mode_rx(trans->op_mode, &rxq->napi, rxcb); + else + iwl_op_mode_rx_rss(trans->op_mode, &rxq->napi, rxcb, rxq->id); + + /* + * After here, we should always check rxcb->_page_stolen, + * if it is true then one of the handlers took the page. + */ + + if (reclaim && txq) { + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int index = SEQ_TO_INDEX(sequence); + int cmd_index = iwl_txq_get_cmd_index(txq, index); + + kfree_sensitive(txq->entries[cmd_index].free_buf); + txq->entries[cmd_index].free_buf = NULL; + + /* Invoke any callbacks, transfer the buffer to caller, + * and fire off the (possibly) blocking + * iwl_trans_send_cmd() + * as we reclaim the driver command queue + */ + if (!rxcb->_page_stolen) + iwl_pcie_hcmd_complete(trans, rxcb); + else + IWL_WARN(trans, "Claim null rxb?\n"); + } + + return rxcb->_page_stolen; +} + static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, struct iwl_rxq *rxq, struct iwl_rx_mem_buffer *rxb, @@ -1304,7 +1416,6 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, int i) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - struct iwl_txq *txq = trans_pcie->txqs.txq[trans->conf.cmd_queue]; bool page_stolen = false; int max_len = trans_pcie->rx_buf_bytes; u32 offset = 0; @@ -1316,7 +1427,6 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, while (offset + sizeof(u32) + sizeof(struct iwl_cmd_header) < max_len) { struct iwl_rx_packet *pkt; - bool reclaim; int len; struct iwl_rx_cmd_buffer rxcb = { ._offset = rxb->offset + offset, @@ -1359,91 +1469,14 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, if (len < sizeof(*pkt) || offset > max_len) break; - maybe_trace_iwlwifi_dev_rx(trans, pkt, len); - - /* Reclaim a command buffer only if this packet is a response - * to a (driver-originated) command. - * If the packet (e.g. Rx frame) originated from uCode, - * there is no command buffer to reclaim. - * Ucode should set SEQ_RX_FRAME bit if ucode-originated, - * but apparently a few don't get set; catch them here. */ - reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME); - if (reclaim && !pkt->hdr.group_id) { - int i; - - for (i = 0; i < trans->conf.n_no_reclaim_cmds; i++) { - if (trans->conf.no_reclaim_cmds[i] == - pkt->hdr.cmd) { - reclaim = false; - break; - } - } - } - - if (rxq->id == IWL_DEFAULT_RX_QUEUE) - iwl_op_mode_rx(trans->op_mode, &rxq->napi, - &rxcb); - else - iwl_op_mode_rx_rss(trans->op_mode, &rxq->napi, - &rxcb, rxq->id); - - /* - * After here, we should always check rxcb._page_stolen, - * if it is true then one of the handlers took the page. - */ - - if (reclaim && txq) { - u16 sequence = le16_to_cpu(pkt->hdr.sequence); - int index = SEQ_TO_INDEX(sequence); - int cmd_index = iwl_txq_get_cmd_index(txq, index); - - kfree_sensitive(txq->entries[cmd_index].free_buf); - txq->entries[cmd_index].free_buf = NULL; - - /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking - * iwl_trans_send_cmd() - * as we reclaim the driver command queue */ - if (!rxcb._page_stolen) - iwl_pcie_hcmd_complete(trans, &rxcb); - else - IWL_WARN(trans, "Claim null rxb?\n"); - } + page_stolen |= iwl_pcie_rx_handle_pkt(trans, rxq, &rxcb, + pkt, len); - page_stolen |= rxcb._page_stolen; if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) break; } - /* page was stolen from us -- free our reference */ - if (page_stolen) { - __free_pages(rxb->page, trans_pcie->rx_page_order); - rxb->page = NULL; - } - - /* Reuse the page if possible. For notification packets and - * SKBs that fail to Rx correctly, add them back into the - * rx_free list for reuse later. */ - if (rxb->page != NULL) { - rxb->page_dma = - dma_map_page(trans->dev, rxb->page, rxb->offset, - trans_pcie->rx_buf_bytes, - DMA_FROM_DEVICE); - if (dma_mapping_error(trans->dev, rxb->page_dma)) { - /* - * free the page(s) as well to not break - * the invariant that the items on the used - * list have no page(s) - */ - __free_pages(rxb->page, trans_pcie->rx_page_order); - rxb->page = NULL; - iwl_pcie_rx_reuse_rbd(trans, rxb, rxq, emergency); - } else { - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - } - } else - iwl_pcie_rx_reuse_rbd(trans, rxb, rxq, emergency); + iwl_pcie_rx_recycle_rbd(trans, rxq, rxb, emergency, page_stolen); } static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans, -- 2.34.1 From: Benjamin Berg Change the RX command buffer handling to prepare for split RX buffers. This adds an array of fragments and a helper to create an SKB. Also add appropriate guards everywhere as the code does not expect split RBs at this point. Signed-off-by: Benjamin Berg Assisted-by: LLM Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/dvm/rx.c | 6 ++ .../wireless/intel/iwlwifi/iwl-nvm-parse.c | 1 + .../net/wireless/intel/iwlwifi/iwl-trans.h | 89 +++++++++++++++++-- .../net/wireless/intel/iwlwifi/mld/debugfs.c | 6 +- .../net/wireless/intel/iwlwifi/mld/notif.c | 14 ++- .../net/wireless/intel/iwlwifi/mvm/debugfs.c | 8 +- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 19 +++- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 26 +++--- 8 files changed, 136 insertions(+), 33 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/rx.c b/drivers/net/wireless/intel/iwlwifi/dvm/rx.c index fa2aff5bea6c..1ba3ca606713 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/rx.c @@ -997,6 +997,12 @@ void iwl_rx_dispatch(struct iwl_op_mode *op_mode, struct napi_struct *napi, struct iwl_rx_packet *pkt = rxb_addr(rxb); struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); + if (unlikely(rxb_is_split(rxb))) { + IWL_ERR(priv, "dropping split RX command 0x%04x\n", + WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd)); + return; + } + /* * Do the notification wait before RX handlers so * even if the RX handler consumes the RXB we have diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c index fc5b6ce86d0b..40d081160f36 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c @@ -499,6 +499,7 @@ static void iwl_init_vht_hw_capab(struct iwl_trans *trans, * split up A-MSDUs and the real limit that was set applies. * Note that EHT doesn't honour this (HE copies the VHT value), * but EHT is also entirely disabled for fips_enabled. + * Note that the fips limit can be removed if split RB is enabled. */ switch (iwlwifi_mod_params.amsdu_size) { case IWL_AMSDU_DEF: diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h index f97bde14cdc8..6aee494c6f2d 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h @@ -9,6 +9,7 @@ #include #include /* for page_address */ +#include #include #include @@ -230,34 +231,104 @@ static inline void iwl_free_resp(struct iwl_host_cmd *cmd) free_pages(cmd->_rx_page_addr, cmd->_rx_page_order); } +/* Fits max MPDU size across 2k RBs (AMSDUs are not split when sniffing) */ +#define IWL_RX_MAX_SPLIT_RBS 6 +static_assert(IWL_RX_MAX_SPLIT_RBS <= MAX_SKB_FRAGS); + +/** + * struct iwl_rx_cmd_buffer - an RX packet handed over to the op mode + * @_pages_stolen: the op mode took ownership of @_page and the @_frags pages + * @_rx_page_order: page order of the pages referenced in @_frags + * @truesize: true size of each buffer fragment + * @_frags: List of fragments, page is NULL if there are no further fragments. + * Only has more than one fragment for MPDUs when an SKB will be built + * using iwl_rxb_add_frags. + */ struct iwl_rx_cmd_buffer { - struct page *_page; - int _offset; - bool _page_stolen; + bool _pages_stolen; u32 _rx_page_order; unsigned int truesize; + + struct { + struct page *page; + u32 offset; + } _frags[IWL_RX_MAX_SPLIT_RBS]; }; static inline void *rxb_addr(struct iwl_rx_cmd_buffer *r) { - return (void *)((unsigned long)page_address(r->_page) + r->_offset); + return (void *)((unsigned long)page_address(r->_frags[0].page) + + r->_frags[0].offset); } static inline int rxb_offset(struct iwl_rx_cmd_buffer *r) { - return r->_offset; + return r->_frags[0].offset; } static inline struct page *rxb_steal_page(struct iwl_rx_cmd_buffer *r) { - r->_page_stolen = true; - get_page(r->_page); - return r->_page; + r->_pages_stolen = true; + + get_page(r->_frags[0].page); + + return r->_frags[0].page; +} + +static inline bool rxb_is_split(struct iwl_rx_cmd_buffer *r) +{ + return !!r->_frags[1].page; +} + +/** + * iwl_rxb_add_frags - add received data to an SKB as paged fragments + * @rxb: the RX buffer + * @skb: the SKB to add the data to + * @offset: offset within @rxb's first page of the first byte to add + * @len: number of bytes to add + */ +static inline void iwl_rxb_add_frags(struct iwl_rx_cmd_buffer *rxb, + struct sk_buff *skb, + unsigned int offset, unsigned int len) +{ + rxb->_pages_stolen = true; + + for (unsigned int i = 0; len && i < ARRAY_SIZE(rxb->_frags); i++) { + /* + * Only AX210 HW will put multiple commands into one buffer + * and only then is _frags[0].offset % rxb->truesize != 0 + */ + unsigned int fraglen = + min(len, rxb->truesize - offset - + rxb->_frags[i].offset % rxb->truesize); + struct page *page = rxb->_frags[i].page; + u32 frag_offset = rxb->_frags[i].offset + offset; + + if (WARN_ON_ONCE(!page)) + break; + + if (i > 0 && page == rxb->_frags[i - 1].page && + frag_offset == rxb->_frags[i - 1].offset + rxb->truesize) { + skb_coalesce_rx_frag(skb, skb_shinfo(skb)->nr_frags - 1, + fraglen, rxb->truesize); + } else { + get_page(page); + + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, + page, frag_offset, fraglen, + rxb->truesize); + } + len -= fraglen; + offset = 0; + } } static inline void iwl_free_rxb(struct iwl_rx_cmd_buffer *r) { - __free_pages(r->_page, r->_rx_page_order); + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(r->_frags) && r->_frags[i].page; i++) + __free_pages(r->_frags[i].page, r->_rx_page_order); } #define MAX_NO_RECLAIM_CMDS 6 diff --git a/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c index b8793b71494d..8d2b97ef83a6 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c @@ -474,12 +474,12 @@ static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mld *mld, if (iwl_mld_dbgfs_fw_cmd_disabled(mld)) return -EIO; - rxb._page = alloc_pages(GFP_KERNEL, 0); - if (!rxb._page) + rxb._frags[0].page = alloc_pages(GFP_KERNEL, 0); + if (!rxb._frags[0].page) return -ENOMEM; pkt = rxb_addr(&rxb); - ret = hex2bin(page_address(rxb._page), buf, n_bytes); + ret = hex2bin(page_address(rxb._frags[0].page), buf, n_bytes); if (ret) goto out; diff --git a/drivers/net/wireless/intel/iwlwifi/mld/notif.c b/drivers/net/wireless/intel/iwlwifi/mld/notif.c index 7d9416ecbf92..fb16ca457c28 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/notif.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/notif.c @@ -570,8 +570,8 @@ static void iwl_mld_rx_notif(struct iwl_mld *mld, return; /* Set the async handler entry */ - entry->rxb._page = rxb_steal_page(rxb); - entry->rxb._offset = rxb->_offset; + entry->rxb._frags[0].page = rxb_steal_page(rxb); + entry->rxb._frags[0].offset = rxb->_frags[0].offset; entry->rxb._rx_page_order = rxb->_rx_page_order; entry->rx_h = rx_h; @@ -600,6 +600,11 @@ void iwl_mld_rx(struct iwl_op_mode *op_mode, struct napi_struct *napi, struct iwl_mld *mld = IWL_OP_MODE_GET_MLD(op_mode); u16 cmd_id = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); + if (unlikely(rxb_is_split(rxb))) { + IWL_ERR(mld, "dropping split RX command 0x%04x\n", cmd_id); + return; + } + if (likely(cmd_id == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mld_rx_mpdu(mld, napi, rxb, 0); else if (cmd_id == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE)) @@ -630,6 +635,11 @@ void iwl_mld_rx_rss(struct iwl_op_mode *op_mode, struct napi_struct *napi, if (unlikely(queue >= mld->trans->info.num_rxqs)) return; + if (unlikely(rxb_is_split(rxb))) { + IWL_ERR(mld, "dropping split RX command 0x%04x\n", cmd_id); + return; + } + if (likely(cmd_id == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mld_rx_mpdu(mld, napi, rxb, queue); else if (unlikely(cmd_id == WIDE_ID(DATA_PATH_GROUP, diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c index 90175307a7db..74961bf870f6 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c @@ -1164,7 +1164,7 @@ static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer rxb = { ._rx_page_order = 0, .truesize = 0, /* not used */ - ._offset = 0, + ._frags[0].offset = 0, }; struct iwl_rx_packet *pkt; int bin_len = count / 2; @@ -1177,12 +1177,12 @@ static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm, if (!mvm->trans->mac_cfg->mq_rx_supported) return -EOPNOTSUPP; - rxb._page = alloc_pages(GFP_ATOMIC, 0); - if (!rxb._page) + rxb._frags[0].page = alloc_pages(GFP_ATOMIC, 0); + if (!rxb._frags[0].page) return -ENOMEM; pkt = rxb_addr(&rxb); - ret = hex2bin(page_address(rxb._page), buf, bin_len); + ret = hex2bin(page_address(rxb._frags[0].page), buf, bin_len); if (ret) goto out; diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index c8035023c724..df2c47ebe5ab 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -1761,8 +1761,8 @@ static void iwl_mvm_rx_common(struct iwl_mvm *mvm, if (!entry) return; - entry->rxb._page = rxb_steal_page(rxb); - entry->rxb._offset = rxb->_offset; + entry->rxb._frags[0].page = rxb_steal_page(rxb); + entry->rxb._frags[0].offset = rxb->_frags[0].offset; entry->rxb._rx_page_order = rxb->_rx_page_order; entry->fn = rx_h->fn; entry->context = rx_h->context; @@ -1786,6 +1786,11 @@ static void iwl_mvm_rx(struct iwl_op_mode *op_mode, struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); + if (unlikely(rxb_is_split(rxb))) { + IWL_ERR(mvm, "dropping split RX command 0x%04x\n", cmd); + return; + } + if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mvm_rx_rx_mpdu(mvm, napi, rxb); else if (cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_PHY_CMD)) @@ -1802,6 +1807,11 @@ void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode, struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); + if (unlikely(rxb_is_split(rxb))) { + IWL_ERR(mvm, "dropping split RX command 0x%04x\n", cmd); + return; + } + if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, 0); else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP, @@ -2135,6 +2145,11 @@ static void iwl_mvm_rx_mq_rss(struct iwl_op_mode *op_mode, if (unlikely(queue >= mvm->trans->info.num_rxqs)) return; + if (unlikely(rxb_is_split(rxb))) { + IWL_ERR(mvm, "dropping split RX command 0x%04x\n", cmd); + return; + } + if (unlikely(cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE))) iwl_mvm_rx_frame_release(mvm, napi, rxb, queue); else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP, diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index a6ad557a4548..e66d685eea6f 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -1306,12 +1306,12 @@ static void iwl_pcie_rx_reuse_rbd(struct iwl_trans *trans, static void iwl_pcie_rx_recycle_rbd(struct iwl_trans *trans, struct iwl_rxq *rxq, struct iwl_rx_mem_buffer *rxb, - bool emergency, bool page_stolen) + bool emergency, bool pages_stolen) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); /* page was stolen from us -- free our reference */ - if (page_stolen) { + if (pages_stolen) { __free_pages(rxb->page, trans_pcie->rx_page_order); rxb->page = NULL; } @@ -1347,7 +1347,7 @@ static void iwl_pcie_rx_recycle_rbd(struct iwl_trans *trans, /* * iwl_pcie_rx_handle_pkt - hand a single RX packet to the op mode * - * Returns true if the page was stolen. + * Returns true if the pages were stolen. */ static bool iwl_pcie_rx_handle_pkt(struct iwl_trans *trans, struct iwl_rxq *rxq, @@ -1383,7 +1383,7 @@ static bool iwl_pcie_rx_handle_pkt(struct iwl_trans *trans, iwl_op_mode_rx_rss(trans->op_mode, &rxq->napi, rxcb, rxq->id); /* - * After here, we should always check rxcb->_page_stolen, + * After here, we should always check rxcb->_pages_stolen, * if it is true then one of the handlers took the page. */ @@ -1400,13 +1400,13 @@ static bool iwl_pcie_rx_handle_pkt(struct iwl_trans *trans, * iwl_trans_send_cmd() * as we reclaim the driver command queue */ - if (!rxcb->_page_stolen) + if (!rxcb->_pages_stolen) iwl_pcie_hcmd_complete(trans, rxcb); else IWL_WARN(trans, "Claim null rxb?\n"); } - return rxcb->_page_stolen; + return rxcb->_pages_stolen; } static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, @@ -1416,7 +1416,7 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, int i) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - bool page_stolen = false; + bool pages_stolen = false; int max_len = trans_pcie->rx_buf_bytes; u32 offset = 0; @@ -1429,11 +1429,11 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, struct iwl_rx_packet *pkt; int len; struct iwl_rx_cmd_buffer rxcb = { - ._offset = rxb->offset + offset, ._rx_page_order = trans_pcie->rx_page_order, - ._page = rxb->page, - ._page_stolen = false, .truesize = max_len, + ._frags[0].offset = rxb->offset + offset, + ._frags[0].page = rxb->page, + ._pages_stolen = false, }; pkt = rxb_addr(&rxcb); @@ -1469,14 +1469,14 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, if (len < sizeof(*pkt) || offset > max_len) break; - page_stolen |= iwl_pcie_rx_handle_pkt(trans, rxq, &rxcb, - pkt, len); + pages_stolen |= iwl_pcie_rx_handle_pkt(trans, rxq, &rxcb, + pkt, len); if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) break; } - iwl_pcie_rx_recycle_rbd(trans, rxq, rxb, emergency, page_stolen); + iwl_pcie_rx_recycle_rbd(trans, rxq, rxb, emergency, pages_stolen); } static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans, -- 2.34.1 From: Benjamin Berg Report split RX buffers to the opmode rather than silently discarding them. This requires a few adjustments as multiple RBs will be used each iteration in iwl_pcie_rx_handle. Simply remove the call to iwl_pcie_rx_move_to_allocator. iwl_pcie_rx_reuse_rbd already takes care of that, even if it is not done for every RB there. Signed-off-by: Benjamin Berg Assisted-by: LLM Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- .../net/wireless/intel/iwlwifi/iwl-devtrace.c | 12 +- .../net/wireless/intel/iwlwifi/iwl-devtrace.h | 10 +- .../wireless/intel/iwlwifi/pcie/internal.h | 5 +- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 233 +++++++++++------- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 8 +- 5 files changed, 166 insertions(+), 102 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c index 7e686297963d..cef8618cb9f8 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. - * Copyright (C) 2018, 2023 Intel Corporation + * Copyright (C) 2018, 2023, 2026 Intel Corporation *****************************************************************************/ #include @@ -24,13 +24,15 @@ EXPORT_TRACEPOINT_SYMBOL(iwlwifi_dev_ucode_wrap_event); #include "iwl-devtrace.h" #endif /* __CHECKER__ */ -void __trace_iwlwifi_dev_rx(struct iwl_trans *trans, void *pkt, size_t len) +void __trace_iwlwifi_dev_rx(struct iwl_trans *trans, void *pkt, size_t len, + size_t first_frag_len) { size_t hdr_offset = 0, trace_len; - trace_len = iwl_rx_trace_len(trans, pkt, len, &hdr_offset); + trace_len = iwl_rx_trace_len(trans, pkt, first_frag_len, &hdr_offset); trace_iwlwifi_dev_rx(trans->dev, pkt, len, trace_len, hdr_offset); - if (trace_len < len) - trace_iwlwifi_dev_rx_data(trans->dev, pkt, len, trace_len); + if (trace_len < first_frag_len) + trace_iwlwifi_dev_rx_data(trans->dev, pkt, first_frag_len, + trace_len); } diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h index 99789c7cef3b..b17ba944c45a 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-devtrace.h @@ -3,7 +3,7 @@ * * Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. * Copyright(C) 2016 Intel Deutschland GmbH - * Copyright(c) 2018, 2023, 2025 Intel Corporation + * Copyright(c) 2018, 2023, 2025 - 2026 Intel Corporation *****************************************************************************/ #ifndef __IWLWIFI_DEVICE_TRACE @@ -101,15 +101,17 @@ DECLARE_TRACEPOINT(iwlwifi_dev_rx); DECLARE_TRACEPOINT(iwlwifi_dev_rx_data); #endif -void __trace_iwlwifi_dev_rx(struct iwl_trans *trans, void *pkt, size_t len); +void __trace_iwlwifi_dev_rx(struct iwl_trans *trans, void *pkt, size_t len, + size_t first_frag_len); static inline void maybe_trace_iwlwifi_dev_rx(struct iwl_trans *trans, - void *pkt, size_t len) + void *pkt, size_t len, + size_t first_frag_len) { #ifdef CONFIG_IWLWIFI_DEVICE_TRACING if (tracepoint_enabled(iwlwifi_dev_rx) || tracepoint_enabled(iwlwifi_dev_rx_data)) - __trace_iwlwifi_dev_rx(trans, pkt, len); + __trace_iwlwifi_dev_rx(trans, pkt, len, first_frag_len); #endif } #endif /* __IWLWIFI_DEVICE_TRACE */ diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h index eaf369dbf17b..fba854922d22 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h +++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h @@ -145,9 +145,8 @@ struct iwl_rx_completion_desc_bz { * @rb_stts: driver's pointer to receive buffer status * @rb_stts_dma: bus address of receive buffer status * @lock: per-queue lock + * @incomplete_split_rb: next RB is a continuation of an invalid split RB * @queue: actual rx queue. Not used for multi-rx queue. - * @next_rb_is_fragment: indicates that the previous RB that we handled set - * the fragmented flag, so the next one is still another fragment * @napi: NAPI struct for this queue * @queue_size: size of this queue * @@ -167,7 +166,7 @@ struct iwl_rxq { u32 queue_size; struct list_head rx_free; struct list_head rx_used; - bool need_update, next_rb_is_fragment; + bool need_update, incomplete_split_rb; void *rb_stts; dma_addr_t rb_stts_dma; spinlock_t lock; diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c index e66d685eea6f..0693568f5e9f 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c @@ -1119,6 +1119,7 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans) rxq->read = 0; rxq->write = 0; rxq->write_actual = 0; + rxq->incomplete_split_rb = false; memset(rxq->rb_stts, 0, (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) ? @@ -1352,13 +1353,14 @@ static void iwl_pcie_rx_recycle_rbd(struct iwl_trans *trans, static bool iwl_pcie_rx_handle_pkt(struct iwl_trans *trans, struct iwl_rxq *rxq, struct iwl_rx_cmd_buffer *rxcb, - struct iwl_rx_packet *pkt, int len) + struct iwl_rx_packet *pkt, int len, + size_t first_frag_len) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); struct iwl_txq *txq = trans_pcie->txqs.txq[trans->conf.cmd_queue]; bool reclaim; - maybe_trace_iwlwifi_dev_rx(trans, pkt, len); + maybe_trace_iwlwifi_dev_rx(trans, pkt, len, first_frag_len); /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -1409,32 +1411,94 @@ static bool iwl_pcie_rx_handle_pkt(struct iwl_trans *trans, return rxcb->_pages_stolen; } -static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, - struct iwl_rxq *rxq, - struct iwl_rx_mem_buffer *rxb, - bool emergency, - int i) +static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans, + struct iwl_rxq *rxq, u32 i) +{ + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_rx_mem_buffer *rxb; + u16 vid; + + BUILD_BUG_ON(sizeof(struct iwl_rx_completion_desc) != 32); + BUILD_BUG_ON(sizeof(struct iwl_rx_completion_desc_bz) != 4); + + if (!trans->mac_cfg->mq_rx_supported) { + rxb = rxq->queue[i]; + rxq->queue[i] = NULL; + return rxb; + } + + if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) { + struct iwl_rx_completion_desc_bz *cd = rxq->used_bd; + + vid = le16_to_cpu(cd[i].rbid); + } else if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { + struct iwl_rx_completion_desc *cd = rxq->used_bd; + + vid = le16_to_cpu(cd[i].rbid); + } else { + __le32 *cd = rxq->used_bd; + + vid = le32_to_cpu(cd[i]) & 0x0FFF; /* 12-bit VID */ + } + + if (!vid || vid > RX_POOL_SIZE(trans_pcie->num_rx_bufs)) + goto out_err; + + rxb = trans_pcie->global_table[vid - 1]; + if (rxb->invalid) + goto out_err; + + IWL_DEBUG_RX(trans, "Got virtual RB ID %u\n", (u32)rxb->vid); + + rxb->invalid = true; + + return rxb; + +out_err: + WARN(1, "Invalid rxb from HW %u\n", (u32)vid); + iwl_trans_force_nmi(trans); + return NULL; +} + +static void iwl_pcie_rx_handle_rbs(struct iwl_trans *trans, struct iwl_rxq *rxq, + u32 idx, unsigned int n, bool emergency) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_rx_mem_buffer *rxbs[IWL_RX_MAX_SPLIT_RBS] = {}; + u32 max_len = trans_pcie->rx_buf_bytes; + struct iwl_rx_cmd_buffer rxcb = { + ._rx_page_order = trans_pcie->rx_page_order, + .truesize = max_len, + }; bool pages_stolen = false; - int max_len = trans_pcie->rx_buf_bytes; + bool error = false; u32 offset = 0; - if (WARN_ON(!rxb)) - return; + for (int i = 0; i < n; i++) { + rxbs[i] = iwl_pcie_get_rxb(trans, rxq, + (idx + i) & (rxq->queue_size - 1)); + if (!rxbs[i]) { + error = true; + continue; + } - dma_unmap_page(trans->dev, rxb->page_dma, max_len, DMA_FROM_DEVICE); + dma_unmap_page(trans->dev, rxbs[i]->page_dma, max_len, + DMA_FROM_DEVICE); + + rxcb._frags[i].page = rxbs[i]->page; + rxcb._frags[i].offset = rxbs[i]->offset; + } + if (error) + goto out_recycle; while (offset + sizeof(u32) + sizeof(struct iwl_cmd_header) < max_len) { struct iwl_rx_packet *pkt; - int len; - struct iwl_rx_cmd_buffer rxcb = { - ._rx_page_order = trans_pcie->rx_page_order, - .truesize = max_len, - ._frags[0].offset = rxb->offset + offset, - ._frags[0].page = rxb->page, - ._pages_stolen = false, - }; + u32 first_frag_len; + u32 len; + + /* Reset/update for next command on <= AX210 (n == 1) */ + rxcb._pages_stolen = false; + rxcb._frags[0].offset = rxbs[0]->offset + offset; pkt = rxb_addr(&rxcb); @@ -1462,73 +1526,67 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans, len = iwl_rx_packet_len(pkt); len += sizeof(u32); /* account for status word */ + first_frag_len = min(len, max_len - offset); + /* Verify offset (pre-AX210, n == 1) and length for newer HW */ offset += ALIGN(len, FH_RSCSR_FRAME_ALIGN); - - /* check that what the device tells us made sense */ - if (len < sizeof(*pkt) || offset > max_len) + if (len < sizeof(*pkt) || offset > n * max_len) break; pages_stolen |= iwl_pcie_rx_handle_pkt(trans, rxq, &rxcb, - pkt, len); + pkt, len, + first_frag_len); if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) break; } - iwl_pcie_rx_recycle_rbd(trans, rxq, rxb, emergency, pages_stolen); +out_recycle: + /* the op mode took either all of the pages or none */ + for (int i = 0; i < n; i++) { + if (rxbs[i]) + iwl_pcie_rx_recycle_rbd(trans, rxq, rxbs[i], emergency, + pages_stolen); + } } -static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans, - struct iwl_rxq *rxq, int i, - bool *join) +static bool iwl_pcie_rx_is_fragmented(struct iwl_trans *trans, + struct iwl_rxq *rxq, u32 i) { - struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - struct iwl_rx_mem_buffer *rxb; - u16 vid; - - BUILD_BUG_ON(sizeof(struct iwl_rx_completion_desc) != 32); - BUILD_BUG_ON(sizeof(struct iwl_rx_completion_desc_bz) != 4); - - if (!trans->mac_cfg->mq_rx_supported) { - rxb = rxq->queue[i]; - rxq->queue[i] = NULL; - return rxb; - } - if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) { struct iwl_rx_completion_desc_bz *cd = rxq->used_bd; - vid = le16_to_cpu(cd[i].rbid); - *join = cd[i].flags & IWL_RX_CD_FLAGS_FRAGMENTED; + return cd[i].flags & IWL_RX_CD_FLAGS_FRAGMENTED; } else if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { struct iwl_rx_completion_desc *cd = rxq->used_bd; - vid = le16_to_cpu(cd[i].rbid); - *join = cd[i].flags & IWL_RX_CD_FLAGS_FRAGMENTED; - } else { - __le32 *cd = rxq->used_bd; - - vid = le32_to_cpu(cd[i]) & 0x0FFF; /* 12-bit VID */ + return cd[i].flags & IWL_RX_CD_FLAGS_FRAGMENTED; } - if (!vid || vid > RX_POOL_SIZE(trans_pcie->num_rx_bufs)) - goto out_err; + return false; +} - rxb = trans_pcie->global_table[vid - 1]; - if (rxb->invalid) - goto out_err; +static int iwl_pcie_rx_count_rbs(struct iwl_trans *trans, + struct iwl_rxq *rxq, u32 i, u32 r, + bool *incomplete) +{ + int n = 1; - IWL_DEBUG_RX(trans, "Got virtual RB ID %u\n", (u32)rxb->vid); + while (iwl_pcie_rx_is_fragmented(trans, rxq, i)) { + /* the split RB is too long and cannot be processed */ + if (n == IWL_RX_MAX_SPLIT_RBS) { + *incomplete = true; + return n; + } - rxb->invalid = true; + i = (i + 1) & (rxq->queue_size - 1); + n++; - return rxb; + if (i == r) + return 0; + } -out_err: - WARN(1, "Invalid rxb from HW %u\n", (u32)vid); - iwl_trans_force_nmi(trans); - return NULL; + return n; } /* @@ -1567,12 +1625,12 @@ static int iwl_pcie_rx_handle(struct iwl_trans *trans, int queue, int budget) while (i != r && ++handled < budget) { struct iwl_rb_allocator *rba = &trans_pcie->rba; - struct iwl_rx_mem_buffer *rxb; /* number of RBDs still waiting for page allocation */ u32 rb_pending_alloc = atomic_read(&trans_pcie->rba.req_pending) * RX_CLAIM_REQ_ALLOC; - bool join = false; + bool incomplete = false; + int n; if (unlikely(rb_pending_alloc >= rxq->queue_size / 2 && !emergency)) { @@ -1585,31 +1643,33 @@ static int iwl_pcie_rx_handle(struct iwl_trans *trans, int queue, int budget) IWL_DEBUG_RX(trans, "Q %d: HW = %d, SW = %d\n", rxq->id, r, i); - rxb = iwl_pcie_get_rxb(trans, rxq, i, &join); - if (!rxb) + n = iwl_pcie_rx_count_rbs(trans, rxq, i, r, &incomplete); + + /* incomplete split RB, just leave the RBs unread */ + if (!n) goto out; - if (unlikely(join || rxq->next_rb_is_fragment)) { - rxq->next_rb_is_fragment = join; - /* - * We can only get a multi-RB in the following cases: - * - firmware issue, sending a too big notification - * - sniffer mode with a large A-MSDU - * - large MTU frames (>2k) - * since the multi-RB functionality is limited to newer - * hardware that cannot put multiple entries into a - * single RB. - * - * Right now, the higher layers aren't set up to deal - * with that, so discard all of these. - */ - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; + if (!incomplete && !rxq->incomplete_split_rb) { + iwl_pcie_rx_handle_rbs(trans, rxq, i, n, emergency); } else { - iwl_pcie_rx_handle_rb(trans, rxq, rxb, emergency, i); + IWL_FW_CHECK(trans, !rxq->incomplete_split_rb, + "got too large split RB!\n"); + + /* Not unmapped, put back into the rx_free list */ + for (int j = 0; j < n; j++) { + struct iwl_rx_mem_buffer *rxb = + iwl_pcie_get_rxb(trans, rxq, + (j + i) & (rxq->queue_size - 1)); + + if (rxb) { + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + } + } } - i = (i + 1) & (rxq->queue_size - 1); + rxq->incomplete_split_rb = incomplete; + i = (i + n) & (rxq->queue_size - 1); /* * If we have RX_CLAIM_REQ_ALLOC released rx buffers - @@ -1621,12 +1681,9 @@ static int iwl_pcie_rx_handle(struct iwl_trans *trans, int queue, int budget) if (rxq->used_count >= RX_CLAIM_REQ_ALLOC) iwl_pcie_rx_allocator_get(trans, rxq); - if (rxq->used_count % RX_CLAIM_REQ_ALLOC == 0 && !emergency) { - /* Add the remaining empty RBDs for allocator use */ - iwl_pcie_rx_move_to_allocator(rxq, rba); - } else if (emergency) { - count++; - if (count == 8) { + if (emergency) { + count += n; + if (count >= 8) { count = 0; if (rb_pending_alloc < rxq->queue_size / 3) { IWL_DEBUG_TPT(trans, diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c index ea0279948ef4..d5e3d417bf9f 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c @@ -1632,8 +1632,12 @@ void iwl_pcie_hcmd_complete(struct iwl_trans *trans, else iwl_txq_gen1_tfd_unmap(trans, meta, txq, index); - /* Input error checking is done when commands are added to queue. */ - if (meta->flags & CMD_WANT_SKB) { + /* + * Input error checking is done when commands are added to queue. + * + * Ignore split RBs here, iwl_trans_send_cmd will error out. + */ + if ((meta->flags & CMD_WANT_SKB) && !rxb_is_split(rxb)) { struct page *p = rxb_steal_page(rxb); meta->source->resp_pkt = pkt; -- 2.34.1 From: Benjamin Berg Use iwl_rxb_add_frags() instead of adding the single RX page to the SKB by hand, so that a packet the device split across multiple RBs ends up as a multi-fragment SKB. Skip trying to pull the whole frame for split RBs. Handling that would require adding new logic and the case cannot happen currently. Signed-off-by: Benjamin Berg Assisted-by: LLM Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- .../net/wireless/intel/iwlwifi/mld/debugfs.c | 4 ++- .../net/wireless/intel/iwlwifi/mld/notif.c | 14 +++------- drivers/net/wireless/intel/iwlwifi/mld/rx.c | 8 +++--- .../net/wireless/intel/iwlwifi/mvm/debugfs.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 27 +++++++------------ drivers/net/wireless/intel/iwlwifi/mvm/rx.c | 6 ++--- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 9 +++---- 7 files changed, 27 insertions(+), 43 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c index 8d2b97ef83a6..f92a23f312ba 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/debugfs.c @@ -466,7 +466,9 @@ static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mld *mld, struct iwl_op_mode *opmode = container_of((void *)mld, struct iwl_op_mode, op_mode_specific); - struct iwl_rx_cmd_buffer rxb = {}; + struct iwl_rx_cmd_buffer rxb = { + .truesize = PAGE_SIZE, + }; struct iwl_rx_packet *pkt; int n_bytes = count / 2; int ret = -EINVAL; diff --git a/drivers/net/wireless/intel/iwlwifi/mld/notif.c b/drivers/net/wireless/intel/iwlwifi/mld/notif.c index fb16ca457c28..74043bfd867e 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/notif.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/notif.c @@ -600,13 +600,10 @@ void iwl_mld_rx(struct iwl_op_mode *op_mode, struct napi_struct *napi, struct iwl_mld *mld = IWL_OP_MODE_GET_MLD(op_mode); u16 cmd_id = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); - if (unlikely(rxb_is_split(rxb))) { - IWL_ERR(mld, "dropping split RX command 0x%04x\n", cmd_id); - return; - } - if (likely(cmd_id == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mld_rx_mpdu(mld, napi, rxb, 0); + else if (unlikely(rxb_is_split(rxb))) + IWL_ERR(mld, "dropping split notification 0x%04x\n", cmd_id); else if (cmd_id == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE)) iwl_mld_handle_frame_release_notif(mld, napi, pkt, 0); else if (cmd_id == WIDE_ID(LEGACY_GROUP, BAR_FRAME_RELEASE)) @@ -635,13 +632,10 @@ void iwl_mld_rx_rss(struct iwl_op_mode *op_mode, struct napi_struct *napi, if (unlikely(queue >= mld->trans->info.num_rxqs)) return; - if (unlikely(rxb_is_split(rxb))) { - IWL_ERR(mld, "dropping split RX command 0x%04x\n", cmd_id); - return; - } - if (likely(cmd_id == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mld_rx_mpdu(mld, napi, rxb, queue); + else if (unlikely(rxb_is_split(rxb))) + IWL_ERR(mld, "dropping split notification 0x%04x\n", cmd_id); else if (unlikely(cmd_id == WIDE_ID(DATA_PATH_GROUP, RX_QUEUES_NOTIFICATION))) iwl_mld_handle_rx_queues_sync_notif(mld, napi, pkt, queue); diff --git a/drivers/net/wireless/intel/iwlwifi/mld/rx.c b/drivers/net/wireless/intel/iwlwifi/mld/rx.c index 69867c10a7b1..a92dd3361af6 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/rx.c @@ -2187,7 +2187,8 @@ static int iwl_mld_build_rx_skb(struct iwl_mld *mld, struct sk_buff *skb, * If the latter changes (there are efforts in the standards group * to do so) we should revisit this and ieee80211_data_to_8023(). */ - headlen = (len <= skb_tailroom(skb)) ? len : hdrlen + crypt_len + 8; + headlen = (!rxb_is_split(rxb) && len <= skb_tailroom(skb)) ? + len : hdrlen + crypt_len + 8; /* The firmware may align the packet to DWORD. * The padding is inserted after the IV. @@ -2228,10 +2229,9 @@ static int iwl_mld_build_rx_skb(struct iwl_mld *mld, struct sk_buff *skb, if (fraglen) { int offset = (u8 *)hdr + headlen + pad_len - - (u8 *)rxb_addr(rxb) + rxb_offset(rxb); + (u8 *)rxb_addr(rxb); - skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset, - fraglen, rxb->truesize); + iwl_rxb_add_frags(rxb, skb, offset, fraglen); } return 0; diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c index 74961bf870f6..913eb4db4e50 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c @@ -1163,7 +1163,7 @@ static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm, op_mode_specific); struct iwl_rx_cmd_buffer rxb = { ._rx_page_order = 0, - .truesize = 0, /* not used */ + .truesize = PAGE_SIZE, ._frags[0].offset = 0, }; struct iwl_rx_packet *pkt; diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index df2c47ebe5ab..25e8c0524855 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -1786,13 +1786,10 @@ static void iwl_mvm_rx(struct iwl_op_mode *op_mode, struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); - if (unlikely(rxb_is_split(rxb))) { - IWL_ERR(mvm, "dropping split RX command 0x%04x\n", cmd); - return; - } - if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mvm_rx_rx_mpdu(mvm, napi, rxb); + else if (unlikely(rxb_is_split(rxb))) + IWL_ERR(mvm, "dropping split notification 0x%04x\n", cmd); else if (cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_PHY_CMD)) iwl_mvm_rx_rx_phy_cmd(mvm, rxb); else @@ -1807,13 +1804,10 @@ void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode, struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); - if (unlikely(rxb_is_split(rxb))) { - IWL_ERR(mvm, "dropping split RX command 0x%04x\n", cmd); - return; - } - if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, 0); + else if (unlikely(rxb_is_split(rxb))) + IWL_ERR(mvm, "dropping split notification 0x%04x\n", cmd); else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP, RX_QUEUES_NOTIFICATION))) iwl_mvm_rx_queue_notif(mvm, napi, rxb, 0); @@ -2145,18 +2139,15 @@ static void iwl_mvm_rx_mq_rss(struct iwl_op_mode *op_mode, if (unlikely(queue >= mvm->trans->info.num_rxqs)) return; - if (unlikely(rxb_is_split(rxb))) { - IWL_ERR(mvm, "dropping split RX command 0x%04x\n", cmd); - return; - } - - if (unlikely(cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE))) + if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) + iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, queue); + else if (unlikely(rxb_is_split(rxb))) + IWL_ERR(mvm, "dropping split notification 0x%04x\n", cmd); + else if (unlikely(cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE))) iwl_mvm_rx_frame_release(mvm, napi, rxb, queue); else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP, RX_QUEUES_NOTIFICATION))) iwl_mvm_rx_queue_notif(mvm, napi, rxb, queue); - else if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) - iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, queue); } static const struct iwl_op_mode_ops iwl_mvm_ops_mq = { diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c index 8c197a090c2b..e043c2aa22b0 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c @@ -83,11 +83,9 @@ static void iwl_mvm_pass_packet_to_mac80211(struct iwl_mvm *mvm, fraglen = len - hdrlen; if (fraglen) { - int offset = (u8 *)hdr + hdrlen - - (u8 *)rxb_addr(rxb) + rxb_offset(rxb); + int offset = (u8 *)hdr + hdrlen - (u8 *)rxb_addr(rxb); - skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset, - fraglen, rxb->truesize); + iwl_rxb_add_frags(rxb, skb, offset, fraglen); } ieee80211_rx_napi(mvm->hw, sta ? &sta->deflink : NULL, skb, napi); diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c index 77a3d8dcab57..d0a92c2e1f92 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c @@ -129,8 +129,8 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb, * If the latter changes (there are efforts in the standards group * to do so) we should revisit this and ieee80211_data_to_8023(). */ - headlen = (len <= skb_tailroom(skb)) ? len : - hdrlen + crypt_len + 8; + headlen = (!rxb_is_split(rxb) && len <= skb_tailroom(skb)) ? + len : hdrlen + crypt_len + 8; /* The firmware may align the packet to DWORD. * The padding is inserted after the IV. @@ -184,10 +184,9 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb, if (fraglen) { int offset = (u8 *)hdr + headlen + pad_len - - (u8 *)rxb_addr(rxb) + rxb_offset(rxb); + (u8 *)rxb_addr(rxb); - skb_add_rx_frag(skb, 0, rxb_steal_page(rxb), offset, - fraglen, rxb->truesize); + iwl_rxb_add_frags(rxb, skb, offset, fraglen); } return 0; -- 2.34.1