brcmfmac: move scheduled scan activation to pno source file
authorArend Van Spriel <arend.vanspriel@broadcom.com>
Wed, 23 Nov 2016 10:25:27 +0000 (10:25 +0000)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 29 Nov 2016 15:29:29 +0000 (17:29 +0200)
Rework .sched_scan_start() callback moving actual configuration of
the device in pno source file.

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: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.h

index e77f904d1d37d85058241c13f81233237948737f..4fbc473bbc9a503558d38a35c2aad91cfdd2b813 100644 (file)
@@ -42,7 +42,6 @@
 #include "common.h"
 
 #define BRCMF_SCAN_IE_LEN_MAX          2048
-#define BRCMF_SCHED_SCAN_PERIOD                30
 
 #define WPA_OUI                                "\x00\x50\xF2"  /* WPA OUI */
 #define WPA_OUI_TYPE                   1
@@ -3342,24 +3341,6 @@ free_req:
        return err;
 }
 
-static bool brcmf_is_ssid_active(struct cfg80211_ssid *ssid,
-                                struct cfg80211_sched_scan_request *req)
-{
-       int i;
-
-       if (!ssid || !req->ssids || !req->n_ssids)
-               return false;
-
-       for (i = 0; i < req->n_ssids; i++) {
-               if (ssid->ssid_len == req->ssids[i].ssid_len) {
-                       if (!strncmp(ssid->ssid, req->ssids[i].ssid,
-                                    ssid->ssid_len))
-                               return true;
-               }
-       }
-       return false;
-}
-
 static int
 brcmf_cfg80211_sched_scan_start(struct wiphy *wiphy,
                                struct net_device *ndev,
@@ -3367,9 +3348,6 @@ brcmf_cfg80211_sched_scan_start(struct wiphy *wiphy,
 {
        struct brcmf_if *ifp = netdev_priv(ndev);
        struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
-       struct cfg80211_ssid *ssid;
-       int i;
-       int ret = 0;
 
        brcmf_dbg(SCAN, "Enter n_match_sets:%d n_ssids:%d\n",
                  req->n_match_sets, req->n_ssids);
@@ -3389,48 +3367,7 @@ brcmf_cfg80211_sched_scan_start(struct wiphy *wiphy,
                return -EINVAL;
        }
 
-       /* clean up everything */
-       ret = brcmf_pno_clean(ifp);
-       if  (ret < 0) {
-               brcmf_err("failed error=%d\n", ret);
-               return ret;
-       }
-
-       /* configure pno */
-       ret = brcmf_pno_config(ifp, BRCMF_SCHED_SCAN_PERIOD, 0, 0);
-       if (ret < 0)
-               return ret;
-
-       /* configure random mac */
-       if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
-               ret = brcmf_pno_set_random(ifp, req->mac_addr,
-                                          req->mac_addr_mask);
-               if (ret < 0)
-                       return ret;
-       }
-
-       /* configure each match set */
-       for (i = 0; i < req->n_match_sets; i++) {
-
-               ssid = &req->match_sets[i].ssid;
-
-               if (!ssid->ssid_len) {
-                       brcmf_err("skip broadcast ssid\n");
-                       continue;
-               }
-
-               ret = brcmf_pno_add_ssid(ifp, ssid,
-                                        brcmf_is_ssid_active(ssid, req));
-               if (ret < 0)
-                       brcmf_dbg(SCAN, ">>> PNO filter %s for ssid (%s)\n",
-                                 ret == 0 ? "set" : "failed", ssid->ssid);
-       }
-       /* Enable the PNO */
-       ret = brcmf_fil_iovar_int_set(ifp, "pfn", 1);
-       if (ret < 0)
-               brcmf_err("PNO enable failed!! ret=%d\n", ret);
-
-       return ret;
+       return brcmf_pno_start_sched_scan(ifp, req);
 }
 
 static int brcmf_cfg80211_sched_scan_stop(struct wiphy *wiphy,
index 72d9eef17e2235665f351a174430a507700fb0b3..d16e89e8f522cef9b9ad7db6af22e8bf8475280b 100644 (file)
 #define BRCMF_PNO_SCAN_INCOMPLETE      0
 #define BRCMF_PNO_WPA_AUTH_ANY         0xFFFFFFFF
 #define BRCMF_PNO_HIDDEN_BIT           2
+#define BRCMF_PNO_SCHED_SCAN_PERIOD    30
 
-int brcmf_pno_clean(struct brcmf_if *ifp)
-{
-       int ret;
-
-       /* Disable pfn */
-       ret = brcmf_fil_iovar_int_set(ifp, "pfn", 0);
-       if (ret == 0) {
-               /* clear pfn */
-               ret = brcmf_fil_iovar_data_set(ifp, "pfnclear", NULL, 0);
-       }
-       if (ret < 0)
-               brcmf_err("failed code %d\n", ret);
-
-       return ret;
-}
-
-int brcmf_pno_config(struct brcmf_if *ifp, u32 scan_freq,
-                    u32 mscan, u32 bestn)
+static int brcmf_pno_config(struct brcmf_if *ifp, u32 scan_freq,
+                           u32 mscan, u32 bestn)
 {
        struct brcmf_pno_param_le pfn_param;
        u16 flags;
@@ -102,7 +87,8 @@ exit:
        return err;
 }
 
-int brcmf_pno_set_random(struct brcmf_if *ifp, u8 *mac_addr, u8 *mac_mask)
+static int brcmf_pno_set_random(struct brcmf_if *ifp, u8 *mac_addr,
+                               u8 *mac_mask)
 {
        struct brcmf_pno_macaddr_le pfn_mac;
        int err, i;
@@ -128,8 +114,8 @@ int brcmf_pno_set_random(struct brcmf_if *ifp, u8 *mac_addr, u8 *mac_mask)
        return err;
 }
 
-int brcmf_pno_add_ssid(struct brcmf_if *ifp, struct cfg80211_ssid *ssid,
-                      bool active)
+static int brcmf_pno_add_ssid(struct brcmf_if *ifp, struct cfg80211_ssid *ssid,
+                             bool active)
 {
        struct brcmf_pno_net_param_le pfn;
 
@@ -144,3 +130,85 @@ int brcmf_pno_add_ssid(struct brcmf_if *ifp, struct cfg80211_ssid *ssid,
        return brcmf_fil_iovar_data_set(ifp, "pfn_add", &pfn, sizeof(pfn));
 }
 
+static bool brcmf_is_ssid_active(struct cfg80211_ssid *ssid,
+                                struct cfg80211_sched_scan_request *req)
+{
+       int i;
+
+       if (!ssid || !req->ssids || !req->n_ssids)
+               return false;
+
+       for (i = 0; i < req->n_ssids; i++) {
+               if (ssid->ssid_len == req->ssids[i].ssid_len) {
+                       if (!strncmp(ssid->ssid, req->ssids[i].ssid,
+                                    ssid->ssid_len))
+                               return true;
+               }
+       }
+       return false;
+}
+
+int brcmf_pno_clean(struct brcmf_if *ifp)
+{
+       int ret;
+
+       /* Disable pfn */
+       ret = brcmf_fil_iovar_int_set(ifp, "pfn", 0);
+       if (ret == 0) {
+               /* clear pfn */
+               ret = brcmf_fil_iovar_data_set(ifp, "pfnclear", NULL, 0);
+       }
+       if (ret < 0)
+               brcmf_err("failed code %d\n", ret);
+
+       return ret;
+}
+
+int brcmf_pno_start_sched_scan(struct brcmf_if *ifp,
+                              struct cfg80211_sched_scan_request *req)
+{
+       struct cfg80211_ssid *ssid;
+       int i, ret;
+
+       /* clean up everything */
+       ret = brcmf_pno_clean(ifp);
+       if  (ret < 0) {
+               brcmf_err("failed error=%d\n", ret);
+               return ret;
+       }
+
+       /* configure pno */
+       ret = brcmf_pno_config(ifp, BRCMF_PNO_SCHED_SCAN_PERIOD, 0, 0);
+       if (ret < 0)
+               return ret;
+
+       /* configure random mac */
+       if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
+               ret = brcmf_pno_set_random(ifp, req->mac_addr,
+                                          req->mac_addr_mask);
+               if (ret < 0)
+                       return ret;
+       }
+
+       /* configure each match set */
+       for (i = 0; i < req->n_match_sets; i++) {
+               ssid = &req->match_sets[i].ssid;
+               if (!ssid->ssid_len) {
+                       brcmf_err("skip broadcast ssid\n");
+                       continue;
+               }
+
+               ret = brcmf_pno_add_ssid(ifp, ssid,
+                                        brcmf_is_ssid_active(ssid, req));
+               if (ret < 0)
+                       brcmf_dbg(SCAN, ">>> PNO filter %s for ssid (%s)\n",
+                                 ret == 0 ? "set" : "failed", ssid->ssid);
+       }
+       /* Enable the PNO */
+       ret = brcmf_fil_iovar_int_set(ifp, "pfn", 1);
+       if (ret < 0)
+               brcmf_err("PNO enable failed!! ret=%d\n", ret);
+
+       return ret;
+}
+
index f2c5a53d7b1ceb8469517977fd1887f537bc14f5..5803a4ca8cc4decb85fc7565c77d91a70da8122e 100644 (file)
 int brcmf_pno_clean(struct brcmf_if *ifp);
 
 /**
- * brcmf_pno_config - configure pno parameters.
+ * brcmf_pno_start_sched_scan - initiate scheduled scan on device.
  *
  * @ifp: interface object used.
- * @scan_freq: scan frequency period in seconds.
- * @mscan: maximum number of scans stored in firmware.
- * @bestn: maximum number of APs per scan stored in firmware.
+ * @req: configuration parameters for scheduled scan.
  */
-int brcmf_pno_config(struct brcmf_if *ifp, u32 scan_freq,
-                    u32 mscan, u32 bestn);
-
-/**
- * brcmf_pno_set_random - setup randomisation mac address for pno.
- *
- * @ifp: interface object used.
- * @mac_addr: MAC address used with randomisation.
- * @mac_mask: MAC address mask used for randomisation.
- */
-int brcmf_pno_set_random(struct brcmf_if *ifp, u8 *mac_addr, u8 *mac_mask);
-
-/**
- * brcmf_pno_add_ssid - add ssid for pno in firmware.
- *
- * @ifp: interface object used.
- * @ssid: ssid information.
- * @active: indicate this ssid needs to be actively probed.
- */
-int brcmf_pno_add_ssid(struct brcmf_if *ifp, struct cfg80211_ssid *ssid,
-                      bool active);
+int brcmf_pno_start_sched_scan(struct brcmf_if *ifp,
+                              struct cfg80211_sched_scan_request *req);
 
 #endif /* _BRCMF_PNO_H */