2018-10-18 08:36:11

by Johannes Berg

[permalink] [raw]
Subject: [PATCH] mac80211: allow hardware scan to fall back to software

From: Johannes Berg <[email protected]>

In some cases, like in the rsi driver hardware scan offload, there
may be scenarios in which hardware scan might not be available or
desirable.

Allow drivers to cope with this by letting them fall back to software
scan by returning the special value 1 from the hardware scan method.

Requested-by: Sushant Kumar Mishra <[email protected]>
Requested-by: Siva Rebbagondla <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
---
include/net/mac80211.h | 5 +++++
net/mac80211/scan.c | 22 ++++++++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 71985e95d2d9..4631b3b6fc37 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3239,6 +3239,11 @@ enum ieee80211_reconfig_type {
* When the scan finishes, ieee80211_scan_completed() must be called;
* note that it also must be called when the scan cannot finish due to
* any error unless this callback returned a negative error code.
+ * This callback is also allowed to return the special return value 1,
+ * this indicates that hardware scan isn't desirable right now and a
+ * software scan should be done instead. A driver wishing to use this
+ * capability must ensure its (hardware) scan capabilities aren't
+ * advertised as more capable than mac80211's software scan is.
* The callback can sleep.
*
* @cancel_hw_scan: Ask the low-level tp cancel the active hw scan.
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 5d2a11777718..95413413f98c 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -356,7 +356,7 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
{
struct ieee80211_local *local = hw_to_local(hw);
- bool hw_scan = local->ops->hw_scan;
+ bool hw_scan = test_bit(SCAN_HW_SCANNING, &local->scanning);
bool was_scanning = local->scanning;
struct cfg80211_scan_request *scan_req;
struct ieee80211_sub_if_data *scan_sdata;
@@ -606,6 +606,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
struct cfg80211_scan_request *req)
{
struct ieee80211_local *local = sdata->local;
+ bool hw_scan = local->ops->hw_scan;
int rc;

lockdep_assert_held(&local->mtx);
@@ -620,7 +621,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
return 0;
}

- if (local->ops->hw_scan) {
+ again:
+ if (hw_scan) {
u8 *ies;

local->hw_scan_ies_bufsize = local->scan_ies_len + req->ie_len;
@@ -679,7 +681,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
else
memcpy(local->scan_addr, sdata->vif.addr, ETH_ALEN);

- if (local->ops->hw_scan) {
+ if (hw_scan) {
__set_bit(SCAN_HW_SCANNING, &local->scanning);
} else if ((req->n_channels == 1) &&
(req->channels[0] == local->_oper_chandef.chan)) {
@@ -722,7 +724,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,

ieee80211_recalc_idle(local);

- if (local->ops->hw_scan) {
+ if (hw_scan) {
WARN_ON(!ieee80211_prep_hw_scan(local));
rc = drv_hw_scan(local, sdata, local->hw_scan_req);
} else {
@@ -740,6 +742,18 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
RCU_INIT_POINTER(local->scan_sdata, NULL);
}

+ if (hw_scan && rc == 1) {
+ /*
+ * we can't fall back to software for P2P-GO
+ * as it must update NoA etc.
+ */
+ if (ieee80211_vif_type_p2p(&sdata->vif) ==
+ NL80211_IFTYPE_P2P_GO)
+ return -EOPNOTSUPP;
+ hw_scan = false;
+ goto again;
+ }
+
return rc;
}

--
2.17.2



2018-10-18 10:42:40

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH] mac80211: allow hardware scan to fall back to software

On 10/18/2018 10:35 AM, Johannes Berg wrote:
> From: Johannes Berg <[email protected]>
>
> In some cases, like in the rsi driver hardware scan offload, there
> may be scenarios in which hardware scan might not be available or
> desirable.
>
> Allow drivers to cope with this by letting them fall back to software
> scan by returning the special value 1 from the hardware scan method.
>
> Requested-by: Sushant Kumar Mishra <[email protected]>
> Requested-by: Siva Rebbagondla <[email protected]>
> Signed-off-by: Johannes Berg <[email protected]>
> ---
> include/net/mac80211.h | 5 +++++
> net/mac80211/scan.c | 22 ++++++++++++++++++----
> 2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 71985e95d2d9..4631b3b6fc37 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -3239,6 +3239,11 @@ enum ieee80211_reconfig_type {
> * When the scan finishes, ieee80211_scan_completed() must be called;
> * note that it also must be called when the scan cannot finish due to
> * any error unless this callback returned a negative error code.
> + * This callback is also allowed to return the special return value 1,
> + * this indicates that hardware scan isn't desirable right now and a
> + * software scan should be done instead. A driver wishing to use this
> + * capability must ensure its (hardware) scan capabilities aren't
> + * advertised as more capable than mac80211's software scan is.

Hi Johannes,

Not sure what is meant by the last sentence. What does "more capable"
mean? What are (or where to find) the mac80211 software scan capabilities?

Regards,
Arend

2018-10-18 11:07:59

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: allow hardware scan to fall back to software

On Thu, 2018-10-18 at 12:42 +0200, Arend van Spriel wrote:
>
> > + * This callback is also allowed to return the special return value 1,
> > + * this indicates that hardware scan isn't desirable right now and a
> > + * software scan should be done instead. A driver wishing to use this
> > + * capability must ensure its (hardware) scan capabilities aren't
> > + * advertised as more capable than mac80211's software scan is.
>
> Not sure what is meant by the last sentence. What does "more capable"
> mean? What are (or where to find) the mac80211 software scan capabilities?

I was thinking in terms of the scan capabilities exposed to userspace
via nl80211. For example, mac80211 supports max 4 scan SSIDs (though
this is a soft limit, it doesn't really care later), and a maximum probe
request size. That's it though, so it doesn't support things like
NL80211_EXT_FEATURE_LOW_SPAN_SCAN, for example.

johannes


2018-10-18 11:47:15

by Siva Rebbagondla

[permalink] [raw]
Subject: Re: [PATCH] mac80211: allow hardware scan to fall back to software

On Thu, Oct 18, 2018 at 2:06 PM Johannes Berg <[email protected]> wrote:
>
> From: Johannes Berg <[email protected]>
>
> In some cases, like in the rsi driver hardware scan offload, there
> may be scenarios in which hardware scan might not be available or
> desirable.
>
> Allow drivers to cope with this by letting them fall back to software
> scan by returning the special value 1 from the hardware scan method.
>
Acked-and-Tested-by: Siva Rebbagondla <[email protected]>

2018-11-09 06:13:34

by Siva Rebbagondla

[permalink] [raw]
Subject: Re: [PATCH] mac80211: allow hardware scan to fall back to software

Hi,
Gentle Remainder..!!!.
Any update required for this patch?. If not, When can i expect this
patch to be available in wireless-next?.

Thank you,
Siva Rebbagondla

On Thu, Oct 18, 2018 at 5:21 PM Siva Rebbagondla <[email protected]> wrote:
>
> On Thu, Oct 18, 2018 at 2:06 PM Johannes Berg <[email protected]> wrote:
> >
> > From: Johannes Berg <[email protected]>
> >
> > In some cases, like in the rsi driver hardware scan offload, there
> > may be scenarios in which hardware scan might not be available or
> > desirable.
> >
> > Allow drivers to cope with this by letting them fall back to software
> > scan by returning the special value 1 from the hardware scan method.
> >
> Acked-and-Tested-by: Siva Rebbagondla <[email protected]>

2018-11-09 11:19:53

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: allow hardware scan to fall back to software

On Fri, 2018-11-09 at 11:48 +0530, Siva Rebbagondla wrote:
> Hi,
> Gentle Remainder..!!!.
> Any update required for this patch?. If not, When can i expect this
> patch to be available in wireless-next?.

Sorry, I hadn't been merging things for a while due to the merge window.

I just put it into mac80211-next, so I guess the answer should be
"soon".

johannes


2018-11-09 11:55:17

by Siva Rebbagondla

[permalink] [raw]
Subject: Re: [PATCH] mac80211: allow hardware scan to fall back to software

On Fri, Nov 9, 2018 at 4:49 PM Johannes Berg <[email protected]> wrote:
>
> On Fri, 2018-11-09 at 11:48 +0530, Siva Rebbagondla wrote:
> > Hi,
> > Gentle Remainder..!!!.
> > Any update required for this patch?. If not, When can i expect this
> > patch to be available in wireless-next?.
>
> Sorry, I hadn't been merging things for a while due to the merge window.
>
> I just put it into mac80211-next, so I guess the answer should be
> "soon".
Thank you. I was waiting for a long time for this patch.

Best Regards,
Siva Rebbagondla
>
> johannes
>