Skip to contentSkip to conversation

cfg80211: support multiple scheduled scans

PATCH In review Arend van Spriel 3 participants 25 messages Apr 21, 2017 – May 19, 2017

Subsystems (7)
lore
Share & tools
lore

Arend van Spriel

author maintainer
#0 lore raw

v3 cover cfg80211: support multiple scheduled scans

After the RFC rounds here is multi-scheduled scan submission. What has been added since the RFC is support for user-space to specify a BSSID in the matchset (PATCH 3/10). As example this could be used for roaming algorithm done in user-space. The patches for scheduled scan notification api have been collapsed into a single patch and rtnl locking was needed for the cfg80211_sched_scan_results() function.

This series also adds a driver implementation for the new features. Not surprisingly being brcmfmac.

This series applies to master branch of the mac80211-next repository. In this version some rework was needed to stop scheduled scans owned by a specific netlink socket which is released.
---
changes:
V2:
- patch 5/10 changed to resolve kerneldoc issue.
- patch 8/10 and 10/10 resolving uninitialized warnings.
V3:
- patch 1/9 changed getting rid of rdev->sched_scan_req.
---
Arend van Spriel (9):
nl80211: allow multiple active scheduled scan requests
nl80211: add support for BSSIDs in scheduled scan matchsets
cfg80211: add request id parameter to .sched_scan_stop() signature
cfg80211: add request id to cfg80211_sched_scan_*() api
brcmfmac: add firmware feature detection for gscan feature
brcmfmac: move scheduled scan wiphy param setting to pno module
brcmfmac: add support multi-scheduled scan
brcmfmac: add mutex to protect pno requests
brcmfmac: add scheduled scan support for specified BSSIDs

 drivers/net/wireless/ath/ath6kl/cfg80211.c         |   6 +-
 drivers/net/wireless/ath/ath6kl/wmi.c              |   2 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c         |  93 +++--
 .../broadcom/brcm80211/brcmfmac/cfg80211.h         |   8 +-
 .../wireless/broadcom/brcm80211/brcmfmac/core.c    |   1 +
 .../wireless/broadcom/brcm80211/brcmfmac/debug.h   |   2 +
 .../wireless/broadcom/brcm80211/brcmfmac/feature.c |  22 +-
 .../wireless/broadcom/brcm80211/brcmfmac/feature.h |   4 +-
 .../broadcom/brcm80211/brcmfmac/fwil_types.h       |  76 ++++
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.c | 453 ++++++++++++++++++---
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.h |  55 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  |   2 +-
 drivers/net/wireless/marvell/mwifiex/cfg80211.c    |  10 +-
 drivers/net/wireless/marvell/mwifiex/main.c        |   2 +-
 drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c |   2 +-
 drivers/net/wireless/marvell/mwifiex/sta_event.c   |   2 +-
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c   |   2 +-
 drivers/net/wireless/ti/wlcore/main.c              |   2 +-
 include/net/cfg80211.h                             |  39 +-
 include/uapi/linux/nl80211.h                       |  14 +-
 net/mac80211/cfg.c                                 |   3 +-
 net/mac80211/pm.c                                  |   2 +-
 net/mac80211/scan.c                                |   4 +-
 net/mac80211/util.c                                |   2 +-
 net/wireless/core.c                                |  49 ++-
 net/wireless/core.h                                |  16 +-
 net/wireless/nl80211.c                             | 120 ++++--
 net/wireless/rdev-ops.h                            |   8 +-
 net/wireless/scan.c                                | 133 ++++--
 net/wireless/trace.h                               |  54 ++-
 30 files changed, 963 insertions(+), 225 deletions(-)
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH v3 1/9 nl80211: allow multiple active scheduled scan requests

This patch implements the idea to have multiple scheduled scan requests running concurrently. It mainly illustrates how to deal with the incoming request from user-space in terms of backward compatibility. In order to use multiple scheduled scans user-space needs to provide a flag attribute NL80211_ATTR_SCHED_SCAN_MULTI to indicate support. If not the request is treated as a legacy scan.

Drivers currently supporting scheduled scan are now indicating they support a single scheduled scan request. This obsoletes WIPHY_FLAG_SUPPORTS_SCHED_SCAN.

---
 drivers/net/wireless/ath/ath6kl/cfg80211.c         |   2 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c         |   2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  |   2 +-
 drivers/net/wireless/marvell/mwifiex/cfg80211.c    |   2 +-
 drivers/net/wireless/ti/wlcore/main.c              |   2 +-
 include/net/cfg80211.h                             |   7 +-
 include/uapi/linux/nl80211.h                       |  12 ++-
 net/wireless/core.c                                |  48 ++++++---
 net/wireless/core.h                                |  15 ++-
 net/wireless/nl80211.c                             |  77 ++++++++++----
 net/wireless/rdev-ops.h                            |   2 +-
 net/wireless/scan.c                                | 115 +++++++++++++++++----
 net/wireless/trace.h                               |  18 ++--
 13 files changed, 237 insertions(+), 67 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +1 -1
index 0c118b7c..1906412 100644
@@ -3973,7 +3973,7 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
 			    WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
 
 	if (test_bit(ATH6KL_FW_CAPABILITY_SCHED_SCAN_V2, ar->fw_capabilities))
-		ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
+		ar->wiphy->max_sched_scan_reqs = 1;
 
 	if (test_bit(ATH6KL_FW_CAPABILITY_INACTIVITY_TIMEOUT,
 		     ar->fw_capabilities))
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +1 -1
index 7efdcd6..b23c37c 100644
@@ -6359,11 +6359,11 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
 static void brcmf_wiphy_pno_params(struct wiphy *wiphy)
 {
 	/* scheduled scan settings */
+	wiphy->max_sched_scan_reqs = 1;
 	wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT;
 	wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT;
 	wiphy->max_sched_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX;
 	wiphy->max_sched_scan_plan_interval = BRCMF_PNO_SCHED_SCAN_MAX_PERIOD;
-	wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
 }
 
 #ifdef CONFIG_PM
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +1 -1
index 841bfdff..b589c66 100644
@@ -619,7 +619,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 	else
 		hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
 
-	hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
+	hw->wiphy->max_sched_scan_reqs = 1;
 	hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX;
 	hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES;
 	/* we create the 802.11 header and zero length SSID IE. */
drivers/net/wireless/marvell/mwifiex/cfg80211.c +1 -1
index 3a8a08d..ffb78f6 100644
@@ -4295,7 +4295,6 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
 	wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
 			WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
 			WIPHY_FLAG_AP_UAPSD |
-			WIPHY_FLAG_SUPPORTS_SCHED_SCAN |
 			WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
 			WIPHY_FLAG_HAS_CHANNEL_SWITCH |
 			WIPHY_FLAG_PS_ON_BY_DEFAULT;
@@ -4314,6 +4313,7 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
 				    NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
 				    NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
 
+	wiphy->max_sched_scan_reqs = 1;
 	wiphy->max_sched_scan_ssids = MWIFIEX_MAX_SSID_LIST_LENGTH;
 	wiphy->max_sched_scan_ie_len = MWIFIEX_MAX_VSIE_LEN;
 	wiphy->max_match_sets = MWIFIEX_MAX_SSID_LIST_LENGTH;
drivers/net/wireless/ti/wlcore/main.c +1 -1
index a21fda9..382ec15 100644
@@ -6128,6 +6128,7 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
 	wl->hw->wiphy->max_scan_ie_len = WL1271_CMD_TEMPL_MAX_SIZE -
 			sizeof(struct ieee80211_header);
 
+	wl->hw->wiphy->max_sched_scan_reqs = 1;
 	wl->hw->wiphy->max_sched_scan_ie_len = WL1271_CMD_TEMPL_MAX_SIZE -
 		sizeof(struct ieee80211_header);
 
@@ -6135,7 +6136,6 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
 
 	wl->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD |
 				WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
-				WIPHY_FLAG_SUPPORTS_SCHED_SCAN |
 				WIPHY_FLAG_HAS_CHANNEL_SWITCH;
 
 	wl->hw->wiphy->features |= NL80211_FEATURE_AP_SCAN;
include/net/cfg80211.h +6 -1
index 2a200b9..7721a9b 100644
@@ -1678,6 +1678,7 @@ struct cfg80211_bss_select_adjust {
  * @rcu_head: RCU callback used to free the struct
  * @owner_nlportid: netlink portid of owner (if this should is a request
  *	owned by a particular socket)
+ * @list: for keeping list of requests.
  * @delay: delay in seconds to use before starting the first scan
  *	cycle.  The driver may ignore this parameter and start
  *	immediately (or at any other time), if this feature is not
@@ -1722,6 +1723,7 @@ struct cfg80211_sched_scan_request {
 	unsigned long scan_start;
 	struct rcu_head rcu_head;
 	u32 owner_nlportid;
+	struct list_head list;
 
 	/* keep last */
 	struct ieee80211_channel *channels[0];
@@ -3213,7 +3215,7 @@ enum wiphy_flags {
 	WIPHY_FLAG_CONTROL_PORT_PROTOCOL	= BIT(7),
 	WIPHY_FLAG_IBSS_RSN			= BIT(8),
 	WIPHY_FLAG_MESH_AUTH			= BIT(10),
-	WIPHY_FLAG_SUPPORTS_SCHED_SCAN		= BIT(11),
+	/* use hole at 11 */
 	/* use hole at 12 */
 	WIPHY_FLAG_SUPPORTS_FW_ROAM		= BIT(13),
 	WIPHY_FLAG_AP_UAPSD			= BIT(14),
@@ -3551,6 +3553,8 @@ struct wiphy_iftype_ext_capab {
  *	this variable determines its size
  * @max_scan_ssids: maximum number of SSIDs the device can scan for in
  *	any given scan
+ * @max_sched_scan_reqs: maximum number of scheduled scan requests that
+ *	the device can run concurrently.
  * @max_sched_scan_ssids: maximum number of SSIDs the device can scan
  *	for in any given scheduled scan
  * @max_match_sets: maximum number of match sets the device can handle
@@ -3687,6 +3691,7 @@ struct wiphy {
 
 	int bss_priv_size;
 	u8 max_scan_ssids;
+	u8 max_sched_scan_reqs;
 	u8 max_sched_scan_ssids;
 	u8 max_match_sets;
 	u16 max_scan_ie_len;
include/uapi/linux/nl80211.h +11 -1
index 6095a6c..f34127d 100644
@@ -387,7 +387,9 @@
  *	are used.  Extra IEs can also be passed from the userspace by
  *	using the %NL80211_ATTR_IE attribute.  The first cycle of the
  *	scheduled scan can be delayed by %NL80211_ATTR_SCHED_SCAN_DELAY
- *	is supplied.
+ *	is supplied. If the device supports multiple concurrent scheduled
+ *	scans, it will allow such when the caller provides the flag attribute
+ *	%NL80211_ATTR_SCHED_SCAN_MULTI to indicate user-space support for it.
  * @NL80211_CMD_STOP_SCHED_SCAN: stop a scheduled scan. Returns -ENOENT if
  *	scheduled scan is not running. The caller may assume that as soon
  *	as the call returns, it is safe to start a new scheduled scan again.
@@ -2081,6 +2083,11 @@ enum nl80211_commands {
  * @NL80211_ATTR_PMK: PMK for the PMKSA identified by %NL80211_ATTR_PMKID.
  *	This is used with @NL80211_CMD_SET_PMKSA.
  *
+ * @NL80211_ATTR_SCHED_SCAN_MULTI: flag attribute which user-space shall use to
+ *	indicate that it supports multiple active scheduled scan requests.
+ * @NL80211_ATTR_SCHED_SCAN_MAX_REQS: indicates maximum number of scheduled
+ *	scan request that may be active for the device (u32).
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2500,6 +2507,9 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_PMK,
 
+	NL80211_ATTR_SCHED_SCAN_MULTI,
+	NL80211_ATTR_SCHED_SCAN_MAX_REQS,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
net/wireless/core.c +36 -12

108 lines not on this page · raw message

net/wireless/core.h +12 -3
index 5d27eca..25419a0 100644
@@ -74,7 +74,7 @@ struct cfg80211_registered_device {
 	u32 bss_entries;
 	struct cfg80211_scan_request *scan_req; /* protected by RTNL */
 	struct sk_buff *scan_msg;
-	struct cfg80211_sched_scan_request __rcu *sched_scan_req;
+	struct list_head sched_scan_req_list;
 	unsigned long suspend_at;
 	struct work_struct scan_done_wk;
 	struct work_struct sched_scan_results_wk;
@@ -95,6 +95,8 @@ struct cfg80211_registered_device {
 	struct list_head destroy_list;
 	struct work_struct destroy_work;
 
+	spinlock_t sched_stop_list_lock;
+	struct list_head sched_stop_list;
 	struct work_struct sched_scan_stop_wk;
 
 	struct cfg80211_chan_def radar_chandef;
@@ -264,7 +266,7 @@ struct cfg80211_beacon_registration {
 	u32 nlportid;
 };
 
-struct cfg80211_iface_destroy {
+struct cfg80211_nlport_release {
 	struct list_head list;
 	u32 nlportid;
 };
@@ -424,9 +426,16 @@ int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
 void __cfg80211_scan_done(struct work_struct *wk);
 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
 			   bool send_message);
+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);
+int cfg80211_stop_sched_scan_req(struct cfg80211_registered_device *rdev,
+				 struct cfg80211_sched_scan_request *req,
+				 bool driver_initiated);
 int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
-			       bool driver_initiated);
+			       u64 reqid, bool driver_initiated);
 void cfg80211_upload_connect_keys(struct wireless_dev *wdev);
 int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
 			  struct net_device *dev, enum nl80211_iftype ntype,
net/wireless/nl80211.c +58 -19

146 lines not on this page · raw message

net/wireless/rdev-ops.h +1 -1
index e4a9998..783f89c 100644
@@ -813,7 +813,7 @@ static inline int rdev_get_antenna(struct cfg80211_registered_device *rdev,
 		      struct cfg80211_sched_scan_request *request)
 {
 	int ret;
-	trace_rdev_sched_scan_start(&rdev->wiphy, dev, request);
+	trace_rdev_sched_scan_start(&rdev->wiphy, dev, request->reqid);
 	ret = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request);
 	trace_rdev_return_int(&rdev->wiphy, ret);
 	return ret;
net/wireless/scan.c +96 -19

163 lines not on this page · raw message

net/wireless/trace.h +12 -6
index fd55786..52935c4 100644
@@ -1610,20 +1610,26 @@
 	TP_ARGS(wiphy, rx, tx)
 );
 
-TRACE_EVENT(rdev_sched_scan_start,
-	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
-		 struct cfg80211_sched_scan_request *request),
-	TP_ARGS(wiphy, netdev, request),
+DECLARE_EVENT_CLASS(wiphy_netdev_id_evt,
+	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u64 id),
+	TP_ARGS(wiphy, netdev, id),
 	TP_STRUCT__entry(
 		WIPHY_ENTRY
 		NETDEV_ENTRY
+		__field(u64, id)
 	),
 	TP_fast_assign(
 		WIPHY_ASSIGN;
 		NETDEV_ASSIGN;
+		__entry->id = id;
 	),
-	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT,
-		  WIPHY_PR_ARG, NETDEV_PR_ARG)
+	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", id: %llu",
+		  WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->id)
+);
+
+DEFINE_EVENT(wiphy_netdev_id_evt, rdev_sched_scan_start,
+	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u64 id),
+	TP_ARGS(wiphy, netdev, id)
 );
 
 TRACE_EVENT(rdev_tdls_mgmt,
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH V3 1/9] nl80211: allow multiple active scheduled scan requests

Quoted 7 lines

  if (schedule_destroy_work) {

net/wireless/nl80211.c +1 -1
-			struct cfg80211_iface_destroy *destroy;
+			struct cfg80211_nlport_release *destroy;


  destroy = kzalloc(sizeof(*destroy), GFP_ATOMIC);

I was never really happy with this allocation and really want to get rid of it ...

Quoted 15 lines
net/wireless/nl80211.c +4 -0
+		if (schedule_sched_stop_work) {
+			struct cfg80211_nlport_release *destroy;
+
+			destroy = kzalloc(sizeof(*destroy),

GFP_ATOMIC);

net/wireless/nl80211.c +3 -0
+			if (destroy) {
+				destroy->nlportid = notify->portid;
+				spin_lock(&rdev-
Quoted 1 line

sched_stop_list_lock);

(quoted diff) +1 -0
+				list_add(&destroy->list, &rdev-
Quoted 1 line

sched_stop_list);

(quoted diff) +1 -0
+				spin_unlock(&rdev-
Quoted 1 line

sched_stop_list_lock);

(quoted diff) +1 -0
+				schedule_work(&rdev-
Quoted 1 line

sched_scan_stop_wk);

Review

Quoted 2 lines
(quoted diff) +2 -0
+			}
+		}

Can't we set some kind of flag in the struct cfg80211_sched_scan_request and iterate through them later again, checking which need to be destroyed?

johannes

maintainer
#3 lore raw

Re: [PATCH V3 1/9] nl80211: allow multiple active scheduled scan requests

Quoted 9 lines · Johannes Berg
Quoted 6 lines

  if (schedule_destroy_work) {

net/wireless/nl80211.c +1 -1
-			struct cfg80211_iface_destroy *destroy;
+			struct cfg80211_nlport_release *destroy;


  destroy = kzalloc(sizeof(*destroy), GFP_ATOMIC);

I was never really happy with this allocation and really want to get rid of it ...

Done :)

Quoted 18 lines
Quoted 18 lines
net/wireless/nl80211.c +4 -0
+		if (schedule_sched_stop_work) {
+			struct cfg80211_nlport_release *destroy;
+
+			destroy = kzalloc(sizeof(*destroy),

GFP_ATOMIC);

(quoted diff) +2 -0
+			if (destroy) {
+				destroy->nlportid = notify-
Quoted 1 line

portid;

(quoted diff) +1 -0
+				spin_lock(&rdev-
Quoted 1 line

sched_stop_list_lock);

(quoted diff) +1 -0
+				list_add(&destroy->list, &rdev-
Quoted 1 line

sched_stop_list);

(quoted diff) +1 -0
+				spin_unlock(&rdev-
Quoted 1 line

sched_stop_list_lock);

(quoted diff) +1 -0
+				schedule_work(&rdev-
Quoted 8 lines

Review

Quoted 4 lines
Quoted 1 line

sched_scan_stop_wk);

(quoted diff) +2 -0
+			}
+		}

Can't we set some kind of flag in the struct cfg80211_sched_scan_request and iterate through them later again, checking which need to be destroyed?

Easy enough - I'll also do that.

johannes

author maintainer
#4 lore raw

Re: [PATCH V3 1/9] nl80211: allow multiple active scheduled scan requests

In reply to Johannes Berg
Quoted 10 lines · Johannes Berg
Quoted 7 lines
  		if (schedule_destroy_work) {
net/wireless/nl80211.c +1 -1
-			struct cfg80211_iface_destroy *destroy;
+			struct cfg80211_nlport_release *destroy;
 
  			destroy = kzalloc(sizeof(*destroy),

GFP_ATOMIC);

I was never really happy with this allocation and really want to get rid of it ...

Agree. I don't like the allocation overhead either for deferred processing in another context.

Quoted 13 lines
Quoted 13 lines
net/wireless/nl80211.c +4 -0
+		if (schedule_sched_stop_work) {
+			struct cfg80211_nlport_release *destroy;
+
+			destroy = kzalloc(sizeof(*destroy),

GFP_ATOMIC);

net/wireless/nl80211.c +3 -0
+			if (destroy) {
+				destroy->nlportid = notify->portid;
+				spin_lock(&rdev-
Quoted 1 line

sched_stop_list_lock);

(quoted diff) +1 -0
+				list_add(&destroy->list, &rdev-
Quoted 1 line

sched_stop_list);

(quoted diff) +1 -0
+				spin_unlock(&rdev-
Quoted 1 line

sched_stop_list_lock);

Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +1 -0
+				schedule_work(&rdev-
Quoted 1 line

sched_scan_stop_wk);

(quoted diff) +2 -0
+			}
+		}

Can't we set some kind of flag in the struct cfg80211_sched_scan_request and iterate through them later again, checking which need to be destroyed?

Sure. In the worker we are already iterating so I guess we could. The number of internal fields in struct cfg80211_sched_scan_request with one of them being the list_head. Thinking about hiding those from the drivers. Is it worth it?

Regards,
Arend

maintainer
#5 lore raw

Re: [PATCH V3 1/9] nl80211: allow multiple active scheduled scan requests

FWIW:

https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git/commit/?id=978812b3f43dda86e20588cfe0a4a244c4fab141

Quoted 4 lines · Arend van Spriel

Sure. In the worker we are already iterating so I guess we could. The number of internal fields in struct cfg80211_sched_scan_request with one of them being the list_head. Thinking about hiding those from the drivers. Is it worth it?

I guess it could be done, but I'm tending towards doing that less again, I have no strong preference in this case. If it was something that seems likely to get abused, perhaps, but here...

johannes

author maintainer
#6 lore raw

Re: [PATCH V3 1/9] nl80211: allow multiple active scheduled scan requests

Quoted 7 lines · Johannes Berg

FWIW:

https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git/commit/?id=978812b3f43dda86e20588cfe0a4a244c4fab141

On Wed, 2017-04-26 at 10:46 +0200, Arend van Spriel wrote:

Quoted 8 lines
Quoted 4 lines

Sure. In the worker we are already iterating so I guess we could. The number of internal fields in struct cfg80211_sched_scan_request with one of them being the list_head. Thinking about hiding those from the drivers. Is it worth it?

I guess it could be done, but I'm tending towards doing that less again, I have no strong preference in this case. If it was something that seems likely to get abused, perhaps, but here...

Ok. As long as drivers don't think they can use the list_head to push it on a private list. The internal use comment does not end up in kerneldoc. So maybe we can improve that? Would work for me.

Regards,
Arend

maintainer
#7 lore raw

Re: [PATCH V3 1/9] nl80211: allow multiple active scheduled scan requests

Quoted 7 lines · Arend van Spriel

I guess it could be done, but I'm tending towards doing that less

Quoted 3 lines

again, I have no strong preference in this case. If it was something
that seems likely to get abused, perhaps, but here...

Ok. As long as drivers don't think they can use the list_head to push it on a private list.

They'll crash immediately and be disabused of that notion :)

Quoted 2 lines

The internal use comment does not end up in kerneldoc. So maybe we can improve that? Would work for me.

It's difficult - though we could replace it with /* private: */ and remove those things from kernel-doc entirely.

johannes

author maintainer
#8 lore raw

Re: [PATCH V3 1/9] nl80211: allow multiple active scheduled scan requests

Quoted 9 lines · Johannes Berg
Quoted 7 lines · Arend van Spriel

I guess it could be done, but I'm tending towards doing that less

Quoted 3 lines

again, I have no strong preference in this case. If it was something
that seems likely to get abused, perhaps, but here...

Ok. As long as drivers don't think they can use the list_head to push it on a private list.

Quoted 7 lines

They'll crash immediately and be disabused of that notion :)

Quoted 2 lines

The internal use comment does not end up in kerneldoc. So maybe we can improve that? Would work for me.

It's difficult - though we could replace it with /* private: */ and remove those things from kernel-doc entirely.

probably won't work:

	/* internal */
	struct wiphy *wiphy;
	struct net_device *dev;
	unsigned long scan_start;
	struct rcu_head rcu_head;
	u32 owner_nlportid;

	/* keep last */
	struct ieee80211_channel *channels[0];
};

Regards,
Arend

author maintainer
#9 lore raw

PATCH v3 2/9 nl80211: add support for BSSIDs in scheduled scan matchsets

In reply to Arend van Spriel

This patch allows for the scheduled scan request to specify matchsets for specific BSSIDs.

---
 include/net/cfg80211.h       |  6 +++++-
 include/uapi/linux/nl80211.h |  2 ++
 net/wireless/nl80211.c       | 41 +++++++++++++++++++++++++++++++----------
 3 files changed, 38 insertions(+), 11 deletions(-)
include/net/cfg80211.h +5 -1
index 7721a9b..2142800 100644
@@ -1613,11 +1613,15 @@ static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
 /**
  * struct cfg80211_match_set - sets of attributes to match
  *
- * @ssid: SSID to be matched; may be zero-length for no match (RSSI only)
+ * @ssid: SSID to be matched; may be zero-length in case of BSSID match
+ *	or no match (RSSI only)
+ * @bssid: BSSID to be matched; may be all-zero BSSID in case of SSID match
+ *	or no match (RSSI only)
  * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  */
 struct cfg80211_match_set {
 	struct cfg80211_ssid ssid;
+	u8 bssid[ETH_ALEN];
 	s32 rssi_thold;
 };
 
include/uapi/linux/nl80211.h +2 -0
index f34127d..925eb38 100644
@@ -3209,6 +3209,7 @@ enum nl80211_reg_rule_attr {
  *	BSS-es in the specified band is to be adjusted before doing
  *	RSSI-based BSS selection. The attribute value is a packed structure
  *	value as specified by &struct nl80211_bss_select_rssi_adjust.
+ * @NL80211_SCHED_SCAN_MATCH_ATTR_BSSID: BSSID to be used for matching.
  * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
  *	attribute number currently defined
  * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
@@ -3220,6 +3221,7 @@ enum nl80211_sched_scan_match_attr {
 	NL80211_SCHED_SCAN_MATCH_ATTR_RSSI,
 	NL80211_SCHED_SCAN_MATCH_ATTR_RELATIVE_RSSI,
 	NL80211_SCHED_SCAN_MATCH_ATTR_RSSI_ADJUST,
+	NL80211_SCHED_SCAN_MATCH_ATTR_BSSID,
 
 	/* keep last */
 	__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
net/wireless/nl80211.c +31 -10

73 lines not on this page · raw message

Signature · 1 line
1.9.1
author maintainer
#10 lore raw

PATCH v3 3/9 cfg80211: add request id parameter to .sched_scan_stop() signature

In reply to Arend van Spriel

For multiple scheduled scan support the driver needs to know which scheduled scan request is being stopped. Pass the request id in the .sched_scan_stop() callback.

---
 drivers/net/wireless/ath/ath6kl/cfg80211.c                |  2 +-
 .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c   |  6 +++---
 drivers/net/wireless/marvell/mwifiex/cfg80211.c           |  2 +-
 include/net/cfg80211.h                                    | 15 ++++++++-------
 net/mac80211/cfg.c                                        |  3 ++-
 net/wireless/rdev-ops.h                                   |  6 +++---
 net/wireless/scan.c                                       |  2 +-
 net/wireless/trace.h                                      | 10 +++++-----
 8 files changed, 24 insertions(+), 22 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +1 -1
index 1906412..fd53ffb 100644
@@ -3352,7 +3352,7 @@ static int ath6kl_cfg80211_sscan_start(struct wiphy *wiphy,
 }
 
 static int ath6kl_cfg80211_sscan_stop(struct wiphy *wiphy,
-				      struct net_device *dev)
+				      struct net_device *dev, u64 reqid)
 {
 	struct ath6kl_vif *vif = netdev_priv(dev);
 	bool stopped;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +3 -3
index b23c37c..3ca1132 100644
@@ -3390,7 +3390,7 @@ static int brcmf_start_internal_escan(struct brcmf_if *ifp,
 }
 
 static int brcmf_cfg80211_sched_scan_stop(struct wiphy *wiphy,
-					  struct net_device *ndev)
+					  struct net_device *ndev, u64 reqid)
 {
 	struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
 	struct brcmf_if *ifp = netdev_priv(ndev);
@@ -3592,7 +3592,7 @@ static s32 brcmf_cfg80211_resume(struct wiphy *wiphy)
 				      cfg->wowl.pre_pmmode);
 		cfg->wowl.active = false;
 		if (cfg->wowl.nd_enabled) {
-			brcmf_cfg80211_sched_scan_stop(cfg->wiphy, ifp->ndev);
+			brcmf_cfg80211_sched_scan_stop(cfg->wiphy, ifp->ndev, 0);
 			brcmf_fweh_unregister(cfg->pub, BRCMF_E_PFN_NET_FOUND);
 			brcmf_fweh_register(cfg->pub, BRCMF_E_PFN_NET_FOUND,
 					    brcmf_notify_sched_scan_results);
@@ -3676,7 +3676,7 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
 
 	/* Stop scheduled scan */
 	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PNO))
-		brcmf_cfg80211_sched_scan_stop(wiphy, ndev);
+		brcmf_cfg80211_sched_scan_stop(wiphy, ndev, 0);
 
 	/* end any scanning */
 	if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status))
drivers/net/wireless/marvell/mwifiex/cfg80211.c +1 -1
index ffb78f6..65783a4 100644
@@ -2718,7 +2718,7 @@ static int mwifiex_set_ibss_params(struct mwifiex_private *priv,
  * previous bgscan configuration in the firmware
  */
 static int mwifiex_cfg80211_sched_scan_stop(struct wiphy *wiphy,
-					    struct net_device *dev)
+					    struct net_device *dev, u64 reqid)
 {
 	struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
 
include/net/cfg80211.h +8 -7
index 2142800..84e3baa 100644
@@ -2771,12 +2771,12 @@ struct cfg80211_nan_func {
  * @set_cqm_txe_config: Configure connection quality monitor TX error
  *	thresholds.
  * @sched_scan_start: Tell the driver to start a scheduled scan.
- * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan. This
- *	call must stop the scheduled scan and be ready for starting a new one
- *	before it returns, i.e. @sched_scan_start may be called immediately
- *	after that again and should not fail in that case. The driver should
- *	not call cfg80211_sched_scan_stopped() for a requested stop (when this
- *	method returns 0.)
+ * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan with
+ *	given request id. This call must stop the scheduled scan and be ready
+ *	for starting a new one before it returns, i.e. @sched_scan_start may be
+ *	called immediately after that again and should not fail in that case.
+ *	The driver should not call cfg80211_sched_scan_stopped() for a requested
+ *	stop (when this method returns 0).
  *
  * @mgmt_frame_register: Notify driver that a management frame type was
  *	registered. The callback is allowed to sleep.
@@ -3074,7 +3074,8 @@ struct cfg80211_ops {
 	int	(*sched_scan_start)(struct wiphy *wiphy,
 				struct net_device *dev,
 				struct cfg80211_sched_scan_request *request);
-	int	(*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev);
+	int	(*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev,
+				   u64 reqid);
 
 	int	(*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev,
 				  struct cfg80211_gtk_rekey_data *data);
net/mac80211/cfg.c +2 -1
index d041f78..038c313 100644
@@ -2242,7 +2242,8 @@ static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev)
 }
 
 static int
-ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
+ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev,
+			  u64 reqid)
 {
 	struct ieee80211_local *local = wiphy_priv(wiphy);
 
net/wireless/rdev-ops.h +3 -3
index 783f89c..0598c1e 100644
@@ -820,11 +820,11 @@ static inline int rdev_get_antenna(struct cfg80211_registered_device *rdev,
 }
 
 static inline int rdev_sched_scan_stop(struct cfg80211_registered_device *rdev,
-				       struct net_device *dev)
+				       struct net_device *dev, u64 reqid)
 {
 	int ret;
-	trace_rdev_sched_scan_stop(&rdev->wiphy, dev);
-	ret = rdev->ops->sched_scan_stop(&rdev->wiphy, dev);
+	trace_rdev_sched_scan_stop(&rdev->wiphy, dev, reqid);
+	ret = rdev->ops->sched_scan_stop(&rdev->wiphy, dev, reqid);
 	trace_rdev_return_int(&rdev->wiphy, ret);
 	return ret;
 }
net/wireless/scan.c +1 -1
index bd9feed9..8d86f70 100644
@@ -436,7 +436,7 @@ int cfg80211_stop_sched_scan_req(struct cfg80211_registered_device *rdev,
 	ASSERT_RTNL();
 
 	if (!driver_initiated) {
-		int err = rdev_sched_scan_stop(rdev, req->dev);
+		int err = rdev_sched_scan_stop(rdev, req->dev, req->reqid);
 		if (err)
 			return err;
 	}
net/wireless/trace.h +5 -5
index 52935c4..8d8f6b4 100644
@@ -576,11 +576,6 @@
 	TP_ARGS(wiphy, netdev)
 );
 
-DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop,
-	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
-	TP_ARGS(wiphy, netdev)
-);
-
 DEFINE_EVENT(wiphy_netdev_evt, rdev_set_rekey_data,
 	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
 	TP_ARGS(wiphy, netdev)
@@ -1632,6 +1627,11 @@
 	TP_ARGS(wiphy, netdev, id)
 );
 
+DEFINE_EVENT(wiphy_netdev_id_evt, rdev_sched_scan_stop,
+	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u64 id),
+	TP_ARGS(wiphy, netdev, id)
+);
+
 TRACE_EVENT(rdev_tdls_mgmt,
 	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
 		 u8 *peer, u8 action_code, u8 dialog_token,
Signature · 1 line
1.9.1
author maintainer
#11 lore raw

PATCH v3 4/9 cfg80211: add request id to cfg80211_sched_scan_*() api

In reply to Arend van Spriel

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.

---
 drivers/net/wireless/ath/ath6kl/cfg80211.c         |  2 +-
 drivers/net/wireless/ath/ath6kl/wmi.c              |  2 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c         |  4 +--
 drivers/net/wireless/marvell/mwifiex/cfg80211.c    |  6 ++---
 drivers/net/wireless/marvell/mwifiex/main.c        |  2 +-
 drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c |  2 +-
 drivers/net/wireless/marvell/mwifiex/sta_event.c   |  2 +-
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c   |  2 +-
 include/net/cfg80211.h                             | 11 +++++---
 net/mac80211/pm.c                                  |  2 +-
 net/mac80211/scan.c                                |  4 +--
 net/mac80211/util.c                                |  2 +-
 net/wireless/core.c                                |  1 -
 net/wireless/core.h                                |  1 -
 net/wireless/nl80211.c                             |  2 ++
 net/wireless/scan.c                                | 30 ++++++++++------------
 net/wireless/trace.h                               | 26 ++++++++++++++-----
 17 files changed, 59 insertions(+), 42 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +1 -1
index fd53ffb..decb937 100644
@@ -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,
drivers/net/wireless/ath/ath6kl/wmi.c +1 -1
index 84a6d12..04df853 100644
@@ -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,
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +2 -2
index 3ca1132..8da9ae0 100644
@@ -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,
@@ -3357,7 +3357,7 @@ static int brcmf_start_internal_escan(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;
drivers/net/wireless/marvell/mwifiex/cfg80211.c +3 -3
index 65783a4..9b30ad4 100644
@@ -2053,7 +2053,7 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
 	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 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv)
 		    (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 @@ static int mwifiex_set_ibss_params(struct mwifiex_private *priv,
 		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)
drivers/net/wireless/marvell/mwifiex/main.c +1 -1
index f50080a..f82da3f 100644
@@ -748,7 +748,7 @@ static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter,
 		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;
drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c +1 -1
index ab75da3..f1d1f56f 100644
@@ -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;
drivers/net/wireless/marvell/mwifiex/sta_event.c +1 -1
index b5b7664..839df8a 100644
@@ -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;
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c +1 -1
index 1532ac9..42997e0 100644
@@ -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
include/net/cfg80211.h +8 -3
index 84e3baa..0f82062 100644
@@ -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
@@ -1722,6 +1723,7 @@ struct cfg80211_sched_scan_request {
 	struct cfg80211_bss_select_adjust rssi_adjust;
 
 	/* internal */
+	struct work_struct results_wk;
 	struct wiphy *wiphy;
 	struct net_device *dev;
 	unsigned long scan_start;
@@ -4561,31 +4563,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
net/mac80211/pm.c +1 -1
index 76a8bcd..a87d195 100644
@@ -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)
net/mac80211/scan.c +2 -2
index faab3c4..94be10e 100644
@@ -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)
net/mac80211/util.c +1 -1
index 7a37ce7..5890969 100644
@@ -2103,7 +2103,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) {
net/wireless/core.c +0 -1
index 45e1400..9b8e8e8 100644
@@ -490,7 +490,6 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
 	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);
net/wireless/core.h +0 -1
index 25419a0..df5b975 100644
@@ -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;
 
net/wireless/nl80211.c +2 -0
index 19cc70a..b0f7c83 100644
@@ -7402,6 +7402,8 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
 	if (err)
 		goto out_err;
 
+	INIT_WORK(&sched_scan_req->results_wk, __cfg80211_sched_scan_results);
+
 	/* leave request id zero for legacy request
 	 * or if driver does not support multi-scheduled scan
 	 */
net/wireless/scan.c +14 -16
index 8d86f70..9af3141 100644
@@ -369,15 +369,13 @@ void __cfg80211_sched_scan_results(struct work_struct *wk)
 	struct cfg80211_registered_device *rdev;
 	struct cfg80211_sched_scan_request *request;
 
-	rdev = container_of(wk, struct cfg80211_registered_device,
-			    sched_scan_results_wk);
+	request = container_of(wk, struct cfg80211_sched_scan_request, results_wk);
+	rdev = wiphy_to_rdev(request->wiphy);
 
 	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) {
 		if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
 			/* flush entries from previous scans */
 			spin_lock_bh(&rdev->bss_lock);
@@ -391,40 +389,40 @@ void __cfg80211_sched_scan_results(struct work_struct *wk)
 	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(wiphy_to_rdev(wiphy), reqid);
 	rtnl_unlock();
 
 	if (!IS_ERR(request))
-		queue_work(cfg80211_wq,
-			   &wiphy_to_rdev(wiphy)->sched_scan_results_wk);
+		queue_work(cfg80211_wq, &request->results_wk);
+	else
+		wiphy_err(wiphy, "reqid %llu not found\n", reqid);
 }
 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);
net/wireless/trace.h +20 -6
index 8d8f6b4..ca8b205 100644
@@ -2820,14 +2820,28 @@
 		  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,
Signature · 1 line
1.9.1
maintainer
#12 lore raw

Re: [PATCH V3 4/9] cfg80211: add request id to cfg80211_sched_scan_*() api

Quoted 8 lines · Arend van Spriel

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.

m>

All your reviewers aren't paying attention ;-)

Quoted 8 lines
include/net/cfg80211.h +0 -0
@@ -1722,6 +1723,7 @@ struct cfg80211_sched_scan_request {
  	struct cfg80211_bss_select_adjust rssi_adjust;


  /* internal */

include/net/cfg80211.h +1 -0
+	struct work_struct results_wk;

  struct wiphy *wiphy;
  struct net_device *dev;
  unsigned long scan_start;

Superficially, this is fine - but you need to think hard about the semantics of when you cancel this work.

Quoted 16 lines

+++ b/net/wireless/scan.c

net/wireless/scan.c +0 -0
@@ -369,15 +369,13 @@ void __cfg80211_sched_scan_results(struct
 work_struct *wk)
  	struct cfg80211_registered_device *rdev;
  	struct cfg80211_sched_scan_request *request;

net/wireless/scan.c +1 -2
-	rdev = container_of(wk, struct cfg80211_registered_device,
-			    sched_scan_results_wk);
+	request = container_of(wk, struct

cfg80211_sched_scan_request, results_wk);

net/wireless/scan.c +1 -0
+	rdev = wiphy_to_rdev(request->wiphy);


  rtnl_lock();

net/wireless/scan.c +0 -2
-	request = cfg80211_find_sched_scan_req(rdev, 0);
-
Quoted 2 lines

  /* we don't have sched_scan_req anymore if the scan is stopping */

That comment is kinda wrong now, afaict? Also you return

net/wireless/scan.c void __cfg80211_sched_scan_results(struct work_struct *wk) · line 378

Quoted 2 lines
net/wireless/scan.c +1 -1
-	if (!IS_ERR(request)) {
+	if (request) {

This seems wrong - you do return an ERR_PTR() from find. Not that there's all that much point in doing so vs. returning NULL, might be worth cleaning it up.

Quoted 24 lines
net/wireless/scan.c +1 -1
-void cfg80211_sched_scan_results(struct wiphy *wiphy)
+void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid)

 {

(quoted diff) +0 -1
-	struct cfg80211_registered_device *rdev =

wiphy_to_rdev(wiphy);
  struct cfg80211_sched_scan_request *request;

net/wireless/scan.c +1 -1
-	trace_cfg80211_sched_scan_results(wiphy);
+	trace_cfg80211_sched_scan_results(wiphy, reqid);

  /* ignore if we're not scanning */

  rtnl_lock();

(quoted diff) +1 -1
-	request = cfg80211_find_sched_scan_req(rdev, 0);
+	request = cfg80211_find_sched_scan_req(wiphy_to_rdev(wiphy),

reqid);
  rtnl_unlock();

  if (!IS_ERR(request))

(quoted diff) +0 -2
-		queue_work(cfg80211_wq,
-			   &wiphy_to_rdev(wiphy)-
Quoted 1 line

sched_scan_results_wk);

net/wireless/scan.c +3 -0
+		queue_work(cfg80211_wq, &request->results_wk);
+	else
+		wiphy_err(wiphy, "reqid %llu not found\n", reqid);
Quoted 1 line

 }

This seems problematic - you use the request pointer outside the locking now. I'd move that rtnl_unlock() to afterwards. The message could also mention sched scan, that might be useful. Although I suspect that may happen due to races (e.g. netlink socket close vs. firmware stop) so maybe it's not all that useful.

Most importantly though, you don't protect against queuing the work here, and then deleting the request. In the old case the comment that I pointed out above will save us, but in this new case it can't (the comment is now wrong), and that's a problem.

I looked briefly at this and I suspect it will be very hard to fix that with a per-request work struct. It might be better to have a per-work status flag that you set here, then you schedule the global work, and that global work will send all the appropriate result messages after clearing the status bit again, similar to what I did with the netlink destroy now.

johannes

author maintainer
#13 lore raw

Re: [PATCH V3 4/9] cfg80211: add request id to cfg80211_sched_scan_*() api

Quoted 45 lines · Johannes Berg
Quoted 8 lines · Arend van Spriel

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.

m>

All your reviewers aren't paying attention ;-)

include/net/cfg80211.h struct cfg80211_sched_scan_request { · line 1729

Quoted 8 lines
include/net/cfg80211.h +1 -0
@@ -1722,6 +1723,7 @@ struct cfg80211_sched_scan_request {
 	struct cfg80211_bss_select_adjust rssi_adjust;
 
 	/* internal */
+	struct work_struct results_wk;
 	struct wiphy *wiphy;
 	struct net_device *dev;
 	unsigned long scan_start;

Superficially, this is fine - but you need to think hard about the semantics of when you cancel this work.

Quoted 17 lines

+++ b/net/wireless/scan.c

net/wireless/scan.c +2 -4
@@ -369,15 +369,13 @@ void __cfg80211_sched_scan_results(struct
 work_struct *wk)
 	struct cfg80211_registered_device *rdev;
 	struct cfg80211_sched_scan_request *request;
 
-	rdev = container_of(wk, struct cfg80211_registered_device,
-			    sched_scan_results_wk);
+	request = container_of(wk, struct
 cfg80211_sched_scan_request, results_wk);
+	rdev = wiphy_to_rdev(request->wiphy);
 
 	rtnl_lock();
 
-	request = cfg80211_find_sched_scan_req(rdev, 0);
-
 	/* we don't have sched_scan_req anymore if the scan is
Quoted 1 line

stopping */

That comment is kinda wrong now, afaict? Also you return

Quoted 6 lines

net/wireless/scan.c void __cfg80211_sched_scan_results(struct work_struct *wk) · line 378

Quoted 2 lines
net/wireless/scan.c +1 -1
-	if (!IS_ERR(request)) {
+	if (request) {

This seems wrong - you do return an ERR_PTR() from find. Not that there's all that much point in doing so vs. returning NULL, might be worth cleaning it up.

Indeed. Not sure if it was me being sloppy/confused or due to rebasing the patches. Anyway, I will fix this.

Quoted 21 lines
Quoted 21 lines
net/wireless/scan.c +1 -2
-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);

net/wireless/scan.c +2 -2
 	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(wiphy_to_rdev(wiphy),

reqid);

net/wireless/scan.c +0 -2
 	rtnl_unlock();
 
 	if (!IS_ERR(request))
-		queue_work(cfg80211_wq,
-			   &wiphy_to_rdev(wiphy)-
Quoted 1 line

sched_scan_results_wk);

Quoted 10 lines

net/wireless/scan.c void __cfg80211_sched_scan_results(struct work_struct *wk) · line 407

Quoted 4 lines
net/wireless/scan.c +3 -0
+		queue_work(cfg80211_wq, &request->results_wk);
+	else
+		wiphy_err(wiphy, "reqid %llu not found\n", reqid);
 }

This seems problematic - you use the request pointer outside the locking now. I'd move that rtnl_unlock() to afterwards. The message could also mention sched scan, that might be useful. Although I suspect that may happen due to races (e.g. netlink socket close vs. firmware stop) so maybe it's not all that useful.

When adding the worker in the request I was thinking about what might happen between the queue_work and the work actually being scheduled.

Quoted 11 lines

Most importantly though, you don't protect against queuing the work here, and then deleting the request. In the old case the comment that I pointed out above will save us, but in this new case it can't (the comment is now wrong), and that's a problem.

I looked briefly at this and I suspect it will be very hard to fix that with a per-request work struct. It might be better to have a per-work status flag that you set here, then you schedule the global work, and that global work will send all the appropriate result messages after clearing the status bit again, similar to what I did with the netlink destroy now.

I guess it is in you repo as I did not see anything related on the mailing list. So regarding this rework, do you want me to send the series again or just this patch?

Regards,
Arend

maintainer
#14 lore raw

Re: [PATCH V3 4/9] cfg80211: add request id to cfg80211_sched_scan_*() api

Quoted 3 lines · Arend Van Spriel

I guess it is in you repo as I did not see anything related on the mailing list.

Yeah. But that should be up-to-date.

Quoted 2 lines

So regarding this rework, do you want me to send the
series again or just this patch?

Just this single patch is fine.

johannes

author maintainer
#15 lore raw

PATCH v3 5/9 brcmfmac: add firmware feature detection for gscan feature

In reply to Arend van Spriel

From: Arend van Spriel <[email protected]>

Detect gscan support in firmware by doing pfn_gscan_cfg iovar with invalid version.

---
 .../wireless/broadcom/brcm80211/brcmfmac/feature.c | 22 +++++++-
 .../wireless/broadcom/brcm80211/brcmfmac/feature.h |  4 +-
 .../broadcom/brcm80211/brcmfmac/fwil_types.h       | 59 ++++++++++++++++++++++
 3 files changed, 83 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +21 -1
index 62985f2..8c7ef59 100644
@@ -27,6 +27,7 @@
 #include "feature.h"
 #include "common.h"
 
+#define BRCMF_FW_UNSUPPORTED	23
 
 /*
  * expand feature list to array of feature strings.
@@ -113,6 +114,22 @@ static void brcmf_feat_iovar_int_get(struct brcmf_if *ifp,
 	}
 }
 
+static void brcmf_feat_iovar_data_set(struct brcmf_if *ifp,
+				      enum brcmf_feat_id id, char *name,
+				      const void *data, size_t len)
+{
+	int err;
+
+	err = brcmf_fil_iovar_data_set(ifp, name, data, len);
+	if (err != -BRCMF_FW_UNSUPPORTED) {
+		brcmf_dbg(INFO, "enabling feature: %s\n", brcmf_feat_names[id]);
+		ifp->drvr->feat_flags |= BIT(id);
+	} else {
+		brcmf_dbg(TRACE, "%s feature check failed: %d\n",
+			  brcmf_feat_names[id], err);
+	}
+}
+
 static void brcmf_feat_firmware_capabilities(struct brcmf_if *ifp)
 {
 	char caps[256];
@@ -136,11 +153,14 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
 {
 	struct brcmf_if *ifp = brcmf_get_ifp(drvr, 0);
 	struct brcmf_pno_macaddr_le pfn_mac;
+	struct brcmf_gscan_config gscan_cfg;
 	u32 wowl_cap;
 	s32 err;
 
 	brcmf_feat_firmware_capabilities(ifp);
-
+	memset(&gscan_cfg, 0, sizeof(gscan_cfg));
+	brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN, "pfn_gscan_cfg",
+				  &gscan_cfg, sizeof(gscan_cfg));
 	brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_PNO, "pfn");
 	if (drvr->bus_if->wowl_supported)
 		brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl");
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h +3 -1
index db4733a..c1dbd17 100644
@@ -31,6 +31,7 @@
  * WOWL_GTK: (WOWL) GTK rekeying offload
  * WOWL_ARP_ND: ARP and Neighbor Discovery offload support during WOWL.
  * MFP: 802.11w Management Frame Protection.
+ * GSCAN: enhanced scan offload feature.
  */
 #define BRCMF_FEAT_LIST \
 	BRCMF_FEAT_DEF(MBSS) \
@@ -44,7 +45,8 @@
 	BRCMF_FEAT_DEF(WOWL_ND) \
 	BRCMF_FEAT_DEF(WOWL_GTK) \
 	BRCMF_FEAT_DEF(WOWL_ARP_ND) \
-	BRCMF_FEAT_DEF(MFP)
+	BRCMF_FEAT_DEF(MFP) \
+	BRCMF_FEAT_DEF(GSCAN)
 
 /*
  * Quirks:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +59 -0

63 lines not on this page · raw message

Signature · 1 line
1.9.1
#16 lore raw

Re: [V3, 5/9] brcmfmac: add firmware feature detection for gscan feature

Quoted 9 lines · Arend Van Spriel

From: Arend van Spriel <[email protected]>

Detect gscan support in firmware by doing pfn_gscan_cfg iovar with invalid version.

Failed to apply:

fatal: sha1 information is lacking or useless (drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c).
error: could not build fake ancestor
Applying: brcmfmac: add support multi-scheduled scan
Patch failed at 0001 brcmfmac: add support multi-scheduled scan
The copy of the patch that failed is found in: .git/rebase-apply/patch

5 patches set to Changes Requested.

9692541 [V3,5/9] brcmfmac: add firmware feature detection for gscan feature 9692537 [V3,6/9] brcmfmac: move scheduled scan wiphy param setting to pno module 9692543 [V3,7/9] brcmfmac: add support multi-scheduled scan
9692535 [V3,8/9] brcmfmac: add mutex to protect pno requests 9692539 [V3,9/9] brcmfmac: add scheduled scan support for specified BSSIDs

Signature · 3 lines
https://patchwork.kernel.org/patch/9692541/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#17 lore raw

Re: [V3, 5/9] brcmfmac: add firmware feature detection for gscan feature

Quoted 19 lines · Kalle Valo
Quoted 9 lines · Arend Van Spriel

From: Arend van Spriel <[email protected]>

Detect gscan support in firmware by doing pfn_gscan_cfg iovar with invalid version.

Failed to apply:

fatal: sha1 information is lacking or useless (drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c).
error: could not build fake ancestor
Applying: brcmfmac: add support multi-scheduled scan
Patch failed at 0001 brcmfmac: add support multi-scheduled scan
The copy of the patch that failed is found in: .git/rebase-apply/patch

Quoted 7 lines

5 patches set to Changes Requested.

9692541 [V3,5/9] brcmfmac: add firmware feature detection for gscan feature 9692537 [V3,6/9] brcmfmac: move scheduled scan wiphy param setting to pno module 9692543 [V3,7/9] brcmfmac: add support multi-scheduled scan
9692535 [V3,8/9] brcmfmac: add mutex to protect pno requests 9692539 [V3,9/9] brcmfmac: add scheduled scan support for specified BSSIDs

Actually I made a mistake and forgot to manually remove patches 5 and 6 from the tree after the conflict (I haven't automated that part yet in my script). So these are now applied:

9fe929aaace6 brcmfmac: add firmware feature detection for gscan feature 94ed6ffb7965 brcmfmac: move scheduled scan wiphy param setting to pno module

Please resend patches 7-9 and double check that the tree looks ok :)

Signature · 1 line
Kalle Valo
author maintainer
#18 lore raw

Re: [V3, 5/9] brcmfmac: add firmware feature detection for gscan feature

Quoted 29 lines · Kalle Valo
Quoted 19 lines · Kalle Valo
Quoted 9 lines · Arend Van Spriel

From: Arend van Spriel <[email protected]>

Detect gscan support in firmware by doing pfn_gscan_cfg iovar with invalid version.

Failed to apply:

fatal: sha1 information is lacking or useless (drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c).
error: could not build fake ancestor
Applying: brcmfmac: add support multi-scheduled scan
Patch failed at 0001 brcmfmac: add support multi-scheduled scan
The copy of the patch that failed is found in: .git/rebase-apply/patch

Quoted 7 lines

5 patches set to Changes Requested.

9692541 [V3,5/9] brcmfmac: add firmware feature detection for gscan feature 9692537 [V3,6/9] brcmfmac: move scheduled scan wiphy param setting to pno module 9692543 [V3,7/9] brcmfmac: add support multi-scheduled scan
9692535 [V3,8/9] brcmfmac: add mutex to protect pno requests 9692539 [V3,9/9] brcmfmac: add scheduled scan support for specified BSSIDs

Quoted 8 lines

Actually I made a mistake and forgot to manually remove patches 5 and 6 from the tree after the conflict (I haven't automated that part yet in my script). So these are now applied:

9fe929aaace6 brcmfmac: add firmware feature detection for gscan feature 94ed6ffb7965 brcmfmac: move scheduled scan wiphy param setting to pno module

Please resend patches 7-9 and double check that the tree looks ok :)

Will do. These patches were in same series as cfg80211 changes and all based on mac80211-next/master. I already mentioned to you and Johannes in earlier version of the patch series (posted April 7) that this would result in a merge conflict, but I can imagine that info got lost after more than a month.

Regards,
Arend

#19 lore raw

Re: [V3, 5/9] brcmfmac: add firmware feature detection for gscan feature

Quoted 38 lines · Arend Van Spriel
Quoted 37 lines · Kalle Valo
Quoted 20 lines · Kalle Valo
Quoted 9 lines · Arend Van Spriel

From: Arend van Spriel <[email protected]>

Detect gscan support in firmware by doing pfn_gscan_cfg iovar with invalid version.

Failed to apply:

fatal: sha1 information is lacking or useless (drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c).
error: could not build fake ancestor
Applying: brcmfmac: add support multi-scheduled scan
Patch failed at 0001 brcmfmac: add support multi-scheduled scan The copy of the patch that failed is found in: .git/rebase-apply/patch

Quoted 7 lines

5 patches set to Changes Requested.

9692541 [V3,5/9] brcmfmac: add firmware feature detection for gscan feature 9692537 [V3,6/9] brcmfmac: move scheduled scan wiphy param setting to pno module 9692543 [V3,7/9] brcmfmac: add support multi-scheduled scan
9692535 [V3,8/9] brcmfmac: add mutex to protect pno requests 9692539 [V3,9/9] brcmfmac: add scheduled scan support for specified BSSIDs

Actually I made a mistake and forgot to manually remove patches 5 and 6 from the tree after the conflict (I haven't automated that part yet in my script). So these are now applied:

9fe929aaace6 brcmfmac: add firmware feature detection for gscan feature 94ed6ffb7965 brcmfmac: move scheduled scan wiphy param setting to pno module

Quoted 7 lines
Quoted 1 line

Please resend patches 7-9 and double check that the tree looks ok :)

Will do. These patches were in same series as cfg80211 changes and all based on mac80211-next/master. I already mentioned to you and Johannes in earlier version of the patch series (posted April 7) that this would result in a merge conflict, but I can imagine that info got lost after more than a month.

Ah, I remember now. But yeah, too many emails so I tend to forget so old discussions while looking at patches.

Signature · 1 line
Kalle Valo
author maintainer
#20 lore raw

PATCH v3 6/9 brcmfmac: move scheduled scan wiphy param setting to pno module

In reply to Arend van Spriel

As pno module is providing scheduled scan functionality have it taking care of setting related wiphy parameters as well.

---
 .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c    | 18 +++++-------------
 .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.h    |  2 ++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c | 10 ++++++++++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.h |  8 ++++++++
 4 files changed, 25 insertions(+), 13 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +5 -13
index 8da9ae0..6585411 100644
@@ -6356,16 +6356,6 @@ static int brcmf_setup_ifmodes(struct wiphy *wiphy, struct brcmf_if *ifp)
 	return -ENOMEM;
 }
 
-static void brcmf_wiphy_pno_params(struct wiphy *wiphy)
-{
-	/* scheduled scan settings */
-	wiphy->max_sched_scan_reqs = 1;
-	wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT;
-	wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT;
-	wiphy->max_sched_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX;
-	wiphy->max_sched_scan_plan_interval = BRCMF_PNO_SCHED_SCAN_MAX_PERIOD;
-}
-
 #ifdef CONFIG_PM
 static const struct wiphy_wowlan_support brcmf_wowlan_support = {
 	.flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
@@ -6412,6 +6402,7 @@ static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp)
 	const struct ieee80211_iface_combination *combo;
 	struct ieee80211_supported_band *band;
 	u16 max_interfaces = 0;
+	bool gscan;
 	__le32 bandlist[3];
 	u32 n_bands;
 	int err, i;
@@ -6461,9 +6452,10 @@ static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp)
 		wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
 	wiphy->mgmt_stypes = brcmf_txrx_stypes;
 	wiphy->max_remain_on_channel_duration = 5000;
-	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PNO))
-		brcmf_wiphy_pno_params(wiphy);
-
+	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PNO)) {
+		gscan = brcmf_feat_is_enabled(ifp, BRCMF_FEAT_GSCAN);
+		brcmf_pno_wiphy_params(wiphy, gscan);
+	}
 	/* vendor commands/events support */
 	wiphy->vendor_commands = brcmf_vendor_cmds;
 	wiphy->n_vendor_commands = BRCMF_VNDR_CMDS_LAST - 1;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h +2 -0
index 8f19d95..a1c2e0a 100644
@@ -24,6 +24,8 @@
 #include "fwil_types.h"
 #include "p2p.h"
 
+#define BRCMF_SCAN_IE_LEN_MAX		2048
+
 #define WL_NUM_SCAN_MAX			10
 #define WL_TLV_INFO_MAX			1024
 #define WL_BSS_INFO_MAX			2048
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c +10 -0
index 6c3bde8..a473445 100644
@@ -239,3 +239,13 @@ int brcmf_pno_start_sched_scan(struct brcmf_if *ifp,
 	return ret;
 }
 
+void brcmf_pno_wiphy_params(struct wiphy *wiphy, bool gscan)
+{
+	/* scheduled scan settings */
+	wiphy->max_sched_scan_reqs = gscan ? 2 : 1;
+	wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT;
+	wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT;
+	wiphy->max_sched_scan_ie_len = BRCMF_SCAN_IE_LEN_MAX;
+	wiphy->max_sched_scan_plan_interval = BRCMF_PNO_SCHED_SCAN_MAX_PERIOD;
+}
+
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.h +8 -0
index bae55b2..07ec51f 100644
@@ -37,4 +37,12 @@
 int brcmf_pno_start_sched_scan(struct brcmf_if *ifp,
 			       struct cfg80211_sched_scan_request *req);
 
+/**
+ * brcmf_pno_wiphy_params - fill scheduled scan parameters in wiphy instance.
+ *
+ * @wiphy: wiphy instance to be used.
+ * @gscan: indicates whether the device has support for g-scan feature.
+ */
+void brcmf_pno_wiphy_params(struct wiphy *wiphy, bool gscan);
+
 #endif /* _BRCMF_PNO_H */
Signature · 1 line
1.9.1
author maintainer
#21 lore raw

PATCH v3 7/9 brcmfmac: add support multi-scheduled scan

In reply to Arend van Spriel

This change adds support for multi-scheduled scan in the driver. It currently relies on g-scan support in firmware and will set struct wiphy::max_sched_scan_reqs accordingly. This is limited to 16 concurrent requests.

The firmware currently has a limit of 64 channels that can be configured for all requests in total regardless whether there are duplicates. So if a request uses 35 channels there are 29 channels left for another request. When user-space does not specify any channels cfg80211 will add all channels defined by the wiphy instance to the request, which makes reaching the limit rather easy for dual-band devices.

---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c         |  67 +++-
 .../broadcom/brcm80211/brcmfmac/cfg80211.h         |   6 +-
 .../wireless/broadcom/brcm80211/brcmfmac/core.c    |   1 +
 .../wireless/broadcom/brcm80211/brcmfmac/debug.h   |   2 +
 .../broadcom/brcm80211/brcmfmac/fwil_types.h       |  32 +-
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.c | 398 ++++++++++++++++++---
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.h |  47 ++-
 7 files changed, 464 insertions(+), 89 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +49 -18
index 6585411..151bba1 100644
@@ -719,6 +719,8 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
 {
 	struct brcmf_scan_params_le params_le;
 	struct cfg80211_scan_request *scan_request;
+	u64 reqid;
+	u32 bucket;
 	s32 err = 0;
 
 	brcmf_dbg(SCAN, "Enter\n");
@@ -749,7 +751,7 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
 		err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SCAN,
 					     &params_le, sizeof(params_le));
 		if (err)
-			brcmf_err("Scan abort  failed\n");
+			brcmf_err("Scan abort failed\n");
 	}
 
 	brcmf_scan_config_mpc(ifp, 1);
@@ -758,11 +760,21 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
 	 * e-scan can be initiated internally
 	 * which takes precedence.
 	 */
-	if (cfg->internal_escan) {
-		brcmf_dbg(SCAN, "scheduled scan completed\n");
-		cfg->internal_escan = false;
-		if (!aborted)
-			cfg80211_sched_scan_results(cfg_to_wiphy(cfg), 0);
+	if (cfg->int_escan_map) {
+		brcmf_dbg(SCAN, "scheduled scan completed (%x)\n",
+			  cfg->int_escan_map);
+		while (cfg->int_escan_map) {
+			bucket = __ffs(cfg->int_escan_map);
+			cfg->int_escan_map &= ~BIT(bucket);
+			reqid = brcmf_pno_find_reqid_by_bucket(cfg->pno,
+							       bucket);
+			if (!aborted) {
+				brcmf_dbg(SCAN, "report results: reqid=%llu\n",
+					  reqid);
+				cfg80211_sched_scan_results(cfg_to_wiphy(cfg),
+							    reqid);
+			}
+		}
 	} else if (scan_request) {
 		struct cfg80211_scan_info info = {
 			.aborted = aborted,
@@ -1011,7 +1023,7 @@ static void brcmf_escan_prep(struct brcmf_cfg80211_info *cfg,
 			if (!ssid_le.SSID_len)
 				brcmf_dbg(SCAN, "%d: Broadcast scan\n", i);
 			else
-				brcmf_dbg(SCAN, "%d: scan for  %s size =%d\n",
+				brcmf_dbg(SCAN, "%d: scan for  %.32s size=%d\n",
 					  i, ssid_le.SSID, ssid_le.SSID_len);
 			memcpy(ptr, &ssid_le, sizeof(ssid_le));
 			ptr += sizeof(ssid_le);
@@ -3011,7 +3023,7 @@ void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg)
 	struct escan_info *escan = &cfg->escan_info;
 
 	set_bit(BRCMF_SCAN_STATUS_ABORT, &cfg->scan_status);
-	if (cfg->internal_escan || cfg->scan_request) {
+	if (cfg->int_escan_map || cfg->scan_request) {
 		escan->escan_state = WL_ESCAN_STATE_IDLE;
 		brcmf_notify_escan_complete(cfg, escan->ifp, true, true);
 	}
@@ -3034,7 +3046,7 @@ static void brcmf_escan_timeout(unsigned long data)
 	struct brcmf_cfg80211_info *cfg =
 			(struct brcmf_cfg80211_info *)data;
 
-	if (cfg->internal_escan || cfg->scan_request) {
+	if (cfg->int_escan_map || cfg->scan_request) {
 		brcmf_err("timer expired\n");
 		schedule_work(&cfg->escan_timeout_work);
 	}
@@ -3120,7 +3132,7 @@ static void brcmf_escan_timeout(unsigned long data)
 		if (brcmf_p2p_scan_finding_common_channel(cfg, bss_info_le))
 			goto exit;
 
-		if (!cfg->internal_escan && !cfg->scan_request) {
+		if (!cfg->int_escan_map && !cfg->scan_request) {
 			brcmf_dbg(SCAN, "result without cfg80211 request\n");
 			goto exit;
 		}
@@ -3166,7 +3178,7 @@ static void brcmf_escan_timeout(unsigned long data)
 		cfg->escan_info.escan_state = WL_ESCAN_STATE_IDLE;
 		if (brcmf_p2p_scan_finding_common_channel(cfg, NULL))
 			goto exit;
-		if (cfg->internal_escan || cfg->scan_request) {
+		if (cfg->int_escan_map || cfg->scan_request) {
 			brcmf_inform_bss(cfg);
 			aborted = status != BRCMF_E_STATUS_SUCCESS;
 			brcmf_notify_escan_complete(cfg, ifp, aborted, false);
@@ -3236,17 +3248,21 @@ static int brcmf_internal_escan_add_info(struct cfg80211_scan_request *req,
 	return 0;
 }
 
-static int brcmf_start_internal_escan(struct brcmf_if *ifp,
+static int brcmf_start_internal_escan(struct brcmf_if *ifp, u32 fwmap,
 				      struct cfg80211_scan_request *request)
 {
 	struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
 	int err;
 
 	if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) {
+		if (cfg->int_escan_map)
+			brcmf_dbg(SCAN, "aborting internal scan: map=%u\n",
+				  cfg->int_escan_map);
 		/* Abort any on-going scan */
 		brcmf_abort_scanning(cfg);
 	}
 
+	brcmf_dbg(SCAN, "start internal scan: map=%u\n", fwmap);
 	set_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
 	cfg->escan_info.run = brcmf_run_escan;
 	err = brcmf_do_escan(ifp, request);
@@ -3254,7 +3270,7 @@ static int brcmf_start_internal_escan(struct brcmf_if *ifp,
 		clear_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status);
 		return err;
 	}
-	cfg->internal_escan = true;
+	cfg->int_escan_map = fwmap;
 	return 0;
 }
 
@@ -3296,6 +3312,7 @@ static int brcmf_start_internal_escan(struct brcmf_if *ifp,
 	struct wiphy *wiphy = cfg_to_wiphy(cfg);
 	int i, err = 0;
 	struct brcmf_pno_scanresults_le *pfn_result;
+	u32 bucket_map;
 	u32 result_count;
 	u32 status;
 
@@ -3333,6 +3350,7 @@ static int brcmf_start_internal_escan(struct brcmf_if *ifp,
 
 	netinfo_start = brcmf_get_netinfo_array(pfn_result);
 
+	bucket_map = 0;
 	for (i = 0; i < result_count; i++) {
 		netinfo = &netinfo_start[i];
 		if (!netinfo) {
@@ -3344,6 +3362,7 @@ static int brcmf_start_internal_escan(struct brcmf_if *ifp,
 
 		brcmf_dbg(SCAN, "SSID:%.32s Channel:%d\n",
 			  netinfo->SSID, netinfo->channel);
+		bucket_map |= brcmf_pno_get_bucket_map(cfg->pno, netinfo);
 		err = brcmf_internal_escan_add_info(request,
 						    netinfo->SSID,
 						    netinfo->SSID_len,
@@ -3352,7 +3371,10 @@ static int brcmf_start_internal_escan(struct brcmf_if *ifp,
 			goto out_err;
 	}
 
-	err = brcmf_start_internal_escan(ifp, request);
+	if (!bucket_map)
+		goto free_req;
+
+	err = brcmf_start_internal_escan(ifp, bucket_map, request);
 	if (!err)
 		goto free_req;
 
@@ -3371,11 +3393,11 @@ static int brcmf_start_internal_escan(struct brcmf_if *ifp,
 	struct brcmf_if *ifp = netdev_priv(ndev);
 	struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
 
-	brcmf_dbg(SCAN, "Enter n_match_sets:%d n_ssids:%d\n",
+	brcmf_dbg(SCAN, "Enter: n_match_sets=%d n_ssids=%d\n",
 		  req->n_match_sets, req->n_ssids);
 
 	if (test_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status)) {
-		brcmf_err("Scanning suppressed: status (%lu)\n",
+		brcmf_err("Scanning suppressed: status=%lu\n",
 			  cfg->scan_status);
 		return -EAGAIN;
 	}
@@ -3396,8 +3418,8 @@ static int brcmf_cfg80211_sched_scan_stop(struct wiphy *wiphy,
 	struct brcmf_if *ifp = netdev_priv(ndev);
 
 	brcmf_dbg(SCAN, "enter\n");
-	brcmf_pno_clean(ifp);
-	if (cfg->internal_escan)
+	brcmf_pno_stop_sched_scan(ifp, reqid);
+	if (cfg->int_escan_map)
 		brcmf_notify_escan_complete(cfg, ifp, true, true);
 	return 0;
 }
@@ -6922,6 +6944,13 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
 		brcmf_p2p_detach(&cfg->p2p);
 		goto wiphy_unreg_out;
 	}
+	err = brcmf_pno_attach(cfg);
+	if (err) {
+		brcmf_err("PNO initialisation failed (%d)\n", err);
+		brcmf_btcoex_detach(cfg);
+		brcmf_p2p_detach(&cfg->p2p);
+		goto wiphy_unreg_out;
+	}
 
 	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_TDLS)) {
 		err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1);
@@ -6954,6 +6983,7 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
 	return cfg;
 
 detach:
+	brcmf_pno_detach(cfg);
 	brcmf_btcoex_detach(cfg);
 	brcmf_p2p_detach(&cfg->p2p);
 wiphy_unreg_out:
@@ -6973,6 +7003,7 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg)
 	if (!cfg)
 		return;
 
+	brcmf_pno_detach(cfg);
 	brcmf_btcoex_detach(cfg);
 	wiphy_unregister(cfg->wiphy);
 	kfree(cfg->ops);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h +4 -2
index a1c2e0a..12ff154 100644
@@ -273,7 +273,7 @@ struct brcmf_cfg80211_wowl {
  * @pub: common driver information.
  * @channel: current channel.
  * @active_scan: current scan mode.
- * @internal_escan: indicates internally initiated e-scan is running.
+ * @int_escan_map: bucket map for which internal e-scan is done.
  * @ibss_starter: indicates this sta is ibss starter.
  * @pwr_save: indicate whether dongle to support power save mode.
  * @dongle_up: indicate whether dongle up or not.
@@ -289,6 +289,7 @@ struct brcmf_cfg80211_wowl {
  * @vif_cnt: number of vif instances.
  * @vif_event: vif event signalling.
  * @wowl: wowl related information.
+ * @pno: information of pno module.
  */
 struct brcmf_cfg80211_info {
 	struct wiphy *wiphy;
@@ -305,7 +306,7 @@ struct brcmf_cfg80211_info {
 	struct brcmf_pub *pub;
 	u32 channel;
 	bool active_scan;
-	bool internal_escan;
+	u32 int_escan_map;
 	bool ibss_starter;
 	bool pwr_save;
 	bool dongle_up;
@@ -322,6 +323,7 @@ struct brcmf_cfg80211_info {
 	struct brcmu_d11inf d11inf;
 	struct brcmf_assoclist_le assoclist;
 	struct brcmf_cfg80211_wowl wowl;
+	struct brcmf_pno_info *pno;
 };
 
 /**
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +1 -0
index 24118ce..8c011cd 100644
@@ -30,6 +30,7 @@
 #include "debug.h"
 #include "fwil_types.h"
 #include "p2p.h"
+#include "pno.h"
 #include "cfg80211.h"
 #include "fwil.h"
 #include "feature.h"
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +2 -0
index fe264a5..35919d9 100644
@@ -78,6 +78,7 @@
 #define BRCMF_EVENT_ON()	(brcmf_msg_level & BRCMF_EVENT_VAL)
 #define BRCMF_FIL_ON()		(brcmf_msg_level & BRCMF_FIL_VAL)
 #define BRCMF_FWCON_ON()	(brcmf_msg_level & BRCMF_FWCON_VAL)
+#define BRCMF_SCAN_ON()		(brcmf_msg_level & BRCMF_SCAN_VAL)
 
 #else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
 
@@ -96,6 +97,7 @@
 #define BRCMF_EVENT_ON()	0
 #define BRCMF_FIL_ON()		0
 #define BRCMF_FWCON_ON()	0
+#define BRCMF_SCAN_ON()		0
 
 #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +19 -13
index 8c18fad..45aaae8 100644
@@ -835,15 +835,18 @@ struct brcmf_gtk_keyinfo_le {
 	u8 replay_counter[BRCMF_RSN_REPLAY_LEN];
 };
 
+#define BRCMF_PNO_REPORT_NO_BATCH	BIT(2)
+
 /**
  * struct brcmf_gscan_bucket_config - configuration data for channel bucket.
  *
- * @bucket_end_index: !unknown!
- * @bucket_freq_multiple: !unknown!
- * @flag: !unknown!
- * @reserved: !unknown!
- * @repeat: !unknown!
- * @max_freq_multiple: !unknown!
+ * @bucket_end_index: last channel index in @channel_list in
+ *	@struct brcmf_pno_config_le.
+ * @bucket_freq_multiple: scan interval expressed in N * @scan_freq.
+ * @flag: channel bucket report flags.
+ * @reserved: for future use.
+ * @repeat: number of scan at interval for exponential scan.
+ * @max_freq_multiple: maximum scan interval for exponential scan.
  */
 struct brcmf_gscan_bucket_config {
 	u8 bucket_end_index;
@@ -855,16 +858,19 @@ struct brcmf_gscan_bucket_config {
 };
 
 /* version supported which must match firmware */
-#define BRCMF_GSCAN_CFG_VERSION                     1
+#define BRCMF_GSCAN_CFG_VERSION                     2
 
 /**
  * enum brcmf_gscan_cfg_flags - bit values for gscan flags.
  *
  * @BRCMF_GSCAN_CFG_FLAGS_ALL_RESULTS: send probe responses/beacons to host.
+ * @BRCMF_GSCAN_CFG_ALL_BUCKETS_IN_1ST_SCAN: all buckets will be included in
+ *	first scan cycle.
  * @BRCMF_GSCAN_CFG_FLAGS_CHANGE_ONLY: indicated only flags member is changed.
  */
 enum brcmf_gscan_cfg_flags {
 	BRCMF_GSCAN_CFG_FLAGS_ALL_RESULTS = BIT(0),
+	BRCMF_GSCAN_CFG_ALL_BUCKETS_IN_1ST_SCAN = BIT(3),
 	BRCMF_GSCAN_CFG_FLAGS_CHANGE_ONLY = BIT(7),
 };
 
@@ -884,12 +890,12 @@ enum brcmf_gscan_cfg_flags {
  */
 struct brcmf_gscan_config {
 	__le16 version;
-	u8  flags;
-	u8   buffer_threshold;
-	u8   swc_nbssid_threshold;
-	u8  swc_rssi_window_size;
-	u8  count_of_channel_buckets;
-	u8  retry_threshold;
+	u8 flags;
+	u8 buffer_threshold;
+	u8 swc_nbssid_threshold;
+	u8 swc_rssi_window_size;
+	u8 count_of_channel_buckets;
+	u8 retry_threshold;
 	__le16  lost_ap_window;
 	struct brcmf_gscan_bucket_config bucket[1];
 };
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c +348 -50

468 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.h +41 -6

63 lines not on this page · raw message

Signature · 1 line
1.9.1
author maintainer
#22 lore raw

PATCH v3 8/9 brcmfmac: add mutex to protect pno requests

In reply to Arend van Spriel

The request references kept in pno are accessed in user-space context and in firmware event handler context. As such we need to protect it with a lock. As both context allow sleep a mutex seems appropriate.

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.c | 33 ++++++++++++++++------
 1 file changed, 25 insertions(+), 8 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c +25 -8
index 5ae0680..81e8549 100644
@@ -43,6 +43,7 @@
 struct brcmf_pno_info {
 	int n_reqs;
 	struct cfg80211_sched_scan_request *reqs[BRCMF_PNO_MAX_BUCKETS];
+	struct mutex req_lock;
 };
 
 #define ifp_to_pno(_ifp)	((_ifp)->drvr->config->pno)
@@ -55,13 +56,17 @@ static int brcmf_pno_store_request(struct brcmf_pno_info *pi,
 		return -ENOSPC;
 	}
 	brcmf_dbg(SCAN, "reqid=%llu\n", req->reqid);
+	mutex_lock(&pi->req_lock);
 	pi->reqs[pi->n_reqs++] = req;
+	mutex_unlock(&pi->req_lock);
 	return 0;
 }
 
 static int brcmf_pno_remove_request(struct brcmf_pno_info *pi, u64 reqid)
 {
-	int i;
+	int i, err = 0;
+
+	mutex_lock(&pi->req_lock);
 
 	/* find request */
 	for (i = 0; i < pi->n_reqs; i++) {
@@ -71,7 +76,8 @@ static int brcmf_pno_remove_request(struct brcmf_pno_info *pi, u64 reqid)
 	/* request not found */
 	if (WARN_ON(i == pi->n_reqs)) {
 		brcmf_err("reqid not found\n");
-		return -ENOENT;
+		err = -ENOENT;
+		goto done;
 	}
 
 	brcmf_dbg(SCAN, "reqid=%llu\n", reqid);
@@ -79,14 +85,17 @@ static int brcmf_pno_remove_request(struct brcmf_pno_info *pi, u64 reqid)
 
 	/* if last we are done */
 	if (!pi->n_reqs || i == pi->n_reqs)
-		return 0;
+		goto done;
 
 	/* fill the gap with remaining requests */
 	while (i <= pi->n_reqs - 1) {
 		pi->reqs[i] = pi->reqs[i + 1];
 		i++;
 	}
-	return 0;
+
+done:
+	mutex_unlock(&pi->req_lock);
+	return err;
 }
 
 static int brcmf_pno_channel_config(struct brcmf_if *ifp,
@@ -489,6 +498,7 @@ int brcmf_pno_attach(struct brcmf_cfg80211_info *cfg)
 		return -ENOMEM;
 
 	cfg->pno = pi;
+	mutex_init(&pi->req_lock);
 	return 0;
 }
 
@@ -501,6 +511,7 @@ void brcmf_pno_detach(struct brcmf_cfg80211_info *cfg)
 	cfg->pno = NULL;
 
 	WARN_ON(pi->n_reqs);
+	mutex_destroy(&pi->req_lock);
 	kfree(pi);
 }
 
@@ -516,11 +527,15 @@ void brcmf_pno_wiphy_params(struct wiphy *wiphy, bool gscan)
 
 u64 brcmf_pno_find_reqid_by_bucket(struct brcmf_pno_info *pi, u32 bucket)
 {
-	/* bucket appears to be gone */
-	if (bucket >= pi->n_reqs)
-		return 0;
+	u64 reqid = 0;
+
+	mutex_lock(&pi->req_lock);
+
+	if (bucket < pi->n_reqs)
+		reqid = pi->reqs[bucket]->reqid;
 
-	return pi->reqs[bucket]->reqid;
+	mutex_unlock(&pi->req_lock);
+	return reqid;
 }
 
 u32 brcmf_pno_get_bucket_map(struct brcmf_pno_info *pi,
@@ -531,6 +546,7 @@ u32 brcmf_pno_get_bucket_map(struct brcmf_pno_info *pi,
 	u32 bucket_map = 0;
 	int i, j;
 
+	mutex_lock(&pi->req_lock);
 	for (i = 0; i < pi->n_reqs; i++) {
 		req = pi->reqs[i];
 
@@ -545,5 +561,6 @@ u32 brcmf_pno_get_bucket_map(struct brcmf_pno_info *pi,
 			}
 		}
 	}
+	mutex_unlock(&pi->req_lock);
 	return bucket_map;
 }
Signature · 1 line
1.9.1
author maintainer
#23 lore raw

PATCH v3 9/9 brcmfmac: add scheduled scan support for specified BSSIDs

In reply to Arend van Spriel

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_SEPARATELY needed to be removed from the flags in brcmf_pno_config().

---
 .../broadcom/brcm80211/brcmfmac/fwil_types.h       | 11 ++++
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.c | 58 ++++++++++++++++------
 2 files changed, 53 insertions(+), 16 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +11 -0
index 45aaae8..b857d53 100644
@@ -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
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c +42 -16

105 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#24 lore raw
In reply to Arend van Spriel
Quoted 4 lines

  nl80211: allow multiple active scheduled scan requests
  nl80211: add support for BSSIDs in scheduled scan matchsets
  cfg80211: add request id parameter to .sched_scan_stop() signature

I applied these.

Quoted 1 line

  cfg80211: add request id to cfg80211_sched_scan_*() api

Will comment here separately.

johannes