mac80211: Various small fixes for cfg.c: mpath_set_pinfo()
[firefly-linux-kernel-4.4.55.git] / net / mac80211 / cfg.c
index 7d9abea37b1763fd5f5b2e68b5ccc7a01c6006bc..a58c0b649ba137b09214c031bf3508b5fe2974eb 100644 (file)
 #include "rate.h"
 #include "mesh.h"
 
-static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name,
-                                             enum nl80211_iftype type,
-                                             u32 *flags,
-                                             struct vif_params *params)
+static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, char *name,
+                                               enum nl80211_iftype type,
+                                               u32 *flags,
+                                               struct vif_params *params)
 {
        struct ieee80211_local *local = wiphy_priv(wiphy);
-       struct net_device *dev;
+       struct wireless_dev *wdev;
        struct ieee80211_sub_if_data *sdata;
        int err;
 
-       err = ieee80211_if_add(local, name, &dev, type, params);
+       err = ieee80211_if_add(local, name, &wdev, type, params);
        if (err)
                return ERR_PTR(err);
 
        if (type == NL80211_IFTYPE_MONITOR && flags) {
-               sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+               sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
                sdata->u.mntr_flags = *flags;
        }
 
-       return dev;
+       return wdev;
 }
 
-static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev)
+static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
 {
-       ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev));
+       ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev));
 
        return 0;
 }
@@ -917,6 +917,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
 
        kfree_rcu(old, rcu_head);
 
+       sta_info_flush(sdata->local, sdata);
        ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
 
        return 0;
@@ -1377,6 +1378,8 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
        else
                memset(next_hop, 0, ETH_ALEN);
 
+       memset(pinfo, 0, sizeof(*pinfo));
+
        pinfo->generation = mesh_paths_generation;
 
        pinfo->filled = MPATH_INFO_FRAME_QLEN |
@@ -1395,7 +1398,6 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
        pinfo->discovery_timeout =
                        jiffies_to_msecs(mpath->discovery_timeout);
        pinfo->discovery_retries = mpath->discovery_retries;
-       pinfo->flags = 0;
        if (mpath->flags & MESH_PATH_ACTIVE)
                pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
        if (mpath->flags & MESH_PATH_RESOLVING)
@@ -1404,10 +1406,8 @@ static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
                pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
        if (mpath->flags & MESH_PATH_FIXED)
                pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
-       if (mpath->flags & MESH_PATH_RESOLVING)
-               pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
-
-       pinfo->flags = mpath->flags;
+       if (mpath->flags & MESH_PATH_RESOLVED)
+               pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED;
 }
 
 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
@@ -1763,10 +1763,11 @@ static int ieee80211_resume(struct wiphy *wiphy)
 #endif
 
 static int ieee80211_scan(struct wiphy *wiphy,
-                         struct net_device *dev,
                          struct cfg80211_scan_request *req)
 {
-       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+       struct ieee80211_sub_if_data *sdata;
+
+       sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev);
 
        switch (ieee80211_vif_type_p2p(&sdata->vif)) {
        case NL80211_IFTYPE_STATION:
@@ -2492,6 +2493,7 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
        skb->dev = sdata->dev;
 
        if (!need_offchan) {
+               *cookie = (unsigned long) skb;
                ieee80211_tx_skb(sdata, skb);
                ret = 0;
                goto out_unlock;
@@ -2981,14 +2983,14 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
        return 0;
 }
 
-static void ieee80211_set_monitor_enabled(struct wiphy *wiphy, bool enabled)
+static struct ieee80211_channel *
+ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev,
+                         enum nl80211_channel_type *type)
 {
        struct ieee80211_local *local = wiphy_priv(wiphy);
 
-       if (enabled)
-               WARN_ON(ieee80211_add_virtual_monitor(local));
-       else
-               ieee80211_del_virtual_monitor(local);
+       *type = local->_oper_channel_type;
+       return local->oper_channel;
 }
 
 #ifdef CONFIG_PM
@@ -3065,11 +3067,11 @@ struct cfg80211_ops mac80211_config_ops = {
        .tdls_mgmt = ieee80211_tdls_mgmt,
        .probe_client = ieee80211_probe_client,
        .set_noack_map = ieee80211_set_noack_map,
-       .set_monitor_enabled = ieee80211_set_monitor_enabled,
 #ifdef CONFIG_PM
        .set_wakeup = ieee80211_set_wakeup,
 #endif
        .get_et_sset_count = ieee80211_get_et_sset_count,
        .get_et_stats = ieee80211_get_et_stats,
        .get_et_strings = ieee80211_get_et_strings,
+       .get_channel = ieee80211_cfg_get_channel,
 };