mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
wifi: iwlwifi: mld: Add KUnit tests for channel-load thresholds
Add a KUnit test suite for iwl_mld_chan_load_requires_scan, covering level-up, level-down, and no-change transitions. The test directly sets channel-load values, validating scan-trigger decisions and updated load levels Signed-off-by: Avinash Bhatt <avinash.bhatt@intel.com> Link: https://patch.msgid.link/20260512222731.4dd3ccaffc46.I9c1f210e5ef25248097a226f4b3a2af5fbcf3c87@changeid Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
This commit is contained in:
parent
59a26553f1
commit
ace3199321
|
|
@ -852,6 +852,7 @@ bool iwl_mld_chan_load_requires_scan(struct iwl_mld *mld,
|
|||
|
||||
return scan_trig;
|
||||
}
|
||||
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mld_chan_load_requires_scan);
|
||||
|
||||
static unsigned int
|
||||
iwl_mld_get_default_chan_load(struct ieee80211_bss_conf *link_conf)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
# 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
|
||||
|
||||
ccflags-y += -I$(src)/../
|
||||
obj-$(CONFIG_IWLWIFI_KUNIT_TESTS) += iwlmld-tests.o
|
||||
|
|
|
|||
139
drivers/net/wireless/intel/iwlwifi/mld/tests/chan_load_thresh.c
Normal file
139
drivers/net/wireless/intel/iwlwifi/mld/tests/chan_load_thresh.c
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
|
||||
/*
|
||||
* KUnit tests for channel helper functions
|
||||
*
|
||||
* Copyright (C) 2026 Intel Corporation
|
||||
*/
|
||||
#include <kunit/static_stub.h>
|
||||
#include "mld.h"
|
||||
#include "link.h"
|
||||
#include "iface.h"
|
||||
#include "utils.h"
|
||||
|
||||
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
|
||||
|
||||
struct test_chan_load_case {
|
||||
const char *desc;
|
||||
u32 load;
|
||||
enum iwl_mld_link_chan_load_level old_lvl;
|
||||
enum iwl_mld_link_chan_load_level expected_lvl;
|
||||
bool expected_scan_trig;
|
||||
};
|
||||
|
||||
static const struct test_chan_load_case test_chan_load_thresh_cases[] = {
|
||||
/* Level-up transitions */
|
||||
{
|
||||
.desc = "Transition NONE->NONE",
|
||||
.load = 20,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL_NONE,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL_NONE,
|
||||
.expected_scan_trig = false,
|
||||
},
|
||||
{
|
||||
.desc = "Transition NONE->LVL1",
|
||||
.load = 50,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL_NONE,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL1,
|
||||
.expected_scan_trig = true,
|
||||
},
|
||||
{
|
||||
.desc = "Transition LVL1->LVL2",
|
||||
.load = 75,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL1,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL2,
|
||||
.expected_scan_trig = true,
|
||||
},
|
||||
{
|
||||
.desc = "Transition LVL2->LVL3",
|
||||
.load = 90,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL2,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL3,
|
||||
.expected_scan_trig = true,
|
||||
},
|
||||
|
||||
/* Level-down transitions */
|
||||
{
|
||||
.desc = "Transition LVL1->NONE",
|
||||
.load = 30,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL1,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL_NONE,
|
||||
.expected_scan_trig = false,
|
||||
},
|
||||
{
|
||||
.desc = "Transition LVL2->LVL1",
|
||||
.load = 60,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL2,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL1,
|
||||
.expected_scan_trig = false,
|
||||
},
|
||||
{
|
||||
.desc = "Transition LVL3->LVL2",
|
||||
.load = 70,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL3,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL2,
|
||||
.expected_scan_trig = false,
|
||||
},
|
||||
|
||||
/* No change */
|
||||
{
|
||||
.desc = "Transition LVL2->LVL2",
|
||||
.load = 72,
|
||||
.old_lvl = LINK_CHAN_LOAD_LVL2,
|
||||
.expected_lvl = LINK_CHAN_LOAD_LVL2,
|
||||
.expected_scan_trig = false,
|
||||
},
|
||||
};
|
||||
|
||||
KUNIT_ARRAY_PARAM_DESC(test_chan_load_thresh_cases,
|
||||
test_chan_load_thresh_cases, desc);
|
||||
|
||||
static void test_chan_load_thresholds(struct kunit *test)
|
||||
{
|
||||
const struct test_chan_load_case *tc = test->param_value;
|
||||
struct iwl_mld *mld = test->priv;
|
||||
struct ieee80211_vif *vif;
|
||||
struct iwl_mld_vif *mld_vif;
|
||||
struct ieee80211_bss_conf *link_conf;
|
||||
struct iwl_mld_link *mld_link;
|
||||
struct iwl_mld_kunit_link assoc_link = {
|
||||
.id = 0,
|
||||
.chandef = &chandef_6ghz_160mhz,
|
||||
};
|
||||
bool scan_trig;
|
||||
u32 chan_load;
|
||||
|
||||
/* Setup associated non-MLO station */
|
||||
vif = iwlmld_kunit_setup_non_mlo_assoc(&assoc_link);
|
||||
mld_vif = iwl_mld_vif_from_mac80211(vif);
|
||||
|
||||
link_conf = &vif->bss_conf;
|
||||
mld_link = &mld_vif->deflink;
|
||||
|
||||
chan_load = tc->load;
|
||||
mld_link->chan_load_lvl = tc->old_lvl;
|
||||
|
||||
/* Execute function under test */
|
||||
wiphy_lock(mld->wiphy);
|
||||
scan_trig = iwl_mld_chan_load_requires_scan(mld, link_conf, chan_load);
|
||||
wiphy_unlock(mld->wiphy);
|
||||
|
||||
/* Check return value */
|
||||
KUNIT_EXPECT_EQ(test, tc->expected_scan_trig, scan_trig);
|
||||
|
||||
/* Check updated channel-load level */
|
||||
KUNIT_EXPECT_EQ(test, tc->expected_lvl, mld_link->chan_load_lvl);
|
||||
}
|
||||
|
||||
static struct kunit_case chan_load_thresh_test_cases[] = {
|
||||
KUNIT_CASE_PARAM(test_chan_load_thresholds,
|
||||
test_chan_load_thresh_cases_gen_params),
|
||||
{}
|
||||
};
|
||||
|
||||
static struct kunit_suite chan_load_thresh_test_suite = {
|
||||
.name = "iwl_mld_chan_load_threshold_tests",
|
||||
.init = iwlmld_kunit_test_init,
|
||||
.test_cases = chan_load_thresh_test_cases,
|
||||
};
|
||||
|
||||
kunit_test_suite(chan_load_thresh_test_suite);
|
||||
Loading…
Reference in New Issue
Block a user