public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Miri Korenblit <miriam.rachel.korenblit@intel.com>
To: linux-wireless@vger.kernel.org
Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH iwlwifi-next 01/15] wifi: iwlwifi: uefi: add support for PPAG table rev5
Date: Thu, 19 Mar 2026 20:48:41 +0200	[thread overview]
Message-ID: <20260319204647.b9ebcff37599.I1e8bb9cee5a028ed416b6094c0fdbf9f859c6dd8@changeid> (raw)
In-Reply-To: <20260319184855.1981384-1-miriam.rachel.korenblit@intel.com>

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

This table has another subband for UNII-9.
Add defines for the sizes of rev4 and rev5 to easily know how much data
to ask from iwl_uefi_get_verified_variable.
In case rev5 doesn't exist, fallback to rev4.
Check that the revision advertised by the fetched table matches the size
that we got.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/uefi.c | 66 +++++++++++++-------
 drivers/net/wireless/intel/iwlwifi/fw/uefi.h | 17 +++--
 2 files changed, 57 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
index fba41976be6b..84b6f8b7eda9 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
@@ -570,44 +570,66 @@ int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt)
 int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
 {
 	struct uefi_cnv_var_ppag *data;
+	int n_subbands;
+	u32 valid_rev;
 	int ret = 0;
-	int data_sz = sizeof(*data) + sizeof(data->vals[0]) *
-		IWL_NUM_CHAIN_LIMITS * UEFI_PPAG_SUB_BANDS_NUM;
 
 	data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_PPAG_NAME,
-					      "PPAG", data_sz, NULL);
-	if (IS_ERR(data))
-		return -EINVAL;
+					      "PPAG", UEFI_PPAG_DATA_SIZE_V5,
+					      NULL);
+	if (!IS_ERR(data)) {
+		n_subbands = UEFI_PPAG_SUB_BANDS_NUM_REV5;
+		valid_rev = BIT(5);
+
+		goto parse_table;
+	}
+
+	data = iwl_uefi_get_verified_variable(fwrt->trans,
+					      IWL_UEFI_PPAG_NAME,
+					      "PPAG",
+					      UEFI_PPAG_DATA_SIZE_V4,
+					      NULL);
+	if (!IS_ERR(data)) {
+		n_subbands = UEFI_PPAG_SUB_BANDS_NUM_REV4;
+		/* revisions 1-4 have all the same size */
+		valid_rev = BIT(1) | BIT(2) | BIT(3) | BIT(4);
 
-	if (data->revision < IWL_UEFI_MIN_PPAG_REV ||
-	    data->revision > IWL_UEFI_MAX_PPAG_REV) {
+		goto parse_table;
+	}
+
+	return -EINVAL;
+
+parse_table:
+	if (!(BIT(data->revision) & valid_rev)) {
 		ret = -EINVAL;
-		IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI PPAG revision:%d\n",
+		IWL_DEBUG_RADIO(fwrt,
+				"Unsupported UEFI PPAG revision:%d\n",
 				data->revision);
 		goto out;
 	}
 
-	fwrt->ppag_bios_rev = data->revision;
-	fwrt->ppag_flags = iwl_bios_get_ppag_flags(data->ppag_modes,
-						   fwrt->ppag_bios_rev);
-
 	/*
 	 * Make sure fwrt has enough room to hold
 	 * data coming from the UEFI table
 	 */
-	BUILD_BUG_ON(ARRAY_SIZE(fwrt->ppag_chains) *
-		     ARRAY_SIZE(fwrt->ppag_chains[0].subbands) <
-		     IWL_NUM_CHAIN_LIMITS * UEFI_PPAG_SUB_BANDS_NUM);
-
-	for (int chain = 0; chain < IWL_NUM_CHAIN_LIMITS; chain++) {
-		for (int subband = 0;
-		     subband < UEFI_PPAG_SUB_BANDS_NUM;
-		     subband++)
+	if (WARN_ON(ARRAY_SIZE(fwrt->ppag_chains) *
+		    ARRAY_SIZE(fwrt->ppag_chains[0].subbands)  <
+		    UEFI_PPAG_NUM_CHAINS * n_subbands)) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	fwrt->ppag_bios_rev = data->revision;
+	fwrt->ppag_flags = iwl_bios_get_ppag_flags(data->ppag_modes,
+						   fwrt->ppag_bios_rev);
+
+	for (int chain = 0; chain < UEFI_PPAG_NUM_CHAINS; chain++) {
+		for (int subband = 0; subband < n_subbands; subband++)
 			fwrt->ppag_chains[chain].subbands[subband] =
-				data->vals[chain * UEFI_PPAG_SUB_BANDS_NUM + subband];
+				data->vals[chain * n_subbands + subband];
 	}
 
-	iwl_bios_print_ppag(fwrt, UEFI_PPAG_SUB_BANDS_NUM);
+	iwl_bios_print_ppag(fwrt, n_subbands);
 	fwrt->ppag_bios_source = BIOS_SOURCE_UEFI;
 out:
 	kfree(data);
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/uefi.h b/drivers/net/wireless/intel/iwlwifi/fw/uefi.h
index 4f0ce068a589..5046b6a45419 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/uefi.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/uefi.h
@@ -34,8 +34,6 @@
 #define IWL_UEFI_WRDS_REVISION		2
 #define IWL_UEFI_EWRD_REVISION		2
 #define IWL_UEFI_WGDS_REVISION		3
-#define IWL_UEFI_MIN_PPAG_REV		1
-#define IWL_UEFI_MAX_PPAG_REV		4
 #define IWL_UEFI_MIN_WTAS_REVISION	1
 #define IWL_UEFI_MAX_WTAS_REVISION	2
 #define IWL_UEFI_SPLC_REVISION		0
@@ -77,7 +75,9 @@ struct uefi_cnv_common_step_data {
 } __packed;
 
 #define UEFI_SAR_MAX_SUB_BANDS_NUM	11
-#define UEFI_PPAG_SUB_BANDS_NUM		11
+#define UEFI_PPAG_SUB_BANDS_NUM_REV4	11
+#define UEFI_PPAG_SUB_BANDS_NUM_REV5	12
+#define UEFI_PPAG_NUM_CHAINS		2
 #define UEFI_SAR_MAX_CHAINS_PER_PROFILE	4
 
 /*
@@ -143,7 +143,9 @@ struct uefi_cnv_var_wgds {
  * @ppag_modes: values from &enum iwl_ppag_flags
  * @vals: the PPAG values per chain and band as an array.
  *	vals[chain * num_of_subbands + subband] will return the right value.
- *	num_of_subbands is %UEFI_PPAG_SUB_BANDS_NUM.
+ *	num_of_subbands depends on the revision. For revision 5, it is
+ *	%UEFI_PPAG_SUB_BANDS_NUM_REV5, for earlier revision it is
+ *	%UEFI_PPAG_SUB_BANDS_NUM_REV4.
  *	the max number of chains is currently 2
  */
 struct uefi_cnv_var_ppag {
@@ -152,6 +154,13 @@ struct uefi_cnv_var_ppag {
 	s8 vals[];
 } __packed;
 
+#define UEFI_PPAG_DATA_SIZE_V4				\
+	(offsetof(struct uefi_cnv_var_ppag, vals) +	\
+	sizeof(s8) * UEFI_PPAG_NUM_CHAINS * UEFI_PPAG_SUB_BANDS_NUM_REV4)
+#define UEFI_PPAG_DATA_SIZE_V5				\
+	(offsetof(struct uefi_cnv_var_ppag, vals) +	\
+	sizeof(s8) * UEFI_PPAG_NUM_CHAINS * UEFI_PPAG_SUB_BANDS_NUM_REV5)
+
 /* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI
  * @revision: the revision of the table
  * @tas_selection: different options of TAS enablement.
-- 
2.34.1


  reply	other threads:[~2026-03-19 18:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 18:48 [PATCH iwlwifi-next 00/15] wifi: iwlwifi: updates - 2026-03-19 Miri Korenblit
2026-03-19 18:48 ` Miri Korenblit [this message]
2026-03-19 18:48 ` [PATCH iwlwifi-next 02/15] wifi: iwlwifi: restrict TOP reset to some devices Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 03/15] wifi: iwlwifi: mvm: zero iwl_geo_tx_power_profiles_cmd before sending Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 04/15] wifi: iwlwifi: uefi: support the new WRDS and EWRD tables Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 05/15] wifi: iwlwifi: acpi: add support for WRDS rev 3 table Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 06/15] wifi: iwlwifi: acpi: add support for EWRD " Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 07/15] wifi: iwlwifi: mld: support version 11 of REDUCE_TX_POWER_CMD Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 08/15] wifi: iwlwifi: uefi: open code the parsing of the WGDS table Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 09/15] wifi: iwlwifi: uefi: add support for WGDS rev4 Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 10/15] wifi: iwlwifi: acpi: validate the WGDS table Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 11/15] wifi: iwlwifi: acpi: add support for WGDS revision 4 Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 12/15] wifi: iwlwifi: support PER_CHAIN_LIMIT_OFFSET_CMD v6 Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 13/15] wifi: iwlwifi: uefi: mode the comments valid kerneldoc comments Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 14/15] wifi: iwlwifi: remove IWL_MAX_WD_TIMEOUT Miri Korenblit
2026-03-19 18:48 ` [PATCH iwlwifi-next 15/15] wifi: iwlwifi: mld: remove SCAN_TIMEOUT_MSEC Miri Korenblit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260319204647.b9ebcff37599.I1e8bb9cee5a028ed416b6094c0fdbf9f859c6dd8@changeid \
    --to=miriam.rachel.korenblit@intel.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox