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>,
	Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH iwlwifi-next 08/15] wifi: iwlwifi: uefi: open code the parsing of the WGDS table
Date: Thu, 19 Mar 2026 20:48:48 +0200	[thread overview]
Message-ID: <20260319204647.140706e6e91f.I83ca04932bc21aa358119890001e876ced1e1bda@changeid> (raw)
In-Reply-To: <20260319184855.1981384-1-miriam.rachel.korenblit@intel.com>

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

We will soon add support for UNII-9 band in the WGDS table. We need to
decouple the UEFI code from the firmware runtime code.
The firmware runtime is just a software object which will need to grow
and UEFI objects need a new revision to grow. Existing systems will keep
the same UEFI objects.

Just like PPAG and SAR, stop using structures to parse the UEFI tables
since the layout depends on the revision.
The support for the new revision will be added in the next patch, for
now, just do the ground work.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/uefi.c | 33 +++++++++++++++++---
 drivers/net/wireless/intel/iwlwifi/fw/uefi.h | 18 +++++++++--
 2 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
index 3d3d698bacd0..ccac50385175 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/uefi.c
@@ -593,10 +593,11 @@ int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt)
 int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt)
 {
 	struct uefi_cnv_var_wgds *data;
-	int i, ret = 0;
+	int ret = 0;
 
 	data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WGDS_NAME,
-					      "WGDS", sizeof(*data), NULL);
+					      "WGDS", UEFI_WGDS_TABLE_SIZE_REV3,
+					      NULL);
 	if (IS_ERR(data))
 		return -EINVAL;
 
@@ -615,10 +616,32 @@ int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt)
 		goto out;
 	}
 
+	if (WARN_ON(BIOS_GEO_MAX_PROFILE_NUM >
+		    ARRAY_SIZE(fwrt->geo_profiles) ||
+		    UEFI_GEO_NUM_BANDS_REV3 >
+		    ARRAY_SIZE(fwrt->geo_profiles[0].bands) ||
+		    BIOS_GEO_NUM_CHAINS >
+		    ARRAY_SIZE(fwrt->geo_profiles[0].bands[0].chains))) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	fwrt->geo_rev = data->revision;
-	for (i = 0; i < data->num_profiles; i++)
-		memcpy(&fwrt->geo_profiles[i], &data->geo_profiles[i],
-		       sizeof(struct iwl_geo_profile));
+	for (int prof = 0; prof < data->num_profiles; prof++) {
+		const u8 *val = &data->vals[UEFI_WGDS_PROFILE_SIZE_REV3 * prof];
+		struct iwl_geo_profile *geo_prof = &fwrt->geo_profiles[prof];
+
+		for (int subband = 0;
+		     subband < UEFI_GEO_NUM_BANDS_REV3;
+		     subband++) {
+			geo_prof->bands[subband].max = *val++;
+
+			for (int chain = 0;
+			     chain < BIOS_GEO_NUM_CHAINS;
+			     chain++)
+				geo_prof->bands[subband].chains[chain] = *val++;
+		}
+	}
 
 	fwrt->geo_num_profiles = data->num_profiles;
 	fwrt->geo_enabled = true;
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/uefi.h b/drivers/net/wireless/intel/iwlwifi/fw/uefi.h
index aa5a4c5a7392..3959937242d8 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/uefi.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/uefi.h
@@ -81,6 +81,8 @@ struct uefi_cnv_common_step_data {
 
 #define UEFI_SAR_MAX_CHAINS_PER_PROFILE	4
 
+#define UEFI_GEO_NUM_BANDS_REV3		3
+
 /*
  * struct uefi_cnv_var_wrds - WRDS table as defined in UEFI
  *
@@ -145,14 +147,26 @@ struct uefi_cnv_var_ewrd {
  * @revision: the revision of the table
  * @num_profiles: the number of geo profiles we have in the table.
  *	The first 3 are mandatory, and can have up to 8.
- * @geo_profiles: a per-profile table of the offsets to add to SAR values.
+ * @vals: a per-profile table of the offsets to add to SAR values. This is an
+ *	array of profiles, each profile is an array of
+ *	&struct iwl_geo_profile_band, one for each subband.
+ *	There are %UEFI_GEO_NUM_BANDS_REV3 subbands.
  */
 struct uefi_cnv_var_wgds {
 	u8 revision;
 	u8 num_profiles;
-	struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM];
+	u8 vals[];
 } __packed;
 
+/* struct iwl_geo_profile_band is 3 bytes-long, but since it is not packed,
+ * we can't use sizeof()
+ */
+#define UEFI_WGDS_PROFILE_SIZE_REV3 (sizeof(u8) * 3 * UEFI_GEO_NUM_BANDS_REV3)
+
+#define UEFI_WGDS_TABLE_SIZE_REV3				\
+	(offsetof(struct uefi_cnv_var_wgds, vals) +		\
+	 UEFI_WGDS_PROFILE_SIZE_REV3 * BIOS_GEO_MAX_PROFILE_NUM)
+
 /*
  * struct uefi_cnv_var_ppag - PPAG table as defined in UEFI
  * @revision: the revision of the table
-- 
2.34.1


  parent 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 ` [PATCH iwlwifi-next 01/15] wifi: iwlwifi: uefi: add support for PPAG table rev5 Miri Korenblit
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 ` Miri Korenblit [this message]
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.140706e6e91f.I83ca04932bc21aa358119890001e876ced1e1bda@changeid \
    --to=miriam.rachel.korenblit@intel.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=johannes.berg@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