diff options
author | Rory Little <rory@candelatech.com> | 2024-08-06 02:40:23 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2024-08-27 10:28:53 +0200 |
commit | 7c3b69eadea9e57c28bf914b0fd70f268f3682e1 (patch) | |
tree | 6f65d8da713a3f5d06d14241cf86c88d22027a4d /net/mac80211 | |
parent | staging: rtl8192e: Constify struct lib80211_crypto_ops (diff) | |
download | linux-7c3b69eadea9e57c28bf914b0fd70f268f3682e1.tar.xz linux-7c3b69eadea9e57c28bf914b0fd70f268f3682e1.zip |
wifi: mac80211: Add non-atomic station iterator
Drivers may at times want to iterate their stations with a function
which requires some non-atomic operations.
ieee80211_iterate_stations_mtx() introduces an API to iterate stations
while holding that wiphy's mutex. This allows the iterating function to
do non-atomic operations safely.
Signed-off-by: Rory Little <rory@candelatech.com>
Link: https://patch.msgid.link/20240806004024.2014080-2-rory@candelatech.com
[unify internal list iteration functions]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/util.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index ced19ce7c51a..830f736f9c13 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -833,7 +833,8 @@ static void __iterate_stations(struct ieee80211_local *local, { struct sta_info *sta; - list_for_each_entry_rcu(sta, &local->sta_list, list) { + list_for_each_entry_rcu(sta, &local->sta_list, list, + lockdep_is_held(&local->hw.wiphy->mtx)) { if (!sta->uploaded) continue; @@ -854,6 +855,19 @@ void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, } EXPORT_SYMBOL_GPL(ieee80211_iterate_stations_atomic); +void ieee80211_iterate_stations_mtx(struct ieee80211_hw *hw, + void (*iterator)(void *data, + struct ieee80211_sta *sta), + void *data) +{ + struct ieee80211_local *local = hw_to_local(hw); + + lockdep_assert_wiphy(local->hw.wiphy); + + __iterate_stations(local, iterator, data); +} +EXPORT_SYMBOL_GPL(ieee80211_iterate_stations_mtx); + struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev) { struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |