95dac04de5e4110bb50a43a22f9a90796985cca3
[openwrt/openwrt.git] /
1 From: Aditya Kumar Singh <quic_adisi@quicinc.com>
2 Date: Fri, 6 Sep 2024 12:14:22 +0530
3 Subject: [PATCH] wifi: cfg80211: move DFS related members to links[] in
4 wireless_dev
5
6 A few members related to DFS handling are currently under per wireless
7 device data structure. However, in order to support DFS with MLO, there is
8 a need to have them on a per-link manner.
9
10 Hence, as a preliminary step, move members cac_started, cac_start_time
11 and cac_time_ms to be on a per-link basis.
12
13 Since currently, link ID is not known at all places, use default value of
14 0 for now.
15
16 Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
17 Link: https://patch.msgid.link/20240906064426.2101315-5-quic_adisi@quicinc.com
18 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 ---
20
21 --- a/drivers/net/wireless/marvell/mwifiex/11h.c
22 +++ b/drivers/net/wireless/marvell/mwifiex/11h.c
23 @@ -117,7 +117,7 @@ void mwifiex_dfs_cac_work_queue(struct w
24 dfs_cac_work);
25
26 chandef = priv->dfs_chandef;
27 - if (priv->wdev.cac_started) {
28 + if (priv->wdev.links[0].cac_started) {
29 mwifiex_dbg(priv->adapter, MSG,
30 "CAC timer finished; No radar detected\n");
31 cfg80211_cac_event(priv->netdev, &chandef,
32 @@ -174,7 +174,7 @@ int mwifiex_stop_radar_detection(struct
33 */
34 void mwifiex_abort_cac(struct mwifiex_private *priv)
35 {
36 - if (priv->wdev.cac_started) {
37 + if (priv->wdev.links[0].cac_started) {
38 if (mwifiex_stop_radar_detection(priv, &priv->dfs_chandef))
39 mwifiex_dbg(priv->adapter, ERROR,
40 "failed to stop CAC in FW\n");
41 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
42 +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
43 @@ -1880,7 +1880,7 @@ mwifiex_cfg80211_del_station(struct wiph
44 struct mwifiex_sta_node *sta_node;
45 u8 deauth_mac[ETH_ALEN];
46
47 - if (!priv->bss_started && priv->wdev.cac_started) {
48 + if (!priv->bss_started && priv->wdev.links[0].cac_started) {
49 mwifiex_dbg(priv->adapter, INFO, "%s: abort CAC!\n", __func__);
50 mwifiex_abort_cac(priv);
51 }
52 @@ -3978,7 +3978,7 @@ mwifiex_cfg80211_channel_switch(struct w
53 return -EBUSY;
54 }
55
56 - if (priv->wdev.cac_started)
57 + if (priv->wdev.links[0].cac_started)
58 return -EBUSY;
59
60 if (cfg80211_chandef_identical(&params->chandef,
61 --- a/drivers/net/wireless/quantenna/qtnfmac/event.c
62 +++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
63 @@ -520,21 +520,21 @@ static int qtnf_event_handle_radar(struc
64 cfg80211_radar_event(wiphy, &chandef, GFP_KERNEL);
65 break;
66 case QLINK_RADAR_CAC_FINISHED:
67 - if (!vif->wdev.cac_started)
68 + if (!vif->wdev.links[0].cac_started)
69 break;
70
71 cfg80211_cac_event(vif->netdev, &chandef,
72 NL80211_RADAR_CAC_FINISHED, GFP_KERNEL);
73 break;
74 case QLINK_RADAR_CAC_ABORTED:
75 - if (!vif->wdev.cac_started)
76 + if (!vif->wdev.links[0].cac_started)
77 break;
78
79 cfg80211_cac_event(vif->netdev, &chandef,
80 NL80211_RADAR_CAC_ABORTED, GFP_KERNEL);
81 break;
82 case QLINK_RADAR_CAC_STARTED:
83 - if (vif->wdev.cac_started)
84 + if (vif->wdev.links[0].cac_started)
85 break;
86
87 if (!wiphy_ext_feature_isset(wiphy,
88 --- a/include/net/cfg80211.h
89 +++ b/include/net/cfg80211.h
90 @@ -6198,9 +6198,6 @@ enum ieee80211_ap_reg_power {
91 * @address: The address for this device, valid only if @netdev is %NULL
92 * @is_running: true if this is a non-netdev device that has been started, e.g.
93 * the P2P Device.
94 - * @cac_started: true if DFS channel availability check has been started
95 - * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
96 - * @cac_time_ms: CAC time in ms
97 * @ps: powersave mode is enabled
98 * @ps_timeout: dynamic powersave timeout
99 * @ap_unexpected_nlportid: (private) netlink port ID of application
100 @@ -6224,6 +6221,11 @@ enum ieee80211_ap_reg_power {
101 * unprotected beacon report
102 * @links: array of %IEEE80211_MLD_MAX_NUM_LINKS elements containing @addr
103 * @ap and @client for each link
104 + * @links[].cac_started: true if DFS channel availability check has been
105 + * started
106 + * @links[].cac_start_time: timestamp (jiffies) when the dfs state was
107 + * entered.
108 + * @links[].cac_time_ms: CAC time in ms
109 * @valid_links: bitmap describing what elements of @links are valid
110 */
111 struct wireless_dev {
112 @@ -6265,11 +6267,6 @@ struct wireless_dev {
113 u32 owner_nlportid;
114 bool nl_owner_dead;
115
116 - /* FIXME: need to rework radar detection for MLO */
117 - bool cac_started;
118 - unsigned long cac_start_time;
119 - unsigned int cac_time_ms;
120 -
121 #ifdef CPTCFG_CFG80211_WEXT
122 /* wext data */
123 struct {
124 @@ -6336,6 +6333,10 @@ struct wireless_dev {
125 struct cfg80211_internal_bss *current_bss;
126 } client;
127 };
128 +
129 + bool cac_started;
130 + unsigned long cac_start_time;
131 + unsigned int cac_time_ms;
132 } links[IEEE80211_MLD_MAX_NUM_LINKS];
133 u16 valid_links;
134 };
135 --- a/net/mac80211/cfg.c
136 +++ b/net/mac80211/cfg.c
137 @@ -1656,7 +1656,7 @@ static int ieee80211_stop_ap(struct wiph
138 ieee80211_link_info_change_notify(sdata, link,
139 BSS_CHANGED_BEACON_ENABLED);
140
141 - if (sdata->wdev.cac_started) {
142 + if (sdata->wdev.links[0].cac_started) {
143 chandef = link_conf->chanreq.oper;
144 wiphy_delayed_work_cancel(wiphy, &link->dfs_cac_timer_work);
145 cfg80211_cac_event(sdata->dev, &chandef,
146 @@ -3498,9 +3498,9 @@ static void ieee80211_end_cac(struct wip
147 wiphy_delayed_work_cancel(wiphy,
148 &sdata->deflink.dfs_cac_timer_work);
149
150 - if (sdata->wdev.cac_started) {
151 + if (sdata->wdev.links[0].cac_started) {
152 ieee80211_link_release_channel(&sdata->deflink);
153 - sdata->wdev.cac_started = false;
154 + sdata->wdev.links[0].cac_started = false;
155 }
156 }
157 }
158 @@ -3955,7 +3955,7 @@ __ieee80211_channel_switch(struct wiphy
159 if (!list_empty(&local->roc_list) || local->scanning)
160 return -EBUSY;
161
162 - if (sdata->wdev.cac_started)
163 + if (sdata->wdev.links[0].cac_started)
164 return -EBUSY;
165
166 if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS))
167 --- a/net/mac80211/iface.c
168 +++ b/net/mac80211/iface.c
169 @@ -553,7 +553,7 @@ static void ieee80211_do_stop(struct iee
170 wiphy_delayed_work_cancel(local->hw.wiphy,
171 &sdata->deflink.dfs_cac_timer_work);
172
173 - if (sdata->wdev.cac_started) {
174 + if (sdata->wdev.links[0].cac_started) {
175 chandef = sdata->vif.bss_conf.chanreq.oper;
176 WARN_ON(local->suspended);
177 ieee80211_link_release_channel(&sdata->deflink);
178 --- a/net/mac80211/mlme.c
179 +++ b/net/mac80211/mlme.c
180 @@ -3039,7 +3039,7 @@ void ieee80211_dfs_cac_timer_work(struct
181
182 lockdep_assert_wiphy(sdata->local->hw.wiphy);
183
184 - if (sdata->wdev.cac_started) {
185 + if (sdata->wdev.links[0].cac_started) {
186 ieee80211_link_release_channel(link);
187 cfg80211_cac_event(sdata->dev, &chandef,
188 NL80211_RADAR_CAC_FINISHED,
189 --- a/net/mac80211/scan.c
190 +++ b/net/mac80211/scan.c
191 @@ -585,7 +585,7 @@ static bool __ieee80211_can_leave_ch(str
192 return false;
193
194 list_for_each_entry(sdata_iter, &local->interfaces, list) {
195 - if (sdata_iter->wdev.cac_started)
196 + if (sdata_iter->wdev.links[0].cac_started)
197 return false;
198 }
199
200 --- a/net/mac80211/util.c
201 +++ b/net/mac80211/util.c
202 @@ -3462,7 +3462,7 @@ void ieee80211_dfs_cac_cancel(struct iee
203 wiphy_delayed_work_cancel(local->hw.wiphy,
204 &sdata->deflink.dfs_cac_timer_work);
205
206 - if (sdata->wdev.cac_started) {
207 + if (sdata->wdev.links[0].cac_started) {
208 chandef = sdata->vif.bss_conf.chanreq.oper;
209 ieee80211_link_release_channel(&sdata->deflink);
210 cfg80211_cac_event(sdata->dev,
211 --- a/net/wireless/ibss.c
212 +++ b/net/wireless/ibss.c
213 @@ -94,7 +94,7 @@ int __cfg80211_join_ibss(struct cfg80211
214
215 lockdep_assert_held(&rdev->wiphy.mtx);
216
217 - if (wdev->cac_started)
218 + if (wdev->links[0].cac_started)
219 return -EBUSY;
220
221 if (wdev->u.ibss.ssid_len)
222 --- a/net/wireless/mesh.c
223 +++ b/net/wireless/mesh.c
224 @@ -127,7 +127,7 @@ int __cfg80211_join_mesh(struct cfg80211
225 if (!rdev->ops->join_mesh)
226 return -EOPNOTSUPP;
227
228 - if (wdev->cac_started)
229 + if (wdev->links[0].cac_started)
230 return -EBUSY;
231
232 if (!setup->chandef.chan) {
233 --- a/net/wireless/mlme.c
234 +++ b/net/wireless/mlme.c
235 @@ -1124,13 +1124,14 @@ void cfg80211_cac_event(struct net_devic
236
237 trace_cfg80211_cac_event(netdev, event);
238
239 - if (WARN_ON(!wdev->cac_started && event != NL80211_RADAR_CAC_STARTED))
240 + if (WARN_ON(!wdev->links[0].cac_started &&
241 + event != NL80211_RADAR_CAC_STARTED))
242 return;
243
244 switch (event) {
245 case NL80211_RADAR_CAC_FINISHED:
246 - timeout = wdev->cac_start_time +
247 - msecs_to_jiffies(wdev->cac_time_ms);
248 + timeout = wdev->links[0].cac_start_time +
249 + msecs_to_jiffies(wdev->links[0].cac_time_ms);
250 WARN_ON(!time_after_eq(jiffies, timeout));
251 cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_AVAILABLE);
252 memcpy(&rdev->cac_done_chandef, chandef,
253 @@ -1139,10 +1140,10 @@ void cfg80211_cac_event(struct net_devic
254 cfg80211_sched_dfs_chan_update(rdev);
255 fallthrough;
256 case NL80211_RADAR_CAC_ABORTED:
257 - wdev->cac_started = false;
258 + wdev->links[0].cac_started = false;
259 break;
260 case NL80211_RADAR_CAC_STARTED:
261 - wdev->cac_started = true;
262 + wdev->links[0].cac_started = true;
263 break;
264 default:
265 WARN_ON(1);
266 --- a/net/wireless/nl80211.c
267 +++ b/net/wireless/nl80211.c
268 @@ -6066,7 +6066,7 @@ static int nl80211_start_ap(struct sk_bu
269 if (!rdev->ops->start_ap)
270 return -EOPNOTSUPP;
271
272 - if (wdev->cac_started)
273 + if (wdev->links[0].cac_started)
274 return -EBUSY;
275
276 if (wdev->links[link_id].ap.beacon_interval)
277 @@ -10122,7 +10122,7 @@ static int nl80211_start_radar_detection
278 goto unlock;
279 }
280
281 - if (cfg80211_beaconing_iface_active(wdev) || wdev->cac_started) {
282 + if (cfg80211_beaconing_iface_active(wdev) || wdev->links[0].cac_started) {
283 err = -EBUSY;
284 goto unlock;
285 }
286 @@ -10158,9 +10158,9 @@ static int nl80211_start_radar_detection
287 default:
288 break;
289 }
290 - wdev->cac_started = true;
291 - wdev->cac_start_time = jiffies;
292 - wdev->cac_time_ms = cac_time_ms;
293 + wdev->links[0].cac_started = true;
294 + wdev->links[0].cac_start_time = jiffies;
295 + wdev->links[0].cac_time_ms = cac_time_ms;
296 }
297 unlock:
298 wiphy_unlock(wiphy);
299 --- a/net/wireless/reg.c
300 +++ b/net/wireless/reg.c
301 @@ -4241,7 +4241,7 @@ static void cfg80211_check_and_end_cac(s
302 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
303 struct cfg80211_chan_def *chandef;
304
305 - if (!wdev->cac_started)
306 + if (!wdev->links[0].cac_started)
307 continue;
308
309 /* FIXME: radar detection is tied to link 0 for now */