diff mbox series

[wireless-next,08/15] wifi: iwlwifi: mld: KUnit: introduce iwl_mld_kunit_link

Message ID 20250313002008.f336491ccc4e.I6b727765eb394a3dbb78cea71e356be1bdc4a17c@changeid (mailing list archive)
State New
Delegated to: Johannes Berg
Headers show
Series wifi: iwlwifi: updates - 2025-03-13 | expand

Checks

Context Check Description
wifibot/fixes_present success Fixes tag not required for -next series
wifibot/series_format success Posting correctly formatted
wifibot/tree_selection success Clearly marked for wireless-next
wifibot/ynl success Generated files up to date; no warnings/errors; no diff in generated;
wifibot/build_32bit success Errors and warnings before: 0 this patch: 0
wifibot/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
wifibot/build_clang success Errors and warnings before: 0 this patch: 0
wifibot/build_clang_rust success No Rust files in patch. Skipping build
wifibot/build_tools success No tools touched, skip
wifibot/check_selftest success No net selftest shell script
wifibot/checkpatch success total: 0 errors, 0 warnings, 0 checks, 227 lines checked
wifibot/deprecated_api success None detected
wifibot/header_inline success No static functions without inline keyword in header files
wifibot/kdoc success Errors and warnings before: 0 this patch: 0
wifibot/source_inline success Was 0 now: 0
wifibot/verify_fixes success No Fixes tag
wifibot/verify_signedoff success Signed-off-by tag matches author and committer

Commit Message

Miri Korenblit March 12, 2025, 10:22 p.m. UTC
To allow setting up association/EMLSR states with more flexibility,
change the relevant functions to receive a new struct, iwl_mld_kunit_link,
which will contain all the link parameters (for now just link id, band
and bandwidth).

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 .../intel/iwlwifi/mld/tests/link-selection.c  | 13 +++---
 .../wireless/intel/iwlwifi/mld/tests/link.c   | 15 +++++--
 .../wireless/intel/iwlwifi/mld/tests/utils.c  | 45 +++++++++----------
 .../wireless/intel/iwlwifi/mld/tests/utils.h  | 22 ++++++---
 4 files changed, 54 insertions(+), 41 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/link-selection.c b/drivers/net/wireless/intel/iwlwifi/mld/tests/link-selection.c
index d835550c1a6b..34782569d67e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tests/link-selection.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/link-selection.c
@@ -126,23 +126,24 @@  static void test_link_grading(struct kunit *test)
 	struct ieee80211_vif *vif;
 	struct ieee80211_bss_conf *link;
 	unsigned int actual_grade;
-	u8 assoc_link_id;
 	/* Extract test case parameters */
 	u8 link_id = test_param->input.link.link_id;
-	enum nl80211_band band = test_param->input.link.chandef->chan->band;
 	bool active = test_param->input.link.active;
 	u16 valid_links;
+	struct iwl_mld_kunit_link assoc_link = {
+		.band = test_param->input.link.chandef->chan->band,
+	};
 
 	/* If the link is not active, use a different link as the assoc link */
 	if (active) {
-		assoc_link_id = link_id;
+		assoc_link.id = link_id;
 		valid_links = BIT(link_id);
 	} else {
-		assoc_link_id = BIT(ffz(BIT(link_id)));
-		valid_links = BIT(assoc_link_id) | BIT(link_id);
+		assoc_link.id = BIT(ffz(BIT(link_id)));
+		valid_links = BIT(assoc_link.id) | BIT(link_id);
 	}
 
-	vif = iwlmld_kunit_setup_mlo_assoc(valid_links, assoc_link_id, band);
+	vif = iwlmld_kunit_setup_mlo_assoc(valid_links, &assoc_link);
 
 	wiphy_lock(mld->wiphy);
 	link = wiphy_dereference(mld->wiphy, vif->link_conf[link_id]);
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/link.c b/drivers/net/wireless/intel/iwlwifi/mld/tests/link.c
index 6e251dbc1dfe..4a4eaa134bd3 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tests/link.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/link.c
@@ -2,7 +2,7 @@ 
 /*
  * KUnit tests for channel helper functions
  *
- * Copyright (C) 2024 Intel Corporation
+ * Copyright (C) 2024-2025 Intel Corporation
  */
 #include <kunit/static_stub.h>
 
@@ -61,6 +61,14 @@  static void test_missed_beacon(struct kunit *test)
 		(const void *)(test->param_value);
 	struct ieee80211_vif *vif;
 	struct iwl_rx_packet *pkt;
+	struct iwl_mld_kunit_link link1 = {
+		.id = 0,
+		.band = NL80211_BAND_6GHZ,
+	};
+	struct iwl_mld_kunit_link link2 = {
+		.id = 1,
+		.band = NL80211_BAND_5GHZ,
+	};
 
 	kunit_activate_static_stub(test, ieee80211_connection_loss,
 				   fake_ieee80211_connection_loss);
@@ -68,12 +76,11 @@  static void test_missed_beacon(struct kunit *test)
 	notif = (void *)pkt->data;
 
 	if (test_param->input.emlsr) {
-		vif = iwlmld_kunit_assoc_emlsr(0x3, NL80211_BAND_5GHZ,
-					       NL80211_BAND_6GHZ);
+		vif = iwlmld_kunit_assoc_emlsr(&link1, &link2);
 	} else {
 		struct iwl_mld_vif *mld_vif;
 
-		vif = iwlmld_kunit_setup_non_mlo_assoc(NL80211_BAND_6GHZ);
+		vif = iwlmld_kunit_setup_non_mlo_assoc(&link1);
 		mld_vif = iwl_mld_vif_from_mac80211(vif);
 		notif->link_id = cpu_to_le32(mld_vif->deflink.fw_id);
 	}
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c b/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c
index 6331cd91cdf6..fa2710661bd5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c
@@ -329,7 +329,7 @@  static void iwlmld_kunit_set_vif_associated(struct ieee80211_vif *vif)
 }
 
 static struct ieee80211_vif *
-iwlmld_kunit_setup_assoc(bool mlo, u8 link_id, enum nl80211_band band)
+iwlmld_kunit_setup_assoc(bool mlo, struct iwl_mld_kunit_link *assoc_link)
 {
 	struct kunit *test = kunit_get_current_test();
 	struct iwl_mld *mld = test->priv;
@@ -337,32 +337,32 @@  iwlmld_kunit_setup_assoc(bool mlo, u8 link_id, enum nl80211_band band)
 	struct ieee80211_bss_conf *link;
 	struct ieee80211_chanctx_conf *chan_ctx;
 
-	KUNIT_ASSERT_TRUE(test, mlo || link_id == 0);
+	KUNIT_ASSERT_TRUE(test, mlo || assoc_link->id == 0);
 
 	vif = iwlmld_kunit_add_vif(mlo, NL80211_IFTYPE_STATION);
 
 	if (mlo)
-		link = iwlmld_kunit_add_link(vif, link_id);
+		link = iwlmld_kunit_add_link(vif, assoc_link->id);
 	else
 		link = &vif->bss_conf;
 
-	chan_ctx = iwlmld_kunit_add_chanctx(band);
+	chan_ctx = iwlmld_kunit_add_chanctx(assoc_link->band);
 
 	wiphy_lock(mld->wiphy);
 	iwlmld_kunit_assign_chanctx_to_link(vif, link, chan_ctx);
 	wiphy_unlock(mld->wiphy);
 
 	/* The AP sta will now be pointer to by mld_vif->ap_sta */
-	iwlmld_kunit_setup_sta(vif, IEEE80211_STA_AUTHORIZED, link_id);
+	iwlmld_kunit_setup_sta(vif, IEEE80211_STA_AUTHORIZED, assoc_link->id);
 
 	iwlmld_kunit_set_vif_associated(vif);
 
 	return vif;
 }
 
-struct ieee80211_vif *iwlmld_kunit_setup_mlo_assoc(u16 valid_links,
-						   u8 assoc_link_id,
-						   enum nl80211_band band)
+struct ieee80211_vif *
+iwlmld_kunit_setup_mlo_assoc(u16 valid_links,
+			     struct iwl_mld_kunit_link *assoc_link)
 {
 	struct kunit *test = kunit_get_current_test();
 	struct ieee80211_vif *vif;
@@ -370,13 +370,13 @@  struct ieee80211_vif *iwlmld_kunit_setup_mlo_assoc(u16 valid_links,
 	KUNIT_ASSERT_TRUE(test,
 			  hweight16(valid_links) == 1 ||
 			  hweight16(valid_links) == 2);
-	KUNIT_ASSERT_TRUE(test, valid_links & BIT(assoc_link_id));
+	KUNIT_ASSERT_TRUE(test, valid_links & BIT(assoc_link->id));
 
-	vif = iwlmld_kunit_setup_assoc(true, assoc_link_id, band);
+	vif = iwlmld_kunit_setup_assoc(true, assoc_link);
 
 	/* Add the other link, if applicable */
 	if (hweight16(valid_links) > 1) {
-		u8 other_link_id = ffs(valid_links & ~BIT(assoc_link_id)) - 1;
+		u8 other_link_id = ffs(valid_links & ~BIT(assoc_link->id)) - 1;
 
 		iwlmld_kunit_add_link(vif, other_link_id);
 	}
@@ -384,9 +384,10 @@  struct ieee80211_vif *iwlmld_kunit_setup_mlo_assoc(u16 valid_links,
 	return vif;
 }
 
-struct ieee80211_vif *iwlmld_kunit_setup_non_mlo_assoc(enum nl80211_band band)
+struct ieee80211_vif *
+iwlmld_kunit_setup_non_mlo_assoc(struct iwl_mld_kunit_link *assoc_link)
 {
-	return iwlmld_kunit_setup_assoc(false, 0, band);
+	return iwlmld_kunit_setup_assoc(false, assoc_link);
 }
 
 struct iwl_rx_packet *
@@ -403,9 +404,8 @@  _iwl_mld_kunit_create_pkt(const void *notif, size_t notif_sz)
 	return pkt;
 }
 
-struct ieee80211_vif *iwlmld_kunit_assoc_emlsr(u16 valid_links,
-					       enum nl80211_band band1,
-					       enum nl80211_band band2)
+struct ieee80211_vif *iwlmld_kunit_assoc_emlsr(struct iwl_mld_kunit_link *link1,
+					       struct iwl_mld_kunit_link *link2)
 {
 	struct kunit *test = kunit_get_current_test();
 	struct iwl_mld *mld = test->priv;
@@ -414,23 +414,20 @@  struct ieee80211_vif *iwlmld_kunit_assoc_emlsr(u16 valid_links,
 	struct ieee80211_chanctx_conf *chan_ctx;
 	struct ieee80211_sta *sta;
 	struct iwl_mld_vif *mld_vif;
-	u8 assoc_link_id, other_link_id;
+	u16 valid_links = BIT(link1->id) | BIT(link2->id);
 
 	KUNIT_ASSERT_TRUE(test, hweight16(valid_links) == 2);
 
-	assoc_link_id = ffs(valid_links) - 1;
-	other_link_id = ffs(valid_links & ~BIT(assoc_link_id)) - 1;
-
-	vif = iwlmld_kunit_setup_mlo_assoc(valid_links, assoc_link_id, band1);
+	vif = iwlmld_kunit_setup_mlo_assoc(valid_links, link1);
 	mld_vif = iwl_mld_vif_from_mac80211(vif);
 
 	/* Activate second link */
 	wiphy_lock(mld->wiphy);
 
-	link = wiphy_dereference(mld->wiphy, vif->link_conf[other_link_id]);
+	link = wiphy_dereference(mld->wiphy, vif->link_conf[link2->id]);
 	KUNIT_EXPECT_NOT_NULL(test, link);
 
-	chan_ctx = iwlmld_kunit_add_chanctx(band2);
+	chan_ctx = iwlmld_kunit_add_chanctx(link2->band);
 	iwlmld_kunit_assign_chanctx_to_link(vif, link, chan_ctx);
 
 	wiphy_unlock(mld->wiphy);
@@ -439,7 +436,7 @@  struct ieee80211_vif *iwlmld_kunit_assoc_emlsr(u16 valid_links,
 	sta = mld_vif->ap_sta;
 	KUNIT_EXPECT_NOT_NULL(test, sta);
 
-	iwlmld_kunit_alloc_link_sta(sta, other_link_id);
+	iwlmld_kunit_alloc_link_sta(sta, link2->id);
 
 	return vif;
 }
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.h b/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.h
index 9b1f2ada997f..bb757a7dd8e7 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.h
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.h
@@ -13,6 +13,12 @@  struct iwl_mld;
 
 int iwlmld_kunit_test_init(struct kunit *test);
 
+struct iwl_mld_kunit_link {
+	u8 id;
+	enum nl80211_band band;
+	enum nl80211_chan_width bandwidth;
+};
+
 enum nl80211_iftype;
 
 struct ieee80211_vif *iwlmld_kunit_add_vif(bool mlo, enum nl80211_iftype type);
@@ -88,10 +94,12 @@  struct ieee80211_sta *iwlmld_kunit_setup_sta(struct ieee80211_vif *vif,
 					     enum ieee80211_sta_state state,
 					     int link_id);
 
-struct ieee80211_vif *iwlmld_kunit_setup_mlo_assoc(u16 valid_links,
-						   u8 assoc_link_id,
-						   enum nl80211_band band);
-struct ieee80211_vif *iwlmld_kunit_setup_non_mlo_assoc(enum nl80211_band band);
+struct ieee80211_vif *
+iwlmld_kunit_setup_mlo_assoc(u16 valid_links,
+			     struct iwl_mld_kunit_link *assoc_link);
+
+struct ieee80211_vif *
+iwlmld_kunit_setup_non_mlo_assoc(struct iwl_mld_kunit_link *assoc_link);
 
 struct iwl_rx_packet *
 _iwl_mld_kunit_create_pkt(const void *notif, size_t notif_sz);
@@ -99,9 +107,9 @@  _iwl_mld_kunit_create_pkt(const void *notif, size_t notif_sz);
 #define iwl_mld_kunit_create_pkt(_notif)	\
 	_iwl_mld_kunit_create_pkt(&(_notif), sizeof(_notif))
 
-struct ieee80211_vif *iwlmld_kunit_assoc_emlsr(u16 valid_links,
-					       enum nl80211_band band1,
-					       enum nl80211_band band2);
+struct ieee80211_vif *
+iwlmld_kunit_assoc_emlsr(struct iwl_mld_kunit_link *link1,
+			 struct iwl_mld_kunit_link *link2);
 
 struct element *iwlmld_kunit_gen_element(u8 id, const void *data, size_t len);