]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: iwlwifi: mld: add kunit test for emlsr with bt on
authorSomashekhar Puttagangaiah <somashekhar.puttagangaiah@intel.com>
Wed, 30 Apr 2025 12:57:15 +0000 (15:57 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 6 May 2025 17:23:24 +0000 (20:23 +0300)
add kunit test to validate entering and exiting
emlsr scenarios when the bt is on with certain
penalty on wifi.

Signed-off-by: Somashekhar Puttagangaiah <somashekhar.puttagangaiah@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250430155443.6621494fa412.If89b4b2dab308d825ca02284dd8e0030675d7af5@changeid
drivers/net/wireless/intel/iwlwifi/mld/mlo.c
drivers/net/wireless/intel/iwlwifi/mld/mlo.h
drivers/net/wireless/intel/iwlwifi/mld/tests/Makefile
drivers/net/wireless/intel/iwlwifi/mld/tests/emlsr_with_bt.c [new file with mode: 0644]

index c84b39794c8fa435559156d5e256cf0ab313bc8a..824a328da28ef2250d6c4c0ea7ba666716217eee 100644 (file)
@@ -640,7 +640,8 @@ s8 iwl_mld_get_emlsr_rssi_thresh(struct iwl_mld *mld,
 #define IWL_MLD_BT_COEX_ENABLE_EMLSR_RSSI_THRESH       -63
 #define IWL_MLD_BT_COEX_WIFI_LOSS_THRESH               7
 
-static bool
+VISIBLE_IF_IWLWIFI_KUNIT
+bool
 iwl_mld_bt_allows_emlsr(struct iwl_mld *mld, struct ieee80211_bss_conf *link,
                        bool check_entry)
 {
@@ -669,6 +670,7 @@ iwl_mld_bt_allows_emlsr(struct iwl_mld *mld, struct ieee80211_bss_conf *link,
                      link->link_id, bt_penalty);
        return bt_penalty < IWL_MLD_BT_COEX_WIFI_LOSS_THRESH;
 }
+EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mld_bt_allows_emlsr);
 
 static u32
 iwl_mld_emlsr_disallowed_with_link(struct iwl_mld *mld,
index c2bf04b799fb8e2d62c3e3c73b6cd381c18bf609..2122a7c3e9454306954c8d6b115c2fd932548489 100644 (file)
@@ -161,6 +161,10 @@ struct iwl_mld_link_sel_data {
 u32 iwl_mld_emlsr_pair_state(struct ieee80211_vif *vif,
                             struct iwl_mld_link_sel_data *a,
                             struct iwl_mld_link_sel_data *b);
+
+bool iwl_mld_bt_allows_emlsr(struct iwl_mld *mld,
+                            struct ieee80211_bss_conf *link,
+                            bool entry_criteria);
 #endif
 
 #endif /* __iwl_mld_mlo_h__ */
index 36317feb923ba02e833d77f56b200889a44b2379..3e2ae602061334e2fa37e722b8abbcaf4f91fb41 100644 (file)
@@ -1,5 +1,5 @@
 # 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 += module.o hcmd.o utils.o link.o rx.o agg.o link-selection.o emlsr_with_bt.o
 
 ccflags-y += -I$(src)/../
 obj-$(CONFIG_IWLWIFI_KUNIT_TESTS) += iwlmld-tests.o
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tests/emlsr_with_bt.c b/drivers/net/wireless/intel/iwlwifi/mld/tests/emlsr_with_bt.c
new file mode 100644 (file)
index 0000000..91556ee
--- /dev/null
@@ -0,0 +1,140 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
+/*
+ * KUnit tests for link selection functions
+ *
+ * Copyright (C) 2025 Intel Corporation
+ */
+#include <kunit/static_stub.h>
+
+#include "utils.h"
+#include "mld.h"
+#include "mlo.h"
+
+static const struct emlsr_with_bt_test_case {
+       const char *desc;
+       struct {
+               struct iwl_bt_coex_profile_notif notif;
+               s32 signal;
+               bool check_entry;
+       } input;
+       bool emlsr_allowed;
+} emlsr_with_bt_cases[] = {
+       {
+               .desc = "BT penalty(exit) with low rssi 4.5: emlsr allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {4, 5},
+                       .notif.wifi_loss_mid_high_rssi[1] = {7, 9},
+                       .signal = -69,
+                       .check_entry = false,
+               },
+               .emlsr_allowed = true,
+       },
+       {
+               .desc = "BT penalty(exit) from high rssi 5: emlsr allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {7, 9},
+                       .notif.wifi_loss_mid_high_rssi[1] = {5, 5},
+                       .signal = -68,
+                       .check_entry = false,
+               },
+               .emlsr_allowed = true,
+       },
+       {
+               .desc = "BT penalty(exit) with low rssi 8: emlsr not allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {7, 9},
+                       .notif.wifi_loss_mid_high_rssi[1] = {4, 5},
+                       .signal = -69,
+                       .check_entry = false,
+               },
+               .emlsr_allowed = false,
+       },
+       {
+               .desc = "BT penalty(exit) from high rssi 9: emlsr not allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {4, 5},
+                       .notif.wifi_loss_mid_high_rssi[1] = {9, 9},
+                       .signal = -68,
+                       .check_entry = false,
+               },
+               .emlsr_allowed = false,
+       },
+       {
+               .desc = "BT penalty(entry) with low rssi 4.5: emlsr allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {4, 5},
+                       .notif.wifi_loss_mid_high_rssi[1] = {7, 9},
+                       .signal = -63,
+                       .check_entry = true,
+               },
+               .emlsr_allowed = true,
+       },
+       {
+               .desc = "BT penalty(entry) from high rssi 5: emlsr allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {7, 9},
+                       .notif.wifi_loss_mid_high_rssi[1] = {5, 5},
+                       .signal = -62,
+                       .check_entry = false,
+               },
+               .emlsr_allowed = true,
+       },
+       {
+               .desc = "BT penalty(entry) with low rssi 8: emlsr not allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {7, 9},
+                       .notif.wifi_loss_mid_high_rssi[1] = {4, 5},
+                       .signal = -63,
+                       .check_entry = false,
+               },
+               .emlsr_allowed = true,
+       },
+       {
+               .desc = "BT penalty(entry) from high rssi 9: emlsr not allowed",
+               .input = {
+                       .notif.wifi_loss_low_rssi[1] = {4, 5},
+                       .notif.wifi_loss_mid_high_rssi[1] = {9, 9},
+                       .signal = -62,
+                       .check_entry = true,
+               },
+               .emlsr_allowed = false,
+       },
+};
+
+KUNIT_ARRAY_PARAM_DESC(emlsr_with_bt, emlsr_with_bt_cases, desc);
+
+static void test_emlsr_with_bt(struct kunit *test)
+{
+       struct iwl_mld *mld = test->priv;
+       const struct emlsr_with_bt_test_case *test_param =
+               (const void *)(test->param_value);
+       struct ieee80211_vif *vif =
+               iwlmld_kunit_add_vif(true, NL80211_IFTYPE_STATION);
+       struct ieee80211_bss_conf *link = iwlmld_kunit_add_link(vif, 1);
+       bool actual_value = false;
+
+       KUNIT_ALLOC_AND_ASSERT(test, link->bss);
+
+       /* Extract test case parameters */
+       link->bss->signal = DBM_TO_MBM(test_param->input.signal);
+       memcpy(&mld->last_bt_notif, &test_param->input.notif,
+              sizeof(struct iwl_bt_coex_profile_notif));
+
+       actual_value = iwl_mld_bt_allows_emlsr(mld, link,
+                                              test_param->input.check_entry);
+       /* Assert that the returned value matches the expected emlsr_allowed */
+       KUNIT_EXPECT_EQ(test, actual_value, test_param->emlsr_allowed);
+}
+
+static struct kunit_case emlsr_with_bt_test_cases[] = {
+       KUNIT_CASE_PARAM(test_emlsr_with_bt, emlsr_with_bt_gen_params),
+       {},
+};
+
+static struct kunit_suite emlsr_with_bt = {
+       .name = "iwlmld-emlsr-with-bt-tests",
+       .test_cases = emlsr_with_bt_test_cases,
+       .init = iwlmld_kunit_test_init,
+};
+
+kunit_test_suite(emlsr_with_bt);