Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH 1/2] wifi: iwlwifi: mld: add KUnit tests for TLC rate helpers
@ 2026-08-30 13:03 April John
  2026-08-30 13:03 ` [PATCH 2/2] wifi: iwlwifi: mld: add KUnit test for HE PPE parsing April John
  0 siblings, 1 reply; 2+ messages in thread
From: April John @ 2026-08-30 13:03 UTC (permalink / raw)
  To: linux-wireless; +Cc: miriam.rachel.korenblit, April John

From: April John <aprl@acab.dev>

Add tests for iwl_mld_get_highest_fw_mcs() covering the 2-bit VHT
MCS field extraction for different NSS values, and for
iwl_mld_get_eht_max_nss() covering the min() of the peer RX and own
TX NSS capabilities.

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

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile b/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile
index efa61638b8ee..2af1fb838520 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile
@@ -1,6 +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
 
 ccflags-y += -I$(src)/../
 obj-$(CONFIG_IWLWIFI_KUNIT_TESTS) += iwlmld-tests.o
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/tlc.c b/drivers/net/wireless/intel/iwlwifi/mld/tests/tlc.c
new file mode 100644
index 000000000000..704a1bb1a5ea
--- /dev/null
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/tlc.c
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/*
+ * KUnit tests for TLC rate-selection helper functions
+ *
+ * Copyright (C) 2026 Intel Corporation
+ */
+#include <kunit/test.h>
+
+#include "tlc.h"
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+struct highest_fw_mcs_case {
+	const char *desc;
+	int nss;
+	u16 rx_mcs_map;
+	int expected_mcs;
+};
+
+static const struct highest_fw_mcs_case highest_fw_mcs_cases[] = {
+	{
+		.desc = "NSS 1 supports MCS 0-7",
+		.nss = 1,
+		.rx_mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_7,
+		.expected_mcs = IWL_TLC_MNG_HT_RATE_MCS7,
+	},
+	{
+		.desc = "NSS 1 supports MCS 0-8",
+		.nss = 1,
+		.rx_mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_8,
+		.expected_mcs = IWL_TLC_MNG_HT_RATE_MCS8,
+	},
+	{
+		.desc = "NSS 1 supports MCS 0-9",
+		.nss = 1,
+		.rx_mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9,
+		.expected_mcs = IWL_TLC_MNG_HT_RATE_MCS9,
+	},
+	{
+		.desc = "NSS 2 supports MCS 0-9",
+		.nss = 2,
+		.rx_mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 2,
+		.expected_mcs = IWL_TLC_MNG_HT_RATE_MCS9,
+	},
+	{
+		.desc = "NSS 4 supports MCS 0-8",
+		.nss = 4,
+		.rx_mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_8 << 6,
+		.expected_mcs = IWL_TLC_MNG_HT_RATE_MCS8,
+	},
+};
+
+KUNIT_ARRAY_PARAM_DESC(highest_fw_mcs_cases, highest_fw_mcs_cases, desc);
+
+static void test_highest_fw_mcs(struct kunit *test)
+{
+	const struct highest_fw_mcs_case *tc = test->param_value;
+	struct ieee80211_sta_vht_cap vht_cap = {
+		.vht_mcs.rx_mcs_map = cpu_to_le16(tc->rx_mcs_map),
+	};
+
+	KUNIT_EXPECT_EQ(test, tc->expected_mcs,
+			iwl_mld_get_highest_fw_mcs(&vht_cap, tc->nss));
+}
+
+static struct kunit_case highest_fw_mcs_test_cases[] = {
+	KUNIT_CASE_PARAM(test_highest_fw_mcs, highest_fw_mcs_cases_gen_params),
+	{},
+};
+
+static struct kunit_suite highest_fw_mcs_tests = {
+	.name = "iwl_mld_highest_fw_mcs_tests",
+	.test_cases = highest_fw_mcs_test_cases,
+};
+
+kunit_test_suite(highest_fw_mcs_tests);
+
+struct eht_max_nss_case {
+	const char *desc;
+	u8 rx_nss;
+	u8 tx_nss;
+	u8 expected_nss;
+};
+
+static const struct eht_max_nss_case eht_max_nss_cases[] = {
+	{
+		.desc = "RX limited",
+		.rx_nss = 0x02,
+		.tx_nss = 0x80,
+		.expected_nss = 2,
+	},
+	{
+		.desc = "TX limited",
+		.rx_nss = 0x0f,
+		.tx_nss = 0x30,
+		.expected_nss = 3,
+	},
+	{
+		.desc = "Equal",
+		.rx_nss = 0x05,
+		.tx_nss = 0x50,
+		.expected_nss = 5,
+	},
+	{
+		.desc = "Both zero",
+		.rx_nss = 0x00,
+		.tx_nss = 0x00,
+		.expected_nss = 0,
+	},
+	{
+		.desc = "Both max",
+		.rx_nss = 0x0f,
+		.tx_nss = 0xf0,
+		.expected_nss = 15,
+	},
+};
+
+KUNIT_ARRAY_PARAM_DESC(eht_max_nss_cases, eht_max_nss_cases, desc);
+
+static void test_eht_max_nss(struct kunit *test)
+{
+	const struct eht_max_nss_case *tc = test->param_value;
+
+	KUNIT_EXPECT_EQ(test, tc->expected_nss,
+			iwl_mld_get_eht_max_nss(tc->rx_nss, tc->tx_nss));
+}
+
+static struct kunit_case eht_max_nss_test_cases[] = {
+	KUNIT_CASE_PARAM(test_eht_max_nss, eht_max_nss_cases_gen_params),
+	{},
+};
+
+static struct kunit_suite eht_max_nss_tests = {
+	.name = "iwl_mld_eht_max_nss_tests",
+	.test_cases = eht_max_nss_test_cases,
+};
+
+kunit_test_suite(eht_max_nss_tests);
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
index b6c2fa3664cb..72ddb788ad3e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
@@ -161,7 +161,7 @@ static u8 iwl_mld_get_fw_sgi(struct iwl_mld_tlc_sta_capa *capa)
 	return sgi_chwidths;
 }
 
-static int
+VISIBLE_IF_IWLWIFI_KUNIT int
 iwl_mld_get_highest_fw_mcs(const struct ieee80211_sta_vht_cap *vht_cap,
 			   int nss)
 {
@@ -183,6 +183,7 @@ iwl_mld_get_highest_fw_mcs(const struct ieee80211_sta_vht_cap *vht_cap,
 
 	return 0;
 }
+EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mld_get_highest_fw_mcs);
 
 static void
 iwl_mld_fill_vht_rates(struct iwl_mld_tlc_sta_capa *capa,
@@ -316,7 +317,7 @@ iwl_mld_get_eht_mcs_of_bw(enum IWL_TLC_MCS_PER_BW bw,
 	}
 }
 
-static u8 iwl_mld_get_eht_max_nss(u8 rx_nss, u8 tx_nss)
+VISIBLE_IF_IWLWIFI_KUNIT u8 iwl_mld_get_eht_max_nss(u8 rx_nss, u8 tx_nss)
 {
 	u8 tx = u8_get_bits(tx_nss, IEEE80211_EHT_MCS_NSS_TX);
 	u8 rx = u8_get_bits(rx_nss, IEEE80211_EHT_MCS_NSS_RX);
@@ -325,6 +326,7 @@ static u8 iwl_mld_get_eht_max_nss(u8 rx_nss, u8 tx_nss)
 	 */
 	return min(tx, rx);
 }
+EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mld_get_eht_max_nss);
 
 #define MAX_NSS_MCS(mcs_num, rx, tx) \
 	iwl_mld_get_eht_max_nss((rx)->rx_tx_mcs ##mcs_num## _max_nss, \
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tlc.h b/drivers/net/wireless/intel/iwlwifi/mld/tlc.h
index c7ff209c9ab6..269d0f2a61ef 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tlc.h
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tlc.h
@@ -23,4 +23,10 @@ int iwl_mld_send_tlc_dhc(struct iwl_mld *mld, u8 sta_id, u32 type, u32 data);
 void iwl_mld_tlc_update_phy(struct iwl_mld *mld, struct ieee80211_vif *vif,
 			    struct ieee80211_bss_conf *link_conf);
 
+#if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
+int iwl_mld_get_highest_fw_mcs(const struct ieee80211_sta_vht_cap *vht_cap,
+			       int nss);
+u8 iwl_mld_get_eht_max_nss(u8 rx_nss, u8 tx_nss);
+#endif
+
 #endif /* __iwl_mld_tlc_h__ */

base-commit: 4a2610a5a9fcf77eaad82bb030ec77ec5e381db8
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] wifi: iwlwifi: mld: add KUnit test for HE PPE parsing
  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
  0 siblings, 0 replies; 2+ messages in thread
From: April John @ 2026-08-30 13:03 UTC (permalink / raw)
  To: linux-wireless; +Cc: miriam.rachel.korenblit, April John

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-30 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] wifi: iwlwifi: mld: add KUnit test for HE PPE parsing April John

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox