diff mbox

[10/10] brcmfmac: add scheduled scan support for specified BSSIDs

Message ID 1491556990-25143-11-git-send-email-arend.vanspriel@broadcom.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show

Commit Message

Arend van Spriel April 7, 2017, 9:23 a.m. UTC
Add support to handle scheduled scan request containing BSSID in
the matchsets. The firmware can send event upon finding BSSIDs and
SSIDs. To get these in one event the bit REPORT_SEPERATELY needed
to be removed from the flags in brcmf_pno_config().

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>
---
 .../broadcom/brcm80211/brcmfmac/fwil_types.h       | 11 +++++
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.c | 56 ++++++++++++++++------
 2 files changed, 52 insertions(+), 15 deletions(-)

Comments

kernel test robot April 8, 2017, 11:41 a.m. UTC | #1
Hi Arend,

[auto build test WARNING on mac80211-next/master]
[cannot apply to v4.11-rc5 next-20170407]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Arend-van-Spriel/cfg80211-support-multiple-scheduled-scans/20170408-175235
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: i386-randconfig-x008-201714 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c: In function 'brcmf_pno_config_sched_scans':
>> drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:384:7: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
       if (!err && is_valid_ether_addr(ms->bssid))
          ^
   drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:372:12: note: 'err' was declared here
     int i, j, err;
               ^~~
   drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:166:6: warning: 'mac_mask' may be used uninitialized in this function [-Wmaybe-uninitialized]
     u8 *mac_mask;
         ^~~~~~~~
   In file included from arch/x86/include/asm/string.h:2:0,
                    from include/linux/string.h:18,
                    from arch/x86/include/asm/page_32.h:34,
                    from arch/x86/include/asm/page.h:13,
                    from arch/x86/include/asm/thread_info.h:11,
                    from include/linux/thread_info.h:25,
                    from arch/x86/include/asm/preempt.h:6,
                    from include/linux/preempt.h:80,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from include/linux/ktime.h:24,
                    from include/linux/timer.h:5,
                    from include/linux/netdevice.h:28,
                    from drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:16:
   arch/x86/include/asm/string_32.h:182:25: warning: 'mac_addr' may be used uninitialized in this function [-Wmaybe-uninitialized]
    #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
                            ^~~~~~~~~~~~~~~~
   drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:165:6: note: 'mac_addr' was declared here
     u8 *mac_addr;
         ^~~~~~~~
   drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:128:22: warning: 'scan_freq' may be used uninitialized in this function [-Wmaybe-uninitialized]
     pfn_param.scan_freq = cpu_to_le32(scan_freq);
                          
   drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:401:6: note: 'scan_freq' was declared here
     u32 scan_freq;
         ^~~~~~~~~
   drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c:465:2: warning: 'buckets' may be used uninitialized in this function [-Wmaybe-uninitialized]
     kfree(buckets);
     ^~~~~~~~~~~~~~

vim +/err +384 drivers/net/wireless//broadcom/brcm80211/brcmfmac/pno.c

   368	{
   369		struct cfg80211_sched_scan_request *r;
   370		struct cfg80211_match_set *ms;
   371		bool active;
   372		int i, j, err;
   373	
   374		for (i = 0; i < pi->n_reqs; i++) {
   375			r = pi->reqs[i];
   376	
   377			for (j = 0; j < r->n_match_sets; j++) {
   378				ms = &r->match_sets[j];
   379				if (ms->ssid.ssid_len) {
   380					active = brcmf_is_ssid_active(&ms->ssid, r);
   381					err = brcmf_pno_add_ssid(ifp, &ms->ssid,
   382								 active);
   383				}
 > 384				if (!err && is_valid_ether_addr(ms->bssid))
   385					err = brcmf_pno_add_bssid(ifp, ms->bssid);
   386	
   387				if (err < 0)
   388					return err;
   389			}
   390		}
   391		return 0;
   392	}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
index cc832ab..51d89c6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h
@@ -806,6 +806,17 @@  struct brcmf_pno_macaddr_le {
 };
 
 /**
+ * struct brcmf_pno_bssid_le - bssid configuration for PNO scan.
+ *
+ * @bssid: BSS network identifier.
+ * @flags: flags for this BSSID.
+ */
+struct brcmf_pno_bssid_le {
+	u8 bssid[ETH_ALEN];
+	__le16 flags;
+};
+
+/**
  * struct brcmf_pktcnt_le - packet counters.
  *
  * @rx_good_pkt: packets (MSDUs & MMPDUs) received from this station
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
index 4c17a1c..f178af0 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
@@ -120,7 +120,6 @@  static int brcmf_pno_config(struct brcmf_if *ifp, u32 scan_freq,
 
 	/* set extra pno params */
 	flags = BIT(BRCMF_PNO_IMMEDIATE_SCAN_BIT) |
-		BIT(BRCMF_PNO_REPORT_SEPARATELY_BIT) |
 		BIT(BRCMF_PNO_ENABLE_ADAPTSCAN_BIT);
 	pfn_param.repeat = BRCMF_PNO_REPEAT;
 	pfn_param.exp = BRCMF_PNO_FREQ_EXPO_MAX;
@@ -205,6 +204,7 @@  static int brcmf_pno_add_ssid(struct brcmf_if *ifp, struct cfg80211_ssid *ssid,
 			      bool active)
 {
 	struct brcmf_pno_net_param_le pfn;
+	int err;
 
 	pfn.auth = cpu_to_le32(WLAN_AUTH_OPEN);
 	pfn.wpa_auth = cpu_to_le32(BRCMF_PNO_WPA_AUTH_ANY);
@@ -215,7 +215,28 @@  static int brcmf_pno_add_ssid(struct brcmf_if *ifp, struct cfg80211_ssid *ssid,
 		pfn.flags = cpu_to_le32(1 << BRCMF_PNO_HIDDEN_BIT);
 	pfn.ssid.SSID_len = cpu_to_le32(ssid->ssid_len);
 	memcpy(pfn.ssid.SSID, ssid->ssid, ssid->ssid_len);
-	return brcmf_fil_iovar_data_set(ifp, "pfn_add", &pfn, sizeof(pfn));
+
+	brcmf_dbg(SCAN, "adding ssid=%.32s (active=%d)\n", ssid->ssid, active);
+	err = brcmf_fil_iovar_data_set(ifp, "pfn_add", &pfn, sizeof(pfn));
+	if (err < 0)
+		brcmf_err("adding failed: err=%d\n", err);
+	return err;
+}
+
+static int brcmf_pno_add_bssid(struct brcmf_if *ifp, const u8 *bssid)
+{
+	struct brcmf_pno_bssid_le bssid_cfg;
+	int err;
+
+	memcpy(bssid_cfg.bssid, bssid, ETH_ALEN);
+	bssid_cfg.flags = 0;
+
+	brcmf_dbg(SCAN, "adding bssid=%pM\n", bssid);
+	err = brcmf_fil_iovar_data_set(ifp, "pfn_add_bssid", &bssid_cfg,
+				       sizeof(bssid_cfg));
+	if (err < 0)
+		brcmf_err("adding failed: err=%d\n", err);
+	return err;
 }
 
 static bool brcmf_is_ssid_active(struct cfg80211_ssid *ssid,
@@ -342,8 +363,8 @@  static int brcmf_pno_prep_fwconfig(struct brcmf_pno_info *pi,
 	return err;
 }
 
-static int brcmf_pno_config_ssids(struct brcmf_if *ifp,
-				  struct brcmf_pno_info *pi)
+static int brcmf_pno_config_networks(struct brcmf_if *ifp,
+				     struct brcmf_pno_info *pi)
 {
 	struct cfg80211_sched_scan_request *r;
 	struct cfg80211_match_set *ms;
@@ -355,16 +376,16 @@  static int brcmf_pno_config_ssids(struct brcmf_if *ifp,
 
 		for (j = 0; j < r->n_match_sets; j++) {
 			ms = &r->match_sets[j];
-			if (!ms->ssid.ssid_len)
-				continue;
-			active = brcmf_is_ssid_active(&ms->ssid, r);
-			brcmf_dbg(SCAN, "adding %.32s (active=%d)\n",
-				  ms->ssid.ssid, active);
-			err = brcmf_pno_add_ssid(ifp, &ms->ssid, active);
-			if (err < 0) {
-				brcmf_err("adding failed: err=%d\n", err);
-				return err;
+			if (ms->ssid.ssid_len) {
+				active = brcmf_is_ssid_active(&ms->ssid, r);
+				err = brcmf_pno_add_ssid(ifp, &ms->ssid,
+							 active);
 			}
+			if (!err && is_valid_ether_addr(ms->bssid))
+				err = brcmf_pno_add_bssid(ifp, ms->bssid);
+
+			if (err < 0)
+				return err;
 		}
 	}
 	return 0;
@@ -428,7 +449,7 @@  static int brcmf_pno_config_sched_scans(struct brcmf_if *ifp)
 	if (err < 0)
 		goto clean;
 
-	err = brcmf_pno_config_ssids(ifp, pi);
+	err = brcmf_pno_config_networks(ifp, pi);
 	if (err < 0)
 		goto clean;
 
@@ -560,7 +581,12 @@  u32 brcmf_pno_get_bucket_map(struct brcmf_pno_info *pi,
 		for (j = 0; j < req->n_match_sets; j++) {
 			ms = &req->match_sets[j];
 			if (ms->ssid.ssid_len == ni->SSID_len &&
-			    !strncmp(ms->ssid.ssid, ni->SSID, ni->SSID_len)) {
+			    !memcmp(ms->ssid.ssid, ni->SSID, ni->SSID_len)) {
+				bucket_map |= BIT(i);
+				break;
+			}
+			if (is_valid_ether_addr(ms->bssid) &&
+			    !memcmp(ms->bssid, ni->bssid, ETH_ALEN)) {
 				bucket_map |= BIT(i);
 				break;
 			}