wifi: iwlwifi: cfg: unify num_rbds config
authorJohannes Berg <johannes.berg@intel.com>
Fri, 9 May 2025 10:44:41 +0000 (13:44 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Sat, 10 May 2025 18:42:16 +0000 (21:42 +0300)
This should depend on both the RF (VHT/HE/EHT support) and
the MAC (<=22000 can put multiple frames into one buffer),
so unify the config in the struct iwl_cfg to just have it
sized according to the RF, and then double it for all the
MACs starting from AX210 (So/Ty).

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20250509104454.2582160-3-miriam.rachel.korenblit@intel.com
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
12 files changed:
drivers/net/wireless/intel/iwlwifi/cfg/22000.c
drivers/net/wireless/intel/iwlwifi/cfg/9000.c
drivers/net/wireless/intel/iwlwifi/cfg/ax210.c
drivers/net/wireless/intel/iwlwifi/cfg/bz.c
drivers/net/wireless/intel/iwlwifi/cfg/dr.c
drivers/net/wireless/intel/iwlwifi/cfg/sc.c
drivers/net/wireless/intel/iwlwifi/iwl-config.h
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
drivers/net/wireless/intel/iwlwifi/pcie/rx.c

index 92ae336405fdaad14fe4e2d95ee8de60761a468e..0ae910828704948cc90dbd67c73948307fd1ca3d 100644 (file)
@@ -131,16 +131,6 @@ const struct iwl_mac_cfg iwl_qu_long_latency_mac_cfg = {
        .ltr_delay = IWL_CFG_TRANS_LTR_DELAY_2500US,
 };
 
-/*
- * If the device doesn't support HE, no need to have that many buffers.
- * 22000 devices can split multiple frames into a single RB, so fewer are
- * needed; AX210 cannot (but use smaller RBs by default) - these sizes
- * were picked according to 8 MSDUs inside 256 A-MSDUs in an A-MPDU, with
- * additional overhead to account for processing time.
- */
-#define IWL_NUM_RBDS_NON_HE            512
-#define IWL_NUM_RBDS_22000_HE          2048
-
 /*
  * All JF radio modules are part of the 9000 series, but the MAC part
  * looks more like 22000.  That's why this device is here, but called
@@ -182,17 +172,17 @@ const char iwl_ax201_killer_1650i_name[] =
 const struct iwl_cfg iwl_qu_hr1 = {
        IWL_DEVICE_22500,
        .tx_with_siso_diversity = true,
-       .num_rbds = IWL_NUM_RBDS_22000_HE,
+       .num_rbds = IWL_NUM_RBDS_HE,
 };
 
 const struct iwl_cfg iwl_qu_hr = {
        IWL_DEVICE_22500,
-       .num_rbds = IWL_NUM_RBDS_22000_HE,
+       .num_rbds = IWL_NUM_RBDS_HE,
 };
 
 const struct iwl_cfg iwl_qu_hr_80mhz = {
        IWL_DEVICE_22500,
-       .num_rbds = IWL_NUM_RBDS_22000_HE,
+       .num_rbds = IWL_NUM_RBDS_HE,
        .bw_limit = 80,
 };
 
index 5424133fae1dc1e6b4ce9e96b630f959c9d2a99f..e4f99cef6d7a376e028cc2f2807bd94594b80d94 100644 (file)
@@ -105,7 +105,7 @@ static const struct iwl_tt_params iwl9000_tt_params = {
        .dccm2_offset = IWL9000_DCCM2_OFFSET,                           \
        .dccm2_len = IWL9000_DCCM2_LEN,                                 \
        .thermal_params = &iwl9000_tt_params,                           \
-       .num_rbds = 512,                                                \
+       .num_rbds = IWL_NUM_RBDS_NON_HE,                                \
        .vht_mu_mimo_supported = true,                                  \
        .nvm_type = IWL_NVM_EXT,                                        \
        .ht_params = {                                                  \
index d0a8069196b2f8b0da48fbda2ff1e6954b02a6fe..6d3c1e032265bf47051b8b1c54bcde36aa8cc62c 100644 (file)
@@ -141,16 +141,6 @@ const struct iwl_mac_cfg iwl_so_long_latency_imr_mac_cfg = {
        .imr_enabled = true,
 };
 
-/*
- * If the device doesn't support HE, no need to have that many buffers.
- * AX210 devices can split multiple frames into a single RB, so fewer are
- * needed; AX210 cannot (but use smaller RBs by default) - these sizes
- * were picked according to 8 MSDUs inside 256 A-MSDUs in an A-MPDU, with
- * additional overhead to account for processing time.
- */
-#define IWL_NUM_RBDS_NON_HE            512
-#define IWL_NUM_RBDS_AX210_HE          4096
-
 const struct iwl_mac_cfg iwl_ma_mac_cfg = {
        .device_family = IWL_DEVICE_FAMILY_AX210,
        .base = &iwl_ax210_base,
@@ -193,17 +183,17 @@ const char iwl_ax210_name[] = "Intel(R) Wi-Fi 6 AX210 160MHz";
 const struct iwl_cfg iwl_cfg_ma = {
        .uhb_supported = true,
        IWL_DEVICE_AX210,
-       .num_rbds = IWL_NUM_RBDS_AX210_HE,
+       .num_rbds = IWL_NUM_RBDS_HE,
 };
 
 const struct iwl_cfg iwl_cfg_so_a0_hr_a0 = {
        IWL_DEVICE_AX210,
-       .num_rbds = IWL_NUM_RBDS_AX210_HE,
+       .num_rbds = IWL_NUM_RBDS_HE,
 };
 
 const struct iwl_cfg iwl_cfg_so_a0_hr_a0_80mhz = {
        IWL_DEVICE_AX210,
-       .num_rbds = IWL_NUM_RBDS_AX210_HE,
+       .num_rbds = IWL_NUM_RBDS_HE,
        .bw_limit = 80,
 };
 
index 86871b0431b1ef6c63cab5e45c49534969087373..dc1b4930c24ab84013df38ac9205c48b2d945dee 100644 (file)
@@ -106,12 +106,6 @@ static const struct iwl_family_base_params iwl_bz_base = {
        .nvm_ver = IWL_BZ_NVM_VERSION,                                  \
        .nvm_type = IWL_NVM_EXT
 
-/*
- * This size was picked according to 8 MSDUs inside 512 A-MSDUs in an
- * A-MPDU, with additional overhead to account for processing time.
- */
-#define IWL_NUM_RBDS_BZ_EHT            (512 * 16)
-
 const struct iwl_mac_cfg iwl_bz_mac_cfg = {
        .device_family = IWL_DEVICE_FAMILY_BZ,
        .base = &iwl_bz_base,
@@ -142,13 +136,13 @@ const char iwl_mtp_name[] = "Intel(R) Wi-Fi 7 BE202 160MHz";
 const struct iwl_cfg iwl_cfg_bz = {
        .uhb_supported = true,
        IWL_DEVICE_BZ,
-       .num_rbds = IWL_NUM_RBDS_BZ_EHT,
+       .num_rbds = IWL_NUM_RBDS_EHT,
 };
 
 const struct iwl_cfg iwl_cfg_bz_160mhz = {
        .uhb_supported = true,
        IWL_DEVICE_BZ,
-       .num_rbds = IWL_NUM_RBDS_BZ_EHT,
+       .num_rbds = IWL_NUM_RBDS_EHT,
        .bw_limit = 160,
 };
 
index 6696c30ed7b66584ffd319f5df28b13aad09def5..91da094231585b45f2f62ebcb06228f460bcfc87 100644 (file)
@@ -93,7 +93,7 @@ static const struct iwl_family_base_params iwl_dr_base = {
        .nvm_ver = IWL_DR_NVM_VERSION,                                  \
        .nvm_type = IWL_NVM_EXT,                                        \
        .uhb_supported = true,                                          \
-       .num_rbds = IWL_NUM_RBDS_DR_EHT,                                \
+       .num_rbds = IWL_NUM_RBDS_EHT,                           \
        .ht_params = {                                                  \
                .stbc = true,                                           \
                .ldpc = true,                                           \
@@ -101,12 +101,6 @@ static const struct iwl_family_base_params iwl_dr_base = {
                              BIT(NL80211_BAND_5GHZ),                   \
        }
 
-/*
- * This size was picked according to 8 MSDUs inside 512 A-MSDUs in an
- * A-MPDU, with additional overhead to account for processing time.
- */
-#define IWL_NUM_RBDS_DR_EHT            (512 * 16)
-
 const struct iwl_mac_cfg iwl_dr_mac_cfg = {
        .device_family = IWL_DEVICE_FAMILY_DR,
        .base = &iwl_dr_base,
index 6669dc3160193f9fbf9fdaafa125f242d309afdd..6db25355df4277bd778471c947128e049834bfc2 100644 (file)
@@ -100,7 +100,7 @@ static const struct iwl_family_base_params iwl_sc_base = {
        .nvm_ver = IWL_SC_NVM_VERSION,                                  \
        .nvm_type = IWL_NVM_EXT,                                        \
        .uhb_supported = true,                                          \
-       .num_rbds = IWL_NUM_RBDS_SC_EHT,                                \
+       .num_rbds = IWL_NUM_RBDS_EHT,                           \
        .ht_params = {                                                  \
                .stbc = true,                                           \
                .ldpc = true,                                           \
@@ -108,12 +108,6 @@ static const struct iwl_family_base_params iwl_sc_base = {
                              BIT(NL80211_BAND_5GHZ),                   \
        }
 
-/*
- * This size was picked according to 8 MSDUs inside 512 A-MSDUs in an
- * A-MPDU, with additional overhead to account for processing time.
- */
-#define IWL_NUM_RBDS_SC_EHT            (512 * 16)
-
 const struct iwl_mac_cfg iwl_sc_mac_cfg = {
        .device_family = IWL_DEVICE_FAMILY_SC,
        .base = &iwl_sc_base,
index 9e6c9650fbae67c866affa7efdeff684f95e62ff..3593914793a57be7d6629c1ed9eafbb3db37311d 100644 (file)
@@ -342,6 +342,16 @@ struct iwl_mac_cfg {
            imr_enabled:1;
 };
 
+/*
+ * These sizes were picked according to 8 MSDUs inside 64/256/612 A-MSDUs
+ * in an A-MPDU, with additional overhead to account for processing time.
+ * They will be doubled for MACs starting from So/Ty that don't support
+ * putting multiple frames into a single buffer.
+ */
+#define IWL_NUM_RBDS_NON_HE            (64 * 8)
+#define IWL_NUM_RBDS_HE                        (256 * 8)
+#define IWL_NUM_RBDS_EHT               (512 * 8)
+
 /**
  * struct iwl_cfg
  * @fw_name_pre: Firmware filename prefix. The api version and extension
index 904df78297f3cd59488d43cbe2e20d4f2343a4f8..894436a6535116bdee407f120d8226023dec843f 100644 (file)
@@ -1214,6 +1214,19 @@ static inline bool iwl_trans_is_hw_error_value(u32 val)
 
 void iwl_trans_free_restart_list(void);
 
+static inline u16 iwl_trans_get_num_rbds(struct iwl_trans *trans)
+{
+       u16 result = trans->cfg->num_rbds;
+
+       /*
+        * Since AX210 family (So/Ty) the device cannot put mutliple
+        * frames into the same buffer, so double the value for them.
+        */
+       if (trans->mac_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
+               return 2 * result;
+       return result;
+}
+
 /*****************************************************
  * PCIe handling
  *****************************************************/
index dcc8edeb34ff725aa2b47f4ed2c80efafaaa47c7..4759e570e807503d4459bbf0f98691dacb984df5 100644 (file)
@@ -256,7 +256,7 @@ int iwl_pcie_ctxt_info_gen3_alloc(struct iwl_trans *trans,
        ctxt_info_gen3->mtr_size =
                cpu_to_le16(TFD_QUEUE_CB_SIZE(cmdq_size));
        ctxt_info_gen3->mcr_size =
-               cpu_to_le16(RX_QUEUE_CB_SIZE(trans->cfg->num_rbds));
+               cpu_to_le16(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)));
 
        trans_pcie->ctxt_info_gen3 = ctxt_info_gen3;
        trans_pcie->prph_info = prph_info;
index cc3e3d91b27f5e100a45e196e646233c9156a4c7..cb36baac14da88874b7b13074180dc2a20366048 100644 (file)
@@ -202,10 +202,10 @@ int iwl_pcie_ctxt_info_init(struct iwl_trans *trans,
                rb_size = IWL_CTXT_INFO_RB_SIZE_4K;
        }
 
-       WARN_ON(RX_QUEUE_CB_SIZE(trans->cfg->num_rbds) > 12);
+       WARN_ON(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)) > 12);
        control_flags = IWL_CTXT_INFO_TFD_FORMAT_LONG;
        control_flags |=
-               u32_encode_bits(RX_QUEUE_CB_SIZE(trans->cfg->num_rbds),
+               u32_encode_bits(RX_QUEUE_CB_SIZE(iwl_trans_get_num_rbds(trans)),
                                IWL_CTXT_INFO_RB_CB_SIZE);
        control_flags |= u32_encode_bits(rb_size, IWL_CTXT_INFO_RB_SIZE);
        ctxt_info->control.control_flags = cpu_to_le32(control_flags);
index 45a62733b28a7773ce56c5b211f9cce44ec587c0..7db0ca1a59aa6613659c7ff23ba828d3455c901b 100644 (file)
@@ -1864,7 +1864,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        ret = -EINVAL;
                        goto out_free_trans;
                }
-               trans_pcie->num_rx_bufs = iwl_trans->cfg->num_rbds;
+               trans_pcie->num_rx_bufs = iwl_trans_get_num_rbds(iwl_trans);
        } else {
                trans_pcie->num_rx_bufs = RX_QUEUE_SIZE;
        }
index c283ceff0417ef226eab49c8eeb85a627b2a3684..c5fdadf7de1f89aff64771b2d78f91fab2ec1f9b 100644 (file)
@@ -722,7 +722,7 @@ static int iwl_pcie_alloc_rxq_dma(struct iwl_trans *trans,
 
        spin_lock_init(&rxq->lock);
        if (trans->mac_cfg->mq_rx_supported)
-               rxq->queue_size = trans->cfg->num_rbds;
+               rxq->queue_size = iwl_trans_get_num_rbds(trans);
        else
                rxq->queue_size = RX_QUEUE_SIZE;