File Index
Files and directories
Sign in
FILE

link.c

File preview with syntax highlighting.

linux-6.19.14/drivers/net/wireless/intel/iwlwifi/mld/tests/link.c C
  1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
  2/*
  3 * KUnit tests for channel helper functions
  4 *
  5 * Copyright (C) 2024-2025 Intel Corporation
  6 */
  7#include <kunit/static_stub.h>
  8
  9#include "utils.h"
 10#include "mld.h"
 11#include "link.h"
 12#include "iface.h"
 13#include "fw/api/mac-cfg.h"
 14
 15static const struct missed_beacon_test_case {
 16	const char *desc;
 17	struct {
 18		struct iwl_missed_beacons_notif notif;
 19		bool emlsr;
 20	} input;
 21	struct {
 22		bool disconnected;
 23		bool emlsr;
 24	} output;
 25} missed_beacon_cases[] = {
 26	{
 27		.desc = "no EMLSR, no disconnect",
 28		.input.notif = {
 29			.consec_missed_beacons = cpu_to_le32(4),
 30		},
 31	},
 32	{
 33		.desc = "no EMLSR, no beacon loss since Rx, no disconnect",
 34		.input.notif = {
 35			.consec_missed_beacons = cpu_to_le32(20),
 36		},
 37	},
 38	{
 39		.desc = "no EMLSR, beacon loss since Rx, disconnect",
 40		.input.notif = {
 41			.consec_missed_beacons = cpu_to_le32(20),
 42			.consec_missed_beacons_since_last_rx =
 43				cpu_to_le32(10),
 44		},
 45		.output.disconnected = true,
 46	},
 47};
 48
 49KUNIT_ARRAY_PARAM_DESC(test_missed_beacon, missed_beacon_cases, desc);
 50
 51static void fake_ieee80211_connection_loss(struct ieee80211_vif *vif)
 52{
 53	vif->cfg.assoc = false;
 54}
 55
 56static void test_missed_beacon(struct kunit *test)
 57{
 58	struct iwl_mld *mld = test->priv;
 59	struct iwl_missed_beacons_notif *notif;
 60	const struct missed_beacon_test_case *test_param =
 61		(const void *)(test->param_value);
 62	struct ieee80211_vif *vif;
 63	struct iwl_rx_packet *pkt;
 64	struct iwl_mld_kunit_link link1 = {
 65		.id = 0,
 66		.chandef = &chandef_6ghz_160mhz,
 67	};
 68	struct iwl_mld_kunit_link link2 = {
 69		.id = 1,
 70		.chandef = &chandef_5ghz_80mhz,
 71	};
 72
 73	kunit_activate_static_stub(test, ieee80211_connection_loss,
 74				   fake_ieee80211_connection_loss);
 75	pkt = iwl_mld_kunit_create_pkt(test_param->input.notif);
 76	notif = (void *)pkt->data;
 77
 78	if (test_param->input.emlsr) {
 79		vif = iwlmld_kunit_assoc_emlsr(&link1, &link2);
 80	} else {
 81		struct iwl_mld_vif *mld_vif;
 82
 83		vif = iwlmld_kunit_setup_non_mlo_assoc(&link1);
 84		mld_vif = iwl_mld_vif_from_mac80211(vif);
 85		notif->link_id = cpu_to_le32(mld_vif->deflink.fw_id);
 86	}
 87
 88	wiphy_lock(mld->wiphy);
 89
 90	iwl_mld_handle_missed_beacon_notif(mld, pkt);
 91
 92	wiphy_unlock(mld->wiphy);
 93
 94	KUNIT_ASSERT_NE(test, vif->cfg.assoc, test_param->output.disconnected);
 95
 96	/* TODO: add test cases for esr and check */
 97}
 98
 99static struct kunit_case link_cases[] = {
100	KUNIT_CASE_PARAM(test_missed_beacon, test_missed_beacon_gen_params),
101	{},
102};
103
104static struct kunit_suite link = {
105	.name = "iwlmld-link",
106	.test_cases = link_cases,
107	.init = iwlmld_kunit_test_init,
108};
109
110kunit_test_suite(link);
~/ Read-only file preview.