mac80211: refactor virtual monitor code
authorMichal Kazior <michal.kazior@tieto.com>
Fri, 29 Jun 2012 10:47:02 +0000 (12:47 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 29 Jun 2012 11:39:16 +0000 (13:39 +0200)
Use cfg80211 the new .set_monitor_enabled instead
of tracking it inside mac80211.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/cfg.c
net/mac80211/ieee80211_i.h
net/mac80211/iface.c

index 0f02c8b77e1c8f95769d738b0b32cce482768675..ea4b1ea9105a3ff721d864a4de719a0fa9feb4e5 100644 (file)
@@ -2990,6 +2990,16 @@ ieee80211_wiphy_get_channel(struct wiphy *wiphy,
        return local->oper_channel;
 }
 
+static void ieee80211_set_monitor_enabled(struct wiphy *wiphy, bool enabled)
+{
+       struct ieee80211_local *local = wiphy_priv(wiphy);
+
+       if (enabled)
+               WARN_ON(ieee80211_add_virtual_monitor(local));
+       else
+               ieee80211_del_virtual_monitor(local);
+}
+
 #ifdef CONFIG_PM
 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
 {
@@ -3065,6 +3075,7 @@ struct cfg80211_ops mac80211_config_ops = {
        .probe_client = ieee80211_probe_client,
        .get_channel = ieee80211_wiphy_get_channel,
        .set_noack_map = ieee80211_set_noack_map,
+       .set_monitor_enabled = ieee80211_set_monitor_enabled,
 #ifdef CONFIG_PM
        .set_wakeup = ieee80211_set_wakeup,
 #endif
index 6b7157d205070276355581d7039aa1002cbeae8f..b88bdfd248ff7caaf71475d2283db00fd4fdd79e 100644 (file)
@@ -1485,6 +1485,10 @@ int ieee80211_add_srates_ie(struct ieee80211_sub_if_data *sdata,
 int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata,
                                struct sk_buff *skb, bool need_basic);
 
+/* virtual monitor */
+int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
+void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
+
 /* channel management */
 enum ieee80211_chan_mode {
        CHAN_MODE_UNDEFINED,
index 0a6b4e1043cb7ea96ddfd4dbe3dcfca5080cac8b..fbef7a1ada7aaed349d4cec790643d47c8066b93 100644 (file)
@@ -330,7 +330,7 @@ static void ieee80211_set_default_queues(struct ieee80211_sub_if_data *sdata)
        sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE;
 }
 
-static int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
+int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
 {
        struct ieee80211_sub_if_data *sdata;
        int ret;
@@ -371,7 +371,7 @@ static int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
        return 0;
 }
 
-static void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
+void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
 {
        struct ieee80211_sub_if_data *sdata;
 
@@ -487,12 +487,6 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
                        break;
                }
 
-               if (local->monitors == 0 && local->open_count == 0) {
-                       res = ieee80211_add_virtual_monitor(local);
-                       if (res)
-                               goto err_stop;
-               }
-
                /* must be before the call to ieee80211_configure_filter */
                local->monitors++;
                if (local->monitors == 1) {
@@ -507,8 +501,6 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
                break;
        default:
                if (coming_up) {
-                       ieee80211_del_virtual_monitor(local);
-
                        res = drv_add_interface(local, sdata);
                        if (res)
                                goto err_stop;
@@ -743,7 +735,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
                if (local->monitors == 0) {
                        local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR;
                        hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
-                       ieee80211_del_virtual_monitor(local);
                }
 
                ieee80211_adjust_monitor_flags(sdata, -1);
@@ -817,9 +808,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
                }
        }
        spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
-
-       if (local->monitors == local->open_count && local->monitors > 0)
-               ieee80211_add_virtual_monitor(local);
 }
 
 static int ieee80211_stop(struct net_device *dev)