~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/wireless/tests/chan.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * KUnit tests for channel helper functions
  4  *
  5  * Copyright (C) 2023-2024 Intel Corporation
  6  */
  7 #include <net/cfg80211.h>
  8 #include <kunit/test.h>
  9 
 10 MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING);
 11 
 12 static struct ieee80211_channel chan_6ghz_1 = {
 13         .band = NL80211_BAND_6GHZ,
 14         .center_freq = 5955,
 15 };
 16 
 17 static struct ieee80211_channel chan_6ghz_5 = {
 18         .band = NL80211_BAND_6GHZ,
 19         .center_freq = 5975,
 20 };
 21 
 22 static struct ieee80211_channel chan_6ghz_105 = {
 23         .band = NL80211_BAND_6GHZ,
 24         .center_freq = 6475,
 25 };
 26 
 27 static const struct chandef_compat_case {
 28         const char *desc;
 29         /* leave c1 empty for tests for identical */
 30         struct cfg80211_chan_def c1, c2;
 31         /* we test both ways around, so c2 should always be the compat one */
 32         bool compat;
 33 } chandef_compat_cases[] = {
 34         {
 35                 .desc = "identical non-HT",
 36                 .c2 = {
 37                         .width = NL80211_CHAN_WIDTH_20_NOHT,
 38                         .chan = &chan_6ghz_1,
 39                         .center_freq1 = 5955,
 40                 },
 41                 .compat = true,
 42         },
 43         {
 44                 .desc = "identical 20 MHz",
 45                 .c2 = {
 46                         .width = NL80211_CHAN_WIDTH_20,
 47                         .chan = &chan_6ghz_1,
 48                         .center_freq1 = 5955,
 49                 },
 50                 .compat = true,
 51         },
 52         {
 53                 .desc = "identical 40 MHz",
 54                 .c2 = {
 55                         .width = NL80211_CHAN_WIDTH_40,
 56                         .chan = &chan_6ghz_1,
 57                         .center_freq1 = 5955 + 10,
 58                 },
 59                 .compat = true,
 60         },
 61         {
 62                 .desc = "identical 80 MHz",
 63                 .c2 = {
 64                         .width = NL80211_CHAN_WIDTH_80,
 65                         .chan = &chan_6ghz_1,
 66                         .center_freq1 = 5955 + 10 + 20,
 67                 },
 68                 .compat = true,
 69         },
 70         {
 71                 .desc = "identical 160 MHz",
 72                 .c2 = {
 73                         .width = NL80211_CHAN_WIDTH_160,
 74                         .chan = &chan_6ghz_1,
 75                         .center_freq1 = 5955 + 10 + 20 + 40,
 76                 },
 77                 .compat = true,
 78         },
 79         {
 80                 .desc = "identical 320 MHz",
 81                 .c2 = {
 82                         .width = NL80211_CHAN_WIDTH_320,
 83                         .chan = &chan_6ghz_1,
 84                         .center_freq1 = 5955 + 10 + 20 + 40 + 80,
 85                 },
 86                 .compat = true,
 87         },
 88         {
 89                 .desc = "20 MHz in 320 MHz\n",
 90                 .c1 = {
 91                         .width = NL80211_CHAN_WIDTH_20,
 92                         .chan = &chan_6ghz_1,
 93                         .center_freq1 = 5955,
 94                 },
 95                 .c2 = {
 96                         .width = NL80211_CHAN_WIDTH_320,
 97                         .chan = &chan_6ghz_1,
 98                         .center_freq1 = 5955 + 10 + 20 + 40 + 80,
 99                 },
100                 .compat = true,
101         },
102         {
103                 .desc = "different 20 MHz",
104                 .c1 = {
105                         .width = NL80211_CHAN_WIDTH_20,
106                         .chan = &chan_6ghz_1,
107                         .center_freq1 = 5955,
108                 },
109                 .c2 = {
110                         .width = NL80211_CHAN_WIDTH_20,
111                         .chan = &chan_6ghz_5,
112                         .center_freq1 = 5975,
113                 },
114         },
115         {
116                 .desc = "different primary 320 MHz",
117                 .c1 = {
118                         .width = NL80211_CHAN_WIDTH_320,
119                         .chan = &chan_6ghz_105,
120                         .center_freq1 = 6475 + 110,
121                 },
122                 .c2 = {
123                         .width = NL80211_CHAN_WIDTH_320,
124                         .chan = &chan_6ghz_105,
125                         .center_freq1 = 6475 - 50,
126                 },
127         },
128         {
129                 /* similar to previous test but one has lower BW */
130                 .desc = "matching primary 160 MHz",
131                 .c1 = {
132                         .width = NL80211_CHAN_WIDTH_160,
133                         .chan = &chan_6ghz_105,
134                         .center_freq1 = 6475 + 30,
135                 },
136                 .c2 = {
137                         .width = NL80211_CHAN_WIDTH_320,
138                         .chan = &chan_6ghz_105,
139                         .center_freq1 = 6475 - 50,
140                 },
141                 .compat = true,
142         },
143         {
144                 .desc = "matching primary 160 MHz & punctured secondary 160 Mhz",
145                 .c1 = {
146                         .width = NL80211_CHAN_WIDTH_160,
147                         .chan = &chan_6ghz_105,
148                         .center_freq1 = 6475 + 30,
149                 },
150                 .c2 = {
151                         .width = NL80211_CHAN_WIDTH_320,
152                         .chan = &chan_6ghz_105,
153                         .center_freq1 = 6475 - 50,
154                         .punctured = 0xf,
155                 },
156                 .compat = true,
157         },
158         {
159                 .desc = "matching primary 160 MHz & punctured matching",
160                 .c1 = {
161                         .width = NL80211_CHAN_WIDTH_160,
162                         .chan = &chan_6ghz_105,
163                         .center_freq1 = 6475 + 30,
164                         .punctured = 0xc0,
165                 },
166                 .c2 = {
167                         .width = NL80211_CHAN_WIDTH_320,
168                         .chan = &chan_6ghz_105,
169                         .center_freq1 = 6475 - 50,
170                         .punctured = 0xc000,
171                 },
172                 .compat = true,
173         },
174         {
175                 .desc = "matching primary 160 MHz & punctured not matching",
176                 .c1 = {
177                         .width = NL80211_CHAN_WIDTH_160,
178                         .chan = &chan_6ghz_105,
179                         .center_freq1 = 6475 + 30,
180                         .punctured = 0x80,
181                 },
182                 .c2 = {
183                         .width = NL80211_CHAN_WIDTH_320,
184                         .chan = &chan_6ghz_105,
185                         .center_freq1 = 6475 - 50,
186                         .punctured = 0xc000,
187                 },
188         },
189 };
190 
191 KUNIT_ARRAY_PARAM_DESC(chandef_compat, chandef_compat_cases, desc)
192 
193 static void test_chandef_compat(struct kunit *test)
194 {
195         const struct chandef_compat_case *params = test->param_value;
196         const struct cfg80211_chan_def *ret, *expect;
197         struct cfg80211_chan_def c1 = params->c1;
198 
199         /* tests with identical ones */
200         if (!params->c1.chan)
201                 c1 = params->c2;
202 
203         KUNIT_EXPECT_EQ(test, cfg80211_chandef_valid(&c1), true);
204         KUNIT_EXPECT_EQ(test, cfg80211_chandef_valid(&params->c2), true);
205 
206         expect = params->compat ? &params->c2 : NULL;
207 
208         ret = cfg80211_chandef_compatible(&c1, &params->c2);
209         KUNIT_EXPECT_PTR_EQ(test, ret, expect);
210 
211         if (!params->c1.chan)
212                 expect = &c1;
213 
214         ret = cfg80211_chandef_compatible(&params->c2, &c1);
215         KUNIT_EXPECT_PTR_EQ(test, ret, expect);
216 }
217 
218 static struct kunit_case chandef_compat_test_cases[] = {
219         KUNIT_CASE_PARAM(test_chandef_compat, chandef_compat_gen_params),
220         {}
221 };
222 
223 static struct kunit_suite chandef_compat = {
224         .name = "cfg80211-chandef-compat",
225         .test_cases = chandef_compat_test_cases,
226 };
227 
228 kunit_test_suite(chandef_compat);
229 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php