Debian Codegraph @

drivers/net/wireless/intel/iwlwifi/mld/tests/utils.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3 * Copyright (C) 2024-2025 Intel Corporation
4 */
5
6 #ifndef __iwl_mld_kunit_utils_h__
7 #define __iwl_mld_kunit_utils_h__
8
9 #include <net/mac80211.h>
10 #include <kunit/test-bug.h>
11
12 struct iwl_mld;
13
14 int iwlmld_kunit_test_init(struct kunit *test);
15
16 struct iwl_mld_kunit_link {
17 const struct cfg80211_chan_def *chandef;
18 u8 id;
19 };
20
21 enum nl80211_iftype;
22
23 struct ieee80211_vif *iwlmld_kunit_add_vif(bool mlo, enum nl80211_iftype type);
24
25 struct ieee80211_bss_conf *
26 iwlmld_kunit_add_link(struct ieee80211_vif *vif, int link_id);
27
28 #define KUNIT_ALLOC_AND_ASSERT_SIZE(test, ptr, size) \
29 do { \
30 (ptr) = kunit_kzalloc((test), (size), GFP_KERNEL); \
31 KUNIT_ASSERT_NOT_NULL((test), (ptr)); \
32 } while (0)
33
34 #define KUNIT_ALLOC_AND_ASSERT(test, ptr) \
35 KUNIT_ALLOC_AND_ASSERT_SIZE(test, ptr, sizeof(*(ptr)))
36
37 #define CHANNEL(_name, _band, _freq) \
38 static struct ieee80211_channel _name = { \
39 .band = (_band), \
40 .center_freq = (_freq), \
41 .hw_value = (_freq), \
42 }
43
44 CHANNEL(chan_2ghz, NL80211_BAND_2GHZ, 2412);
45 CHANNEL(chan_2ghz_11, NL80211_BAND_2GHZ, 2462);
46 CHANNEL(chan_5ghz, NL80211_BAND_5GHZ, 5200);
47 CHANNEL(chan_5ghz_120, NL80211_BAND_5GHZ, 5600);
48 CHANNEL(chan_6ghz, NL80211_BAND_6GHZ, 6115);
49 CHANNEL(chan_6ghz_221, NL80211_BAND_6GHZ, 7055);
50 /* Feel free to add more */
51 #undef CHANNEL
52
53 #define CHANDEF_LIST \
54 CHANDEF(chandef_2ghz_20mhz, chan_2ghz, 2412, \
55 NL80211_CHAN_WIDTH_20) \
56 CHANDEF(chandef_2ghz_40mhz, chan_2ghz, 2422, \
57 NL80211_CHAN_WIDTH_40) \
58 CHANDEF(chandef_2ghz_11_20mhz, chan_2ghz_11, 2462, \
59 NL80211_CHAN_WIDTH_20) \
60 CHANDEF(chandef_5ghz_20mhz, chan_5ghz, 5200, \
61 NL80211_CHAN_WIDTH_20) \
62 CHANDEF(chandef_5ghz_40mhz, chan_5ghz, 5210, \
63 NL80211_CHAN_WIDTH_40) \
64 CHANDEF(chandef_5ghz_80mhz, chan_5ghz, 5210, \
65 NL80211_CHAN_WIDTH_80) \
66 CHANDEF(chandef_5ghz_160mhz, chan_5ghz, 5250, \
67 NL80211_CHAN_WIDTH_160) \
68 CHANDEF(chandef_5ghz_120_40mhz, chan_5ghz_120, 5610, \
69 NL80211_CHAN_WIDTH_40) \
70 CHANDEF(chandef_6ghz_20mhz, chan_6ghz, 6115, \
71 NL80211_CHAN_WIDTH_20) \
72 CHANDEF(chandef_6ghz_40mhz, chan_6ghz, 6125, \
73 NL80211_CHAN_WIDTH_40) \
74 CHANDEF(chandef_6ghz_80mhz, chan_6ghz, 6145, \
75 NL80211_CHAN_WIDTH_80) \
76 CHANDEF(chandef_6ghz_160mhz, chan_6ghz, 6185, \
77 NL80211_CHAN_WIDTH_160) \
78 CHANDEF(chandef_6ghz_320mhz, chan_6ghz, 6105, \
79 NL80211_CHAN_WIDTH_320) \
80 CHANDEF(chandef_6ghz_221_160mhz, chan_6ghz_221, 6985, \
81 NL80211_CHAN_WIDTH_160) \
82 /* Feel free to add more */
83
84 #define CHANDEF(_name, _channel, _freq1, _width) \
85 __maybe_unused static const struct cfg80211_chan_def _name = { \
86 .chan = &(_channel), \
87 .center_freq1 = (_freq1), \
88 .width = (_width), \
89 };
90 CHANDEF_LIST
91 #undef CHANDEF
92
93 struct ieee80211_chanctx_conf *
94 iwlmld_kunit_add_chanctx(const struct cfg80211_chan_def *def);
95
96 void iwlmld_kunit_assign_chanctx_to_link(struct ieee80211_vif *vif,
97 struct ieee80211_bss_conf *link,
98 struct ieee80211_chanctx_conf *ctx);
99
100 /* Allocate a sta, initialize it and move it to the wanted state */
101 struct ieee80211_sta *iwlmld_kunit_setup_sta(struct ieee80211_vif *vif,
102 enum ieee80211_sta_state state,
103 int link_id);
104
105 struct ieee80211_vif *
106 iwlmld_kunit_setup_mlo_assoc(u16 valid_links,
107 struct iwl_mld_kunit_link *assoc_link);
108
109 struct ieee80211_vif *
110 iwlmld_kunit_setup_non_mlo_assoc(struct iwl_mld_kunit_link *assoc_link);
111
112 struct iwl_rx_packet *
113 _iwl_mld_kunit_create_pkt(const void *notif, size_t notif_sz);
114
115 #define iwl_mld_kunit_create_pkt(_notif) \
116 _iwl_mld_kunit_create_pkt(&(_notif), sizeof(_notif))
117
118 struct ieee80211_vif *
119 iwlmld_kunit_assoc_emlsr(struct iwl_mld_kunit_link *link1,
120 struct iwl_mld_kunit_link *link2);
121
122 struct element *iwlmld_kunit_gen_element(u8 id, const void *data, size_t len);
123
124 /**
125 * iwlmld_kunit_get_phy_of_link - Get the phy of a link
126 *
127 * @vif: The vif to get the phy from.
128 * @link_id: The id of the link to get the phy for.
129 *
130 * given a vif and link id, return the phy pointer of that link.
131 * This assumes that the link exists, and that it had a chanctx
132 * assigned.
133 * If this is not the case, the test will fail.
134 *
135 * Return: phy pointer.
136 */
137 struct iwl_mld_phy *iwlmld_kunit_get_phy_of_link(struct ieee80211_vif *vif,
138 u8 link_id);
139
140 #endif /* __iwl_mld_kunit_utils_h__ */