developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From 47d4c2ad004b10dff89ff8c5a506df3d78a042f5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Aditya Kumar Singh <quic_adisi@quicinc.com> |
| 3 | Date: Thu, 11 Jul 2024 09:21:43 +0530 |
| 4 | Subject: [PATCH 12/89] bp: wifi: cfg80211: move DFS related members to links[] |
| 5 | in wireless_dev |
| 6 | |
| 7 | A few members related to DFS handling are currently under per wireless |
| 8 | device data structure. However, in order to support DFS with MLO, there is |
| 9 | a need to have them on a per-link manner. |
| 10 | |
| 11 | Hence, as a preliminary step, move members cac_started, cac_start_time |
| 12 | and cac_time_ms to be on a per-link basis. |
| 13 | |
| 14 | Since currently, link ID is not known at all places, use default value of |
| 15 | 0 for now. |
| 16 | |
| 17 | Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> |
| 18 | --- |
| 19 | drivers/net/wireless/marvell/mwifiex/11h.c | 4 ++-- |
| 20 | drivers/net/wireless/marvell/mwifiex/cfg80211.c | 4 ++-- |
| 21 | drivers/net/wireless/quantenna/qtnfmac/event.c | 6 +++--- |
| 22 | include/net/cfg80211.h | 17 +++++++++-------- |
| 23 | net/mac80211/cfg.c | 8 ++++---- |
| 24 | net/mac80211/iface.c | 2 +- |
| 25 | net/mac80211/mlme.c | 2 +- |
| 26 | net/mac80211/scan.c | 2 +- |
| 27 | net/mac80211/util.c | 2 +- |
| 28 | net/wireless/ibss.c | 2 +- |
| 29 | net/wireless/mesh.c | 2 +- |
| 30 | net/wireless/mlme.c | 11 ++++++----- |
| 31 | net/wireless/nl80211.c | 10 +++++----- |
| 32 | net/wireless/reg.c | 2 +- |
| 33 | 14 files changed, 38 insertions(+), 36 deletions(-) |
| 34 | |
| 35 | diff --git a/drivers/net/wireless/marvell/mwifiex/11h.c b/drivers/net/wireless/marvell/mwifiex/11h.c |
| 36 | index b90f922..fb2cad0 100644 |
| 37 | --- a/drivers/net/wireless/marvell/mwifiex/11h.c |
| 38 | +++ b/drivers/net/wireless/marvell/mwifiex/11h.c |
| 39 | @@ -117,7 +117,7 @@ void mwifiex_dfs_cac_work_queue(struct work_struct *work) |
| 40 | dfs_cac_work); |
| 41 | |
| 42 | chandef = priv->dfs_chandef; |
| 43 | - if (priv->wdev.cac_started) { |
| 44 | + if (priv->wdev.links[0].cac_started) { |
| 45 | mwifiex_dbg(priv->adapter, MSG, |
| 46 | "CAC timer finished; No radar detected\n"); |
| 47 | cfg80211_cac_event(priv->netdev, &chandef, |
| 48 | @@ -174,7 +174,7 @@ int mwifiex_stop_radar_detection(struct mwifiex_private *priv, |
| 49 | */ |
| 50 | void mwifiex_abort_cac(struct mwifiex_private *priv) |
| 51 | { |
| 52 | - if (priv->wdev.cac_started) { |
| 53 | + if (priv->wdev.links[0].cac_started) { |
| 54 | if (mwifiex_stop_radar_detection(priv, &priv->dfs_chandef)) |
| 55 | mwifiex_dbg(priv->adapter, ERROR, |
| 56 | "failed to stop CAC in FW\n"); |
| 57 | diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c |
| 58 | index 7a744ce..436d391 100644 |
| 59 | --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c |
| 60 | +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c |
| 61 | @@ -1880,7 +1880,7 @@ mwifiex_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 62 | struct mwifiex_sta_node *sta_node; |
| 63 | u8 deauth_mac[ETH_ALEN]; |
| 64 | |
| 65 | - if (!priv->bss_started && priv->wdev.cac_started) { |
| 66 | + if (!priv->bss_started && priv->wdev.links[0].cac_started) { |
| 67 | mwifiex_dbg(priv->adapter, INFO, "%s: abort CAC!\n", __func__); |
| 68 | mwifiex_abort_cac(priv); |
| 69 | } |
| 70 | @@ -3978,7 +3978,7 @@ mwifiex_cfg80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
| 71 | return -EBUSY; |
| 72 | } |
| 73 | |
| 74 | - if (priv->wdev.cac_started) |
| 75 | + if (priv->wdev.links[0].cac_started) |
| 76 | return -EBUSY; |
| 77 | |
| 78 | if (cfg80211_chandef_identical(¶ms->chandef, |
| 79 | diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c |
| 80 | index 76b07db..8bd1e14 100644 |
| 81 | --- a/drivers/net/wireless/quantenna/qtnfmac/event.c |
| 82 | +++ b/drivers/net/wireless/quantenna/qtnfmac/event.c |
| 83 | @@ -520,21 +520,21 @@ static int qtnf_event_handle_radar(struct qtnf_vif *vif, |
| 84 | cfg80211_radar_event(wiphy, &chandef, GFP_KERNEL); |
| 85 | break; |
| 86 | case QLINK_RADAR_CAC_FINISHED: |
| 87 | - if (!vif->wdev.cac_started) |
| 88 | + if (!vif->wdev.links[0].cac_started) |
| 89 | break; |
| 90 | |
| 91 | cfg80211_cac_event(vif->netdev, &chandef, |
| 92 | NL80211_RADAR_CAC_FINISHED, GFP_KERNEL); |
| 93 | break; |
| 94 | case QLINK_RADAR_CAC_ABORTED: |
| 95 | - if (!vif->wdev.cac_started) |
| 96 | + if (!vif->wdev.links[0].cac_started) |
| 97 | break; |
| 98 | |
| 99 | cfg80211_cac_event(vif->netdev, &chandef, |
| 100 | NL80211_RADAR_CAC_ABORTED, GFP_KERNEL); |
| 101 | break; |
| 102 | case QLINK_RADAR_CAC_STARTED: |
| 103 | - if (vif->wdev.cac_started) |
| 104 | + if (vif->wdev.links[0].cac_started) |
| 105 | break; |
| 106 | |
| 107 | if (!wiphy_ext_feature_isset(wiphy, |
| 108 | diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h |
| 109 | index 850861b..86634cc 100644 |
| 110 | --- a/include/net/cfg80211.h |
| 111 | +++ b/include/net/cfg80211.h |
| 112 | @@ -6206,9 +6206,6 @@ enum ieee80211_ap_reg_power { |
| 113 | * @address: The address for this device, valid only if @netdev is %NULL |
| 114 | * @is_running: true if this is a non-netdev device that has been started, e.g. |
| 115 | * the P2P Device. |
| 116 | - * @cac_started: true if DFS channel availability check has been started |
| 117 | - * @cac_start_time: timestamp (jiffies) when the dfs state was entered. |
| 118 | - * @cac_time_ms: CAC time in ms |
| 119 | * @ps: powersave mode is enabled |
| 120 | * @ps_timeout: dynamic powersave timeout |
| 121 | * @ap_unexpected_nlportid: (private) netlink port ID of application |
| 122 | @@ -6232,6 +6229,11 @@ enum ieee80211_ap_reg_power { |
| 123 | * unprotected beacon report |
| 124 | * @links: array of %IEEE80211_MLD_MAX_NUM_LINKS elements containing @addr |
| 125 | * @ap and @client for each link |
| 126 | + * @links[].cac_started: true if DFS channel availability check has been |
| 127 | + * started |
| 128 | + * @links[].cac_start_time: timestamp (jiffies) when the dfs state was |
| 129 | + * entered. |
| 130 | + * @links[].cac_time_ms: CAC time in ms |
| 131 | * @valid_links: bitmap describing what elements of @links are valid |
| 132 | */ |
| 133 | struct wireless_dev { |
| 134 | @@ -6273,11 +6275,6 @@ struct wireless_dev { |
| 135 | u32 owner_nlportid; |
| 136 | bool nl_owner_dead; |
| 137 | |
| 138 | - /* FIXME: need to rework radar detection for MLO */ |
| 139 | - bool cac_started; |
| 140 | - unsigned long cac_start_time; |
| 141 | - unsigned int cac_time_ms; |
| 142 | - |
| 143 | #ifdef CPTCFG_CFG80211_WEXT |
| 144 | /* wext data */ |
| 145 | struct { |
| 146 | @@ -6344,6 +6341,10 @@ struct wireless_dev { |
| 147 | struct cfg80211_internal_bss *current_bss; |
| 148 | } client; |
| 149 | }; |
| 150 | + |
| 151 | + bool cac_started; |
| 152 | + unsigned long cac_start_time; |
| 153 | + unsigned int cac_time_ms; |
| 154 | } links[IEEE80211_MLD_MAX_NUM_LINKS]; |
| 155 | u16 valid_links; |
| 156 | }; |
| 157 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
| 158 | index ec47ab1..4d5eb60 100644 |
| 159 | --- a/net/mac80211/cfg.c |
| 160 | +++ b/net/mac80211/cfg.c |
| 161 | @@ -1656,7 +1656,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev, |
| 162 | ieee80211_link_info_change_notify(sdata, link, |
| 163 | BSS_CHANGED_BEACON_ENABLED); |
| 164 | |
| 165 | - if (sdata->wdev.cac_started) { |
| 166 | + if (sdata->wdev.links[0].cac_started) { |
| 167 | chandef = link_conf->chanreq.oper; |
| 168 | wiphy_delayed_work_cancel(wiphy, &link->dfs_cac_timer_work); |
| 169 | cfg80211_cac_event(sdata->dev, &chandef, |
| 170 | @@ -3494,9 +3494,9 @@ static void ieee80211_end_cac(struct wiphy *wiphy, |
| 171 | wiphy_delayed_work_cancel(wiphy, |
| 172 | &sdata->deflink.dfs_cac_timer_work); |
| 173 | |
| 174 | - if (sdata->wdev.cac_started) { |
| 175 | + if (sdata->wdev.links[0].cac_started) { |
| 176 | ieee80211_link_release_channel(&sdata->deflink); |
| 177 | - sdata->wdev.cac_started = false; |
| 178 | + sdata->wdev.links[0].cac_started = false; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | @@ -3951,7 +3951,7 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
| 183 | if (!list_empty(&local->roc_list) || local->scanning) |
| 184 | return -EBUSY; |
| 185 | |
| 186 | - if (sdata->wdev.cac_started) |
| 187 | + if (sdata->wdev.links[0].cac_started) |
| 188 | return -EBUSY; |
| 189 | |
| 190 | if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS)) |
| 191 | diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
| 192 | index 00d75e0..f0d9024 100644 |
| 193 | --- a/net/mac80211/iface.c |
| 194 | +++ b/net/mac80211/iface.c |
| 195 | @@ -552,7 +552,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do |
| 196 | wiphy_delayed_work_cancel(local->hw.wiphy, |
| 197 | &sdata->deflink.dfs_cac_timer_work); |
| 198 | |
| 199 | - if (sdata->wdev.cac_started) { |
| 200 | + if (sdata->wdev.links[0].cac_started) { |
| 201 | chandef = sdata->vif.bss_conf.chanreq.oper; |
| 202 | WARN_ON(local->suspended); |
| 203 | ieee80211_link_release_channel(&sdata->deflink); |
| 204 | diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c |
| 205 | index 5b83e7b..2258858 100644 |
| 206 | --- a/net/mac80211/mlme.c |
| 207 | +++ b/net/mac80211/mlme.c |
| 208 | @@ -3039,7 +3039,7 @@ void ieee80211_dfs_cac_timer_work(struct wiphy *wiphy, struct wiphy_work *work) |
| 209 | |
| 210 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
| 211 | |
| 212 | - if (sdata->wdev.cac_started) { |
| 213 | + if (sdata->wdev.links[0].cac_started) { |
| 214 | ieee80211_link_release_channel(link); |
| 215 | cfg80211_cac_event(sdata->dev, &chandef, |
| 216 | NL80211_RADAR_CAC_FINISHED, |
| 217 | diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c |
| 218 | index b5f2df6..7d8e7af 100644 |
| 219 | --- a/net/mac80211/scan.c |
| 220 | +++ b/net/mac80211/scan.c |
| 221 | @@ -585,7 +585,7 @@ static bool __ieee80211_can_leave_ch(struct ieee80211_sub_if_data *sdata) |
| 222 | return false; |
| 223 | |
| 224 | list_for_each_entry(sdata_iter, &local->interfaces, list) { |
| 225 | - if (sdata_iter->wdev.cac_started) |
| 226 | + if (sdata_iter->wdev.links[0].cac_started) |
| 227 | return false; |
| 228 | } |
| 229 | |
| 230 | diff --git a/net/mac80211/util.c b/net/mac80211/util.c |
| 231 | index 77d1e44..424d8d6 100644 |
| 232 | --- a/net/mac80211/util.c |
| 233 | +++ b/net/mac80211/util.c |
| 234 | @@ -3462,7 +3462,7 @@ void ieee80211_dfs_cac_cancel(struct ieee80211_local *local) |
| 235 | wiphy_delayed_work_cancel(local->hw.wiphy, |
| 236 | &sdata->deflink.dfs_cac_timer_work); |
| 237 | |
| 238 | - if (sdata->wdev.cac_started) { |
| 239 | + if (sdata->wdev.links[0].cac_started) { |
| 240 | chandef = sdata->vif.bss_conf.chanreq.oper; |
| 241 | ieee80211_link_release_channel(&sdata->deflink); |
| 242 | cfg80211_cac_event(sdata->dev, |
| 243 | diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c |
| 244 | index 0651e9b..0fc930a 100644 |
| 245 | --- a/net/wireless/ibss.c |
| 246 | +++ b/net/wireless/ibss.c |
| 247 | @@ -94,7 +94,7 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, |
| 248 | |
| 249 | lockdep_assert_held(&rdev->wiphy.mtx); |
| 250 | |
| 251 | - if (wdev->cac_started) |
| 252 | + if (wdev->links[0].cac_started) |
| 253 | return -EBUSY; |
| 254 | |
| 255 | if (wdev->u.ibss.ssid_len) |
| 256 | diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c |
| 257 | index aaca65b..2c66540 100644 |
| 258 | --- a/net/wireless/mesh.c |
| 259 | +++ b/net/wireless/mesh.c |
| 260 | @@ -127,7 +127,7 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, |
| 261 | if (!rdev->ops->join_mesh) |
| 262 | return -EOPNOTSUPP; |
| 263 | |
| 264 | - if (wdev->cac_started) |
| 265 | + if (wdev->links[0].cac_started) |
| 266 | return -EBUSY; |
| 267 | |
| 268 | if (!setup->chandef.chan) { |
| 269 | diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c |
| 270 | index c7e62eb..eda999d 100644 |
| 271 | --- a/net/wireless/mlme.c |
| 272 | +++ b/net/wireless/mlme.c |
| 273 | @@ -1124,13 +1124,14 @@ void cfg80211_cac_event(struct net_device *netdev, |
| 274 | |
| 275 | trace_cfg80211_cac_event(netdev, event); |
| 276 | |
| 277 | - if (WARN_ON(!wdev->cac_started && event != NL80211_RADAR_CAC_STARTED)) |
| 278 | + if (WARN_ON(!wdev->links[0].cac_started && |
| 279 | + event != NL80211_RADAR_CAC_STARTED)) |
| 280 | return; |
| 281 | |
| 282 | switch (event) { |
| 283 | case NL80211_RADAR_CAC_FINISHED: |
| 284 | - timeout = wdev->cac_start_time + |
| 285 | - msecs_to_jiffies(wdev->cac_time_ms); |
| 286 | + timeout = wdev->links[0].cac_start_time + |
| 287 | + msecs_to_jiffies(wdev->links[0].cac_time_ms); |
| 288 | WARN_ON(!time_after_eq(jiffies, timeout)); |
| 289 | cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_AVAILABLE); |
| 290 | memcpy(&rdev->cac_done_chandef, chandef, |
| 291 | @@ -1139,10 +1140,10 @@ void cfg80211_cac_event(struct net_device *netdev, |
| 292 | cfg80211_sched_dfs_chan_update(rdev); |
| 293 | fallthrough; |
| 294 | case NL80211_RADAR_CAC_ABORTED: |
| 295 | - wdev->cac_started = false; |
| 296 | + wdev->links[0].cac_started = false; |
| 297 | break; |
| 298 | case NL80211_RADAR_CAC_STARTED: |
| 299 | - wdev->cac_started = true; |
| 300 | + wdev->links[0].cac_started = true; |
| 301 | break; |
| 302 | default: |
| 303 | WARN_ON(1); |
| 304 | diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
| 305 | index 6489fe9..3e87f5a 100644 |
| 306 | --- a/net/wireless/nl80211.c |
| 307 | +++ b/net/wireless/nl80211.c |
| 308 | @@ -6099,7 +6099,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) |
| 309 | if (!rdev->ops->start_ap) |
| 310 | return -EOPNOTSUPP; |
| 311 | |
| 312 | - if (wdev->cac_started) |
| 313 | + if (wdev->links[0].cac_started) |
| 314 | return -EBUSY; |
| 315 | |
| 316 | if (wdev->links[link_id].ap.beacon_interval) |
| 317 | @@ -10154,7 +10154,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, |
| 318 | goto unlock; |
| 319 | } |
| 320 | |
| 321 | - if (cfg80211_beaconing_iface_active(wdev) || wdev->cac_started) { |
| 322 | + if (cfg80211_beaconing_iface_active(wdev) || wdev->links[0].cac_started) { |
| 323 | err = -EBUSY; |
| 324 | goto unlock; |
| 325 | } |
| 326 | @@ -10177,9 +10177,9 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, |
| 327 | err = rdev_start_radar_detection(rdev, dev, &chandef, cac_time_ms); |
| 328 | if (!err) { |
| 329 | wdev->links[0].ap.chandef = chandef; |
| 330 | - wdev->cac_started = true; |
| 331 | - wdev->cac_start_time = jiffies; |
| 332 | - wdev->cac_time_ms = cac_time_ms; |
| 333 | + wdev->links[0].cac_started = true; |
| 334 | + wdev->links[0].cac_start_time = jiffies; |
| 335 | + wdev->links[0].cac_time_ms = cac_time_ms; |
| 336 | } |
| 337 | unlock: |
| 338 | wiphy_unlock(wiphy); |
| 339 | diff --git a/net/wireless/reg.c b/net/wireless/reg.c |
| 340 | index 4219dc2..0040862 100644 |
| 341 | --- a/net/wireless/reg.c |
| 342 | +++ b/net/wireless/reg.c |
| 343 | @@ -4245,7 +4245,7 @@ static void cfg80211_check_and_end_cac(struct cfg80211_registered_device *rdev) |
| 344 | list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { |
| 345 | struct cfg80211_chan_def *chandef; |
| 346 | |
| 347 | - if (!wdev->cac_started) |
| 348 | + if (!wdev->links[0].cac_started) |
| 349 | continue; |
| 350 | |
| 351 | /* FIXME: radar detection is tied to link 0 for now */ |
| 352 | -- |
| 353 | 2.18.0 |
| 354 | |