cfg80211: add request id to cfg80211_sched_scan_*() api
authorArend Van Spriel <arend.vanspriel@broadcom.com>
Fri, 28 Apr 2017 12:40:28 +0000 (13:40 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 28 Apr 2017 12:51:43 +0000 (14:51 +0200)
Have proper request id filled in the SCHED_SCAN_RESULTS and
SCHED_SCAN_STOPPED notifications toward user-space by having the
driver provide it through the api.

Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
16 files changed:
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/ath/ath6kl/wmi.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
drivers/net/wireless/marvell/mwifiex/cfg80211.c
drivers/net/wireless/marvell/mwifiex/main.c
drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
drivers/net/wireless/marvell/mwifiex/sta_event.c
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
include/net/cfg80211.h
net/mac80211/pm.c
net/mac80211/scan.c
net/mac80211/util.c
net/wireless/core.c
net/wireless/core.h
net/wireless/scan.c
net/wireless/trace.h

index 0bc42fcceb744f1b084ebbaa5277e8ef0a2d4f6c..414b5b596efcd92b7f97a059b710668e059f218c 100644 (file)
@@ -169,7 +169,7 @@ static void ath6kl_cfg80211_sscan_disable(struct ath6kl_vif *vif)
        if (!stopped)
                return;
 
-       cfg80211_sched_scan_stopped(ar->wiphy);
+       cfg80211_sched_scan_stopped(ar->wiphy, 0);
 }
 
 static int ath6kl_set_wpa_version(struct ath6kl_vif *vif,
index a082de81ec4c23e5e085d8e75966e9c880bba181..bfc20b45b806cea3ce1764c8be4add34a8408c1a 100644 (file)
@@ -1082,7 +1082,7 @@ void ath6kl_wmi_sscan_timer(unsigned long ptr)
 {
        struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr;
 
-       cfg80211_sched_scan_results(vif->ar->wiphy);
+       cfg80211_sched_scan_results(vif->ar->wiphy, 0);
 }
 
 static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
index b43cccfb66b665dbcc4ad59037a034401e0a6243..cd1d6730eab73d514db5a1b88d442607c7834e3d 100644 (file)
@@ -762,7 +762,7 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
                brcmf_dbg(SCAN, "scheduled scan completed\n");
                cfg->internal_escan = false;
                if (!aborted)
-                       cfg80211_sched_scan_results(cfg_to_wiphy(cfg));
+                       cfg80211_sched_scan_results(cfg_to_wiphy(cfg), 0);
        } else if (scan_request) {
                struct cfg80211_scan_info info = {
                        .aborted = aborted,
@@ -3372,7 +3372,7 @@ brcmf_notify_sched_scan_results(struct brcmf_if *ifp,
                goto free_req;
 
 out_err:
-       cfg80211_sched_scan_stopped(wiphy);
+       cfg80211_sched_scan_stopped(wiphy, 0);
 free_req:
        kfree(request);
        return err;
index 0406a98f86f07ea8501495ffedb70f71b1be7145..7ec06bf13413bfaf6fb1153cc9a2a34a14e51c1f 100644 (file)
@@ -2053,7 +2053,7 @@ mwifiex_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev,
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
 
        if (!mwifiex_stop_bg_scan(priv))
-               cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy);
+               cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0);
 
        if (mwifiex_deauthenticate(priv, NULL))
                return -EFAULT;
@@ -2321,7 +2321,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
                    (int)sme->ssid_len, (char *)sme->ssid, sme->bssid);
 
        if (!mwifiex_stop_bg_scan(priv))
-               cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy);
+               cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0);
 
        ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid,
                                     priv->bss_mode, sme->channel, sme, 0);
@@ -2530,7 +2530,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
                priv->scan_block = false;
 
        if (!mwifiex_stop_bg_scan(priv))
-               cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy);
+               cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0);
 
        user_scan_cfg = kzalloc(sizeof(*user_scan_cfg), GFP_KERNEL);
        if (!user_scan_cfg)
index 976011d532d56434eb9167a9bba84c3fd6e1c708..dd87b9ff64c371911a74308be55e93e3a46cdd43 100644 (file)
@@ -748,7 +748,7 @@ mwifiex_close(struct net_device *dev)
                mwifiex_dbg(priv->adapter, INFO,
                            "aborting bgscan on ndo_stop\n");
                mwifiex_stop_bg_scan(priv);
-               cfg80211_sched_scan_stopped(priv->wdev.wiphy);
+               cfg80211_sched_scan_stopped(priv->wdev.wiphy, 0);
        }
 
        return 0;
index ab75da3e0c2b7c1d6d0b6206886bf838a7c4c1bf..f1d1f56fc23ff739c3766e38bc723337a581ccb6 100644 (file)
@@ -1201,7 +1201,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
                break;
        case HostCmd_CMD_802_11_BG_SCAN_QUERY:
                ret = mwifiex_ret_802_11_scan(priv, resp);
-               cfg80211_sched_scan_results(priv->wdev.wiphy);
+               cfg80211_sched_scan_results(priv->wdev.wiphy, 0);
                mwifiex_dbg(adapter, CMD,
                            "info: CMD_RESP: BG_SCAN result is ready!\n");
                break;
index b5b7664507eb51c1d93b6d26b8d44007aeed88fb..839df8a9634e86c58367c7149d146d8a9bd36657 100644 (file)
@@ -793,7 +793,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
 
        case EVENT_BG_SCAN_STOPPED:
                dev_dbg(adapter->dev, "event: BGS_STOPPED\n");
-               cfg80211_sched_scan_stopped(priv->wdev.wiphy);
+               cfg80211_sched_scan_stopped(priv->wdev.wiphy, 0);
                if (priv->sched_scanning)
                        priv->sched_scanning = false;
                break;
index 1532ac9cee0b2f0a4bffda01073db5fa181286ca..42997e05d90fa528a5db7b64cef75f5f6283bd1d 100644 (file)
@@ -560,7 +560,7 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
 #endif
                        mwifiex_dbg(adapter, CMD, "aborting bgscan!\n");
                        mwifiex_stop_bg_scan(priv);
-                       cfg80211_sched_scan_stopped(priv->wdev.wiphy);
+                       cfg80211_sched_scan_stopped(priv->wdev.wiphy, 0);
 #ifdef CONFIG_PM
                }
 #endif
index 52e810fe0833d8dfeeda20e8b05a45f2bb1ad86d..6e90f1a4950f1dfa333478d9d0104210307006af 100644 (file)
@@ -1666,6 +1666,7 @@ struct cfg80211_bss_select_adjust {
  *     (others are filtered out).
  *     If ommited, all results are passed.
  * @n_match_sets: number of match sets
+ * @results_wk: worker for processing results notification.
  * @wiphy: the wiphy this was for
  * @dev: the interface
  * @scan_start: start time of the scheduled scan
@@ -1726,6 +1727,7 @@ struct cfg80211_sched_scan_request {
        struct wiphy *wiphy;
        struct net_device *dev;
        unsigned long scan_start;
+       bool report_results;
        struct rcu_head rcu_head;
        u32 owner_nlportid;
        bool nl_owner_dead;
@@ -4564,31 +4566,34 @@ void cfg80211_scan_done(struct cfg80211_scan_request *request,
  * cfg80211_sched_scan_results - notify that new scan results are available
  *
  * @wiphy: the wiphy which got scheduled scan results
+ * @reqid: identifier for the related scheduled scan request
  */
-void cfg80211_sched_scan_results(struct wiphy *wiphy);
+void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
 
 /**
  * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped
  *
  * @wiphy: the wiphy on which the scheduled scan stopped
+ * @reqid: identifier for the related scheduled scan request
  *
  * The driver can call this function to inform cfg80211 that the
  * scheduled scan had to be stopped, for whatever reason.  The driver
  * is then called back via the sched_scan_stop operation when done.
  */
-void cfg80211_sched_scan_stopped(struct wiphy *wiphy);
+void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
 
 /**
  * cfg80211_sched_scan_stopped_rtnl - notify that the scheduled scan has stopped
  *
  * @wiphy: the wiphy on which the scheduled scan stopped
+ * @reqid: identifier for the related scheduled scan request
  *
  * The driver can call this function to inform cfg80211 that the
  * scheduled scan had to be stopped, for whatever reason.  The driver
  * is then called back via the sched_scan_stop operation when done.
  * This function should be called with rtnl locked.
  */
-void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy);
+void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy, u64 reqid);
 
 /**
  * cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
index 76a8bcd8ef11237cf8715bf6a10c9085a2152d4d..a87d195c4a615761ed6041296b417ec3c9a8f996 100644 (file)
@@ -10,7 +10,7 @@ static void ieee80211_sched_scan_cancel(struct ieee80211_local *local)
 {
        if (ieee80211_request_sched_scan_stop(local))
                return;
-       cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy);
+       cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy, 0);
 }
 
 int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
index 0b16e2e8dc9eb51681e220da7f22162336034c0b..47d2ed5704700f110aa6a0f57ecb5af29e0c5db9 100644 (file)
@@ -1219,7 +1219,7 @@ void ieee80211_sched_scan_results(struct ieee80211_hw *hw)
 
        trace_api_sched_scan_results(local);
 
-       cfg80211_sched_scan_results(hw->wiphy);
+       cfg80211_sched_scan_results(hw->wiphy, 0);
 }
 EXPORT_SYMBOL(ieee80211_sched_scan_results);
 
@@ -1239,7 +1239,7 @@ void ieee80211_sched_scan_end(struct ieee80211_local *local)
 
        mutex_unlock(&local->mtx);
 
-       cfg80211_sched_scan_stopped(local->hw.wiphy);
+       cfg80211_sched_scan_stopped(local->hw.wiphy, 0);
 }
 
 void ieee80211_sched_scan_stopped_work(struct work_struct *work)
index bfc28053639be13d153d5a73bff616e230f30e96..ac9ac6c35594a4c67d570bb40cc4ad44f3d7bfa0 100644 (file)
@@ -2112,7 +2112,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
        mutex_unlock(&local->mtx);
 
        if (sched_scan_stopped)
-               cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy);
+               cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy, 0);
 
  wake_up:
        if (local->in_reconfig) {
index a3c0c48afb8501d40e96c30141e5a89b14766cb8..83ea164f16b3e018546260d8e809ae6b244d85e3 100644 (file)
@@ -456,7 +456,6 @@ use_default_name:
        INIT_LIST_HEAD(&rdev->bss_list);
        INIT_LIST_HEAD(&rdev->sched_scan_req_list);
        INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done);
-       INIT_WORK(&rdev->sched_scan_results_wk, __cfg80211_sched_scan_results);
        INIT_LIST_HEAD(&rdev->mlme_unreg);
        spin_lock_init(&rdev->mlme_unreg_lock);
        INIT_WORK(&rdev->mlme_unreg_wk, cfg80211_mlme_unreg_wk);
@@ -473,6 +472,7 @@ use_default_name:
 
        INIT_WORK(&rdev->destroy_work, cfg80211_destroy_iface_wk);
        INIT_WORK(&rdev->sched_scan_stop_wk, cfg80211_sched_scan_stop_wk);
+       INIT_WORK(&rdev->sched_scan_res_wk, cfg80211_sched_scan_results_wk);
        INIT_WORK(&rdev->propagate_radar_detect_wk,
                  cfg80211_propagate_radar_detect_wk);
        INIT_WORK(&rdev->propagate_cac_done_wk, cfg80211_propagate_cac_done_wk);
index 96baffab5e5b14f71277a18e7a2af628c3910dca..6e809325af3bf090f09fb8fef4356bada3a1beed 100644 (file)
@@ -77,7 +77,6 @@ struct cfg80211_registered_device {
        struct list_head sched_scan_req_list;
        unsigned long suspend_at;
        struct work_struct scan_done_wk;
-       struct work_struct sched_scan_results_wk;
 
        struct genl_info *cur_cmd_info;
 
@@ -93,6 +92,7 @@ struct cfg80211_registered_device {
 
        struct work_struct destroy_work;
        struct work_struct sched_scan_stop_wk;
+       struct work_struct sched_scan_res_wk;
 
        struct cfg80211_chan_def radar_chandef;
        struct work_struct propagate_radar_detect_wk;
@@ -412,7 +412,7 @@ void cfg80211_add_sched_scan_req(struct cfg80211_registered_device *rdev,
                                 struct cfg80211_sched_scan_request *req);
 int cfg80211_sched_scan_req_possible(struct cfg80211_registered_device *rdev,
                                     bool want_multi);
-void __cfg80211_sched_scan_results(struct work_struct *wk);
+void cfg80211_sched_scan_results_wk(struct work_struct *work);
 int cfg80211_stop_sched_scan_req(struct cfg80211_registered_device *rdev,
                                 struct cfg80211_sched_scan_request *req,
                                 bool driver_initiated);
index 8d86f704bcf3db68b37cb4fac47423650a9c8514..14d5f0c8c45ff07224f2dc8e6310c2edc440874e 100644 (file)
@@ -328,7 +328,7 @@ cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid)
                if (pos->reqid == reqid)
                        return pos;
        }
-       return ERR_PTR(-ENOENT);
+       return NULL;
 }
 
 /*
@@ -364,67 +364,66 @@ int cfg80211_sched_scan_req_possible(struct cfg80211_registered_device *rdev,
        return 0;
 }
 
-void __cfg80211_sched_scan_results(struct work_struct *wk)
+void cfg80211_sched_scan_results_wk(struct work_struct *work)
 {
        struct cfg80211_registered_device *rdev;
-       struct cfg80211_sched_scan_request *request;
+       struct cfg80211_sched_scan_request *req, *tmp;
 
-       rdev = container_of(wk, struct cfg80211_registered_device,
-                           sched_scan_results_wk);
+       rdev = container_of(work, struct cfg80211_registered_device,
+                          sched_scan_res_wk);
 
        rtnl_lock();
-
-       request = cfg80211_find_sched_scan_req(rdev, 0);
-
-       /* we don't have sched_scan_req anymore if the scan is stopping */
-       if (!IS_ERR(request)) {
-               if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
-                       /* flush entries from previous scans */
-                       spin_lock_bh(&rdev->bss_lock);
-                       __cfg80211_bss_expire(rdev, request->scan_start);
-                       spin_unlock_bh(&rdev->bss_lock);
-                       request->scan_start = jiffies;
+       list_for_each_entry_safe(req, tmp, &rdev->sched_scan_req_list, list) {
+               if (req->report_results) {
+                       req->report_results = false;
+                       if (req->flags & NL80211_SCAN_FLAG_FLUSH) {
+                               /* flush entries from previous scans */
+                               spin_lock_bh(&rdev->bss_lock);
+                               __cfg80211_bss_expire(rdev, req->scan_start);
+                               spin_unlock_bh(&rdev->bss_lock);
+                               req->scan_start = jiffies;
+                       }
+                       nl80211_send_sched_scan(req,
+                                               NL80211_CMD_SCHED_SCAN_RESULTS);
                }
-               nl80211_send_sched_scan(request, NL80211_CMD_SCHED_SCAN_RESULTS);
        }
-
        rtnl_unlock();
 }
 
-void cfg80211_sched_scan_results(struct wiphy *wiphy)
+void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid)
 {
        struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
        struct cfg80211_sched_scan_request *request;
 
-       trace_cfg80211_sched_scan_results(wiphy);
+       trace_cfg80211_sched_scan_results(wiphy, reqid);
        /* ignore if we're not scanning */
 
        rtnl_lock();
-       request = cfg80211_find_sched_scan_req(rdev, 0);
+       request = cfg80211_find_sched_scan_req(rdev, reqid);
+       if (request) {
+               request->report_results = true;
+               queue_work(cfg80211_wq, &rdev->sched_scan_res_wk);
+       }
        rtnl_unlock();
-
-       if (!IS_ERR(request))
-               queue_work(cfg80211_wq,
-                          &wiphy_to_rdev(wiphy)->sched_scan_results_wk);
 }
 EXPORT_SYMBOL(cfg80211_sched_scan_results);
 
-void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy)
+void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy, u64 reqid)
 {
        struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
 
        ASSERT_RTNL();
 
-       trace_cfg80211_sched_scan_stopped(wiphy);
+       trace_cfg80211_sched_scan_stopped(wiphy, reqid);
 
-       __cfg80211_stop_sched_scan(rdev, 0, true);
+       __cfg80211_stop_sched_scan(rdev, reqid, true);
 }
 EXPORT_SYMBOL(cfg80211_sched_scan_stopped_rtnl);
 
-void cfg80211_sched_scan_stopped(struct wiphy *wiphy)
+void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid)
 {
        rtnl_lock();
-       cfg80211_sched_scan_stopped_rtnl(wiphy);
+       cfg80211_sched_scan_stopped_rtnl(wiphy, reqid);
        rtnl_unlock();
 }
 EXPORT_SYMBOL(cfg80211_sched_scan_stopped);
@@ -456,8 +455,8 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
        ASSERT_RTNL();
 
        sched_scan_req = cfg80211_find_sched_scan_req(rdev, reqid);
-       if (IS_ERR(sched_scan_req))
-               return PTR_ERR(sched_scan_req);
+       if (!sched_scan_req)
+               return -ENOENT;
 
        return cfg80211_stop_sched_scan_req(rdev, sched_scan_req,
                                            driver_initiated);
index 8d8f6b462b1807df9847ded59029f5eef1500662..ca8b2059f92c43c5d4d3bac24f39fd141cd31141 100644 (file)
@@ -2820,14 +2820,28 @@ TRACE_EVENT(cfg80211_scan_done,
                  MAC_PR_ARG(tsf_bssid))
 );
 
-DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_results,
-       TP_PROTO(struct wiphy *wiphy),
-       TP_ARGS(wiphy)
+DECLARE_EVENT_CLASS(wiphy_id_evt,
+       TP_PROTO(struct wiphy *wiphy, u64 id),
+       TP_ARGS(wiphy, id),
+       TP_STRUCT__entry(
+               WIPHY_ENTRY
+               __field(u64, id)
+       ),
+       TP_fast_assign(
+               WIPHY_ASSIGN;
+               __entry->id = id;
+       ),
+       TP_printk(WIPHY_PR_FMT ", id: %llu", WIPHY_PR_ARG, __entry->id)
 );
 
-DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_stopped,
-       TP_PROTO(struct wiphy *wiphy),
-       TP_ARGS(wiphy)
+DEFINE_EVENT(wiphy_id_evt, cfg80211_sched_scan_stopped,
+       TP_PROTO(struct wiphy *wiphy, u64 id),
+       TP_ARGS(wiphy, id)
+);
+
+DEFINE_EVENT(wiphy_id_evt, cfg80211_sched_scan_results,
+       TP_PROTO(struct wiphy *wiphy, u64 id),
+       TP_ARGS(wiphy, id)
 );
 
 TRACE_EVENT(cfg80211_get_bss,