mac80211: expose API allowing station iteration
authorArik Nemtsov <arik@wizery.com>
Wed, 22 Oct 2014 09:30:59 +0000 (12:30 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 23 Oct 2014 18:40:03 +0000 (20:40 +0200)
Allow drivers to iterate all stations currently uploaded to them.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/mac80211.h
net/mac80211/util.c

index 99dd3ce7484e266a560205943becdd3e0b1c281c..2b7426a90ff09f37e6cd803a0062d76617a97cc2 100644 (file)
@@ -4192,6 +4192,22 @@ void ieee80211_iterate_active_interfaces_rtnl(struct ieee80211_hw *hw,
                                                struct ieee80211_vif *vif),
                                              void *data);
 
+/**
+ * ieee80211_iterate_stations_atomic - iterate stations
+ *
+ * This function iterates over all stations associated with a given
+ * hardware that are currently uploaded to the driver and calls the callback
+ * function for them.
+ * This function requires the iterator callback function to be atomic,
+ *
+ * @hw: the hardware struct of which the interfaces should be iterated over
+ * @iterator: the iterator function to call, cannot sleep
+ * @data: first argument of the iterator function
+ */
+void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
+                                      void (*iterator)(void *data,
+                                               struct ieee80211_sta *sta),
+                                      void *data);
 /**
  * ieee80211_queue_work - add work onto the mac80211 workqueue
  *
index 9247a960ea5917b339e1206b5d4f0c71f08ba7b7..666aa1306c45f5d8e71a4e677a1c13841c3acd57 100644 (file)
@@ -693,6 +693,34 @@ void ieee80211_iterate_active_interfaces_rtnl(
 }
 EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_rtnl);
 
+static void __iterate_stations(struct ieee80211_local *local,
+                              void (*iterator)(void *data,
+                                               struct ieee80211_sta *sta),
+                              void *data)
+{
+       struct sta_info *sta;
+
+       list_for_each_entry_rcu(sta, &local->sta_list, list) {
+               if (!sta->uploaded)
+                       continue;
+
+               iterator(data, &sta->sta);
+       }
+}
+
+void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
+                       void (*iterator)(void *data,
+                                        struct ieee80211_sta *sta),
+                       void *data)
+{
+       struct ieee80211_local *local = hw_to_local(hw);
+
+       rcu_read_lock();
+       __iterate_stations(local, iterator, data);
+       rcu_read_unlock();
+}
+EXPORT_SYMBOL_GPL(ieee80211_iterate_stations_atomic);
+
 struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev)
 {
        struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);