Skip to content

Commit cfbb2ad

Browse files
benzeajmberg-intel
authored andcommitted
wifi: cfg80211: tests: verify BSS use flags of NSTR links
Extend the test to pass an RNR appropriate for an NSTR and verify that use_for as well as cannot_use_reasons are set correctly. Signed-off-by: Benjamin Berg <[email protected]> Link: https://msgid.link/20240129220918.b00aee4c4c9f.I942fddf51cabaab761de3865b4e06cce831a46ef@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 45d4393 commit cfbb2ad

File tree

1 file changed

+56
-12
lines changed

1 file changed

+56
-12
lines changed

net/wireless/tests/scan.c

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ static struct inform_bss_ml_sta_case {
407407
int mld_id;
408408
bool sta_prof_vendor_elems;
409409
bool include_oper_class;
410+
bool nstr;
410411
} inform_bss_ml_sta_cases[] = {
411412
{
412413
.desc = "zero_mld_id",
@@ -426,6 +427,10 @@ static struct inform_bss_ml_sta_case {
426427
.mld_id = 1,
427428
.sta_prof_vendor_elems = true,
428429
.include_oper_class = true,
430+
}, {
431+
.desc = "nstr",
432+
.mld_id = 0,
433+
.nstr = true,
429434
},
430435
};
431436
KUNIT_ARRAY_PARAM_DESC(inform_bss_ml_sta, inform_bss_ml_sta_cases, desc)
@@ -458,7 +463,7 @@ static void test_inform_bss_ml_sta(struct kunit *test)
458463
struct {
459464
struct ieee80211_neighbor_ap_info info;
460465
struct ieee80211_tbtt_info_ge_11 ap;
461-
} __packed rnr = {
466+
} __packed rnr_normal = {
462467
.info = {
463468
.tbtt_info_hdr = u8_encode_bits(0, IEEE80211_AP_INFO_TBTT_HDR_COUNT),
464469
.tbtt_info_len = sizeof(struct ieee80211_tbtt_info_ge_11),
@@ -477,6 +482,28 @@ static void test_inform_bss_ml_sta(struct kunit *test)
477482
IEEE80211_RNR_MLD_PARAMS_LINK_ID),
478483
}
479484
};
485+
struct {
486+
struct ieee80211_neighbor_ap_info info;
487+
struct ieee80211_rnr_mld_params mld_params;
488+
} __packed rnr_nstr = {
489+
.info = {
490+
.tbtt_info_hdr =
491+
u8_encode_bits(0, IEEE80211_AP_INFO_TBTT_HDR_COUNT) |
492+
u8_encode_bits(IEEE80211_TBTT_INFO_TYPE_MLD,
493+
IEEE80211_AP_INFO_TBTT_HDR_TYPE),
494+
.tbtt_info_len = sizeof(struct ieee80211_rnr_mld_params),
495+
.op_class = 81,
496+
.channel = 11,
497+
},
498+
.mld_params = {
499+
.mld_id = params->mld_id,
500+
.params =
501+
le16_encode_bits(link_id,
502+
IEEE80211_RNR_MLD_PARAMS_LINK_ID),
503+
}
504+
};
505+
size_t rnr_len = params->nstr ? sizeof(rnr_nstr) : sizeof(rnr_normal);
506+
void *rnr = params->nstr ? (void *)&rnr_nstr : (void *)&rnr_normal;
480507
struct {
481508
__le16 control;
482509
u8 var_len;
@@ -516,7 +543,7 @@ static void test_inform_bss_ml_sta(struct kunit *test)
516543
u16_encode_bits(link_id,
517544
IEEE80211_MLE_STA_CONTROL_LINK_ID)),
518545
.var_len = sizeof(sta_prof) - 2 - 2,
519-
.bssid = { *rnr.ap.bssid },
546+
.bssid = { *rnr_normal.ap.bssid },
520547
.beacon_int = cpu_to_le16(101),
521548
.tsf_offset = cpu_to_le64(-123ll),
522549
.capabilities = cpu_to_le16(0xdead),
@@ -540,8 +567,8 @@ static void test_inform_bss_ml_sta(struct kunit *test)
540567
}
541568

542569
skb_put_u8(input, WLAN_EID_REDUCED_NEIGHBOR_REPORT);
543-
skb_put_u8(input, sizeof(rnr));
544-
skb_put_data(input, &rnr, sizeof(rnr));
570+
skb_put_u8(input, rnr_len);
571+
skb_put_data(input, rnr, rnr_len);
545572

546573
/* build a multi-link element */
547574
skb_put_u8(input, WLAN_EID_EXTENSION);
@@ -587,9 +614,10 @@ static void test_inform_bss_ml_sta(struct kunit *test)
587614
KUNIT_EXPECT_EQ(test, ctx.inform_bss_count, 2);
588615

589616
/* Check link_bss *****************************************************/
590-
link_bss = cfg80211_get_bss(wiphy, NULL, sta_prof.bssid, NULL, 0,
591-
IEEE80211_BSS_TYPE_ANY,
592-
IEEE80211_PRIVACY_ANY);
617+
link_bss = __cfg80211_get_bss(wiphy, NULL, sta_prof.bssid, NULL, 0,
618+
IEEE80211_BSS_TYPE_ANY,
619+
IEEE80211_PRIVACY_ANY,
620+
0);
593621
KUNIT_ASSERT_NOT_NULL(test, link_bss);
594622
KUNIT_EXPECT_EQ(test, link_bss->signal, 0);
595623
KUNIT_EXPECT_EQ(test, link_bss->beacon_interval,
@@ -600,27 +628,43 @@ static void test_inform_bss_ml_sta(struct kunit *test)
600628
KUNIT_EXPECT_PTR_EQ(test, link_bss->channel,
601629
ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(2462)));
602630

631+
/* Test wiphy does not set WIPHY_FLAG_SUPPORTS_NSTR_NONPRIMARY */
632+
if (params->nstr) {
633+
KUNIT_EXPECT_EQ(test, link_bss->use_for, 0);
634+
KUNIT_EXPECT_EQ(test, link_bss->cannot_use_reasons,
635+
NL80211_BSS_CANNOT_USE_NSTR_NONPRIMARY);
636+
KUNIT_EXPECT_NULL(test,
637+
cfg80211_get_bss(wiphy, NULL, sta_prof.bssid,
638+
NULL, 0,
639+
IEEE80211_BSS_TYPE_ANY,
640+
IEEE80211_PRIVACY_ANY));
641+
} else {
642+
KUNIT_EXPECT_EQ(test, link_bss->use_for,
643+
NL80211_BSS_USE_FOR_ALL);
644+
KUNIT_EXPECT_EQ(test, link_bss->cannot_use_reasons, 0);
645+
}
646+
603647
rcu_read_lock();
604648
ies = rcu_dereference(link_bss->ies);
605649
KUNIT_EXPECT_NOT_NULL(test, ies);
606650
KUNIT_EXPECT_EQ(test, ies->tsf, tsf + le64_to_cpu(sta_prof.tsf_offset));
607651
/* Resulting length should be:
608652
* SSID (inherited) + RNR (inherited) + vendor element(s) +
609653
* operating class (if requested) +
610-
* generated RNR (if MLD ID == 0) +
654+
* generated RNR (if MLD ID == 0 and not NSTR) +
611655
* MLE common info + MLE header and control
612656
*/
613657
if (params->sta_prof_vendor_elems)
614658
KUNIT_EXPECT_EQ(test, ies->len,
615-
6 + 2 + sizeof(rnr) + 2 + 160 + 2 + 165 +
659+
6 + 2 + rnr_len + 2 + 160 + 2 + 165 +
616660
(params->include_oper_class ? 3 : 0) +
617-
(!params->mld_id ? 22 : 0) +
661+
(!params->mld_id && !params->nstr ? 22 : 0) +
618662
mle_basic_common_info.var_len + 5);
619663
else
620664
KUNIT_EXPECT_EQ(test, ies->len,
621-
6 + 2 + sizeof(rnr) + 2 + 155 +
665+
6 + 2 + rnr_len + 2 + 155 +
622666
(params->include_oper_class ? 3 : 0) +
623-
(!params->mld_id ? 22 : 0) +
667+
(!params->mld_id && !params->nstr ? 22 : 0) +
624668
mle_basic_common_info.var_len + 5);
625669
rcu_read_unlock();
626670

0 commit comments

Comments
 (0)