Linux wireless drivers development
 help / color / mirror / Atom feed
From: April John <aprl@berlin.ccc.de>
To: linux-wireless@vger.kernel.org
Cc: miriam.rachel.korenblit@intel.com, April John <aprl@acab.dev>
Subject: [PATCH 2/2] wifi: iwlwifi: mld: add KUnit test for HE PPE parsing
Date: Sun, 30 Aug 2026 15:03:23 +0200	[thread overview]
Message-ID: <20260830130323.187435-2-aprl@berlin.ccc.de> (raw)
In-Reply-To: <20260830130323.187435-1-aprl@berlin.ccc.de>

From: April John <aprl@acab.dev>

Add tests for iwl_mld_he_get_ppe_val() covering both the single-byte
extraction path and the cross-byte path where a 3-bit value spans a
byte boundary.

Signed-off-by: April John <aprl@acab.dev>
---
 drivers/net/wireless/intel/iwlwifi/mld/sta.c  |  3 +-
 drivers/net/wireless/intel/iwlwifi/mld/sta.h  |  4 +
 .../wireless/intel/iwlwifi/mld/tests/Makefile |  2 +-
 .../wireless/intel/iwlwifi/mld/tests/sta.c    | 86 +++++++++++++++++++
 4 files changed, 93 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/mld/tests/sta.c

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/sta.c b/drivers/net/wireless/intel/iwlwifi/mld/sta.c
index 7957ac11b0cd..fd0cee9a92b5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/sta.c
@@ -121,7 +121,7 @@ static u8 iwl_mld_get_uapsd_acs(struct ieee80211_sta *sta)
 	return uapsd_acs | uapsd_acs << 4;
 }
 
-static u8 iwl_mld_he_get_ppe_val(u8 *ppe, u8 ppe_pos_bit)
+VISIBLE_IF_IWLWIFI_KUNIT u8 iwl_mld_he_get_ppe_val(u8 *ppe, u8 ppe_pos_bit)
 {
 	u8 byte_num = ppe_pos_bit / 8;
 	u8 bit_num = ppe_pos_bit % 8;
@@ -146,6 +146,7 @@ static u8 iwl_mld_he_get_ppe_val(u8 *ppe, u8 ppe_pos_bit)
 
 	return res;
 }
+EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mld_he_get_ppe_val);
 
 static void iwl_mld_parse_ppe(struct iwl_mld *mld,
 			      struct iwl_he_pkt_ext_v2 *pkt_ext, u8 nss,
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/sta.h b/drivers/net/wireless/intel/iwlwifi/mld/sta.h
index 98d693235c66..8659bb7bf6cf 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/sta.h
+++ b/drivers/net/wireless/intel/iwlwifi/mld/sta.h
@@ -300,4 +300,8 @@ void iwl_mld_remove_nan_mgmt_sta(struct iwl_mld *mld,
 void iwl_mld_remove_nan_mcast_data_sta(struct iwl_mld *mld,
 				       struct iwl_mld_int_sta *sta);
 
+#if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
+u8 iwl_mld_he_get_ppe_val(u8 *ppe, u8 ppe_pos_bit);
+#endif
+
 #endif /* __iwl_mld_sta_h__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile b/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile
index 2af1fb838520..3201dce9a5b0 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 iwlmld-tests-y += module.o hcmd.o utils.o link.o rx.o agg.o link-selection.o
 iwlmld-tests-y += chan_load_thresh.o
-iwlmld-tests-y += tlc.o
+iwlmld-tests-y += tlc.o sta.o
 
 ccflags-y += -I$(src)/../
 obj-$(CONFIG_IWLWIFI_KUNIT_TESTS) += iwlmld-tests.o
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/sta.c b/drivers/net/wireless/intel/iwlwifi/mld/tests/sta.c
new file mode 100644
index 000000000000..675408661af2
--- /dev/null
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/sta.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/*
+ * KUnit tests for STA capability helper functions
+ *
+ * Copyright (C) 2026 Intel Corporation
+ */
+#include <kunit/test.h>
+
+#include "sta.h"
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+struct ppe_val_case {
+	const char *desc;
+	u8 ppe[2];
+	u8 ppe_pos_bit;
+	u8 expected_val;
+};
+
+static const struct ppe_val_case ppe_val_cases[] = {
+	{
+		.desc = "Aligned in byte 0",
+		.ppe = { 0b111, 0 },
+		.ppe_pos_bit = 0,
+		.expected_val = 7,
+	},
+	{
+		.desc = "Unaligned in byte 0",
+		.ppe = { 0b00111000, 0 },
+		.ppe_pos_bit = 3,
+		.expected_val = 7,
+	},
+	{
+		.desc = "Highest non-crossing position",
+		.ppe = { 0b11100000, 0 },
+		.ppe_pos_bit = 5,
+		.expected_val = 7,
+	},
+	{
+		.desc = "Value in byte 1",
+		.ppe = { 0, 0b00000011 },
+		.ppe_pos_bit = 8,
+		.expected_val = 3,
+	},
+	{
+		.desc = "Cross-byte at bit 6",
+		.ppe = { 0b01000000, 0b00000001 },
+		.ppe_pos_bit = 6,
+		.expected_val = 5,
+	},
+	{
+		.desc = "Cross-byte at bit 7",
+		.ppe = { 0b10000000, 0b00000011 },
+		.ppe_pos_bit = 7,
+		.expected_val = 7,
+	},
+	{
+		.desc = "Cross-byte all zeros",
+		.ppe = { 0, 0 },
+		.ppe_pos_bit = 6,
+		.expected_val = 0,
+	},
+};
+
+KUNIT_ARRAY_PARAM_DESC(ppe_val_cases, ppe_val_cases, desc);
+
+static void test_he_get_ppe_val(struct kunit *test)
+{
+	const struct ppe_val_case *tc = test->param_value;
+	u8 ppe[] = { tc->ppe[0], tc->ppe[1] };
+
+	KUNIT_EXPECT_EQ(test, tc->expected_val,
+			iwl_mld_he_get_ppe_val(ppe, tc->ppe_pos_bit));
+}
+
+static struct kunit_case ppe_val_test_cases[] = {
+	KUNIT_CASE_PARAM(test_he_get_ppe_val, ppe_val_cases_gen_params),
+	{},
+};
+
+static struct kunit_suite ppe_val_tests = {
+	.name = "iwl_mld_ppe_val_tests",
+	.test_cases = ppe_val_test_cases,
+};
+
+kunit_test_suite(ppe_val_tests);
-- 
2.53.0


      reply	other threads:[~2026-08-30 13:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30 13:03 [PATCH 1/2] wifi: iwlwifi: mld: add KUnit tests for TLC rate helpers April John
2026-08-30 13:03 ` April John [this message]

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=20260830130323.187435-2-aprl@berlin.ccc.de \
    --to=aprl@berlin.ccc.de \
    --cc=aprl@acab.dev \
    --cc=linux-wireless@vger.kernel.org \
    --cc=miriam.rachel.korenblit@intel.com \
    /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