76c351aa831f5984eee4407d4eac2cb196c9c495
[openwrt/openwrt.git] /
1 From: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
2 Date: Tue, 17 Sep 2024 19:32:39 +0530
3 Subject: [PATCH] wifi: cfg80211: check radio iface combination for multi radio
4 per wiphy
5
6 Currently, wiphy_verify_combinations() fails for the multi-radio per wiphy
7 due to the condition check on new global interface combination that DFS
8 only works on one channel. In a multi-radio scenario, new global interface
9 combination encompasses the capabilities of all radio combinations, so it
10 supports more than one channel with DFS. For multi-radio per wiphy,
11 interface combination verification needs to be performed for radio specific
12 interface combinations. This is necessary as the new global interface
13 combination combines the capabilities of all radio combinations.
14
15 Fixes: a01b1e9f9955 ("wifi: mac80211: add support for DFS with multiple radios")
16 Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
17 ---
18
19 --- a/net/wireless/core.c
20 +++ b/net/wireless/core.c
21 @@ -599,16 +599,20 @@ use_default_name:
22 }
23 EXPORT_SYMBOL(wiphy_new_nm);
24
25 -static int wiphy_verify_combinations(struct wiphy *wiphy)
26 +static
27 +int wiphy_verify_iface_combinations(struct wiphy *wiphy,
28 + const struct ieee80211_iface_combination *iface_comb,
29 + int n_iface_comb,
30 + bool combined_radio)
31 {
32 const struct ieee80211_iface_combination *c;
33 int i, j;
34
35 - for (i = 0; i < wiphy->n_iface_combinations; i++) {
36 + for (i = 0; i < n_iface_comb; i++) {
37 u32 cnt = 0;
38 u16 all_iftypes = 0;
39
40 - c = &wiphy->iface_combinations[i];
41 + c = &iface_comb[i];
42
43 /*
44 * Combinations with just one interface aren't real,
45 @@ -621,9 +625,13 @@ static int wiphy_verify_combinations(str
46 if (WARN_ON(!c->num_different_channels))
47 return -EINVAL;
48
49 - /* DFS only works on one channel. */
50 - if (WARN_ON(c->radar_detect_widths &&
51 - (c->num_different_channels > 1)))
52 + /* DFS only works on one channel. Avoid this check
53 + * for multi-radio global combination, since it hold
54 + * the capabilities of all radio combinations.
55 + */
56 + if (!combined_radio &&
57 + WARN_ON(c->radar_detect_widths &&
58 + c->num_different_channels > 1))
59 return -EINVAL;
60
61 if (WARN_ON(!c->n_limits))
62 @@ -644,13 +652,21 @@ static int wiphy_verify_combinations(str
63 if (WARN_ON(wiphy->software_iftypes & types))
64 return -EINVAL;
65
66 - /* Only a single P2P_DEVICE can be allowed */
67 - if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) &&
68 + /* Only a single P2P_DEVICE can be allowed, avoid this
69 + * check for multi-radio global combination, since it
70 + * hold the capabilities of all radio combinations.
71 + */
72 + if (!combined_radio &&
73 + WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) &&
74 c->limits[j].max > 1))
75 return -EINVAL;
76
77 - /* Only a single NAN can be allowed */
78 - if (WARN_ON(types & BIT(NL80211_IFTYPE_NAN) &&
79 + /* Only a single NAN can be allowed, avoid this
80 + * check for multi-radio global combination, since it
81 + * hold the capabilities of all radio combinations.
82 + */
83 + if (!combined_radio &&
84 + WARN_ON(types & BIT(NL80211_IFTYPE_NAN) &&
85 c->limits[j].max > 1))
86 return -EINVAL;
87
88 @@ -674,6 +690,34 @@ static int wiphy_verify_combinations(str
89 return 0;
90 }
91
92 +static int wiphy_verify_combinations(struct wiphy *wiphy)
93 +{
94 + int i, ret;
95 + bool combined_radio = false;
96 +
97 + if (wiphy->n_radio) {
98 + for (i = 0; i < wiphy->n_radio; i++) {
99 + const struct wiphy_radio *radio = &wiphy->radio[i];
100 +
101 + ret = wiphy_verify_iface_combinations(wiphy,
102 + radio->iface_combinations,
103 + radio->n_iface_combinations,
104 + false);
105 + if (ret)
106 + return ret;
107 + }
108 +
109 + combined_radio = true;
110 + }
111 +
112 + ret = wiphy_verify_iface_combinations(wiphy,
113 + wiphy->iface_combinations,
114 + wiphy->n_iface_combinations,
115 + combined_radio);
116 +
117 + return ret;
118 +}
119 +
120 int wiphy_register(struct wiphy *wiphy)
121 {
122 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);