mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-25 21:00:50 -05:00
wifi: iwlwifi: mld: KUnit: introduce iwl_mld_kunit_link
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> Link: https://patch.msgid.link/20250313002008.f336491ccc4e.I6b727765eb394a3dbb78cea71e356be1bdc4a17c@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
committed by
Johannes Berg
parent
c008fadb90
commit
de5ca699bc
@@ -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]);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user