18634fe1465740c49a4894b5d62a781ad80ce048
[openwrt/staging/wigyori.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 6 Jun 2024 12:19:08 +0200
3 Subject: [PATCH] wifi: mac80211: add support for DFS with multiple
4 radios
5
6 DFS can be supported with multi-channel combinations, as long as each DFS
7 capable radio only supports one channel.
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/net/mac80211/main.c
13 +++ b/net/mac80211/main.c
14 @@ -1084,6 +1084,27 @@ static int ieee80211_init_cipher_suites(
15 return 0;
16 }
17
18 +static bool
19 +ieee80211_ifcomb_check(const struct ieee80211_iface_combination *c, int n_comb)
20 +{
21 + int i, j;
22 +
23 + for (i = 0; i < n_comb; i++, c++) {
24 + /* DFS is not supported with multi-channel combinations yet */
25 + if (c->radar_detect_widths &&
26 + c->num_different_channels > 1)
27 + return false;
28 +
29 + /* mac80211 doesn't support more than one IBSS interface */
30 + for (j = 0; j < c->n_limits; j++)
31 + if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) &&
32 + c->limits[j].max > 1)
33 + return false;
34 + }
35 +
36 + return true;
37 +}
38 +
39 int ieee80211_register_hw(struct ieee80211_hw *hw)
40 {
41 struct ieee80211_local *local = hw_to_local(hw);
42 @@ -1173,17 +1194,20 @@ int ieee80211_register_hw(struct ieee802
43 if (comb->num_different_channels > 1)
44 return -EINVAL;
45 }
46 - } else {
47 - /* DFS is not supported with multi-channel combinations yet */
48 - for (i = 0; i < local->hw.wiphy->n_iface_combinations; i++) {
49 - const struct ieee80211_iface_combination *comb;
50 + }
51
52 - comb = &local->hw.wiphy->iface_combinations[i];
53 + if (hw->wiphy->n_radio) {
54 + for (i = 0; i < hw->wiphy->n_radio; i++) {
55 + const struct wiphy_radio *radio = &hw->wiphy->radio[i];
56
57 - if (comb->radar_detect_widths &&
58 - comb->num_different_channels > 1)
59 + if (!ieee80211_ifcomb_check(radio->iface_combinations,
60 + radio->n_iface_combinations))
61 return -EINVAL;
62 }
63 + } else {
64 + if (!ieee80211_ifcomb_check(hw->wiphy->iface_combinations,
65 + hw->wiphy->n_iface_combinations))
66 + return -EINVAL;
67 }
68
69 /* Only HW csum features are currently compatible with mac80211 */
70 @@ -1313,18 +1337,6 @@ int ieee80211_register_hw(struct ieee802
71 hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR);
72 hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_MONITOR);
73
74 - /* mac80211 doesn't support more than one IBSS interface right now */
75 - for (i = 0; i < hw->wiphy->n_iface_combinations; i++) {
76 - const struct ieee80211_iface_combination *c;
77 - int j;
78 -
79 - c = &hw->wiphy->iface_combinations[i];
80 -
81 - for (j = 0; j < c->n_limits; j++)
82 - if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) &&
83 - c->limits[j].max > 1)
84 - return -EINVAL;
85 - }
86
87 local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) +
88 sizeof(void *) * channels, GFP_KERNEL);