All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: luca@coelho.fi, linux-wireless@vger.kernel.org
Subject: [PATCH 11/12] iwlwifi: convert flat SAR profile table to a struct version
Date: Thu,  5 Aug 2021 13:19:33 +0300	[thread overview]
Message-ID: <iwlwifi.20210805130823.01530088097f.I903c236a574c7e4c0fc4db101fc39c0f5415ca43@changeid> (raw)
In-Reply-To: <20210805101934.431479-1-luca@coelho.fi>

From: Luca Coelho <luciano.coelho@intel.com>

The SAR profiles have been stored in single-dimension arrays and the
access has been done via a single index.  We will soon need to support
different revisions of this table, which will make the flat array even
harder to handle.  To prepare for that, convert the single-dimension
array to a struct with substructures.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 30 +++++++++++++-------
 drivers/net/wireless/intel/iwlwifi/fw/acpi.h | 13 ++++++---
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
index dff792653a24..f20f0150f407 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
@@ -414,16 +414,25 @@ static int iwl_sar_set_profile(union acpi_object *table,
 			       struct iwl_sar_profile *profile,
 			       bool enabled)
 {
-	int i;
+	int i, j, idx = 0;
 
 	profile->enabled = enabled;
 
-	for (i = 0; i < ACPI_SAR_TABLE_SIZE; i++) {
-		if (table[i].type != ACPI_TYPE_INTEGER ||
-		    table[i].integer.value > U8_MAX)
-			return -EINVAL;
+	/*
+	 * The table from ACPI is flat, but we store it in a
+	 * structured array.
+	 */
+	for (i = 0; i < ACPI_SAR_NUM_CHAINS; i++) {
+		for (j = 0; j < ACPI_SAR_NUM_SUB_BANDS; j++) {
+			if (table[idx].type != ACPI_TYPE_INTEGER ||
+			    table[idx].integer.value > U8_MAX)
+				return -EINVAL;
+
+			profile->chains[i].subbands[j] =
+				table[idx].integer.value;
 
-		profile->table[i] = table[i].integer.value;
+			idx++;
+		}
 	}
 
 	return 0;
@@ -434,7 +443,7 @@ static int iwl_sar_fill_table(struct iwl_fw_runtime *fwrt,
 			      int prof_a, int prof_b)
 {
 	int profs[ACPI_SAR_NUM_CHAINS] = { prof_a, prof_b };
-	int i, j, idx;
+	int i, j;
 
 	for (i = 0; i < ACPI_SAR_NUM_CHAINS; i++) {
 		struct iwl_sar_profile *prof;
@@ -467,11 +476,10 @@ static int iwl_sar_fill_table(struct iwl_fw_runtime *fwrt,
 			       i, profs[i]);
 		IWL_DEBUG_RADIO(fwrt, "  Chain[%d]:\n", i);
 		for (j = 0; j < n_subbands; j++) {
-			idx = i * ACPI_SAR_NUM_SUB_BANDS + j;
 			per_chain[i * n_subbands + j] =
-				cpu_to_le16(prof->table[idx]);
+				cpu_to_le16(prof->chains[i].subbands[j]);
 			IWL_DEBUG_RADIO(fwrt, "    Band[%d] = %d * .125dBm\n",
-					j, prof->table[idx]);
+					j, prof->chains[i].subbands[j]);
 		}
 	}
 
@@ -595,7 +603,7 @@ int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt)
 			break;
 
 		/* go to the next table */
-		pos += ACPI_SAR_TABLE_SIZE;
+		pos += ACPI_SAR_NUM_CHAINS * ACPI_SAR_NUM_SUB_BANDS;
 	}
 
 out_free:
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
index 24e94430e5d9..cd26a155baf7 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
@@ -26,7 +26,6 @@
 
 #define ACPI_WIFI_DOMAIN	(0x07)
 
-#define ACPI_SAR_TABLE_SIZE		10
 #define ACPI_SAR_PROFILE_NUM		4
 
 #define ACPI_GEO_TABLE_SIZE		6
@@ -37,9 +36,11 @@
 #define ACPI_SAR_NUM_SUB_BANDS		5
 #define ACPI_SAR_NUM_TABLES		1
 
-#define ACPI_WRDS_WIFI_DATA_SIZE	(ACPI_SAR_TABLE_SIZE + 2)
+#define ACPI_WRDS_WIFI_DATA_SIZE	(ACPI_SAR_NUM_CHAINS * \
+					 ACPI_SAR_NUM_SUB_BANDS + 2)
 #define ACPI_EWRD_WIFI_DATA_SIZE	((ACPI_SAR_PROFILE_NUM - 1) * \
-					 ACPI_SAR_TABLE_SIZE + 3)
+					 ACPI_SAR_NUM_CHAINS * \
+					 ACPI_SAR_NUM_SUB_BANDS + 3)
 #define ACPI_WGDS_WIFI_DATA_SIZE	19
 #define ACPI_WRDD_WIFI_DATA_SIZE	2
 #define ACPI_SPLC_WIFI_DATA_SIZE	2
@@ -64,9 +65,13 @@
 #define ACPI_PPAG_MIN_HB -16
 #define ACPI_PPAG_MAX_HB 40
 
+struct iwl_sar_profile_chain {
+	u8 subbands[ACPI_SAR_NUM_SUB_BANDS];
+};
+
 struct iwl_sar_profile {
 	bool enabled;
-	u8 table[ACPI_SAR_TABLE_SIZE];
+	struct iwl_sar_profile_chain chains[ACPI_SAR_NUM_CHAINS];
 };
 
 struct iwl_geo_profile {
-- 
2.32.0


  parent reply	other threads:[~2021-08-05 10:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 10:19 [PATCH 00/12] iwlwifi: updates intended for v5.15 2021-08-05 Luca Coelho
2021-08-05 10:19 ` [PATCH 01/12] iwlwifi: mvm: d3: separate TKIP data from key iteration Luca Coelho
2021-08-26 20:35   ` Luca Coelho
2021-08-05 10:19 ` [PATCH 02/12] iwlwifi: mvm: d3: remove fixed cmd_flags argument Luca Coelho
2021-08-05 10:19 ` [PATCH 03/12] iwlwifi: mvm: d3: refactor TSC/RSC configuration Luca Coelho
2021-08-05 10:19 ` [PATCH 04/12] iwlwifi: mvm: d3: add separate key iteration for GTK type Luca Coelho
2021-08-05 10:19 ` [PATCH 05/12] iwlwifi: mvm: d3: make key reprogramming iteration optional Luca Coelho
2021-08-05 10:19 ` [PATCH 06/12] iwlwifi: mvm: d3: implement RSC command version 5 Luca Coelho
2021-08-05 10:19 ` [PATCH 07/12] iwlwifi: mvm: silently drop encrypted frames for unknown station Luca Coelho
2021-08-05 10:19 ` [PATCH 08/12] iwlwifi: mvm: Refactor setting of SSIDs for 6GHz scan Luca Coelho
2021-08-05 10:19 ` [PATCH 09/12] iwlwifi: mvm: fix access to BSS elements Luca Coelho
2021-08-05 10:19 ` [PATCH 10/12] iwlwifi: rename ACPI_SAR_NUM_CHAIN_LIMITS to ACPI_SAR_NUM_CHAINS Luca Coelho
2021-08-05 10:19 ` Luca Coelho [this message]
2021-08-05 10:19 ` [PATCH 12/12] iwlwifi: remove ACPI_SAR_NUM_TABLES definition Luca Coelho

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=iwlwifi.20210805130823.01530088097f.I903c236a574c7e4c0fc4db101fc39c0f5415ca43@changeid \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.